veil_funcs.h File Reference


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.

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

Include dependency graph for veil_funcs.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void * vl_malloc (size_t size)
 Dynamically allocate memory using palloc in TopMemoryContext.
char * vl_ObjTypeName (ObjType obj)
 Return a static string describing an ObjType object.
VarEntryvl_lookup_shared_variable (char *name)
 Define a new, or attach to an existing, shared variable.
VarEntryvl_lookup_variable (char *name)
 Lookup a variable by name, creating it as as a session variable if it does not already exist.
veil_variable_tvl_next_variable (veil_variable_t *prev)
 Return the next variable from a scan of the hash of variables.
void vl_ClearInt4Array (Int4Array *array)
 Reset all Int4 entries in an Int4Array (to zero).
Int4Arrayvl_NewInt4Array (Int4Array *current, bool shared, int32 min, int32 max)
 Return a newly initialised (zeroed) Int4Array.
void vl_Int4ArraySet (Int4Array *array, int32 idx, int32 value)
 Set an entry within an Int4Array.
int32 vl_Int4ArrayGet (Int4Array *array, int32 idx)
 Get an entry from an Int4Array.
Rangevl_NewRange (bool shared)
 Create a new session or shared Range object.
Int4Varvl_NewInt4 (bool shared)
 Create a new session or shared Int4Var object.
void vl_ClearBitmap (Bitmap *bitmap)
 Clear all bits in a Bitmap.
void vl_NewBitmap (Bitmap **p_bitmap, bool shared, int32 min, int32 max)
 Return a newly initialised (empty) Bitmap.
void vl_BitmapSetbit (Bitmap *bitmap, int32 bit)
 Set a bit within a Bitmap.
void vl_BitmapClearbit (Bitmap *bitmap, int32 bit)
 Clear a bit within a Bitmap.
bool vl_BitmapTestbit (Bitmap *bitmap, int32 bit)
 Test a bit within a Bitmap.
void vl_BitmapUnion (Bitmap *target, Bitmap *source)
 Create the union of two bitmaps, updating the first with the result.
void vl_BitmapIntersect (Bitmap *target, Bitmap *source)
 Create the intersection of two bitmaps, updating the first with the result.
int32 vl_BitmapNextBit (Bitmap *bitmap, int32 bit, bool *found)
 Return the next set bit in the Bitmap.
Bitmapvl_BitmapFromArray (BitmapArray *bmarray, int32 elem)
 Return a specified Bitmap from a BitmapArray.
void vl_ClearBitmapArray (BitmapArray *bmarray)
 Clear all bitmaps in the given BitmapArray.
void vl_NewBitmapArray (BitmapArray **p_bmarray, bool shared, int32 arrayzero, int32 arraymax, int32 bitzero, int32 bitmax)
 Return a newly initialised (empty) BitmapArray.
VarEntryvl_NextHashEntry (HTAB *hash, VarEntry *prev)
 Utility function for scanning the hash table of a BitmapHash.
void vl_NewBitmapHash (BitmapHash **p_bmhash, char *name, int32 bitzero, int32 bitmax)
 Return a newly initialised (empty) BitmapHash.
Bitmapvl_BitmapFromHash (BitmapHash *bmhash, char *hashelem)
 Return a specified Bitmap from a BitmapHash.
Bitmapvl_AddBitmapToHash (BitmapHash *bmhash, char *hashelem)
 Create a newly allocated empty Bitmap to a BitmapHash.
bool vl_BitmapHashHasKey (BitmapHash *bmhash, char *hashelem)
 Determine whether the supplied key exists in the BitmapHash.
HTAB * vl_get_shared_hash (void)
 Return the shared hash for the current context.
bool vl_prepare_context_switch (void)
 Prepare for a switch to the alternate context.
bool vl_complete_context_switch (void)
 Complete the context switch started by vl_prepare_context_switch().
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.
void vl_free (void *mem)
 Free a piece of shared memory within the current context.
void _PG_init (void)
 Veil's startup function.
int vl_spi_connect (bool *p_pushed)
 If already connected in this session, push the current connection, and get a new one.
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.
bool vl_db_exists (Oid db_id)
 Determine whether the given oid represents an existing database or not.
