/ Check-in [9b6e9a6e]
Login

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

Overview
Comment:Bungled checkin. Ignore.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | mistake
Files: files | file ages | folders
SHA3-256: 9b6e9a6e45f3da3ac76b40f1c56d6aa0e9ee40b67968bd9ad183e169bb9f4c9a
User & Date: drh 2018-12-05 23:25:44
Original Comment: Simplify the sqlite3_normalized_sql() implementation so that it asssumes well-formed SQL inputs in this sense: double-quoted names are always taken to be valid identifiers and never string literals.
Context
2018-12-05
23:25
Bungled checkin. Ignore. Closed-Leaf check-in: 9b6e9a6e user: drh tags: mistake
21:55
Fix an imbalanced lock problem in sqlite3Normalize() introduced by the simplification in [94ea6379178e3ff6a]. check-in: f6962437 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/prepare.c.

   712    712   #ifdef SQLITE_ENABLE_NORMALIZE
   713    713   /*
   714    714   ** Checks if the specified token is a table, column, or function name,
   715    715   ** based on the databases associated with the statement being prepared.
   716    716   ** If the function fails, zero is returned and pRc is filled with the
   717    717   ** error code.
   718    718   */
          719  +#if 0
   719    720   static int shouldTreatAsIdentifier(
   720    721     sqlite3 *db,        /* Database handle. */
   721    722     const char *zToken, /* Pointer to start of token to be checked */
   722    723     int nToken,         /* Length of token to be checked */
   723    724     int *pRc            /* Pointer to error code upon failure */
   724    725   ){
   725    726     int bFound = 0;     /* Non-zero if token is an identifier name. */
................................................................................
   793    794   done2:
   794    795     sqlite3BtreeLeaveAll(db);
   795    796     sqlite3_mutex_leave(db->mutex);
   796    797   done1:
   797    798     if( zId!=zSpace ) sqlite3DbFree(db, zId);
   798    799     return bFound;
   799    800   }
          801  +#endif
   800    802   
   801    803   /*
   802    804   ** Attempt to estimate the final output buffer size needed for the fully
   803    805   ** normalized version of the specified SQL string.  This should take into
   804    806   ** account any potential expansion that could occur (e.g. via IN clauses
   805    807   ** being expanded, etc).  This size returned is the total number of bytes
   806    808   ** including the NUL terminator.
................................................................................
   968    970               break;
   969    971             }
   970    972           }
   971    973           if( j>0 && sqlite3IsIdChar(z[j-1]) && sqlite3IsIdChar(zSql[i]) ){
   972    974             z[j++] = ' ';
   973    975           }
   974    976           if( tokenType==TK_ID ){
   975         -          int i2 = i, n2 = n, rc = SQLITE_OK;
          977  +          int i2 = i, n2 = n  ;//, rc = SQLITE_OK;
   976    978             if( nParen>0 ){
   977    979               assert( nParen<nSql );
   978    980               sqlite3HashInsert(&inHash, zSql+nParen, 0);
   979    981             }
   980    982             if( flags&SQLITE_TOKEN_QUOTED ){ i2++; n2-=2; }
          983  +#if 0
   981    984             if( shouldTreatAsIdentifier(db, zSql+i2, n2, &rc)==0 ){
   982    985               if( rc!=SQLITE_OK ) goto normalizeError;
   983    986               if( sqlite3_keyword_check(zSql+i2, n2)==0 ){
   984    987                 z[j++] = '?';
   985    988                 break;
   986    989               }
   987    990             }
          991  +#endif
   988    992           }
   989    993           copyNormalizedToken(zSql, i, n, flags, z, &j);
   990    994           break;
   991    995         }
   992    996       }
   993    997     }
   994    998     assert( j<nZ && "one" );

Changes to test/normalize.test.

   203    203     {SELECT a FROM t1 WHERE x IN (1,2,3) AND hex8('abc');}
   204    204     0x2
   205    205     {0 {SELECT a FROM t1 WHERE x IN(?,?,?)AND hex8(?);}}
   206    206   
   207    207     430
   208    208     {SELECT "a" FROM t1 WHERE "x" IN ("1","2",'3');}
   209    209     0x2
   210         -  {0 {SELECT"a"FROM t1 WHERE"x"IN(?,?,?);}}
          210  +  {0 {SELECT"a"FROM t1 WHERE"x"IN("1","2",?);}}
   211    211   
   212    212     440
   213    213     {SELECT 'a' FROM t1 WHERE 'x';}
   214    214     0x2
   215    215     {0 {SELECT?FROM t1 WHERE?;}}
   216    216   
   217    217     450