[tracker/wip/carlosg/domain-ontologies: 30/93] libtracker-data: Remove TRACKER_PRAGMAS_FILE envvar



commit b9dfc72390329cc3f1c74768551bc6116e2eac35
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jun 4 17:08:27 2017 +0200

    libtracker-data: Remove TRACKER_PRAGMAS_FILE envvar
    
    Now that we are exposing databases to apps, it doesn't make sense to offer
    an environment variable that can entirely mangle how tracker behaves for
    these (Nor IMHO made sense back in the days, either).
    
    Let's just remove this envvar and pretend it never existed.

 docs/manpages/tracker-info.1                   |    7 --
 docs/manpages/tracker-search.1                 |    7 --
 docs/manpages/tracker-sparql.1                 |    7 --
 docs/manpages/tracker-store.1                  |    7 --
 docs/manpages/tracker-tag.1                    |    7 --
 docs/reference/libtracker-sparql/overview.sgml |   10 ---
 src/libtracker-data/tracker-db-manager.c       |  102 ++++++++++--------------
 7 files changed, 43 insertions(+), 104 deletions(-)
---
diff --git a/docs/manpages/tracker-info.1 b/docs/manpages/tracker-info.1
index f507593..fbbc68f 100644
--- a/docs/manpages/tracker-info.1
+++ b/docs/manpages/tracker-info.1
@@ -72,13 +72,6 @@ approach you can use if you want to \fIwrite\fR to the database.
 With "\fBauto\fR" the backend is decided for you, much like it would
 be if this environment variable was undefined.
 
-.TP
-.B TRACKER_PRAGMAS_FILE
-Tracker has a fixed set of PRAGMA settings for creating its SQLite connection.
-With this environment variable pointing to a text file you can override these
-settings. The file is a \\n separated list of SQLite queries to execute on any
-newly created SQLite connection in \fBtracker-store\fR.
-
 .SH SEE ALSO
 .BR tracker-store (1),
 .BR tracker-sparql (1).
diff --git a/docs/manpages/tracker-search.1 b/docs/manpages/tracker-search.1
index 109602e..06762f5 100644
--- a/docs/manpages/tracker-search.1
+++ b/docs/manpages/tracker-search.1
@@ -129,13 +129,6 @@ approach you can use if you want to \fIwrite\fR to the database.
 With "\fBauto\fR" the backend is decided for you, much like it would
 be if this environment variable was undefined.
 
-.TP
-.B TRACKER_PRAGMAS_FILE
-Tracker has a fixed set of PRAGMA settings for creating its SQLite connection.
-With this environment variable pointing to a text file you can override these
-settings. The file is a \\n separated list of SQLite queries to execute on any
-newly created SQLite connection in tracker-store.
-
 .SH SEE ALSO
 .BR tracker-store (1),
 .BR tracker-stats (1),
diff --git a/docs/manpages/tracker-sparql.1 b/docs/manpages/tracker-sparql.1
index cf60f9f..78ea989 100644
--- a/docs/manpages/tracker-sparql.1
+++ b/docs/manpages/tracker-sparql.1
@@ -236,13 +236,6 @@ approach you can use if you want to \fIwrite\fR to the database.
 With "\fBauto\fR" the backend is decided for you, much like it would
 be if this environment variable was undefined.
 
-.TP
-.B TRACKER_PRAGMAS_FILE
-Tracker has a fixed set of PRAGMA settings for creating its SQLite connection.
-With this environment variable pointing to a text file you can override these
-settings. The file is a \\n separated list of SQLite queries to execute on any
-newly created SQLite connection in \fBtracker-store\fR.
-
 .SH EXAMPLES
 .TP
 List all classes
diff --git a/docs/manpages/tracker-store.1 b/docs/manpages/tracker-store.1
index 77ecb17..28452f0 100644
--- a/docs/manpages/tracker-store.1
+++ b/docs/manpages/tracker-store.1
@@ -75,13 +75,6 @@ number represents the number of cached statements to keep around.
 This environment variable is used mainly for testing purposes.
 
 .TP
