Veil
veil_interface.c File Reference

Functions providing the SQL interface to veil, and utility functions to support them. More...

#include "postgres.h"
#include "access/xact.h"
#include "executor/spi.h"
#include "funcapi.h"
#include "utils/hsearch.h"
#include "utils/memutils.h"
#include "veil_version.h"
#include "veil_funcs.h"
#include "veil_datatypes.h"

Go to the source code of this file.

Functions

static char * strfromtext (text *in)
 Create a dynamically allocated C string as a copy of a text value. More...
 
static text * textfromstr (char *in)
 Create a dynamically allocated text value as a copy of a C string. More...
 
static text * textfromstrn (char *in, int limit)
 Create a dynamically allocated text value as a copy of a C string, applying a limit to the length. More...
 
static char * copystr (char *str)
 Create a dynamically allocated text value as a copy of a C string, applying a limit to the length. More...
 
static char * strfromint (int32 val)
 Create a dynamically allocated C string as a copy of an integer value. More...
 
static char * strfrombool (bool val)
 Create a dynamically allocated C string as a copy of a boolean value. More...
 
static void ensure_init ()
 Perform session initialisation once for the session. More...
 
void vl_type_mismatch (char *name, ObjType expected, ObjType got)
 Report, by raising an error, a type mismatch between the expected and actual type of a VarEntry variable. More...
 
static Int4VarGetInt4Var (char *name, bool create)
 Return the Int4Var variable matching the name parameter, possibly creating the variable. More...
 
static RangeGetRange (char *name, bool create)
 Return the Range variable matching the name parameter, possibly creating the variable. More...
 
static BitmapGetBitmapFromVar (VarEntry *var, bool allow_empty, bool allow_ref)
 Return the Bitmap from a bitmap variable. More...
 
static BitmapGetBitmap (char *name, bool allow_empty, bool allow_ref)
 Return the Bitmap matching the name parameter, possibly creating the VarEntry (variable) for it. More...
 
static BitmapRefGetBitmapRefFromVar (VarEntry *var)
 Return the BitmapRef from a bitmap ref variable. More...
 
static BitmapRefGetBitmapRef (char *name)
 Return the BitmapRef matching the name parameter, possibly creating the VarEntry (variable) for it. More...
 
static BitmapArrayGetBitmapArrayFromVar (VarEntry *var, bool allow_empty)
 Return the BitmapArray from a bitmap array variable. More...
 
static BitmapArrayGetBitmapArray (char *name, bool allow_empty)
 Return the BitmapArray matching the name parameter, possibly creating the (VarEntry) variable. More...
 
static BitmapHashGetBitmapHashFromVar (VarEntry *var, bool allow_empty)
 Return the BitmapHash from a bitmap hash variable. More...
 
static BitmapHashGetBitmapHash (char *name, bool allow_empty)
 Return the BitmapHash matching the name parameter, possibly creating the VarEntry (variable) for it. More...
 
static Int4ArrayGetInt4ArrayFromVar (VarEntry *var, bool allow_empty)
 Return the Int4Array from an Int4Array variable. More...
 
static Int4ArrayGetInt4Array (char *name, bool allow_empty)
 Return the Int4Array matching the name parameter, possibly creating the VarEntry (variable) for it. More...
 
Datum veil_variables (PG_FUNCTION_ARGS)
 veil_variables() returns setof veil_variable_t Return a veil_variable_t record for each defined variable. More...
 
Datum veil_share (PG_FUNCTION_ARGS)
 veil_share(name text) returns bool Define a shared variable called NAME, returning true. More...
 
Datum veil_init_range (PG_FUNCTION_ARGS)
 veil_init_range(name text, min int4, max int4) returns int4 Initialise a Range variable called NAME constrained by MIN and MAX, returning the number of elements in the range. More...
 
static Datum datum_from_range (int64 min, int64 max)
 Create a datum containing the values of a veil_range_t composite type. More...
 
Datum veil_range (PG_FUNCTION_ARGS)
 veil_range(name text) returns veil_range_t Return the range (as a SQL veil_range_t composite type) from the named variable. More...
 
Datum veil_init_bitmap (PG_FUNCTION_ARGS)
 veil_init_bitmap(bitmap_name text, range_nametext) returns bool Create or re-initialise a Bitmap, for dealing with a named range of values. More...
 
Datum veil_clear_bitmap (PG_FUNCTION_ARGS)
 veil_clear_bitmap(name text) returns bool Clear all bits in the specified Bitmap. More...
 
Datum veil_bitmap_setbit (PG_FUNCTION_ARGS)
 veil_bitmap_setbit(name text, bit_number int4) returns bool Set the specified bit in the specified Bitmap. More...
 
Datum veil_bitmap_clearbit (PG_FUNCTION_ARGS)
 veil_bitmap_clearbit(name int4, bit_number text) returns bool Clear the specified bit in the specified Bitmap. More...
 
Datum veil_bitmap_testbit (PG_FUNCTION_ARGS)
 veil_bitmap_testbit(name text, bit_number int4) returns bool Test the specified bit in the specified Bitmap, returning true if it is set. More...
 
Datum veil_bitmap_union (PG_FUNCTION_ARGS)
 veil_bitmap_union(result_name text, name2 text) returns bool Union the bitmap specified in parameter 1 with that in parameter 2, with the result in parameter 1. More...
 
Datum veil_bitmap_intersect (PG_FUNCTION_ARGS)
 veil_bitmap_intersect(result_name text, name2 text) returns bool Intersect the bitmap specified in parameter 1 with that in parameter 2, with the result in parameter 1. More...
 
Datum veil_bitmap_bits (PG_FUNCTION_ARGS)
 veil_bitmap_bits(name text) returns setof int4 Return the set of all bits set in the specified Bitmap or BitmapRef. More...
 
Datum veil_bitmap_range (PG_FUNCTION_ARGS)
 veil_bitmap_range(name text) returns veil_range_t Return composite type giving the range of the specified Bitmap or BitmapRef. More...
 
Datum veil_init_bitmap_array (PG_FUNCTION_ARGS)
 veil_init_bitmap_array(text, text, text) returns bool Create or reset a BitmapArray. More...
 
Datum veil_clear_bitmap_array (PG_FUNCTION_ARGS)
 veil_clear_bitmap_array(bmarray text) returns bool Clear the bits in an existing BitmapArray. More...
 
Datum veil_bitmap_from_array (PG_FUNCTION_ARGS)
 veil_bitmap_from_array(bmref text, bmarray text, index int4) returns text Place a reference to the specified Bitmap from a BitmapArray into the specified BitmapRef An error will be raised if any parameter is not of the correct type. More...
 
Datum veil_bitmap_array_testbit (PG_FUNCTION_ARGS)
 veil_bitmap_array_testbit(bmarray text, arr_idx int4, bitno int4) returns bool Test a specified bit within a BitmapArray More...
 
Datum veil_bitmap_array_setbit (PG_FUNCTION_ARGS)
 veil_bitmap_array_setbit(bmarray text, arr_idx int4, bitno int4) returns bool Set a specified bit within a BitmapArray More...
 
Datum veil_bitmap_array_clearbit (PG_FUNCTION_ARGS)
 veil_bitmap_array_clearbit(bmarray text, arr_idx int4, bitno int4) returns bool Clear a specified bit within a BitmapArray More...
 
Datum veil_union_from_bitmap_array (PG_FUNCTION_ARGS)
 veil_union_from_bitmap_array(bitmap text, bmarray text, arr_idx int4) returns bool Union a Bitmap with the specified Bitmap from a BitmapArray with the result placed into the first parameter. More...
 
