/ Check-in [e5f01d7f]
Login

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

Overview
Comment:Add new pragmas: "function_list" and "module_list"
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | list-pragmas
Files: files | file ages | folders
SHA3-256: e5f01d7fde05fdb547f35816ff15c31a92c170b31877f4c640b7bc2be3f580b3
User & Date: drh 2017-07-07 15:43:22
Context
2017-07-07
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: 2f3c3781 user: drh tags: list-pragmas
15:43
Add new pragmas: "function_list" and "module_list" check-in: e5f01d7f user: drh tags: list-pragmas
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: aacbb9a4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

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  +  case PragTyp_FUNCTION_LIST: {
         1230  +    int i;
         1231  +    HashElem *j;
         1232  +    FuncDef *p;
         1233  +    pParse->nMem = 2;
         1234  +    for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){
         1235  +      for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){
         1236  +        sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 1);
         1237  +        sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
         1238  +      }
         1239  +    }
         1240  +    for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){
         1241  +      p = (FuncDef*)sqliteHashData(j);
         1242  +      sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 0);
         1243  +      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 2);
         1244  +    }
         1245  +  }
         1246  +  break;
         1247  +
         1248  +#ifndef SQLITE_OMIT_VIRTUALTABLE
         1249  +  case PragTyp_MODULE_LIST: {
         1250  +    HashElem *j;
         1251  +    pParse->nMem = 1;
         1252  +    for(j=sqliteHashFirst(&db->aModule); j; j=sqliteHashNext(j)){
         1253  +      Module *pMod = (Module*)sqliteHashData(j);
         1254  +      sqlite3VdbeMultiLoad(v, 1, "s", pMod->zName);
         1255  +      sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
         1256  +    }
         1257  +  }
         1258  +  break;
         1259  +#endif /* SQLITE_OMIT_VIRTUALTABLE */
         1260  +
         1261  +
  1228   1262   #endif /* SQLITE_OMIT_SCHEMA_PRAGMAS */
  1229   1263   
  1230   1264   #ifndef SQLITE_OMIT_FOREIGN_KEY
  1231   1265     case PragTyp_FOREIGN_KEY_LIST: if( zRight ){
  1232   1266       FKey *pFK;
  1233   1267       Table *pTab;
  1234   1268       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_SECURE_DELETE                 29
           38  +#define PragTyp_SHRINK_MEMORY                 30
           39  +#define PragTyp_SOFT_HEAP_LIMIT               31
           40  +#define PragTyp_SYNCHRONOUS                   32
           41  +#define PragTyp_TABLE_INFO                    33
           42  +#define PragTyp_TEMP_STORE                    34
           43  +#define PragTyp_TEMP_STORE_DIRECTORY          35
           44  +#define PragTyp_THREADS                       36
           45  +#define PragTyp_WAL_AUTOCHECKPOINT            37
           46  +#define PragTyp_WAL_CHECKPOINT                38
           47  +#define PragTyp_ACTIVATE_EXTENSIONS           39
           48  +#define PragTyp_HEXKEY                        40
           49  +#define PragTyp_KEY                           41
           50  +#define PragTyp_REKEY                         42
           51  +#define PragTyp_LOCK_STATUS                   43
           52  +#define PragTyp_PARSER_TRACE                  44
           53  +#define PragTyp_STATS                         45
    52     54   
    53     55   /* Property flags associated with various pragma. */
    54     56   #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
    55     57   #define PragFlg_NoColumns  0x02 /* OP_ResultRow called with zero columns */
    56     58   #define PragFlg_NoColumns1 0x04 /* zero columns if RHS argument is present */
    57     59   #define PragFlg_ReadOnly   0x08 /* Read-only HEADER_VALUE */
    58     60   #define PragFlg_Result0    0x10 /* Acts as query when no argument */
................................................................................
    90     92     /*  22 */ "name",       
    91     93     /*  23 */ "unique",     
    92     94     /*  24 */ "origin",     
    93     95     /*  25 */ "partial",    
    94     96     /*  26 */ "seq",         /* Used by: database_list */
    95     97     /*  27 */ "name",       
    96     98     /*  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",     
           99  +  /*  29 */ "name",        /* Used by: function_list */
          100  +  /*  30 */ "builtin",    
          101  +  /*  31 */ "name",        /* Used by: module_list */
          102  +  /*  32 */ "seq",         /* Used by: collation_list */
          103  +  /*  33 */ "name",       
          104  +  /*  34 */ "id",          /* Used by: foreign_key_list */
          105  +  /*  35 */ "seq",        
          106  +  /*  36 */ "table",      
          107  +  /*  37 */ "from",       
          108  +  /*  38 */ "to",         
          109  +  /*  39 */ "on_update",  
          110  +  /*  40 */ "on_delete",  
          111  +  /*  41 */ "match",      
          112  +  /*  42 */ "table",       /* Used by: foreign_key_check */
          113  +  /*  43 */ "rowid",      
          114  +  /*  44 */ "parent",     
          115  +  /*  45 */ "fkid",       
          116  +  /*  46 */ "busy",        /* Used by: wal_checkpoint */
          117  +  /*  47 */ "log",        
          118  +  /*  48 */ "checkpointed",
          119  +  /*  49 */ "timeout",     /* Used by: busy_timeout */
          120  +  /*  50 */ "database",    /* Used by: lock_status */
          121  +  /*  51 */ "status",     
   117    122   };
   118    123   
   119    124   /* Definitions of all built-in pragmas */
   120    125   typedef struct PragmaName {
   121    126     const char *const zName; /* Name of pragma */
   122    127     u8 ePragTyp;             /* PragTyp_XXX value */
   123    128     u8 mPragFlg;             /* Zero or more PragFlg_XXX values */
................................................................................
   155    160     /* ColNames:  */ 0, 0,
   156    161     /* iArg:      */ SQLITE_AutoIndex },
   157    162   #endif
   158    163   #endif
   159    164    {/* zName:     */ "busy_timeout",
   160    165     /* ePragTyp:  */ PragTyp_BUSY_TIMEOUT,
   161    166     /* ePragFlg:  */ PragFlg_Result0,
   162         -  /* ColNames:  */ 46, 1,
          167  +  /* ColNames:  */ 49, 1,
   163    168     /* iArg:      */ 0 },
   164    169   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   165    170    {/* zName:     */ "cache_size",
   166    171     /* ePragTyp:  */ PragTyp_CACHE_SIZE,
   167    172     /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
   168    173     /* ColNames:  */ 0, 0,
   169    174     /* iArg:      */ 0 },
