/ Changes On Branch list-pragmas
Login

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

Changes In Branch list-pragmas Excluding Merge-Ins

This is equivalent to a diff from aacbb9a461 to 2f3c3781ef

2017-07-07
17:43
Add new PRAGMAs: "function_list", "module_list", and "pragma_list". All are enclosed within #ifdef SQLITE_INTROSPECTION_PRAGMAS. The compile-time option is not on ctime.c yet, since these are still experimental and one can always test "PRAGMA pragma_list" and see whether or not it returns an empty set. (check-in: e0b6ae92ad user: drh tags: trunk)
17:33
Add the "Pragma_list" pragma. Put all three pragmas created on this branch inside of #ifdef SQLITE_INTROSPECTION_PRAGMAS. (Closed-Leaf check-in: 2f3c3781ef user: drh tags: list-pragmas)
16:00
Enhance the sqlite3VdbeMultiLoad() interface to automatically generate the OP_ResultRow opcode on PRAGMA implementations, for a small reduction in the library footprint. (check-in: c46f0f076c user: drh tags: trunk)
15:43
Add new pragmas: "function_list" and "module_list" (check-in: e5f01d7fde user: drh tags: list-pragmas)
14:26
Merge recent enhancements from trunk. (check-in: 73d0fc027d user: drh tags: bind-pointer)
13:59
Exploit the fact that Expr.pRight and Expr.x are never used at the same time for a small performance gain. (check-in: aacbb9a461 user: drh tags: trunk)
12:58
More efficient and compact implementation of walkExpr(). (check-in: 115d4b8339 user: drh tags: trunk)

