1
0
Fork 0
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:
Kenichi Ishigaki 2009-03-28 03:18:33 +00:00
parent c2bbe22fd5
commit 61a5ea496f
52 changed files with 4156 additions and 3004 deletions

View file

@ -20,3 +20,4 @@ output/.*
~$
^sqlite\-
\.svn
^bugs/

15
alter.c
View file

@ -12,10 +12,9 @@
** This file contains C code routines that used to generate VDBE code
** 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 <ctype.h>
/*
** 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) );
iDb = sqlite3SchemaToIndex(db, pNew->pSchema);
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];
pDflt = pCol->pDflt;
pTab = sqlite3FindTable(db, zTab, zDb);
@ -513,7 +512,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n);
if( zCol ){
char *zEnd = &zCol[pColDef->n-1];
while( (zEnd>zCol && *zEnd==';') || isspace(*(unsigned char *)zEnd) ){
while( (zEnd>zCol && *zEnd==';') || sqlite3Isspace(*zEnd) ){
*zEnd-- = '\0';
}
sqlite3NestedParse(pParse,
@ -584,7 +583,11 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
/* 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));
if( !pNew ) goto exit_begin_add_column;
@ -596,7 +599,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
nAlloc = (((pNew->nCol-1)/8)*8)+8;
assert( nAlloc>=pNew->nCol && nAlloc%8==0 && nAlloc-pNew->nCol<8 );
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 ){
db->mallocFailed = 1;
goto exit_begin_add_column;

View file

@ -11,7 +11,7 @@
*************************************************************************
** 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
#include "sqliteInt.h"
@ -416,10 +416,15 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
/* Load new statistics out of the sqlite_stat1 table */
zSql = sqlite3MPrintf(db, "SELECT idx, stat FROM %Q.sqlite_stat1",
sInfo.zDatabase);
if( zSql==0 ){
rc = SQLITE_NOMEM;
}else{
(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;
}

View file

@ -11,7 +11,7 @@
*************************************************************************
** 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"
@ -265,7 +265,7 @@ static void detachFunc(
"cannot DETACH database within transaction");
goto detach_error;
}
if( sqlite3BtreeIsInReadTrans(pDb->pBt) ){
if( sqlite3BtreeIsInReadTrans(pDb->pBt) || sqlite3BtreeIsInBackup(pDb->pBt) ){
sqlite3_snprintf(sizeof(zErr),zErr, "database %s is locked", zName);
goto detach_error;
}

View file

@ -34,7 +34,7 @@
** 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.
**
** @(#) $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"
@ -275,6 +275,14 @@ void sqlite3BitvecDestroy(Bitvec *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
/*
** Let V[] be an array of unsigned characters sufficient to hold

565
btree.c
View file

@ -9,7 +9,7 @@
** 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.
** See the header comment on "btreeInt.h" for additional information.
@ -282,6 +282,80 @@ static void invalidateAllOverflowCache(BtShared *pBt){
#define invalidateAllOverflowCache(x)
#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
** and BtCursor.pKey. The cursor's state is set to CURSOR_REQUIRESEEK.
@ -1100,6 +1174,21 @@ int sqlite3BtreeGetPage(
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
** error, return ((unsigned int)-1).
@ -1124,7 +1213,6 @@ static int getAndInitPage(
MemPage **ppPage /* Write the page pointer here */
){
int rc;
DbPage *pDbPage;
MemPage *pPage;
assert( sqlite3_mutex_held(pBt->mutex) );
@ -1137,10 +1225,9 @@ static int getAndInitPage(
** pagerPagecount() to make sure pgno is within limits, which results
** in a measureable performance improvements.
*/
pDbPage = sqlite3PagerLookup(pBt->pPager, pgno);
if( pDbPage ){
*ppPage = pPage = btreePageLookup(pBt, pgno);
if( pPage ){
/* Page is already in cache */
*ppPage = pPage = btreePageFromDbPage(pDbPage, pgno, pBt);
rc = SQLITE_OK;
}else{
/* Page not in cache. Acquire it. */
@ -2013,7 +2100,7 @@ int sqlite3BtreeBeginTrans(Btree *p, int wrflag){
if( pBt->readOnly ){
rc = SQLITE_READONLY;
}else{
rc = sqlite3PagerBegin(pBt->pPage1->pDbPage, wrflag>1);
rc = sqlite3PagerBegin(pBt->pPager, wrflag>1);
if( rc==SQLITE_OK ){
rc = newDatabase(pBt);
}
@ -2372,7 +2459,7 @@ int sqlite3BtreeIncrVacuum(Btree *p){
rc = SQLITE_DONE;
}else{
invalidateAllOverflowCache(pBt);
rc = incrVacuumStep(pBt, 0, sqlite3PagerImageSize(pBt->pPager));
rc = incrVacuumStep(pBt, 0, pagerPagecount(pBt));
}
sqlite3BtreeLeave(p);
return rc;
@ -2540,6 +2627,7 @@ int sqlite3BtreeCommitPhaseTwo(Btree *p){
/* Set the handles current transaction state to TRANS_NONE and unlock
** the pager if this call closed the only read or write transaction.
*/
btreeClearHasContent(pBt);
p->inTrans = TRANS_NONE;
unlockBtreeIfUnused(pBt);
@ -2675,6 +2763,7 @@ int sqlite3BtreeRollback(Btree *p){
}
}
btreeClearHasContent(pBt);
p->inTrans = TRANS_NONE;
pBt->inStmt = 0;
unlockBtreeIfUnused(pBt);
@ -3082,34 +3171,29 @@ int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
**
** If an error occurs an SQLite error code is returned. Otherwise:
**
** Unless pPgnoNext is NULL, the page number of the next overflow
** page in the linked list is written to *pPgnoNext. If page ovfl
** is the last page in its linked list, *pPgnoNext is set to zero.
** The page number of the next overflow page in the linked list is
** written to *pPgnoNext. If page ovfl is the last page in its linked
** list, *pPgnoNext is set to zero.
**
** If ppPage is not NULL, *ppPage is set to the MemPage* handle
** for page ovfl. The underlying pager page may have been requested
** with the noContent flag set, so the page data accessable via
** this handle may not be trusted.
** If ppPage is not NULL, and a reference to the MemPage object corresponding
** to page number pOvfl was obtained, then *ppPage is set to point to that
** reference. It is the responsibility of the caller to call releasePage()
** 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(
BtShared *pBt,
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 next = 0;
MemPage *pPage = 0;
int rc = SQLITE_OK;
assert( sqlite3_mutex_held(pBt->mutex) );
/* One of these must not be NULL. Otherwise, why call this function? */
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);
}
assert(pPgnoNext);
#ifndef SQLITE_OMIT_AUTOVACUUM
/* Try to find the next page in the overflow list using the
@ -3129,34 +3213,29 @@ static int getOverflowPage(
if( iGuess<=pagerPagecount(pBt) ){
rc = ptrmapGet(pBt, iGuess, &eType, &pgno);
if( rc!=SQLITE_OK ){
return rc;
}
if( eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){
if( rc==SQLITE_OK && eType==PTRMAP_OVERFLOW2 && pgno==ovfl ){
next = iGuess;
rc = SQLITE_DONE;
}
}
}
#endif
if( next==0 || ppPage ){
MemPage *pPage = 0;
rc = sqlite3BtreeGetPage(pBt, ovfl, &pPage, next!=0);
if( rc==SQLITE_OK ){
rc = sqlite3BtreeGetPage(pBt, ovfl, &pPage, 0);
assert(rc==SQLITE_OK || pPage==0);
if( next==0 && rc==SQLITE_OK ){
next = get4byte(pPage->aData);
}
}
*pPgnoNext = next;
if( ppPage ){
*ppPage = pPage;
}else{
releasePage(pPage);
}
}
*pPgnoNext = next;
return rc;
return (rc==SQLITE_DONE ? SQLITE_OK : rc);
}
/*
@ -4265,6 +4344,7 @@ static int allocateBtreePage(
iPage = get4byte(&aData[8+closest*4]);
if( !searchList || iPage==nearby ){
int noContent;
Pgno nPage;
*pPgno = iPage;
nPage = pagerPagecount(pBt);
@ -4281,9 +4361,9 @@ static int allocateBtreePage(
}
put4byte(&aData[4], k-1);
assert( sqlite3PagerIswriteable(pTrunk->pDbPage) );
rc = sqlite3BtreeGetPage(pBt, *pPgno, ppPage, 1);
noContent = !btreeGetHasContent(pBt, *pPgno);
rc = sqlite3BtreeGetPage(pBt, *pPgno, ppPage, noContent);
if( rc==SQLITE_OK ){
sqlite3PagerDontRollback((*ppPage)->pDbPage);
rc = sqlite3PagerWrite((*ppPage)->pDbPage);
if( rc!=SQLITE_OK ){
releasePage(*ppPage);
@ -4301,6 +4381,10 @@ static int allocateBtreePage(
int nPage = pagerPagecount(pBt);
*pPgno = nPage + 1;
if( *pPgno==PENDING_BYTE_PAGE(pBt) ){
(*pPgno)++;
}
#ifndef SQLITE_OMIT_AUTOVACUUM
if( pBt->autoVacuum && PTRMAP_ISPAGE(pBt, *pPgno) ){
/* 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){
BtShared *pBt = pPage->pBt;
MemPage *pPage1 = pBt->pPage1;
int rc, n, k;
static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
MemPage *pTrunk = 0; /* Free-list trunk page */
Pgno iTrunk = 0; /* Page number of free-list trunk page */
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(pPage->pBt->mutex) );
assert( pPage->pgno>1 );
pPage->isInit = 0;
assert( sqlite3_mutex_held(pBt->mutex) );
assert( iPage>1 );
assert( !pMemPage || pMemPage->pgno==iPage );
if( pMemPage ){
pPage = pMemPage;
sqlite3PagerRef(pPage->pDbPage);
}else{
pPage = btreePageLookup(pBt, iPage);
}
/* Increment the free page count on pPage1 */
rc = sqlite3PagerWrite(pPage1->pDbPage);
if( rc ) return rc;
n = get4byte(&pPage1->aData[36]);
put4byte(&pPage1->aData[36], n+1);
if( rc ) goto freepage_out;
nFree = get4byte(&pPage1->aData[36]);
put4byte(&pPage1->aData[36], nFree+1);
#ifdef SQLITE_SECURE_DELETE
/* If the SQLITE_SECURE_DELETE compile-time option is enabled, then
** always fully overwrite deleted information with zeros.
*/
rc = sqlite3PagerWrite(pPage->pDbPage);
if( rc ) return rc;
if( (!pPage && (rc = sqlite3BtreeGetPage(pBt, iPage, &pPage, 0)))
|| (rc = sqlite3PagerWrite(pPage->pDbPage))
){
goto freepage_out;
}
memset(pPage->aData, 0, pPage->pBt->pageSize);
#endif
@ -4373,27 +4476,34 @@ static int freePage(MemPage *pPage){
** to indicate that the page is free.
*/
if( ISAUTOVACUUM ){
rc = ptrmapPut(pBt, pPage->pgno, PTRMAP_FREEPAGE, 0);
if( rc ) return rc;
rc = ptrmapPut(pBt, iPage, PTRMAP_FREEPAGE, 0);
if( rc ) goto freepage_out;
}
if( n==0 ){
/* This is the first free page */
rc = sqlite3PagerWrite(pPage->pDbPage);
if( rc ) return rc;
memset(pPage->aData, 0, 8);
put4byte(&pPage1->aData[32], pPage->pgno);
TRACE(("FREE-PAGE: %d first\n", pPage->pgno));
}else{
/* Other free pages already exist. Retrive the first trunk page
** of the freelist and find out how many leaves it has. */
MemPage *pTrunk;
rc = sqlite3BtreeGetPage(pBt, get4byte(&pPage1->aData[32]), &pTrunk, 0);
if( rc ) return rc;
k = get4byte(&pTrunk->aData[4]);
if( k>=pBt->usableSize/4 - 8 ){
/* The trunk is full. Turn the page being freed into a new
** trunk page with no leaves.
/* Now manipulate the actual database free-list structure. There are two
** possibilities. If the free-list is currently empty, or if the first
** trunk page in the free-list is full, then this page will become a
** new free-list trunk page. Otherwise, it will become a leaf of the
** first trunk page in the current free-list. This block tests if it
** is possible to add the page as a new free-list leaf.
*/
if( nFree!=0 ){
int nLeaf; /* Initial number of leaf cells on trunk page */
iTrunk = get4byte(&pPage1->aData[32]);
rc = sqlite3BtreeGetPage(pBt, iTrunk, &pTrunk, 0);
if( rc!=SQLITE_OK ){
goto freepage_out;
}
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
** 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 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);
if( rc==SQLITE_OK ){
put4byte(&pTrunk->aData[4], k+1);
put4byte(&pTrunk->aData[8+k*4], pPage->pgno);
put4byte(&pTrunk->aData[4], nLeaf+1);
put4byte(&pTrunk->aData[8+nLeaf*4], iPage);
#ifndef SQLITE_SECURE_DELETE
rc = sqlite3PagerDontWrite(pPage->pDbPage);
if( pPage ){
sqlite3PagerDontWrite(pPage->pDbPage);
}
#endif
rc = btreeSetHasContent(pBt, iPage);
}
TRACE(("FREE-PAGE: %d leaf on trunk page %d\n",pPage->pgno,pTrunk->pgno));
goto freepage_out;
}
}
/* 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;
}
static int freePage(MemPage *pPage){
return freePage2(pPage->pBt, pPage, pPage->pgno);
}
/*
** Free any overflow pages associated with the given Cell.
@ -4442,7 +4569,7 @@ static int clearCell(MemPage *pPage, unsigned char *pCell){
Pgno ovflPgno;
int rc;
int nOvfl;
int ovflPageSize;
u16 ovflPageSize;
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
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 */
}
ovflPgno = get4byte(&pCell[info.iOverflow]);
assert( pBt->usableSize > 4 );
ovflPageSize = pBt->usableSize - 4;
nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
assert( ovflPgno==0 || nOvfl>0 );
while( nOvfl-- ){
MemPage *pOvfl;
Pgno iNext = 0;
MemPage *pOvfl = 0;
if( ovflPgno==0 || ovflPgno>pagerPagecount(pBt) ){
return SQLITE_CORRUPT_BKPT;
}
rc = getOverflowPage(pBt, ovflPgno, &pOvfl, (nOvfl==0)?0:&ovflPgno);
if( nOvfl ){
rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
if( rc ) return rc;
rc = freePage(pOvfl);
}
rc = freePage2(pBt, pOvfl, ovflPgno);
if( pOvfl ){
sqlite3PagerUnref(pOvfl->pDbPage);
}
if( rc ) return rc;
ovflPgno = iNext;
}
return SQLITE_OK;
}
@ -4531,7 +4664,9 @@ static int fillInCell(
nSrc = nData;
nData = 0;
}else{
/* TBD: Perhaps raise SQLITE_CORRUPT if nKey is larger than 31 bits? */
if( nKey>0x7fffffff || pKey==0 ){
return SQLITE_CORRUPT;
}
nPayload += (int)nKey;
pSrc = pKey;
nSrc = (int)nKey;
@ -5453,7 +5588,10 @@ static int balance_nonroot(BtCursor *pCur){
j--;
sqlite3BtreeParseCellPtr(pNew, apCell[j], &info);
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;
}else{
pCell -= 4;
@ -6229,11 +6367,6 @@ static int btreeCreateTable(Btree *p, int *piTable, int flags){
}
assert( eType!=PTRMAP_ROOTPAGE );
assert( eType!=PTRMAP_FREEPAGE );
rc = sqlite3PagerWrite(pRoot->pDbPage);
if( rc!=SQLITE_OK ){
releasePage(pRoot);
return rc;
}
rc = relocatePage(pBt, pRoot, eType, iPtrPage, pgnoMove, 0);
releasePage(pRoot);
@ -7094,17 +7227,6 @@ const char *sqlite3BtreeGetFilename(Btree *p){
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
** 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);
}
#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.
*/
@ -7358,6 +7265,12 @@ int sqlite3BtreeIsInReadTrans(Btree *p){
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
** a single shared-btree. The memory is used by client code for its own

View file

@ -13,7 +13,7 @@
** subsystem. See comments in the source code for a detailed description
** 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_
#define _BTREE_H_
@ -98,13 +98,13 @@ int sqlite3BtreeCreateTable(Btree*, int*, int flags);
int sqlite3BtreeIsInTrans(Btree*);
int sqlite3BtreeIsInStmt(Btree*);
int sqlite3BtreeIsInReadTrans(Btree*);
int sqlite3BtreeIsInBackup(Btree*);
void *sqlite3BtreeSchema(Btree *, int, void(*)(void *));
int sqlite3BtreeSchemaLocked(Btree *);
int sqlite3BtreeLockTable(Btree *, int, u8);
int sqlite3BtreeSavepoint(Btree *, int, int);
const char *sqlite3BtreeGetFilename(Btree *);
const char *sqlite3BtreeGetDirname(Btree *);
const char *sqlite3BtreeGetJournalname(Btree *);
int sqlite3BtreeCopyFile(Btree *, Btree *);

View file

@ -9,7 +9,7 @@
** 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.
** For a detailed discussion of BTrees, refer to
@ -204,10 +204,6 @@
** * zero or more pages numbers of leaves
*/
#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
** 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 locked; /* True if db currently has pBt locked */
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 *pPrev; /* Back pointer of the same list */
};
@ -383,6 +380,7 @@ struct BtShared {
void *pSchema; /* Pointer to space allocated by sqlite3BtreeSchema() */
void (*xFreeSchema)(void*); /* Destructor for BtShared.pSchema */
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
int nRef; /* Number of references to this structure */
BtShared *pNext; /* Next on a list of sharable BtShared structs */
@ -490,18 +488,10 @@ struct BtCursor {
#define CURSOR_REQUIRESEEK 2
#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
** 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.
/*
** The database page the PENDING_BYTE occupies. This page is never used.
*/
#ifdef SQLITE_OMIT_DISKIO
# define PENDING_BYTE_PAGE(pBt) 0x7fffffff
#else
# define PENDING_BYTE_PAGE(pBt) ((Pgno)((PENDING_BYTE/(pBt)->pageSize)+1))
#endif
# define PENDING_BYTE_PAGE(pBt) PAGER_MJ_PGNO(pBt)
/*
** A linked list of the following structures is stored at BtShared.pLock.

69
build.c
View file

@ -22,10 +22,9 @@
** COMMIT
** 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 <ctype.h>
/*
** 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.
** Unlinking from the Table must be done by the calling function.
*/
static void sqliteDeleteIndex(Index *p){
static void sqlite3DeleteIndex(Index *p){
Index *pOld;
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
** schema-cookie mismatch occurs.
**
** If iDb<=0 then reset the internal schema tables for all database
** files. If iDb>=2 then reset the internal schema for only the
** If iDb==0 then reset the internal schema tables for all database
** files. If iDb>=1 then reset the internal schema for only the
** single file indicated.
*/
void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){
@ -526,7 +525,7 @@ void sqlite3DeleteTable(Table *pTable){
for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
pNext = pIndex->pNext;
assert( pIndex->pSchema==pTable->pSchema );
sqliteDeleteIndex(pIndex);
sqlite3DeleteIndex(pIndex);
}
#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
** "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.
** Parameter zName points to a nul-terminated buffer containing the name
** of a database ("main", "temp" or the name of an attached db). This
** function returns the index of the named database in db->aDb[], or
** -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 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 ){
n = sqlite3Strlen30(zName);
Db *pDb;
int n = sqlite3Strlen30(zName);
for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){
if( (!OMIT_TEMPDB || i!=1 ) && n==sqlite3Strlen30(pDb->zName) &&
0==sqlite3StrICmp(pDb->zName, zName) ){
break;
}
}
sqlite3DbFree(db, zName);
}
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
** 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;
i = *pIdx;
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;
if( needQuote ) z[i++] = '"';
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
** 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;
char *zStmt;
char *zSep, *zSep2, *zEnd, *z;
@ -1387,8 +1396,7 @@ static char *createTableStmt(sqlite3 *db, Table *p, int isTemp){
db->mallocFailed = 1;
return 0;
}
sqlite3_snprintf(n, zStmt,
!OMIT_TEMPDB&&isTemp ? "CREATE TEMP TABLE ":"CREATE TABLE ");
sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
k = sqlite3Strlen30(zStmt);
identPut(zStmt, &k, p->zName);
zStmt[k++] = '(';
@ -1553,7 +1561,7 @@ void sqlite3EndTable(
/* Compute the complete text of the CREATE statement */
if( pSelect ){
zStmt = createTableStmt(db, p, p->pSchema==db->aDb[1].pSchema);
zStmt = createTableStmt(db, p);
}else{
n = (int)(pEnd->z - pParse->sNameToken.z) + 1;
zStmt = sqlite3MPrintf(db,
@ -1712,7 +1720,7 @@ void sqlite3CreateView(
sEnd.n = 0;
n = (int)(sEnd.z - 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.n = 1;
@ -2420,7 +2428,8 @@ void sqlite3CreateIndex(
pDb = &db->aDb[iDb];
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);
goto exit_create_index;
}
@ -3422,11 +3431,6 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
** rollback the whole transaction. For operations where all constraints
** 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.
**
** 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){
Vdbe *v = sqlite3GetVdbe(pParse);
@ -3436,9 +3440,6 @@ void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){
if( setStatement && pParse->nested==0 ){
sqlite3VdbeAddOp1(v, OP_Statement, iDb);
}
if( (OMIT_TEMPDB || iDb!=1) && pParse->db->aDb[1].pBt!=0 ){
sqlite3BeginWriteOperation(pParse, setStatement, 1);
}
}
/*

View file

@ -13,7 +13,7 @@
** This file contains functions used to access the internal hash tables
** 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"
@ -228,8 +228,9 @@ CollSeq *sqlite3FindCollSeq(
** that uses encoding enc. The value returned indicates how well the
** 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
** encoding is requested, or vice versa.
** 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){
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;
if( p->nArg==nArg || nArg==-1 ){
match = 4;

51
date.c
View file

@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** 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
** dates and times are stored as the number of days since noon
@ -46,7 +46,6 @@
** Richmond, Virginia (USA)
*/
#include "sqliteInt.h"
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <time.h>
@ -118,7 +117,7 @@ static int getDigits(const char *zDate, ...){
pVal = va_arg(ap, int*);
val = 0;
while( N-- ){
if( !isdigit(*(u8*)zDate) ){
if( !sqlite3Isdigit(*zDate) ){
goto end_getDigits;
}
val = val*10 + *zDate - '0';
@ -162,7 +161,7 @@ static int parseTimezone(const char *zDate, DateTime *p){
int sgn = 0;
int nHr, nMn;
int c;
while( isspace(*(u8*)zDate) ){ zDate++; }
while( sqlite3Isspace(*zDate) ){ zDate++; }
p->tz = 0;
c = *zDate;
if( c=='-' ){
@ -182,7 +181,7 @@ static int parseTimezone(const char *zDate, DateTime *p){
zDate += 5;
p->tz = sgn*(nMn + nHr*60);
zulu_time:
while( isspace(*(u8*)zDate) ){ zDate++; }
while( sqlite3Isspace(*zDate) ){ zDate++; }
return *zDate!=0;
}
@ -206,10 +205,10 @@ static int parseHhMmSs(const char *zDate, DateTime *p){
return 1;
}
zDate += 2;
if( *zDate=='.' && isdigit((u8)zDate[1]) ){
if( *zDate=='.' && sqlite3Isdigit(zDate[1]) ){
double rScale = 1.0;
zDate++;
while( isdigit(*(u8*)zDate) ){
while( sqlite3Isdigit(*zDate) ){
ms = ms*10.0 + *zDate - '0';
rScale *= 10.0;
zDate++;
@ -294,7 +293,7 @@ static int parseYyyyMmDd(const char *zDate, DateTime *p){
return 1;
}
zDate += 10;
while( isspace(*(u8*)zDate) || 'T'==*(u8*)zDate ){ zDate++; }
while( sqlite3Isspace(*zDate) || 'T'==*(u8*)zDate ){ zDate++; }
if( parseHhMmSs(zDate, p)==0 ){
/* We got the time */
}else if( *zDate==0 ){
@ -630,6 +629,7 @@ static int parseModifier(const char *zMod, DateTime *p){
case '7':
case '8':
case '9': {
double rRounder;
n = getValue(z, &r);
assert( n>=1 );
if( z[n]==':' ){
@ -641,7 +641,7 @@ static int parseModifier(const char *zMod, DateTime *p){
const char *z2 = z;
DateTime tx;
sqlite3_int64 day;
if( !isdigit(*(u8*)z2) ) z2++;
if( !sqlite3Isdigit(*z2) ) z2++;
memset(&tx, 0, sizeof(tx));
if( parseHhMmSs(z2, &tx) ) break;
computeJD(&tx);
@ -656,20 +656,21 @@ static int parseModifier(const char *zMod, DateTime *p){
break;
}
z += n;
while( isspace(*(u8*)z) ) z++;
while( sqlite3Isspace(*z) ) z++;
n = sqlite3Strlen30(z);
if( n>10 || n<3 ) break;
if( z[n-1]=='s' ){ z[n-1] = 0; n--; }
computeJD(p);
rc = 0;
rRounder = r<0 ? -0.5 : +0.5;
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 ){
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 ){
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 ){
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 ){
int x, y;
computeYMD_HMS(p);
@ -681,13 +682,17 @@ static int parseModifier(const char *zMod, DateTime *p){
computeJD(p);
y = (int)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 ){
int y = (int)r;
computeYMD_HMS(p);
p->Y += (int)r;
p->Y += y;
p->validJD = 0;
computeJD(p);
if( y!=r ){
p->iJD += (sqlite3_int64)((r - y)*365.0*86400000.0 + rRounder);
}
}else{
rc = 1;
}
@ -887,6 +892,10 @@ static void strftimeFunc(
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) ){
z = zBuf;
}else if( n>(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ){
@ -1033,9 +1042,19 @@ static void currentTimeFunc(
double rT;
char zBuf[20];
UNUSED_PARAMETER(argc);
UNUSED_PARAMETER(argv);
db = sqlite3_context_db_handle(context);
sqlite3OsCurrentTime(db->pVfs, &rT);
#ifndef SQLITE_OMIT_FLOATING_POINT
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
{
struct tm sNow;

11
expr.c
View file

@ -12,10 +12,9 @@
** This file contains routines used for analyzing expressions and
** 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 <ctype.h>
/*
** 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){
assert( z || v==0 || sqlite3VdbeDb(v)->mallocFailed );
assert( !z || !isdigit(z[n]) );
assert( !z || !sqlite3Isdigit(z[n]) );
UNUSED_PARAMETER(n);
if( z ){
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 ){
int i;
int n = pExpr->token.n;
assert( !isdigit(z[n]) );
assert( !sqlite3Isdigit(z[n]) );
if( sqlite3GetInt32(z, &i) ){
if( negFlag ) i = -i;
sqlite3VdbeAddOp2(v, OP_Integer, i, iMem);
@ -1933,12 +1932,10 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
case TK_UMINUS: {
Expr *pLeft = pExpr->pLeft;
assert( pLeft );
if( pLeft->op==TK_FLOAT || pLeft->op==TK_INTEGER ){
if( pLeft->op==TK_FLOAT ){
codeReal(v, (char*)pLeft->token.z, pLeft->token.n, 1, target);
}else{
}else if( pLeft->op==TK_INTEGER ){
codeInteger(v, pLeft, 1, target);
}
}else{
regFree1 = r1 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_Integer, 0, r1);

View file

@ -145,8 +145,8 @@ static int getNextToken(
pRet->pPhrase->isNot = 1;
}
}
}
nConsumed = iEnd;
}
pModule->xClose(pCursor);
}

View file

@ -113,7 +113,10 @@ struct sqlite3_tokenizer_module {
** stemming has been performed). *pnBytes should be set to the length
** of this buffer in bytes. The input text that generated the token is
** 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
** implementation. It is only required to be valid until the next call

102
func.c
View file

@ -16,10 +16,9 @@
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** 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 <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include "vdbeInt.h"
@ -44,7 +43,7 @@ static void minmaxFunc(
int iBest;
CollSeq *pColl;
if( argc==0 ) return;
assert( argc>1 );
mask = sqlite3_user_data(context)==0 ? 0 : -1;
pColl = sqlite3GetFuncCollSeq(context);
assert( pColl );
@ -54,6 +53,7 @@ static void minmaxFunc(
for(i=1; i<argc; i++){
if( sqlite3_value_type(argv[i])==SQLITE_NULL ) return;
if( (sqlite3MemCompare(argv[iBest], argv[i], pColl)^mask)>=0 ){
testcase( mask==0 );
iBest = i;
}
}
@ -71,11 +71,11 @@ static void typeofFunc(
const char *z = 0;
UNUSED_PARAMETER(NotUsed);
switch( sqlite3_value_type(argv[0]) ){
case SQLITE_NULL: z = "null"; break;
case SQLITE_INTEGER: z = "integer"; break;
case SQLITE_TEXT: z = "text"; break;
case SQLITE_FLOAT: z = "real"; break;
case SQLITE_BLOB: z = "blob"; break;
default: z = "null"; break;
}
sqlite3_result_text(context, z, -1, SQLITE_STATIC);
}
@ -170,8 +170,14 @@ static void substrFunc(
int len;
int p0type;
i64 p1, p2;
int negP2 = 0;
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]);
if( p0type==SQLITE_BLOB ){
len = sqlite3_value_bytes(argv[0]);
@ -189,6 +195,10 @@ static void substrFunc(
p1 = sqlite3_value_int(argv[1]);
if( argc==3 ){
p2 = sqlite3_value_int(argv[2]);
if( p2<0 ){
p2 = -p2;
negP2 = 1;
}
}else{
p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];
}
@ -196,13 +206,25 @@ static void substrFunc(
p1 += len;
if( p1<0 ){
p2 += p1;
if( p2<0 ) p2 = 0;
p1 = 0;
}
}else if( p1>0 ){
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 ){
p2 = len-p1;
if( p2<0 ) p2 = 0;
}
if( p0type!=SQLITE_BLOB ){
while( *z && p1 ){
@ -214,7 +236,6 @@ static void substrFunc(
}
sqlite3_result_text(context, (char*)z, (int)(z2-z), SQLITE_TRANSIENT);
}else{
if( p2<0 ) p2 = 0;
sqlite3_result_blob(context, (char*)&z[p1], (int)p2, SQLITE_TRANSIENT);
}
}
@ -222,6 +243,7 @@ static void substrFunc(
/*
** Implementation of the round() function
*/
#ifndef SQLITE_OMIT_FLOATING_POINT
static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
int n = 0;
double r;
@ -239,6 +261,7 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
sqlite3AtoF(zBuf, &r);
sqlite3_result_double(context, r);
}
#endif
/*
** 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;
const char *z2;
int i, n;
if( argc<1 || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
UNUSED_PARAMETER(argc);
z2 = (char*)sqlite3_value_text(argv[0]);
n = sqlite3_value_bytes(argv[0]);
/* 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 ){
memcpy(z1, z2, n+1);
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);
}
}
}
static void lowerFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
char *z1;
u8 *z1;
const char *z2;
int i, n;
if( argc<1 || SQLITE_NULL==sqlite3_value_type(argv[0]) ) return;
UNUSED_PARAMETER(argc);
z2 = (char*)sqlite3_value_text(argv[0]);
n = sqlite3_value_bytes(argv[0]);
/* 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 ){
memcpy(z1, z2, n+1);
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.
*/
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]) ){
case SQLITE_NULL: {
sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC);
break;
}
case SQLITE_INTEGER:
case SQLITE_FLOAT: {
sqlite3_result_value(context, argv[0]);
@ -740,6 +760,12 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
z[j] = 0;
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]);
assert( zStr==sqlite3_value_text(argv[0]) ); /* No encoding change */
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]);
assert( zPattern==sqlite3_value_text(argv[1]) ); /* No encoding change */
zRep = sqlite3_value_text(argv[2]);
@ -977,10 +1012,10 @@ static void soundexFunc(
assert( argc==1 );
zIn = (u8*)sqlite3_value_text(argv[0]);
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] ){
u8 prevcode = iCode[zIn[i]&0x7f];
zResult[0] = toupper(zIn[i]);
zResult[0] = sqlite3Toupper(zIn[i]);
for(j=1; j<4 && zIn[i]; i++){
int code = iCode[zIn[i]&0x7f];
if( code>0 ){
@ -1098,7 +1133,8 @@ static void avgFinalize(sqlite3_context *context){
static void totalFinalize(sqlite3_context *context){
SumCtx *p;
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;
StrAccum *pAccum;
const char *zSep;
int nVal, nSep, i;
if( argc==0 || sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
int nVal, nSep;
assert( argc==1 || argc==2 );
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
if( pAccum ){
@ -1194,22 +1231,18 @@ static void groupConcatStep(
pAccum->useMalloc = 1;
pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
if( pAccum->nChar ){
if( argc>1 ){
zSep = (char*)sqlite3_value_text(argv[argc-1]);
nSep = sqlite3_value_bytes(argv[argc-1]);
if( argc==2 ){
zSep = (char*)sqlite3_value_text(argv[1]);
nSep = sqlite3_value_bytes(argv[1]);
}else{
zSep = ",";
nSep = 1;
}
sqlite3StrAccumAppend(pAccum, zSep, nSep);
}
i = 0;
do{
zVal = (char*)sqlite3_value_text(argv[i]);
nVal = sqlite3_value_bytes(argv[i]);
zVal = (char*)sqlite3_value_text(argv[0]);
nVal = sqlite3_value_bytes(argv[0]);
sqlite3StrAccumAppend(pAccum, zVal, nVal);
i++;
}while( i<argc-1 );
}
}
static void groupConcatFinalize(sqlite3_context *context){
@ -1348,8 +1381,10 @@ void sqlite3RegisterGlobalFunctions(void){
FUNCTION(substr, 2, 0, 0, substrFunc ),
FUNCTION(substr, 3, 0, 0, substrFunc ),
FUNCTION(abs, 1, 0, 0, absFunc ),
#ifndef SQLITE_OMIT_FLOATING_POINT
FUNCTION(round, 1, 0, 0, roundFunc ),
FUNCTION(round, 2, 0, 0, roundFunc ),
#endif
FUNCTION(upper, 1, 0, 0, upperFunc ),
FUNCTION(lower, 1, 0, 0, lowerFunc ),
FUNCTION(coalesce, 1, 0, 0, 0 ),
@ -1357,7 +1392,7 @@ void sqlite3RegisterGlobalFunctions(void){
FUNCTION(coalesce, 0, 0, 0, 0 ),
FUNCTION(hex, 1, 0, 0, hexFunc ),
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(nullif, 2, 0, 1, nullifFunc ),
FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
@ -1379,7 +1414,8 @@ void sqlite3RegisterGlobalFunctions(void){
AGGREGATE(avg, 1, 0, 0, sumStep, avgFinalize ),
AGGREGATE(count, 0, 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),
#ifdef SQLITE_CASE_SENSITIVE_LIKE

View file

@ -12,7 +12,7 @@
**
** 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"
@ -62,6 +62,72 @@ const unsigned char sqlite3UpperToLower[] = {
#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 SQLite library.
@ -102,3 +168,23 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = {
** read-only.
*/
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;

View file

@ -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
@ -28,7 +28,7 @@
**
** 1) The in-memory representation grows too large for the allocated
** buffer, or
** 2) The xSync() method is called.
** 2) The sqlite3JournalCreate() function is called.
*/
#include "sqliteInt.h"
@ -95,8 +95,9 @@ static int jrnlRead(
JournalFile *p = (JournalFile *)pJfd;
if( p->pReal ){
rc = sqlite3OsRead(p->pReal, zBuf, iAmt, iOfst);
}else if( (iAmt+iOfst)>p->iSize ){
rc = SQLITE_IOERR_SHORT_READ;
}else{
assert( iAmt+iOfst<=p->iSize );
memcpy(zBuf, &p->zBuf[iOfst], iAmt);
}
return rc;

View file

@ -2,7 +2,7 @@
**
** 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
** or not a given identifier is really an SQL keyword. The same thing

View file

@ -14,11 +14,10 @@
** other files are for internal use by SQLite and should not be
** 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 <ctype.h>
/*
** Execute SQL code. Return one of the SQLITE_ success/failure
@ -115,7 +114,7 @@ int sqlite3_exec(
if( rc!=SQLITE_SCHEMA ){
nRetry = 0;
zSql = zLeftover;
while( isspace((unsigned char)zSql[0]) ) zSql++;
while( sqlite3Isspace(zSql[0]) ) zSql++;
}
break;
}

View file

@ -12,7 +12,7 @@
** This file contains code used to dynamically load extensions into
** 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
@ -21,7 +21,6 @@
#include "sqlite3ext.h"
#include "sqliteInt.h"
#include <string.h>
#include <ctype.h>
#ifndef SQLITE_OMIT_LOAD_EXTENSION

64
main.c
View file

@ -14,10 +14,9 @@
** other files are for internal use by SQLite and should not be
** 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 <ctype.h>
#ifdef SQLITE_ENABLE_FTS3
# include "fts3.h"
@ -192,6 +191,7 @@ int sqlite3_initialize(void){
** reason. So we run it once during initialization.
*/
#ifndef NDEBUG
#ifndef SQLITE_OMIT_FLOATING_POINT
/* This section of code's only "output" is via assert() statements. */
if ( rc==SQLITE_OK ){
u64 x = (((u64)1)<<63)-1;
@ -201,6 +201,7 @@ int sqlite3_initialize(void){
memcpy(&y, &x, 8);
assert( sqlite3IsNaN(y) );
}
#endif
#endif
return rc;
@ -387,9 +388,22 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
if( db->lookaside.nOut ){
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( pBuf==0 ){
if( sz==0 || cnt==0 ){
sz = 0;
pStart = 0;
}else if( pBuf==0 ){
sz = (sz + 7)&~7;
sqlite3BeginBenignMalloc();
pStart = sqlite3Malloc( sz*cnt );
@ -398,16 +412,13 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
sz = sz&~7;
pStart = pBuf;
}
if( db->lookaside.bMalloced ){
sqlite3_free(db->lookaside.pStart);
}
db->lookaside.pStart = pStart;
db->lookaside.pFree = 0;
db->lookaside.sz = (u16)sz;
db->lookaside.bMalloced = pBuf==0 ?1:0;
if( pStart ){
int i;
LookasideSlot *p;
assert( sz > sizeof(LookasideSlot*) );
p = (LookasideSlot*)pStart;
for(i=cnt-1; i>=0; i--){
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.bEnabled = 1;
db->lookaside.bMalloced = pBuf==0 ?1:0;
}else{
db->lookaside.pEnd = 0;
db->lookaside.bEnabled = 0;
db->lookaside.bMalloced = 0;
}
return SQLITE_OK;
}
@ -586,12 +599,22 @@ int sqlite3_close(sqlite3 *db){
/* If there are any outstanding VMs, return SQLITE_BUSY. */
if( db->pVdbe ){
sqlite3Error(db, SQLITE_BUSY,
"Unable to close due to unfinalised statements");
"unable to close due to unfinalised statements");
sqlite3_mutex_leave(db->mutex);
return SQLITE_BUSY;
}
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. */
sqlite3CloseSavepoints(db);
@ -932,7 +955,7 @@ int sqlite3CreateFunc(
if( p && p->iPrefEnc==enc && p->nArg==nArg ){
if( db->activeVdbeCnt ){
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 );
return SQLITE_BUSY;
}else{
@ -1342,7 +1365,7 @@ static int createCollation(
if( pColl && pColl->xCmp ){
if( db->activeVdbeCnt ){
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;
}
sqlite3ExpirePreparedStatements(db);
@ -2127,6 +2150,25 @@ int sqlite3_test_control(int op, ...){
sqlite3BenignMallocHooks(xBenignBegin, xBenignEnd);
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);
#endif /* SQLITE_OMIT_BUILTIN_TEST */

View file

@ -12,11 +12,10 @@
**
** 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 <stdarg.h>
#include <ctype.h>
/*
** This routine runs when the memory allocator sees that the
@ -154,7 +153,9 @@ int sqlite3MallocInit(void){
** Deinitialize the memory allocation subsystem.
*/
void sqlite3MallocEnd(void){
if( sqlite3GlobalConfig.m.xShutdown ){
sqlite3GlobalConfig.m.xShutdown(sqlite3GlobalConfig.m.pAppData);
}
memset(&mem0, 0, sizeof(mem0));
}
@ -265,7 +266,15 @@ static int mallocWithAlarm(int n, void **pp){
*/
void *sqlite3Malloc(int n){
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;
}else if( sqlite3GlobalConfig.bMemstat ){
sqlite3_mutex_enter(mem0.mutex);
@ -554,7 +563,8 @@ void *sqlite3Realloc(void *pOld, int nBytes){
if( pOld==0 ){
return sqlite3Malloc(nBytes);
}
if( nBytes<=0 ){
if( nBytes<=0 || NEVER(nBytes>=0x7fffff00) ){
/* The NEVER(...) term is explained in comments on sqlite3Malloc() */
sqlite3_free(pOld);
return 0;
}

11
mem2.c
View file

@ -19,7 +19,7 @@
** This file contains implementations of the low-level memory allocation
** 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"
@ -163,9 +163,11 @@ static struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){
pInt = (int*)pAllocation;
pU8 = (u8*)pAllocation;
assert( pInt[nReserve/sizeof(int)]==(int)REARGUARD );
assert( (nReserve-0)<=p->iSize || pU8[nReserve-1]==0x65 );
assert( (nReserve-1)<=p->iSize || pU8[nReserve-2]==0x65 );
assert( (nReserve-2)<=p->iSize || pU8[nReserve-3]==0x65 );
/* This checks any of the "extra" bytes allocated due
** to rounding up to an 8 byte boundary to ensure
** they haven't been overwritten.
*/
while( nReserve-- > p->iSize ) assert( pU8[nReserve]==0x65 );
return p;
}
@ -186,6 +188,7 @@ static int sqlite3MemSize(void *p){
*/
static int sqlite3MemInit(void *NotUsed){
UNUSED_PARAMETER(NotUsed);
assert( (sizeof(struct MemBlockHdr)&7) == 0 );
if( !sqlite3GlobalConfig.bMemstat ){
/* If memory status is enabled, then the malloc.c wrapper will already
** hold the STATIC_MEM mutex when the routines here are invoked. */

View file

@ -14,7 +14,7 @@
** 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"
@ -67,7 +67,9 @@ int sqlite3MutexInit(void){
*/
int sqlite3MutexEnd(void){
int rc = SQLITE_OK;
if( sqlite3GlobalConfig.mutex.xMutexEnd ){
rc = sqlite3GlobalConfig.mutex.xMutexEnd();
}
return rc;
}

View file

@ -11,7 +11,7 @@
*************************************************************************
** 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"
@ -213,6 +213,8 @@ static int winMutexTry(sqlite3_mutex *p){
p->nRef++;
rc = SQLITE_OK;
}
#else
UNUSED_PARAMETER(p);
#endif
return rc;
}

View file

@ -16,7 +16,7 @@
#define OP_RowKey 14
#define OP_IsUnique 15
#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_Expire 18
#define OP_NullRow 20
@ -43,19 +43,19 @@
#define OP_IdxDelete 41
#define OP_Sort 42
#define OP_ResetCount 43
#define OP_NotNull 69 /* same as TK_NOTNULL */
#define OP_Ge 75 /* same as TK_GE */
#define OP_Remainder 85 /* same as TK_REM */
#define OP_Divide 84 /* same as TK_SLASH */
#define OP_NotNull 71 /* same as TK_NOTNULL */
#define OP_Ge 77 /* same as TK_GE */
#define OP_Remainder 87 /* same as TK_REM */
#define OP_Divide 86 /* same as TK_SLASH */
#define OP_Integer 44
#define OP_Explain 45
#define OP_IncrVacuum 46
#define OP_AggStep 47
#define OP_CreateIndex 48
#define OP_NewRowid 49
#define OP_And 64 /* same as TK_AND */
#define OP_ShiftLeft 79 /* same as TK_LSHIFT */
#define OP_Real 129 /* same as TK_FLOAT */
#define OP_And 66 /* same as TK_AND */
#define OP_ShiftLeft 81 /* same as TK_LSHIFT */
#define OP_Real 130 /* same as TK_FLOAT */
#define OP_Return 50
#define OP_Trace 51
#define OP_IfPos 52
@ -63,29 +63,29 @@
#define OP_Rewind 54
#define OP_SeekGe 55
#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_Subtract 82 /* same as TK_MINUS */
#define OP_Subtract 84 /* same as TK_MINUS */
#define OP_Null 58
#define OP_VColumn 59
#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_Permutation 62
#define OP_ToBlob 142 /* same as TK_TO_BLOB */
#define OP_RealAffinity 65
#define OP_Yield 66
#define OP_RealAffinity 63
#define OP_Yield 64
#define OP_AggFinal 67
#define OP_IfZero 76
#define OP_Last 87
#define OP_Rowid 88
#define OP_IfZero 68
#define OP_Last 69
#define OP_Rowid 78
#define OP_Sequence 89
#define OP_NotFound 92
#define OP_SeekGt 93
#define OP_NotFound 90
#define OP_SeekGt 91
#define OP_MakeRecord 94
#define OP_ToText 141 /* same as TK_TO_TEXT */
#define OP_BitAnd 77 /* same as TK_BITAND */
#define OP_Add 81 /* same as TK_PLUS */
#define OP_BitAnd 79 /* same as TK_BITAND */
#define OP_Add 83 /* same as TK_PLUS */
#define OP_ResultRow 95
#define OP_String 96
#define OP_Goto 97
@ -98,10 +98,10 @@
#define OP_Column 104
#define OP_Not 19 /* same as TK_NOT */
#define OP_Compare 105
#define OP_Le 73 /* same as TK_LE */
#define OP_BitOr 78 /* same as TK_BITOR */
#define OP_Multiply 83 /* same as TK_STAR */
#define OP_String8 91 /* same as TK_STRING */
#define OP_Le 75 /* same as TK_LE */
#define OP_BitOr 80 /* same as TK_BITOR */
#define OP_Multiply 85 /* same as TK_STAR */
#define OP_String8 93 /* same as TK_STRING */
#define OP_VOpen 106
#define OP_CreateTable 107
#define OP_Found 108
@ -116,10 +116,10 @@
#define OP_Next 116
#define OP_Prev 117
#define OP_SeekLe 118
#define OP_Lt 74 /* same as TK_LT */
#define OP_Ne 70 /* same as TK_NE */
#define OP_Lt 76 /* same as TK_LT */
#define OP_Ne 72 /* same as TK_NE */
#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_Gosub 121
#define OP_ContextPush 122
@ -127,14 +127,14 @@
#define OP_Destroy 124
#define OP_IdxGE 125
#define OP_ReadCookie 126
#define OP_BitNot 90 /* same as TK_BITNOT */
#define OP_Or 63 /* same as TK_OR */
#define OP_BitNot 92 /* same as TK_BITNOT */
#define OP_Or 65 /* same as TK_OR */
#define OP_Jump 127
#define OP_ToReal 145 /* same as TK_TO_REAL */
#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/
#define OP_Function 128
#define OP_Concat 86 /* same as TK_CONCAT */
#define OP_SCopy 130
#define OP_Concat 88 /* same as TK_CONCAT */
#define OP_SCopy 129
#define OP_Int64 131
/* The following opcode values are never used */
@ -167,15 +167,15 @@
/* 32 */ 0x10, 0x00, 0x02, 0x02, 0x01, 0x00, 0x00, 0x08,\
/* 40 */ 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00,\
/* 48 */ 0x02, 0x02, 0x04, 0x00, 0x05, 0x11, 0x01, 0x11,\
/* 56 */ 0x00, 0x04, 0x02, 0x00, 0x00, 0x05, 0x00, 0x2c,\
/* 64 */ 0x2c, 0x04, 0x04, 0x00, 0x05, 0x05, 0x15, 0x15,\
/* 72 */ 0x15, 0x15, 0x15, 0x15, 0x05, 0x2c, 0x2c, 0x2c,\
/* 80 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x01,\
/* 88 */ 0x02, 0x02, 0x04, 0x02, 0x11, 0x11, 0x00, 0x00,\
/* 56 */ 0x00, 0x04, 0x02, 0x00, 0x00, 0x05, 0x00, 0x04,\
/* 64 */ 0x04, 0x2c, 0x2c, 0x00, 0x05, 0x01, 0x05, 0x05,\
/* 72 */ 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x02, 0x2c,\
/* 80 */ 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c, 0x2c,\
/* 88 */ 0x2c, 0x02, 0x11, 0x11, 0x04, 0x02, 0x00, 0x00,\
/* 96 */ 0x02, 0x01, 0x00, 0x00, 0x21, 0x00, 0x02, 0x00,\
/* 104 */ 0x00, 0x00, 0x00, 0x02, 0x11, 0x08, 0x00, 0x00,\
/* 112 */ 0x00, 0x05, 0x00, 0x0c, 0x01, 0x01, 0x11, 0x05,\
/* 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,\
/* 144 */ 0x04, 0x04,}

14
os.h
View file

@ -17,7 +17,7 @@
** This header file is #include-ed by sqliteInt.h and thus ends up
** 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_
#define _SQLITE_OS_H_
@ -195,9 +195,7 @@
** a random byte is selected for a shared lock. The pool of bytes for
** shared locks begins at SHARED_FIRST.
**
** These #defines are available in sqlite_aux.h so that adaptors for
** connecting SQLite to other operating systems can use the same byte
** ranges for locking. In particular, the same locking strategy and
** The same locking strategy and
** 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
** and all locking correctly. To do so would require that samba (or whatever
@ -221,13 +219,7 @@
** 1GB boundary.
**
*/
#ifndef SQLITE_TEST
#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 PENDING_BYTE sqlite3PendingByte
#define RESERVED_BYTE (PENDING_BYTE+1)
#define SHARED_FIRST (PENDING_BYTE+2)
#define SHARED_SIZE 510

View file

@ -43,7 +43,7 @@
** * Definitions of sqlite3_vfs objects for all locking methods
** 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"
#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 */
int lastErrno; /* The unix errno from the last I/O error */
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__)
pthread_t tid; /* The thread that "owns" this unixFile */
#endif
@ -202,6 +204,11 @@ struct unixFile {
unsigned char transCntrChng; /* True if the transaction counter changed */
unsigned char dbUpdate; /* True if any part of database file changed */
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
#ifdef SQLITE_TEST
/* In test mode, increase the size of this structure a bit so that
@ -920,6 +927,7 @@ static int findLockInfo(
return SQLITE_IOERR;
}
#ifdef __APPLE__
/* On OS X on an msdos filesystem, the inode number is reported
** incorrectly for zero-size files. See ticket #3260. To work
** 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.
*/
if( statbuf.st_size==0 ){
write(fd, "S", 1);
rc = write(fd, "S", 1);
if( rc!=1 ){
return SQLITE_IOERR;
}
rc = fstat(fd, &statbuf);
if( rc!=0 ){
pFile->lastErrno = errno;
return SQLITE_IOERR;
}
}
#endif
memset(&lockKey, 0, sizeof(lockKey));
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.
*/
#ifndef __DJGPP__
if( !reserved ){
struct flock lock;
lock.l_whence = SEEK_SET;
@ -1098,6 +1111,7 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
reserved = 1;
}
}
#endif
unixLeaveMutex();
OSTRACE4("TEST WR-LOCK %d %d %d\n", pFile->h, rc, reserved);
@ -2682,6 +2696,12 @@ static int unixRead(
){
int got;
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);
if( got==amt ){
return SQLITE_OK;
@ -2747,6 +2767,11 @@ static int unixWrite(
assert( id );
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
/* 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
@ -2758,11 +2783,12 @@ static int unixWrite(
unixFile *pFile = (unixFile*)id;
pFile->dbUpdate = 1; /* The database has been modified */
if( offset<=24 && offset+amt>=27 ){
int rc;
char oldCntr[4];
SimulateIOErrorBenign(1);
seekAndRead(pFile, 24, oldCntr, 4);
rc = seekAndRead(pFile, 24, oldCntr, 4);
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 */
}
}
@ -3670,6 +3696,12 @@ static int unixOpen(
*pOutFlags = flags;
}
#ifndef NDEBUG
if( (flags & SQLITE_OPEN_MAIN_DB)!=0 ){
((unixFile*)pFile)->isLockable = 1;
}
#endif
assert(fd!=0);
if( isOpenDirectory ){
rc = openDirectory(zPath, &dirfd);

View file

@ -12,7 +12,7 @@
**
** 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"
#if SQLITE_OS_WIN /* This file is used for windows only */
@ -100,6 +100,7 @@ struct winFile {
HANDLE h; /* Handle for accessing the file */
unsigned char locktype; /* Type of lock currently held on this file */
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
WCHAR *zDeleteOnClose; /* Name of file to delete when closing */
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 */
pFile->hMutex = CreateMutexW(NULL, FALSE, zName);
if (!pFile->hMutex){
pFile->lastErrno = GetLastError();
free(zName);
return FALSE;
}
@ -388,6 +390,7 @@ static BOOL winceCreateLock(const char *zFilename, winFile *pFile){
FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(winceLock));
/* If mapping failed, close the shared memory handle and erase it */
if (!pFile->shared){
pFile->lastErrno = GetLastError();
CloseHandle(pFile->hShared);
pFile->hShared = NULL;
}
@ -653,14 +656,17 @@ static int winRead(
DWORD rc;
DWORD got;
winFile *pFile = (winFile*)id;
DWORD error;
assert( id!=0 );
SimulateIOError(return SQLITE_IOERR_READ);
OSTRACE3("READ %d lock=%d\n", pFile->h, pFile->locktype);
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;
}
if( !ReadFile(pFile->h, pBuf, amt, &got, 0) ){
pFile->lastErrno = GetLastError();
return SQLITE_IOERR_READ;
}
if( got==(DWORD)amt ){
@ -687,12 +693,14 @@ static int winWrite(
DWORD rc;
DWORD wrote = 0;
winFile *pFile = (winFile*)id;
DWORD error;
assert( id!=0 );
SimulateIOError(return SQLITE_IOERR_WRITE);
SimulateDiskfullError(return SQLITE_FULL);
OSTRACE3("WRITE %d lock=%d\n", pFile->h, pFile->locktype);
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;
}
assert( amt>0 );
@ -705,6 +713,7 @@ static int winWrite(
pBuf = &((char*)pBuf)[wrote];
}
if( !rc || amt>(int)wrote ){
pFile->lastErrno = GetLastError();
return SQLITE_FULL;
}
return SQLITE_OK;
@ -718,15 +727,21 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
LONG upperBits = (LONG)((nByte>>32) & 0x7fffffff);
LONG lowerBits = (LONG)(nByte & 0xffffffff);
winFile *pFile = (winFile*)id;
DWORD error = NO_ERROR;
OSTRACE3("TRUNCATE %d %lld\n", pFile->h, nByte);
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
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 */
if( SetEndOfFile(pFile->h) ){
return SQLITE_OK;
}
error = GetLastError();
}
pFile->lastErrno = error;
return SQLITE_IOERR_TRUNCATE;
}
@ -745,10 +760,10 @@ int sqlite3_fullsync_count = 0;
static int winSync(sqlite3_file *id, int flags){
#ifndef SQLITE_NO_SYNC
winFile *pFile = (winFile*)id;
OSTRACE3("SYNC %d lock=%d\n", pFile->h, pFile->locktype);
#else
UNUSED_PARAMETER(id);
#endif
OSTRACE3("SYNC %d lock=%d\n", pFile->h, pFile->locktype);
#ifndef SQLITE_TEST
UNUSED_PARAMETER(flags);
#else
@ -766,6 +781,7 @@ static int winSync(sqlite3_file *id, int flags){
if( FlushFileBuffers(pFile->h) ){
return SQLITE_OK;
}else{
pFile->lastErrno = GetLastError();
return SQLITE_IOERR;
}
#endif
@ -777,8 +793,15 @@ static int winSync(sqlite3_file *id, int flags){
static int winFileSize(sqlite3_file *id, sqlite3_int64 *pSize){
winFile *pFile = (winFile*)id;
DWORD upperBits, lowerBits;
DWORD error;
SimulateIOError(return SQLITE_IOERR_FSTAT);
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;
return SQLITE_OK;
}
@ -814,6 +837,9 @@ static int getReadLock(winFile *pFile){
res = LockFile(pFile->h, SHARED_FIRST+pFile->sharedLockByte, 0, 1, 0);
#endif
}
if( res == 0 ){
pFile->lastErrno = GetLastError();
}
return res;
}
@ -831,6 +857,9 @@ static int unlockReadLock(winFile *pFile){
res = UnlockFile(pFile->h, SHARED_FIRST + pFile->sharedLockByte, 0, 1, 0);
#endif
}
if( res == 0 ){
pFile->lastErrno = GetLastError();
}
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 gotPendingLock = 0;/* True if we acquired a PENDING lock this time */
winFile *pFile = (winFile*)id;
DWORD error = NO_ERROR;
assert( pFile!=0 );
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.
*/
newLocktype = pFile->locktype;
if( pFile->locktype==NO_LOCK
|| (locktype==EXCLUSIVE_LOCK && pFile->locktype==RESERVED_LOCK)
if( (pFile->locktype==NO_LOCK)
|| ( (locktype==EXCLUSIVE_LOCK)
&& (pFile->locktype==RESERVED_LOCK))
){
int cnt = 3;
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);
}
gotPendingLock = res;
if( !res ){
error = GetLastError();
}
}
/* Acquire a shared lock
@ -911,6 +945,8 @@ static int winLock(sqlite3_file *id, int locktype){
res = getReadLock(pFile);
if( res ){
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);
if( res ){
newLocktype = RESERVED_LOCK;
}else{
error = GetLastError();
}
}
@ -941,7 +979,8 @@ static int winLock(sqlite3_file *id, int locktype){
if( res ){
newLocktype = EXCLUSIVE_LOCK;
}else{
OSTRACE2("error-code = %d\n", GetLastError());
error = GetLastError();
OSTRACE2("error-code = %d\n", error);
getReadLock(pFile);
}
}
@ -961,6 +1000,7 @@ static int winLock(sqlite3_file *id, int locktype){
}else{
OSTRACE4("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
locktype, newLocktype);
pFile->lastErrno = error;
rc = SQLITE_BUSY;
}
pFile->locktype = (u8)newLocktype;
@ -1041,6 +1081,10 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){
*(int*)pArg = ((winFile*)id)->locktype;
return SQLITE_OK;
}
case SQLITE_LAST_ERRNO: {
*(int*)pArg = (int)((winFile*)id)->lastErrno;
return SQLITE_OK;
}
}
return SQLITE_ERROR;
}
@ -1320,6 +1364,7 @@ static int winOpen(
memset(pFile, 0, sizeof(*pFile));
pFile->pMethod = &winIoMethod;
pFile->h = h;
pFile->lastErrno = NO_ERROR;
#if SQLITE_OS_WINCE
if( (flags & (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
100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).
*/
double now;
sqlite3_int64 timeW, timeF;
#if SQLITE_OS_WINCE
SYSTEMTIME time;
GetSystemTime(&time);
@ -1644,11 +1689,28 @@ int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
GetSystemTimeAsFileTime( &ft );
#endif
UNUSED_PARAMETER(pVfs);
now = ((double)ft.dwHighDateTime) * 4294967296.0;
*prNow = (now + ft.dwLowDateTime)/864000000000.0 + 2305813.5;
#if defined(_MSC_VER)
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
if( sqlite3_current_time ){
*prNow = sqlite3_current_time/86400.0 + 2440587.5;
*prNow = ((double)sqlite3_current_time + (double)43200) / (double)86400 + (double)2440587;
}
#endif
return 0;

3354
pager.c

File diff suppressed because it is too large Load diff

110
pager.h
View file

@ -13,15 +13,16 @@
** subsystem. The page cache subsystem reads and writes a file a page
** 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_
#define _PAGER_H_
/*
** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
** Default maximum size for persistent journal files. A negative
** 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
#define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1
@ -43,10 +44,20 @@ typedef struct Pager Pager;
*/
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().
**
** 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_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 */
/*
** See source code comments for a detailed description of the following
** routines:
** The remainder of this file contains the declarations of the functions
** 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 sqlite3PagerClose(Pager *pPager);
int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
/* Functions used to configure a Pager object. */
void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *);
void sqlite3PagerSetReiniter(Pager*, void(*)(DbPage*));
int sqlite3PagerSetPagesize(Pager*, u16*);
int sqlite3PagerMaxPageCount(Pager*, int);
int sqlite3PagerReadFileheader(Pager*, int, unsigned char*);
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);
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 sqlite3PagerJournalMode(Pager *, int);
i64 sqlite3PagerJournalSizeLimit(Pager *, i64);
void *sqlite3PagerTempSpace(Pager*);
int sqlite3PagerSync(Pager *pPager);
sqlite3_backup **sqlite3PagerBackupPtr(Pager*);
/* 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 sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
#ifndef SQLITE_OMIT_AUTOVACUUM
void sqlite3PagerTruncateImage(Pager*,Pgno);
Pgno sqlite3PagerImageSize(Pager *);
#endif
/* Functions used to query pager state and configuration. */
u8 sqlite3PagerIsreadonly(Pager*);
int sqlite3PagerRefcount(Pager*);
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
void sqlite3PagerSetCodec(Pager*,void*(*)(void*,void*,Pgno,int),void*);
#endif
/* Functions to support testing and debugging. */
#if !defined(NDEBUG) || defined(SQLITE_TEST)
Pgno sqlite3PagerPagenumber(DbPage*);
int sqlite3PagerIswriteable(DbPage*);
#endif
#ifdef SQLITE_TEST
int *sqlite3PagerStats(Pager*);
void sqlite3PagerRefdump(Pager*);
int sqlite3PagerIsMemdb(Pager*);
#endif
#ifdef SQLITE_TEST
void disable_simulated_io_errors(void);
void enable_simulated_io_errors(void);
void disable_simulated_io_errors(void);
void enable_simulated_io_errors(void);
#else
# define disable_simulated_io_errors()
# define enable_simulated_io_errors()

772
parse.c
View file

@ -95,7 +95,7 @@ struct AttachKey { int type; Token key; };
#define YYCODETYPE unsigned char
#define YYNOCODE 251
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 62
#define YYWILDCARD 64
#define sqlite3ParserTOKENTYPE Token
typedef union {
int yyinit;
@ -179,366 +179,366 @@ static const YYMINORTYPE yyzerominor = { 0 };
** yy_default[] Default action for each state.
*/
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 304, 74, 581, 83, 164, 205, 587, 543, 86, 86,
/* 10 */ 86, 86, 350, 96, 96, 96, 96, 93, 93, 94,
/* 20 */ 94, 94, 91, 227, 188, 158, 532, 524, 88, 96,
/* 30 */ 96, 96, 96, 93, 93, 94, 94, 94, 91, 227,
/* 40 */ 489, 315, 505, 504, 92, 82, 309, 518, 516, 522,
/* 50 */ 522, 95, 95, 86, 86, 86, 86, 434, 96, 96,
/* 60 */ 96, 96, 93, 93, 94, 94, 94, 91, 227, 304,
/* 70 */ 450, 308, 543, 525, 540, 63, 96, 96, 96, 96,
/* 80 */ 93, 93, 94, 94, 94, 91, 227, 93, 93, 94,
/* 90 */ 94, 94, 91, 227, 586, 532, 524, 332, 596, 77,
/* 100 */ 239, 59, 20, 233, 226, 563, 543, 538, 538, 538,
/* 110 */ 182, 345, 269, 92, 82, 309, 518, 516, 522, 522,
/* 120 */ 95, 95, 86, 86, 86, 86, 592, 96, 96, 96,
/* 130 */ 96, 93, 93, 94, 94, 94, 91, 227, 304, 230,
/* 140 */ 489, 481, 308, 229, 550, 176, 114, 289, 340, 290,
/* 150 */ 325, 170, 451, 447, 480, 191, 607, 394, 262, 264,
/* 160 */ 152, 150, 406, 22, 532, 524, 416, 295, 379, 589,
/* 170 */ 450, 543, 604, 920, 540, 920, 301, 589, 293, 492,
/* 180 */ 453, 206, 92, 82, 309, 518, 516, 522, 522, 95,
/* 190 */ 95, 86, 86, 86, 86, 373, 96, 96, 96, 96,
/* 200 */ 93, 93, 94, 94, 94, 91, 227, 538, 538, 538,
/* 210 */ 230, 304, 599, 74, 153, 83, 164, 114, 289, 340,
/* 220 */ 290, 325, 170, 94, 94, 94, 91, 227, 278, 262,
/* 230 */ 474, 446, 494, 219, 588, 585, 171, 532, 524, 371,
/* 240 */ 378, 383, 588, 585, 281, 339, 505, 504, 546, 606,
/* 250 */ 388, 445, 555, 556, 90, 92, 82, 309, 518, 516,
/* 260 */ 522, 522, 95, 95, 86, 86, 86, 86, 466, 96,
/* 270 */ 96, 96, 96, 93, 93, 94, 94, 94, 91, 227,
/* 280 */ 322, 357, 171, 488, 304, 371, 378, 383, 171, 61,
/* 290 */ 154, 371, 378, 383, 231, 559, 388, 74, 357, 83,
/* 300 */ 164, 56, 388, 321, 551, 28, 240, 163, 226, 464,
/* 310 */ 532, 524, 324, 119, 558, 557, 346, 568, 511, 511,
/* 320 */ 490, 551, 49, 346, 550, 511, 511, 76, 92, 82,
/* 330 */ 309, 518, 516, 522, 522, 95, 95, 86, 86, 86,
/* 340 */ 86, 550, 96, 96, 96, 96, 93, 93, 94, 94,
/* 350 */ 94, 91, 227, 304, 349, 423, 451, 307, 109, 402,
/* 360 */ 234, 238, 357, 331, 560, 357, 566, 22, 341, 346,
/* 370 */ 229, 511, 511, 531, 530, 554, 226, 559, 284, 532,
/* 380 */ 524, 374, 387, 464, 490, 551, 49, 472, 551, 40,
/* 390 */ 151, 410, 159, 573, 527, 526, 558, 92, 82, 309,
/* 400 */ 518, 516, 522, 522, 95, 95, 86, 86, 86, 86,
/* 410 */ 165, 96, 96, 96, 96, 93, 93, 94, 94, 94,
/* 420 */ 91, 227, 304, 528, 91, 227, 550, 331, 353, 222,
/* 430 */ 521, 385, 348, 402, 234, 238, 400, 357, 157, 158,
/* 440 */ 357, 589, 565, 473, 229, 204, 318, 225, 532, 524,
/* 450 */ 60, 436, 205, 525, 543, 413, 424, 403, 226, 296,
/* 460 */ 551, 49, 420, 551, 40, 306, 92, 82, 309, 518,
/* 470 */ 516, 522, 522, 95, 95, 86, 86, 86, 86, 550,
/* 480 */ 96, 96, 96, 96, 93, 93, 94, 94, 94, 91,
/* 490 */ 227, 304, 479, 564, 461, 286, 494, 288, 357, 297,
/* 500 */ 357, 436, 334, 376, 217, 141, 588, 585, 374, 74,
/* 510 */ 357, 83, 164, 930, 130, 609, 2, 532, 524, 543,
/* 520 */ 17, 551, 43, 551, 50, 391, 525, 23, 272, 604,
/* 530 */ 921, 589, 921, 551, 43, 92, 82, 309, 518, 516,
/* 540 */ 522, 522, 95, 95, 86, 86, 86, 86, 592, 96,
/* 550 */ 96, 96, 96, 93, 93, 94, 94, 94, 91, 227,
/* 560 */ 304, 510, 281, 481, 429, 274, 249, 319, 242, 599,
/* 570 */ 142, 589, 459, 459, 218, 263, 480, 589, 338, 311,
/* 580 */ 589, 439, 440, 204, 1, 149, 532, 524, 589, 451,
/* 590 */ 392, 346, 169, 511, 511, 589, 588, 585, 221, 590,
/* 600 */ 22, 492, 359, 206, 92, 82, 309, 518, 516, 522,
/* 610 */ 522, 95, 95, 86, 86, 86, 86, 550, 96, 96,
/* 620 */ 96, 96, 93, 93, 94, 94, 94, 91, 227, 304,
/* 630 */ 397, 470, 208, 454, 475, 357, 588, 585, 469, 161,
/* 640 */ 161, 376, 588, 585, 256, 588, 585, 346, 277, 511,
/* 650 */ 511, 236, 196, 588, 585, 532, 524, 165, 551, 31,
/* 660 */ 588, 585, 458, 396, 459, 459, 550, 437, 401, 437,
/* 670 */ 595, 542, 303, 92, 82, 309, 518, 516, 522, 522,
/* 680 */ 95, 95, 86, 86, 86, 86, 550, 96, 96, 96,
/* 690 */ 96, 93, 93, 94, 94, 94, 91, 227, 304, 357,
/* 700 */ 442, 227, 421, 355, 441, 357, 543, 357, 179, 357,
/* 710 */ 506, 357, 306, 471, 357, 169, 386, 262, 610, 600,
/* 720 */ 360, 490, 551, 16, 532, 524, 551, 3, 551, 111,
/* 730 */ 551, 33, 551, 24, 551, 34, 190, 551, 51, 582,
/* 740 */ 579, 578, 92, 82, 309, 518, 516, 522, 522, 95,
/* 750 */ 95, 86, 86, 86, 86, 357, 96, 96, 96, 96,
/* 760 */ 93, 93, 94, 94, 94, 91, 227, 304, 357, 552,
/* 770 */ 550, 543, 357, 553, 357, 326, 357, 169, 551, 42,
/* 780 */ 357, 605, 606, 320, 357, 282, 357, 201, 211, 166,
/* 790 */ 287, 551, 112, 532, 524, 551, 37, 551, 98, 551,
/* 800 */ 54, 649, 552, 551, 52, 167, 553, 551, 113, 551,
/* 810 */ 35, 92, 82, 309, 518, 516, 522, 522, 95, 95,
/* 820 */ 86, 86, 86, 86, 357, 96, 96, 96, 96, 93,
/* 830 */ 93, 94, 94, 94, 91, 227, 304, 276, 399, 550,
/* 840 */ 155, 357, 509, 357, 21, 357, 343, 551, 55, 357,
/* 850 */ 598, 302, 412, 357, 601, 2, 426, 229, 494, 219,
/* 860 */ 600, 360, 532, 524, 551, 25, 551, 29, 551, 41,
/* 870 */ 525, 381, 551, 39, 550, 281, 551, 10, 276, 223,
/* 880 */ 92, 81, 309, 518, 516, 522, 522, 95, 95, 86,
/* 890 */ 86, 86, 86, 357, 96, 96, 96, 96, 93, 93,
/* 900 */ 94, 94, 94, 91, 227, 304, 357, 281, 281, 228,
/* 910 */ 357, 323, 357, 285, 357, 169, 551, 26, 357, 487,
/* 920 */ 512, 191, 495, 357, 70, 357, 409, 407, 460, 551,
/* 930 */ 46, 532, 524, 551, 30, 551, 32, 551, 48, 18,
/* 940 */ 276, 551, 47, 314, 310, 602, 551, 103, 551, 108,
/* 950 */ 82, 309, 518, 516, 522, 522, 95, 95, 86, 86,
/* 960 */ 86, 86, 357, 96, 96, 96, 96, 93, 93, 94,
/* 970 */ 94, 94, 91, 227, 304, 513, 276, 276, 19, 357,
/* 980 */ 146, 357, 517, 357, 603, 551, 97, 357, 8, 455,
/* 990 */ 356, 169, 357, 498, 498, 199, 545, 62, 70, 80,
/* 1000 */ 532, 524, 551, 102, 551, 100, 551, 99, 266, 452,
/* 1010 */ 551, 38, 368, 414, 336, 551, 45, 276, 362, 214,
/* 1020 */ 309, 518, 516, 522, 522, 95, 95, 86, 86, 86,
/* 1030 */ 86, 357, 96, 96, 96, 96, 93, 93, 94, 94,
/* 1040 */ 94, 91, 227, 71, 352, 237, 4, 357, 276, 369,
/* 1050 */ 316, 456, 276, 357, 551, 110, 357, 276, 344, 523,
/* 1060 */ 449, 572, 539, 357, 570, 294, 71, 352, 404, 4,
/* 1070 */ 551, 44, 351, 316, 260, 330, 551, 36, 370, 551,
/* 1080 */ 27, 344, 162, 435, 247, 489, 551, 53, 496, 478,
/* 1090 */ 520, 853, 462, 279, 246, 78, 583, 243, 330, 271,
/* 1100 */ 375, 292, 395, 438, 499, 84, 73, 476, 489, 465,
/* 1110 */ 533, 501, 258, 541, 72, 354, 358, 337, 493, 540,
/* 1120 */ 424, 298, 483, 497, 536, 147, 259, 549, 84, 73,
/* 1130 */ 116, 569, 203, 571, 57, 195, 580, 72, 354, 358,
/* 1140 */ 78, 367, 540, 500, 267, 363, 463, 115, 229, 425,
/* 1150 */ 432, 508, 538, 538, 538, 535, 534, 12, 172, 5,
/* 1160 */ 229, 187, 241, 245, 248, 251, 183, 273, 576, 104,
/* 1170 */ 128, 575, 364, 123, 390, 538, 538, 538, 535, 534,
/* 1180 */ 12, 125, 168, 327, 235, 448, 329, 71, 352, 574,
/* 1190 */ 4, 261, 193, 591, 316, 126, 393, 200, 342, 143,
/* 1200 */ 313, 268, 344, 185, 529, 464, 257, 312, 107, 175,
/* 1210 */ 561, 87, 202, 213, 58, 7, 333, 67, 594, 330,
/* 1220 */ 69, 431, 250, 79, 482, 244, 270, 366, 265, 489,
/* 1230 */ 135, 174, 275, 548, 428, 577, 427, 122, 133, 299,
/* 1240 */ 224, 215, 347, 467, 181, 415, 433, 216, 194, 84,
/* 1250 */ 73, 300, 412, 105, 398, 384, 254, 238, 72, 354,
/* 1260 */ 358, 305, 417, 540, 411, 408, 229, 418, 207, 291,
/* 1270 */ 405, 173, 101, 422, 584, 75, 280, 544, 232, 317,
/* 1280 */ 210, 132, 118, 129, 335, 593, 485, 184, 253, 380,
/* 1290 */ 562, 377, 136, 209, 160, 145, 538, 538, 538, 535,
/* 1300 */ 534, 12, 547, 650, 468, 127, 13, 382, 15, 514,
/* 1310 */ 502, 389, 144, 444, 443, 486, 191, 255, 66, 430,
/* 1320 */ 131, 121, 137, 106, 519, 65, 608, 89, 192, 85,
/* 1330 */ 283, 419, 134, 252, 457, 156, 140, 64, 148, 372,
/* 1340 */ 597, 120, 567, 6, 537, 212, 186, 503, 189, 177,
/* 1350 */ 328, 491, 651, 507, 365, 477, 197, 9, 14, 293,
/* 1360 */ 484, 178, 68, 138, 220, 180, 139, 515, 117, 198,
/* 1370 */ 11, 124, 931, 931, 931, 931, 931, 931, 931, 931,
/* 1380 */ 361,
/* 0 */ 304, 74, 581, 83, 164, 205, 281, 543, 86, 86,
/* 10 */ 86, 86, 587, 96, 96, 96, 96, 93, 93, 94,
/* 20 */ 94, 94, 91, 227, 492, 359, 206, 308, 532, 524,
/* 30 */ 88, 96, 96, 96, 96, 93, 93, 94, 94, 94,
/* 40 */ 91, 227, 322, 350, 589, 326, 92, 82, 309, 518,
/* 50 */ 516, 522, 522, 95, 95, 86, 86, 86, 86, 525,
/* 60 */ 96, 96, 96, 96, 93, 93, 94, 94, 94, 91,
/* 70 */ 227, 304, 552, 308, 543, 446, 553, 63, 96, 96,
/* 80 */ 96, 96, 93, 93, 94, 94, 94, 91, 227, 589,
/* 90 */ 301, 589, 179, 492, 453, 206, 445, 230, 269, 532,
/* 100 */ 524, 494, 564, 77, 114, 289, 340, 290, 325, 170,
/* 110 */ 436, 588, 585, 437, 401, 437, 262, 92, 82, 309,
/* 120 */ 518, 516, 522, 522, 95, 95, 86, 86, 86, 86,
/* 130 */ 466, 96, 96, 96, 96, 93, 93, 94, 94, 94,
/* 140 */ 91, 227, 304, 230, 345, 357, 494, 219, 321, 176,
/* 150 */ 114, 289, 340, 290, 325, 170, 588, 585, 588, 585,
/* 160 */ 171, 357, 262, 371, 378, 383, 555, 556, 551, 50,
/* 170 */ 532, 524, 434, 464, 388, 93, 93, 94, 94, 94,
/* 180 */ 91, 227, 586, 489, 551, 43, 592, 649, 92, 82,
/* 190 */ 309, 518, 516, 522, 522, 95, 95, 86, 86, 86,
/* 200 */ 86, 481, 96, 96, 96, 96, 93, 93, 94, 94,
/* 210 */ 94, 91, 227, 450, 304, 153, 480, 540, 607, 74,
/* 220 */ 263, 83, 164, 402, 234, 238, 332, 596, 416, 357,
/* 230 */ 319, 357, 233, 490, 229, 315, 505, 504, 559, 182,
/* 240 */ 188, 158, 532, 524, 94, 94, 94, 91, 227, 538,
/* 250 */ 538, 538, 551, 40, 551, 49, 239, 558, 557, 90,
/* 260 */ 92, 82, 309, 518, 516, 522, 522, 95, 95, 86,
/* 270 */ 86, 86, 86, 550, 96, 96, 96, 96, 93, 93,
/* 280 */ 94, 94, 94, 91, 227, 171, 304, 397, 371, 378,
/* 290 */ 383, 61, 353, 222, 451, 387, 331, 379, 226, 388,
/* 300 */ 423, 348, 357, 171, 566, 22, 371, 378, 383, 560,
/* 310 */ 447, 163, 191, 464, 532, 524, 165, 388, 554, 226,
/* 320 */ 231, 339, 505, 504, 373, 551, 49, 56, 151, 410,
/* 330 */ 240, 76, 92, 82, 309, 518, 516, 522, 522, 95,
/* 340 */ 95, 86, 86, 86, 86, 550, 96, 96, 96, 96,
/* 350 */ 93, 93, 94, 94, 94, 91, 227, 304, 204, 357,
/* 360 */ 565, 473, 109, 402, 234, 238, 357, 331, 154, 436,
/* 370 */ 357, 306, 341, 357, 229, 74, 262, 83, 164, 531,
/* 380 */ 530, 474, 551, 28, 226, 532, 524, 546, 606, 551,
/* 390 */ 49, 525, 550, 551, 51, 568, 551, 42, 159, 490,
/* 400 */ 527, 526, 550, 92, 82, 309, 518, 516, 522, 522,
/* 410 */ 95, 95, 86, 86, 86, 86, 376, 96, 96, 96,
/* 420 */ 96, 93, 93, 94, 94, 94, 91, 227, 304, 528,
/* 430 */ 479, 334, 550, 17, 488, 559, 357, 278, 391, 357,
/* 440 */ 284, 451, 23, 472, 157, 158, 589, 74, 264, 83,
/* 450 */ 164, 406, 22, 204, 558, 229, 532, 524, 60, 551,
/* 460 */ 40, 318, 551, 43, 930, 130, 609, 2, 394, 346,
/* 470 */ 272, 511, 511, 573, 92, 82, 309, 518, 516, 522,
/* 480 */ 522, 95, 95, 86, 86, 86, 86, 550, 96, 96,
/* 490 */ 96, 96, 93, 93, 94, 94, 94, 91, 227, 304,
/* 500 */ 217, 604, 920, 286, 920, 592, 141, 142, 311, 459,
/* 510 */ 249, 376, 242, 588, 585, 403, 226, 589, 357, 510,
/* 520 */ 481, 589, 346, 256, 511, 511, 236, 532, 524, 413,
/* 530 */ 424, 604, 921, 396, 921, 480, 420, 338, 324, 119,
/* 540 */ 1, 551, 31, 599, 589, 92, 82, 309, 518, 516,
/* 550 */ 522, 522, 95, 95, 86, 86, 86, 86, 357, 96,
/* 560 */ 96, 96, 96, 93, 93, 94, 94, 94, 91, 227,
/* 570 */ 304, 276, 307, 599, 429, 589, 475, 355, 161, 605,
/* 580 */ 606, 551, 16, 399, 588, 585, 442, 349, 588, 585,
/* 590 */ 441, 277, 543, 281, 346, 451, 511, 511, 532, 524,
/* 600 */ 551, 3, 229, 459, 386, 590, 22, 346, 281, 511,
/* 610 */ 511, 588, 585, 223, 458, 381, 92, 82, 309, 518,
/* 620 */ 516, 522, 522, 95, 95, 86, 86, 86, 86, 221,
/* 630 */ 96, 96, 96, 96, 93, 93, 94, 94, 94, 91,
/* 640 */ 227, 304, 588, 585, 323, 454, 385, 392, 357, 169,
/* 650 */ 357, 400, 357, 205, 357, 543, 357, 20, 357, 543,
/* 660 */ 357, 543, 357, 589, 346, 521, 511, 511, 542, 532,
/* 670 */ 524, 551, 111, 551, 33, 551, 24, 551, 34, 551,
/* 680 */ 112, 551, 37, 551, 98, 551, 54, 92, 82, 309,
/* 690 */ 518, 516, 522, 522, 95, 95, 86, 86, 86, 86,
/* 700 */ 357, 96, 96, 96, 96, 93, 93, 94, 94, 94,
/* 710 */ 91, 227, 304, 357, 506, 357, 421, 598, 302, 357,
/* 720 */ 208, 357, 543, 551, 52, 357, 282, 357, 543, 357,
/* 730 */ 588, 585, 357, 610, 600, 360, 551, 113, 551, 35,
/* 740 */ 532, 524, 551, 55, 551, 25, 91, 227, 551, 29,
/* 750 */ 551, 41, 551, 39, 550, 551, 10, 287, 92, 82,
/* 760 */ 309, 518, 516, 522, 522, 95, 95, 86, 86, 86,
/* 770 */ 86, 357, 96, 96, 96, 96, 93, 93, 94, 94,
/* 780 */ 94, 91, 227, 304, 357, 460, 357, 582, 579, 578,
/* 790 */ 357, 595, 357, 303, 551, 26, 357, 439, 440, 357,
/* 800 */ 343, 357, 374, 357, 201, 211, 166, 551, 46, 551,
/* 810 */ 30, 532, 524, 551, 32, 551, 48, 276, 276, 551,
/* 820 */ 47, 276, 551, 103, 551, 108, 551, 97, 426, 92,
/* 830 */ 82, 309, 518, 516, 522, 522, 95, 95, 86, 86,
/* 840 */ 86, 86, 357, 96, 96, 96, 96, 93, 93, 94,
/* 850 */ 94, 94, 91, 227, 304, 357, 471, 357, 169, 512,
/* 860 */ 517, 357, 459, 362, 357, 551, 102, 357, 225, 509,
/* 870 */ 357, 21, 357, 356, 357, 490, 601, 2, 551, 100,
/* 880 */ 551, 99, 532, 524, 551, 38, 374, 551, 45, 18,
/* 890 */ 551, 110, 296, 551, 44, 551, 36, 551, 27, 196,
/* 900 */ 92, 81, 309, 518, 516, 522, 522, 95, 95, 86,
/* 910 */ 86, 86, 86, 404, 96, 96, 96, 96, 93, 93,
/* 920 */ 94, 94, 94, 91, 227, 304, 513, 357, 190, 167,
/* 930 */ 155, 161, 288, 550, 297, 281, 461, 320, 494, 219,
/* 940 */ 8, 285, 276, 169, 600, 360, 409, 407, 498, 498,
/* 950 */ 551, 53, 218, 532, 524, 169, 459, 276, 525, 525,
/* 960 */ 266, 276, 550, 550, 550, 368, 281, 276, 487, 602,
/* 970 */ 191, 314, 82, 309, 518, 516, 522, 522, 95, 95,
/* 980 */ 86, 86, 86, 86, 214, 96, 96, 96, 96, 93,
/* 990 */ 93, 94, 94, 94, 91, 227, 304, 274, 228, 523,
/* 1000 */ 276, 336, 310, 520, 456, 495, 470, 70, 552, 246,
/* 1010 */ 603, 19, 553, 146, 165, 469, 455, 199, 169, 295,
/* 1020 */ 545, 62, 70, 80, 532, 524, 227, 452, 237, 149,
/* 1030 */ 293, 369, 412, 414, 449, 572, 351, 539, 570, 294,
/* 1040 */ 260, 370, 271, 853, 309, 518, 516, 522, 522, 95,
/* 1050 */ 95, 86, 86, 86, 86, 462, 96, 96, 96, 96,
/* 1060 */ 93, 93, 94, 94, 94, 91, 227, 71, 352, 306,
/* 1070 */ 4, 162, 435, 247, 316, 583, 438, 496, 478, 71,
/* 1080 */ 352, 279, 4, 344, 292, 243, 316, 375, 395, 465,
/* 1090 */ 258, 501, 337, 536, 533, 344, 499, 541, 493, 147,
/* 1100 */ 267, 330, 298, 549, 497, 483, 259, 424, 569, 116,
/* 1110 */ 571, 489, 203, 330, 57, 195, 580, 78, 78, 367,
/* 1120 */ 363, 115, 463, 489, 425, 500, 229, 187, 432, 508,
/* 1130 */ 241, 84, 73, 476, 576, 128, 5, 364, 125, 575,
/* 1140 */ 72, 354, 358, 84, 73, 540, 390, 123, 327, 329,
/* 1150 */ 574, 591, 72, 354, 358, 193, 126, 540, 448, 107,
/* 1160 */ 172, 393, 200, 342, 268, 245, 248, 251, 183, 273,
/* 1170 */ 529, 104, 143, 257, 313, 229, 58, 538, 538, 538,
/* 1180 */ 535, 534, 12, 59, 168, 312, 235, 563, 561, 538,
/* 1190 */ 538, 538, 535, 534, 12, 261, 87, 7, 71, 352,
/* 1200 */ 213, 4, 67, 333, 594, 316, 69, 185, 250, 464,
/* 1210 */ 79, 431, 244, 175, 344, 270, 202, 366, 482, 135,
/* 1220 */ 265, 174, 275, 122, 489, 427, 548, 428, 133, 577,
/* 1230 */ 299, 215, 330, 347, 467, 181, 300, 415, 224, 216,
/* 1240 */ 433, 417, 489, 194, 152, 150, 412, 408, 398, 411,
/* 1250 */ 207, 291, 418, 405, 450, 173, 105, 422, 540, 384,
/* 1260 */ 254, 238, 84, 73, 584, 305, 75, 101, 232, 317,
/* 1270 */ 229, 72, 354, 358, 210, 118, 540, 280, 129, 132,
/* 1280 */ 335, 593, 544, 485, 184, 253, 562, 209, 136, 380,
/* 1290 */ 538, 538, 538, 160, 377, 145, 547, 650, 468, 127,
/* 1300 */ 13, 382, 15, 514, 502, 389, 144, 444, 538, 538,
/* 1310 */ 538, 535, 534, 12, 191, 255, 486, 66, 443, 430,
/* 1320 */ 131, 121, 137, 106, 519, 65, 89, 192, 608, 252,
/* 1330 */ 283, 419, 134, 597, 457, 85, 372, 156, 140, 120,
/* 1340 */ 148, 503, 64, 567, 212, 6, 186, 537, 189, 177,
/* 1350 */ 365, 328, 651, 491, 507, 9, 197, 477, 14, 293,
/* 1360 */ 484, 68, 220, 138, 117, 178, 180, 139, 11, 198,
/* 1370 */ 515, 124, 931, 931, 931, 931, 931, 931, 931, 931,
/* 1380 */ 931, 361,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 19, 221, 222, 223, 224, 24, 150, 26, 72, 73,
/* 10 */ 74, 75, 19, 77, 78, 79, 80, 81, 82, 83,
/* 20 */ 84, 85, 86, 87, 205, 206, 45, 46, 76, 77,
/* 0 */ 19, 221, 222, 223, 224, 24, 150, 26, 74, 75,
/* 10 */ 76, 77, 150, 79, 80, 81, 82, 83, 84, 85,
/* 20 */ 86, 87, 88, 89, 165, 166, 167, 19, 47, 48,
/* 30 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
/* 40 */ 61, 168, 169, 170, 63, 64, 65, 66, 67, 68,
/* 50 */ 69, 70, 71, 72, 73, 74, 75, 150, 77, 78,
/* 60 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 19,
/* 70 */ 91, 19, 91, 165, 95, 25, 77, 78, 79, 80,
/* 80 */ 81, 82, 83, 84, 85, 86, 87, 81, 82, 83,
/* 90 */ 84, 85, 86, 87, 150, 45, 46, 146, 147, 49,
/* 100 */ 150, 22, 22, 152, 231, 26, 26, 128, 129, 130,
/* 110 */ 159, 118, 204, 63, 64, 65, 66, 67, 68, 69,
/* 120 */ 70, 71, 72, 73, 74, 75, 12, 77, 78, 79,
/* 130 */ 80, 81, 82, 83, 84, 85, 86, 87, 19, 87,
/* 140 */ 61, 27, 19, 113, 193, 93, 94, 95, 96, 97,
/* 150 */ 98, 99, 150, 23, 40, 25, 42, 127, 106, 157,
/* 160 */ 81, 82, 160, 161, 45, 46, 52, 95, 217, 26,
/* 170 */ 91, 91, 22, 23, 95, 25, 162, 26, 106, 165,
/* 180 */ 166, 167, 63, 64, 65, 66, 67, 68, 69, 70,
/* 190 */ 71, 72, 73, 74, 75, 244, 77, 78, 79, 80,
/* 200 */ 81, 82, 83, 84, 85, 86, 87, 128, 129, 130,
/* 210 */ 87, 19, 62, 221, 25, 223, 224, 94, 95, 96,
/* 220 */ 97, 98, 99, 83, 84, 85, 86, 87, 194, 106,
/* 230 */ 23, 33, 81, 82, 91, 92, 93, 45, 46, 96,
/* 240 */ 97, 98, 91, 92, 150, 168, 169, 170, 189, 190,
/* 250 */ 107, 53, 101, 102, 135, 63, 64, 65, 66, 67,
/* 260 */ 68, 69, 70, 71, 72, 73, 74, 75, 11, 77,
/* 270 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
/* 280 */ 186, 150, 93, 23, 19, 96, 97, 98, 93, 24,
/* 290 */ 159, 96, 97, 98, 196, 150, 107, 221, 150, 223,
/* 300 */ 224, 203, 107, 105, 173, 174, 150, 159, 231, 52,
/* 310 */ 45, 46, 245, 246, 169, 170, 109, 241, 111, 112,
/* 320 */ 150, 173, 174, 109, 193, 111, 112, 135, 63, 64,
/* 330 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
/* 340 */ 75, 193, 77, 78, 79, 80, 81, 82, 83, 84,
/* 350 */ 85, 86, 87, 19, 19, 164, 150, 154, 24, 102,
/* 360 */ 103, 104, 150, 215, 173, 150, 160, 161, 220, 109,
/* 370 */ 113, 111, 112, 45, 46, 230, 231, 150, 150, 45,
/* 380 */ 46, 150, 212, 52, 150, 173, 174, 182, 173, 174,
/* 390 */ 184, 185, 159, 150, 66, 67, 169, 63, 64, 65,
/* 400 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
/* 410 */ 46, 77, 78, 79, 80, 81, 82, 83, 84, 85,
/* 420 */ 86, 87, 19, 95, 86, 87, 193, 215, 213, 214,
/* 430 */ 95, 228, 220, 102, 103, 104, 233, 150, 205, 206,
/* 440 */ 150, 26, 171, 172, 113, 159, 212, 216, 45, 46,
/* 450 */ 47, 180, 24, 165, 26, 180, 181, 230, 231, 17,
/* 460 */ 173, 174, 187, 173, 174, 101, 63, 64, 65, 66,
/* 470 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 193,
/* 480 */ 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
/* 490 */ 87, 19, 204, 172, 25, 23, 81, 55, 150, 57,
/* 500 */ 150, 180, 215, 217, 214, 23, 91, 92, 150, 221,
/* 510 */ 150, 223, 224, 142, 143, 144, 145, 45, 46, 91,
/* 520 */ 234, 173, 174, 173, 174, 239, 165, 22, 17, 22,
/* 530 */ 23, 26, 25, 173, 174, 63, 64, 65, 66, 67,
/* 540 */ 68, 69, 70, 71, 72, 73, 74, 75, 12, 77,
/* 550 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
/* 560 */ 19, 23, 150, 27, 23, 204, 55, 219, 57, 62,
/* 570 */ 23, 26, 25, 25, 216, 225, 40, 26, 42, 219,
/* 580 */ 26, 94, 95, 159, 22, 116, 45, 46, 26, 150,
/* 590 */ 23, 109, 25, 111, 112, 26, 91, 92, 186, 160,
/* 600 */ 161, 165, 166, 167, 63, 64, 65, 66, 67, 68,
/* 610 */ 69, 70, 71, 72, 73, 74, 75, 193, 77, 78,
/* 620 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 19,
/* 630 */ 19, 30, 159, 23, 83, 150, 91, 92, 37, 92,
/* 640 */ 92, 217, 91, 92, 150, 91, 92, 109, 137, 111,
/* 650 */ 112, 150, 159, 91, 92, 45, 46, 46, 173, 174,
/* 660 */ 91, 92, 117, 239, 117, 117, 193, 102, 103, 104,
/* 670 */ 23, 117, 25, 63, 64, 65, 66, 67, 68, 69,
/* 680 */ 70, 71, 72, 73, 74, 75, 193, 77, 78, 79,
/* 690 */ 80, 81, 82, 83, 84, 85, 86, 87, 19, 150,
/* 700 */ 28, 87, 23, 150, 32, 150, 26, 150, 22, 150,
/* 710 */ 150, 150, 101, 23, 150, 25, 44, 106, 0, 1,
/* 720 */ 2, 150, 173, 174, 45, 46, 173, 174, 173, 174,
/* 730 */ 173, 174, 173, 174, 173, 174, 159, 173, 174, 7,
/* 740 */ 8, 9, 63, 64, 65, 66, 67, 68, 69, 70,
/* 750 */ 71, 72, 73, 74, 75, 150, 77, 78, 79, 80,
/* 760 */ 81, 82, 83, 84, 85, 86, 87, 19, 150, 110,
/* 770 */ 193, 91, 150, 114, 150, 83, 150, 25, 173, 174,
/* 780 */ 150, 189, 190, 212, 150, 150, 150, 102, 103, 104,
/* 790 */ 150, 173, 174, 45, 46, 173, 174, 173, 174, 173,
/* 800 */ 174, 115, 110, 173, 174, 159, 114, 173, 174, 173,
/* 810 */ 174, 63, 64, 65, 66, 67, 68, 69, 70, 71,
/* 820 */ 72, 73, 74, 75, 150, 77, 78, 79, 80, 81,
/* 830 */ 82, 83, 84, 85, 86, 87, 19, 150, 94, 193,
/* 840 */ 159, 150, 23, 150, 25, 150, 150, 173, 174, 150,
/* 850 */ 247, 248, 100, 150, 144, 145, 150, 113, 81, 82,
/* 860 */ 1, 2, 45, 46, 173, 174, 173, 174, 173, 174,
/* 870 */ 165, 127, 173, 174, 193, 150, 173, 174, 150, 192,
/* 880 */ 63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
/* 890 */ 73, 74, 75, 150, 77, 78, 79, 80, 81, 82,
/* 900 */ 83, 84, 85, 86, 87, 19, 150, 150, 150, 204,
/* 910 */ 150, 186, 150, 23, 150, 25, 173, 174, 150, 23,
/* 920 */ 192, 25, 23, 150, 25, 150, 7, 8, 207, 173,
/* 930 */ 174, 45, 46, 173, 174, 173, 174, 173, 174, 22,
/* 940 */ 150, 173, 174, 186, 186, 23, 173, 174, 173, 174,
/* 950 */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
/* 960 */ 74, 75, 150, 77, 78, 79, 80, 81, 82, 83,
/* 970 */ 84, 85, 86, 87, 19, 21, 150, 150, 22, 150,
/* 980 */ 24, 150, 192, 150, 62, 173, 174, 150, 71, 23,
/* 990 */ 150, 25, 150, 128, 129, 25, 23, 134, 25, 136,
/* 1000 */ 45, 46, 173, 174, 173, 174, 173, 174, 148, 173,
/* 1010 */ 173, 174, 58, 185, 150, 173, 174, 150, 192, 192,
/* 1020 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
/* 1030 */ 75, 150, 77, 78, 79, 80, 81, 82, 83, 84,
/* 1040 */ 85, 86, 87, 19, 20, 150, 22, 150, 150, 236,
/* 1050 */ 26, 97, 150, 150, 173, 174, 150, 150, 34, 192,
/* 1060 */ 173, 150, 150, 150, 150, 150, 19, 20, 242, 22,
/* 1070 */ 173, 174, 227, 26, 150, 51, 173, 174, 150, 173,
/* 1080 */ 174, 34, 150, 165, 150, 61, 173, 174, 232, 198,
/* 1090 */ 192, 137, 176, 150, 192, 125, 176, 150, 51, 192,
/* 1100 */ 177, 176, 150, 182, 232, 81, 82, 83, 61, 176,
/* 1110 */ 150, 176, 208, 165, 90, 91, 92, 190, 165, 95,
/* 1120 */ 181, 150, 165, 185, 198, 195, 197, 150, 81, 82,
/* 1130 */ 63, 153, 188, 36, 240, 115, 156, 90, 91, 92,
/* 1140 */ 125, 156, 95, 198, 208, 150, 188, 150, 113, 182,
/* 1150 */ 150, 150, 128, 129, 130, 131, 132, 133, 5, 195,
/* 1160 */ 113, 6, 201, 10, 11, 12, 13, 14, 149, 16,
/* 1170 */ 22, 149, 156, 191, 18, 128, 129, 130, 131, 132,
/* 1180 */ 133, 218, 29, 120, 31, 210, 149, 19, 20, 13,
/* 1190 */ 22, 38, 151, 140, 26, 188, 18, 155, 122, 218,
/* 1200 */ 156, 199, 34, 50, 198, 52, 198, 43, 243, 56,
/* 1210 */ 183, 134, 59, 226, 240, 25, 158, 134, 149, 51,
/* 1220 */ 101, 238, 209, 123, 210, 200, 209, 41, 237, 61,
/* 1230 */ 191, 151, 209, 193, 156, 156, 210, 191, 22, 178,
/* 1240 */ 229, 87, 101, 175, 156, 175, 175, 229, 155, 81,
/* 1250 */ 82, 178, 100, 179, 156, 102, 103, 104, 90, 91,
/* 1260 */ 92, 108, 175, 95, 175, 183, 113, 177, 155, 175,
/* 1270 */ 175, 155, 163, 156, 156, 124, 150, 202, 179, 249,
/* 1280 */ 235, 156, 246, 191, 121, 150, 23, 115, 139, 208,
/* 1290 */ 23, 138, 48, 116, 115, 24, 128, 129, 130, 131,
/* 1300 */ 132, 133, 127, 115, 1, 105, 22, 19, 25, 20,
/* 1310 */ 1, 47, 22, 48, 20, 11, 25, 137, 22, 118,
/* 1320 */ 105, 126, 22, 17, 95, 71, 4, 22, 126, 71,
/* 1330 */ 23, 23, 22, 15, 23, 22, 22, 25, 22, 47,
/* 1340 */ 1, 101, 23, 119, 117, 120, 17, 54, 25, 101,
/* 1350 */ 3, 23, 115, 23, 39, 23, 115, 5, 119, 106,
/* 1360 */ 23, 99, 22, 22, 47, 119, 116, 110, 35, 15,
/* 1370 */ 22, 22, 250, 250, 250, 250, 250, 250, 250, 250,
/* 1380 */ 60,
/* 40 */ 88, 89, 186, 19, 26, 85, 65, 66, 67, 68,
/* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 165,
/* 60 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
/* 70 */ 89, 19, 112, 19, 93, 34, 116, 25, 79, 80,
/* 80 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 26,
/* 90 */ 162, 26, 22, 165, 166, 167, 55, 89, 204, 47,
/* 100 */ 48, 83, 172, 51, 96, 97, 98, 99, 100, 101,
/* 110 */ 180, 93, 94, 104, 105, 106, 108, 65, 66, 67,
/* 120 */ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
/* 130 */ 11, 79, 80, 81, 82, 83, 84, 85, 86, 87,
/* 140 */ 88, 89, 19, 89, 120, 150, 83, 84, 107, 95,
/* 150 */ 96, 97, 98, 99, 100, 101, 93, 94, 93, 94,
/* 160 */ 95, 150, 108, 98, 99, 100, 103, 104, 173, 174,
/* 170 */ 47, 48, 150, 54, 109, 83, 84, 85, 86, 87,
/* 180 */ 88, 89, 150, 63, 173, 174, 12, 117, 65, 66,
/* 190 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
/* 200 */ 77, 27, 79, 80, 81, 82, 83, 84, 85, 86,
/* 210 */ 87, 88, 89, 93, 19, 25, 42, 97, 44, 221,
/* 220 */ 225, 223, 224, 104, 105, 106, 146, 147, 54, 150,
/* 230 */ 219, 150, 152, 150, 115, 168, 169, 170, 150, 159,
/* 240 */ 205, 206, 47, 48, 85, 86, 87, 88, 89, 129,
/* 250 */ 130, 131, 173, 174, 173, 174, 150, 169, 170, 136,
/* 260 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
/* 270 */ 75, 76, 77, 193, 79, 80, 81, 82, 83, 84,
/* 280 */ 85, 86, 87, 88, 89, 95, 19, 19, 98, 99,
/* 290 */ 100, 24, 213, 214, 150, 212, 215, 217, 231, 109,
/* 300 */ 164, 220, 150, 95, 160, 161, 98, 99, 100, 173,
/* 310 */ 23, 159, 25, 54, 47, 48, 48, 109, 230, 231,
/* 320 */ 196, 168, 169, 170, 244, 173, 174, 203, 184, 185,
/* 330 */ 150, 136, 65, 66, 67, 68, 69, 70, 71, 72,
/* 340 */ 73, 74, 75, 76, 77, 193, 79, 80, 81, 82,
/* 350 */ 83, 84, 85, 86, 87, 88, 89, 19, 159, 150,
/* 360 */ 171, 172, 24, 104, 105, 106, 150, 215, 159, 180,
/* 370 */ 150, 103, 220, 150, 115, 221, 108, 223, 224, 47,
/* 380 */ 48, 23, 173, 174, 231, 47, 48, 189, 190, 173,
/* 390 */ 174, 165, 193, 173, 174, 241, 173, 174, 159, 150,
/* 400 */ 68, 69, 193, 65, 66, 67, 68, 69, 70, 71,
/* 410 */ 72, 73, 74, 75, 76, 77, 217, 79, 80, 81,
/* 420 */ 82, 83, 84, 85, 86, 87, 88, 89, 19, 97,
/* 430 */ 204, 215, 193, 234, 23, 150, 150, 194, 239, 150,
/* 440 */ 150, 150, 22, 182, 205, 206, 26, 221, 157, 223,
/* 450 */ 224, 160, 161, 159, 169, 115, 47, 48, 49, 173,
/* 460 */ 174, 212, 173, 174, 142, 143, 144, 145, 128, 111,
/* 470 */ 17, 113, 114, 150, 65, 66, 67, 68, 69, 70,
/* 480 */ 71, 72, 73, 74, 75, 76, 77, 193, 79, 80,
/* 490 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 19,
/* 500 */ 214, 22, 23, 23, 25, 12, 23, 23, 219, 25,
/* 510 */ 57, 217, 59, 93, 94, 230, 231, 26, 150, 23,
/* 520 */ 27, 26, 111, 150, 113, 114, 150, 47, 48, 180,
/* 530 */ 181, 22, 23, 239, 25, 42, 187, 44, 245, 246,
/* 540 */ 22, 173, 174, 64, 26, 65, 66, 67, 68, 69,
/* 550 */ 70, 71, 72, 73, 74, 75, 76, 77, 150, 79,
/* 560 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
/* 570 */ 19, 150, 154, 64, 23, 26, 85, 150, 94, 189,
/* 580 */ 190, 173, 174, 96, 93, 94, 28, 19, 93, 94,
/* 590 */ 32, 138, 26, 150, 111, 150, 113, 114, 47, 48,
/* 600 */ 173, 174, 115, 119, 46, 160, 161, 111, 150, 113,
/* 610 */ 114, 93, 94, 192, 119, 128, 65, 66, 67, 68,
/* 620 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 186,
/* 630 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
/* 640 */ 89, 19, 93, 94, 186, 23, 228, 23, 150, 25,
/* 650 */ 150, 233, 150, 24, 150, 26, 150, 22, 150, 93,
/* 660 */ 150, 26, 150, 26, 111, 97, 113, 114, 119, 47,
/* 670 */ 48, 173, 174, 173, 174, 173, 174, 173, 174, 173,
/* 680 */ 174, 173, 174, 173, 174, 173, 174, 65, 66, 67,
/* 690 */ 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
/* 700 */ 150, 79, 80, 81, 82, 83, 84, 85, 86, 87,
/* 710 */ 88, 89, 19, 150, 150, 150, 23, 247, 248, 150,
/* 720 */ 159, 150, 93, 173, 174, 150, 150, 150, 93, 150,
/* 730 */ 93, 94, 150, 0, 1, 2, 173, 174, 173, 174,
/* 740 */ 47, 48, 173, 174, 173, 174, 88, 89, 173, 174,
/* 750 */ 173, 174, 173, 174, 193, 173, 174, 150, 65, 66,
/* 760 */ 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
/* 770 */ 77, 150, 79, 80, 81, 82, 83, 84, 85, 86,
/* 780 */ 87, 88, 89, 19, 150, 207, 150, 7, 8, 9,
/* 790 */ 150, 23, 150, 25, 173, 174, 150, 96, 97, 150,
/* 800 */ 150, 150, 150, 150, 104, 105, 106, 173, 174, 173,
/* 810 */ 174, 47, 48, 173, 174, 173, 174, 150, 150, 173,
/* 820 */ 174, 150, 173, 174, 173, 174, 173, 174, 150, 65,
/* 830 */ 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
/* 840 */ 76, 77, 150, 79, 80, 81, 82, 83, 84, 85,
/* 850 */ 86, 87, 88, 89, 19, 150, 23, 150, 25, 192,
/* 860 */ 192, 150, 25, 192, 150, 173, 174, 150, 216, 23,
/* 870 */ 150, 25, 150, 150, 150, 150, 144, 145, 173, 174,
/* 880 */ 173, 174, 47, 48, 173, 174, 150, 173, 174, 22,
/* 890 */ 173, 174, 17, 173, 174, 173, 174, 173, 174, 159,
/* 900 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
/* 910 */ 75, 76, 77, 242, 79, 80, 81, 82, 83, 84,
/* 920 */ 85, 86, 87, 88, 89, 19, 21, 150, 159, 159,
/* 930 */ 159, 94, 57, 193, 59, 150, 25, 212, 83, 84,
/* 940 */ 73, 23, 150, 25, 1, 2, 7, 8, 129, 130,
/* 950 */ 173, 174, 216, 47, 48, 25, 119, 150, 165, 165,
/* 960 */ 148, 150, 193, 193, 193, 60, 150, 150, 23, 23,
/* 970 */ 25, 186, 66, 67, 68, 69, 70, 71, 72, 73,
/* 980 */ 74, 75, 76, 77, 192, 79, 80, 81, 82, 83,
/* 990 */ 84, 85, 86, 87, 88, 89, 19, 204, 204, 192,
/* 1000 */ 150, 150, 186, 192, 99, 23, 30, 25, 112, 192,
/* 1010 */ 64, 22, 116, 24, 48, 39, 23, 25, 25, 97,
/* 1020 */ 23, 135, 25, 137, 47, 48, 89, 173, 150, 118,
/* 1030 */ 108, 236, 102, 185, 173, 150, 227, 150, 150, 150,
/* 1040 */ 150, 150, 192, 138, 67, 68, 69, 70, 71, 72,
/* 1050 */ 73, 74, 75, 76, 77, 176, 79, 80, 81, 82,
/* 1060 */ 83, 84, 85, 86, 87, 88, 89, 19, 20, 103,
/* 1070 */ 22, 150, 165, 150, 26, 176, 182, 232, 198, 19,
/* 1080 */ 20, 150, 22, 35, 176, 150, 26, 177, 150, 176,
/* 1090 */ 208, 176, 190, 198, 150, 35, 232, 165, 165, 195,
/* 1100 */ 208, 53, 150, 150, 185, 165, 197, 181, 153, 65,
/* 1110 */ 38, 63, 188, 53, 240, 117, 156, 126, 126, 156,
/* 1120 */ 150, 150, 188, 63, 182, 198, 115, 6, 150, 150,
/* 1130 */ 201, 83, 84, 85, 149, 22, 195, 156, 218, 149,
/* 1140 */ 92, 93, 94, 83, 84, 97, 18, 191, 121, 149,
/* 1150 */ 13, 36, 92, 93, 94, 151, 188, 97, 210, 243,
/* 1160 */ 5, 18, 155, 123, 199, 10, 11, 12, 13, 14,
/* 1170 */ 198, 16, 218, 198, 156, 115, 240, 129, 130, 131,
/* 1180 */ 132, 133, 134, 22, 29, 45, 31, 26, 183, 129,
/* 1190 */ 130, 131, 132, 133, 134, 40, 135, 25, 19, 20,
/* 1200 */ 226, 22, 135, 158, 149, 26, 103, 52, 209, 54,
/* 1210 */ 124, 238, 200, 58, 35, 209, 61, 43, 210, 191,
/* 1220 */ 237, 151, 209, 191, 63, 210, 193, 156, 22, 156,
/* 1230 */ 178, 89, 53, 103, 175, 156, 178, 175, 229, 229,
/* 1240 */ 175, 175, 63, 155, 83, 84, 102, 183, 156, 175,
/* 1250 */ 155, 175, 177, 175, 93, 155, 179, 156, 97, 104,
/* 1260 */ 105, 106, 83, 84, 156, 110, 125, 163, 179, 249,
/* 1270 */ 115, 92, 93, 94, 235, 246, 97, 150, 191, 156,
/* 1280 */ 122, 150, 202, 23, 117, 140, 23, 118, 50, 208,
/* 1290 */ 129, 130, 131, 117, 139, 24, 128, 117, 1, 107,
/* 1300 */ 22, 19, 25, 20, 1, 49, 22, 50, 129, 130,
/* 1310 */ 131, 132, 133, 134, 25, 138, 11, 22, 20, 120,
/* 1320 */ 107, 127, 22, 17, 97, 73, 22, 127, 4, 15,
/* 1330 */ 23, 23, 22, 1, 23, 73, 49, 22, 22, 103,
/* 1340 */ 22, 56, 25, 23, 121, 33, 17, 119, 25, 103,
/* 1350 */ 41, 3, 117, 23, 23, 5, 117, 23, 33, 108,
/* 1360 */ 23, 22, 49, 22, 37, 101, 33, 118, 22, 15,
/* 1370 */ 112, 22, 250, 250, 250, 250, 250, 250, 250, 250,
/* 1380 */ 250, 62,
};
#define YY_SHIFT_USE_DFLT (-65)
#define YY_SHIFT_USE_DFLT (-67)
#define YY_SHIFT_MAX 404
static const short yy_shift_ofst[] = {
/* 0 */ 859, 1047, 1153, -19, 1047, 1168, 1168, 143, 151, 331,
/* 10 */ 403, 1168, 1168, 1168, 1168, 1168, -48, 257, 415, 569,
/* 20 */ 777, 777, 680, 1035, 50, 610, 541, 472, 679, 192,
/* 30 */ 119, 265, 334, 748, 748, 748, 748, 748, 748, 748,
/* 40 */ 748, 748, 748, 748, 748, 748, 748, 748, 748, 748,
/* 50 */ 748, 748, 817, 886, 955, 955, 1024, 1168, 1168, 1168,
/* 60 */ 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168,
/* 70 */ 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168,
/* 80 */ 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168,
/* 90 */ 1168, 1168, 1168, 1168, 1168, 1168, 1168, -64, -64, -1,
/* 100 */ -1, 52, 6, 140, 954, 611, 569, 569, 338, 680,
/* 110 */ 614, -65, -65, -65, 79, 123, 114, 114, 507, 150,
/* 120 */ 569, 569, 569, 569, 569, 744, 569, 569, 569, 569,
/* 130 */ 718, 569, 428, 569, 569, 569, 569, 569, 569, 569,
/* 140 */ 569, 428, 428, 30, 1035, 1035, 1035, -65, -65, -65,
/* 150 */ -21, 189, -21, 195, 207, 260, 536, 547, 505, 482,
/* 160 */ 551, 545, 554, 538, 562, 569, 198, 214, 569, 569,
/* 170 */ 569, 569, 732, 569, 569, 569, 569, 569, 569, 692,
/* 180 */ 569, 672, 214, 569, 569, 569, 569, 569, 548, 569,
/* 190 */ 214, 569, 569, 569, 569, 569, 214, 569, 569, 569,
/* 200 */ 569, 198, 569, 569, 214, 569, 80, 569, 214, 569,
/* 210 */ 565, 198, 569, 863, -7, 680, 601, 601, 970, 865,
/* 220 */ 601, 752, 601, -7, 601, 970, 865, 680, -7, 659,
/* 230 */ 680, 469, 364, 956, 1067, 1097, 1020, 1015, 1067, 1020,
/* 240 */ 1020, 1151, 1156, 1020, 1163, 1155, 1148, 1020, 1155, 1156,
/* 250 */ 1063, 1155, 1176, 1053, 1067, 1178, 1148, 1076, 1015, 1015,
/* 260 */ 1020, 1097, 1164, 1077, 1190, 1083, 1155, 1119, 1100, 1119,
/* 270 */ 1063, 1186, 1156, 1176, 1119, 1063, 1020, 1156, 1035, 1020,
/* 280 */ 1216, 1154, 1154, 1141, 1020, 1141, 1141, 1216, 1178, 1141,
/* 290 */ 1141, 1152, 1141, 1164, 1020, 1141, 1178, 1178, 1020, -65,
/* 300 */ -65, -65, -65, -65, 328, 511, 685, 442, 72, 335,
/* 310 */ 966, 973, 919, 917, 890, 819, 686, 922, 896, 899,
/* 320 */ 130, 487, 690, 567, 647, 1305, 1308, 1310, 1322, 1318,
/* 330 */ 1313, 1312, 1339, 1319, 1312, 1224, 1227, 1323, 1263, 1330,
/* 340 */ 1317, 1332, 1239, 1337, 1340, 1246, 1257, 1333, 1311, 1229,
/* 350 */ 1201, 1304, 1290, 1283, 1188, 1179, 1172, 1241, 1237, 1328,
/* 360 */ 1347, 1354, 1320, 1349, 1248, 1293, 1315, 1225, 1329, 1240,
/* 370 */ 1258, 1292, 1314, 1316, 1254, 1307, 1202, 1306, 1300, 1195,
/* 380 */ 1215, 1348, 1294, 1296, 1250, 1180, 1265, 1291, 1264, 1341,
/* 390 */ 1289, 1309, 1262, 1288, 1284, 1200, 1303, 1253, 1271, 1175,
/* 400 */ 1352, 1244, 1177, 1267, 1149,
/* 0 */ 943, 1060, 1155, -19, 1060, 1179, 1179, 65, 63, 259,
/* 10 */ 409, 1179, 1179, 1179, 1179, 1179, -48, 119, 18, 637,
/* 20 */ 855, 855, 566, 1011, 52, 622, 551, 480, 693, 195,
/* 30 */ 123, 267, 338, 764, 764, 764, 764, 764, 764, 764,
/* 40 */ 764, 764, 764, 764, 764, 764, 764, 764, 764, 764,
/* 50 */ 764, 764, 835, 906, 977, 977, 1048, 1179, 1179, 1179,
/* 60 */ 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,
/* 70 */ 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,
/* 80 */ 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179,
/* 90 */ 1179, 1179, 1179, 1179, 1179, 1179, 1179, -66, -66, -1,
/* 100 */ -1, 54, 92, 159, 905, 268, 637, 637, 658, 566,
/* 110 */ 937, -67, -67, -67, 1161, 8, 174, 174, 509, 479,
/* 120 */ 637, 637, 637, 637, 637, 487, 637, 637, 637, 637,
/* 130 */ 733, 637, 629, 637, 637, 637, 637, 637, 637, 637,
/* 140 */ 637, 629, 629, 340, 1011, 1011, 1011, -67, -67, -67,
/* 150 */ 120, 190, 120, 208, 358, 411, 493, 484, 420, 483,
/* 160 */ 491, 495, 549, 496, 518, 637, 41, 553, 637, 637,
/* 170 */ 637, 637, 780, 637, 637, 637, 637, 637, 637, -40,
/* 180 */ 637, 558, 553, 637, 637, 637, 637, 637, 837, 637,
/* 190 */ 553, 637, 637, 637, 637, 637, 553, 637, 637, 637,
/* 200 */ 637, 41, 637, 637, 553, 637, 635, 637, 553, 637,
/* 210 */ 9, 41, 637, 886, 24, 566, 976, 976, 992, 819,
/* 220 */ 976, 930, 976, 24, 976, 992, 819, 566, 24, 896,
/* 230 */ 566, 911, 966, 989, 1044, 1072, 998, 991, 1044, 998,
/* 240 */ 998, 1141, 1128, 998, 1158, 1121, 1113, 998, 1121, 1128,
/* 250 */ 1027, 1121, 1137, 1115, 1044, 1143, 1113, 1040, 991, 991,
/* 260 */ 998, 1072, 1140, 1061, 1172, 1067, 1121, 1103, 1086, 1103,
/* 270 */ 1027, 1174, 1128, 1137, 1103, 1027, 998, 1128, 1011, 998,
/* 280 */ 1206, 1142, 1142, 1130, 998, 1130, 1130, 1206, 1143, 1130,
/* 290 */ 1130, 1144, 1130, 1140, 998, 1130, 1143, 1143, 998, -67,
/* 300 */ -67, -67, -67, -67, 332, 453, 700, 875, 922, 568,
/* 310 */ 993, 997, 939, 867, 918, 846, 70, 946, 945, 982,
/* 320 */ 287, 701, 833, 624, 768, 1304, 1308, 1310, 1324, 1314,
/* 330 */ 1315, 1317, 1332, 1320, 1317, 1312, 1228, 1323, 1260, 1331,
/* 340 */ 1313, 1334, 1325, 1337, 1339, 1333, 1258, 1327, 1311, 1227,
/* 350 */ 1199, 1305, 1284, 1277, 1180, 1176, 1167, 1239, 1235, 1330,
/* 360 */ 1348, 1354, 1319, 1349, 1246, 1285, 1309, 1223, 1329, 1236,
/* 370 */ 1262, 1287, 1316, 1318, 1252, 1307, 1200, 1306, 1300, 1194,
/* 380 */ 1213, 1346, 1298, 1295, 1249, 1177, 1257, 1289, 1256, 1341,
/* 390 */ 1283, 1303, 1264, 1282, 1278, 1192, 1297, 1251, 1271, 1168,
/* 400 */ 1350, 1238, 1169, 1263, 1145,
};
#define YY_REDUCE_USE_DFLT (-221)
#define YY_REDUCE_MAX 303
static const short yy_reduce_ofst[] = {
/* 0 */ 371, 148, -49, 288, 131, 212, 215, 206, 145, 286,
/* 10 */ 76, 360, 350, 348, 287, 290, -220, 424, 227, 2,
/* 20 */ -127, 77, 14, 233, -8, -8, -8, -8, -8, -8,
/* 30 */ -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
/* 40 */ -8, -8, -8, -8, -8, -8, -8, -8, -8, -8,
/* 50 */ -8, -8, -8, -8, -8, -8, 553, 485, 557, 691,
/* 60 */ 622, 703, 760, 768, 903, 837, 906, 897, 762, 756,
/* 70 */ 699, 674, 618, 555, 549, 559, 561, 564, 605, 695,
/* 80 */ 764, 624, 626, 630, 634, 636, 831, 693, 833, 743,
/* 90 */ 842, 881, 913, 773, 775, 812, 829, -8, -8, -8,
/* 100 */ -8, 271, -8, -8, 203, 275, 826, 439, -8, 436,
/* 110 */ -8, -8, -8, -8, 191, 321, 59, 592, 603, 603,
/* 120 */ 907, 902, 898, 867, 758, 473, 827, 358, 234, 790,
/* 130 */ 710, 231, 705, 94, 571, 728, 170, 757, 725, 687,
/* 140 */ 412, -92, 361, 646, 681, 493, 577, 98, 67, -181,
/* 150 */ 887, 828, 836, 938, 34, 34, 927, 721, 947, 34,
/* 160 */ 840, 932, 864, 34, 156, -93, 205, 34, 501, 635,
/* 170 */ 640, 706, 860, 915, 914, 977, 997, 995, 1126, 964,
/* 180 */ 1000, 1045, 34, 911, 912, 924, -50, 1135, 721, 696,
/* 190 */ 34, 560, 494, 243, 228, -144, 34, 840, -56, 928,
/* 200 */ 934, 921, 943, 952, 34, 960, 953, 971, 34, 895,
/* 210 */ 813, 967, 1001, 845, 1081, 918, 916, 920, 891, 856,
/* 220 */ 925, 923, 933, 904, 935, 926, 872, 948, 936, 930,
/* 230 */ 957, 929, 939, 978, 944, 894, 980, 945, 958, 985,
/* 240 */ 1118, 1075, 1092, 1125, 961, 1019, 963, 1016, 1022, 982,
/* 250 */ 975, 1037, 1041, 965, 1007, 1042, 981, 1002, 1006, 1008,
/* 260 */ 1044, 974, 1027, 987, 1058, 983, 1069, 1013, 1025, 1017,
/* 270 */ 1014, 991, 1039, 1080, 1023, 1026, 1078, 1046, 1040, 1079,
/* 280 */ 1061, 1011, 1018, 1068, 1088, 1070, 1071, 1073, 1093, 1087,
/* 290 */ 1089, 1090, 1094, 1082, 1098, 1095, 1113, 1116, 1117, 1074,
/* 300 */ 1099, 1109, 1030, 1036,
/* 0 */ 322, 152, 80, 226, 209, 81, 79, 144, 88, 199,
/* 10 */ 154, 289, -5, 11, 216, 286, -220, 294, 285, 291,
/* 20 */ 67, 153, -72, 239, -2, -2, -2, -2, -2, -2,
/* 30 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
/* 40 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
/* 50 */ -2, -2, -2, -2, -2, -2, 427, 368, 500, 571,
/* 60 */ 508, 582, 636, 646, 722, 711, 724, 720, 640, 634,
/* 70 */ 579, 569, 506, 498, 408, 502, 504, 220, 223, 577,
/* 80 */ 642, 510, 512, 550, 563, 565, 705, 575, 707, 621,
/* 90 */ 714, 717, 777, 649, 651, 653, 692, -2, -2, -2,
/* 100 */ -2, 189, -2, -2, 418, 349, 671, 445, -2, -141,
/* 110 */ -2, -2, -2, -2, 136, -70, 198, 390, 470, 470,
/* 120 */ 850, 817, 811, 807, 816, 561, 792, 736, 249, 668,
/* 130 */ 732, 652, 794, -144, 725, 667, 83, 785, 458, 421,
/* 140 */ 443, -106, 793, 770, 771, 740, 769, 124, 293, 35,
/* 150 */ 861, 848, 854, 919, 243, 243, 902, 578, 935, 243,
/* 160 */ 723, 921, 851, 243, 180, 22, 261, 243, 376, 576,
/* 170 */ 607, 678, 812, 889, 888, 953, 971, 970, 1127, 941,
/* 180 */ 978, 1039, 243, 885, 887, 890, 106, 1131, 578, 650,
/* 190 */ 243, 564, 373, 323, 290, -138, 243, 723, 32, 891,
/* 200 */ 923, 894, 931, 938, 243, 944, 933, 952, 243, 878,
/* 210 */ 795, 942, 979, 809, 1081, 907, 879, 899, 880, 845,
/* 220 */ 908, 910, 913, 882, 915, 895, 864, 932, 892, 904,
/* 230 */ 940, 909, 926, 955, 924, 874, 960, 927, 934, 963,
/* 240 */ 1108, 1080, 1087, 1123, 929, 985, 920, 981, 990, 956,
/* 250 */ 948, 1000, 1004, 916, 968, 1007, 954, 965, 972, 975,
/* 260 */ 1018, 936, 1005, 974, 1045, 973, 1055, 999, 1012, 1006,
/* 270 */ 1008, 983, 1028, 1070, 1013, 1015, 1071, 1032, 1033, 1073,
/* 280 */ 1052, 1009, 1010, 1059, 1079, 1062, 1065, 1058, 1088, 1066,
/* 290 */ 1074, 1075, 1076, 1064, 1092, 1078, 1095, 1100, 1101, 1077,
/* 300 */ 1089, 1104, 1020, 1029,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 615, 848, 929, 736, 929, 848, 929, 929, 875, 929,
@ -629,9 +629,9 @@ static const YYCODETYPE yyFallback[] = {
26, /* EXCLUSIVE => ID */
0, /* COMMIT => nothing */
26, /* END => ID */
0, /* ROLLBACK => nothing */
0, /* SAVEPOINT => nothing */
0, /* RELEASE => nothing */
26, /* ROLLBACK => ID */
26, /* SAVEPOINT => ID */
26, /* RELEASE => ID */
0, /* TO => nothing */
0, /* CREATE => nothing */
0, /* TABLE => nothing */
@ -650,8 +650,10 @@ static const YYCODETYPE yyFallback[] = {
26, /* ASC => ID */
26, /* ATTACH => ID */
26, /* BEFORE => ID */
26, /* BY => ID */
26, /* CASCADE => ID */
26, /* CAST => ID */
26, /* COLUMNKW => ID */
26, /* CONFLICT => ID */
26, /* DATABASE => ID */
26, /* DESC => ID */
@ -736,7 +738,6 @@ static const YYCODETYPE yyFallback[] = {
0, /* FROM => nothing */
0, /* JOIN => nothing */
0, /* INDEXED => nothing */
0, /* BY => nothing */
0, /* USING => nothing */
0, /* ORDER => nothing */
0, /* GROUP => nothing */
@ -757,7 +758,6 @@ static const YYCODETYPE yyFallback[] = {
0, /* INDEX => nothing */
0, /* ALTER => nothing */
0, /* ADD => nothing */
0, /* COLUMNKW => nothing */
};
#endif /* YYFALLBACK */
@ -844,34 +844,34 @@ static const char *const yyTokenName[] = {
"EXISTS", "TEMP", "LP", "RP",
"AS", "COMMA", "ID", "ABORT",
"AFTER", "ANALYZE", "ASC", "ATTACH",
"BEFORE", "CASCADE", "CAST", "CONFLICT",
"DATABASE", "DESC", "DETACH", "EACH",
"FAIL", "FOR", "IGNORE", "INITIALLY",
"INSTEAD", "LIKE_KW", "MATCH", "KEY",
"OF", "OFFSET", "PRAGMA", "RAISE",
"REPLACE", "RESTRICT", "ROW", "TRIGGER",
"VACUUM", "VIEW", "VIRTUAL", "REINDEX",
"RENAME", "CTIME_KW", "ANY", "OR",
"AND", "IS", "BETWEEN", "IN",
"ISNULL", "NOTNULL", "NE", "EQ",
"GT", "LE", "LT", "GE",
"ESCAPE", "BITAND", "BITOR", "LSHIFT",
"RSHIFT", "PLUS", "MINUS", "STAR",
"SLASH", "REM", "CONCAT", "COLLATE",
"UMINUS", "UPLUS", "BITNOT", "STRING",
"JOIN_KW", "CONSTRAINT", "DEFAULT", "NULL",
"PRIMARY", "UNIQUE", "CHECK", "REFERENCES",
"AUTOINCR", "ON", "DELETE", "UPDATE",
"INSERT", "SET", "DEFERRABLE", "FOREIGN",
"DROP", "UNION", "ALL", "EXCEPT",
"INTERSECT", "SELECT", "DISTINCT", "DOT",
"FROM", "JOIN", "INDEXED", "BY",
"USING", "ORDER", "GROUP", "HAVING",
"LIMIT", "WHERE", "INTO", "VALUES",
"INTEGER", "FLOAT", "BLOB", "REGISTER",
"VARIABLE", "CASE", "WHEN", "THEN",
"ELSE", "INDEX", "ALTER", "ADD",
"COLUMNKW", "error", "input", "cmdlist",
"BEFORE", "BY", "CASCADE", "CAST",
"COLUMNKW", "CONFLICT", "DATABASE", "DESC",
"DETACH", "EACH", "FAIL", "FOR",
"IGNORE", "INITIALLY", "INSTEAD", "LIKE_KW",
"MATCH", "KEY", "OF", "OFFSET",
"PRAGMA", "RAISE", "REPLACE", "RESTRICT",
"ROW", "TRIGGER", "VACUUM", "VIEW",
"VIRTUAL", "REINDEX", "RENAME", "CTIME_KW",
"ANY", "OR", "AND", "IS",
"BETWEEN", "IN", "ISNULL", "NOTNULL",
"NE", "EQ", "GT", "LE",
"LT", "GE", "ESCAPE", "BITAND",
"BITOR", "LSHIFT", "RSHIFT", "PLUS",
"MINUS", "STAR", "SLASH", "REM",
"CONCAT", "COLLATE", "UMINUS", "UPLUS",
"BITNOT", "STRING", "JOIN_KW", "CONSTRAINT",
"DEFAULT", "NULL", "PRIMARY", "UNIQUE",
"CHECK", "REFERENCES", "AUTOINCR", "ON",
"DELETE", "UPDATE", "INSERT", "SET",
"DEFERRABLE", "FOREIGN", "DROP", "UNION",
"ALL", "EXCEPT", "INTERSECT", "SELECT",
"DISTINCT", "DOT", "FROM", "JOIN",
"INDEXED", "USING", "ORDER", "GROUP",
"HAVING", "LIMIT", "WHERE", "INTO",
"VALUES", "INTEGER", "FLOAT", "BLOB",
"REGISTER", "VARIABLE", "CASE", "WHEN",
"THEN", "ELSE", "INDEX", "ALTER",
"ADD", "error", "input", "cmdlist",
"ecmd", "explain", "cmdx", "cmd",
"transtype", "trans_opt", "nm", "savepoint_opt",
"create_table", "create_table_args", "temp", "ifnotexists",
@ -3386,8 +3386,8 @@ static void yy_reduce(
if( yysize ){
yypParser->yyidx++;
yymsp -= yysize-1;
yymsp->stateno = yyact;
yymsp->major = yygoto;
yymsp->stateno = (YYACTIONTYPE)yyact;
yymsp->major = (YYCODETYPE)yygoto;
yymsp->minor = yygotominor;
}else
#endif

216
parse.h
View file

@ -30,114 +30,114 @@
#define TK_ASC 30
#define TK_ATTACH 31
#define TK_BEFORE 32
#define TK_CASCADE 33
#define TK_CAST 34
#define TK_CONFLICT 35
#define TK_DATABASE 36
#define TK_DESC 37
#define TK_DETACH 38
#define TK_EACH 39
#define TK_FAIL 40
#define TK_FOR 41
#define TK_IGNORE 42
#define TK_INITIALLY 43
#define TK_INSTEAD 44
#define TK_LIKE_KW 45
#define TK_MATCH 46
#define TK_KEY 47
#define TK_OF 48
#define TK_OFFSET 49
#define TK_PRAGMA 50
#define TK_RAISE 51
#define TK_REPLACE 52
#define TK_RESTRICT 53
#define TK_ROW 54
#define TK_TRIGGER 55
#define TK_VACUUM 56
#define TK_VIEW 57
#define TK_VIRTUAL 58
#define TK_REINDEX 59
#define TK_RENAME 60
#define TK_CTIME_KW 61
#define TK_ANY 62
#define TK_OR 63
#define TK_AND 64
#define TK_IS 65
#define TK_BETWEEN 66
#define TK_IN 67
#define TK_ISNULL 68
#define TK_NOTNULL 69
#define TK_NE 70
#define TK_EQ 71
#define TK_GT 72
#define TK_LE 73
#define TK_LT 74
#define TK_GE 75
#define TK_ESCAPE 76
#define TK_BITAND 77
#define TK_BITOR 78
#define TK_LSHIFT 79
#define TK_RSHIFT 80
#define TK_PLUS 81
#define TK_MINUS 82
#define TK_STAR 83
#define TK_SLASH 84
#define TK_REM 85
#define TK_CONCAT 86
#define TK_COLLATE 87
#define TK_UMINUS 88
#define TK_UPLUS 89
#define TK_BITNOT 90
#define TK_STRING 91
#define TK_JOIN_KW 92
#define TK_CONSTRAINT 93
#define TK_DEFAULT 94
#define TK_NULL 95
#define TK_PRIMARY 96
#define TK_UNIQUE 97
#define TK_CHECK 98
#define TK_REFERENCES 99
#define TK_AUTOINCR 100
#define TK_ON 101
#define TK_DELETE 102
#define TK_UPDATE 103
#define TK_INSERT 104
#define TK_SET 105
#define TK_DEFERRABLE 106
#define TK_FOREIGN 107
#define TK_DROP 108
#define TK_UNION 109
#define TK_ALL 110
#define TK_EXCEPT 111
#define TK_INTERSECT 112
#define TK_SELECT 113
#define TK_DISTINCT 114
#define TK_DOT 115
#define TK_FROM 116
#define TK_JOIN 117
#define TK_INDEXED 118
#define TK_BY 119
#define TK_USING 120
#define TK_ORDER 121
#define TK_GROUP 122
#define TK_HAVING 123
#define TK_LIMIT 124
#define TK_WHERE 125
#define TK_INTO 126
#define TK_VALUES 127
#define TK_INTEGER 128
#define TK_FLOAT 129
#define TK_BLOB 130
#define TK_REGISTER 131
#define TK_VARIABLE 132
#define TK_CASE 133
#define TK_WHEN 134
#define TK_THEN 135
#define TK_ELSE 136
#define TK_INDEX 137
#define TK_ALTER 138
#define TK_ADD 139
#define TK_COLUMNKW 140
#define TK_BY 33
#define TK_CASCADE 34
#define TK_CAST 35
#define TK_COLUMNKW 36
#define TK_CONFLICT 37
#define TK_DATABASE 38
#define TK_DESC 39
#define TK_DETACH 40
#define TK_EACH 41
#define TK_FAIL 42
#define TK_FOR 43
#define TK_IGNORE 44
#define TK_INITIALLY 45
#define TK_INSTEAD 46
#define TK_LIKE_KW 47
#define TK_MATCH 48
#define TK_KEY 49
#define TK_OF 50
#define TK_OFFSET 51
#define TK_PRAGMA 52
#define TK_RAISE 53
#define TK_REPLACE 54
#define TK_RESTRICT 55
#define TK_ROW 56
#define TK_TRIGGER 57
#define TK_VACUUM 58
#define TK_VIEW 59
#define TK_VIRTUAL 60
#define TK_REINDEX 61
#define TK_RENAME 62
#define TK_CTIME_KW 63
#define TK_ANY 64
#define TK_OR 65
#define TK_AND 66
#define TK_IS 67
#define TK_BETWEEN 68
#define TK_IN 69
#define TK_ISNULL 70
#define TK_NOTNULL 71
#define TK_NE 72
#define TK_EQ 73
#define TK_GT 74
#define TK_LE 75
#define TK_LT 76
#define TK_GE 77
#define TK_ESCAPE 78
#define TK_BITAND 79
#define TK_BITOR 80
#define TK_LSHIFT 81
#define TK_RSHIFT 82
#define TK_PLUS 83
#define TK_MINUS 84
#define TK_STAR 85
#define TK_SLASH 86
#define TK_REM 87
#define TK_CONCAT 88
#define TK_COLLATE 89
#define TK_UMINUS 90
#define TK_UPLUS 91
#define TK_BITNOT 92
#define TK_STRING 93
#define TK_JOIN_KW 94
#define TK_CONSTRAINT 95
#define TK_DEFAULT 96
#define TK_NULL 97
#define TK_PRIMARY 98
#define TK_UNIQUE 99
#define TK_CHECK 100
#define TK_REFERENCES 101
#define TK_AUTOINCR 102
#define TK_ON 103
#define TK_DELETE 104
#define TK_UPDATE 105
#define TK_INSERT 106
#define TK_SET 107
#define TK_DEFERRABLE 108
#define TK_FOREIGN 109
#define TK_DROP 110
#define TK_UNION 111
#define TK_ALL 112
#define TK_EXCEPT 113
#define TK_INTERSECT 114
#define TK_SELECT 115
#define TK_DISTINCT 116
#define TK_DOT 117
#define TK_FROM 118
#define TK_JOIN 119
#define TK_INDEXED 120
#define TK_USING 121
#define TK_ORDER 122
#define TK_GROUP 123
#define TK_HAVING 124
#define TK_LIMIT 125
#define TK_WHERE 126
#define TK_INTO 127
#define TK_VALUES 128
#define TK_INTEGER 129
#define TK_FLOAT 130
#define TK_BLOB 131
#define TK_REGISTER 132
#define TK_VARIABLE 133
#define TK_CASE 134
#define TK_WHEN 135
#define TK_THEN 136
#define TK_ELSE 137
#define TK_INDEX 138
#define TK_ALTER 139
#define TK_ADD 140
#define TK_TO_TEXT 141
#define TK_TO_BLOB 142
#define TK_TO_NUMERIC 143

View file

@ -11,7 +11,7 @@
*************************************************************************
** 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"
@ -23,14 +23,13 @@ struct PCache {
PgHdr *pSynced; /* Last synced page in dirty page list */
int nRef; /* Number of referenced pages */
int nMax; /* Configured cache size */
int nMin; /* Configured minimum cache size */
int szPage; /* Size of every page in this cache */
int szExtra; /* Size of extra space for each page */
int bPurgeable; /* True if pages are on backing store */
int (*xStress)(void*,PgHdr*); /* Call to try make a page clean */
void *pStress; /* Argument to xStress */
sqlite3_pcache *pCache; /* Pluggable cache module */
PgHdr *pPage1;
PgHdr *pPage1; /* Reference to page 1 */
};
/*
@ -181,7 +180,6 @@ void sqlite3PcacheOpen(
p->xStress = xStress;
p->pStress = pStress;
p->nMax = 100;
p->nMin = 10;
}
/*
@ -263,14 +261,21 @@ int sqlite3PcacheFetch(
}
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 ){
pCache->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 ){
pCache->pPage1 = pPage;
}
@ -431,9 +436,8 @@ void sqlite3PcacheClose(PCache *pCache){
/*
** Discard the contents of the cache.
*/
int sqlite3PcacheClear(PCache *pCache){
void sqlite3PcacheClear(PCache *pCache){
sqlite3PcacheTruncate(pCache, 0);
return SQLITE_OK;
}
/*

View file

@ -12,7 +12,7 @@
** This header file defines the interface that the sqlite page cache
** 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_
@ -111,7 +111,7 @@ void sqlite3PcacheClose(PCache*);
void sqlite3PcacheClearSyncFlags(PCache *);
/* Discard the contents of the cache */
int sqlite3PcacheClear(PCache*);
void sqlite3PcacheClear(PCache*);
/* Return the total number of outstanding page references */
int sqlite3PcacheRefCount(PCache*);

View file

@ -16,7 +16,7 @@
** If the default page cache implementation is overriden, then neither of
** 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"
@ -201,7 +201,6 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache){
int nByte = sizeof(PgHdr1) + pCache->szPage;
PgHdr1 *p = (PgHdr1 *)pcache1Alloc(nByte);
if( p ){
memset(p, 0, nByte);
if( pCache->bPurgeable ){
pcache1.nCurrentPage++;
}
@ -550,11 +549,13 @@ static void *pcache1Fetch(sqlite3_pcache *p, unsigned int iKey, int createFlag){
if( pPage ){
unsigned int h = iKey % pCache->nHash;
memset(pPage, 0, pCache->szPage + sizeof(PgHdr1));
*(void **)(PGHDR1_TO_PAGE(pPage)) = 0;
pCache->nPage++;
pPage->iKey = iKey;
pPage->pNext = pCache->apHash[h];
pPage->pCache = pCache;
pPage->pLruPrev = 0;
pPage->pLruNext = 0;
pCache->apHash[h] = pPage;
}

View file

@ -11,10 +11,9 @@
*************************************************************************
** 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 <ctype.h>
/* 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 iValue[] = {1, 0, 0, 0, 1, 1, 2};
int i, n;
if( isdigit(*z) ){
if( sqlite3Isdigit(*z) ){
return (u8)atoi(z);
}
n = sqlite3Strlen30(z);

View file

@ -13,10 +13,9 @@
** interface, and routines that contribute to loading the database schema
** 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 <ctype.h>
/*
** Fill the InitData structure with an error message that indicates

View file

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.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"
@ -3365,8 +3365,8 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
if( pFunc->iDistinct>=0 ){
Expr *pE = pFunc->pExpr;
if( pE->pList==0 || pE->pList->nExpr!=1 ){
sqlite3ErrorMsg(pParse, "DISTINCT in aggregate must be followed "
"by an expression");
sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one "
"argument");
pFunc->iDistinct = -1;
}else{
KeyInfo *pKeyInfo = keyInfoFromExprList(pParse, pE->pList);

91
shell.c
View file

@ -12,7 +12,7 @@
** This file contains code to implement the "sqlite" command line
** 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)
/* This needs to come before any includes for MSVC compiler */
@ -227,6 +227,7 @@ static void shellstaticFunc(
){
assert( 0==argc );
assert( zShellStatic );
UNUSED_PARAMETER(argc);
UNUSED_PARAMETER(argv);
sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);
}
@ -929,6 +930,7 @@ static int run_schema_dump_query(
** Text of a help message
*/
static char zHelp[] =
".backup ?DB? FILE Backup DB (default \"main\") to FILE\n"
".bail ON|OFF Stop after hitting an error. Default OFF\n"
".databases List names and files of attached databases\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"
".quit Exit this program\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"
".separator STRING Change separator used by output mode and .import\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;
n = strlen30(azArg[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]);
}else
@ -1452,7 +1491,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){
rc = 2;
}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");
if( alt==0 ){
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
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 ){
struct callback_data data;
char *zErrMsg = 0;

250
sqlite3.h
View file

@ -30,7 +30,7 @@
** the version number) and changes its name to "sqlite3.h" as
** 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_
#define _SQLITE3_H_
@ -107,8 +107,8 @@ extern "C" {
** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z
** are the major version, minor version, and release number.
*/
#define SQLITE_VERSION "3.6.10"
#define SQLITE_VERSION_NUMBER 3006010
#define SQLITE_VERSION "3.6.11"
#define SQLITE_VERSION_NUMBER 3006011
/*
** 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.
**
** 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
** bound set by a compile-time C preprocessor macro named SQLITE_MAX_XYZ.
** For the limit category of SQLITE_LIMIT_XYZ there is a
** [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_".)
** Attempts to increase a limit above its hard upper bound are
** 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
** both their own internal database and also databases that are controlled
** 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
** off the Internet. The internal databases can be given the
** 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>
** KEYWORDS: {limit category} {limit categories}
**
** These constants define various aspects of a [database connection]
** that can be limited in size by calls to [sqlite3_limit()].
** The meanings of the various limits are as follows:
** These constants define various performance limits
** that can be lowered at run-time using [sqlite3_limit()].
** The synopsis of the meanings of the various limits is shown below.
** Additional information is available at [limits | Limits in SQLite].
**
** <dl>
** <dt>SQLITE_LIMIT_LENGTH</dt>
@ -2843,7 +2846,7 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
**
** <dt>SQLITE_LIMIT_COLUMN</dt>
** <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>
**
** <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>
**
** <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>
** <dd>The maximum length of the pattern argument to the LIKE or
** GLOB operators.</dd>
** <dd>The maximum length of the pattern argument to the [LIKE] or
** [GLOB] operators.</dd>
**
** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
** <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}
**
** 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>
** <li> ?
@ -4977,8 +4980,8 @@ int sqlite3_get_autocommit(sqlite3*);
** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600>
**
** The sqlite3_db_handle interface returns the [database connection] handle
** to which a [prepared statement] belongs. The database handle returned by
** sqlite3_db_handle is the same database handle that was the first argument
** to which a [prepared statement] belongs. The [database connection]
** 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
** 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
** 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,
** 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
** cache setting should set it explicitly.
**
** See Also: [SQLite Shared-Cache Mode]
**
** INVARIANTS:
**
** {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_FAULT_INSTALL 9
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
#define SQLITE_TESTCTRL_PENDING_BYTE 11
/*
** 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
** pages before re-requesting the same page, or it can
** allocate a new page and return a pointer to it. If a new
** page is allocated, then it must be completely zeroed before
** it is returned.
** page is allocated, then the first sizeof(void*) bytes of
** 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
** pinned pages associated with the specific cache passed
** as the first argument to xFetch() that can be unpinned. The
** cache implementation should attempt to allocate a new
** cache entry and return a pointer to it. Again, the new
** page should be zeroed before it is returned. If the xFetch()
** method returns NULL when createFlag==2, SQLite assumes that
** a memory allocation failed and returns SQLITE_NOMEM to the
** user.
** cache entry and return a pointer to it. Again, the first
** sizeof(void*) bytes of the page should be zeroed before
** it is returned. If the xFetch() method returns NULL when
** createFlag==2, SQLite assumes that a memory allocation
** failed and returns SQLITE_NOMEM to the user.
** </table>
**
** 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*);
};
/*
** 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
** builds on processors without floating point support.

View file

@ -11,7 +11,7 @@
*************************************************************************
** 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_
#define _SQLITEINT_H_
@ -1618,9 +1618,6 @@ struct WhereLevel {
int addrInTop; /* Top of the IN loop */
} *aInLoop; /* Information about each nested IN operator */
} 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;
/* 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
#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
*/
@ -2258,6 +2279,7 @@ int sqlite3BitvecTest(Bitvec*, u32);
int sqlite3BitvecSet(Bitvec*, u32);
void sqlite3BitvecClear(Bitvec*, u32);
void sqlite3BitvecDestroy(Bitvec*);
u32 sqlite3BitvecSize(Bitvec*);
int sqlite3BitvecBuiltinTest(int,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);
#ifndef SQLITE_AMALGAMATION
extern const unsigned char sqlite3UpperToLower[];
extern const unsigned char sqlite3CtypeMap[];
extern SQLITE_WSD struct Sqlite3Config sqlite3Config;
extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
extern int sqlite3PendingByte;
#endif
void sqlite3RootPageMoved(Db*, int, int);
void sqlite3Reindex(Parse*, Token*, Token*);
@ -2529,6 +2553,7 @@ char sqlite3AffinityType(const Token*);
void sqlite3Analyze(Parse*, Token*, Token*);
int sqlite3InvokeBusyHandler(BusyHandler*);
int sqlite3FindDb(sqlite3*, Token*);
int sqlite3FindDbName(sqlite3 *, const char *);
int sqlite3AnalysisLoad(sqlite3*,int iDB);
void sqlite3DefaultRowEst(Index*);
void sqlite3RegisterLikeFunctions(sqlite3*, int);
@ -2550,6 +2575,9 @@ char *sqlite3StrAccumFinish(StrAccum*);
void sqlite3StrAccumReset(StrAccum*);
void sqlite3SelectDestInit(SelectDest*,int,int);
void sqlite3BackupRestart(sqlite3_backup *);
void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
/*
** The interface to the LEMON-generated parser
*/

View file

@ -16,7 +16,7 @@
** These routines are in a separate files so that they will not be linked
** 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 <stdlib.h>
@ -132,6 +132,7 @@ int sqlite3_get_table(
*pazResult = 0;
if( pnColumn ) *pnColumn = 0;
if( pnRow ) *pnRow = 0;
if( pzErrMsg ) *pzErrMsg = 0;
res.zErrMsg = 0;
res.nResult = 0;
res.nRow = 0;

View file

@ -15,10 +15,9 @@
** individual tokens and sends those tokens one-by-one over to the
** 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 <ctype.h>
#include <stdlib.h>
/*
@ -124,7 +123,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
int i, c;
switch( *z ){
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;
return i;
}
@ -258,7 +257,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
}
case '.': {
#ifndef SQLITE_OMIT_FLOATING_POINT
if( !isdigit(z[1]) )
if( !sqlite3Isdigit(z[1]) )
#endif
{
*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 '5': case '6': case '7': case '8': case '9': {
*tokenType = TK_INTEGER;
for(i=0; isdigit(z[i]); i++){}
for(i=0; sqlite3Isdigit(z[i]); i++){}
#ifndef SQLITE_OMIT_FLOATING_POINT
if( z[i]=='.' ){
i++;
while( isdigit(z[i]) ){ i++; }
while( sqlite3Isdigit(z[i]) ){ i++; }
*tokenType = TK_FLOAT;
}
if( (z[i]=='e' || z[i]=='E') &&
( isdigit(z[i+1])
|| ((z[i+1]=='+' || z[i+1]=='-') && isdigit(z[i+2]))
( sqlite3Isdigit(z[i+1])
|| ((z[i+1]=='+' || z[i+1]=='-') && sqlite3Isdigit(z[i+2]))
)
){
i += 2;
while( isdigit(z[i]) ){ i++; }
while( sqlite3Isdigit(z[i]) ){ i++; }
*tokenType = TK_FLOAT;
}
#endif
@ -300,11 +299,11 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
}
case '?': {
*tokenType = TK_VARIABLE;
for(i=1; isdigit(z[i]); i++){}
for(i=1; sqlite3Isdigit(z[i]); i++){}
return i;
}
case '#': {
for(i=1; isdigit(z[i]); i++){}
for(i=1; sqlite3Isdigit(z[i]); i++){}
if( i>1 ){
/* Parameters of the form #NNN (where NNN is a number) are used
** internally by sqlite3NestedParse. */
@ -328,7 +327,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
}else if( c=='(' && n>0 ){
do{
i++;
}while( (c=z[i])!=0 && !isspace(c) && c!=')' );
}while( (c=z[i])!=0 && !sqlite3Isspace(c) && c!=')' );
if( c==')' ){
i++;
}else{
@ -350,7 +349,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
if( z[1]=='\'' ){
*tokenType = TK_BLOB;
for(i=2; (c=z[i])!=0 && c!='\''; i++){
if( !isxdigit(c) ){
if( !sqlite3Isxdigit(c) ){
*tokenType = TK_ILLEGAL;
}
}

26
util.c
View file

@ -14,12 +14,10 @@
** This file contains functions for allocating memory, comparing
** 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 <stdarg.h>
#include <ctype.h>
/*
** 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);
if( enc==SQLITE_UTF16BE ) z++;
if( *z=='-' || *z=='+' ) z += incr;
if( !isdigit(*(u8*)z) ){
if( !sqlite3Isdigit(*z) ){
return 0;
}
z += incr;
if( realnum ) *realnum = 0;
while( isdigit(*(u8*)z) ){ z += incr; }
while( sqlite3Isdigit(*z) ){ z += incr; }
if( *z=='.' ){
z += incr;
if( !isdigit(*(u8*)z) ) return 0;
while( isdigit(*(u8*)z) ){ z += incr; }
if( !sqlite3Isdigit(*z) ) return 0;
while( sqlite3Isdigit(*z) ){ z += incr; }
if( realnum ) *realnum = 1;
}
if( *z=='e' || *z=='E' ){
z += incr;
if( *z=='+' || *z=='-' ) z += incr;
if( !isdigit(*(u8*)z) ) return 0;
while( isdigit(*(u8*)z) ){ z += incr; }
if( !sqlite3Isdigit(*z) ) return 0;
while( sqlite3Isdigit(*z) ){ z += incr; }
if( realnum ) *realnum = 1;
}
return *z==0;
@ -296,7 +294,7 @@ int sqlite3AtoF(const char *z, double *pResult){
const char *zBegin = z;
LONGDOUBLE_TYPE v1 = 0.0;
int nSignificant = 0;
while( isspace(*(u8*)z) ) z++;
while( sqlite3Isspace(*z) ) z++;
if( *z=='-' ){
sign = -1;
z++;
@ -306,7 +304,7 @@ int sqlite3AtoF(const char *z, double *pResult){
while( z[0]=='0' ){
z++;
}
while( isdigit(*(u8*)z) ){
while( sqlite3Isdigit(*z) ){
v1 = v1*10.0 + (*z - '0');
z++;
nSignificant++;
@ -320,7 +318,7 @@ int sqlite3AtoF(const char *z, double *pResult){
z++;
}
}
while( isdigit(*(u8*)z) ){
while( sqlite3Isdigit(*z) ){
if( nSignificant<18 ){
v1 = v1*10.0 + (*z - '0');
divisor *= 10.0;
@ -341,7 +339,7 @@ int sqlite3AtoF(const char *z, double *pResult){
}else if( *z=='+' ){
z++;
}
while( isdigit(*(u8*)z) ){
while( sqlite3Isdigit(*z) ){
eval = eval*10 + *z - '0';
z++;
}
@ -400,7 +398,7 @@ int sqlite3Atoi64(const char *zNum, i64 *pNum){
int neg;
int i, c;
const char *zStart;
while( isspace(*(u8*)zNum) ) zNum++;
while( sqlite3Isspace(*zNum) ) zNum++;
if( *zNum=='-' ){
neg = 1;
zNum++;

View file

@ -14,7 +14,7 @@
** Most of the code in this file may be omitted by defining the
** 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 "vdbeInt.h"
@ -91,17 +91,17 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
int isMemDb; /* True is vacuuming a :memory: database */
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. */
saved_flags = db->flags;
saved_nChange = db->nChange;
saved_nTotalChange = db->nTotalChange;
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;
pMainPager = sqlite3BtreePager(pMain);
isMemDb = sqlite3PagerFile(pMainPager)->pMethods==0;
@ -265,7 +265,6 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
#ifndef SQLITE_OMIT_AUTOVACUUM
sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
#endif
rc = sqlite3BtreeCommit(pMain);
}
if( rc==SQLITE_OK ){

16
vdbe.c
View file

@ -43,10 +43,9 @@
** in this file for details. If in doubt, do not deviate from existing
** 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 <ctype.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_Multiply: b *= a; break;
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;
break;
}
@ -1874,7 +1874,7 @@ case OP_IfNot: { /* jump, in1 */
c = pOp->p3;
}else{
#ifdef SQLITE_OMIT_FLOATING_POINT
c = sqlite3VdbeIntValue(pIn1);
c = sqlite3VdbeIntValue(pIn1)!=0;
#else
c = sqlite3VdbeRealValue(pIn1)!=0.0;
#endif
@ -3490,7 +3490,7 @@ case OP_NewRowid: { /* out2-prerelease */
** larger than the previous rowid. This has been shown experimentally
** to double the speed of the COPY operation.
*/
int res, rx=SQLITE_OK, cnt;
int res=0, rx=SQLITE_OK, cnt;
i64 x;
cnt = 0;
if( (sqlite3BtreeFlags(pC->pCursor)&(BTREE_INTKEY|BTREE_ZERODATA)) !=
@ -3714,7 +3714,7 @@ case OP_Insert: {
*/
case OP_Delete: {
int i = pOp->p1;
i64 iKey;
i64 iKey = 0;
VdbeCursor *pC;
assert( i>=0 && i<p->nCursor );
@ -4025,7 +4025,7 @@ case OP_Next: { /* jump */
/* Opcode: IdxInsert P1 P2 P3 * *
**
** 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.
**
** 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 rowid of the table entry to which this index entry points.
**
** See also: Rowid, MakeIdxRec.
** See also: Rowid, MakeRecord.
*/
case OP_IdxRowid: { /* out2-prerelease */
int i = pOp->p1;

View file

@ -15,7 +15,7 @@
** 6000 lines long) it was split up into several smaller files and
** 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_
#define _VDBEINT_H_
@ -382,9 +382,6 @@ int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
int sqlite3VdbeReleaseBuffers(Vdbe *p);
#endif
#ifndef NDEBUG
void sqlite3VdbeMemSanity(Mem*);
#endif
int sqlite3VdbeMemTranslate(Mem*, u8);
#ifdef SQLITE_DEBUG
void sqlite3VdbePrintSql(Vdbe*);

View file

@ -13,7 +13,7 @@
** This file contains code use to implement APIs that are part of the
** 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 "vdbeInt.h"
@ -752,7 +752,8 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){
vals = sqlite3_data_count(pStmt);
pOut = &pVm->pResultSet[i];
}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 ){
sqlite3_mutex_enter(pVm->db->mutex);
sqlite3Error(pVm->db, SQLITE_RANGE, 0);

View file

@ -14,10 +14,9 @@
** 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.
**
** $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 <ctype.h>
#include "vdbeInt.h"
@ -963,7 +962,7 @@ void sqlite3VdbePrintSql(Vdbe *p){
pOp = &p->aOp[0];
if( pOp->opcode==OP_Trace && pOp->p4.z!=0 ){
const char *z = pOp->p4.z;
while( isspace(*(u8*)z) ) z++;
while( sqlite3Isspace(*z) ) z++;
printf("SQL: [%s]\n", z);
}
}
@ -983,9 +982,9 @@ void sqlite3VdbeIOTraceSql(Vdbe *p){
int i, j;
char z[1000];
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++){
if( isspace((unsigned char)z[i]) ){
if( sqlite3Isspace(z[i]) ){
if( z[i-1]!=' ' ){
z[j++] = ' ';
}
@ -1388,10 +1387,10 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
/* Sync the master journal file. If the IOCAP_SEQUENTIAL device
** flag is set this is not required.
*/
zMainFile = sqlite3BtreeGetDirname(db->aDb[0].pBt);
if( (needSync
&& (0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL))
&& (rc=sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))!=SQLITE_OK) ){
if( needSync
&& 0==(sqlite3OsDeviceCharacteristics(pMaster)&SQLITE_IOCAP_SEQUENTIAL)
&& SQLITE_OK!=(rc = sqlite3OsSync(pMaster, SQLITE_SYNC_NORMAL))
){
sqlite3OsCloseFree(pMaster);
sqlite3OsDelete(pVfs, zMaster, 0);
sqlite3DbFree(db, zMaster);

View file

@ -15,10 +15,9 @@
** only within the VDBE. Interface routines refer to a Mem using the
** 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 <ctype.h>
#include "vdbeInt.h"
/*
@ -374,17 +373,20 @@ double sqlite3VdbeRealValue(Mem *pMem){
}else if( pMem->flags & MEM_Int ){
return (double)pMem->u.i;
}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;
if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
|| sqlite3VdbeMemNulTerminate(pMem) ){
return 0.0;
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
return (double)0;
}
assert( pMem->z );
sqlite3AtoF(pMem->z, &val);
return val;
}else{
return 0.0;
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
return (double)0;
}
}
@ -870,55 +872,6 @@ int sqlite3VdbeMemFromBtree(
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
** external API. It works in a similar way to sqlite3_value_text(),
** except the data returned is in the encoding specified by the second
@ -1019,7 +972,8 @@ int sqlite3ValueFromExpr(
}else if( op==TK_UMINUS ) {
if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){
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

23
where.c
View file

@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** 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"
@ -888,7 +888,7 @@ static void exprAnalyzeOrTerm(
if( chngToIN ){
int okToChngToIN = 0; /* True if the conversion to IN is valid */
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 */
/* Search for a table and column that appears on one side or the
@ -1547,7 +1547,8 @@ static double bestVirtualIndex(
+ sizeof(*pIdxOrderBy)*nOrderBy );
if( pIdxInfo==0 ){
sqlite3ErrorMsg(pParse, "out of memory");
return 0.0;
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
return (double)0;
}
*ppIdxInfo = pIdxInfo;
@ -1650,7 +1651,8 @@ static double bestVirtualIndex(
pIdxInfo->idxNum = 0;
pIdxInfo->needToFreeIdxStr = 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;
if( pIdxInfo->nOrderBy && !orderByUsable ){
*(int*)&pIdxInfo->nOrderBy = 0;
@ -1679,7 +1681,8 @@ static double bestVirtualIndex(
if( !pIdxInfo->aConstraint[i].usable && pUsage[i].argvIndex>0 ){
sqlite3ErrorMsg(pParse,
"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;
if( pExpr->pSelect!=0 ){
inMultiplier *= 25;
}else if( ALWAYS(pExpr->pList) ){
}else if( pExpr->pList ){
inMultiplier *= pExpr->pList->nExpr + 1;
}
}
@ -3092,12 +3095,14 @@ WhereInfo *sqlite3WhereBegin(
sCost.plan.wsFlags = WHERE_VIRTUALTABLE | WHERE_ORDERBY;
}
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
** inital value of lowestCost in this loop. If it is, then
** 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
#endif
@ -3127,7 +3132,7 @@ WhereInfo *sqlite3WhereBegin(
pLevel->iIdxCur = -1;
}
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
** INDEXED BY clause attached to it, that the named index is being