Veil2
Postgres extension for VPD implementations
veil2.h File Reference

Main header file for veil2. More...

#include "extension/pgbitmap/pgbitmap.h"
Include dependency graph for veil2.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tuple_2ints
 

Macros

#define DOCS_PATH   "<path to postgres extension docs>"
 
#define DATA_PATH   "<path to postgres extension data files>"
 

Typedefs

typedef bool() Fetch_fn(HeapTuple, TupleDesc, void *)
 

Functions

void veil2_spi_connect (bool *p_pushed, const char *msg)
 
void veil2_spi_finish (bool pushed, const char *msg)
 
int veil2_query_wn (const char *qry, int nargs, Oid *argtypes, Datum *args, const char *nulls, bool read_only, void **saved_plan, Fetch_fn process_row, void *fn_param)
 
int veil2_query (const char *qry, int nargs, Oid *argtypes, Datum *args, bool read_only, void **saved_plan, Fetch_fn process_row, void *fn_param)
 
bool veil2_bool_from_query (const char *qry, int nargs, Oid *argtypes, Datum *args, void **saved_plan, bool *result)
 
Datum veil2_session_ready (PG_FUNCTION_ARGS)
 
Datum veil2_reset_session (PG_FUNCTION_ARGS)
 
Datum veil2_reset_session_privs (PG_FUNCTION_ARGS)
 
Datum veil2_true (PG_FUNCTION_ARGS)
 
Datum veil2_i_have_global_priv (PG_FUNCTION_ARGS)
 
Datum veil2_i_have_personal_priv (PG_FUNCTION_ARGS)
 
Datum veil2_i_have_priv_in_scope (PG_FUNCTION_ARGS)
 
Datum veil2_i_have_priv_in_scope_or_global (PG_FUNCTION_ARGS)
 
Datum veil2_i_have_priv_in_superior_scope (PG_FUNCTION_ARGS)
 
Datum veil2_i_have_priv_in_scope_or_superior (PG_FUNCTION_ARGS)
 
Datum veil2_i_have_priv_in_scope_or_superior_or_global (PG_FUNCTION_ARGS)
 
Datum veil2_result_counts (PG_FUNCTION_ARGS)
 
Datum veil2_docpath (PG_FUNCTION_ARGS)
 
Datum veil2_datapath (PG_FUNCTION_ARGS)
 

Detailed Description

Macro Definition Documentation

◆ DATA_PATH

#define DATA_PATH   "<path to postgres extension data files>"

Definition at line 88 of file veil2.h.

◆ DOCS_PATH

#define DOCS_PATH   "<path to postgres extension docs>"

Definition at line 84 of file veil2.h.

Typedef Documentation

◆ Fetch_fn

typedef bool() Fetch_fn(HeapTuple, TupleDesc, void *)

A Fetch_fn is a function that processes records, one at a time, returned from a query.

Definition at line 20 of file veil2.h.

Function Documentation

◆ veil2_bool_from_query()

bool veil2_bool_from_query ( const char *  qry,
int  nargs,
Oid *  argtypes,
Datum *  args,
void **  saved_plan,
bool *  result 
)

Executes a query that returns a single bool value.

Parameters
qryThe text of the query to be performed.
nargsThe number of input parameters ($1, $2, etc) to the query
argtypesPointer to an array containing the OIDs of the data
argsActual parameters
saved_planAdress of void pointer into which the query plan will be saved. Passing the same void pointer on a subsequent call will cause the saved query plan to be re-used. This may be NULL, in which case the query plan will not be saved.
resultVariable into which the result of the query will be placed.
Returns
true if the query returned a record, false otherwise.

Definition at line 267 of file query.c.

Here is the call graph for this function:

◆ veil2_datapath()

Datum veil2_datapath ( PG_FUNCTION_ARGS  )

◆ veil2_docpath()

Datum veil2_docpath ( PG_FUNCTION_ARGS  )

◆ veil2_i_have_global_priv()

Datum veil2_i_have_global_priv ( PG_FUNCTION_ARGS  )

◆ veil2_i_have_personal_priv()

Datum veil2_i_have_personal_priv ( PG_FUNCTION_ARGS  )

◆ veil2_i_have_priv_in_scope()

