Veil
veil_funcs.h File Reference

Provide definitions for all non-local C-callable Veil functions. More...

#include "veil_datatypes.h"
#include "fmgr.h"

Go to the source code of this file.

Functions

void * vl_malloc (size_t size)
 Dynamically allocate memory using palloc in TopMemoryContext. More...
 
char * vl_ObjTypeName (ObjType obj)
 Return a static string describing an ObjType object. More...
 
VarEntryvl_lookup_shared_variable (char *name)
 Define a new, or attach to an existing, shared variable. More...
 
VarEntryvl_lookup_variable (char *name)
 Lookup a variable by name, creating it as as a session variable if it does not already exist. More...
 
veil_variable_tvl_next_variable (veil_variable_t *prev)
 Return the next variable from a scan of the hash of variables. More...
 
void vl_ClearInt4Array (Int4Array *array)
 Reset all Int4 entries in an Int4Array (to zero). More...
 
Int4Arrayvl_NewInt4Array (Int4Array *current, bool shared, int32 min, int32 max)
 Return a newly initialised (zeroed) Int4Array. More...
 
void vl_Int4ArraySet (Int4Array *array, int32 idx, int32 value)
 Set an entry within an Int4Array. More...
 
int32 vl_Int4ArrayGet (Int4Array *array, int32 idx)
 Get an entry from an Int4Array. More...
 
Rangevl_NewRange (bool shared)
 Create a new session or shared Range object. More...
 
Int4Varvl_NewInt4 (bool shared)
 Create a new session or shared Int4Var object. More...
 
void vl_ClearBitmap (Bitmap *bitmap)
 Clear all bits in a Bitmap. More...
 
void vl_NewBitmap (Bitmap **p_bitmap, bool shared, int32 min, int32 max)
 Return a newly initialised (empty) Bitmap. More...
 
void vl_BitmapSetbit (Bitmap *bitmap, int32 bit)
 Set a bit within a Bitmap. More...
 
void vl_BitmapClearbit (Bitmap *bitmap, int32 bit)
 Clear a bit within a Bitmap. More...
 
bool vl_BitmapTestbit (Bitmap *bitmap, int32 bit)
 Test a bit within a Bitmap. More...
 
void vl_BitmapUnion (Bitmap *target, Bitmap *source)
 Create the union of two bitmaps, updating the first with the result. More...
 
void vl_BitmapIntersect (Bitmap *target, Bitmap *source)
 Create the intersection of two bitmaps, updating the first with the result. More...
 
int32 vl_BitmapNextBit (Bitmap *bitmap, int32 bit, bool *found)
 Return the next set bit in the Bitmap. More...
 
Bitmapvl_BitmapFromArray (BitmapArray *bmarray, int32 elem)
 Return a specified Bitmap from a BitmapArray. More...
 
void vl_ClearBitmapArray (BitmapArray *bmarray)
 Clear all bitmaps in the given BitmapArray. More...
 
void vl_NewBitmapArray (BitmapArray **p_bmarray, bool shared, int32 arrayzero, int32 arraymax, int32 bitzero, int32 bitmax)
 Return a newly initialised (empty) BitmapArray. More...
 
VarEntryvl_NextHashEntry (HTAB *hash, VarEntry *prev)
 Utility function for scanning the hash table of a BitmapHash. More...
 
void vl_NewBitmapHash (BitmapHash **p_bmhash, char *name, int32 bitzero, int32 bitmax)
 Return a newly initialised (empty) BitmapHash. More...
 
Bitmapvl_BitmapFromHash (BitmapHash *bmhash, char *hashelem)
 Return a specified Bitmap from a BitmapHash. More...
 
Bitmapvl_AddBitmapToHash (BitmapHash *bmhash, char *hashelem)
 Create a newly allocated empty Bitmap to a BitmapHash. More...
 
bool vl_BitmapHashHasKey (BitmapHash *bmhash, char *hashelem)
 Determine whether the supplied key exists in the BitmapHash. More...
 
HTAB * vl_get_shared_hash (void)
 Return the shared hash for the current context. More...
 
bool vl_prepare_context_switch (void)
 Prepare for a switch to the alternate context. More...
 
bool vl_complete_context_switch (void)
 Complete the context switch started by vl_prepare_context_switch(). More...
 
void vl_force_context_switch (void)
 In desparation, if we are unable to complete a context switch, we should use this function.
 
