1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

rework the VDBE engine. NULL is now distinct from "" (CVS 49)

FossilOrigin-Name: 6ea5cebf05562de00d2cf0b9e2aac5f3857638ee
This commit is contained in:
drh
2000-06-04 12:58:36 +00:00
parent 32aa77ed6e
commit c61053b771
11 changed files with 568 additions and 341 deletions

View File

@@ -1,5 +1,5 @@
C :-)\s(CVS\s48) C rework\sthe\sVDBE\sengine.\s\sNULL\sis\snow\sdistinct\sfrom\s""\s(CVS\s49)
D 2000-06-03T19:28:49 D 2000-06-04T12:58:37
F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4 F COPYRIGHT 74a8a6531a42e124df07ab5599aad63870fa0bd4
F Makefile.in 17ba1ccf8d2d40c627796bba8f72952365d6d644 F Makefile.in 17ba1ccf8d2d40c627796bba8f72952365d6d644
F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958 F README 51f6a4e7408b34afa5bc1c0485f61b6a4efb6958
@@ -10,20 +10,20 @@ F src/build.c 15c4f3844774baa882435223119a18c33810ee94
F src/dbbe.c ae8b5d2cdb4fa7dd11313059984be9457fa77f63 F src/dbbe.c ae8b5d2cdb4fa7dd11313059984be9457fa77f63
F src/dbbe.h a8a46f71238e0f09f3ec08fd9d1c8c7f4cdc49bf F src/dbbe.h a8a46f71238e0f09f3ec08fd9d1c8c7f4cdc49bf
F src/delete.c e11433c14ed5cc8553cba14296b3baa3c23054bc F src/delete.c e11433c14ed5cc8553cba14296b3baa3c23054bc
F src/expr.c 6df33b3a42039e1eb1eb556c84a4b190a8eca8ca F src/expr.c 793c15de4ce2911fa1a74999750bd3c0c9ca513f
F src/insert.c 62951015437a96d388f43b591437d489719872fb F src/insert.c ddae33b3dea1b4e743092d04240a20def9f88b72
F src/main.c ed15e0132659ace7f44ea2dbcdd21c232af3dbd5 F src/main.c ed15e0132659ace7f44ea2dbcdd21c232af3dbd5
F src/parse.y 9ec486608b7b4daaccf4ad9f05eef1a26a008fb8 F src/parse.y 9ec486608b7b4daaccf4ad9f05eef1a26a008fb8
F src/select.c 2f4ae48deae2c5c94a89b3bc4fef2fe96c575e9f F src/select.c 2dff3d237db6588ad657bb13f19dedebc046a4eb
F src/shell.c bd658f9208bc20ce565c3f687836155772ca939a F src/shell.c d184aeae4b14d469da1fb09f7899c27367a67dc6
F src/sqlite.h 58da0a8590133777b741f9836beaef3d58f40268 F src/sqlite.h 58da0a8590133777b741f9836beaef3d58f40268
F src/sqliteInt.h 606a1614000f4e1cf208fe656bfabc5bd2957c7e F src/sqliteInt.h da9749098da8c3537175e637179ca456709aee53
F src/tclsqlite.c 10c00c460246cfba375b768c90b22bfe3c774c8f F src/tclsqlite.c 9f358618ae803bedf4fb96da5154fd45023bc1f7
F src/tokenize.c 15c229fee77325334c6814652e429b0930eba6c1 F src/tokenize.c 15c229fee77325334c6814652e429b0930eba6c1
F src/update.c 3f05d5082fd2c34f15d1e4a4db17355ad8807a78 F src/update.c 3f05d5082fd2c34f15d1e4a4db17355ad8807a78
F src/util.c c22846f23b9311ca0e68f076686493bac7b20d5d F src/util.c a06e8379665b18539cd9400641f3581d925f337e
F src/vdbe.c a584da66af8b44b0236bece378c4dc8ef333f814 F src/vdbe.c 35e1c8fce3e5a5e59f493b1fe9a4f6f6a3205585
F src/vdbe.h ab574c91c6328c5795f68b84074fbcf860eae70e F src/vdbe.h f20a3140905c385237e0891122beccde779c78c7
F src/where.c bed9a8360cbfbf712bdc397c8e22216a5e5f9800 F src/where.c bed9a8360cbfbf712bdc397c8e22216a5e5f9800
F test/all.test 0950c135cab7e60c07bd745ccfad1476211e5bd7 F test/all.test 0950c135cab7e60c07bd745ccfad1476211e5bd7
F test/copy.test 6b218a41dc6469491049b50ee105f76282f2547d F test/copy.test 6b218a41dc6469491049b50ee105f76282f2547d
@@ -47,7 +47,7 @@ F www/c_interface.tcl 8867d76ddd416d2fbd41e4cb3de8efa9cef105a5
F www/changes.tcl 567cc6066d87460bdedff8e5bbc20f41ddaadf77 F www/changes.tcl 567cc6066d87460bdedff8e5bbc20f41ddaadf77
F www/index.tcl f8189a7898f6d06307c34047b9d7e00860026e44 F www/index.tcl f8189a7898f6d06307c34047b9d7e00860026e44
F www/sqlite.tcl 2f933ce18cffd34a0a020a82435ab937137970fd F www/sqlite.tcl 2f933ce18cffd34a0a020a82435ab937137970fd
P 729d6586b8377d0e6cefa64c8cf3d883e9f0ddc3 P f76656416500851069633cc603905befa27cca66
R 31c9e39e649b3b2d917f87f2b14771de R dca222cd1ac9b9199dff323c95ec2e9d
U drh U drh
Z 40d2fc5da1772ef64d963d97198b5963 Z 114e443f09135bb7212679d2a361e0f5

