]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add tests to make sure altering or adding an index to a virtual table is prohibited...
authordanielk1977 <danielk1977@noemail.net>
Wed, 21 Jun 2006 12:36:25 +0000 (12:36 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 21 Jun 2006 12:36:25 +0000 (12:36 +0000)
FossilOrigin-Name: 6c3e8852ffbaf5ab52ffdf7ed3767fa1d4fd5882

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

index 470dc056dc345232e418b88c2698cccd9866f0de..1626cf1063b849324bfd1b41678cadcbb286ac84 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Test\scases\sfor\saccessing\svirtual\stables\swhen\sthe\scorresponding\smodule\sis\sundefined.\s(CVS\s3279)
-D 2006-06-21T07:34:11
+C Add\stests\sto\smake\ssure\saltering\sor\sadding\san\sindex\sto\sa\svirtual\stable\sis\sprohibited.\s(CVS\s3280)
+D 2006-06-21T12:36:25
 F Makefile.in f839b470345d3cb4b0644068474623fe2464b5d3
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -30,13 +30,13 @@ F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
 F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
 F sqlite3.def f756049b1bf3e8442baf6862db393ca423225262
 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
-F src/alter.c 451b34fc4eb2475ca76a2e86b21e1030a9428091
+F src/alter.c eba661e77bfd00282fbfa316cdb6aef04856fedc
 F src/analyze.c 7d2b7ab9a9c2fd6e55700f69064dfdd3e36d7a8a
 F src/attach.c 27a31d3b89d7ebb5b358847607b1ec795384123c
 F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
 F src/btree.c ed343b3dbcbc7da9ac481ef2b98c4239fe6d9629
 F src/btree.h 40055cfc09defd1146bc5b922399c035f969e56d
-F src/build.c 467944d9b0dc1483a50e5ee0f0771e0e53264c43
+F src/build.c ef710ff6b3a91d4c1dd4c7009a8800ff38660613
 F src/callback.c fd9bb39f7ff6b52bad8365617abc61c720640429
 F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
 F src/date.c cd2bd5d1ebc6fa12d6312f69789ae5b0a2766f2e
@@ -295,7 +295,7 @@ F test/vtab1.test a4a613abd0dc3d89e6c3850c8fdaf21b3235900b
 F test/vtab2.test e57f9865368df26ef5eb8bc630962d82086f174b
 F test/vtab3.test f38d6d7d19f08bffdadce4d5b8cba078f8118587
 F test/vtab4.test 4b4293341443839ef6dc02f8d9e614702a6c67ff
-F test/vtab5.test a275f233722cbc89141710e5df62421ae26d456b
+F test/vtab5.test 9fb8f335651afe8f870011e2f68e5b00c5ad03cd
 F test/vtab6.test 0b4fe07e421b2b9a334bec8781e75cbd8e230bd3
 F test/where.test ee7c9a6659b07e1ee61177f6e7ff71565ee2c9df
 F test/where2.test a16476a5913e75cf65b38f2daa6157a6b7791394
@@ -372,7 +372,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 643e63e5883eec109a91a44dae62b58650646575
-R 5df237ae1d0f32a0a5347808bfb7d55a
+P bcef48c54dd01cf089db16192e670cb0717988ac
+R f99945aeb4a525d461aed39d7b881f31
 U danielk1977
-Z 155064465a7da1b6e1f61624d89bfddf
+Z 1883f2f742b7c696a0a5c5e4faa758d4
index 8357e85fb7e276b0cd1ff59de7d34d33e041f3f4..ee22e91c7b539bf536b714c18f77e674801d4345 100644 (file)
@@ -1 +1 @@
-bcef48c54dd01cf089db16192e670cb0717988ac
\ No newline at end of file
+6c3e8852ffbaf5ab52ffdf7ed3767fa1d4fd5882
\ No newline at end of file
index 224cfa4b67b739a36afe3aaab2ab3558d0f7da01..efab598ed822c56f0203d7493d5b11f90b1cfe98 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.20 2006/02/09 02:56:03 drh Exp $
+** $Id: alter.c,v 1.21 2006/06/21 12:36:25 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -272,6 +272,12 @@ void sqlite3AlterRenameTable(
 
   pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);
   if( !pTab ) goto exit_rename_table;
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+  if( IsVirtual(pTab) ){
+    sqlite3ErrorMsg(pParse, "virtual tables may not be altered");
+    goto exit_rename_table;
+  }
+#endif
   iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
   zDb = db->aDb[iDb].zName;
 
@@ -512,6 +518,13 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
   pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase);
   if( !pTab ) goto exit_begin_add_column;
 
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+  if( IsVirtual(pTab) ){
+    sqlite3ErrorMsg(pParse, "virtual tables may not be altered");
+    goto exit_begin_add_column;
+  }
+#endif
+
   /* Make sure this is not an attempt to ALTER a view. */
   if( pTab->pSelect ){
     sqlite3ErrorMsg(pParse, "Cannot add a column to a view");
index 84464bfbf870af65f86c01410e617bbae621e867..df9015ff32070c89fe1c2244eed230e354d1d6a0 100644 (file)
@@ -22,7 +22,7 @@
 **     COMMIT
 **     ROLLBACK
 **
-** $Id: build.c,v 1.406 2006/06/21 07:34:11 danielk1977 Exp $
+** $Id: build.c,v 1.407 2006/06/21 12:36:25 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -2304,6 +2304,12 @@ void sqlite3CreateIndex(
     goto exit_create_index;
   }
 #endif
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+  if( IsVirtual(pTab) ){
+    sqlite3ErrorMsg(pParse, "virtual tables may not be indexed");
+    goto exit_create_index;
+  }
+#endif
 
   /*
   ** Find the name of the index.  Make sure there is not already another
index 02059a33e5ce5e7c6e783f9c4dbda1f54b302875..36dad9bb56e02e71329182ab2a2e8f71506cd8e0 100644 (file)
@@ -10,7 +10,7 @@
 #***********************************************************************
 # This file implements regression tests for SQLite library.
 #
-# $Id: vtab5.test,v 1.5 2006/06/20 11:01:09 danielk1977 Exp $
+# $Id: vtab5.test,v 1.6 2006/06/21 12:36:26 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -33,13 +33,11 @@ do_test vtab5-1.1 {
     CREATE VIRTUAL TABLE techo USING echo(treal);
   }
 } {}
-
 do_test vtab5.1.2 {
   execsql {
     SELECT * FROM techo;
   }
 } {a b c}
-
 do_test vtab5.1.3 {
   db close
   sqlite3 db test.db
@@ -126,5 +124,29 @@ ifcapable trigger {
   } {1 {cannot create triggers on virtual tables}}
 }
 
+# Test that it is impossible to create an index on a virtual table.
+#
+do_test vtab5.4.1 {
+  catchsql {
+    CREATE INDEX echo_strings_i ON echo_strings(str);
+  }
+} {1 {virtual tables may not be indexed}}
+
+# Test that it is impossible to add a column to a virtual table.
+#
+do_test vtab5.4.2 {
+  catchsql {
+    ALTER TABLE echo_strings ADD COLUMN col2;
+  }
+} {1 {virtual tables may not be altered}}
+
+# Test that it is impossible to add a column to a virtual table.
+#
+do_test vtab5.4.3 {
+  catchsql {
+    ALTER TABLE echo_strings RENAME TO echo_strings2;
+  }
+} {1 {virtual tables may not be altered}}
+
 finish_test