/ Check-in [7b7a69d0]
Login

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

Overview
Comment:Add the SF_HasAgg constant (currently unused). Also enhance the comments on many other constant definitions to detail constraints on their values.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7b7a69d098f7581a43b818c251717c2450b797de
User & Date: drh 2016-04-14 16:40:13
Context
2016-04-14
19:29
Work toward improving analysis and code generation for DISTINCT and aggregate queries. Leaf check-in: 129083bd user: drh tags: better-distinct-agg
17:29
In the ICU extension toupper() and tolower() SQL functions, avoid calling u_strToUpper() or u_strToLower() a second time if the buffer passed to the first invocation turns out to be large enough. check-in: d23e5813 user: dan tags: trunk
16:40
Add the SF_HasAgg constant (currently unused). Also enhance the comments on many other constant definitions to detail constraints on their values. check-in: 7b7a69d0 user: drh tags: trunk
15:44
Correctly interpret negative "PRAGMA cache_size" values when determining the cache-size used for sorting large amounts of data (i.e. the functionality in vdbesort.c). check-in: 79147dca user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pager.h.

    64     64   ** Valid values for the second argument to sqlite3PagerLockingMode().
    65     65   */
    66     66   #define PAGER_LOCKINGMODE_QUERY      -1
    67     67   #define PAGER_LOCKINGMODE_NORMAL      0
    68     68   #define PAGER_LOCKINGMODE_EXCLUSIVE   1
    69     69   
    70     70   /*
    71         -** Numeric constants that encode the journalmode.  
           71  +** Numeric constants that encode the journalmode.
           72  +**
           73  +** The numeric values encoded here (other than PAGER_JOURNALMODE_QUERY)
           74  +** are exposed in the API via the "PRAGMA journal_mode" command and
           75  +** therefore cannot be changed without a compatibility break.
    72     76   */
    73     77   #define PAGER_JOURNALMODE_QUERY     (-1)  /* Query the value of journalmode */
    74     78   #define PAGER_JOURNALMODE_DELETE      0   /* Commit by deleting journal file */
    75     79   #define PAGER_JOURNALMODE_PERSIST     1   /* Commit by zeroing journal header */
    76     80   #define PAGER_JOURNALMODE_OFF         2   /* Journal omitted.  */
    77     81   #define PAGER_JOURNALMODE_TRUNCATE    3   /* Commit by truncating journal */
    78     82   #define PAGER_JOURNALMODE_MEMORY      4   /* In-memory journal file */
................................................................................
    82     86   ** Flags that make up the mask passed to sqlite3PagerGet().
    83     87   */
    84     88   #define PAGER_GET_NOCONTENT     0x01  /* Do not load data from disk */
    85     89   #define PAGER_GET_READONLY      0x02  /* Read-only page is acceptable */
    86     90   
    87     91   /*
    88     92   ** Flags for sqlite3PagerSetFlags()
           93  +**
           94  +** Value constraints (enforced via assert()):
           95  +**    PAGER_FULLFSYNC      == SQLITE_FullFSync
           96  +**    PAGER_CKPT_FULLFSYNC == SQLITE_CkptFullFSync
           97  +**    PAGER_CACHE_SPILL    == SQLITE_CacheSpill
    89     98   */
    90     99   #define PAGER_SYNCHRONOUS_OFF       0x01  /* PRAGMA synchronous=OFF */
    91    100   #define PAGER_SYNCHRONOUS_NORMAL    0x02  /* PRAGMA synchronous=NORMAL */
    92    101   #define PAGER_SYNCHRONOUS_FULL      0x03  /* PRAGMA synchronous=FULL */
    93    102   #define PAGER_SYNCHRONOUS_EXTRA     0x04  /* PRAGMA synchronous=EXTRA */
    94    103   #define PAGER_SYNCHRONOUS_MASK      0x07  /* Mask for four values above */
    95    104   #define PAGER_FULLFSYNC             0x08  /* PRAGMA fullfsync=ON */