void * vl_shmalloc (size_t size)
 Dynamically allocate a piece of shared memory from the current context. More...
 
void vl_free (void *mem)
 Free a piece of shared memory within the current context. More...
 
void _PG_init (void)
 Veil's startup function. More...
 
int vl_spi_connect (bool *p_pushed)
 If already connected in this session, push the current connection, and get a new one. More...
 
int vl_spi_finish (bool pushed)
 Reciprocal function for vl_spi_connect()
 
bool vl_bool_from_query (const char *qry, bool *result)
 Executes a query that returns a single bool value. More...
 
bool vl_db_exists (Oid db_id)
 Determine whether the given oid represents an existing database or not. More...
 
int vl_call_init_fns (bool param)
 Identify any registered init_functions and execute them. More...
 
void veil_config_init (void)
 Initialise Veil's use of GUC variables.
 
void veil_load_config (void)
 Retrieve Veil's GUC variables for this session.
 
int veil_shared_hash_elems (void)
 Return the number of entries that should be allocated for shared variables in our shared hashes. More...
 
int veil_dbs_in_cluster (void)
 Return the number of databases, within the database cluster, that will use Veil. More...
 
int veil_shmem_context_size (void)
 Return the amount of shared memory to be requested for each of the two shared memory contexts. 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...
 
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...
 
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_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_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_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...
 
char * vl_serialise_var (char *name)
 Serialise a veil variable. More...
 
int32 vl_deserialise (char **p_stream)
 De-serialise a base64 string containing, possibly many, derialised veil variables. More...
 
VarEntryvl_deserialise_next (char **p_stream)
 De-serialise the next veil variable from *p_stream. More...
 

Detailed Description

Provide definitions for all non-local C-callable Veil functions.

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

Definition in file veil_funcs.h.

Function Documentation

◆ vl_malloc()

void* vl_malloc ( size_t  size)

Dynamically allocate memory using palloc in TopMemoryContext.

Parameters
sizeThe size of the chunk of memory being requested.
Returns
Pointer to the newly allocated chunk of memory

Definition at line 28 of file veil_utils.c.

Referenced by create_shared_hash(), get_shmem_context(), vl_NewBitmap(), vl_NewBitmapArray(), vl_NewInt4(), vl_NewInt4Array(), and vl_NewRange().

◆ vl_ObjTypeName()

char* vl_ObjTypeName ( ObjType  obj)

Return a static string describing an ObjType object.

Parameters
objThe ObjType for which we want a description.
Returns
Pointer to a static string describing obj.

Definition at line 45 of file veil_utils.c.

Referenced by vl_next_variable(), and vl_type_mismatch().

◆ vl_lookup_shared_variable()

VarEntry* vl_lookup_shared_variable ( char *  name)

Define a new, or attach to an existing, shared variable.

Raise an ERROR if the variable already exists as a session variable or if we cannot create the variable due to resource limitations (out of memory, or out of space in the shared hash).

Parameters
nameThe name of the variable.
Returns
Pointer to the shared variable. If the variable is newly created by this call then it will be unitialised (ie it will have a NULL obj reference).

Definition at line 70 of file veil_variables.c.

References create_session_hash(), VarEntry::obj, session_hash, VarEntry::shared, and vl_get_shared_hash().

Referenced by veil_share().

◆ vl_lookup_variable()

VarEntry* vl_lookup_variable ( char *  name)

Lookup a variable by name, creating it as as a session variable if it does not already exist.

Parameters
nameThe name of the variable
Returns
Pointer to the shared or session variable. If the variable is newly created by this call then it will be unitialised (ie it will have a NULL obj reference).

Definition at line 122 of file veil_variables.c.

References create_session_hash(), VarEntry::obj, session_hash, VarEntry::shared, and vl_get_shared_hash().

Referenced by deserialise_bitmap(), deserialise_bitmap_array(), deserialise_bitmap_hash(), deserialise_int4array(), deserialise_int4var(), deserialise_range(), GetBitmap(), GetBitmapArray(), GetBitmapHash(), GetBitmapRef(), GetInt4Array(), GetInt4Var(), GetRange(), veil_clear_bitmap(), veil_clear_bitmap_array(), veil_clear_bitmap_hash(), veil_init_bitmap(), veil_init_bitmap_array(), veil_init_bitmap_hash(), veil_init_int4array(), and vl_serialise_var().

