]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Provide grave accent quoting of identifiers for MySQL compatibility.
authordrh <drh@noemail.net>
Sat, 13 Aug 2005 18:15:42 +0000 (18:15 +0000)
committerdrh <drh@noemail.net>
Sat, 13 Aug 2005 18:15:42 +0000 (18:15 +0000)
Ticket #1337. (CVS 2591)

FossilOrigin-Name: 6b7a4e97528a4e179e0bbae69469cb1a3d1f794b

manifest
manifest.uuid
src/tokenize.c
src/util.c
test/quote.test

index 63e30b20f9f53d26f0c09655d70b0dc1d796d0d7..46c9fd83ee57aff0f083d6d73771175662d97f32 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Give\sthe\ssame\saccess\spermissions\sto\sjournal\sfiles\sas\sis\sgiven\sto\sdatabases.\s(CVS\s2590)
-D 2005-08-13T17:17:02
+C Provide\sgrave\saccent\squoting\sof\sidentifiers\sfor\sMySQL\scompatibility.\nTicket\s#1337.\s(CVS\s2591)
+D 2005-08-13T18:15:43
 F Makefile.in 22ea9c0fe748f591712d8fe3c6d972c6c173a165
 F Makefile.linux-gcc 06be33b2a9ad4f005a5f42b22c4a19dab3cbb5c7
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -73,11 +73,11 @@ F src/test2.c 792f203be69fea88668fa221321194f0a28dfdfa
 F src/test3.c f4e6a16a602091696619a1171bda25c0e3df49f7
 F src/test4.c a8fd681e139e1c61f22a77d07fc3a99cb28fff3f
 F src/test5.c 64f08b2a50ef371a1bd68ff206829e7b1b9997f5
-F src/tokenize.c 57ec9926612fb9e325b57a141303573bc20c79bf
+F src/tokenize.c 0ea99e6d02287d6c46788fd5f97533636667244f
 F src/trigger.c f51dec15921629591cb98bf2e350018e268b109a
 F src/update.c a9d2c5f504212d62da1b094476f1389c0e02f83f
 F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c
-F src/util.c 668d31be592753e5b8ea00e69ea8d3eedb29fa22
+F src/util.c f66b47d937bde79d458a18665b67a98dbba5108f
 F src/vacuum.c 829d9e1a6d7c094b80e0899686670932eafd768c
 F src/vdbe.c 69f33e22c7d0a64b23fbb69e6da95a1bb6869032
 F src/vdbe.h 68e80f65658e7fd85561721f617bdebf8bb84b59
@@ -185,7 +185,7 @@ F test/pragma.test 95ea907adf68459e1be6f310c9ae94d1d59c465b
 F test/printf.test dc39f7c66db3adfe754b4fc0b97fdd97fa06a9c8
 F test/progress.test 16496001da445e6534afb94562c286708316d82f x
 F test/quick.test a94d12658a2b590c1a5be580bef09bbb04c1266b
-F test/quote.test 6d75cf635d93ba2484dc9cb378d88cbae9dc2c62
+F test/quote.test c1ca5e18800455f1c882baf5b0274755a3836549
 F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
 F test/rollback.test 94cd981ee3a627d9f6466f69dcf1f7dbfe695d7a
 F test/rowid.test 040a3bef06f970c45f5fcd14b2355f7f4d62f0cf
@@ -291,7 +291,7 @@ F www/tclsqlite.tcl 3df553505b6efcad08f91e9b975deb2e6c9bb955
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 528299b8316726dbcc5548e9aa0648c8b1bd055b
-P 4f07661279fb11a06b3ddffeda672f077c0d306a
-R b836f0b3a75836080ea6277724098755
+P 7961ec0ccbc99d890689013b9602635941f308a6
+R 8fe3c3a40a20fda764293dad136929fd
 U drh
-Z 529dbcca7dd17d3d06b72e71d043be10
+Z 59ce15d25edf70c7b49901f8f0f074fa
index 3b647afb641554902f07c553be9e37dbe7fef78c..1ee2ab737c30393bd6d7a43c1d74e5b58e012e7d 100644 (file)
@@ -1 +1 @@
-7961ec0ccbc99d890689013b9602635941f308a6
\ No newline at end of file
+6b7a4e97528a4e179e0bbae69469cb1a3d1f794b
\ No newline at end of file
index 1dab3c528aee9f62609891a694b31d073c2081a8..5ab7ec0665807f66aa89cae18532c8db366d2120 100644 (file)
@@ -15,7 +15,7 @@
 ** individual tokens and sends those tokens one-by-one over to the
 ** parser for analysis.
 **
