/ Check-in [600482d1]
Login

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

Overview
Comment:Dequote the "from" table in a FOREIGN KEY definition (affects the output of "pragma foreign_key_list). Fix for #3800. (CVS 6547)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 600482d1619c07690b6517ded9655462bdab7538
User & Date: danielk1977 2009-04-24 18:06:09
Context
2009-04-24
20:32
Add another test case for the "x IS NULL" uniqueness problem of ticket #3824. No changes to code. This just double-checks that everything is working now. (CVS 6548) check-in: 3ceae357 user: drh tags: trunk
18:06
Dequote the "from" table in a FOREIGN KEY definition (affects the output of "pragma foreign_key_list). Fix for #3800. (CVS 6547) check-in: 600482d1 user: danielk1977 tags: trunk
15:46
Get rid of the special RowSet processing in where.c and move that into clients. Added the WHERE_DUPLICATES_OK option to eliminate an unnecessary RowSet during DELETE with a WHERE clause containing ORs. (CVS 6546) check-in: 98606bee user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

    18     18   **     CREATE INDEX
    19     19   **     DROP INDEX
    20     20   **     creating ID lists
    21     21   **     BEGIN TRANSACTION
    22     22   **     COMMIT
    23     23   **     ROLLBACK
    24     24   **
    25         -** $Id: build.c,v 1.530 2009/04/23 13:22:43 drh Exp $
           25  +** $Id: build.c,v 1.531 2009/04/24 18:06:09 danielk1977 Exp $
    26     26   */
    27     27   #include "sqliteInt.h"
    28     28   
    29     29   /*
    30     30   ** This routine is called when a new SQL statement is beginning to
    31     31   ** be parsed.  Initialize the pParse structure as needed.
    32     32   */
................................................................................
  2268   2268     pFKey->pNextFrom = p->pFKey;
  2269   2269     z = (char*)&pFKey[1];
  2270   2270     pFKey->aCol = (struct sColMap*)z;
  2271   2271     z += sizeof(struct sColMap)*nCol;
  2272   2272     pFKey->zTo = z;
  2273   2273     memcpy(z, pTo->z, pTo->n);
  2274   2274     z[pTo->n] = 0;
         2275  +  sqlite3Dequote(z);
  2275   2276     z += pTo->n+1;
  2276   2277     pFKey->pNextTo = 0;
  2277   2278     pFKey->nCol = nCol;
  2278   2279     if( pFromCol==0 ){
  2279   2280       pFKey->aCol[0].iFrom = p->nCol-1;
  2280   2281     }else{
  2281   2282       for(i=0; i<nCol; i++){

Changes to tool/genfkey.test.

   256    256   Error in table t8: foreign key columns do not exist
   257    257   Error in table t4: implicit mapping to composite primary key
   258    258   Error in table t1: implicit mapping to non-existant primary key
   259    259   Error in table t2: implicit mapping to non-existant primary key
   260    260   Error in table t6: foreign key is not unique
   261    261   Error in table t7: foreign key is not unique
   262    262   }]}"
          263  +
          264  +# Test that ticket #3800 has been resolved.
          265  +#
          266  +do_test genfkey-5.1 {
          267  +  execsql {
          268  +    DROP TABLE t1; DROP TABLE t2; DROP TABLE t3;
          269  +    DROP TABLE t4; DROP TABLE t5; DROP TABLE t6;
          270  +    DROP TABLE t7; DROP TABLE t8;
          271  +  }
          272  +} {}
          273  +do_test genfkey-5.2 {
          274  +  execsql {
          275  +    CREATE TABLE "t.3" (c1 PRIMARY KEY);
          276  +    CREATE TABLE t13 (c1, foreign key(c1) references "t.3"(c1));
          277  +  }
          278  +} {}
          279  +do_test genfkey-5.3 {
          280  +  set rc [catch {exec ./sqlite3 test.db .genfkey} msg]
          281  +} {0}
          282  +do_test genfkey-5.4 {
          283  +  db eval $msg
          284  +} {}
          285  +do_test genfkey-5.5 {
          286  +  catchsql { INSERT INTO t13 VALUES(1) }
          287  +} {1 {constraint failed}}
          288  +do_test genfkey-5.5 {
          289  +  catchsql { 
          290  +    INSERT INTO "t.3" VALUES(1);
          291  +    INSERT INTO t13 VALUES(1);
          292  +  }
          293  +} {0 {}}
   263    294