/ Check-in [b79cc8dc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid returning duplicate rows in experimental pragmas "pragma_list", "module_list" and "function_list".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b79cc8dc88c8ae03daff1290fd650b2b0e6f673ec9d83be6a533a57172930190
User & Date: dan 2017-08-25 09:17:14
Context
2017-08-25
11:44
Improve the internal mechanism used to keep track of what kind of syncing to do for WAL transaction commits and checkpoint operations. Use the checkpoint-style of syncing to sync the header of a new or restarted WAL file. check-in: e8d23afe user: drh tags: trunk
09:17
Avoid returning duplicate rows in experimental pragmas "pragma_list", "module_list" and "function_list". check-in: b79cc8dc user: dan tags: trunk
2017-08-24
20:54
Fix an incorrect hyperlink in a comment. check-in: 25292b9a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

  1230   1230       int i;
  1231   1231       HashElem *j;
  1232   1232       FuncDef *p;
  1233   1233       pParse->nMem = 2;
  1234   1234       for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){
  1235   1235         for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){
  1236   1236           sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 1);
  1237         -        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
  1238   1237         }
  1239   1238       }
  1240   1239       for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){
  1241   1240         p = (FuncDef*)sqliteHashData(j);
  1242   1241         sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 0);
  1243         -      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
  1244   1242       }
  1245   1243     }
  1246   1244     break;
  1247   1245   
  1248   1246   #ifndef SQLITE_OMIT_VIRTUALTABLE
  1249   1247     case PragTyp_MODULE_LIST: {
  1250   1248       HashElem *j;
  1251   1249       pParse->nMem = 1;
  1252   1250       for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){
  1253   1251         Module *pMod = (Module*)sqliteHashData(j);
  1254   1252         sqlite3VdbeMultiLoad(v, 1, "s", pMod->zName);
  1255         -      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
  1256   1253       }
  1257   1254     }
  1258   1255     break;
  1259   1256   #endif /* SQLITE_OMIT_VIRTUALTABLE */
  1260   1257   
  1261   1258     case PragTyp_PRAGMA_LIST: {
  1262   1259       int i;
  1263   1260       for(i=0; i<ArraySize(aPragmaName); i++){
  1264   1261         sqlite3VdbeMultiLoad(v, 1, "s", aPragmaName[i].zName);
  1265         -      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
  1266   1262       }
  1267   1263     }
  1268   1264     break;
  1269   1265   #endif /* SQLITE_INTROSPECTION_PRAGMAS */
  1270   1266   
  1271   1267   #endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */
  1272   1268   

Added test/pragma5.test.

            1  +# 2017 August 25
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +# This file implements regression tests for SQLite library.
           12  +#
           13  +# This file implements tests for the PRAGMA command. Specifically,
           14  +# those pragmas enabled at build time by setting:
           15  +#
           16  +#   -DSQLITE_INTROSPECTION_PRAGMAS
           17  +#
           18  +
           19  +set testdir [file dirname $argv0]
           20  +source $testdir/tester.tcl
           21  +set testprefix pragma5
           22  +
           23  +if { [catch {db one "SELECT count(*) FROM pragma_function_list"}] } {
           24  +  finish_test
           25  +  return
           26  +}
           27  +
           28  +db function external external
           29  +
           30  +do_execsql_test 1.0 {
           31  +  PRAGMA table_info(pragma_function_list)
           32  +} {
           33  +  0 name {} 0 {} 0 
           34  +  1 builtin {} 0 {} 0
           35  +}
           36  +do_execsql_test 1.1 {
           37  +  SELECT * FROM pragma_function_list WHERE name='upper'
           38  +} {upper 1}
           39  +do_execsql_test 1.2 {
           40  +  SELECT * FROM pragma_function_list WHERE name LIKE 'exter%';
           41  +} {external 0}
           42  +
           43  +ifcapable fts5 {
           44  +  do_execsql_test 2.0 {
           45  +    PRAGMA table_info(pragma_module_list)
           46  +  } {
           47  +    0 name {} 0 {} 0 
           48  +  }
           49  +  do_execsql_test 2.1 {
           50  +    SELECT * FROM pragma_module_list WHERE name='fts5'
           51  +  } {fts5}
           52  +}
           53  +
           54  +do_execsql_test 3.0 {
           55  +  PRAGMA table_info(pragma_pragma_list)
           56  +} {
           57  +  0 name {} 0 {} 0 
           58  +}
           59  +do_execsql_test 3.1 {
           60  +  SELECT * FROM pragma_pragma_list WHERE name='pragma_list'
           61  +} {pragma_list}
           62  +
           63  +
           64  +finish_test