int vl_call_init_fns (bool param)
 Identify any registered init_functions and execute them.
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.
int veil_dbs_in_cluster (void)
 Return the number of databases, within the database cluster, that will use Veil.
int veil_shmem_context_size (void)
 Return the amount of shared memory to be requested for each of the two shared memory contexts.
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.
Datum veil_variables (FunctionCallInfo fcinfo)
 veil_variables() returns setof veil_variable_t Return a veil_variable_t record for each defined variable.
Datum veil_share (FunctionCallInfo fcinfo)
 veil_share(name text) returns bool Define a shared variable called NAME, returning true.
Datum veil_init_range (FunctionCallInfo fcinfo)
 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.
Datum veil_range (FunctionCallInfo fcinfo)
 veil_range(name text) returns veil_range_t Return the range (as a SQL veil_range_t composite type) from the named variable.
Datum veil_init_bitmap (FunctionCallInfo fcinfo)
 veil_init_bitmap(bitmap_name text, range_nametext) returns bool Create or re-initialise a Bitmap, for dealing with a named range of values.
Datum veil_clear_bitmap (FunctionCallInfo fcinfo)
 veil_clear_bitmap(name text) returns bool Clear all bits in the specified Bitmap.
Datum veil_bitmap_setbit (FunctionCallInfo fcinfo)
 veil_bitmap_setbit(name text, bit_number int4) returns bool Set the specified bit in the specified Bitmap.
Datum veil_bitmap_clearbit (FunctionCallInfo fcinfo)
 veil_bitmap_clearbit(name int4, bit_number text) returns bool Clear the specified bit in the specified Bitmap.
Datum veil_bitmap_testbit (FunctionCallInfo fcinfo)
 veil_bitmap_testbit(name text, bit_number int4) returns bool Test the specified bit in the specified Bitmap, returning true if it is set.
Datum veil_bitmap_union (FunctionCallInfo fcinfo)
 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.
Datum veil_bitmap_intersect (FunctionCallInfo fcinfo)
 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.
Datum veil_bitmap_bits (FunctionCallInfo fcinfo)
 veil_bitmap_bits(name text) returns setof int4 Return the set of all bits set in the specified Bitmap or BitmapRef.
Datum veil_bitmap_range (FunctionCallInfo fcinfo)
 veil_bitmap_range(name text) returns veil_range_t Return composite type giving the range of the specified Bitmap or BitmapRef.
Datum veil_init_bitmap_array (FunctionCallInfo fcinfo)
 veil_init_bitmap_array(text, text, text) returns bool Create or reset a BitmapArray.
Datum veil_clear_bitmap_array (FunctionCallInfo fcinfo)
 veil_clear_bitmap_array(bmarray text) returns bool Clear the bits in an existing BitmapArray.
Datum veil_bitmap_from_array (FunctionCallInfo fcinfo)
 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.
Datum veil_bitmap_array_testbit (FunctionCallInfo fcinfo)
 veil_bitmap_array_testbit(bmarray text, arr_idx int4, bitno int4) returns bool Test a specified bit within a BitmapArray
Datum veil_bitmap_array_setbit (FunctionCallInfo fcinfo)
 veil_bitmap_array_setbit(bmarray text, arr_idx int4, bitno int4) returns bool Set a specified bit within a BitmapArray
Datum veil_bitmap_array_clearbit (FunctionCallInfo fcinfo)
 veil_bitmap_array_clearbit(bmarray text, arr_idx int4, bitno int4) returns bool Clear a specified bit within a BitmapArray
Datum veil_union_from_bitmap_array (FunctionCallInfo fcinfo)
 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.
Datum veil_intersect_from_bitmap_array (FunctionCallInfo fcinfo)
 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.
Datum veil_bitmap_array_bits (FunctionCallInfo fcinfo)
 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.
Datum veil_bitmap_array_arange (FunctionCallInfo fcinfo)
 veil_bitmap_array_arange(bmarray text) returns veil_range_t Return composite type giving the range of the array part of the specified BitmapArray
Datum veil_bitmap_array_brange (FunctionCallInfo fcinfo)
 veil_bitmap_array_brange(bmarray text) returns veil_range_t Return composite type giving the range of every Bitmap within the BitmapArray.
