Raise an error on an attempt to rename an eponymous virtual table.

FossilOrigin-Name: c7909e8e0d0577c6109f13c0b14fb565239aae8af8963d659f363e124f3437fc
This commit is contained in:
drh 2021-04-22 18:02:48 +00:00
parent a5b51b8715
commit 3d8c92d041
6 changed files with 60 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Add\sthe\sexperimental\ssqlite3session_changeset_size()\sAPI.
D 2021-04-22T17:55:42.561
C Raise\san\serror\son\san\sattempt\sto\srename\san\seponymous\svirtual\stable.
D 2021-04-22T18:02:48.159
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -477,7 +477,7 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
F src/alter.c 0fe0f82a9cf3c4c136aa5fe7bce147a12ff3389cd009a29d8a62ce4037763e5d
F src/alter.c 6c62a47364d4eb142de6b0aa8a21e83450ad115ca5c2100f031af171777af068
F src/analyze.c 01c6c6765cb4d40b473b71d85535093730770bb186f2f473abac25f07fcdee5c
F src/attach.c a7d1a7df69f053951ec1665e5894c61184fda3f677323762f1c3679ebd27d5c7
F src/auth.c 08954fdc4cc2da5264ba5b75cfd90b67a6fc7d1710a02ccf917c38eadec77853
@ -548,7 +548,7 @@ F src/shell.c.in 9320b476fde0f7c46700e5695b69b435f1e46843a1513cdd187ac426cdbee01
F src/sqlite.h.in 372554fcd1e1ed25ba44a316e8abdaad712470b7dcfa185ece54f51b10fbde10
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 61b38c073d5e1e96a3d45271b257aef27d0d13da2bea5347692ae579475cd95e
F src/sqliteInt.h 234ab17b1797cbc2adb7741a15786edf72bc96d40b4de68795e91926cfd46eba
F src/sqliteInt.h a00cc0642e2a4e26367313dc553781253e278a0e571e7211cc56245a8db3e0e7
F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
F src/status.c 4b8bc2a6905163a38b739854a35b826c737333fab5b1f8e03fa7eb9a4799c4c1
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
@ -625,7 +625,7 @@ F src/vdbemem.c 947f2a65910edb4014dc981d33e414a68c51f169f9df8c4c493a0ba840b6eb1f
F src/vdbesort.c f5b5e473a7cee44e47a94817b042fd7172cf3aa2c0a7928a8339d612bcfdec5a
F src/vdbetrace.c 666c6fd9f1b62be6999e072a45b913e3c2c3518bc60dfd4d54fe304130acb724
F src/vdbevtab.c f99b275366c5fc5e2d99f734729880994ab9500bdafde7fae3b02d562b9d323c
F src/vtab.c 032a0165c147fda16927e6a3230e90c068d4af93f887ce94e26f678fe48e5e4c
F src/vtab.c b928405ccb66040fc6c3a11eaa93ddb02cbf20f9ab6860b301b222b9b50dc089
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c 69e770e96fd56cc21608992bf2c6f1f3dc5cf2572d0495c6a643b06c3a679f14
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
@ -1440,7 +1440,7 @@ F test/sync.test 89539f4973c010eda5638407e71ca7fddbcd8e0594f4c9980229f804d433309
F test/sync2.test 8f9f7d4f6d5be8ca8941a8dadcc4299e558cb6a1ff653a9469146c7a76ef2039
F test/syscall.test a39d9a36f852ae6e4800f861bc2f2e83f68bbc2112d9399931ecfadeabd2d69d
F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04
F test/tabfunc01.test 5ca6d004157a3e886a55a9387b960cc0db41acd88753eb597ff409ec6cfb1be0
F test/tabfunc01.test acb5be558868c65d8cf3495539fff23093d77139eb1e4e8c4580568099f98645
F test/table.test eb3463b7add9f16a5bb836badf118cf391b809d09fdccd1f79684600d07ec132
F test/tableapi.test ecbcc29c4ab62c1912c3717c48ea5c5e59f7d64e4a91034e6148bd2b82f177f4
F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
@ -1914,8 +1914,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 9c7a449f52a391506ebf4a8efa4ff27e6e97bd8da4b300a5c0dd942a209fe474 4d5fd2151e024d11289b6c4fbce2996d8d07b2b5a1c953ef895c237e79d3aa55
R a84d1eee362399318f4f6d583239c517
T +closed 4d5fd2151e024d11289b6c4fbce2996d8d07b2b5a1c953ef895c237e79d3aa55
U dan
Z 9bc3972a508ee6a4946adabac402e49c
P 3de544d495fee553d95fde3fb656745d633138115d25ed39760a1ea7c8c3fae6
R 6a9c7cdbbc90921854925aabbca2bec9
U drh
Z f41afbcd09712ab0e6057d2e621e731f