Changes to src/sqliteInt.h.

  1346   1346   ** A macro to discover the encoding of a database.
  1347   1347   */
  1348   1348   #define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)
  1349   1349   #define ENC(db)        ((db)->enc)
  1350   1350   
  1351   1351   /*
  1352   1352   ** Possible values for the sqlite3.flags.
         1353  +**
         1354  +** Value constraints (enforced via assert()):
         1355  +**      SQLITE_FullFSync     == PAGER_FULLFSYNC
         1356  +**      SQLITE_CkptFullFSync == PAGER_CKPT_FULLFSYNC
         1357  +**      SQLITE_CacheSpill    == PAGER_CACHE_SPILL
  1353   1358   */
  1354   1359   #define SQLITE_VdbeTrace      0x00000001  /* True to trace VDBE execution */
  1355   1360   #define SQLITE_InternChanges  0x00000002  /* Uncommitted Hash table changes */
  1356   1361   #define SQLITE_FullColNames   0x00000004  /* Show full column names on SELECT */
  1357   1362   #define SQLITE_FullFSync      0x00000008  /* Use full fsync on the backend */
  1358   1363   #define SQLITE_CkptFullFSync  0x00000010  /* Use full fsync for checkpoint */
  1359   1364   #define SQLITE_CacheSpill     0x00000020  /* OK to spill pager cache */
................................................................................
  1480   1485   };
  1481   1486   
  1482   1487   /*
  1483   1488   ** Possible values for FuncDef.flags.  Note that the _LENGTH and _TYPEOF
  1484   1489   ** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG.  And
  1485   1490   ** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC.  There
  1486   1491   ** are assert() statements in the code to verify this.
         1492  +**
         1493  +** Value constraints (enforced via assert()):
         1494  +**     SQLITE_FUNC_MINMAX    ==  NC_MinMaxAgg      == SF_MinMaxAgg
         1495  +**     SQLITE_FUNC_LENGTH    ==  OPFLAG_LENGTHARG
         1496  +**     SQLITE_FUNC_TYPEOF    ==  OPFLAG_TYPEOFARG
         1497  +**     SQLITE_FUNC_CONSTANT  ==  SQLITE_DETERMINISTIC from the API
         1498  +**     SQLITE_FUNC_ENCMASK   depends on SQLITE_UTF* macros in the API
  1487   1499   */
  1488   1500   #define SQLITE_FUNC_ENCMASK  0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
  1489   1501   #define SQLITE_FUNC_LIKE     0x0004 /* Candidate for the LIKE optimization */
  1490   1502   #define SQLITE_FUNC_CASE     0x0008 /* Case-sensitive LIKE-type function */
  1491   1503   #define SQLITE_FUNC_EPHEM    0x0010 /* Ephemeral.  Delete with VDBE */
  1492   1504   #define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/
  1493   1505   #define SQLITE_FUNC_LENGTH   0x0040 /* Built-in length() function */
................................................................................
  2479   2491   #define JT_OUTER     0x0020    /* The "OUTER" keyword is present */
  2480   2492   #define JT_ERROR     0x0040    /* unknown or unsupported join type */
  2481   2493   
  2482   2494   
  2483   2495   /*
  2484   2496   ** Flags appropriate for the wctrlFlags parameter of sqlite3WhereBegin()
  2485   2497   ** and the WhereInfo.wctrlFlags member.
         2498  +**
         2499  +** Value constraints (enforced via assert()):
         2500  +**     WHERE_USE_LIMIT  == SF_FixedLimit
  2486   2501   */
  2487   2502   #define WHERE_ORDERBY_NORMAL   0x0000 /* No-op */
  2488   2503   #define WHERE_ORDERBY_MIN      0x0001 /* ORDER BY processing for min() func */
  2489   2504   #define WHERE_ORDERBY_MAX      0x0002 /* ORDER BY processing for max() func */
  2490   2505   #define WHERE_ONEPASS_DESIRED  0x0004 /* Want to do one-pass UPDATE/DELETE */
  2491   2506   #define WHERE_DUPLICATES_OK    0x0008 /* Ok to return a row more than once */
  2492   2507   #define WHERE_OMIT_OPEN_CLOSE  0x0010 /* Table cursors are already open */
