20 #include "utils/hsearch.h" 21 #include "storage/shmem.h" 29 #define SESSION_HASH_ELEMS 32 51 hashctl.entrysize =
sizeof(
VarEntry);
53 return hash_create(
"VEIL_SESSION",
84 (errcode(ERRCODE_INTERNAL_ERROR),
85 errmsg(
"attempt to redefine session variable %s", name),
86 errdetail(
"You are trying to create shared variable %s " 87 "but it already exists as a session variable.",
91 var = (
VarEntry *) hash_search(shared_hash, (
void *) name,
96 (errcode(ERRCODE_INTERNAL_ERROR),
97 errmsg(
"Out of memory for shared variables")));
136 var = (
VarEntry *)hash_search(shared_hash, (
void *) name,
147 (errcode(ERRCODE_INTERNAL_ERROR),
148 errmsg(
"Out of memory for shared variables")));
169 static bool doing_shared;
171 static HASH_SEQ_STATUS status;
184 hash_seq_init(&status, hash);
187 var = hash_seq_search(&status);
193 doing_shared =
false;
195 hash_seq_init(&status, hash);
196 var = hash_seq_search(&status);
228 for (i = 0; i < elems; i++) {
247 int32 min, int32 max)
250 int elems = 1 + max - min;
254 if (elems <= cur_elems) {
274 result->
type = OBJ_INT4_ARRAY;
292 if ((idx < array->arrayzero) ||
296 (errcode(ERRCODE_INTERNAL_ERROR),
297 errmsg(
"Int4ArraySet range error"),
298 errdetail(
"Index (%d) not in range %d..%d. ", idx,
316 if ((idx < array->arrayzero) ||
320 (errcode(ERRCODE_INTERNAL_ERROR),
321 errmsg(
"Int4ArrayGet range error"),
322 errdetail(
"Index (%d) not in range %d..%d. ", idx,
#define SESSION_HASH_ELEMS
Baselines the number of session variables that can be created in each context.
Subtype of Object for storing arrays of integers.
HTAB * vl_get_shared_hash(void)
Return the shared hash for the current context.
Describes a veil shared or session variable.
bool shared
Whether this is a shared variable (as opposed to a session variable)
char * name
The name of the variable.
Int4Array * vl_NewInt4Array(Int4Array *current, bool shared, int32 min, int32 max)
Return a newly initialised (zeroed) Int4Array.
void vl_ClearInt4Array(Int4Array *array)
Reset all Int4 entries in an Int4Array (to zero).
ObjType type
This must have the value OBJ_INT4_ARRAY.
static HTAB * create_session_hash()
Create, or attach to, a hash for session variables.
#define HASH_KEYLEN
The key length for veil hash types.
int32 arrayzero
The index of array element zero: the index of the lowest numbered bitmap in the array.
Provide definitions for all non-local C-callable Veil functions.
bool shared
Whether this is a shared variable.
VarEntry * vl_lookup_shared_variable(char *name)
Define a new, or attach to an existing, shared variable.
char * type
The type of the variable (eg "Bitmap")
static HTAB * session_hash
This identifies the hash table for all session variables.
int32 vl_Int4ArrayGet(Int4Array *array, int32 idx)
Get an entry from an Int4Array.
void * vl_shmalloc(size_t size)
Dynamically allocate a piece of shared memory from the current context.
void * vl_malloc(size_t size)
Dynamically allocate memory using palloc in TopMemoryContext.
ObjType type
Identifies the type of the object.
int32 arraymax
The index of the lowest numbered bitmap in the array.
Object * obj
Pointer to the contents of the 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...
veil_variable_t * vl_next_variable(veil_variable_t *prev)
Return the next variable from a scan of the hash of variables.
int32 array[0]
Element zero of the array of integers.
struct VarEntry VarEntry
A Veil variable.
void vl_Int4ArraySet(Int4Array *array, int32 idx, int32 value)
Set an entry within an Int4Array.
char key[60]
String containing variable name.
char * vl_ObjTypeName(ObjType obj)
Return a static string describing an ObjType object.
Define all Veil public datatypes.