-.B TRACKER_PRAGMAS_FILE
-Tracker has a fixed set of PRAGMA settings for creating its SQLite connection.
-With this environment variable pointing to a text file you can override these
-settings. The file is a \\n separated list of SQLite queries to execute on any
-newly created SQLite connection in tracker-store.
-
-.TP
 .B TRACKER_USE_LOG_FILES
 Don't just log to stdout and stderr, but to log files too which are
 kept in $HOME/.local/share/tracker/. This came into effect in 0.15.3
diff --git a/docs/manpages/tracker-tag.1 b/docs/manpages/tracker-tag.1
index b450f8f..c4e3285 100644
--- a/docs/manpages/tracker-tag.1
+++ b/docs/manpages/tracker-tag.1
@@ -97,13 +97,6 @@ approach you can use if you want to \fIwrite\fR to the database.
 With "\fBauto\fR" the backend is decided for you, much like it would
 be if this environment variable was undefined.
 
-.TP
-.B TRACKER_PRAGMAS_FILE
-Tracker has a fixed set of PRAGMA settings for creating its SQLite connection.
-With this environment variable pointing to a text file you can override these
-settings. The file is a \\n separated list of SQLite queries to execute on any
-newly created SQLite connection in \fBtracker-store\fR.
-
 .SH SEE ALSO
 .BR tracker-store (1),
 .BR tracker-sparql (1),
diff --git a/docs/reference/libtracker-sparql/overview.sgml b/docs/reference/libtracker-sparql/overview.sgml
index 400dca9..1489045 100644
--- a/docs/reference/libtracker-sparql/overview.sgml
+++ b/docs/reference/libtracker-sparql/overview.sgml
@@ -174,16 +174,6 @@ $ pkg-config --libs tracker-sparql-0.12
            is <emphasis>0</emphasis>.
          </para>
        </listitem>
-       <listitem>
-         <emphasis>TRACKER_PRAGMAS_FILE</emphasis>
-         <para>
-           Tracker has a fixed set of PRAGMA settings for creating its
-           SQLite connection. With this environment variable pointing to
-           a text file you can override these settings. The file is a
-           \n separated list of SQLite queries to execute on any newly
-           created SQLite connection in tracker-store.
-         </para>
-       </listitem>
       </itemizedlist>
     </para>
 
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 9e2d796..d5351db 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -214,78 +214,62 @@ db_set_params (TrackerDBInterface   *iface,
                gboolean              readonly,
                GError              **error)
 {
-       gchar *queries = NULL;
-       const gchar *pragmas_file;
-
-       pragmas_file = g_getenv ("TRACKER_PRAGMAS_FILE");
-
-       if (pragmas_file && g_file_get_contents (pragmas_file, &queries, NULL, NULL)) {
-               gchar *query = strtok (queries, "\n");
-               g_debug ("PRAGMA's from file: %s", pragmas_file);
-               while (query) {
-                       g_debug ("  INIT query: %s", query);
-                       tracker_db_interface_execute_query (iface, NULL, "%s", query);
-                       query = strtok (NULL, "\n");
-               }
-               g_free (queries);
-       } else {
-               GError *internal_error = NULL;
-               TrackerDBStatement *stmt;
+       GError *internal_error = NULL;
+       TrackerDBStatement *stmt;
 
 #ifdef DISABLE_JOURNAL
-               tracker_db_interface_execute_query (iface, NULL, "PRAGMA synchronous = NORMAL;");
+       tracker_db_interface_execute_query (iface, NULL, "PRAGMA synchronous = NORMAL;");
 #else
-               tracker_db_interface_execute_query (iface, NULL, "PRAGMA synchronous = OFF;");
+       tracker_db_interface_execute_query (iface, NULL, "PRAGMA synchronous = OFF;");
 #endif /* DISABLE_JOURNAL */
-               tracker_db_interface_execute_query (iface, NULL, "PRAGMA encoding = \"UTF-8\"");
-               tracker_db_interface_execute_query (iface, NULL, "PRAGMA auto_vacuum = 0;");
+       tracker_db_interface_execute_query (iface, NULL, "PRAGMA encoding = \"UTF-8\"");
+       tracker_db_interface_execute_query (iface, NULL, "PRAGMA auto_vacuum = 0;");
 
-               if (readonly) {
-                       tracker_db_interface_execute_query (iface, NULL, "PRAGMA temp_store = MEMORY;");
-               } else {
-                       tracker_db_interface_execute_query (iface, NULL, "PRAGMA temp_store = FILE;");
-               }
+       if (readonly) {
+               tracker_db_interface_execute_query (iface, NULL, "PRAGMA temp_store = MEMORY;");
+       } else {
+               tracker_db_interface_execute_query (iface, NULL, "PRAGMA temp_store = FILE;");
+       }
 
-               stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE,
-                                                             &internal_error,
-                                                             "PRAGMA journal_mode = WAL;");
+       stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE,
+                                                     &internal_error,
+                                                     "PRAGMA journal_mode = WAL;");
 