◆ vl_next_variable()

veil_variable_t* vl_next_variable ( veil_variable_t prev)

Return the next variable from a scan of the hash of variables.

Note that this function is not re-entrant.

Parameters
prevThe last variable retrieved by a scan, or NULL if starting a new scan.
Returns
The next variable encountered in the scan. NULL if we have finished.

Definition at line 167 of file veil_variables.c.

References create_session_hash(), VarEntry::key, veil_variable_t::name, VarEntry::obj, session_hash, VarEntry::shared, veil_variable_t::shared, Object::type, veil_variable_t::type, vl_get_shared_hash(), and vl_ObjTypeName().

Referenced by veil_variables().

◆ vl_ClearInt4Array()

void vl_ClearInt4Array ( Int4Array array)

Reset all Int4 entries in an Int4Array (to zero).

Parameters
arrayThe array to be reset.

Definition at line 224 of file veil_variables.c.

References Int4Array::array, Int4Array::arraymax, and Int4Array::arrayzero.

Referenced by veil_clear_int4array(), and vl_NewInt4Array().

◆ vl_NewInt4Array()

Int4Array* vl_NewInt4Array ( Int4Array current,
bool  shared,
int32  min,
int32  max 
)

Return a newly initialised (zeroed) Int4Array.

It may already exist in which case it will be re-used if possible. It may be created in either session or shared memory depending on the value of shared.

Parameters
currentPointer to an existing Int4Array if one exists.
sharedWhether to create the variable in shared or session memory.
minIndex of the first entry in the array.
maxIndex of the last entry in the array.

Definition at line 246 of file veil_variables.c.

References Int4Array::arraymax, Int4Array::arrayzero, Int4Array::type, vl_ClearInt4Array(), vl_malloc(), and vl_shmalloc().

Referenced by veil_init_int4array().

◆ vl_Int4ArraySet()

void vl_Int4ArraySet ( Int4Array array,
int32  idx,
int32  value 
)

Set an entry within an Int4Array.

If idx is outside of the acceptable range, raise an error.

Parameters
arrayThe Int4Array within which the entry is to be set.
idxThe index of the entry to be set.
valueThe value to which the entry will be set.

Definition at line 290 of file veil_variables.c.

References Int4Array::array, Int4Array::arraymax, and Int4Array::arrayzero.

Referenced by veil_int4array_set().

◆ vl_Int4ArrayGet()

int32 vl_Int4ArrayGet ( Int4Array array,
int32  idx 
)

Get an entry from an Int4Array.

If idx is outside of the acceptable range, raise an error.

Parameters
arrayThe Int4Array within from the entry is to be read.
idxThe index of the entry to be retrieved.
Returns
The value of the entry

Definition at line 314 of file veil_variables.c.

References Int4Array::array, Int4Array::arraymax, and Int4Array::arrayzero.

Referenced by veil_int4array_get().

◆ vl_NewRange()

Range* vl_NewRange ( bool  shared)

Create a new session or shared Range object.

Parameters
sharedWhether the object is to be created in shared (true) or session (false) memory.
Returns
Pointer to newly created object.

Definition at line 28 of file veil_datatypes.c.

References Range::type, vl_malloc(), and vl_shmalloc().

◆ vl_NewInt4()

Int4Var* vl_NewInt4 ( bool  shared)

Create a new session or shared Int4Var object.

Parameters
sharedWhether the object is to be created in shared (true) or session (false) memory.
Returns
Pointer to newly created object.

Definition at line 52 of file veil_datatypes.c.

References Int4Var::type, vl_malloc(), and vl_shmalloc().

◆ vl_ClearBitmap()

void vl_ClearBitmap ( Bitmap bitmap)

Clear all bits in a Bitmap.

Parameters
bitmapThe Bitmap in which all bits are to be cleared

Definition at line 73 of file veil_bitmap.c.

References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitset, and Bitmap::bitzero.

Referenced by veil_clear_bitmap(), veil_intersect_from_bitmap_hash(), vl_ClearBitmapArray(), and vl_NewBitmap().

◆ vl_NewBitmap()

void vl_NewBitmap ( Bitmap **  p_bitmap,
bool  shared,
int32  min,
int32  max 
)

Return a newly initialised (empty) Bitmap.

