diff options
author | drh <drh@noemail.net> | 2019-06-17 13:56:11 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-06-17 13:56:11 +0000 |
commit | d0ff601c62a4873a5808fd072dc573797883ef51 (patch) | |
tree | 1be3dd9024bf6fc6ccc012eb2685f7d34916fbe9 /src/resolve.c | |
parent | 0a6873bfd65233d242fd17ec818ac57593f25540 (diff) | |
download | sqlite-d0ff601c62a4873a5808fd072dc573797883ef51.tar.gz sqlite-d0ff601c62a4873a5808fd072dc573797883ef51.zip |
Improved interface to double-quoted string literal enabling/disabling.
FossilOrigin-Name: 923cfd53fcff2fcb91530bf819d2ecb0eda3f6a27dae29c7460f9ce3a3ffce7b
Diffstat (limited to 'src/resolve.c')
-rw-r--r-- | src/resolve.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/resolve.c b/src/resolve.c index ddb1bcfcb..8dac077ee 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -149,6 +149,23 @@ int sqlite3MatchSpanName( } /* +** Return TRUE if the double-quoted string mis-feature should be supported. +*/ +static int areDoubleQuotedStringsEnabled(sqlite3 *db, NameContext *pTopNC){ + if( db->init.busy ) return 1; /* Always support for legacy schemas */ + if( pTopNC->ncFlags & NC_IsDDL ){ + /* Currently parsing a DDL statement */ + if( sqlite3WritableSchema(db) && (db->flags & SQLITE_DqsDML)!=0 ){ + return 1; + } + return (db->flags & SQLITE_DqsDDL)!=0; + }else{ + /* Currently parsing a DML statement */ + return (db->flags & SQLITE_DqsDML)!=0; + } +} + +/* ** Given the name of a column of the form X.Y.Z or Y.Z or just Z, look up ** that name in the set of source tables in pSrcList and make the pExpr ** expression node refer back to that source column. The following changes @@ -476,9 +493,8 @@ static int lookupName( */ if( cnt==0 && zTab==0 ){ assert( pExpr->op==TK_ID ); - if( ExprHasProperty(pExpr,EP_DblQuoted) - && 0==(pTopNC->ncFlags&NC_NoDblQStr) - && 0==(db->flags & SQLITE_NoDQS) + if( ExprHasProperty(pExpr,EP_DblQuoted) + && areDoubleQuotedStringsEnabled(db, pTopNC) ){ /* If a double-quoted identifier does not match any known column name, ** then treat it as a string. @@ -1771,15 +1787,7 @@ int sqlite3ResolveSelfReference( } sNC.pParse = pParse; sNC.pSrcList = &sSrc; - sNC.ncFlags = type; - if( (pParse->db->flags & SQLITE_NoDQS)!=0 - || (!pParse->db->init.busy - && !sqlite3WritableSchema(pParse->db) - && (pParse->db->flags & SQLITE_NoDQSSchema)!=0 - ) - ){ - sNC.ncFlags |= NC_NoDblQStr; - } + sNC.ncFlags = type | NC_IsDDL; if( (rc = sqlite3ResolveExprNames(&sNC, pExpr))!=SQLITE_OK ) return rc; if( pList ) rc = sqlite3ResolveExprListNames(&sNC, pList); return rc; |