/ Check-in [d0cfbbba]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:When a "pragma main.table_info(...)" is issued, consider only tables from the main database, not the temp db. Ticket #3320. (CVS 5568)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d0cfbbbaeef7b8ce9f73c6cd58888989a2df5b1f
User & Date: danielk1977 2008-08-20 16:34:24
Context
2008-08-20
16:35
Refactor the name resolution procedures in the code generator. (CVS 5569) check-in: daf730d1 user: drh tags: trunk
16:34
When a "pragma main.table_info(...)" is issued, consider only tables from the main database, not the temp db. Ticket #3320. (CVS 5568) check-in: d0cfbbba user: danielk1977 tags: trunk
16:21
Fix typo in main.c: SQLITE_MAX_ATTACH -> SQLITE_MAX_ATTACHED. Ticket #3319. (CVS 5567) check-in: 66ff55ef user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pragma.c.

     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** This file contains code used to implement the PRAGMA command.
    13     13   **
    14         -** $Id: pragma.c,v 1.183 2008/07/28 19:34:53 drh Exp $
           14  +** $Id: pragma.c,v 1.184 2008/08/20 16:34:24 danielk1977 Exp $
    15     15   */
    16     16   #include "sqliteInt.h"
    17     17   #include <ctype.h>
    18     18   
    19     19   /* Ignore this whole file if pragmas are disabled
    20     20   */
    21     21   #if !defined(SQLITE_OMIT_PRAGMA) && !defined(SQLITE_OMIT_PARSER)
................................................................................
   271    271     if( !zLeft ) return;
   272    272     if( minusFlag ){
   273    273       zRight = sqlite3MPrintf(db, "-%T", pValue);
   274    274     }else{
   275    275       zRight = sqlite3NameFromToken(db, pValue);
   276    276     }
   277    277   
   278         -  zDb = ((iDb>0)?pDb->zName:0);
          278  +  zDb = ((pId2 && pId2->n>0)?pDb->zName:0);
   279    279     if( sqlite3AuthCheck(pParse, SQLITE_PRAGMA, zLeft, zRight, zDb) ){
   280    280       goto pragma_out;
   281    281     }
   282    282    
   283    283   #ifndef SQLITE_OMIT_PAGER_PRAGMAS
   284    284     /*
   285    285     **  PRAGMA [database.]default_cache_size

Changes to test/pragma.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.
    12     12   #
    13     13   # This file implements tests for the PRAGMA command.
    14     14   #
    15         -# $Id: pragma.test,v 1.64 2008/07/12 14:52:20 drh Exp $
           15  +# $Id: pragma.test,v 1.65 2008/08/20 16:34:24 danielk1977 Exp $
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Test organization:
    21     21   #
    22     22   # pragma-1.*: Test cache_size, default_cache_size and synchronous on main db.
................................................................................
   537    537   }
   538    538   do_test pragma-6.5 {
   539    539     execsql {
   540    540       CREATE INDEX t3i1 ON t3(a,b);
   541    541       pragma index_info(t3i1);
   542    542     }
   543    543   } {0 0 a 1 1 b}
          544  +
          545  +ifcapable tempdb {
          546  +  # Test for ticket #3320. When a temp table of the same name exists, make
          547  +  # sure the schema of the main table can still be queried using 
          548  +  # "pragma table_info":
          549  +  do_test pragma-6.6.1 {
          550  +    execsql {
          551  +      CREATE TABLE trial(col_main);
          552  +      CREATE TEMP TABLE trial(col_temp);
          553  +    }
          554  +  } {}
          555  +  do_test pragma-6.6.2 {
          556  +    execsql {
          557  +      PRAGMA table_info(trial);
          558  +    }
          559  +  } {0 col_temp {} 0 {} 0}
          560  +  do_test pragma-6.6.3 {
          561  +    execsql {
          562  +      PRAGMA temp.table_info(trial);
          563  +    }
          564  +  } {0 col_temp {} 0 {} 0}
          565  +  do_test pragma-6.6.4 {
          566  +    execsql {
          567  +      PRAGMA main.table_info(trial);
          568  +    }
          569  +  } {0 col_main {} 0 {} 0}
          570  +}
   544    571   } ;# ifcapable schema_pragmas
   545    572   # Miscellaneous tests
   546    573   #
   547    574   ifcapable schema_pragmas {
   548    575   do_test pragma-7.1 {
   549    576     # Make sure a pragma knows to read the schema if it needs to
   550    577     db close