Veil
|
Functions for dealing with Veil variables. More...
#include "postgres.h"
#include "veil_datatypes.h"
#include "utils/hsearch.h"
#include "storage/shmem.h"
#include "veil_funcs.h"
Go to the source code of this file.
Macros | |
#define | SESSION_HASH_ELEMS 32 |
Baselines the number of session variables that can be created in each context. | |
Functions | |
static HTAB * | create_session_hash () |
Create, or attach to, a hash for session variables. | |
VarEntry * | vl_lookup_shared_variable (char *name) |
Define a new, or attach to an existing, shared variable. More... | |
VarEntry * | vl_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_t * | vl_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... | |
Int4Array * | vl_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... | |
Variables | |
static HTAB * | session_hash = NULL |
This identifies the hash table for all session variables. More... | |
Functions for dealing with Veil variables.
Variables may be either session or shared, and are used to retain state between function calls. Shared variables are available to all suitably privileged sessions within a database. Session variables hold values that are private to a single session.
Definition in file veil_variables.c.
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).
name | The name of the variable. |
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().
VarEntry* vl_lookup_variable | ( | char * | name | ) |
Lookup a variable by name, creating it as as a session variable if it does not already exist.
name | The name of the variable |
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().
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.
prev | The last variable retrieved by a scan, or NULL if starting a new scan. |
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().
void vl_ClearInt4Array | ( | Int4Array * | array | ) |
Reset all Int4 entries in an Int4Array (to zero).
array | The 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().
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.
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 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().
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.
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 290 of file veil_variables.c.
References Int4Array::array, Int4Array::arraymax, and Int4Array::arrayzero.
Referenced by veil_int4array_set().
int32 vl_Int4ArrayGet | ( | Int4Array * | array, |
int32 | idx | ||
) |
Get an entry from an Int4Array.
If idx is outside of the acceptable range, raise an error.
array | The Int4Array within from the entry is to be read. |
idx | The index of the entry to be retrieved. |
Definition at line 314 of file veil_variables.c.
References Int4Array::array, Int4Array::arraymax, and Int4Array::arrayzero.
Referenced by veil_int4array_get().
|
static |
This identifies the hash table for all session variables.
The shared variable hash tables are managed in veil_shmem.c.
Definition at line 36 of file veil_variables.c.
Referenced by vl_lookup_shared_variable(), vl_lookup_variable(), and vl_next_variable().