veil_variables.c File Reference


Detailed Description

Functions for dealing with Veil variables.

     Author:       Marc Munro
     Copyright (c) 2005 - 2010 Marc Munro
     License:      BSD
 $Id: veil_variables.c,v 1.6 2008/07/05 00:32:26 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"

Include dependency graph for veil_variables.c:

Go to the source code of this file.

Defines

#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.
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.

Variables

static HTAB * session_hash = ((void *) 0)
 This identifies the hash table for all session variables.


Function Documentation

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 71 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 125 of file veil_variables.c.

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 171 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 228 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 250 of file veil_variables.c.

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

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.


Variable Documentation

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


Generated on Fri Mar 12 08:38:46 2010 for Veil by  doxygen 1.5.6