/ Check-in [97a94446]
Login

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

Overview
Comment:Restore the legacy behavior of enabling double-quoted string literals in all contexts. But also provide a new compile-time option (SQLITE_DQS) to change the default to something more restrictive.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 97a94446f3941c313c4c3a19d9f89f24d7ef06e842f79d66f0ad88810b872084
User & Date: drh 2019-07-02 12:23:09
Context
2019-07-04
16:05
Fix a race condition that could occur in SQLITE_ENABLE_MEMORY_MANAGEMENT builds when two threads simultaneously open the first two database connections in the process. check-in: 5ea3f6fc user: dan tags: trunk
2019-07-02
12:23
Restore the legacy behavior of enabling double-quoted string literals in all contexts. But also provide a new compile-time option (SQLITE_DQS) to change the default to something more restrictive. check-in: 97a94446 user: drh tags: trunk
2019-06-28
07:08
Use the OP_Sequence opcode for generating unique rowid values for an autoindex on a co-routine implementation of a subquery. check-in: eab42975 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/main.c.

  3069   3069     memcpy(db->aLimit, aHardLimit, sizeof(db->aLimit));
  3070   3070     db->aLimit[SQLITE_LIMIT_WORKER_THREADS] = SQLITE_DEFAULT_WORKER_THREADS;
  3071   3071     db->autoCommit = 1;
  3072   3072     db->nextAutovac = -1;
  3073   3073     db->szMmap = sqlite3GlobalConfig.szMmap;
  3074   3074     db->nextPagesize = 0;
  3075   3075     db->nMaxSorterMmap = 0x7FFFFFFF;
  3076         -  db->flags |= SQLITE_ShortColNames | SQLITE_EnableTrigger | SQLITE_CacheSpill
         3076  +  db->flags |= SQLITE_ShortColNames
         3077  +                 | SQLITE_EnableTrigger
         3078  +                 | SQLITE_CacheSpill
         3079  +
         3080  +/* The SQLITE_DQS compile-time option determines the default settings
         3081  +** for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML.
         3082  +**
         3083  +**    SQLITE_DQS     SQLITE_DBCONFIG_DQS_DDL    SQLITE_DBCONFIG_DQS_DML
         3084  +**    ----------     -----------------------    -----------------------
         3085  +**     undefined               on                          on   
         3086  +**         3                   on                          on
         3087  +**         2                   on                         off
         3088  +**         1                  off                          on
         3089  +**         0                  off                         off
         3090  +**
         3091  +** Legacy behavior is 3 (double-quoted string literals are allowed anywhere)
         3092  +** and so that is the default.  But developers are encouranged to use
         3093  +** -DSQLITE_DQS=0 (best) or -DSQLITE_DQS=1 (second choice) if possible.
         3094  +*/
         3095  +#if !defined(SQLITE_DQS)
         3096  +# define SQLITE_DQS 3
         3097  +#endif
         3098  +#if (SQLITE_DQS&1)==1
  3077   3099                    | SQLITE_DqsDML
         3100  +#endif
         3101  +#if (SQLITE_DQS&2)==2
         3102  +                 | SQLITE_DqsDDL
         3103  +#endif
         3104  +
  3078   3105   #if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
  3079   3106                    | SQLITE_AutoIndex
  3080   3107   #endif
  3081   3108   #if SQLITE_DEFAULT_CKPTFULLFSYNC
  3082   3109                    | SQLITE_CkptFullFSync
  3083   3110   #endif
  3084   3111   #if SQLITE_DEFAULT_FILE_FORMAT<4

Changes to src/sqlite.h.in.

  2231   2231   ** using the [PRAGMA legacy_alter_table] statement.
  2232   2232   ** </dd>
  2233   2233   **
  2234   2234   ** [[SQLITE_DBCONFIG_DQS_DML]]
  2235   2235   ** <dt>SQLITE_DBCONFIG_DQS_DML</td>
  2236   2236   ** <dd>The SQLITE_DBCONFIG_DQS_DML option activates or deactivates
  2237   2237   ** the legacy [double-quoted string literal] misfeature for DML statement
  2238         -** only, that is DELETE, INSERT, SELECT, and UPDATE statements.
         2238  +** only, that is DELETE, INSERT, SELECT, and UPDATE statements. The
         2239  +** default value of this setting is determined by the [-DSQLITE_DQS]
         2240  +** compile-time option.
  2239   2241   ** </dd>
  2240   2242   **
  2241   2243   ** [[SQLITE_DBCONFIG_DQS_DDL]]
  2242   2244   ** <dt>SQLITE_DBCONFIG_DQS_DDL</td>
  2243   2245   ** <dd>The SQLITE_DBCONFIG_DQS option activates or deactivates
  2244   2246   ** the legacy [double-quoted string literal] misfeature for DDL statements,
  2245         -** such as CREATE TABLE and CREATE INDEX.
         2247  +** such as CREATE TABLE and CREATE INDEX. The
         2248  +** default value of this setting is determined by the [-DSQLITE_DQS]
         2249  +** compile-time option.
  2246   2250   ** </dd>
  2247   2251   ** </dl>
  2248   2252   */
  2249   2253   #define SQLITE_DBCONFIG_MAINDBNAME            1000 /* const char* */
  2250   2254   #define SQLITE_DBCONFIG_LOOKASIDE             1001 /* void* int int */
  2251   2255   #define SQLITE_DBCONFIG_ENABLE_FKEY           1002 /* int int* */
  2252   2256   #define SQLITE_DBCONFIG_ENABLE_TRIGGER        1003 /* int int* */

Changes to test/quote.test.

    88     88   
    89     89   #-------------------------------------------------------------------------
    90     90   # Check that it is not possible to use double-quotes for a string
    91     91   # constant in a CHECK constraint or CREATE INDEX statement. However, 
    92     92   # SQLite can load such a schema from disk.
    93     93   #
    94     94   reset_db 
           95  +sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 0
           96  +sqlite3_db_config db SQLITE_DBCONFIG_DQS_DML 1
    95     97   do_execsql_test 2.0 {
    96     98     CREATE TABLE t1(x, y, z);
    97     99   }
    98    100   foreach {tn sql errname} {
    99    101     1 { CREATE TABLE xyz(a, b, c CHECK (c!="null") ) } null
   100    102     2 { CREATE INDEX i2 ON t1(x, y, z||"abc") }        abc
   101    103     3 { CREATE INDEX i3 ON t1("w") }                   w