JULEA
Loading...
Searching...
No Matches
sql-generic.h
Go to the documentation of this file.
1/*
2 * JULEA - Flexible storage framework
3 * Copyright (C) 2022 Timm Leon Erxleben
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
23#ifndef JULEA_DB_UTIL_SQL_GENERIC_H
24#define JULEA_DB_UTIL_SQL_GENERIC_H
25
26#include <glib.h>
27
28#include <julea-db.h>
29
31{
33 gpointer backend_data; // though the backend_data is usually passed to every function it is usefull to have another global reference (e.g. in j_sql_statement_free)
34
35 struct
36 {
37 gpointer (*connection_open)(gpointer db_connection_info);
38 void (*connection_close)(gpointer db_connection);
39 gboolean (*transaction_start)(gpointer db_connection, GError** error);
40 gboolean (*transaction_commit)(gpointer db_connection, GError** error);
41 gboolean (*transaction_abort)(gpointer db_connection, GError** error);
42 gboolean (*statement_prepare)(gpointer db_connection, const char* sql, gpointer _stmt, GArray* types_in, GArray* types_out, GError** error);
43 gboolean (*statement_finalize)(gpointer db_connection, gpointer _stmt, GError** error);
44 gboolean (*statement_bind_null)(gpointer db_connection, gpointer _stmt, guint idx, GError** error);
45 gboolean (*statement_bind_value)(gpointer db_connection, gpointer _stmt, guint idx, JDBType type, JDBTypeValue* value, GError** error);
46 gboolean (*statement_step)(gpointer db_connection, gpointer _stmt, gboolean* found, GError** error);
47 gboolean (*statement_step_and_reset_check_done)(gpointer db_connection, gpointer _stmt, GError** error);
48 gboolean (*statement_reset)(gpointer db_connection, gpointer _stmt, GError** error);
49 gboolean (*statement_column)(gpointer db_connection, gpointer _stmt, guint idx, JDBType type, JDBTypeValue* value, GError** error);
50 gboolean (*sql_exec)(gpointer db_connection, const char* sql, GError** error);
52
53 struct
54 {
55 const gchar* autoincrement;
56 const gchar* uint64_type;
57 // SQLite does not support autoincrement with other types than INTEGER which is 64-bit signed. Therefore ID types should differ between backends instead of simply using unsigned bigint.
58 const gchar* id_type;
59 const gchar* select_last;
60 const gchar* quote;
61 } sql;
62};
63
65
66gboolean sql_generic_init(JSQLSpecifics* specifics);
67void sql_generic_fini(void);
68
69gboolean sql_generic_batch_start(gpointer backend_data, gchar const* namespace, JSemantics* semantics, gpointer* _batch, GError** error);
70gboolean sql_generic_batch_execute(gpointer backend_data, gpointer _batch, GError** error);
71
72gboolean sql_generic_schema_create(gpointer backend_data, gpointer _batch, gchar const* name, bson_t const* schema, GError** error);
73gboolean sql_generic_schema_get(gpointer backend_data, gpointer _batch, gchar const* name, bson_t* schema, GError** error);
74gboolean sql_generic_schema_delete(gpointer backend_data, gpointer _batch, gchar const* name, GError** error);
75
76gboolean sql_generic_insert(gpointer backend_data, gpointer _batch, gchar const* name, bson_t const* metadata, bson_t* id, GError** error);
77gboolean sql_generic_update(gpointer backend_data, gpointer _batch, gchar const* name, bson_t const* selector, bson_t const* metadata, GError** error);
78gboolean sql_generic_delete(gpointer backend_data, gpointer _batch, gchar const* name, bson_t const* selector, GError** error);
79gboolean sql_generic_query(gpointer backend_data, gpointer _batch, gchar const* name, bson_t const* selector, gpointer* iterator, GError** error);
80gboolean sql_generic_iterate(gpointer backend_data, gpointer _iterator, bson_t* metadata, GError** error);
81
82#endif
JDBType
Definition jdb-type.h:35
gboolean sql_generic_delete(gpointer backend_data, gpointer _batch, gchar const *name, bson_t const *selector, GError **error)
Definition sql-generic-dml.c:455
gboolean sql_generic_schema_delete(gpointer backend_data, gpointer _batch, gchar const *name, GError **error)
Definition sql-generic-ddl.c:383
gboolean sql_generic_init(JSQLSpecifics *specifics)
Definition sql-generic-common.c:29
gboolean sql_generic_schema_get(gpointer backend_data, gpointer _batch, gchar const *name, bson_t *schema, GError **error)
Definition sql-generic-dql.c:288
gboolean sql_generic_insert(gpointer backend_data, gpointer _batch, gchar const *name, bson_t const *metadata, bson_t *id, GError **error)
Definition sql-generic-dml.c:25
gboolean sql_generic_batch_start(gpointer backend_data, gchar const *namespace, JSemantics *semantics, gpointer *_batch, GError **error)
Definition sql-generic-tcl.c:108
gboolean sql_generic_query(gpointer backend_data, gpointer _batch, gchar const *name, bson_t const *selector, gpointer *iterator, GError **error)
Definition sql-generic-dql.c:991
gboolean sql_generic_iterate(gpointer backend_data, gpointer _iterator, bson_t *metadata, GError **error)
Definition sql-generic-dql.c:1198
gboolean sql_generic_update(gpointer backend_data, gpointer _batch, gchar const *name, bson_t const *selector, bson_t const *metadata, GError **error)
Definition sql-generic-dml.c:265
gboolean sql_generic_schema_create(gpointer backend_data, gpointer _batch, gchar const *name, bson_t const *schema, GError **error)
Definition sql-generic-ddl.c:25
gboolean sql_generic_batch_execute(gpointer backend_data, gpointer _batch, GError **error)
Definition sql-generic-tcl.c:147
void sql_generic_fini(void)
Definition sql-generic-common.c:67
Definition sql-generic.h:31
gboolean(* statement_step)(gpointer db_connection, gpointer _stmt, gboolean *found, GError **error)
Definition sql-generic.h:46
struct JSQLSpecifics::@14 sql
gboolean single_threaded
Definition sql-generic.h:32
gboolean(* statement_step_and_reset_check_done)(gpointer db_connection, gpointer _stmt, GError **error)
Definition sql-generic.h:47
gboolean(* statement_prepare)(gpointer db_connection, const char *sql, gpointer _stmt, GArray *types_in, GArray *types_out, GError **error)
Definition sql-generic.h:42
gboolean(* transaction_abort)(gpointer db_connection, GError **error)
Definition sql-generic.h:41
gboolean(* statement_bind_value)(gpointer db_connection, gpointer _stmt, guint idx, JDBType type, JDBTypeValue *value, GError **error)
Definition sql-generic.h:45
gpointer(* connection_open)(gpointer db_connection_info)
Definition sql-generic.h:37
gboolean(* statement_bind_null)(gpointer db_connection, gpointer _stmt, guint idx, GError **error)
Definition sql-generic.h:44
gboolean(* sql_exec)(gpointer db_connection, const char *sql, GError **error)
Definition sql-generic.h:50
gboolean(* transaction_start)(gpointer db_connection, GError **error)
Definition sql-generic.h:39
void(* connection_close)(gpointer db_connection)
Definition sql-generic.h:38
gboolean(* statement_column)(gpointer db_connection, gpointer _stmt, guint idx, JDBType type, JDBTypeValue *value, GError **error)
Definition sql-generic.h:49
struct JSQLSpecifics::@13 func
const gchar * quote
Definition sql-generic.h:60
const gchar * id_type
Definition sql-generic.h:58
gboolean(* statement_finalize)(gpointer db_connection, gpointer _stmt, GError **error)
Definition sql-generic.h:43
gboolean(* statement_reset)(gpointer db_connection, gpointer _stmt, GError **error)
Definition sql-generic.h:48
const gchar * autoincrement
Definition sql-generic.h:55
const gchar * select_last
Definition sql-generic.h:59
const gchar * uint64_type
Definition sql-generic.h:56
gboolean(* transaction_commit)(gpointer db_connection, GError **error)
Definition sql-generic.h:40
gpointer backend_data
Definition sql-generic.h:33
Definition jsemantics.c:42
Definition jdb-type.h:50