]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Improved error message when a double-quoted string is used and it seems likely
authordrh <>
Mon, 22 Jan 2024 15:26:33 +0000 (15:26 +0000)
committerdrh <>
Mon, 22 Jan 2024 15:26:33 +0000 (15:26 +0000)
that the user wanted a single-quoted string literal.

FossilOrigin-Name: 0a834bd81122b6e9c34c8253f9e45d53dab3274be28df60968366fa42237617b

manifest
manifest.uuid
src/resolve.c
test/quote.test

index ddd60a6df8595c165072f3a833dae00a0046dd38..7a89979994f7ed0057f648ae0db5d03066272143 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C The\s-DSQLITE_JSON_BLOB_INPUT_BUG_COMPATIBLE\scompile-time\soption\scauses\sblob\ninputs\sto\sJSON\sfunctions\sthat\sare\snot\sJSONB\sto\sbe\sprocessed\sas\sif\sthey\nwhere\stext,\simmulating\shistorical\sbugging\sbehavior\swhich\ssome\sapplications\nhave\scome\sto\srely\supon.\s\sSee\n[forum:/forumpost/012136abd5292b8d|forum\sthread\s012136abd5292b8d]\sfor\ndiscussion.
-D 2024-01-22T14:16:10.354
+C Improved\serror\smessage\swhen\sa\sdouble-quoted\sstring\sis\sused\sand\sit\sseems\slikely\nthat\sthe\suser\swanted\sa\ssingle-quoted\sstring\sliteral.
+D 2024-01-22T15:26:33.828
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -736,7 +736,7 @@ F src/pragma.h e690a356c18e98414d2e870ea791c1be1545a714ba623719deb63f7f226d8bb7
 F src/prepare.c 371f6115cb69286ebc12c6f2d7511279c2e47d9f54f475d46a554d687a3b312c
 F src/printf.c 18fbdf028345c8fbe6044f5f5bfda5a10d48d6287afef088cc21b0ca57985640
 F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
-F src/resolve.c e25f51a473a5f30a0d978e4df2aaa98aeec84eac29ecae1ad4708a6c3e669345
+F src/resolve.c 6221ea6fa0f4767b051bae74a2c967c4ca411fc46512a7f6f1ec97555114ea6b
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c f1a81ff4f8e9e76c224e2ab3a4baa799add0db22158c7fcede65d8cc4a6fa2da
 F src/shell.c.in 5ea8c6b0057bfe3bcdff31949fe72aa231ae429047c421ea1b168af6825a4890
@@ -1497,7 +1497,7 @@ F test/quickcheck.test a4b7e878cd97e46108291c409b0bf8214f29e18fddd68a42bc5c1375a
 F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26
 F test/quota.test bfb269ce81ea52f593f9648316cd5013d766dd2a
 F test/quota2.test 7dc12e08b11cbc4c16c9ba2aa2e040ea8d8ab4b8
-F test/quote.test ffb40f0eb7a25c1d8cfe11ee2fe67f8e85fbf3fed348810834114be1fdada142
+F test/quote.test 7b01b2a261bc26d9821aea9f4941ce1e08191d62fc55ba8862440fb3a59197a4
 F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459
 F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df
 F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736
@@ -2159,8 +2159,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 4dc00f577632c7b13135505007804d42a12f81a9ebd58d4c380727256b054b7e
-R 59af26cba445671768ccc033868954ad
+P 65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a
+R 7e3b76756c0a4c8c51526beb20e2ad21
+T *branch * improved-dqs-error-msg
+T *sym-improved-dqs-error-msg *
+T -sym-trunk *
 U drh
-Z 9f8b0dd9fdc4264b889c936f6659e28d
+Z eea53958dbf5ca2fad33a06e593a1f98
 # Remove this line to create a well-formed Fossil manifest.