Datum veil_init_bitmap_hash (FunctionCallInfo fcinfo)
 veil_init_bitmap_hash(bmhash text, range text) returns bool Create or reset a BitmapHash.
Datum veil_clear_bitmap_hash (FunctionCallInfo fcinfo)
 veil_clear_bitmap_hash(bmhash text) returns bool Clear the bits in an existing BitmapHash.
Datum veil_bitmap_hash_key_exists (FunctionCallInfo fcinfo)
 veil_bitmap_hashkey_exists(bmhash text, key text) returns bool Return true if the key exists in the bitmap hash.
Datum veil_bitmap_from_hash (FunctionCallInfo fcinfo)
 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.
Datum veil_bitmap_hash_testbit (FunctionCallInfo fcinfo)
 veil_bitmap_hash_testbit(bmhash text, key text, bitno int4) returns bool Test a specified bit within a BitmapHash
Datum veil_bitmap_hash_setbit (FunctionCallInfo fcinfo)
 veil_bitmap_hash_setbit(bmhash text, key text, bitno int4) returns bool Set a specified bit within a BitmapHash
Datum veil_bitmap_hash_clearbit (FunctionCallInfo fcinfo)
 veil_bitmap_hash_clearbit(bmhash text, key text, bitno int4) returns bool Clear a specified bit within a BitmapHash
Datum veil_union_into_bitmap_hash (FunctionCallInfo fcinfo)
 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.
Datum veil_union_from_bitmap_hash (FunctionCallInfo fcinfo)
 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.
Datum veil_intersect_from_bitmap_hash (FunctionCallInfo fcinfo)
 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.
Datum veil_bitmap_hash_bits (FunctionCallInfo fcinfo)
 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.
Datum veil_bitmap_hash_entries (FunctionCallInfo fcinfo)
 veil_bitmap_hash_entries(bmhash text) returns setof text Return the key of every Bitmap within the BitmapHash.
Datum veil_bitmap_hash_range (FunctionCallInfo fcinfo)
 veil_bitmap_hash_range(bmhash text) returns veil_range_t Return composite type giving the range of every Bitmap within the BitmapHash.
Datum veil_int4_set (FunctionCallInfo fcinfo)
 veil_int4_set(name text,value int4) returns int4 Set an Int4Var variable type to a specified value.
Datum veil_int4_get (FunctionCallInfo fcinfo)
 veil_int4_get(name text) returns int4 Return the value of an Int4Var variable.
Datum veil_init_int4array (FunctionCallInfo fcinfo)
 veil_init_int4array(arrayname text, range text) returns bool Initialise an Int4Array variable.
Datum veil_clear_int4array (FunctionCallInfo fcinfo)
 veil_clear_int4array(name text) returns bool Clear an Int4Array variable.
Datum veil_int4array_set (FunctionCallInfo fcinfo)
 veil_int4array_set(array text, idx int4, value int4) returns int4 Set an Int4Array entry.
Datum veil_int4array_get (FunctionCallInfo fcinfo)
 veil_int4array_get(array text, idx int4) returns int4 Get an Int4Array entry.
Datum veil_init (FunctionCallInfo fcinfo)
 veil_init(doing_reset bool) returns bool Initialise or reset a veil session.
Datum veil_perform_reset (FunctionCallInfo fcinfo)
 veil_perform_reset() returns bool Reset veil shared memory for this database.
Datum veil_force_reset (FunctionCallInfo fcinfo)
 veil_force_reset() returns bool Reset veil shared memory for this database, ignoring existing transactions.
Datum veil_version (FunctionCallInfo fcinfo)
 veil_version() returns text Return a string describing this version of veil.
Datum veil_serialise (FunctionCallInfo fcinfo)
 veil_serialise(varname text) returns text Return a string representing the contents of our variable.
Datum veil_deserialise (FunctionCallInfo fcinfo)
 veil_deserialise(stream text) returns text Create or reset variables based on the output of previous veil_serialise calls.
char * vl_serialise_var (char *name)
 Serialise a veil variable.
int4 vl_deserialise (char **p_stream)
 De-serialise a base64 string containing, possibly many, derialised veil variables.
VarEntryvl_deserialise_next (char **p_stream)
 De-serialise the next veil variable from *p_stream.


Function Documentation

void* vl_malloc ( size_t  size  ) 

