diff options
author | drh <drh@noemail.net> | 2018-12-10 20:01:40 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-12-10 20:01:40 +0000 |
commit | 1a6c2b1d383009aeb306f53f1915a443ab79de0f (patch) | |
tree | eb1fc5b14fee5fb4e352f27735fd86028fc73603 /src | |
parent | 21b9225ff595a1ec121ac18ebb5ab066257a9893 (diff) | |
download | sqlite-1a6c2b1d383009aeb306f53f1915a443ab79de0f.tar.gz sqlite-1a6c2b1d383009aeb306f53f1915a443ab79de0f.zip |
Further refinements to the sqlite3_normalized_sql() interface. TH3 now
gives 100% MC/DC on that interface.
FossilOrigin-Name: c96bf6cca220e363b099455ce35195ce7e89d374a52dc787f56e7b11e587bced
Diffstat (limited to 'src')
-rw-r--r-- | src/resolve.c | 2 | ||||
-rw-r--r-- | src/sqlite.h.in | 15 | ||||
-rw-r--r-- | src/sqliteInt.h | 2 | ||||
-rw-r--r-- | src/tokenize.c | 7 | ||||
-rw-r--r-- | src/vdbeapi.c | 4 | ||||
-rw-r--r-- | src/vdbeaux.c | 7 |
6 files changed, 14 insertions, 23 deletions
diff --git a/src/resolve.c b/src/resolve.c index a9262a45a..6dc42aef7 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -491,7 +491,7 @@ static int lookupName( sqlite3_log(SQLITE_WARNING, "double-quoted string literal: \"%w\"", zCol); #ifdef SQLITE_ENABLE_NORMALIZE - sqlite3VdbeAddDblquoteStr(db,pParse->pVdbe, zCol); + sqlite3VdbeAddDblquoteStr(db, pParse->pVdbe, zCol); #endif pExpr->op = TK_STRING; pExpr->y.pTab = 0; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 4f33bb9ca..08d499037 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -3629,14 +3629,13 @@ int sqlite3_limit(sqlite3*, int id, int newVal); ** deplete the limited store of lookaside memory. Future versions of ** SQLite may act on this hint differently. ** -** [[SQLITE_PREPARE_NORMALIZE]] ^(<dt>SQLITE_PREPARE_NORMALIZE</dt> -** <dd>The SQLITE_PREPARE_NORMALIZE flag indicates that a normalized -** representation of the SQL statement should be calculated and then -** associated with the prepared statement, which can be obtained via -** the [sqlite3_normalized_sql()] interface.)^ The semantics used to -** normalize a SQL statement are unspecified and subject to change. -** At a minimum, literal values will be replaced with suitable -** placeholders. +** [[SQLITE_PREPARE_NORMALIZE]] <dt>SQLITE_PREPARE_NORMALIZE</dt> +** <dd>The SQLITE_PREPARE_NORMALIZE flag is a no-op. This flag used +** to be required for any prepared statement that wanted to use the +** [sqlite3_normalized_sql()] interface. However, the +** [sqlite3_normalized_sql()] interface is now available to all +** prepared statements, regardless of whether or not they use this +** flag. ** </dl> */ #define SQLITE_PREPARE_PERSISTENT 0x01 diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b8f771488..7dd258482 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4413,7 +4413,7 @@ int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *); void sqlite3ParserReset(Parse*); #ifdef SQLITE_ENABLE_NORMALIZE -char *sqlite3Normalize(Vdbe*, const char*, int); +char *sqlite3Normalize(Vdbe*, const char*); #endif int sqlite3Reprepare(Vdbe*); void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*); diff --git a/src/tokenize.c b/src/tokenize.c index 499fae6f1..297f9ab00 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -734,8 +734,7 @@ static void addSpaceSeparator(sqlite3_str *pStr){ */ char *sqlite3Normalize( Vdbe *pVdbe, /* VM being reprepared */ - const char *zSql, /* The original SQL string */ - int nSql /* Size of the input string in bytes */ + const char *zSql /* The original SQL string */ ){ sqlite3 *db; /* The database connection */ int i; /* Next unread byte of zSql[] */ @@ -748,12 +747,12 @@ char *sqlite3Normalize( int j; /* Bytes of normalized SQL generated so far */ sqlite3_str *pStr; /* The normalized SQL string under construction */ - if( zSql==0 || nSql==0 ) return 0; db = sqlite3VdbeDb(pVdbe); tokenType = -1; nParen = iStartIN = nParenAtIN = 0; pStr = sqlite3_str_new(db); - for(i=0; i<nSql && pStr->accError==0; i+=n){ + assert( pStr!=0 ); /* sqlite3_str_new() never returns NULL */ + for(i=0; zSql[i] && pStr->accError==0; i+=n){ if( tokenType!=TK_SPACE ){ prevType = tokenType; } diff --git a/src/vdbeapi.c b/src/vdbeapi.c index d8a463ae3..91379a146 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -1713,9 +1713,9 @@ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){ const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt){ Vdbe *p = (Vdbe *)pStmt; if( p==0 ) return 0; - if( p->zNormSql==0 && p->zSql!=0 ){ + if( p->zNormSql==0 && ALWAYS(p->zSql!=0) ){ sqlite3_mutex_enter(p->db->mutex); - p->zNormSql = sqlite3Normalize(p, p->zSql, sqlite3Strlen30(p->zSql)); + p->zNormSql = sqlite3Normalize(p, p->zSql); sqlite3_mutex_leave(p->db->mutex); } return p->zNormSql; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index ac7bf6a65..5225cbc73 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -64,13 +64,6 @@ void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){ } assert( p->zSql==0 ); p->zSql = sqlite3DbStrNDup(p->db, z, n); -#ifdef SQLITE_ENABLE_NORMALIZE - assert( p->zNormSql==0 ); - if( p->zSql && (prepFlags & SQLITE_PREPARE_NORMALIZE)!=0 ){ - p->zNormSql = sqlite3Normalize(p, p->zSql, n); - assert( p->zNormSql!=0 || p->db->mallocFailed ); - } -#endif } #ifdef SQLITE_ENABLE_NORMALIZE |