Hi,
I've spotted a bug in the CREATE TEMP TABLE statement. If you do:
CREATE TEMP TABLE main.table (col);
then the table is made but temporary, in conflict to the qualified name. If
you do the same, but specify an attached database, you receive the error
"temporary table name must be unqualified". Here is a very simple patch
(against current trunk) that fixes this issue in 'sqlite3StartTable':
diff a/src/build.c b/src/build.c
--- a/src/build.c
+++ b/src/build.c
@@ -746,7 +746,7 @@
*/
iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
if( iDb<0 ) return;
- if( !OMIT_TEMPDB && isTemp && iDb>1 ){
+ if( !OMIT_TEMPDB && isTemp && iDb!=1 && pName2->n!=0 ){
/* If creating a temp table, the name may not be qualified */
sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
return;
And here is a very simple set of test cases for the fixed source:
do_test temp-table-fix1 {
catchsql {
CREATE TEMP TABLE main.fix(col);
}
} {1 {temporary table name must be unqualified}}
do_test temp-table-fix2 {
catchsql {
CREATE TEMP TABLE temp.fix(col);
}
} {0 {}}
do_test temp-table-fix3 {
catchsql {
CREATE TEMP TABLE fix(col);
}
} {1 {table fix already exists}}
Regards
Andy
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users