mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
DBD-SQLite: updated bundled sqlite from 3.6.10 to 3.6.11
This commit is contained in:
parent
c2bbe22fd5
commit
61a5ea496f
52 changed files with 4156 additions and 3004 deletions
|
@ -20,3 +20,4 @@ output/.*
|
||||||
~$
|
~$
|
||||||
^sqlite\-
|
^sqlite\-
|
||||||
\.svn
|
\.svn
|
||||||
|
^bugs/
|
||||||
|
|
15
alter.c
15
alter.c
|
@ -12,10 +12,9 @@
|
||||||
** This file contains C code routines that used to generate VDBE code
|
** This file contains C code routines that used to generate VDBE code
|
||||||
** that implements the ALTER TABLE command.
|
** that implements the ALTER TABLE command.
|
||||||
**
|
**
|
||||||
** $Id: alter.c,v 1.51 2008/12/10 19:26:22 drh Exp $
|
** $Id: alter.c,v 1.53 2009/02/13 03:43:32 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The code in this file only exists if we are not omitting the
|
** The code in this file only exists if we are not omitting the
|
||||||
|
@ -454,7 +453,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
|
||||||
assert( sqlite3BtreeHoldsAllMutexes(db) );
|
assert( sqlite3BtreeHoldsAllMutexes(db) );
|
||||||
iDb = sqlite3SchemaToIndex(db, pNew->pSchema);
|
iDb = sqlite3SchemaToIndex(db, pNew->pSchema);
|
||||||
zDb = db->aDb[iDb].zName;
|
zDb = db->aDb[iDb].zName;
|
||||||
zTab = pNew->zName;
|
zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */
|
||||||
pCol = &pNew->aCol[pNew->nCol-1];
|
pCol = &pNew->aCol[pNew->nCol-1];
|
||||||
pDflt = pCol->pDflt;
|
pDflt = pCol->pDflt;
|
||||||
pTab = sqlite3FindTable(db, zTab, zDb);
|
pTab = sqlite3FindTable(db, zTab, zDb);
|
||||||
|
@ -513,7 +512,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
|
||||||
zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);
|
zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);
|
||||||
if( zCol ){
|
if( zCol ){
|
||||||
char *zEnd = &zCol[pColDef->n-1];
|
char *zEnd = &zCol[pColDef->n-1];
|
||||||
while( (zEnd>zCol && *zEnd==';') || isspace(*(unsigned char *)zEnd) ){
|
while( (zEnd>zCol && *zEnd==';') || sqlite3Isspace(*zEnd) ){
|
||||||
*zEnd-- = '\0';
|
*zEnd-- = '\0';
|
||||||
}
|
}
|
||||||
sqlite3NestedParse(pParse,
|
sqlite3NestedParse(pParse,
|
||||||
|
@ -584,7 +583,11 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
|
||||||
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
|
||||||
|
|
||||||
/* Put a copy of the Table struct in Parse.pNewTable for the
|
/* Put a copy of the Table struct in Parse.pNewTable for the
|
||||||
** sqlite3AddColumn() function and friends to modify.
|
** sqlite3AddColumn() function and friends to modify. But modify
|
||||||
|
** the name by adding an "sqlite_altertab_" prefix. By adding this
|
||||||
|
** prefix, we insure that the name will not collide with an existing
|
||||||
|
** table because user table are not allowed to have the "sqlite_"
|
||||||
|
** prefix on their name.
|
||||||
*/
|
*/
|
||||||
pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));
|
pNew = (Table*)sqlite3DbMallocZero(db, sizeof(Table));
|
||||||
if( !pNew ) goto exit_begin_add_column;
|
if( !pNew ) goto exit_begin_add_column;
|
||||||
|
@ -596,7 +599,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
|
||||||
nAlloc = (((pNew->nCol-1)/8)*8)+8;
|
nAlloc = (((pNew->nCol-1)/8)*8)+8;
|
||||||
assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
|
assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
|
||||||
pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);
|
pNew->aCol = (Column*)sqlite3DbMallocZero(db, sizeof(Column)*nAlloc);
|
||||||
pNew->zName = sqlite3DbStrDup(db, pTab->zName);
|
pNew->zName = sqlite3MPrintf(db, "sqlite_altertab_%s", pTab->zName);
|
||||||
if( !pNew->aCol || !pNew->zName ){
|
if( !pNew->aCol || !pNew->zName ){
|
||||||
db->mallocFailed = 1;
|
db->mallocFailed = 1;
|
||||||
goto exit_begin_add_column;
|
goto exit_begin_add_column;
|
||||||
|
|
15
analyze.c
15
analyze.c
|
@ -11,7 +11,7 @@
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file contains code associated with the ANALYZE command.
|
** This file contains code associated with the ANALYZE command.
|
||||||
**
|
**
|
||||||
** @(#) $Id: analyze.c,v 1.47 2008/12/10 16:45:51 drh Exp $
|
** @(#) $Id: analyze.c,v 1.48 2009/02/13 16:59:53 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_OMIT_ANALYZE
|
#ifndef SQLITE_OMIT_ANALYZE
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
@ -416,10 +416,15 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
|
||||||
/* Load new statistics out of the sqlite_stat1 table */
|
/* Load new statistics out of the sqlite_stat1 table */
|
||||||
zSql = sqlite3MPrintf(db, "SELECT idx, stat FROM %Q.sqlite_stat1",
|
zSql = sqlite3MPrintf(db, "SELECT idx, stat FROM %Q.sqlite_stat1",
|
||||||
sInfo.zDatabase);
|
sInfo.zDatabase);
|
||||||
(void)sqlite3SafetyOff(db);
|
if( zSql==0 ){
|
||||||
rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
|
rc = SQLITE_NOMEM;
|
||||||
(void)sqlite3SafetyOn(db);
|
}else{
|
||||||
sqlite3DbFree(db, zSql);
|
(void)sqlite3SafetyOff(db);
|
||||||
|
rc = sqlite3_exec(db, zSql, analysisLoader, &sInfo, 0);
|
||||||
|
(void)sqlite3SafetyOn(db);
|
||||||
|
sqlite3DbFree(db, zSql);
|
||||||
|
if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
|
||||||
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
attach.c
4
attach.c
|
@ -11,7 +11,7 @@
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file contains code used to implement the ATTACH and DETACH commands.
|
** This file contains code used to implement the ATTACH and DETACH commands.
|
||||||
**
|
**
|
||||||
** $Id: attach.c,v 1.81 2008/12/10 16:45:51 drh Exp $
|
** $Id: attach.c,v 1.82 2009/02/03 16:51:25 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
@ -265,7 +265,7 @@ static void detachFunc(
|
||||||
"cannot DETACH database within transaction");
|
"cannot DETACH database within transaction");
|
||||||
goto detach_error;
|
goto detach_error;
|
||||||
}
|
}
|
||||||
if( sqlite3BtreeIsInReadTrans(pDb->pBt) ){
|
if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){
|
||||||
sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName);
|
sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName);
|
||||||
goto detach_error;
|
goto detach_error;
|
||||||
}
|
}
|
||||||
|
|
10
bitvec.c
10
bitvec.c
|
@ -34,7 +34,7 @@
|
||||||
** start of a transaction, and is thus usually less than a few thousand,
|
** start of a transaction, and is thus usually less than a few thousand,
|
||||||
** but can be as large as 2 billion for a really big database.
|
** but can be as large as 2 billion for a really big database.
|
||||||
**
|
**
|
||||||
** @(#) $Id: bitvec.c,v 1.10 2009/01/02 21:39:39 drh Exp $
|
** @(#) $Id: bitvec.c,v 1.13 2009/01/20 17:06:27 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
@ -275,6 +275,14 @@ void sqlite3BitvecDestroy(Bitvec *p){
|
||||||
sqlite3_free(p);
|
sqlite3_free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Return the value of the iSize parameter specified when Bitvec *p
|
||||||
|
** was created.
|
||||||
|
*/
|
||||||
|
u32 sqlite3BitvecSize(Bitvec *p){
|
||||||
|
return p->iSize;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
#ifndef SQLITE_OMIT_BUILTIN_TEST
|
||||||
/*
|
/*
|
||||||
** Let V[] be an array of unsigned characters sufficient to hold
|
** Let V[] be an array of unsigned characters sufficient to hold
|
||||||
|
|
577
btree.c
577
btree.c
|
@ -9,7 +9,7 @@
|
||||||
** May you share freely, never taking more than you give.
|
** May you share freely, never taking more than you give.
|
||||||
**
|
**
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** $Id: btree.c,v 1.558 2009/01/10 16:15:21 drh Exp $
|
** $Id: btree.c,v 1.565 2009/02/04 01:49:30 shane Exp $
|
||||||
**
|
**
|
||||||
** This file implements a external (disk-based) database using BTrees.
|
** This file implements a external (disk-based) database using BTrees.
|
||||||
** See the header comment on "btreeInt.h" for additional information.
|
** See the header comment on "btreeInt.h" for additional information.
|
||||||
|
@ -282,6 +282,80 @@ static void invalidateAllOverflowCache(BtShared *pBt){
|
||||||
#define invalidateAllOverflowCache(x)
|
#define invalidateAllOverflowCache(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Set bit pgno of the BtShared.pHasContent bitvec. This is called
|
||||||
|
** when a page that previously contained data becomes a free-list leaf
|
||||||
|
** page.
|
||||||
|
**
|
||||||
|
** The BtShared.pHasContent bitvec exists to work around an obscure
|
||||||
|
** bug caused by the interaction of two useful IO optimizations surrounding
|
||||||
|
** free-list leaf pages:
|
||||||
|
**
|
||||||
|
** 1) When all data is deleted from a page and the page becomes
|
||||||
|
** a free-list leaf page, the page is not written to the database
|
||||||
|
** (as free-list leaf pages contain no meaningful data). Sometimes
|
||||||
|
** such a page is not even journalled (as it will not be modified,
|
||||||
|
** why bother journalling it?).
|
||||||
|
**
|
||||||
|
** 2) When a free-list leaf page is reused, its content is not read
|
||||||
|
** from the database or written to the journal file (why should it
|
||||||
|
** be, if it is not at all meaningful?).
|
||||||
|
**
|
||||||
|
** By themselves, these optimizations work fine and provide a handy
|
||||||
|
** performance boost to bulk delete or insert operations. However, if
|
||||||
|
** a page is moved to the free-list and then reused within the same
|
||||||
|
** transaction, a problem comes up. If the page is not journalled when
|
||||||
|
** it is moved to the free-list and it is also not journalled when it
|
||||||
|
** is extracted from the free-list and reused, then the original data
|
||||||
|
** may be lost. In the event of a rollback, it may not be possible
|
||||||
|
** to restore the database to its original configuration.
|
||||||
|
**
|
||||||
|
** The solution is the BtShared.pHasContent bitvec. Whenever a page is
|
||||||
|
** moved to become a free-list leaf page, the corresponding bit is
|
||||||
|
** set in the bitvec. Whenever a leaf page is extracted from the free-list,
|
||||||
|
** optimization 2 above is ommitted if the corresponding bit is already
|
||||||
|
** set in BtShared.pHasContent. The contents of the bitvec are cleared
|
||||||
|
** at the end of every transaction.
|
||||||
|
*/
|
||||||
|
static int btreeSetHasContent(BtShared *pBt, Pgno pgno){
|
||||||
|
int rc = SQLITE_OK;
|
||||||
|
if( !pBt->pHasContent ){
|
||||||
|
int nPage;
|
||||||
|
rc = sqlite3PagerPagecount(pBt->pPager, &nPage);
|
||||||
|
if( rc==SQLITE_OK ){
|
||||||
|
pBt->pHasContent = sqlite3BitvecCreate((u32)nPage);
|
||||||
|
if( !pBt->pHasContent ){
|
||||||
|
rc = SQLITE_NOMEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( rc==SQLITE_OK && pgno<=sqlite3BitvecSize(pBt->pHasContent) ){
|
||||||
|
rc = sqlite3BitvecSet(pBt->pHasContent, pgno);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Query the BtShared.pHasContent vector.
|
||||||
|
**
|
||||||
|
** This function is called when a free-list leaf page is removed from the
|
||||||
|
** free-list for reuse. It returns false if it is safe to retrieve the
|
||||||
|
** page from the pager layer with the 'no-content' flag set. True otherwise.
|
||||||
|
*/
|
||||||
|
static int btreeGetHasContent(BtShared *pBt, Pgno pgno){
|
||||||
|
Bitvec *p = pBt->pHasContent;
|
||||||
|
return (p && (pgno>sqlite3BitvecSize(p) || sqlite3BitvecTest(p, pgno)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Clear (destroy) the BtShared.pHasContent bitvec. This should be
|
||||||
|
** invoked at the conclusion of each write-transaction.
|
||||||
|
*/
|
||||||
|
static void btreeClearHasContent(BtShared *pBt){
|
||||||
|
sqlite3BitvecDestroy(pBt->pHasContent);
|
||||||
|
pBt->pHasContent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Save the current cursor position in the variables BtCursor.nKey
|
** Save the current cursor position in the variables BtCursor.nKey
|
||||||
** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK.
|
** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK.
|
||||||
|
@ -1100,6 +1174,21 @@ int sqlite3BtreeGetPage(
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Retrieve a page from the pager cache. If the requested page is not
|
||||||
|
** already in the pager cache return NULL. Initialize the MemPage.pBt and
|
||||||
|
** MemPage.aData elements if needed.
|
||||||
|
*/
|
||||||
|
static MemPage *btreePageLookup(BtShared *pBt, Pgno pgno){
|
||||||
|
DbPage *pDbPage;
|
||||||
|
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||||
|
pDbPage = sqlite3PagerLookup(pBt->pPager, pgno);
|
||||||
|
if( pDbPage ){
|
||||||
|
return btreePageFromDbPage(pDbPage, pgno, pBt);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Return the size of the database file in pages. If there is any kind of
|
** Return the size of the database file in pages. If there is any kind of
|
||||||
** error, return ((unsigned int)-1).
|
** error, return ((unsigned int)-1).
|
||||||
|
@ -1124,7 +1213,6 @@ static int getAndInitPage(
|
||||||
MemPage **ppPage /* Write the page pointer here */
|
MemPage **ppPage /* Write the page pointer here */
|
||||||
){
|
){
|
||||||
int rc;
|
int rc;
|
||||||
DbPage *pDbPage;
|
|
||||||
MemPage *pPage;
|
MemPage *pPage;
|
||||||
|
|
||||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||||
|
@ -1137,10 +1225,9 @@ static int getAndInitPage(
|
||||||
** pagerPagecount() to make sure pgno is within limits, which results
|
** pagerPagecount() to make sure pgno is within limits, which results
|
||||||
** in a measureable performance improvements.
|
** in a measureable performance improvements.
|
||||||
*/
|
*/
|
||||||
pDbPage = sqlite3PagerLookup(pBt->pPager, pgno);
|
*ppPage = pPage = btreePageLookup(pBt, pgno);
|
||||||
if( pDbPage ){
|
if( pPage ){
|
||||||
/* Page is already in cache */
|
/* Page is already in cache */
|
||||||
*ppPage = pPage = btreePageFromDbPage(pDbPage, pgno, pBt);
|
|
||||||
rc = SQLITE_OK;
|
rc = SQLITE_OK;
|
||||||
}else{
|
}else{
|
||||||
/* Page not in cache. Acquire it. */
|
/* Page not in cache. Acquire it. */
|
||||||
|
@ -2013,7 +2100,7 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
|
||||||
if( pBt->readOnly ){
|
if( pBt->readOnly ){
|
||||||
rc = SQLITE_READONLY;
|
rc = SQLITE_READONLY;
|
||||||
}else{
|
}else{
|
||||||
rc = sqlite3PagerBegin(pBt->pPage1->pDbPage, wrflag>1);
|
rc = sqlite3PagerBegin(pBt->pPager, wrflag>1);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
rc = newDatabase(pBt);
|
rc = newDatabase(pBt);
|
||||||
}
|
}
|
||||||
|
@ -2372,7 +2459,7 @@ int sqlite3BtreeIncrVacuum(Btree *p){
|
||||||
rc = SQLITE_DONE;
|
rc = SQLITE_DONE;
|
||||||
}else{
|
}else{
|
||||||
invalidateAllOverflowCache(pBt);
|
invalidateAllOverflowCache(pBt);
|
||||||
rc = incrVacuumStep(pBt, 0, sqlite3PagerImageSize(pBt->pPager));
|
rc = incrVacuumStep(pBt, 0, pagerPagecount(pBt));
|
||||||
}
|
}
|
||||||
sqlite3BtreeLeave(p);
|
sqlite3BtreeLeave(p);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -2540,6 +2627,7 @@ int sqlite3BtreeCommitPhaseTwo(Btree *p){
|
||||||
/* Set the handles current transaction state to TRANS_NONE and unlock
|
/* Set the handles current transaction state to TRANS_NONE and unlock
|
||||||
** the pager if this call closed the only read or write transaction.
|
** the pager if this call closed the only read or write transaction.
|
||||||
*/
|
*/
|
||||||
|
btreeClearHasContent(pBt);
|
||||||
p->inTrans = TRANS_NONE;
|
p->inTrans = TRANS_NONE;
|
||||||
unlockBtreeIfUnused(pBt);
|
unlockBtreeIfUnused(pBt);
|
||||||
|
|
||||||
|
@ -2675,6 +2763,7 @@ int sqlite3BtreeRollback(Btree *p){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btreeClearHasContent(pBt);
|
||||||
p->inTrans = TRANS_NONE;
|
p->inTrans = TRANS_NONE;
|
||||||
pBt->inStmt = 0;
|
pBt->inStmt = 0;
|
||||||
unlockBtreeIfUnused(pBt);
|
unlockBtreeIfUnused(pBt);
|
||||||
|
@ -3082,34 +3171,29 @@ int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
|
||||||
**
|
**
|
||||||
** If an error occurs an SQLite error code is returned. Otherwise:
|
** If an error occurs an SQLite error code is returned. Otherwise:
|
||||||
**
|
**
|
||||||
** Unless pPgnoNext is NULL, the page number of the next overflow
|
** The page number of the next overflow page in the linked list is
|
||||||
** page in the linked list is written to *pPgnoNext. If page ovfl
|
** written to *pPgnoNext. If page ovfl is the last page in its linked
|
||||||
** is the last page in its linked list, *pPgnoNext is set to zero.
|
** list, *pPgnoNext is set to zero.
|
||||||
**
|
**
|
||||||
** If ppPage is not NULL, *ppPage is set to the MemPage* handle
|
** If ppPage is not NULL, and a reference to the MemPage object corresponding
|
||||||
** for page ovfl. The underlying pager page may have been requested
|
** to page number pOvfl was obtained, then *ppPage is set to point to that
|
||||||
** with the noContent flag set, so the page data accessable via
|
** reference. It is the responsibility of the caller to call releasePage()
|
||||||
** this handle may not be trusted.
|
** on *ppPage to free the reference. In no reference was obtained (because
|
||||||
|
** the pointer-map was used to obtain the value for *pPgnoNext), then
|
||||||
|
** *ppPage is set to zero.
|
||||||
*/
|
*/
|
||||||
static int getOverflowPage(
|
static int getOverflowPage(
|
||||||
BtShared *pBt,
|
BtShared *pBt,
|
||||||
Pgno ovfl, /* Overflow page */
|
Pgno ovfl, /* Overflow page */
|
||||||
MemPage **ppPage, /* OUT: MemPage handle */
|
MemPage **ppPage, /* OUT: MemPage handle (may be NULL) */
|
||||||
Pgno *pPgnoNext /* OUT: Next overflow page number */
|
Pgno *pPgnoNext /* OUT: Next overflow page number */
|
||||||
){
|
){
|
||||||
Pgno next = 0;
|
Pgno next = 0;
|
||||||
|
MemPage *pPage = 0;
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
|
|
||||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||||
/* One of these must not be NULL. Otherwise, why call this function? */
|
assert(pPgnoNext);
|
||||||
assert(ppPage || pPgnoNext);
|
|
||||||
|
|
||||||
/* If pPgnoNext is NULL, then this function is being called to obtain
|
|
||||||
** a MemPage* reference only. No page-data is required in this case.
|
|
||||||
*/
|
|
||||||
if( !pPgnoNext ){
|
|
||||||
return sqlite3BtreeGetPage(pBt, ovfl, ppPage, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||||
/* Try to find the next page in the overflow list using the
|
/* Try to find the next page in the overflow list using the
|
||||||
|
@ -3129,34 +3213,29 @@ static int getOverflowPage(
|
||||||
|
|
||||||
if( iGuess<=pagerPagecount(pBt) ){
|
if( iGuess<=pagerPagecount(pBt) ){
|
||||||
rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
|
rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
if( eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){
|
|
||||||
next = iGuess;
|
next = iGuess;
|
||||||
|
rc = SQLITE_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( next==0 || ppPage ){
|
if( rc==SQLITE_OK ){
|
||||||
MemPage *pPage = 0;
|
rc = sqlite3BtreeGetPage(pBt, ovfl, &pPage, 0);
|
||||||
|
|
||||||
rc = sqlite3BtreeGetPage(pBt, ovfl, &pPage, next!=0);
|
|
||||||
assert(rc==SQLITE_OK || pPage==0);
|
assert(rc==SQLITE_OK || pPage==0);
|
||||||
if( next==0 && rc==SQLITE_OK ){
|
if( next==0 && rc==SQLITE_OK ){
|
||||||
next = get4byte(pPage->aData);
|
next = get4byte(pPage->aData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ppPage ){
|
|
||||||
*ppPage = pPage;
|
|
||||||
}else{
|
|
||||||
releasePage(pPage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
*pPgnoNext = next;
|
|
||||||
|
|
||||||
return rc;
|
*pPgnoNext = next;
|
||||||
|
if( ppPage ){
|
||||||
|
*ppPage = pPage;
|
||||||
|
}else{
|
||||||
|
releasePage(pPage);
|
||||||
|
}
|
||||||
|
return (rc==SQLITE_DONE ? SQLITE_OK : rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4265,6 +4344,7 @@ static int allocateBtreePage(
|
||||||
|
|
||||||
iPage = get4byte(&aData[8+closest*4]);
|
iPage = get4byte(&aData[8+closest*4]);
|
||||||
if( !searchList || iPage==nearby ){
|
if( !searchList || iPage==nearby ){
|
||||||
|
int noContent;
|
||||||
Pgno nPage;
|
Pgno nPage;
|
||||||
*pPgno = iPage;
|
*pPgno = iPage;
|
||||||
nPage = pagerPagecount(pBt);
|
nPage = pagerPagecount(pBt);
|
||||||
|
@ -4281,9 +4361,9 @@ static int allocateBtreePage(
|
||||||
}
|
}
|
||||||
put4byte(&aData[4], k-1);
|
put4byte(&aData[4], k-1);
|
||||||
assert( sqlite3PagerIswriteable(pTrunk->pDbPage) );
|
assert( sqlite3PagerIswriteable(pTrunk->pDbPage) );
|
||||||
rc = sqlite3BtreeGetPage(pBt, *pPgno, ppPage, 1);
|
noContent = !btreeGetHasContent(pBt, *pPgno);
|
||||||
|
rc = sqlite3BtreeGetPage(pBt, *pPgno, ppPage, noContent);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
sqlite3PagerDontRollback((*ppPage)->pDbPage);
|
|
||||||
rc = sqlite3PagerWrite((*ppPage)->pDbPage);
|
rc = sqlite3PagerWrite((*ppPage)->pDbPage);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
releasePage(*ppPage);
|
releasePage(*ppPage);
|
||||||
|
@ -4301,6 +4381,10 @@ static int allocateBtreePage(
|
||||||
int nPage = pagerPagecount(pBt);
|
int nPage = pagerPagecount(pBt);
|
||||||
*pPgno = nPage + 1;
|
*pPgno = nPage + 1;
|
||||||
|
|
||||||
|
if( *pPgno==PENDING_BYTE_PAGE(pBt) ){
|
||||||
|
(*pPgno)++;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||||
if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, *pPgno) ){
|
if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, *pPgno) ){
|
||||||
/* If *pPgno refers to a pointer-map page, allocate two new pages
|
/* If *pPgno refers to a pointer-map page, allocate two new pages
|
||||||
|
@ -4340,32 +4424,51 @@ end_allocate_page:
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Add a page of the database file to the freelist.
|
** This function is used to add page iPage to the database file free-list.
|
||||||
|
** It is assumed that the page is not already a part of the free-list.
|
||||||
**
|
**
|
||||||
** sqlite3PagerUnref() is NOT called for pPage.
|
** The value passed as the second argument to this function is optional.
|
||||||
|
** If the caller happens to have a pointer to the MemPage object
|
||||||
|
** corresponding to page iPage handy, it may pass it as the second value.
|
||||||
|
** Otherwise, it may pass NULL.
|
||||||
|
**
|
||||||
|
** If a pointer to a MemPage object is passed as the second argument,
|
||||||
|
** its reference count is not altered by this function.
|
||||||
*/
|
*/
|
||||||
static int freePage(MemPage *pPage){
|
static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
|
||||||
BtShared *pBt = pPage->pBt;
|
MemPage *pTrunk = 0; /* Free-list trunk page */
|
||||||
MemPage *pPage1 = pBt->pPage1;
|
Pgno iTrunk = 0; /* Page number of free-list trunk page */
|
||||||
int rc, n, k;
|
MemPage *pPage1 = pBt->pPage1; /* Local reference to page 1 */
|
||||||
|
MemPage *pPage; /* Page being freed. May be NULL. */
|
||||||
|
int rc; /* Return Code */
|
||||||
|
int nFree; /* Initial number of pages on free-list */
|
||||||
|
|
||||||
/* Prepare the page for freeing */
|
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||||
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
|
assert( iPage>1 );
|
||||||
assert( pPage->pgno>1 );
|
assert( !pMemPage || pMemPage->pgno==iPage );
|
||||||
pPage->isInit = 0;
|
|
||||||
|
if( pMemPage ){
|
||||||
|
pPage = pMemPage;
|
||||||
|
sqlite3PagerRef(pPage->pDbPage);
|
||||||
|
}else{
|
||||||
|
pPage = btreePageLookup(pBt, iPage);
|
||||||
|
}
|
||||||
|
|
||||||
/* Increment the free page count on pPage1 */
|
/* Increment the free page count on pPage1 */
|
||||||
rc = sqlite3PagerWrite(pPage1->pDbPage);
|
rc = sqlite3PagerWrite(pPage1->pDbPage);
|
||||||
if( rc ) return rc;
|
if( rc ) goto freepage_out;
|
||||||
n = get4byte(&pPage1->aData[36]);
|
nFree = get4byte(&pPage1->aData[36]);
|
||||||
put4byte(&pPage1->aData[36], n+1);
|
put4byte(&pPage1->aData[36], nFree+1);
|
||||||
|
|
||||||
#ifdef SQLITE_SECURE_DELETE
|
#ifdef SQLITE_SECURE_DELETE
|
||||||
/* If the SQLITE_SECURE_DELETE compile-time option is enabled, then
|
/* If the SQLITE_SECURE_DELETE compile-time option is enabled, then
|
||||||
** always fully overwrite deleted information with zeros.
|
** always fully overwrite deleted information with zeros.
|
||||||
*/
|
*/
|
||||||
rc = sqlite3PagerWrite(pPage->pDbPage);
|
if( (!pPage && (rc = sqlite3BtreeGetPage(pBt, iPage, &pPage, 0)))
|
||||||
if( rc ) return rc;
|
|| (rc = sqlite3PagerWrite(pPage->pDbPage))
|
||||||
|
){
|
||||||
|
goto freepage_out;
|
||||||
|
}
|
||||||
memset(pPage->aData, 0, pPage->pBt->pageSize);
|
memset(pPage->aData, 0, pPage->pBt->pageSize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4373,27 +4476,34 @@ static int freePage(MemPage *pPage){
|
||||||
** to indicate that the page is free.
|
** to indicate that the page is free.
|
||||||
*/
|
*/
|
||||||
if( ISAUTOVACUUM ){
|
if( ISAUTOVACUUM ){
|
||||||
rc = ptrmapPut(pBt, pPage->pgno, PTRMAP_FREEPAGE, 0);
|
rc = ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0);
|
||||||
if( rc ) return rc;
|
if( rc ) goto freepage_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( n==0 ){
|
/* Now manipulate the actual database free-list structure. There are two
|
||||||
/* This is the first free page */
|
** possibilities. If the free-list is currently empty, or if the first
|
||||||
rc = sqlite3PagerWrite(pPage->pDbPage);
|
** trunk page in the free-list is full, then this page will become a
|
||||||
if( rc ) return rc;
|
** new free-list trunk page. Otherwise, it will become a leaf of the
|
||||||
memset(pPage->aData, 0, 8);
|
** first trunk page in the current free-list. This block tests if it
|
||||||
put4byte(&pPage1->aData[32], pPage->pgno);
|
** is possible to add the page as a new free-list leaf.
|
||||||
TRACE(("FREE-PAGE: %d first\n", pPage->pgno));
|
*/
|
||||||
}else{
|
if( nFree!=0 ){
|
||||||
/* Other free pages already exist. Retrive the first trunk page
|
int nLeaf; /* Initial number of leaf cells on trunk page */
|
||||||
** of the freelist and find out how many leaves it has. */
|
|
||||||
MemPage *pTrunk;
|
iTrunk = get4byte(&pPage1->aData[32]);
|
||||||
rc = sqlite3BtreeGetPage(pBt, get4byte(&pPage1->aData[32]), &pTrunk, 0);
|
rc = sqlite3BtreeGetPage(pBt, iTrunk, &pTrunk, 0);
|
||||||
if( rc ) return rc;
|
if( rc!=SQLITE_OK ){
|
||||||
k = get4byte(&pTrunk->aData[4]);
|
goto freepage_out;
|
||||||
if( k>=pBt->usableSize/4 - 8 ){
|
}
|
||||||
/* The trunk is full. Turn the page being freed into a new
|
|
||||||
** trunk page with no leaves.
|
nLeaf = get4byte(&pTrunk->aData[4]);
|
||||||
|
if( nLeaf<0 ){
|
||||||
|
rc = SQLITE_CORRUPT_BKPT;
|
||||||
|
goto freepage_out;
|
||||||
|
}
|
||||||
|
if( nLeaf<pBt->usableSize/4 - 8 ){
|
||||||
|
/* In this case there is room on the trunk page to insert the page
|
||||||
|
** being freed as a new leaf.
|
||||||
**
|
**
|
||||||
** Note that the trunk page is not really full until it contains
|
** Note that the trunk page is not really full until it contains
|
||||||
** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have
|
** usableSize/4 - 2 entries, not usableSize/4 - 8 entries as we have
|
||||||
|
@ -4406,32 +4516,49 @@ static int freePage(MemPage *pPage){
|
||||||
** to 3.6.0 or later) we should consider fixing the conditional above
|
** to 3.6.0 or later) we should consider fixing the conditional above
|
||||||
** to read "usableSize/4-2" instead of "usableSize/4-8".
|
** to read "usableSize/4-2" instead of "usableSize/4-8".
|
||||||
*/
|
*/
|
||||||
rc = sqlite3PagerWrite(pPage->pDbPage);
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
put4byte(pPage->aData, pTrunk->pgno);
|
|
||||||
put4byte(&pPage->aData[4], 0);
|
|
||||||
put4byte(&pPage1->aData[32], pPage->pgno);
|
|
||||||
TRACE(("FREE-PAGE: %d new trunk page replacing %d\n",
|
|
||||||
pPage->pgno, pTrunk->pgno));
|
|
||||||
}
|
|
||||||
}else if( k<0 ){
|
|
||||||
rc = SQLITE_CORRUPT;
|
|
||||||
}else{
|
|
||||||
/* Add the newly freed page as a leaf on the current trunk */
|
|
||||||
rc = sqlite3PagerWrite(pTrunk->pDbPage);
|
rc = sqlite3PagerWrite(pTrunk->pDbPage);
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
put4byte(&pTrunk->aData[4], k+1);
|
put4byte(&pTrunk->aData[4], nLeaf+1);
|
||||||
put4byte(&pTrunk->aData[8+k*4], pPage->pgno);
|
put4byte(&pTrunk->aData[8+nLeaf*4], iPage);
|
||||||
#ifndef SQLITE_SECURE_DELETE
|
#ifndef SQLITE_SECURE_DELETE
|
||||||
rc = sqlite3PagerDontWrite(pPage->pDbPage);
|
if( pPage ){
|
||||||
|
sqlite3PagerDontWrite(pPage->pDbPage);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
rc = btreeSetHasContent(pBt, iPage);
|
||||||
}
|
}
|
||||||
TRACE(("FREE-PAGE: %d leaf on trunk page %d\n",pPage->pgno,pTrunk->pgno));
|
TRACE(("FREE-PAGE: %d leaf on trunk page %d\n",pPage->pgno,pTrunk->pgno));
|
||||||
|
goto freepage_out;
|
||||||
}
|
}
|
||||||
releasePage(pTrunk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If control flows to this point, then it was not possible to add the
|
||||||
|
** the page being freed as a leaf page of the first trunk in the free-list.
|
||||||
|
** Possibly because the free-list is empty, or possibly because the
|
||||||
|
** first trunk in the free-list is full. Either way, the page being freed
|
||||||
|
** will become the new first trunk page in the free-list.
|
||||||
|
*/
|
||||||
|
if( ((!pPage) && (0 != (rc = sqlite3BtreeGetPage(pBt, iPage, &pPage, 0))))
|
||||||
|
|| (0 != (rc = sqlite3PagerWrite(pPage->pDbPage)))
|
||||||
|
){
|
||||||
|
goto freepage_out;
|
||||||
|
}
|
||||||
|
put4byte(pPage->aData, iTrunk);
|
||||||
|
put4byte(&pPage->aData[4], 0);
|
||||||
|
put4byte(&pPage1->aData[32], iPage);
|
||||||
|
TRACE(("FREE-PAGE: %d new trunk page replacing %d\n", pPage->pgno, iTrunk));
|
||||||
|
|
||||||
|
freepage_out:
|
||||||
|
if( pPage ){
|
||||||
|
pPage->isInit = 0;
|
||||||
|
}
|
||||||
|
releasePage(pPage);
|
||||||
|
releasePage(pTrunk);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
static int freePage(MemPage *pPage){
|
||||||
|
return freePage2(pPage->pBt, pPage, pPage->pgno);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Free any overflow pages associated with the given Cell.
|
** Free any overflow pages associated with the given Cell.
|
||||||
|
@ -4442,7 +4569,7 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
|
||||||
Pgno ovflPgno;
|
Pgno ovflPgno;
|
||||||
int rc;
|
int rc;
|
||||||
int nOvfl;
|
int nOvfl;
|
||||||
int ovflPageSize;
|
u16 ovflPageSize;
|
||||||
|
|
||||||
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
|
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
|
||||||
sqlite3BtreeParseCellPtr(pPage, pCell, &info);
|
sqlite3BtreeParseCellPtr(pPage, pCell, &info);
|
||||||
|
@ -4450,20 +4577,26 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
|
||||||
return SQLITE_OK; /* No overflow pages. Return without doing anything */
|
return SQLITE_OK; /* No overflow pages. Return without doing anything */
|
||||||
}
|
}
|
||||||
ovflPgno = get4byte(&pCell[info.iOverflow]);
|
ovflPgno = get4byte(&pCell[info.iOverflow]);
|
||||||
|
assert( pBt->usableSize > 4 );
|
||||||
ovflPageSize = pBt->usableSize - 4;
|
ovflPageSize = pBt->usableSize - 4;
|
||||||
nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
|
nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
|
||||||
assert( ovflPgno==0 || nOvfl>0 );
|
assert( ovflPgno==0 || nOvfl>0 );
|
||||||
while( nOvfl-- ){
|
while( nOvfl-- ){
|
||||||
MemPage *pOvfl;
|
Pgno iNext = 0;
|
||||||
|
MemPage *pOvfl = 0;
|
||||||
if( ovflPgno==0 || ovflPgno>pagerPagecount(pBt) ){
|
if( ovflPgno==0 || ovflPgno>pagerPagecount(pBt) ){
|
||||||
return SQLITE_CORRUPT_BKPT;
|
return SQLITE_CORRUPT_BKPT;
|
||||||
}
|
}
|
||||||
|
if( nOvfl ){
|
||||||
rc = getOverflowPage(pBt, ovflPgno, &pOvfl, (nOvfl==0)?0:&ovflPgno);
|
rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
rc = freePage(pOvfl);
|
}
|
||||||
sqlite3PagerUnref(pOvfl->pDbPage);
|
rc = freePage2(pBt, pOvfl, ovflPgno);
|
||||||
|
if( pOvfl ){
|
||||||
|
sqlite3PagerUnref(pOvfl->pDbPage);
|
||||||
|
}
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
|
ovflPgno = iNext;
|
||||||
}
|
}
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
@ -4531,7 +4664,9 @@ static int fillInCell(
|
||||||
nSrc = nData;
|
nSrc = nData;
|
||||||
nData = 0;
|
nData = 0;
|
||||||
}else{
|
}else{
|
||||||
/* TBD: Perhaps raise SQLITE_CORRUPT if nKey is larger than 31 bits? */
|
if( nKey>0x7fffffff || pKey==0 ){
|
||||||
|
return SQLITE_CORRUPT;
|
||||||
|
}
|
||||||
nPayload += (int)nKey;
|
nPayload += (int)nKey;
|
||||||
pSrc = pKey;
|
pSrc = pKey;
|
||||||
nSrc = (int)nKey;
|
nSrc = (int)nKey;
|
||||||
|
@ -5453,7 +5588,10 @@ static int balance_nonroot(BtCursor *pCur){
|
||||||
j--;
|
j--;
|
||||||
sqlite3BtreeParseCellPtr(pNew, apCell[j], &info);
|
sqlite3BtreeParseCellPtr(pNew, apCell[j], &info);
|
||||||
pCell = pTemp;
|
pCell = pTemp;
|
||||||
fillInCell(pParent, pCell, 0, info.nKey, 0, 0, 0, &sz);
|
rc = fillInCell(pParent, pCell, 0, info.nKey, 0, 0, 0, &sz);
|
||||||
|
if( rc!=SQLITE_OK ){
|
||||||
|
goto balance_cleanup;
|
||||||
|
}
|
||||||
pTemp = 0;
|
pTemp = 0;
|
||||||
}else{
|
}else{
|
||||||
pCell -= 4;
|
pCell -= 4;
|
||||||
|
@ -6229,11 +6367,6 @@ static int btreeCreateTable(Btree *p, int *piTable, int flags){
|
||||||
}
|
}
|
||||||
assert( eType!=PTRMAP_ROOTPAGE );
|
assert( eType!=PTRMAP_ROOTPAGE );
|
||||||
assert( eType!=PTRMAP_FREEPAGE );
|
assert( eType!=PTRMAP_FREEPAGE );
|
||||||
rc = sqlite3PagerWrite(pRoot->pDbPage);
|
|
||||||
if( rc!=SQLITE_OK ){
|
|
||||||
releasePage(pRoot);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);
|
rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);
|
||||||
releasePage(pRoot);
|
releasePage(pRoot);
|
||||||
|
|
||||||
|
@ -7094,17 +7227,6 @@ const char *sqlite3BtreeGetFilename(Btree *p){
|
||||||
return sqlite3PagerFilename(p->pBt->pPager);
|
return sqlite3PagerFilename(p->pBt->pPager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
** Return the pathname of the directory that contains the database file.
|
|
||||||
**
|
|
||||||
** The pager directory name is invariant as long as the pager is
|
|
||||||
** open so it is safe to access without the BtShared mutex.
|
|
||||||
*/
|
|
||||||
const char *sqlite3BtreeGetDirname(Btree *p){
|
|
||||||
assert( p->pBt->pPager!=0 );
|
|
||||||
return sqlite3PagerDirname(p->pBt->pPager);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Return the pathname of the journal file for this database. The return
|
** Return the pathname of the journal file for this database. The return
|
||||||
** value of this routine is the same regardless of whether the journal file
|
** value of this routine is the same regardless of whether the journal file
|
||||||
|
@ -7118,221 +7240,6 @@ const char *sqlite3BtreeGetJournalname(Btree *p){
|
||||||
return sqlite3PagerJournalname(p->pBt->pPager);
|
return sqlite3PagerJournalname(p->pBt->pPager);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_VACUUM
|
|
||||||
/*
|
|
||||||
** Copy the complete content of pBtFrom into pBtTo. A transaction
|
|
||||||
** must be active for both files.
|
|
||||||
**
|
|
||||||
** The size of file pTo may be reduced by this operation.
|
|
||||||
** If anything goes wrong, the transaction on pTo is rolled back.
|
|
||||||
**
|
|
||||||
** If successful, CommitPhaseOne() may be called on pTo before returning.
|
|
||||||
** The caller should finish committing the transaction on pTo by calling
|
|
||||||
** sqlite3BtreeCommit().
|
|
||||||
*/
|
|
||||||
static int btreeCopyFile(Btree *pTo, Btree *pFrom){
|
|
||||||
int rc = SQLITE_OK;
|
|
||||||
Pgno i;
|
|
||||||
|
|
||||||
Pgno nFromPage; /* Number of pages in pFrom */
|
|
||||||
Pgno nToPage; /* Number of pages in pTo */
|
|
||||||
Pgno nNewPage; /* Number of pages in pTo after the copy */
|
|
||||||
|
|
||||||
Pgno iSkip; /* Pending byte page in pTo */
|
|
||||||
int nToPageSize; /* Page size of pTo in bytes */
|
|
||||||
int nFromPageSize; /* Page size of pFrom in bytes */
|
|
||||||
|
|
||||||
BtShared *pBtTo = pTo->pBt;
|
|
||||||
BtShared *pBtFrom = pFrom->pBt;
|
|
||||||
pBtTo->db = pTo->db;
|
|
||||||
pBtFrom->db = pFrom->db;
|
|
||||||
|
|
||||||
nToPageSize = pBtTo->pageSize;
|
|
||||||
nFromPageSize = pBtFrom->pageSize;
|
|
||||||
|
|
||||||
assert( pTo->inTrans==TRANS_WRITE );
|
|
||||||
assert( pFrom->inTrans==TRANS_WRITE );
|
|
||||||
if( NEVER(pBtTo->pCursor) ){
|
|
||||||
return SQLITE_BUSY;
|
|
||||||
}
|
|
||||||
|
|
||||||
nToPage = pagerPagecount(pBtTo);
|
|
||||||
nFromPage = pagerPagecount(pBtFrom);
|
|
||||||
iSkip = PENDING_BYTE_PAGE(pBtTo);
|
|
||||||
|
|
||||||
/* Variable nNewPage is the number of pages required to store the
|
|
||||||
** contents of pFrom using the current page-size of pTo.
|
|
||||||
*/
|
|
||||||
nNewPage = (Pgno)
|
|
||||||
(((i64)nFromPage*(i64)nFromPageSize+(i64)nToPageSize-1)/(i64)nToPageSize);
|
|
||||||
|
|
||||||
for(i=1; rc==SQLITE_OK && (i<=nToPage || i<=nNewPage); i++){
|
|
||||||
|
|
||||||
/* Journal the original page.
|
|
||||||
**
|
|
||||||
** iSkip is the page number of the locking page (PENDING_BYTE_PAGE)
|
|
||||||
** in database *pTo (before the copy). This page is never written
|
|
||||||
** into the journal file. Unless i==iSkip or the page was not
|
|
||||||
** present in pTo before the copy operation, journal page i from pTo.
|
|
||||||
*/
|
|
||||||
if( i!=iSkip && i<=nToPage ){
|
|
||||||
DbPage *pDbPage = 0;
|
|
||||||
rc = sqlite3PagerGet(pBtTo->pPager, i, &pDbPage);
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
rc = sqlite3PagerWrite(pDbPage);
|
|
||||||
if( rc==SQLITE_OK && i>nFromPage ){
|
|
||||||
/* Yeah. It seems wierd to call DontWrite() right after Write(). But
|
|
||||||
** that is because the names of those procedures do not exactly
|
|
||||||
** represent what they do. Write() really means "put this page in the
|
|
||||||
** rollback journal and mark it as dirty so that it will be written
|
|
||||||
** to the database file later." DontWrite() undoes the second part of
|
|
||||||
** that and prevents the page from being written to the database. The
|
|
||||||
** page is still on the rollback journal, though. And that is the
|
|
||||||
** whole point of this block: to put pages on the rollback journal.
|
|
||||||
*/
|
|
||||||
rc = sqlite3PagerDontWrite(pDbPage);
|
|
||||||
}
|
|
||||||
sqlite3PagerUnref(pDbPage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Overwrite the data in page i of the target database */
|
|
||||||
if( rc==SQLITE_OK && i!=iSkip && i<=nNewPage ){
|
|
||||||
|
|
||||||
DbPage *pToPage = 0;
|
|
||||||
sqlite3_int64 iOff;
|
|
||||||
|
|
||||||
rc = sqlite3PagerGet(pBtTo->pPager, i, &pToPage);
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
rc = sqlite3PagerWrite(pToPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(
|
|
||||||
iOff=(i-1)*nToPageSize;
|
|
||||||
rc==SQLITE_OK && iOff<i*nToPageSize;
|
|
||||||
iOff += nFromPageSize
|
|
||||||
){
|
|
||||||
DbPage *pFromPage = 0;
|
|
||||||
Pgno iFrom = (Pgno)(iOff/nFromPageSize)+1;
|
|
||||||
|
|
||||||
if( iFrom==PENDING_BYTE_PAGE(pBtFrom) ){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = sqlite3PagerGet(pBtFrom->pPager, iFrom, &pFromPage);
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
char *zTo = sqlite3PagerGetData(pToPage);
|
|
||||||
char *zFrom = sqlite3PagerGetData(pFromPage);
|
|
||||||
int nCopy;
|
|
||||||
|
|
||||||
if( nFromPageSize>=nToPageSize ){
|
|
||||||
zFrom += ((i-1)*nToPageSize - ((iFrom-1)*nFromPageSize));
|
|
||||||
nCopy = nToPageSize;
|
|
||||||
}else{
|
|
||||||
zTo += (((iFrom-1)*nFromPageSize) - (i-1)*nToPageSize);
|
|
||||||
nCopy = nFromPageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(zTo, zFrom, nCopy);
|
|
||||||
sqlite3PagerUnref(pFromPage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( pToPage ){
|
|
||||||
MemPage *p = (MemPage *)sqlite3PagerGetExtra(pToPage);
|
|
||||||
p->isInit = 0;
|
|
||||||
sqlite3PagerUnref(pToPage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If things have worked so far, the database file may need to be
|
|
||||||
** truncated. The complex part is that it may need to be truncated to
|
|
||||||
** a size that is not an integer multiple of nToPageSize - the current
|
|
||||||
** page size used by the pager associated with B-Tree pTo.
|
|
||||||
**
|
|
||||||
** For example, say the page-size of pTo is 2048 bytes and the original
|
|
||||||
** number of pages is 5 (10 KB file). If pFrom has a page size of 1024
|
|
||||||
** bytes and 9 pages, then the file needs to be truncated to 9KB.
|
|
||||||
*/
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
sqlite3_file *pFile = sqlite3PagerFile(pBtTo->pPager);
|
|
||||||
i64 iSize = (i64)nFromPageSize * (i64)nFromPage;
|
|
||||||
i64 iNow = (i64)((nToPage>nNewPage)?nToPage:nNewPage) * (i64)nToPageSize;
|
|
||||||
i64 iPending = ((i64)PENDING_BYTE_PAGE(pBtTo)-1) *(i64)nToPageSize;
|
|
||||||
|
|
||||||
assert( iSize<=iNow );
|
|
||||||
|
|
||||||
/* Commit phase one syncs the journal file associated with pTo
|
|
||||||
** containing the original data. It does not sync the database file
|
|
||||||
** itself. After doing this it is safe to use OsTruncate() and other
|
|
||||||
** file APIs on the database file directly.
|
|
||||||
*/
|
|
||||||
pBtTo->db = pTo->db;
|
|
||||||
rc = sqlite3PagerCommitPhaseOne(pBtTo->pPager, 0, 1);
|
|
||||||
if( iSize<iNow && rc==SQLITE_OK ){
|
|
||||||
rc = sqlite3OsTruncate(pFile, iSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The loop that copied data from database pFrom to pTo did not
|
|
||||||
** populate the locking page of database pTo. If the page-size of
|
|
||||||
** pFrom is smaller than that of pTo, this means some data will
|
|
||||||
** not have been copied.
|
|
||||||
**
|
|
||||||
** This block copies the missing data from database pFrom to pTo
|
|
||||||
** using file APIs. This is safe because at this point we know that
|
|
||||||
** all of the original data from pTo has been synced into the
|
|
||||||
** journal file. At this point it would be safe to do anything at
|
|
||||||
** all to the database file except truncate it to zero bytes.
|
|
||||||
*/
|
|
||||||
if( rc==SQLITE_OK && nFromPageSize<nToPageSize && iSize>iPending){
|
|
||||||
i64 iOff;
|
|
||||||
for(
|
|
||||||
iOff=iPending;
|
|
||||||
rc==SQLITE_OK && iOff<(iPending+nToPageSize);
|
|
||||||
iOff += nFromPageSize
|
|
||||||
){
|
|
||||||
DbPage *pFromPage = 0;
|
|
||||||
Pgno iFrom = (Pgno)(iOff/nFromPageSize)+1;
|
|
||||||
|
|
||||||
if( iFrom==PENDING_BYTE_PAGE(pBtFrom) || iFrom>nFromPage ){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = sqlite3PagerGet(pBtFrom->pPager, iFrom, &pFromPage);
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
char *zFrom = sqlite3PagerGetData(pFromPage);
|
|
||||||
rc = sqlite3OsWrite(pFile, zFrom, nFromPageSize, iOff);
|
|
||||||
sqlite3PagerUnref(pFromPage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Sync the database file */
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
rc = sqlite3PagerSync(pBtTo->pPager);
|
|
||||||
}
|
|
||||||
if( rc==SQLITE_OK ){
|
|
||||||
pBtTo->pageSizeFixed = 0;
|
|
||||||
}else{
|
|
||||||
sqlite3BtreeRollback(pTo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){
|
|
||||||
int rc;
|
|
||||||
sqlite3BtreeEnter(pTo);
|
|
||||||
sqlite3BtreeEnter(pFrom);
|
|
||||||
rc = btreeCopyFile(pTo, pFrom);
|
|
||||||
sqlite3BtreeLeave(pFrom);
|
|
||||||
sqlite3BtreeLeave(pTo);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SQLITE_OMIT_VACUUM */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Return non-zero if a transaction is active.
|
** Return non-zero if a transaction is active.
|
||||||
*/
|
*/
|
||||||
|
@ -7358,6 +7265,12 @@ int sqlite3BtreeIsInReadTrans(Btree *p){
|
||||||
return p->inTrans!=TRANS_NONE;
|
return p->inTrans!=TRANS_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sqlite3BtreeIsInBackup(Btree *p){
|
||||||
|
assert( p );
|
||||||
|
assert( sqlite3_mutex_held(p->db->mutex) );
|
||||||
|
return p->nBackup!=0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This function returns a pointer to a blob of memory associated with
|
** This function returns a pointer to a blob of memory associated with
|
||||||
** a single shared-btree. The memory is used by client code for its own
|
** a single shared-btree. The memory is used by client code for its own
|
||||||
|
|
4
btree.h
4
btree.h
|
@ -13,7 +13,7 @@
|
||||||
** subsystem. See comments in the source code for a detailed description
|
** subsystem. See comments in the source code for a detailed description
|
||||||
** of what each interface routine does.
|
** of what each interface routine does.
|
||||||
**
|
**
|
||||||
** @(#) $Id: btree.h,v 1.106 2008/12/17 17:30:26 danielk1977 Exp $
|
** @(#) $Id: btree.h,v 1.108 2009/02/03 16:51:25 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _BTREE_H_
|
#ifndef _BTREE_H_
|
||||||
#define _BTREE_H_
|
#define _BTREE_H_
|
||||||
|
@ -98,13 +98,13 @@ int sqlite3BtreeCreateTable(Btree*, int*, int flags);
|
||||||
int sqlite3BtreeIsInTrans(Btree*);
|
int sqlite3BtreeIsInTrans(Btree*);
|
||||||
int sqlite3BtreeIsInStmt(Btree*);
|
int sqlite3BtreeIsInStmt(Btree*);
|
||||||
int sqlite3BtreeIsInReadTrans(Btree*);
|
int sqlite3BtreeIsInReadTrans(Btree*);
|
||||||
|
int sqlite3BtreeIsInBackup(Btree*);
|
||||||
void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
|
void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
|
||||||
int sqlite3BtreeSchemaLocked(Btree *);
|
int sqlite3BtreeSchemaLocked(Btree *);
|
||||||
int sqlite3BtreeLockTable(Btree *, int, u8);
|
int sqlite3BtreeLockTable(Btree *, int, u8);
|
||||||
int sqlite3BtreeSavepoint(Btree *, int, int);
|
int sqlite3BtreeSavepoint(Btree *, int, int);
|
||||||
|
|
||||||
const char *sqlite3BtreeGetFilename(Btree *);
|
const char *sqlite3BtreeGetFilename(Btree *);
|
||||||
const char *sqlite3BtreeGetDirname(Btree *);
|
|
||||||
const char *sqlite3BtreeGetJournalname(Btree *);
|
const char *sqlite3BtreeGetJournalname(Btree *);
|
||||||
int sqlite3BtreeCopyFile(Btree *, Btree *);
|
int sqlite3BtreeCopyFile(Btree *, Btree *);
|
||||||
|
|
||||||
|
|
22
btreeInt.h
22
btreeInt.h
|
@ -9,7 +9,7 @@
|
||||||
** May you share freely, never taking more than you give.
|
** May you share freely, never taking more than you give.
|
||||||
**
|
**
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** $Id: btreeInt.h,v 1.38 2008/12/27 15:23:13 danielk1977 Exp $
|
** $Id: btreeInt.h,v 1.42 2009/02/03 16:51:25 danielk1977 Exp $
|
||||||
**
|
**
|
||||||
** This file implements a external (disk-based) database using BTrees.
|
** This file implements a external (disk-based) database using BTrees.
|
||||||
** For a detailed discussion of BTrees, refer to
|
** For a detailed discussion of BTrees, refer to
|
||||||
|
@ -204,10 +204,6 @@
|
||||||
** * zero or more pages numbers of leaves
|
** * zero or more pages numbers of leaves
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "pager.h"
|
|
||||||
#include "btree.h"
|
|
||||||
#include "os.h"
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
/* Round up a number to the next larger multiple of 8. This is used
|
/* Round up a number to the next larger multiple of 8. This is used
|
||||||
** to force 8-byte alignment on 64-bit architectures.
|
** to force 8-byte alignment on 64-bit architectures.
|
||||||
|
@ -328,6 +324,7 @@ struct Btree {
|
||||||
u8 sharable; /* True if we can share pBt with another db */
|
u8 sharable; /* True if we can share pBt with another db */
|
||||||
u8 locked; /* True if db currently has pBt locked */
|
u8 locked; /* True if db currently has pBt locked */
|
||||||
int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */
|
int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */
|
||||||
|
int nBackup; /* Number of backup operations reading this btree */
|
||||||
Btree *pNext; /* List of other sharable Btrees from the same db */
|
Btree *pNext; /* List of other sharable Btrees from the same db */
|
||||||
Btree *pPrev; /* Back pointer of the same list */
|
Btree *pPrev; /* Back pointer of the same list */
|
||||||
};
|
};
|
||||||
|
@ -383,6 +380,7 @@ struct BtShared {
|
||||||
void *pSchema; /* Pointer to space allocated by sqlite3BtreeSchema() */
|
void *pSchema; /* Pointer to space allocated by sqlite3BtreeSchema() */
|
||||||
void (*xFreeSchema)(void*); /* Destructor for BtShared.pSchema */
|
void (*xFreeSchema)(void*); /* Destructor for BtShared.pSchema */
|
||||||
sqlite3_mutex *mutex; /* Non-recursive mutex required to access this struct */
|
sqlite3_mutex *mutex; /* Non-recursive mutex required to access this struct */
|
||||||
|
Bitvec *pHasContent; /* Set of pages moved to free-list this transaction */
|
||||||
#ifndef SQLITE_OMIT_SHARED_CACHE
|
#ifndef SQLITE_OMIT_SHARED_CACHE
|
||||||
int nRef; /* Number of references to this structure */
|
int nRef; /* Number of references to this structure */
|
||||||
BtShared *pNext; /* Next on a list of sharable BtShared structs */
|
BtShared *pNext; /* Next on a list of sharable BtShared structs */
|
||||||
|
@ -490,18 +488,10 @@ struct BtCursor {
|
||||||
#define CURSOR_REQUIRESEEK 2
|
#define CURSOR_REQUIRESEEK 2
|
||||||
#define CURSOR_FAULT 3
|
#define CURSOR_FAULT 3
|
||||||
|
|
||||||
/* The database page the PENDING_BYTE occupies. This page is never used.
|
/*
|
||||||
** TODO: This macro is very similary to PAGER_MJ_PGNO() in pager.c. They
|
** The database page the PENDING_BYTE occupies. This page is never used.
|
||||||
** should possibly be consolidated (presumably in pager.h).
|
|
||||||
**
|
|
||||||
** If disk I/O is omitted (meaning that the database is stored purely
|
|
||||||
** in memory) then there is no pending byte.
|
|
||||||
*/
|
*/
|
||||||
#ifdef SQLITE_OMIT_DISKIO
|
# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)
|
||||||
# define PENDING_BYTE_PAGE(pBt) 0x7fffffff
|
|
||||||
#else
|
|
||||||
# define PENDING_BYTE_PAGE(pBt) ((Pgno)((PENDING_BYTE/(pBt)->pageSize)+1))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** A linked list of the following structures is stored at BtShared.pLock.
|
** A linked list of the following structures is stored at BtShared.pLock.
|
||||||
|
|
71
build.c
71
build.c
|
@ -22,10 +22,9 @@
|
||||||
** COMMIT
|
** COMMIT
|
||||||
** ROLLBACK
|
** ROLLBACK
|
||||||
**
|
**
|
||||||
** $Id: build.c,v 1.511 2008/12/30 06:24:58 danielk1977 Exp $
|
** $Id: build.c,v 1.518 2009/02/13 03:43:32 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This routine is called when a new SQL statement is beginning to
|
** This routine is called when a new SQL statement is beginning to
|
||||||
|
@ -366,7 +365,7 @@ static void freeIndex(Index *p){
|
||||||
** it is not unlinked from the Table that it indexes.
|
** it is not unlinked from the Table that it indexes.
|
||||||
** Unlinking from the Table must be done by the calling function.
|
** Unlinking from the Table must be done by the calling function.
|
||||||
*/
|
*/
|
||||||
static void sqliteDeleteIndex(Index *p){
|
static void sqlite3DeleteIndex(Index *p){
|
||||||
Index *pOld;
|
Index *pOld;
|
||||||
const char *zName = p->zName;
|
const char *zName = p->zName;
|
||||||
|
|
||||||
|
@ -411,8 +410,8 @@ void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){
|
||||||
** if there were schema changes during the transaction or if a
|
** if there were schema changes during the transaction or if a
|
||||||
** schema-cookie mismatch occurs.
|
** schema-cookie mismatch occurs.
|
||||||
**
|
**
|
||||||
** If iDb<=0 then reset the internal schema tables for all database
|
** If iDb==0 then reset the internal schema tables for all database
|
||||||
** files. If iDb>=2 then reset the internal schema for only the
|
** files. If iDb>=1 then reset the internal schema for only the
|
||||||
** single file indicated.
|
** single file indicated.
|
||||||
*/
|
*/
|
||||||
void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){
|
void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){
|
||||||
|
@ -526,7 +525,7 @@ void sqlite3DeleteTable(Table *pTable){
|
||||||
for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
|
for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
|
||||||
pNext = pIndex->pNext;
|
pNext = pIndex->pNext;
|
||||||
assert( pIndex->pSchema==pTable->pSchema );
|
assert( pIndex->pSchema==pTable->pSchema );
|
||||||
sqliteDeleteIndex(pIndex);
|
sqlite3DeleteIndex(pIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_FOREIGN_KEY
|
#ifndef SQLITE_OMIT_FOREIGN_KEY
|
||||||
|
@ -622,31 +621,41 @@ void sqlite3OpenMasterTable(Parse *p, int iDb){
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The token *pName contains the name of a database (either "main" or
|
** Parameter zName points to a nul-terminated buffer containing the name
|
||||||
** "temp" or the name of an attached db). This routine returns the
|
** of a database ("main", "temp" or the name of an attached db). This
|
||||||
** index of the named database in db->aDb[], or -1 if the named db
|
** function returns the index of the named database in db->aDb[], or
|
||||||
** does not exist.
|
** -1 if the named db cannot be found.
|
||||||
*/
|
*/
|
||||||
int sqlite3FindDb(sqlite3 *db, Token *pName){
|
int sqlite3FindDbName(sqlite3 *db, const char *zName){
|
||||||
int i = -1; /* Database number */
|
int i = -1; /* Database number */
|
||||||
int n; /* Number of characters in the name */
|
|
||||||
Db *pDb; /* A database whose name space is being searched */
|
|
||||||
char *zName; /* Name we are searching for */
|
|
||||||
|
|
||||||
zName = sqlite3NameFromToken(db, pName);
|
|
||||||
if( zName ){
|
if( zName ){
|
||||||
n = sqlite3Strlen30(zName);
|
Db *pDb;
|
||||||
|
int n = sqlite3Strlen30(zName);
|
||||||
for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){
|
for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){
|
||||||
if( (!OMIT_TEMPDB || i!=1 ) && n==sqlite3Strlen30(pDb->zName) &&
|
if( (!OMIT_TEMPDB || i!=1 ) && n==sqlite3Strlen30(pDb->zName) &&
|
||||||
0==sqlite3StrICmp(pDb->zName, zName) ){
|
0==sqlite3StrICmp(pDb->zName, zName) ){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sqlite3DbFree(db, zName);
|
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The token *pName contains the name of a database (either "main" or
|
||||||
|
** "temp" or the name of an attached db). This routine returns the
|
||||||
|
** index of the named database in db->aDb[], or -1 if the named db
|
||||||
|
** does not exist.
|
||||||
|
*/
|
||||||
|
int sqlite3FindDb(sqlite3 *db, Token *pName){
|
||||||
|
int i; /* Database number */
|
||||||
|
char *zName; /* Name we are searching for */
|
||||||
|
zName = sqlite3NameFromToken(db, pName);
|
||||||
|
i = sqlite3FindDbName(db, zName);
|
||||||
|
sqlite3DbFree(db, zName);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
/* The table or view or trigger name is passed to this routine via tokens
|
/* The table or view or trigger name is passed to this routine via tokens
|
||||||
** pName1 and pName2. If the table name was fully qualified, for example:
|
** pName1 and pName2. If the table name was fully qualified, for example:
|
||||||
**
|
**
|
||||||
|
@ -1339,9 +1348,9 @@ static void identPut(char *z, int *pIdx, char *zSignedIdent){
|
||||||
int i, j, needQuote;
|
int i, j, needQuote;
|
||||||
i = *pIdx;
|
i = *pIdx;
|
||||||
for(j=0; zIdent[j]; j++){
|
for(j=0; zIdent[j]; j++){
|
||||||
if( !isalnum(zIdent[j]) && zIdent[j]!='_' ) break;
|
if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;
|
||||||
}
|
}
|
||||||
needQuote = zIdent[j]!=0 || isdigit(zIdent[0])
|
needQuote = zIdent[j]!=0 || sqlite3Isdigit(zIdent[0])
|
||||||
|| sqlite3KeywordCode(zIdent, j)!=TK_ID;
|
|| sqlite3KeywordCode(zIdent, j)!=TK_ID;
|
||||||
if( needQuote ) z[i++] = '"';
|
if( needQuote ) z[i++] = '"';
|
||||||
for(j=0; zIdent[j]; j++){
|
for(j=0; zIdent[j]; j++){
|
||||||
|
@ -1358,7 +1367,7 @@ static void identPut(char *z, int *pIdx, char *zSignedIdent){
|
||||||
** table. Memory to hold the text of the statement is obtained
|
** table. Memory to hold the text of the statement is obtained
|
||||||
** from sqliteMalloc() and must be freed by the calling function.
|
** from sqliteMalloc() and must be freed by the calling function.
|
||||||
*/
|
*/
|
||||||
static char *createTableStmt(sqlite3 *db, Table *p, int isTemp){
|
static char *createTableStmt(sqlite3 *db, Table *p){
|
||||||
int i, k, n;
|
int i, k, n;
|
||||||
char *zStmt;
|
char *zStmt;
|
||||||
char *zSep, *zSep2, *zEnd, *z;
|
char *zSep, *zSep2, *zEnd, *z;
|
||||||
|
@ -1387,8 +1396,7 @@ static char *createTableStmt(sqlite3 *db, Table *p, int isTemp){
|
||||||
db->mallocFailed = 1;
|
db->mallocFailed = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sqlite3_snprintf(n, zStmt,
|
sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
|
||||||
!OMIT_TEMPDB&&isTemp ? "CREATE TEMP TABLE ":"CREATE TABLE ");
|
|
||||||
k = sqlite3Strlen30(zStmt);
|
k = sqlite3Strlen30(zStmt);
|
||||||
identPut(zStmt, &k, p->zName);
|
identPut(zStmt, &k, p->zName);
|
||||||
zStmt[k++] = '(';
|
zStmt[k++] = '(';
|
||||||
|
@ -1553,7 +1561,7 @@ void sqlite3EndTable(
|
||||||
|
|
||||||
/* Compute the complete text of the CREATE statement */
|
/* Compute the complete text of the CREATE statement */
|
||||||
if( pSelect ){
|
if( pSelect ){
|
||||||
zStmt = createTableStmt(db, p, p->pSchema==db->aDb[1].pSchema);
|
zStmt = createTableStmt(db, p);
|
||||||
}else{
|
}else{
|
||||||
n = (int)(pEnd->z - pParse->sNameToken.z) + 1;
|
n = (int)(pEnd->z - pParse->sNameToken.z) + 1;
|
||||||
zStmt = sqlite3MPrintf(db,
|
zStmt = sqlite3MPrintf(db,
|
||||||
|
@ -1712,7 +1720,7 @@ void sqlite3CreateView(
|
||||||
sEnd.n = 0;
|
sEnd.n = 0;
|
||||||
n = (int)(sEnd.z - pBegin->z);
|
n = (int)(sEnd.z - pBegin->z);
|
||||||
z = (const unsigned char*)pBegin->z;
|
z = (const unsigned char*)pBegin->z;
|
||||||
while( n>0 && (z[n-1]==';' || isspace(z[n-1])) ){ n--; }
|
while( n>0 && (z[n-1]==';' || sqlite3Isspace(z[n-1])) ){ n--; }
|
||||||
sEnd.z = &z[n-1];
|
sEnd.z = &z[n-1];
|
||||||
sEnd.n = 1;
|
sEnd.n = 1;
|
||||||
|
|
||||||
|
@ -2420,7 +2428,8 @@ void sqlite3CreateIndex(
|
||||||
pDb = &db->aDb[iDb];
|
pDb = &db->aDb[iDb];
|
||||||
|
|
||||||
if( pTab==0 || pParse->nErr ) goto exit_create_index;
|
if( pTab==0 || pParse->nErr ) goto exit_create_index;
|
||||||
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
|
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
|
||||||
|
&& memcmp(&pTab->zName[7],"altertab_",9)!=0 ){
|
||||||
sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
|
sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);
|
||||||
goto exit_create_index;
|
goto exit_create_index;
|
||||||
}
|
}
|
||||||
|
@ -3422,11 +3431,6 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
|
||||||
** rollback the whole transaction. For operations where all constraints
|
** rollback the whole transaction. For operations where all constraints
|
||||||
** can be checked before any changes are made to the database, it is never
|
** can be checked before any changes are made to the database, it is never
|
||||||
** necessary to undo a write and the checkpoint should not be set.
|
** necessary to undo a write and the checkpoint should not be set.
|
||||||
**
|
|
||||||
** Only database iDb and the temp database are made writable by this call.
|
|
||||||
** If iDb==0, then the main and temp databases are made writable. If
|
|
||||||
** iDb==1 then only the temp database is made writable. If iDb>1 then the
|
|
||||||
** specified auxiliary database and the temp database are made writable.
|
|
||||||
*/
|
*/
|
||||||
void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){
|
void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){
|
||||||
Vdbe *v = sqlite3GetVdbe(pParse);
|
Vdbe *v = sqlite3GetVdbe(pParse);
|
||||||
|
@ -3436,9 +3440,6 @@ void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){
|
||||||
if( setStatement && pParse->nested==0 ){
|
if( setStatement && pParse->nested==0 ){
|
||||||
sqlite3VdbeAddOp1(v, OP_Statement, iDb);
|
sqlite3VdbeAddOp1(v, OP_Statement, iDb);
|
||||||
}
|
}
|
||||||
if( (OMIT_TEMPDB || iDb!=1) && pParse->db->aDb[1].pBt!=0 ){
|
|
||||||
sqlite3BeginWriteOperation(pParse, setStatement, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
** This file contains functions used to access the internal hash tables
|
** This file contains functions used to access the internal hash tables
|
||||||
** of user defined functions and collation sequences.
|
** of user defined functions and collation sequences.
|
||||||
**
|
**
|
||||||
** $Id: callback.c,v 1.34 2008/12/10 21:19:57 drh Exp $
|
** $Id: callback.c,v 1.35 2009/01/31 22:28:49 drh Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
@ -228,8 +228,9 @@ CollSeq *sqlite3FindCollSeq(
|
||||||
** that uses encoding enc. The value returned indicates how well the
|
** that uses encoding enc. The value returned indicates how well the
|
||||||
** request is matched. A higher value indicates a better match.
|
** request is matched. A higher value indicates a better match.
|
||||||
**
|
**
|
||||||
** The returned value is always between 1 and 6, as follows:
|
** The returned value is always between 0 and 6, as follows:
|
||||||
**
|
**
|
||||||
|
** 0: Not a match, or if nArg<0 and the function is has no implementation.
|
||||||
** 1: A variable arguments function that prefers UTF-8 when a UTF-16
|
** 1: A variable arguments function that prefers UTF-8 when a UTF-16
|
||||||
** encoding is requested, or vice versa.
|
** encoding is requested, or vice versa.
|
||||||
** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is
|
** 2: A variable arguments function that uses UTF-16BE when UTF-16LE is
|
||||||
|
@ -244,7 +245,9 @@ CollSeq *sqlite3FindCollSeq(
|
||||||
*/
|
*/
|
||||||
static int matchQuality(FuncDef *p, int nArg, u8 enc){
|
static int matchQuality(FuncDef *p, int nArg, u8 enc){
|
||||||
int match = 0;
|
int match = 0;
|
||||||
if( p->nArg==-1 || p->nArg==nArg || nArg==-1 ){
|
if( p->nArg==-1 || p->nArg==nArg
|
||||||
|
|| (nArg==-1 && (p->xFunc!=0 || p->xStep!=0))
|
||||||
|
){
|
||||||
match = 1;
|
match = 1;
|
||||||
if( p->nArg==nArg || nArg==-1 ){
|
if( p->nArg==nArg || nArg==-1 ){
|
||||||
match = 4;
|
match = 4;
|
||||||
|
|
51
date.c
51
date.c
|
@ -16,7 +16,7 @@
|
||||||
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
|
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
|
||||||
** All other code has file scope.
|
** All other code has file scope.
|
||||||
**
|
**
|
||||||
** $Id: date.c,v 1.99 2008/12/20 13:18:50 drh Exp $
|
** $Id: date.c,v 1.103 2009/02/04 03:59:25 shane Exp $
|
||||||
**
|
**
|
||||||
** SQLite processes all times and dates as Julian Day numbers. The
|
** SQLite processes all times and dates as Julian Day numbers. The
|
||||||
** dates and times are stored as the number of days since noon
|
** dates and times are stored as the number of days since noon
|
||||||
|
@ -46,7 +46,6 @@
|
||||||
** Richmond, Virginia (USA)
|
** Richmond, Virginia (USA)
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -118,7 +117,7 @@ static int getDigits(const char *zDate, ...){
|
||||||
pVal = va_arg(ap, int*);
|
pVal = va_arg(ap, int*);
|
||||||
val = 0;
|
val = 0;
|
||||||
while( N-- ){
|
while( N-- ){
|
||||||
if( !isdigit(*(u8*)zDate) ){
|
if( !sqlite3Isdigit(*zDate) ){
|
||||||
goto end_getDigits;
|
goto end_getDigits;
|
||||||
}
|
}
|
||||||
val = val*10 + *zDate - '0';
|
val = val*10 + *zDate - '0';
|
||||||
|
@ -162,7 +161,7 @@ static int parseTimezone(const char *zDate, DateTime *p){
|
||||||
int sgn = 0;
|
int sgn = 0;
|
||||||
int nHr, nMn;
|
int nHr, nMn;
|
||||||
int c;
|
int c;
|
||||||
while( isspace(*(u8*)zDate) ){ zDate++; }
|
while( sqlite3Isspace(*zDate) ){ zDate++; }
|
||||||
p->tz = 0;
|
p->tz = 0;
|
||||||
c = *zDate;
|
c = *zDate;
|
||||||
if( c=='-' ){
|
if( c=='-' ){
|
||||||
|
@ -182,7 +181,7 @@ static int parseTimezone(const char *zDate, DateTime *p){
|
||||||
zDate += 5;
|
zDate += 5;
|
||||||
p->tz = sgn*(nMn + nHr*60);
|
p->tz = sgn*(nMn + nHr*60);
|
||||||
zulu_time:
|
zulu_time:
|
||||||
while( isspace(*(u8*)zDate) ){ zDate++; }
|
while( sqlite3Isspace(*zDate) ){ zDate++; }
|
||||||
return *zDate!=0;
|
return *zDate!=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,10 +205,10 @@ static int parseHhMmSs(const char *zDate, DateTime *p){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
zDate += 2;
|
zDate += 2;
|
||||||
if( *zDate=='.' && isdigit((u8)zDate[1]) ){
|
if( *zDate=='.' && sqlite3Isdigit(zDate[1]) ){
|
||||||
double rScale = 1.0;
|
double rScale = 1.0;
|
||||||
zDate++;
|
zDate++;
|
||||||
while( isdigit(*(u8*)zDate) ){
|
while( sqlite3Isdigit(*zDate) ){
|
||||||
ms = ms*10.0 + *zDate - '0';
|
ms = ms*10.0 + *zDate - '0';
|
||||||
rScale *= 10.0;
|
rScale *= 10.0;
|
||||||
zDate++;
|
zDate++;
|
||||||
|
@ -294,7 +293,7 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
zDate += 10;
|
zDate += 10;
|
||||||
while( isspace(*(u8*)zDate) || 'T'==*(u8*)zDate ){ zDate++; }
|
while( sqlite3Isspace(*zDate) || 'T'==*(u8*)zDate ){ zDate++; }
|
||||||
if( parseHhMmSs(zDate, p)==0 ){
|
if( parseHhMmSs(zDate, p)==0 ){
|
||||||
/* We got the time */
|
/* We got the time */
|
||||||
}else if( *zDate==0 ){
|
}else if( *zDate==0 ){
|
||||||
|
@ -630,6 +629,7 @@ static int parseModifier(const char *zMod, DateTime *p){
|
||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9': {
|
case '9': {
|
||||||
|
double rRounder;
|
||||||
n = getValue(z, &r);
|
n = getValue(z, &r);
|
||||||
assert( n>=1 );
|
assert( n>=1 );
|
||||||
if( z[n]==':' ){
|
if( z[n]==':' ){
|
||||||
|
@ -641,7 +641,7 @@ static int parseModifier(const char *zMod, DateTime *p){
|
||||||
const char *z2 = z;
|
const char *z2 = z;
|
||||||
DateTime tx;
|
DateTime tx;
|
||||||
sqlite3_int64 day;
|
sqlite3_int64 day;
|
||||||
if( !isdigit(*(u8*)z2) ) z2++;
|
if( !sqlite3Isdigit(*z2) ) z2++;
|
||||||
memset(&tx, 0, sizeof(tx));
|
memset(&tx, 0, sizeof(tx));
|
||||||
if( parseHhMmSs(z2, &tx) ) break;
|
if( parseHhMmSs(z2, &tx) ) break;
|
||||||
computeJD(&tx);
|
computeJD(&tx);
|
||||||
|
@ -656,20 +656,21 @@ static int parseModifier(const char *zMod, DateTime *p){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
z += n;
|
z += n;
|
||||||
while( isspace(*(u8*)z) ) z++;
|
while( sqlite3Isspace(*z) ) z++;
|
||||||
n = sqlite3Strlen30(z);
|
n = sqlite3Strlen30(z);
|
||||||
if( n>10 || n<3 ) break;
|
if( n>10 || n<3 ) break;
|
||||||
if( z[n-1]=='s' ){ z[n-1] = 0; n--; }
|
if( z[n-1]=='s' ){ z[n-1] = 0; n--; }
|
||||||
computeJD(p);
|
computeJD(p);
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
rRounder = r<0 ? -0.5 : +0.5;
|
||||||
if( n==3 && strcmp(z,"day")==0 ){
|
if( n==3 && strcmp(z,"day")==0 ){
|
||||||
p->iJD += (sqlite3_int64)(r*86400000.0 + 0.5);
|
p->iJD += (sqlite3_int64)(r*86400000.0 + rRounder);
|
||||||
}else if( n==4 && strcmp(z,"hour")==0 ){
|
}else if( n==4 && strcmp(z,"hour")==0 ){
|
||||||
p->iJD += (sqlite3_int64)(r*(86400000.0/24.0) + 0.5);
|
p->iJD += (sqlite3_int64)(r*(86400000.0/24.0) + rRounder);
|
||||||
}else if( n==6 && strcmp(z,"minute")==0 ){
|
}else if( n==6 && strcmp(z,"minute")==0 ){
|
||||||
p->iJD += (sqlite3_int64)(r*(86400000.0/(24.0*60.0)) + 0.5);
|
p->iJD += (sqlite3_int64)(r*(86400000.0/(24.0*60.0)) + rRounder);
|
||||||
}else if( n==6 && strcmp(z,"second")==0 ){
|
}else if( n==6 && strcmp(z,"second")==0 ){
|
||||||
p->iJD += (sqlite3_int64)(r*(86400000.0/(24.0*60.0*60.0)) + 0.5);
|
p->iJD += (sqlite3_int64)(r*(86400000.0/(24.0*60.0*60.0)) + rRounder);
|
||||||
}else if( n==5 && strcmp(z,"month")==0 ){
|
}else if( n==5 && strcmp(z,"month")==0 ){
|
||||||
int x, y;
|
int x, y;
|
||||||
computeYMD_HMS(p);
|
computeYMD_HMS(p);
|
||||||
|
@ -681,13 +682,17 @@ static int parseModifier(const char *zMod, DateTime *p){
|
||||||
computeJD(p);
|
computeJD(p);
|
||||||
y = (int)r;
|
y = (int)r;
|
||||||
if( y!=r ){
|
if( y!=r ){
|
||||||
p->iJD += (sqlite3_int64)((r - y)*30.0*86400000.0 + 0.5);
|
p->iJD += (sqlite3_int64)((r - y)*30.0*86400000.0 + rRounder);
|
||||||
}
|
}
|
||||||
}else if( n==4 && strcmp(z,"year")==0 ){
|
}else if( n==4 && strcmp(z,"year")==0 ){
|
||||||
|
int y = (int)r;
|
||||||
computeYMD_HMS(p);
|
computeYMD_HMS(p);
|
||||||
p->Y += (int)r;
|
p->Y += y;
|
||||||
p->validJD = 0;
|
p->validJD = 0;
|
||||||
computeJD(p);
|
computeJD(p);
|
||||||
|
if( y!=r ){
|
||||||
|
p->iJD += (sqlite3_int64)((r - y)*365.0*86400000.0 + rRounder);
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
|
@ -887,6 +892,10 @@ static void strftimeFunc(
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
testcase( n==sizeof(zBuf)-1 );
|
||||||
|
testcase( n==sizeof(zBuf) );
|
||||||
|
testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH]+1 );
|
||||||
|
testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH] );
|
||||||
if( n<sizeof(zBuf) ){
|
if( n<sizeof(zBuf) ){
|
||||||
z = zBuf;
|
z = zBuf;
|
||||||
}else if( n>(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ){
|
}else if( n>(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ){
|
||||||
|
@ -1033,9 +1042,19 @@ static void currentTimeFunc(
|
||||||
double rT;
|
double rT;
|
||||||
char zBuf[20];
|
char zBuf[20];
|
||||||
|
|
||||||
|
UNUSED_PARAMETER(argc);
|
||||||
|
UNUSED_PARAMETER(argv);
|
||||||
|
|
||||||
db = sqlite3_context_db_handle(context);
|
db = sqlite3_context_db_handle(context);
|
||||||
sqlite3OsCurrentTime(db->pVfs, &rT);
|
sqlite3OsCurrentTime(db->pVfs, &rT);
|
||||||
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
t = 86400.0*(rT - 2440587.5) + 0.5;
|
t = 86400.0*(rT - 2440587.5) + 0.5;
|
||||||
|
#else
|
||||||
|
/* without floating point support, rT will have
|
||||||
|
** already lost fractional day precision.
|
||||||
|
*/
|
||||||
|
t = 86400 * (rT - 2440587) - 43200;
|
||||||
|
#endif
|
||||||
#ifdef HAVE_GMTIME_R
|
#ifdef HAVE_GMTIME_R
|
||||||
{
|
{
|
||||||
struct tm sNow;
|
struct tm sNow;
|
||||||
|
|
17
expr.c
17
expr.c
|
@ -12,10 +12,9 @@
|
||||||
** This file contains routines used for analyzing expressions and
|
** This file contains routines used for analyzing expressions and
|
||||||
** for generating VDBE code that evaluates expressions in SQLite.
|
** for generating VDBE code that evaluates expressions in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: expr.c,v 1.409 2009/01/10 13:24:51 drh Exp $
|
** $Id: expr.c,v 1.411 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Return the 'affinity' of the expression pExpr if any.
|
** Return the 'affinity' of the expression pExpr if any.
|
||||||
|
@ -1452,7 +1451,7 @@ static char *dup8bytes(Vdbe *v, const char *in){
|
||||||
*/
|
*/
|
||||||
static void codeReal(Vdbe *v, const char *z, int n, int negateFlag, int iMem){
|
static void codeReal(Vdbe *v, const char *z, int n, int negateFlag, int iMem){
|
||||||
assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed );
|
assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed );
|
||||||
assert( !z || !isdigit(z[n]) );
|
assert( !z || !sqlite3Isdigit(z[n]) );
|
||||||
UNUSED_PARAMETER(n);
|
UNUSED_PARAMETER(n);
|
||||||
if( z ){
|
if( z ){
|
||||||
double value;
|
double value;
|
||||||
|
@ -1486,7 +1485,7 @@ static void codeInteger(Vdbe *v, Expr *pExpr, int negFlag, int iMem){
|
||||||
}else if( (z = (char*)pExpr->token.z)!=0 ){
|
}else if( (z = (char*)pExpr->token.z)!=0 ){
|
||||||
int i;
|
int i;
|
||||||
int n = pExpr->token.n;
|
int n = pExpr->token.n;
|
||||||
assert( !isdigit(z[n]) );
|
assert( !sqlite3Isdigit(z[n]) );
|
||||||
if( sqlite3GetInt32(z, &i) ){
|
if( sqlite3GetInt32(z, &i) ){
|
||||||
if( negFlag ) i = -i;
|
if( negFlag ) i = -i;
|
||||||
sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);
|
sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);
|
||||||
|
@ -1933,12 +1932,10 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||||
case TK_UMINUS: {
|
case TK_UMINUS: {
|
||||||
Expr *pLeft = pExpr->pLeft;
|
Expr *pLeft = pExpr->pLeft;
|
||||||
assert( pLeft );
|
assert( pLeft );
|
||||||
if( pLeft->op==TK_FLOAT || pLeft->op==TK_INTEGER ){
|
if( pLeft->op==TK_FLOAT ){
|
||||||
if( pLeft->op==TK_FLOAT ){
|
codeReal(v, (char*)pLeft->token.z, pLeft->token.n, 1, target);
|
||||||
codeReal(v, (char*)pLeft->token.z, pLeft->token.n, 1, target);
|
}else if( pLeft->op==TK_INTEGER ){
|
||||||
}else{
|
codeInteger(v, pLeft, 1, target);
|
||||||
codeInteger(v, pLeft, 1, target);
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
regFree1 = r1 = sqlite3GetTempReg(pParse);
|
regFree1 = r1 = sqlite3GetTempReg(pParse);
|
||||||
sqlite3VdbeAddOp2(v, OP_Integer, 0, r1);
|
sqlite3VdbeAddOp2(v, OP_Integer, 0, r1);
|
||||||
|
|
|
@ -145,8 +145,8 @@ static int getNextToken(
|
||||||
pRet->pPhrase->isNot = 1;
|
pRet->pPhrase->isNot = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nConsumed = iEnd;
|
||||||
}
|
}
|
||||||
nConsumed = iEnd;
|
|
||||||
|
|
||||||
pModule->xClose(pCursor);
|
pModule->xClose(pCursor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,10 @@ struct sqlite3_tokenizer_module {
|
||||||
** stemming has been performed). *pnBytes should be set to the length
|
** stemming has been performed). *pnBytes should be set to the length
|
||||||
** of this buffer in bytes. The input text that generated the token is
|
** of this buffer in bytes. The input text that generated the token is
|
||||||
** identified by the byte offsets returned in *piStartOffset and
|
** identified by the byte offsets returned in *piStartOffset and
|
||||||
** *piEndOffset.
|
** *piEndOffset. *piStartOffset should be set to the index of the first
|
||||||
|
** byte of the token in the input buffer. *piEndOffset should be set
|
||||||
|
** to the index of the first byte just past the end of the token in
|
||||||
|
** the input buffer.
|
||||||
**
|
**
|
||||||
** The buffer *ppToken is set to point at is managed by the tokenizer
|
** The buffer *ppToken is set to point at is managed by the tokenizer
|
||||||
** implementation. It is only required to be valid until the next call
|
** implementation. It is only required to be valid until the next call
|
||||||
|
|
104
func.c
104
func.c
|
@ -16,10 +16,9 @@
|
||||||
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
||||||
** All other code has file scope.
|
** All other code has file scope.
|
||||||
**
|
**
|
||||||
** $Id: func.c,v 1.209 2008/12/10 23:04:13 drh Exp $
|
** $Id: func.c,v 1.222 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
|
@ -44,7 +43,7 @@ static void minmaxFunc(
|
||||||
int iBest;
|
int iBest;
|
||||||
CollSeq *pColl;
|
CollSeq *pColl;
|
||||||
|
|
||||||
if( argc==0 ) return;
|
assert( argc>1 );
|
||||||
mask = sqlite3_user_data(context)==0 ? 0 : -1;
|
mask = sqlite3_user_data(context)==0 ? 0 : -1;
|
||||||
pColl = sqlite3GetFuncCollSeq(context);
|
pColl = sqlite3GetFuncCollSeq(context);
|
||||||
assert( pColl );
|
assert( pColl );
|
||||||
|
@ -54,6 +53,7 @@ static void minmaxFunc(
|
||||||
for(i=1; i<argc; i++){
|
for(i=1; i<argc; i++){
|
||||||
if( sqlite3_value_type(argv[i])==SQLITE_NULL ) return;
|
if( sqlite3_value_type(argv[i])==SQLITE_NULL ) return;
|
||||||
if( (sqlite3MemCompare(argv[iBest], argv[i], pColl)^mask)>=0 ){
|
if( (sqlite3MemCompare(argv[iBest], argv[i], pColl)^mask)>=0 ){
|
||||||
|
testcase( mask==0 );
|
||||||
iBest = i;
|
iBest = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,11 @@ static void typeofFunc(
|
||||||
const char *z = 0;
|
const char *z = 0;
|
||||||
UNUSED_PARAMETER(NotUsed);
|
UNUSED_PARAMETER(NotUsed);
|
||||||
switch( sqlite3_value_type(argv[0]) ){
|
switch( sqlite3_value_type(argv[0]) ){
|
||||||
case SQLITE_NULL: z = "null"; break;
|
|
||||||
case SQLITE_INTEGER: z = "integer"; break;
|
case SQLITE_INTEGER: z = "integer"; break;
|
||||||
case SQLITE_TEXT: z = "text"; break;
|
case SQLITE_TEXT: z = "text"; break;
|
||||||
case SQLITE_FLOAT: z = "real"; break;
|
case SQLITE_FLOAT: z = "real"; break;
|
||||||
case SQLITE_BLOB: z = "blob"; break;
|
case SQLITE_BLOB: z = "blob"; break;
|
||||||
|
default: z = "null"; break;
|
||||||
}
|
}
|
||||||
sqlite3_result_text(context, z, -1, SQLITE_STATIC);
|
sqlite3_result_text(context, z, -1, SQLITE_STATIC);
|
||||||
}
|
}
|
||||||
|
@ -170,8 +170,14 @@ static void substrFunc(
|
||||||
int len;
|
int len;
|
||||||
int p0type;
|
int p0type;
|
||||||
i64 p1, p2;
|
i64 p1, p2;
|
||||||
|
int negP2 = 0;
|
||||||
|
|
||||||
assert( argc==3 || argc==2 );
|
assert( argc==3 || argc==2 );
|
||||||
|
if( sqlite3_value_type(argv[1])==SQLITE_NULL
|
||||||
|
|| (argc==3 && sqlite3_value_type(argv[2])==SQLITE_NULL)
|
||||||
|
){
|
||||||
|
return;
|
||||||
|
}
|
||||||
p0type = sqlite3_value_type(argv[0]);
|
p0type = sqlite3_value_type(argv[0]);
|
||||||
if( p0type==SQLITE_BLOB ){
|
if( p0type==SQLITE_BLOB ){
|
||||||
len = sqlite3_value_bytes(argv[0]);
|
len = sqlite3_value_bytes(argv[0]);
|
||||||
|
@ -189,6 +195,10 @@ static void substrFunc(
|
||||||
p1 = sqlite3_value_int(argv[1]);
|
p1 = sqlite3_value_int(argv[1]);
|
||||||
if( argc==3 ){
|
if( argc==3 ){
|
||||||
p2 = sqlite3_value_int(argv[2]);
|
p2 = sqlite3_value_int(argv[2]);
|
||||||
|
if( p2<0 ){
|
||||||
|
p2 = -p2;
|
||||||
|
negP2 = 1;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];
|
p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];
|
||||||
}
|
}
|
||||||
|
@ -196,13 +206,25 @@ static void substrFunc(
|
||||||
p1 += len;
|
p1 += len;
|
||||||
if( p1<0 ){
|
if( p1<0 ){
|
||||||
p2 += p1;
|
p2 += p1;
|
||||||
|
if( p2<0 ) p2 = 0;
|
||||||
p1 = 0;
|
p1 = 0;
|
||||||
}
|
}
|
||||||
}else if( p1>0 ){
|
}else if( p1>0 ){
|
||||||
p1--;
|
p1--;
|
||||||
|
}else if( p2>0 ){
|
||||||
|
p2--;
|
||||||
}
|
}
|
||||||
|
if( negP2 ){
|
||||||
|
p1 -= p2;
|
||||||
|
if( p1<0 ){
|
||||||
|
p2 += p1;
|
||||||
|
p1 = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert( p1>=0 && p2>=0 );
|
||||||
if( p1+p2>len ){
|
if( p1+p2>len ){
|
||||||
p2 = len-p1;
|
p2 = len-p1;
|
||||||
|
if( p2<0 ) p2 = 0;
|
||||||
}
|
}
|
||||||
if( p0type!=SQLITE_BLOB ){
|
if( p0type!=SQLITE_BLOB ){
|
||||||
while( *z && p1 ){
|
while( *z && p1 ){
|
||||||
|
@ -214,7 +236,6 @@ static void substrFunc(
|
||||||
}
|
}
|
||||||
sqlite3_result_text(context, (char*)z, (int)(z2-z), SQLITE_TRANSIENT);
|
sqlite3_result_text(context, (char*)z, (int)(z2-z), SQLITE_TRANSIENT);
|
||||||
}else{
|
}else{
|
||||||
if( p2<0 ) p2 = 0;
|
|
||||||
sqlite3_result_blob(context, (char*)&z[p1], (int)p2, SQLITE_TRANSIENT);
|
sqlite3_result_blob(context, (char*)&z[p1], (int)p2, SQLITE_TRANSIENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,6 +243,7 @@ static void substrFunc(
|
||||||
/*
|
/*
|
||||||
** Implementation of the round() function
|
** Implementation of the round() function
|
||||||
*/
|
*/
|
||||||
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||||
int n = 0;
|
int n = 0;
|
||||||
double r;
|
double r;
|
||||||
|
@ -239,6 +261,7 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||||
sqlite3AtoF(zBuf, &r);
|
sqlite3AtoF(zBuf, &r);
|
||||||
sqlite3_result_double(context, r);
|
sqlite3_result_double(context, r);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Allocate nByte bytes of space using sqlite3_malloc(). If the
|
** Allocate nByte bytes of space using sqlite3_malloc(). If the
|
||||||
|
@ -266,7 +289,7 @@ static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||||
char *z1;
|
char *z1;
|
||||||
const char *z2;
|
const char *z2;
|
||||||
int i, n;
|
int i, n;
|
||||||
if( argc<1 || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
|
UNUSED_PARAMETER(argc);
|
||||||
z2 = (char*)sqlite3_value_text(argv[0]);
|
z2 = (char*)sqlite3_value_text(argv[0]);
|
||||||
n = sqlite3_value_bytes(argv[0]);
|
n = sqlite3_value_bytes(argv[0]);
|
||||||
/* Verify that the call to _bytes() does not invalidate the _text() pointer */
|
/* Verify that the call to _bytes() does not invalidate the _text() pointer */
|
||||||
|
@ -276,17 +299,17 @@ static void upperFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||||
if( z1 ){
|
if( z1 ){
|
||||||
memcpy(z1, z2, n+1);
|
memcpy(z1, z2, n+1);
|
||||||
for(i=0; z1[i]; i++){
|
for(i=0; z1[i]; i++){
|
||||||
z1[i] = (char)toupper(z1[i]);
|
z1[i] = (char)sqlite3Toupper(z1[i]);
|
||||||
}
|
}
|
||||||
sqlite3_result_text(context, z1, -1, sqlite3_free);
|
sqlite3_result_text(context, z1, -1, sqlite3_free);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||||
char *z1;
|
u8 *z1;
|
||||||
const char *z2;
|
const char *z2;
|
||||||
int i, n;
|
int i, n;
|
||||||
if( argc<1 || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
|
UNUSED_PARAMETER(argc);
|
||||||
z2 = (char*)sqlite3_value_text(argv[0]);
|
z2 = (char*)sqlite3_value_text(argv[0]);
|
||||||
n = sqlite3_value_bytes(argv[0]);
|
n = sqlite3_value_bytes(argv[0]);
|
||||||
/* Verify that the call to _bytes() does not invalidate the _text() pointer */
|
/* Verify that the call to _bytes() does not invalidate the _text() pointer */
|
||||||
|
@ -296,9 +319,9 @@ static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||||
if( z1 ){
|
if( z1 ){
|
||||||
memcpy(z1, z2, n+1);
|
memcpy(z1, z2, n+1);
|
||||||
for(i=0; z1[i]; i++){
|
for(i=0; z1[i]; i++){
|
||||||
z1[i] = (char)tolower(z1[i]);
|
z1[i] = sqlite3Tolower(z1[i]);
|
||||||
}
|
}
|
||||||
sqlite3_result_text(context, z1, -1, sqlite3_free);
|
sqlite3_result_text(context, (char *)z1, -1, sqlite3_free);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -687,12 +710,9 @@ static const char hexdigits[] = {
|
||||||
** single-quote escapes.
|
** single-quote escapes.
|
||||||
*/
|
*/
|
||||||
static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||||
if( argc<1 ) return;
|
assert( argc==1 );
|
||||||
|
UNUSED_PARAMETER(argc);
|
||||||
switch( sqlite3_value_type(argv[0]) ){
|
switch( sqlite3_value_type(argv[0]) ){
|
||||||
case SQLITE_NULL: {
|
|
||||||
sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case SQLITE_INTEGER:
|
case SQLITE_INTEGER:
|
||||||
case SQLITE_FLOAT: {
|
case SQLITE_FLOAT: {
|
||||||
sqlite3_result_value(context, argv[0]);
|
sqlite3_result_value(context, argv[0]);
|
||||||
|
@ -740,6 +760,12 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||||
z[j] = 0;
|
z[j] = 0;
|
||||||
sqlite3_result_text(context, z, j, sqlite3_free);
|
sqlite3_result_text(context, z, j, sqlite3_free);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
assert( sqlite3_value_type(argv[0])==SQLITE_NULL );
|
||||||
|
sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -821,7 +847,16 @@ static void replaceFunc(
|
||||||
nStr = sqlite3_value_bytes(argv[0]);
|
nStr = sqlite3_value_bytes(argv[0]);
|
||||||
assert( zStr==sqlite3_value_text(argv[0]) ); /* No encoding change */
|
assert( zStr==sqlite3_value_text(argv[0]) ); /* No encoding change */
|
||||||
zPattern = sqlite3_value_text(argv[1]);
|
zPattern = sqlite3_value_text(argv[1]);
|
||||||
if( zPattern==0 || zPattern[0]==0 ) return;
|
if( zPattern==0 ){
|
||||||
|
assert( sqlite3_value_type(argv[1])==SQLITE_NULL
|
||||||
|
|| sqlite3_context_db_handle(context)->mallocFailed );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if( zPattern[0]==0 ){
|
||||||
|
assert( sqlite3_value_type(argv[1])!=SQLITE_NULL );
|
||||||
|
sqlite3_result_value(context, argv[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
nPattern = sqlite3_value_bytes(argv[1]);
|
nPattern = sqlite3_value_bytes(argv[1]);
|
||||||
assert( zPattern==sqlite3_value_text(argv[1]) ); /* No encoding change */
|
assert( zPattern==sqlite3_value_text(argv[1]) ); /* No encoding change */
|
||||||
zRep = sqlite3_value_text(argv[2]);
|
zRep = sqlite3_value_text(argv[2]);
|
||||||
|
@ -977,10 +1012,10 @@ static void soundexFunc(
|
||||||
assert( argc==1 );
|
assert( argc==1 );
|
||||||
zIn = (u8*)sqlite3_value_text(argv[0]);
|
zIn = (u8*)sqlite3_value_text(argv[0]);
|
||||||
if( zIn==0 ) zIn = (u8*)"";
|
if( zIn==0 ) zIn = (u8*)"";
|
||||||
for(i=0; zIn[i] && !isalpha(zIn[i]); i++){}
|
for(i=0; zIn[i] && !sqlite3Isalpha(zIn[i]); i++){}
|
||||||
if( zIn[i] ){
|
if( zIn[i] ){
|
||||||
u8 prevcode = iCode[zIn[i]&0x7f];
|
u8 prevcode = iCode[zIn[i]&0x7f];
|
||||||
zResult[0] = toupper(zIn[i]);
|
zResult[0] = sqlite3Toupper(zIn[i]);
|
||||||
for(j=1; j<4 && zIn[i]; i++){
|
for(j=1; j<4 && zIn[i]; i++){
|
||||||
int code = iCode[zIn[i]&0x7f];
|
int code = iCode[zIn[i]&0x7f];
|
||||||
if( code>0 ){
|
if( code>0 ){
|
||||||
|
@ -1098,7 +1133,8 @@ static void avgFinalize(sqlite3_context *context){
|
||||||
static void totalFinalize(sqlite3_context *context){
|
static void totalFinalize(sqlite3_context *context){
|
||||||
SumCtx *p;
|
SumCtx *p;
|
||||||
p = sqlite3_aggregate_context(context, 0);
|
p = sqlite3_aggregate_context(context, 0);
|
||||||
sqlite3_result_double(context, p ? p->rSum : 0.0);
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
sqlite3_result_double(context, p ? p->rSum : (double)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1185,8 +1221,9 @@ static void groupConcatStep(
|
||||||
const char *zVal;
|
const char *zVal;
|
||||||
StrAccum *pAccum;
|
StrAccum *pAccum;
|
||||||
const char *zSep;
|
const char *zSep;
|
||||||
int nVal, nSep, i;
|
int nVal, nSep;
|
||||||
if( argc==0 || sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
|
assert( argc==1 || argc==2 );
|
||||||
|
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
|
||||||
pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
|
pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
|
||||||
|
|
||||||
if( pAccum ){
|
if( pAccum ){
|
||||||
|
@ -1194,22 +1231,18 @@ static void groupConcatStep(
|
||||||
pAccum->useMalloc = 1;
|
pAccum->useMalloc = 1;
|
||||||
pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
|
pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
|
||||||
if( pAccum->nChar ){
|
if( pAccum->nChar ){
|
||||||
if( argc>1 ){
|
if( argc==2 ){
|
||||||
zSep = (char*)sqlite3_value_text(argv[argc-1]);
|
zSep = (char*)sqlite3_value_text(argv[1]);
|
||||||
nSep = sqlite3_value_bytes(argv[argc-1]);
|
nSep = sqlite3_value_bytes(argv[1]);
|
||||||
}else{
|
}else{
|
||||||
zSep = ",";
|
zSep = ",";
|
||||||
nSep = 1;
|
nSep = 1;
|
||||||
}
|
}
|
||||||
sqlite3StrAccumAppend(pAccum, zSep, nSep);
|
sqlite3StrAccumAppend(pAccum, zSep, nSep);
|
||||||
}
|
}
|
||||||
i = 0;
|
zVal = (char*)sqlite3_value_text(argv[0]);
|
||||||
do{
|
nVal = sqlite3_value_bytes(argv[0]);
|
||||||
zVal = (char*)sqlite3_value_text(argv[i]);
|
sqlite3StrAccumAppend(pAccum, zVal, nVal);
|
||||||
nVal = sqlite3_value_bytes(argv[i]);
|
|
||||||
sqlite3StrAccumAppend(pAccum, zVal, nVal);
|
|
||||||
i++;
|
|
||||||
}while( i<argc-1 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void groupConcatFinalize(sqlite3_context *context){
|
static void groupConcatFinalize(sqlite3_context *context){
|
||||||
|
@ -1348,8 +1381,10 @@ void sqlite3RegisterGlobalFunctions(void){
|
||||||
FUNCTION(substr, 2, 0, 0, substrFunc ),
|
FUNCTION(substr, 2, 0, 0, substrFunc ),
|
||||||
FUNCTION(substr, 3, 0, 0, substrFunc ),
|
FUNCTION(substr, 3, 0, 0, substrFunc ),
|
||||||
FUNCTION(abs, 1, 0, 0, absFunc ),
|
FUNCTION(abs, 1, 0, 0, absFunc ),
|
||||||
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
FUNCTION(round, 1, 0, 0, roundFunc ),
|
FUNCTION(round, 1, 0, 0, roundFunc ),
|
||||||
FUNCTION(round, 2, 0, 0, roundFunc ),
|
FUNCTION(round, 2, 0, 0, roundFunc ),
|
||||||
|
#endif
|
||||||
FUNCTION(upper, 1, 0, 0, upperFunc ),
|
FUNCTION(upper, 1, 0, 0, upperFunc ),
|
||||||
FUNCTION(lower, 1, 0, 0, lowerFunc ),
|
FUNCTION(lower, 1, 0, 0, lowerFunc ),
|
||||||
FUNCTION(coalesce, 1, 0, 0, 0 ),
|
FUNCTION(coalesce, 1, 0, 0, 0 ),
|
||||||
|
@ -1357,7 +1392,7 @@ void sqlite3RegisterGlobalFunctions(void){
|
||||||
FUNCTION(coalesce, 0, 0, 0, 0 ),
|
FUNCTION(coalesce, 0, 0, 0, 0 ),
|
||||||
FUNCTION(hex, 1, 0, 0, hexFunc ),
|
FUNCTION(hex, 1, 0, 0, hexFunc ),
|
||||||
FUNCTION(ifnull, 2, 0, 1, ifnullFunc ),
|
FUNCTION(ifnull, 2, 0, 1, ifnullFunc ),
|
||||||
FUNCTION(random, -1, 0, 0, randomFunc ),
|
FUNCTION(random, 0, 0, 0, randomFunc ),
|
||||||
FUNCTION(randomblob, 1, 0, 0, randomBlob ),
|
FUNCTION(randomblob, 1, 0, 0, randomBlob ),
|
||||||
FUNCTION(nullif, 2, 0, 1, nullifFunc ),
|
FUNCTION(nullif, 2, 0, 1, nullifFunc ),
|
||||||
FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
|
FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
|
||||||
|
@ -1379,7 +1414,8 @@ void sqlite3RegisterGlobalFunctions(void){
|
||||||
AGGREGATE(avg, 1, 0, 0, sumStep, avgFinalize ),
|
AGGREGATE(avg, 1, 0, 0, sumStep, avgFinalize ),
|
||||||
AGGREGATE(count, 0, 0, 0, countStep, countFinalize ),
|
AGGREGATE(count, 0, 0, 0, countStep, countFinalize ),
|
||||||
AGGREGATE(count, 1, 0, 0, countStep, countFinalize ),
|
AGGREGATE(count, 1, 0, 0, countStep, countFinalize ),
|
||||||
AGGREGATE(group_concat, -1, 0, 0, groupConcatStep, groupConcatFinalize),
|
AGGREGATE(group_concat, 1, 0, 0, groupConcatStep, groupConcatFinalize),
|
||||||
|
AGGREGATE(group_concat, 2, 0, 0, groupConcatStep, groupConcatFinalize),
|
||||||
|
|
||||||
LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
|
LIKEFUNC(glob, 2, &globInfo, SQLITE_FUNC_LIKE|SQLITE_FUNC_CASE),
|
||||||
#ifdef SQLITE_CASE_SENSITIVE_LIKE
|
#ifdef SQLITE_CASE_SENSITIVE_LIKE
|
||||||
|
|
88
global.c
88
global.c
|
@ -12,7 +12,7 @@
|
||||||
**
|
**
|
||||||
** This file contains definitions of global variables and contants.
|
** This file contains definitions of global variables and contants.
|
||||||
**
|
**
|
||||||
** $Id: global.c,v 1.9 2008/12/08 18:19:18 drh Exp $
|
** $Id: global.c,v 1.12 2009/02/05 16:31:46 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
@ -62,6 +62,72 @@ const unsigned char sqlite3UpperToLower[] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The following 256 byte lookup table is used to support SQLites built-in
|
||||||
|
** equivalents to the following standard library functions:
|
||||||
|
**
|
||||||
|
** isspace() 0x01
|
||||||
|
** isalpha() 0x02
|
||||||
|
** isdigit() 0x04
|
||||||
|
** isalnum() 0x06
|
||||||
|
** isxdigit() 0x08
|
||||||
|
** toupper() 0x20
|
||||||
|
**
|
||||||
|
** Bit 0x20 is set if the mapped character requires translation to upper
|
||||||
|
** case. i.e. if the character is a lower-case ASCII character.
|
||||||
|
** If x is a lower-case ASCII character, then its upper-case equivalent
|
||||||
|
** is (x - 0x20). Therefore toupper() can be implemented as:
|
||||||
|
**
|
||||||
|
** (x & ~(map[x]&0x20))
|
||||||
|
**
|
||||||
|
** Standard function tolower() is implemented using the sqlite3UpperToLower[]
|
||||||
|
** array. tolower() is used more often than toupper() by SQLite.
|
||||||
|
**
|
||||||
|
** SQLite's versions are identical to the standard versions assuming a
|
||||||
|
** locale of "C". They are implemented as macros in sqliteInt.h.
|
||||||
|
*/
|
||||||
|
#ifdef SQLITE_ASCII
|
||||||
|
const unsigned char sqlite3CtypeMap[256] = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 00..07 ........ */
|
||||||
|
0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, /* 08..0f ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 10..17 ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 18..1f ........ */
|
||||||
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 20..27 !"#$%&' */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 28..2f ()*+,-./ */
|
||||||
|
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, /* 30..37 01234567 */
|
||||||
|
0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 38..3f 89:;<=>? */
|
||||||
|
|
||||||
|
0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x02, /* 40..47 @ABCDEFG */
|
||||||
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 48..4f HIJKLMNO */
|
||||||
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 50..57 PQRSTUVW */
|
||||||
|
0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, /* 58..5f XYZ[\]^_ */
|
||||||
|
0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x22, /* 60..67 `abcdefg */
|
||||||
|
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, /* 68..6f hijklmno */
|
||||||
|
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, /* 70..77 pqrstuvw */
|
||||||
|
0x22, 0x22, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, /* 78..7f xyz{|}~. */
|
||||||
|
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 80..87 ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 88..8f ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 90..97 ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 98..9f ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a0..a7 ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a8..af ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b0..b7 ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b8..bf ........ */
|
||||||
|
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c0..c7 ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c8..cf ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d0..d7 ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d8..df ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e0..e7 ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e8..ef ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f0..f7 ........ */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 /* f8..ff ........ */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The following singleton contains the global configuration for
|
** The following singleton contains the global configuration for
|
||||||
** the SQLite library.
|
** the SQLite library.
|
||||||
|
@ -102,3 +168,23 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = {
|
||||||
** read-only.
|
** read-only.
|
||||||
*/
|
*/
|
||||||
SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
|
SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The value of the "pending" byte must be 0x40000000 (1 byte past the
|
||||||
|
** 1-gibabyte boundary) in a compatible database. SQLite never uses
|
||||||
|
** the database page that contains the pending byte. It never attempts
|
||||||
|
** to read or write that page. The pending byte page is set assign
|
||||||
|
** for use by the VFS layers as space for managing file locks.
|
||||||
|
**
|
||||||
|
** During testing, it is often desirable to move the pending byte to
|
||||||
|
** a different position in the file. This allows code that has to
|
||||||
|
** deal with the pending byte to run on files that are much smaller
|
||||||
|
** than 1 GiB. The sqlite3_test_control() interface can be used to
|
||||||
|
** move the pending byte.
|
||||||
|
**
|
||||||
|
** IMPORTANT: Changing the pending byte to any value other than
|
||||||
|
** 0x40000000 results in an incompatible database file format!
|
||||||
|
** Changing the pending byte during operating results in undefined
|
||||||
|
** and dileterious behavior.
|
||||||
|
*/
|
||||||
|
int sqlite3PendingByte = 0x40000000;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
**
|
**
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
**
|
**
|
||||||
** @(#) $Id: journal.c,v 1.8 2008/05/01 18:01:47 drh Exp $
|
** @(#) $Id: journal.c,v 1.9 2009/01/20 17:06:27 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
|
#ifdef SQLITE_ENABLE_ATOMIC_WRITE
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
**
|
**
|
||||||
** 1) The in-memory representation grows too large for the allocated
|
** 1) The in-memory representation grows too large for the allocated
|
||||||
** buffer, or
|
** buffer, or
|
||||||
** 2) The xSync() method is called.
|
** 2) The sqlite3JournalCreate() function is called.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
@ -95,8 +95,9 @@ static int jrnlRead(
|
||||||
JournalFile *p = (JournalFile *)pJfd;
|
JournalFile *p = (JournalFile *)pJfd;
|
||||||
if( p->pReal ){
|
if( p->pReal ){
|
||||||
rc = sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);
|
rc = sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);
|
||||||
|
}else if( (iAmt+iOfst)>p->iSize ){
|
||||||
|
rc = SQLITE_IOERR_SHORT_READ;
|
||||||
}else{
|
}else{
|
||||||
assert( iAmt+iOfst<=p->iSize );
|
|
||||||
memcpy(zBuf, &p->zBuf[iOfst], iAmt);
|
memcpy(zBuf, &p->zBuf[iOfst], iAmt);
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
|
532
keywordhash.h
532
keywordhash.h
|
@ -1,266 +1,266 @@
|
||||||
/***** This file contains automatically generated code ******
|
/***** This file contains automatically generated code ******
|
||||||
**
|
**
|
||||||
** The code in this file has been automatically generated by
|
** The code in this file has been automatically generated by
|
||||||
**
|
**
|
||||||
** $Header: /sqlite/sqlite/tool/mkkeywordhash.c,v 1.36 2008/12/31 21:52:41 drh Exp $
|
** $Header: /sqlite/sqlite/tool/mkkeywordhash.c,v 1.37 2009/02/01 00:00:46 drh Exp $
|
||||||
**
|
**
|
||||||
** The code in this file implements a function that determines whether
|
** The code in this file implements a function that determines whether
|
||||||
** or not a given identifier is really an SQL keyword. The same thing
|
** or not a given identifier is really an SQL keyword. The same thing
|
||||||
** might be implemented more directly using a hand-written hash table.
|
** might be implemented more directly using a hand-written hash table.
|
||||||
** But by using this automatically generated code, the size of the code
|
** But by using this automatically generated code, the size of the code
|
||||||
** is substantially reduced. This is important for embedded applications
|
** is substantially reduced. This is important for embedded applications
|
||||||
** on platforms with limited memory.
|
** on platforms with limited memory.
|
||||||
*/
|
*/
|
||||||
/* Hash score: 171 */
|
/* Hash score: 171 */
|
||||||
static int keywordCode(const char *z, int n){
|
static int keywordCode(const char *z, int n){
|
||||||
/* zText[] encodes 801 bytes of keywords in 541 bytes */
|
/* zText[] encodes 801 bytes of keywords in 541 bytes */
|
||||||
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
|
/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
|
||||||
/* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
|
/* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
|
||||||
/* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
|
/* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
|
||||||
/* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */
|
/* UNIQUERYATTACHAVINGROUPDATEBEGINNERELEASEBETWEENOTNULLIKE */
|
||||||
/* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */
|
/* CASCADELETECASECOLLATECREATECURRENT_DATEDETACHIMMEDIATEJOIN */
|
||||||
/* SERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHENWHERENAME */
|
/* SERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHENWHERENAME */
|
||||||
/* AFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */
|
/* AFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */
|
||||||
/* CURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROMFULLGLOBYIF */
|
/* CURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAILFROMFULLGLOBYIF */
|
||||||
/* ISNULLORDERESTRICTOUTERIGHTROLLBACKROWUNIONUSINGVACUUMVIEW */
|
/* ISNULLORDERESTRICTOUTERIGHTROLLBACKROWUNIONUSINGVACUUMVIEW */
|
||||||
/* INITIALLY */
|
/* INITIALLY */
|
||||||
static const char zText[540] = {
|
static const char zText[540] = {
|
||||||
'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
|
'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
|
||||||
'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
|
'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
|
||||||
'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
|
'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
|
||||||
'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
|
'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
|
||||||
'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
|
'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
|
||||||
'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
|
'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
|
||||||
'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
|
'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
|
||||||
'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
|
'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
|
||||||
'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
|
'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
|
||||||
'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
|
'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
|
||||||
'U','E','R','Y','A','T','T','A','C','H','A','V','I','N','G','R','O','U',
|
'U','E','R','Y','A','T','T','A','C','H','A','V','I','N','G','R','O','U',
|
||||||
'P','D','A','T','E','B','E','G','I','N','N','E','R','E','L','E','A','S',
|
'P','D','A','T','E','B','E','G','I','N','N','E','R','E','L','E','A','S',
|
||||||
'E','B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C',
|
'E','B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C',
|
||||||
'A','S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L',
|
'A','S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L',
|
||||||
'A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D',
|
'A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D',
|
||||||
'A','T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E',
|
'A','T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E',
|
||||||
'J','O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A',
|
'J','O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A',
|
||||||
'L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U',
|
'L','Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U',
|
||||||
'E','S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W',
|
'E','S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W',
|
||||||
'H','E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C',
|
'H','E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C',
|
||||||
'E','A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R',
|
'E','A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R',
|
||||||
'E','M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M',
|
'E','M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M',
|
||||||
'M','I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U',
|
'M','I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U',
|
||||||
'R','R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M',
|
'R','R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M',
|
||||||
'A','R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T',
|
'A','R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T',
|
||||||
'D','R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L',
|
'D','R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L',
|
||||||
'O','B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S',
|
'O','B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S',
|
||||||
'T','R','I','C','T','O','U','T','E','R','I','G','H','T','R','O','L','L',
|
'T','R','I','C','T','O','U','T','E','R','I','G','H','T','R','O','L','L',
|
||||||
'B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N','G','V',
|
'B','A','C','K','R','O','W','U','N','I','O','N','U','S','I','N','G','V',
|
||||||
'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y',
|
'A','C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y',
|
||||||
};
|
};
|
||||||
static const unsigned char aHash[127] = {
|
static const unsigned char aHash[127] = {
|
||||||
70, 99, 112, 68, 0, 43, 0, 0, 76, 0, 71, 0, 0,
|
70, 99, 112, 68, 0, 43, 0, 0, 76, 0, 71, 0, 0,
|
||||||
41, 12, 72, 15, 0, 111, 79, 49, 106, 0, 19, 0, 0,
|
41, 12, 72, 15, 0, 111, 79, 49, 106, 0, 19, 0, 0,
|
||||||
116, 0, 114, 109, 0, 22, 87, 0, 9, 0, 0, 64, 65,
|
116, 0, 114, 109, 0, 22, 87, 0, 9, 0, 0, 64, 65,
|
||||||
0, 63, 6, 0, 47, 84, 96, 0, 113, 95, 0, 0, 44,
|
0, 63, 6, 0, 47, 84, 96, 0, 113, 95, 0, 0, 44,
|
||||||
0, 97, 24, 0, 17, 0, 117, 48, 23, 0, 5, 104, 25,
|
0, 97, 24, 0, 17, 0, 117, 48, 23, 0, 5, 104, 25,
|
||||||
90, 0, 0, 119, 100, 55, 118, 52, 7, 50, 0, 85, 0,
|
90, 0, 0, 119, 100, 55, 118, 52, 7, 50, 0, 85, 0,
|
||||||
94, 26, 0, 93, 0, 0, 0, 89, 86, 91, 82, 103, 14,
|
94, 26, 0, 93, 0, 0, 0, 89, 86, 91, 82, 103, 14,
|
||||||
38, 102, 0, 75, 0, 18, 83, 105, 31, 0, 115, 74, 107,
|
38, 102, 0, 75, 0, 18, 83, 105, 31, 0, 115, 74, 107,
|
||||||
56, 45, 78, 0, 0, 88, 39, 0, 110, 0, 35, 0, 0,
|
56, 45, 78, 0, 0, 88, 39, 0, 110, 0, 35, 0, 0,
|
||||||
28, 0, 80, 53, 58, 0, 20, 57, 0, 51,
|
28, 0, 80, 53, 58, 0, 20, 57, 0, 51,
|
||||||
};
|
};
|
||||||
static const unsigned char aNext[119] = {
|
static const unsigned char aNext[119] = {
|
||||||
0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 3, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
|
0, 3, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 32, 21, 0, 0, 0, 42, 2, 46, 0,
|
0, 0, 0, 0, 32, 21, 0, 0, 0, 42, 2, 46, 0,
|
||||||
0, 0, 0, 0, 29, 0, 37, 0, 0, 0, 1, 60, 0,
|
0, 0, 0, 0, 29, 0, 37, 0, 0, 0, 1, 60, 0,
|
||||||
0, 61, 0, 40, 0, 0, 0, 0, 0, 0, 0, 59, 0,
|
0, 61, 0, 40, 0, 0, 0, 0, 0, 0, 0, 59, 0,
|
||||||
0, 0, 0, 30, 54, 16, 33, 11, 0, 0, 0, 0, 0,
|
0, 0, 0, 30, 54, 16, 33, 11, 0, 0, 0, 0, 0,
|
||||||
0, 0, 10, 66, 73, 0, 8, 0, 98, 92, 0, 101, 0,
|
0, 0, 10, 66, 73, 0, 8, 0, 98, 92, 0, 101, 0,
|
||||||
81, 0, 69, 0, 0, 108, 27, 36, 67, 77, 0, 34, 62,
|
81, 0, 69, 0, 0, 108, 27, 36, 67, 77, 0, 34, 62,
|
||||||
0, 0,
|
0, 0,
|
||||||
};
|
};
|
||||||
static const unsigned char aLen[119] = {
|
static const unsigned char aLen[119] = {
|
||||||
7, 5, 7, 4, 6, 4, 5, 3, 6, 3, 7, 6, 6,
|
7, 5, 7, 4, 6, 4, 5, 3, 6, 3, 7, 6, 6,
|
||||||
7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
|
7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
|
||||||
11, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10, 4,
|
11, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10, 4,
|
||||||
6, 2, 3, 4, 9, 2, 6, 5, 6, 6, 5, 6, 5,
|
6, 2, 3, 4, 9, 2, 6, 5, 6, 6, 5, 6, 5,
|
||||||
5, 7, 7, 3, 7, 4, 4, 7, 3, 6, 4, 7, 6,
|
5, 7, 7, 3, 7, 4, 4, 7, 3, 6, 4, 7, 6,
|
||||||
12, 6, 9, 4, 6, 5, 4, 7, 6, 5, 6, 7, 5,
|
12, 6, 9, 4, 6, 5, 4, 7, 6, 5, 6, 7, 5,
|
||||||
4, 5, 6, 5, 7, 3, 7, 13, 2, 2, 4, 6, 6,
|
4, 5, 6, 5, 7, 3, 7, 13, 2, 2, 4, 6, 6,
|
||||||
8, 5, 17, 12, 7, 8, 8, 2, 4, 4, 4, 4, 4,
|
8, 5, 17, 12, 7, 8, 8, 2, 4, 4, 4, 4, 4,
|
||||||
2, 2, 6, 5, 8, 5, 5, 8, 3, 5, 5, 6, 4,
|
2, 2, 6, 5, 8, 5, 5, 8, 3, 5, 5, 6, 4,
|
||||||
9, 3,
|
9, 3,
|
||||||
};
|
};
|
||||||
static const unsigned short int aOffset[119] = {
|
static const unsigned short int aOffset[119] = {
|
||||||
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
|
0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
|
||||||
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
|
36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
|
||||||
86, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152, 159,
|
86, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152, 159,
|
||||||
162, 162, 165, 167, 167, 171, 176, 179, 184, 189, 194, 197, 203,
|
162, 162, 165, 167, 167, 171, 176, 179, 184, 189, 194, 197, 203,
|
||||||
206, 210, 217, 223, 223, 226, 229, 233, 234, 238, 244, 248, 255,
|
206, 210, 217, 223, 223, 226, 229, 233, 234, 238, 244, 248, 255,
|
||||||
261, 273, 279, 288, 290, 296, 301, 303, 310, 315, 320, 326, 332,
|
261, 273, 279, 288, 290, 296, 301, 303, 310, 315, 320, 326, 332,
|
||||||
337, 341, 344, 350, 354, 361, 363, 370, 372, 374, 383, 387, 393,
|
337, 341, 344, 350, 354, 361, 363, 370, 372, 374, 383, 387, 393,
|
||||||
399, 407, 412, 412, 428, 435, 442, 443, 450, 454, 458, 462, 466,
|
399, 407, 412, 412, 428, 435, 442, 443, 450, 454, 458, 462, 466,
|
||||||
469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516, 521, 527,
|
469, 471, 473, 479, 483, 491, 495, 500, 508, 511, 516, 521, 527,
|
||||||
531, 536,
|
531, 536,
|
||||||
};
|
};
|
||||||
static const unsigned char aCode[119] = {
|
static const unsigned char aCode[119] = {
|
||||||
TK_REINDEX, TK_INDEX, TK_INDEXED, TK_DESC, TK_ESCAPE,
|
TK_REINDEX, TK_INDEX, TK_INDEXED, TK_DESC, TK_ESCAPE,
|
||||||
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOR,
|
TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOR,
|
||||||
TK_FOREIGN, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
|
TK_FOREIGN, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
|
||||||
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
|
TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
|
||||||
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
|
TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
|
||||||
TK_EXCEPT, TK_TRANSACTION,TK_ON, TK_JOIN_KW, TK_ALTER,
|
TK_EXCEPT, TK_TRANSACTION,TK_ON, TK_JOIN_KW, TK_ALTER,
|
||||||
TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, TK_INTERSECT,
|
TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, TK_INTERSECT,
|
||||||
TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, TK_OFFSET,
|
TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO, TK_OFFSET,
|
||||||
TK_OF, TK_SET, TK_TEMP, TK_TEMP, TK_OR,
|
TK_OF, TK_SET, TK_TEMP, TK_TEMP, TK_OR,
|
||||||
TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING, TK_GROUP,
|
TK_UNIQUE, TK_QUERY, TK_ATTACH, TK_HAVING, TK_GROUP,
|
||||||
TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE, TK_BETWEEN,
|
TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RELEASE, TK_BETWEEN,
|
||||||
TK_NOT, TK_NOTNULL, TK_NULL, TK_LIKE_KW, TK_CASCADE,
|
TK_NOT, TK_NOTNULL, TK_NULL, TK_LIKE_KW, TK_CASCADE,
|
||||||
TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE,
|
TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE, TK_CREATE,
|
||||||
TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT,
|
TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN, TK_INSERT,
|
||||||
TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
|
TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA, TK_ABORT,
|
||||||
TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_WHERE,
|
TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN, TK_WHERE,
|
||||||
TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND, TK_DEFAULT,
|
TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND, TK_DEFAULT,
|
||||||
TK_AUTOINCR, TK_TO, TK_IN, TK_CAST, TK_COLUMNKW,
|
TK_AUTOINCR, TK_TO, TK_IN, TK_CAST, TK_COLUMNKW,
|
||||||
TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW,
|
TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW, TK_CTIME_KW,
|
||||||
TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP,
|
TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS, TK_DROP,
|
||||||
TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW, TK_BY,
|
TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW, TK_BY,
|
||||||
TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_JOIN_KW,
|
TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_JOIN_KW,
|
||||||
TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
|
TK_JOIN_KW, TK_ROLLBACK, TK_ROW, TK_UNION, TK_USING,
|
||||||
TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
|
TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
|
||||||
};
|
};
|
||||||
int h, i;
|
int h, i;
|
||||||
if( n<2 ) return TK_ID;
|
if( n<2 ) return TK_ID;
|
||||||
h = ((charMap(z[0])*4) ^
|
h = ((charMap(z[0])*4) ^
|
||||||
(charMap(z[n-1])*3) ^
|
(charMap(z[n-1])*3) ^
|
||||||
n) % 127;
|
n) % 127;
|
||||||
for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){
|
for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){
|
||||||
if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){
|
if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){
|
||||||
testcase( i==0 ); /* TK_REINDEX */
|
testcase( i==0 ); /* TK_REINDEX */
|
||||||
testcase( i==1 ); /* TK_INDEX */
|
testcase( i==1 ); /* TK_INDEX */
|
||||||
testcase( i==2 ); /* TK_INDEXED */
|
testcase( i==2 ); /* TK_INDEXED */
|
||||||
testcase( i==3 ); /* TK_DESC */
|
testcase( i==3 ); /* TK_DESC */
|
||||||
testcase( i==4 ); /* TK_ESCAPE */
|
testcase( i==4 ); /* TK_ESCAPE */
|
||||||
testcase( i==5 ); /* TK_EACH */
|
testcase( i==5 ); /* TK_EACH */
|
||||||
testcase( i==6 ); /* TK_CHECK */
|
testcase( i==6 ); /* TK_CHECK */
|
||||||
testcase( i==7 ); /* TK_KEY */
|
testcase( i==7 ); /* TK_KEY */
|
||||||
testcase( i==8 ); /* TK_BEFORE */
|
testcase( i==8 ); /* TK_BEFORE */
|
||||||
testcase( i==9 ); /* TK_FOR */
|
testcase( i==9 ); /* TK_FOR */
|
||||||
testcase( i==10 ); /* TK_FOREIGN */
|
testcase( i==10 ); /* TK_FOREIGN */
|
||||||
testcase( i==11 ); /* TK_IGNORE */
|
testcase( i==11 ); /* TK_IGNORE */
|
||||||
testcase( i==12 ); /* TK_LIKE_KW */
|
testcase( i==12 ); /* TK_LIKE_KW */
|
||||||
testcase( i==13 ); /* TK_EXPLAIN */
|
testcase( i==13 ); /* TK_EXPLAIN */
|
||||||
testcase( i==14 ); /* TK_INSTEAD */
|
testcase( i==14 ); /* TK_INSTEAD */
|
||||||
testcase( i==15 ); /* TK_ADD */
|
testcase( i==15 ); /* TK_ADD */
|
||||||
testcase( i==16 ); /* TK_DATABASE */
|
testcase( i==16 ); /* TK_DATABASE */
|
||||||
testcase( i==17 ); /* TK_AS */
|
testcase( i==17 ); /* TK_AS */
|
||||||
testcase( i==18 ); /* TK_SELECT */
|
testcase( i==18 ); /* TK_SELECT */
|
||||||
testcase( i==19 ); /* TK_TABLE */
|
testcase( i==19 ); /* TK_TABLE */
|
||||||
testcase( i==20 ); /* TK_JOIN_KW */
|
testcase( i==20 ); /* TK_JOIN_KW */
|
||||||
testcase( i==21 ); /* TK_THEN */
|
testcase( i==21 ); /* TK_THEN */
|
||||||
testcase( i==22 ); /* TK_END */
|
testcase( i==22 ); /* TK_END */
|
||||||
testcase( i==23 ); /* TK_DEFERRABLE */
|
testcase( i==23 ); /* TK_DEFERRABLE */
|
||||||
testcase( i==24 ); /* TK_ELSE */
|
testcase( i==24 ); /* TK_ELSE */
|
||||||
testcase( i==25 ); /* TK_EXCEPT */
|
testcase( i==25 ); /* TK_EXCEPT */
|
||||||
testcase( i==26 ); /* TK_TRANSACTION */
|
testcase( i==26 ); /* TK_TRANSACTION */
|
||||||
testcase( i==27 ); /* TK_ON */
|
testcase( i==27 ); /* TK_ON */
|
||||||
testcase( i==28 ); /* TK_JOIN_KW */
|
testcase( i==28 ); /* TK_JOIN_KW */
|
||||||
testcase( i==29 ); /* TK_ALTER */
|
testcase( i==29 ); /* TK_ALTER */
|
||||||
testcase( i==30 ); /* TK_RAISE */
|
testcase( i==30 ); /* TK_RAISE */
|
||||||
testcase( i==31 ); /* TK_EXCLUSIVE */
|
testcase( i==31 ); /* TK_EXCLUSIVE */
|
||||||
testcase( i==32 ); /* TK_EXISTS */
|
testcase( i==32 ); /* TK_EXISTS */
|
||||||
testcase( i==33 ); /* TK_SAVEPOINT */
|
testcase( i==33 ); /* TK_SAVEPOINT */
|
||||||
testcase( i==34 ); /* TK_INTERSECT */
|
testcase( i==34 ); /* TK_INTERSECT */
|
||||||
testcase( i==35 ); /* TK_TRIGGER */
|
testcase( i==35 ); /* TK_TRIGGER */
|
||||||
testcase( i==36 ); /* TK_REFERENCES */
|
testcase( i==36 ); /* TK_REFERENCES */
|
||||||
testcase( i==37 ); /* TK_CONSTRAINT */
|
testcase( i==37 ); /* TK_CONSTRAINT */
|
||||||
testcase( i==38 ); /* TK_INTO */
|
testcase( i==38 ); /* TK_INTO */
|
||||||
testcase( i==39 ); /* TK_OFFSET */
|
testcase( i==39 ); /* TK_OFFSET */
|
||||||
testcase( i==40 ); /* TK_OF */
|
testcase( i==40 ); /* TK_OF */
|
||||||
testcase( i==41 ); /* TK_SET */
|
testcase( i==41 ); /* TK_SET */
|
||||||
testcase( i==42 ); /* TK_TEMP */
|
testcase( i==42 ); /* TK_TEMP */
|
||||||
testcase( i==43 ); /* TK_TEMP */
|
testcase( i==43 ); /* TK_TEMP */
|
||||||
testcase( i==44 ); /* TK_OR */
|
testcase( i==44 ); /* TK_OR */
|
||||||
testcase( i==45 ); /* TK_UNIQUE */
|
testcase( i==45 ); /* TK_UNIQUE */
|
||||||
testcase( i==46 ); /* TK_QUERY */
|
testcase( i==46 ); /* TK_QUERY */
|
||||||
testcase( i==47 ); /* TK_ATTACH */
|
testcase( i==47 ); /* TK_ATTACH */
|
||||||
testcase( i==48 ); /* TK_HAVING */
|
testcase( i==48 ); /* TK_HAVING */
|
||||||
testcase( i==49 ); /* TK_GROUP */
|
testcase( i==49 ); /* TK_GROUP */
|
||||||
testcase( i==50 ); /* TK_UPDATE */
|
testcase( i==50 ); /* TK_UPDATE */
|
||||||
testcase( i==51 ); /* TK_BEGIN */
|
testcase( i==51 ); /* TK_BEGIN */
|
||||||
testcase( i==52 ); /* TK_JOIN_KW */
|
testcase( i==52 ); /* TK_JOIN_KW */
|
||||||
testcase( i==53 ); /* TK_RELEASE */
|
testcase( i==53 ); /* TK_RELEASE */
|
||||||
testcase( i==54 ); /* TK_BETWEEN */
|
testcase( i==54 ); /* TK_BETWEEN */
|
||||||
testcase( i==55 ); /* TK_NOT */
|
testcase( i==55 ); /* TK_NOT */
|
||||||
testcase( i==56 ); /* TK_NOTNULL */
|
testcase( i==56 ); /* TK_NOTNULL */
|
||||||
testcase( i==57 ); /* TK_NULL */
|
testcase( i==57 ); /* TK_NULL */
|
||||||
testcase( i==58 ); /* TK_LIKE_KW */
|
testcase( i==58 ); /* TK_LIKE_KW */
|
||||||
testcase( i==59 ); /* TK_CASCADE */
|
testcase( i==59 ); /* TK_CASCADE */
|
||||||
testcase( i==60 ); /* TK_ASC */
|
testcase( i==60 ); /* TK_ASC */
|
||||||
testcase( i==61 ); /* TK_DELETE */
|
testcase( i==61 ); /* TK_DELETE */
|
||||||
testcase( i==62 ); /* TK_CASE */
|
testcase( i==62 ); /* TK_CASE */
|
||||||
testcase( i==63 ); /* TK_COLLATE */
|
testcase( i==63 ); /* TK_COLLATE */
|
||||||
testcase( i==64 ); /* TK_CREATE */
|
testcase( i==64 ); /* TK_CREATE */
|
||||||
testcase( i==65 ); /* TK_CTIME_KW */
|
testcase( i==65 ); /* TK_CTIME_KW */
|
||||||
testcase( i==66 ); /* TK_DETACH */
|
testcase( i==66 ); /* TK_DETACH */
|
||||||
testcase( i==67 ); /* TK_IMMEDIATE */
|
testcase( i==67 ); /* TK_IMMEDIATE */
|
||||||
testcase( i==68 ); /* TK_JOIN */
|
testcase( i==68 ); /* TK_JOIN */
|
||||||
testcase( i==69 ); /* TK_INSERT */
|
testcase( i==69 ); /* TK_INSERT */
|
||||||
testcase( i==70 ); /* TK_MATCH */
|
testcase( i==70 ); /* TK_MATCH */
|
||||||
testcase( i==71 ); /* TK_PLAN */
|
testcase( i==71 ); /* TK_PLAN */
|
||||||
testcase( i==72 ); /* TK_ANALYZE */
|
testcase( i==72 ); /* TK_ANALYZE */
|
||||||
testcase( i==73 ); /* TK_PRAGMA */
|
testcase( i==73 ); /* TK_PRAGMA */
|
||||||
testcase( i==74 ); /* TK_ABORT */
|
testcase( i==74 ); /* TK_ABORT */
|
||||||
testcase( i==75 ); /* TK_VALUES */
|
testcase( i==75 ); /* TK_VALUES */
|
||||||
testcase( i==76 ); /* TK_VIRTUAL */
|
testcase( i==76 ); /* TK_VIRTUAL */
|
||||||
testcase( i==77 ); /* TK_LIMIT */
|
testcase( i==77 ); /* TK_LIMIT */
|
||||||
testcase( i==78 ); /* TK_WHEN */
|
testcase( i==78 ); /* TK_WHEN */
|
||||||
testcase( i==79 ); /* TK_WHERE */
|
testcase( i==79 ); /* TK_WHERE */
|
||||||
testcase( i==80 ); /* TK_RENAME */
|
testcase( i==80 ); /* TK_RENAME */
|
||||||
testcase( i==81 ); /* TK_AFTER */
|
testcase( i==81 ); /* TK_AFTER */
|
||||||
testcase( i==82 ); /* TK_REPLACE */
|
testcase( i==82 ); /* TK_REPLACE */
|
||||||
testcase( i==83 ); /* TK_AND */
|
testcase( i==83 ); /* TK_AND */
|
||||||
testcase( i==84 ); /* TK_DEFAULT */
|
testcase( i==84 ); /* TK_DEFAULT */
|
||||||
testcase( i==85 ); /* TK_AUTOINCR */
|
testcase( i==85 ); /* TK_AUTOINCR */
|
||||||
testcase( i==86 ); /* TK_TO */
|
testcase( i==86 ); /* TK_TO */
|
||||||
testcase( i==87 ); /* TK_IN */
|
testcase( i==87 ); /* TK_IN */
|
||||||
testcase( i==88 ); /* TK_CAST */
|
testcase( i==88 ); /* TK_CAST */
|
||||||
testcase( i==89 ); /* TK_COLUMNKW */
|
testcase( i==89 ); /* TK_COLUMNKW */
|
||||||
testcase( i==90 ); /* TK_COMMIT */
|
testcase( i==90 ); /* TK_COMMIT */
|
||||||
testcase( i==91 ); /* TK_CONFLICT */
|
testcase( i==91 ); /* TK_CONFLICT */
|
||||||
testcase( i==92 ); /* TK_JOIN_KW */
|
testcase( i==92 ); /* TK_JOIN_KW */
|
||||||
testcase( i==93 ); /* TK_CTIME_KW */
|
testcase( i==93 ); /* TK_CTIME_KW */
|
||||||
testcase( i==94 ); /* TK_CTIME_KW */
|
testcase( i==94 ); /* TK_CTIME_KW */
|
||||||
testcase( i==95 ); /* TK_PRIMARY */
|
testcase( i==95 ); /* TK_PRIMARY */
|
||||||
testcase( i==96 ); /* TK_DEFERRED */
|
testcase( i==96 ); /* TK_DEFERRED */
|
||||||
testcase( i==97 ); /* TK_DISTINCT */
|
testcase( i==97 ); /* TK_DISTINCT */
|
||||||
testcase( i==98 ); /* TK_IS */
|
testcase( i==98 ); /* TK_IS */
|
||||||
testcase( i==99 ); /* TK_DROP */
|
testcase( i==99 ); /* TK_DROP */
|
||||||
testcase( i==100 ); /* TK_FAIL */
|
testcase( i==100 ); /* TK_FAIL */
|
||||||
testcase( i==101 ); /* TK_FROM */
|
testcase( i==101 ); /* TK_FROM */
|
||||||
testcase( i==102 ); /* TK_JOIN_KW */
|
testcase( i==102 ); /* TK_JOIN_KW */
|
||||||
testcase( i==103 ); /* TK_LIKE_KW */
|
testcase( i==103 ); /* TK_LIKE_KW */
|
||||||
testcase( i==104 ); /* TK_BY */
|
testcase( i==104 ); /* TK_BY */
|
||||||
testcase( i==105 ); /* TK_IF */
|
testcase( i==105 ); /* TK_IF */
|
||||||
testcase( i==106 ); /* TK_ISNULL */
|
testcase( i==106 ); /* TK_ISNULL */
|
||||||
testcase( i==107 ); /* TK_ORDER */
|
testcase( i==107 ); /* TK_ORDER */
|
||||||
testcase( i==108 ); /* TK_RESTRICT */
|
testcase( i==108 ); /* TK_RESTRICT */
|
||||||
testcase( i==109 ); /* TK_JOIN_KW */
|
testcase( i==109 ); /* TK_JOIN_KW */
|
||||||
testcase( i==110 ); /* TK_JOIN_KW */
|
testcase( i==110 ); /* TK_JOIN_KW */
|
||||||
testcase( i==111 ); /* TK_ROLLBACK */
|
testcase( i==111 ); /* TK_ROLLBACK */
|
||||||
testcase( i==112 ); /* TK_ROW */
|
testcase( i==112 ); /* TK_ROW */
|
||||||
testcase( i==113 ); /* TK_UNION */
|
testcase( i==113 ); /* TK_UNION */
|
||||||
testcase( i==114 ); /* TK_USING */
|
testcase( i==114 ); /* TK_USING */
|
||||||
testcase( i==115 ); /* TK_VACUUM */
|
testcase( i==115 ); /* TK_VACUUM */
|
||||||
testcase( i==116 ); /* TK_VIEW */
|
testcase( i==116 ); /* TK_VIEW */
|
||||||
testcase( i==117 ); /* TK_INITIALLY */
|
testcase( i==117 ); /* TK_INITIALLY */
|
||||||
testcase( i==118 ); /* TK_ALL */
|
testcase( i==118 ); /* TK_ALL */
|
||||||
return aCode[i];
|
return aCode[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TK_ID;
|
return TK_ID;
|
||||||
}
|
}
|
||||||
int sqlite3KeywordCode(const unsigned char *z, int n){
|
int sqlite3KeywordCode(const unsigned char *z, int n){
|
||||||
return keywordCode((char*)z, n);
|
return keywordCode((char*)z, n);
|
||||||
}
|
}
|
||||||
|
|
5
legacy.c
5
legacy.c
|
@ -14,11 +14,10 @@
|
||||||
** other files are for internal use by SQLite and should not be
|
** other files are for internal use by SQLite and should not be
|
||||||
** accessed by users of the library.
|
** accessed by users of the library.
|
||||||
**
|
**
|
||||||
** $Id: legacy.c,v 1.30 2008/12/10 19:26:24 drh Exp $
|
** $Id: legacy.c,v 1.31 2009/01/20 16:53:40 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Execute SQL code. Return one of the SQLITE_ success/failure
|
** Execute SQL code. Return one of the SQLITE_ success/failure
|
||||||
|
@ -115,7 +114,7 @@ int sqlite3_exec(
|
||||||
if( rc!=SQLITE_SCHEMA ){
|
if( rc!=SQLITE_SCHEMA ){
|
||||||
nRetry = 0;
|
nRetry = 0;
|
||||||
zSql = zLeftover;
|
zSql = zLeftover;
|
||||||
while( isspace((unsigned char)zSql[0]) ) zSql++;
|
while( sqlite3Isspace(zSql[0]) ) zSql++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
** This file contains code used to dynamically load extensions into
|
** This file contains code used to dynamically load extensions into
|
||||||
** the SQLite library.
|
** the SQLite library.
|
||||||
**
|
**
|
||||||
** $Id: loadext.c,v 1.57 2008/12/08 18:19:18 drh Exp $
|
** $Id: loadext.c,v 1.58 2009/01/20 16:53:40 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SQLITE_CORE
|
#ifndef SQLITE_CORE
|
||||||
|
@ -21,7 +21,6 @@
|
||||||
#include "sqlite3ext.h"
|
#include "sqlite3ext.h"
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_LOAD_EXTENSION
|
#ifndef SQLITE_OMIT_LOAD_EXTENSION
|
||||||
|
|
||||||
|
|
64
main.c
64
main.c
|
@ -14,10 +14,9 @@
|
||||||
** other files are for internal use by SQLite and should not be
|
** other files are for internal use by SQLite and should not be
|
||||||
** accessed by users of the library.
|
** accessed by users of the library.
|
||||||
**
|
**
|
||||||
** $Id: main.c,v 1.521 2009/01/10 16:15:22 drh Exp $
|
** $Id: main.c,v 1.528 2009/02/05 16:31:46 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
#ifdef SQLITE_ENABLE_FTS3
|
#ifdef SQLITE_ENABLE_FTS3
|
||||||
# include "fts3.h"
|
# include "fts3.h"
|
||||||
|
@ -192,6 +191,7 @@ int sqlite3_initialize(void){
|
||||||
** reason. So we run it once during initialization.
|
** reason. So we run it once during initialization.
|
||||||
*/
|
*/
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
/* This section of code's only "output" is via assert() statements. */
|
/* This section of code's only "output" is via assert() statements. */
|
||||||
if ( rc==SQLITE_OK ){
|
if ( rc==SQLITE_OK ){
|
||||||
u64 x = (((u64)1)<<63)-1;
|
u64 x = (((u64)1)<<63)-1;
|
||||||
|
@ -201,6 +201,7 @@ int sqlite3_initialize(void){
|
||||||
memcpy(&y, &x, 8);
|
memcpy(&y, &x, 8);
|
||||||
assert( sqlite3IsNaN(y) );
|
assert( sqlite3IsNaN(y) );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -387,9 +388,22 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
|
||||||
if( db->lookaside.nOut ){
|
if( db->lookaside.nOut ){
|
||||||
return SQLITE_BUSY;
|
return SQLITE_BUSY;
|
||||||
}
|
}
|
||||||
if( sz<0 ) sz = 0;
|
/* Free any existing lookaside buffer for this handle before
|
||||||
|
** allocating a new one so we don't have to have space for
|
||||||
|
** both at the same time.
|
||||||
|
*/
|
||||||
|
if( db->lookaside.bMalloced ){
|
||||||
|
sqlite3_free(db->lookaside.pStart);
|
||||||
|
}
|
||||||
|
/* The size of a lookaside slot needs to be larger than a pointer
|
||||||
|
** to be useful.
|
||||||
|
*/
|
||||||
|
if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;
|
||||||
if( cnt<0 ) cnt = 0;
|
if( cnt<0 ) cnt = 0;
|
||||||
if( pBuf==0 ){
|
if( sz==0 || cnt==0 ){
|
||||||
|
sz = 0;
|
||||||
|
pStart = 0;
|
||||||
|
}else if( pBuf==0 ){
|
||||||
sz = (sz + 7)&~7;
|
sz = (sz + 7)&~7;
|
||||||
sqlite3BeginBenignMalloc();
|
sqlite3BeginBenignMalloc();
|
||||||
pStart = sqlite3Malloc( sz*cnt );
|
pStart = sqlite3Malloc( sz*cnt );
|
||||||
|
@ -398,16 +412,13 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
|
||||||
sz = sz&~7;
|
sz = sz&~7;
|
||||||
pStart = pBuf;
|
pStart = pBuf;
|
||||||
}
|
}
|
||||||
if( db->lookaside.bMalloced ){
|
|
||||||
sqlite3_free(db->lookaside.pStart);
|
|
||||||
}
|
|
||||||
db->lookaside.pStart = pStart;
|
db->lookaside.pStart = pStart;
|
||||||
db->lookaside.pFree = 0;
|
db->lookaside.pFree = 0;
|
||||||
db->lookaside.sz = (u16)sz;
|
db->lookaside.sz = (u16)sz;
|
||||||
db->lookaside.bMalloced = pBuf==0 ?1:0;
|
|
||||||
if( pStart ){
|
if( pStart ){
|
||||||
int i;
|
int i;
|
||||||
LookasideSlot *p;
|
LookasideSlot *p;
|
||||||
|
assert( sz > sizeof(LookasideSlot*) );
|
||||||
p = (LookasideSlot*)pStart;
|
p = (LookasideSlot*)pStart;
|
||||||
for(i=cnt-1; i>=0; i--){
|
for(i=cnt-1; i>=0; i--){
|
||||||
p->pNext = db->lookaside.pFree;
|
p->pNext = db->lookaside.pFree;
|
||||||
|
@ -416,9 +427,11 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
|
||||||
}
|
}
|
||||||
db->lookaside.pEnd = p;
|
db->lookaside.pEnd = p;
|
||||||
db->lookaside.bEnabled = 1;
|
db->lookaside.bEnabled = 1;
|
||||||
|
db->lookaside.bMalloced = pBuf==0 ?1:0;
|
||||||
}else{
|
}else{
|
||||||
db->lookaside.pEnd = 0;
|
db->lookaside.pEnd = 0;
|
||||||
db->lookaside.bEnabled = 0;
|
db->lookaside.bEnabled = 0;
|
||||||
|
db->lookaside.bMalloced = 0;
|
||||||
}
|
}
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
@ -586,12 +599,22 @@ int sqlite3_close(sqlite3 *db){
|
||||||
/* If there are any outstanding VMs, return SQLITE_BUSY. */
|
/* If there are any outstanding VMs, return SQLITE_BUSY. */
|
||||||
if( db->pVdbe ){
|
if( db->pVdbe ){
|
||||||
sqlite3Error(db, SQLITE_BUSY,
|
sqlite3Error(db, SQLITE_BUSY,
|
||||||
"Unable to close due to unfinalised statements");
|
"unable to close due to unfinalised statements");
|
||||||
sqlite3_mutex_leave(db->mutex);
|
sqlite3_mutex_leave(db->mutex);
|
||||||
return SQLITE_BUSY;
|
return SQLITE_BUSY;
|
||||||
}
|
}
|
||||||
assert( sqlite3SafetyCheckSickOrOk(db) );
|
assert( sqlite3SafetyCheckSickOrOk(db) );
|
||||||
|
|
||||||
|
for(j=0; j<db->nDb; j++){
|
||||||
|
Btree *pBt = db->aDb[j].pBt;
|
||||||
|
if( pBt && sqlite3BtreeIsInBackup(pBt) ){
|
||||||
|
sqlite3Error(db, SQLITE_BUSY,
|
||||||
|
"unable to close due to unfinished backup operation");
|
||||||
|
sqlite3_mutex_leave(db->mutex);
|
||||||
|
return SQLITE_BUSY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Free any outstanding Savepoint structures. */
|
/* Free any outstanding Savepoint structures. */
|
||||||
sqlite3CloseSavepoints(db);
|
sqlite3CloseSavepoints(db);
|
||||||
|
|
||||||
|
@ -932,7 +955,7 @@ int sqlite3CreateFunc(
|
||||||
if( p && p->iPrefEnc==enc && p->nArg==nArg ){
|
if( p && p->iPrefEnc==enc && p->nArg==nArg ){
|
||||||
if( db->activeVdbeCnt ){
|
if( db->activeVdbeCnt ){
|
||||||
sqlite3Error(db, SQLITE_BUSY,
|
sqlite3Error(db, SQLITE_BUSY,
|
||||||
"Unable to delete/modify user-function due to active statements");
|
"unable to delete/modify user-function due to active statements");
|
||||||
assert( !db->mallocFailed );
|
assert( !db->mallocFailed );
|
||||||
return SQLITE_BUSY;
|
return SQLITE_BUSY;
|
||||||
}else{
|
}else{
|
||||||
|
@ -1342,7 +1365,7 @@ static int createCollation(
|
||||||
if( pColl && pColl->xCmp ){
|
if( pColl && pColl->xCmp ){
|
||||||
if( db->activeVdbeCnt ){
|
if( db->activeVdbeCnt ){
|
||||||
sqlite3Error(db, SQLITE_BUSY,
|
sqlite3Error(db, SQLITE_BUSY,
|
||||||
"Unable to delete/modify collation sequence due to active statements");
|
"unable to delete/modify collation sequence due to active statements");
|
||||||
return SQLITE_BUSY;
|
return SQLITE_BUSY;
|
||||||
}
|
}
|
||||||
sqlite3ExpirePreparedStatements(db);
|
sqlite3ExpirePreparedStatements(db);
|
||||||
|
@ -2127,6 +2150,25 @@ int sqlite3_test_control(int op, ...){
|
||||||
sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd);
|
sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** sqlite3_test_control(PENDING_BYTE, unsigned int X)
|
||||||
|
**
|
||||||
|
** Set the PENDING byte to the value in the argument, if X>0.
|
||||||
|
** Make no changes if X==0. Return the value of the pending byte
|
||||||
|
** as it existing before this routine was called.
|
||||||
|
**
|
||||||
|
** IMPORTANT: Changing the PENDING byte from 0x40000000 results in
|
||||||
|
** an incompatible database file format. Changing the PENDING byte
|
||||||
|
** while any database connection is open results in undefined and
|
||||||
|
** dileterious behavior.
|
||||||
|
*/
|
||||||
|
case SQLITE_TESTCTRL_PENDING_BYTE: {
|
||||||
|
unsigned int newVal = va_arg(ap, unsigned int);
|
||||||
|
rc = sqlite3PendingByte;
|
||||||
|
if( newVal ) sqlite3PendingByte = newVal;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
#endif /* SQLITE_OMIT_BUILTIN_TEST */
|
#endif /* SQLITE_OMIT_BUILTIN_TEST */
|
||||||
|
|
20
malloc.c
20
malloc.c
|
@ -12,11 +12,10 @@
|
||||||
**
|
**
|
||||||
** Memory allocation functions used throughout sqlite.
|
** Memory allocation functions used throughout sqlite.
|
||||||
**
|
**
|
||||||
** $Id: malloc.c,v 1.53 2008/12/16 17:20:38 shane Exp $
|
** $Id: malloc.c,v 1.56 2009/02/17 18:37:29 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This routine runs when the memory allocator sees that the
|
** This routine runs when the memory allocator sees that the
|
||||||
|
@ -154,7 +153,9 @@ int sqlite3MallocInit(void){
|
||||||
** Deinitialize the memory allocation subsystem.
|
** Deinitialize the memory allocation subsystem.
|
||||||
*/
|
*/
|
||||||
void sqlite3MallocEnd(void){
|
void sqlite3MallocEnd(void){
|
||||||
sqlite3GlobalConfig.m.xShutdown(sqlite3GlobalConfig.m.pAppData);
|
if( sqlite3GlobalConfig.m.xShutdown ){
|
||||||
|
sqlite3GlobalConfig.m.xShutdown(sqlite3GlobalConfig.m.pAppData);
|
||||||
|
}
|
||||||
memset(&mem0, 0, sizeof(mem0));
|
memset(&mem0, 0, sizeof(mem0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +266,15 @@ static int mallocWithAlarm(int n, void **pp){
|
||||||
*/
|
*/
|
||||||
void *sqlite3Malloc(int n){
|
void *sqlite3Malloc(int n){
|
||||||
void *p;
|
void *p;
|
||||||
if( n<=0 ){
|
if( n<=0 || NEVER(n>=0x7fffff00) ){
|
||||||
|
/* The NEVER(n>=0x7fffff00) term is added out of paranoia. We want to make
|
||||||
|
** absolutely sure that there is nothing within SQLite that can cause a
|
||||||
|
** memory allocation of a number of bytes which is near the maximum signed
|
||||||
|
** integer value and thus cause an integer overflow inside of the xMalloc()
|
||||||
|
** implementation. The n>=0x7fffff00 gives us 255 bytes of headroom. The
|
||||||
|
** test should never be true because SQLITE_MAX_LENGTH should be much
|
||||||
|
** less than 0x7fffff00 and it should catch large memory allocations
|
||||||
|
** before they reach this point. */
|
||||||
p = 0;
|
p = 0;
|
||||||
}else if( sqlite3GlobalConfig.bMemstat ){
|
}else if( sqlite3GlobalConfig.bMemstat ){
|
||||||
sqlite3_mutex_enter(mem0.mutex);
|
sqlite3_mutex_enter(mem0.mutex);
|
||||||
|
@ -554,7 +563,8 @@ void *sqlite3Realloc(void *pOld, int nBytes){
|
||||||
if( pOld==0 ){
|
if( pOld==0 ){
|
||||||
return sqlite3Malloc(nBytes);
|
return sqlite3Malloc(nBytes);
|
||||||
}
|
}
|
||||||
if( nBytes<=0 ){
|
if( nBytes<=0 || NEVER(nBytes>=0x7fffff00) ){
|
||||||
|
/* The NEVER(...) term is explained in comments on sqlite3Malloc() */
|
||||||
sqlite3_free(pOld);
|
sqlite3_free(pOld);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
11
mem2.c
11
mem2.c
|
@ -19,7 +19,7 @@
|
||||||
** This file contains implementations of the low-level memory allocation
|
** This file contains implementations of the low-level memory allocation
|
||||||
** routines specified in the sqlite3_mem_methods object.
|
** routines specified in the sqlite3_mem_methods object.
|
||||||
**
|
**
|
||||||
** $Id: mem2.c,v 1.42 2008/12/10 19:26:24 drh Exp $
|
** $Id: mem2.c,v 1.43 2009/02/05 03:00:06 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
@ -163,9 +163,11 @@ static struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){
|
||||||
pInt = (int*)pAllocation;
|
pInt = (int*)pAllocation;
|
||||||
pU8 = (u8*)pAllocation;
|
pU8 = (u8*)pAllocation;
|
||||||
assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );
|
assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );
|
||||||
assert( (nReserve-0)<=p->iSize || pU8[nReserve-1]==0x65 );
|
/* This checks any of the "extra" bytes allocated due
|
||||||
assert( (nReserve-1)<=p->iSize || pU8[nReserve-2]==0x65 );
|
** to rounding up to an 8 byte boundary to ensure
|
||||||
assert( (nReserve-2)<=p->iSize || pU8[nReserve-3]==0x65 );
|
** they haven't been overwritten.
|
||||||
|
*/
|
||||||
|
while( nReserve-- > p->iSize ) assert( pU8[nReserve]==0x65 );
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +188,7 @@ static int sqlite3MemSize(void *p){
|
||||||
*/
|
*/
|
||||||
static int sqlite3MemInit(void *NotUsed){
|
static int sqlite3MemInit(void *NotUsed){
|
||||||
UNUSED_PARAMETER(NotUsed);
|
UNUSED_PARAMETER(NotUsed);
|
||||||
|
assert( (sizeof(struct MemBlockHdr)&7) == 0 );
|
||||||
if( !sqlite3GlobalConfig.bMemstat ){
|
if( !sqlite3GlobalConfig.bMemstat ){
|
||||||
/* If memory status is enabled, then the malloc.c wrapper will already
|
/* If memory status is enabled, then the malloc.c wrapper will already
|
||||||
** hold the STATIC_MEM mutex when the routines here are invoked. */
|
** hold the STATIC_MEM mutex when the routines here are invoked. */
|
||||||
|
|
6
mutex.c
6
mutex.c
|
@ -14,7 +14,7 @@
|
||||||
** This file contains code that is common across all mutex implementations.
|
** This file contains code that is common across all mutex implementations.
|
||||||
|
|
||||||
**
|
**
|
||||||
** $Id: mutex.c,v 1.29 2008/10/07 15:25:48 drh Exp $
|
** $Id: mutex.c,v 1.30 2009/02/17 16:29:11 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
@ -67,7 +67,9 @@ int sqlite3MutexInit(void){
|
||||||
*/
|
*/
|
||||||
int sqlite3MutexEnd(void){
|
int sqlite3MutexEnd(void){
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
rc = sqlite3GlobalConfig.mutex.xMutexEnd();
|
if( sqlite3GlobalConfig.mutex.xMutexEnd ){
|
||||||
|
rc = sqlite3GlobalConfig.mutex.xMutexEnd();
|
||||||
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file contains the C functions that implement mutexes for win32
|
** This file contains the C functions that implement mutexes for win32
|
||||||
**
|
**
|
||||||
** $Id: mutex_w32.c,v 1.13 2008/12/08 18:19:18 drh Exp $
|
** $Id: mutex_w32.c,v 1.15 2009/01/30 16:09:23 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
@ -213,6 +213,8 @@ static int winMutexTry(sqlite3_mutex *p){
|
||||||
p->nRef++;
|
p->nRef++;
|
||||||
rc = SQLITE_OK;
|
rc = SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UNUSED_PARAMETER(p);
|
||||||
#endif
|
#endif
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
74
opcodes.h
74
opcodes.h
|
@ -16,7 +16,7 @@
|
||||||
#define OP_RowKey 14
|
#define OP_RowKey 14
|
||||||
#define OP_IsUnique 15
|
#define OP_IsUnique 15
|
||||||
#define OP_SetNumColumns 16
|
#define OP_SetNumColumns 16
|
||||||
#define OP_Eq 71 /* same as TK_EQ */
|
#define OP_Eq 73 /* same as TK_EQ */
|
||||||
#define OP_VUpdate 17
|
#define OP_VUpdate 17
|
||||||
#define OP_Expire 18
|
#define OP_Expire 18
|
||||||
#define OP_NullRow 20
|
#define OP_NullRow 20
|
||||||
|
@ -43,19 +43,19 @@
|
||||||
#define OP_IdxDelete 41
|
#define OP_IdxDelete 41
|
||||||
#define OP_Sort 42
|
#define OP_Sort 42
|
||||||
#define OP_ResetCount 43
|
#define OP_ResetCount 43
|
||||||
#define OP_NotNull 69 /* same as TK_NOTNULL */
|
#define OP_NotNull 71 /* same as TK_NOTNULL */
|
||||||
#define OP_Ge 75 /* same as TK_GE */
|
#define OP_Ge 77 /* same as TK_GE */
|
||||||
#define OP_Remainder 85 /* same as TK_REM */
|
#define OP_Remainder 87 /* same as TK_REM */
|
||||||
#define OP_Divide 84 /* same as TK_SLASH */
|
#define OP_Divide 86 /* same as TK_SLASH */
|
||||||
#define OP_Integer 44
|
#define OP_Integer 44
|
||||||
#define OP_Explain 45
|
#define OP_Explain 45
|
||||||
#define OP_IncrVacuum 46
|
#define OP_IncrVacuum 46
|
||||||
#define OP_AggStep 47
|
#define OP_AggStep 47
|
||||||
#define OP_CreateIndex 48
|
#define OP_CreateIndex 48
|
||||||
#define OP_NewRowid 49
|
#define OP_NewRowid 49
|
||||||
#define OP_And 64 /* same as TK_AND */
|
#define OP_And 66 /* same as TK_AND */
|
||||||
#define OP_ShiftLeft 79 /* same as TK_LSHIFT */
|
#define OP_ShiftLeft 81 /* same as TK_LSHIFT */
|
||||||
#define OP_Real 129 /* same as TK_FLOAT */
|
#define OP_Real 130 /* same as TK_FLOAT */
|
||||||
#define OP_Return 50
|
#define OP_Return 50
|
||||||
#define OP_Trace 51
|
#define OP_Trace 51
|
||||||
#define OP_IfPos 52
|
#define OP_IfPos 52
|
||||||
|
@ -63,29 +63,29 @@
|
||||||
#define OP_Rewind 54
|
#define OP_Rewind 54
|
||||||
#define OP_SeekGe 55
|
#define OP_SeekGe 55
|
||||||
#define OP_Affinity 56
|
#define OP_Affinity 56
|
||||||
#define OP_Gt 72 /* same as TK_GT */
|
#define OP_Gt 74 /* same as TK_GT */
|
||||||
#define OP_AddImm 57
|
#define OP_AddImm 57
|
||||||
#define OP_Subtract 82 /* same as TK_MINUS */
|
#define OP_Subtract 84 /* same as TK_MINUS */
|
||||||
#define OP_Null 58
|
#define OP_Null 58
|
||||||
#define OP_VColumn 59
|
#define OP_VColumn 59
|
||||||
#define OP_Clear 60
|
#define OP_Clear 60
|
||||||
#define OP_IsNull 68 /* same as TK_ISNULL */
|
#define OP_IsNull 70 /* same as TK_ISNULL */
|
||||||
#define OP_If 61
|
#define OP_If 61
|
||||||
#define OP_Permutation 62
|
#define OP_Permutation 62
|
||||||
#define OP_ToBlob 142 /* same as TK_TO_BLOB */
|
#define OP_ToBlob 142 /* same as TK_TO_BLOB */
|
||||||
#define OP_RealAffinity 65
|
#define OP_RealAffinity 63
|
||||||
#define OP_Yield 66
|
#define OP_Yield 64
|
||||||
#define OP_AggFinal 67
|
#define OP_AggFinal 67
|
||||||
#define OP_IfZero 76
|
#define OP_IfZero 68
|
||||||
#define OP_Last 87
|
#define OP_Last 69
|
||||||
#define OP_Rowid 88
|
#define OP_Rowid 78
|
||||||
#define OP_Sequence 89
|
#define OP_Sequence 89
|
||||||
#define OP_NotFound 92
|
#define OP_NotFound 90
|
||||||
#define OP_SeekGt 93
|
#define OP_SeekGt 91
|
||||||
#define OP_MakeRecord 94
|
#define OP_MakeRecord 94
|
||||||
#define OP_ToText 141 /* same as TK_TO_TEXT */
|
#define OP_ToText 141 /* same as TK_TO_TEXT */
|
||||||
#define OP_BitAnd 77 /* same as TK_BITAND */
|
#define OP_BitAnd 79 /* same as TK_BITAND */
|
||||||
#define OP_Add 81 /* same as TK_PLUS */
|
#define OP_Add 83 /* same as TK_PLUS */
|
||||||
#define OP_ResultRow 95
|
#define OP_ResultRow 95
|
||||||
#define OP_String 96
|
#define OP_String 96
|
||||||
#define OP_Goto 97
|
#define OP_Goto 97
|
||||||
|
@ -98,10 +98,10 @@
|
||||||
#define OP_Column 104
|
#define OP_Column 104
|
||||||
#define OP_Not 19 /* same as TK_NOT */
|
#define OP_Not 19 /* same as TK_NOT */
|
||||||
#define OP_Compare 105
|
#define OP_Compare 105
|
||||||
#define OP_Le 73 /* same as TK_LE */
|
#define OP_Le 75 /* same as TK_LE */
|
||||||
#define OP_BitOr 78 /* same as TK_BITOR */
|
#define OP_BitOr 80 /* same as TK_BITOR */
|
||||||
#define OP_Multiply 83 /* same as TK_STAR */
|
#define OP_Multiply 85 /* same as TK_STAR */
|
||||||
#define OP_String8 91 /* same as TK_STRING */
|
#define OP_String8 93 /* same as TK_STRING */
|
||||||
#define OP_VOpen 106
|
#define OP_VOpen 106
|
||||||
#define OP_CreateTable 107
|
#define OP_CreateTable 107
|
||||||
#define OP_Found 108
|
#define OP_Found 108
|
||||||
|
@ -116,10 +116,10 @@
|
||||||
#define OP_Next 116
|
#define OP_Next 116
|
||||||
#define OP_Prev 117
|
#define OP_Prev 117
|
||||||
#define OP_SeekLe 118
|
#define OP_SeekLe 118
|
||||||
#define OP_Lt 74 /* same as TK_LT */
|
#define OP_Lt 76 /* same as TK_LT */
|
||||||
#define OP_Ne 70 /* same as TK_NE */
|
#define OP_Ne 72 /* same as TK_NE */
|
||||||
#define OP_MustBeInt 119
|
#define OP_MustBeInt 119
|
||||||
#define OP_ShiftRight 80 /* same as TK_RSHIFT */
|
#define OP_ShiftRight 82 /* same as TK_RSHIFT */
|
||||||
#define OP_CollSeq 120
|
#define OP_CollSeq 120
|
||||||
#define OP_Gosub 121
|
#define OP_Gosub 121
|
||||||
#define OP_ContextPush 122
|
#define OP_ContextPush 122
|
||||||
|
@ -127,14 +127,14 @@
|
||||||
#define OP_Destroy 124
|
#define OP_Destroy 124
|
||||||
#define OP_IdxGE 125
|
#define OP_IdxGE 125
|
||||||
#define OP_ReadCookie 126
|
#define OP_ReadCookie 126
|
||||||
#define OP_BitNot 90 /* same as TK_BITNOT */
|
#define OP_BitNot 92 /* same as TK_BITNOT */
|
||||||
#define OP_Or 63 /* same as TK_OR */
|
#define OP_Or 65 /* same as TK_OR */
|
||||||
#define OP_Jump 127
|
#define OP_Jump 127
|
||||||
#define OP_ToReal 145 /* same as TK_TO_REAL */
|
#define OP_ToReal 145 /* same as TK_TO_REAL */
|
||||||
#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
|
#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
|
||||||
#define OP_Function 128
|
#define OP_Function 128
|
||||||
#define OP_Concat 86 /* same as TK_CONCAT */
|
#define OP_Concat 88 /* same as TK_CONCAT */
|
||||||
#define OP_SCopy 130
|
#define OP_SCopy 129
|
||||||
#define OP_Int64 131
|
#define OP_Int64 131
|
||||||
|
|
||||||
/* The following opcode values are never used */
|
/* The following opcode values are never used */
|
||||||
|
@ -167,15 +167,15 @@
|
||||||
/* 32 */ 0x10, 0x00, 0x02, 0x02, 0x01, 0x00, 0x00, 0x08,\
|
/* 32 */ 0x10, 0x00, 0x02, 0x02, 0x01, 0x00, 0x00, 0x08,\
|
||||||
/* 40 */ 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00,\
|
/* 40 */ 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00,\
|
||||||
/* 48 */ 0x02, 0x02, 0x04, 0x00, 0x05, 0x11, 0x01, 0x11,\
|
/* 48 */ 0x02, 0x02, 0x04, 0x00, 0x05, 0x11, 0x01, 0x11,\
|
||||||
/* 56 */ 0x00, 0x04, 0x02, 0x00, 0x00, 0x05, 0x00, 0x2c,\
|
/* 56 */ 0x00, 0x04, 0x02, 0x00, 0x00, 0x05, 0x00, 0x04,\
|
||||||
/* 64 */ 0x2c, 0x04, 0x04, 0x00, 0x05, 0x05, 0x15, 0x15,\
|
/* 64 */ 0x04, 0x2c, 0x2c, 0x00, 0x05, 0x01, 0x05, 0x05,\
|
||||||
/* 72 */ 0x15, 0x15, 0x15, 0x15, 0x05, 0x2c, 0x2c, 0x2c,\
|
/* 72 */ 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x02, 0x2c,\
|
||||||
/* 80 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x01,\
|
/* 80 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c,\
|
||||||
/* 88 */ 0x02, 0x02, 0x04, 0x02, 0x11, 0x11, 0x00, 0x00,\
|
/* 88 */ 0x2c, 0x02, 0x11, 0x11, 0x04, 0x02, 0x00, 0x00,\
|
||||||
/* 96 */ 0x02, 0x01, 0x00, 0x00, 0x21, 0x00, 0x02, 0x00,\
|
/* 96 */ 0x02, 0x01, 0x00, 0x00, 0x21, 0x00, 0x02, 0x00,\
|
||||||
/* 104 */ 0x00, 0x00, 0x00, 0x02, 0x11, 0x08, 0x00, 0x00,\
|
/* 104 */ 0x00, 0x00, 0x00, 0x02, 0x11, 0x08, 0x00, 0x00,\
|
||||||
/* 112 */ 0x00, 0x05, 0x00, 0x0c, 0x01, 0x01, 0x11, 0x05,\
|
/* 112 */ 0x00, 0x05, 0x00, 0x0c, 0x01, 0x01, 0x11, 0x05,\
|
||||||
/* 120 */ 0x00, 0x01, 0x00, 0x00, 0x02, 0x11, 0x02, 0x01,\
|
/* 120 */ 0x00, 0x01, 0x00, 0x00, 0x02, 0x11, 0x02, 0x01,\
|
||||||
/* 128 */ 0x00, 0x02, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00,\
|
/* 128 */ 0x00, 0x04, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,\
|
||||||
/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\
|
/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\
|
||||||
/* 144 */ 0x04, 0x04,}
|
/* 144 */ 0x04, 0x04,}
|
||||||
|
|
14
os.h
14
os.h
|
@ -17,7 +17,7 @@
|
||||||
** This header file is #include-ed by sqliteInt.h and thus ends up
|
** This header file is #include-ed by sqliteInt.h and thus ends up
|
||||||
** being included by every source file.
|
** being included by every source file.
|
||||||
**
|
**
|
||||||
** $Id: os.h,v 1.107 2009/01/14 23:03:41 drh Exp $
|
** $Id: os.h,v 1.108 2009/02/05 16:31:46 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE_OS_H_
|
#ifndef _SQLITE_OS_H_
|
||||||
#define _SQLITE_OS_H_
|
#define _SQLITE_OS_H_
|
||||||
|
@ -195,9 +195,7 @@
|
||||||
** a random byte is selected for a shared lock. The pool of bytes for
|
** a random byte is selected for a shared lock. The pool of bytes for
|
||||||
** shared locks begins at SHARED_FIRST.
|
** shared locks begins at SHARED_FIRST.
|
||||||
**
|
**
|
||||||
** These #defines are available in sqlite_aux.h so that adaptors for
|
** The same locking strategy and
|
||||||
** connecting SQLite to other operating systems can use the same byte
|
|
||||||
** ranges for locking. In particular, the same locking strategy and
|
|
||||||
** byte ranges are used for Unix. This leaves open the possiblity of having
|
** byte ranges are used for Unix. This leaves open the possiblity of having
|
||||||
** clients on win95, winNT, and unix all talking to the same shared file
|
** clients on win95, winNT, and unix all talking to the same shared file
|
||||||
** and all locking correctly. To do so would require that samba (or whatever
|
** and all locking correctly. To do so would require that samba (or whatever
|
||||||
|
@ -221,13 +219,7 @@
|
||||||
** 1GB boundary.
|
** 1GB boundary.
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_TEST
|
#define PENDING_BYTE sqlite3PendingByte
|
||||||
#define PENDING_BYTE 0x40000000 /* First byte past the 1GB boundary */
|
|
||||||
#else
|
|
||||||
extern unsigned int sqlite3_pending_byte;
|
|
||||||
#define PENDING_BYTE sqlite3_pending_byte
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define RESERVED_BYTE (PENDING_BYTE+1)
|
#define RESERVED_BYTE (PENDING_BYTE+1)
|
||||||
#define SHARED_FIRST (PENDING_BYTE+2)
|
#define SHARED_FIRST (PENDING_BYTE+2)
|
||||||
#define SHARED_SIZE 510
|
#define SHARED_SIZE 510
|
||||||
|
|
44
os_unix.c
44
os_unix.c
|
@ -43,7 +43,7 @@
|
||||||
** * Definitions of sqlite3_vfs objects for all locking methods
|
** * Definitions of sqlite3_vfs objects for all locking methods
|
||||||
** plus implementations of sqlite3_os_init() and sqlite3_os_end().
|
** plus implementations of sqlite3_os_init() and sqlite3_os_end().
|
||||||
**
|
**
|
||||||
** $Id: os_unix.c,v 1.237 2009/01/15 04:30:03 drh Exp $
|
** $Id: os_unix.c,v 1.241 2009/02/09 17:34:07 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#if SQLITE_OS_UNIX /* This file is used on unix only */
|
#if SQLITE_OS_UNIX /* This file is used on unix only */
|
||||||
|
@ -183,7 +183,9 @@ struct unixFile {
|
||||||
unsigned char locktype; /* The type of lock held on this fd */
|
unsigned char locktype; /* The type of lock held on this fd */
|
||||||
int lastErrno; /* The unix errno from the last I/O error */
|
int lastErrno; /* The unix errno from the last I/O error */
|
||||||
void *lockingContext; /* Locking style specific state */
|
void *lockingContext; /* Locking style specific state */
|
||||||
int openFlags; /* The flags specified at open */
|
#if SQLITE_ENABLE_LOCKING_STYLE
|
||||||
|
int openFlags; /* The flags specified at open() */
|
||||||
|
#endif
|
||||||
#if SQLITE_THREADSAFE && defined(__linux__)
|
#if SQLITE_THREADSAFE && defined(__linux__)
|
||||||
pthread_t tid; /* The thread that "owns" this unixFile */
|
pthread_t tid; /* The thread that "owns" this unixFile */
|
||||||
#endif
|
#endif
|
||||||
|
@ -202,6 +204,11 @@ struct unixFile {
|
||||||
unsigned char transCntrChng; /* True if the transaction counter changed */
|
unsigned char transCntrChng; /* True if the transaction counter changed */
|
||||||
unsigned char dbUpdate; /* True if any part of database file changed */
|
unsigned char dbUpdate; /* True if any part of database file changed */
|
||||||
unsigned char inNormalWrite; /* True if in a normal write operation */
|
unsigned char inNormalWrite; /* True if in a normal write operation */
|
||||||
|
|
||||||
|
/* If true, that means we are dealing with a database file that has
|
||||||
|
** a range of locking bytes from PENDING_BYTE through PENDING_BYTE+511
|
||||||
|
** which should never be read or written. Asserts() will verify this */
|
||||||
|
unsigned char isLockable; /* True if file might be locked */
|
||||||
#endif
|
#endif
|
||||||
#ifdef SQLITE_TEST
|
#ifdef SQLITE_TEST
|
||||||
/* In test mode, increase the size of this structure a bit so that
|
/* In test mode, increase the size of this structure a bit so that
|
||||||
|
@ -920,6 +927,7 @@ static int findLockInfo(
|
||||||
return SQLITE_IOERR;
|
return SQLITE_IOERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
/* On OS X on an msdos filesystem, the inode number is reported
|
/* On OS X on an msdos filesystem, the inode number is reported
|
||||||
** incorrectly for zero-size files. See ticket #3260. To work
|
** incorrectly for zero-size files. See ticket #3260. To work
|
||||||
** around this problem (we consider it a bug in OS X, not SQLite)
|
** around this problem (we consider it a bug in OS X, not SQLite)
|
||||||
|
@ -931,13 +939,17 @@ static int findLockInfo(
|
||||||
** the first page of the database, no damage is done.
|
** the first page of the database, no damage is done.
|
||||||
*/
|
*/
|
||||||
if( statbuf.st_size==0 ){
|
if( statbuf.st_size==0 ){
|
||||||
write(fd, "S", 1);
|
rc = write(fd, "S", 1);
|
||||||
|
if( rc!=1 ){
|
||||||
|
return SQLITE_IOERR;
|
||||||
|
}
|
||||||
rc = fstat(fd, &statbuf);
|
rc = fstat(fd, &statbuf);
|
||||||
if( rc!=0 ){
|
if( rc!=0 ){
|
||||||
pFile->lastErrno = errno;
|
pFile->lastErrno = errno;
|
||||||
return SQLITE_IOERR;
|
return SQLITE_IOERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
memset(&lockKey, 0, sizeof(lockKey));
|
memset(&lockKey, 0, sizeof(lockKey));
|
||||||
lockKey.fid.dev = statbuf.st_dev;
|
lockKey.fid.dev = statbuf.st_dev;
|
||||||
|
@ -1084,6 +1096,7 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
|
||||||
|
|
||||||
/* Otherwise see if some other process holds it.
|
/* Otherwise see if some other process holds it.
|
||||||
*/
|
*/
|
||||||
|
#ifndef __DJGPP__
|
||||||
if( !reserved ){
|
if( !reserved ){
|
||||||
struct flock lock;
|
struct flock lock;
|
||||||
lock.l_whence = SEEK_SET;
|
lock.l_whence = SEEK_SET;
|
||||||
|
@ -1098,6 +1111,7 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
|
||||||
reserved = 1;
|
reserved = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
unixLeaveMutex();
|
unixLeaveMutex();
|
||||||
OSTRACE4("TEST WR-LOCK %d %d %d\n", pFile->h, rc, reserved);
|
OSTRACE4("TEST WR-LOCK %d %d %d\n", pFile->h, rc, reserved);
|
||||||
|
@ -1425,7 +1439,7 @@ static int unixUnlock(sqlite3_file *id, int locktype){
|
||||||
if( IS_LOCK_ERROR(rc) ){
|
if( IS_LOCK_ERROR(rc) ){
|
||||||
pFile->lastErrno = tErrno;
|
pFile->lastErrno = tErrno;
|
||||||
}
|
}
|
||||||
goto end_unlock;
|
goto end_unlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lock.l_type = F_UNLCK;
|
lock.l_type = F_UNLCK;
|
||||||
|
@ -2682,6 +2696,12 @@ static int unixRead(
|
||||||
){
|
){
|
||||||
int got;
|
int got;
|
||||||
assert( id );
|
assert( id );
|
||||||
|
|
||||||
|
/* Never read or write any of the bytes in the locking range */
|
||||||
|
assert( ((unixFile*)id)->isLockable==0
|
||||||
|
|| offset>=PENDING_BYTE+512
|
||||||
|
|| offset+amt<=PENDING_BYTE );
|
||||||
|
|
||||||
got = seekAndRead((unixFile*)id, offset, pBuf, amt);
|
got = seekAndRead((unixFile*)id, offset, pBuf, amt);
|
||||||
if( got==amt ){
|
if( got==amt ){
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
|
@ -2747,6 +2767,11 @@ static int unixWrite(
|
||||||
assert( id );
|
assert( id );
|
||||||
assert( amt>0 );
|
assert( amt>0 );
|
||||||
|
|
||||||
|
/* Never read or write any of the bytes in the locking range */
|
||||||
|
assert( ((unixFile*)id)->isLockable==0
|
||||||
|
|| offset>=PENDING_BYTE+512
|
||||||
|
|| offset+amt<=PENDING_BYTE );
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
/* If we are doing a normal write to a database file (as opposed to
|
/* If we are doing a normal write to a database file (as opposed to
|
||||||
** doing a hot-journal rollback or a write to some file other than a
|
** doing a hot-journal rollback or a write to some file other than a
|
||||||
|
@ -2758,11 +2783,12 @@ static int unixWrite(
|
||||||
unixFile *pFile = (unixFile*)id;
|
unixFile *pFile = (unixFile*)id;
|
||||||
pFile->dbUpdate = 1; /* The database has been modified */
|
pFile->dbUpdate = 1; /* The database has been modified */
|
||||||
if( offset<=24 && offset+amt>=27 ){
|
if( offset<=24 && offset+amt>=27 ){
|
||||||
|
int rc;
|
||||||
char oldCntr[4];
|
char oldCntr[4];
|
||||||
SimulateIOErrorBenign(1);
|
SimulateIOErrorBenign(1);
|
||||||
seekAndRead(pFile, 24, oldCntr, 4);
|
rc = seekAndRead(pFile, 24, oldCntr, 4);
|
||||||
SimulateIOErrorBenign(0);
|
SimulateIOErrorBenign(0);
|
||||||
if( memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){
|
if( rc!=4 || memcmp(oldCntr, &((char*)pBuf)[24-offset], 4)!=0 ){
|
||||||
pFile->transCntrChng = 1; /* The transaction counter has changed */
|
pFile->transCntrChng = 1; /* The transaction counter has changed */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3670,6 +3696,12 @@ static int unixOpen(
|
||||||
*pOutFlags = flags;
|
*pOutFlags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if( (flags & SQLITE_OPEN_MAIN_DB)!=0 ){
|
||||||
|
((unixFile*)pFile)->isLockable = 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
assert(fd!=0);
|
assert(fd!=0);
|
||||||
if( isOpenDirectory ){
|
if( isOpenDirectory ){
|
||||||
rc = openDirectory(zPath, &dirfd);
|
rc = openDirectory(zPath, &dirfd);
|
||||||
|
|
86
os_win.c
86
os_win.c
|
@ -12,7 +12,7 @@
|
||||||
**
|
**
|
||||||
** This file contains code that is specific to windows.
|
** This file contains code that is specific to windows.
|
||||||
**
|
**
|
||||||
** $Id: os_win.c,v 1.145 2008/12/11 02:58:27 shane Exp $
|
** $Id: os_win.c,v 1.148 2009/02/05 03:16:21 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#if SQLITE_OS_WIN /* This file is used for windows only */
|
#if SQLITE_OS_WIN /* This file is used for windows only */
|
||||||
|
@ -100,6 +100,7 @@ struct winFile {
|
||||||
HANDLE h; /* Handle for accessing the file */
|
HANDLE h; /* Handle for accessing the file */
|
||||||
unsigned char locktype; /* Type of lock currently held on this file */
|
unsigned char locktype; /* Type of lock currently held on this file */
|
||||||
short sharedLockByte; /* Randomly chosen byte used as a shared lock */
|
short sharedLockByte; /* Randomly chosen byte used as a shared lock */
|
||||||
|
DWORD lastErrno; /* The Windows errno from the last I/O error */
|
||||||
#if SQLITE_OS_WINCE
|
#if SQLITE_OS_WINCE
|
||||||
WCHAR *zDeleteOnClose; /* Name of file to delete when closing */
|
WCHAR *zDeleteOnClose; /* Name of file to delete when closing */
|
||||||
HANDLE hMutex; /* Mutex used to control access to shared lock */
|
HANDLE hMutex; /* Mutex used to control access to shared lock */
|
||||||
|
@ -358,6 +359,7 @@ static BOOL winceCreateLock(const char *zFilename, winFile *pFile){
|
||||||
/* Create/open the named mutex */
|
/* Create/open the named mutex */
|
||||||
pFile->hMutex = CreateMutexW(NULL, FALSE, zName);
|
pFile->hMutex = CreateMutexW(NULL, FALSE, zName);
|
||||||
if (!pFile->hMutex){
|
if (!pFile->hMutex){
|
||||||
|
pFile->lastErrno = GetLastError();
|
||||||
free(zName);
|
free(zName);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -388,6 +390,7 @@ static BOOL winceCreateLock(const char *zFilename, winFile *pFile){
|
||||||
FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));
|
FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));
|
||||||
/* If mapping failed, close the shared memory handle and erase it */
|
/* If mapping failed, close the shared memory handle and erase it */
|
||||||
if (!pFile->shared){
|
if (!pFile->shared){
|
||||||
|
pFile->lastErrno = GetLastError();
|
||||||
CloseHandle(pFile->hShared);
|
CloseHandle(pFile->hShared);
|
||||||
pFile->hShared = NULL;
|
pFile->hShared = NULL;
|
||||||
}
|
}
|
||||||
|
@ -653,14 +656,17 @@ static int winRead(
|
||||||
DWORD rc;
|
DWORD rc;
|
||||||
DWORD got;
|
DWORD got;
|
||||||
winFile *pFile = (winFile*)id;
|
winFile *pFile = (winFile*)id;
|
||||||
|
DWORD error;
|
||||||
assert( id!=0 );
|
assert( id!=0 );
|
||||||
SimulateIOError(return SQLITE_IOERR_READ);
|
SimulateIOError(return SQLITE_IOERR_READ);
|
||||||
OSTRACE3("READ %d lock=%d\n", pFile->h, pFile->locktype);
|
OSTRACE3("READ %d lock=%d\n", pFile->h, pFile->locktype);
|
||||||
rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
|
rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
|
||||||
if( rc==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR ){
|
if( rc==INVALID_SET_FILE_POINTER && (error=GetLastError())!=NO_ERROR ){
|
||||||
|
pFile->lastErrno = error;
|
||||||
return SQLITE_FULL;
|
return SQLITE_FULL;
|
||||||
}
|
}
|
||||||
if( !ReadFile(pFile->h, pBuf, amt, &got, 0) ){
|
if( !ReadFile(pFile->h, pBuf, amt, &got, 0) ){
|
||||||
|
pFile->lastErrno = GetLastError();
|
||||||
return SQLITE_IOERR_READ;
|
return SQLITE_IOERR_READ;
|
||||||
}
|
}
|
||||||
if( got==(DWORD)amt ){
|
if( got==(DWORD)amt ){
|
||||||
|
@ -687,12 +693,14 @@ static int winWrite(
|
||||||
DWORD rc;
|
DWORD rc;
|
||||||
DWORD wrote = 0;
|
DWORD wrote = 0;
|
||||||
winFile *pFile = (winFile*)id;
|
winFile *pFile = (winFile*)id;
|
||||||
|
DWORD error;
|
||||||
assert( id!=0 );
|
assert( id!=0 );
|
||||||
SimulateIOError(return SQLITE_IOERR_WRITE);
|
SimulateIOError(return SQLITE_IOERR_WRITE);
|
||||||
SimulateDiskfullError(return SQLITE_FULL);
|
SimulateDiskfullError(return SQLITE_FULL);
|
||||||
OSTRACE3("WRITE %d lock=%d\n", pFile->h, pFile->locktype);
|
OSTRACE3("WRITE %d lock=%d\n", pFile->h, pFile->locktype);
|
||||||
rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
|
rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
|
||||||
if( rc==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR ){
|
if( rc==INVALID_SET_FILE_POINTER && (error=GetLastError())!=NO_ERROR ){
|
||||||
|
pFile->lastErrno = error;
|
||||||
return SQLITE_FULL;
|
return SQLITE_FULL;
|
||||||
}
|
}
|
||||||
assert( amt>0 );
|
assert( amt>0 );
|
||||||
|
@ -705,6 +713,7 @@ static int winWrite(
|
||||||
pBuf = &((char*)pBuf)[wrote];
|
pBuf = &((char*)pBuf)[wrote];
|
||||||
}
|
}
|
||||||
if( !rc || amt>(int)wrote ){
|
if( !rc || amt>(int)wrote ){
|
||||||
|
pFile->lastErrno = GetLastError();
|
||||||
return SQLITE_FULL;
|
return SQLITE_FULL;
|
||||||
}
|
}
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
|
@ -718,15 +727,21 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
|
||||||
LONG upperBits = (LONG)((nByte>>32) & 0x7fffffff);
|
LONG upperBits = (LONG)((nByte>>32) & 0x7fffffff);
|
||||||
LONG lowerBits = (LONG)(nByte & 0xffffffff);
|
LONG lowerBits = (LONG)(nByte & 0xffffffff);
|
||||||
winFile *pFile = (winFile*)id;
|
winFile *pFile = (winFile*)id;
|
||||||
|
DWORD error = NO_ERROR;
|
||||||
OSTRACE3("TRUNCATE %d %lld\n", pFile->h, nByte);
|
OSTRACE3("TRUNCATE %d %lld\n", pFile->h, nByte);
|
||||||
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
|
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
|
||||||
rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
|
rc = SetFilePointer(pFile->h, lowerBits, &upperBits, FILE_BEGIN);
|
||||||
if( INVALID_SET_FILE_POINTER != rc ){
|
if( INVALID_SET_FILE_POINTER == rc ){
|
||||||
|
error = GetLastError();
|
||||||
|
}
|
||||||
|
if( error == NO_ERROR ){
|
||||||
/* SetEndOfFile will fail if nByte is negative */
|
/* SetEndOfFile will fail if nByte is negative */
|
||||||
if( SetEndOfFile(pFile->h) ){
|
if( SetEndOfFile(pFile->h) ){
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
error = GetLastError();
|
||||||
}
|
}
|
||||||
|
pFile->lastErrno = error;
|
||||||
return SQLITE_IOERR_TRUNCATE;
|
return SQLITE_IOERR_TRUNCATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,10 +760,10 @@ int sqlite3_fullsync_count = 0;
|
||||||
static int winSync(sqlite3_file *id, int flags){
|
static int winSync(sqlite3_file *id, int flags){
|
||||||
#ifndef SQLITE_NO_SYNC
|
#ifndef SQLITE_NO_SYNC
|
||||||
winFile *pFile = (winFile*)id;
|
winFile *pFile = (winFile*)id;
|
||||||
|
OSTRACE3("SYNC %d lock=%d\n", pFile->h, pFile->locktype);
|
||||||
#else
|
#else
|
||||||
UNUSED_PARAMETER(id);
|
UNUSED_PARAMETER(id);
|
||||||
#endif
|
#endif
|
||||||
OSTRACE3("SYNC %d lock=%d\n", pFile->h, pFile->locktype);
|
|
||||||
#ifndef SQLITE_TEST
|
#ifndef SQLITE_TEST
|
||||||
UNUSED_PARAMETER(flags);
|
UNUSED_PARAMETER(flags);
|
||||||
#else
|
#else
|
||||||
|
@ -766,6 +781,7 @@ static int winSync(sqlite3_file *id, int flags){
|
||||||
if( FlushFileBuffers(pFile->h) ){
|
if( FlushFileBuffers(pFile->h) ){
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}else{
|
}else{
|
||||||
|
pFile->lastErrno = GetLastError();
|
||||||
return SQLITE_IOERR;
|
return SQLITE_IOERR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -777,8 +793,15 @@ static int winSync(sqlite3_file *id, int flags){
|
||||||
static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
|
static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
|
||||||
winFile *pFile = (winFile*)id;
|
winFile *pFile = (winFile*)id;
|
||||||
DWORD upperBits, lowerBits;
|
DWORD upperBits, lowerBits;
|
||||||
|
DWORD error;
|
||||||
SimulateIOError(return SQLITE_IOERR_FSTAT);
|
SimulateIOError(return SQLITE_IOERR_FSTAT);
|
||||||
lowerBits = GetFileSize(pFile->h, &upperBits);
|
lowerBits = GetFileSize(pFile->h, &upperBits);
|
||||||
|
if( (lowerBits == INVALID_FILE_SIZE)
|
||||||
|
&& ((error = GetLastError()) != NO_ERROR) )
|
||||||
|
{
|
||||||
|
pFile->lastErrno = error;
|
||||||
|
return SQLITE_IOERR_FSTAT;
|
||||||
|
}
|
||||||
*pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
|
*pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
@ -814,6 +837,9 @@ static int getReadLock(winFile *pFile){
|
||||||
res = LockFile(pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);
|
res = LockFile(pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if( res == 0 ){
|
||||||
|
pFile->lastErrno = GetLastError();
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,6 +857,9 @@ static int unlockReadLock(winFile *pFile){
|
||||||
res = UnlockFile(pFile->h, SHARED_FIRST + pFile->sharedLockByte, 0, 1, 0);
|
res = UnlockFile(pFile->h, SHARED_FIRST + pFile->sharedLockByte, 0, 1, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
if( res == 0 ){
|
||||||
|
pFile->lastErrno = GetLastError();
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -866,6 +895,7 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||||
int newLocktype; /* Set pFile->locktype to this value before exiting */
|
int newLocktype; /* Set pFile->locktype to this value before exiting */
|
||||||
int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */
|
int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */
|
||||||
winFile *pFile = (winFile*)id;
|
winFile *pFile = (winFile*)id;
|
||||||
|
DWORD error = NO_ERROR;
|
||||||
|
|
||||||
assert( pFile!=0 );
|
assert( pFile!=0 );
|
||||||
OSTRACE5("LOCK %d %d was %d(%d)\n",
|
OSTRACE5("LOCK %d %d was %d(%d)\n",
|
||||||
|
@ -890,8 +920,9 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||||
** the PENDING_LOCK byte is temporary.
|
** the PENDING_LOCK byte is temporary.
|
||||||
*/
|
*/
|
||||||
newLocktype = pFile->locktype;
|
newLocktype = pFile->locktype;
|
||||||
if( pFile->locktype==NO_LOCK
|
if( (pFile->locktype==NO_LOCK)
|
||||||
|| (locktype==EXCLUSIVE_LOCK && pFile->locktype==RESERVED_LOCK)
|
|| ( (locktype==EXCLUSIVE_LOCK)
|
||||||
|
&& (pFile->locktype==RESERVED_LOCK))
|
||||||
){
|
){
|
||||||
int cnt = 3;
|
int cnt = 3;
|
||||||
while( cnt-->0 && (res = LockFile(pFile->h, PENDING_BYTE, 0, 1, 0))==0 ){
|
while( cnt-->0 && (res = LockFile(pFile->h, PENDING_BYTE, 0, 1, 0))==0 ){
|
||||||
|
@ -902,6 +933,9 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||||
Sleep(1);
|
Sleep(1);
|
||||||
}
|
}
|
||||||
gotPendingLock = res;
|
gotPendingLock = res;
|
||||||
|
if( !res ){
|
||||||
|
error = GetLastError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Acquire a shared lock
|
/* Acquire a shared lock
|
||||||
|
@ -911,6 +945,8 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||||
res = getReadLock(pFile);
|
res = getReadLock(pFile);
|
||||||
if( res ){
|
if( res ){
|
||||||
newLocktype = SHARED_LOCK;
|
newLocktype = SHARED_LOCK;
|
||||||
|
}else{
|
||||||
|
error = GetLastError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -921,6 +957,8 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||||
res = LockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);
|
res = LockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);
|
||||||
if( res ){
|
if( res ){
|
||||||
newLocktype = RESERVED_LOCK;
|
newLocktype = RESERVED_LOCK;
|
||||||
|
}else{
|
||||||
|
error = GetLastError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -941,7 +979,8 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||||
if( res ){
|
if( res ){
|
||||||
newLocktype = EXCLUSIVE_LOCK;
|
newLocktype = EXCLUSIVE_LOCK;
|
||||||
}else{
|
}else{
|
||||||
OSTRACE2("error-code = %d\n", GetLastError());
|
error = GetLastError();
|
||||||
|
OSTRACE2("error-code = %d\n", error);
|
||||||
getReadLock(pFile);
|
getReadLock(pFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -961,6 +1000,7 @@ static int winLock(sqlite3_file *id, int locktype){
|
||||||
}else{
|
}else{
|
||||||
OSTRACE4("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
|
OSTRACE4("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
|
||||||
locktype, newLocktype);
|
locktype, newLocktype);
|
||||||
|
pFile->lastErrno = error;
|
||||||
rc = SQLITE_BUSY;
|
rc = SQLITE_BUSY;
|
||||||
}
|
}
|
||||||
pFile->locktype = (u8)newLocktype;
|
pFile->locktype = (u8)newLocktype;
|
||||||
|
@ -1041,6 +1081,10 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
|
||||||
*(int*)pArg = ((winFile*)id)->locktype;
|
*(int*)pArg = ((winFile*)id)->locktype;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
|
case SQLITE_LAST_ERRNO: {
|
||||||
|
*(int*)pArg = (int)((winFile*)id)->lastErrno;
|
||||||
|
return SQLITE_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SQLITE_ERROR;
|
return SQLITE_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1320,6 +1364,7 @@ static int winOpen(
|
||||||
memset(pFile, 0, sizeof(*pFile));
|
memset(pFile, 0, sizeof(*pFile));
|
||||||
pFile->pMethod = &winIoMethod;
|
pFile->pMethod = &winIoMethod;
|
||||||
pFile->h = h;
|
pFile->h = h;
|
||||||
|
pFile->lastErrno = NO_ERROR;
|
||||||
#if SQLITE_OS_WINCE
|
#if SQLITE_OS_WINCE
|
||||||
if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) ==
|
if( (flags & (SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)) ==
|
||||||
(SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)
|
(SQLITE_OPEN_READWRITE|SQLITE_OPEN_MAIN_DB)
|
||||||
|
@ -1632,7 +1677,7 @@ int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
|
||||||
/* FILETIME structure is a 64-bit value representing the number of
|
/* FILETIME structure is a 64-bit value representing the number of
|
||||||
100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).
|
100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).
|
||||||
*/
|
*/
|
||||||
double now;
|
sqlite3_int64 timeW, timeF;
|
||||||
#if SQLITE_OS_WINCE
|
#if SQLITE_OS_WINCE
|
||||||
SYSTEMTIME time;
|
SYSTEMTIME time;
|
||||||
GetSystemTime(&time);
|
GetSystemTime(&time);
|
||||||
|
@ -1644,11 +1689,28 @@ int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
|
||||||
GetSystemTimeAsFileTime( &ft );
|
GetSystemTimeAsFileTime( &ft );
|
||||||
#endif
|
#endif
|
||||||
UNUSED_PARAMETER(pVfs);
|
UNUSED_PARAMETER(pVfs);
|
||||||
now = ((double)ft.dwHighDateTime) * 4294967296.0;
|
#if defined(_MSC_VER)
|
||||||
*prNow = (now + ft.dwLowDateTime)/864000000000.0 + 2305813.5;
|
timeW = (((sqlite3_int64)ft.dwHighDateTime)*4294967296) + ft.dwLowDateTime;
|
||||||
|
timeF = timeW % 864000000000; /* fractional days (100-nanoseconds) */
|
||||||
|
timeW = timeW / 864000000000; /* whole days */
|
||||||
|
timeW = timeW + 2305813; /* add whole days (from 2305813.5) */
|
||||||
|
timeF = timeF + 432000000000; /* add half a day (from 2305813.5) */
|
||||||
|
timeW = timeW + (timeF / 864000000000); /* add whole day if half day made one */
|
||||||
|
timeF = timeF % 864000000000; /* compute new fractional days */
|
||||||
|
*prNow = (double)timeW + ((double)timeF / (double)864000000000);
|
||||||
|
#else
|
||||||
|
timeW = (((sqlite3_int64)ft.dwHighDateTime)*4294967296LL) + ft.dwLowDateTime;
|
||||||
|
timeF = timeW % 864000000000LL; /* fractional days (100-nanoseconds) */
|
||||||
|
timeW = timeW / 864000000000LL; /* whole days */
|
||||||
|
timeW = timeW + 2305813; /* add whole days (from 2305813.5) */
|
||||||
|
timeF = timeF + 432000000000LL; /* add half a day (from 2305813.5) */
|
||||||
|
timeW = timeW + (timeF / 864000000000LL); /* add whole day if half day made one */
|
||||||
|
timeF = timeF % 864000000000LL; /* compute new fractional days */
|
||||||
|
*prNow = (double)timeW + ((double)timeF / (double)864000000000LL);
|
||||||
|
#endif
|
||||||
#ifdef SQLITE_TEST
|
#ifdef SQLITE_TEST
|
||||||
if( sqlite3_current_time ){
|
if( sqlite3_current_time ){
|
||||||
*prNow = sqlite3_current_time/86400.0 + 2440587.5;
|
*prNow = ((double)sqlite3_current_time + (double)43200) / (double)86400 + (double)2440587;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
110
pager.h
110
pager.h
|
@ -13,15 +13,16 @@
|
||||||
** subsystem. The page cache subsystem reads and writes a file a page
|
** subsystem. The page cache subsystem reads and writes a file a page
|
||||||
** at a time and provides a journal for rollback.
|
** at a time and provides a journal for rollback.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.h,v 1.93 2009/01/07 15:18:21 danielk1977 Exp $
|
** @(#) $Id: pager.h,v 1.100 2009/02/03 16:51:25 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PAGER_H_
|
#ifndef _PAGER_H_
|
||||||
#define _PAGER_H_
|
#define _PAGER_H_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
|
** Default maximum size for persistent journal files. A negative
|
||||||
** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
|
** value means no limit. This value may be overridden using the
|
||||||
|
** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit".
|
||||||
*/
|
*/
|
||||||
#ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
|
#ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
|
||||||
#define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1
|
#define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1
|
||||||
|
@ -43,10 +44,20 @@ typedef struct Pager Pager;
|
||||||
*/
|
*/
|
||||||
typedef struct PgHdr DbPage;
|
typedef struct PgHdr DbPage;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
|
||||||
|
** reserved for working around a windows/posix incompatibility). It is
|
||||||
|
** used in the journal to signify that the remainder of the journal file
|
||||||
|
** is devoted to storing a master journal name - there are no more pages to
|
||||||
|
** roll back. See comments for function writeMasterJournal() in pager.c
|
||||||
|
** for details.
|
||||||
|
*/
|
||||||
|
#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Allowed values for the flags parameter to sqlite3PagerOpen().
|
** Allowed values for the flags parameter to sqlite3PagerOpen().
|
||||||
**
|
**
|
||||||
** NOTE: This values must match the corresponding BTREE_ values in btree.h.
|
** NOTE: These values must match the corresponding BTREE_ values in btree.h.
|
||||||
*/
|
*/
|
||||||
#define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */
|
#define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */
|
||||||
#define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */
|
#define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */
|
||||||
|
@ -69,75 +80,82 @@ typedef struct PgHdr DbPage;
|
||||||
#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
|
#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** See source code comments for a detailed description of the following
|
** The remainder of this file contains the declarations of the functions
|
||||||
** routines:
|
** that make up the Pager sub-system API. See source code comments for
|
||||||
|
** a detailed description of each routine.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Open and close a Pager connection. */
|
||||||
int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int);
|
int sqlite3PagerOpen(sqlite3_vfs *, Pager **ppPager, const char*, int,int,int);
|
||||||
|
int sqlite3PagerClose(Pager *pPager);
|
||||||
|
int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
|
||||||
|
|
||||||
|
/* Functions used to configure a Pager object. */
|
||||||
void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
|
void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
|
||||||
void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*));
|
void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*));
|
||||||
int sqlite3PagerSetPagesize(Pager*, u16*);
|
int sqlite3PagerSetPagesize(Pager*, u16*);
|
||||||
int sqlite3PagerMaxPageCount(Pager*, int);
|
int sqlite3PagerMaxPageCount(Pager*, int);
|
||||||
int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
|
|
||||||
void sqlite3PagerSetCachesize(Pager*, int);
|
void sqlite3PagerSetCachesize(Pager*, int);
|
||||||
int sqlite3PagerClose(Pager *pPager);
|
|
||||||
int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
|
|
||||||
#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
|
|
||||||
DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
|
|
||||||
int sqlite3PagerPageRefcount(DbPage*);
|
|
||||||
int sqlite3PagerRef(DbPage*);
|
|
||||||
int sqlite3PagerUnref(DbPage*);
|
|
||||||
int sqlite3PagerWrite(DbPage*);
|
|
||||||
int sqlite3PagerPagecount(Pager*, int*);
|
|
||||||
int sqlite3PagerBegin(DbPage*, int exFlag);
|
|
||||||
int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);
|
|
||||||
int sqlite3PagerCommitPhaseTwo(Pager*);
|
|
||||||
int sqlite3PagerRollback(Pager*);
|
|
||||||
u8 sqlite3PagerIsreadonly(Pager*);
|
|
||||||
void sqlite3PagerDontRollback(DbPage*);
|
|
||||||
int sqlite3PagerDontWrite(DbPage*);
|
|
||||||
int sqlite3PagerRefcount(Pager*);
|
|
||||||
void sqlite3PagerSetSafetyLevel(Pager*,int,int);
|
void sqlite3PagerSetSafetyLevel(Pager*,int,int);
|
||||||
const char *sqlite3PagerFilename(Pager*);
|
|
||||||
const sqlite3_vfs *sqlite3PagerVfs(Pager*);
|
|
||||||
sqlite3_file *sqlite3PagerFile(Pager*);
|
|
||||||
const char *sqlite3PagerDirname(Pager*);
|
|
||||||
const char *sqlite3PagerJournalname(Pager*);
|
|
||||||
int sqlite3PagerNosync(Pager*);
|
|
||||||
int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);
|
|
||||||
void *sqlite3PagerGetData(DbPage *);
|
|
||||||
void *sqlite3PagerGetExtra(DbPage *);
|
|
||||||
int sqlite3PagerLockingMode(Pager *, int);
|
int sqlite3PagerLockingMode(Pager *, int);
|
||||||
int sqlite3PagerJournalMode(Pager *, int);
|
int sqlite3PagerJournalMode(Pager *, int);
|
||||||
i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
|
i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
|
||||||
void *sqlite3PagerTempSpace(Pager*);
|
sqlite3_backup **sqlite3PagerBackupPtr(Pager*);
|
||||||
int sqlite3PagerSync(Pager *pPager);
|
|
||||||
|
|
||||||
|
/* Functions used to obtain and release page references. */
|
||||||
|
int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag);
|
||||||
|
#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0)
|
||||||
|
DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
|
||||||
|
void sqlite3PagerRef(DbPage*);
|
||||||
|
void sqlite3PagerUnref(DbPage*);
|
||||||
|
|
||||||
|
/* Operations on page references. */
|
||||||
|
int sqlite3PagerWrite(DbPage*);
|
||||||
|
void sqlite3PagerDontWrite(DbPage*);
|
||||||
|
int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int);
|
||||||
|
int sqlite3PagerPageRefcount(DbPage*);
|
||||||
|
void *sqlite3PagerGetData(DbPage *);
|
||||||
|
void *sqlite3PagerGetExtra(DbPage *);
|
||||||
|
|
||||||
|
/* Functions used to manage pager transactions and savepoints. */
|
||||||
|
int sqlite3PagerPagecount(Pager*, int*);
|
||||||
|
int sqlite3PagerBegin(Pager*, int exFlag);
|
||||||
|
int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int);
|
||||||
|
int sqlite3PagerSync(Pager *pPager);
|
||||||
|
int sqlite3PagerCommitPhaseTwo(Pager*);
|
||||||
|
int sqlite3PagerRollback(Pager*);
|
||||||
int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
|
int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
|
||||||
int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
|
int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
/* Functions used to query pager state and configuration. */
|
||||||
void sqlite3PagerTruncateImage(Pager*,Pgno);
|
u8 sqlite3PagerIsreadonly(Pager*);
|
||||||
Pgno sqlite3PagerImageSize(Pager *);
|
int sqlite3PagerRefcount(Pager*);
|
||||||
#endif
|
const char *sqlite3PagerFilename(Pager*);
|
||||||
|
const sqlite3_vfs *sqlite3PagerVfs(Pager*);
|
||||||
|
sqlite3_file *sqlite3PagerFile(Pager*);
|
||||||
|
const char *sqlite3PagerJournalname(Pager*);
|
||||||
|
int sqlite3PagerNosync(Pager*);
|
||||||
|
void *sqlite3PagerTempSpace(Pager*);
|
||||||
|
int sqlite3PagerIsMemdb(Pager*);
|
||||||
|
|
||||||
|
/* Functions used to truncate the database file. */
|
||||||
|
void sqlite3PagerTruncateImage(Pager*,Pgno);
|
||||||
|
|
||||||
|
/* Used by encryption extensions. */
|
||||||
#ifdef SQLITE_HAS_CODEC
|
#ifdef SQLITE_HAS_CODEC
|
||||||
void sqlite3PagerSetCodec(Pager*,void*(*)(void*,void*,Pgno,int),void*);
|
void sqlite3PagerSetCodec(Pager*,void*(*)(void*,void*,Pgno,int),void*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Functions to support testing and debugging. */
|
||||||
#if !defined(NDEBUG) || defined(SQLITE_TEST)
|
#if !defined(NDEBUG) || defined(SQLITE_TEST)
|
||||||
Pgno sqlite3PagerPagenumber(DbPage*);
|
Pgno sqlite3PagerPagenumber(DbPage*);
|
||||||
int sqlite3PagerIswriteable(DbPage*);
|
int sqlite3PagerIswriteable(DbPage*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SQLITE_TEST
|
#ifdef SQLITE_TEST
|
||||||
int *sqlite3PagerStats(Pager*);
|
int *sqlite3PagerStats(Pager*);
|
||||||
void sqlite3PagerRefdump(Pager*);
|
void sqlite3PagerRefdump(Pager*);
|
||||||
int sqlite3PagerIsMemdb(Pager*);
|
void disable_simulated_io_errors(void);
|
||||||
#endif
|
void enable_simulated_io_errors(void);
|
||||||
|
|
||||||
#ifdef SQLITE_TEST
|
|
||||||
void disable_simulated_io_errors(void);
|
|
||||||
void enable_simulated_io_errors(void);
|
|
||||||
#else
|
#else
|
||||||
# define disable_simulated_io_errors()
|
# define disable_simulated_io_errors()
|
||||||
# define enable_simulated_io_errors()
|
# define enable_simulated_io_errors()
|
||||||
|
|
772
parse.c
772
parse.c
|
@ -95,7 +95,7 @@ struct AttachKey { int type; Token key; };
|
||||||
#define YYCODETYPE unsigned char
|
#define YYCODETYPE unsigned char
|
||||||
#define YYNOCODE 251
|
#define YYNOCODE 251
|
||||||
#define YYACTIONTYPE unsigned short int
|
#define YYACTIONTYPE unsigned short int
|
||||||
#define YYWILDCARD 62
|
#define YYWILDCARD 64
|
||||||
#define sqlite3ParserTOKENTYPE Token
|
#define sqlite3ParserTOKENTYPE Token
|
||||||
typedef union {
|
typedef union {
|
||||||
int yyinit;
|
int yyinit;
|
||||||
|
@ -179,366 +179,366 @@ static const YYMINORTYPE yyzerominor = { 0 };
|
||||||
** yy_default[] Default action for each state.
|
** yy_default[] Default action for each state.
|
||||||
*/
|
*/
|
||||||
static const YYACTIONTYPE yy_action[] = {
|
static const YYACTIONTYPE yy_action[] = {
|
||||||
/* 0 */ 304, 74, 581, 83, 164, 205, 587, 543, 86, 86,
|
/* 0 */ 304, 74, 581, 83, 164, 205, 281, 543, 86, 86,
|
||||||
/* 10 */ 86, 86, 350, 96, 96, 96, 96, 93, 93, 94,
|
/* 10 */ 86, 86, 587, 96, 96, 96, 96, 93, 93, 94,
|
||||||
/* 20 */ 94, 94, 91, 227, 188, 158, 532, 524, 88, 96,
|
/* 20 */ 94, 94, 91, 227, 492, 359, 206, 308, 532, 524,
|
||||||
/* 30 */ 96, 96, 96, 93, 93, 94, 94, 94, 91, 227,
|
/* 30 */ 88, 96, 96, 96, 96, 93, 93, 94, 94, 94,
|
||||||
/* 40 */ 489, 315, 505, 504, 92, 82, 309, 518, 516, 522,
|
/* 40 */ 91, 227, 322, 350, 589, 326, 92, 82, 309, 518,
|
||||||
/* 50 */ 522, 95, 95, 86, 86, 86, 86, 434, 96, 96,
|
/* 50 */ 516, 522, 522, 95, 95, 86, 86, 86, 86, 525,
|
||||||
/* 60 */ 96, 96, 93, 93, 94, 94, 94, 91, 227, 304,
|
/* 60 */ 96, 96, 96, 96, 93, 93, 94, 94, 94, 91,
|
||||||
/* 70 */ 450, 308, 543, 525, 540, 63, 96, 96, 96, 96,
|
/* 70 */ 227, 304, 552, 308, 543, 446, 553, 63, 96, 96,
|
||||||
/* 80 */ 93, 93, 94, 94, 94, 91, 227, 93, 93, 94,
|
/* 80 */ 96, 96, 93, 93, 94, 94, 94, 91, 227, 589,
|
||||||
/* 90 */ 94, 94, 91, 227, 586, 532, 524, 332, 596, 77,
|
/* 90 */ 301, 589, 179, 492, 453, 206, 445, 230, 269, 532,
|
||||||
/* 100 */ 239, 59, 20, 233, 226, 563, 543, 538, 538, 538,
|
/* 100 */ 524, 494, 564, 77, 114, 289, 340, 290, 325, 170,
|
||||||
/* 110 */ 182, 345, 269, 92, 82, 309, 518, 516, 522, 522,
|
/* 110 */ 436, 588, 585, 437, 401, 437, 262, 92, 82, 309,
|
||||||
/* 120 */ 95, 95, 86, 86, 86, 86, 592, 96, 96, 96,
|
/* 120 */ 518, 516, 522, 522, 95, 95, 86, 86, 86, 86,
|
||||||
/* 130 */ 96, 93, 93, 94, 94, 94, 91, 227, 304, 230,
|
/* 130 */ 466, 96, 96, 96, 96, 93, 93, 94, 94, 94,
|
||||||
/* 140 */ 489, 481, 308, 229, 550, 176, 114, 289, 340, 290,
|
/* 140 */ 91, 227, 304, 230, 345, 357, 494, 219, 321, 176,
|
||||||
/* 150 */ 325, 170, 451, 447, 480, 191, 607, 394, 262, 264,
|
/* 150 */ 114, 289, 340, 290, 325, 170, 588, 585, 588, 585,
|
||||||
/* 160 */ 152, 150, 406, 22, 532, 524, 416, 295, 379, 589,
|
/* 160 */ 171, 357, 262, 371, 378, 383, 555, 556, 551, 50,
|
||||||
/* 170 */ 450, 543, 604, 920, 540, 920, 301, 589, 293, 492,
|
/* 170 */ 532, 524, 434, 464, 388, 93, 93, 94, 94, 94,
|
||||||
/* 180 */ 453, 206, 92, 82, 309, 518, 516, 522, 522, 95,
|
/* 180 */ 91, 227, 586, 489, 551, 43, 592, 649, 92, 82,
|
||||||
/* 190 */ 95, 86, 86, 86, 86, 373, 96, 96, 96, 96,
|
/* 190 */ 309, 518, 516, 522, 522, 95, 95, 86, 86, 86,
|
||||||
/* 200 */ 93, 93, 94, 94, 94, 91, 227, 538, 538, 538,
|
/* 200 */ 86, 481, 96, 96, 96, 96, 93, 93, 94, 94,
|
||||||
/* 210 */ 230, 304, 599, 74, 153, 83, 164, 114, 289, 340,
|
/* 210 */ 94, 91, 227, 450, 304, 153, 480, 540, 607, 74,
|
||||||
/* 220 */ 290, 325, 170, 94, 94, 94, 91, 227, 278, 262,
|
/* 220 */ 263, 83, 164, 402, 234, 238, 332, 596, 416, 357,
|
||||||
/* 230 */ 474, 446, 494, 219, 588, 585, 171, 532, 524, 371,
|
/* 230 */ 319, 357, 233, 490, 229, 315, 505, 504, 559, 182,
|
||||||
/* 240 */ 378, 383, 588, 585, 281, 339, 505, 504, 546, 606,
|
/* 240 */ 188, 158, 532, 524, 94, 94, 94, 91, 227, 538,
|
||||||
/* 250 */ 388, 445, 555, 556, 90, 92, 82, 309, 518, 516,
|
/* 250 */ 538, 538, 551, 40, 551, 49, 239, 558, 557, 90,
|
||||||
/* 260 */ 522, 522, 95, 95, 86, 86, 86, 86, 466, 96,
|
/* 260 */ 92, 82, 309, 518, 516, 522, 522, 95, 95, 86,
|
||||||
/* 270 */ 96, 96, 96, 93, 93, 94, 94, 94, 91, 227,
|
/* 270 */ 86, 86, 86, 550, 96, 96, 96, 96, 93, 93,
|
||||||
/* 280 */ 322, 357, 171, 488, 304, 371, 378, 383, 171, 61,
|
/* 280 */ 94, 94, 94, 91, 227, 171, 304, 397, 371, 378,
|
||||||
/* 290 */ 154, 371, 378, 383, 231, 559, 388, 74, 357, 83,
|
/* 290 */ 383, 61, 353, 222, 451, 387, 331, 379, 226, 388,
|
||||||
/* 300 */ 164, 56, 388, 321, 551, 28, 240, 163, 226, 464,
|
/* 300 */ 423, 348, 357, 171, 566, 22, 371, 378, 383, 560,
|
||||||
/* 310 */ 532, 524, 324, 119, 558, 557, 346, 568, 511, 511,
|
/* 310 */ 447, 163, 191, 464, 532, 524, 165, 388, 554, 226,
|
||||||
/* 320 */ 490, 551, 49, 346, 550, 511, 511, 76, 92, 82,
|
/* 320 */ 231, 339, 505, 504, 373, 551, 49, 56, 151, 410,
|
||||||
/* 330 */ 309, 518, 516, 522, 522, 95, 95, 86, 86, 86,
|
/* 330 */ 240, 76, 92, 82, 309, 518, 516, 522, 522, 95,
|
||||||
/* 340 */ 86, 550, 96, 96, 96, 96, 93, 93, 94, 94,
|
/* 340 */ 95, 86, 86, 86, 86, 550, 96, 96, 96, 96,
|
||||||
/* 350 */ 94, 91, 227, 304, 349, 423, 451, 307, 109, 402,
|
/* 350 */ 93, 93, 94, 94, 94, 91, 227, 304, 204, 357,
|
||||||
/* 360 */ 234, 238, 357, 331, 560, 357, 566, 22, 341, 346,
|
/* 360 */ 565, 473, 109, 402, 234, 238, 357, 331, 154, 436,
|
||||||
/* 370 */ 229, 511, 511, 531, 530, 554, 226, 559, 284, 532,
|
/* 370 */ 357, 306, 341, 357, 229, 74, 262, 83, 164, 531,
|
||||||
/* 380 */ 524, 374, 387, 464, 490, 551, 49, 472, 551, 40,
|
/* 380 */ 530, 474, 551, 28, 226, 532, 524, 546, 606, 551,
|
||||||
/* 390 */ 151, 410, 159, 573, 527, 526, 558, 92, 82, 309,
|
/* 390 */ 49, 525, 550, 551, 51, 568, 551, 42, 159, 490,
|
||||||
/* 400 */ 518, 516, 522, 522, 95, 95, 86, 86, 86, 86,
|
/* 400 */ 527, 526, 550, 92, 82, 309, 518, 516, 522, 522,
|
||||||
/* 410 */ 165, 96, 96, 96, 96, 93, 93, 94, 94, 94,
|
/* 410 */ 95, 95, 86, 86, 86, 86, 376, 96, 96, 96,
|
||||||
/* 420 */ 91, 227, 304, 528, 91, 227, 550, 331, 353, 222,
|
/* 420 */ 96, 93, 93, 94, 94, 94, 91, 227, 304, 528,
|
||||||
/* 430 */ 521, 385, 348, 402, 234, 238, 400, 357, 157, 158,
|
/* 430 */ 479, 334, 550, 17, 488, 559, 357, 278, 391, 357,
|
||||||
/* 440 */ 357, 589, 565, 473, 229, 204, 318, 225, 532, 524,
|
/* 440 */ 284, 451, 23, 472, 157, 158, 589, 74, 264, 83,
|
||||||
/* 450 */ 60, 436, 205, 525, 543, 413, 424, 403, 226, 296,
|
/* 450 */ 164, 406, 22, 204, 558, 229, 532, 524, 60, 551,
|
||||||
/* 460 */ 551, 49, 420, 551, 40, 306, 92, 82, 309, 518,
|
/* 460 */ 40, 318, 551, 43, 930, 130, 609, 2, 394, 346,
|
||||||
/* 470 */ 516, 522, 522, 95, 95, 86, 86, 86, 86, 550,
|
/* 470 */ 272, 511, 511, 573, 92, 82, 309, 518, 516, 522,
|
||||||
/* 480 */ 96, 96, 96, 96, 93, 93, 94, 94, 94, 91,
|
/* 480 */ 522, 95, 95, 86, 86, 86, 86, 550, 96, 96,
|
||||||
/* 490 */ 227, 304, 479, 564, 461, 286, 494, 288, 357, 297,
|
/* 490 */ 96, 96, 93, 93, 94, 94, 94, 91, 227, 304,
|
||||||
/* 500 */ 357, 436, 334, 376, 217, 141, 588, 585, 374, 74,
|
/* 500 */ 217, 604, 920, 286, 920, 592, 141, 142, 311, 459,
|
||||||
/* 510 */ 357, 83, 164, 930, 130, 609, 2, 532, 524, 543,
|
/* 510 */ 249, 376, 242, 588, 585, 403, 226, 589, 357, 510,
|
||||||
/* 520 */ 17, 551, 43, 551, 50, 391, 525, 23, 272, 604,
|
/* 520 */ 481, 589, 346, 256, 511, 511, 236, 532, 524, 413,
|
||||||
/* 530 */ 921, 589, 921, 551, 43, 92, 82, 309, 518, 516,
|
/* 530 */ 424, 604, 921, 396, 921, 480, 420, 338, 324, 119,
|
||||||
/* 540 */ 522, 522, 95, 95, 86, 86, 86, 86, 592, 96,
|
/* 540 */ 1, 551, 31, 599, 589, 92, 82, 309, 518, 516,
|
||||||
/* 550 */ 96, 96, 96, 93, 93, 94, 94, 94, 91, 227,
|
/* 550 */ 522, 522, 95, 95, 86, 86, 86, 86, 357, 96,
|
||||||
/* 560 */ 304, 510, 281, 481, 429, 274, 249, 319, 242, 599,
|
/* 560 */ 96, 96, 96, 93, 93, 94, 94, 94, 91, 227,
|
||||||
/* 570 */ 142, 589, 459, 459, 218, 263, 480, 589, 338, 311,
|
/* 570 */ 304, 276, 307, 599, 429, 589, 475, 355, 161, 605,
|
||||||
/* 580 */ 589, 439, 440, 204, 1, 149, 532, 524, 589, 451,
|
/* 580 */ 606, 551, 16, 399, 588, 585, 442, 349, 588, 585,
|
||||||
/* 590 */ 392, 346, 169, 511, 511, 589, 588, 585, 221, 590,
|
/* 590 */ 441, 277, 543, 281, 346, 451, 511, 511, 532, 524,
|
||||||
/* 600 */ 22, 492, 359, 206, 92, 82, 309, 518, 516, 522,
|
/* 600 */ 551, 3, 229, 459, 386, 590, 22, 346, 281, 511,
|
||||||
/* 610 */ 522, 95, 95, 86, 86, 86, 86, 550, 96, 96,
|
/* 610 */ 511, 588, 585, 223, 458, 381, 92, 82, 309, 518,
|
||||||
/* 620 */ 96, 96, 93, 93, 94, 94, 94, 91, 227, 304,
|
/* 620 */ 516, 522, 522, 95, 95, 86, 86, 86, 86, 221,
|
||||||
/* 630 */ 397, 470, 208, 454, 475, 357, 588, 585, 469, 161,
|
/* 630 */ 96, 96, 96, 96, 93, 93, 94, 94, 94, 91,
|
||||||
/* 640 */ 161, 376, 588, 585, 256, 588, 585, 346, 277, 511,
|
/* 640 */ 227, 304, 588, 585, 323, 454, 385, 392, 357, 169,
|
||||||
/* 650 */ 511, 236, 196, 588, 585, 532, 524, 165, 551, 31,
|
/* 650 */ 357, 400, 357, 205, 357, 543, 357, 20, 357, 543,
|
||||||
/* 660 */ 588, 585, 458, 396, 459, 459, 550, 437, 401, 437,
|
/* 660 */ 357, 543, 357, 589, 346, 521, 511, 511, 542, 532,
|
||||||
/* 670 */ 595, 542, 303, 92, 82, 309, 518, 516, 522, 522,
|
/* 670 */ 524, 551, 111, 551, 33, 551, 24, 551, 34, 551,
|
||||||
/* 680 */ 95, 95, 86, 86, 86, 86, 550, 96, 96, 96,
|
/* 680 */ 112, 551, 37, 551, 98, 551, 54, 92, 82, 309,
|
||||||
/* 690 */ 96, 93, 93, 94, 94, 94, 91, 227, 304, 357,
|
/* 690 */ 518, 516, 522, 522, 95, 95, 86, 86, 86, 86,
|
||||||
/* 700 */ 442, 227, 421, 355, 441, 357, 543, 357, 179, 357,
|
/* 700 */ 357, 96, 96, 96, 96, 93, 93, 94, 94, 94,
|
||||||
/* 710 */ 506, 357, 306, 471, 357, 169, 386, 262, 610, 600,
|
/* 710 */ 91, 227, 304, 357, 506, 357, 421, 598, 302, 357,
|
||||||
/* 720 */ 360, 490, 551, 16, 532, 524, 551, 3, 551, 111,
|
/* 720 */ 208, 357, 543, 551, 52, 357, 282, 357, 543, 357,
|
||||||
/* 730 */ 551, 33, 551, 24, 551, 34, 190, 551, 51, 582,
|
/* 730 */ 588, 585, 357, 610, 600, 360, 551, 113, 551, 35,
|
||||||
/* 740 */ 579, 578, 92, 82, 309, 518, 516, 522, 522, 95,
|
/* 740 */ 532, 524, 551, 55, 551, 25, 91, 227, 551, 29,
|
||||||
/* 750 */ 95, 86, 86, 86, 86, 357, 96, 96, 96, 96,
|
/* 750 */ 551, 41, 551, 39, 550, 551, 10, 287, 92, 82,
|
||||||
/* 760 */ 93, 93, 94, 94, 94, 91, 227, 304, 357, 552,
|
/* 760 */ 309, 518, 516, 522, 522, 95, 95, 86, 86, 86,
|
||||||
/* 770 */ 550, 543, 357, 553, 357, 326, 357, 169, 551, 42,
|
/* 770 */ 86, 357, 96, 96, 96, 96, 93, 93, 94, 94,
|
||||||
/* 780 */ 357, 605, 606, 320, 357, 282, 357, 201, 211, 166,
|
/* 780 */ 94, 91, 227, 304, 357, 460, 357, 582, 579, 578,
|
||||||
/* 790 */ 287, 551, 112, 532, 524, 551, 37, 551, 98, 551,
|
/* 790 */ 357, 595, 357, 303, 551, 26, 357, 439, 440, 357,
|
||||||
/* 800 */ 54, 649, 552, 551, 52, 167, 553, 551, 113, 551,
|
/* 800 */ 343, 357, 374, 357, 201, 211, 166, 551, 46, 551,
|
||||||
/* 810 */ 35, 92, 82, 309, 518, 516, 522, 522, 95, 95,
|
/* 810 */ 30, 532, 524, 551, 32, 551, 48, 276, 276, 551,
|
||||||
/* 820 */ 86, 86, 86, 86, 357, 96, 96, 96, 96, 93,
|
/* 820 */ 47, 276, 551, 103, 551, 108, 551, 97, 426, 92,
|
||||||
/* 830 */ 93, 94, 94, 94, 91, 227, 304, 276, 399, 550,
|
/* 830 */ 82, 309, 518, 516, 522, 522, 95, 95, 86, 86,
|
||||||
/* 840 */ 155, 357, 509, 357, 21, 357, 343, 551, 55, 357,
|
/* 840 */ 86, 86, 357, 96, 96, 96, 96, 93, 93, 94,
|
||||||
/* 850 */ 598, 302, 412, 357, 601, 2, 426, 229, 494, 219,
|
/* 850 */ 94, 94, 91, 227, 304, 357, 471, 357, 169, 512,
|
||||||
/* 860 */ 600, 360, 532, 524, 551, 25, 551, 29, 551, 41,
|
/* 860 */ 517, 357, 459, 362, 357, 551, 102, 357, 225, 509,
|
||||||
/* 870 */ 525, 381, 551, 39, 550, 281, 551, 10, 276, 223,
|
/* 870 */ 357, 21, 357, 356, 357, 490, 601, 2, 551, 100,
|
||||||
/* 880 */ 92, 81, 309, 518, 516, 522, 522, 95, 95, 86,
|
/* 880 */ 551, 99, 532, 524, 551, 38, 374, 551, 45, 18,
|
||||||
/* 890 */ 86, 86, 86, 357, 96, 96, 96, 96, 93, 93,
|
/* 890 */ 551, 110, 296, 551, 44, 551, 36, 551, 27, 196,
|
||||||
/* 900 */ 94, 94, 94, 91, 227, 304, 357, 281, 281, 228,
|
/* 900 */ 92, 81, 309, 518, 516, 522, 522, 95, 95, 86,
|
||||||
/* 910 */ 357, 323, 357, 285, 357, 169, 551, 26, 357, 487,
|
/* 910 */ 86, 86, 86, 404, 96, 96, 96, 96, 93, 93,
|
||||||
/* 920 */ 512, 191, 495, 357, 70, 357, 409, 407, 460, 551,
|
/* 920 */ 94, 94, 94, 91, 227, 304, 513, 357, 190, 167,
|
||||||
/* 930 */ 46, 532, 524, 551, 30, 551, 32, 551, 48, 18,
|
/* 930 */ 155, 161, 288, 550, 297, 281, 461, 320, 494, 219,
|
||||||
/* 940 */ 276, 551, 47, 314, 310, 602, 551, 103, 551, 108,
|
/* 940 */ 8, 285, 276, 169, 600, 360, 409, 407, 498, 498,
|
||||||
/* 950 */ 82, 309, 518, 516, 522, 522, 95, 95, 86, 86,
|
/* 950 */ 551, 53, 218, 532, 524, 169, 459, 276, 525, 525,
|
||||||
/* 960 */ 86, 86, 357, 96, 96, 96, 96, 93, 93, 94,
|
/* 960 */ 266, 276, 550, 550, 550, 368, 281, 276, 487, 602,
|
||||||
/* 970 */ 94, 94, 91, 227, 304, 513, 276, 276, 19, 357,
|
/* 970 */ 191, 314, 82, 309, 518, 516, 522, 522, 95, 95,
|
||||||
/* 980 */ 146, 357, 517, 357, 603, 551, 97, 357, 8, 455,
|
/* 980 */ 86, 86, 86, 86, 214, 96, 96, 96, 96, 93,
|
||||||
/* 990 */ 356, 169, 357, 498, 498, 199, 545, 62, 70, 80,
|
/* 990 */ 93, 94, 94, 94, 91, 227, 304, 274, 228, 523,
|
||||||
/* 1000 */ 532, 524, 551, 102, 551, 100, 551, 99, 266, 452,
|
/* 1000 */ 276, 336, 310, 520, 456, 495, 470, 70, 552, 246,
|
||||||
/* 1010 */ 551, 38, 368, 414, 336, 551, 45, 276, 362, 214,
|
/* 1010 */ 603, 19, 553, 146, 165, 469, 455, 199, 169, 295,
|
||||||
/* 1020 */ 309, 518, 516, 522, 522, 95, 95, 86, 86, 86,
|
/* 1020 */ 545, 62, 70, 80, 532, 524, 227, 452, 237, 149,
|
||||||
/* 1030 */ 86, 357, 96, 96, 96, 96, 93, 93, 94, 94,
|
/* 1030 */ 293, 369, 412, 414, 449, 572, 351, 539, 570, 294,
|
||||||
/* 1040 */ 94, 91, 227, 71, 352, 237, 4, 357, 276, 369,
|
/* 1040 */ 260, 370, 271, 853, 309, 518, 516, 522, 522, 95,
|
||||||
/* 1050 */ 316, 456, 276, 357, 551, 110, 357, 276, 344, 523,
|
/* 1050 */ 95, 86, 86, 86, 86, 462, 96, 96, 96, 96,
|
||||||
/* 1060 */ 449, 572, 539, 357, 570, 294, 71, 352, 404, 4,
|
/* 1060 */ 93, 93, 94, 94, 94, 91, 227, 71, 352, 306,
|
||||||
/* 1070 */ 551, 44, 351, 316, 260, 330, 551, 36, 370, 551,
|
/* 1070 */ 4, 162, 435, 247, 316, 583, 438, 496, 478, 71,
|
||||||
/* 1080 */ 27, 344, 162, 435, 247, 489, 551, 53, 496, 478,
|
/* 1080 */ 352, 279, 4, 344, 292, 243, 316, 375, 395, 465,
|
||||||
/* 1090 */ 520, 853, 462, 279, 246, 78, 583, 243, 330, 271,
|
/* 1090 */ 258, 501, 337, 536, 533, 344, 499, 541, 493, 147,
|
||||||
/* 1100 */ 375, 292, 395, 438, 499, 84, 73, 476, 489, 465,
|
/* 1100 */ 267, 330, 298, 549, 497, 483, 259, 424, 569, 116,
|
||||||
/* 1110 */ 533, 501, 258, 541, 72, 354, 358, 337, 493, 540,
|
/* 1110 */ 571, 489, 203, 330, 57, 195, 580, 78, 78, 367,
|
||||||
/* 1120 */ 424, 298, 483, 497, 536, 147, 259, 549, 84, 73,
|
/* 1120 */ 363, 115, 463, 489, 425, 500, 229, 187, 432, 508,
|
||||||
/* 1130 */ 116, 569, 203, 571, 57, 195, 580, 72, 354, 358,
|
/* 1130 */ 241, 84, 73, 476, 576, 128, 5, 364, 125, 575,
|
||||||
/* 1140 */ 78, 367, 540, 500, 267, 363, 463, 115, 229, 425,
|
/* 1140 */ 72, 354, 358, 84, 73, 540, 390, 123, 327, 329,
|
||||||
/* 1150 */ 432, 508, 538, 538, 538, 535, 534, 12, 172, 5,
|
/* 1150 */ 574, 591, 72, 354, 358, 193, 126, 540, 448, 107,
|
||||||
/* 1160 */ 229, 187, 241, 245, 248, 251, 183, 273, 576, 104,
|
/* 1160 */ 172, 393, 200, 342, 268, 245, 248, 251, 183, 273,
|
||||||
/* 1170 */ 128, 575, 364, 123, 390, 538, 538, 538, 535, 534,
|
/* 1170 */ 529, 104, 143, 257, 313, 229, 58, 538, 538, 538,
|
||||||
/* 1180 */ 12, 125, 168, 327, 235, 448, 329, 71, 352, 574,
|
/* 1180 */ 535, 534, 12, 59, 168, 312, 235, 563, 561, 538,
|
||||||
/* 1190 */ 4, 261, 193, 591, 316, 126, 393, 200, 342, 143,
|
/* 1190 */ 538, 538, 535, 534, 12, 261, 87, 7, 71, 352,
|
||||||
/* 1200 */ 313, 268, 344, 185, 529, 464, 257, 312, 107, 175,
|
/* 1200 */ 213, 4, 67, 333, 594, 316, 69, 185, 250, 464,
|
||||||
/* 1210 */ 561, 87, 202, 213, 58, 7, 333, 67, 594, 330,
|
/* 1210 */ 79, 431, 244, 175, 344, 270, 202, 366, 482, 135,
|
||||||
/* 1220 */ 69, 431, 250, 79, 482, 244, 270, 366, 265, 489,
|
/* 1220 */ 265, 174, 275, 122, 489, 427, 548, 428, 133, 577,
|
||||||
/* 1230 */ 135, 174, 275, 548, 428, 577, 427, 122, 133, 299,
|
/* 1230 */ 299, 215, 330, 347, 467, 181, 300, 415, 224, 216,
|
||||||
/* 1240 */ 224, 215, 347, 467, 181, 415, 433, 216, 194, 84,
|
/* 1240 */ 433, 417, 489, 194, 152, 150, 412, 408, 398, 411,
|
||||||
/* 1250 */ 73, 300, 412, 105, 398, 384, 254, 238, 72, 354,
|
/* 1250 */ 207, 291, 418, 405, 450, 173, 105, 422, 540, 384,
|
||||||
/* 1260 */ 358, 305, 417, 540, 411, 408, 229, 418, 207, 291,
|
/* 1260 */ 254, 238, 84, 73, 584, 305, 75, 101, 232, 317,
|
||||||
/* 1270 */ 405, 173, 101, 422, 584, 75, 280, 544, 232, 317,
|
/* 1270 */ 229, 72, 354, 358, 210, 118, 540, 280, 129, 132,
|
||||||
/* 1280 */ 210, 132, 118, 129, 335, 593, 485, 184, 253, 380,
|
/* 1280 */ 335, 593, 544, 485, 184, 253, 562, 209, 136, 380,
|
||||||
/* 1290 */ 562, 377, 136, 209, 160, 145, 538, 538, 538, 535,
|
/* 1290 */ 538, 538, 538, 160, 377, 145, 547, 650, 468, 127,
|
||||||
/* 1300 */ 534, 12, 547, 650, 468, 127, 13, 382, 15, 514,
|
/* 1300 */ 13, 382, 15, 514, 502, 389, 144, 444, 538, 538,
|
||||||
/* 1310 */ 502, 389, 144, 444, 443, 486, 191, 255, 66, 430,
|
/* 1310 */ 538, 535, 534, 12, 191, 255, 486, 66, 443, 430,
|
||||||
/* 1320 */ 131, 121, 137, 106, 519, 65, 608, 89, 192, 85,
|
/* 1320 */ 131, 121, 137, 106, 519, 65, 89, 192, 608, 252,
|
||||||
/* 1330 */ 283, 419, 134, 252, 457, 156, 140, 64, 148, 372,
|
/* 1330 */ 283, 419, 134, 597, 457, 85, 372, 156, 140, 120,
|
||||||
/* 1340 */ 597, 120, 567, 6, 537, 212, 186, 503, 189, 177,
|
/* 1340 */ 148, 503, 64, 567, 212, 6, 186, 537, 189, 177,
|
||||||
/* 1350 */ 328, 491, 651, 507, 365, 477, 197, 9, 14, 293,
|
/* 1350 */ 365, 328, 651, 491, 507, 9, 197, 477, 14, 293,
|
||||||
/* 1360 */ 484, 178, 68, 138, 220, 180, 139, 515, 117, 198,
|
/* 1360 */ 484, 68, 220, 138, 117, 178, 180, 139, 11, 198,
|
||||||
/* 1370 */ 11, 124, 931, 931, 931, 931, 931, 931, 931, 931,
|
/* 1370 */ 515, 124, 931, 931, 931, 931, 931, 931, 931, 931,
|
||||||
/* 1380 */ 361,
|
/* 1380 */ 931, 361,
|
||||||
};
|
};
|
||||||
static const YYCODETYPE yy_lookahead[] = {
|
static const YYCODETYPE yy_lookahead[] = {
|
||||||
/* 0 */ 19, 221, 222, 223, 224, 24, 150, 26, 72, 73,
|
/* 0 */ 19, 221, 222, 223, 224, 24, 150, 26, 74, 75,
|
||||||
/* 10 */ 74, 75, 19, 77, 78, 79, 80, 81, 82, 83,
|
/* 10 */ 76, 77, 150, 79, 80, 81, 82, 83, 84, 85,
|
||||||
/* 20 */ 84, 85, 86, 87, 205, 206, 45, 46, 76, 77,
|
/* 20 */ 86, 87, 88, 89, 165, 166, 167, 19, 47, 48,
|
||||||
/* 30 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
|
/* 30 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
|
||||||
/* 40 */ 61, 168, 169, 170, 63, 64, 65, 66, 67, 68,
|
/* 40 */ 88, 89, 186, 19, 26, 85, 65, 66, 67, 68,
|
||||||
/* 50 */ 69, 70, 71, 72, 73, 74, 75, 150, 77, 78,
|
/* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 165,
|
||||||
/* 60 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 19,
|
/* 60 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
|
||||||
/* 70 */ 91, 19, 91, 165, 95, 25, 77, 78, 79, 80,
|
/* 70 */ 89, 19, 112, 19, 93, 34, 116, 25, 79, 80,
|
||||||
/* 80 */ 81, 82, 83, 84, 85, 86, 87, 81, 82, 83,
|
/* 80 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 26,
|
||||||
/* 90 */ 84, 85, 86, 87, 150, 45, 46, 146, 147, 49,
|
/* 90 */ 162, 26, 22, 165, 166, 167, 55, 89, 204, 47,
|
||||||
/* 100 */ 150, 22, 22, 152, 231, 26, 26, 128, 129, 130,
|
/* 100 */ 48, 83, 172, 51, 96, 97, 98, 99, 100, 101,
|
||||||
/* 110 */ 159, 118, 204, 63, 64, 65, 66, 67, 68, 69,
|
/* 110 */ 180, 93, 94, 104, 105, 106, 108, 65, 66, 67,
|
||||||
/* 120 */ 70, 71, 72, 73, 74, 75, 12, 77, 78, 79,
|
/* 120 */ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
|
||||||
/* 130 */ 80, 81, 82, 83, 84, 85, 86, 87, 19, 87,
|
/* 130 */ 11, 79, 80, 81, 82, 83, 84, 85, 86, 87,
|
||||||
/* 140 */ 61, 27, 19, 113, 193, 93, 94, 95, 96, 97,
|
/* 140 */ 88, 89, 19, 89, 120, 150, 83, 84, 107, 95,
|
||||||
/* 150 */ 98, 99, 150, 23, 40, 25, 42, 127, 106, 157,
|
/* 150 */ 96, 97, 98, 99, 100, 101, 93, 94, 93, 94,
|
||||||
/* 160 */ 81, 82, 160, 161, 45, 46, 52, 95, 217, 26,
|
/* 160 */ 95, 150, 108, 98, 99, 100, 103, 104, 173, 174,
|
||||||
/* 170 */ 91, 91, 22, 23, 95, 25, 162, 26, 106, 165,
|
/* 170 */ 47, 48, 150, 54, 109, 83, 84, 85, 86, 87,
|
||||||
/* 180 */ 166, 167, 63, 64, 65, 66, 67, 68, 69, 70,
|
/* 180 */ 88, 89, 150, 63, 173, 174, 12, 117, 65, 66,
|
||||||
/* 190 */ 71, 72, 73, 74, 75, 244, 77, 78, 79, 80,
|
/* 190 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
|
||||||
/* 200 */ 81, 82, 83, 84, 85, 86, 87, 128, 129, 130,
|
/* 200 */ 77, 27, 79, 80, 81, 82, 83, 84, 85, 86,
|
||||||
/* 210 */ 87, 19, 62, 221, 25, 223, 224, 94, 95, 96,
|
/* 210 */ 87, 88, 89, 93, 19, 25, 42, 97, 44, 221,
|
||||||
/* 220 */ 97, 98, 99, 83, 84, 85, 86, 87, 194, 106,
|
/* 220 */ 225, 223, 224, 104, 105, 106, 146, 147, 54, 150,
|
||||||
/* 230 */ 23, 33, 81, 82, 91, 92, 93, 45, 46, 96,
|
/* 230 */ 219, 150, 152, 150, 115, 168, 169, 170, 150, 159,
|
||||||
/* 240 */ 97, 98, 91, 92, 150, 168, 169, 170, 189, 190,
|
/* 240 */ 205, 206, 47, 48, 85, 86, 87, 88, 89, 129,
|
||||||
/* 250 */ 107, 53, 101, 102, 135, 63, 64, 65, 66, 67,
|
/* 250 */ 130, 131, 173, 174, 173, 174, 150, 169, 170, 136,
|
||||||
/* 260 */ 68, 69, 70, 71, 72, 73, 74, 75, 11, 77,
|
/* 260 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
|
||||||
/* 270 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
|
/* 270 */ 75, 76, 77, 193, 79, 80, 81, 82, 83, 84,
|
||||||
/* 280 */ 186, 150, 93, 23, 19, 96, 97, 98, 93, 24,
|
/* 280 */ 85, 86, 87, 88, 89, 95, 19, 19, 98, 99,
|
||||||
/* 290 */ 159, 96, 97, 98, 196, 150, 107, 221, 150, 223,
|
/* 290 */ 100, 24, 213, 214, 150, 212, 215, 217, 231, 109,
|
||||||
/* 300 */ 224, 203, 107, 105, 173, 174, 150, 159, 231, 52,
|
/* 300 */ 164, 220, 150, 95, 160, 161, 98, 99, 100, 173,
|
||||||
/* 310 */ 45, 46, 245, 246, 169, 170, 109, 241, 111, 112,
|
/* 310 */ 23, 159, 25, 54, 47, 48, 48, 109, 230, 231,
|
||||||
/* 320 */ 150, 173, 174, 109, 193, 111, 112, 135, 63, 64,
|
/* 320 */ 196, 168, 169, 170, 244, 173, 174, 203, 184, 185,
|
||||||
/* 330 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
|
/* 330 */ 150, 136, 65, 66, 67, 68, 69, 70, 71, 72,
|
||||||
/* 340 */ 75, 193, 77, 78, 79, 80, 81, 82, 83, 84,
|
/* 340 */ 73, 74, 75, 76, 77, 193, 79, 80, 81, 82,
|
||||||
/* 350 */ 85, 86, 87, 19, 19, 164, 150, 154, 24, 102,
|
/* 350 */ 83, 84, 85, 86, 87, 88, 89, 19, 159, 150,
|
||||||
/* 360 */ 103, 104, 150, 215, 173, 150, 160, 161, 220, 109,
|
/* 360 */ 171, 172, 24, 104, 105, 106, 150, 215, 159, 180,
|
||||||
/* 370 */ 113, 111, 112, 45, 46, 230, 231, 150, 150, 45,
|
/* 370 */ 150, 103, 220, 150, 115, 221, 108, 223, 224, 47,
|
||||||
/* 380 */ 46, 150, 212, 52, 150, 173, 174, 182, 173, 174,
|
/* 380 */ 48, 23, 173, 174, 231, 47, 48, 189, 190, 173,
|
||||||
/* 390 */ 184, 185, 159, 150, 66, 67, 169, 63, 64, 65,
|
/* 390 */ 174, 165, 193, 173, 174, 241, 173, 174, 159, 150,
|
||||||
/* 400 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
|
/* 400 */ 68, 69, 193, 65, 66, 67, 68, 69, 70, 71,
|
||||||
/* 410 */ 46, 77, 78, 79, 80, 81, 82, 83, 84, 85,
|
/* 410 */ 72, 73, 74, 75, 76, 77, 217, 79, 80, 81,
|
||||||
/* 420 */ 86, 87, 19, 95, 86, 87, 193, 215, 213, 214,
|
/* 420 */ 82, 83, 84, 85, 86, 87, 88, 89, 19, 97,
|
||||||
/* 430 */ 95, 228, 220, 102, 103, 104, 233, 150, 205, 206,
|
/* 430 */ 204, 215, 193, 234, 23, 150, 150, 194, 239, 150,
|
||||||
/* 440 */ 150, 26, 171, 172, 113, 159, 212, 216, 45, 46,
|
/* 440 */ 150, 150, 22, 182, 205, 206, 26, 221, 157, 223,
|
||||||
/* 450 */ 47, 180, 24, 165, 26, 180, 181, 230, 231, 17,
|
/* 450 */ 224, 160, 161, 159, 169, 115, 47, 48, 49, 173,
|
||||||
/* 460 */ 173, 174, 187, 173, 174, 101, 63, 64, 65, 66,
|
/* 460 */ 174, 212, 173, 174, 142, 143, 144, 145, 128, 111,
|
||||||
/* 470 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 193,
|
/* 470 */ 17, 113, 114, 150, 65, 66, 67, 68, 69, 70,
|
||||||
/* 480 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
|
/* 480 */ 71, 72, 73, 74, 75, 76, 77, 193, 79, 80,
|
||||||
/* 490 */ 87, 19, 204, 172, 25, 23, 81, 55, 150, 57,
|
/* 490 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 19,
|
||||||
/* 500 */ 150, 180, 215, 217, 214, 23, 91, 92, 150, 221,
|
/* 500 */ 214, 22, 23, 23, 25, 12, 23, 23, 219, 25,
|
||||||
/* 510 */ 150, 223, 224, 142, 143, 144, 145, 45, 46, 91,
|
/* 510 */ 57, 217, 59, 93, 94, 230, 231, 26, 150, 23,
|
||||||
/* 520 */ 234, 173, 174, 173, 174, 239, 165, 22, 17, 22,
|
/* 520 */ 27, 26, 111, 150, 113, 114, 150, 47, 48, 180,
|
||||||
/* 530 */ 23, 26, 25, 173, 174, 63, 64, 65, 66, 67,
|
/* 530 */ 181, 22, 23, 239, 25, 42, 187, 44, 245, 246,
|
||||||
/* 540 */ 68, 69, 70, 71, 72, 73, 74, 75, 12, 77,
|
/* 540 */ 22, 173, 174, 64, 26, 65, 66, 67, 68, 69,
|
||||||
/* 550 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
|
/* 550 */ 70, 71, 72, 73, 74, 75, 76, 77, 150, 79,
|
||||||
/* 560 */ 19, 23, 150, 27, 23, 204, 55, 219, 57, 62,
|
/* 560 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
|
||||||
/* 570 */ 23, 26, 25, 25, 216, 225, 40, 26, 42, 219,
|
/* 570 */ 19, 150, 154, 64, 23, 26, 85, 150, 94, 189,
|
||||||
/* 580 */ 26, 94, 95, 159, 22, 116, 45, 46, 26, 150,
|
/* 580 */ 190, 173, 174, 96, 93, 94, 28, 19, 93, 94,
|
||||||
/* 590 */ 23, 109, 25, 111, 112, 26, 91, 92, 186, 160,
|
/* 590 */ 32, 138, 26, 150, 111, 150, 113, 114, 47, 48,
|
||||||
/* 600 */ 161, 165, 166, 167, 63, 64, 65, 66, 67, 68,
|
/* 600 */ 173, 174, 115, 119, 46, 160, 161, 111, 150, 113,
|
||||||
/* 610 */ 69, 70, 71, 72, 73, 74, 75, 193, 77, 78,
|
/* 610 */ 114, 93, 94, 192, 119, 128, 65, 66, 67, 68,
|
||||||
/* 620 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 19,
|
/* 620 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 186,
|
||||||
/* 630 */ 19, 30, 159, 23, 83, 150, 91, 92, 37, 92,
|
/* 630 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
|
||||||
/* 640 */ 92, 217, 91, 92, 150, 91, 92, 109, 137, 111,
|
/* 640 */ 89, 19, 93, 94, 186, 23, 228, 23, 150, 25,
|
||||||
/* 650 */ 112, 150, 159, 91, 92, 45, 46, 46, 173, 174,
|
/* 650 */ 150, 233, 150, 24, 150, 26, 150, 22, 150, 93,
|
||||||
/* 660 */ 91, 92, 117, 239, 117, 117, 193, 102, 103, 104,
|
/* 660 */ 150, 26, 150, 26, 111, 97, 113, 114, 119, 47,
|
||||||
/* 670 */ 23, 117, 25, 63, 64, 65, 66, 67, 68, 69,
|
/* 670 */ 48, 173, 174, 173, 174, 173, 174, 173, 174, 173,
|
||||||
/* 680 */ 70, 71, 72, 73, 74, 75, 193, 77, 78, 79,
|
/* 680 */ 174, 173, 174, 173, 174, 173, 174, 65, 66, 67,
|
||||||
/* 690 */ 80, 81, 82, 83, 84, 85, 86, 87, 19, 150,
|
/* 690 */ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
|
||||||
/* 700 */ 28, 87, 23, 150, 32, 150, 26, 150, 22, 150,
|
/* 700 */ 150, 79, 80, 81, 82, 83, 84, 85, 86, 87,
|
||||||
/* 710 */ 150, 150, 101, 23, 150, 25, 44, 106, 0, 1,
|
/* 710 */ 88, 89, 19, 150, 150, 150, 23, 247, 248, 150,
|
||||||
/* 720 */ 2, 150, 173, 174, 45, 46, 173, 174, 173, 174,
|
/* 720 */ 159, 150, 93, 173, 174, 150, 150, 150, 93, 150,
|
||||||
/* 730 */ 173, 174, 173, 174, 173, 174, 159, 173, 174, 7,
|
/* 730 */ 93, 94, 150, 0, 1, 2, 173, 174, 173, 174,
|
||||||
/* 740 */ 8, 9, 63, 64, 65, 66, 67, 68, 69, 70,
|
/* 740 */ 47, 48, 173, 174, 173, 174, 88, 89, 173, 174,
|
||||||
/* 750 */ 71, 72, 73, 74, 75, 150, 77, 78, 79, 80,
|
/* 750 */ 173, 174, 173, 174, 193, 173, 174, 150, 65, 66,
|
||||||
/* 760 */ 81, 82, 83, 84, 85, 86, 87, 19, 150, 110,
|
/* 760 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
|
||||||
/* 770 */ 193, 91, 150, 114, 150, 83, 150, 25, 173, 174,
|
/* 770 */ 77, 150, 79, 80, 81, 82, 83, 84, 85, 86,
|
||||||
/* 780 */ 150, 189, 190, 212, 150, 150, 150, 102, 103, 104,
|
/* 780 */ 87, 88, 89, 19, 150, 207, 150, 7, 8, 9,
|
||||||
/* 790 */ 150, 173, 174, 45, 46, 173, 174, 173, 174, 173,
|
/* 790 */ 150, 23, 150, 25, 173, 174, 150, 96, 97, 150,
|
||||||
/* 800 */ 174, 115, 110, 173, 174, 159, 114, 173, 174, 173,
|
/* 800 */ 150, 150, 150, 150, 104, 105, 106, 173, 174, 173,
|
||||||
/* 810 */ 174, 63, 64, 65, 66, 67, 68, 69, 70, 71,
|
/* 810 */ 174, 47, 48, 173, 174, 173, 174, 150, 150, 173,
|
||||||
/* 820 */ 72, 73, 74, 75, 150, 77, 78, 79, 80, 81,
|
/* 820 */ 174, 150, 173, 174, 173, 174, 173, 174, 150, 65,
|
||||||
/* 830 */ 82, 83, 84, 85, 86, 87, 19, 150, 94, 193,
|
/* 830 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
|
||||||
/* 840 */ 159, 150, 23, 150, 25, 150, 150, 173, 174, 150,
|
/* 840 */ 76, 77, 150, 79, 80, 81, 82, 83, 84, 85,
|
||||||
/* 850 */ 247, 248, 100, 150, 144, 145, 150, 113, 81, 82,
|
/* 850 */ 86, 87, 88, 89, 19, 150, 23, 150, 25, 192,
|
||||||
/* 860 */ 1, 2, 45, 46, 173, 174, 173, 174, 173, 174,
|
/* 860 */ 192, 150, 25, 192, 150, 173, 174, 150, 216, 23,
|
||||||
/* 870 */ 165, 127, 173, 174, 193, 150, 173, 174, 150, 192,
|
/* 870 */ 150, 25, 150, 150, 150, 150, 144, 145, 173, 174,
|
||||||
/* 880 */ 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
|
/* 880 */ 173, 174, 47, 48, 173, 174, 150, 173, 174, 22,
|
||||||
/* 890 */ 73, 74, 75, 150, 77, 78, 79, 80, 81, 82,
|
/* 890 */ 173, 174, 17, 173, 174, 173, 174, 173, 174, 159,
|
||||||
/* 900 */ 83, 84, 85, 86, 87, 19, 150, 150, 150, 204,
|
/* 900 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
|
||||||
/* 910 */ 150, 186, 150, 23, 150, 25, 173, 174, 150, 23,
|
/* 910 */ 75, 76, 77, 242, 79, 80, 81, 82, 83, 84,
|
||||||
/* 920 */ 192, 25, 23, 150, 25, 150, 7, 8, 207, 173,
|
/* 920 */ 85, 86, 87, 88, 89, 19, 21, 150, 159, 159,
|
||||||
/* 930 */ 174, 45, 46, 173, 174, 173, 174, 173, 174, 22,
|
/* 930 */ 159, 94, 57, 193, 59, 150, 25, 212, 83, 84,
|
||||||
/* 940 */ 150, 173, 174, 186, 186, 23, 173, 174, 173, 174,
|
/* 940 */ 73, 23, 150, 25, 1, 2, 7, 8, 129, 130,
|
||||||
/* 950 */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
|
/* 950 */ 173, 174, 216, 47, 48, 25, 119, 150, 165, 165,
|
||||||
/* 960 */ 74, 75, 150, 77, 78, 79, 80, 81, 82, 83,
|
/* 960 */ 148, 150, 193, 193, 193, 60, 150, 150, 23, 23,
|
||||||
/* 970 */ 84, 85, 86, 87, 19, 21, 150, 150, 22, 150,
|
/* 970 */ 25, 186, 66, 67, 68, 69, 70, 71, 72, 73,
|
||||||
/* 980 */ 24, 150, 192, 150, 62, 173, 174, 150, 71, 23,
|
/* 980 */ 74, 75, 76, 77, 192, 79, 80, 81, 82, 83,
|
||||||
/* 990 */ 150, 25, 150, 128, 129, 25, 23, 134, 25, 136,
|
/* 990 */ 84, 85, 86, 87, 88, 89, 19, 204, 204, 192,
|
||||||
/* 1000 */ 45, 46, 173, 174, 173, 174, 173, 174, 148, 173,
|
/* 1000 */ 150, 150, 186, 192, 99, 23, 30, 25, 112, 192,
|
||||||
/* 1010 */ 173, 174, 58, 185, 150, 173, 174, 150, 192, 192,
|
/* 1010 */ 64, 22, 116, 24, 48, 39, 23, 25, 25, 97,
|
||||||
/* 1020 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
|
/* 1020 */ 23, 135, 25, 137, 47, 48, 89, 173, 150, 118,
|
||||||
/* 1030 */ 75, 150, 77, 78, 79, 80, 81, 82, 83, 84,
|
/* 1030 */ 108, 236, 102, 185, 173, 150, 227, 150, 150, 150,
|
||||||
/* 1040 */ 85, 86, 87, 19, 20, 150, 22, 150, 150, 236,
|
/* 1040 */ 150, 150, 192, 138, 67, 68, 69, 70, 71, 72,
|
||||||
/* 1050 */ 26, 97, 150, 150, 173, 174, 150, 150, 34, 192,
|
/* 1050 */ 73, 74, 75, 76, 77, 176, 79, 80, 81, 82,
|
||||||
/* 1060 */ 173, 150, 150, 150, 150, 150, 19, 20, 242, 22,
|
/* 1060 */ 83, 84, 85, 86, 87, 88, 89, 19, 20, 103,
|
||||||
/* 1070 */ 173, 174, 227, 26, 150, 51, 173, 174, 150, 173,
|
/* 1070 */ 22, 150, 165, 150, 26, 176, 182, 232, 198, 19,
|
||||||
/* 1080 */ 174, 34, 150, 165, 150, 61, 173, 174, 232, 198,
|
/* 1080 */ 20, 150, 22, 35, 176, 150, 26, 177, 150, 176,
|
||||||
/* 1090 */ 192, 137, 176, 150, 192, 125, 176, 150, 51, 192,
|
/* 1090 */ 208, 176, 190, 198, 150, 35, 232, 165, 165, 195,
|
||||||
/* 1100 */ 177, 176, 150, 182, 232, 81, 82, 83, 61, 176,
|
/* 1100 */ 208, 53, 150, 150, 185, 165, 197, 181, 153, 65,
|
||||||
/* 1110 */ 150, 176, 208, 165, 90, 91, 92, 190, 165, 95,
|
/* 1110 */ 38, 63, 188, 53, 240, 117, 156, 126, 126, 156,
|
||||||
/* 1120 */ 181, 150, 165, 185, 198, 195, 197, 150, 81, 82,
|
/* 1120 */ 150, 150, 188, 63, 182, 198, 115, 6, 150, 150,
|
||||||
/* 1130 */ 63, 153, 188, 36, 240, 115, 156, 90, 91, 92,
|
/* 1130 */ 201, 83, 84, 85, 149, 22, 195, 156, 218, 149,
|
||||||
/* 1140 */ 125, 156, 95, 198, 208, 150, 188, 150, 113, 182,
|
/* 1140 */ 92, 93, 94, 83, 84, 97, 18, 191, 121, 149,
|
||||||
/* 1150 */ 150, 150, 128, 129, 130, 131, 132, 133, 5, 195,
|
/* 1150 */ 13, 36, 92, 93, 94, 151, 188, 97, 210, 243,
|
||||||
/* 1160 */ 113, 6, 201, 10, 11, 12, 13, 14, 149, 16,
|
/* 1160 */ 5, 18, 155, 123, 199, 10, 11, 12, 13, 14,
|
||||||
/* 1170 */ 22, 149, 156, 191, 18, 128, 129, 130, 131, 132,
|
/* 1170 */ 198, 16, 218, 198, 156, 115, 240, 129, 130, 131,
|
||||||
/* 1180 */ 133, 218, 29, 120, 31, 210, 149, 19, 20, 13,
|
/* 1180 */ 132, 133, 134, 22, 29, 45, 31, 26, 183, 129,
|
||||||
/* 1190 */ 22, 38, 151, 140, 26, 188, 18, 155, 122, 218,
|
/* 1190 */ 130, 131, 132, 133, 134, 40, 135, 25, 19, 20,
|
||||||
/* 1200 */ 156, 199, 34, 50, 198, 52, 198, 43, 243, 56,
|
/* 1200 */ 226, 22, 135, 158, 149, 26, 103, 52, 209, 54,
|
||||||
/* 1210 */ 183, 134, 59, 226, 240, 25, 158, 134, 149, 51,
|
/* 1210 */ 124, 238, 200, 58, 35, 209, 61, 43, 210, 191,
|
||||||
/* 1220 */ 101, 238, 209, 123, 210, 200, 209, 41, 237, 61,
|
/* 1220 */ 237, 151, 209, 191, 63, 210, 193, 156, 22, 156,
|
||||||
/* 1230 */ 191, 151, 209, 193, 156, 156, 210, 191, 22, 178,
|
/* 1230 */ 178, 89, 53, 103, 175, 156, 178, 175, 229, 229,
|
||||||
/* 1240 */ 229, 87, 101, 175, 156, 175, 175, 229, 155, 81,
|
/* 1240 */ 175, 175, 63, 155, 83, 84, 102, 183, 156, 175,
|
||||||
/* 1250 */ 82, 178, 100, 179, 156, 102, 103, 104, 90, 91,
|
/* 1250 */ 155, 175, 177, 175, 93, 155, 179, 156, 97, 104,
|
||||||
/* 1260 */ 92, 108, 175, 95, 175, 183, 113, 177, 155, 175,
|
/* 1260 */ 105, 106, 83, 84, 156, 110, 125, 163, 179, 249,
|
||||||
/* 1270 */ 175, 155, 163, 156, 156, 124, 150, 202, 179, 249,
|
/* 1270 */ 115, 92, 93, 94, 235, 246, 97, 150, 191, 156,
|
||||||
/* 1280 */ 235, 156, 246, 191, 121, 150, 23, 115, 139, 208,
|
/* 1280 */ 122, 150, 202, 23, 117, 140, 23, 118, 50, 208,
|
||||||
/* 1290 */ 23, 138, 48, 116, 115, 24, 128, 129, 130, 131,
|
/* 1290 */ 129, 130, 131, 117, 139, 24, 128, 117, 1, 107,
|
||||||
/* 1300 */ 132, 133, 127, 115, 1, 105, 22, 19, 25, 20,
|
/* 1300 */ 22, 19, 25, 20, 1, 49, 22, 50, 129, 130,
|
||||||
/* 1310 */ 1, 47, 22, 48, 20, 11, 25, 137, 22, 118,
|
/* 1310 */ 131, 132, 133, 134, 25, 138, 11, 22, 20, 120,
|
||||||
/* 1320 */ 105, 126, 22, 17, 95, 71, 4, 22, 126, 71,
|
/* 1320 */ 107, 127, 22, 17, 97, 73, 22, 127, 4, 15,
|
||||||
/* 1330 */ 23, 23, 22, 15, 23, 22, 22, 25, 22, 47,
|
/* 1330 */ 23, 23, 22, 1, 23, 73, 49, 22, 22, 103,
|
||||||
/* 1340 */ 1, 101, 23, 119, 117, 120, 17, 54, 25, 101,
|
/* 1340 */ 22, 56, 25, 23, 121, 33, 17, 119, 25, 103,
|
||||||
/* 1350 */ 3, 23, 115, 23, 39, 23, 115, 5, 119, 106,
|
/* 1350 */ 41, 3, 117, 23, 23, 5, 117, 23, 33, 108,
|
||||||
/* 1360 */ 23, 99, 22, 22, 47, 119, 116, 110, 35, 15,
|
/* 1360 */ 23, 22, 49, 22, 37, 101, 33, 118, 22, 15,
|
||||||
/* 1370 */ 22, 22, 250, 250, 250, 250, 250, 250, 250, 250,
|
/* 1370 */ 112, 22, 250, 250, 250, 250, 250, 250, 250, 250,
|
||||||
/* 1380 */ 60,
|
/* 1380 */ 250, 62,
|
||||||
};
|
};
|
||||||
#define YY_SHIFT_USE_DFLT (-65)
|
#define YY_SHIFT_USE_DFLT (-67)
|
||||||
#define YY_SHIFT_MAX 404
|
#define YY_SHIFT_MAX 404
|
||||||
static const short yy_shift_ofst[] = {
|
static const short yy_shift_ofst[] = {
|
||||||
/* 0 */ 859, 1047, 1153, -19, 1047, 1168, 1168, 143, 151, 331,
|
/* 0 */ 943, 1060, 1155, -19, 1060, 1179, 1179, 65, 63, 259,
|
||||||
/* 10 */ 403, 1168, 1168, 1168, 1168, 1168, -48, 257, 415, 569,
|
/* 10 */ 409, 1179, 1179, 1179, 1179, 1179, -48, 119, 18, 637,
|
||||||
/* 20 */ 777, 777, 680, 1035, 50, 610, 541, 472, 679, 192,
|
/* 20 */ 855, 855, 566, 1011, 52, 622, 551, 480, 693, 195,
|
||||||
/* 30 */ 119, 265, 334, 748, 748, 748, 748, 748, 748, 748,
|
/* 30 */ 123, 267, 338, 764, 764, 764, 764, 764, 764, 764,
|
||||||
/* 40 */ 748, 748, 748, 748, 748, 748, 748, 748, 748, 748,
|
/* 40 */ 764, 764, 764, 764, 764, 764, 764, 764, 764, 764,
|
||||||
/* 50 */ 748, 748, 817, 886, 955, 955, 1024, 1168, 1168, 1168,
|
/* 50 */ 764, 764, 835, 906, 977, 977, 1048, 1179, 1179, 1179,
|
||||||
/* 60 */ 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168,
|
/* 60 */ 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,
|
||||||
/* 70 */ 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168,
|
/* 70 */ 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,
|
||||||
/* 80 */ 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168,
|
/* 80 */ 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,
|
||||||
/* 90 */ 1168, 1168, 1168, 1168, 1168, 1168, 1168, -64, -64, -1,
|
/* 90 */ 1179, 1179, 1179, 1179, 1179, 1179, 1179, -66, -66, -1,
|
||||||
/* 100 */ -1, 52, 6, 140, 954, 611, 569, 569, 338, 680,
|
/* 100 */ -1, 54, 92, 159, 905, 268, 637, 637, 658, 566,
|
||||||
/* 110 */ 614, -65, -65, -65, 79, 123, 114, 114, 507, 150,
|
/* 110 */ 937, -67, -67, -67, 1161, 8, 174, 174, 509, 479,
|
||||||
/* 120 */ 569, 569, 569, 569, 569, 744, 569, 569, 569, 569,
|
/* 120 */ 637, 637, 637, 637, 637, 487, 637, 637, 637, 637,
|
||||||
/* 130 */ 718, 569, 428, 569, 569, 569, 569, 569, 569, 569,
|
/* 130 */ 733, 637, 629, 637, 637, 637, 637, 637, 637, 637,
|
||||||
/* 140 */ 569, 428, 428, 30, 1035, 1035, 1035, -65, -65, -65,
|
/* 140 */ 637, 629, 629, 340, 1011, 1011, 1011, -67, -67, -67,
|
||||||
/* 150 */ -21, 189, -21, 195, 207, 260, 536, 547, 505, 482,
|
/* 150 */ 120, 190, 120, 208, 358, 411, 493, 484, 420, 483,
|
||||||
/* 160 */ 551, 545, 554, 538, 562, 569, 198, 214, 569, 569,
|
/* 160 */ 491, 495, 549, 496, 518, 637, 41, 553, 637, 637,
|
||||||
/* 170 */ 569, 569, 732, 569, 569, 569, 569, 569, 569, 692,
|
/* 170 */ 637, 637, 780, 637, 637, 637, 637, 637, 637, -40,
|
||||||
/* 180 */ 569, 672, 214, 569, 569, 569, 569, 569, 548, 569,
|
/* 180 */ 637, 558, 553, 637, 637, 637, 637, 637, 837, 637,
|
||||||
/* 190 */ 214, 569, 569, 569, 569, 569, 214, 569, 569, 569,
|
/* 190 */ 553, 637, 637, 637, 637, 637, 553, 637, 637, 637,
|
||||||
/* 200 */ 569, 198, 569, 569, 214, 569, 80, 569, 214, 569,
|
/* 200 */ 637, 41, 637, 637, 553, 637, 635, 637, 553, 637,
|
||||||
/* 210 */ 565, 198, 569, 863, -7, 680, 601, 601, 970, 865,
|
/* 210 */ 9, 41, 637, 886, 24, 566, 976, 976, 992, 819,
|
||||||
/* 220 */ 601, 752, 601, -7, 601, 970, 865, 680, -7, 659,
|
/* 220 */ 976, 930, 976, 24, 976, 992, 819, 566, 24, 896,
|
||||||
/* 230 */ 680, 469, 364, 956, 1067, 1097, 1020, 1015, 1067, 1020,
|
/* 230 */ 566, 911, 966, 989, 1044, 1072, 998, 991, 1044, 998,
|
||||||
/* 240 */ 1020, 1151, 1156, 1020, 1163, 1155, 1148, 1020, 1155, 1156,
|
/* 240 */ 998, 1141, 1128, 998, 1158, 1121, 1113, 998, 1121, 1128,
|
||||||
/* 250 */ 1063, 1155, 1176, 1053, 1067, 1178, 1148, 1076, 1015, 1015,
|
/* 250 */ 1027, 1121, 1137, 1115, 1044, 1143, 1113, 1040, 991, 991,
|
||||||
/* 260 */ 1020, 1097, 1164, 1077, 1190, 1083, 1155, 1119, 1100, 1119,
|
/* 260 */ 998, 1072, 1140, 1061, 1172, 1067, 1121, 1103, 1086, 1103,
|
||||||
/* 270 */ 1063, 1186, 1156, 1176, 1119, 1063, 1020, 1156, 1035, 1020,
|
/* 270 */ 1027, 1174, 1128, 1137, 1103, 1027, 998, 1128, 1011, 998,
|
||||||
/* 280 */ 1216, 1154, 1154, 1141, 1020, 1141, 1141, 1216, 1178, 1141,
|
/* 280 */ 1206, 1142, 1142, 1130, 998, 1130, 1130, 1206, 1143, 1130,
|
||||||
/* 290 */ 1141, 1152, 1141, 1164, 1020, 1141, 1178, 1178, 1020, -65,
|
/* 290 */ 1130, 1144, 1130, 1140, 998, 1130, 1143, 1143, 998, -67,
|
||||||
/* 300 */ -65, -65, -65, -65, 328, 511, 685, 442, 72, 335,
|
/* 300 */ -67, -67, -67, -67, 332, 453, 700, 875, 922, 568,
|
||||||
/* 310 */ 966, 973, 919, 917, 890, 819, 686, 922, 896, 899,
|
/* 310 */ 993, 997, 939, 867, 918, 846, 70, 946, 945, 982,
|
||||||
/* 320 */ 130, 487, 690, 567, 647, 1305, 1308, 1310, 1322, 1318,
|
/* 320 */ 287, 701, 833, 624, 768, 1304, 1308, 1310, 1324, 1314,
|
||||||
/* 330 */ 1313, 1312, 1339, 1319, 1312, 1224, 1227, 1323, 1263, 1330,
|
/* 330 */ 1315, 1317, 1332, 1320, 1317, 1312, 1228, 1323, 1260, 1331,
|
||||||
/* 340 */ 1317, 1332, 1239, 1337, 1340, 1246, 1257, 1333, 1311, 1229,
|
/* 340 */ 1313, 1334, 1325, 1337, 1339, 1333, 1258, 1327, 1311, 1227,
|
||||||
/* 350 */ 1201, 1304, 1290, 1283, 1188, 1179, 1172, 1241, 1237, 1328,
|
/* 350 */ 1199, 1305, 1284, 1277, 1180, 1176, 1167, 1239, 1235, 1330,
|
||||||
/* 360 */ 1347, 1354, 1320, 1349, 1248, 1293, 1315, 1225, 1329, 1240,
|
/* 360 */ 1348, 1354, 1319, 1349, 1246, 1285, 1309, 1223, 1329, 1236,
|
||||||
/* 370 */ 1258, 1292, 1314, 1316, 1254, 1307, 1202, 1306, 1300, 1195,
|
/* 370 */ 1262, 1287, 1316, 1318, 1252, 1307, 1200, 1306, 1300, 1194,
|
||||||
/* 380 */ 1215, 1348, 1294, 1296, 1250, 1180, 1265, 1291, 1264, 1341,
|
/* 380 */ 1213, 1346, 1298, 1295, 1249, 1177, 1257, 1289, 1256, 1341,
|
||||||
/* 390 */ 1289, 1309, 1262, 1288, 1284, 1200, 1303, 1253, 1271, 1175,
|
/* 390 */ 1283, 1303, 1264, 1282, 1278, 1192, 1297, 1251, 1271, 1168,
|
||||||
/* 400 */ 1352, 1244, 1177, 1267, 1149,
|
/* 400 */ 1350, 1238, 1169, 1263, 1145,
|
||||||
};
|
};
|
||||||
#define YY_REDUCE_USE_DFLT (-221)
|
#define YY_REDUCE_USE_DFLT (-221)
|
||||||
#define YY_REDUCE_MAX 303
|
#define YY_REDUCE_MAX 303
|
||||||
static const short yy_reduce_ofst[] = {
|
static const short yy_reduce_ofst[] = {
|
||||||
/* 0 */ 371, 148, -49, 288, 131, 212, 215, 206, 145, 286,
|
/* 0 */ 322, 152, 80, 226, 209, 81, 79, 144, 88, 199,
|
||||||
/* 10 */ 76, 360, 350, 348, 287, 290, -220, 424, 227, 2,
|
/* 10 */ 154, 289, -5, 11, 216, 286, -220, 294, 285, 291,
|
||||||
/* 20 */ -127, 77, 14, 233, -8, -8, -8, -8, -8, -8,
|
/* 20 */ 67, 153, -72, 239, -2, -2, -2, -2, -2, -2,
|
||||||
/* 30 */ -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
|
/* 30 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
|
||||||
/* 40 */ -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
|
/* 40 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
|
||||||
/* 50 */ -8, -8, -8, -8, -8, -8, 553, 485, 557, 691,
|
/* 50 */ -2, -2, -2, -2, -2, -2, 427, 368, 500, 571,
|
||||||
/* 60 */ 622, 703, 760, 768, 903, 837, 906, 897, 762, 756,
|
/* 60 */ 508, 582, 636, 646, 722, 711, 724, 720, 640, 634,
|
||||||
/* 70 */ 699, 674, 618, 555, 549, 559, 561, 564, 605, 695,
|
/* 70 */ 579, 569, 506, 498, 408, 502, 504, 220, 223, 577,
|
||||||
/* 80 */ 764, 624, 626, 630, 634, 636, 831, 693, 833, 743,
|
/* 80 */ 642, 510, 512, 550, 563, 565, 705, 575, 707, 621,
|
||||||
/* 90 */ 842, 881, 913, 773, 775, 812, 829, -8, -8, -8,
|
/* 90 */ 714, 717, 777, 649, 651, 653, 692, -2, -2, -2,
|
||||||
/* 100 */ -8, 271, -8, -8, 203, 275, 826, 439, -8, 436,
|
/* 100 */ -2, 189, -2, -2, 418, 349, 671, 445, -2, -141,
|
||||||
/* 110 */ -8, -8, -8, -8, 191, 321, 59, 592, 603, 603,
|
/* 110 */ -2, -2, -2, -2, 136, -70, 198, 390, 470, 470,
|
||||||
/* 120 */ 907, 902, 898, 867, 758, 473, 827, 358, 234, 790,
|
/* 120 */ 850, 817, 811, 807, 816, 561, 792, 736, 249, 668,
|
||||||
/* 130 */ 710, 231, 705, 94, 571, 728, 170, 757, 725, 687,
|
/* 130 */ 732, 652, 794, -144, 725, 667, 83, 785, 458, 421,
|
||||||
/* 140 */ 412, -92, 361, 646, 681, 493, 577, 98, 67, -181,
|
/* 140 */ 443, -106, 793, 770, 771, 740, 769, 124, 293, 35,
|
||||||
/* 150 */ 887, 828, 836, 938, 34, 34, 927, 721, 947, 34,
|
/* 150 */ 861, 848, 854, 919, 243, 243, 902, 578, 935, 243,
|
||||||
/* 160 */ 840, 932, 864, 34, 156, -93, 205, 34, 501, 635,
|
/* 160 */ 723, 921, 851, 243, 180, 22, 261, 243, 376, 576,
|
||||||
/* 170 */ 640, 706, 860, 915, 914, 977, 997, 995, 1126, 964,
|
/* 170 */ 607, 678, 812, 889, 888, 953, 971, 970, 1127, 941,
|
||||||
/* 180 */ 1000, 1045, 34, 911, 912, 924, -50, 1135, 721, 696,
|
/* 180 */ 978, 1039, 243, 885, 887, 890, 106, 1131, 578, 650,
|
||||||
/* 190 */ 34, 560, 494, 243, 228, -144, 34, 840, -56, 928,
|
/* 190 */ 243, 564, 373, 323, 290, -138, 243, 723, 32, 891,
|
||||||
/* 200 */ 934, 921, 943, 952, 34, 960, 953, 971, 34, 895,
|
/* 200 */ 923, 894, 931, 938, 243, 944, 933, 952, 243, 878,
|
||||||
/* 210 */ 813, 967, 1001, 845, 1081, 918, 916, 920, 891, 856,
|
/* 210 */ 795, 942, 979, 809, 1081, 907, 879, 899, 880, 845,
|
||||||
/* 220 */ 925, 923, 933, 904, 935, 926, 872, 948, 936, 930,
|
/* 220 */ 908, 910, 913, 882, 915, 895, 864, 932, 892, 904,
|
||||||
/* 230 */ 957, 929, 939, 978, 944, 894, 980, 945, 958, 985,
|
/* 230 */ 940, 909, 926, 955, 924, 874, 960, 927, 934, 963,
|
||||||
/* 240 */ 1118, 1075, 1092, 1125, 961, 1019, 963, 1016, 1022, 982,
|
/* 240 */ 1108, 1080, 1087, 1123, 929, 985, 920, 981, 990, 956,
|
||||||
/* 250 */ 975, 1037, 1041, 965, 1007, 1042, 981, 1002, 1006, 1008,
|
/* 250 */ 948, 1000, 1004, 916, 968, 1007, 954, 965, 972, 975,
|
||||||
/* 260 */ 1044, 974, 1027, 987, 1058, 983, 1069, 1013, 1025, 1017,
|
/* 260 */ 1018, 936, 1005, 974, 1045, 973, 1055, 999, 1012, 1006,
|
||||||
/* 270 */ 1014, 991, 1039, 1080, 1023, 1026, 1078, 1046, 1040, 1079,
|
/* 270 */ 1008, 983, 1028, 1070, 1013, 1015, 1071, 1032, 1033, 1073,
|
||||||
/* 280 */ 1061, 1011, 1018, 1068, 1088, 1070, 1071, 1073, 1093, 1087,
|
/* 280 */ 1052, 1009, 1010, 1059, 1079, 1062, 1065, 1058, 1088, 1066,
|
||||||
/* 290 */ 1089, 1090, 1094, 1082, 1098, 1095, 1113, 1116, 1117, 1074,
|
/* 290 */ 1074, 1075, 1076, 1064, 1092, 1078, 1095, 1100, 1101, 1077,
|
||||||
/* 300 */ 1099, 1109, 1030, 1036,
|
/* 300 */ 1089, 1104, 1020, 1029,
|
||||||
};
|
};
|
||||||
static const YYACTIONTYPE yy_default[] = {
|
static const YYACTIONTYPE yy_default[] = {
|
||||||
/* 0 */ 615, 848, 929, 736, 929, 848, 929, 929, 875, 929,
|
/* 0 */ 615, 848, 929, 736, 929, 848, 929, 929, 875, 929,
|
||||||
|
@ -629,9 +629,9 @@ static const YYCODETYPE yyFallback[] = {
|
||||||
26, /* EXCLUSIVE => ID */
|
26, /* EXCLUSIVE => ID */
|
||||||
0, /* COMMIT => nothing */
|
0, /* COMMIT => nothing */
|
||||||
26, /* END => ID */
|
26, /* END => ID */
|
||||||
0, /* ROLLBACK => nothing */
|
26, /* ROLLBACK => ID */
|
||||||
0, /* SAVEPOINT => nothing */
|
26, /* SAVEPOINT => ID */
|
||||||
0, /* RELEASE => nothing */
|
26, /* RELEASE => ID */
|
||||||
0, /* TO => nothing */
|
0, /* TO => nothing */
|
||||||
0, /* CREATE => nothing */
|
0, /* CREATE => nothing */
|
||||||
0, /* TABLE => nothing */
|
0, /* TABLE => nothing */
|
||||||
|
@ -650,8 +650,10 @@ static const YYCODETYPE yyFallback[] = {
|
||||||
26, /* ASC => ID */
|
26, /* ASC => ID */
|
||||||
26, /* ATTACH => ID */
|
26, /* ATTACH => ID */
|
||||||
26, /* BEFORE => ID */
|
26, /* BEFORE => ID */
|
||||||
|
26, /* BY => ID */
|
||||||
26, /* CASCADE => ID */
|
26, /* CASCADE => ID */
|
||||||
26, /* CAST => ID */
|
26, /* CAST => ID */
|
||||||
|
26, /* COLUMNKW => ID */
|
||||||
26, /* CONFLICT => ID */
|
26, /* CONFLICT => ID */
|
||||||
26, /* DATABASE => ID */
|
26, /* DATABASE => ID */
|
||||||
26, /* DESC => ID */
|
26, /* DESC => ID */
|
||||||
|
@ -736,7 +738,6 @@ static const YYCODETYPE yyFallback[] = {
|
||||||
0, /* FROM => nothing */
|
0, /* FROM => nothing */
|
||||||
0, /* JOIN => nothing */
|
0, /* JOIN => nothing */
|
||||||
0, /* INDEXED => nothing */
|
0, /* INDEXED => nothing */
|
||||||
0, /* BY => nothing */
|
|
||||||
0, /* USING => nothing */
|
0, /* USING => nothing */
|
||||||
0, /* ORDER => nothing */
|
0, /* ORDER => nothing */
|
||||||
0, /* GROUP => nothing */
|
0, /* GROUP => nothing */
|
||||||
|
@ -757,7 +758,6 @@ static const YYCODETYPE yyFallback[] = {
|
||||||
0, /* INDEX => nothing */
|
0, /* INDEX => nothing */
|
||||||
0, /* ALTER => nothing */
|
0, /* ALTER => nothing */
|
||||||
0, /* ADD => nothing */
|
0, /* ADD => nothing */
|
||||||
0, /* COLUMNKW => nothing */
|
|
||||||
};
|
};
|
||||||
#endif /* YYFALLBACK */
|
#endif /* YYFALLBACK */
|
||||||
|
|
||||||
|
@ -844,34 +844,34 @@ static const char *const yyTokenName[] = {
|
||||||
"EXISTS", "TEMP", "LP", "RP",
|
"EXISTS", "TEMP", "LP", "RP",
|
||||||
"AS", "COMMA", "ID", "ABORT",
|
"AS", "COMMA", "ID", "ABORT",
|
||||||
"AFTER", "ANALYZE", "ASC", "ATTACH",
|
"AFTER", "ANALYZE", "ASC", "ATTACH",
|
||||||
"BEFORE", "CASCADE", "CAST", "CONFLICT",
|
"BEFORE", "BY", "CASCADE", "CAST",
|
||||||
"DATABASE", "DESC", "DETACH", "EACH",
|
"COLUMNKW", "CONFLICT", "DATABASE", "DESC",
|
||||||
"FAIL", "FOR", "IGNORE", "INITIALLY",
|
"DETACH", "EACH", "FAIL", "FOR",
|
||||||
"INSTEAD", "LIKE_KW", "MATCH", "KEY",
|
"IGNORE", "INITIALLY", "INSTEAD", "LIKE_KW",
|
||||||
"OF", "OFFSET", "PRAGMA", "RAISE",
|
"MATCH", "KEY", "OF", "OFFSET",
|
||||||
"REPLACE", "RESTRICT", "ROW", "TRIGGER",
|
"PRAGMA", "RAISE", "REPLACE", "RESTRICT",
|
||||||
"VACUUM", "VIEW", "VIRTUAL", "REINDEX",
|
"ROW", "TRIGGER", "VACUUM", "VIEW",
|
||||||
"RENAME", "CTIME_KW", "ANY", "OR",
|
"VIRTUAL", "REINDEX", "RENAME", "CTIME_KW",
|
||||||
"AND", "IS", "BETWEEN", "IN",
|
"ANY", "OR", "AND", "IS",
|
||||||
"ISNULL", "NOTNULL", "NE", "EQ",
|
"BETWEEN", "IN", "ISNULL", "NOTNULL",
|
||||||
"GT", "LE", "LT", "GE",
|
"NE", "EQ", "GT", "LE",
|
||||||
"ESCAPE", "BITAND", "BITOR", "LSHIFT",
|
"LT", "GE", "ESCAPE", "BITAND",
|
||||||
"RSHIFT", "PLUS", "MINUS", "STAR",
|
"BITOR", "LSHIFT", "RSHIFT", "PLUS",
|
||||||
"SLASH", "REM", "CONCAT", "COLLATE",
|
"MINUS", "STAR", "SLASH", "REM",
|
||||||
"UMINUS", "UPLUS", "BITNOT", "STRING",
|
"CONCAT", "COLLATE", "UMINUS", "UPLUS",
|
||||||
"JOIN_KW", "CONSTRAINT", "DEFAULT", "NULL",
|
"BITNOT", "STRING", "JOIN_KW", "CONSTRAINT",
|
||||||
"PRIMARY", "UNIQUE", "CHECK", "REFERENCES",
|
"DEFAULT", "NULL", "PRIMARY", "UNIQUE",
|
||||||
"AUTOINCR", "ON", "DELETE", "UPDATE",
|
"CHECK", "REFERENCES", "AUTOINCR", "ON",
|
||||||
"INSERT", "SET", "DEFERRABLE", "FOREIGN",
|
"DELETE", "UPDATE", "INSERT", "SET",
|
||||||
"DROP", "UNION", "ALL", "EXCEPT",
|
"DEFERRABLE", "FOREIGN", "DROP", "UNION",
|
||||||
"INTERSECT", "SELECT", "DISTINCT", "DOT",
|
"ALL", "EXCEPT", "INTERSECT", "SELECT",
|
||||||
"FROM", "JOIN", "INDEXED", "BY",
|
"DISTINCT", "DOT", "FROM", "JOIN",
|
||||||
"USING", "ORDER", "GROUP", "HAVING",
|
"INDEXED", "USING", "ORDER", "GROUP",
|
||||||
"LIMIT", "WHERE", "INTO", "VALUES",
|
"HAVING", "LIMIT", "WHERE", "INTO",
|
||||||
"INTEGER", "FLOAT", "BLOB", "REGISTER",
|
"VALUES", "INTEGER", "FLOAT", "BLOB",
|
||||||
"VARIABLE", "CASE", "WHEN", "THEN",
|
"REGISTER", "VARIABLE", "CASE", "WHEN",
|
||||||
"ELSE", "INDEX", "ALTER", "ADD",
|
"THEN", "ELSE", "INDEX", "ALTER",
|
||||||
"COLUMNKW", "error", "input", "cmdlist",
|
"ADD", "error", "input", "cmdlist",
|
||||||
"ecmd", "explain", "cmdx", "cmd",
|
"ecmd", "explain", "cmdx", "cmd",
|
||||||
"transtype", "trans_opt", "nm", "savepoint_opt",
|
"transtype", "trans_opt", "nm", "savepoint_opt",
|
||||||
"create_table", "create_table_args", "temp", "ifnotexists",
|
"create_table", "create_table_args", "temp", "ifnotexists",
|
||||||
|
@ -3386,8 +3386,8 @@ static void yy_reduce(
|
||||||
if( yysize ){
|
if( yysize ){
|
||||||
yypParser->yyidx++;
|
yypParser->yyidx++;
|
||||||
yymsp -= yysize-1;
|
yymsp -= yysize-1;
|
||||||
yymsp->stateno = yyact;
|
yymsp->stateno = (YYACTIONTYPE)yyact;
|
||||||
yymsp->major = yygoto;
|
yymsp->major = (YYCODETYPE)yygoto;
|
||||||
yymsp->minor = yygotominor;
|
yymsp->minor = yygotominor;
|
||||||
}else
|
}else
|
||||||
#endif
|
#endif
|
||||||
|
|
216
parse.h
216
parse.h
|
@ -30,114 +30,114 @@
|
||||||
#define TK_ASC 30
|
#define TK_ASC 30
|
||||||
#define TK_ATTACH 31
|
#define TK_ATTACH 31
|
||||||
#define TK_BEFORE 32
|
#define TK_BEFORE 32
|
||||||
#define TK_CASCADE 33
|
#define TK_BY 33
|
||||||
#define TK_CAST 34
|
#define TK_CASCADE 34
|
||||||
#define TK_CONFLICT 35
|
#define TK_CAST 35
|
||||||
#define TK_DATABASE 36
|
#define TK_COLUMNKW 36
|
||||||
#define TK_DESC 37
|
#define TK_CONFLICT 37
|
||||||
#define TK_DETACH 38
|
#define TK_DATABASE 38
|
||||||
#define TK_EACH 39
|
#define TK_DESC 39
|
||||||
#define TK_FAIL 40
|
#define TK_DETACH 40
|
||||||
#define TK_FOR 41
|
#define TK_EACH 41
|
||||||
#define TK_IGNORE 42
|
#define TK_FAIL 42
|
||||||
#define TK_INITIALLY 43
|
#define TK_FOR 43
|
||||||
#define TK_INSTEAD 44
|
#define TK_IGNORE 44
|
||||||
#define TK_LIKE_KW 45
|
#define TK_INITIALLY 45
|
||||||
#define TK_MATCH 46
|
#define TK_INSTEAD 46
|
||||||
#define TK_KEY 47
|
#define TK_LIKE_KW 47
|
||||||
#define TK_OF 48
|
#define TK_MATCH 48
|
||||||
#define TK_OFFSET 49
|
#define TK_KEY 49
|
||||||
#define TK_PRAGMA 50
|
#define TK_OF 50
|
||||||
#define TK_RAISE 51
|
#define TK_OFFSET 51
|
||||||
#define TK_REPLACE 52
|
#define TK_PRAGMA 52
|
||||||
#define TK_RESTRICT 53
|
#define TK_RAISE 53
|
||||||
#define TK_ROW 54
|
#define TK_REPLACE 54
|
||||||
#define TK_TRIGGER 55
|
#define TK_RESTRICT 55
|
||||||
#define TK_VACUUM 56
|
#define TK_ROW 56
|
||||||
#define TK_VIEW 57
|
#define TK_TRIGGER 57
|
||||||
#define TK_VIRTUAL 58
|
#define TK_VACUUM 58
|
||||||
#define TK_REINDEX 59
|
#define TK_VIEW 59
|
||||||
#define TK_RENAME 60
|
#define TK_VIRTUAL 60
|
||||||
#define TK_CTIME_KW 61
|
#define TK_REINDEX 61
|
||||||
#define TK_ANY 62
|
#define TK_RENAME 62
|
||||||
#define TK_OR 63
|
#define TK_CTIME_KW 63
|
||||||
#define TK_AND 64
|
#define TK_ANY 64
|
||||||
#define TK_IS 65
|
#define TK_OR 65
|
||||||
#define TK_BETWEEN 66
|
#define TK_AND 66
|
||||||
#define TK_IN 67
|
#define TK_IS 67
|
||||||
#define TK_ISNULL 68
|
#define TK_BETWEEN 68
|
||||||
#define TK_NOTNULL 69
|
#define TK_IN 69
|
||||||
#define TK_NE 70
|
#define TK_ISNULL 70
|
||||||
#define TK_EQ 71
|
#define TK_NOTNULL 71
|
||||||
#define TK_GT 72
|
#define TK_NE 72
|
||||||
#define TK_LE 73
|
#define TK_EQ 73
|
||||||
#define TK_LT 74
|
#define TK_GT 74
|
||||||
#define TK_GE 75
|
#define TK_LE 75
|
||||||
#define TK_ESCAPE 76
|
#define TK_LT 76
|
||||||
#define TK_BITAND 77
|
#define TK_GE 77
|
||||||
#define TK_BITOR 78
|
#define TK_ESCAPE 78
|
||||||
#define TK_LSHIFT 79
|
#define TK_BITAND 79
|
||||||
#define TK_RSHIFT 80
|
#define TK_BITOR 80
|
||||||
#define TK_PLUS 81
|
#define TK_LSHIFT 81
|
||||||
#define TK_MINUS 82
|
#define TK_RSHIFT 82
|
||||||
#define TK_STAR 83
|
#define TK_PLUS 83
|
||||||
#define TK_SLASH 84
|
#define TK_MINUS 84
|
||||||
#define TK_REM 85
|
#define TK_STAR 85
|
||||||
#define TK_CONCAT 86
|
#define TK_SLASH 86
|
||||||
#define TK_COLLATE 87
|
#define TK_REM 87
|
||||||
#define TK_UMINUS 88
|
#define TK_CONCAT 88
|
||||||
#define TK_UPLUS 89
|
#define TK_COLLATE 89
|
||||||
#define TK_BITNOT 90
|
#define TK_UMINUS 90
|
||||||
#define TK_STRING 91
|
#define TK_UPLUS 91
|
||||||
#define TK_JOIN_KW 92
|
#define TK_BITNOT 92
|
||||||
#define TK_CONSTRAINT 93
|
#define TK_STRING 93
|
||||||
#define TK_DEFAULT 94
|
#define TK_JOIN_KW 94
|
||||||
#define TK_NULL 95
|
#define TK_CONSTRAINT 95
|
||||||
#define TK_PRIMARY 96
|
#define TK_DEFAULT 96
|
||||||
#define TK_UNIQUE 97
|
#define TK_NULL 97
|
||||||
#define TK_CHECK 98
|
#define TK_PRIMARY 98
|
||||||
#define TK_REFERENCES 99
|
#define TK_UNIQUE 99
|
||||||
#define TK_AUTOINCR 100
|
#define TK_CHECK 100
|
||||||
#define TK_ON 101
|
#define TK_REFERENCES 101
|
||||||
#define TK_DELETE 102
|
#define TK_AUTOINCR 102
|
||||||
#define TK_UPDATE 103
|
#define TK_ON 103
|
||||||
#define TK_INSERT 104
|
#define TK_DELETE 104
|
||||||
#define TK_SET 105
|
#define TK_UPDATE 105
|
||||||
#define TK_DEFERRABLE 106
|
#define TK_INSERT 106
|
||||||
#define TK_FOREIGN 107
|
#define TK_SET 107
|
||||||
#define TK_DROP 108
|
#define TK_DEFERRABLE 108
|
||||||
#define TK_UNION 109
|
#define TK_FOREIGN 109
|
||||||
#define TK_ALL 110
|
#define TK_DROP 110
|
||||||
#define TK_EXCEPT 111
|
#define TK_UNION 111
|
||||||
#define TK_INTERSECT 112
|
#define TK_ALL 112
|
||||||
#define TK_SELECT 113
|
#define TK_EXCEPT 113
|
||||||
#define TK_DISTINCT 114
|
#define TK_INTERSECT 114
|
||||||
#define TK_DOT 115
|
#define TK_SELECT 115
|
||||||
#define TK_FROM 116
|
#define TK_DISTINCT 116
|
||||||
#define TK_JOIN 117
|
#define TK_DOT 117
|
||||||
#define TK_INDEXED 118
|
#define TK_FROM 118
|
||||||
#define TK_BY 119
|
#define TK_JOIN 119
|
||||||
#define TK_USING 120
|
#define TK_INDEXED 120
|
||||||
#define TK_ORDER 121
|
#define TK_USING 121
|
||||||
#define TK_GROUP 122
|
#define TK_ORDER 122
|
||||||
#define TK_HAVING 123
|
#define TK_GROUP 123
|
||||||
#define TK_LIMIT 124
|
#define TK_HAVING 124
|
||||||
#define TK_WHERE 125
|
#define TK_LIMIT 125
|
||||||
#define TK_INTO 126
|
#define TK_WHERE 126
|
||||||
#define TK_VALUES 127
|
#define TK_INTO 127
|
||||||
#define TK_INTEGER 128
|
#define TK_VALUES 128
|
||||||
#define TK_FLOAT 129
|
#define TK_INTEGER 129
|
||||||
#define TK_BLOB 130
|
#define TK_FLOAT 130
|
||||||
#define TK_REGISTER 131
|
#define TK_BLOB 131
|
||||||
#define TK_VARIABLE 132
|
#define TK_REGISTER 132
|
||||||
#define TK_CASE 133
|
#define TK_VARIABLE 133
|
||||||
#define TK_WHEN 134
|
#define TK_CASE 134
|
||||||
#define TK_THEN 135
|
#define TK_WHEN 135
|
||||||
#define TK_ELSE 136
|
#define TK_THEN 136
|
||||||
#define TK_INDEX 137
|
#define TK_ELSE 137
|
||||||
#define TK_ALTER 138
|
#define TK_INDEX 138
|
||||||
#define TK_ADD 139
|
#define TK_ALTER 139
|
||||||
#define TK_COLUMNKW 140
|
#define TK_ADD 140
|
||||||
#define TK_TO_TEXT 141
|
#define TK_TO_TEXT 141
|
||||||
#define TK_TO_BLOB 142
|
#define TK_TO_BLOB 142
|
||||||
#define TK_TO_NUMERIC 143
|
#define TK_TO_NUMERIC 143
|
||||||
|
|
24
pcache.c
24
pcache.c
|
@ -11,7 +11,7 @@
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file implements that page cache.
|
** This file implements that page cache.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pcache.c,v 1.39 2008/12/04 20:40:10 drh Exp $
|
** @(#) $Id: pcache.c,v 1.43 2009/01/23 16:45:01 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
@ -23,14 +23,13 @@ struct PCache {
|
||||||
PgHdr *pSynced; /* Last synced page in dirty page list */
|
PgHdr *pSynced; /* Last synced page in dirty page list */
|
||||||
int nRef; /* Number of referenced pages */
|
int nRef; /* Number of referenced pages */
|
||||||
int nMax; /* Configured cache size */
|
int nMax; /* Configured cache size */
|
||||||
int nMin; /* Configured minimum cache size */
|
|
||||||
int szPage; /* Size of every page in this cache */
|
int szPage; /* Size of every page in this cache */
|
||||||
int szExtra; /* Size of extra space for each page */
|
int szExtra; /* Size of extra space for each page */
|
||||||
int bPurgeable; /* True if pages are on backing store */
|
int bPurgeable; /* True if pages are on backing store */
|
||||||
int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */
|
int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */
|
||||||
void *pStress; /* Argument to xStress */
|
void *pStress; /* Argument to xStress */
|
||||||
sqlite3_pcache *pCache; /* Pluggable cache module */
|
sqlite3_pcache *pCache; /* Pluggable cache module */
|
||||||
PgHdr *pPage1;
|
PgHdr *pPage1; /* Reference to page 1 */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -181,7 +180,6 @@ void sqlite3PcacheOpen(
|
||||||
p->xStress = xStress;
|
p->xStress = xStress;
|
||||||
p->pStress = pStress;
|
p->pStress = pStress;
|
||||||
p->nMax = 100;
|
p->nMax = 100;
|
||||||
p->nMin = 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -263,14 +261,21 @@ int sqlite3PcacheFetch(
|
||||||
}
|
}
|
||||||
|
|
||||||
if( pPage ){
|
if( pPage ){
|
||||||
|
if( !pPage->pData ){
|
||||||
|
memset(pPage, 0, sizeof(PgHdr) + pCache->szExtra);
|
||||||
|
pPage->pExtra = (void*)&pPage[1];
|
||||||
|
pPage->pData = (void *)&((char *)pPage)[sizeof(PgHdr) + pCache->szExtra];
|
||||||
|
pPage->pCache = pCache;
|
||||||
|
pPage->pgno = pgno;
|
||||||
|
}
|
||||||
|
assert( pPage->pCache==pCache );
|
||||||
|
assert( pPage->pgno==pgno );
|
||||||
|
assert( pPage->pExtra==(void *)&pPage[1] );
|
||||||
|
|
||||||
if( 0==pPage->nRef ){
|
if( 0==pPage->nRef ){
|
||||||
pCache->nRef++;
|
pCache->nRef++;
|
||||||
}
|
}
|
||||||
pPage->nRef++;
|
pPage->nRef++;
|
||||||
pPage->pData = (void*)&pPage[1];
|
|
||||||
pPage->pExtra = (void*)&((char*)pPage->pData)[pCache->szPage];
|
|
||||||
pPage->pCache = pCache;
|
|
||||||
pPage->pgno = pgno;
|
|
||||||
if( pgno==1 ){
|
if( pgno==1 ){
|
||||||
pCache->pPage1 = pPage;
|
pCache->pPage1 = pPage;
|
||||||
}
|
}
|
||||||
|
@ -431,9 +436,8 @@ void sqlite3PcacheClose(PCache *pCache){
|
||||||
/*
|
/*
|
||||||
** Discard the contents of the cache.
|
** Discard the contents of the cache.
|
||||||
*/
|
*/
|
||||||
int sqlite3PcacheClear(PCache *pCache){
|
void sqlite3PcacheClear(PCache *pCache){
|
||||||
sqlite3PcacheTruncate(pCache, 0);
|
sqlite3PcacheTruncate(pCache, 0);
|
||||||
return SQLITE_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
4
pcache.h
4
pcache.h
|
@ -12,7 +12,7 @@
|
||||||
** This header file defines the interface that the sqlite page cache
|
** This header file defines the interface that the sqlite page cache
|
||||||
** subsystem.
|
** subsystem.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pcache.h,v 1.16 2008/11/19 16:52:44 danielk1977 Exp $
|
** @(#) $Id: pcache.h,v 1.19 2009/01/20 17:06:27 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _PCACHE_H_
|
#ifndef _PCACHE_H_
|
||||||
|
@ -111,7 +111,7 @@ void sqlite3PcacheClose(PCache*);
|
||||||
void sqlite3PcacheClearSyncFlags(PCache *);
|
void sqlite3PcacheClearSyncFlags(PCache *);
|
||||||
|
|
||||||
/* Discard the contents of the cache */
|
/* Discard the contents of the cache */
|
||||||
int sqlite3PcacheClear(PCache*);
|
void sqlite3PcacheClear(PCache*);
|
||||||
|
|
||||||
/* Return the total number of outstanding page references */
|
/* Return the total number of outstanding page references */
|
||||||
int sqlite3PcacheRefCount(PCache*);
|
int sqlite3PcacheRefCount(PCache*);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
** If the default page cache implementation is overriden, then neither of
|
** If the default page cache implementation is overriden, then neither of
|
||||||
** these two features are available.
|
** these two features are available.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pcache1.c,v 1.7 2009/01/07 15:18:21 danielk1977 Exp $
|
** @(#) $Id: pcache1.c,v 1.8 2009/01/23 16:45:01 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
@ -201,7 +201,6 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache){
|
||||||
int nByte = sizeof(PgHdr1) + pCache->szPage;
|
int nByte = sizeof(PgHdr1) + pCache->szPage;
|
||||||
PgHdr1 *p = (PgHdr1 *)pcache1Alloc(nByte);
|
PgHdr1 *p = (PgHdr1 *)pcache1Alloc(nByte);
|
||||||
if( p ){
|
if( p ){
|
||||||
memset(p, 0, nByte);
|
|
||||||
if( pCache->bPurgeable ){
|
if( pCache->bPurgeable ){
|
||||||
pcache1.nCurrentPage++;
|
pcache1.nCurrentPage++;
|
||||||
}
|
}
|
||||||
|
@ -550,11 +549,13 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){
|
||||||
|
|
||||||
if( pPage ){
|
if( pPage ){
|
||||||
unsigned int h = iKey % pCache->nHash;
|
unsigned int h = iKey % pCache->nHash;
|
||||||
memset(pPage, 0, pCache->szPage + sizeof(PgHdr1));
|
*(void **)(PGHDR1_TO_PAGE(pPage)) = 0;
|
||||||
pCache->nPage++;
|
pCache->nPage++;
|
||||||
pPage->iKey = iKey;
|
pPage->iKey = iKey;
|
||||||
pPage->pNext = pCache->apHash[h];
|
pPage->pNext = pCache->apHash[h];
|
||||||
pPage->pCache = pCache;
|
pPage->pCache = pCache;
|
||||||
|
pPage->pLruPrev = 0;
|
||||||
|
pPage->pLruNext = 0;
|
||||||
pCache->apHash[h] = pPage;
|
pCache->apHash[h] = pPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
5
pragma.c
5
pragma.c
|
@ -11,10 +11,9 @@
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** This file contains code used to implement the PRAGMA command.
|
** This file contains code used to implement the PRAGMA command.
|
||||||
**
|
**
|
||||||
** $Id: pragma.c,v 1.201 2009/01/13 20:14:16 drh Exp $
|
** $Id: pragma.c,v 1.202 2009/01/20 16:53:41 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
/* Ignore this whole file if pragmas are disabled
|
/* Ignore this whole file if pragmas are disabled
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +36,7 @@ static u8 getSafetyLevel(const char *z){
|
||||||
static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4};
|
static const u8 iLength[] = {2, 2, 3, 5, 3, 4, 4};
|
||||||
static const u8 iValue[] = {1, 0, 0, 0, 1, 1, 2};
|
static const u8 iValue[] = {1, 0, 0, 0, 1, 1, 2};
|
||||||
int i, n;
|
int i, n;
|
||||||
if( isdigit(*z) ){
|
if( sqlite3Isdigit(*z) ){
|
||||||
return (u8)atoi(z);
|
return (u8)atoi(z);
|
||||||
}
|
}
|
||||||
n = sqlite3Strlen30(z);
|
n = sqlite3Strlen30(z);
|
||||||
|
|
|
@ -13,10 +13,9 @@
|
||||||
** interface, and routines that contribute to loading the database schema
|
** interface, and routines that contribute to loading the database schema
|
||||||
** from disk.
|
** from disk.
|
||||||
**
|
**
|
||||||
** $Id: prepare.c,v 1.104 2009/01/09 02:49:32 drh Exp $
|
** $Id: prepare.c,v 1.105 2009/01/20 16:53:41 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Fill the InitData structure with an error message that indicates
|
** Fill the InitData structure with an error message that indicates
|
||||||
|
|
6
select.c
6
select.c
|
@ -12,7 +12,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 in SQLite.
|
** to handle SELECT statements in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: select.c,v 1.498 2009/01/09 02:49:32 drh Exp $
|
** $Id: select.c,v 1.499 2009/02/09 13:19:28 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
@ -3365,8 +3365,8 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
|
||||||
if( pFunc->iDistinct>=0 ){
|
if( pFunc->iDistinct>=0 ){
|
||||||
Expr *pE = pFunc->pExpr;
|
Expr *pE = pFunc->pExpr;
|
||||||
if( pE->pList==0 || pE->pList->nExpr!=1 ){
|
if( pE->pList==0 || pE->pList->nExpr!=1 ){
|
||||||
sqlite3ErrorMsg(pParse, "DISTINCT in aggregate must be followed "
|
sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one "
|
||||||
"by an expression");
|
"argument");
|
||||||
pFunc->iDistinct = -1;
|
pFunc->iDistinct = -1;
|
||||||
}else{
|
}else{
|
||||||
KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->pList);
|
KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->pList);
|
||||||
|
|
91
shell.c
91
shell.c
|
@ -12,7 +12,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.198 2009/01/14 23:38:03 drh Exp $
|
** $Id: shell.c,v 1.201 2009/02/04 22:46:47 drh Exp $
|
||||||
*/
|
*/
|
||||||
#if defined(_WIN32) || defined(WIN32)
|
#if defined(_WIN32) || defined(WIN32)
|
||||||
/* This needs to come before any includes for MSVC compiler */
|
/* This needs to come before any includes for MSVC compiler */
|
||||||
|
@ -227,6 +227,7 @@ static void shellstaticFunc(
|
||||||
){
|
){
|
||||||
assert( 0==argc );
|
assert( 0==argc );
|
||||||
assert( zShellStatic );
|
assert( zShellStatic );
|
||||||
|
UNUSED_PARAMETER(argc);
|
||||||
UNUSED_PARAMETER(argv);
|
UNUSED_PARAMETER(argv);
|
||||||
sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);
|
sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);
|
||||||
}
|
}
|
||||||
|
@ -929,6 +930,7 @@ static int run_schema_dump_query(
|
||||||
** Text of a help message
|
** Text of a help message
|
||||||
*/
|
*/
|
||||||
static char zHelp[] =
|
static char zHelp[] =
|
||||||
|
".backup ?DB? FILE Backup DB (default \"main\") to FILE\n"
|
||||||
".bail ON|OFF Stop after hitting an error. Default OFF\n"
|
".bail ON|OFF Stop after hitting an error. Default OFF\n"
|
||||||
".databases List names and files of attached databases\n"
|
".databases List names and files of attached databases\n"
|
||||||
".dump ?TABLE? ... Dump the database in an SQL text format\n"
|
".dump ?TABLE? ... Dump the database in an SQL text format\n"
|
||||||
|
@ -960,6 +962,7 @@ static char zHelp[] =
|
||||||
".prompt MAIN CONTINUE Replace the standard prompts\n"
|
".prompt MAIN CONTINUE Replace the standard prompts\n"
|
||||||
".quit Exit this program\n"
|
".quit Exit this program\n"
|
||||||
".read FILENAME Execute SQL in FILENAME\n"
|
".read FILENAME Execute SQL in FILENAME\n"
|
||||||
|
".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n"
|
||||||
".schema ?TABLE? Show the CREATE statements\n"
|
".schema ?TABLE? Show the CREATE statements\n"
|
||||||
".separator STRING Change separator used by output mode and .import\n"
|
".separator STRING Change separator used by output mode and .import\n"
|
||||||
".show Show the current values for various settings\n"
|
".show Show the current values for various settings\n"
|
||||||
|
@ -1091,7 +1094,43 @@ static int do_meta_command(char *zLine, struct callback_data *p){
|
||||||
if( nArg==0 ) return rc;
|
if( nArg==0 ) return rc;
|
||||||
n = strlen30(azArg[0]);
|
n = strlen30(azArg[0]);
|
||||||
c = azArg[0][0];
|
c = azArg[0][0];
|
||||||
if( c=='b' && n>1 && strncmp(azArg[0], "bail", n)==0 && nArg>1 ){
|
if( c=='b' && n>=3 && strncmp(azArg[0], "backup", n)==0 && nArg>1 ){
|
||||||
|
const char *zDestFile;
|
||||||
|
const char *zDb;
|
||||||
|
sqlite3 *pDest;
|
||||||
|
sqlite3_backup *pBackup;
|
||||||
|
int rc;
|
||||||
|
if( nArg==2 ){
|
||||||
|
zDestFile = azArg[1];
|
||||||
|
zDb = "main";
|
||||||
|
}else{
|
||||||
|
zDestFile = azArg[2];
|
||||||
|
zDb = azArg[1];
|
||||||
|
}
|
||||||
|
rc = sqlite3_open(zDestFile, &pDest);
|
||||||
|
if( rc!=SQLITE_OK ){
|
||||||
|
fprintf(stderr, "Error: cannot open %s\n", zDestFile);
|
||||||
|
sqlite3_close(pDest);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
open_db(p);
|
||||||
|
pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);
|
||||||
|
if( pBackup==0 ){
|
||||||
|
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest));
|
||||||
|
sqlite3_close(pDest);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK ){}
|
||||||
|
sqlite3_backup_finish(pBackup);
|
||||||
|
if( rc==SQLITE_DONE ){
|
||||||
|
rc = SQLITE_OK;
|
||||||
|
}else{
|
||||||
|
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(pDest));
|
||||||
|
}
|
||||||
|
sqlite3_close(pDest);
|
||||||
|
}else
|
||||||
|
|
||||||
|
if( c=='b' && n>=3 && strncmp(azArg[0], "bail", n)==0 && nArg>1 ){
|
||||||
bail_on_error = booleanValue(azArg[1]);
|
bail_on_error = booleanValue(azArg[1]);
|
||||||
}else
|
}else
|
||||||
|
|
||||||
|
@ -1452,7 +1491,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
|
||||||
rc = 2;
|
rc = 2;
|
||||||
}else
|
}else
|
||||||
|
|
||||||
if( c=='r' && strncmp(azArg[0], "read", n)==0 && nArg==2 ){
|
if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 && nArg==2 ){
|
||||||
FILE *alt = fopen(azArg[1], "rb");
|
FILE *alt = fopen(azArg[1], "rb");
|
||||||
if( alt==0 ){
|
if( alt==0 ){
|
||||||
fprintf(stderr,"can't open \"%s\"\n", azArg[1]);
|
fprintf(stderr,"can't open \"%s\"\n", azArg[1]);
|
||||||
|
@ -1462,6 +1501,52 @@ static int do_meta_command(char *zLine, struct callback_data *p){
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
|
|
||||||
|
if( c=='r' && n>=3 && strncmp(azArg[0], "restore", n)==0 && nArg>1 ){
|
||||||
|
const char *zSrcFile;
|
||||||
|
const char *zDb;
|
||||||
|
sqlite3 *pSrc;
|
||||||
|
sqlite3_backup *pBackup;
|
||||||
|
int rc;
|
||||||
|
int nTimeout = 0;
|
||||||
|
|
||||||
|
if( nArg==2 ){
|
||||||
|
zSrcFile = azArg[1];
|
||||||
|
zDb = "main";
|
||||||
|
}else{
|
||||||
|
zSrcFile = azArg[2];
|
||||||
|
zDb = azArg[1];
|
||||||
|
}
|
||||||
|
rc = sqlite3_open(zSrcFile, &pSrc);
|
||||||
|
if( rc!=SQLITE_OK ){
|
||||||
|
fprintf(stderr, "Error: cannot open %s\n", zSrcFile);
|
||||||
|
sqlite3_close(pSrc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
open_db(p);
|
||||||
|
pBackup = sqlite3_backup_init(p->db, zDb, pSrc, "main");
|
||||||
|
if( pBackup==0 ){
|
||||||
|
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
|
||||||
|
sqlite3_close(pSrc);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
while( (rc = sqlite3_backup_step(pBackup,100))==SQLITE_OK
|
||||||
|
|| rc==SQLITE_BUSY ){
|
||||||
|
if( rc==SQLITE_BUSY ){
|
||||||
|
if( nTimeout++ >= 3 ) break;
|
||||||
|
sqlite3_sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sqlite3_backup_finish(pBackup);
|
||||||
|
if( rc==SQLITE_DONE ){
|
||||||
|
rc = SQLITE_OK;
|
||||||
|
}else if( rc==SQLITE_BUSY || rc==SQLITE_LOCKED ){
|
||||||
|
fprintf(stderr, "source database is busy\n");
|
||||||
|
}else{
|
||||||
|
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
|
||||||
|
}
|
||||||
|
sqlite3_close(pSrc);
|
||||||
|
}else
|
||||||
|
|
||||||
if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){
|
if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){
|
||||||
struct callback_data data;
|
struct callback_data data;
|
||||||
char *zErrMsg = 0;
|
char *zErrMsg = 0;
|
||||||
|
|
250
sqlite3.h
250
sqlite3.h
|
@ -30,7 +30,7 @@
|
||||||
** the version number) and changes its name to "sqlite3.h" as
|
** the version number) and changes its name to "sqlite3.h" as
|
||||||
** part of the build process.
|
** part of the build process.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqlite.h.in,v 1.421 2008/12/30 06:24:58 danielk1977 Exp $
|
** @(#) $Id: sqlite.h.in,v 1.432 2009/02/12 17:07:35 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITE3_H_
|
#ifndef _SQLITE3_H_
|
||||||
#define _SQLITE3_H_
|
#define _SQLITE3_H_
|
||||||
|
@ -107,8 +107,8 @@ extern "C" {
|
||||||
** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
|
** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
|
||||||
** are the major version, minor version, and release number.
|
** are the major version, minor version, and release number.
|
||||||
*/
|
*/
|
||||||
#define SQLITE_VERSION "3.6.10"
|
#define SQLITE_VERSION "3.6.11"
|
||||||
#define SQLITE_VERSION_NUMBER 3006010
|
#define SQLITE_VERSION_NUMBER 3006011
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
|
** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
|
||||||
|
@ -2789,8 +2789,10 @@ typedef struct sqlite3_stmt sqlite3_stmt;
|
||||||
** new limit for that construct. The function returns the old limit.
|
** new limit for that construct. The function returns the old limit.
|
||||||
**
|
**
|
||||||
** If the new limit is a negative number, the limit is unchanged.
|
** If the new limit is a negative number, the limit is unchanged.
|
||||||
** For the limit category of SQLITE_LIMIT_XYZ there is a hard upper
|
** For the limit category of SQLITE_LIMIT_XYZ there is a
|
||||||
** bound set by a compile-time C preprocessor macro named SQLITE_MAX_XYZ.
|
** [limits | hard upper bound]
|
||||||
|
** set by a compile-time C preprocessor macro named
|
||||||
|
** [limits | SQLITE_MAX_XYZ].
|
||||||
** (The "_LIMIT_" in the name is changed to "_MAX_".)
|
** (The "_LIMIT_" in the name is changed to "_MAX_".)
|
||||||
** Attempts to increase a limit above its hard upper bound are
|
** Attempts to increase a limit above its hard upper bound are
|
||||||
** silently truncated to the hard upper limit.
|
** silently truncated to the hard upper limit.
|
||||||
|
@ -2798,7 +2800,7 @@ typedef struct sqlite3_stmt sqlite3_stmt;
|
||||||
** Run time limits are intended for use in applications that manage
|
** Run time limits are intended for use in applications that manage
|
||||||
** both their own internal database and also databases that are controlled
|
** both their own internal database and also databases that are controlled
|
||||||
** by untrusted external sources. An example application might be a
|
** by untrusted external sources. An example application might be a
|
||||||
** webbrowser that has its own databases for storing history and
|
** web browser that has its own databases for storing history and
|
||||||
** separate databases controlled by JavaScript applications downloaded
|
** separate databases controlled by JavaScript applications downloaded
|
||||||
** off the Internet. The internal databases can be given the
|
** off the Internet. The internal databases can be given the
|
||||||
** large, default limits. Databases managed by external sources can
|
** large, default limits. Databases managed by external sources can
|
||||||
|
@ -2830,9 +2832,10 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
|
||||||
** CAPI3REF: Run-Time Limit Categories {H12790} <H12760>
|
** CAPI3REF: Run-Time Limit Categories {H12790} <H12760>
|
||||||
** KEYWORDS: {limit category} {limit categories}
|
** KEYWORDS: {limit category} {limit categories}
|
||||||
**
|
**
|
||||||
** These constants define various aspects of a [database connection]
|
** These constants define various performance limits
|
||||||
** that can be limited in size by calls to [sqlite3_limit()].
|
** that can be lowered at run-time using [sqlite3_limit()].
|
||||||
** The meanings of the various limits are as follows:
|
** The synopsis of the meanings of the various limits is shown below.
|
||||||
|
** Additional information is available at [limits | Limits in SQLite].
|
||||||
**
|
**
|
||||||
** <dl>
|
** <dl>
|
||||||
** <dt>SQLITE_LIMIT_LENGTH</dt>
|
** <dt>SQLITE_LIMIT_LENGTH</dt>
|
||||||
|
@ -2843,7 +2846,7 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
|
||||||
**
|
**
|
||||||
** <dt>SQLITE_LIMIT_COLUMN</dt>
|
** <dt>SQLITE_LIMIT_COLUMN</dt>
|
||||||
** <dd>The maximum number of columns in a table definition or in the
|
** <dd>The maximum number of columns in a table definition or in the
|
||||||
** result set of a SELECT or the maximum number of columns in an index
|
** result set of a [SELECT] or the maximum number of columns in an index
|
||||||
** or in an ORDER BY or GROUP BY clause.</dd>
|
** or in an ORDER BY or GROUP BY clause.</dd>
|
||||||
**
|
**
|
||||||
** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
|
** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
|
||||||
|
@ -2860,11 +2863,11 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
|
||||||
** <dd>The maximum number of arguments on a function.</dd>
|
** <dd>The maximum number of arguments on a function.</dd>
|
||||||
**
|
**
|
||||||
** <dt>SQLITE_LIMIT_ATTACHED</dt>
|
** <dt>SQLITE_LIMIT_ATTACHED</dt>
|
||||||
** <dd>The maximum number of attached databases.</dd>
|
** <dd>The maximum number of [ATTACH | attached databases].</dd>
|
||||||
**
|
**
|
||||||
** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
|
** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
|
||||||
** <dd>The maximum length of the pattern argument to the LIKE or
|
** <dd>The maximum length of the pattern argument to the [LIKE] or
|
||||||
** GLOB operators.</dd>
|
** [GLOB] operators.</dd>
|
||||||
**
|
**
|
||||||
** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
|
** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
|
||||||
** <dd>The maximum number of variables in an SQL statement that can
|
** <dd>The maximum number of variables in an SQL statement that can
|
||||||
|
@ -3099,7 +3102,7 @@ typedef struct sqlite3_context sqlite3_context;
|
||||||
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
|
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
|
||||||
**
|
**
|
||||||
** In the SQL strings input to [sqlite3_prepare_v2()] and its variants,
|
** In the SQL strings input to [sqlite3_prepare_v2()] and its variants,
|
||||||
** literals may be replaced by a parameter in one of these forms:
|
** literals may be replaced by a [parameter] in one of these forms:
|
||||||
**
|
**
|
||||||
** <ul>
|
** <ul>
|
||||||
** <li> ?
|
** <li> ?
|
||||||
|
@ -4977,8 +4980,8 @@ int sqlite3_get_autocommit(sqlite3*);
|
||||||
** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600>
|
** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600>
|
||||||
**
|
**
|
||||||
** The sqlite3_db_handle interface returns the [database connection] handle
|
** The sqlite3_db_handle interface returns the [database connection] handle
|
||||||
** to which a [prepared statement] belongs. The database handle returned by
|
** to which a [prepared statement] belongs. The [database connection]
|
||||||
** sqlite3_db_handle is the same database handle that was the first argument
|
** returned by sqlite3_db_handle is the same [database connection] that was the first argument
|
||||||
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
|
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
|
||||||
** create the statement in the first place.
|
** create the statement in the first place.
|
||||||
**
|
**
|
||||||
|
@ -5183,7 +5186,7 @@ void *sqlite3_update_hook(
|
||||||
** to the same database. Sharing is enabled if the argument is true
|
** to the same database. Sharing is enabled if the argument is true
|
||||||
** and disabled if the argument is false.
|
** and disabled if the argument is false.
|
||||||
**
|
**
|
||||||
** Cache sharing is enabled and disabled for an entire process. {END}
|
** Cache sharing is enabled and disabled for an entire process.
|
||||||
** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
|
** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
|
||||||
** sharing was enabled or disabled for each thread separately.
|
** sharing was enabled or disabled for each thread separately.
|
||||||
**
|
**
|
||||||
|
@ -5203,6 +5206,8 @@ void *sqlite3_update_hook(
|
||||||
** future releases of SQLite. Applications that care about shared
|
** future releases of SQLite. Applications that care about shared
|
||||||
** cache setting should set it explicitly.
|
** cache setting should set it explicitly.
|
||||||
**
|
**
|
||||||
|
** See Also: [SQLite Shared-Cache Mode]
|
||||||
|
**
|
||||||
** INVARIANTS:
|
** INVARIANTS:
|
||||||
**
|
**
|
||||||
** {H10331} A successful invocation of [sqlite3_enable_shared_cache(B)]
|
** {H10331} A successful invocation of [sqlite3_enable_shared_cache(B)]
|
||||||
|
@ -6372,6 +6377,7 @@ int sqlite3_test_control(int op, ...);
|
||||||
#define SQLITE_TESTCTRL_BITVEC_TEST 8
|
#define SQLITE_TESTCTRL_BITVEC_TEST 8
|
||||||
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
|
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
|
||||||
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
|
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
|
||||||
|
#define SQLITE_TESTCTRL_PENDING_BYTE 11
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CAPI3REF: SQLite Runtime Status {H17200} <S60200>
|
** CAPI3REF: SQLite Runtime Status {H17200} <S60200>
|
||||||
|
@ -6661,17 +6667,17 @@ typedef struct sqlite3_pcache sqlite3_pcache;
|
||||||
** in which case SQLite will attempt to unpin one or more
|
** in which case SQLite will attempt to unpin one or more
|
||||||
** pages before re-requesting the same page, or it can
|
** pages before re-requesting the same page, or it can
|
||||||
** allocate a new page and return a pointer to it. If a new
|
** allocate a new page and return a pointer to it. If a new
|
||||||
** page is allocated, then it must be completely zeroed before
|
** page is allocated, then the first sizeof(void*) bytes of
|
||||||
** it is returned.
|
** it (at least) must be zeroed before it is returned.
|
||||||
** <tr><td>2<td>If createFlag is set to 2, then SQLite is not holding any
|
** <tr><td>2<td>If createFlag is set to 2, then SQLite is not holding any
|
||||||
** pinned pages associated with the specific cache passed
|
** pinned pages associated with the specific cache passed
|
||||||
** as the first argument to xFetch() that can be unpinned. The
|
** as the first argument to xFetch() that can be unpinned. The
|
||||||
** cache implementation should attempt to allocate a new
|
** cache implementation should attempt to allocate a new
|
||||||
** cache entry and return a pointer to it. Again, the new
|
** cache entry and return a pointer to it. Again, the first
|
||||||
** page should be zeroed before it is returned. If the xFetch()
|
** sizeof(void*) bytes of the page should be zeroed before
|
||||||
** method returns NULL when createFlag==2, SQLite assumes that
|
** it is returned. If the xFetch() method returns NULL when
|
||||||
** a memory allocation failed and returns SQLITE_NOMEM to the
|
** createFlag==2, SQLite assumes that a memory allocation
|
||||||
** user.
|
** failed and returns SQLITE_NOMEM to the user.
|
||||||
** </table>
|
** </table>
|
||||||
**
|
**
|
||||||
** xUnpin() is called by SQLite with a pointer to a currently pinned page
|
** xUnpin() is called by SQLite with a pointer to a currently pinned page
|
||||||
|
@ -6722,6 +6728,202 @@ struct sqlite3_pcache_methods {
|
||||||
void (*xDestroy)(sqlite3_pcache*);
|
void (*xDestroy)(sqlite3_pcache*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: Online Backup Object
|
||||||
|
** EXPERIMENTAL
|
||||||
|
**
|
||||||
|
** The sqlite3_backup object records state information about an ongoing
|
||||||
|
** online backup operation. The sqlite3_backup object is created by
|
||||||
|
** a call to [sqlite3_backup_init()] and is destroyed by a call to
|
||||||
|
** [sqlite3_backup_finish()].
|
||||||
|
**
|
||||||
|
** See Also: [Using the SQLite Online Backup API]
|
||||||
|
*/
|
||||||
|
typedef struct sqlite3_backup sqlite3_backup;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** CAPI3REF: Online Backup API.
|
||||||
|
** EXPERIMENTAL
|
||||||
|
**
|
||||||
|
** This API is used to overwrite the contents of one database with that
|
||||||
|
** of another. It is useful either for creating backups of databases or
|
||||||
|
** for copying in-memory databases to or from persistent files.
|
||||||
|
**
|
||||||
|
** See Also: [Using the SQLite Online Backup API]
|
||||||
|
**
|
||||||
|
** Exclusive access is required to the destination database for the
|
||||||
|
** duration of the operation. However the source database is only
|
||||||
|
** read-locked while it is actually being read, it is not locked
|
||||||
|
** continuously for the entire operation. Thus, the backup may be
|
||||||
|
** performed on a live database without preventing other users from
|
||||||
|
** writing to the database for an extended period of time.
|
||||||
|
**
|
||||||
|
** To perform a backup operation:
|
||||||
|
** <ol>
|
||||||
|
** <li><b>sqlite3_backup_init()</b> is called once to initialize the
|
||||||
|
** backup,
|
||||||
|
** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
|
||||||
|
** the data between the two databases, and finally
|
||||||
|
** <li><b>sqlite3_backup_finish()</b> is called to release all resources
|
||||||
|
** associated with the backup operation.
|
||||||
|
** </ol>
|
||||||
|
** There should be exactly one call to sqlite3_backup_finish() for each
|
||||||
|
** successful call to sqlite3_backup_init().
|
||||||
|
**
|
||||||
|
** <b>sqlite3_backup_init()</b>
|
||||||
|
**
|
||||||
|
** The first two arguments passed to [sqlite3_backup_init()] are the database
|
||||||
|
** handle associated with the destination database and the database name
|
||||||
|
** used to attach the destination database to the handle. The database name
|
||||||
|
** is "main" for the main database, "temp" for the temporary database, or
|
||||||
|
** the name specified as part of the [ATTACH] statement if the destination is
|
||||||
|
** an attached database. The third and fourth arguments passed to
|
||||||
|
** sqlite3_backup_init() identify the [database connection]
|
||||||
|
** and database name used
|
||||||
|
** to access the source database. The values passed for the source and
|
||||||
|
** destination [database connection] parameters must not be the same.
|
||||||
|
**
|
||||||
|
** If an error occurs within sqlite3_backup_init(), then NULL is returned
|
||||||
|
** and an error code and error message written into the [database connection]
|
||||||
|
** passed as the first argument. They may be retrieved using the
|
||||||
|
** [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()] functions.
|
||||||
|
** Otherwise, if successful, a pointer to an [sqlite3_backup] object is
|
||||||
|
** returned. This pointer may be used with the sqlite3_backup_step() and
|
||||||
|
** sqlite3_backup_finish() functions to perform the specified backup
|
||||||
|
** operation.
|
||||||
|
**
|
||||||
|
** <b>sqlite3_backup_step()</b>
|
||||||
|
**
|
||||||
|
** Function [sqlite3_backup_step()] is used to copy up to nPage pages between
|
||||||
|
** the source and destination databases, where nPage is the value of the
|
||||||
|
** second parameter passed to sqlite3_backup_step(). If nPage is a negative
|
||||||
|
** value, all remaining source pages are copied. If the required pages are
|
||||||
|
** succesfully copied, but there are still more pages to copy before the
|
||||||
|
** backup is complete, it returns [SQLITE_OK]. If no error occured and there
|
||||||
|
** are no more pages to copy, then [SQLITE_DONE] is returned. If an error
|
||||||
|
** occurs, then an SQLite error code is returned. As well as [SQLITE_OK] and
|
||||||
|
** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
|
||||||
|
** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
|
||||||
|
** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
|
||||||
|
**
|
||||||
|
** As well as the case where the destination database file was opened for
|
||||||
|
** read-only access, sqlite3_backup_step() may return [SQLITE_READONLY] if
|
||||||
|
** the destination is an in-memory database with a different page size
|
||||||
|
** from the source database.
|
||||||
|
**
|
||||||
|
** If sqlite3_backup_step() cannot obtain a required file-system lock, then
|
||||||
|
** the [sqlite3_busy_handler | busy-handler function]
|
||||||
|
** is invoked (if one is specified). If the
|
||||||
|
** busy-handler returns non-zero before the lock is available, then
|
||||||
|
** [SQLITE_BUSY] is returned to the caller. In this case the call to
|
||||||
|
** sqlite3_backup_step() can be retried later. If the source
|
||||||
|
** [database connection]
|
||||||
|
** is being used to write to the source database when sqlite3_backup_step()
|
||||||
|
** is called, then [SQLITE_LOCKED] is returned immediately. Again, in this
|
||||||
|
** case the call to sqlite3_backup_step() can be retried later on. If
|
||||||
|
** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
|
||||||
|
** [SQLITE_READONLY] is returned, then
|
||||||
|
** there is no point in retrying the call to sqlite3_backup_step(). These
|
||||||
|
** errors are considered fatal. At this point the application must accept
|
||||||
|
** that the backup operation has failed and pass the backup operation handle
|
||||||
|
** to the sqlite3_backup_finish() to release associated resources.
|
||||||
|
**
|
||||||
|
** Following the first call to sqlite3_backup_step(), an exclusive lock is
|
||||||
|
** obtained on the destination file. It is not released until either
|
||||||
|
** sqlite3_backup_finish() is called or the backup operation is complete
|
||||||
|
** and sqlite3_backup_step() returns [SQLITE_DONE]. Additionally, each time
|
||||||
|
** a call to sqlite3_backup_step() is made a [shared lock] is obtained on
|
||||||
|
** the source database file. This lock is released before the
|
||||||
|
** sqlite3_backup_step() call returns. Because the source database is not
|
||||||
|
** locked between calls to sqlite3_backup_step(), it may be modified mid-way
|
||||||
|
** through the backup procedure. If the source database is modified by an
|
||||||
|
** external process or via a database connection other than the one being
|
||||||
|
** used by the backup operation, then the backup will be transparently
|
||||||
|
** restarted by the next call to sqlite3_backup_step(). If the source
|
||||||
|
** database is modified by the using the same database connection as is used
|
||||||
|
** by the backup operation, then the backup database is transparently
|
||||||
|
** updated at the same time.
|
||||||
|
**
|
||||||
|
** <b>sqlite3_backup_finish()</b>
|
||||||
|
**
|
||||||
|
** Once sqlite3_backup_step() has returned [SQLITE_DONE], or when the
|
||||||
|
** application wishes to abandon the backup operation, the [sqlite3_backup]
|
||||||
|
** object should be passed to sqlite3_backup_finish(). This releases all
|
||||||
|
** resources associated with the backup operation. If sqlite3_backup_step()
|
||||||
|
** has not yet returned [SQLITE_DONE], then any active write-transaction on the
|
||||||
|
** destination database is rolled back. The [sqlite3_backup] object is invalid
|
||||||
|
** and may not be used following a call to sqlite3_backup_finish().
|
||||||
|
**
|
||||||
|
** The value returned by sqlite3_backup_finish is [SQLITE_OK] if no error
|
||||||
|
** occurred, regardless or whether or not sqlite3_backup_step() was called
|
||||||
|
** a sufficient number of times to complete the backup operation. Or, if
|
||||||
|
** an out-of-memory condition or IO error occured during a call to
|
||||||
|
** sqlite3_backup_step() then [SQLITE_NOMEM] or an
|
||||||
|
** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] error code
|
||||||
|
** is returned. In this case the error code and an error message are
|
||||||
|
** written to the destination [database connection].
|
||||||
|
**
|
||||||
|
** A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() is
|
||||||
|
** not a permanent error and does not affect the return value of
|
||||||
|
** sqlite3_backup_finish().
|
||||||
|
**
|
||||||
|
** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
|
||||||
|
**
|
||||||
|
** Each call to sqlite3_backup_step() sets two values stored internally
|
||||||
|
** by an [sqlite3_backup] object. The number of pages still to be backed
|
||||||
|
** up, which may be queried by sqlite3_backup_remaining(), and the total
|
||||||
|
** number of pages in the source database file, which may be queried by
|
||||||
|
** sqlite3_backup_pagecount().
|
||||||
|
**
|
||||||
|
** The values returned by these functions are only updated by
|
||||||
|
** sqlite3_backup_step(). If the source database is modified during a backup
|
||||||
|
** operation, then the values are not updated to account for any extra
|
||||||
|
** pages that need to be updated or the size of the source database file
|
||||||
|
** changing.
|
||||||
|
**
|
||||||
|
** <b>Concurrent Usage of Database Handles</b>
|
||||||
|
**
|
||||||
|
** The source [database connection] may be used by the application for other
|
||||||
|
** purposes while a backup operation is underway or being initialized.
|
||||||
|
** If SQLite is compiled and configured to support threadsafe database
|
||||||
|
** connections, then the source database connection may be used concurrently
|
||||||
|
** from within other threads.
|
||||||
|
**
|
||||||
|
** However, the application must guarantee that the destination database
|
||||||
|
** connection handle is not passed to any other API (by any thread) after
|
||||||
|
** sqlite3_backup_init() is called and before the corresponding call to
|
||||||
|
** sqlite3_backup_finish(). Unfortunately SQLite does not currently check
|
||||||
|
** for this, if the application does use the destination [database connection]
|
||||||
|
** for some other purpose during a backup operation, things may appear to
|
||||||
|
** work correctly but in fact be subtly malfunctioning. Use of the
|
||||||
|
** destination database connection while a backup is in progress might
|
||||||
|
** also cause a mutex deadlock.
|
||||||
|
**
|
||||||
|
** Furthermore, if running in [shared cache mode], the application must
|
||||||
|
** guarantee that the shared cache used by the destination database
|
||||||
|
** is not accessed while the backup is running. In practice this means
|
||||||
|
** that the application must guarantee that the file-system file being
|
||||||
|
** backed up to is not accessed by any connection within the process,
|
||||||
|
** not just the specific connection that was passed to sqlite3_backup_init().
|
||||||
|
**
|
||||||
|
** The [sqlite3_backup] object itself is partially threadsafe. Multiple
|
||||||
|
** threads may safely make multiple concurrent calls to sqlite3_backup_step().
|
||||||
|
** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
|
||||||
|
** APIs are not strictly speaking threadsafe. If they are invoked at the
|
||||||
|
** same time as another thread is invoking sqlite3_backup_step() it is
|
||||||
|
** possible that they return invalid values.
|
||||||
|
*/
|
||||||
|
sqlite3_backup *sqlite3_backup_init(
|
||||||
|
sqlite3 *pDest, /* Destination database handle */
|
||||||
|
const char *zDestName, /* Destination database name */
|
||||||
|
sqlite3 *pSource, /* Source database handle */
|
||||||
|
const char *zSourceName /* Source database name */
|
||||||
|
);
|
||||||
|
int sqlite3_backup_step(sqlite3_backup *p, int nPage);
|
||||||
|
int sqlite3_backup_finish(sqlite3_backup *p);
|
||||||
|
int sqlite3_backup_remaining(sqlite3_backup *p);
|
||||||
|
int sqlite3_backup_pagecount(sqlite3_backup *p);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Undo the hack that converts floating point types to integer for
|
** Undo the hack that converts floating point types to integer for
|
||||||
** builds on processors without floating point support.
|
** builds on processors without floating point support.
|
||||||
|
|
36
sqliteInt.h
36
sqliteInt.h
|
@ -11,7 +11,7 @@
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Internal interface definitions for SQLite.
|
** Internal interface definitions for SQLite.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqliteInt.h,v 1.824 2009/01/14 23:03:41 drh Exp $
|
** @(#) $Id: sqliteInt.h,v 1.833 2009/02/05 16:53:43 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _SQLITEINT_H_
|
#ifndef _SQLITEINT_H_
|
||||||
#define _SQLITEINT_H_
|
#define _SQLITEINT_H_
|
||||||
|
@ -1618,9 +1618,6 @@ struct WhereLevel {
|
||||||
int addrInTop; /* Top of the IN loop */
|
int addrInTop; /* Top of the IN loop */
|
||||||
} *aInLoop; /* Information about each nested IN operator */
|
} *aInLoop; /* Information about each nested IN operator */
|
||||||
} in; /* Used when plan.wsFlags&WHERE_IN_ABLE */
|
} in; /* Used when plan.wsFlags&WHERE_IN_ABLE */
|
||||||
struct {
|
|
||||||
WherePlan *aPlan; /* Plans for each term of the WHERE clause */
|
|
||||||
} or; /* Used when plan.wsFlags&WHERE_MULTI_OR */
|
|
||||||
} u;
|
} u;
|
||||||
|
|
||||||
/* The following field is really not part of the current level. But
|
/* The following field is really not part of the current level. But
|
||||||
|
@ -2150,6 +2147,30 @@ int sqlite3WalkSelectFrom(Walker*, Select*);
|
||||||
# define SQLITE_CORRUPT_BKPT SQLITE_CORRUPT
|
# define SQLITE_CORRUPT_BKPT SQLITE_CORRUPT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The following macros mimic the standard library functions toupper(),
|
||||||
|
** isspace(), isalnum(), isdigit() and isxdigit(), respectively. The
|
||||||
|
** sqlite versions only work for ASCII characters, regardless of locale.
|
||||||
|
*/
|
||||||
|
#ifdef SQLITE_ASCII
|
||||||
|
# define sqlite3Toupper(x) ((x)&~(sqlite3CtypeMap[(unsigned char)(x)]&0x20))
|
||||||
|
# define sqlite3Isspace(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x01)
|
||||||
|
# define sqlite3Isalnum(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x06)
|
||||||
|
# define sqlite3Isalpha(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x02)
|
||||||
|
# define sqlite3Isdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x04)
|
||||||
|
# define sqlite3Isxdigit(x) (sqlite3CtypeMap[(unsigned char)(x)]&0x08)
|
||||||
|
# define sqlite3Tolower(x) (sqlite3UpperToLower[(unsigned char)(x)])
|
||||||
|
#else
|
||||||
|
# include <ctype.h>
|
||||||
|
# define sqlite3Toupper(x) toupper((unsigned char)(x))
|
||||||
|
# define sqlite3Isspace(x) isspace((unsigned char)(x))
|
||||||
|
# define sqlite3Isalnum(x) isalnum((unsigned char)(x))
|
||||||
|
# define sqlite3Isalpha(x) isalpha((unsigned char)(x))
|
||||||
|
# define sqlite3Isdigit(x) isdigit((unsigned char)(x))
|
||||||
|
# define sqlite3Isxdigit(x) isxdigit((unsigned char)(x))
|
||||||
|
# define sqlite3Tolower(x) tolower((unsigned char)(x))
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Internal function prototypes
|
** Internal function prototypes
|
||||||
*/
|
*/
|
||||||
|
@ -2258,6 +2279,7 @@ int sqlite3BitvecTest(Bitvec*, u32);
|
||||||
int sqlite3BitvecSet(Bitvec*, u32);
|
int sqlite3BitvecSet(Bitvec*, u32);
|
||||||
void sqlite3BitvecClear(Bitvec*, u32);
|
void sqlite3BitvecClear(Bitvec*, u32);
|
||||||
void sqlite3BitvecDestroy(Bitvec*);
|
void sqlite3BitvecDestroy(Bitvec*);
|
||||||
|
u32 sqlite3BitvecSize(Bitvec*);
|
||||||
int sqlite3BitvecBuiltinTest(int,int*);
|
int sqlite3BitvecBuiltinTest(int,int*);
|
||||||
|
|
||||||
RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);
|
RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);
|
||||||
|
@ -2506,8 +2528,10 @@ int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
|
||||||
void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
|
void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
|
||||||
#ifndef SQLITE_AMALGAMATION
|
#ifndef SQLITE_AMALGAMATION
|
||||||
extern const unsigned char sqlite3UpperToLower[];
|
extern const unsigned char sqlite3UpperToLower[];
|
||||||
|
extern const unsigned char sqlite3CtypeMap[];
|
||||||
extern SQLITE_WSD struct Sqlite3Config sqlite3Config;
|
extern SQLITE_WSD struct Sqlite3Config sqlite3Config;
|
||||||
extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
|
extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
|
||||||
|
extern int sqlite3PendingByte;
|
||||||
#endif
|
#endif
|
||||||
void sqlite3RootPageMoved(Db*, int, int);
|
void sqlite3RootPageMoved(Db*, int, int);
|
||||||
void sqlite3Reindex(Parse*, Token*, Token*);
|
void sqlite3Reindex(Parse*, Token*, Token*);
|
||||||
|
@ -2529,6 +2553,7 @@ char sqlite3AffinityType(const Token*);
|
||||||
void sqlite3Analyze(Parse*, Token*, Token*);
|
void sqlite3Analyze(Parse*, Token*, Token*);
|
||||||
int sqlite3InvokeBusyHandler(BusyHandler*);
|
int sqlite3InvokeBusyHandler(BusyHandler*);
|
||||||
int sqlite3FindDb(sqlite3*, Token*);
|
int sqlite3FindDb(sqlite3*, Token*);
|
||||||
|
int sqlite3FindDbName(sqlite3 *, const char *);
|
||||||
int sqlite3AnalysisLoad(sqlite3*,int iDB);
|
int sqlite3AnalysisLoad(sqlite3*,int iDB);
|
||||||
void sqlite3DefaultRowEst(Index*);
|
void sqlite3DefaultRowEst(Index*);
|
||||||
void sqlite3RegisterLikeFunctions(sqlite3*, int);
|
void sqlite3RegisterLikeFunctions(sqlite3*, int);
|
||||||
|
@ -2550,6 +2575,9 @@ char *sqlite3StrAccumFinish(StrAccum*);
|
||||||
void sqlite3StrAccumReset(StrAccum*);
|
void sqlite3StrAccumReset(StrAccum*);
|
||||||
void sqlite3SelectDestInit(SelectDest*,int,int);
|
void sqlite3SelectDestInit(SelectDest*,int,int);
|
||||||
|
|
||||||
|
void sqlite3BackupRestart(sqlite3_backup *);
|
||||||
|
void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The interface to the LEMON-generated parser
|
** The interface to the LEMON-generated parser
|
||||||
*/
|
*/
|
||||||
|
|
3
table.c
3
table.c
|
@ -16,7 +16,7 @@
|
||||||
** These routines are in a separate files so that they will not be linked
|
** These routines are in a separate files so that they will not be linked
|
||||||
** if they are not used.
|
** if they are not used.
|
||||||
**
|
**
|
||||||
** $Id: table.c,v 1.38 2008/12/10 19:26:24 drh Exp $
|
** $Id: table.c,v 1.39 2009/01/19 20:49:10 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -132,6 +132,7 @@ int sqlite3_get_table(
|
||||||
*pazResult = 0;
|
*pazResult = 0;
|
||||||
if( pnColumn ) *pnColumn = 0;
|
if( pnColumn ) *pnColumn = 0;
|
||||||
if( pnRow ) *pnRow = 0;
|
if( pnRow ) *pnRow = 0;
|
||||||
|
if( pzErrMsg ) *pzErrMsg = 0;
|
||||||
res.zErrMsg = 0;
|
res.zErrMsg = 0;
|
||||||
res.nResult = 0;
|
res.nResult = 0;
|
||||||
res.nRow = 0;
|
res.nRow = 0;
|
||||||
|
|
25
tokenize.c
25
tokenize.c
|
@ -15,10 +15,9 @@
|
||||||
** individual tokens and sends those tokens one-by-one over to the
|
** individual tokens and sends those tokens one-by-one over to the
|
||||||
** parser for analysis.
|
** parser for analysis.
|
||||||
**
|
**
|
||||||
** $Id: tokenize.c,v 1.152 2008/09/01 15:52:11 drh Exp $
|
** $Id: tokenize.c,v 1.153 2009/01/20 16:53:41 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -124,7 +123,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
||||||
int i, c;
|
int i, c;
|
||||||
switch( *z ){
|
switch( *z ){
|
||||||
case ' ': case '\t': case '\n': case '\f': case '\r': {
|
case ' ': case '\t': case '\n': case '\f': case '\r': {
|
||||||
for(i=1; isspace(z[i]); i++){}
|
for(i=1; sqlite3Isspace(z[i]); i++){}
|
||||||
*tokenType = TK_SPACE;
|
*tokenType = TK_SPACE;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +257,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
||||||
}
|
}
|
||||||
case '.': {
|
case '.': {
|
||||||
#ifndef SQLITE_OMIT_FLOATING_POINT
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
if( !isdigit(z[1]) )
|
if( !sqlite3Isdigit(z[1]) )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
*tokenType = TK_DOT;
|
*tokenType = TK_DOT;
|
||||||
|
@ -270,20 +269,20 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
||||||
case '0': case '1': case '2': case '3': case '4':
|
case '0': case '1': case '2': case '3': case '4':
|
||||||
case '5': case '6': case '7': case '8': case '9': {
|
case '5': case '6': case '7': case '8': case '9': {
|
||||||
*tokenType = TK_INTEGER;
|
*tokenType = TK_INTEGER;
|
||||||
for(i=0; isdigit(z[i]); i++){}
|
for(i=0; sqlite3Isdigit(z[i]); i++){}
|
||||||
#ifndef SQLITE_OMIT_FLOATING_POINT
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
if( z[i]=='.' ){
|
if( z[i]=='.' ){
|
||||||
i++;
|
i++;
|
||||||
while( isdigit(z[i]) ){ i++; }
|
while( sqlite3Isdigit(z[i]) ){ i++; }
|
||||||
*tokenType = TK_FLOAT;
|
*tokenType = TK_FLOAT;
|
||||||
}
|
}
|
||||||
if( (z[i]=='e' || z[i]=='E') &&
|
if( (z[i]=='e' || z[i]=='E') &&
|
||||||
( isdigit(z[i+1])
|
( sqlite3Isdigit(z[i+1])
|
||||||
|| ((z[i+1]=='+' || z[i+1]=='-') && isdigit(z[i+2]))
|
|| ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))
|
||||||
)
|
)
|
||||||
){
|
){
|
||||||
i += 2;
|
i += 2;
|
||||||
while( isdigit(z[i]) ){ i++; }
|
while( sqlite3Isdigit(z[i]) ){ i++; }
|
||||||
*tokenType = TK_FLOAT;
|
*tokenType = TK_FLOAT;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -300,11 +299,11 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
||||||
}
|
}
|
||||||
case '?': {
|
case '?': {
|
||||||
*tokenType = TK_VARIABLE;
|
*tokenType = TK_VARIABLE;
|
||||||
for(i=1; isdigit(z[i]); i++){}
|
for(i=1; sqlite3Isdigit(z[i]); i++){}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
case '#': {
|
case '#': {
|
||||||
for(i=1; isdigit(z[i]); i++){}
|
for(i=1; sqlite3Isdigit(z[i]); i++){}
|
||||||
if( i>1 ){
|
if( i>1 ){
|
||||||
/* Parameters of the form #NNN (where NNN is a number) are used
|
/* Parameters of the form #NNN (where NNN is a number) are used
|
||||||
** internally by sqlite3NestedParse. */
|
** internally by sqlite3NestedParse. */
|
||||||
|
@ -328,7 +327,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
||||||
}else if( c=='(' && n>0 ){
|
}else if( c=='(' && n>0 ){
|
||||||
do{
|
do{
|
||||||
i++;
|
i++;
|
||||||
}while( (c=z[i])!=0 && !isspace(c) && c!=')' );
|
}while( (c=z[i])!=0 && !sqlite3Isspace(c) && c!=')' );
|
||||||
if( c==')' ){
|
if( c==')' ){
|
||||||
i++;
|
i++;
|
||||||
}else{
|
}else{
|
||||||
|
@ -350,7 +349,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
||||||
if( z[1]=='\'' ){
|
if( z[1]=='\'' ){
|
||||||
*tokenType = TK_BLOB;
|
*tokenType = TK_BLOB;
|
||||||
for(i=2; (c=z[i])!=0 && c!='\''; i++){
|
for(i=2; (c=z[i])!=0 && c!='\''; i++){
|
||||||
if( !isxdigit(c) ){
|
if( !sqlite3Isxdigit(c) ){
|
||||||
*tokenType = TK_ILLEGAL;
|
*tokenType = TK_ILLEGAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
util.c
26
util.c
|
@ -14,12 +14,10 @@
|
||||||
** 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.246 2009/01/10 16:15:22 drh Exp $
|
** $Id: util.c,v 1.248 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Routine needed to support the testcase() macro.
|
** Routine needed to support the testcase() macro.
|
||||||
|
@ -256,23 +254,23 @@ int sqlite3IsNumber(const char *z, int *realnum, u8 enc){
|
||||||
int incr = (enc==SQLITE_UTF8?1:2);
|
int incr = (enc==SQLITE_UTF8?1:2);
|
||||||
if( enc==SQLITE_UTF16BE ) z++;
|
if( enc==SQLITE_UTF16BE ) z++;
|
||||||
if( *z=='-' || *z=='+' ) z += incr;
|
if( *z=='-' || *z=='+' ) z += incr;
|
||||||
if( !isdigit(*(u8*)z) ){
|
if( !sqlite3Isdigit(*z) ){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
z += incr;
|
z += incr;
|
||||||
if( realnum ) *realnum = 0;
|
if( realnum ) *realnum = 0;
|
||||||
while( isdigit(*(u8*)z) ){ z += incr; }
|
while( sqlite3Isdigit(*z) ){ z += incr; }
|
||||||
if( *z=='.' ){
|
if( *z=='.' ){
|
||||||
z += incr;
|
z += incr;
|
||||||
if( !isdigit(*(u8*)z) ) return 0;
|
if( !sqlite3Isdigit(*z) ) return 0;
|
||||||
while( isdigit(*(u8*)z) ){ z += incr; }
|
while( sqlite3Isdigit(*z) ){ z += incr; }
|
||||||
if( realnum ) *realnum = 1;
|
if( realnum ) *realnum = 1;
|
||||||
}
|
}
|
||||||
if( *z=='e' || *z=='E' ){
|
if( *z=='e' || *z=='E' ){
|
||||||
z += incr;
|
z += incr;
|
||||||
if( *z=='+' || *z=='-' ) z += incr;
|
if( *z=='+' || *z=='-' ) z += incr;
|
||||||
if( !isdigit(*(u8*)z) ) return 0;
|
if( !sqlite3Isdigit(*z) ) return 0;
|
||||||
while( isdigit(*(u8*)z) ){ z += incr; }
|
while( sqlite3Isdigit(*z) ){ z += incr; }
|
||||||
if( realnum ) *realnum = 1;
|
if( realnum ) *realnum = 1;
|
||||||
}
|
}
|
||||||
return *z==0;
|
return *z==0;
|
||||||
|
@ -296,7 +294,7 @@ int sqlite3AtoF(const char *z, double *pResult){
|
||||||
const char *zBegin = z;
|
const char *zBegin = z;
|
||||||
LONGDOUBLE_TYPE v1 = 0.0;
|
LONGDOUBLE_TYPE v1 = 0.0;
|
||||||
int nSignificant = 0;
|
int nSignificant = 0;
|
||||||
while( isspace(*(u8*)z) ) z++;
|
while( sqlite3Isspace(*z) ) z++;
|
||||||
if( *z=='-' ){
|
if( *z=='-' ){
|
||||||
sign = -1;
|
sign = -1;
|
||||||
z++;
|
z++;
|
||||||
|
@ -306,7 +304,7 @@ int sqlite3AtoF(const char *z, double *pResult){
|
||||||
while( z[0]=='0' ){
|
while( z[0]=='0' ){
|
||||||
z++;
|
z++;
|
||||||
}
|
}
|
||||||
while( isdigit(*(u8*)z) ){
|
while( sqlite3Isdigit(*z) ){
|
||||||
v1 = v1*10.0 + (*z - '0');
|
v1 = v1*10.0 + (*z - '0');
|
||||||
z++;
|
z++;
|
||||||
nSignificant++;
|
nSignificant++;
|
||||||
|
@ -320,7 +318,7 @@ int sqlite3AtoF(const char *z, double *pResult){
|
||||||
z++;
|
z++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( isdigit(*(u8*)z) ){
|
while( sqlite3Isdigit(*z) ){
|
||||||
if( nSignificant<18 ){
|
if( nSignificant<18 ){
|
||||||
v1 = v1*10.0 + (*z - '0');
|
v1 = v1*10.0 + (*z - '0');
|
||||||
divisor *= 10.0;
|
divisor *= 10.0;
|
||||||
|
@ -341,7 +339,7 @@ int sqlite3AtoF(const char *z, double *pResult){
|
||||||
}else if( *z=='+' ){
|
}else if( *z=='+' ){
|
||||||
z++;
|
z++;
|
||||||
}
|
}
|
||||||
while( isdigit(*(u8*)z) ){
|
while( sqlite3Isdigit(*z) ){
|
||||||
eval = eval*10 + *z - '0';
|
eval = eval*10 + *z - '0';
|
||||||
z++;
|
z++;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +398,7 @@ int sqlite3Atoi64(const char *zNum, i64 *pNum){
|
||||||
int neg;
|
int neg;
|
||||||
int i, c;
|
int i, c;
|
||||||
const char *zStart;
|
const char *zStart;
|
||||||
while( isspace(*(u8*)zNum) ) zNum++;
|
while( sqlite3Isspace(*zNum) ) zNum++;
|
||||||
if( *zNum=='-' ){
|
if( *zNum=='-' ){
|
||||||
neg = 1;
|
neg = 1;
|
||||||
zNum++;
|
zNum++;
|
||||||
|
|
13
vacuum.c
13
vacuum.c
|
@ -14,7 +14,7 @@
|
||||||
** Most of the code in this file may be omitted by defining the
|
** Most of the code in this file may be omitted by defining the
|
||||||
** SQLITE_OMIT_VACUUM macro.
|
** SQLITE_OMIT_VACUUM macro.
|
||||||
**
|
**
|
||||||
** $Id: vacuum.c,v 1.84 2008/11/17 19:18:55 danielk1977 Exp $
|
** $Id: vacuum.c,v 1.86 2009/02/03 16:51:25 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
|
@ -91,17 +91,17 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
|
||||||
int isMemDb; /* True is vacuuming a :memory: database */
|
int isMemDb; /* True is vacuuming a :memory: database */
|
||||||
int nRes;
|
int nRes;
|
||||||
|
|
||||||
|
if( !db->autoCommit ){
|
||||||
|
sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
|
||||||
|
return SQLITE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Save the current value of the write-schema flag before setting it. */
|
/* Save the current value of the write-schema flag before setting it. */
|
||||||
saved_flags = db->flags;
|
saved_flags = db->flags;
|
||||||
saved_nChange = db->nChange;
|
saved_nChange = db->nChange;
|
||||||
saved_nTotalChange = db->nTotalChange;
|
saved_nTotalChange = db->nTotalChange;
|
||||||
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
|
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
|
||||||
|
|
||||||
if( !db->autoCommit ){
|
|
||||||
sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
|
|
||||||
rc = SQLITE_ERROR;
|
|
||||||
goto end_of_vacuum;
|
|
||||||
}
|
|
||||||
pMain = db->aDb[0].pBt;
|
pMain = db->aDb[0].pBt;
|
||||||
pMainPager = sqlite3BtreePager(pMain);
|
pMainPager = sqlite3BtreePager(pMain);
|
||||||
isMemDb = sqlite3PagerFile(pMainPager)->pMethods==0;
|
isMemDb = sqlite3PagerFile(pMainPager)->pMethods==0;
|
||||||
|
@ -265,7 +265,6 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
|
||||||
#ifndef SQLITE_OMIT_AUTOVACUUM
|
#ifndef SQLITE_OMIT_AUTOVACUUM
|
||||||
sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
|
sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
|
||||||
#endif
|
#endif
|
||||||
rc = sqlite3BtreeCommit(pMain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
|
|
16
vdbe.c
16
vdbe.c
|
@ -43,10 +43,9 @@
|
||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.811 2009/01/14 00:55:10 drh Exp $
|
** $Id: vdbe.c,v 1.817 2009/02/16 17:55:47 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1229,7 +1228,8 @@ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */
|
||||||
case OP_Subtract: b -= a; break;
|
case OP_Subtract: b -= a; break;
|
||||||
case OP_Multiply: b *= a; break;
|
case OP_Multiply: b *= a; break;
|
||||||
case OP_Divide: {
|
case OP_Divide: {
|
||||||
if( a==0.0 ) goto arithmetic_result_is_null;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
if( a==(double)0 ) goto arithmetic_result_is_null;
|
||||||
b /= a;
|
b /= a;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1874,7 +1874,7 @@ case OP_IfNot: { /* jump, in1 */
|
||||||
c = pOp->p3;
|
c = pOp->p3;
|
||||||
}else{
|
}else{
|
||||||
#ifdef SQLITE_OMIT_FLOATING_POINT
|
#ifdef SQLITE_OMIT_FLOATING_POINT
|
||||||
c = sqlite3VdbeIntValue(pIn1);
|
c = sqlite3VdbeIntValue(pIn1)!=0;
|
||||||
#else
|
#else
|
||||||
c = sqlite3VdbeRealValue(pIn1)!=0.0;
|
c = sqlite3VdbeRealValue(pIn1)!=0.0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -3490,7 +3490,7 @@ case OP_NewRowid: { /* out2-prerelease */
|
||||||
** larger than the previous rowid. This has been shown experimentally
|
** larger than the previous rowid. This has been shown experimentally
|
||||||
** to double the speed of the COPY operation.
|
** to double the speed of the COPY operation.
|
||||||
*/
|
*/
|
||||||
int res, rx=SQLITE_OK, cnt;
|
int res=0, rx=SQLITE_OK, cnt;
|
||||||
i64 x;
|
i64 x;
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
if( (sqlite3BtreeFlags(pC->pCursor)&(BTREE_INTKEY|BTREE_ZERODATA)) !=
|
if( (sqlite3BtreeFlags(pC->pCursor)&(BTREE_INTKEY|BTREE_ZERODATA)) !=
|
||||||
|
@ -3714,7 +3714,7 @@ case OP_Insert: {
|
||||||
*/
|
*/
|
||||||
case OP_Delete: {
|
case OP_Delete: {
|
||||||
int i = pOp->p1;
|
int i = pOp->p1;
|
||||||
i64 iKey;
|
i64 iKey = 0;
|
||||||
VdbeCursor *pC;
|
VdbeCursor *pC;
|
||||||
|
|
||||||
assert( i>=0 && i<p->nCursor );
|
assert( i>=0 && i<p->nCursor );
|
||||||
|
@ -4025,7 +4025,7 @@ case OP_Next: { /* jump */
|
||||||
/* Opcode: IdxInsert P1 P2 P3 * *
|
/* Opcode: IdxInsert P1 P2 P3 * *
|
||||||
**
|
**
|
||||||
** Register P2 holds a SQL index key made using the
|
** Register P2 holds a SQL index key made using the
|
||||||
** MakeIdxRec instructions. This opcode writes that key
|
** MakeRecord instructions. This opcode writes that key
|
||||||
** into the index P1. Data for the entry is nil.
|
** into the index P1. Data for the entry is nil.
|
||||||
**
|
**
|
||||||
** P3 is a flag that provides a hint to the b-tree layer that this
|
** P3 is a flag that provides a hint to the b-tree layer that this
|
||||||
|
@ -4092,7 +4092,7 @@ case OP_IdxDelete: {
|
||||||
** the end of the index key pointed to by cursor P1. This integer should be
|
** the end of the index key pointed to by cursor P1. This integer should be
|
||||||
** the rowid of the table entry to which this index entry points.
|
** the rowid of the table entry to which this index entry points.
|
||||||
**
|
**
|
||||||
** See also: Rowid, MakeIdxRec.
|
** See also: Rowid, MakeRecord.
|
||||||
*/
|
*/
|
||||||
case OP_IdxRowid: { /* out2-prerelease */
|
case OP_IdxRowid: { /* out2-prerelease */
|
||||||
int i = pOp->p1;
|
int i = pOp->p1;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
** 6000 lines long) it was split up into several smaller files and
|
** 6000 lines long) it was split up into several smaller files and
|
||||||
** this header information was factored out.
|
** this header information was factored out.
|
||||||
**
|
**
|
||||||
** $Id: vdbeInt.h,v 1.161 2009/01/05 18:02:27 drh Exp $
|
** $Id: vdbeInt.h,v 1.162 2009/02/03 15:39:01 drh Exp $
|
||||||
*/
|
*/
|
||||||
#ifndef _VDBEINT_H_
|
#ifndef _VDBEINT_H_
|
||||||
#define _VDBEINT_H_
|
#define _VDBEINT_H_
|
||||||
|
@ -382,9 +382,6 @@ int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
|
||||||
int sqlite3VdbeReleaseBuffers(Vdbe *p);
|
int sqlite3VdbeReleaseBuffers(Vdbe *p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NDEBUG
|
|
||||||
void sqlite3VdbeMemSanity(Mem*);
|
|
||||||
#endif
|
|
||||||
int sqlite3VdbeMemTranslate(Mem*, u8);
|
int sqlite3VdbeMemTranslate(Mem*, u8);
|
||||||
#ifdef SQLITE_DEBUG
|
#ifdef SQLITE_DEBUG
|
||||||
void sqlite3VdbePrintSql(Vdbe*);
|
void sqlite3VdbePrintSql(Vdbe*);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
** This file contains code use to implement APIs that are part of the
|
** This file contains code use to implement APIs that are part of the
|
||||||
** VDBE.
|
** VDBE.
|
||||||
**
|
**
|
||||||
** $Id: vdbeapi.c,v 1.150 2008/12/10 18:03:47 drh Exp $
|
** $Id: vdbeapi.c,v 1.151 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
|
@ -752,7 +752,8 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){
|
||||||
vals = sqlite3_data_count(pStmt);
|
vals = sqlite3_data_count(pStmt);
|
||||||
pOut = &pVm->pResultSet[i];
|
pOut = &pVm->pResultSet[i];
|
||||||
}else{
|
}else{
|
||||||
static const Mem nullMem = {{0}, 0.0, 0, "", 0, MEM_Null, SQLITE_NULL, 0, 0, 0 };
|
/* ((double)0) In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
static const Mem nullMem = {{0}, (double)0, 0, "", 0, MEM_Null, SQLITE_NULL, 0, 0, 0 };
|
||||||
if( pVm->db ){
|
if( pVm->db ){
|
||||||
sqlite3_mutex_enter(pVm->db->mutex);
|
sqlite3_mutex_enter(pVm->db->mutex);
|
||||||
sqlite3Error(pVm->db, SQLITE_RANGE, 0);
|
sqlite3Error(pVm->db, SQLITE_RANGE, 0);
|
||||||
|
|
19
vdbeaux.c
19
vdbeaux.c
|
@ -14,10 +14,9 @@
|
||||||
** to version 2.8.7, all this code was combined into the vdbe.c source file.
|
** to version 2.8.7, all this code was combined into the vdbe.c source file.
|
||||||
** But that file was getting too big so this subroutines were split out.
|
** But that file was getting too big so this subroutines were split out.
|
||||||
**
|
**
|
||||||
** $Id: vdbeaux.c,v 1.430 2009/01/07 08:12:16 danielk1977 Exp $
|
** $Id: vdbeaux.c,v 1.435 2009/02/03 16:51:25 danielk1977 Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -963,7 +962,7 @@ void sqlite3VdbePrintSql(Vdbe *p){
|
||||||
pOp = &p->aOp[0];
|
pOp = &p->aOp[0];
|
||||||
if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){
|
if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){
|
||||||
const char *z = pOp->p4.z;
|
const char *z = pOp->p4.z;
|
||||||
while( isspace(*(u8*)z) ) z++;
|
while( sqlite3Isspace(*z) ) z++;
|
||||||
printf("SQL: [%s]\n", z);
|
printf("SQL: [%s]\n", z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -983,9 +982,9 @@ void sqlite3VdbeIOTraceSql(Vdbe *p){
|
||||||
int i, j;
|
int i, j;
|
||||||
char z[1000];
|
char z[1000];
|
||||||
sqlite3_snprintf(sizeof(z), z, "%s", pOp->p4.z);
|
sqlite3_snprintf(sizeof(z), z, "%s", pOp->p4.z);
|
||||||
for(i=0; isspace((unsigned char)z[i]); i++){}
|
for(i=0; sqlite3Isspace(z[i]); i++){}
|
||||||
for(j=0; z[i]; i++){
|
for(j=0; z[i]; i++){
|
||||||
if( isspace((unsigned char)z[i]) ){
|
if( sqlite3Isspace(z[i]) ){
|
||||||
if( z[i-1]!=' ' ){
|
if( z[i-1]!=' ' ){
|
||||||
z[j++] = ' ';
|
z[j++] = ' ';
|
||||||
}
|
}
|
||||||
|
@ -1299,7 +1298,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||||
if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))
|
if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))
|
||||||
|| nTrans<=1
|
|| nTrans<=1
|
||||||
){
|
){
|
||||||
for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
|
for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
|
||||||
Btree *pBt = db->aDb[i].pBt;
|
Btree *pBt = db->aDb[i].pBt;
|
||||||
if( pBt ){
|
if( pBt ){
|
||||||
rc = sqlite3BtreeCommitPhaseOne(pBt, 0);
|
rc = sqlite3BtreeCommitPhaseOne(pBt, 0);
|
||||||
|
@ -1388,10 +1387,10 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
|
||||||
/* Sync the master journal file. If the IOCAP_SEQUENTIAL device
|
/* Sync the master journal file. If the IOCAP_SEQUENTIAL device
|
||||||
** flag is set this is not required.
|
** flag is set this is not required.
|
||||||
*/
|
*/
|
||||||
zMainFile = sqlite3BtreeGetDirname(db->aDb[0].pBt);
|
if( needSync
|
||||||
if( (needSync
|
&& 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)
|
||||||
&& (0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL))
|
&& SQLITE_OK!=(rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))
|
||||||
&& (rc=sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))!=SQLITE_OK) ){
|
){
|
||||||
sqlite3OsCloseFree(pMaster);
|
sqlite3OsCloseFree(pMaster);
|
||||||
sqlite3OsDelete(pVfs, zMaster, 0);
|
sqlite3OsDelete(pVfs, zMaster, 0);
|
||||||
sqlite3DbFree(db, zMaster);
|
sqlite3DbFree(db, zMaster);
|
||||||
|
|
64
vdbemem.c
64
vdbemem.c
|
@ -15,10 +15,9 @@
|
||||||
** only within the VDBE. Interface routines refer to a Mem using the
|
** only within the VDBE. Interface routines refer to a Mem using the
|
||||||
** name sqlite_value
|
** name sqlite_value
|
||||||
**
|
**
|
||||||
** $Id: vdbemem.c,v 1.134 2009/01/05 22:30:39 drh Exp $
|
** $Id: vdbemem.c,v 1.137 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -374,17 +373,20 @@ double sqlite3VdbeRealValue(Mem *pMem){
|
||||||
}else if( pMem->flags & MEM_Int ){
|
}else if( pMem->flags & MEM_Int ){
|
||||||
return (double)pMem->u.i;
|
return (double)pMem->u.i;
|
||||||
}else if( pMem->flags & (MEM_Str|MEM_Blob) ){
|
}else if( pMem->flags & (MEM_Str|MEM_Blob) ){
|
||||||
double val = 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
double val = (double)0;
|
||||||
pMem->flags |= MEM_Str;
|
pMem->flags |= MEM_Str;
|
||||||
if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
|
if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
|
||||||
|| sqlite3VdbeMemNulTerminate(pMem) ){
|
|| sqlite3VdbeMemNulTerminate(pMem) ){
|
||||||
return 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
return (double)0;
|
||||||
}
|
}
|
||||||
assert( pMem->z );
|
assert( pMem->z );
|
||||||
sqlite3AtoF(pMem->z, &val);
|
sqlite3AtoF(pMem->z, &val);
|
||||||
return val;
|
return val;
|
||||||
}else{
|
}else{
|
||||||
return 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
return (double)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -870,55 +872,6 @@ int sqlite3VdbeMemFromBtree(
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
** Perform various checks on the memory cell pMem. An assert() will
|
|
||||||
** fail if pMem is internally inconsistent.
|
|
||||||
*/
|
|
||||||
void sqlite3VdbeMemSanity(Mem *pMem){
|
|
||||||
int flags = pMem->flags;
|
|
||||||
assert( flags!=0 ); /* Must define some type */
|
|
||||||
if( flags & (MEM_Str|MEM_Blob) ){
|
|
||||||
int x = flags & (MEM_Static|MEM_Dyn|MEM_Ephem|MEM_Short);
|
|
||||||
assert( x!=0 ); /* Strings must define a string subtype */
|
|
||||||
assert( (x & (x-1))==0 ); /* Only one string subtype can be defined */
|
|
||||||
assert( pMem->z!=0 ); /* Strings must have a value */
|
|
||||||
/* Mem.z points to Mem.zShort iff the subtype is MEM_Short */
|
|
||||||
assert( (x & MEM_Short)==0 || pMem->z==pMem->zShort );
|
|
||||||
assert( (x & MEM_Short)!=0 || pMem->z!=pMem->zShort );
|
|
||||||
/* No destructor unless there is MEM_Dyn */
|
|
||||||
assert( pMem->xDel==0 || (pMem->flags & MEM_Dyn)!=0 );
|
|
||||||
|
|
||||||
if( (flags & MEM_Str) ){
|
|
||||||
assert( pMem->enc==SQLITE_UTF8 ||
|
|
||||||
pMem->enc==SQLITE_UTF16BE ||
|
|
||||||
pMem->enc==SQLITE_UTF16LE
|
|
||||||
);
|
|
||||||
/* If the string is UTF-8 encoded and nul terminated, then pMem->n
|
|
||||||
** must be the length of the string. (Later:) If the database file
|
|
||||||
** has been corrupted, '\000' characters might have been inserted
|
|
||||||
** into the middle of the string. In that case, the sqlite3Strlen30()
|
|
||||||
** might be less.
|
|
||||||
*/
|
|
||||||
if( pMem->enc==SQLITE_UTF8 && (flags & MEM_Term) ){
|
|
||||||
assert( sqlite3Strlen30(pMem->z)<=pMem->n );
|
|
||||||
assert( pMem->z[pMem->n]==0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
/* Cannot define a string subtype for non-string objects */
|
|
||||||
assert( (pMem->flags & (MEM_Static|MEM_Dyn|MEM_Ephem|MEM_Short))==0 );
|
|
||||||
assert( pMem->xDel==0 );
|
|
||||||
}
|
|
||||||
/* MEM_Null excludes all other types */
|
|
||||||
assert( (pMem->flags&(MEM_Str|MEM_Int|MEM_Real|MEM_Blob))==0
|
|
||||||
|| (pMem->flags&MEM_Null)==0 );
|
|
||||||
/* If the MEM is both real and integer, the values are equal */
|
|
||||||
assert( (pMem->flags & (MEM_Int|MEM_Real))!=(MEM_Int|MEM_Real)
|
|
||||||
|| pMem->r==pMem->u.i );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This function is only available internally, it is not part of the
|
/* This function is only available internally, it is not part of the
|
||||||
** external API. It works in a similar way to sqlite3_value_text(),
|
** external API. It works in a similar way to sqlite3_value_text(),
|
||||||
** except the data returned is in the encoding specified by the second
|
** except the data returned is in the encoding specified by the second
|
||||||
|
@ -1019,7 +972,8 @@ int sqlite3ValueFromExpr(
|
||||||
}else if( op==TK_UMINUS ) {
|
}else if( op==TK_UMINUS ) {
|
||||||
if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){
|
if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){
|
||||||
pVal->u.i = -1 * pVal->u.i;
|
pVal->u.i = -1 * pVal->u.i;
|
||||||
pVal->r = -1.0 * pVal->r;
|
/* (double)-1 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
pVal->r = (double)-1 * pVal->r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef SQLITE_OMIT_BLOB_LITERAL
|
#ifndef SQLITE_OMIT_BLOB_LITERAL
|
||||||
|
|
23
where.c
23
where.c
|
@ -16,7 +16,7 @@
|
||||||
** so is applicable. Because this module is responsible for selecting
|
** so is applicable. Because this module is responsible for selecting
|
||||||
** indices, you might also think of this module as the "query optimizer".
|
** indices, you might also think of this module as the "query optimizer".
|
||||||
**
|
**
|
||||||
** $Id: where.c,v 1.364 2009/01/14 00:55:10 drh Exp $
|
** $Id: where.c,v 1.368 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
@ -888,7 +888,7 @@ static void exprAnalyzeOrTerm(
|
||||||
if( chngToIN ){
|
if( chngToIN ){
|
||||||
int okToChngToIN = 0; /* True if the conversion to IN is valid */
|
int okToChngToIN = 0; /* True if the conversion to IN is valid */
|
||||||
int iColumn = -1; /* Column index on lhs of IN operator */
|
int iColumn = -1; /* Column index on lhs of IN operator */
|
||||||
int iCursor; /* Table cursor common to all terms */
|
int iCursor = -1; /* Table cursor common to all terms */
|
||||||
int j = 0; /* Loop counter */
|
int j = 0; /* Loop counter */
|
||||||
|
|
||||||
/* Search for a table and column that appears on one side or the
|
/* Search for a table and column that appears on one side or the
|
||||||
|
@ -1547,7 +1547,8 @@ static double bestVirtualIndex(
|
||||||
+ sizeof(*pIdxOrderBy)*nOrderBy );
|
+ sizeof(*pIdxOrderBy)*nOrderBy );
|
||||||
if( pIdxInfo==0 ){
|
if( pIdxInfo==0 ){
|
||||||
sqlite3ErrorMsg(pParse, "out of memory");
|
sqlite3ErrorMsg(pParse, "out of memory");
|
||||||
return 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
return (double)0;
|
||||||
}
|
}
|
||||||
*ppIdxInfo = pIdxInfo;
|
*ppIdxInfo = pIdxInfo;
|
||||||
|
|
||||||
|
@ -1650,7 +1651,8 @@ static double bestVirtualIndex(
|
||||||
pIdxInfo->idxNum = 0;
|
pIdxInfo->idxNum = 0;
|
||||||
pIdxInfo->needToFreeIdxStr = 0;
|
pIdxInfo->needToFreeIdxStr = 0;
|
||||||
pIdxInfo->orderByConsumed = 0;
|
pIdxInfo->orderByConsumed = 0;
|
||||||
pIdxInfo->estimatedCost = SQLITE_BIG_DBL / 2.0;
|
/* ((double)2) In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
pIdxInfo->estimatedCost = SQLITE_BIG_DBL / ((double)2);
|
||||||
nOrderBy = pIdxInfo->nOrderBy;
|
nOrderBy = pIdxInfo->nOrderBy;
|
||||||
if( pIdxInfo->nOrderBy && !orderByUsable ){
|
if( pIdxInfo->nOrderBy && !orderByUsable ){
|
||||||
*(int*)&pIdxInfo->nOrderBy = 0;
|
*(int*)&pIdxInfo->nOrderBy = 0;
|
||||||
|
@ -1679,7 +1681,8 @@ static double bestVirtualIndex(
|
||||||
if( !pIdxInfo->aConstraint[i].usable && pUsage[i].argvIndex>0 ){
|
if( !pIdxInfo->aConstraint[i].usable && pUsage[i].argvIndex>0 ){
|
||||||
sqlite3ErrorMsg(pParse,
|
sqlite3ErrorMsg(pParse,
|
||||||
"table %s: xBestIndex returned an invalid plan", pTab->zName);
|
"table %s: xBestIndex returned an invalid plan", pTab->zName);
|
||||||
return 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
return (double)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1924,7 +1927,7 @@ static void bestIndex(
|
||||||
wsFlags |= WHERE_COLUMN_IN;
|
wsFlags |= WHERE_COLUMN_IN;
|
||||||
if( pExpr->pSelect!=0 ){
|
if( pExpr->pSelect!=0 ){
|
||||||
inMultiplier *= 25;
|
inMultiplier *= 25;
|
||||||
}else if( ALWAYS(pExpr->pList) ){
|
}else if( pExpr->pList ){
|
||||||
inMultiplier *= pExpr->pList->nExpr + 1;
|
inMultiplier *= pExpr->pList->nExpr + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3092,12 +3095,14 @@ WhereInfo *sqlite3WhereBegin(
|
||||||
sCost.plan.wsFlags = WHERE_VIRTUALTABLE | WHERE_ORDERBY;
|
sCost.plan.wsFlags = WHERE_VIRTUALTABLE | WHERE_ORDERBY;
|
||||||
}
|
}
|
||||||
sCost.plan.nEq = 0;
|
sCost.plan.nEq = 0;
|
||||||
if( (SQLITE_BIG_DBL/2.0)<sCost.rCost ){
|
/* (double)2 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
if( (SQLITE_BIG_DBL/((double)2))<sCost.rCost ){
|
||||||
/* The cost is not allowed to be larger than SQLITE_BIG_DBL (the
|
/* The cost is not allowed to be larger than SQLITE_BIG_DBL (the
|
||||||
** inital value of lowestCost in this loop. If it is, then
|
** inital value of lowestCost in this loop. If it is, then
|
||||||
** the (cost<lowestCost) test below will never be true.
|
** the (cost<lowestCost) test below will never be true.
|
||||||
*/
|
*/
|
||||||
sCost.rCost = (SQLITE_BIG_DBL/2.0);
|
/* (double)2 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
sCost.rCost = (SQLITE_BIG_DBL/((double)2));
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
#endif
|
#endif
|
||||||
|
@ -3127,7 +3132,7 @@ WhereInfo *sqlite3WhereBegin(
|
||||||
pLevel->iIdxCur = -1;
|
pLevel->iIdxCur = -1;
|
||||||
}
|
}
|
||||||
notReady &= ~getMask(pMaskSet, pTabList->a[bestJ].iCursor);
|
notReady &= ~getMask(pMaskSet, pTabList->a[bestJ].iCursor);
|
||||||
pLevel->iFrom = bestJ;
|
pLevel->iFrom = (u8)bestJ;
|
||||||
|
|
||||||
/* Check that if the table scanned by this loop iteration had an
|
/* Check that if the table scanned by this loop iteration had an
|
||||||
** INDEXED BY clause attached to it, that the named index is being
|
** INDEXED BY clause attached to it, that the named index is being
|
||||||
|
|
Loading…
Add table
Reference in a new issue