Comment changes. Change the use of BTree so that either the key is

an integer or the data is empty. (CVS 337)

FossilOrigin-Name: 18e606f7486eb3a4ab128504d88a44f53d39e5b2
This commit is contained in:
drh 2001-12-31 02:48:51 +00:00
parent f7f07c7aef
commit c839258651
7 changed files with 48 additions and 37 deletions

View File

@ -1,5 +1,5 @@
C Version\s2.2.0\s(CVS\s453)
D 2001-12-22T22:00:00
C Comment\schanges.\s\sChange\sthe\suse\sof\sBTree\sso\sthat\seither\sthe\skey\sis\nan\sinteger\sor\sthe\sdata\sis\sempty.\s(CVS\s337)
D 2001-12-31T02:48:51
F Makefile.in 352fed589f09dd94347e0bb391d047118ebd6105
F Makefile.template c88ffcb9c339e718f434d0c7f045bcd7eea125af
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
@ -26,7 +26,7 @@ F src/delete.c f7690efc09ad6a2f1f3f0490e1b0cbb676bb95cf
F src/expr.c ef1c365c5d558fa691878830501d3c36ed7edb25
F src/hash.c 6f1a7712ae3aac8351662969aec5693740a2fbf7
F src/hash.h a5f5b3ce2d086a172c5879b0b06a27a82eac9fac
F src/insert.c 78c11efb6464ab01548f9b4c92b51cb30e3a7a3c
F src/insert.c 74e249cf3c0e7da634eb115edeef77b42ec1d947
F src/main.c 00a9f5603e130fc0b1a05f731731c9c99ebdc2dc
F src/md5.c 52f677bfc590e09f71d07d7e327bd59da738d07c
F src/os.c 07882cde5c61f26751b8ee76fd84726c1f7e453c
@ -36,20 +36,20 @@ F src/pager.h f78d064c780855ff70beacbeba0e2324471b26fe
F src/parse.y f050644e7a2586227686e8c1709aa2662b9bcf9c
F src/printf.c 300a90554345751f26e1fc0c0333b90a66110a1d
F src/random.c 2a9cc2c9716d14815fd4c2accf89d87a1143e46b
F src/select.c bb7bf8d6e6154269145158952e041755cc4d9873
F src/select.c 79120c805dc61513bc5902baa39991896718c5c4
F src/shell.c 407095aaeeae78f42deb3e846b1ad77f8ed3b4ef
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
F src/sqlite.h.in a4c11d38d62b1bfbd50a5804edee8ca54c1adc9b
F src/sqliteInt.h 0b1e8ba2738440e2f06a4e01bb89230492bc203b
F src/sqliteInt.h d2bfc012fb2c91652d67401e5d7a646a0c30a675
F src/table.c c89698bd5bb4b8d14722d6ee7e9be014c383d24a
F src/tclsqlite.c b82e4faeae89fdb7304b3c970979ade299336a1f
F src/test1.c 41eabe255970ef947263b94145c9b2766bab8675
F src/test2.c e9f99aa5ee73872819259d6612c11e55e1644321
F src/test3.c d6775f95fd91f5b3cf0e2382a28e5aaeb68f745b
F src/tokenize.c 830e9ef684334070a26583d94770bb869e2727bf
F src/update.c 6a77d1459d2e829fd9dd244ce8b5ada7ac485317
F src/update.c f9f48e78c13c79e32a55840414bea84479f9848d
F src/util.c 8e9ca72d8288cae39c57c6f397abd14a56b14a38
F src/vdbe.c f97e2d5bc6db936a2d001e0a1a94102e99ece821
F src/vdbe.c b00fbd59e4a3264a2eec4dc7103c2cf52e9e49b0
F src/vdbe.h e5cc6fb13d1905a4339db4d6dba4ab393c0765fa
F src/where.c 178a908a40cc6d72150a747db69638a97bd86487
F test/all.test 2a51e5395ac7c2c539689b123b9782a05e3837fe
@ -119,7 +119,7 @@ F www/speed.tcl 83457b2bf6bb430900bd48ca3dd98264d9a916a5
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
F www/tclsqlite.tcl 880ef67cb4f2797b95bf1368fc4e0d8ca0fda956
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
P a26d0880b20ca5534400a3689d1da31fe6aaa934
R ca7de0eadaa033a7f4b8aa20c781d7ab
P 6bb62d8fab621b79b2fd1601669b1d4c8a547774
R c0cff954d526606a2c04afff4a5fc733
U drh
Z c050baa80c96802f9a0e4328455fadff
Z 124639b155da23bf7001c10245c441bd

