GnuCash
2.6.99
|
Modules | |
Columns | |
Files | |
file | gnc-backend-sql.h |
load and save data to SQL | |
Data Structures | |
struct | GncSqlBackend |
struct | GncSqlStatement |
struct | GncSqlConnection |
struct | GncSqlRow |
struct | GncSqlResult |
struct | GncSqlObjectBackend |
struct | GncSqlColumnInfo |
struct | GncSqlColumnTableEntry |
struct | GncSqlColumnTypeHandler |
struct | write_objects_t |
Typedefs | |
typedef struct GncSqlConnection | GncSqlConnection |
typedef struct GncSqlBackend | GncSqlBackend |
typedef struct GncSqlColumnTableEntry | GncSqlColumnTableEntry |
typedef struct GncSqlStatement | GncSqlStatement |
typedef struct GncSqlResult | GncSqlResult |
typedef struct GncSqlRow | GncSqlRow |
typedef void(* | GNC_SQL_LOAD_FN )(const GncSqlBackend *be, GncSqlRow *row, QofSetterFunc setter, gpointer pObject, const GncSqlColumnTableEntry *table) |
typedef void(* | GNC_SQL_ADD_COL_INFO_TO_LIST_FN )(const GncSqlBackend *be, const GncSqlColumnTableEntry *table_row, GList **pList) |
typedef void(* | GNC_SQL_ADD_COLNAME_TO_LIST_FN )(const GncSqlColumnTableEntry *table_row, GList **pList) |
typedef void(* | GNC_SQL_ADD_GVALUE_TO_SLIST_FN )(const GncSqlBackend *be, QofIdTypeConst obj_name, const gpointer pObject, const GncSqlColumnTableEntry *table_row, GSList **pList) |
Enumerations | |
enum | GncSqlBasicColumnType { BCT_STRING, BCT_INT, BCT_INT64, BCT_DATE, BCT_DOUBLE, BCT_DATETIME } |
enum | E_DB_OPERATION { OP_DB_INSERT, OP_DB_UPDATE, OP_DB_DELETE } |
void gnc_sql_add_colname_to_list | ( | const GncSqlColumnTableEntry * | table_row, |
GList ** | pList | ||
) |
Adds a column name to a list. If the column type spans multiple columns, all of the column names for the pieces are added.
table_row | DB table column |
pList | List |
Definition at line 1166 of file gnc-backend-sql.c.
gboolean gnc_sql_add_columns_to_table | ( | GncSqlBackend * | be, |
const gchar * | table_name, | ||
const GncSqlColumnTableEntry * | new_col_table | ||
) |
Adds one or more columns to an existing table.
be | SQL backend |
table_name | SQL table name |
new_col_table | Column table for new columns |
Definition at line 3206 of file gnc-backend-sql.c.
void gnc_sql_add_gvalue_objectref_guid_to_slist | ( | const GncSqlBackend * | be, |
QofIdTypeConst | obj_name, | ||
const gpointer | pObject, | ||
const GncSqlColumnTableEntry * | table_row, | ||
GSList ** | pList | ||
) |
Adds a GValue for an object reference GncGUID to the end of a GSList.
be | SQL backend struct |
obj_name | QOF object type name |
pObject | Object |
table_row | DB table column description |
pList | List |
Definition at line 1825 of file gnc-backend-sql.c.
void gnc_sql_add_objectref_guid_col_info_to_list | ( | const GncSqlBackend * | be, |
const GncSqlColumnTableEntry * | table_row, | ||
GList ** | pList | ||
) |
Adds a column info structure for an object reference GncGUID to the end of a GList.
be | SQL backend struct |
table_row | DB table column description |
pList | List |
Definition at line 1868 of file gnc-backend-sql.c.
void gnc_sql_add_subtable_colnames_to_list | ( | const GncSqlColumnTableEntry * | table_row, |
const GncSqlColumnTableEntry * | subtable, | ||
GList ** | pList | ||
) |
Appends column names for a subtable to the end of a GList.
table_row | Main DB column description |
subtable | Sub-column description table |
pList | List |
Definition at line 1173 of file gnc-backend-sql.c.
guint gnc_sql_append_guid_list_to_sql | ( | GString * | str, |
GList * | list, | ||
guint | maxCount | ||
) |
Appends the ascii strings for a list of GUIDs to the end of an SQL string.
str | SQL string |
list | List of GUIDs |
maxCount | Max # of GUIDs to append |
Definition at line 2629 of file gnc-backend-sql.c.
void gnc_sql_begin_edit | ( | GncSqlBackend * | be, |
QofInstance * | inst | ||
) |
An object is about to be edited.
be | SQL backend |
inst | Object being edited |
Definition at line 526 of file gnc-backend-sql.c.
void gnc_sql_commit_edit | ( | GncSqlBackend * | qbe, |
QofInstance * | inst | ||
) |
Object editting is complete and the object should be saved.
qbe | SQL backend |
inst | Object being edited |
Definition at line 569 of file gnc-backend-sql.c.
gboolean gnc_sql_commit_standard_item | ( | GncSqlBackend * | be, |
QofInstance * | inst, | ||
const gchar * | tableName, | ||
QofIdTypeConst | obj_name, | ||
const GncSqlColumnTableEntry * | col_table | ||
) |
Commits a "standard" item to the database. In most cases, a commit of one object vs another differs only in the table name and column table.
be | SQL backend |
inst | Instance |
tableName | SQL table name |
obj_name | QOF object type name |
col_table | Column table |
Definition at line 3044 of file gnc-backend-sql.c.
gchar* gnc_sql_convert_timespec_to_string | ( | const GncSqlBackend * | be, |
Timespec | ts | ||
) |
Converts a Timespec value to a string value for the database.
be | SQL backend |
ts | Timespec to be converted |
Definition at line 1883 of file gnc-backend-sql.c.
gboolean gnc_sql_create_index | ( | const GncSqlBackend * | be, |
const gchar * | index_name, | ||
const gchar * | table_name, | ||
const GncSqlColumnTableEntry * | col_table | ||
) |
Creates an index in the database
be | SQL backend struct |
index_name | Index name |
table_name | Table name |
col_table | Columns that the index should index |
Definition at line 3142 of file gnc-backend-sql.c.
GncSqlStatement* gnc_sql_create_select_statement | ( | GncSqlBackend * | be, |
const gchar * | table_name | ||
) |
Creates a basic SELECT statement for a table.
be | SQL backend struct |
table_name | Table name |
Definition at line 2495 of file gnc-backend-sql.c.
GncSqlStatement* gnc_sql_create_statement_from_sql | ( | GncSqlBackend * | be, |
const gchar * | sql | ||
) |
Creates a statement from an SQL char string.
be | SQL backend struct |
sql | SQL char string |
Definition at line 2548 of file gnc-backend-sql.c.
gboolean gnc_sql_create_table | ( | GncSqlBackend * | be, |
const gchar * | table_name, | ||
gint | table_version, | ||
const GncSqlColumnTableEntry * | col_table | ||
) |
Creates a table in the database
be | SQL backend struct |
table_name | Table name |
table_version | Table version |
col_table | DB table description |
Definition at line 3111 of file gnc-backend-sql.c.
gboolean gnc_sql_create_temp_table | ( | const GncSqlBackend * | be, |
const gchar * | table_name, | ||
const GncSqlColumnTableEntry * | col_table | ||
) |
Creates a temporary table in the database. A temporary table does not have a version number added to the versions table.
be | SQL backend struct |
table_name | Table name |
col_table | DB table description |
Definition at line 3131 of file gnc-backend-sql.c.
gboolean gnc_sql_do_db_operation | ( | GncSqlBackend * | be, |
E_DB_OPERATION | op, | ||
const gchar * | table_name, | ||
QofIdTypeConst | obj_name, | ||
gpointer | pObject, | ||
const GncSqlColumnTableEntry * | table | ||
) |
Performs an operation on the database.
be | SQL backend struct |
op | Operation type |
table_name | SQL table name |
obj_name | QOF object type name |
pObject | Gnucash object |
table | DB table description |
Definition at line 2698 of file gnc-backend-sql.c.
gint gnc_sql_execute_nonselect_sql | ( | GncSqlBackend * | be, |
const gchar * | sql | ||
) |
Executes an SQL non-SELECT statement from an SQL char string.
be | SQL backend struct |
sql | SQL non-SELECT string |
Definition at line 2591 of file gnc-backend-sql.c.
GncSqlResult* gnc_sql_execute_select_sql | ( | GncSqlBackend * | be, |
const gchar * | sql | ||
) |
Executes an SQL SELECT statement from an SQL char string and returns the result rows. If an error occurs, an entry is added to the log, an error status is returned to qof and NULL is returned.
be | SQL backend struct |
sql | SQL SELECT string |
Definition at line 2566 of file gnc-backend-sql.c.
GncSqlResult* gnc_sql_execute_select_statement | ( | GncSqlBackend * | be, |
GncSqlStatement * | statement | ||
) |
Executes an SQL SELECT statement and returns the result rows. If an error occurs, an entry is added to the log, an error status is returned to qof and NULL is returned.
be | SQL backend struct |
statement | Statement |
Definition at line 2530 of file gnc-backend-sql.c.
void gnc_sql_finalize_version_info | ( | GncSqlBackend * | be | ) |
Finalizes DB table version information.
be | SQL backend struct |
Finalizes the version table info by destroying the hash table.
be | Backend struct |
Definition at line 3333 of file gnc-backend-sql.c.
QofAccessFunc gnc_sql_get_getter | ( | QofIdTypeConst | obj_name, |
const GncSqlColumnTableEntry * | table_row | ||
) |
Returns the QOF access function for a column.
obj_name | QOF object type name |
table_row | DB table column |
Definition at line 1140 of file gnc-backend-sql.c.
gint64 gnc_sql_get_integer_value | ( | const GValue * | value | ) |
Gets an integer value (of any size) from a GValue.
value | Source value |
Definition at line 1085 of file gnc-backend-sql.c.
gchar* gnc_sql_get_sql_value | ( | const GncSqlConnection * | conn, |
const GValue * | value | ||
) |
Returns a string corresponding to the SQL representation of a GValue. The caller must free the string.
conn | SQL connection |
value | Value to be converted |
Definition at line 2773 of file gnc-backend-sql.c.
gint gnc_sql_get_table_version | ( | const GncSqlBackend * | be, |
const gchar * | table_name | ||
) |
Returns the version number for a DB table.
be | SQL backend struct |
table_name | Table name |
Definition at line 3159 of file gnc-backend-sql.c.
void gnc_sql_init | ( | GncSqlBackend * | be | ) |
Initialize the SQL backend.
be | SQL backend |
Definition at line 137 of file gnc-backend-sql.c.
void gnc_sql_init_version_info | ( | GncSqlBackend * | be | ) |
Initializes DB table version information.
be | SQL backend struct |
Sees if the version table exists, and if it does, loads the info into the version hash table. Otherwise, it creates an empty version table.
be | Backend struct |
Definition at line 3251 of file gnc-backend-sql.c.
void gnc_sql_load | ( | GncSqlBackend * | be, |
QofBook * | book, | ||
QofBackendLoadType | loadType | ||
) |
Load the contents of an SQL database into a book.
be | SQL backend |
book | Book to be loaded |
Definition at line 228 of file gnc-backend-sql.c.
const GncGUID* gnc_sql_load_guid | ( | const GncSqlBackend * | be, |
GncSqlRow * | row | ||
) |
Loads the object guid from a database row. The table must have a column named "guid" with type CT_GUID.
be | SQL backend struct |
row | Database row |
Definition at line 2422 of file gnc-backend-sql.c.
void gnc_sql_load_object | ( | const GncSqlBackend * | be, |
GncSqlRow * | row, | ||
QofIdTypeConst | obj_name, | ||
gpointer | pObject, | ||
const GncSqlColumnTableEntry * | table | ||
) |
Loads a Gnucash object from the database.
be | SQL backend struct |
row | DB result row |
obj_name | QOF object type name |
pObject | Object to be loaded |
table | DB table description |
Definition at line 2458 of file gnc-backend-sql.c.
const GncGUID* gnc_sql_load_tx_guid | ( | const GncSqlBackend * | be, |
GncSqlRow * | row | ||
) |
Loads the transaction guid from a database row. The table must have a column named "tx_guid" with type CT_GUID.
be | SQL backend struct |
row | Database row |
Definition at line 2445 of file gnc-backend-sql.c.
gboolean gnc_sql_object_is_it_in_db | ( | GncSqlBackend * | be, |
const gchar * | table_name, | ||
QofIdTypeConst | obj_name, | ||
const gpointer | pObject, | ||
const GncSqlColumnTableEntry * | table | ||
) |
Checks whether an object is in the database or not.
be | SQL backend struct |
table_name | DB table name |
obj_name | QOF object type name |
pObject | Object to be checked |
table | DB table description |
Definition at line 2659 of file gnc-backend-sql.c.
void gnc_sql_push_commodity_for_postload_processing | ( | GncSqlBackend * | be, |
gpointer * | comm | ||
) |
Register a commodity to be committed after loading is complete.
Necessary to save corrections made while loading.
be | SQL backend |
comm | The commodity item to be committed. |
Definition at line 214 of file gnc-backend-sql.c.
void gnc_sql_register_col_type_handler | ( | const gchar * | colType, |
const GncSqlColumnTypeHandler * | handler | ||
) |
Registers a column handler for a new column type.
colType | Column type |
handler | Column handler |
Definition at line 2348 of file gnc-backend-sql.c.
void gnc_sql_rollback_edit | ( | GncSqlBackend * | qbe, |
QofInstance * | inst | ||
) |
Object editing has been cancelled.
qbe | SQL backend |
inst | Object being edited |
Definition at line 536 of file gnc-backend-sql.c.
void gnc_sql_set_load_order | ( | const gchar ** | load_order | ) |
Specifies the load order for a set of objects. When loading from a database, the objects will be loaded in this order, so that when later objects have references to objects, those objects will already have been loaded.
load_order | NULL-terminated array of object type ID strings |
Definition at line 177 of file gnc-backend-sql.c.
gboolean gnc_sql_set_table_version | ( | GncSqlBackend * | be, |
const gchar * | table_name, | ||
gint | version | ||
) |
Registers the version for a table. Registering involves updating the db version table and also the hash table.
be | Backend struct |
table_name | Table name |
version | Version number |
Definition at line 3354 of file gnc-backend-sql.c.
void gnc_sql_sync_all | ( | GncSqlBackend * | be, |
QofBook * | book | ||
) |
Save the contents of a book to an SQL database.
be | SQL backend |
book | Book to be saved |
Definition at line 450 of file gnc-backend-sql.c.
void gnc_sql_upgrade_table | ( | GncSqlBackend * | be, |
const gchar * | table_name, | ||
const GncSqlColumnTableEntry * | col_table | ||
) |
Upgrades a table to a new structure. The upgrade is done by creating a new table with the new structure, SELECTing the old data into the new table, deleting the old table, then renaming the new table. Therefore, this will only work if the new table structure is similar enough to the old table that the SELECT will work.
be | SQL backend |
table_name | SQL table name |
col_table | Column table |
Definition at line 3176 of file gnc-backend-sql.c.