Datum veil_intersect_from_bitmap_array (PG_FUNCTION_ARGS)
 veil_intersect_from_bitmap_array(bitmap text, bmarray text, arr_idx int4) returns bool Intersect a Bitmap with the specified Bitmap from a BitmapArray with the result placed into the first parameter. More...
 
Datum veil_bitmap_array_bits (PG_FUNCTION_ARGS)
 veil_bitmap_array_bits(bmarray text, arr_idx int4) returns setof int4 Return the set of all bits set in the specified Bitmap from the BitmapArray. More...
 
Datum veil_bitmap_array_arange (PG_FUNCTION_ARGS)
 veil_bitmap_array_arange(bmarray text) returns veil_range_t Return composite type giving the range of the array part of the specified BitmapArray More...
 
Datum veil_bitmap_array_brange (PG_FUNCTION_ARGS)
 veil_bitmap_array_brange(bmarray text) returns veil_range_t Return composite type giving the range of every Bitmap within the BitmapArray. More...
 
Datum veil_init_bitmap_hash (PG_FUNCTION_ARGS)
 veil_init_bitmap_hash(bmhash text, range text) returns bool Create or reset a BitmapHash. More...
 
Datum veil_clear_bitmap_hash (PG_FUNCTION_ARGS)
 veil_clear_bitmap_hash(bmhash text) returns bool Clear the bits in an existing BitmapHash. More...
 
Datum veil_bitmap_hash_key_exists (PG_FUNCTION_ARGS)
 veil_bitmap_hashkey_exists(bmhash text, key text) returns bool Return true if the key exists in the bitmap hash. More...
 
Datum veil_bitmap_from_hash (PG_FUNCTION_ARGS)
 veil_bitmap_from_hash(bmref text, bmhash text, key text) returns text Place a reference to the specified Bitmap from a BitmapHash into the specified BitmapRef An error will be raised if any parameter is not of the correct type. More...
 
Datum veil_bitmap_hash_testbit (PG_FUNCTION_ARGS)
 veil_bitmap_hash_testbit(bmhash text, key text, bitno int4) returns bool Test a specified bit within a BitmapHash More...
 
Datum veil_bitmap_hash_setbit (PG_FUNCTION_ARGS)
 veil_bitmap_hash_setbit(bmhash text, key text, bitno int4) returns bool Set a specified bit within a BitmapHash More...
 
Datum veil_bitmap_hash_clearbit (PG_FUNCTION_ARGS)
 veil_bitmap_hash_clearbit(bmhash text, key text, bitno int4) returns bool Clear a specified bit within a BitmapHash More...
 
Datum veil_union_into_bitmap_hash (PG_FUNCTION_ARGS)
 veil_union_into_bitmap_hash(bmhash text, key text, bitmap text) returns bool Union a Bitmap with the specified Bitmap from a BitmapHash with the result placed into the bitmap hash. More...
 
Datum veil_union_from_bitmap_hash (PG_FUNCTION_ARGS)
 veil_union_from_bitmap_hash(bmhash text, key text, bitmap text) returns bool Union a Bitmap with the specified Bitmap from a BitmapHash with the result placed into the bitmap parameter. More...
 
Datum veil_intersect_from_bitmap_hash (PG_FUNCTION_ARGS)
 veil_intersect_from_bitmap_hash(bitmap text, bmhash text, key text) returns bool Intersect a Bitmap with the specified Bitmap from a BitmapArray with the result placed into the bitmap parameter. More...
 
Datum veil_bitmap_hash_bits (PG_FUNCTION_ARGS)
 veil_bitmap_hash_bits(bmhash text, key text) returns setof int4 Return the set of all bits set in the specified Bitmap from the BitmapHash. More...
 
Datum veil_bitmap_hash_range (PG_FUNCTION_ARGS)
 veil_bitmap_hash_range(bmhash text) returns veil_range_t Return composite type giving the range of every Bitmap within the BitmapHash. More...
 
Datum veil_bitmap_hash_entries (PG_FUNCTION_ARGS)
 veil_bitmap_hash_entries(bmhash text) returns setof text Return the key of every Bitmap within the BitmapHash. More...
 
Datum veil_int4_set (PG_FUNCTION_ARGS)
 veil_int4_set(name text,value int4) returns int4 Set an Int4Var variable type to a specified value. More...
 
Datum veil_int4_get (PG_FUNCTION_ARGS)
 veil_int4_get(name text) returns int4 Return the value of an Int4Var variable. More...
 
Datum veil_init_int4array (PG_FUNCTION_ARGS)
 veil_init_int4array(arrayname text, range text) returns bool Initialise an Int4Array variable. More...
 
Datum veil_clear_int4array (PG_FUNCTION_ARGS)
 veil_clear_int4array(name text) returns bool Clear an Int4Array variable. More...
 
Datum veil_int4array_set (PG_FUNCTION_ARGS)
 veil_int4array_set(array text, idx int4, value int4) returns int4 Set an Int4Array entry. More...
 
Datum veil_int4array_get (PG_FUNCTION_ARGS)
 veil_int4array_get(array text, idx int4) returns int4 Get an Int4Array entry. More...
 
Datum veil_init (PG_FUNCTION_ARGS)
 veil_init(doing_reset bool) returns bool Initialise or reset a veil session. More...
 
Datum veil_perform_reset (PG_FUNCTION_ARGS)
 veil_perform_reset() returns bool Reset veil shared memory for this database. More...
 
Datum veil_force_reset (PG_FUNCTION_ARGS)
 veil_force_reset() returns bool Reset veil shared memory for this database, ignoring existing transactions. More...
 
Datum veil_version (PG_FUNCTION_ARGS)
 veil_version() returns text Return a string describing this version of veil. More...
 
Datum veil_serialise (PG_FUNCTION_ARGS)
 veil_serialise(varname text) returns text Return a string representing the contents of our variable. More...
 
Datum veil_deserialise (PG_FUNCTION_ARGS)
 veil_deserialise(stream text) returns text Create or reset variables based on the output of previous veil_serialise calls. More...
 

Detailed Description

Functions providing the SQL interface to veil, and utility functions to support them.

Author: Marc Munro
Copyright (c) 2005 - 2012 Marc Munro
License: BSD

Definition in file veil_interface.c.

Function Documentation

◆ strfromtext()

◆ textfromstr()

static text* textfromstr ( char *  in)
static

Create a dynamically allocated text value as a copy of a C string.

Parameters
inString to be copied
Returns
Dynamically allocated (by palloc()) copy of in.

Definition at line 52 of file veil_interface.c.

Referenced by veil_serialise(), and veil_version().

◆ textfromstrn()

static text* textfromstrn ( char *  in,
int  limit 
)
static

Create a dynamically allocated text value as a copy of a C string, applying a limit to the length.

Parameters
inString to be copied
limitMaximum length of string to be copied.
Returns
Dynamically allocated (by palloc()) copy of in.

Definition at line 71 of file veil_interface.c.

Referenced by veil_bitmap_hash_entries().

◆ copystr()

static char* copystr ( char *  str)
static

Create a dynamically allocated text value as a copy of a C string, applying a limit to the length.

Parameters
strString to be copied
Returns
Dynamically allocated (by palloc()) copy of str.

Definition at line 95 of file veil_interface.c.

Referenced by veil_variables().

◆ strfromint()

static char* strfromint ( int32  val)
static

Create a dynamically allocated C string as a copy of an integer value.

Parameters
valvalue to be stringified
Returns
Dynamically allocated string.

Definition at line 109 of file veil_interface.c.

Referenced by datum_from_range().

◆ strfrombool()

static char* strfrombool ( bool  val)
static

