Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | The sqlite3_normalized_sql() interface should not be transforming quoted identifier names into wildcards. Fix this, and at the same time simplify the code substantially. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e8540377ec66fa5f9ae3c93bedb5c094 |
User & Date: | drh 2018-12-05 23:45:46.950 |
Context
2018-12-06
| ||
20:18 | Experimental changes to (optionally) allow double-quoted strings to be checked against known identifiers. (Leaf check-in: 73a6b8c1b9 user: mistachkin tags: normalize_v4) | |
2018-12-05
| ||
23:56 | Get rid of the hash table used to track IN operators in the sqlite3_normalized_sql() implementation. Use simple integer variables instead. (check-in: 272dc74fd0 user: drh tags: trunk) | |
23:45 | The sqlite3_normalized_sql() interface should not be transforming quoted identifier names into wildcards. Fix this, and at the same time simplify the code substantially. (check-in: e8540377ec user: drh tags: trunk) | |
21:55 | Fix an imbalanced lock problem in sqlite3Normalize() introduced by the simplification in [94ea6379178e3ff6a]. (check-in: f69624373e user: drh tags: trunk) | |
Changes
Changes to src/expr.c.
︙ | ︙ | |||
2145 2146 2147 2148 2149 2150 2151 | */ int sqlite3IsRowid(const char *z){ if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1; if( sqlite3StrICmp(z, "ROWID")==0 ) return 1; if( sqlite3StrICmp(z, "OID")==0 ) return 1; return 0; } | < < < < < < < < | 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 | */ int sqlite3IsRowid(const char *z){ if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1; if( sqlite3StrICmp(z, "ROWID")==0 ) return 1; if( sqlite3StrICmp(z, "OID")==0 ) return 1; return 0; } /* ** pX is the RHS of an IN operator. If pX is a SELECT statement ** that can be simplified to a direct table access, then return ** a pointer to the SELECT statement. If pX is not a SELECT statement, ** or if the SELECT statement needs to be manifested into a transient ** table, then return NULL. |
︙ | ︙ |
Changes to src/prepare.c.
︙ | ︙ | |||
706 707 708 709 710 711 712 | rc = sqlite3ApiExit(db, rc); assert( (rc&db->errMask)==rc ); sqlite3_mutex_leave(db->mutex); return rc; } #ifdef SQLITE_ENABLE_NORMALIZE | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 706 707 708 709 710 711 712 713 714 715 716 717 718 719 | rc = sqlite3ApiExit(db, rc); assert( (rc&db->errMask)==rc ); sqlite3_mutex_leave(db->mutex); return rc; } #ifdef SQLITE_ENABLE_NORMALIZE /* ** Attempt to estimate the final output buffer size needed for the fully ** normalized version of the specified SQL string. This should take into ** account any potential expansion that could occur (e.g. via IN clauses ** being expanded, etc). This size returned is the total number of bytes ** including the NUL terminator. |
︙ | ︙ | |||
968 969 970 971 972 973 974 | break; } } if( j>0 && sqlite3IsIdChar(z[j-1]) && sqlite3IsIdChar(zSql[i]) ){ z[j++] = ' '; } if( tokenType==TK_ID ){ | | < < < < < < < | 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 | break; } } if( j>0 && sqlite3IsIdChar(z[j-1]) && sqlite3IsIdChar(zSql[i]) ){ z[j++] = ' '; } if( tokenType==TK_ID ){ int i2 = i, n2 = n; if( nParen>0 ){ assert( nParen<nSql ); sqlite3HashInsert(&inHash, zSql+nParen, 0); } if( flags&SQLITE_TOKEN_QUOTED ){ i2++; n2-=2; } } copyNormalizedToken(zSql, i, n, flags, z, &j); break; } } } assert( j<nZ && "one" ); |
︙ | ︙ |
Changes to src/sqliteInt.h.
︙ | ︙ | |||
4023 4024 4025 4026 4027 4028 4029 | #ifdef SQLITE_ENABLE_CURSOR_HINTS int sqlite3ExprContainsSubquery(Expr*); #endif int sqlite3ExprIsInteger(Expr*, int*); int sqlite3ExprCanBeNull(const Expr*); int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); int sqlite3IsRowid(const char*); | < < < | 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 | #ifdef SQLITE_ENABLE_CURSOR_HINTS int sqlite3ExprContainsSubquery(Expr*); #endif int sqlite3ExprIsInteger(Expr*, int*); int sqlite3ExprCanBeNull(const Expr*); int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); int sqlite3IsRowid(const char*); void sqlite3GenerateRowDelete( Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int); void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int); int sqlite3GenerateIndexKey(Parse*, Index*, int, int, int, int*,Index*,int); void sqlite3ResolvePartIdxLabel(Parse*,int); int sqlite3ExprReferencesUpdatedColumn(Expr*,int*,int); void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int, |
︙ | ︙ |
Changes to test/normalize.test.
︙ | ︙ | |||
203 204 205 206 207 208 209 | {SELECT a FROM t1 WHERE x IN (1,2,3) AND hex8('abc');} 0x2 {0 {SELECT a FROM t1 WHERE x IN(?,?,?)AND hex8(?);}} 430 {SELECT "a" FROM t1 WHERE "x" IN ("1","2",'3');} 0x2 | | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | {SELECT a FROM t1 WHERE x IN (1,2,3) AND hex8('abc');} 0x2 {0 {SELECT a FROM t1 WHERE x IN(?,?,?)AND hex8(?);}} 430 {SELECT "a" FROM t1 WHERE "x" IN ("1","2",'3');} 0x2 {0 {SELECT"a"FROM t1 WHERE"x"IN("1","2",?);}} 440 {SELECT 'a' FROM t1 WHERE 'x';} 0x2 {0 {SELECT?FROM t1 WHERE?;}} 450 |
︙ | ︙ |