]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the ALTER TABLE RENAME algorithm so that it is not confused
authordrh <drh@noemail.net>
Fri, 9 May 2008 14:17:51 +0000 (14:17 +0000)
committerdrh <drh@noemail.net>
Fri, 9 May 2008 14:17:51 +0000 (14:17 +0000)
by comments in the CREATE TABLE statement.  Ticket #3102. (CVS 5110)

FossilOrigin-Name: ab18b4e75916b05863b31bc63625aa64a104a42c

manifest
manifest.uuid
src/alter.c
test/alter.test

index 38dea92d487889c4ac9f81520eda47c0abe55e06..96ff0ea2d806362026c698f80ddafd37b9e6c809 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Back\sout\scheck-in\s(5108).\s\sThe\soriginal\sisnan()\simplementation\sis\spreferred.\s\sTicket\s#3101\sand\s#3060.\s(CVS\s5109)
-D 2008-05-09T13:47:59
+C Fix\sthe\sALTER\sTABLE\sRENAME\salgorithm\sso\sthat\sit\sis\snot\sconfused\nby\scomments\sin\sthe\sCREATE\sTABLE\sstatement.\s\sTicket\s#3102.\s(CVS\s5110)
+D 2008-05-09T14:17:52
 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
 F Makefile.in 8b9b8263852f0217157f9042b8e3dae7427ec739
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -79,7 +79,7 @@ F sqlite.pc.in c322c6244c6395955dca34d87955aabde7df7623
 F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
 F sqlite3.def a1be7b9a4b8b51ac41c6ff6e8e44a14ef66b338b
 F sqlite3.pc.in 32b8a014799c2028c8e0c9cc5659718262fc493f
-F src/alter.c b42d782906fc3b92c331efbe06e9389617b47ce7
+F src/alter.c cc38b9e2a8cf19428f64e5da7ec4da35b7c02779
 F src/analyze.c 9ee63497ee720728abe630d169ab91323ac7519c
 F src/attach.c 496cc628b2e8c4d8db99d7c136761fcbebd8420b
 F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
@@ -180,7 +180,7 @@ F src/where.c 85719d58e0f680b5d8239dc6af82b159775d7376
 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617
 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
 F test/all.test d56a3ca8acdf761204aff0a2e7aa5eb8e11b31e6
-F test/alter.test 1426bb4c8609731622a9bf9dd48c39f5931c4d7d
+F test/alter.test 6353aae6839e486c9b7d8f73b1f4a1e98e57332c
 F test/alter2.test dd55146e812622c8fc51fd2216bcd8dca8880752
 F test/alter3.test 25b95a136708f22b87184fa6a4309eea03d65153
 F test/altermalloc.test 29d4a8400277efb4ba8ffe90804c6dc2fdfbf063
@@ -634,7 +634,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
-P 19ee2b3324461150d2c1600c67fe604114a1b69f
-R 8d099f80fb2f7dafcb5d0c712527b62c
+P 2349ae75dfdd626ed97db99ac6de4bdc5a395008
+R f36404afe38ae90063c0c43dc92e5da7
 U drh
-Z f6a0ef8be8db87133187cef718ae3189
+Z 2b92517d2da71a3352efb5891980e09b
index cbbac4f079f06f0e54fbc01d78c122aeeca19fd1..0fdd692e6252d9a7d12158f8279ad782363bec92 100644 (file)
@@ -1 +1 @@
-2349ae75dfdd626ed97db99ac6de4bdc5a395008
\ No newline at end of file
+ab18b4e75916b05863b31bc63625aa64a104a42c
\ No newline at end of file
index 2acefe2b8237b9628bfdc5130a6a2042d0fe96b6..329a5a9882f470ba2e15326256f0776a8928099c 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that used to generate VDBE code
 ** that implements the ALTER TABLE command.
 **
-** $Id: alter.c,v 1.43 2008/03/19 21:45:51 drh Exp $
+** $Id: alter.c,v 1.44 2008/05/09 14:17:52 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -54,8 +54,8 @@ static void renameTableFunc(
   sqlite3 *db = sqlite3_context_db_handle(context);
 
   /* The principle used to locate the table name in the CREATE TABLE 
-  ** statement is that the table name is the first token that is immediatedly
-  ** followed by a left parenthesis - TK_LP - or "USING" TK_USING.
+  ** statement is that the table name is the first non-space token that
+  ** is immediately followed by a left parenthesis - TK_LP - or "USING" TK_USING.
   */
   if( zSql ){
     do {
@@ -74,7 +74,7 @@ static void renameTableFunc(
       do {
         zCsr += len;
         len = sqlite3GetToken(zCsr, &token);
-      } while( token==TK_SPACE );
+      } while( token==TK_SPACE || token==TK_COMMENT );
       assert( len>0 );
     } while( token!=TK_LP && token!=TK_USING );
 
index d838503e272b7b73c7fe476e6a32db86931e6645..002fb5a5a8480c6e33818d9f270e87496465f8dd 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is testing the ALTER TABLE statement.
 #
-# $Id: alter.test,v 1.29 2008/02/09 14:30:30 drh Exp $
+# $Id: alter.test,v 1.30 2008/05/09 14:17:52 drh Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -785,5 +785,30 @@ do_test alter-12.5 {
   }
 } {1 {Cannot add a column to a view}}
 
+# Ticket #3102:
+# Verify that comments do not interfere with the table rename
+# algorithm.
+#
+do_test alter-13.1 {
+  execsql {
+    CREATE TABLE /* hi */ t3102a(x);
+    CREATE TABLE t3102b -- comment
+    (y);
+    CREATE INDEX t3102c ON t3102a(x);
+    SELECT name FROM sqlite_master WHERE name LIKE 't3102%' ORDER BY 1;
+  }
+} {t3102a t3102b t3102c}
+do_test alter-13.2 {
+  execsql {
+    ALTER TABLE t3102a RENAME TO t3102a_rename;
+    SELECT name FROM sqlite_master WHERE name LIKE 't3102%' ORDER BY 1;
+  }
+} {t3102a_rename t3102b t3102c}
+do_test alter-13.3 {
+  execsql {
+    ALTER TABLE t3102b RENAME TO t3102b_rename;
+    SELECT name FROM sqlite_master WHERE name LIKE 't3102%' ORDER BY 1;
+  }
+} {t3102a_rename t3102b_rename t3102c}
 
 finish_test