................................................................................
  2539   2554     int nErr;            /* Number of errors encountered while resolving names */
  2540   2555     u16 ncFlags;         /* Zero or more NC_* flags defined below */
  2541   2556   };
  2542   2557   
  2543   2558   /*
  2544   2559   ** Allowed values for the NameContext, ncFlags field.
  2545   2560   **
  2546         -** Note:  NC_MinMaxAgg must have the same value as SF_MinMaxAgg and
  2547         -** SQLITE_FUNC_MINMAX.
         2561  +** Value constraints (all checked via assert()):
         2562  +**    NC_HasAgg    == SF_HasAgg
         2563  +**    NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
  2548   2564   **
  2549   2565   */
  2550   2566   #define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */
  2551         -#define NC_HasAgg    0x0002  /* One or more aggregate functions seen */
         2567  +#define NC_PartIdx   0x0002  /* True if resolving a partial index WHERE */
  2552   2568   #define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */
  2553   2569   #define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */
  2554         -#define NC_PartIdx   0x0010  /* True if resolving a partial index WHERE */
         2570  +#define NC_HasAgg    0x0010  /* One or more aggregate functions seen */
  2555   2571   #define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */
  2556   2572   #define NC_MinMaxAgg 0x1000  /* min/max aggregates seen.  See note above */
  2557   2573   
  2558   2574   /*
  2559   2575   ** An instance of the following structure contains all information
  2560   2576   ** needed to generate code for a single SELECT statement.
  2561   2577   **
................................................................................
  2596   2612     Expr *pOffset;         /* OFFSET expression. NULL means not used. */
  2597   2613     With *pWith;           /* WITH clause attached to this select. Or NULL. */
  2598   2614   };
  2599   2615   
  2600   2616   /*
  2601   2617   ** Allowed values for Select.selFlags.  The "SF" prefix stands for
  2602   2618   ** "Select Flag".
         2619  +**
         2620  +** Value constraints (all checked via assert())
         2621  +**     SF_HasAgg     == NC_HasAgg
         2622  +**     SF_MinMaxAgg  == NC_MinMaxAgg     == SQLITE_FUNC_MINMAX
         2623  +**     SF_FixedLimit == WHERE_USE_LIMIT
  2603   2624   */
  2604   2625   #define SF_Distinct       0x00001  /* Output should be DISTINCT */
  2605   2626   #define SF_All            0x00002  /* Includes the ALL keyword */
  2606   2627   #define SF_Resolved       0x00004  /* Identifiers have been resolved */
  2607         -#define SF_Aggregate      0x00008  /* Contains aggregate functions */
  2608         -#define SF_UsesEphemeral  0x00010  /* Uses the OpenEphemeral opcode */
  2609         -#define SF_Expanded       0x00020  /* sqlite3SelectExpand() called on this */
  2610         -#define SF_HasTypeInfo    0x00040  /* FROM subqueries have Table metadata */
  2611         -#define SF_Compound       0x00080  /* Part of a compound query */
  2612         -#define SF_Values         0x00100  /* Synthesized from VALUES clause */
  2613         -#define SF_MultiValue     0x00200  /* Single VALUES term with multiple rows */
  2614         -#define SF_NestedFrom     0x00400  /* Part of a parenthesized FROM clause */
  2615         -#define SF_MaybeConvert   0x00800  /* Need convertCompoundSelectToSubquery() */
         2628  +#define SF_Aggregate      0x00008  /* Contains agg functions or a GROUP BY */
         2629  +#define SF_HasAgg         0x00010  /* Contains aggregate functions */
         2630  +#define SF_UsesEphemeral  0x00020  /* Uses the OpenEphemeral opcode */
         2631  +#define SF_Expanded       0x00040  /* sqlite3SelectExpand() called on this */
         2632  +#define SF_HasTypeInfo    0x00080  /* FROM subqueries have Table metadata */
         2633  +#define SF_Compound       0x00100  /* Part of a compound query */
         2634  +#define SF_Values         0x00200  /* Synthesized from VALUES clause */
         2635  +#define SF_MultiValue     0x00400  /* Single VALUES term with multiple rows */
         2636  +#define SF_NestedFrom     0x00800  /* Part of a parenthesized FROM clause */
  2616   2637   #define SF_MinMaxAgg      0x01000  /* Aggregate containing min() or max() */
  2617   2638   #define SF_Recursive      0x02000  /* The recursive part of a recursive CTE */
  2618   2639   #define SF_FixedLimit     0x04000  /* nSelectRow set by a constant LIMIT */
  2619         -#define SF_Converted      0x08000  /* By convertCompoundSelectToSubquery() */
  2620         -#define SF_IncludeHidden  0x10000  /* Include hidden columns in output */
         2640  +#define SF_MaybeConvert   0x08000  /* Need convertCompoundSelectToSubquery() */
         2641  +#define SF_Converted      0x10000  /* By convertCompoundSelectToSubquery() */
         2642  +#define SF_IncludeHidden  0x20000  /* Include hidden columns in output */
  2621   2643   
  2622   2644   
  2623   2645   /*
  2624   2646   ** The results of a SELECT can be distributed in several ways, as defined
  2625   2647   ** by one of the following macros.  The "SRT" prefix means "SELECT Result
  2626   2648   ** Type".
  2627   2649   **
................................................................................
  2924   2946   struct AuthContext {
  2925   2947     const char *zAuthContext;   /* Put saved Parse.zAuthContext here */
  2926   2948     Parse *pParse;              /* The Parse structure */
  2927   2949   };
  2928   2950   
  2929   2951   /*
  2930   2952   ** Bitfield flags for P5 value in various opcodes.
         2953  +**
         2954  +** Value constraints (enforced via assert()):
         2955  +**    OPFLAG_LENGTHARG    == SQLITE_FUNC_LENGTH
         2956  +**    OPFLAG_TYPEOFARG    == SQLITE_FUNC_TYPEOF
         2957  +**    OPFLAG_BULKCSR      == BTREE_BULKLOAD
         2958  +**    OPFLAG_SEEKEQ       == BTREE_SEEK_EQ
         2959  +**    OPFLAG_FORDELETE    == BTREE_FORDELETE
         2960  +**    OPFLAG_SAVEPOSITION == BTREE_SAVEPOSITION
         2961  +**    OPFLAG_AUXDELETE    == BTREE_AUXDELETE
  2931   2962   */
  2932   2963   #define OPFLAG_NCHANGE       0x01    /* OP_Insert: Set to update db->nChange */
  2933   2964                                        /* Also used in P2 (not P5) of OP_Delete */
  2934   2965   #define OPFLAG_EPHEM         0x01    /* OP_Column: Ephemeral output is ok */
  2935   2966   #define OPFLAG_LASTROWID     0x02    /* Set to update db->lastRowid */
  2936   2967   #define OPFLAG_ISUPDATE      0x04    /* This OP_Insert is an sql UPDATE */
  2937   2968   #define OPFLAG_APPEND        0x08    /* This is likely to be an append */