................................................................................
   192    197     /* ColNames:  */ 0, 0,
   193    198     /* iArg:      */ SQLITE_CkptFullFSync },
   194    199   #endif
   195    200   #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   196    201    {/* zName:     */ "collation_list",
   197    202     /* ePragTyp:  */ PragTyp_COLLATION_LIST,
   198    203     /* ePragFlg:  */ PragFlg_Result0,
   199         -  /* ColNames:  */ 29, 2,
          204  +  /* ColNames:  */ 32, 2,
   200    205     /* iArg:      */ 0 },
   201    206   #endif
   202    207   #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
   203    208    {/* zName:     */ "compile_options",
   204    209     /* ePragTyp:  */ PragTyp_COMPILE_OPTIONS,
   205    210     /* ePragFlg:  */ PragFlg_Result0,
   206    211     /* ColNames:  */ 0, 0,
................................................................................
   264    269     /* ColNames:  */ 0, 0,
   265    270     /* iArg:      */ 0 },
   266    271   #endif
   267    272   #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
   268    273    {/* zName:     */ "foreign_key_check",
   269    274     /* ePragTyp:  */ PragTyp_FOREIGN_KEY_CHECK,
   270    275     /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result0,
   271         -  /* ColNames:  */ 39, 4,
          276  +  /* ColNames:  */ 42, 4,
   272    277     /* iArg:      */ 0 },
   273    278   #endif
   274    279   #if !defined(SQLITE_OMIT_FOREIGN_KEY)
   275    280    {/* zName:     */ "foreign_key_list",
   276    281     /* ePragTyp:  */ PragTyp_FOREIGN_KEY_LIST,
   277    282     /* ePragFlg:  */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt,
   278         -  /* ColNames:  */ 31, 8,
          283  +  /* ColNames:  */ 34, 8,
   279    284     /* iArg:      */ 0 },
   280    285   #endif
   281    286   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   282    287   #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
   283    288    {/* zName:     */ "foreign_keys",
   284    289     /* ePragTyp:  */ PragTyp_FLAG,
   285    290     /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,
................................................................................
   301    306     /* ColNames:  */ 0, 0,
   302    307     /* iArg:      */ SQLITE_FullColNames },
   303    308    {/* zName:     */ "fullfsync",
   304    309     /* ePragTyp:  */ PragTyp_FLAG,
   305    310     /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,
   306    311     /* ColNames:  */ 0, 0,
   307    312     /* iArg:      */ SQLITE_FullFSync },
          313  +#endif
          314  +#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
          315  + {/* zName:     */ "function_list",
          316  +  /* ePragTyp:  */ PragTyp_FUNCTION_LIST,
          317  +  /* ePragFlg:  */ PragFlg_Result0,
          318  +  /* ColNames:  */ 29, 2,
          319  +  /* iArg:      */ 0 },
   308    320   #endif
   309    321   #if defined(SQLITE_HAS_CODEC)
   310    322    {/* zName:     */ "hexkey",
   311    323     /* ePragTyp:  */ PragTyp_HEXKEY,
   312    324     /* ePragFlg:  */ 0,
   313    325     /* ColNames:  */ 0, 0,
   314    326     /* iArg:      */ 0 },
