mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Improve the error messages emitted by RENAME TABLE.
FossilOrigin-Name: 6805b5900df5e6d3329cbad2660875ebe4069efe37b19575f527d153dc0882a1
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Add\sanother\stest\scase\sto\saltertab.test.
|
C Improve\sthe\serror\smessages\semitted\sby\sRENAME\sTABLE.
|
||||||
D 2018-09-01T20:38:42.637
|
D 2018-09-03T20:05:15.294
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F Makefile.in 6b650013511fd9d8b094203ac268af9220d292cc7d4e1bc9fbca15aacd8c7995
|
F Makefile.in 6b650013511fd9d8b094203ac268af9220d292cc7d4e1bc9fbca15aacd8c7995
|
||||||
@@ -434,7 +434,7 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
|
|||||||
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
|
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
|
||||||
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
|
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
|
||||||
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
|
||||||
F src/alter.c f309bac1d1d2081d4a085225abc492b7feb0b9bb7954b8dcde38774fb3af9b3e
|
F src/alter.c 8e6fc7ba56710f58cfaa3212cc059bdfde0100b8825cecace0d6a96b0c57c997
|
||||||
F src/analyze.c 3dc6b98cf007b005af89df165c966baaa48e8124f38c87b4d2b276fe7f0b9eb9
|
F src/analyze.c 3dc6b98cf007b005af89df165c966baaa48e8124f38c87b4d2b276fe7f0b9eb9
|
||||||
F src/attach.c 4bd5b92633671d3e8ce431153ebb1893b50335818423b5373f3f27969f79769a
|
F src/attach.c 4bd5b92633671d3e8ce431153ebb1893b50335818423b5373f3f27969f79769a
|
||||||
F src/auth.c 32a5bbe3b755169ab6c66311c5225a3cd4f75a46c041f7fb117e0cbb68055114
|
F src/auth.c 32a5bbe3b755169ab6c66311c5225a3cd4f75a46c041f7fb117e0cbb68055114
|
||||||
@@ -597,14 +597,14 @@ F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
|||||||
F test/aggnested.test 18b00de006597e960a6b27ccec51474ac66cf1070a87c1933e5694dc02190ef1
|
F test/aggnested.test 18b00de006597e960a6b27ccec51474ac66cf1070a87c1933e5694dc02190ef1
|
||||||
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
|
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
|
||||||
F test/all.test ae17c4412639e16bd797c7617864a16c2badc0035c808ae8246f145e38f8e2f9
|
F test/all.test ae17c4412639e16bd797c7617864a16c2badc0035c808ae8246f145e38f8e2f9
|
||||||
F test/alter.test 905d899b2f15d369244a8fa681d919423ecdffc4db44e317bc3499c9ccbcb154
|
F test/alter.test cf28c2f35253d3395cf16334fb9dde1d8c4b035cb7c89204353ee1f47feaec1b
|
||||||
F test/alter2.test 7ea05c7d92ac99349a802ef7ada17294dd647060
|
F test/alter2.test 7ea05c7d92ac99349a802ef7ada17294dd647060
|
||||||
F test/alter3.test 4d79934d812eaeacc6f22781a080f8cfe012fdc3
|
F test/alter3.test 4d79934d812eaeacc6f22781a080f8cfe012fdc3
|
||||||
F test/alter4.test 7e93a21fe131e1dfeb317e90056856f96b10381fc7fe3a05e765569a23400433
|
F test/alter4.test 7e93a21fe131e1dfeb317e90056856f96b10381fc7fe3a05e765569a23400433
|
||||||
F test/altercol.test a5e24ad5e71afbf4a604336ee5f5287d3633ef26952b4ee8b5fe154a30ed2993
|
F test/altercol.test a5e24ad5e71afbf4a604336ee5f5287d3633ef26952b4ee8b5fe154a30ed2993
|
||||||
F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc
|
F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc
|
||||||
F test/altermalloc2.test 0231398534c494401a70a1d06a63d7849cb5b317fcc14228cbdb53039eba7eae
|
F test/altermalloc2.test 0231398534c494401a70a1d06a63d7849cb5b317fcc14228cbdb53039eba7eae
|
||||||
F test/altertab.test 0221db3e69471afa41183bf47b2a5658d73abcb96a19f0089a5f6ec0e2bd18db
|
F test/altertab.test 6c37c18200337463acbfb3efb0e7bb79d8d8902e61e0d9dfd2aa15cc33df7790
|
||||||
F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f
|
F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f
|
||||||
F test/analyze.test b3a9c67d00e1df7588a5b7be9a0292899f94fe8cac1f94a017277474ca2e59df
|
F test/analyze.test b3a9c67d00e1df7588a5b7be9a0292899f94fe8cac1f94a017277474ca2e59df
|
||||||
F test/analyze3.test ff62d9029e6deb2c914490c6b00caf7fae47cc85cdc046e4a0d0a4d4b87c71d8
|
F test/analyze3.test ff62d9029e6deb2c914490c6b00caf7fae47cc85cdc046e4a0d0a4d4b87c71d8
|
||||||
@@ -1762,7 +1762,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 336b8a0923bf65b7a2c35811cb6dec0e262a0b31e534d2a6ab093d2afdb05c1f
|
P 828e8849faed85812c03215b00a2ba34cbb00dfa4d4afdcbd11300ba7fcf9743
|
||||||
R 145add99fb2b5f66c58aac85bb08034b
|
R 449b06d6ad0445dae4839b47d935273b
|
||||||
U dan
|
U dan
|
||||||
Z 0fb0cfe4b4e70bc2c434fcc422411670
|
Z 4bd06618a9b82e1d30214a9078fefd40
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
828e8849faed85812c03215b00a2ba34cbb00dfa4d4afdcbd11300ba7fcf9743
|
6805b5900df5e6d3329cbad2660875ebe4069efe37b19575f527d153dc0882a1
|
||||||
30
src/alter.c
30
src/alter.c
@@ -191,7 +191,7 @@ void sqlite3AlterRenameTable(
|
|||||||
** the schema to use the new table name. */
|
** the schema to use the new table name. */
|
||||||
sqlite3NestedParse(pParse,
|
sqlite3NestedParse(pParse,
|
||||||
"UPDATE \"%w\".%s SET "
|
"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)"
|
"WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)"
|
||||||
"AND name NOT LIKE 'sqlite_%%'"
|
"AND name NOT LIKE 'sqlite_%%'"
|
||||||
, zDb, MASTER_NAME, zDb, zTabName, zName, (iDb==1), zTabName
|
, zDb, MASTER_NAME, zDb, zTabName, zName, (iDb==1), zTabName
|
||||||
@@ -231,7 +231,7 @@ void sqlite3AlterRenameTable(
|
|||||||
if( iDb!=1 ){
|
if( iDb!=1 ){
|
||||||
sqlite3NestedParse(pParse,
|
sqlite3NestedParse(pParse,
|
||||||
"UPDATE sqlite_temp_master SET "
|
"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 = "
|
"tbl_name = "
|
||||||
"CASE WHEN tbl_name=%Q COLLATE nocase THEN %Q ELSE tbl_name END "
|
"CASE WHEN tbl_name=%Q COLLATE nocase THEN %Q ELSE tbl_name END "
|
||||||
"WHERE type IN ('view', 'trigger')"
|
"WHERE type IN ('view', 'trigger')"
|
||||||
@@ -1275,10 +1275,12 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
|
|||||||
** parent table. It is passed three arguments:
|
** parent table. It is passed three arguments:
|
||||||
**
|
**
|
||||||
** 0: The database containing the table being renamed.
|
** 0: The database containing the table being renamed.
|
||||||
** 1: The complete text of the schema statement being modified,
|
** 1. type: Type of object ("table", "view" etc.)
|
||||||
** 2: The old name of the table being renamed, and
|
** 2. object: Name of object
|
||||||
** 3: The new name of the table being renamed.
|
** 3: The complete text of the schema statement being modified,
|
||||||
** 4: True if the schema statement comes from the temp db.
|
** 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:
|
** It returns the new schema statement. For example:
|
||||||
**
|
**
|
||||||
@@ -1292,10 +1294,10 @@ static void renameTableFunc(
|
|||||||
){
|
){
|
||||||
sqlite3 *db = sqlite3_context_db_handle(context);
|
sqlite3 *db = sqlite3_context_db_handle(context);
|
||||||
const char *zDb = (const char*)sqlite3_value_text(argv[0]);
|
const char *zDb = (const char*)sqlite3_value_text(argv[0]);
|
||||||
const char *zInput = (const char*)sqlite3_value_text(argv[1]);
|
const char *zInput = (const char*)sqlite3_value_text(argv[3]);
|
||||||
const char *zOld = (const char*)sqlite3_value_text(argv[2]);
|
const char *zOld = (const char*)sqlite3_value_text(argv[4]);
|
||||||
const char *zNew = (const char*)sqlite3_value_text(argv[3]);
|
const char *zNew = (const char*)sqlite3_value_text(argv[5]);
|
||||||
int bTemp = sqlite3_value_int(argv[4]);
|
int bTemp = sqlite3_value_int(argv[6]);
|
||||||
UNUSED_PARAMETER(NotUsed);
|
UNUSED_PARAMETER(NotUsed);
|
||||||
|
|
||||||
if( zInput && zOld && zNew ){
|
if( zInput && zOld && zNew ){
|
||||||
@@ -1388,7 +1390,11 @@ static void renameTableFunc(
|
|||||||
rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
|
rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
|
||||||
}
|
}
|
||||||
if( rc!=SQLITE_OK ){
|
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);
|
renameParseCleanup(&sParse);
|
||||||
@@ -1453,7 +1459,7 @@ static void renameTableTest(
|
|||||||
void sqlite3AlterFunctions(void){
|
void sqlite3AlterFunctions(void){
|
||||||
static FuncDef aAlterTableFuncs[] = {
|
static FuncDef aAlterTableFuncs[] = {
|
||||||
FUNCTION(sqlite_rename_column, 9, 0, 0, renameColumnFunc),
|
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),
|
FUNCTION(sqlite_rename_test, 5, 0, 0, renameTableTest),
|
||||||
};
|
};
|
||||||
sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));
|
sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));
|
||||||
|
|||||||
@@ -688,11 +688,13 @@ do_test alter-9.1 {
|
|||||||
execsql {SELECT SQLITE_RENAME_COLUMN(0,0,0,0,0,0,0,0,0)}
|
execsql {SELECT SQLITE_RENAME_COLUMN(0,0,0,0,0,0,0,0,0)}
|
||||||
} {{}}
|
} {{}}
|
||||||
foreach {tn sql} {
|
foreach {tn sql} {
|
||||||
1 { SELECT SQLITE_RENAME_TABLE(0,0,0,0,0) }
|
1 { SELECT SQLITE_RENAME_TABLE(0,0,0,0,0,0,0) }
|
||||||
2 { SELECT SQLITE_RENAME_TABLE(10,20,30,40,50) }
|
2 { SELECT SQLITE_RENAME_TABLE(10,20,30,40,50,60,70) }
|
||||||
3 { SELECT SQLITE_RENAME_TABLE('foo', 'foo', 'foo', 'foo', 'foo') }
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ do_execsql_test 7.1 {
|
|||||||
|
|
||||||
do_execsql_test 7.2 {
|
do_execsql_test 7.2 {
|
||||||
SELECT
|
SELECT
|
||||||
sqlite_rename_table(db, sql, zOld, zNew, bTemp)
|
sqlite_rename_table(db, 0, 0, sql, zOld, zNew, bTemp)
|
||||||
FROM ddd;
|
FROM ddd;
|
||||||
} {{} {} {}}
|
} {{} {} {}}
|
||||||
|
|
||||||
@@ -267,6 +267,45 @@ do_execsql_test 8.2 {
|
|||||||
SELECT sql FROM aux.sqlite_master WHERE name = 'c1';
|
SELECT sql FROM aux.sqlite_master WHERE name = 'c1';
|
||||||
} {{CREATE TABLE c1(x INTEGER PRIMARY KEY, y REFERENCES "ppp"(a))}}
|
} {{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
|
finish_test
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user