The bitmap may already exist in which case it will be re-used if possible. The bitmap may be created in either session or shared memory depending on the value of shared.

Parameters
p_bitmapPointer to an existing bitmap if one exists
sharedWhether to create the bitmap in shared memory
minThe smallest bit to be stored in the bitmap
maxThe largest bit to be stored in the bitmap

Definition at line 95 of file veil_bitmap.c.

References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitzero, DBG_SET_CANARY, DBG_SET_ELEMS, DBG_SET_TRAILER, Bitmap::type, vl_ClearBitmap(), vl_free(), vl_malloc(), and vl_shmalloc().

Referenced by veil_init_bitmap(), and vl_NewBitmapArray().

◆ vl_BitmapSetbit()

void vl_BitmapSetbit ( Bitmap bitmap,
int32  bit 
)

Set a bit within a Bitmap.

If the bit is outside of the acceptable range, raise an error.

Parameters
bitmapThe Bitmap within which the bit is to be set.
bitThe bit to be set.

Definition at line 151 of file veil_bitmap.c.

References bitmasks, Bitmap::bitmax, Bitmap::bitset, BITSET_BIT, BITSET_ELEM, BITZERO, Bitmap::bitzero, DBG_CHECK_INDEX, DBG_TEST_CANARY, and DBG_TEST_TRAILER.

Referenced by veil_bitmap_array_setbit(), veil_bitmap_hash_setbit(), and veil_bitmap_setbit().

◆ vl_BitmapClearbit()

void vl_BitmapClearbit ( Bitmap bitmap,
int32  bit 
)

Clear a bit within a Bitmap.

If the bit is outside of the acceptable range, raise an error.

Parameters
bitmapThe Bitmap within which the bit is to be cleared.
bitThe bit to be cleared.

Definition at line 181 of file veil_bitmap.c.

References bitmasks, Bitmap::bitmax, Bitmap::bitset, BITSET_BIT, BITSET_ELEM, BITZERO, and Bitmap::bitzero.

Referenced by veil_bitmap_array_clearbit(), veil_bitmap_clearbit(), and veil_bitmap_hash_clearbit().

◆ vl_BitmapTestbit()

bool vl_BitmapTestbit ( Bitmap bitmap,
int32  bit 
)

Test a bit within a Bitmap.

If the bit is outside of the acceptable range return false.

Parameters
bitmapThe Bitmap within which the bit is to be set.
bitThe bit to be tested.
Returns
True if the bit is set, false otherwise.

Definition at line 210 of file veil_bitmap.c.

References bitmasks, Bitmap::bitmax, Bitmap::bitset, BITSET_BIT, BITSET_ELEM, BITZERO, and Bitmap::bitzero.

Referenced by veil_bitmap_array_testbit(), veil_bitmap_hash_testbit(), veil_bitmap_testbit(), and vl_BitmapNextBit().

◆ vl_BitmapUnion()

void vl_BitmapUnion ( Bitmap target,
Bitmap source 
)

Create the union of two bitmaps, updating the first with the result.

Parameters
targetThe Bitmap into which the result will be placed.
sourceThe Bitmap to be unioned into target.

Definition at line 232 of file veil_bitmap.c.

References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitset, and Bitmap::bitzero.

Referenced by veil_bitmap_union(), veil_union_from_bitmap_array(), veil_union_from_bitmap_hash(), and veil_union_into_bitmap_hash().

◆ vl_BitmapIntersect()

void vl_BitmapIntersect ( Bitmap target,
Bitmap source 
)

Create the intersection of two bitmaps, updating the first with the result.

Parameters
targetThe Bitmap into which the result will be placed.
sourceThe Bitmap to be intersected into target.

Definition at line 262 of file veil_bitmap.c.

References ARRAYELEMS, Bitmap::bitmax, Bitmap::bitset, and Bitmap::bitzero.

Referenced by veil_bitmap_intersect(), veil_intersect_from_bitmap_array(), and veil_intersect_from_bitmap_hash().

◆ vl_BitmapNextBit()

int32 vl_BitmapNextBit ( Bitmap bitmap,
int32  bit,
bool *  found 
)

Return the next set bit in the Bitmap.

Parameters
bitmapThe Bitmap being scanned.
bitThe starting bit from which to scan the bitmap
foundBoolean that will be set to true when a set bit has been found.
Returns
The bit id of the found bit, or zero if no set bits were found.

