Index: src/pragma.c ================================================================== --- src/pragma.c +++ src/pragma.c @@ -9,11 +9,11 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.183 2008/07/28 19:34:53 drh Exp $ +** $Id: pragma.c,v 1.184 2008/08/20 16:34:24 danielk1977 Exp $ */ #include "sqliteInt.h" #include /* Ignore this whole file if pragmas are disabled @@ -273,11 +273,11 @@ zRight = sqlite3MPrintf(db, "-%T", pValue); }else{ zRight = sqlite3NameFromToken(db, pValue); } - zDb = ((iDb>0)?pDb->zName:0); + zDb = ((pId2 && pId2->n>0)?pDb->zName:0); if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){ goto pragma_out; } #ifndef SQLITE_OMIT_PAGER_PRAGMAS Index: test/pragma.test ================================================================== --- test/pragma.test +++ test/pragma.test @@ -10,11 +10,11 @@ #*********************************************************************** # This file implements regression tests for SQLite library. # # This file implements tests for the PRAGMA command. # -# $Id: pragma.test,v 1.64 2008/07/12 14:52:20 drh Exp $ +# $Id: pragma.test,v 1.65 2008/08/20 16:34:24 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Test organization: @@ -539,10 +539,37 @@ execsql { CREATE INDEX t3i1 ON t3(a,b); pragma index_info(t3i1); } } {0 0 a 1 1 b} + +ifcapable tempdb { + # Test for ticket #3320. When a temp table of the same name exists, make + # sure the schema of the main table can still be queried using + # "pragma table_info": + do_test pragma-6.6.1 { + execsql { + CREATE TABLE trial(col_main); + CREATE TEMP TABLE trial(col_temp); + } + } {} + do_test pragma-6.6.2 { + execsql { + PRAGMA table_info(trial); + } + } {0 col_temp {} 0 {} 0} + do_test pragma-6.6.3 { + execsql { + PRAGMA temp.table_info(trial); + } + } {0 col_temp {} 0 {} 0} + do_test pragma-6.6.4 { + execsql { + PRAGMA main.table_info(trial); + } + } {0 col_main {} 0 {} 0} +} } ;# ifcapable schema_pragmas # Miscellaneous tests # ifcapable schema_pragmas { do_test pragma-7.1 {