[tracker] libtracker-db: Remove static stored procedures functionality
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker] libtracker-db: Remove static stored procedures functionality
- Date: Thu, 16 Apr 2009 08:58:50 -0400 (EDT)
commit 797cdecbed4be4e574e4ce524e4a921a4e90e97c
Author: Jürg Billeter <j bitron ch>
Date: Tue Apr 14 11:12:48 2009 +0200
libtracker-db: Remove static stored procedures functionality
Replaced by dynamic statement preparation.
---
data/db/Makefile.am | 1 -
data/db/sqlite-stored-procs.sql | 4 -
src/libtracker-data/tracker-data-manager.c | 22 ---
src/libtracker-data/tracker-data-manager.h | 4 -
src/libtracker-db/tracker-db-interface-sqlite.c | 117 ----------------
src/libtracker-db/tracker-db-interface.c | 110 ---------------
src/libtracker-db/tracker-db-interface.h | 29 ----
src/libtracker-db/tracker-db-manager.c | 162 -----------------------
8 files changed, 0 insertions(+), 449 deletions(-)
diff --git a/data/db/Makefile.am b/data/db/Makefile.am
index 0b2a9f0..0275ea1 100644
--- a/data/db/Makefile.am
+++ b/data/db/Makefile.am
@@ -5,7 +5,6 @@ configdir = $(datadir)/tracker
config_DATA = \
sqlite-contents.sql \
sqlite-fulltext.sql \
- sqlite-stored-procs.sql \
sqlite-tracker.sql
EXTRA_DIST = $(config_DATA)
diff --git a/data/db/sqlite-stored-procs.sql b/data/db/sqlite-stored-procs.sql
deleted file mode 100644
index ce6e61a..0000000
--- a/data/db/sqlite-stored-procs.sql
+++ /dev/null
@@ -1,4 +0,0 @@
-/*
- * This file is dedicated to stored procedures
- */
-
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index dcfa4ec..d8d1eae 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -826,27 +826,6 @@ tracker_data_manager_get_language (void)
return private->language;
}
-TrackerDBResultSet *
-tracker_data_manager_exec_proc (TrackerDBInterface *iface,
- const gchar *procedure,
- ...)
-{
- TrackerDBResultSet *result_set;
- va_list args;
-
- g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (iface), NULL);
- g_return_val_if_fail (procedure != NULL, NULL);
-
- va_start (args, procedure);
- result_set = tracker_db_interface_execute_vprocedure (iface,
- NULL,
- procedure,
- args);
- va_end (args);
-
- return result_set;
-}
-
gint
tracker_data_manager_get_db_option_int (const gchar *option)
{
@@ -885,7 +864,6 @@ tracker_data_manager_set_db_option_int (const gchar *option,
{
TrackerDBInterface *iface;
TrackerDBStatement *stmt;
- TrackerDBResultSet *result_set;
gchar *str;
g_return_if_fail (option != NULL);
diff --git a/src/libtracker-data/tracker-data-manager.h b/src/libtracker-data/tracker-data-manager.h
index f1015e0..1241573 100644
--- a/src/libtracker-data/tracker-data-manager.h
+++ b/src/libtracker-data/tracker-data-manager.h
@@ -48,10 +48,6 @@ void tracker_data_manager_shutdown (void);
TrackerConfig * tracker_data_manager_get_config (void);
TrackerLanguage * tracker_data_manager_get_language (void);
-/* Operations for TrackerDBInterface */
-TrackerDBResultSet *tracker_data_manager_exec_proc (TrackerDBInterface *iface,
- const gchar *procedure,
- ...);
gint tracker_data_manager_get_db_option_int (const gchar *option);
void tracker_data_manager_set_db_option_int (const gchar *option,
gint value);
diff --git a/src/libtracker-db/tracker-db-interface-sqlite.c b/src/libtracker-db/tracker-db-interface-sqlite.c
index 30a6d74..2347acc 100644
--- a/src/libtracker-db/tracker-db-interface-sqlite.c
+++ b/src/libtracker-db/tracker-db-interface-sqlite.c
@@ -38,7 +38,6 @@ struct TrackerDBInterfaceSqlitePrivate {
GHashTable *dynamic_statements;
GHashTable *statements;
- GHashTable *procedures;
GSList *function_data;
GSList *aggregate_data;
@@ -188,10 +187,6 @@ tracker_db_interface_sqlite_finalize (GObject *object)
g_hash_table_destroy (priv->statements);
- if (priv->procedures) {
- g_hash_table_unref (priv->procedures);
- }
-
g_slist_foreach (priv->function_data, (GFunc) g_free, NULL);
g_slist_free (priv->function_data);
@@ -531,24 +526,6 @@ internal_sqlite3_aggregate_final (sqlite3_context *context)
}
static void
-tracker_db_interface_sqlite_set_procedure_table (TrackerDBInterface *db_interface,
- GHashTable *procedure_table)
-{
- TrackerDBInterfaceSqlitePrivate *priv;
-
- priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
-
- if (priv->procedures) {
- g_hash_table_unref (priv->procedures);
- priv->procedures = NULL;
- }
-
- if (procedure_table) {
- priv->procedures = g_hash_table_ref (procedure_table);
- }
-}
-
-static void
foreach_print_error (gpointer key, gpointer value, gpointer stmt)
{
if (value == stmt)
@@ -639,97 +616,6 @@ create_result_set_from_stmt (TrackerDBInterfaceSqlite *interface,
return result_set;
}
-static sqlite3_stmt *
-get_stored_stmt (TrackerDBInterfaceSqlite *db_interface,
- const gchar *procedure_name)
-{
- TrackerDBInterfaceSqlitePrivate *priv;
- sqlite3_stmt *stmt;
- gint result;
-
- priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
- stmt = g_hash_table_lookup (priv->statements, procedure_name);
-
- if (!stmt || sqlite3_expired (stmt) != 0) {
- const gchar *procedure;
-
- procedure = g_hash_table_lookup (priv->procedures, procedure_name);
-
- if (!procedure) {
- g_critical ("Sqlite3 prepared query:'%s' was not found",
- procedure_name);
- return NULL;
- }
-
- /* g_debug ("Running procedure: '%s'", procedure); */
- result = sqlite3_prepare_v2 (priv->db, procedure, -1, &stmt, NULL);
-
- if (result == SQLITE_OK && stmt) {
- g_hash_table_insert (priv->statements,
- g_strdup (procedure_name),
- stmt);
- }
- } else {
- sqlite3_reset (stmt);
- }
-
- return stmt;
-}
-
-static TrackerDBResultSet *
-tracker_db_interface_sqlite_execute_procedure (TrackerDBInterface *db_interface,
- GError **error,
- const gchar *procedure_name,
- va_list args)
-{
- TrackerDBInterfaceSqlitePrivate *priv;
- sqlite3_stmt *stmt;
- gint stmt_args, n_args;
- gchar *str;
-
- priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
- stmt = get_stored_stmt (TRACKER_DB_INTERFACE_SQLITE (db_interface), procedure_name);
- stmt_args = sqlite3_bind_parameter_count (stmt);
-
- for (n_args = 1; n_args <= stmt_args; n_args++) {
- str = va_arg (args, gchar *);
- sqlite3_bind_text (stmt, n_args, str, -1, SQLITE_STATIC);
- }
-
- return create_result_set_from_stmt (TRACKER_DB_INTERFACE_SQLITE (db_interface), stmt, error);
-}
-
-static TrackerDBResultSet *
-tracker_db_interface_sqlite_execute_procedure_len (TrackerDBInterface *db_interface,
- GError **error,
- const gchar *procedure_name,
- va_list args)
-{
- TrackerDBInterfaceSqlitePrivate *priv;
- sqlite3_stmt *stmt;
- gint stmt_args, n_args, len;
- gchar *str;
-
- priv = TRACKER_DB_INTERFACE_SQLITE_GET_PRIVATE (db_interface);
- stmt = get_stored_stmt (TRACKER_DB_INTERFACE_SQLITE (db_interface), procedure_name);
- stmt_args = sqlite3_bind_parameter_count (stmt);
-
- for (n_args = 1; n_args <= stmt_args; n_args++) {
- str = va_arg (args, gchar *);
- len = va_arg (args, gint);
-
- if (len == -1) {
- /* Assume we're dealing with strings */
- sqlite3_bind_text (stmt, n_args, str, len, SQLITE_STATIC);
- } else {
- /* Deal with it as a blob */
- sqlite3_bind_blob (stmt, n_args, str, len, SQLITE_STATIC);
- }
- }
-
- return create_result_set_from_stmt (TRACKER_DB_INTERFACE_SQLITE (db_interface), stmt, error);
-}
-
static TrackerDBResultSet *
tracker_db_interface_sqlite_execute_query (TrackerDBInterface *db_interface,
GError **error,
@@ -771,9 +657,6 @@ tracker_db_interface_sqlite_execute_query (TrackerDBInterface *db_interface,
static void
tracker_db_interface_sqlite_iface_init (TrackerDBInterfaceIface *iface)
{
- iface->set_procedure_table = tracker_db_interface_sqlite_set_procedure_table;
- iface->execute_procedure = tracker_db_interface_sqlite_execute_procedure;
- iface->execute_procedure_len = tracker_db_interface_sqlite_execute_procedure_len;
iface->create_statement = tracker_db_interface_sqlite_create_statement;
iface->execute_query = tracker_db_interface_sqlite_execute_query;
}
diff --git a/src/libtracker-db/tracker-db-interface.c b/src/libtracker-db/tracker-db-interface.c
index 3d356b7..98a65c9 100644
--- a/src/libtracker-db/tracker-db-interface.c
+++ b/src/libtracker-db/tracker-db-interface.c
@@ -320,116 +320,6 @@ tracker_db_interface_execute_query (TrackerDBInterface *interface,
return result_set;
}
-void
-tracker_db_interface_set_procedure_table (TrackerDBInterface *interface,
- GHashTable *procedure_table)
-{
- g_return_if_fail (TRACKER_IS_DB_INTERFACE (interface));
- g_return_if_fail (procedure_table != NULL);
-
- if (!TRACKER_DB_INTERFACE_GET_IFACE (interface)->set_procedure_table) {
- g_critical ("Database abstraction %s doesn't implement "
- "the method set_procedure_table()",
- G_OBJECT_TYPE_NAME (interface));
- return;
- }
-
- TRACKER_DB_INTERFACE_GET_IFACE (interface)->set_procedure_table (interface,
- procedure_table);
-}
-
-TrackerDBResultSet *
-tracker_db_interface_execute_vprocedure (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- va_list args)
-{
- TrackerDBResultSet *result_set;
-
- g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (interface), NULL);
- g_return_val_if_fail (procedure != NULL, NULL);
-
- if (!TRACKER_DB_INTERFACE_GET_IFACE (interface)->execute_procedure) {
- g_critical ("Database abstraction %s doesn't implement "
- "the method execute_procedure()",
- G_OBJECT_TYPE_NAME (interface));
- return NULL;
- }
-
- result_set = TRACKER_DB_INTERFACE_GET_IFACE (interface)->execute_procedure (interface,
- error,
- procedure,
- args);
-
- return ensure_result_set_state (result_set);
-}
-
-
-
-TrackerDBResultSet *
-tracker_db_interface_execute_vprocedure_len (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- va_list args)
-{
- TrackerDBResultSet *result_set;
-
- g_return_val_if_fail (TRACKER_IS_DB_INTERFACE (interface), NULL);
- g_return_val_if_fail (procedure != NULL, NULL);
-
- if (!TRACKER_DB_INTERFACE_GET_IFACE (interface)->execute_procedure_len) {
- g_critical ("Database abstraction %s doesn't implement "
- "the method execute_procedure_len()",
- G_OBJECT_TYPE_NAME (interface));
- return NULL;
- }
-
- result_set = TRACKER_DB_INTERFACE_GET_IFACE (interface)->execute_procedure_len (interface,
- error,
- procedure,
- args);
-
- return ensure_result_set_state (result_set);
-}
-
-TrackerDBResultSet *
-tracker_db_interface_execute_procedure (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- ...)
-{
- TrackerDBResultSet *result_set;
- va_list args;
-
- va_start (args, procedure);
- result_set = tracker_db_interface_execute_vprocedure (interface,
- error,
- procedure,
- args);
- va_end (args);
-
- return result_set;
-}
-
-TrackerDBResultSet *
-tracker_db_interface_execute_procedure_len (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- ...)
-{
- TrackerDBResultSet *result_set;
- va_list args;
-
- va_start (args, procedure);
- result_set = tracker_db_interface_execute_vprocedure_len (interface,
- error,
- procedure,
- args);
- va_end (args);
-
- return result_set;
-}
-
gboolean
tracker_db_interface_start_transaction (TrackerDBInterface *interface)
{
diff --git a/src/libtracker-db/tracker-db-interface.h b/src/libtracker-db/tracker-db-interface.h
index 230c3ba..4ced292 100644
--- a/src/libtracker-db/tracker-db-interface.h
+++ b/src/libtracker-db/tracker-db-interface.h
@@ -61,16 +61,6 @@ typedef struct TrackerDBResultSetClass TrackerDBResultSetClass;
struct TrackerDBInterfaceIface {
GTypeInterface iface;
- void (* set_procedure_table) (TrackerDBInterface *interface,
- GHashTable *procedure_table);
- TrackerDBResultSet * (* execute_procedure) (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- va_list args);
- TrackerDBResultSet * (* execute_procedure_len) (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- va_list args);
TrackerDBStatement * (* create_statement) (TrackerDBInterface *interface,
const gchar *query);
TrackerDBResultSet * (* execute_query) (TrackerDBInterface *interface,
@@ -127,25 +117,6 @@ TrackerDBResultSet * tracker_db_interface_execute_query (TrackerDBInterface *
GError **error,
const gchar *query,
...) G_GNUC_PRINTF (3, 4);
-void tracker_db_interface_set_procedure_table (TrackerDBInterface *interface,
- GHashTable *procedure_table);
-TrackerDBResultSet * tracker_db_interface_execute_vprocedure (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- va_list args);
-TrackerDBResultSet * tracker_db_interface_execute_procedure (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- ...) G_GNUC_NULL_TERMINATED;
-
-TrackerDBResultSet * tracker_db_interface_execute_vprocedure_len (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- va_list args);
-TrackerDBResultSet * tracker_db_interface_execute_procedure_len (TrackerDBInterface *interface,
- GError **error,
- const gchar *procedure,
- ...) G_GNUC_NULL_TERMINATED;
gboolean tracker_db_interface_start_transaction (TrackerDBInterface *interface);
gboolean tracker_db_interface_end_transaction (TrackerDBInterface *interface);
diff --git a/src/libtracker-db/tracker-db-manager.c b/src/libtracker-db/tracker-db-manager.c
index 541e4e0..a4bd271 100644
--- a/src/libtracker-db/tracker-db-manager.c
+++ b/src/libtracker-db/tracker-db-manager.c
@@ -155,7 +155,6 @@ static gboolean db_exec_no_reply (TrackerDBInterface *iface,
static TrackerDBInterface *db_interface_create (TrackerDB db);
static gboolean initialized;
-static GHashTable *prepared_queries;
static gchar *sql_dir;
static gchar *data_dir;
static gchar *user_data_dir;
@@ -253,147 +252,6 @@ db_exec_no_reply (TrackerDBInterface *iface,
return TRUE;
}
-static gboolean
-load_prepared_queries (void)
-{
- GTimer *t;
- GError *error = NULL;
- GMappedFile *mapped_file;
- GStrv queries;
- gchar *filename;
- gdouble secs;
-
- g_message ("Loading prepared queries...");
-
- filename = g_build_filename (sql_dir, "sqlite-stored-procs.sql", NULL);
-
- t = g_timer_new ();
-
- mapped_file = g_mapped_file_new (filename, FALSE, &error);
-
- if (error || !mapped_file) {
- g_warning ("Could not get contents of SQL file:'%s', %s",
- filename,
- error ? error->message : "no error given");
-
- if (mapped_file) {
- g_mapped_file_free (mapped_file);
- }
-
- g_timer_destroy (t);
- g_free (filename);
-
- return FALSE;
- }
-
- g_message ("Loaded prepared queries file:'%s' size:%" G_GSIZE_FORMAT " bytes",
- filename,
- g_mapped_file_get_length (mapped_file));
-
- queries = g_strsplit (g_mapped_file_get_contents (mapped_file), "\n", -1);
- g_free (filename);
-
- if (queries) {
- GStrv p;
- gchar *start;
- gchar *end;
-
- start = NULL;
- end = NULL;
-
- for (p = queries; *p; p++) {
- GStrv details;
- gchar *line;
- const gchar *str;
-
- line = NULL;
-
- /* Check for comments */
- if (start) {
- if ((str = strstr (*p, "*/")) != NULL) {
- str += 2;
- end = g_strndup (str, strlen (*p) - strlen (str));
- } else {
- continue;
- }
- } else {
- if ((str = strstr (*p, "/*")) != NULL) {
- start = g_strndup (*p, str - *p);
-
- if ((str = strstr (*p, "*/")) != NULL) {
- str += 2;
- end = g_strndup (str, strlen (*p) - strlen (str));
- } else {
- continue;
- }
- }
- }
-
- /* Remove comments */
- if (start && end) {
- if (start[0] != '\0' && end[0] != '\0') {
- line = g_strconcat (start, end, NULL);
- }
-
- g_free (start);
- g_free (end);
-
- start = NULL;
- end = NULL;
-
- if (!line) {
- continue;
- }
- } else {
- line = *p;
- }
-
- /* Check for comments and empty lines */
- if (line[0] == '#' || line[0] == '\0') {
- if (line != *p) {
- g_free (line);
- }
-
- continue;
- }
-
- /* Continue processing */
- details = g_strsplit (line, " ", 2);
-
- if (line != *p) {
- g_free (line);
- }
-
- if (!details) {
- continue;
- }
- else if (!details[0] || !details[1]) {
- g_strfreev (details);
- continue;
- }
-
- g_message (" Adding query:'%s'", g_strstrip (details[0]));
-
- g_hash_table_insert (prepared_queries,
- g_strdup (g_strstrip (details[0])),
- g_strdup (g_strstrip (details[1])));
- g_strfreev (details);
- }
-
- g_strfreev (queries);
- }
-
- secs = g_timer_elapsed (t, NULL);
- g_timer_destroy (t);
- g_mapped_file_free (mapped_file);
-
- g_message ("Found %d prepared queries in %4.4f seconds",
- g_hash_table_size (prepared_queries),
- secs);
-
- return TRUE;
-}
-
/* Converts date/time in UTC format to ISO 8160 standardised format for display */
static GValue
function_date_to_str (TrackerDBInterface *interface,
@@ -902,9 +760,6 @@ db_interface_get (TrackerDB type,
iface = tracker_db_interface_sqlite_new (path);
- tracker_db_interface_set_procedure_table (iface,
- prepared_queries);
-
db_set_params (iface,
dbs[type].cache_size,
dbs[type].page_size,
@@ -1302,14 +1157,6 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
tracker_db_interface_sqlite_enable_shared_cache ();
}
- /* Add prepared queries */
- prepared_queries = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- g_free,
- g_free);
-
- load_prepared_queries ();
-
/* Should we reindex? If so, just remove all databases files,
* NOT the paths, note, that these paths are also used for
* other things like the nfs lock file.
@@ -1394,11 +1241,6 @@ tracker_db_manager_shutdown (void)
}
}
- if (prepared_queries) {
- g_hash_table_unref (prepared_queries);
- prepared_queries = NULL;
- }
-
g_free (data_dir);
g_free (user_data_dir);
g_free (sys_tmp_dir);
@@ -1503,8 +1345,6 @@ tracker_db_manager_get_db_interfaces (gint num, ...)
if (!connection) {
connection = tracker_db_interface_sqlite_new (dbs[db].abs_filename);
- tracker_db_interface_set_procedure_table (connection,
- prepared_queries);
db_set_params (connection,
dbs[db].cache_size,
@@ -1539,8 +1379,6 @@ tracker_db_manager_get_db_interfaces_ro (gint num, ...)
if (!connection) {
connection = tracker_db_interface_sqlite_new_ro (dbs[db].abs_filename);
- tracker_db_interface_set_procedure_table (connection,
- prepared_queries);
db_set_params (connection,
dbs[db].cache_size,
dbs[db].page_size,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]