#include <sqlite3.h>
#include "str_functions.h"
Go to the source code of this file.
Data Structures | |
struct | SQL_Result |
Data structure that holds the result of SQL functions and command. More... | |
Defines | |
SQL file access flags. | |
These flags are for SQLite 3.3.X and earlier, as those versions do not have following definitions. | |
#define | SQLITE_OPEN_READONLY 0x00000001 |
The database is opened for reading only. | |
#define | SQLITE_OPEN_READWRITE 0x00000002 |
The database is opened for reading and writing. | |
#define | SQLITE_OPEN_CREATE 0x00000004 |
The database is opened for reading and writing, and is creates it if it does not already exist. | |
SQL_Result initial parameters. | |
These parameters define the initial size of SQL_Result.
Change them by define -D<parameter>=<param_value> flag in CC. | |
#define | SQL_RESULT_FIELD_CHUNK_SIZE 2048 |
Chunk size for field names. | |
#define | SQL_RESULT_FIELD_ELEMENT_COUNT 128 |
Number of fields. | |
#define | SQL_RESULT_FIELD_CONST_COUNT 0 |
Number of constant fields. | |
#define | SQL_RESULT_RESULT_CHUNK_SIZE 65536 |
Chunk size for result names. | |
#define | SQL_RESULT_RESULT_ELEMENT_COUNT 512 |
Number of results. | |
#define | SQL_RESULT_RESULT_CONST_COUNT 0 |
Number of constant results. | |
Functions | |
SQL_Result * | sql_result_new () |
New a SQL_Result instance. | |
StringList * | sql_result_free (SQL_Result *sResult, gboolean freeResult) |
Free a SQL_Result instance. | |
int | sqlite_count_matches (sqlite3 *db, const char *sqlClause, char **errMsg_ptr) |
Count the matches returned by SQL clause. | |
SQL_Result * | sqlite_get_sql_result (sqlite3 *db, const char *sqlClause) |
Get the results of SQL clause. | |
SQL_Result * | sqlite_get_tableNames (sqlite3 *db) |
Get the list of table names in the database. | |
StringList * | sqlite_get_fieldNames (sqlite3 *db, const char *sqlClause, int *execResult_ptr, char **errMsg_ptr) |
Get the fields of result table of a SQL clause. | |
char * | sqlite_value_signed_text (sqlite3_value *value) |
Return the value as signed string. | |
char * | sqlite_value_signed_text_buffer (char *buf, sqlite3_value *value) |
Store the value as signed string to provided buffer. |
#define SQL_RESULT_FIELD_CONST_COUNT 0 |
Normally you don't need to change this.
#define SQL_RESULT_RESULT_ELEMENT_COUNT 512 |
It should be rol_count * col_count.
#define SQLITE_OPEN_CREATE 0x00000004 |
This is the behavior that is always used for sqlite3_open().
StringList* sql_result_free | ( | SQL_Result * | sResult, | |
gboolean | freeResult | |||
) |
sResult | SQL_Result to be freed. | |
freeResult | TRUE for free the whole SQL_Result; while FALSE keep the sResult->resultList but free everything else. |
SQL_Result* sql_result_new | ( | ) |
int sqlite_count_matches | ( | sqlite3 * | db, | |
const char * | sqlClause, | |||
char ** | errMsg_ptr | |||
) |
The error message passed back through the errMsg is held in memory obtained from sqlite3_malloc(). To avoid a memory leak, the calling application should call sqlite3_free() on any error message returned through the errMsg parameter when it has finished using the error message.
db | The database. | |
sqlClause | SQL clause. | |
errMsg_ptr | The error message will be written here. Free it with sqlite3_free(). |
StringList* sqlite_get_fieldNames | ( | sqlite3 * | db, | |
const char * | sqlClause, | |||
int * | execResult_ptr, | |||
char ** | errMsg_ptr | |||
) |
The result code is store in execResult_ptr, calling application should provide a int-type variable to store the result code.
The error message passed back through the errMsg is held in memory obtained from sqlite3_malloc(). To avoid a memory leak, the calling application should call sqlite3_free() on any error message returned through the errMsg parameter when it has finished using the error message.
db | The database. | |
sqlClause | SQL clause. | |
execResult_ptr | The result code will be written here. | |
errMsg_ptr | The error message will be written here. |
SQL_Result* sqlite_get_sql_result | ( | sqlite3 * | db, | |
const char * | sqlClause | |||
) |
SQL_Result* sqlite_get_tableNames | ( | sqlite3 * | db | ) |
db | The database. |
resultList
. char* sqlite_value_signed_text | ( | sqlite3_value * | value | ) |
sqlite3_value_text() returns unsigned char array, unfortunately, this is not expected for most of string functions. This function return the value as a signed string.
value | the value from SQLite. |
char* sqlite_value_signed_text_buffer | ( | char * | buf, | |
sqlite3_value * | value | |||
) |
It is similar with sqlite3_value_text(), except developers can provide their own buffer space to s
buf | the provided buffer. | |
value | the value from SQLite. |