Create a dynamically allocated C string as a copy of a boolean value.

Parameters
valvalue to be stringified
Returns
Dynamically allocated string.

Definition at line 124 of file veil_interface.c.

Referenced by veil_variables().

◆ ensure_init()

static void ensure_init ( )
static

Perform session initialisation once for the session.

This calls the user-defined function veil_init which should create and possibly initialise all session and, maybe, shared variables. This function may be safely called any number of times - it will only perform the initialisation on the first call.

Definition at line 145 of file veil_interface.c.

References vl_bool_from_query(), vl_get_shared_hash(), vl_spi_connect(), and vl_spi_finish().

Referenced by veil_bitmap_array_arange(), veil_bitmap_array_bits(), veil_bitmap_array_brange(), veil_bitmap_array_clearbit(), veil_bitmap_array_setbit(), veil_bitmap_array_testbit(), veil_bitmap_bits(), veil_bitmap_clearbit(), veil_bitmap_hash_bits(), veil_bitmap_hash_clearbit(), veil_bitmap_hash_entries(), veil_bitmap_hash_range(), veil_bitmap_hash_setbit(), veil_bitmap_hash_testbit(), veil_bitmap_intersect(), veil_bitmap_range(), veil_bitmap_setbit(), veil_bitmap_testbit(), veil_bitmap_union(), veil_clear_bitmap(), veil_clear_bitmap_array(), veil_clear_bitmap_hash(), veil_clear_int4array(), veil_deserialise(), veil_force_reset(), veil_init_bitmap(), veil_init_bitmap_array(), veil_init_bitmap_hash(), veil_init_int4array(), veil_init_range(), veil_int4_get(), veil_int4_set(), veil_int4array_get(), veil_int4array_set(), veil_intersect_from_bitmap_array(), veil_intersect_from_bitmap_hash(), veil_perform_reset(), veil_range(), veil_serialise(), veil_share(), veil_union_from_bitmap_array(), veil_union_from_bitmap_hash(), veil_union_into_bitmap_hash(), and veil_variables().

◆ vl_type_mismatch()

void vl_type_mismatch ( char *  name,
ObjType  expected,
ObjType  got 
)

Report, by raising an error, a type mismatch between the expected and actual type of a VarEntry variable.

Parameters
nameThe name of the variable
expectedThe expected type.
gotThe actual type

Definition at line 199 of file veil_interface.c.

References vl_ObjTypeName().

◆ GetInt4Var()

static Int4Var* GetInt4Var ( char *  name,
bool  create 
)
static

Return the Int4Var variable matching the name parameter, possibly creating the variable.

Raise an error if the named variable already exists and is of the wrong type.

Parameters
nameThe name of the variable.
createWhether to create the variable if it does not exist.
Returns
Pointer to the variable or null if the variable does not exist and create was false.

Definition at line 221 of file veil_interface.c.

References VarEntry::obj, Int4Var::type, and vl_lookup_variable().

Referenced by veil_int4_get(), and veil_int4_set().

◆ GetRange()

static Range* GetRange ( char *  name,
bool  create 
)
static

Return the Range variable matching the name parameter, possibly creating the variable.

Raise an error if the named variable already exists and is of the wrong type.

Parameters
nameThe name of the variable.
createWhether to create the variable if it does not exist.
Returns
Pointer to the variable or null if the variable does not exist and create was false.

Definition at line 258 of file veil_interface.c.

References VarEntry::obj, Range::type, and vl_lookup_variable().

Referenced by veil_init_bitmap(), veil_init_bitmap_array(), veil_init_bitmap_hash(), veil_init_int4array(), veil_init_range(), and veil_range().

◆ GetBitmapFromVar()

static Bitmap* GetBitmapFromVar ( VarEntry var,
bool  allow_empty,
bool  allow_ref 
)
static

Return the Bitmap from a bitmap variable.

This function exists primarily to perform type checking, and to raise an error if the variable is not a bitmap.

Parameters
varThe VarEntry that should contain a bitmap.
allow_emptyWhether to raise an error if the variable has not yet been initialised.
allow_refWhether to (not) raise an error if the variable is a bitmap_ref rather than a bitmap.
Returns
Pointer to the variable or null if the variable is undefined and allow_empty was true.

Definition at line 298 of file veil_interface.c.

References VarEntry::obj, and Bitmap::type.

Referenced by GetBitmap(), veil_clear_bitmap(), and veil_init_bitmap().

◆ GetBitmap()

static Bitmap* GetBitmap ( char *  name,
bool  allow_empty,
bool  allow_ref 
)
static

Return the Bitmap matching the name parameter, possibly creating the VarEntry (variable) for it.

Raise an error if the named variable already exists and is of the wrong type.

Parameters
nameThe name of the variable.
allow_emptyWhether to raise an error if the variable has not been defined.
allow_refWhether to (not) raise an error if the variable is a bitmap_ref rather than a bitmap.
Returns
Pointer to the variable or null if the variable does not exist and allow_empty was false.

Definition at line 348 of file veil_interface.c.

References GetBitmapFromVar(), and vl_lookup_variable().

Referenced by veil_bitmap_bits(), veil_bitmap_clearbit(), veil_bitmap_intersect(), veil_bitmap_range(), veil_bitmap_setbit(), veil_bitmap_testbit(), veil_bitmap_union(), veil_intersect_from_bitmap_array(), veil_intersect_from_bitmap_hash(), veil_union_from_bitmap_array(), veil_union_from_bitmap_hash(), and veil_union_into_bitmap_hash().

◆ GetBitmapRefFromVar()

static BitmapRef* GetBitmapRefFromVar ( VarEntry var)
static

Return the BitmapRef from a bitmap ref variable.

This function exists primarily to perform type checking, and to raise an error if the variable is not a bitmap ref. Note that BitmapRef variables may not be shared as they can contain references to non-shared objects.

Parameters
varThe VarEntry that should contain a bitmap ref.
Returns
Pointer to the variable.

Definition at line 371 of file veil_interface.c.

References VarEntry::obj, and BitmapRef::type.

Referenced by GetBitmapRef().

◆ GetBitmapRef()

static BitmapRef* GetBitmapRef ( char *  name)
static

Return the BitmapRef matching the name parameter, possibly creating the VarEntry (variable) for it.

Raise an error if the named variable already exists and is of the wrong type.

Parameters
nameThe name of the variable.
Returns
Pointer to the variable

Definition at line 408 of file veil_interface.c.

References GetBitmapRefFromVar(), and vl_lookup_variable().

Referenced by veil_bitmap_from_array(), and veil_bitmap_from_hash().

◆ GetBitmapArrayFromVar()

static BitmapArray* GetBitmapArrayFromVar ( VarEntry var,
bool  allow_empty 
)
static

Return the BitmapArray from a bitmap array variable.

This function exists primarily to perform type checking, and to raise an error if the variable is not a bitmap array.

Parameters
varThe VarEntry that should contain a bitmap array.
allow_emptyWhether to raise an error if the variable has not yet been initialised.
Returns
Pointer to the variable or null if the variable is undefined and allow_empty was true.

Definition at line 431 of file veil_interface.c.

References VarEntry::obj, and BitmapArray::type.

Referenced by GetBitmapArray(), veil_clear_bitmap_array(), and veil_init_bitmap_array().

◆ GetBitmapArray()

static BitmapArray* GetBitmapArray ( char *  name,
bool  allow_empty 
)
static

Return the BitmapArray matching the name parameter, possibly creating the (VarEntry) variable.

Raise an error if the named variable already exists and is of the wrong type.

Parameters
nameThe name of the variable.
allow_emptyWhether to raise an error if the variable has not been defined
Returns
Pointer to the variable or null if the variable does not exist and create was false.

