aboutsummaryrefslogtreecommitdiff
path: root/ext/misc/normalize.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2018-01-08 19:29:28 +0000
committerdrh <drh@noemail.net>2018-01-08 19:29:28 +0000
commitd19866bb98c548049757d4e54efda009badd655c (patch)
tree450f613485b35a7d33deb41b3a1e63289d721c30 /ext/misc/normalize.c
parentef4248122488372b8aeb7b37d3a06df6a7cf77d2 (diff)
downloadsqlite-d19866bb98c548049757d4e54efda009badd655c.tar.gz
sqlite-d19866bb98c548049757d4e54efda009badd655c.zip
Special handling of the NULL keyword. Sometimes it is a literal, and sometimes
it is a keyword. FossilOrigin-Name: db5d138e97f22ad4d4d11dbef96df93696ba0e557809066bc263ca3c3898f349
Diffstat (limited to 'ext/misc/normalize.c')
-rw-r--r--ext/misc/normalize.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/ext/misc/normalize.c b/ext/misc/normalize.c
index fe5fb01b4..a3c00210f 100644
--- a/ext/misc/normalize.c
+++ b/ext/misc/normalize.c
@@ -573,6 +573,17 @@ char *sqlite3_normalize(const char *zSql){
}
case TK_PUNCT:
case TK_NAME: {
+ if( n==4 && sqlite3_strnicmp(zSql+i,"NULL",4)==0 ){
+ if( (j>=3 && strncmp(z+j-2,"is",2)==0 && !IdChar(z[j-3]))
+ || (j>=4 && strncmp(z+j-3,"not",3)==0 && !IdChar(z[j-4]))
+ ){
+ /* NULL is a keyword in this case, not a literal value */
+ }else{
+ /* Here the NULL is a literal value */
+ z[j++] = '?';
+ break;
+ }
+ }
if( j>0 && IdChar(z[j-1]) && IdChar(zSql[i]) ) z[j++] = ' ';
for(k=0; k<n; k++){
z[j++] = sqlite3Tolower(zSql[i+k]);