From: danielk1977 Date: Thu, 13 Dec 2007 08:15:30 +0000 (+0000) Subject: Return an error if the user attempts to rename a view. Related to (but not a fix... X-Git-Tag: version-3.6.10~1554 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61116ae1cad0917a3f7686c53ba773e7edc7f957;p=thirdparty%2Fsqlite.git Return an error if the user attempts to rename a view. Related to (but not a fix for) #2831. (CVS 4623) FossilOrigin-Name: 19d56d997f50be81ac2baace16b7e7a1b674301a --- diff --git a/manifest b/manifest index 1951a0b5b0..b92539930f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Adjust\sthe\stest\ssuite\sto\saccount\sfor\srecent\schanges\srelated\sto\s#2822.\sMost\schanges\sare\srelated\sto\sEnglish\slanguage\serror\smessages\sonly.\s(CVS\s4622) -D 2007-12-13T07:58:51 +C Return\san\serror\sif\sthe\suser\sattempts\sto\srename\sa\sview.\sRelated\sto\s(but\snot\sa\sfix\sfor)\s#2831.\s(CVS\s4623) +D 2007-12-13T08:15:31 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.in 0590398f62fc2c456ff4c45e9741f5a718b7e2ac F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -78,7 +78,7 @@ F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2 F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.def a96c1d0d39362b763d2ddba220a32da41a15c4b4 F sqlite3.pc.in abed4664817e1cd500f2276142c71958087c16bc -F src/alter.c 8512ed319aa5f7b9bbbd4e17953809e3ff398fdd +F src/alter.c 451da14ff9ffaceaac2d2a7d866cd67a5903478a F src/analyze.c fd1a3d756c1a20fca3c505bed0398f4cdca83cb8 F src/attach.c a01d55157d46a1234909f3a7f21fb09549c947bd F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627 @@ -181,7 +181,7 @@ F src/where.c 4d71db7ee641cd28cdef88cc6149bd3a51d2e671 F tclinstaller.tcl 4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/all.test ee350b9ab15b175fc0a8fb51bf2141ed3a3b9cba -F test/alter.test a87b7933d41c713c53341abe4eb014d0e273119e +F test/alter.test 345648dcd1801cc0287cd996076db512d1dcdabe F test/alter2.test 9d9850064b5c572991ea744a88ea650045f4ac6a F test/alter3.test 8ce6b9c5605b3cfe7b901f454ecaf174c4f93e31 F test/altermalloc.test 29d4a8400277efb4ba8ffe90804c6dc2fdfbf063 @@ -600,7 +600,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 -P 56063ec84b130bcdb0e90bc76fabca394d0d867f -R f457ed8bb872aba62e47c1fbbf619525 +P 2f88b9b3e3c9abc3ae4a5dcef82707dd74f8aace +R c81a64bbb6406c1577adc63cf75c1142 U danielk1977 -Z 9c40edbf16b75a2e3c6478efc41069ac +Z edcd429ac1cef28184ff735c983803e3 diff --git a/manifest.uuid b/manifest.uuid index 07cf3eeb59..71f528b538 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2f88b9b3e3c9abc3ae4a5dcef82707dd74f8aace \ No newline at end of file +19d56d997f50be81ac2baace16b7e7a1b674301a \ No newline at end of file diff --git a/src/alter.c b/src/alter.c index 09eeb4f532..4af4519b95 100644 --- a/src/alter.c +++ b/src/alter.c @@ -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.33 2007/10/20 20:58:57 drh Exp $ +** $Id: alter.c,v 1.34 2007/12/13 08:15:31 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -320,6 +320,13 @@ void sqlite3AlterRenameTable( goto exit_rename_table; } +#ifndef SQLITE_OMIT_VIEW + if( pTab->pSelect ){ + sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName); + goto exit_rename_table; + } +#endif + #ifndef SQLITE_OMIT_AUTHORIZATION /* Invoke the authorization callback. */ if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, 0) ){ diff --git a/test/alter.test b/test/alter.test index f994fc5da4..60ce6050ab 100644 --- a/test/alter.test +++ b/test/alter.test @@ -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.27 2007/10/23 15:39:46 drh Exp $ +# $Id: alter.test,v 1.28 2007/12/13 08:15:31 danielk1977 Exp $ # set testdir [file dirname $argv0] @@ -37,6 +37,8 @@ ifcapable !altertable { # alter-2.*: Test error conditions and messages. # alter-3.*: Test ALTER TABLE on tables that have TRIGGERs attached to them. # alter-4.*: Test ALTER TABLE on tables that have AUTOINCREMENT fields. +# ... +# alter-12.*: Test ALTER TABLE on views. # # Create some tables to rename. Be sure to include some TEMP tables @@ -758,5 +760,30 @@ if {!$isutf16} { } {0 {xyz abc 5 6}} } +do_test alter-12.1 { + execsql { + CREATE TABLE t12(a, b, c); + CREATE VIEW v1 AS SELECT * FROM t12; + } +} {} +do_test alter-12.2 { + catchsql { + ALTER TABLE v1 RENAME TO v2; + } +} {1 {view v1 may not be altered}} +do_test alter-12.3 { + execsql { SELECT * FROM v1; } +} {} +do_test alter-12.4 { + db close + sqlite3 db test.db + execsql { SELECT * FROM v1; } +} {} +do_test alter-12.5 { + catchsql { + ALTER TABLE v1 ADD COLUMN new_column; + } +} {1 {Cannot add a column to a view}} + finish_test