Definition at line 463 of file veil_interface.c.

References GetBitmapArrayFromVar(), and vl_lookup_variable().

Referenced by veil_bitmap_array_arange(), veil_bitmap_array_bits(), veil_bitmap_array_brange(), veil_bitmap_array_clearbit(), veil_bitmap_array_setbit(), veil_bitmap_array_testbit(), veil_bitmap_from_array(), veil_intersect_from_bitmap_array(), and veil_union_from_bitmap_array().

◆ GetBitmapHashFromVar()

static BitmapHash* GetBitmapHashFromVar ( VarEntry var,
bool  allow_empty 
)
static

Return the BitmapHash from a bitmap hash variable.

This function exists primarily to perform type checking, and to raise an error if the variable is not a bitmap hash.

Parameters
varThe VarEntry that should contain a bitmap hash.
allow_emptyWhether to raise an error if the variable has not yet been initialised.
Returns
Pointer to the variable or null if the variable is undefined and allow_empty was true.

Definition at line 487 of file veil_interface.c.

References VarEntry::obj, and BitmapHash::type.

Referenced by GetBitmapHash(), veil_clear_bitmap_hash(), and veil_init_bitmap_hash().

◆ GetBitmapHash()

static BitmapHash* GetBitmapHash ( char *  name,
bool  allow_empty 
)
static

Return the BitmapHash matching the name parameter, possibly creating the VarEntry (variable) for it.

Raise an error if the named variable already exists and is of the wrong type.

Parameters
nameThe name of the variable.
allow_emptyWhether to raise an error if the variable has not been defined.
Returns
Pointer to the variable or null if the variable does not exist and create was false.

Definition at line 519 of file veil_interface.c.

References GetBitmapHashFromVar(), and vl_lookup_variable().

Referenced by veil_bitmap_from_hash(), veil_bitmap_hash_bits(), veil_bitmap_hash_clearbit(), veil_bitmap_hash_entries(), veil_bitmap_hash_key_exists(), veil_bitmap_hash_range(), veil_bitmap_hash_setbit(), veil_bitmap_hash_testbit(), veil_intersect_from_bitmap_hash(), veil_union_from_bitmap_hash(), and veil_union_into_bitmap_hash().

◆ GetInt4ArrayFromVar()

static Int4Array* GetInt4ArrayFromVar ( VarEntry var,
bool  allow_empty 
)
static

Return the Int4Array from an Int4Array variable.

This function exists primarily to perform type checking, and to raise an error if the variable is not an Int4Array.

Parameters
varThe VarEntry that should contain an Int4Array.
allow_emptyWhether to raise an error if the variable has not yet been initialised.
Returns
Pointer to the variable or null if the variable is undefined and allow_empty was true.

Definition at line 543 of file veil_interface.c.

References VarEntry::obj, and Int4Array::type.

Referenced by GetInt4Array(), and veil_init_int4array().

◆ GetInt4Array()

static Int4Array* GetInt4Array ( char *  name,
bool  allow_empty 
)
static

Return the Int4Array matching the name parameter, possibly creating the VarEntry (variable) for it.

Raise an error if the named variable already exists and is of the wrong type.

Parameters
nameThe name of the variable.
allow_emptyWhether to raise an error if the variable has not been defined.
Returns
Pointer to the variable or null if the variable does not exist and create was false.

Definition at line 575 of file veil_interface.c.

References GetInt4ArrayFromVar(), veil_variables(), and vl_lookup_variable().

Referenced by veil_clear_int4array(), veil_int4array_get(), and veil_int4array_set().

◆ veil_variables()

Datum veil_variables ( PG_FUNCTION_ARGS  )

veil_variables() returns setof veil_variable_t Return a veil_variable_t record for each defined variable.

This includes both session and shared variables.

Parameters
fcinfoNone
Returns
setof veil_variable_t

Definition at line 597 of file veil_interface.c.

References copystr(), ensure_init(), veil_variable_t::name, veil_variable_t::shared, strfrombool(), veil_variable_t::type, veil_share(), and vl_next_variable().

Referenced by GetInt4Array().

◆ veil_share()

Datum veil_share ( PG_FUNCTION_ARGS  )

veil_share(name text) returns bool Define a shared variable called NAME, returning true.

If the variable is already defined as a session variable an ERROR will be raised.

Session variables are simply defined by their first usage. Shared variables must be defined using this function. They may then be used in exactly the same way as session variables. Shared variables are shared by all backends and so need only be initialised once. The result of this function tells the caller whether the variable needs to be initialised. The caller that first defines a shared variable will get a false result and from this will know that the variable must be initialised. All subsequent callers will get a true result and so will know that the variable is already initialised.

Parameters
fcinfoname text name of variable.
Returns
bool true if the variable already exists

Definition at line 672 of file veil_interface.c.

References ensure_init(), VarEntry::obj, strfromtext(), veil_init_range(), and vl_lookup_shared_variable().

Referenced by veil_variables().

◆ veil_init_range()

Datum veil_init_range ( PG_FUNCTION_ARGS  )

veil_init_range(name text, min int4, max int4) returns int4 Initialise a Range variable called NAME constrained by MIN and MAX, returning the number of elements in the range.

Ranges may be examined using the veil_range() function.

Parameters
fcinfoname text The name of the variable to initialise.
min int4 The min value of the range.
max int4 The max value of the range.
Returns
int4 The size of the range ((max - min) + 1).

Definition at line 700 of file veil_interface.c.

References ensure_init(), GetRange(), Range::max, Range::min, and strfromtext().

Referenced by veil_share().

◆ datum_from_range()

static Datum datum_from_range ( int64  min,
int64  max 
)
static

Create a datum containing the values of a veil_range_t composite type.

Parameters
minMin value of range
maxMax value of range
Returns
Composite (row) type datum containing the range elements.

Definition at line 729 of file veil_interface.c.

References strfromint(), and veil_range().

Referenced by veil_bitmap_array_arange(), veil_bitmap_array_brange(), veil_bitmap_hash_range(), veil_bitmap_range(), and veil_range().

◆ veil_range()

Datum veil_range ( PG_FUNCTION_ARGS  )

veil_range(name text) returns veil_range_t Return the range (as a SQL veil_range_t composite type) from the named variable.

An Error will be raised if the variable is not defined or is of the wrong type.

Parameters
fcinfoname text The name of the range variable.
Returns
veil_range_t Composite type containing the min and max values from the named variable.

Definition at line 780 of file veil_interface.c.

References datum_from_range(), ensure_init(), GetRange(), Range::max, Range::min, strfromtext(), and veil_init_bitmap().

Referenced by datum_from_range().

◆ veil_init_bitmap()

Datum veil_init_bitmap ( PG_FUNCTION_ARGS  )

veil_init_bitmap(bitmap_name text, range_nametext) returns bool Create or re-initialise a Bitmap, for dealing with a named range of values.

An error will be raised if the variable already exists and is not a Bitmap.

Parameters
fcinfobitmap_name text The name of the bitmap to create or reset
range_name text The name of a Range variable that defines the range of the new bitmap.
Returns
bool true

Definition at line 811 of file veil_interface.c.

References ensure_init(), GetBitmapFromVar(), GetRange(), Range::max, Range::min, VarEntry::obj, VarEntry::shared, strfromtext(), veil_clear_bitmap(), vl_lookup_variable(), and vl_NewBitmap().

Referenced by veil_range().

◆ veil_clear_bitmap()

Datum veil_clear_bitmap ( PG_FUNCTION_ARGS  )

veil_clear_bitmap(name text) returns bool Clear all bits in the specified Bitmap.