Definition at line 295 of file veil_bitmap.c.

References vl_BitmapTestbit().

Referenced by veil_bitmap_array_bits(), veil_bitmap_bits(), and veil_bitmap_hash_bits().

◆ vl_BitmapFromArray()

Bitmap* vl_BitmapFromArray ( BitmapArray bmarray,
int32  elem 
)

Return a specified Bitmap from a BitmapArray.

Parameters
bmarrayThe BitmapArray from which the result is to be returned.
elemThe index of the Bitmap within the array.
Returns
The bitmap corresponding to the parameters, or NULL if no such entry exists within the array.

Definition at line 321 of file veil_bitmap.c.

References BitmapArray::arraymax, BitmapArray::arrayzero, BitmapArray::bitmap, DBG_CHECK_INDEX, DBG_TEST_CANARY, and DBG_TEST_TRAILER.

Referenced by veil_bitmap_array_bits(), 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().

◆ vl_ClearBitmapArray()

void vl_ClearBitmapArray ( BitmapArray bmarray)

Clear all bitmaps in the given BitmapArray.

Parameters
bmarrayThe BitmapArray to be cleared

Definition at line 341 of file veil_bitmap.c.

References BitmapArray::arraymax, BitmapArray::arrayzero, BitmapArray::bitmap, DBG_CHECK_INDEX, DBG_TEST_CANARY, DBG_TEST_TRAILER, and vl_ClearBitmap().

Referenced by veil_clear_bitmap_array(), and vl_NewBitmapArray().

◆ vl_NewBitmapArray()

void vl_NewBitmapArray ( BitmapArray **  p_bmarray,
bool  shared,
int32  arrayzero,
int32  arraymax,
int32  bitzero,
int32  bitmax 
)

Return a newly initialised (empty) BitmapArray.

It may already exist in which case it will be re-used if possible. It may be created in either session or shared memory depending on the value of shared.

Parameters
p_bmarrayPointer to an existing bitmap if one exists.
sharedWhether to create the bitmap in shared memory
arrayzeroThe lowest array index
arraymaxThe highest array index
bitzeroThe smallest bit to be stored in the bitmap
bitmaxThe largest bit to be stored in the bitmap

Definition at line 368 of file veil_bitmap.c.

References ARRAYELEMS, BitmapArray::arraymax, BitmapArray::arrayzero, BitmapArray::bitmap, BitmapArray::bitmax, BitmapArray::bitzero, DBG_TEST_CANARY, DBG_TEST_TRAILER, BitmapArray::type, vl_ClearBitmapArray(), vl_free(), vl_malloc(), vl_NewBitmap(), and vl_shmalloc().

Referenced by veil_init_bitmap_array().

◆ vl_NextHashEntry()

VarEntry* vl_NextHashEntry ( HTAB *  hash,
VarEntry prev 
)

Utility function for scanning the hash table of a BitmapHash.

Parameters
hashThe hash table being scanned
prevThe entry from which to scan, starting with NULL.
Returns
The next element in the hash table (a VarEntry) or NULL when the last element has already been scanned.

Definition at line 474 of file veil_bitmap.c.

Referenced by serialise_bitmap_hash(), sizeof_bitmaps_in_hash(), veil_bitmap_hash_entries(), and vl_NewBitmapHash().

◆ vl_NewBitmapHash()

void vl_NewBitmapHash ( BitmapHash **  p_bmhash,
char *  name,
int32  bitzero,
int32  bitmax 
)

Return a newly initialised (empty) BitmapHash.

It may already exist in which case it will be re-used if possible. BitmapHash variables may only be created as session (not shared) variables.

Parameters
p_bmhashPointer to an existing bitmap if one exists.
nameThe name to be used for the hash table
bitzeroThe smallest bit to be stored in the bitmap
bitmaxThe largest bit to be stored in the bitmap

Definition at line 499 of file veil_bitmap.c.

References BitmapHash::hash, VarEntry::obj, Object::type, and vl_NextHashEntry().

Referenced by veil_clear_bitmap_hash(), and veil_init_bitmap_hash().

◆ vl_BitmapFromHash()

Bitmap* vl_BitmapFromHash ( BitmapHash bmhash,
char *  hashelem 
)

Return a specified Bitmap from a BitmapHash.

Raise an error if the returned object from the hash search is not a bitmap.