................................................................................
   391    403     /* ColNames:  */ 0, 0,
   392    404     /* iArg:      */ 0 },
   393    405   #endif
   394    406   #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
   395    407    {/* zName:     */ "lock_status",
   396    408     /* ePragTyp:  */ PragTyp_LOCK_STATUS,
   397    409     /* ePragFlg:  */ PragFlg_Result0,
   398         -  /* ColNames:  */ 47, 2,
          410  +  /* ColNames:  */ 50, 2,
   399    411     /* iArg:      */ 0 },
   400    412   #endif
   401    413   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
   402    414    {/* zName:     */ "locking_mode",
   403    415     /* ePragTyp:  */ PragTyp_LOCKING_MODE,
   404    416     /* ePragFlg:  */ PragFlg_Result0|PragFlg_SchemaReq,
   405    417     /* ColNames:  */ 0, 0,
................................................................................
   410    422     /* ColNames:  */ 0, 0,
   411    423     /* iArg:      */ 0 },
   412    424    {/* zName:     */ "mmap_size",
   413    425     /* ePragTyp:  */ PragTyp_MMAP_SIZE,
   414    426     /* ePragFlg:  */ 0,
   415    427     /* ColNames:  */ 0, 0,
   416    428     /* iArg:      */ 0 },
          429  +#endif
          430  +#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
          431  +#if !defined(SQLITE_OMIT_VIRTUALTABLE)
          432  + {/* zName:     */ "module_list",
          433  +  /* ePragTyp:  */ PragTyp_MODULE_LIST,
          434  +  /* ePragFlg:  */ PragFlg_Result0,
          435  +  /* ColNames:  */ 31, 1,
          436  +  /* iArg:      */ 0 },
          437  +#endif
   417    438   #endif
   418    439    {/* zName:     */ "optimize",
   419    440     /* ePragTyp:  */ PragTyp_OPTIMIZE,
   420    441     /* ePragFlg:  */ PragFlg_Result1|PragFlg_NeedSchema,
   421    442     /* ColNames:  */ 0, 0,
   422    443     /* iArg:      */ 0 },
   423    444   #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
................................................................................
   598    619     /* ePragTyp:  */ PragTyp_WAL_AUTOCHECKPOINT,
   599    620     /* ePragFlg:  */ 0,
   600    621     /* ColNames:  */ 0, 0,
   601    622     /* iArg:      */ 0 },
   602    623    {/* zName:     */ "wal_checkpoint",
   603    624     /* ePragTyp:  */ PragTyp_WAL_CHECKPOINT,
   604    625     /* ePragFlg:  */ PragFlg_NeedSchema,
   605         -  /* ColNames:  */ 43, 3,
          626  +  /* ColNames:  */ 46, 3,
   606    627     /* iArg:      */ 0 },
   607    628   #endif
   608    629   #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
   609    630    {/* zName:     */ "writable_schema",
   610    631     /* ePragTyp:  */ PragTyp_FLAG,
   611    632     /* ePragFlg:  */ PragFlg_Result0|PragFlg_NoColumns1,
   612    633     /* ColNames:  */ 0, 0,
   613    634     /* iArg:      */ SQLITE_WriteSchema },
   614    635   #endif
   615    636   };
   616         -/* Number of pragmas: 60 on by default, 74 total. */
          637  +/* Number of pragmas: 62 on by default, 76 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  +
          260  +  NAME: module_list
          261  +  FLAG: Result0
          262  +  COLS: name
          263  +  IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
          264  +  IF:   !defined(SQLITE_OMIT_VIRTUALTABLE)
          265  +
   255    266     NAME: collation_list
   256    267     FLAG: Result0
   257    268     COLS: seq name
   258    269     IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
   259    270   
   260    271     NAME: foreign_key_list
   261    272     FLAG: NeedSchema Result1 SchemaOpt