Top | ![]() |
![]() |
![]() |
![]() |
#define | PRELUDEDB_SQL_TIMESTAMP_STRING_SIZE |
enum | preludedb_sql_time_constraint_type_t |
typedef | preludedb_sql_t |
typedef | preludedb_sql_table_t |
typedef | preludedb_sql_row_t |
typedef | preludedb_sql_field_t |
int preludedb_sql_new (preludedb_sql_t **newdb
,const char *type
,preludedb_sql_settings_t *settings
);
This function initialize the new
object, load and setup the plugin that
handle the database named type
with the configuration stored in settings
.
void
preludedb_sql_destroy (preludedb_sql_t *sql
);
Destroy sql
and the underlying plugin.
int preludedb_sql_enable_query_logging (preludedb_sql_t *sql
,const char *filename
);
Log all queries in the specified file.
void
preludedb_sql_disable_query_logging (preludedb_sql_t *sql
);
Disable query logging.
const char *
preludedb_sql_get_plugin_error (preludedb_sql_t *sql
);
preludedb_sql_get_plugin_error
is deprecated and should not be used in newly-written code.
Use preludedb_strerror()
.
Get sql plugin specific error message.
int preludedb_sql_query (preludedb_sql_t *sql
,const char *query
,preludedb_sql_table_t **table
);
Execute a SQL query.
int preludedb_sql_query_sprintf (preludedb_sql_t *sql
,preludedb_sql_table_t **table
,const char *format
,...
);
Execute a SQL query.
int preludedb_sql_insert (preludedb_sql_t *sql
,const char *table
,const char *fields
,const char *format
,...
);
Insert values in a table.
int preludedb_sql_build_limit_offset_string (preludedb_sql_t *sql
,int limit
,int offset
,prelude_string_t *output
);
Build a limit/offset string for a SQL query, depending on the underlying type of database.
int
preludedb_sql_transaction_start (preludedb_sql_t *sql
);
Begin a sql transaction.
int
preludedb_sql_transaction_end (preludedb_sql_t *sql
);
Finish a sql transaction (SQL COMMIT command).
int
preludedb_sql_transaction_abort (preludedb_sql_t *sql
);
Abort a sql transaction (SQL ROLLBACK command).
int preludedb_sql_escape_fast (preludedb_sql_t *sql
,const char *input
,size_t input_size
,char **output
);
Escape a string buffer.
int preludedb_sql_escape (preludedb_sql_t *sql
,const char *input
,char **output
);
Escape a string buffer.
int preludedb_sql_escape_binary (preludedb_sql_t *sql
,const unsigned char *input
,size_t input_size
,char **output
);
Escape a binary buffer.
int preludedb_sql_unescape_binary (preludedb_sql_t *sql
,const char *input
,size_t input_size
,unsigned char **output
,size_t *output_size
);
Unescape to a binary buffer.
void
preludedb_sql_table_destroy (preludedb_sql_table_t *table
);
Destroy the table
object.
const char * preludedb_sql_table_get_column_name (preludedb_sql_table_t *table
,unsigned int column_num
);
Get the name of the column number column_num
.
int preludedb_sql_table_get_column_num (preludedb_sql_table_t *table
,const char *column_name
);
Get the number of the column named column_name
.
unsigned int
preludedb_sql_table_get_column_count (preludedb_sql_table_t *table
);
Get the the number of columns.
unsigned int
preludedb_sql_table_get_row_count (preludedb_sql_table_t *table
);
Get the the number of row in the table. Depending on the database backend, this might require retrieving all rows.
int preludedb_sql_table_fetch_row (preludedb_sql_table_t *table
,preludedb_sql_row_t **row
);
Fetch the next table's row.
int preludedb_sql_row_fetch_field (preludedb_sql_row_t *row
,int column_num
,preludedb_sql_field_t **field
);
preludedb_sql_row_fetch_field
is deprecated and should not be used in newly-written code.
use preludedb_sql_row_get_field()
instead.
Fetch the field of column column_num
int preludedb_sql_row_fetch_field_by_name (preludedb_sql_row_t *row
,const char *column_name
,preludedb_sql_field_t **field
);
preludedb_sql_row_fetch_field_by_name
is deprecated and should not be used in newly-written code.
use preludedb_sql_row_get_field_by_name()
instead.
Fetch the field of column column_name
char *
preludedb_sql_field_get_value (preludedb_sql_field_t *field
);
size_t
preludedb_sql_field_get_len (preludedb_sql_field_t *field
);
Get the field value length.
int preludedb_sql_field_to_int8 (preludedb_sql_field_t *field
,int8_t *value
);
int preludedb_sql_field_to_uint8 (preludedb_sql_field_t *field
,uint8_t *value
);
int preludedb_sql_field_to_int16 (preludedb_sql_field_t *field
,int16_t *value
);
int preludedb_sql_field_to_uint16 (preludedb_sql_field_t *field
,uint16_t *value
);
int preludedb_sql_field_to_int32 (preludedb_sql_field_t *field
,int32_t *value
);
int preludedb_sql_field_to_uint32 (preludedb_sql_field_t *field
,uint32_t *value
);
int preludedb_sql_field_to_int64 (preludedb_sql_field_t *field
,int64_t *value
);
int preludedb_sql_field_to_uint64 (preludedb_sql_field_t *field
,uint64_t *value
);
int preludedb_sql_field_to_float (preludedb_sql_field_t *field
,float *value
);
int preludedb_sql_field_to_double (preludedb_sql_field_t *field
,double *value
);
int preludedb_sql_field_to_string (preludedb_sql_field_t *field
,prelude_string_t *output
);
Get the string value of field
.
int preludedb_sql_build_criterion_string (preludedb_sql_t *sql
,prelude_string_t *output
,const char *field
,idmef_criterion_operator_t idmef_operator
,idmef_criterion_value_t *value
);
Build a sql "field operator value" string.
int preludedb_sql_time_from_timestamp (idmef_time_t *time
,const char *time_buf
,int32_t gmtoff
,uint32_t usec
);
Set an idmef time using the timestamp, GMT offset and microseconds given in input.
int preludedb_sql_time_to_timestamp (preludedb_sql_t *sql
,const idmef_time_t *time
,char *time_buf
,size_t time_buf_size
,char *gmtoff_buf
,size_t gmtoff_buf_size
,char *usec_buf
,size_t usec_buf_size
);
Set timestamp, GMT offset, and microseconds buffers with the idmef time object given in input.