Fix the CREATE INDEX statement so that trying to create a TEMP index on

a non-TEMP table throws an error rather than segfaulting.

FossilOrigin-Name: e3c8935f8736d00dc83644fa21d86ca7fec6d2fc
This commit is contained in:
drh 2013-08-01 22:27:26 +00:00
parent af4300636a
commit 989b116a03
4 changed files with 31 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Fix\san\sincorrect\sexpected\sresult\sin\sa\stest\scase\sin\scorruptG.test.
D 2013-08-01T22:26:56.329
C Fix\sthe\sCREATE\sINDEX\sstatement\sso\sthat\strying\sto\screate\sa\sTEMP\sindex\son\na\snon-TEMP\stable\sthrows\san\serror\srather\sthan\ssegfaulting.
D 2013-08-01T22:27:26.044
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -166,7 +166,7 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
F src/btree.c 3f7bbfd72efb1cbf6a49515c376a031767ec930a
F src/btree.h 6fa8a3ff2483d0bb64a9f0105a8cedeac9e00cca
F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2
F src/build.c 42239cfd95533e4aacf4d58b4724c8f858de5ced
F src/build.c 1a6db7f48ad5fd050a43ed4dcc653c9be0882c48
F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc
F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac
F src/ctime.c 4262c227bc91cecc61ae37ed3a40f08069cfa267
@ -585,7 +585,7 @@ F test/incrvacuum.test d2a6ddf5e429720b5fe502766af747915ccf6c32
F test/incrvacuum2.test 379eeb8740b0ef60c372c439ad4cbea20b34bb9b
F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a
F test/incrvacuum_ioerr.test 6ae2f783424e47a0033304808fe27789cf93e635
F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097
F test/index.test f2abacfb83d384ae36b8a919fbd94b1319333e55
F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6
F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7
F test/index4.test 2983216eb8c86ee62d9ed7cb206b5cc3331c0026
@ -1104,7 +1104,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae
F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
P e436b2f4e5c5e6b2f70e65332c0c7d618e2ef20a
R b6c71bf72fc88457d8239caf7a219b2b
P 6913831ad2892fdc8331ee53426d935386eacb9e
R c4336b3c1d9855c02f7d72f3a4291b06
U drh
Z d61b007331cedb7cbca3d1493ff2bd3f
Z 038dfb0c43b0a82e8c8dc532f3798b80

View File

@ -1 +1 @@
6913831ad2892fdc8331ee53426d935386eacb9e
e3c8935f8736d00dc83644fa21d86ca7fec6d2fc

View File

@ -2550,7 +2550,12 @@ Index *sqlite3CreateIndex(
pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);
assert( db->mallocFailed==0 || pTab==0 );
if( pTab==0 ) goto exit_create_index;
assert( db->aDb[iDb].pSchema==pTab->pSchema );
if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){
sqlite3ErrorMsg(pParse,
"cannot create a TEMP index on non-TEMP table \"%s\"",
pTab->zName);
goto exit_create_index;
}
}else{
assert( pName==0 );
assert( pStart==0 );

View File

@ -715,6 +715,23 @@ do_test index-20.2 {
DROP INDEX "t6i1";
}
} {}
# Try to create a TEMP index on a non-TEMP table. */
#
do_test index-21.1 {
catchsql {
CREATE INDEX temp.i21 ON t6(c);
}
} {1 {cannot create a TEMP index on non-TEMP table "t6"}}
do_test index-21.2 {
catchsql {
CREATE TEMP TABLE t6(x);
INSERT INTO temp.t6 values(1),(5),(9);
CREATE INDEX temp.i21 ON t6(x);
SELECT x FROM t6 ORDER BY x DESC;
}
} {0 {9 5 1}}
finish_test