Dynamically allocate memory using palloc in TopMemoryContext.

Parameters:
size The 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_NewInt4(), and vl_NewRange().

char* vl_ObjTypeName ( ObjType  obj  ) 

Return a static string describing an ObjType object.

Parameters:
obj The 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_type_mismatch().

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:
name The 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().

Here is the call graph for this function:

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:
name The 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 124 of file veil_variables.c.

Referenced by deserialise_bitmap(), deserialise_bitmap_array(), deserialise_bitmap_hash(), deserialise_int4array(), deserialise_int4var(), deserialise_range(), veil_int4_get(), and vl_serialise_var().

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:
prev The 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 170 of file veil_variables.c.

References create_session_hash(), and session_hash.

Here is the call graph for this function:

void vl_ClearInt4Array ( Int4Array array  ) 

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

Parameters:
array The array to be reset.

Definition at line 227 of file veil_variables.c.

References Int4Array::array.

Referenced by 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:
current Pointer to an existing Int4Array if one exists.
shared Whether to create the variable in shared or session memory.
min Index of the first entry in the array.
max Index of the last entry in the array.

Definition at line 249 of file veil_variables.c.

References Int4Array::arraymax, Int4Array::arrayzero, and vl_ClearInt4Array().

Referenced by deserialise_int4array(), and veil_int4_get().

Here is the call graph for this function:

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:
array The Int4Array within which the entry is to be set.
idx The index of the entry to be set.
value The value to which the entry will be set.

Definition at line 293 of file veil_variables.c.

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

Referenced by veil_clear_int4array().

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:
array The Int4Array within from the entry is to be read.
idx The index of the entry to be retrieved.
Returns:
The value of the entry

Definition at line 318 of file veil_variables.c.

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

Referenced by veil_int4array_set().

Range* vl_NewRange ( bool  shared  ) 

Create a new session or shared Range object.

Parameters:
shared Whether 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().

Referenced by deserialise_range().

Here is the call graph for this function:

Int4Var* vl_NewInt4 ( bool  shared  ) 

Create a new session or shared Int4Var object.

Parameters:
shared Whether 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::isnull, Int4Var::type, vl_malloc(), and vl_shmalloc().

Referenced by deserialise_int4var().

Here is the call graph for this function:

void vl_ClearBitmap ( Bitmap bitmap  ) 

Clear all bits in a Bitmap.

Parameters:
bitmap The Bitmap in which all bits are to be cleared

Definition at line 41 of file veil_bitmap.c.

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

Referenced by 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_bitmap Pointer to an existing bitmap if one exists
shared Whether to create the bitmap in shared memory
min The smallest bit to be stored in the bitmap
max The largest bit to be stored in the bitmap

Definition at line 63 of file veil_bitmap.c.

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

Referenced by deserialise_one_bitmap().

Here is the call graph for this function:

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:
bitmap The Bitmap within which the bit is to be set.
bit The bit to be set.

Definition at line 121 of file veil_bitmap.c.

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

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:
bitmap The Bitmap within which the bit is to be cleared.
bit The bit to be cleared.

Definition at line 155 of file veil_bitmap.c.

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

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:
bitmap The Bitmap within which the bit is to be set.
bit The bit to be tested.
Returns:
True if the bit is set, false otherwise.

Definition at line 185 of file veil_bitmap.c.

void vl_BitmapUnion ( Bitmap target,
Bitmap source 
)

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

Parameters:
target The Bitmap into which the result will be placed.
source The Bitmap to be unioned into target.

Definition at line 207 of file veil_bitmap.c.

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

Referenced by deserialise_bitmap_hash().

void vl_BitmapIntersect ( Bitmap target,
Bitmap source 
)

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

Parameters:
target The Bitmap into which the result will be placed.
source The Bitmap to be intersected into target.

Definition at line 238 of file veil_bitmap.c.

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

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

Return the next set bit in the Bitmap.

Parameters:
bitmap The Bitmap being scanned.
bit The starting bit from which to scan the bitmap
found Boolean 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 272 of file veil_bitmap.c.

Bitmap* vl_BitmapFromArray ( BitmapArray bmarray,
int32  elem 
)

Return a specified Bitmap from a BitmapArray.

Parameters:
bmarray The BitmapArray from which the result is to be returned.
elem The 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 298 of file veil_bitmap.c.

