[libgda] SQLCipher: Fix enable as provider
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] SQLCipher: Fix enable as provider
- Date: Thu, 7 Mar 2019 19:54:37 +0000 (UTC)
commit 9952baac5d2800ab203f9f68cf701ac5371a7dc8
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date: Thu Mar 7 13:52:56 2019 -0600
SQLCipher: Fix enable as provider
Fix https://gitlab.gnome.org/GNOME/libgda/issues/181
.gitlab-ci.yml | 2 +-
libgda/gda-config.c | 7 +-
libgda/sqlite/Makefile.am | 11 +-
libgda/sqlite/gda-sqlite-provider.c | 284 ++++++++++++++++++++++++-
libgda/sqlite/gda-sqlite.h | 99 ++++++++-
libgda/sqlite/gda-symbols-util.c | 303 ---------------------------
libgda/sqlite/gda-symbols-util.h | 129 ------------
libgda/sqlite/meson.build | 4 +-
providers/sqlcipher/Makefile.am | 1 -
providers/sqlcipher/gda-sqlcipher-provider.c | 16 +-
providers/sqlcipher/libmain.c | 2 -
tests/parser/check_parser.c | 2 +
12 files changed, 399 insertions(+), 461 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b13403586..355d8f448 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -129,7 +129,7 @@ meson_build:
script:
- export PGPASSWORD=$POSTGRES_PASSWORD
- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
- - meson _build --prefix=/usr -Denable-debug=true -Denable-gtk-doc=true -Denable-tools=true
-Ddisable-crypto=true
+ - meson _build --prefix=/usr -Denable-debug=true -Denable-gtk-doc=true -Denable-tools=true
- cd _build
- ninja
- broadwayd &
diff --git a/libgda/gda-config.c b/libgda/gda-config.c
index 3d4cb8cea..701389107 100644
--- a/libgda/gda-config.c
+++ b/libgda/gda-config.c
@@ -1688,7 +1688,6 @@ gda_config_get_provider (const gchar *provider_name, GError **error)
GDA_CONFIG_UNLOCK ();
return ip->instance;
}
-
/* need to actually create the provider object */
if (!ip->handle) {
GdaProviderInfo *info = (GdaProviderInfo*) ip;
@@ -1847,6 +1846,7 @@ load_all_providers (void)
const gchar *dirname;
g_assert (unique_instance);
GdaConfigPrivate *priv = gda_config_get_instance_private (unique_instance);
+ GError *error = NULL;
dirname = g_getenv ("GDA_TOP_BUILD_DIR");
if (dirname) {
@@ -1864,8 +1864,11 @@ load_all_providers (void)
priv->providers_loaded = TRUE;
/* find SQLite provider, and instantiate it if not installed */
- _gda_config_sqlite_provider = gda_config_get_provider ("SQLite", NULL);
+ _gda_config_sqlite_provider = gda_config_get_provider ("SQLite", &error);
if (!_gda_config_sqlite_provider) {
+ g_message (_("No default SQLite Provider Trying to create a new one. Error was: %s"),
+ error && error->message ? error->message: _("No detail"));
+ g_clear_error (&error);
_gda_config_sqlite_provider = (GdaServerProvider*)
g_object_new (GDA_TYPE_SQLITE_PROVIDER, NULL);
}
diff --git a/libgda/sqlite/Makefile.am b/libgda/sqlite/Makefile.am
index 921dc8c4f..b38f8c8a9 100644
--- a/libgda/sqlite/Makefile.am
+++ b/libgda/sqlite/Makefile.am
@@ -10,7 +10,7 @@ sqliteinc= -I$(top_srcdir)/libgda/sqlite/sqlite-src \
endif
SUBDIRS+= virtual
-noinst_LTLIBRARIES = libgda-sqlite.la libgda-sqlcipher.la
+noinst_LTLIBRARIES = libgda-sqlite.la
if BDBSQL
noinst_LTLIBRARIES += libgda-bdbsqlite.la
endif
@@ -51,9 +51,7 @@ sqlitesources = \
gda-sqlite-util.c \
gda-sqlite-util.h \
gda-sqlite.h \
- keywords_hash.h \
- gda-symbols-util.h \
- gda-symbols-util.c
+ keywords_hash.h
BUILT_SOURCES = keywords_hash.code
@@ -70,11 +68,6 @@ libgda_bdbsqlite_la_CFLAGS = $(BDBSQL_CFLAGS) -DPNAME=\""BDBSql"\" -DCLASS_PREFI
libgda_bdbsqlite_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED)
libgda_bdbsqlite_la_LIBADD =
-libgda_sqlcipher_la_SOURCES = $(sqlitesources)
-libgda_sqlcipher_la_CFLAGS = -DPNAME=\""SQLCipher"\" -DCLASS_PREFIX=\""GdaSQLCipher"\" -DSTATIC_SQLITE
-DSQLITE_HAS_CODEC -DSEARCH_LIB_PATH=\"""\"
-libgda_sqlcipher_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED)
-libgda_sqlcipher_la_LIBADD =
-
gdaincludedir=$(includedir)/libgda-$(GDA_ABI_MAJOR_VERSION).$(GDA_ABI_MINOR_VERSION)/libgda/sqlite
gdainclude_HEADERS=$(sqliteheaders)
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index c7aa197e6..3702804f9 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -67,7 +67,6 @@
#include <libgda/gda-debug-macros.h>
#include <libgda/gda-provider-meta.h>
#include <libgda/gda-provider.h>
-#include "gda-symbols-util.h"
#define FILE_EXTENSION ".db"
static gchar *get_table_nth_column_name (GdaServerProvider *prov, GdaConnection *cnc, const gchar
*table_name, gint pos);
@@ -951,7 +950,7 @@ gda_sqlite_provider_class_init (GdaSqliteProviderClass *klass)
g_param_spec_boolean ("is-default", "Is Default Provider",
_("Set to TRUE if the provider is the internal default"),
TRUE,
-
(G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
(G_PARAM_WRITABLE | G_PARAM_EXPLICIT_NOTIFY)));
/* set virtual functions */
gda_server_provider_set_impl_functions (GDA_SERVER_PROVIDER_CLASS (klass),
GDA_SERVER_PROVIDER_FUNCTIONS_BASE,
@@ -967,9 +966,9 @@ gda_sqlite_provider_class_init (GdaSqliteProviderClass *klass)
#ifdef HAVE_SQLITE
GModule *module2;
- module2 = find_sqlite_library ("libsqlite3");
+ module2 = gda_sqlite_find_library ("libsqlite3");
if (module2)
- load_symbols (module2, &s3r);
+ gda_sqlite_load_symbols (module2, &s3r);
if (s3r == NULL) {
g_warning (_("Can't find libsqlite3." G_MODULE_SUFFIX " file."));
}
@@ -5127,3 +5126,280 @@ gda_sqlite_provider_iface_get_last_inserted (GdaProvider *provider,
return NULL;
}
+static GModule *
+find_sqlite_in_dir (const gchar *dir_name, const gchar *name_part)
+{
+ GDir *dir;
+ GError *err = NULL;
+ const gchar *name;
+ GModule *handle = NULL;
+
+#ifdef GDA_DEBUG_NO
+ g_print ("Looking for '%s' in %s\n", name_part, dir_name);
+#endif
+ dir = g_dir_open (dir_name, 0, &err);
+ if (err) {
+ gda_log_error (err->message);
+ g_error_free (err);
+ return FALSE;
+ }
+
+ while ((name = g_dir_read_name (dir))) {
+ const gchar *ptr1, *ptr2;
+ ptr1 = g_strrstr (name, "." G_MODULE_SUFFIX);
+ if (! ptr1)
+ continue;
+ ptr2 = g_strrstr (name, name_part);
+ if (!ptr2)
+ continue;
+ if (ptr1 < ptr2)
+ continue;
+
+ gchar *path;
+
+ path = g_build_path (G_DIR_SEPARATOR_S, dir_name, name, NULL);
+ handle = g_module_open (path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+ g_free (path);
+ if (!handle) {
+ /*g_warning (_("Error: %s"), g_module_error ());*/
+ continue;
+ }
+
+ gpointer func;
+ if (g_module_symbol (handle, "sqlite3_open", &func)) {
+#ifdef GDA_DEBUG_NO
+ path = g_build_path (G_DIR_SEPARATOR_S, dir_name, name, NULL);
+ g_print ("'%s' found as: '%s'\n", name_part, path);
+ g_free (path);
+#endif
+ break;
+ }
+ else {
+ g_module_close (handle);
+ handle = NULL;
+ }
+
+ }
+ /* free memory */
+ g_dir_close (dir);
+ return handle;
+}
+
+GModule *
+gda_sqlite_find_library (const gchar *name_part)
+{
+ GModule *handle = NULL;
+ const gchar *env;
+
+ /* first use the compile time SEARCH_LIB_PATH */
+ if (SEARCH_LIB_PATH) {
+ gchar **array;
+ gint i;
+ array = g_strsplit (SEARCH_LIB_PATH, ":", 0);
+ for (i = 0; array[i]; i++) {
+ handle = find_sqlite_in_dir (array [i], name_part);
+ if (handle)
+ break;
+ }
+ g_strfreev (array);
+ if (handle)
+ return handle;
+ }
+
+ /* then try by 'normal' shared library finding */
+ handle = g_module_open (name_part, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+ if (handle) {
+ gpointer func;
+ if (g_module_symbol (handle, "sqlite3_open", &func)) {
+#ifdef GDA_DEBUG_NO
+ g_print ("'%s' found using default shared library finding\n", name_part);
+#endif
+ return handle;
+ }
+
+ g_module_close (handle);
+ handle = NULL;
+ }
+
+ /* lastly, use LD_LIBRARY_PATH */
+ env = g_getenv ("LD_LIBRARY_PATH");
+ if (env) {
+ gchar **array;
+ gint i;
+ array = g_strsplit (env, ":", 0);
+ for (i = 0; array[i]; i++) {
+ handle = find_sqlite_in_dir (array [i], name_part);
+ if (handle)
+ break;
+ }
+ g_strfreev (array);
+ if (handle)
+ return handle;
+ }
+
+ return NULL;
+}
+
+
+void
+gda_sqlite_load_symbols (GModule *module, Sqlite3ApiRoutines** apilib)
+{
+ g_assert (module);
+ (*apilib) = g_new (Sqlite3ApiRoutines, 1);
+
+ if (! g_module_symbol (module, "sqlite3_bind_blob", (gpointer*) &((*apilib)->sqlite3_bind_blob)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_bind_double", (gpointer*) &((*apilib)->sqlite3_bind_double)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_bind_int", (gpointer*) &((*apilib)->sqlite3_bind_int)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_bind_int64", (gpointer*) &((*apilib)->sqlite3_bind_int64)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_bind_null", (gpointer*) &((*apilib)->sqlite3_bind_null)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_bind_text", (gpointer*) &((*apilib)->sqlite3_bind_text)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_bind_zeroblob", (gpointer*)
&((*apilib)->sqlite3_bind_zeroblob)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_blob_bytes", (gpointer*) &((*apilib)->sqlite3_blob_bytes)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_blob_close", (gpointer*) &((*apilib)->sqlite3_blob_close)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_blob_open", (gpointer*) &((*apilib)->sqlite3_blob_open)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_blob_read", (gpointer*) &((*apilib)->sqlite3_blob_read)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_blob_write", (gpointer*) &((*apilib)->sqlite3_blob_write)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_busy_timeout", (gpointer*)
&((*apilib)->sqlite3_busy_timeout)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_changes", (gpointer*) &((*apilib)->sqlite3_changes)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_clear_bindings", (gpointer*)
&((*apilib)->sqlite3_clear_bindings)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_close", (gpointer*) &((*apilib)->sqlite3_close)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_close_v2", (gpointer*) &((*apilib)->sqlite3_close_v2)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_blob", (gpointer*) &((*apilib)->sqlite3_column_blob)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_bytes", (gpointer*)
&((*apilib)->sqlite3_column_bytes)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_count", (gpointer*)
&((*apilib)->sqlite3_column_count)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_database_name", (gpointer*)
&((*apilib)->sqlite3_column_database_name)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_decltype", (gpointer*)
&((*apilib)->sqlite3_column_decltype)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_double", (gpointer*)
&((*apilib)->sqlite3_column_double)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_int", (gpointer*) &((*apilib)->sqlite3_column_int)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_int64", (gpointer*)
&((*apilib)->sqlite3_column_int64)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_name", (gpointer*) &((*apilib)->sqlite3_column_name)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_origin_name", (gpointer*)
&((*apilib)->sqlite3_column_origin_name)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_table_name", (gpointer*)
&((*apilib)->sqlite3_column_table_name)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_text", (gpointer*) &((*apilib)->sqlite3_column_text)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_column_type", (gpointer*) &((*apilib)->sqlite3_column_type)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_config", (gpointer*) &((*apilib)->sqlite3_config)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_create_function", (gpointer*)
&((*apilib)->sqlite3_create_function)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_create_module", (gpointer*)
&((*apilib)->sqlite3_create_module)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_db_handle", (gpointer*) &((*apilib)->sqlite3_db_handle)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_declare_vtab", (gpointer*)
&((*apilib)->sqlite3_declare_vtab)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_errcode", (gpointer*) &((*apilib)->sqlite3_errcode)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_errmsg", (gpointer*) &((*apilib)->sqlite3_errmsg)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_exec", (gpointer*) &((*apilib)->sqlite3_exec)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_extended_result_codes", (gpointer*)
&((*apilib)->sqlite3_extended_result_codes)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_finalize", (gpointer*) &((*apilib)->sqlite3_finalize)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_free", (gpointer*) &((*apilib)->sqlite3_free)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_free_table", (gpointer*) &((*apilib)->sqlite3_free_table)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_get_table", (gpointer*) &((*apilib)->sqlite3_get_table)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_last_insert_rowid", (gpointer*)
&((*apilib)->sqlite3_last_insert_rowid)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_malloc", (gpointer*) &((*apilib)->sqlite3_malloc)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_mprintf", (gpointer*) &((*apilib)->sqlite3_mprintf)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_open", (gpointer*) &((*apilib)->sqlite3_open)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_open_v2", (gpointer*) &((*apilib)->sqlite3_open_v2)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_prepare", (gpointer*) &((*apilib)->sqlite3_prepare)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_prepare_v2", (gpointer*) &((*apilib)->sqlite3_prepare_v2)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_reset", (gpointer*) &((*apilib)->sqlite3_reset)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_result_blob", (gpointer*) &((*apilib)->sqlite3_result_blob)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_result_double", (gpointer*)
&((*apilib)->sqlite3_result_double)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_result_error", (gpointer*)
&((*apilib)->sqlite3_result_error)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_result_int", (gpointer*) &((*apilib)->sqlite3_result_int)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_result_int64", (gpointer*)
&((*apilib)->sqlite3_result_int64)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_result_null", (gpointer*) &((*apilib)->sqlite3_result_null)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_result_text", (gpointer*) &((*apilib)->sqlite3_result_text)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_step", (gpointer*) &((*apilib)->sqlite3_step)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_table_column_metadata", (gpointer*)
&((*apilib)->sqlite3_table_column_metadata)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_threadsafe", (gpointer*) &((*apilib)->sqlite3_threadsafe)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_value_blob", (gpointer*) &((*apilib)->sqlite3_value_blob)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_value_bytes", (gpointer*) &((*apilib)->sqlite3_value_bytes)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_value_int", (gpointer*) &((*apilib)->sqlite3_value_int)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_value_int64", (gpointer*) &((*apilib)->sqlite3_value_int64)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_value_double", (gpointer*)
&((*apilib)->sqlite3_value_double)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_value_text", (gpointer*) &((*apilib)->sqlite3_value_text)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_value_type", (gpointer*) &((*apilib)->sqlite3_value_type)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_key", (gpointer*) &((*apilib)->sqlite3_key)))
+ (*apilib)->sqlite3_key = NULL;
+ if (! g_module_symbol (module, "sqlite3_key_v2", (gpointer*) &((*apilib)->sqlite3_key_v2)))
+ (*apilib)->sqlite3_key_v2 = NULL;
+ if (! g_module_symbol (module, "sqlite3_rekey", (gpointer*) &((*apilib)->sqlite3_key)))
+ (*apilib)->sqlite3_rekey = NULL;
+
+ if (! g_module_symbol (module, "sqlite3_create_collation", (gpointer*)
&((*apilib)->sqlite3_create_collation)))
+ goto onerror;
+ if (! g_module_symbol (module, "sqlite3_enable_load_extension", (gpointer*)
&((*apilib)->sqlite3_enable_load_extension)))
+ (*apilib)->sqlite3_enable_load_extension = NULL;
+ return;
+
+ onerror:
+ g_free ((*apilib));
+ apilib = NULL;
+ g_module_close (module);
+}
+
+
diff --git a/libgda/sqlite/gda-sqlite.h b/libgda/sqlite/gda-sqlite.h
index bb1a4ae7c..7915735de 100644
--- a/libgda/sqlite/gda-sqlite.h
+++ b/libgda/sqlite/gda-sqlite.h
@@ -37,7 +37,6 @@
#define SQLITE3_CALL(x) (s3r->x)
#else
#include <sqlite3.h>
- #include "gda-symbols-util.h"
#define SQLITE3_CALL(p,x) (((Sqlite3ApiRoutines*) gda_sqlite_provider_get_api(p))->x)
#if (SQLITE_VERSION_NUMBER < 3005000)
typedef sqlite_int64 sqlite3_int64;
@@ -58,4 +57,102 @@ typedef struct {
extern GHashTable *error_blobs_hash;
+
+/**
+ * API interface to SQLite derived providers
+ */
+typedef struct {
+ int (*sqlite3_bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
+ int (*sqlite3_bind_double)(sqlite3_stmt*,int,double);
+ int (*sqlite3_bind_int)(sqlite3_stmt*,int,int);
+ int (*sqlite3_bind_int64)(sqlite3_stmt*,int,sqlite_int64);
+ int (*sqlite3_bind_null)(sqlite3_stmt*,int);
+ int (*sqlite3_bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
+ int (*sqlite3_bind_zeroblob)(sqlite3_stmt*,int,int);
+ int (*sqlite3_blob_bytes)(sqlite3_blob*);
+ int (*sqlite3_blob_close)(sqlite3_blob*);
+ int (*sqlite3_blob_open)(sqlite3*,const char*,const char*,const
char*,sqlite3_int64,int,sqlite3_blob**);
+ int (*sqlite3_blob_read)(sqlite3_blob*,void*,int,int);
+ int (*sqlite3_blob_write)(sqlite3_blob*,const void*,int,int);
+
+ int (*sqlite3_busy_timeout)(sqlite3*,int ms);
+ int (*sqlite3_changes)(sqlite3*);
+ int (*sqlite3_clear_bindings)(sqlite3_stmt*);
+ int (*sqlite3_close)(sqlite3*);
+ int (*sqlite3_close_v2)(sqlite3*);
+
+ const void * (*sqlite3_column_blob)(sqlite3_stmt*,int iCol);
+ int (*sqlite3_column_bytes)(sqlite3_stmt*,int iCol);
+ int (*sqlite3_column_count)(sqlite3_stmt*pStmt);
+ const char * (*sqlite3_column_database_name)(sqlite3_stmt*,int);
+ const char * (*sqlite3_column_decltype)(sqlite3_stmt*,int i);
+ double (*sqlite3_column_double)(sqlite3_stmt*,int iCol);
+ int (*sqlite3_column_int)(sqlite3_stmt*,int iCol);
+ sqlite_int64 (*sqlite3_column_int64)(sqlite3_stmt*,int iCol);
+ const char * (*sqlite3_column_name)(sqlite3_stmt*,int);
+ const char * (*sqlite3_column_origin_name)(sqlite3_stmt*,int);
+ const char * (*sqlite3_column_table_name)(sqlite3_stmt*,int);
+ const unsigned char * (*sqlite3_column_text)(sqlite3_stmt*,int iCol);
+ int (*sqlite3_column_type)(sqlite3_stmt*,int iCol);
+
+ int (*sqlite3_config) (int, ...);
+
+ int (*sqlite3_create_function)(sqlite3*,const char*,int,int,void*,void
(*xFunc)(sqlite3_context*,int,sqlite3_value**),void (*xStep)(sqlite3_context*,int,sqlite3_value**),void
(*xFinal)(sqlite3_context*));
+ int (*sqlite3_create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
+ sqlite3 * (*sqlite3_db_handle)(sqlite3_stmt*);
+ int (*sqlite3_declare_vtab)(sqlite3*,const char*);
+
+ int (*sqlite3_errcode)(sqlite3*db);
+ const char * (*sqlite3_errmsg)(sqlite3*);
+
+ int (*sqlite3_exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
+ int (*sqlite3_extended_result_codes)(sqlite3*,int);
+ int (*sqlite3_finalize)(sqlite3_stmt*pStmt);
+ void (*sqlite3_free)(void*);
+ void (*sqlite3_free_table)(char**result);
+ int (*sqlite3_get_table)(sqlite3*,const char*,char***,int*,int*,char**);
+ sqlite_int64 (*sqlite3_last_insert_rowid)(sqlite3*);
+
+ void *(*sqlite3_malloc)(int);
+ char * (*sqlite3_mprintf)(const char*,...);
+ int (*sqlite3_open)(const char*,sqlite3**);
+ int (*sqlite3_open_v2)(const char *filename, sqlite3 **ppDb, int flags, const char *zVfs);
+ int (*sqlite3_prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
+ int (*sqlite3_prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
+
+ int (*sqlite3_reset)(sqlite3_stmt*pStmt);
+ void (*sqlite3_result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
+ void (*sqlite3_result_double)(sqlite3_context*,double);
+ void (*sqlite3_result_error)(sqlite3_context*,const char*,int);
+ void (*sqlite3_result_int)(sqlite3_context*,int);
+ void (*sqlite3_result_int64)(sqlite3_context*,sqlite_int64);
+ void (*sqlite3_result_null)(sqlite3_context*);
+ void (*sqlite3_result_text)(sqlite3_context*,const char*,int,void(*)(void*));
+
+ int (*sqlite3_step)(sqlite3_stmt*);
+ int (*sqlite3_table_column_metadata)(sqlite3*,const char*,const char*,const char*,char const**,char
const**,int*,int*,int*);
+ int (*sqlite3_threadsafe)(void);
+
+ const void * (*sqlite3_value_blob)(sqlite3_value*);
+ int (*sqlite3_value_bytes)(sqlite3_value*);
+ int (*sqlite3_value_int)(sqlite3_value*);
+ double (*sqlite3_value_double)(sqlite3_value*);
+ sqlite3_int64 (*sqlite3_value_int64)(sqlite3_value*);
+ const unsigned char * (*sqlite3_value_text)(sqlite3_value*);
+ int (*sqlite3_value_type)(sqlite3_value*);
+
+ int (*sqlite3_key)(sqlite3 *, const void *, int);
+ int (*sqlite3_key_v2)(sqlite3 *, const char *, const void *, int);
+ int (*sqlite3_rekey)(sqlite3 *, const void *, int);
+
+ int (*sqlite3_create_collation) (sqlite3*, const char *, int, void*, int(*xCompare)(void*,int,const
void*,int,const void*));
+
+ int (*sqlite3_enable_load_extension) (sqlite3 *, int);
+} Sqlite3ApiRoutines;
+
+extern Sqlite3ApiRoutines *s3r;
+
+GModule *gda_sqlite_find_library (const gchar *name_part);
+void gda_sqlite_load_symbols (GModule *module, Sqlite3ApiRoutines **apilib);
+
#endif
diff --git a/libgda/sqlite/meson.build b/libgda/sqlite/meson.build
index ee60a31f9..217daee70 100644
--- a/libgda/sqlite/meson.build
+++ b/libgda/sqlite/meson.build
@@ -43,9 +43,7 @@ sqlitesources_provider = files([
'gda-sqlite-util.c',
'gda-sqlite-util.h',
'gda-sqlite.h',
- 'keywords_hash.h',
- 'gda-symbols-util.h',
- 'gda-symbols-util.c'
+ 'keywords_hash.h'
])
sqlitesources = []
sqlitesources += sqlitesources_provider
diff --git a/providers/sqlcipher/Makefile.am b/providers/sqlcipher/Makefile.am
index 6daf73f4b..f742de743 100644
--- a/providers/sqlcipher/Makefile.am
+++ b/providers/sqlcipher/Makefile.am
@@ -27,7 +27,6 @@ libgda_sqlcipher_la_SOURCES = \
libgda_sqlcipher_la_LDFLAGS = -export-dynamic -module -avoid-version $(NO_UNDEFINED)
$(LIBTOOL_PROV_EXPORT_OPTIONS)
libgda_sqlcipher_la_LIBADD = \
- $(top_builddir)/libgda/sqlite/libgda-sqlcipher.la \
$(top_builddir)/libgda/libgda-6.0.la \
$(COREDEPS_LIBS) \
$(LIBCRYPTO_LIBS)
diff --git a/providers/sqlcipher/gda-sqlcipher-provider.c b/providers/sqlcipher/gda-sqlcipher-provider.c
index 246b8ca42..451af9fa8 100644
--- a/providers/sqlcipher/gda-sqlcipher-provider.c
+++ b/providers/sqlcipher/gda-sqlcipher-provider.c
@@ -19,7 +19,7 @@
#include <glib/gi18n-lib.h>
#include <providers/sqlcipher/gda-sqlcipher-provider.h>
-#include "libgda/sqlite/gda-symbols-util.h"
+#include <libgda/sqlite/gda-sqlite.h>
// API routines from library
Sqlite3ApiRoutines *libapi;
@@ -40,14 +40,18 @@ gda_sqlcipher_provider_class_init (GdaSqlcipherProviderClass *klass)
{
GModule *module2;
- module2 = find_sqlite_library ("sqlcipher");
+ module2 = gda_sqlite_find_library ("sqlcipher");
if (module2)
- load_symbols (module2, &libapi);
- if (s3r == NULL) {
- g_warning (_("Can't find libsqlite3." G_MODULE_SUFFIX " file."));
+ gda_sqlite_load_symbols (module2, &libapi);
+ if (libapi == NULL) {
+ g_warning (_("Can't find sqlcipher." G_MODULE_SUFFIX " file."));
}
GDA_SQLITE_PROVIDER_CLASS (gda_sqlcipher_provider_parent_class)->get_api =
gda_sqlcipher_provider_get_api_internal;
}
static void
-gda_sqlcipher_provider_init (GdaSqlcipherProvider *object) {}
+gda_sqlcipher_provider_init (GdaSqlcipherProvider *object) {
+ g_object_set (G_OBJECT (object), "is-default", TRUE, NULL);
+}
+
+
diff --git a/providers/sqlcipher/libmain.c b/providers/sqlcipher/libmain.c
index e1423f208..d6990af49 100644
--- a/providers/sqlcipher/libmain.c
+++ b/providers/sqlcipher/libmain.c
@@ -29,7 +29,6 @@
#include "gda-sqlcipher-provider.h"
#include <libgda/gda-server-provider-extra.h>
#include <libgda/binreloc/gda-binreloc.h>
-#include <libgda/sqlite/gda-symbols-util.h>
static gchar *module_path = NULL;
const gchar *plugin_get_name (void);
@@ -108,7 +107,6 @@ GdaServerProvider *
plugin_create_provider (void)
{
GdaServerProvider *prov;
-
prov = (GdaServerProvider*) g_object_new (GDA_TYPE_SQLCIPHER_PROVIDER, NULL);
g_object_set_data ((GObject *) prov, "GDA_PROVIDER_DIR", module_path);
return prov;
diff --git a/tests/parser/check_parser.c b/tests/parser/check_parser.c
index eade05588..926526780 100644
--- a/tests/parser/check_parser.c
+++ b/tests/parser/check_parser.c
@@ -57,6 +57,7 @@ main (int argc, char** argv)
/* create parsers */
parsers_hash = g_hash_table_new (g_str_hash, g_str_equal);
providers_model = gda_config_list_providers ();
+ g_message ("Providers found: %d", gda_data_model_get_n_rows (providers_model));
for (i = 0; i < gda_data_model_get_n_rows (providers_model); i++) {
const GValue *pname;
GError *lerror = NULL;
@@ -239,6 +240,7 @@ create_parser_for_provider (const gchar *prov_name)
GdaSqlParser *parser;
GError *error = NULL;
+ g_message ("Trying to get provider: %s", prov_name);
prov = gda_config_get_provider (prov_name, &error);
if (!prov)
g_error ("Could not create provider for '%s': %s\n", prov_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]