src/evsql.h
changeset 23 1dee73ae4ad0
parent 21 e5da1d428e3e
child 24 82cfdb6680d1
equal deleted inserted replaced
22:85ba190a9e68 23:1dee73ae4ad0
    18  * A query handle
    18  * A query handle
    19  */
    19  */
    20 struct evsql_query;
    20 struct evsql_query;
    21 
    21 
    22 /*
    22 /*
    23  * Query parameter info
    23  * Query parameter info.
    24  * /
    24  *
       
    25  * Use the EVSQL_PARAM_* macros to define the value of list
       
    26  */
    25 struct evsql_query_params {
    27 struct evsql_query_params {
    26     int count;
    28     // nonzero to get results in binary format
    27     const char * const *values;
    29     int result_binary;
    28     const int *lengths;
    30     
    29     const int *formats;
    31     // the list of parameters, terminated by { 0, 0 }
    30     int result_format;
    32     struct evsql_query_param {
    31 }; */
    33         // the textual or binary value for this parameter
       
    34         char *value;
       
    35 
       
    36         // the explicit length of the parameter if it's binary. Must be non-zero for NULL values.
       
    37         int length;
       
    38     } list[];
       
    39 };
       
    40 
       
    41 // macros for defining evsql_query_params
       
    42 #define EVSQL_PARAM_NULL                    { NULL, 1 }
       
    43 #define EVSQL_PARAM_TEXT(value)             { value, 0 }
       
    44 #define EVSQL_PARAM_BINARY(value, length)   { value, length }
    32 
    45 
    33 /*
    46 /*
    34  * Result type
    47  * Result type
    35  */
    48  */
    36 struct evsql_result_info {
    49 struct evsql_result_info {
    69  * Queue the given query for execution.
    82  * Queue the given query for execution.
    70  */
    83  */
    71 struct evsql_query *evsql_query (struct evsql *evsql, const char *command, evsql_query_cb query_fn, void *cb_arg);
    84 struct evsql_query *evsql_query (struct evsql *evsql, const char *command, evsql_query_cb query_fn, void *cb_arg);
    72 
    85 
    73 /*
    86 /*
       
    87  * Same, but uses the SQL-level support for binding parameters.
       
    88  */
       
    89 struct evsql_query *evsql_query_params (struct evsql *evsql, const char *command, struct evsql_query_params params, evsql_query_cb query_fn, void *cb_arg);
       
    90 
       
    91 /*
    74  * Close a connection. Callbacks for waiting queries will not be run.
    92  * Close a connection. Callbacks for waiting queries will not be run.
    75  *
    93  *
    76  * XXX: not implemented yet.
    94  * XXX: not implemented yet.
    77  */
    95  */
    78 void evsql_close (struct evsql *evsql);
    96 void evsql_close (struct evsql *evsql);