/ Check-in [5547f39d]
Login

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

Overview
Comment:The keywords TRUE and FALSE should only act as boolean literal values if unquoted.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5547f39de993c708f72301ef25df190a2f007e0c4253799bdd9e86bb1ae41777
User & Date: drh 2019-01-11 13:32:23
Context
2019-01-11
14:22
Add the "dbfuzz2" target to main.mk. Remove an unused local variable from dbfuzz2.c. check-in: 05c7609c user: drh tags: trunk
13:32
The keywords TRUE and FALSE should only act as boolean literal values if unquoted. check-in: 5547f39d user: drh tags: trunk
13:03
Separate makefile targets for "dbfuzz2", "dbfuzz2-asan", and "dbfuzz2-msan". check-in: ea119641 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

   776    776           pNew->u.iValue = iValue;
   777    777         }else{
   778    778           pNew->u.zToken = (char*)&pNew[1];
   779    779           assert( pToken->z!=0 || pToken->n==0 );
   780    780           if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);
   781    781           pNew->u.zToken[pToken->n] = 0;
   782    782           if( dequote && sqlite3Isquote(pNew->u.zToken[0]) ){
   783         -          if( pNew->u.zToken[0]=='"' ) pNew->flags |= EP_DblQuoted;
   784         -          sqlite3Dequote(pNew->u.zToken);
          783  +          sqlite3DequoteExpr(pNew);
   785    784           }
   786    785         }
   787    786       }
   788    787   #if SQLITE_MAX_EXPR_DEPTH>0
   789    788       pNew->nHeight = 1;
   790    789   #endif  
   791    790     }
................................................................................
  1808   1807   /*
  1809   1808   ** If the input expression is an ID with the name "true" or "false"
  1810   1809   ** then convert it into an TK_TRUEFALSE term.  Return non-zero if
  1811   1810   ** the conversion happened, and zero if the expression is unaltered.
  1812   1811   */
  1813   1812   int sqlite3ExprIdToTrueFalse(Expr *pExpr){
  1814   1813     assert( pExpr->op==TK_ID || pExpr->op==TK_STRING );
  1815         -  if( sqlite3StrICmp(pExpr->u.zToken, "true")==0
  1816         -   || sqlite3StrICmp(pExpr->u.zToken, "false")==0
         1814  +  if( !ExprHasProperty(pExpr, EP_Quoted)
         1815  +   && (sqlite3StrICmp(pExpr->u.zToken, "true")==0
         1816  +       || sqlite3StrICmp(pExpr->u.zToken, "false")==0)
  1817   1817     ){
  1818   1818       pExpr->op = TK_TRUEFALSE;
  1819   1819       return 1;
  1820   1820     }
  1821   1821     return 0;
  1822   1822   }
  1823   1823   

Changes to src/parse.y.

   951    951         p->op2 = 0;
   952    952         p->iTable = 0;
   953    953         p->iColumn = 0;
   954    954         p->u.zToken = (char*)&p[1];
   955    955         memcpy(p->u.zToken, t.z, t.n);
   956    956         p->u.zToken[t.n] = 0;
   957    957         if( sqlite3Isquote(p->u.zToken[0]) ){
   958         -        if( p->u.zToken[0]=='"' ) p->flags |= EP_DblQuoted;
   959         -        sqlite3Dequote(p->u.zToken);
          958  +        sqlite3DequoteExpr(p);
   960    959         }
   961    960   #if SQLITE_MAX_EXPR_DEPTH>0
   962    961         p->nHeight = 1;
   963    962   #endif  
   964    963         if( IN_RENAME_OBJECT ){
   965    964           return (Expr*)sqlite3RenameTokenMap(pParse, (void*)p, &t);
   966    965         }

Changes to src/sqliteInt.h.

  2518   2518   #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */
  2519   2519   #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
  2520   2520   #define EP_Subquery  0x200000 /* Tree contains a TK_SELECT operator */
  2521   2521   #define EP_Alias     0x400000 /* Is an alias for a result set column */
  2522   2522   #define EP_Leaf      0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
  2523   2523   #define EP_WinFunc  0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
  2524   2524   #define EP_Subrtn   0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
         2525  +#define EP_Quoted   0x4000000 /* TK_ID was originally quoted */
  2525   2526   
  2526   2527   /*
  2527   2528   ** The EP_Propagate mask is a set of properties that automatically propagate
  2528   2529   ** upwards into parent nodes.
  2529   2530   */
  2530   2531   #define EP_Propagate (EP_Collate|EP_Subquery|EP_HasFunc)
  2531   2532   
................................................................................
  3810   3811   #endif
  3811   3812   #endif
  3812   3813   
  3813   3814   
  3814   3815   void sqlite3SetString(char **, sqlite3*, const char*);
  3815   3816   void sqlite3ErrorMsg(Parse*, const char*, ...);
  3816   3817   void sqlite3Dequote(char*);
         3818  +void sqlite3DequoteExpr(Expr*);
  3817   3819   void sqlite3TokenInit(Token*,char*);
  3818   3820   int sqlite3KeywordCode(const unsigned char*, int);
  3819   3821   int sqlite3RunParser(Parse*, const char*, char **);
  3820   3822   void sqlite3FinishCoding(Parse*);
  3821   3823   int sqlite3GetTempReg(Parse*);
  3822   3824   void sqlite3ReleaseTempReg(Parse*,int);
  3823   3825   int sqlite3GetTempRange(Parse*,int);

Changes to src/util.c.

   234    234   ** The input string must be zero-terminated.  A new zero-terminator
   235    235   ** is added to the dequoted string.
   236    236   **
   237    237   ** The return value is -1 if no dequoting occurs or the length of the
   238    238   ** dequoted string, exclusive of the zero terminator, if dequoting does
   239    239   ** occur.
   240    240   **
   241         -** 2002-Feb-14: This routine is extended to remove MS-Access style
          241  +** 2002-02-14: This routine is extended to remove MS-Access style
   242    242   ** brackets from around identifiers.  For example:  "[a-b-c]" becomes
   243    243   ** "a-b-c".
   244    244   */
   245    245   void sqlite3Dequote(char *z){
   246    246     char quote;
   247    247     int i, j;
   248    248     if( z==0 ) return;
................................................................................
   259    259           break;
   260    260         }
   261    261       }else{
   262    262         z[j++] = z[i];
   263    263       }
   264    264     }
   265    265     z[j] = 0;
          266  +}
          267  +void sqlite3DequoteExpr(Expr *p){
          268  +  assert( sqlite3Isquote(p->u.zToken[0]) );
          269  +  p->flags |= p->u.zToken[0]=='"' ? EP_Quoted|EP_DblQuoted : EP_Quoted;
          270  +  sqlite3Dequote(p->u.zToken);
   266    271   }
   267    272   
   268    273   /*
   269    274   ** Generate a Token object from a string
   270    275   */
   271    276   void sqlite3TokenInit(Token *p, char *z){
   272    277     p->z = z;