View File

@@ -1 +1 @@
f76656416500851069633cc603905befa27cca66 6ea5cebf05562de00d2cf0b9e2aac5f3857638ee

View File

@@ -23,7 +23,7 @@
************************************************************************* *************************************************************************
** This file contains C code routines used for processing expressions ** This file contains C code routines used for processing expressions
** **
** $Id: expr.c,v 1.4 2000/06/03 19:19:41 drh Exp $ ** $Id: expr.c,v 1.5 2000/06/04 12:58:37 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -324,7 +324,7 @@ void sqliteExprCode(Parse *pParse, Expr *pExpr){
break; break;
} }
case TK_NULL: { case TK_NULL: {
sqliteVdbeAddOp(v, OP_String, 0, 0, "", 0); sqliteVdbeAddOp(v, OP_Null, 0, 0, 0, 0);
break; break;
} }
case TK_AND: case TK_AND:

View File

@@ -24,7 +24,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle INSERT statements. ** to handle INSERT statements.
** **
** $Id: insert.c,v 1.4 2000/06/03 18:06:53 drh Exp $ ** $Id: insert.c,v 1.5 2000/06/04 12:58:38 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -122,8 +122,11 @@ void sqliteInsert(
} }
if( pField && j>=pField->nId ){ if( pField && j>=pField->nId ){
char *zDflt = pTab->aCol[i].zDflt; char *zDflt = pTab->aCol[i].zDflt;
if( zDflt==0 ) zDflt = ""; if( zDflt==0 ){
sqliteVdbeAddOp(v, OP_Null, 0, 0, 0, 0);
}else{
sqliteVdbeAddOp(v, OP_String, 0, 0, zDflt, 0); sqliteVdbeAddOp(v, OP_String, 0, 0, zDflt, 0);
}
}else{ }else{
sqliteExprCode(pParse, pList->a[j].pExpr); sqliteExprCode(pParse, pList->a[j].pExpr);
} }
@@ -146,8 +149,11 @@ void sqliteInsert(
} }
if( pField && j>=pField->nId ){ if( pField && j>=pField->nId ){
char *zDflt = pTab->aCol[idx].zDflt; char *zDflt = pTab->aCol[idx].zDflt;
if( zDflt==0 ) zDflt = ""; if( zDflt==0 ){
sqliteVdbeAddOp(v, OP_Null, 0, 0, 0, 0);
}else{
sqliteVdbeAddOp(v, OP_String, 0, 0, zDflt, 0); sqliteVdbeAddOp(v, OP_String, 0, 0, zDflt, 0);
}
}else{ }else{
sqliteExprCode(pParse, pList->a[j].pExpr); sqliteExprCode(pParse, pList->a[j].pExpr);
} }

View File