Referenced by veil_bitmap_array_bits().

void vl_ClearBitmapArray ( BitmapArray bmarray  ) 

Clear all bitmaps in the given BitmapArray.

Parameters:
bmarray The BitmapArray to be cleared

Definition at line 321 of file veil_bitmap.c.

References ARRAYELEMS, BitmapArray::arraymax, BitmapArray::arrayzero, BitmapArray::bitmax, BitmapArray::bitzero, and DBG_TEST_CANARY.

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_bmarray Pointer to an existing bitmap if one exists.
shared Whether to create the bitmap in shared memory
arrayzero The lowest array index
arraymax The highest array index
bitzero The smallest bit to be stored in the bitmap
bitmax The largest bit to be stored in the bitmap

Definition at line 351 of file veil_bitmap.c.

Referenced by deserialise_bitmap_array().

VarEntry* vl_NextHashEntry ( HTAB *  hash,
VarEntry prev 
)

Utility function for scanning the hash table of a BitmapHash.

Parameters:
hash The hash table being scanned
prev The 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 459 of file veil_bitmap.c.

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

Referenced by serialise_bitmap_hash(), sizeof_bitmaps_in_hash(), and vl_NextHashEntry().

Here is the call graph for this function:

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_bmhash Pointer to an existing bitmap if one exists.
name The name to be used for the hash table
bitzero The smallest bit to be stored in the bitmap
bitmax The largest bit to be stored in the bitmap

Definition at line 484 of file veil_bitmap.c.

Referenced by deserialise_bitmap_hash().

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:
bmhash The BitmapHash from which the result is to be returned.
hashelem The 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 534 of file veil_bitmap.c.

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

Bitmap* vl_AddBitmapToHash ( BitmapHash bmhash,
char *  hashelem 
)

Create a newly allocated empty Bitmap to a BitmapHash.

Parameters:
bmhash The BitmapHash to which to add the new Bitmap.
hashelem The key for the new entry
Returns:
Pointer to the newly allocated empty Bitmap.

Definition at line 576 of file veil_bitmap.c.

Referenced by deserialise_bitmap_hash().

bool vl_BitmapHashHasKey ( BitmapHash bmhash,
char *  hashelem 
)

Determine whether the supplied key exists in the BitmapHash.

Parameters:
bmhash The BitmapHash to be tested
hashelem The key to be tested
Returns:
True if the key already exists in the hash.

Definition at line 619 of file veil_bitmap.c.

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 511 of file veil_shmem.c.

References get_cur_context().

Referenced by ensure_init(), and vl_lookup_shared_variable().

Here is the call graph for this function:

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 563 of file veil_shmem.c.

Referenced by veil_init().

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 637 of file veil_shmem.c.

void* vl_shmalloc ( size_t  size  ) 

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

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

Definition at line 376 of file veil_shmem.c.

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

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:
mem Pointer to the memory to be freed.

Definition at line 399 of file veil_shmem.c.

Referenced by vl_NewBitmap().

void _PG_init ( void   ) 

Veil's startup function.

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

If shared_preload_libraries is not defined, Veil may still be run but it will steal shared memory from postgres, potentially exhausting it.

Definition at line 111 of file veil_shmem.c.

References veil_config_init(), veil_dbs_in_cluster(), and veil_shmem_context_size().

Here is the call graph for this function:

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(), and veil_init().

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

Executes a query that returns a single bool value.

Parameters:
qry The text of the query to be performed.
result Variable into which the result of the query will be placed.
Returns:
true if the query returned a record, false otherwise.

Definition at line 234 of file veil_query.c.

References fetch_one_bool(), and query().

Referenced by ensure_init(), and veil_init().

Here is the call graph for this function:

bool vl_db_exists ( Oid  db_id  ) 

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

Parameters:
db_id Oid of the database in which we are interested.
Returns:
True if the database exists.

Definition at line 277 of file veil_query.c.

Referenced by get_shmem_context().

int vl_call_init_fns ( bool  param  ) 

Identify any registered init_functions and execute them.

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

Definition at line 341 of file veil_query.c.

Referenced by veil_int4array_get().

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

Here is the call graph for this function:

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

Here is the call graph for this function:

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