Changes to src/pragma.c.

  1221   1221       for(p=sqliteHashFirst(&db->aCollSeq); p; p=sqliteHashNext(p)){
  1222   1222         CollSeq *pColl = (CollSeq *)sqliteHashData(p);
  1223   1223         sqlite3VdbeMultiLoad(v, 1, "is", i++, pColl->zName);
  1224   1224         sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
  1225   1225       }
  1226   1226     }
  1227   1227     break;
         1228  +
         1229  +#ifdef SQLITE_INTROSPECTION_PRAGMAS
         1230  +  case PragTyp_FUNCTION_LIST: {
         1231  +    int i;
         1232  +    HashElem *j;
         1233  +    FuncDef *p;
         1234  +    pParse->nMem = 2;
         1235  +    for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){
         1236  +      for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){
         1237  +        sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 1);
         1238  +        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
         1239  +      }
         1240  +    }
         1241  +    for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){
         1242  +      p = (FuncDef*)sqliteHashData(j);
         1243  +      sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 0);
         1244  +      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
         1245  +    }
         1246  +  }
         1247  +  break;
         1248  +
         1249  +#ifndef SQLITE_OMIT_VIRTUALTABLE
         1250  +  case PragTyp_MODULE_LIST: {
         1251  +    HashElem *j;
         1252  +    pParse->nMem = 1;
         1253  +    for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){
         1254  +      Module *pMod = (Module*)sqliteHashData(j);
         1255  +      sqlite3VdbeMultiLoad(v, 1, "s", pMod->zName);
         1256  +      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
         1257  +    }
         1258  +  }
         1259  +  break;
         1260  +#endif /* SQLITE_OMIT_VIRTUALTABLE */
         1261  +
         1262  +  case PragTyp_PRAGMA_LIST: {
         1263  +    int i;
         1264  +    for(i=0; i<ArraySize(aPragmaName); i++){
         1265  +      sqlite3VdbeMultiLoad(v, 1, "s", aPragmaName[i].zName);
         1266  +      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
         1267  +    }
         1268  +  }
         1269  +  break;
         1270  +#endif /* SQLITE_INTROSPECTION_PRAGMAS */
         1271  +
  1228   1272   #endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */
  1229   1273   
  1230   1274   #ifndef SQLITE_OMIT_FOREIGN_KEY
  1231   1275     case PragTyp_FOREIGN_KEY_LIST: if( zRight ){
  1232   1276       FKey *pFK;
  1233   1277       Table *pTab;
  1234   1278       pTab = sqlite3FindTable(db, zRight, zDb);

Changes to src/pragma.h.

    16     16   #define PragTyp_COMPILE_OPTIONS                8
    17     17   #define PragTyp_DATA_STORE_DIRECTORY           9
    18     18   #define PragTyp_DATABASE_LIST                 10
    19     19   #define PragTyp_DEFAULT_CACHE_SIZE            11
    20     20   #define PragTyp_ENCODING                      12
    21     21   #define PragTyp_FOREIGN_KEY_CHECK             13
    22     22   #define PragTyp_FOREIGN_KEY_LIST              14
    23         -#define PragTyp_INCREMENTAL_VACUUM            15
    24         -#define PragTyp_INDEX_INFO                    16
    25         -#define PragTyp_INDEX_LIST                    17
    26         -#define PragTyp_INTEGRITY_CHECK               18
    27         -#define PragTyp_JOURNAL_MODE                  19
    28         -#define PragTyp_JOURNAL_SIZE_LIMIT            20
    29         -#define PragTyp_LOCK_PROXY_FILE               21
    30         -#define PragTyp_LOCKING_MODE                  22
    31         -#define PragTyp_PAGE_COUNT                    23
    32         -#define PragTyp_MMAP_SIZE                     24
    33         -#define PragTyp_OPTIMIZE                      25
    34         -#define PragTyp_PAGE_SIZE                     26
    35         -#define PragTyp_SECURE_DELETE                 27
    36         -#define PragTyp_SHRINK_MEMORY                 28
    37         -#define PragTyp_SOFT_HEAP_LIMIT               29
    38         -#define PragTyp_SYNCHRONOUS                   30
    39         -#define PragTyp_TABLE_INFO                    31
    40         -#define PragTyp_TEMP_STORE                    32
    41         -#define PragTyp_TEMP_STORE_DIRECTORY          33
    42         -#define PragTyp_THREADS                       34
    43         -#define PragTyp_WAL_AUTOCHECKPOINT            35
    44         -#define PragTyp_WAL_CHECKPOINT                36
    45         -#define PragTyp_ACTIVATE_EXTENSIONS           37
    46         -#define PragTyp_HEXKEY                        38
    47         -#define PragTyp_KEY                           39
    48         -#define PragTyp_REKEY                         40
    49         -#define PragTyp_LOCK_STATUS                   41
    50         -#define PragTyp_PARSER_TRACE                  42
    51         -#define PragTyp_STATS                         43
           23  +#define PragTyp_FUNCTION_LIST                 15
           24  +#define PragTyp_INCREMENTAL_VACUUM            16
           25  +#define PragTyp_INDEX_INFO                    17
           26  +#define PragTyp_INDEX_LIST                    18
           27  +#define PragTyp_INTEGRITY_CHECK               19
           28  +#define PragTyp_JOURNAL_MODE                  20
           29  +#define PragTyp_JOURNAL_SIZE_LIMIT            21
           30  +#define PragTyp_LOCK_PROXY_FILE               22
           31  +#define PragTyp_LOCKING_MODE                  23
           32  +#define PragTyp_PAGE_COUNT                    24
           33  +#define PragTyp_MMAP_SIZE                     25
           34  +#define PragTyp_MODULE_LIST                   26
           35  +#define PragTyp_OPTIMIZE                      27
           36  +#define PragTyp_PAGE_SIZE                     28
           37  +#define PragTyp_PRAGMA_LIST                   29
           38  +#define PragTyp_SECURE_DELETE                 30
           39  +#define PragTyp_SHRINK_MEMORY                 31
           40  +#define PragTyp_SOFT_HEAP_LIMIT               32
           41  +#define PragTyp_SYNCHRONOUS                   33
           42  +#define PragTyp_TABLE_INFO                    34
           43  +#define PragTyp_TEMP_STORE                    35
           44  +#define PragTyp_TEMP_STORE_DIRECTORY          36
           45  +#define PragTyp_THREADS                       37
           46  +#define PragTyp_WAL_AUTOCHECKPOINT            38
           47  +#define PragTyp_WAL_CHECKPOINT                39
           48  +#define PragTyp_ACTIVATE_EXTENSIONS           40
           49  +#define PragTyp_HEXKEY                        41
           50  +#define PragTyp_KEY                           42
           51  +#define PragTyp_REKEY                         43
           52  +#define PragTyp_LOCK_STATUS                   44
           53  +#define PragTyp_PARSER_TRACE                  45
           54  +#define PragTyp_STATS                         46
    52     55   
    53     56   /* Property flags associated with various pragma. */
    54     57   #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
    55     58   #define PragFlg_NoColumns  0x02 /* OP_ResultRow called with zero columns */
    56     59   #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
    57     60   #define PragFlg_ReadOnly   0x08 /* Read-only HEADER_VALUE */
    58     61   #define PragFlg_Result0    0x10 /* Acts as query when no argument */
................................................................................
    90     93     /*  22 */ "name",       
    91     94     /*  23 */ "unique",     
    92     95     /*  24 */ "origin",     
    93     96     /*  25 */ "partial",    
    94     97     /*  26 */ "seq",         /* Used by: database_list */
    95     98     /*  27 */ "name",       
    96     99     /*  28 */ "file",       
    97         -  /*  29 */ "seq",         /* Used by: collation_list */
    98         -  /*  30 */ "name",       
    99         -  /*  31 */ "id",          /* Used by: foreign_key_list */
   100         -  /*  32 */ "seq",        
   101         -  /*  33 */ "table",      
   102         -  /*  34 */ "from",       
   103         -  /*  35 */ "to",         
   104         -  /*  36 */ "on_update",  
   105         -  /*  37 */ "on_delete",  
   106         -  /*  38 */ "match",      
   107         -  /*  39 */ "table",       /* Used by: foreign_key_check */
   108         -  /*  40 */ "rowid",      
   109         -  /*  41 */ "parent",     
   110         -  /*  42 */ "fkid",       
   111         -  /*  43 */ "busy",        /* Used by: wal_checkpoint */
   112         -  /*  44 */ "log",        
   113         -  /*  45 */ "checkpointed",
   114         -  /*  46 */ "timeout",     /* Used by: busy_timeout */
   115         -  /*  47 */ "database",    /* Used by: lock_status */
   116         -  /*  48 */ "status",     
          100  +  /*  29 */ "name",        /* Used by: function_list */
          101  +  /*  30 */ "builtin",    
          102  +  /*  31 */ "name",        /* Used by: module_list pragma_list */
          103  +  /*  32 */ "seq",         /* Used by: collation_list */
          104  +  /*  33 */ "name",       
          105  +  /*  34 */ "id",          /* Used by: foreign_key_list */
          106  +  /*  35 */ "seq",        
          107  +  /*  36 */ "table",      
          108  +  /*  37 */ "from",       
          109  +  /*  38 */ "to",         
          110  +  /*  39 */ "on_update",  
          111  +  /*  40 */ "on_delete",  
          112  +  /*  41 */ "match",      
          113  +  /*  42 */ "table",       /* Used by: foreign_key_check */
          114  +  /*  43 */ "rowid",      
          115  +  /*  44 */ "parent",     
          116  +  /*  45 */ "fkid",       
          117  +  /*  46 */ "busy",        /* Used by: wal_checkpoint */
          118  +  /*  47 */ "log",        
          119  +  /*  48 */ "checkpointed",
          120  +  /*  49 */ "timeout",     /* Used by: busy_timeout */
          121  +  /*  50 */ "database",    /* Used by: lock_status */
          122  +  /*  51 */ "status",     
   117    123   };
   118    124   
   119    125   /* Definitions of all built-in pragmas */
   120    126   typedef struct PragmaName {
   121    127     const char *const zName; /* Name of pragma */
   122    128     u8 ePragTyp;             /* PragTyp_XXX value */
   123    129     u8 mPragFlg;             /* Zero or more PragFlg_XXX values */
................................................................................
   155    161     /* ColNames:  */ 0, 0,
   156    162     /* iArg:      */ SQLITE_AutoIndex },
   157    163   #endif
   158    164   #endif
   159    165    {/* zName:     */ "busy_timeout",
   160    166     /* ePragTyp:  */ PragTyp_BUSY_TIMEOUT,
   161    167     /* ePragFlg:  */ PragFlg_Result0,
   162         -  /* ColNames:  */ 46, 1,
          168  +  /* ColNames:  */ 49, 1,
   163    169     /* iArg:      */ 0 },
   164    170   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   165    171    {/* zName:     */ "cache_size",
   166    172     /* ePragTyp:  */ PragTyp_CACHE_SIZE,
   167    173     /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
   168    174     /* ColNames:  */ 0, 0,
   169    175     /* iArg:      */ 0 },