An error will be raised if the variable is not a Bitmap or BitmapRef.

Parameters
fcinfoname text The name of the bitmap to be cleared.
Returns
bool true

Definition at line 845 of file veil_interface.c.

References ensure_init(), GetBitmapFromVar(), strfromtext(), veil_bitmap_setbit(), vl_ClearBitmap(), and vl_lookup_variable().

Referenced by veil_init_bitmap().

◆ veil_bitmap_setbit()

Datum veil_bitmap_setbit ( PG_FUNCTION_ARGS  )

veil_bitmap_setbit(name text, bit_number int4) returns bool Set the specified bit in the specified Bitmap.

An error will be raised if the variable is not a Bitmap or BitmapRef.

Parameters
fcinfoname text The name of the bitmap variable.
bit_number int4 The bit to be set.
Returns
bool true

Definition at line 874 of file veil_interface.c.

References ensure_init(), GetBitmap(), strfromtext(), veil_bitmap_clearbit(), and vl_BitmapSetbit().

Referenced by veil_clear_bitmap().

◆ veil_bitmap_clearbit()

Datum veil_bitmap_clearbit ( PG_FUNCTION_ARGS  )

veil_bitmap_clearbit(name int4, bit_number text) returns bool Clear the specified bit in the specified Bitmap.

An error will be raised if the variable is not a Bitmap or BitmapRef.

Parameters
fcinfoname text The name of the bitmap variable.
bit_number int4 The bit to be cleared.
Returns
bool true

Definition at line 902 of file veil_interface.c.

References ensure_init(), GetBitmap(), strfromtext(), veil_bitmap_testbit(), and vl_BitmapClearbit().

Referenced by veil_bitmap_setbit().

◆ veil_bitmap_testbit()

Datum veil_bitmap_testbit ( PG_FUNCTION_ARGS  )

veil_bitmap_testbit(name text, bit_number int4) returns bool Test the specified bit in the specified Bitmap, returning true if it is set.

An error will be raised if the variable is not a Bitmap or BitmapRef.

Parameters
fcinfoname text The name of the bitmap variable.
bit_number int4 The bit to be tested.
Returns
bool true if the bit was set

Definition at line 931 of file veil_interface.c.

References ensure_init(), GetBitmap(), strfromtext(), veil_bitmap_union(), and vl_BitmapTestbit().

Referenced by veil_bitmap_clearbit().

◆ veil_bitmap_union()

Datum veil_bitmap_union ( PG_FUNCTION_ARGS  )

veil_bitmap_union(result_name text, name2 text) returns bool Union the bitmap specified in parameter 1 with that in parameter 2, with the result in parameter 1.

An error will be raised if the variables are not of type Bitmap or BitmapRef.

Parameters
fcinforesult_name text The target bitmap
name2 text The bitmap with which to union the target
Returns
bool true

Definition at line 963 of file veil_interface.c.

References ensure_init(), GetBitmap(), strfromtext(), veil_bitmap_intersect(), and vl_BitmapUnion().

Referenced by veil_bitmap_testbit().

◆ veil_bitmap_intersect()

Datum veil_bitmap_intersect ( PG_FUNCTION_ARGS  )

veil_bitmap_intersect(result_name text, name2 text) returns bool Intersect the bitmap specified in parameter 1 with that in parameter 2, with the result in parameter 1.

An error will be raised if the variables are not of type Bitmap or BitmapRef.

Parameters
fcinforesult_name text The target bitmap
name2 text The bitmap with which to intersect the target
Returns
bool true

Definition at line 999 of file veil_interface.c.

References ensure_init(), GetBitmap(), strfromtext(), veil_bitmap_bits(), and vl_BitmapIntersect().

Referenced by veil_bitmap_union().

◆ veil_bitmap_bits()

Datum veil_bitmap_bits ( PG_FUNCTION_ARGS  )

veil_bitmap_bits(name text) returns setof int4 Return the set of all bits set in the specified Bitmap or BitmapRef.

Parameters
fcinfoname text The name of the bitmap.
Returns
setof int4The set of bits that are set in the bitmap.

Definition at line 1028 of file veil_interface.c.

References ensure_init(), GetBitmap(), strfromtext(), veil_bitmap_range(), and vl_BitmapNextBit().

Referenced by veil_bitmap_intersect().

◆ veil_bitmap_range()

Datum veil_bitmap_range ( PG_FUNCTION_ARGS  )

veil_bitmap_range(name text) returns veil_range_t Return composite type giving the range of the specified Bitmap or BitmapRef.

Parameters
fcinfoname text The name of the bitmap.
Returns
veil_range_t Composite type containing the min and max values of the bitmap's range

Definition at line 1092 of file veil_interface.c.

References Bitmap::bitmax, Bitmap::bitzero, datum_from_range(), ensure_init(), GetBitmap(), strfromtext(), and veil_init_bitmap_array().

Referenced by veil_bitmap_bits().

◆ veil_init_bitmap_array()

Datum veil_init_bitmap_array ( PG_FUNCTION_ARGS  )

veil_init_bitmap_array(text, text, text) returns bool Create or reset a BitmapArray.

An error will be raised if any parameter is not of the correct type.

Parameters
fcinfobmarray text The name of the bitmap array.
array_range text Name of the Range variable that provides the range of the array part of the bitmap array.
bitmap_range text Name of the Range variable that provides the range of each bitmap in the array.
Returns
bool True

Definition at line 1128 of file veil_interface.c.

References ensure_init(), GetBitmapArrayFromVar(), GetRange(), Range::max, Range::min, VarEntry::obj, VarEntry::shared, strfromtext(), veil_clear_bitmap_array(), vl_lookup_variable(), and vl_NewBitmapArray().

Referenced by veil_bitmap_range().

◆ veil_clear_bitmap_array()

Datum veil_clear_bitmap_array ( PG_FUNCTION_ARGS  )

veil_clear_bitmap_array(bmarray text) returns bool Clear the bits in an existing BitmapArray.

An error will be raised if the parameter is not of the correct type.

Parameters
fcinfobmarray text The name of the BitmapArray.
Returns
bool True

Definition at line 1168 of file veil_interface.c.

References ensure_init(), GetBitmapArrayFromVar(), strfromtext(), veil_bitmap_from_array(), vl_ClearBitmapArray(), and vl_lookup_variable().

Referenced by veil_init_bitmap_array().

◆ veil_bitmap_from_array()

Datum veil_bitmap_from_array ( PG_FUNCTION_ARGS  )

veil_bitmap_from_array(bmref text, bmarray text, index int4) returns text Place a reference to the specified Bitmap from a BitmapArray into the specified BitmapRef An error will be raised if any parameter is not of the correct type.

Parameters
fcinfobmref text The name of the BitmapRef into which a reference to the relevant Bitmap will be placed.
bmarray text Name of the BitmapArray containing the Bitmap in which we are interested.
index int4 Index into the array of the bitmap in question.
Returns
text The name of the BitmapRef

Definition at line 1200 of file veil_interface.c.

References BitmapArray::arraymax, BitmapArray::arrayzero, BitmapRef::bitmap, GetBitmapArray(), GetBitmapRef(), strfromtext(), veil_bitmap_array_testbit(), vl_BitmapFromArray(), and BitmapRef::xid.

Referenced by veil_clear_bitmap_array().

◆ veil_bitmap_array_testbit()

Datum veil_bitmap_array_testbit ( PG_FUNCTION_ARGS  )

veil_bitmap_array_testbit(bmarray text, arr_idx int4, bitno int4) returns bool Test a specified bit within a BitmapArray

An error will be raised if the first parameter is not a BitmapArray.

