/ 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 Unified Diffs Show Whitespace Changes Patch

Changes to src/build.c.

18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
....
2268
2269
2270
2271
2272
2273
2274

2275
2276
2277
2278
2279
2280
2281
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.530 2009/04/23 13:22:43 drh Exp $
*/
#include "sqliteInt.h"

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
*/
................................................................................
  pFKey->pNextFrom = p->pFKey;
  z = (char*)&pFKey[1];
  pFKey->aCol = (struct sColMap*)z;
  z += sizeof(struct sColMap)*nCol;
  pFKey->zTo = z;
  memcpy(z, pTo->z, pTo->n);
  z[pTo->n] = 0;

  z += pTo->n+1;
  pFKey->pNextTo = 0;
  pFKey->nCol = nCol;
  if( pFromCol==0 ){
    pFKey->aCol[0].iFrom = p->nCol-1;
  }else{
    for(i=0; i<nCol; i++){







|







 







>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
....
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**
** $Id: build.c,v 1.531 2009/04/24 18:06:09 danielk1977 Exp $
*/
#include "sqliteInt.h"

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Initialize the pParse structure as needed.
*/
................................................................................
  pFKey->pNextFrom = p->pFKey;
  z = (char*)&pFKey[1];
  pFKey->aCol = (struct sColMap*)z;
  z += sizeof(struct sColMap)*nCol;
  pFKey->zTo = z;
  memcpy(z, pTo->z, pTo->n);
  z[pTo->n] = 0;
  sqlite3Dequote(z);
  z += pTo->n+1;
  pFKey->pNextTo = 0;
  pFKey->nCol = nCol;
  if( pFromCol==0 ){
    pFKey->aCol[0].iFrom = p->nCol-1;
  }else{
    for(i=0; i<nCol; i++){

Changes to tool/genfkey.test.

256
257
258
259
260
261
262
263































Error in table t8: foreign key columns do not exist
Error in table t4: implicit mapping to composite primary key
Error in table t1: implicit mapping to non-existant primary key
Error in table t2: implicit mapping to non-existant primary key
Error in table t6: foreign key is not unique
Error in table t7: foreign key is not unique
}]}"








































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
Error in table t8: foreign key columns do not exist
Error in table t4: implicit mapping to composite primary key
Error in table t1: implicit mapping to non-existant primary key
Error in table t2: implicit mapping to non-existant primary key
Error in table t6: foreign key is not unique
Error in table t7: foreign key is not unique
}]}"

# Test that ticket #3800 has been resolved.
#
do_test genfkey-5.1 {
  execsql {
    DROP TABLE t1; DROP TABLE t2; DROP TABLE t3;
    DROP TABLE t4; DROP TABLE t5; DROP TABLE t6;
    DROP TABLE t7; DROP TABLE t8;
  }
} {}
do_test genfkey-5.2 {
  execsql {
    CREATE TABLE "t.3" (c1 PRIMARY KEY);
    CREATE TABLE t13 (c1, foreign key(c1) references "t.3"(c1));
  }
} {}
do_test genfkey-5.3 {
  set rc [catch {exec ./sqlite3 test.db .genfkey} msg]
} {0}
do_test genfkey-5.4 {
  db eval $msg
} {}
do_test genfkey-5.5 {
  catchsql { INSERT INTO t13 VALUES(1) }
} {1 {constraint failed}}
do_test genfkey-5.5 {
  catchsql { 
    INSERT INTO "t.3" VALUES(1);
    INSERT INTO t13 VALUES(1);
  }
} {0 {}}