Changes to src/whereInt.h.

   488    488   
   489    489   
   490    490   /*
   491    491   ** Bitmasks for the operators on WhereTerm objects.  These are all
   492    492   ** operators that are of interest to the query planner.  An
   493    493   ** OR-ed combination of these values can be used when searching for
   494    494   ** particular WhereTerms within a WhereClause.
          495  +**
          496  +** Value constraints:
          497  +**     WO_EQ    == SQLITE_INDEX_CONSTRAINT_EQ
          498  +**     WO_LT    == SQLITE_INDEX_CONSTRAINT_LT
          499  +**     WO_LE    == SQLITE_INDEX_CONSTRAINT_LE
          500  +**     WO_GT    == SQLITE_INDEX_CONSTRAINT_GT
          501  +**     WO_GE    == SQLITE_INDEX_CONSTRAINT_GE
          502  +**     WO_MATCH == SQLITE_INDEX_CONSTRAINT_MATCH
   495    503   */
   496    504   #define WO_IN     0x0001
   497    505   #define WO_EQ     0x0002
   498    506   #define WO_LT     (WO_EQ<<(TK_LT-TK_EQ))
   499    507   #define WO_LE     (WO_EQ<<(TK_LE-TK_EQ))
   500    508   #define WO_GT     (WO_EQ<<(TK_GT-TK_EQ))
   501    509   #define WO_GE     (WO_EQ<<(TK_GE-TK_EQ))