internal BansheeDbConnection(string db_path) : base(db_path)
        {
            // Each cache page is about 1.5K, so 32768 pages = 49152K = 48M
            int cache_size = (TableExists("CoreTracks") && Query <long> ("SELECT COUNT(*) FROM CoreTracks") > 10000) ? 32768 : 16384;

            Execute("PRAGMA cache_size = ?", cache_size);
            Execute("PRAGMA synchronous = OFF");
            Execute("PRAGMA temp_store = MEMORY");

            // TODO didn't want this on b/c smart playlists used to rely on it, but
            // now they shouldn't b/c we have smart custom functions we use for sorting/searching.
            // See BGO #603665 for discussion about turning this back on.
            //Execute ("PRAGMA case_sensitive_like=ON");

            Log.DebugFormat("Opened SQLite (version {1}) connection to {0}", db_path, ServerVersion);

            migrator      = new BansheeDbFormatMigrator(this);
            configuration = new DatabaseConfigurationClient(this);

            if (ApplicationContext.CommandLine.Contains("debug-sql"))
            {
                Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = true;
                WarnIfCalledFromThread = ThreadAssist.MainThread;
            }
        }
        void IInitializeService.Initialize()
        {
            lock (this) {
                migrator.Migrate();
                migrator = null;

                try {
                    OptimizeDatabase();
                } catch (Exception e) {
                    Log.Error("Error determining if ANALYZE is necessary", e);
                }

                // Update cached sorting keys
                BeginTransaction();
                try {
                    SortKeyUpdater.Update();
                    CommitTransaction();
                } catch {
                    RollbackTransaction();
                }
            }

            if (Banshee.Metrics.BansheeMetrics.EnableCollection.Get())
            {
                Banshee.Metrics.BansheeMetrics.Start();
            }

            if (validate_schema)
            {
                ValidateSchema();
            }
        }
        void IInitializeService.Initialize ()
        {
            lock (this) {
                migrator.Migrate ();
                migrator = null;

                try {
                    OptimizeDatabase ();
                } catch (Exception e) {
                    Log.Exception ("Error determining if ANALYZE is necessary", e);
                }

                // Update cached sorting keys
                BeginTransaction ();
                try {
                    SortKeyUpdater.Update ();
                    CommitTransaction ();
                } catch {
                    RollbackTransaction ();
                }
            }

            if (Banshee.Metrics.BansheeMetrics.EnableCollection.Get ()) {
                Banshee.Metrics.BansheeMetrics.Start ();
            }
        }
 private void OnMigrationFinished(object o, EventArgs args)
 {
     migrator.Finished -= OnMigrationFinished;
     migrator.SlowStarted -= OnMigrationSlowStarted;
     migrator.SlowPulse -= OnMigrationSlowPulse;
     migrator.SlowFinished -= OnMigrationSlowFinished;
     migrator = null;
 }
        public BansheeDbFormatMigratorMonitor(BansheeDbFormatMigrator migrator)
        {
            if (migrator == null) {
                return;
            }

            this.migrator = migrator;
            migrator.Finished += OnMigrationFinished;
            migrator.SlowStarted += OnMigrationSlowStarted;
            migrator.SlowPulse += OnMigrationSlowPulse;
            migrator.SlowFinished += OnMigrationSlowFinished;
        }
        void IInitializeService.Initialize()
        {
            lock (this) {
                migrator.Migrate();
                migrator = null;

                try {
                    OptimizeDatabase();
                } catch (Exception e) {
                    Log.Exception("Error determining if ANALYZE is necessary", e);
                }

                // Update cached sorting keys
                SortKeyUpdater.Update();
            }
        }
        internal BansheeDbConnection (string db_path) : base (db_path)
        {
            // Each cache page is about 1.5K, so 32768 pages = 49152K = 48M
            int cache_size = (TableExists ("CoreTracks") && Query<long> ("SELECT COUNT(*) FROM CoreTracks") > 10000) ? 32768 : 16384;
            Execute ("PRAGMA cache_size = ?", cache_size);
            Execute ("PRAGMA synchronous = OFF");
            Execute ("PRAGMA temp_store = MEMORY");

            // TODO didn't want this on b/c smart playlists used to rely on it, but
            // now they shouldn't b/c we have smart custom functions we use for sorting/searching.
            // See BGO #603665 for discussion about turning this back on.
            //Execute ("PRAGMA case_sensitive_like=ON");

            Log.DebugFormat ("Opened SQLite (version {1}) connection to {0}", db_path, ServerVersion);

            migrator = new BansheeDbFormatMigrator (this);
            configuration = new DatabaseConfigurationClient (this);

            if (ApplicationContext.CommandLine.Contains ("debug-sql")) {
                Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = true;
                WarnIfCalledFromThread = ThreadAssist.MainThread;
            }
        }
        public BansheeDbConnection() : base(DatabaseFile)
        {
            // Each cache page is about 1.5K, so 32768 pages = 49152K = 48M
            int cache_size = (TableExists("CoreTracks") && Query <long> ("SELECT COUNT(*) FROM CoreTracks") > 10000) ? 32768 : 16384;

            Execute("PRAGMA cache_size = ?", cache_size);
            Execute("PRAGMA synchronous = OFF");
            Execute("PRAGMA temp_store = MEMORY");
            Execute("PRAGMA count_changes = OFF");

            // don't want this on because it breaks searching/smart playlists.  See BGO #526371
            //Execute ("PRAGMA case_sensitive_like=ON");

            Log.DebugFormat("Opened SQLite connection to {0}", DatabaseFile);

            migrator      = new BansheeDbFormatMigrator(this);
            configuration = new DatabaseConfigurationClient(this);

            if (Banshee.Base.ApplicationContext.CommandLine.Contains("debug-sql"))
            {
                Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = true;
                WarnIfCalledFromThread = Banshee.Base.ThreadAssist.MainThread;
            }
        }