-               if (internal_error) {
-                       g_message ("Can't set journal mode to WAL: '%s'",
-                                  internal_error->message);
-                       g_propagate_error (error, internal_error);
-               } else {
-                       TrackerDBCursor *cursor;
-
-                       cursor = tracker_db_statement_start_cursor (stmt, NULL);
-                       if (tracker_db_cursor_iter_next (cursor, NULL, NULL)) {
-                               if (g_ascii_strcasecmp (tracker_db_cursor_get_string (cursor, 0, NULL), 
"WAL") != 0) {
-                                       g_set_error (error,
-                                                    TRACKER_DB_INTERFACE_ERROR,
-                                                    TRACKER_DB_OPEN_ERROR,
-                                                    "Can't set journal mode to WAL");
-                               }
-                       }
-                       g_object_unref (cursor);
-               }
+       if (internal_error) {
+               g_message ("Can't set journal mode to WAL: '%s'",
+                          internal_error->message);
+               g_propagate_error (error, internal_error);
+       } else {
+               TrackerDBCursor *cursor;
 
-               if (stmt) {
-                       g_object_unref (stmt);
+               cursor = tracker_db_statement_start_cursor (stmt, NULL);
+               if (tracker_db_cursor_iter_next (cursor, NULL, NULL)) {
+                       if (g_ascii_strcasecmp (tracker_db_cursor_get_string (cursor, 0, NULL), "WAL") != 0) {
+                               g_set_error (error,
+                                            TRACKER_DB_INTERFACE_ERROR,
+                                            TRACKER_DB_OPEN_ERROR,
+                                            "Can't set journal mode to WAL");
+                       }
                }
+               g_object_unref (cursor);
+       }
 
-               /* disable autocheckpoint */
-               tracker_db_interface_execute_query (iface, NULL, "PRAGMA wal_autocheckpoint = 0");
+       if (stmt) {
+               g_object_unref (stmt);
+       }
 
-               tracker_db_interface_execute_query (iface, NULL, "PRAGMA journal_size_limit = 10240000");
+       /* disable autocheckpoint */
+       tracker_db_interface_execute_query (iface, NULL, "PRAGMA wal_autocheckpoint = 0");
 
-               if (page_size != TRACKER_DB_PAGE_SIZE_DONT_SET) {
-                       g_message ("  Setting page size to %d", page_size);
-                       tracker_db_interface_execute_query (iface, NULL, "PRAGMA page_size = %d", page_size);
-               }
+       tracker_db_interface_execute_query (iface, NULL, "PRAGMA journal_size_limit = 10240000");
 
-               tracker_db_interface_execute_query (iface, NULL, "PRAGMA cache_size = %d", cache_size);
-               g_message ("  Setting cache size to %d", cache_size);
+       if (page_size != TRACKER_DB_PAGE_SIZE_DONT_SET) {
+               g_message ("  Setting page size to %d", page_size);
+               tracker_db_interface_execute_query (iface, NULL, "PRAGMA page_size = %d", page_size);
        }
+
+       tracker_db_interface_execute_query (iface, NULL, "PRAGMA cache_size = %d", cache_size);
+       g_message ("  Setting cache size to %d", cache_size);
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]