................................................................................
   192    198     /* ColNames:  */ 0, 0,
   193    199     /* iArg:      */ SQLITE_CkptFullFSync },
   194    200   #endif
   195    201   #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   196    202    {/* zName:     */ "collation_list",
   197    203     /* ePragTyp:  */ PragTyp_COLLATION_LIST,
   198    204     /* ePragFlg:  */ PragFlg_Result0,
   199         -  /* ColNames:  */ 29, 2,
          205  +  /* ColNames:  */ 32, 2,
   200    206     /* iArg:      */ 0 },
   201    207   #endif
   202    208   #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
   203    209    {/* zName:     */ "compile_options",
   204    210     /* ePragTyp:  */ PragTyp_COMPILE_OPTIONS,
   205    211     /* ePragFlg:  */ PragFlg_Result0,
   206    212     /* ColNames:  */ 0, 0,
................................................................................
   264    270     /* ColNames:  */ 0, 0,
   265    271     /* iArg:      */ 0 },
   266    272   #endif
   267    273   #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
   268    274    {/* zName:     */ "foreign_key_check",
   269    275     /* ePragTyp:  */ PragTyp_FOREIGN_KEY_CHECK,
   270    276     /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0,
   271         -  /* ColNames:  */ 39, 4,
          277  +  /* ColNames:  */ 42, 4,
   272    278     /* iArg:      */ 0 },
   273    279   #endif
   274    280   #if !defined(SQLITE_OMIT_FOREIGN_KEY)
   275    281    {/* zName:     */ "foreign_key_list",
   276    282     /* ePragTyp:  */ PragTyp_FOREIGN_KEY_LIST,
   277    283     /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
   278         -  /* ColNames:  */ 31, 8,
          284  +  /* ColNames:  */ 34, 8,
   279    285     /* iArg:      */ 0 },
   280    286   #endif
   281    287   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   282    288   #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
   283    289    {/* zName:     */ "foreign_keys",
   284    290     /* ePragTyp:  */ PragTyp_FLAG,
   285    291     /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,
................................................................................
   301    307     /* ColNames:  */ 0, 0,
   302    308     /* iArg:      */ SQLITE_FullColNames },
   303    309    {/* zName:     */ "fullfsync",
   304    310     /* ePragTyp:  */ PragTyp_FLAG,
   305    311     /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,
   306    312     /* ColNames:  */ 0, 0,
   307    313     /* iArg:      */ SQLITE_FullFSync },
          314  +#endif
          315  +#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
          316  +#if defined(SQLITE_INTROSPECTION_PRAGMAS)
          317  + {/* zName:     */ "function_list",
          318  +  /* ePragTyp:  */ PragTyp_FUNCTION_LIST,
          319  +  /* ePragFlg:  */ PragFlg_Result0,
          320  +  /* ColNames:  */ 29, 2,
          321  +  /* iArg:      */ 0 },
          322  +#endif
   308    323   #endif
   309    324   #if defined(SQLITE_HAS_CODEC)
   310    325    {/* zName:     */ "hexkey",
   311    326     /* ePragTyp:  */ PragTyp_HEXKEY,
   312    327     /* ePragFlg:  */ 0,
   313    328     /* ColNames:  */ 0, 0,
   314    329     /* iArg:      */ 0 },
