Author: Marc Munro
Copyright (c) 2005, 2006 Marc Munro
License: BSD
$Id: veil_variables.c,v 1.5 2007/07/31 22:18:27 bloodnok Exp $
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.
#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.
Defines | |
| #define | SESSION_HASH_ELEMS 32 |
Functions | |
| static HTAB * | create_session_hash () |
| VarEntry * | vl_lookup_shared_variable (char *name) |
| VarEntry * | vl_lookup_variable (char *name) |
| veil_variable_t * | vl_next_variable (veil_variable_t *prev) |
| void | vl_ClearInt4Array (Int4Array *array) |
| Int4Array * | vl_NewInt4Array (Int4Array *current, bool shared, int32 min, int32 max) |
| void | vl_Int4ArraySet (Int4Array *array, int32 idx, int32 value) |
| int32 | vl_Int4ArrayGet (Int4Array *array, int32 idx) |
Variables | |
| static HTAB * | session_hash = ((void *) 0) |
| #define SESSION_HASH_ELEMS 32 |
Baselines the number of session variables that can be created in each context.
Definition at line 30 of file veil_variables.c.
Referenced by create_session_hash().
| static HTAB* create_session_hash | ( | ) | [static] |
Create, or attach to, a hash for session variables.
Definition at line 45 of file veil_variables.c.
References HASH_KEYLEN, and SESSION_HASH_ELEMS.
Referenced by vl_lookup_shared_variable(), and vl_next_variable().
| void vl_ClearInt4Array | ( | Int4Array * | array | ) |
Reset all Int4 entries in an Int4Array (to zero).
| array | The array to be reset. |
Definition at line 228 of file veil_variables.c.
References Int4Array::array.
Referenced by vl_NewInt4Array().
| 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 318 of file veil_variables.c.
References Int4Array::arraymax, and Int4Array::arrayzero.
| 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 293 of file veil_variables.c.
References Int4Array::arraymax, and Int4Array::arrayzero.
Referenced by veil_clear_int4array().
| 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 71 of file veil_variables.c.
References create_session_hash(), VarEntry::obj, session_hash, VarEntry::shared, and vl_get_shared_hash().

| 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 125 of file veil_variables.c.
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 250 of file veil_variables.c.
References Int4Array::arraymax, Int4Array::arrayzero, and vl_ClearInt4Array().

| 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 171 of file veil_variables.c.
References create_session_hash(), and session_hash.

HTAB* session_hash = ((void *) 0) [static] |
This identifies the hash table for all session variables. The shared variable hash tables are managed in veil_shmem.c.
Definition at line 37 of file veil_variables.c.
Referenced by vl_lookup_shared_variable(), and vl_next_variable().
1.5.4