Parameters
bmhashThe BitmapHash from which the result is to be returned.
hashelemThe key of the Bitmap within the hash.
Returns
The bitmap corresponding to the parameters, or NULL if no such entry exists within the hash.

Definition at line 548 of file veil_bitmap.c.

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

Referenced by veil_bitmap_hash_bits(), veil_bitmap_hash_testbit(), veil_intersect_from_bitmap_hash(), and veil_union_from_bitmap_hash().

◆ vl_AddBitmapToHash()

Bitmap* vl_AddBitmapToHash ( BitmapHash bmhash,
char *  hashelem 
)

Create a newly allocated empty Bitmap to a BitmapHash.

Parameters
bmhashThe BitmapHash to which to add the new Bitmap.
hashelemThe key for the new entry
Returns
Pointer to the newly allocated empty Bitmap.

Definition at line 588 of file veil_bitmap.c.

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

Referenced by veil_bitmap_from_hash(), veil_bitmap_hash_clearbit(), veil_bitmap_hash_setbit(), and veil_union_into_bitmap_hash().

◆ vl_BitmapHashHasKey()

bool vl_BitmapHashHasKey ( BitmapHash bmhash,
char *  hashelem 
)

Determine whether the supplied key exists in the BitmapHash.

Parameters
bmhashThe BitmapHash to be tested
hashelemThe key to be tested
Returns
True if the key already exists in the hash.

Definition at line 629 of file veil_bitmap.c.

References BitmapHash::hash.

Referenced by veil_bitmap_hash_key_exists().

◆ vl_get_shared_hash()

HTAB* vl_get_shared_hash ( void  )

Return the shared hash for the current context.

Returns
Pointer to the HTAB for the current context's shared hash.

Definition at line 552 of file veil_shmem.c.

References get_cur_context(), get_cur_context_id(), get_hash0(), and get_hash1().

Referenced by ensure_init(), vl_lookup_shared_variable(), vl_lookup_variable(), and vl_next_variable().

◆ vl_prepare_context_switch()

bool vl_prepare_context_switch ( void  )

Prepare for a switch to the alternate context.

Switching will only be allowed if there are no transactions that may still be using the context to which we are switching, and there is no other process attempting the switch.

Returns
true if the switch preparation was successful.

Definition at line 604 of file veil_shmem.c.

References clear_hash(), ShmemCtl::context, ShmemCtl::current_context, get_cur_context(), get_hash0(), get_hash1(), MemContext::next, OTHER_CONTEXT, prepared_for_switch, ShmemCtl::switching, VeilLWLock, and ShmemCtl::xid.

Referenced by veil_perform_reset().

◆ vl_complete_context_switch()

bool vl_complete_context_switch ( void  )

Complete the context switch started by vl_prepare_context_switch().

Raise an ERROR if the context switch cannot be completed.

Returns
true if the context switch is successfully completed.

Definition at line 678 of file veil_shmem.c.

References ShmemCtl::current_context, OTHER_CONTEXT, prepared_for_switch, ShmemCtl::switching, VeilLWLock, and ShmemCtl::xid.

Referenced by veil_perform_reset().

◆ vl_shmalloc()

void* vl_shmalloc ( size_t  size)

Dynamically allocate a piece of shared memory from the current context.

Parameters
sizeThe size of the requested piece of memory.
Returns
Pointer to dynamically allocated memory.

Definition at line 414 of file veil_shmem.c.

References do_vl_shmalloc(), get_cur_context(), and VeilLWLock.

Referenced by vl_NewBitmap(), vl_NewBitmapArray(), vl_NewInt4(), vl_NewInt4Array(), and vl_NewRange().

◆ vl_free()

void vl_free ( void *  mem)

Free a piece of shared memory within the current context.

Currently this does nothing as implementation of freeing of shared memory has been deferred.

Parameters
memPointer to the memory to be freed.

Definition at line 437 of file veil_shmem.c.

Referenced by vl_NewBitmap(), and vl_NewBitmapArray().

◆ _PG_init()

void _PG_init ( void  )

Veil's startup function.

This should be run when the Veil shared library is loaded by postgres.

Definition at line 141 of file veil_shmem.c.

References InitialLWLock, TRANCHE_NAME, veil_config_init(), veil_dbs_in_cluster(), veil_shmem_context_size(), and VeilLWLock.