View File

@ -1 +1 @@
6bb62d8fab621b79b2fd1601669b1d4c8a547774
18e606f7486eb3a4ab128504d88a44f53d39e5b2

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle INSERT statements in SQLite.
**
** $Id: insert.c,v 1.29 2001/12/22 21:48:30 drh Exp $
** $Id: insert.c,v 1.30 2001/12/31 02:48:51 drh Exp $
*/
#include "sqliteInt.h"
@ -132,6 +132,13 @@ void sqliteInsert(
/* If the INSERT statement included an IDLIST term, then make sure
** all elements of the IDLIST really are columns of the table and
** remember the column indices.
**
** If the table has an INTEGER PRIMARY KEY column and that column
** is named in the IDLIST, then record in the keyColumn variable
** the index into IDLIST of the primary key column. keyColumn is
** the index of the primary key as it appears in IDLIST, not as
** is appears in the original table. (The index of the primary
** key in the original table is pTab->iPKey.)
*/
if( pColumn ){
for(i=0; i<pColumn->nId; i++){
@ -157,7 +164,8 @@ void sqliteInsert(
}
/* If there is not IDLIST term but the table has an integer primary
** key, the set the keyColumn variable to the primary key column.
** key, the set the keyColumn variable to the primary key column index
** in the original table definition.
*/
if( pColumn==0 ){
keyColumn = pTab->iPKey;
@ -205,7 +213,7 @@ void sqliteInsert(
sqliteVdbeAddOp(v, OP_NewRecno, base, 0);
}
/* If there are indices, we'll need this record number again, so make
/* If there are indices, we'll need the new record number again, so make
** a copy.
*/
if( pTab->pIndex ){
@ -219,7 +227,7 @@ void sqliteInsert(
if( i==pTab->iPKey ){
/* The value of the INTEGER PRIMARY KEY column is always a NULL.
** Whenever this column is used, the record number will be substituted
** in its place, so there is no point it it taking up space in
** in its place, so there is no point in it taking up space in
** the data record. */
sqliteVdbeAddOp(v, OP_String, 0, 0);
continue;

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.51 2001/12/22 14:49:25 drh Exp $
** $Id: select.c,v 1.52 2001/12/31 02:48:51 drh Exp $
*/
#include "sqliteInt.h"
@ -130,7 +130,6 @@ static int selectInnerLoop(
sqliteVdbeAddOp(v, OP_Goto, 0, iContinue);
sqliteVdbeResolveLabel(v, lbl);
sqliteVdbeAddOp(v, OP_String, 0, 0);
sqliteVdbeChangeP3(v, -1, "", P3_STATIC);
sqliteVdbeAddOp(v, OP_Put, distinct, 0);
}
@ -159,7 +158,6 @@ static int selectInnerLoop(
if( eDest==SRT_Union ){
sqliteVdbeAddOp(v, OP_MakeRecord, nColumn, 0);
sqliteVdbeAddOp(v, OP_String, iParm, 0);
sqliteVdbeChangeP3(v, -1, "", P3_STATIC);
sqliteVdbeAddOp(v, OP_Put, iParm, 0);
}else
@ -189,7 +187,6 @@ static int selectInnerLoop(
if( eDest==SRT_Set ){
assert( nColumn==1 );
sqliteVdbeAddOp(v, OP_String, 0, 0);
sqliteVdbeChangeP3(v, -1, "", P3_STATIC);
sqliteVdbeAddOp(v, OP_Put, iParm, 0);
}else
@ -909,7 +906,6 @@ int sqliteSelect(
sqliteVdbeAddOp(v, OP_AggReset, 0, pParse->nAgg);
if( pGroupBy==0 ){
sqliteVdbeAddOp(v, OP_String, 0, 0);
sqliteVdbeChangeP3(v, -1, "", P3_STATIC);
sqliteVdbeAddOp(v, OP_AggFocus, 0, 0);
for(i=0; i<pParse->nAgg; i++){
Expr *pE;

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.73 2001/12/21 14:30:43 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.74 2001/12/31 02:48:51 drh Exp $
*/
#include "sqlite.h"
#include "hash.h"
@ -230,7 +230,7 @@ struct Table {
char *zName; /* Name of the table */
int nCol; /* Number of columns in this table */
Column *aCol; /* Information about each column */
int iPKey; /* Use this column as the record-number for each row */
int iPKey; /* If not less then 0, use aCol[iPKey] as the primary key */
Index *pIndex; /* List of SQL indexes on this table. */
int tnum; /* Page containing root for this table */
u8 readOnly; /* True if this table should not be written by the user */

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle UPDATE statements.
**
** $Id: update.c,v 1.24 2001/12/22 14:49:25 drh Exp $
** $Id: update.c,v 1.25 2001/12/31 02:48:51 drh Exp $
*/
#include "sqliteInt.h"
@ -49,7 +49,7 @@ void sqliteUpdate(
/* Locate the table which we want to update. This table has to be
** put in an IdList structure because some of the subroutines we
** will be calling are designed to work with multiple tables and expect
** an IdList* parameter instead of just a Table* parameger.
** an IdList* parameter instead of just a Table* parameter.
*/
pTabList = sqliteIdListAppend(0, pTableName);
if( pTabList==0 ) goto update_cleanup;
@ -119,7 +119,8 @@ void sqliteUpdate(
/* Allocate memory for the array apIdx[] and fill it with pointers to every
** index that needs to be updated. Indices only need updating if their
** key includes one of the columns named in pChanges.
** key includes one of the columns named in pChanges or if the record
** number of the original table entry is changing.
*/
for(nIdx=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
if( chngRecno ){
@ -203,7 +204,12 @@ void sqliteUpdate(
sqliteVdbeAddOp(v, OP_Dup, 0, 0);
pIdx = apIdx[i];
for(j=0; j<pIdx->nColumn; j++){
sqliteVdbeAddOp(v, OP_Column, base, pIdx->aiColumn[j]);
int x = pIdx->aiColumn[j];
if( x==pTab->iPKey ){
sqliteVdbeAddOp(v, OP_Dup, j, 0);
}else{
sqliteVdbeAddOp(v, OP_Column, base, x);
}
}
sqliteVdbeAddOp(v, OP_MakeIdxKey, pIdx->nColumn, 0);
sqliteVdbeAddOp(v, OP_IdxDelete, base+i+1, 0);
@ -233,7 +239,7 @@ void sqliteUpdate(
}
}
/* If changing the record number, delete the hold record.
/* If changing the record number, delete the old record.
*/
if( chngRecno ){
sqliteVdbeAddOp(v, OP_Delete, 0, 0);

View File

@ -30,7 +30,7 @@
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
** $Id: vdbe.c,v 1.102 2001/12/22 14:49:25 drh Exp $
** $Id: vdbe.c,v 1.103 2001/12/31 02:48:51 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@ -56,11 +56,11 @@ typedef struct VdbeOp Op;
typedef unsigned char Bool;
/*
** A cursor is a pointer into a database file. The database file
** can represent either an SQL table or an SQL index. Each file is
** a bag of key/data pairs. The cursor can loop over all key/data
** pairs (in an arbitrary order) or it can retrieve a particular
** key/data pair given a copy of the key.
** A cursor is a pointer into a single BTree within a database file.
** The cursor can seek to a BTree entry with a particular key, or
** loop over all entries of the Btree. You can also insert new BTree
** entries or retrieve the key or data from the entry that the cursor
** is currently pointing to.
**
** Every cursor that the virtual machine has open is represented by an
** instance of the following structure.
@ -98,7 +98,7 @@ struct Sorter {
** layer without having to malloc. NBFS is short for Number of Bytes
** For Strings.
*/
#define NBFS 30
#define NBFS 32
/*
** A single level of the stack is an instance of the following
@ -170,8 +170,8 @@ struct Set {
/*
** A Keylist is a bunch of keys into a table. The keylist can
** grow without bound. The keylist stores the keys of database
** records that need to be deleted.
** grow without bound. The keylist stores the ROWIDs of database
** records that need to be deleted or updated.
*/
typedef struct Keylist Keylist;
struct Keylist {
@ -394,7 +394,7 @@ void sqliteVdbeChangeP1(Vdbe *p, int addr, int val){
** first null byte. If n>0 then copy n+1 bytes of zP3.
**
** If n==P3_STATIC it means that zP3 is a pointer to a constant static
** string we can just copy the pointer. n==P3_POINTER means zP3 is
** string and we can just copy the pointer. n==P3_POINTER means zP3 is
** a pointer to some object other than a string.
**
** If addr<0 then change P3 on the most recently inserted instruction.
@ -1177,6 +1177,7 @@ case OP_String: {
z = pOp->p3;
if( z==0 ){
zStack[i] = 0;
aStack[i].n = 0;
aStack[i].flags = STK_Null;
}else{
zStack[i] = z;