-** $Id: tokenize.c,v 1.104 2005/06/22 08:48:06 drh Exp $
+** $Id: tokenize.c,v 1.105 2005/08/13 18:15:43 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -183,7 +183,9 @@ static int getToken(const unsigned char *z, int *tokenType){
       *tokenType = TK_BITNOT;
       return 1;
     }
-    case '\'': case '"': {
+    case '`':
+    case '\'':
+    case '"': {
       int delim = z[0];
       for(i=1; (c=z[i])!=0; i++){
         if( c==delim ){
@@ -565,6 +567,7 @@ int sqlite3_complete(const char *zSql){
         token = tkOTHER;
         break;
       }
+      case '`':     /* Grave-accent quoted symbols used by MySQL */
       case '"':     /* single- and double-quoted strings */
       case '\'': {
         int c = *zSql;
index 18b5ada24754c4a1a295a650f60795e17e17cca1..80ac674374deec795c3e7c64119f86ff43a9edf3 100644 (file)
@@ -14,7 +14,7 @@
 ** This file contains functions for allocating memory, comparing
 ** strings, and stuff like that.
 **
-** $Id: util.c,v 1.141 2005/07/20 14:31:53 drh Exp $
+** $Id: util.c,v 1.142 2005/08/13 18:15:43 drh Exp $
 */
 #include "sqliteInt.h"
 #include <stdarg.h>
@@ -470,7 +470,8 @@ void sqlite3Dequote(char *z){
   switch( quote ){
     case '\'':  break;
     case '"':   break;
-    case '[':   quote = ']';  break;
+    case '`':   break;                /* For MySQL compatibility */
+    case '[':   quote = ']';  break;  /* For MS SqlServer compatibility */
     default:    return;
   }
   for(i=1, j=0; z[i]; i++){
index 14d676e6f0096e5f70981e5a4fa41afe68ea35e6..54df546410deeda28297ac19972e5a4bb2b17572 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this file is the ability to specify table and column names
 # as quoted strings.
 #
-# $Id: quote.test,v 1.4 2004/08/20 18:34:20 drh Exp $
+# $Id: quote.test,v 1.5 2005/08/13 18:15:43 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -20,31 +20,27 @@ source $testdir/tester.tcl
 # Create a table with a strange name and with strange column names.
 #
 do_test quote-1.0 {
-  set r [catch {
-    execsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}
-  } msg]
-  lappend r $msg
+  catchsql {CREATE TABLE '@abc' ( '#xyz' int, '!pqr' text );}
 } {0 {}}
 
 # Insert, update and query the table.
 #
 do_test quote-1.1 {
-  set r [catch {
-    execsql {INSERT INTO '@abc' VALUES(5,'hello')}
-  } msg]
-  lappend r $msg
+  catchsql {INSERT INTO '@abc' VALUES(5,'hello')}
 } {0 {}}
-do_test quote-1.2 {
-  set r [catch {
-    execsql {SELECT * FROM '@abc'}
-  } msg ]
-  lappend r $msg
+do_test quote-1.2.1 {
+  catchsql {SELECT * FROM '@abc'}
+} {0 {5 hello}}
+do_test quote-1.2.2 {
+  catchsql {SELECT * FROM [@abc]}  ;# SqlServer compatibility
+} {0 {5 hello}}
+do_test quote-1.2.3 {
+  catchsql {SELECT * FROM `@abc`}  ;# MySQL compatibility
 } {0 {5 hello}}
 do_test quote-1.3 {
-  set r [catch {
-    execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}
-  } msg ]
-  lappend r $msg
+  catchsql {
+    SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'
+  }
 } {0 {hello 10}}
 do_test quote-1.3.1 {
   catchsql {
@@ -56,6 +52,11 @@ do_test quote-1.3.2 {
     SELECT "!pqr", "#xyz"+5 FROM '@abc'
   }
 } {0 {hello 10}}
+do_test quote-1.3.3 {
+  catchsql {
+    SELECT [!pqr], `#xyz`+5 FROM '@abc'
+  }
+} {0 {hello 10}}
 do_test quote-1.3 {
   set r [catch {
     execsql {SELECT '@abc'.'!pqr', '@abc'.'#xyz'+5 FROM '@abc'}