◆ vl_spi_connect()

int vl_spi_connect ( bool *  p_pushed)

If already connected in this session, push the current connection, and get a new one.

We are already connected, if:

  • are within a query
  • and the current transaction id matches the saved transaction id

Definition at line 46 of file veil_query.c.

Referenced by ensure_init(), exec_init_fn(), veil_perform_reset(), and vl_call_init_fns().

◆ vl_bool_from_query()

bool vl_bool_from_query ( const char *  qry,
bool *  result 
)

Executes a query that returns a single bool value.

Parameters
qryThe text of the query to be performed.
resultVariable into which the result of the query will be placed.
Returns
true if the query returned a record, false otherwise.

Definition at line 232 of file veil_query.c.

References fetch_one_bool(), and query().

Referenced by ensure_init(), exec_init_fn(), and veil_perform_reset().

◆ vl_db_exists()

bool vl_db_exists ( Oid  db_id)

Determine whether the given oid represents an existing database or not.

Parameters
db_idOid of the database in which we are interested.
Returns
True if the database exists.

Definition at line 275 of file veil_query.c.

References str_from_oid_query().

Referenced by get_shmem_context().

◆ vl_call_init_fns()

int vl_call_init_fns ( bool  param)

Identify any registered init_functions and execute them.

Parameters
paramThe boolean parameter to be passed to each init_function.
Returns
The number of init_functions executed.

Definition at line 336 of file veil_query.c.

References exec_init_fn(), query(), vl_spi_connect(), and vl_spi_finish().

Referenced by veil_init().

◆ veil_shared_hash_elems()

int veil_shared_hash_elems ( void  )

Return the number of entries that should be allocated for shared variables in our shared hashes.

This defaults to 32 and may be defined in postgresql.conf using eg: "veil.shared_hash_elems = 64"

Definition at line 65 of file veil_config.c.

References shared_hash_elems, and veil_load_config().

Referenced by create_shared_hash().

◆ veil_dbs_in_cluster()

int veil_dbs_in_cluster ( void  )

Return the number of databases, within the database cluster, that will use Veil.

Each such database will be allocated 2 chunks of shared memory (of shmem_context_size), and a single LWLock. It defaults to 1 and may be defined in postgresql.conf using eg: "veil.dbs_in_cluster = 2"

Definition at line 52 of file veil_config.c.

References dbs_in_cluster, and veil_load_config().

Referenced by _PG_init(), and get_shmem_context().

◆ veil_shmem_context_size()

int veil_shmem_context_size ( void  )

Return the amount of shared memory to be requested for each of the two shared memory contexts.

This variable has no effect unless shared_preload_libraries has been defined in postgresql.conf to load the Veil shared library Note that this must be large enough to allocate at least one chunk of memory for each veil-using database in the Postgres cluster. It defaults to 16K and may be defined in postgresql.conf using eg: "veil.shmem_context_size = 16384"

Definition at line 82 of file veil_config.c.

References shmem_context_size, and veil_load_config().

Referenced by _PG_init(), and shmalloc_init().

◆ 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().

◆ 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().

◆ 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_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_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_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().

◆ vl_serialise_var()

char* vl_serialise_var ( char *  name)

Serialise a veil variable.

Parameters
nameThe name of the variable to be serialised.
Returns
Dynamically allocated string containing the serialised value.

Definition at line 911 of file veil_serialise.c.

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

Referenced by veil_serialise().

◆ vl_deserialise()

int32 vl_deserialise ( char **  p_stream)

De-serialise a base64 string containing, possibly many, derialised veil variables.

Parameters
**p_streamPointer into the stream currently being read.
Returns
A count of the number of variables that have been de-serialised.

Definition at line 996 of file veil_serialise.c.

References vl_deserialise_next().

Referenced by veil_deserialise().

◆ vl_deserialise_next()

VarEntry* vl_deserialise_next ( char **  p_stream)

De-serialise the next veil variable from *p_stream.

Parameters
**p_streamPointer into the stream currently being read. pointer is updated to point to the next free slot in the stream after reading the stream
Returns
The deserialised variable.

Definition at line 958 of file veil_serialise.c.

References deserialise_bitmap(), deserialise_bitmap_array(), deserialise_bitmap_hash(), deserialise_char(), deserialise_int4array(), deserialise_int4var(), and deserialise_range().

Referenced by vl_deserialise().