................................................................................
   391    406     /* ColNames:  */ 0, 0,
   392    407     /* iArg:      */ 0 },
   393    408   #endif
   394    409   #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
   395    410    {/* zName:     */ "lock_status",
   396    411     /* ePragTyp:  */ PragTyp_LOCK_STATUS,
   397    412     /* ePragFlg:  */ PragFlg_Result0,
   398         -  /* ColNames:  */ 47, 2,
          413  +  /* ColNames:  */ 50, 2,
   399    414     /* iArg:      */ 0 },
   400    415   #endif
   401    416   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   402    417    {/* zName:     */ "locking_mode",
   403    418     /* ePragTyp:  */ PragTyp_LOCKING_MODE,
   404    419     /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,
   405    420     /* ColNames:  */ 0, 0,
................................................................................
   410    425     /* ColNames:  */ 0, 0,
   411    426     /* iArg:      */ 0 },
   412    427    {/* zName:     */ "mmap_size",
   413    428     /* ePragTyp:  */ PragTyp_MMAP_SIZE,
   414    429     /* ePragFlg:  */ 0,
   415    430     /* ColNames:  */ 0, 0,
   416    431     /* iArg:      */ 0 },
          432  +#endif
          433  +#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
          434  +#if !defined(SQLITE_OMIT_VIRTUALTABLE)
          435  +#if defined(SQLITE_INTROSPECTION_PRAGMAS)
          436  + {/* zName:     */ "module_list",
          437  +  /* ePragTyp:  */ PragTyp_MODULE_LIST,
          438  +  /* ePragFlg:  */ PragFlg_Result0,
          439  +  /* ColNames:  */ 31, 1,
          440  +  /* iArg:      */ 0 },
          441  +#endif
          442  +#endif
   417    443   #endif
   418    444    {/* zName:     */ "optimize",
   419    445     /* ePragTyp:  */ PragTyp_OPTIMIZE,
   420    446     /* ePragFlg:  */ PragFlg_Result1|PragFlg_NeedSchema,
   421    447     /* ColNames:  */ 0, 0,
   422    448     /* iArg:      */ 0 },
   423    449   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