index 25bb88a0e7e7d408eddf50b34439d280ae1a43b4..5936974ca1807f71c8e505e30cdfc739227256ad 100644 (file)
@@ -1 +1 @@
-65572223583d43e1d61ec029641f9d3ff340e68ecfba8342c8d1b0a91a680f2a
\ No newline at end of file
+0a834bd81122b6e9c34c8253f9e45d53dab3274be28df60968366fa42237617b
\ No newline at end of file
index b4f03fe7e619b6122427a5d16f3eb316dc394078..fde5506f9c2cfc7ee7d7690426de31ac82e48603 100644 (file)
@@ -277,7 +277,7 @@ static int lookupName(
   Parse *pParse,       /* The parsing context */
   const char *zDb,     /* Name of the database containing table, or NULL */
   const char *zTab,    /* Name of table containing column, or NULL */
-  const char *zCol,    /* Name of the column. */
+  const Expr *pRight,  /* Name of the column. */
   NameContext *pNC,    /* The name context used to resolve the name */
   Expr *pExpr          /* Make this EXPR node point to the selected column */
 ){
@@ -294,6 +294,7 @@ static int lookupName(
   Table *pTab = 0;                  /* Table holding the row */
   Column *pCol;                     /* A column of pTab */
   ExprList *pFJMatch = 0;           /* Matches for FULL JOIN .. USING */
+  const char *zCol = pRight->u.zToken;
 
   assert( pNC );     /* the name context cannot be NULL. */
   assert( zCol );    /* The Z in X.Y.Z cannot be NULL */
@@ -753,6 +754,10 @@ static int lookupName(
       sqlite3ErrorMsg(pParse, "%s: %s.%s.%s", zErr, zDb, zTab, zCol);
     }else if( zTab ){
       sqlite3ErrorMsg(pParse, "%s: %s.%s", zErr, zTab, zCol);
+    }else if( cnt==0 && ExprHasProperty(pRight,EP_DblQuoted) ){
+      sqlite3ErrorMsg(pParse, "no such column: \"%s\" - should this be a"
+                              " string literal in single-quotes?",
+                              zCol);
     }else{
       sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
     }
@@ -1000,7 +1005,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
     */
     case TK_ID:
     case TK_DOT: {
-      const char *zColumn;
       const char *zTable;
       const char *zDb;
       Expr *pRight;
@@ -1009,7 +1013,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
         zDb = 0;
         zTable = 0;
         assert( !ExprHasProperty(pExpr, EP_IntValue) );
-        zColumn = pExpr->u.zToken;
+        pRight = pExpr;
       }else{
         Expr *pLeft = pExpr->pLeft;
         testcase( pNC->ncFlags & NC_IdxExpr );
@@ -1028,14 +1032,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
         }
         assert( ExprUseUToken(pLeft) && ExprUseUToken(pRight) );
         zTable = pLeft->u.zToken;
-        zColumn = pRight->u.zToken;
         assert( ExprUseYTab(pExpr) );
         if( IN_RENAME_OBJECT ){
           sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight);
           sqlite3RenameTokenRemap(pParse, (void*)&pExpr->y.pTab, (void*)pLeft);
         }
       }
-      return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr);
+      return lookupName(pParse, zDb, zTable, pRight, pNC, pExpr);
     }
 
     /* Resolve function names
index 6d7b317ea1c44b50e3ccf47f173f8c640a5e6290..4e40a9e57f6613dae7aa1881d4849ab8e5af741a 100644 (file)
@@ -103,7 +103,7 @@ foreach {tn sql errname} {
   3 { CREATE INDEX i3 ON t1("w") }                   w
   4 { CREATE INDEX i4 ON t1(x) WHERE z="w" }         w
 } {
-  do_catchsql_test 2.1.$tn $sql [list 1 "no such column: $errname"]
+  do_catchsql_test 2.1.$tn $sql [list 1 "no such column: \"$errname\" - should this be a string literal in single-quotes?"]
 }
 
 do_execsql_test 2.2 {
@@ -147,19 +147,19 @@ ifcapable altertable {
       CREATE TABLE t1(a,b);
       CREATE INDEX x1 on t1("b");
       ALTER TABLE t1 DROP COLUMN b;
-    } {1 {error in index x1 after drop column: no such column: b}}
+    } {1 {error in index x1 after drop column: no such column: "b" - should this be a string literal in single-quotes?}}
   do_catchsql_test 3.1 {
     DROP TABLE t1;
     CREATE TABLE t1(a,"b");
     CREATE INDEX x1 on t1("b");
     ALTER TABLE t1 DROP COLUMN b;
-  } {1 {error in index x1 after drop column: no such column: b}}
+  } {1 {error in index x1 after drop column: no such column: "b" - should this be a string literal in single-quotes?}}
   do_catchsql_test 3.2 {
     DROP TABLE t1;
     CREATE TABLE t1(a,'b');
     CREATE INDEX x1 on t1("b");
     ALTER TABLE t1 DROP COLUMN b;
-  } {1 {error in index x1 after drop column: no such column: b}}
+  } {1 {error in index x1 after drop column: no such column: "b" - should this be a string literal in single-quotes?}}
   do_catchsql_test 3.3 {
     DROP TABLE t1;
     CREATE TABLE t1(a,"b");
@@ -172,7 +172,7 @@ ifcapable altertable {
     CREATE INDEX x1 ON t1("a"||"b");
     INSERT INTO t1 VALUES(1,2,3),(1,4,5);
     ALTER TABLE t1 DROP COLUMN b;
-  } {1 {error in index x1 after drop column: no such column: b}}
+  } {1 {error in index x1 after drop column: no such column: "b" - should this be a string literal in single-quotes?}}
   sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
   do_catchsql_test 3.5 {
     DROP TABLE t1;