Skip to content

Commit ce41627

Browse files
committed
Don't use deprecated pragmas
Don't call the empty_result_callback and show_datatypes pragmas when opening or creating a database file. The first one is marked as deprecated in the documentation [1] and the latter one doesn't appear there at all anymore but was removed in February 2004(!) [2]. [1] https://www.sqlite.org/pragma.html#pragma_empty_result_callbacks [2] https://www.mail-archive.com/[email protected]/msg01252.html
1 parent 3ba769f commit ce41627

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

src/sqlitedb.cpp

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,19 @@ bool DBBrowserDB::open(const QString& db)
120120
return false;
121121
}
122122

123-
if (_db){
123+
if (_db)
124+
{
124125
// set preference defaults
125126
QSettings settings(QApplication::organizationName(), QApplication::organizationName());
126127
settings.sync();
127128
bool foreignkeys = settings.value( "/db/foreignkeys", false ).toBool();
128129
setPragma("foreign_keys", foreignkeys ? "1" : "0");
129130

130-
if (SQLITE_OK==sqlite3_exec(_db,"PRAGMA empty_result_callbacks = ON;",
131-
NULL,NULL,NULL)){
132-
if (SQLITE_OK==sqlite3_exec(_db,"PRAGMA show_datatypes = ON;",
133-
NULL,NULL,NULL)){
134-
ok=true;
135-
}
136-
curDBFilename = db;
137-
}
138-
139131
// Enable extension loading
140132
sqlite3_enable_load_extension(_db, 1);
133+
134+
ok = true;
135+
curDBFilename = db;
141136
}
142137

143138
return ok;
@@ -239,16 +234,8 @@ bool DBBrowserDB::create ( const QString & db)
239234
return false;
240235
}
241236

242-
if (_db){
243-
if (SQLITE_OK==sqlite3_exec(_db,"PRAGMA empty_result_callbacks = ON;",
244-
NULL,NULL,NULL)){
245-
if (SQLITE_OK==sqlite3_exec(_db,"PRAGMA show_datatypes = ON;",
246-
NULL,NULL,NULL)){
247-
ok=true;
248-
}
249-
curDBFilename = db;
250-
}
251-
237+
if (_db)
238+
{
252239
// Enable extension loading
253240
sqlite3_enable_load_extension(_db, 1);
254241

@@ -258,6 +245,9 @@ bool DBBrowserDB::create ( const QString & db)
258245
sqlite3_exec(_db, "CREATE TABLE notempty (id integer primary key);", NULL, NULL, NULL);
259246
sqlite3_exec(_db, "DROP TABLE notempty", NULL, NULL, NULL);
260247
sqlite3_exec(_db, "COMMIT;", NULL, NULL, NULL);
248+
249+
ok = true;
250+
curDBFilename = db;
261251
}
262252

263253
return ok;

0 commit comments

Comments
 (0)