Top | ![]() |
![]() |
![]() |
![]() |
gint | (*CamelDBCollate) () |
gboolean | (*CamelDBSelectCB) () |
GQuark | camel_db_error_quark () |
CamelDB * | camel_db_new () |
gboolean | camel_db_open () |
const gchar * | camel_db_get_filename () |
void | camel_db_writer_lock () |
void | camel_db_writer_unlock () |
void | camel_db_reader_lock () |
void | camel_db_reader_unlock () |
gboolean | camel_db_has_table () |
gboolean | camel_db_has_table_with_column () |
gboolean | camel_db_exec_select () |
gboolean | camel_db_exec_statement () |
gboolean | camel_db_begin_transaction () |
gboolean | camel_db_end_transaction () |
gboolean | camel_db_abort_transaction () |
gboolean | camel_db_set_collate () |
gboolean | camel_db_maybe_run_maintenance () |
void | camel_db_release_cache_memory () |
gchar * | camel_db_sqlize_string () |
void | camel_db_free_sqlized_string () |
void | camel_db_sqlize_to_statement () |
gint (*CamelDBCollate) (gpointer enc
,gint length1
,gconstpointer data1
,gint length2
,gconstpointer data2
);
A collation callback function.
enc |
a used encoding (SQLITE_UTF8) |
|
length1 |
length of the |
|
data1 |
the first value, of lenth |
|
length2 |
length of the |
|
data2 |
the second value, of lenth |
Since: 2.24
gboolean (*CamelDBSelectCB) (gpointer user_data
,gint ncol
,gchar **colvalues
,gchar **colnames
);
A callback called for the SELECT statements. The items at the same index of colvalues
and colnames
correspond to each other.
user_data |
a callback user data |
|
ncol |
how many columns is provided |
|
colvalues |
array of column values, as UTF-8 strings. |
[array length=ncol] |
colnames |
array of column names. |
[array length=ncol] |
Since: 3.58
CamelDB * camel_db_new (const gchar *filename
,GError **error
);
Creates a new CamelDB instance and calls camel_db_open()
to
open a database file. Free the returned object with
g_object_unref()
, when no longer needed.
filename |
A file name with the database to open/create |
|
error |
return location for a GError, or |
Since: 3.58
gboolean camel_db_open (CamelDB *cdb
,const gchar *filename
,GError **error
);
Opens the database stored as filename
. The function can be called
only once, all following calls will result into failures.
cdb |
a CamelDB |
|
filename |
A file name with the database to open/create |
|
error |
return location for a GError, or |
Since: 3.58
void
camel_db_writer_lock (CamelDB *cdb
);
Acquires a writer lock on the cdb
. It can be called multiple times.
Call pair function camel_db_writer_unlock()
to release it.
Note: This adds a transaction on the DB. Not all statements can be executed in the transaction.
Since: 3.58
void
camel_db_writer_unlock (CamelDB *cdb
);
Releases a write lock on the cdb
previously acquired
by calling camel_db_writer_lock()
.
Since: 3.58
void
camel_db_reader_lock (CamelDB *cdb
);
Acquires a reader lock on the cdb
. It can be called multiple times.
Call pair function camel_db_reader_unlock()
to release it. it's okay
to call this function when a writer lock is already acquired by the
calling thread.
Since: 3.58
void
camel_db_reader_unlock (CamelDB *cdb
);
Releases a reader lock on the cdb
previously acquired by
calling camel_db_reader_lock()
.
Since: 3.58
gboolean camel_db_has_table (CamelDB *cdb
,const gchar *table_name
);
Checks whether the table_name
exists in the cdb
.
Since: 3.58
gboolean camel_db_has_table_with_column (CamelDB *cdb
,const gchar *table_name
,const gchar *column_name
);
Checks whether the table_name
exists in the cdb
and contains
column named column_name
.
TRUE
, when the table_name
exists and contains column_name
column,
FALSE
when not or when any other error occurred
Since: 3.58
gboolean camel_db_exec_select (CamelDB *cdb
,const gchar *stmt
,CamelDBSelectCB callback
,gpointer user_data
,GError **error
);
Executes a SELECT statement and calls the callback
for each selected row.
cdb |
a CamelDB |
|
stmt |
a SELECT statement to execute |
|
callback |
a callback to call for each row. |
[scope call][closure user_data] |
user_data |
user data for the |
|
error |
return location for a GError, or |
Since: 3.58
gboolean camel_db_exec_statement (CamelDB *cdb
,const gchar *stmt
,GError **error
);
Executes an SQLite statement.
cdb |
a CamelDB |
|
stmt |
an SQL (SQLite) statement to execute |
|
error |
return location for a GError, or |
Since: 3.58
gboolean camel_db_begin_transaction (CamelDB *cdb
,GError **error
);
Begins transaction. End it with camel_db_end_transaction()
or camel_db_abort_transaction()
.
Since: 3.58
gboolean camel_db_end_transaction (CamelDB *cdb
,GError **error
);
Ends an ongoing transaction by committing the changes.
Since: 3.58
gboolean camel_db_abort_transaction (CamelDB *cdb
,GError **error
);
Ends an ongoing transaction by ignoring the changes.
Since: 3.58
gboolean camel_db_set_collate (CamelDB *cdb
,const gchar *col
,const gchar *collate
,CamelDBCollate func
);
Defines a collation collate
, which can be used in SQL (SQLite)
statement as a collation function. The func
is called when
colation is used.
cdb |
a CamelDB |
|
col |
a column name; currently unused |
|
collate |
collation name |
|
func |
a CamelDBCollate collation function. |
[scope call] |
Since: 2.24
gboolean camel_db_maybe_run_maintenance (CamelDB *cdb
,GError **error
);
Runs a cdb
maintenance, which includes vacuum, if necessary.
Since: 3.16
void
camel_db_release_cache_memory (void
);
Instructs sqlite to release its memory, if possible. This can be avoided when CAMEL_SQLITE_FREE_CACHE environment variable is set.
Since: 3.24
gchar *
camel_db_sqlize_string (const gchar *string
);
Converts the string
to be usable in the SQLite statements.
A newly allocated sqlized string
. The returned
value should be freed with camel_db_sqlize_string()
, when no longer needed.
[transfer full]
Since: 2.24
void
camel_db_free_sqlized_string (gchar *string
);
Frees a string previously returned by camel_db_sqlize_string()
.
Since: 2.24
void camel_db_sqlize_to_statement (GString *stmt
,const gchar *str
,CamelDBSqlizeFlags flags
);
Encodes the str
to be safe to use as a string
in an SQL statement and appends it to the stmt
.
When str
is NULL
, a NULL word is appended.
stmt |
a GString with an SQL statement |
|
str |
a string to sqlize. |
[nullable] |
flags |
bit-or of CamelDBSqlizeFlags |
Since: 3.58