Here is the call graph for this function:

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:
name The name of the variable
expected The expected type.
got The actual type

Definition at line 204 of file veil_interface.c.

References vl_ObjTypeName().

Referenced by deserialise_bitmap_array(), deserialise_bitmap_hash(), deserialise_int4array(), deserialise_int4var(), deserialise_one_bitmap(), deserialise_range(), GetBitmapArrayFromVar(), GetBitmapFromVar(), GetBitmapHashFromVar(), GetBitmapRefFromVar(), and GetInt4ArrayFromVar().

Here is the call graph for this function:

Datum veil_variables ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo None
Returns:
setof veil_variable_t

Definition at line 605 of file veil_interface.c.

References ensure_init().

Here is the call graph for this function:

Datum veil_share ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo name text name of variable.
Returns:
bool true if the variable already exists

Definition at line 680 of file veil_interface.c.

Datum veil_init_range ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo name 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 708 of file veil_interface.c.

Datum veil_range ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo name 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 786 of file veil_interface.c.

Datum veil_init_bitmap ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bitmap_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 817 of file veil_interface.c.

Datum veil_clear_bitmap ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo name text The name of the bitmap to be cleared.
Returns:
bool true

Definition at line 851 of file veil_interface.c.

Datum veil_bitmap_setbit ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo name text The name of the bitmap variable.
bit_number int4 The bit to be set.
Returns:
bool true

Definition at line 880 of file veil_interface.c.

Datum veil_bitmap_clearbit ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo name text The name of the bitmap variable.
bit_number int4 The bit to be cleared.
Returns:
bool true

Definition at line 908 of file veil_interface.c.

Datum veil_bitmap_testbit ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo name 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 937 of file veil_interface.c.

Datum veil_bitmap_union ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo result_name text The target bitmap
name2 text The bitmap with which to union the target
Returns:
bool true

Definition at line 969 of file veil_interface.c.

Datum veil_bitmap_intersect ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo result_name text The target bitmap
name2 text The bitmap with which to intersect the target
Returns:
bool true

Definition at line 1005 of file veil_interface.c.

Datum veil_bitmap_bits ( FunctionCallInfo  fcinfo  ) 

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

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

Definition at line 1034 of file veil_interface.c.

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

Here is the call graph for this function:

Datum veil_bitmap_range ( FunctionCallInfo  fcinfo  ) 

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

Parameters:
fcinfo name 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 1099 of file veil_interface.c.

Datum veil_init_bitmap_array ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmarray 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 1136 of file veil_interface.c.

Datum veil_clear_bitmap_array ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmarray text The name of the BitmapArray.
Returns:
bool True

Definition at line 1176 of file veil_interface.c.

Datum veil_bitmap_from_array ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmref 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 1208 of file veil_interface.c.

Datum veil_bitmap_array_testbit ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmarray 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 1254 of file veil_interface.c.

Datum veil_bitmap_array_setbit ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmarray 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 1293 of file veil_interface.c.

Datum veil_bitmap_array_clearbit ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmarray 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 1339 of file veil_interface.c.

Datum veil_union_from_bitmap_array ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bitmap 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 1387 of file veil_interface.c.

Datum veil_intersect_from_bitmap_array ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bitmap 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 1428 of file veil_interface.c.

Datum veil_bitmap_array_bits ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmarray 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 1466 of file veil_interface.c.

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

Here is the call graph for this function:

Datum veil_bitmap_array_arange ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmarray 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 1546 of file veil_interface.c.

Datum veil_bitmap_array_brange ( FunctionCallInfo  fcinfo  ) 

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

Parameters:
fcinfo bmarray 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 1581 of file veil_interface.c.

Datum veil_init_bitmap_hash ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmhash 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 1618 of file veil_interface.c.

Datum veil_clear_bitmap_hash ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmhash text The name of the BitmapHash.
Returns:
bool True

Definition at line 1663 of file veil_interface.c.

Datum veil_bitmap_hash_key_exists ( FunctionCallInfo  fcinfo  ) 

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

Parameters:
fcinfo bmhash 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 1695 of file veil_interface.c.

Datum veil_bitmap_from_hash ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmref 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 1727 of file veil_interface.c.

Datum veil_bitmap_hash_testbit ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmhash 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 1766 of file veil_interface.c.