................................................................................
   434    460   #endif
   435    461   #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
   436    462    {/* zName:     */ "parser_trace",
   437    463     /* ePragTyp:  */ PragTyp_PARSER_TRACE,
   438    464     /* ePragFlg:  */ 0,
   439    465     /* ColNames:  */ 0, 0,
   440    466     /* iArg:      */ 0 },
          467  +#endif
          468  +#if defined(SQLITE_INTROSPECTION_PRAGMAS)
          469  + {/* zName:     */ "pragma_list",
          470  +  /* ePragTyp:  */ PragTyp_PRAGMA_LIST,
          471  +  /* ePragFlg:  */ PragFlg_Result0,
          472  +  /* ColNames:  */ 31, 1,
          473  +  /* iArg:      */ 0 },
   441    474   #endif
   442    475   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   443    476    {/* zName:     */ "query_only",
   444    477     /* ePragTyp:  */ PragTyp_FLAG,
   445    478     /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,
   446    479     /* ColNames:  */ 0, 0,
   447    480     /* iArg:      */ SQLITE_QueryOnly },
................................................................................
   598    631     /* ePragTyp:  */ PragTyp_WAL_AUTOCHECKPOINT,
   599    632     /* ePragFlg:  */ 0,
   600    633     /* ColNames:  */ 0, 0,
   601    634     /* iArg:      */ 0 },
   602    635    {/* zName:     */ "wal_checkpoint",
   603    636     /* ePragTyp:  */ PragTyp_WAL_CHECKPOINT,
   604    637     /* ePragFlg:  */ PragFlg_NeedSchema,
   605         -  /* ColNames:  */ 43, 3,
          638  +  /* ColNames:  */ 46, 3,
   606    639     /* iArg:      */ 0 },
   607    640   #endif
   608    641   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   609    642    {/* zName:     */ "writable_schema",
   610    643     /* ePragTyp:  */ PragTyp_FLAG,
   611    644     /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,
   612    645     /* ColNames:  */ 0, 0,
   613    646     /* iArg:      */ SQLITE_WriteSchema },
   614    647   #endif
   615    648   };
   616         -/* Number of pragmas: 60 on by default, 74 total. */
          649  +/* Number of pragmas: 60 on by default, 77 total. */

Changes to tool/mkpragmatab.tcl.

   248    248     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   249    249   
   250    250     NAME: database_list
   251    251     FLAG: NeedSchema Result0
   252    252     COLS: seq name file
   253    253     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   254    254   
          255  +  NAME: function_list
          256  +  FLAG: Result0
          257  +  COLS: name builtin
          258  +  IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
          259  +  IF:   defined(SQLITE_INTROSPECTION_PRAGMAS)
          260  +
          261  +  NAME: module_list
          262  +  FLAG: Result0
          263  +  COLS: name
          264  +  IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
          265  +  IF:   !defined(SQLITE_OMIT_VIRTUALTABLE)
          266  +  IF:   defined(SQLITE_INTROSPECTION_PRAGMAS)
          267  +
          268  +  NAME: pragma_list
          269  +  FLAG: Result0
          270  +  COLS: name
          271  +  IF:   defined(SQLITE_INTROSPECTION_PRAGMAS)
          272  +
   255    273     NAME: collation_list
   256    274     FLAG: Result0
   257    275     COLS: seq name
   258    276     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   259    277   
   260    278     NAME: foreign_key_list
   261    279     FLAG: NeedSchema Result1 SchemaOpt