Datum veil2_i_have_priv_in_scope ( PG_FUNCTION_ARGS  )

◆ veil2_i_have_priv_in_scope_or_global()

Datum veil2_i_have_priv_in_scope_or_global ( PG_FUNCTION_ARGS  )

◆ veil2_i_have_priv_in_scope_or_superior()

Datum veil2_i_have_priv_in_scope_or_superior ( PG_FUNCTION_ARGS  )

◆ veil2_i_have_priv_in_scope_or_superior_or_global()

Datum veil2_i_have_priv_in_scope_or_superior_or_global ( PG_FUNCTION_ARGS  )

◆ veil2_i_have_priv_in_superior_scope()

Datum veil2_i_have_priv_in_superior_scope ( PG_FUNCTION_ARGS  )

◆ veil2_query()

int veil2_query ( const char *  qry,
int  nargs,
Oid *  argtypes,
Datum *  args,
bool  read_only,
void **  saved_plan,
Fetch_fn  process_row,
void *  fn_param 
)

Execute a query (with all args being non-null) and process the results.

Parameters
qryThe text of the SQL query to be performed.
nargsThe number of input parameters ($1, $2, etc) to the query
argtypesPointer to an array containing the OIDs of the data
argsActual parameters types of the parameters
read_onlyWhether the query should be read-only or not.
saved_planAdress of void pointer into which the query plan will be saved. Passing the same void pointer on a subsequent call will cause the saved query plan to be re-used. This may be NULL, in which case the query plan will not be saved.
process_rowA Fetch_fn() to process each tuple retruned by the query.
fn_paramA parameter to pass to process_row.
Returns
The number of rows processed.

Definition at line 218 of file query.c.

Here is the call graph for this function:

◆ veil2_query_wn()

int veil2_query_wn ( const char *  qry,
int  nargs,
Oid *  argtypes,
Datum *  args,
const char *  nulls,
bool  read_only,
void **  saved_plan,
Fetch_fn  process_row,
void *  fn_param 
)

Execute a query with nulls (ie allowing null arguments) and process the results.

Parameters
qryThe text of the SQL query to be performed.
nargsThe number of input parameters ($1, $2, etc) to the query
argtypesPointer to an array containing the OIDs of the data
argsActual parameters types of the parameters
nullsString identifying which args are null. Null args contain 'n' in the appropriate character position, otherwise there will be a space. If no args may be null, a NULL value can be used instead of a string.
read_onlyWhether the query should be read-only or not.
saved_planAdress of void pointer into which the query plan will be saved. Passing the same void pointer on a subsequent call will cause the saved query plan to be re-used. This may be NULL, in which case the query plan will not be saved.
process_rowA Fetch_fn() to process each tuple retruned by the query.
fn_paramA parameter to pass to process_row.
Returns
The number of rows processed.

Definition at line 165 of file query.c.

Here is the call graph for this function:

◆ veil2_reset_session()

Datum veil2_reset_session ( PG_FUNCTION_ARGS  )

◆ veil2_reset_session_privs()

Datum veil2_reset_session_privs ( PG_FUNCTION_ARGS  )

◆ veil2_result_counts()

Datum veil2_result_counts ( PG_FUNCTION_ARGS  )

◆ veil2_session_ready()

Datum veil2_session_ready ( PG_FUNCTION_ARGS  )

◆ veil2_spi_connect()

void veil2_spi_connect ( bool *  p_pushed,
const char *  msg 
)

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
    Parameters
    p_pushedPointer to a boolean into which we will record whether we have saved a presiously active SPI connection. This allows recursive queries, which is probably overkill for our needs, but since the overhead is low...
    msgAn error message string to be issued in the event of a failure.
    Returns
    integer giving an SPI error code or success.

Definition at line 38 of file query.c.

◆ veil2_spi_finish()

void veil2_spi_finish ( bool  pushed,
const char *  msg 
)

Reciprocal function for veil2_spi_connect()

Parameters
pushedBoolean as set up by veil2_spi_connect(). This tells us whether to revert to a previously active SPI connection.
msgAn error message string to be issued in the event of a failure.
Returns
integer giving an SPI error code or success.

Definition at line 66 of file query.c.

◆ veil2_true()

Datum veil2_true ( PG_FUNCTION_ARGS  )