]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Allow CREATE and DROP VIEW on attached databases. (CVS 1485)
authordanielk1977 <danielk1977@noemail.net>
Fri, 28 May 2004 12:33:30 +0000 (12:33 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Fri, 28 May 2004 12:33:30 +0000 (12:33 +0000)
FossilOrigin-Name: ad879a957d93c0b49c289947826b451d3ea37e5b

manifest
manifest.uuid
src/build.c
src/parse.y
src/sqliteInt.h
test/attach3.test
test/index.test

index d3c188b5b18a29a728294ea53677dcb387cddfc1..eb1d8f8901f7468e5ecd750aa5f3563013e94412 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Allow\sDROP\sTABLE\sand\sDROP\sINDEX\son\sattached\sdatabases.\s(CVS\s1484)
-D 2004-05-28T12:11:21
+C Allow\sCREATE\sand\sDROP\sVIEW\son\sattached\sdatabases.\s(CVS\s1485)
+D 2004-05-28T12:33:31
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -26,7 +26,7 @@ F src/attach.c c315c58cb16fd6e913b3bfa6412aedecb4567fa5
 F src/auth.c 5c2f0bea4729c98c2be3b69d6b466fc51448fe79
 F src/btree.c 6db76fbf63efd6008c5e6cb038ea40f94abffcf7
 F src/btree.h b65140b5ae891f30d2a39e64b9f0343225553545
-F src/build.c ebb6746232d4ff01555a103e69bf8740b13ca5b4
+F src/build.c 3d6fd4a919c82f6b3dbbe2845bd0c087c73397ae
 F src/date.c 0eb922af5c5f5e2455f8dc2f98023ed3e04a857e
 F src/delete.c 66c5ab98cbad7e6b315fc997bfe6c8080784a701
 F src/encode.c a876af473d1d636faa3dca51c7571f2e007eea37
@@ -48,14 +48,14 @@ F src/os_win.c 92b51a38437b98d8aa3ac05b57c71e1d1092e5be
 F src/os_win.h 5d41af24caaef6c13a2d8e2399caa1c57d45c84d
 F src/pager.c 6ff6b906427d4824099140776cb8768f922f3dc5
 F src/pager.h 78a00ac280899bcba1a89dc51585dcae6b7b3253
-F src/parse.y 32d6d4b20926ef4bf2f2243e8d7009856332553c
+F src/parse.y 9d3be712abc9005495701efbec741c58408f1343
 F src/pragma.c f2b05b087a5764802296a28d7abdd75728beedee
 F src/printf.c ef750e8e2398ca7e8b58be991075f08c6a7f0e53
 F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
 F src/select.c 26f726b398af8708c81178acc9c68d64e78e6f5e
 F src/shell.c ed4d237b3e52a0a42512bfcc53530e46de20c28f
 F src/sqlite.h.in edc6408c7f53c2104f781a76b926036e17018ec9
-F src/sqliteInt.h 582a4c482e4935ea99a57b6c89f4c423990e66aa
+F src/sqliteInt.h 1c3fc5d7a2bf33b1ea64284c81dbd07d00d9d1bd
 F src/table.c af14284fa36c8d41f6829e3f2819dce07d3e2de2
 F src/tclsqlite.c 877d0b96013a25b03ed6bd2d32917c42e84403bc
 F src/test1.c 32934478366531503d634968db414df17cb38238
@@ -79,7 +79,7 @@ F src/where.c efe5d25fe18cd7381722457898cd863e84097a0c
 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
 F test/attach.test cb9b884344e6cfa5e165965d5b1adea679a24c83
 F test/attach2.test 5472d442bb2ef1ee587e0ae7472bb68b52509a38
-F test/attach3.test abf067bfc6a6051cc250f5c9a814cebeb23e5c54
+F test/attach3.test 8c55071e4629fe781f3b1955454db2b7f33c943b
 F test/auth.test 95809b8f6a9bec18b94d28cafd03fe27d2f8a9e9
 F test/bigfile.test ea904b853ce2d703b16c5ce90e2b54951bc1ae81
 F test/bigrow.test 8ab252dba108f12ad64e337b0f2ff31a807ac578
@@ -103,7 +103,7 @@ F test/fkey1.test d65c824459916249bee501532d6154ddab0b5db7
 F test/func.test b6d87075ff65babd6466b8a8dfc0d44f6a92df0c
 F test/hook.test 1a67ce0cd64a6455d016962542f2822458dccc49
 F test/in.test b92a2df9162e1cbd33c6449a29a05e6955b1741a
-F test/index.test 3d50e19807186682de60c53f507a831c1b4a38a2
+F test/index.test ad3f479a3dc4a6d9105a2c88e3ee432498441c34
 F test/insert.test 6ec324659656f4a86e4abfcf1a1fd2795ba6b603
 F test/insert2.test c288375a64dad3295044714f0dfed4a193cf067f
 F test/interrupt.test 9142ce4448605127640eda5e283952f75f67ed91
@@ -204,7 +204,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 4984a130ccf3b8e486941a5d0d0cc70a691f0dac
-R f6ec791bb07b629b8edefb69fa686613
+P 2fb3708e10a06660ad1974ef8e9742b706a0a9fc
+R 357b84549b85209a0556b43d32e20b9f
 U danielk1977
-Z 196ddec31e4f147783f673bcab20af4a
+Z 9f71f73052e9fd5a8f1a3443c4f3df37
index eccb5dbcfb6b334f81999ea57f10127cee879342..8a6bf5a92a763912468f9dc06f665f42466f5ce2 100644 (file)
@@ -1 +1 @@
-2fb3708e10a06660ad1974ef8e9742b706a0a9fc
\ No newline at end of file
+ad879a957d93c0b49c289947826b451d3ea37e5b
\ No newline at end of file
index d3b9cb709cd85b8a0b38169da4d58296fdacef5e..92efbf084a20a1fec75ac194fb5805b29400e95b 100644 (file)
@@ -23,7 +23,7 @@
 **     ROLLBACK
 **     PRAGMA
 **
-** $Id: build.c,v 1.195 2004/05/28 12:11:21 danielk1977 Exp $
+** $Id: build.c,v 1.196 2004/05/28 12:33:31 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1148,7 +1148,8 @@ void sqlite3EndTable(Parse *pParse, Token *pEnd, Select *pSelect){
 void sqlite3CreateView(
   Parse *pParse,     /* The parsing context */
   Token *pBegin,     /* The CREATE token that begins the statement */
-  Token *pName,      /* The token that holds the name of the view */
+  Token *pName1,     /* The token that holds the name of the view */
+  Token *pName2,     /* The token that holds the name of the view */
   Select *pSelect,   /* A SELECT statement that will become the new view */
   int isTemp         /* TRUE for a TEMPORARY view */
 ){
@@ -1157,13 +1158,15 @@ void sqlite3CreateView(
   const char *z;
   Token sEnd;
   DbFixer sFix;
+  Token *pName;
 
-  sqlite3StartTable(pParse, pBegin, pName, 0, isTemp, 1);
+  sqlite3StartTable(pParse, pBegin, pName1, pName2, isTemp, 1);
   p = pParse->pNewTable;
   if( p==0 || pParse->nErr ){
     sqlite3SelectDelete(pSelect);
     return;
   }
+  resolveSchemaName(pParse, pName1, pName2, &pName);
   if( sqlite3FixInit(&sFix, pParse, p->iDb, "view", pName)
     && sqlite3FixSelect(&sFix, pSelect)
   ){
index 7681ebc41daa0b352a43346db863e816ae7402f3..6f3a34e27a296f487e3ea4a75ac868a97a0e3419 100644 (file)
@@ -14,7 +14,7 @@
 ** the parser.  Lemon will also generate a header file containing
 ** numeric codes for all of the tokens.
 **
-** @(#) $Id: parse.y,v 1.121 2004/05/28 12:11:21 danielk1977 Exp $
+** @(#) $Id: parse.y,v 1.122 2004/05/28 12:33:31 danielk1977 Exp $
 */
 %token_prefix TK_
 %token_type {Token}
@@ -268,11 +268,11 @@ cmd ::= DROP TABLE nm(X) dbnm(Y).   {
 
 ///////////////////// The CREATE VIEW statement /////////////////////////////
 //
-cmd ::= CREATE(X) temp(T) VIEW nm(Y) AS select(S). {
-  sqlite3CreateView(pParse, &X, &Y, S, T);
+cmd ::= CREATE(X) temp(T) VIEW nm(Y) dbnm(Z) AS select(S). {
+  sqlite3CreateView(pParse, &X, &Y, &Z, S, T);
 }
-cmd ::= DROP VIEW nm(X). {
-  sqlite3DropTable(pParse, &X, 1);
+cmd ::= DROP VIEW nm(X) dbnm(Y). {
+  sqlite3DropTable(pParse, sqlite3SrcListAppend(0,&X,&Y), 1);
 }
 
 //////////////////////// The SELECT statement /////////////////////////////////
index 37c94ec08b70f2d80b9109150bbef5ddc6b57266..7f7e049dd62ada8bf60a7094a8dca013d88d394a 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.258 2004/05/28 12:11:21 danielk1977 Exp $
+** @(#) $Id: sqliteInt.h,v 1.259 2004/05/28 12:33:31 danielk1977 Exp $
 */
 #include "config.h"
 #include "sqlite.h"
@@ -1209,7 +1209,7 @@ void sqlite3AddCollateType(Parse*, const char*, int);
 CollSeq *sqlite3ChangeCollatingFunction(sqlite*,const char*,int,
                   void*, int(*)(void*,int,const void*,int,const void*));
 void sqlite3EndTable(Parse*,Token*,Select*);
-void sqlite3CreateView(Parse*,Token*,Token*,Select*,int);
+void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int);
 int sqlite3ViewGetColumnNames(Parse*,Table*);
 void sqlite3DropTable(Parse*, SrcList*, int);
 void sqlite3DeleteTable(sqlite*, Table*);
index 897e8ea0bb4bc3132fc0f9e4e524549bb65d9c50..a3c8352f8506eb0650cadaddbb4197836e3afe10 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this script is testing the ATTACH and DETACH commands
 # and schema changes to attached databases.
 #
-# $Id: attach3.test,v 1.2 2004/05/28 12:11:21 danielk1977 Exp $
+# $Id: attach3.test,v 1.3 2004/05/28 12:33:32 danielk1977 Exp $
 #
 
 
@@ -102,7 +102,7 @@ do_test attach4-3.3 {
   }
 } {}
 
-# Drop the tables in the auxilary database.
+# Drop tables t1 and t2 in the auxilary database.
 do_test attach4-4.1 {
   execsql {
     DROP TABLE aux.t1;
@@ -122,10 +122,34 @@ do_test attach4-4.3 {
     SELECT name FROM aux.sqlite_master;
   }
 } {t3}
-do_test attach4-4.4 {
+
+# Create a view in the auxilary database.
+do_test attach4-5.1 {
+  execsql {
+    CREATE VIEW aux.v1 AS SELECT * FROM t3;
+  }
+} {}
+do_test attach4-5.2 {
+  execsql {
+    SELECT * FROM aux.sqlite_master WHERE name = 'v1';
+  }
+} {view v1 v1 0 {CREATE VIEW v1 AS SELECT * FROM t3}}
+do_test attach4-5.3 {
+  execsql {
+    INSERT INTO aux.t3 VALUES('hello', 'world');
+    SELECT * FROM v1;
+  }
+} {1 2 hello world}
+
+# Drop the view 
+do_test attach4-6.1 {
+  execsql {
+    DROP VIEW aux.v1;
+  }
+} {}
+do_test attach4-5.2 {
   execsql {
-    DROP TABLE aux.t3;
-    SELECT * FROM aux.sqlite_master;
+    SELECT * FROM aux.sqlite_master WHERE name = 'v1';
   }
 } {}
 
index a9b721da5df5730d22cc3a2ae933c38b86ef7109..023b9a125441440bdcaeb3515dc2b22ce0b8f583 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this file is testing the CREATE INDEX statement.
 #
-# $Id: index.test,v 1.26 2004/05/16 22:55:28 danielk1977 Exp $
+# $Id: index.test,v 1.27 2004/05/28 12:33:32 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -51,7 +51,7 @@ do_test index-1.2 {
 do_test index-2.1 {
   set v [catch {execsql {CREATE INDEX index1 ON test1(f1)}} msg]
   lappend v $msg
-} {1 {no such table: test1}}
+} {1 {no such table: main.test1}}
 
 # Try adding an index on a column of a table where the table
 # exists but the column does not.