diff options
author | danielk1977 <danielk1977@noemail.net> | 2006-06-24 08:51:05 +0000 |
---|---|---|
committer | danielk1977 <danielk1977@noemail.net> | 2006-06-24 08:51:05 +0000 |
commit | 33b3933c1501a4f2e37f9439f772fbc6443a90a5 (patch) | |
tree | c1a2e1b0369ea1f40477ac9abe18d50e9a14fb58 /src | |
parent | cc013f891ce1490d2fa7e173391ca155b05b673e (diff) | |
download | sqlite-33b3933c1501a4f2e37f9439f772fbc6443a90a5.tar.gz sqlite-33b3933c1501a4f2e37f9439f772fbc6443a90a5.zip |
Ensure whitespace specified as part of a virtual table constructor argument is correctly passed to the constructor function. (CVS 3290)
FossilOrigin-Name: 4630e11d9a697a7fa29a0a1bbca91da4ad2bde7b
Diffstat (limited to 'src')
-rw-r--r-- | src/sqliteInt.h | 6 | ||||
-rw-r--r-- | src/tokenize.c | 6 | ||||
-rw-r--r-- | src/vtab.c | 36 |
3 files changed, 18 insertions, 30 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 46139da21..f25ebfd2c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.511 2006/06/23 08:05:19 danielk1977 Exp $ +** @(#) $Id: sqliteInt.h,v 1.512 2006/06/24 08:51:05 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -1307,9 +1307,7 @@ struct Parse { TriggerStack *trigStack; /* Trigger actions being coded */ const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */ #ifndef SQLITE_OMIT_VIRTUALTABLE - int nArgAlloc; /* Number of bytes allocated for zArg[] */ - int nArgUsed; /* Number of bytes of zArg[] used so far */ - char *zArg; /* Complete text of a module argument */ + Token sArg; /* Complete text of a module argument */ u8 declareVtab; /* True if inside sqlite3_declare_vtab() */ Table *pVirtualLock; /* Require virtual table lock on this table */ #endif diff --git a/src/tokenize.c b/src/tokenize.c index c50395aeb..ea584b1cd 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -15,7 +15,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.120 2006/06/12 11:24:37 danielk1977 Exp $ +** $Id: tokenize.c,v 1.121 2006/06/24 08:51:05 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -484,10 +484,6 @@ abort_parse: } #endif -#ifndef SQLITE_OMIT_VIRTUALTABLE - sqliteFree(pParse->zArg); -#endif - if( !IN_DECLARE_VTAB ){ /* If the pParse->declareVtab flag is set, do not delete any table ** structure built up in pParse->pNewTable. The calling code (see vtab.c) diff --git a/src/vtab.c b/src/vtab.c index 4af8be859..e5ebe244a 100644 --- a/src/vtab.c +++ b/src/vtab.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to help implement virtual tables. ** -** $Id: vtab.c,v 1.22 2006/06/23 11:34:55 danielk1977 Exp $ +** $Id: vtab.c,v 1.23 2006/06/24 08:51:05 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_VIRTUALTABLE #include "sqliteInt.h" @@ -138,10 +138,11 @@ void sqlite3VtabBeginParse( ** virtual table currently under construction in pParse->pTable. */ static void addArgumentToVtab(Parse *pParse){ - if( pParse->nArgUsed && pParse->pNewTable ){ - addModuleArgument(pParse->pNewTable, sqliteStrDup(pParse->zArg)); + if( pParse->sArg.z && pParse->pNewTable ){ + char *z = pParse->sArg.z; + int n = pParse->sArg.n; + addModuleArgument(pParse->pNewTable, sqliteStrNDup(z, n)); } - pParse->nArgUsed = 0; } /* @@ -155,9 +156,7 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ Module *pMod = 0; addArgumentToVtab(pParse); - sqliteFree(pParse->zArg); - pParse->zArg = 0; - pParse->nArgAlloc = 0; + pParse->sArg.z = 0; /* Lookup the module name. */ pTab = pParse->pNewTable; @@ -242,7 +241,8 @@ void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ */ void sqlite3VtabArgInit(Parse *pParse){ addArgumentToVtab(pParse); - pParse->nArgUsed = 0; + pParse->sArg.z = 0; + pParse->sArg.n = 0; } /* @@ -250,20 +250,14 @@ void sqlite3VtabArgInit(Parse *pParse){ ** in an argument to the module name in a CREATE VIRTUAL TABLE statement. */ void sqlite3VtabArgExtend(Parse *pParse, Token *p){ - if( pParse->nArgUsed + p->n + 2 >= pParse->nArgAlloc ){ - pParse->nArgAlloc = pParse->nArgAlloc*2 + p->n + 200; - pParse->zArg = sqliteRealloc(pParse->zArg, pParse->nArgAlloc); - if( pParse->zArg==0 ){ - pParse->nArgAlloc = 0; - return; - } - } - if( pParse->nArgUsed ){ - pParse->zArg[pParse->nArgUsed++] = ' '; + Token *pArg = &pParse->sArg; + if( pArg->z==0 ){ + pArg->z = p->z; + pArg->n = p->n; + }else{ + assert(pArg->z < p->z); + pArg->n = (p->z + p->n - pArg->z); } - memcpy(&pParse->zArg[pParse->nArgUsed], p->z, p->n); - pParse->nArgUsed += p->n; - pParse->zArg[pParse->nArgUsed] = 0; } /* |