Begin using sqlite3NestedParse() to generate sections of code. (CVS 2059)
FossilOrigin-Name: 2d302931a69d1add1dae9f820133872b4fefe93e
This commit is contained in:
parent
a64a035f7e
commit
f197484617
20
manifest
20
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sbug\sintroduced\swith\s(2057).\s(CVS\s2058)
|
||||
D 2004-11-05T01:45:14
|
||||
C Begin\susing\ssqlite3NestedParse()\sto\sgenerate\ssections\sof\scode.\s(CVS\s2059)
|
||||
D 2004-11-05T03:56:01
|
||||
F Makefile.in c4d2416860f472a1e3393714d0372074197565df
|
||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
|
||||
@ -29,9 +29,9 @@ F sqlite3.def dbaeb20c153e1d366e8f421b55a573f5dfc00863
|
||||
F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
|
||||
F src/attach.c e49d09dad9f5f9fb10b4b0c1be5a70ae4c45e689
|
||||
F src/auth.c 3b81f2a42f48a62c2c9c9b0eda31a157c681edea
|
||||
F src/btree.c 832ea4553803ff18e6cfc299cb5bf266d3f100aa
|
||||
F src/btree.c f97b5a3919147fe36f776d08c80212ba3ea883aa
|
||||
F src/btree.h 3166388fa58c5594d8064d38b43440d79da38fb6
|
||||
F src/build.c 6e00bcc31c003dc0bf783f777aae7698fdad219a
|
||||
F src/build.c b18a5c7cc68fe77fd6cc30f6bbeefc3ece909108
|
||||
F src/date.c 34bdb0082db7ec2a83ef00063f7b44e61ee19dad
|
||||
F src/delete.c 832adc6fe1c07b7e28e1b4c1038d2b06f7397dd4
|
||||
F src/expr.c 3a43e508a3dc213703808bbcbb17633b88b57d17
|
||||
@ -61,7 +61,7 @@ F src/random.c eff68e3f257e05e81eae6c4d50a51eb88beb4ff3
|
||||
F src/select.c 156990c636102bb6b8de85e7ff3396a62568476b
|
||||
F src/shell.c 55adda3cf3c1cc2f6c1919aac17b2318f9c2a96f
|
||||
F src/sqlite.h.in 4f97b5907acfd2a5068cb0cec9d5178816734db7
|
||||
F src/sqliteInt.h 126ec1947a91438a388112f3d282f625f7f73a0a
|
||||
F src/sqliteInt.h 83d4ad5c75b50bad5c7c1573827231c148335ae6
|
||||
F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9
|
||||
F src/tclsqlite.c 0302e3f42f015d132d1291f3388c06e86c24a008
|
||||
F src/test1.c df1d1ca2c40cafefb9a29860f072c4d0fee1a7b5
|
||||
@ -84,7 +84,7 @@ F src/vdbemem.c ef9ac7d32acfe4bce5c5b408b1294c8d9e0cdb56
|
||||
F src/where.c 6e637a6b3e61fe3104adc4e5caa4738bf6570daa
|
||||
F test/all.test 929bfa932b55e75c96fe2203f7650ba451c1862c
|
||||
F test/attach.test e305dd59a375e37c658c6d401f19f8a95880bf9a
|
||||
F test/attach2.test f7795123d3051ace1672b6d23973da6435de3745
|
||||
F test/attach2.test 48a802ed9c009bcc36ad62646680a55c18403b3e
|
||||
F test/attach3.test 742c932d7130e0e699a5d9f265cb831e0a824633
|
||||
F test/auth.test 1cc252d9e7b3bdc1314199cbf3a0d3c5ed026c21
|
||||
F test/autovacuum.test a5b11269daac313bea6694b04473fdd0e16e439a
|
||||
@ -252,7 +252,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
|
||||
F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
|
||||
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
|
||||
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
|
||||
P b0c103340ad27533d3e5b2f1b18557fd9c8b55df
|
||||
R 03fae3dd272be36dc35894b6aa50fefb
|
||||
U danielk1977
|
||||
Z 809037e96143592365a1e575bfe4ff28
|
||||
P aed2e623ec9c4044696dc2d6f7f4c53216b45479
|
||||
R f11ae296f2dfdf96c95c6e6b63836396
|
||||
U drh
|
||||
Z 443581b69da31601ae9d30cf00bb19d1
|
||||
|
@ -1 +1 @@
|
||||
aed2e623ec9c4044696dc2d6f7f4c53216b45479
|
||||
2d302931a69d1add1dae9f820133872b4fefe93e
|
10
src/btree.c
10
src/btree.c
@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.206 2004/11/05 01:45:14 danielk1977 Exp $
|
||||
** $Id: btree.c,v 1.207 2004/11/05 03:56:01 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@ -3392,14 +3392,6 @@ static void assemblePage(
|
||||
pPage->nCell = nCell;
|
||||
}
|
||||
|
||||
/*
|
||||
** GCC does not define the offsetof() macro so we'll have to do it
|
||||
** ourselves.
|
||||
*/
|
||||
#ifndef offsetof
|
||||
#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))
|
||||
#endif
|
||||
|
||||
/*
|
||||
** The following parameters determine how many adjacent pages get involved
|
||||
** in a balancing operation. NN is the number of neighbors on either side
|
||||
|
54
src/build.c
54
src/build.c
@ -23,7 +23,11 @@
|
||||
** ROLLBACK
|
||||
** PRAGMA
|
||||
**
|
||||
** $Id: build.c,v 1.262 2004/11/05 01:24:13 danielk1977 Exp $
|
||||
<<<<<<< build.c
|
||||
** $Id: build.c,v 1.263 2004/11/05 03:56:02 drh Exp $
|
||||
=======
|
||||
** $Id: build.c,v 1.263 2004/11/05 03:56:02 drh Exp $
|
||||
>>>>>>> 1.262
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@ -123,22 +127,26 @@ void sqlite3FinishCoding(Parse *pParse){
|
||||
**
|
||||
** Not everything is nestable. This facility is designed to permit
|
||||
** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER. Use
|
||||
** care if you decide to try to use this routine for some other purpose.
|
||||
** care if you decide to try to use this routine for some other purposes.
|
||||
*/
|
||||
void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
|
||||
va_list ap;
|
||||
char *zSql;
|
||||
int rc;
|
||||
Parse savedState;
|
||||
# define SAVE_SZ (sizeof(Parse) - offsetof(Parse,nVar))
|
||||
char saveBuf[SAVE_SZ];
|
||||
|
||||
if( pParse->nErr ) return;
|
||||
assert( pParse->nested<10 ); /* Nesting should only be of limited depth */
|
||||
va_start(ap, zFormat);
|
||||
zSql = sqlite3VMPrintf(zFormat, ap);
|
||||
va_end(ap);
|
||||
pParse->nested++;
|
||||
savedState = *pParse;
|
||||
memcpy(saveBuf, &pParse->nVar, SAVE_SZ);
|
||||
memset(&pParse->nVar, 0, SAVE_SZ);
|
||||
rc = sqlite3RunParser(pParse, zSql, 0);
|
||||
sqliteFree(zSql);
|
||||
memcpy(&pParse->nVar, saveBuf, SAVE_SZ);
|
||||
pParse->nested--;
|
||||
}
|
||||
|
||||
@ -573,7 +581,8 @@ int sqlite3TwoPartName(
|
||||
** is reserved for internal use.
|
||||
*/
|
||||
int sqlite3CheckObjectName(Parse *pParse, const char *zName){
|
||||
if( !pParse->db->init.busy && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
|
||||
if( !pParse->db->init.busy && pParse->nested==0
|
||||
&& 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
|
||||
sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName);
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
@ -1636,7 +1645,7 @@ static void destroyRootPage(Vdbe *v, int iTable, int iDb){
|
||||
** reflect this. It is assumed that cursor number 0 is a write-cursor
|
||||
** opened on the sqlite_master table.
|
||||
*/
|
||||
static const VdbeOpList updateMaster[] = {
|
||||
static /*const*/ VdbeOpList updateMaster[] = {
|
||||
/* If the Op_Destroy pushed a 0 onto the stack, then skip the following
|
||||
** code. sqlite_master does not need updating in this case.
|
||||
*/
|
||||
@ -1668,7 +1677,7 @@ static void destroyRootPage(Vdbe *v, int iTable, int iDb){
|
||||
#endif
|
||||
|
||||
sqlite3VdbeAddOp(v, OP_Destroy, iTable, iDb);
|
||||
sqlite3VdbeAddOp(v, OP_Pop, 1, 0);
|
||||
/* sqlite3VdbeAddOp(v, OP_Pop, 1, 0); */
|
||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||
base = sqlite3VdbeAddOpList(v, ArraySize(updateMaster), updateMaster);
|
||||
sqlite3VdbeChangeP1(v, base+13, iTable);
|
||||
@ -1735,7 +1744,6 @@ static void destroyTable(Vdbe *v, Table *pTab){
|
||||
void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView){
|
||||
Table *pTab;
|
||||
Vdbe *v;
|
||||
int base;
|
||||
sqlite3 *db = pParse->db;
|
||||
int iDb;
|
||||
|
||||
@ -1794,22 +1802,6 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView){
|
||||
*/
|
||||
v = sqlite3GetVdbe(pParse);
|
||||
if( v ){
|
||||
static const VdbeOpList dropTable[] = {
|
||||
{ OP_Rewind, 0, ADDR(13), 0},
|
||||
{ OP_String8, 0, 0, 0}, /* 1 */
|
||||
{ OP_MemStore, 1, 1, 0},
|
||||
{ OP_MemLoad, 1, 0, 0}, /* 3 */
|
||||
{ OP_Column, 0, 2, 0}, /* sqlite_master.tbl_name */
|
||||
{ OP_Ne, 0, ADDR(12), 0},
|
||||
{ OP_String8, 0, 0, "trigger"},
|
||||
{ OP_Column, 0, 2, 0}, /* sqlite_master.type */
|
||||
{ OP_Eq, 0, ADDR(12), 0},
|
||||
{ OP_Delete, 0, 0, 0},
|
||||
{ OP_Rewind, 0, ADDR(13), 0},
|
||||
{ OP_Goto, 0, ADDR(3), 0},
|
||||
{ OP_Next, 0, ADDR(3), 0}, /* 12 */
|
||||
};
|
||||
/* Index *pIdx; */
|
||||
Trigger *pTrigger;
|
||||
sqlite3BeginWriteOperation(pParse, 0, pTab->iDb);
|
||||
|
||||
@ -1831,20 +1823,12 @@ void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView){
|
||||
** created in the temp database that refers to a table in another
|
||||
** database.
|
||||
*/
|
||||
sqlite3OpenMasterTable(v, pTab->iDb);
|
||||
base = sqlite3VdbeAddOpList(v, ArraySize(dropTable), dropTable);
|
||||
sqlite3VdbeChangeP3(v, base+1, pTab->zName, 0);
|
||||
sqlite3ChangeCookie(db, v, pTab->iDb);
|
||||
sqlite3NestedParse(pParse,
|
||||
"DELETE FROM %Q.%Q WHERE tbl_name=%Q and type!='trigger'",
|
||||
db->aDb[pTab->iDb].zName, SCHEMA_TABLE(pTab->iDb), pTab->zName);
|
||||
if( !isView ){
|
||||
/*
|
||||
sqlite3VdbeAddOp(v, OP_Destroy, pTab->tnum, pTab->iDb);
|
||||
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
|
||||
sqlite3VdbeAddOp(v, OP_Destroy, pIdx->tnum, pIdx->iDb);
|
||||
}
|
||||
*/
|
||||
destroyTable(v, pTab);
|
||||
}
|
||||
sqlite3VdbeAddOp(v, OP_Close, 0, 0);
|
||||
sqlite3VdbeOp3(v, OP_DropTable, pTab->iDb, 0, pTab->zName, 0);
|
||||
}
|
||||
sqliteViewResetAll(db, iDb);
|
||||
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.331 2004/11/05 00:43:12 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.332 2004/11/05 03:56:02 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITEINT_H_
|
||||
#define _SQLITEINT_H_
|
||||
@ -107,6 +107,14 @@
|
||||
/* #define SQLITE_OMIT_DATETIME_FUNCS 1 */
|
||||
/* #define SQLITE_OMIT_PROGRESS_CALLBACK 1 */
|
||||
|
||||
/*
|
||||
** GCC does not define the offsetof() macro so we'll have to do it
|
||||
** ourselves.
|
||||
*/
|
||||
#ifndef offsetof
|
||||
#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD))
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Integers of known sizes. These typedefs might change for architectures
|
||||
** where the sizes very. Preprocessor macros are available so that the
|
||||
@ -993,42 +1001,51 @@ struct AggExpr {
|
||||
** An SQL parser context. A copy of this structure is passed through
|
||||
** the parser and down into all the parser action routine in order to
|
||||
** carry around information that is global to the entire parse.
|
||||
**
|
||||
** The structure is divided into two parts. When the parser and code
|
||||
** generate call themselves recursively, the first part of the structure
|
||||
** is constant but the second part is reset at the beginning and end of
|
||||
** each recursion.
|
||||
*/
|
||||
struct Parse {
|
||||
sqlite3 *db; /* The main database structure */
|
||||
int rc; /* Return code from execution */
|
||||
char *zErrMsg; /* An error message */
|
||||
Token sErrToken; /* The token at which the error occurred */
|
||||
Token sNameToken; /* Token with unqualified schema object name */
|
||||
Token sLastToken; /* The last token parsed */
|
||||
const char *zSql; /* All SQL text */
|
||||
const char *zTail; /* All SQL text past the last semicolon parsed */
|
||||
Table *pNewTable; /* A table being constructed by CREATE TABLE */
|
||||
Vdbe *pVdbe; /* An engine for executing database bytecode */
|
||||
u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */
|
||||
u8 explain; /* True if the EXPLAIN flag is found on the query */
|
||||
u8 nameClash; /* A permanent table name clashes with temp table name */
|
||||
u8 useAgg; /* If true, extract field values from the aggregator
|
||||
** while generating expressions. Normally false */
|
||||
u8 checkSchema; /* Causes schema cookie check after an error */
|
||||
u8 nested; /* Number of nested calls to the parser/code generator */
|
||||
int nErr; /* Number of errors seen */
|
||||
int nTab; /* Number of previously allocated VDBE cursors */
|
||||
int nMem; /* Number of memory cells used so far */
|
||||
int nSet; /* Number of sets used so far */
|
||||
int nAgg; /* Number of aggregate expressions */
|
||||
int nVar; /* Number of '?' variables seen in the SQL so far */
|
||||
int nVarExpr; /* Number of used slots in apVarExpr[] */
|
||||
int nVarExprAlloc; /* Number of allocated slots in apVarExpr[] */
|
||||
Expr **apVarExpr; /* Pointers to :aaa and $aaaa wildcard expressions */
|
||||
AggExpr *aAgg; /* An array of aggregate expressions */
|
||||
const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
|
||||
Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
|
||||
TriggerStack *trigStack; /* Trigger actions being coded */
|
||||
u32 cookieMask; /* Bitmask of schema verified databases */
|
||||
int cookieValue[MAX_ATTACHED+2]; /* Values of cookies to verify */
|
||||
int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */
|
||||
u32 writeMask; /* Start a write transaction on these databases */
|
||||
|
||||
/* Above is constant between recursions. Below is reset before and after
|
||||
** each recursion */
|
||||
|
||||
int nVar; /* Number of '?' variables seen in the SQL so far */
|
||||
int nVarExpr; /* Number of used slots in apVarExpr[] */
|
||||
int nVarExprAlloc; /* Number of allocated slots in apVarExpr[] */
|
||||
Expr **apVarExpr; /* Pointers to :aaa and $aaaa wildcard expressions */
|
||||
u8 explain; /* True if the EXPLAIN flag is found on the query */
|
||||
u8 useAgg; /* If true, extract field values from the aggregator
|
||||
** while generating expressions. Normally false */
|
||||
int nAgg; /* Number of aggregate expressions */
|
||||
AggExpr *aAgg; /* An array of aggregate expressions */
|
||||
Token sErrToken; /* The token at which the error occurred */
|
||||
Token sNameToken; /* Token with unqualified schema object name */
|
||||
Token sLastToken; /* The last token parsed */
|
||||
const char *zSql; /* All SQL text */
|
||||
const char *zTail; /* All SQL text past the last semicolon parsed */
|
||||
Table *pNewTable; /* A table being constructed by CREATE TABLE */
|
||||
Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
|
||||
TriggerStack *trigStack; /* Trigger actions being coded */
|
||||
const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -12,7 +12,7 @@
|
||||
# focus of this script is testing the ATTACH and DETACH commands
|
||||
# and related functionality.
|
||||
#
|
||||
# $Id: attach2.test,v 1.27 2004/10/07 22:22:39 drh Exp $
|
||||
# $Id: attach2.test,v 1.28 2004/11/05 03:56:02 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -325,6 +325,7 @@ do_test attach2-5.2 {
|
||||
do_test attach2-5.3 {
|
||||
lsort [glob test.db*]
|
||||
} {test.db test.db2}
|
||||
execsql {pragma vdbe_trace=on}
|
||||
do_test attach2-5.4 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
|
Loading…
x
Reference in New Issue
Block a user