Parameters
fcinfobmarray text The name of the BitmapArray
arr_idx int4 Index of the Bitmap within the array.
bitno int4 Bit id of the bit within the Bitmap.
Returns
bool True if the bit was set, false otherwise.

Definition at line 1245 of file veil_interface.c.

References ensure_init(), GetBitmapArray(), strfromtext(), veil_bitmap_array_setbit(), vl_BitmapFromArray(), and vl_BitmapTestbit().

Referenced by veil_bitmap_from_array().

◆ veil_bitmap_array_setbit()

Datum veil_bitmap_array_setbit ( PG_FUNCTION_ARGS  )

veil_bitmap_array_setbit(bmarray text, arr_idx int4, bitno int4) returns bool Set a specified bit within a BitmapArray

An error will be raised if the first parameter is not a BitmapArray.

Parameters
fcinfobmarray text The name of the BitmapArray
arr_idx int4 Index of the Bitmap within the array.
ibitno nt4 Bit id of the bit within the Bitmap.
Returns
bool True

Definition at line 1284 of file veil_interface.c.

References BitmapArray::arraymax, BitmapArray::arrayzero, ensure_init(), GetBitmapArray(), strfromtext(), veil_bitmap_array_clearbit(), vl_BitmapFromArray(), and vl_BitmapSetbit().

Referenced by veil_bitmap_array_testbit().

◆ veil_bitmap_array_clearbit()

Datum veil_bitmap_array_clearbit ( PG_FUNCTION_ARGS  )

veil_bitmap_array_clearbit(bmarray text, arr_idx int4, bitno int4) returns bool Clear a specified bit within a BitmapArray

An error will be raised if the first parameter is not a BitmapArray.

Parameters
fcinfobmarray text The name of the BitmapArray
arr_idx int4 Index of the Bitmap within the array.
bitno int4 Bit id of the bit within the Bitmap.
Returns
bool True

Definition at line 1329 of file veil_interface.c.

References BitmapArray::arraymax, BitmapArray::arrayzero, ensure_init(), GetBitmapArray(), strfromtext(), veil_union_from_bitmap_array(), vl_BitmapClearbit(), and vl_BitmapFromArray().

Referenced by veil_bitmap_array_setbit().

◆ veil_union_from_bitmap_array()

Datum veil_union_from_bitmap_array ( PG_FUNCTION_ARGS  )

veil_union_from_bitmap_array(bitmap text, bmarray text, arr_idx int4) returns bool Union a Bitmap with the specified Bitmap from a BitmapArray with the result placed into the first parameter.

An error will be raised if the parameters are not of the correct types.

Parameters
fcinfobitmap text The name of the Bitmap into which the resulting union will be placed.
bmarray text Name of the BitmapArray
arr_idx int4 Index of the required bitmap in the array
Returns
bool True

Definition at line 1376 of file veil_interface.c.

References ensure_init(), GetBitmap(), GetBitmapArray(), strfromtext(), veil_intersect_from_bitmap_array(), vl_BitmapFromArray(), and vl_BitmapUnion().

Referenced by veil_bitmap_array_clearbit().

◆ veil_intersect_from_bitmap_array()

Datum veil_intersect_from_bitmap_array ( PG_FUNCTION_ARGS  )

veil_intersect_from_bitmap_array(bitmap text, bmarray text, arr_idx int4) returns bool Intersect a Bitmap with the specified Bitmap from a BitmapArray with the result placed into the first parameter.

An error will be raised if the parameters are not of the correct types.

Parameters
fcinfobitmap text The name of the Bitmap into which the resulting intersection will be placed.
bmarray text Name of the BitmapArray
arr_idx int4 Index of the required bitmap in the array
Returns
bool True

Definition at line 1417 of file veil_interface.c.

References ensure_init(), GetBitmap(), GetBitmapArray(), strfromtext(), veil_bitmap_array_bits(), vl_BitmapFromArray(), and vl_BitmapIntersect().

Referenced by veil_union_from_bitmap_array().

◆ veil_bitmap_array_bits()

Datum veil_bitmap_array_bits ( PG_FUNCTION_ARGS  )

veil_bitmap_array_bits(bmarray text, arr_idx int4) returns setof int4 Return the set of all bits set in the specified Bitmap from the BitmapArray.

Parameters
fcinfobmarray text The name of the bitmap array.
arr_idx int4 Index of the required bitmap in the array
Returns
setof int4The set of bits that are set in the bitmap.

Definition at line 1455 of file veil_interface.c.

References BitmapArray::arraymax, BitmapArray::arrayzero, ensure_init(), GetBitmapArray(), strfromtext(), veil_bitmap_array_arange(), vl_BitmapFromArray(), and vl_BitmapNextBit().

Referenced by veil_intersect_from_bitmap_array().

◆ veil_bitmap_array_arange()

Datum veil_bitmap_array_arange ( PG_FUNCTION_ARGS  )

veil_bitmap_array_arange(bmarray text) returns veil_range_t Return composite type giving the range of the array part of the specified BitmapArray

Parameters
fcinfobmarray text The name of the bitmap array.
Returns
veil_range_t Composite type containing the min and max indices of the array

Definition at line 1533 of file veil_interface.c.

References BitmapArray::arraymax, BitmapArray::arrayzero, datum_from_range(), ensure_init(), GetBitmapArray(), strfromtext(), and veil_bitmap_array_brange().

Referenced by veil_bitmap_array_bits().

◆ veil_bitmap_array_brange()

Datum veil_bitmap_array_brange ( PG_FUNCTION_ARGS  )

veil_bitmap_array_brange(bmarray text) returns veil_range_t Return composite type giving the range of every Bitmap within the BitmapArray.

Parameters
fcinfobmarray text The name of the bitmap array.
Returns
veil_range_t Composite type containing the min and max values of the bitmap array's range

Definition at line 1567 of file veil_interface.c.

References BitmapArray::bitmax, BitmapArray::bitzero, datum_from_range(), ensure_init(), GetBitmapArray(), strfromtext(), and veil_init_bitmap_hash().

Referenced by veil_bitmap_array_arange().

◆ veil_init_bitmap_hash()

Datum veil_init_bitmap_hash ( PG_FUNCTION_ARGS  )

veil_init_bitmap_hash(bmhash text, range text) returns bool Create or reset a BitmapHash.

An error will be raised if any parameter is not of the correct type.

Parameters
fcinfobmhash text The name of the bitmap hash.
range text Name of the Range variable that provides the range of each bitmap in the hash.
Returns
bool True

Definition at line 1603 of file veil_interface.c.

References ensure_init(), GetBitmapHashFromVar(), GetRange(), Range::max, Range::min, VarEntry::obj, VarEntry::shared, strfromtext(), veil_clear_bitmap_hash(), vl_lookup_variable(), and vl_NewBitmapHash().

Referenced by veil_bitmap_array_brange().

◆ veil_clear_bitmap_hash()

Datum veil_clear_bitmap_hash ( PG_FUNCTION_ARGS  )

veil_clear_bitmap_hash(bmhash text) returns bool Clear the bits in an existing BitmapHash.

An error will be raised if the parameter is not of the correct type.

Parameters
fcinfobmhash text The name of the BitmapHash.
Returns
bool True

Definition at line 1647 of file veil_interface.c.

References BitmapHash::bitmax, BitmapHash::bitzero, ensure_init(), GetBitmapHashFromVar(), VarEntry::obj, strfromtext(), veil_bitmap_hash_key_exists(), vl_lookup_variable(), and vl_NewBitmapHash().

Referenced by veil_init_bitmap_hash().

◆ veil_bitmap_hash_key_exists()