Datum veil_bitmap_hash_setbit ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmhash 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 1805 of file veil_interface.c.

Datum veil_bitmap_hash_clearbit ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmhash 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 1840 of file veil_interface.c.

Datum veil_union_into_bitmap_hash ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmhash 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 1877 of file veil_interface.c.

Datum veil_union_from_bitmap_hash ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmhash 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 1917 of file veil_interface.c.

Datum veil_intersect_from_bitmap_hash ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bitmap 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 1957 of file veil_interface.c.

Datum veil_bitmap_hash_bits ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo bmhashtext 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 1999 of file veil_interface.c.

Datum veil_bitmap_hash_entries ( FunctionCallInfo  fcinfo  ) 

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

Parameters:
fcinfo bmhash text The name of the bitmap hash.
Returns:
setof text Every key in the hash.

Definition at line 2099 of file veil_interface.c.

Datum veil_bitmap_hash_range ( FunctionCallInfo  fcinfo  ) 

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

Parameters:
fcinfo bmhash 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 2069 of file veil_interface.c.

Datum veil_int4_set ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo name text The name of the int4 variable.
fcinfo value int4 The value to be set (may be null).
Returns:
int4 The new value of the variable.

Definition at line 2163 of file veil_interface.c.

References Int4Var::isnull, and Int4Var::value.

Datum veil_int4_get ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo name text The name of the int4 variable.
Returns:
int4 The value of the variable.

Definition at line 2201 of file veil_interface.c.

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

Here is the call graph for this function:

Datum veil_init_int4array ( FunctionCallInfo  fcinfo  ) 

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

Each entry in the array will be zeroed.

Parameters:
fcinfo arrayname 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 2231 of file veil_interface.c.

Datum veil_clear_int4array ( FunctionCallInfo  fcinfo  ) 

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

Each entry in the array will be zeroed.

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

Definition at line 2264 of file veil_interface.c.

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

Here is the call graph for this function:

Datum veil_int4array_set ( FunctionCallInfo  fcinfo  ) 

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

Parameters:
fcinfo array 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 2290 of file veil_interface.c.

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

Here is the call graph for this function:

Datum veil_int4array_get ( FunctionCallInfo  fcinfo  ) 

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

Parameters:
fcinfo array 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 2318 of file veil_interface.c.

References vl_call_init_fns().

Here is the call graph for this function:

Datum veil_init ( FunctionCallInfo  fcinfo  ) 

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:
fcinfo doing_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 2353 of file veil_interface.c.

References ensure_init(), vl_bool_from_query(), vl_prepare_context_switch(), and vl_spi_connect().

Here is the call graph for this function:

Datum veil_perform_reset ( FunctionCallInfo  fcinfo  ) 

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 2384 of file veil_interface.c.

Datum veil_force_reset ( FunctionCallInfo  fcinfo  ) 

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 2449 of file veil_interface.c.

Datum veil_version ( FunctionCallInfo  fcinfo  ) 

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

Parameters:
fcinfo 
Returns:
text String describing the version.

Definition at line 2466 of file veil_interface.c.

Datum veil_serialise ( FunctionCallInfo  fcinfo  ) 

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 2489 of file veil_interface.c.

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

Here is the call graph for this function:

Datum veil_deserialise ( FunctionCallInfo  fcinfo  ) 

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 2524 of file veil_interface.c.

char* vl_serialise_var ( char *  name  ) 

Serialise a veil variable.

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

Definition at line 865 of file veil_serialise.c.

References VarEntry::obj, serialise_bitmap(), serialise_bitmap_array(), serialise_bitmap_hash(), serialise_int4array(), serialise_int4var(), serialise_range(), Object::type, and vl_lookup_variable().

Here is the call graph for this function:

int4 vl_deserialise ( char **  p_stream  ) 

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

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

Definition at line 952 of file veil_serialise.c.

References vl_deserialise_next().

Referenced by veil_serialise().

Here is the call graph for this function:

VarEntry* vl_deserialise_next ( char **  p_stream  ) 

De-serialise the next veil variable from *p_stream.

Parameters:
**p_stream Pointer 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 913 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().

Here is the call graph for this function:


Generated on Mon Sep 12 15:26:51 2011 for Veil by  doxygen 1.5.6