View File

@ -1 +1 @@
3de544d495fee553d95fde3fb656745d633138115d25ed39760a1ea7c8c3fae6
c7909e8e0d0577c6109f13c0b14fb565239aae8af8963d659f363e124f3437fc

View File

@ -29,8 +29,9 @@
** Or, if zName is not a system table, zero is returned.
*/
static int isAlterableTable(Parse *pParse, Table *pTab){
if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
#ifndef SQLITE_OMIT_VIRTUALTABLE
|| (pTab->tabFlags & TF_Eponymous)!=0
|| ( (pTab->tabFlags & TF_Shadow)!=0
&& sqlite3ReadOnlyShadowTables(pParse->db)
)
@ -918,8 +919,7 @@ static RenameToken *renameTokenFind(
void *pPtr
){
RenameToken **pp;
if( pPtr==0 ){
assert( pParse->nErr || pParse->db->mallocFailed );
if( NEVER(pPtr==0) ){
return 0;
}
for(pp=&pParse->pRename; (*pp); pp=&(*pp)->pNext){

View File

@ -2236,6 +2236,7 @@ struct Table {
#define TF_Shadow 0x1000 /* True for a shadow table */
#define TF_HasStat4 0x2000 /* STAT4 info available for this table */
#define TF_Ephemeral 0x4000 /* An ephemeral table */
#define TF_Eponymous 0x8000 /* An eponymous virtual table */
/*
** Test to see whether or not a table is a virtual table. This is

View File

@ -1221,6 +1221,7 @@ int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){
pTab->pSchema = db->aDb[0].pSchema;
assert( pTab->nModuleArg==0 );
pTab->iPKey = -1;
pTab->tabFlags |= TF_Eponymous;
addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName));
addModuleArgument(pParse, pTab, 0);
addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName));

View File

@ -227,6 +227,50 @@ do_test tabfunc01-751 {
}
} {5.0 x5 | 7.0 x7 | 13.0 x13 | 17.0 x17 | 23.0 x23 |}
ifcapable altertable {
do_test tabfunc01-800 {
catchsql {
ALTER TABLE generate_series ADD COLUMN col2;
}
} {1 {virtual tables may not be altered}}
do_test tabfunc01-810 {
catchsql {
ALTER TABLE generate_series RENAME TO flubber;
}
} {1 {table generate_series may not be altered}}
do_test tabfunc01-820 {
catchsql {
ALTER TABLE generate_series RENAME start TO flubber;
}
} {1 {table generate_series may not be altered}}
do_test tabfunc01-830 {
catchsql {
ALTER TABLE generate_series DROP COLUMN start;
}
} {1 {table generate_series may not be altered}}
do_test tabfunc01-900 {
catchsql {
ALTER TABLE pragma_compile_options ADD COLUMN col2;
}
} {1 {virtual tables may not be altered}}
do_test tabfunc01-910 {
catchsql {
ALTER TABLE pragma_compile_options RENAME TO flubber;
}
} {1 {table pragma_compile_options may not be altered}}
do_test tabfunc01-920 {
catchsql {
ALTER TABLE pragma_compile_options RENAME start TO flubber;
}
} {1 {table pragma_compile_options may not be altered}}
do_test tabfunc01-930 {
catchsql {
ALTER TABLE pragma_compile_options DROP COLUMN start;
}
} {1 {table pragma_compile_options may not be altered}}
}
# Free up memory allocations
intarray_addr
int64array_addr