-C Add\sanother\stest\scase\sto\saltertab.test.
-D 2018-09-01T20:38:42.637
+C Improve\sthe\serror\smessages\semitted\sby\sRENAME\sTABLE.
+D 2018-09-03T20:05:15.294
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in 6b650013511fd9d8b094203ac268af9220d292cc7d4e1bc9fbca15aacd8c7995
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
-F src/alter.c f309bac1d1d2081d4a085225abc492b7feb0b9bb7954b8dcde38774fb3af9b3e
+F src/alter.c 8e6fc7ba56710f58cfaa3212cc059bdfde0100b8825cecace0d6a96b0c57c997
F src/analyze.c 3dc6b98cf007b005af89df165c966baaa48e8124f38c87b4d2b276fe7f0b9eb9
F src/attach.c 4bd5b92633671d3e8ce431153ebb1893b50335818423b5373f3f27969f79769a
F src/auth.c 32a5bbe3b755169ab6c66311c5225a3cd4f75a46c041f7fb117e0cbb68055114
F test/aggnested.test 18b00de006597e960a6b27ccec51474ac66cf1070a87c1933e5694dc02190ef1
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
F test/all.test ae17c4412639e16bd797c7617864a16c2badc0035c808ae8246f145e38f8e2f9
-F test/alter.test 905d899b2f15d369244a8fa681d919423ecdffc4db44e317bc3499c9ccbcb154
+F test/alter.test cf28c2f35253d3395cf16334fb9dde1d8c4b035cb7c89204353ee1f47feaec1b
F test/alter2.test 7ea05c7d92ac99349a802ef7ada17294dd647060
F test/alter3.test 4d79934d812eaeacc6f22781a080f8cfe012fdc3
F test/alter4.test 7e93a21fe131e1dfeb317e90056856f96b10381fc7fe3a05e765569a23400433
F test/altercol.test a5e24ad5e71afbf4a604336ee5f5287d3633ef26952b4ee8b5fe154a30ed2993
F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc
F test/altermalloc2.test 0231398534c494401a70a1d06a63d7849cb5b317fcc14228cbdb53039eba7eae
-F test/altertab.test 0221db3e69471afa41183bf47b2a5658d73abcb96a19f0089a5f6ec0e2bd18db
+F test/altertab.test 6c37c18200337463acbfb3efb0e7bb79d8d8902e61e0d9dfd2aa15cc33df7790
F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f
F test/analyze.test b3a9c67d00e1df7588a5b7be9a0292899f94fe8cac1f94a017277474ca2e59df
F test/analyze3.test ff62d9029e6deb2c914490c6b00caf7fae47cc85cdc046e4a0d0a4d4b87c71d8
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 336b8a0923bf65b7a2c35811cb6dec0e262a0b31e534d2a6ab093d2afdb05c1f
-R 145add99fb2b5f66c58aac85bb08034b
+P 828e8849faed85812c03215b00a2ba34cbb00dfa4d4afdcbd11300ba7fcf9743
+R 449b06d6ad0445dae4839b47d935273b
U dan
-Z 0fb0cfe4b4e70bc2c434fcc422411670
+Z 4bd06618a9b82e1d30214a9078fefd40
-828e8849faed85812c03215b00a2ba34cbb00dfa4d4afdcbd11300ba7fcf9743
\ No newline at end of file
+6805b5900df5e6d3329cbad2660875ebe4069efe37b19575f527d153dc0882a1
\ No newline at end of file
** the schema to use the new table name. */
sqlite3NestedParse(pParse,
"UPDATE \"%w\".%s SET "
- "sql = sqlite_rename_table(%Q, sql, %Q, %Q, %d) "
+ "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, %d) "
"WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)"
"AND name NOT LIKE 'sqlite_%%'"
, zDb, MASTER_NAME, zDb, zTabName, zName, (iDb==1), zTabName
if( iDb!=1 ){
sqlite3NestedParse(pParse,
"UPDATE sqlite_temp_master SET "
- "sql = sqlite_rename_table(%Q, sql, %Q, %Q, 1), "
+ "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, 1), "
"tbl_name = "
"CASE WHEN tbl_name=%Q COLLATE nocase THEN %Q ELSE tbl_name END "
"WHERE type IN ('view', 'trigger')"
** parent table. It is passed three arguments:
**
** 0: The database containing the table being renamed.
-** 1: The complete text of the schema statement being modified,
-** 2: The old name of the table being renamed, and
-** 3: The new name of the table being renamed.
-** 4: True if the schema statement comes from the temp db.
+** 1. type: Type of object ("table", "view" etc.)
+** 2. object: Name of object
+** 3: The complete text of the schema statement being modified,
+** 4: The old name of the table being renamed, and
+** 5: The new name of the table being renamed.
+** 6: True if the schema statement comes from the temp db.
**
** It returns the new schema statement. For example:
**
){
sqlite3 *db = sqlite3_context_db_handle(context);
const char *zDb = (const char*)sqlite3_value_text(argv[0]);
- const char *zInput = (const char*)sqlite3_value_text(argv[1]);
- const char *zOld = (const char*)sqlite3_value_text(argv[2]);
- const char *zNew = (const char*)sqlite3_value_text(argv[3]);
- int bTemp = sqlite3_value_int(argv[4]);
+ const char *zInput = (const char*)sqlite3_value_text(argv[3]);
+ const char *zOld = (const char*)sqlite3_value_text(argv[4]);
+ const char *zNew = (const char*)sqlite3_value_text(argv[5]);
+ int bTemp = sqlite3_value_int(argv[6]);
UNUSED_PARAMETER(NotUsed);
if( zInput && zOld && zNew ){
rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
}
if( rc!=SQLITE_OK ){
- sqlite3_result_error_code(context, rc);
+ if( sParse.zErrMsg ){
+ renameColumnParseError(context, 0, argv[1], argv[2], &sParse);
+ }else{
+ sqlite3_result_error_code(context, rc);
+ }
}
renameParseCleanup(&sParse);
void sqlite3AlterFunctions(void){
static FuncDef aAlterTableFuncs[] = {
FUNCTION(sqlite_rename_column, 9, 0, 0, renameColumnFunc),
- FUNCTION(sqlite_rename_table, 5, 0, 0, renameTableFunc),
+ FUNCTION(sqlite_rename_table, 7, 0, 0, renameTableFunc),
FUNCTION(sqlite_rename_test, 5, 0, 0, renameTableTest),
};
sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));
execsql {SELECT SQLITE_RENAME_COLUMN(0,0,0,0,0,0,0,0,0)}
} {{}}
foreach {tn sql} {
- 1 { SELECT SQLITE_RENAME_TABLE(0,0,0,0,0) }
- 2 { SELECT SQLITE_RENAME_TABLE(10,20,30,40,50) }
- 3 { SELECT SQLITE_RENAME_TABLE('foo', 'foo', 'foo', 'foo', 'foo') }
+ 1 { SELECT SQLITE_RENAME_TABLE(0,0,0,0,0,0,0) }
+ 2 { SELECT SQLITE_RENAME_TABLE(10,20,30,40,50,60,70) }
+ 3 { SELECT SQLITE_RENAME_TABLE('foo','foo','foo','foo','foo','foo','foo') }
} {
- do_catchsql_test alter-9.2.$tn $sql {1 {SQL logic error}}
+ do_test alter-9.2.$tn {
+ catch { execsql $sql }
+ } 1
}
#------------------------------------------------------------------------
do_execsql_test 7.2 {
SELECT
- sqlite_rename_table(db, sql, zOld, zNew, bTemp)
+ sqlite_rename_table(db, 0, 0, sql, zOld, zNew, bTemp)
FROM ddd;
} {{} {} {}}
SELECT sql FROM aux.sqlite_master WHERE name = 'c1';
} {{CREATE TABLE c1(x INTEGER PRIMARY KEY, y REFERENCES "ppp"(a))}}
+reset_db
+do_execsql_test 9.0 {
+ CREATE TABLE t1(a, b, c);
+ CREATE VIEW v1 AS SELECT * FROM t2;
+}
+do_catchsql_test 9.1 {
+ ALTER TABLE t1 RENAME TO t3;
+} {1 {error in view v1: no such table: main.t2}}
+do_execsql_test 9.2 {
+ DROP VIEW v1;
+ CREATE TRIGGER tr AFTER INSERT ON t1 BEGIN
+ INSERT INTO t2 VALUES(new.a);
+ END;
+}
+do_catchsql_test 9.3 {
+ ALTER TABLE t1 RENAME TO t3;
+} {1 {error in trigger tr: no such table: main.t2}}
+
+forcedelete test.db2
+do_execsql_test 9.4 {
+ DROP TRIGGER tr;
+
+ ATTACH 'test.db2' AS aux;
+ CREATE TRIGGER tr AFTER INSERT ON t1 BEGIN SELECT 1, 2, 3; END;
+
+ CREATE TABLE aux.t1(x);
+ CREATE TEMP TRIGGER tr AFTER INSERT ON aux.t1 BEGIN SELECT 1, 2, 3; END;
+}
+do_execsql_test 9.5 {
+ ALTER TABLE main.t1 RENAME TO t3;
+}
+do_execsql_test 9.6 {
+ SELECT sql FROM sqlite_temp_master;
+ SELECT sql FROM sqlite_master WHERE type='trigger';
+} {
+ {CREATE TRIGGER tr AFTER INSERT ON aux.t1 BEGIN SELECT 1, 2, 3; END}
+ {CREATE TRIGGER tr AFTER INSERT ON "t3" BEGIN SELECT 1, 2, 3; END}
+}
+
finish_test