@@ -24,7 +24,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle SELECT statements. ** to handle SELECT statements.
** **
** $Id: select.c,v 1.5 2000/06/03 18:06:53 drh Exp $ ** $Id: select.c,v 1.6 2000/06/04 12:58:38 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -183,7 +183,7 @@ void sqliteSelect(
switch( sqliteFuncId(&p->token) ){ switch( sqliteFuncId(&p->token) ){
case FN_Min: case FN_Min:
case FN_Max: { case FN_Max: {
sqliteVdbeAddOp(v, OP_String, 0, 0, "", 0); sqliteVdbeAddOp(v, OP_Null, 0, 0, 0, 0);
break; break;
} }
default: { default: {
@@ -251,6 +251,7 @@ void sqliteSelect(
} }
if( id!=FN_Count && p->pList && p->pList->nExpr>=1 ){ if( id!=FN_Count && p->pList && p->pList->nExpr>=1 ){
sqliteExprCode(pParse, p->pList->a[0].pExpr); sqliteExprCode(pParse, p->pList->a[0].pExpr);
sqliteVdbeAddOp(v, OP_Concat, 1, 0, 0, 0);
} }
switch( sqliteFuncId(&p->token) ){ switch( sqliteFuncId(&p->token) ){
case FN_Count: op = OP_AddImm; p1 = 1; break; case FN_Count: op = OP_AddImm; p1 = 1; break;

View File

@@ -24,7 +24,7 @@
** This file contains code to implement the "sqlite" command line ** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases. ** utility for accessing SQLite databases.
** **
** $Id: shell.c,v 1.6 2000/06/02 13:27:59 drh Exp $ ** $Id: shell.c,v 1.7 2000/06/04 12:58:38 drh Exp $
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -154,7 +154,7 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){
case MODE_Line: { case MODE_Line: {
if( p->cnt++>0 ) fprintf(p->out,"\n"); if( p->cnt++>0 ) fprintf(p->out,"\n");
for(i=0; i<nArg; i++){ for(i=0; i<nArg; i++){
fprintf(p->out,"%s = %s\n", azCol[i], azArg[i]); fprintf(p->out,"%s = %s\n", azCol[i], azArg[i] ? azArg[i] : 0);
} }
break; break;
} }
@@ -188,7 +188,8 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){
}else{ }else{
w = 10; w = 10;
} }
fprintf(p->out,"%-*.*s%s",w,w,azArg[i], i==nArg-1 ? "\n": " "); fprintf(p->out,"%-*.*s%s",w,w,
azArg[i] ? azArg[i] : "", i==nArg-1 ? "\n": " ");
} }
break; break;
} }
@@ -199,7 +200,8 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){
} }
} }
for(i=0; i<nArg; i++){ for(i=0; i<nArg; i++){
fprintf(p->out,"%s%s",azArg[i], i==nArg-1 ? "\n" : p->separator); fprintf(p->out,"%s%s",azArg[i] ? azArg[i] : "",
i==nArg-1 ? "\n" : p->separator);
} }
break; break;
} }
@@ -214,7 +216,7 @@ static int callback(void *pArg, int nArg, char **azArg, char **azCol){
for(i=0; i<nArg; i++){ for(i=0; i<nArg; i++){
fprintf(p->out,"<TR>"); fprintf(p->out,"<TR>");
for(i=0; i<nArg; i++){ for(i=0; i<nArg; i++){
fprintf(p->out,"<TD>%s</TD>",azArg[i]); fprintf(p->out,"<TD>%s</TD>",azArg[i] ? azArg[i] : "");
} }
fprintf(p->out,"</TD>\n"); fprintf(p->out,"</TD>\n");
} }

View File

@@ -23,7 +23,7 @@
************************************************************************* *************************************************************************
** Internal interface definitions for SQLite. ** Internal interface definitions for SQLite.
** **
** @(#) $Id: sqliteInt.h,v 1.11 2000/06/03 18:06:53 drh Exp $ ** @(#) $Id: sqliteInt.h,v 1.12 2000/06/04 12:58:38 drh Exp $
*/ */
#include "sqlite.h" #include "sqlite.h"
#include "dbbe.h" #include "dbbe.h"
@@ -35,7 +35,7 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
/* #define MEMORY_DEBUG 2 */ #define MEMORY_DEBUG 1
#ifdef MEMORY_DEBUG #ifdef MEMORY_DEBUG
# define sqliteMalloc(X) sqliteMalloc_(X,__FILE__,__LINE__) # define sqliteMalloc(X) sqliteMalloc_(X,__FILE__,__LINE__)
# define sqliteFree(X) sqliteFree_(X,__FILE__,__LINE__) # define sqliteFree(X) sqliteFree_(X,__FILE__,__LINE__)

View File

@@ -23,7 +23,7 @@
************************************************************************* *************************************************************************
** A TCL Interface to SQLite ** A TCL Interface to SQLite
** **
** $Id: tclsqlite.c,v 1.4 2000/06/02 01:17:38 drh Exp $ ** $Id: tclsqlite.c,v 1.5 2000/06/04 12:58:38 drh Exp $
*/ */
#include "sqlite.h" #include "sqlite.h"
#include <tcl.h> #include <tcl.h>
@@ -61,11 +61,15 @@ static int DbEvalCallback(
} }
} }
for(i=0; i<nCol; i++){ for(i=0; i<nCol; i++){
Tcl_SetVar2(cbData->interp, cbData->zArray, azN[i], azCol[i], 0); char *z = azCol[i];
if( z==0 ) z = "";
Tcl_SetVar2(cbData->interp, cbData->zArray, azN[i], z, 0);
} }
}else{ }else{
for(i=0; i<nCol; i++){ for(i=0; i<nCol; i++){
Tcl_SetVar(cbData->interp, azN[i], azCol[i], 0); char *z = azCol[i];
if( z==0 ) z = "";
Tcl_SetVar(cbData->interp, azN[i], z, 0);
} }
} }
cbData->once = 0; cbData->once = 0;
@@ -283,9 +287,9 @@ int TCLSH_MAIN(int argc, char **argv){
TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT | TCL_APPEND_VALUE); TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT | TCL_APPEND_VALUE);
} }
if( Tcl_EvalFile(interp, argv[1])!=TCL_OK ){ if( Tcl_EvalFile(interp, argv[1])!=TCL_OK ){
fprintf(stderr,"%s: %s\n", *argv, char *zInfo = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);
Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY) if( zInfo==0 ) zInfo = interp->result;
); fprintf(stderr,"%s: %s\n", *argv, zInfo);
return 1; return 1;
} }
}else{ }else{

View File

@@ -26,7 +26,7 @@
** This file contains functions for allocating memory, comparing ** This file contains functions for allocating memory, comparing
** strings, and stuff like that. ** strings, and stuff like that.
** **
** $Id: util.c,v 1.9 2000/06/02 13:28:00 drh Exp $ ** $Id: util.c,v 1.10 2000/06/04 12:58:38 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <stdarg.h> #include <stdarg.h>
@@ -632,6 +632,7 @@ int sqliteGlobCompare(const char *zPattern, const char *zString){
}else{ }else{
while( (c2 = *zString)!=0 ){ while( (c2 = *zString)!=0 ){
while( c2 != 0 && c2 != c ){ c2 = *++zString; } while( c2 != 0 && c2 != c ){ c2 = *++zString; }
if( c2==0 ) return 0;
if( sqliteGlobCompare(&zPattern[1],zString) ) return 1; if( sqliteGlobCompare(&zPattern[1],zString) ) return 1;
zString++; zString++;
} }
@@ -699,6 +700,7 @@ sqliteLikeCompare(const unsigned char *zPattern, const unsigned char *zString){
}else{ }else{
while( (c2 = UpperToLower[*zString])!=0 ){ while( (c2 = UpperToLower[*zString])!=0 ){
while( c2 != 0 && c2 != c ){ c2 = UpperToLower[*++zString]; } while( c2 != 0 && c2 != c ){ c2 = UpperToLower[*++zString]; }
if( c2==0 ) return 0;
if( sqliteLikeCompare(&zPattern[1],zString) ) return 1; if( sqliteLikeCompare(&zPattern[1],zString) ) return 1;
zString++; zString++;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -27,7 +27,7 @@
** or VDBE. The VDBE implements an abstract machine that runs a ** or VDBE. The VDBE implements an abstract machine that runs a
** simple program to access and modify the underlying database. ** simple program to access and modify the underlying database.
** **
** $Id: vdbe.h,v 1.4 2000/05/31 20:00:53 drh Exp $ ** $Id: vdbe.h,v 1.5 2000/06/04 12:58:39 drh Exp $
*/ */
#ifndef _SQLITE_VDBE_H_ #ifndef _SQLITE_VDBE_H_
#define _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_
@@ -125,35 +125,36 @@ typedef struct VdbeOp VdbeOp;
#define OP_Integer 44 #define OP_Integer 44
#define OP_String 45 #define OP_String 45
#define OP_Pop 46 #define OP_Null 46
#define OP_Dup 47 #define OP_Pop 47
#define OP_Pull 48 #define OP_Dup 48
#define OP_Pull 49
#define OP_Add 49 #define OP_Add 50
#define OP_AddImm 50 #define OP_AddImm 51
#define OP_Subtract 51 #define OP_Subtract 52
#define OP_Multiply 52 #define OP_Multiply 53
#define OP_Divide 53 #define OP_Divide 54
#define OP_Min 54 #define OP_Min 55
#define OP_Max 55 #define OP_Max 56
#define OP_Like 56 #define OP_Like 57
#define OP_Glob 57 #define OP_Glob 58
#define OP_Eq 58 #define OP_Eq 59
#define OP_Ne 59 #define OP_Ne 60
#define OP_Lt 60 #define OP_Lt 61
#define OP_Le 61 #define OP_Le 62
#define OP_Gt 62 #define OP_Gt 63
#define OP_Ge 63 #define OP_Ge 64
#define OP_IsNull 64 #define OP_IsNull 65
#define OP_NotNull 65 #define OP_NotNull 66
#define OP_Negative 66 #define OP_Negative 67
#define OP_And 67 #define OP_And 68
#define OP_Or 68 #define OP_Or 69
#define OP_Not 69 #define OP_Not 70
#define OP_Concat 70 #define OP_Concat 71
#define OP_Noop 71 #define OP_Noop 72
#define OP_MAX 71 #define OP_MAX 72
/* /*
** Prototypes for the VDBE interface. See comments on the implementation ** Prototypes for the VDBE interface. See comments on the implementation