Datum veil_bitmap_hash_key_exists ( PG_FUNCTION_ARGS  )

veil_bitmap_hashkey_exists(bmhash text, key text) returns bool Return true if the key exists in the bitmap hash.

Parameters
fcinfobmhash text Name of the BitmapHashin which we are interested.
key text Key, into the hash, of the bitmap in question.
Returns
boolean Whether the key is present in the BitmapHash

Definition at line 1679 of file veil_interface.c.

References GetBitmapHash(), strfromtext(), veil_bitmap_from_hash(), and vl_BitmapHashHasKey().

Referenced by veil_clear_bitmap_hash().

◆ veil_bitmap_from_hash()

Datum veil_bitmap_from_hash ( PG_FUNCTION_ARGS  )

veil_bitmap_from_hash(bmref text, bmhash text, key text) returns text Place a reference to the specified Bitmap from a BitmapHash into the specified BitmapRef An error will be raised if any parameter is not of the correct type.

Parameters
fcinfobmref text The name of the BitmapRef into which a reference to the relevant Bitmap will be placed.
bmhash text Name of the BitmapHash containing the Bitmap in which we are interested.
key text Key, into the hash, of the bitmap in question.
Returns
text The name of the BitmapRef

Definition at line 1711 of file veil_interface.c.

References BitmapRef::bitmap, GetBitmapHash(), GetBitmapRef(), strfromtext(), veil_bitmap_hash_testbit(), vl_AddBitmapToHash(), and BitmapRef::xid.

Referenced by veil_bitmap_hash_key_exists().

◆ veil_bitmap_hash_testbit()

Datum veil_bitmap_hash_testbit ( PG_FUNCTION_ARGS  )

veil_bitmap_hash_testbit(bmhash text, key text, bitno int4) returns bool Test a specified bit within a BitmapHash

An error will be raised if the first parameter is not a BitmapHash.

Parameters
fcinfobmhash text The name of the BitmapHash
key text Key of the Bitmap within the hash.
bitno int4 Bit id of the bit within the Bitmap.
Returns
bool True if the bit was set, false otherwise.

Definition at line 1750 of file veil_interface.c.

References ensure_init(), GetBitmapHash(), strfromtext(), veil_bitmap_hash_setbit(), vl_BitmapFromHash(), and vl_BitmapTestbit().

Referenced by veil_bitmap_from_hash().

◆ veil_bitmap_hash_setbit()

Datum veil_bitmap_hash_setbit ( PG_FUNCTION_ARGS  )

veil_bitmap_hash_setbit(bmhash text, key text, bitno int4) returns bool Set a specified bit within a BitmapHash

An error will be raised if the first parameter is not a BitmapHash.

Parameters
fcinfobmhash text The name of the BitmapHash
key text Key of the Bitmap within the hash.
bitno int4 Bit id of the bit within the Bitmap.
Returns
bool True

Definition at line 1789 of file veil_interface.c.

References ensure_init(), GetBitmapHash(), strfromtext(), veil_bitmap_hash_clearbit(), vl_AddBitmapToHash(), and vl_BitmapSetbit().

Referenced by veil_bitmap_hash_testbit().

◆ veil_bitmap_hash_clearbit()

Datum veil_bitmap_hash_clearbit ( PG_FUNCTION_ARGS  )

veil_bitmap_hash_clearbit(bmhash text, key text, bitno int4) returns bool Clear a specified bit within a BitmapHash

An error will be raised if the first parameter is not a BitmapHash.

Parameters
fcinfobmhash text The name of the BitmapHash
key text Key of the Bitmap within the hash.
bitno int4 Bit id of the bit within the Bitmap.
Returns
bool True

Definition at line 1824 of file veil_interface.c.

References ensure_init(), GetBitmapHash(), strfromtext(), veil_union_into_bitmap_hash(), vl_AddBitmapToHash(), and vl_BitmapClearbit().

Referenced by veil_bitmap_hash_setbit().

◆ veil_union_into_bitmap_hash()

Datum veil_union_into_bitmap_hash ( PG_FUNCTION_ARGS  )

veil_union_into_bitmap_hash(bmhash text, key text, bitmap text) returns bool Union a Bitmap with the specified Bitmap from a BitmapHash with the result placed into the bitmap hash.

An error will be raised if the parameters are not of the correct types.

Parameters
fcinfobmhash text Name of the BitmapHash
key text Key of the required bitmap in the hash
bitmap text The name of the Bitmap into which the resulting union will be placed.
Returns
bool True

Definition at line 1861 of file veil_interface.c.

References ensure_init(), GetBitmap(), GetBitmapHash(), strfromtext(), veil_union_from_bitmap_hash(), vl_AddBitmapToHash(), and vl_BitmapUnion().

Referenced by veil_bitmap_hash_clearbit().

◆ veil_union_from_bitmap_hash()

Datum veil_union_from_bitmap_hash ( PG_FUNCTION_ARGS  )

veil_union_from_bitmap_hash(bmhash text, key text, bitmap text) returns bool Union a Bitmap with the specified Bitmap from a BitmapHash with the result placed into the bitmap parameter.

An error will be raised if the parameters are not of the correct types.

Parameters
fcinfobmhash text The name of the Bitmap into which the resulting union will be placed.
key text Name of the BitmapHash
bitmap text Key of the required bitmap in the hash
Returns
bool True

Definition at line 1901 of file veil_interface.c.

References ensure_init(), GetBitmap(), GetBitmapHash(), strfromtext(), veil_intersect_from_bitmap_hash(), vl_BitmapFromHash(), and vl_BitmapUnion().

Referenced by veil_union_into_bitmap_hash().

◆ veil_intersect_from_bitmap_hash()

Datum veil_intersect_from_bitmap_hash ( PG_FUNCTION_ARGS  )

veil_intersect_from_bitmap_hash(bitmap text, bmhash text, key text) returns bool Intersect a Bitmap with the specified Bitmap from a BitmapArray with the result placed into the bitmap parameter.

An error will be raised if the parameters are not of the correct types.

Parameters
fcinfobitmap text The name of the Bitmap into which the resulting intersection will be placed.
bmhash text Name of the BitmapHash
key text Key of the required bitmap in the hash
Returns
bool True

Definition at line 1941 of file veil_interface.c.

References ensure_init(), GetBitmap(), GetBitmapHash(), strfromtext(), veil_bitmap_hash_bits(), vl_BitmapFromHash(), vl_BitmapIntersect(), and vl_ClearBitmap().

Referenced by veil_union_from_bitmap_hash().

◆ veil_bitmap_hash_bits()

Datum veil_bitmap_hash_bits ( PG_FUNCTION_ARGS  )

veil_bitmap_hash_bits(bmhash text, key text) returns setof int4 Return the set of all bits set in the specified Bitmap from the BitmapHash.

Parameters
fcinfobmhashtext The name of the bitmap hash.
key text Key of the required bitmap in the hash
Returns
setof int4The set of bits that are set in the bitmap.

Definition at line 1983 of file veil_interface.c.

References ensure_init(), GetBitmapHash(), strfromtext(), veil_bitmap_hash_range(), vl_BitmapFromHash(), and vl_BitmapNextBit().

Referenced by veil_intersect_from_bitmap_hash().

◆ veil_bitmap_hash_range()

Datum veil_bitmap_hash_range ( PG_FUNCTION_ARGS  )

veil_bitmap_hash_range(bmhash text) returns veil_range_t Return composite type giving the range of every Bitmap within the BitmapHash.

Parameters
fcinfobmhash text The name of the bitmap array.
Returns
veil_range_t Composite type containing the min and max values of the bitmap hash's range

Definition at line 2052 of file veil_interface.c.

