-C Version\s2.8.6\s(CVS\s1080)
-D 2003-08-22T03:00:00
+C Add\sa\s"pk"\scolumn\sto\sthe\stable_info\spragma\swhich\sis\strue\sfor\seach\scolumn\nthat\sis\spart\sof\sthe\sprimary\skey.\s\sAdd\sa\s"foreign_key_list"\spragma\sthat\sgives\ninformation\sabout\sall\sforeign\skeys\sfor\sa\stable.\s\sBoth\schanges\sare\sexperimental.\s(CVS\s1081)
+D 2003-08-23T22:40:54
F Makefile.in 4168f80989c60b195d378bcaa2e2046df03ee2ec
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
F src/btree.c ba1cc0c71c3d2742b9a9047832335dc7d3656c45
F src/btree.h 9b7c09f1e64274d7bb74a57bbfc63778f67b1048
F src/btree_rb.c f30f5cddc4375c05bf361116da1492d9601760ca
-F src/build.c 335a4db960a3305e16c64d67726dd534386df7c3
+F src/build.c 5b379f8b699ecbb3d55f492f0e956b9da40b4a9c
F src/copy.c 9e47975ea96751c658bcf1a0c4f0bb7c6ee61e73
F src/delete.c 0f81e6799c089487615d38e042a2de4d2d6192bc
F src/encode.c 25ea901a9cefb3d93774afa4a06b57cb58acf544
F src/pager.c a4fd3a61d63879365f775875edfffaa8c6f3d7f8
F src/pager.h 5da62c83443f26b1792cfd72c96c422f91aadd31
F src/parse.y 16aed0e3ed05445fa7f6a4209cc054208c7083c0
-F src/pragma.c 3b4f5a800e7a2145bc1930f323232e297d4eb782
+F src/pragma.c cee60f17679210e8acd30d5bdee855716d0c898c
F src/printf.c 12e45d482ac8abcc6f786fc99e5bed7dd9a51af0
F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
F src/select.c 2fa83d6c972d3e3f379faee32e3621411490dedb
F src/shell.c c2ba26c850874964f5ec1ebf6c43406f28e44c4a
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
F src/sqlite.h.in dafa83571810b6932f089b589c783355ef7a54b5
-F src/sqliteInt.h cdcfdb5dca98359e443e23384b822a53ebd610ac
+F src/sqliteInt.h e68eb1eeba806905acc9ed491f4c5b96587020df
F src/table.c 4301926464d88d2c2c7cd21c3360aa75bf068b95
F src/tclsqlite.c ec9e5b796bf9ec1483927e986828a205d4a7422a
F src/test1.c b12b585bfb4763df3262975ed8d3f4f274b5eaed
F test/subselect.test f0fea8cf9f386d416d64d152e3c65f9116d0f50f
F test/table.test 371a1fc1c470982b2f68f9732f903a5d96f949c4
F test/tableapi.test 3c80421a889e1d106df16e5800fa787f0d2914a6
-F test/tclsqlite.test 751b358b45843f7cab569e362f2db135612b8c59
+F test/tclsqlite.test 964fd2f6c11d384ab784c2afe52130f34261ce2d
F test/temptable.test c82bd6f800f10e8cf96921af6315e5f1c21e2692
F test/tester.tcl 2671536d3650c29e7c105219f277568b0884cb58
F test/trans.test 75e7a171b5d2d94ee56766459113e2ad0e5f809d
F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
-P a4e3e075e3b36e0f5f692067c5bf5e1b660d893d
-R 2b873f18d52e7cd646dc86505cc9d590
+P 0bde7ae2ba57de554c3531f3cb7e36bf56d3b12c
+R 0a132fc8e8622ab698832e9d81c6e40c
U drh
-Z 3086609ad6b63303ab73f4ef9de88394
+Z bdf4b37b1c1e30ff9a4a67baf9818ee2
-0bde7ae2ba57de554c3531f3cb7e36bf56d3b12c
\ No newline at end of file
+5232b0665b84a9339a85918570093a376a0ea91f
\ No newline at end of file
** ROLLBACK
** PRAGMA
**
-** $Id: build.c,v 1.157 2003/07/30 12:34:12 drh Exp $
+** $Id: build.c,v 1.158 2003/08/23 22:40:54 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
void sqliteAddPrimaryKey(Parse *pParse, IdList *pList, int onError){
Table *pTab = pParse->pNewTable;
char *zType = 0;
- int iCol = -1;
+ int iCol = -1, i;
if( pTab==0 ) goto primary_key_exit;
if( pTab->hasPrimKey ){
sqliteSetString(&pParse->zErrMsg, "table \"", pTab->zName,
pTab->hasPrimKey = 1;
if( pList==0 ){
iCol = pTab->nCol - 1;
- }else if( pList->nId==1 ){
- for(iCol=0; iCol<pTab->nCol; iCol++){
- if( sqliteStrICmp(pList->a[0].zName, pTab->aCol[iCol].zName)==0 ) break;
+ pTab->aCol[iCol].isPrimKey = 1;
+ }else{
+ for(i=0; i<pList->nId; i++){
+ for(iCol=0; iCol<pTab->nCol; iCol++){
+ if( sqliteStrICmp(pList->a[0].zName, pTab->aCol[iCol].zName)==0 ) break;
+ }
+ if( iCol<pTab->nCol ) pTab->aCol[iCol].isPrimKey = 1;
}
+ if( pList->nId>1 ) iCol = -1;
}
if( iCol>=0 && iCol<pTab->nCol ){
zType = pTab->aCol[iCol].zType;
*************************************************************************
** This file contains code used to implement the PRAGMA command.
**
-** $Id: pragma.c,v 1.10 2003/06/15 23:42:24 drh Exp $
+** $Id: pragma.c,v 1.11 2003/08/23 22:40:54 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
{ OP_ColumnName, 2, 0, "type"},
{ OP_ColumnName, 3, 0, "notnull"},
{ OP_ColumnName, 4, 0, "dflt_value"},
+ { OP_ColumnName, 5, 0, "pk"},
};
int i;
sqliteVdbeAddOpList(v, ArraySize(tableInfoPreface), tableInfoPreface);
sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].notNull, 0);
sqliteVdbeAddOp(v, OP_String, 0, 0);
sqliteVdbeChangeP3(v, -1, pTab->aCol[i].zDflt, P3_STATIC);
- sqliteVdbeAddOp(v, OP_Callback, 5, 0);
+ sqliteVdbeAddOp(v, OP_Integer, pTab->aCol[i].isPrimKey, 0);
+ sqliteVdbeAddOp(v, OP_Callback, 6, 0);
}
}
}else
}
}else
+ if( sqliteStrICmp(zLeft, "foreign_key_list")==0 ){
+ FKey *pFK;
+ Table *pTab;
+ pTab = sqliteFindTable(db, zRight, 0);
+ if( pTab ){
+ v = sqliteGetVdbe(pParse);
+ pFK = pTab->pFKey;
+ }
+ if( pTab && pFK ){
+ int i = 0;
+ static VdbeOp indexListPreface[] = {
+ { OP_ColumnName, 0, 0, "id"},
+ { OP_ColumnName, 1, 0, "seq"},
+ { OP_ColumnName, 2, 0, "table"},
+ { OP_ColumnName, 3, 0, "from"},
+ { OP_ColumnName, 4, 0, "to"},
+ };
+
+ sqliteVdbeAddOpList(v, ArraySize(indexListPreface), indexListPreface);
+ while(pFK){
+ int j;
+ for(j=0; j<pFK->nCol; j++){
+ sqliteVdbeAddOp(v, OP_Integer, i, 0);
+ sqliteVdbeAddOp(v, OP_Integer, j, 0);
+ sqliteVdbeAddOp(v, OP_String, 0, 0);
+ sqliteVdbeChangeP3(v, -1, pFK->zTo, P3_STATIC);
+ sqliteVdbeAddOp(v, OP_String, 0, 0);
+ sqliteVdbeChangeP3(v, -1, pTab->aCol[pFK->aCol[j].iFrom].zName,
+ P3_STATIC);
+ sqliteVdbeAddOp(v, OP_String, 0, 0);
+ sqliteVdbeChangeP3(v, -1, pFK->aCol[j].zCol, P3_STATIC);
+ sqliteVdbeAddOp(v, OP_Callback, 5, 0);
+ }
+ ++i;
+ pFK = pFK->pNextFrom;
+ }
+ }
+ }else
+
if( sqliteStrICmp(zLeft, "database_list")==0 ){
int i;
static VdbeOp indexListPreface[] = {
sqliteVdbeAddOp(v, OP_Callback, 3, 0);
}
}else
+
+
/*
** PRAGMA temp_store
** PRAGMA temp_store = "default"|"memory"|"file"
*************************************************************************
** Internal interface definitions for SQLite.
**
-** @(#) $Id: sqliteInt.h,v 1.196 2003/08/09 21:32:28 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.197 2003/08/23 22:40:54 drh Exp $
*/
#include "config.h"
#include "sqlite.h"
char *zDflt; /* Default value of this column */
char *zType; /* Data type for this column */
u8 notNull; /* True if there is a NOT NULL constraint */
- u8 isPrimKey; /* True if this column is an INTEGER PRIMARY KEY */
+ u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */
u8 sortOrder; /* Some combination of SQLITE_SO_... values */
};
# interface is pretty well tested. This file contains some addition
# tests for fringe issues that the main test suite does not cover.
#
-# $Id: tclsqlite.test,v 1.14 2003/08/19 14:31:02 drh Exp $
+# $Id: tclsqlite.test,v 1.15 2003/08/23 22:40:54 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test tcl-2.1 {
execsql "CREATE TABLE t\u0123x(a int, b\u1235 float)"
execsql "PRAGMA table_info(t\u0123x)"
- } "0 a int 0 {} 1 b\u1235 float 0 {}"
+ } "0 a int 0 {} 0 1 b\u1235 float 0 {} 0"
do_test tcl-2.2 {
execsql "INSERT INTO t\u0123x VALUES(1,2.3)"
db eval "SELECT * FROM t\u0123x" result break
do_test tcl-2.1 {
execsql "CREATE TABLE t\251x(a int, b\306 float)"
execsql "PRAGMA table_info(t\251x)"
- } "0 a int 0 {} 1 b\306 float 0 {}"
+ } "0 a int 0 {} 0 1 b\306 float 0 {} 0"
do_test tcl-2.2 {
execsql "INSERT INTO t\251x VALUES(1,2.3)"
db eval "SELECT * FROM t\251x" result break