Query interface

Query API. More...

Functions

struct evsql_queryevsql_query (struct evsql *evsql, struct evsql_trans *trans, const char *command, evsql_query_cb query_fn, void *cb_arg)
 Queue the given query for execution.
struct evsql_queryevsql_query_params (struct evsql *evsql, struct evsql_trans *trans, const char *command, const struct evsql_query_params *params, evsql_query_cb query_fn, void *cb_arg)
 Execute the given SQL query using the list of parameter types/values given via evsql_query_params.
struct evsql_queryevsql_query_exec (struct evsql *evsql, struct evsql_trans *trans, const struct evsql_query_info *query_info, evsql_query_cb query_fn, void *cb_arg,...)
 Execute the given query_info's SQL query with the values given as variable arguments, using the query_info to resolve the types.
void evsql_query_abort (struct evsql_trans *trans, struct evsql_query *query)
 Abort a query returned by Query interface that has not yet completed (query_fn has not been called yet).
void evsql_query_debug (const char *sql, const struct evsql_query_params *params)
 Print out a textual dump of the given sql query and params using DEBUG.

Detailed Description

Query API.

See also:
evsql.h

Function Documentation

struct evsql_query* evsql_query ( struct evsql evsql,
struct evsql_trans trans,
const char *  command,
evsql_query_cb  query_fn,
void *  cb_arg 
) [read]

Queue the given query for execution.

If trans is given (i.e. not NULL), then the transaction must be idle, and the query will be executed in that transaction's context. Otherwise, the query will be executed without a transaction using an idle connection, or enqueued for later execution.

Once the query is complete (got a result, got an error, the connection failed), then query_fn will be called. The callback can use the Result interface functions to manipulate the query results.

The returned evsql_query handle can be passed to evsql_query_abort at any point before query_fn being called.

Parameters:
evsql the context handle from Session creation interface
trans the optional transaction handle from evsql_trans
command the raw SQL command itself
query_fn the evsql_query_cb() to call once the query is complete
cb_arg the void* passed to the above
Returns:
the evsql_query handle that can be used to abort the query

void evsql_query_abort ( struct evsql_trans trans,
struct evsql_query query 
)

Abort a query returned by Query interface that has not yet completed (query_fn has not been called yet).

The actual query itself may or may not be aborted (and hence may or may not be executed on the server), but query_fn will not be called anymore, and the query will dispose of itself and any results returned.

If the query is part of a transaction, then trans must be given, and the query must be the query that is currently executing on that trans. The transaction's ready_fn will be called once the query has been aborted and the transaction is now idle again.

Parameters:
trans if the query is part of a transaction, then it MUST be given here
query the in-progress query to abort

void evsql_query_debug ( const char *  sql,
const struct evsql_query_params params 
)

Print out a textual dump of the given sql query and params using DEBUG.

Parameters:
sql the SQL query command
params the list of parameter types and values

struct evsql_query* evsql_query_exec ( struct evsql evsql,
struct evsql_trans trans,
const struct evsql_query_info query_info,
evsql_query_cb  query_fn,
void *  cb_arg,
  ... 
) [read]

Execute the given query_info's SQL query with the values given as variable arguments, using the query_info to resolve the types.

See evsql_query() for more info about behaviour.

Parameters:
evsql the context handle from Session creation interface
trans the optional transaction handle from evsql_trans
query_info the SQL query information
query_fn the evsql_query_cb() to call once the query is complete
cb_arg the void* passed to the above
See also:
evsql_query

struct evsql_query* evsql_query_params ( struct evsql evsql,
struct evsql_trans trans,
const char *  command,
const struct evsql_query_params params,
evsql_query_cb  query_fn,
void *  cb_arg 
) [read]

Execute the given SQL query using the list of parameter types/values given via evsql_query_params.

Use the EVSQL_PARAMS macros to declare params, and the Parameter interface functions to populate the values.

See evsql_query() for more info about behaviour.

See the libpq PQexecParams tip for the parameter syntax to use.

Parameters:
evsql the context handle from Session creation interface
trans the optional transaction handle from evsql_trans
command the SQL command to bind the parameters to
params the parameter types and values
query_fn the evsql_query_cb() to call once the query is complete
cb_arg the void* passed to the above
See also:
evsql_query


Generated on Sat Dec 13 20:58:05 2008 for evsql by  doxygen 1.5.6