References BitmapHash::bitmax, BitmapHash::bitzero, datum_from_range(), ensure_init(), GetBitmapHash(), strfromtext(), and veil_bitmap_hash_entries().

Referenced by veil_bitmap_hash_bits().

◆ veil_bitmap_hash_entries()

Datum veil_bitmap_hash_entries ( PG_FUNCTION_ARGS  )

veil_bitmap_hash_entries(bmhash text) returns setof text Return the key of every Bitmap within the BitmapHash.

Parameters
fcinfobmhash text The name of the bitmap hash.
Returns
setof text Every key in the hash.

Definition at line 2081 of file veil_interface.c.

References ensure_init(), GetBitmapHash(), HASH_KEYLEN, strfromtext(), textfromstrn(), veil_int4_set(), and vl_NextHashEntry().

Referenced by veil_bitmap_hash_range().

◆ veil_int4_set()

Datum veil_int4_set ( PG_FUNCTION_ARGS  )

veil_int4_set(name text,value int4) returns int4 Set an Int4Var variable type to a specified value.

An Error will be raised if the variable is not defined or is of the wrong type.

Parameters
fcinfoname text The name of the int4 variable.
fcinfovalue int4 The value to be set (may be null).
Returns
int4 The new value of the variable.

Definition at line 2144 of file veil_interface.c.

References ensure_init(), GetInt4Var(), Int4Var::isnull, strfromtext(), Int4Var::value, and veil_int4_get().

Referenced by veil_bitmap_hash_entries().

◆ veil_int4_get()

Datum veil_int4_get ( PG_FUNCTION_ARGS  )

veil_int4_get(name text) returns int4 Return the value of an Int4Var variable.

An Error will be raised if the variable is not defined or is of the wrong type.

Parameters
fcinfoname text The name of the int4 variable.
Returns
int4 The value of the variable.

Definition at line 2182 of file veil_interface.c.

References ensure_init(), GetInt4Var(), Int4Var::isnull, strfromtext(), Int4Var::value, and veil_init_int4array().

Referenced by veil_int4_set().

◆ veil_init_int4array()

Datum veil_init_int4array ( PG_FUNCTION_ARGS  )

veil_init_int4array(arrayname text, range text) returns bool Initialise an Int4Array variable.

Each entry in the array will be zeroed.

Parameters
fcinfoarrayname text The name of the Int4Array variable.
range text Name of the range variable defining the size of the array.
Returns
bool True

Definition at line 2212 of file veil_interface.c.

References ensure_init(), GetInt4ArrayFromVar(), GetRange(), Range::max, Range::min, VarEntry::obj, VarEntry::shared, strfromtext(), veil_clear_int4array(), vl_lookup_variable(), and vl_NewInt4Array().

Referenced by veil_int4_get().

◆ veil_clear_int4array()

Datum veil_clear_int4array ( PG_FUNCTION_ARGS  )

veil_clear_int4array(name text) returns bool Clear an Int4Array variable.

Each entry in the array will be zeroed.

Parameters
fcinfoname text The name of the Int4Array variable.
Returns
bool True

Definition at line 2245 of file veil_interface.c.

References ensure_init(), GetInt4Array(), strfromtext(), veil_int4array_set(), and vl_ClearInt4Array().

Referenced by veil_init_int4array().

◆ veil_int4array_set()

Datum veil_int4array_set ( PG_FUNCTION_ARGS  )

veil_int4array_set(array text, idx int4, value int4) returns int4 Set an Int4Array entry.

Parameters
fcinfoarray text The name of the Int4Array variable.
idx int4 Index of the entry to be set
value int4 Value to which the entry will be set
Returns
int4 The new value of the array entry

Definition at line 2271 of file veil_interface.c.

References ensure_init(), GetInt4Array(), strfromtext(), veil_int4array_get(), and vl_Int4ArraySet().

Referenced by veil_clear_int4array().

◆ veil_int4array_get()

Datum veil_int4array_get ( PG_FUNCTION_ARGS  )

veil_int4array_get(array text, idx int4) returns int4 Get an Int4Array entry.

Parameters
fcinfoarray text The name of the Int4Array variable.
idx int4 Index of the entry to be retrieved
Returns
int4 The value of the array entry

Definition at line 2299 of file veil_interface.c.

References ensure_init(), GetInt4Array(), strfromtext(), veil_init(), and vl_Int4ArrayGet().

Referenced by veil_int4array_set().

◆ veil_init()

Datum veil_init ( PG_FUNCTION_ARGS  )

veil_init(doing_reset bool) returns bool Initialise or reset a veil session.

The boolean parameter will be false when called for initialisation, and true when performing a reset.

This function may be redefined as a custom function in your implementation, or will call initialisation functions registered in the table veil.veil_init_fns.

Parameters
fcinfodoing_reset bool Whether we are being called in order to reset (true) the session or (false) simply to initialise it.
Returns
bool True

Definition at line 2334 of file veil_interface.c.

References veil_perform_reset(), and vl_call_init_fns().

Referenced by veil_int4array_get().

◆ veil_perform_reset()

Datum veil_perform_reset ( PG_FUNCTION_ARGS  )

veil_perform_reset() returns bool Reset veil shared memory for this database.

This creates a new shared memory context with none of the existing shared variables. All current transactions will be able to continue using the current variables, all new transactions will see the new set, once this function has completed.

Parameters
fcinfo
Returns
bool True if the function is able to complete successfully. If it is unable, no harm will have been done but neither will a memory reset have been performed.

Definition at line 2364 of file veil_interface.c.

References ensure_init(), veil_force_reset(), vl_bool_from_query(), vl_complete_context_switch(), vl_prepare_context_switch(), vl_spi_connect(), and vl_spi_finish().

Referenced by veil_init().

◆ veil_force_reset()

Datum veil_force_reset ( PG_FUNCTION_ARGS  )

veil_force_reset() returns bool Reset veil shared memory for this database, ignoring existing transactions.

This function will always reset the shared memory context, even for sessions that are still using it. Having taken this drastic action, it will then cause a panic to reset the server.

Question - won't a panic reset the shared memory in any case? Is the panic superfluous, or maybe is this entire function superfluous?

Parameters
fcinfo
Returns
bool True.

Definition at line 2420 of file veil_interface.c.

References ensure_init(), veil_version(), and vl_force_context_switch().

Referenced by veil_perform_reset().

◆ veil_version()

Datum veil_version ( PG_FUNCTION_ARGS  )

veil_version() returns text Return a string describing this version of veil.

Parameters
fcinfo
Returns
text String describing the version.

Definition at line 2437 of file veil_interface.c.

References textfromstr(), veil_serialise(), VEIL_VERSION, and VEIL_VERSION_INFO.

Referenced by veil_force_reset().

◆ veil_serialise()

Datum veil_serialise ( PG_FUNCTION_ARGS  )

veil_serialise(varname text) returns text Return a string representing the contents of our variable.

Parameters
fcinfo
varname text Name of the variable to be serialised.
Returns
text String containing the serialised variable.

Definition at line 2460 of file veil_interface.c.

References ensure_init(), strfromtext(), textfromstr(), veil_deserialise(), and vl_serialise_var().

Referenced by veil_version().

◆ veil_deserialise()

Datum veil_deserialise ( PG_FUNCTION_ARGS  )

veil_deserialise(stream text) returns text Create or reset variables based on the output of previous veil_serialise calls.

Parameters
fcinfo
stream text Serialised variables string
Returns
int4 Count of the items de-serialised from the string.

Definition at line 2495 of file veil_interface.c.

References ensure_init(), strfromtext(), and vl_deserialise().

Referenced by veil_serialise().