# # # patch "ChangeLog" # from [2265ee9f8ea8bd515d77ceb6e907f4729f3ccbc9] # to [dca85f9fe8ca9388085fdf412035db13ec3edc16] # # patch "sqlite/attach.c" # from [d73a3505de3fb9e373d0a158978116c4212031d0] # to [514f90623c891143846625afcab409d6b4986565] # # patch "sqlite/btree.c" # from [23bbfb4745e549ca224f6c933a6e9bc106d77f56] # to [ed343b3dbcbc7da9ac481ef2b98c4239fe6d9629] # # patch "sqlite/build.c" # from [b46cd7d0e2daca775d9de0cba8abae1b1625caf4] # to [be0629119df8c1e09050a8fcbf182112f00e3b14] # # patch "sqlite/callback.c" # from [1bf497306c32229114f826707054df7ebe10abf2] # to [d8c5ab1cd6f3b7182b2ee63bf53f1b69c0f74306] # # patch "sqlite/delete.c" # from [ca404d5fd5f678e32f2f46377ad802cd0219aa99] # to [2dea1a83e6ef534346e74fd03114d3a7b16f08fc] # # patch "sqlite/expr.c" # from [9c957fabf95ef62288151eecd5c490a629470666] # to [c85d7bee7d8e3184e00166c2c2ab6edd57b60486] # # patch "sqlite/func.c" # from [93d004b453a5d9aa754e673eef75d3c9527e0f54] # to [380f2f8e555ccbf899e65f01475c4ac13c478dc2] # # patch "sqlite/hash.c" # from [8747cf51d12de46512880dfcf1b68b4e24072863] # to [449f3d6620193aa557f5d86cbc5cc6b87702b185] # # patch "sqlite/hash.h" # from [1b0c445e1c89ff2aaad9b4605ba61375af001e84] # to [1b3f7e2609141fd571f62199fc38687d262e9564] # # patch "sqlite/insert.c" # from [67b3dc11831c58d8703eb502355ad3704ee18f66] # to [1ae4b8ff5549497808e1b57b9243abcb599fd02f] # # patch "sqlite/keywordhash.h" # from [53d6b6630b71e2ec402f2c2ff85e3f7e8e88a3cc] # to [2e5fb8d1a96d93616c86e690bc044dbcc99d4e49] # # patch "sqlite/legacy.c" # from [86b669707b3cefd570e34154e2f6457547d1df4f] # to [fa15d505dd4e45044177ee4d1c6aeaf8c836d390] # # patch "sqlite/main.c" # from [9a42464c44a6532003391486e802e65e88789cfc] # to [5cdd81aaf159836b5ca277192da4f7461fd15078] # # patch "sqlite/os_unix.c" # from [378a89aaf15d83b901c1b73350e91ddecf743986] # to [35ad4d81c90800f509d28580742b67906d289223] # # patch "sqlite/os_win.c" # from [c67a2c46d929cf54c8f80ec5e6079cf684a141a9] # to [8ced9ac82670bbf77492961a2f7ff80a87f1404f] # # patch "sqlite/pager.c" # from [c438aa5fc248e0523e80591eeae33a3993c47278] # to [33186636a07eeaf34028083c32b27b9647556be7] # # patch "sqlite/pager.h" # from [425a9e52d5404158de016799715cbc2c3d685178] # to [43f32f3847421f7502cfbb66f4eb2302b8033818] # # patch "sqlite/parse.c" # from [56d45a7fd03e7c499e1a0bacb81916956b9ec8d7] # to [ba57979ef0f3f4afc8bba8ff550324aa575f243b] # # patch "sqlite/pragma.c" # from [31d3e1b74cab2172807894e70c674d6a577501fd] # to [27d5e395c5d950931c7ac4fe610e7c2993e2fa55] # # patch "sqlite/prepare.c" # from [cf0fc8ebaf94409955ecb09ffeb0099c9ef44693] # to [6afd730cc8851c0920b5f9050294646b1c2ab28c] # # patch "sqlite/printf.c" # from [c7d6ad9efb71c466305297a448308f467b6e2b6e] # to [358b4b585270f92a228e646e7bbb261c65f2a166] # # patch "sqlite/select.c" # from [7d069e875d0eec05129c7e8b9c99422d7c9c6321] # to [ca8ee9b54a52e31c22c23ae5264d323f723d253b] # # patch "sqlite/sqlite3.h" # from [d0605a62334179d9c38bf587ac38b777d6daee2b] # to [8fce4dddf986e8bca2236a84423b2ba4a4ff4bd1] # # patch "sqlite/sqliteInt.h" # from [f61b60f243f1709c943c62cfb6d7a50209080e38] # to [9052a26e0467be0ac0c554fb1f8de671eda2ea0d] # # patch "sqlite/tokenize.c" # from [382b3bb0ca26eb9153b5d20b246ef512a114a24f] # to [91dc520980c0e2fb9265046adf8b7a86eff881dd] # # patch "sqlite/trigger.c" # from [4d3644cbd16959b568c95ae73493402be8021b08] # to [48bbb94c11954c8e132efcc04478efe8304c4196] # # patch "sqlite/update.c" # from [050a7e0ddaac03dec5271712eee62f1a9e699049] # to [34add66fcd3301b33b6e4c4c813f4e408f7ee4a0] # # patch "sqlite/utf.c" # from [1199766bbb0157931a83aa6eede6b6381177be64] # to [1d51225bce1ea8d1978e8ab28e862a0c12c7a8e8] # # patch "sqlite/util.c" # from [405f46fef062b476826d2c171ec21def29563b75] # to [137e6765825863593095cbbeab0e9e4ba1cf575d] # # patch "sqlite/vacuum.c" # from [3865673cc66acd0717ecd517f6b8fdb2a5e7924b] # to [5b37d0f436f8e1ffacd17934e44720b38d2247f9] # # patch "sqlite/vdbe.c" # from [0a7fd81609429bae2b3c326687b02a60a9c01c49] # to [a56ef5de6d91aedf6f1f0db03c65aa01ecbe11ba] # # patch "sqlite/vdbe.h" # from [80ba1c391ec28180dd07a630577f50b22c2062da] # to [44ff995a8b4e87016794095273e9e7300f0001bb] # # patch "sqlite/vdbeInt.h" # from [eb3f86ab08ef11635bc78eb88c3ff13f923c233b] # to [85cd5f81d38edb1b8f4786f407c77a7a3ba636fb] # # patch "sqlite/vdbeaux.c" # from [95f4ed0bc8ed45f16823d84504310495b5dc587d] # to [4002e6b19d7c9719cb81f9797316b9ad118e4370] # # patch "sqlite/vdbemem.c" # from [2034e93b32c14bda6e306bb54e3a8e930b963027] # to [5f0afe3b92bb2c037f8d5d697f7c151fa50783a3] # # patch "sqlite/where.c" # from [c7d71d5e55c9c4c1e948089280fb0dec7c7d1ef6] # to [1ba8eb02aba7eb8b75d7be0635200a14f0bef73a] # ============================================================ --- ChangeLog 2265ee9f8ea8bd515d77ceb6e907f4729f3ccbc9 +++ ChangeLog dca85f9fe8ca9388085fdf412035db13ec3edc16 @@ -1,5 +1,7 @@ 2006-04-07 Matthew Gregan + * sqlite/*: Import SQLite 3.3.5. + * tests/t_mtn_ignore.at: Shuffle the output grepping tests a bit to make failure cases more obvious. ============================================================ --- sqlite/attach.c d73a3505de3fb9e373d0a158978116c4212031d0 +++ sqlite/attach.c 514f90623c891143846625afcab409d6b4986565 @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the ATTACH and DETACH commands. ** -** $Id: attach.c,v 1.49 2006/01/24 12:09:18 danielk1977 Exp $ +** $Id: attach.c,v 1.50 2006/04/05 11:57:37 drh Exp $ */ #include "sqliteInt.h" @@ -185,7 +185,12 @@ } sqlite3ResetInternalSchema(db, 0); db->nDb = iDb; - sqlite3_snprintf(127, zErr, "unable to open database: %s", zFile); + if( rc==SQLITE_NOMEM ){ + sqlite3MallocFailed(); + sqlite3_snprintf(127, zErr, "out of memory"); + }else{ + sqlite3_snprintf(127, zErr, "unable to open database: %s", zFile); + } goto attach_error; } ============================================================ --- sqlite/btree.c 23bbfb4745e549ca224f6c933a6e9bc106d77f56 +++ sqlite/btree.c ed343b3dbcbc7da9ac481ef2b98c4239fe6d9629 @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.314 2006/02/11 01:25:51 drh Exp $ +** $Id: btree.c,v 1.324 2006/04/04 01:54:55 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** For a detailed discussion of BTrees, refer to @@ -388,8 +388,8 @@ u8 wrFlag; /* True if writable */ u8 eState; /* One of the CURSOR_XXX constants (see below) */ #ifndef SQLITE_OMIT_SHARED_CACHE - void *pKey; - i64 nKey; + void *pKey; /* Saved key that was cursor's last known position */ + i64 nKey; /* Size of pKey, or last integer key */ int skip; /* (skip<0) -> Prev() is a no-op. (skip>0) -> Next() is */ #endif }; @@ -469,8 +469,15 @@ /* 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. */ -#define PENDING_BYTE_PAGE(pBt) ((PENDING_BYTE/(pBt)->pageSize)+1) +#ifdef SQLITE_OMIT_DISKIO +# define PENDING_BYTE_PAGE(pBt) 0x7fffffff +#else +# define PENDING_BYTE_PAGE(pBt) ((PENDING_BYTE/(pBt)->pageSize)+1) +#endif /* ** A linked list of the following structures is stored at BtShared.pLock. @@ -867,7 +874,8 @@ } offset = PTRMAP_PTROFFSET(pBt, key); - if( pEType ) *pEType = pPtrmap[offset]; + assert( pEType!=0 ); + *pEType = pPtrmap[offset]; if( pPgno ) *pPgno = get4byte(&pPtrmap[offset+1]); sqlite3pager_unref(pPtrmap); @@ -1273,6 +1281,12 @@ assert( (start + size)<=pPage->pBt->usableSize ); if( size<4 ) size = 4; +#ifdef SQLITE_SECURE_DELETE + /* Overwrite deleted information with zeros when the SECURE_DELETE + ** option is enabled at compile-time */ + memset(&data[start], 0, size); +#endif + /* Add the space back into the linked list of freeblocks */ hdr = pPage->hdrOffset; addr = hdr + 1; @@ -1618,8 +1632,8 @@ ** the right size. This is to guard against size changes that result ** when compiling on a different architecture. */ - assert( sizeof(i64)==8 ); - assert( sizeof(u64)==8 ); + assert( sizeof(i64)==8 || sizeof(i64)==4 ); + assert( sizeof(u64)==8 || sizeof(u64)==4 ); assert( sizeof(u32)==4 ); assert( sizeof(u16)==2 ); assert( sizeof(Pgno)==4 ); @@ -1679,7 +1693,7 @@ assert( (pBt->pageSize & 7)==0 ); /* 8-byte alignment of pageSize */ sqlite3pager_set_pagesize(pBt->pPager, pBt->pageSize); -#ifndef SQLITE_OMIT_SHARED_CACHE +#if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO) /* Add the new btree to the linked list starting at ThreadData.pBtree. ** There is no chance that a malloc() may fail inside of the ** sqlite3ThreadData() call, as the ThreadData structure must have already @@ -1744,7 +1758,7 @@ pTsd->pBtree = pBt->pNext; }else{ BtShared *pPrev; - for(pPrev=pTsd->pBtree; pPrev && pPrev->pNext!=pBt; pPrev=pPrev->pNext); + for(pPrev=pTsd->pBtree; pPrev && pPrev->pNext!=pBt; pPrev=pPrev->pNext){} if( pPrev ){ assert( pTsd==sqlite3ThreadData() ); pPrev->pNext = pBt->pNext; @@ -2457,7 +2471,6 @@ if( rc!=SQLITE_OK ) goto autovacuum_out; put4byte(&pBt->pPage1->aData[32], 0); put4byte(&pBt->pPage1->aData[36], 0); - if( rc!=SQLITE_OK ) goto autovacuum_out; *nTrunc = finSize; assert( finSize!=PENDING_BYTE_PAGE(pBt) ); @@ -3879,6 +3892,15 @@ n = get4byte(&pPage1->aData[36]); put4byte(&pPage1->aData[36], n+1); +#ifdef SQLITE_SECURE_DELETE + /* If the SQLITE_SECURE_DELETE compile-time option is enabled, then + ** always fully overwrite deleted information with zeros. + */ + rc = sqlite3pager_write(pPage->aData); + if( rc ) return rc; + memset(pPage->aData, 0, pPage->pBt->pageSize); +#endif + #ifndef SQLITE_OMIT_AUTOVACUUM /* If the database supports auto-vacuum, write an entry in the pointer-map ** to indicate that the page is free. @@ -3919,7 +3941,9 @@ if( rc ) return rc; put4byte(&pTrunk->aData[4], k+1); put4byte(&pTrunk->aData[8+k*4], pPage->pgno); +#ifndef SQLITE_SECURE_DELETE sqlite3pager_dont_write(pBt->pPager, pPage->pgno); +#endif TRACE(("FREE-PAGE: %d leaf on trunk page %d\n",pPage->pgno,pTrunk->pgno)); } releasePage(pTrunk); @@ -4052,6 +4076,7 @@ n = nPayload; if( n>spaceLeft ) n = spaceLeft; if( n>nSrc ) n = nSrc; + assert( pSrc ); memcpy(pPayload, pSrc, n); nPayload -= n; pPayload += n; @@ -4076,6 +4101,7 @@ MemPage *pThis; unsigned char *aData; + assert( pNewParent!=0 ); if( pgno==0 ) return SQLITE_OK; assert( pBt->pPager!=0 ); aData = sqlite3pager_lookup(pBt->pPager, pgno); @@ -4086,7 +4112,7 @@ if( pThis->pParent!=pNewParent ){ if( pThis->pParent ) sqlite3pager_unref(pThis->pParent->aData); pThis->pParent = pNewParent; - if( pNewParent ) sqlite3pager_ref(pNewParent->aData); + sqlite3pager_ref(pNewParent->aData); } pThis->idxParent = idx; } @@ -4799,6 +4825,7 @@ rc = sqlite3pager_write(pNew->aData); if( rc ) goto balance_cleanup; }else{ + assert( i>0 ); rc = allocatePage(pBt, &pNew, &pgnoNew[i], pgnoNew[i-1], 0); if( rc ) goto balance_cleanup; apNew[i] = pNew; @@ -4950,6 +4977,8 @@ } } assert( j==nCell ); + assert( nOld>0 ); + assert( nNew>0 ); if( (pageFlags & PTF_LEAF)==0 ){ memcpy(&apNew[nNew-1]->aData[8], &apCopy[nOld-1]->aData[8], 4); } @@ -6204,11 +6233,7 @@ IntegrityCk *pCheck, /* Context for the sanity check */ int iPage, /* Page number of the page to check */ MemPage *pParent, /* Parent page */ - char *zParentContext, /* Parent context */ - char *zLowerBound, /* All keys should be greater than this, if not NULL */ - int nLower, /* Number of characters in zLowerBound */ - char *zUpperBound, /* All keys should be less than this, if not NULL */ - int nUpper /* Number of characters in zUpperBound */ + char *zParentContext /* Parent context */ ){ MemPage *pPage; int i, rc, depth, d2, pgno, cnt; @@ -6274,7 +6299,7 @@ checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, zContext); } #endif - d2 = checkTreePage(pCheck,pgno,pPage,zContext,0,0,0,0); + d2 = checkTreePage(pCheck,pgno,pPage,zContext); if( i>0 && d2!=depth ){ checkAppendMsg(pCheck, zContext, "Child page depth differs"); } @@ -6289,7 +6314,7 @@ checkPtrmap(pCheck, pgno, PTRMAP_BTREE, iPage, 0); } #endif - checkTreePage(pCheck, pgno, pPage, zContext,0,0,0,0); + checkTreePage(pCheck, pgno, pPage, zContext); } /* Check for complete coverage of the page @@ -6401,7 +6426,7 @@ checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0, 0); } #endif - checkTreePage(&sCheck, aRoot[i], 0, "List of tree roots: ", 0,0,0,0); + checkTreePage(&sCheck, aRoot[i], 0, "List of tree roots: "); } /* Make sure every page in the file is referenced @@ -6598,17 +6623,23 @@ return (queryTableLock(p, MASTER_ROOT, READ_LOCK)!=SQLITE_OK); } + +#ifndef SQLITE_OMIT_SHARED_CACHE +/* +** Obtain a lock on the table whose root page is iTab. The +** lock is a write lock if isWritelock is true or a read lock +** if it is false. +*/ int sqlite3BtreeLockTable(Btree *p, int iTab, u8 isWriteLock){ int rc = SQLITE_OK; -#ifndef SQLITE_OMIT_SHARED_CACHE u8 lockType = (isWriteLock?WRITE_LOCK:READ_LOCK); rc = queryTableLock(p, iTab, lockType); if( rc==SQLITE_OK ){ rc = lockTable(p, iTab, lockType); } -#endif return rc; } +#endif /* ** The following debugging interface has to be in this file (rather @@ -6623,6 +6654,7 @@ int objc, Tcl_Obj *CONST objv[] ){ +#ifndef SQLITE_OMIT_SHARED_CACHE const ThreadData *pTd = sqlite3ThreadDataReadOnly(); if( pTd->useSharedData ){ BtShared *pBt; @@ -6634,6 +6666,7 @@ } Tcl_SetObjResult(interp, pRet); } +#endif return TCL_OK; } #endif ============================================================ --- sqlite/build.c b46cd7d0e2daca775d9de0cba8abae1b1625caf4 +++ sqlite/build.c be0629119df8c1e09050a8fcbf182112f00e3b14 @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.386 2006/02/10 18:08:09 drh Exp $ +** $Id: build.c,v 1.393 2006/03/24 03:36:26 drh Exp $ */ #include "sqliteInt.h" #include @@ -42,26 +42,28 @@ ** codeTableLocks() functions. */ struct TableLock { - int iDb; - int iTab; - u8 isWriteLock; - const char *zName; + int iDb; /* The database containing the table to be locked */ + int iTab; /* The root page of the table to be locked */ + u8 isWriteLock; /* True for write lock. False for a read lock */ + const char *zName; /* Name of the table */ }; /* -** Have the compiled statement lock the table with rootpage iTab in database -** iDb at the shared-cache level when executed. The isWriteLock argument -** is zero for a read-lock, or non-zero for a write-lock. +** Record the fact that we want to lock a table at run-time. ** -** The zName parameter should point to the unqualified table name. This is -** used to provide a more informative error message should the lock fail. +** The table to be locked has root page iTab and is found in database iDb. +** A read or a write lock can be taken depending on isWritelock. +** +** This routine just records the fact that the lock is desired. The +** code to make the lock occur is generated by a later call to +** codeTableLocks() which occurs during sqlite3FinishCoding(). */ void sqlite3TableLock( - Parse *pParse, - int iDb, - int iTab, - u8 isWriteLock, - const char *zName + Parse *pParse, /* Parsing context */ + int iDb, /* Index of the database containing the table to lock */ + int iTab, /* Root page number of the table to be locked */ + u8 isWriteLock, /* True for a write lock */ + const char *zName /* Name of the table to be locked */ ){ int i; int nBytes; @@ -135,8 +137,8 @@ if( !pParse->pVdbe ){ if( pParse->rc==SQLITE_OK && pParse->nErr ){ pParse->rc = SQLITE_ERROR; + return; } - return; } /* Begin by generating some termination code at the end of the @@ -185,7 +187,7 @@ /* Get the VDBE program ready for execution */ - if( v && pParse->nErr==0 ){ + if( v && pParse->nErr==0 && !sqlite3MallocFailed() ){ FILE *trace = (db->flags & SQLITE_VdbeTrace)!=0 ? stdout : 0; sqlite3VdbeTrace(v, trace); sqlite3VdbeMakeReady(v, pParse->nVar, pParse->nMem+3, @@ -338,7 +340,7 @@ ** it is not unlinked from the Table that it indexes. ** Unlinking from the Table must be done by the calling function. */ -static void sqliteDeleteIndex(sqlite3 *db, Index *p){ +static void sqliteDeleteIndex(Index *p){ Index *pOld; const char *zName = p->zName; @@ -507,7 +509,7 @@ for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){ pNext = pIndex->pNext; assert( pIndex->pSchema==pTable->pSchema ); - sqliteDeleteIndex(db, pIndex); + sqliteDeleteIndex(pIndex); } #ifndef SQLITE_OMIT_FOREIGN_KEY @@ -690,8 +692,7 @@ ** Begin constructing a new table representation in memory. This is ** the first of several action routines that get called in response ** to a CREATE TABLE statement. In particular, this routine is called -** after seeing tokens "CREATE" and "TABLE" and the table name. The -** pStart token is the CREATE and pName is the table name. The isTemp +** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp ** flag is true if the table should be stored in the auxiliary database ** file instead of in the main database file. This is normally the case ** when the "TEMP" or "TEMPORARY" keyword occurs in between @@ -705,7 +706,6 @@ */ void sqlite3StartTable( Parse *pParse, /* Parser context */ - Token *pStart, /* The "CREATE" token */ Token *pName1, /* First part of the name of the table or view */ Token *pName2, /* Second part of the name of the table or view */ int isTemp, /* True if this is a TEMP table */ @@ -1584,7 +1584,7 @@ sqlite3SelectDelete(pSelect); return; } - sqlite3StartTable(pParse, pBegin, pName1, pName2, isTemp, 1, 0); + sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0); p = pParse->pNewTable; if( p==0 || pParse->nErr ){ sqlite3SelectDelete(pSelect); @@ -1727,6 +1727,17 @@ ** used by SQLite when the btree layer moves a table root page. The ** root-page of a table or index in database iDb has changed from iFrom ** to iTo. +** +** Ticket #1728: The symbol table might still contain information +** on tables and/or indices that are the process of being deleted. +** If you are unlucky, one of those deleted indices or tables might +** have the same rootpage number as the real table or index that is +** being moved. So we cannot stop searching after the first match +** because the first match might be for one of the deleted indices +** or tables and not the table/index that is actually being moved. +** We must continue looping until all tables and indices with +** rootpage==iFrom have been converted to have a rootpage of iTo +** in order to be certain that we got the right one. */ #ifndef SQLITE_OMIT_AUTOVACUUM void sqlite3RootPageMoved(Db *pDb, int iFrom, int iTo){ @@ -1738,7 +1749,6 @@ Table *pTab = sqliteHashData(pElem); if( pTab->tnum==iFrom ){ pTab->tnum = iTo; - return; } } pHash = &pDb->pSchema->idxHash; @@ -1746,10 +1756,8 @@ Index *pIdx = sqliteHashData(pElem); if( pIdx->tnum==iFrom ){ pIdx->tnum = iTo; - return; } } - assert(0); } #endif @@ -1925,7 +1933,7 @@ while( pTrigger ){ assert( pTrigger->pSchema==pTab->pSchema || pTrigger->pSchema==db->aDb[1].pSchema ); - sqlite3DropTriggerPtr(pParse, pTrigger, 1); + sqlite3DropTriggerPtr(pParse, pTrigger); pTrigger = pTrigger->pNext; } @@ -2958,7 +2966,7 @@ ** Make sure the TEMP database is open and available for use. Return ** the number of errors. Leave any error messages in the pParse structure. */ -static int sqlite3OpenTempDatabase(Parse *pParse){ +int sqlite3OpenTempDatabase(Parse *pParse){ sqlite3 *db = pParse->db; if( db->aDb[1].pBt==0 && !pParse->explain ){ int rc = sqlite3BtreeFactory(db, 0, 0, MAX_PAGES, &db->aDb[1].pBt); @@ -3018,7 +3026,7 @@ if( iDb>=0 ){ assert( iDbnDb ); assert( db->aDb[iDb].pBt!=0 || iDb==1 ); - assert( iDb<32 ); + assert( iDbcookieMask & mask)==0 ){ pParse->cookieMask |= mask; @@ -3110,7 +3118,7 @@ Table *pTab; /* A table in the database */ for(iDb=0, pDb=db->aDb; iDbnDb; iDb++, pDb++){ - if( pDb==0 ) continue; + assert( pDb!=0 ); for(k=sqliteHashFirst(&pDb->pSchema->tblHash); k; k=sqliteHashNext(k)){ pTab = (Table*)sqliteHashData(k); reindexTable(pParse, pTab, zColl); ============================================================ --- sqlite/callback.c 1bf497306c32229114f826707054df7ebe10abf2 +++ sqlite/callback.c d8c5ab1cd6f3b7182b2ee63bf53f1b69c0f74306 @@ -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.12 2006/01/18 16:51:35 danielk1977 Exp $ +** $Id: callback.c,v 1.14 2006/03/14 11:08:28 drh Exp $ */ #include "sqliteInt.h" @@ -178,9 +178,11 @@ ** return the pColl pointer to be deleted (because it wasn't added ** to the hash table). */ - assert( !pDel || - (sqlite3MallocFailed() && pDel==pColl) ); - sqliteFree(pDel); + assert( !pDel || (sqlite3MallocFailed() && pDel==pColl) ); + if( pDel ){ + sqliteFree(pDel); + pColl = 0; + } } } return pColl; @@ -312,3 +314,54 @@ } return 0; } + +/* +** Free all resources held by the schema structure. The void* argument points +** at a Schema struct. This function does not call sqliteFree() on the +** pointer itself, it just cleans up subsiduary resources (i.e. the contents +** of the schema hash tables). +*/ +void sqlite3SchemaFree(void *p){ + Hash temp1; + Hash temp2; + HashElem *pElem; + Schema *pSchema = (Schema *)p; + + temp1 = pSchema->tblHash; + temp2 = pSchema->trigHash; + sqlite3HashInit(&pSchema->trigHash, SQLITE_HASH_STRING, 0); + sqlite3HashClear(&pSchema->aFKey); + sqlite3HashClear(&pSchema->idxHash); + for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ + sqlite3DeleteTrigger((Trigger*)sqliteHashData(pElem)); + } + sqlite3HashClear(&temp2); + sqlite3HashInit(&pSchema->tblHash, SQLITE_HASH_STRING, 0); + for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ + Table *pTab = sqliteHashData(pElem); + sqlite3DeleteTable(0, pTab); + } + sqlite3HashClear(&temp1); + pSchema->pSeqTab = 0; + pSchema->flags &= ~DB_SchemaLoaded; +} + +/* +** Find and return the schema associated with a BTree. Create +** a new one if necessary. +*/ +Schema *sqlite3SchemaGet(Btree *pBt){ + Schema * p; + if( pBt ){ + p = (Schema *)sqlite3BtreeSchema(pBt,sizeof(Schema),sqlite3SchemaFree); + }else{ + p = (Schema *)sqliteMalloc(sizeof(Schema)); + } + if( p && 0==p->file_format ){ + sqlite3HashInit(&p->tblHash, SQLITE_HASH_STRING, 0); + sqlite3HashInit(&p->idxHash, SQLITE_HASH_STRING, 0); + sqlite3HashInit(&p->trigHash, SQLITE_HASH_STRING, 0); + sqlite3HashInit(&p->aFKey, SQLITE_HASH_STRING, 1); + } + return p; +} ============================================================ --- sqlite/delete.c ca404d5fd5f678e32f2f46377ad802cd0219aa99 +++ sqlite/delete.c 2dea1a83e6ef534346e74fd03114d3a7b16f08fc @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** in order to generate code for DELETE FROM statements. ** -** $Id: delete.c,v 1.121 2006/02/10 02:27:43 danielk1977 Exp $ +** $Id: delete.c,v 1.122 2006/02/24 02:53:50 drh Exp $ */ #include "sqliteInt.h" @@ -382,7 +382,7 @@ ){ int addr; addr = sqlite3VdbeAddOp(v, OP_NotExists, iCur, 0); - sqlite3GenerateRowIndexDelete(db, v, pTab, iCur, 0); + sqlite3GenerateRowIndexDelete(v, pTab, iCur, 0); sqlite3VdbeAddOp(v, OP_Delete, iCur, (count?OPFLAG_NCHANGE:0)); if( count ){ sqlite3VdbeChangeP3(v, -1, pTab->zName, P3_STATIC); @@ -407,7 +407,6 @@ ** deleted. */ void sqlite3GenerateRowIndexDelete( - sqlite3 *db, /* The database containing the index */ Vdbe *v, /* Generate code into this VDBE */ Table *pTab, /* Table containing the row to be deleted */ int iCur, /* Cursor number for the table */ ============================================================ --- sqlite/expr.c 9c957fabf95ef62288151eecd5c490a629470666 +++ sqlite/expr.c c85d7bee7d8e3184e00166c2c2ab6edd57b60486 @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.254 2006/02/10 07:07:15 danielk1977 Exp $ +** $Id: expr.c,v 1.257 2006/03/17 13:56:34 drh Exp $ */ #include "sqliteInt.h" #include @@ -841,11 +841,13 @@ if( pSrcList ){ for(i=0, pItem=pSrcList->a; inSrc; i++, pItem++){ - Table *pTab = pItem->pTab; - int iDb = sqlite3SchemaToIndex(db, pTab->pSchema); + Table *pTab; + int iDb; Column *pCol; - if( pTab==0 ) continue; + pTab = pItem->pTab; + assert( pTab!=0 ); + iDb = sqlite3SchemaToIndex(db, pTab->pSchema); assert( pTab->nCol>0 ); if( zTab ){ if( pItem->zAlias ){ @@ -1379,11 +1381,7 @@ ** expression we need to rerun this code each time. */ if( testAddr>0 && !sqlite3ExprIsConstant(pE2) ){ - VdbeOp *aOp = sqlite3VdbeGetOp(v, testAddr-1); - int j; - for(j=0; j<3; j++){ - aOp[j].opcode = OP_Noop; - } + sqlite3VdbeChangeToNoop(v, testAddr-1, 3); testAddr = 0; } @@ -1692,7 +1690,9 @@ #ifndef SQLITE_OMIT_SUBQUERY case TK_EXISTS: case TK_SELECT: { - sqlite3CodeSubselect(pParse, pExpr); + if( pExpr->iColumn==0 ){ + sqlite3CodeSubselect(pParse, pExpr); + } sqlite3VdbeAddOp(v, OP_MemLoad, pExpr->iColumn, 0); VdbeComment((v, "# load subquery result")); break; ============================================================ --- sqlite/func.c 93d004b453a5d9aa754e673eef75d3c9527e0f54 +++ sqlite/func.c 380f2f8e555ccbf899e65f01475c4ac13c478dc2 @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.121 2006/02/09 22:13:42 drh Exp $ +** $Id: func.c,v 1.126 2006/03/16 16:19:56 drh Exp $ */ #include "sqliteInt.h" #include @@ -121,7 +121,13 @@ switch( sqlite3_value_type(argv[0]) ){ case SQLITE_INTEGER: { i64 iVal = sqlite3_value_int64(argv[0]); - if( iVal<0 ) iVal = iVal * -1; + if( iVal<0 ){ + if( (iVal<<1)==0 ){ + sqlite3_result_error(context, "integer overflow", -1); + return; + } + iVal = -iVal; + } sqlite3_result_int64(context, iVal); break; } @@ -131,7 +137,7 @@ } default: { double rVal = sqlite3_value_double(argv[0]); - if( rVal<0 ) rVal = rVal * -1.0; + if( rVal<0 ) rVal = -rVal; sqlite3_result_double(context, rVal); break; } @@ -195,10 +201,10 @@ if( n>30 ) n = 30; if( n<0 ) n = 0; } - if( SQLITE_NULL==sqlite3_value_type(argv[0]) ) return; + if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; r = sqlite3_value_double(argv[0]); sqlite3_snprintf(sizeof(zBuf),zBuf,"%.*f",n,r); - sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); + sqlite3_result_double(context, atof(zBuf)); } /* @@ -258,9 +264,11 @@ int argc, sqlite3_value **argv ){ - int r; + sqlite_int64 r; sqlite3Randomness(sizeof(r), &r); - sqlite3_result_int(context, r); + if( (r<<1)==0 ) r = 0; /* Prevent 0x8000.... as the result so that we */ + /* can always do abs() of the result */ + sqlite3_result_int64(context, r); } /* @@ -817,9 +825,11 @@ */ typedef struct SumCtx SumCtx; struct SumCtx { - LONGDOUBLE_TYPE sum; /* Sum of terms */ - i64 cnt; /* Number of elements summed */ - u8 approx; /* True if sum is approximate */ + double rSum; /* Floating point sum */ + i64 iSum; /* Integer sum */ + i64 cnt; /* Number of elements summed */ + u8 overflow; /* True if integer overflow seen */ + u8 approx; /* True if non-integer value was input to the sum */ }; /* @@ -849,13 +859,18 @@ if( p && type!=SQLITE_NULL ){ p->cnt++; if( type==SQLITE_INTEGER ){ - p->sum += sqlite3_value_int64(argv[0]); - if( !p->approx ){ - i64 iVal; - p->approx = p->sum!=(LONGDOUBLE_TYPE)(iVal = (i64)p->sum); + i64 v = sqlite3_value_int64(argv[0]); + p->rSum += v; + if( (p->approx|p->overflow)==0 ){ + i64 iNewSum = p->iSum + v; + int s1 = p->iSum >> (sizeof(i64)*8-1); + int s2 = v >> (sizeof(i64)*8-1); + int s3 = iNewSum >> (sizeof(i64)*8-1); + p->overflow = (s1&s2&~s3) | (~s1&~s2&s3); + p->iSum = iNewSum; } }else{ - p->sum += sqlite3_value_double(argv[0]); + p->rSum += sqlite3_value_double(argv[0]); p->approx = 1; } } @@ -864,10 +879,12 @@ SumCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>0 ){ - if( p->approx ){ - sqlite3_result_double(context, p->sum); + if( p->overflow ){ + sqlite3_result_error(context,"integer overflow",-1); + }else if( p->approx ){ + sqlite3_result_double(context, p->rSum); }else{ - sqlite3_result_int64(context, (i64)p->sum); + sqlite3_result_int64(context, p->iSum); } } } @@ -875,13 +892,13 @@ SumCtx *p; p = sqlite3_aggregate_context(context, 0); if( p && p->cnt>0 ){ - sqlite3_result_double(context, p->sum/(double)p->cnt); + sqlite3_result_double(context, p->rSum/(double)p->cnt); } } static void totalFinalize(sqlite3_context *context){ SumCtx *p; p = sqlite3_aggregate_context(context, 0); - sqlite3_result_double(context, p ? p->sum : 0.0); + sqlite3_result_double(context, p ? p->rSum : 0.0); } /* @@ -1062,7 +1079,7 @@ } sqlite3RegisterDateTimeFunctions(db); #ifdef SQLITE_SSE - sqlite3SseFunctions(db); + (void)sqlite3SseFunctions(db); #endif #ifdef SQLITE_CASE_SENSITIVE_LIKE sqlite3RegisterLikeFunctions(db, 1); ============================================================ --- sqlite/hash.c 8747cf51d12de46512880dfcf1b68b4e24072863 +++ sqlite/hash.c 449f3d6620193aa557f5d86cbc5cc6b87702b185 @@ -12,7 +12,7 @@ ** This is the implementation of generic hash-tables ** used in SQLite. ** -** $Id: hash.c,v 1.17 2005/10/03 15:11:09 drh Exp $ +** $Id: hash.c,v 1.18 2006/02/14 10:48:39 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -41,6 +41,8 @@ pNew->count = 0; pNew->htsize = 0; pNew->ht = 0; + pNew->xMalloc = sqlite3MallocX; + pNew->xFree = sqlite3FreeX; } /* Remove all entries from a hash table. Reclaim all memory. @@ -53,15 +55,15 @@ assert( pH!=0 ); elem = pH->first; pH->first = 0; - if( pH->ht ) sqliteFree(pH->ht); + if( pH->ht ) pH->xFree(pH->ht); pH->ht = 0; pH->htsize = 0; while( elem ){ HashElem *next_elem = elem->next; if( pH->copyKey && elem->pKey ){ - sqliteFree(elem->pKey); + pH->xFree(elem->pKey); } - sqliteFree(elem); + pH->xFree(elem); elem = next_elem; } pH->count = 0; @@ -222,9 +224,9 @@ int (*xHash)(const void*,int); /* The hash function */ assert( (new_size & (new_size-1))==0 ); - new_ht = (struct _ht *)sqliteMalloc( new_size*sizeof(struct _ht) ); + new_ht = (struct _ht *)pH->xMalloc( new_size*sizeof(struct _ht) ); if( new_ht==0 ) return; - if( pH->ht ) sqliteFree(pH->ht); + if( pH->ht ) pH->xFree(pH->ht); pH->ht = new_ht; pH->htsize = new_size; xHash = hashFunction(pH->keyClass); @@ -290,9 +292,9 @@ pEntry->chain = 0; } if( pH->copyKey && elem->pKey ){ - sqliteFree(elem->pKey); + pH->xFree(elem->pKey); } - sqliteFree( elem ); + pH->xFree( elem ); pH->count--; if( pH->count<=0 ){ assert( pH->first==0 ); @@ -358,12 +360,12 @@ return old_data; } if( data==0 ) return 0; - new_elem = (HashElem*)sqliteMalloc( sizeof(HashElem) ); + new_elem = (HashElem*)pH->xMalloc( sizeof(HashElem) ); if( new_elem==0 ) return data; if( pH->copyKey && pKey!=0 ){ - new_elem->pKey = sqliteMallocRaw( nKey ); + new_elem->pKey = pH->xMalloc( nKey ); if( new_elem->pKey==0 ){ - sqliteFree(new_elem); + pH->xFree(new_elem); return data; } memcpy((void*)new_elem->pKey, pKey, nKey); @@ -376,7 +378,7 @@ rehash(pH,8); if( pH->htsize==0 ){ pH->count = 0; - sqliteFree(new_elem); + pH->xFree(new_elem); return data; } } ============================================================ --- sqlite/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84 +++ sqlite/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564 @@ -12,7 +12,7 @@ ** This is the header file for the generic hash-table implemenation ** used in SQLite. ** -** $Id: hash.h,v 1.8 2004/08/20 14:08:51 drh Exp $ +** $Id: hash.h,v 1.9 2006/02/14 10:48:39 danielk1977 Exp $ */ #ifndef _SQLITE_HASH_H_ #define _SQLITE_HASH_H_ @@ -34,6 +34,8 @@ char copyKey; /* True if copy of key made on insert */ int count; /* Number of entries in this table */ HashElem *first; /* The first element of the array */ + void *(*xMalloc)(int); /* malloc() function to use */ + void (*xFree)(void *); /* free() function to use */ int htsize; /* Number of buckets in the hash table */ struct _ht { /* the hash table */ int count; /* Number of entries with this hash */ ============================================================ --- sqlite/insert.c 67b3dc11831c58d8703eb502355ad3704ee18f66 +++ sqlite/insert.c 1ae4b8ff5549497808e1b57b9243abcb599fd02f @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle INSERT statements in SQLite. ** -** $Id: insert.c,v 1.161 2006/02/10 02:27:43 danielk1977 Exp $ +** $Id: insert.c,v 1.164 2006/03/15 16:26:10 drh Exp $ */ #include "sqliteInt.h" @@ -269,7 +269,7 @@ if( sqlite3IsReadOnly(pParse, pTab, triggers_exist) ){ goto insert_cleanup; } - if( pTab==0 ) goto insert_cleanup; + assert( pTab!=0 ); /* If pTab is really a view, make sure it has been initialized. */ @@ -874,7 +874,13 @@ sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, 1); assert( pParse->ckOffset==nCol ); pParse->ckOffset = 0; - sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, OE_Abort); + onError = overrideError!=OE_Default ? overrideError : OE_Abort; + if( onError==OE_Ignore || onError==OE_Replace ){ + sqlite3VdbeAddOp(v, OP_Pop, nCol+1+hasTwoRowids, 0); + sqlite3VdbeAddOp(v, OP_Goto, 0, ignoreDest); + }else{ + sqlite3VdbeAddOp(v, OP_Halt, SQLITE_CONSTRAINT, onError); + } sqlite3VdbeResolveLabel(v, allOk); } #endif /* !defined(SQLITE_OMIT_CHECK) */ @@ -911,7 +917,7 @@ break; } case OE_Replace: { - sqlite3GenerateRowIndexDelete(pParse->db, v, pTab, base, 0); + sqlite3GenerateRowIndexDelete(v, pTab, base, 0); if( isUpdate ){ sqlite3VdbeAddOp(v, OP_Dup, nCol+hasTwoRowids, 1); sqlite3VdbeAddOp(v, OP_MoveGe, base, 0); ============================================================ --- sqlite/keywordhash.h 53d6b6630b71e2ec402f2c2ff85e3f7e8e88a3cc +++ sqlite/keywordhash.h 2e5fb8d1a96d93616c86e690bc044dbcc99d4e49 @@ -83,8 +83,8 @@ }; int h, i; if( n<2 ) return TK_ID; - h = ((sqlite3UpperToLower[((unsigned char*)z)[0]]*4) ^ - (sqlite3UpperToLower[((unsigned char*)z)[n-1]]*3) ^ + h = ((charMap(z[0])*4) ^ + (charMap(z[n-1])*3) ^ n) % 127; for(i=((int)aHash[h])-1; i>=0; i=((int)aNext[i])-1){ if( aLen[i]==n && sqlite3StrNICmp(&zText[aOffset[i]],z,n)==0 ){ ============================================================ --- sqlite/legacy.c 86b669707b3cefd570e34154e2f6457547d1df4f +++ sqlite/legacy.c fa15d505dd4e45044177ee4d1c6aeaf8c836d390 @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: legacy.c,v 1.13 2006/01/23 13:14:55 drh Exp $ +** $Id: legacy.c,v 1.14 2006/03/06 20:55:46 drh Exp $ */ #include "sqliteInt.h" @@ -54,8 +54,8 @@ pStmt = 0; rc = sqlite3_prepare(db, zSql, -1, &pStmt, &zLeftover); + assert( rc==SQLITE_OK || pStmt==0 ); if( rc!=SQLITE_OK ){ - if( pStmt ) sqlite3_finalize(pStmt); continue; } if( !pStmt ){ ============================================================ --- sqlite/main.c 9a42464c44a6532003391486e802e65e88789cfc +++ sqlite/main.c 5cdd81aaf159836b5ca277192da4f7461fd15078 @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.334 2006/02/09 13:43:29 danielk1977 Exp $ +** $Id: main.c,v 1.339 2006/03/16 16:19:56 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -109,7 +109,10 @@ } #ifdef SQLITE_SSE - sqlite3_finalize(db->pFetch); + { + extern void sqlite3SseCleanup(sqlite3*); + sqlite3SseCleanup(db); + } #endif /* If there are any outstanding VMs, return SQLITE_BUSY. */ @@ -250,7 +253,7 @@ void *ptr, /* Database connection */ int count /* Number of times table has been busy */ ){ -#if SQLITE_MIN_SLEEP_MS==1 +#if OS_WIN || (defined(HAVE_USLEEP) && HAVE_USLEEP) static const u8 delays[] = { 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 }; static const u8 totals[] = @@ -743,6 +746,7 @@ int(*xCompare)(void*,int,const void*,int,const void*) ){ CollSeq *pColl; + int enc2; if( sqlite3SafetyCheck(db) ){ return SQLITE_MISUSE; @@ -752,15 +756,13 @@ ** to one of SQLITE_UTF16LE or SQLITE_UTF16BE using the ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally. */ - if( enc==SQLITE_UTF16 ){ - enc = SQLITE_UTF16NATIVE; + enc2 = enc & ~SQLITE_UTF16_ALIGNED; + if( enc2==SQLITE_UTF16 ){ + enc2 = SQLITE_UTF16NATIVE; } - if( enc!=SQLITE_UTF8 && enc!=SQLITE_UTF16LE && enc!=SQLITE_UTF16BE ){ - sqlite3Error(db, SQLITE_ERROR, - "Param 3 to sqlite3_create_collation() must be one of " - "SQLITE_UTF8, SQLITE_UTF16, SQLITE_UTF16LE or SQLITE_UTF16BE" - ); + if( (enc2&~3)!=0 ){ + sqlite3Error(db, SQLITE_ERROR, "unknown encoding"); return SQLITE_ERROR; } @@ -768,7 +770,7 @@ ** sequence. If so, and there are active VMs, return busy. If there ** are no active VMs, invalidate any pre-compiled statements. */ - pColl = sqlite3FindCollSeq(db, (u8)enc, zName, strlen(zName), 0); + pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 0); if( pColl && pColl->xCmp ){ if( db->activeVdbeCnt ){ sqlite3Error(db, SQLITE_BUSY, @@ -778,11 +780,11 @@ sqlite3ExpirePreparedStatements(db); } - pColl = sqlite3FindCollSeq(db, (u8)enc, zName, strlen(zName), 1); + pColl = sqlite3FindCollSeq(db, (u8)enc2, zName, strlen(zName), 1); if( pColl ){ pColl->xCmp = xCompare; pColl->pUser = pCtx; - pColl->enc = enc; + pColl->enc = enc2 | (enc & SQLITE_UTF16_ALIGNED); } sqlite3Error(db, SQLITE_OK, 0); return SQLITE_OK; @@ -847,15 +849,13 @@ db->magic = SQLITE_MAGIC_CLOSED; goto opendb_out; } -#ifndef SQLITE_OMIT_PARSER db->aDb[0].pSchema = sqlite3SchemaGet(db->aDb[0].pBt); db->aDb[1].pSchema = sqlite3SchemaGet(0); -#endif - if( db->aDb[0].pSchema ){ ENC(db) = SQLITE_UTF8; } + /* The default safety_level for the main database is 'full'; for the temp ** database it is 'NONE'. This matches the pager layer defaults. */ @@ -1230,4 +1230,3 @@ return sqlite3ApiExit(db, rc); } #endif - ============================================================ --- sqlite/os_unix.c 378a89aaf15d83b901c1b73350e91ddecf743986 +++ sqlite/os_unix.c 35ad4d81c90800f509d28580742b67906d289223 @@ -80,6 +80,7 @@ unsigned char isOpen; /* True if needs to be closed */ unsigned char fullSync; /* Use F_FULLSYNC if available */ int dirfd; /* File descriptor for the directory */ + i64 offset; /* Seek offset */ #ifdef SQLITE_UNIX_THREADS pthread_t tid; /* The thread that "owns" this OsFile */ #endif @@ -340,10 +341,11 @@ ** openKey structures) into lockInfo and openCnt structures. Access to ** these hash tables must be protected by a mutex. */ -static Hash lockHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 }; -static Hash openHash = { SQLITE_HASH_BINARY, 0, 0, 0, 0, 0 }; +static Hash lockHash = {SQLITE_HASH_BINARY, 0, 0, 0, + sqlite3ThreadSafeMalloc, sqlite3ThreadSafeFree, 0, 0}; +static Hash openHash = {SQLITE_HASH_BINARY, 0, 0, 0, + sqlite3ThreadSafeMalloc, sqlite3ThreadSafeFree, 0, 0}; - #ifdef SQLITE_UNIX_THREADS /* ** This variable records whether or not threads can override each others @@ -491,7 +493,7 @@ pLock->nRef--; if( pLock->nRef==0 ){ sqlite3HashInsert(&lockHash, &pLock->key, sizeof(pLock->key), 0); - sqliteFree(pLock); + sqlite3ThreadSafeFree(pLock); } } @@ -504,7 +506,7 @@ if( pOpen->nRef==0 ){ sqlite3HashInsert(&openHash, &pOpen->key, sizeof(pOpen->key), 0); free(pOpen->aPending); - sqliteFree(pOpen); + sqlite3ThreadSafeFree(pOpen); } } @@ -545,7 +547,7 @@ pLock = (struct lockInfo*)sqlite3HashFind(&lockHash, &key1, sizeof(key1)); if( pLock==0 ){ struct lockInfo *pOld; - pLock = sqliteMallocRaw( sizeof(*pLock) ); + pLock = sqlite3ThreadSafeMalloc( sizeof(*pLock) ); if( pLock==0 ){ rc = 1; goto exit_findlockinfo; @@ -557,7 +559,7 @@ pOld = sqlite3HashInsert(&lockHash, &pLock->key, sizeof(key1), pLock); if( pOld!=0 ){ assert( pOld==pLock ); - sqliteFree(pLock); + sqlite3ThreadSafeFree(pLock); rc = 1; goto exit_findlockinfo; } @@ -569,7 +571,7 @@ pOpen = (struct openCnt*)sqlite3HashFind(&openHash, &key2, sizeof(key2)); if( pOpen==0 ){ struct openCnt *pOld; - pOpen = sqliteMallocRaw( sizeof(*pOpen) ); + pOpen = sqlite3ThreadSafeMalloc( sizeof(*pOpen) ); if( pOpen==0 ){ releaseLockInfo(pLock); rc = 1; @@ -583,7 +585,7 @@ pOld = sqlite3HashInsert(&openHash, &pOpen->key, sizeof(key2), pOpen); if( pOld!=0 ){ assert( pOld==pOpen ); - sqliteFree(pOpen); + sqlite3ThreadSafeFree(pOpen); releaseLockInfo(pLock); rc = 1; goto exit_findlockinfo; @@ -904,6 +906,24 @@ } /* +** Seek to the offset in id->offset then read cnt bytes into pBuf. +** Return the number of bytes actually read. Update the offset. +*/ +static int seekAndRead(unixFile *id, void *pBuf, int cnt){ + int got; +#ifdef USE_PREAD + got = pread(id->h, pBuf, cnt, id->offset); +#else + lseek(id->h, id->offset, SEEK_SET); + got = read(id->h, pBuf, cnt); +#endif + if( got>0 ){ + id->offset += got; + } + return got; +} + +/* ** Read data from a file into a buffer. Return SQLITE_OK if all ** bytes were read successfully and SQLITE_IOERR if anything goes ** wrong. @@ -913,7 +933,7 @@ assert( id ); SimulateIOError(SQLITE_IOERR); TIMER_START; - got = read(((unixFile*)id)->h, pBuf, amt); + got = seekAndRead((unixFile*)id, pBuf, amt); TIMER_END; TRACE5("READ %-3d %5d %7d %d\n", ((unixFile*)id)->h, got, last_page, TIMER_ELAPSED); @@ -927,6 +947,25 @@ } /* +** Seek to the offset in id->offset then read cnt bytes into pBuf. +** Return the number of bytes actually read. Update the offset. +*/ +static int seekAndWrite(unixFile *id, const void *pBuf, int cnt){ + int got; +#ifdef USE_PREAD + got = pwrite(id->h, pBuf, cnt, id->offset); +#else + lseek(id->h, id->offset, SEEK_SET); + got = write(id->h, pBuf, cnt); +#endif + if( got>0 ){ + id->offset += got; + } + return got; +} + + +/* ** Write data from a buffer into a file. Return SQLITE_OK on success ** or some other error code on failure. */ @@ -937,7 +976,7 @@ SimulateIOError(SQLITE_IOERR); SimulateDiskfullError; TIMER_START; - while( amt>0 && (wrote = write(((unixFile*)id)->h, pBuf, amt))>0 ){ + while( amt>0 && (wrote = seekAndWrite((unixFile*)id, pBuf, amt))>0 ){ amt -= wrote; pBuf = &((char*)pBuf)[wrote]; } @@ -960,7 +999,7 @@ #ifdef SQLITE_TEST if( offset ) SimulateDiskfullError #endif - lseek(((unixFile*)id)->h, offset, SEEK_SET); + ((unixFile*)id)->offset = offset; return SQLITE_OK; } @@ -1526,7 +1565,7 @@ id->isOpen = 0; TRACE2("CLOSE %-3d\n", id->h); OpenCounter(-1); - sqliteFree(id); + sqlite3ThreadSafeFree(id); *pId = 0; return SQLITE_OK; } @@ -1551,6 +1590,33 @@ (char*)0); sqliteFree(zBuf); } + +#if 0 + /* + ** Remove "/./" path elements and convert "/A/./" path elements + ** to just "/". + */ + if( zFull ){ + int i, j; + for(i=j=0; zFull[i]; i++){ + if( zFull[i]=='/' ){ + if( zFull[i+1]=='/' ) continue; + if( zFull[i+1]=='.' && zFull[i+2]=='/' ){ + i += 1; + continue; + } + if( zFull[i+1]=='.' && zFull[i+2]=='.' && zFull[i+3]=='/' ){ + while( j>0 && zFull[j-1]!='/' ){ j--; } + i += 3; + continue; + } + } + zFull[j++] = zFull[i]; + } + zFull[j] = 0; + } +#endif + return zFull; } @@ -1607,8 +1673,9 @@ pInit->dirfd = -1; pInit->fullSync = 0; pInit->locktype = 0; + pInit->offset = 0; SET_THREADID(pInit); - pNew = sqliteMalloc( sizeof(unixFile) ); + pNew = sqlite3ThreadSafeMalloc( sizeof(unixFile) ); if( pNew==0 ){ close(pInit->h); sqlite3OsEnterMutex(); ============================================================ --- sqlite/os_win.c c67a2c46d929cf54c8f80ec5e6079cf684a141a9 +++ sqlite/os_win.c 8ced9ac82670bbf77492961a2f7ff80a87f1404f @@ -128,19 +128,19 @@ ** is obtained from sqliteMalloc. */ static WCHAR *utf8ToUnicode(const char *zFilename){ - int nByte; + int nChar; WCHAR *zWideFilename; if( !isNT() ){ return 0; } - nByte = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0)*sizeof(WCHAR); - zWideFilename = sqliteMalloc( nByte*sizeof(zWideFilename[0]) ); + nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0); + zWideFilename = sqliteMalloc( nChar*sizeof(zWideFilename[0]) ); if( zWideFilename==0 ){ return 0; } - nByte = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nByte); - if( nByte==0 ){ + nChar = MultiByteToWideChar(CP_UTF8, 0, zFilename, -1, zWideFilename, nChar); + if( nChar==0 ){ sqliteFree(zWideFilename); zWideFilename = 0; } ============================================================ --- sqlite/pager.c c438aa5fc248e0523e80591eeae33a3993c47278 +++ sqlite/pager.c 33186636a07eeaf34028083c32b27b9647556be7 @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.258 2006/02/11 01:25:51 drh Exp $ +** @(#) $Id: pager.c,v 1.265 2006/03/26 20:49:18 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -52,8 +52,8 @@ ** associated file-descriptor is returned. FILEHANDLEID() takes an OsFile ** struct as it's argument. */ -#define PAGERID(p) FILEHANDLEID(&(p)->fd) -#define FILEHANDLEID(fd) (sqlite3OsFileHandle(&fd)) +#define PAGERID(p) ((int)(p->fd)) +#define FILEHANDLEID(fd) ((int)fd) /* ** The page cache as a whole is always in one of the following @@ -190,9 +190,11 @@ ** A macro used for invoking the codec if there is one */ #ifdef SQLITE_HAS_CODEC -# define CODEC(P,D,N,X) if( P->xCodec ){ P->xCodec(P->pCodecArg,D,N,X); } +# define CODEC1(P,D,N,X) if( P->xCodec!=0 ){ P->xCodec(P->pCodecArg,D,N,X); } +# define CODEC2(P,D,N,X) ((char*)(P->xCodec!=0?P->xCodec(P->pCodecArg,D,N,X):D)) #else -# define CODEC(P,D,N,X) +# define CODEC1(P,D,N,X) /* NO-OP */ +# define CODEC2(P,D,N,X) ((char*)D) #endif /* @@ -290,7 +292,7 @@ #endif void (*xDestructor)(void*,int); /* Call this routine when freeing pages */ void (*xReiniter)(void*,int); /* Call this routine when reloading pages */ - void (*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ + void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ void *pCodecArg; /* First argument to xCodec() */ PgHdr *aHash[N_PG_HASH]; /* Hash table to map page number to PgHdr */ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT @@ -436,16 +438,6 @@ } /* -** Write the 32-bit integer 'val' into the page identified by page header -** 'p' at offset 'offset'. -*/ -static void store32bits(u32 val, PgHdr *p, int offset){ - char *ac; - ac = &((char*)PGHDR_TO_DATA(p))[offset]; - put32bits(ac, val); -} - -/* ** Read a 32-bit integer at offset 'offset' from the page identified by ** page header 'p'. */ @@ -935,7 +927,7 @@ ** only the middle sector is corrupt, we will still have a reasonable ** chance of failing the checksum and thus detecting the problem. */ -static u32 pager_cksum(Pager *pPager, Pgno pgno, const u8 *aData){ +static u32 pager_cksum(Pager *pPager, const u8 *aData){ u32 cksum = pPager->cksumInit; int i = pPager->pageSize-200; while( i>0 ){ @@ -987,7 +979,7 @@ rc = read32bits(jfd, &cksum); if( rc ) return rc; pPager->journalOff += 4; - if( pager_cksum(pPager, pgno, aData)!=cksum ){ + if( pager_cksum(pPager, aData)!=cksum ){ return SQLITE_DONE; } } @@ -1041,7 +1033,7 @@ #ifdef SQLITE_CHECK_PAGES pPg->pageHash = pager_pagehash(pPg); #endif - CODEC(pPager, pData, pPg->pgno, 3); + CODEC1(pPager, pData, pPg->pgno, 3); } return rc; } @@ -1154,7 +1146,7 @@ } TRACE3("REFETCH %d page %d\n", PAGERID(pPager), pPg->pgno); if( rc ) break; - CODEC(pPager, zBuf, pPg->pgno, 2); + CODEC1(pPager, zBuf, pPg->pgno, 2); }else{ memset(zBuf, 0, pPager->pageSize); } @@ -1310,9 +1302,6 @@ pPager->dbSize = mxPg; } - /* rc = sqlite3OsSeek(pPager->jfd, JOURNAL_HDR_SZ(pPager)); */ - if( rc!=SQLITE_OK ) goto end_playback; - /* Copy original pages out of the journal and back into the database file. */ for(i=0; iaHash[h]==pPg ); pPager->aHash[h] = pPg->pNextHash; } - + if( MEMDB ){ + clearHistory(PGHDR_TO_HIST(pPg, pPager)); + } pPg->pgno = 0; pPg->pNextHash = pPg->pPrevHash = 0; } @@ -2070,7 +2057,7 @@ pTsd->pPager = pPager->pNext; }else{ Pager *pTmp; - for(pTmp = pTsd->pPager; pTmp->pNext!=pPager; pTmp=pTmp->pNext); + for(pTmp = pTsd->pPager; pTmp->pNext!=pPager; pTmp=pTmp->pNext){} pTmp->pNext = pPager->pNext; } #endif @@ -2279,11 +2266,9 @@ ** any such pages to the file. */ if( pList->pgno<=pPager->dbSize ){ - CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 6); + char *pData = CODEC2(pPager, PGHDR_TO_DATA(pList), pList->pgno, 6); TRACE3("STORE %d page %d\n", PAGERID(pPager), pList->pgno); - rc = sqlite3OsWrite(pPager->fd, PGHDR_TO_DATA(pList), - pPager->pageSize); - CODEC(pPager, PGHDR_TO_DATA(pList), pList->pgno, 0); + rc = sqlite3OsWrite(pPager->fd, pData, pPager->pageSize); TEST_INCR(pPager->nWrite); } #ifndef NDEBUG @@ -2477,7 +2462,7 @@ if( pPg==p->pAll ){ p->pAll = pPg->pNextAll; }else{ - for( pTmp=p->pAll; pTmp->pNextAll!=pPg; pTmp=pTmp->pNextAll ); + for( pTmp=p->pAll; pTmp->pNextAll!=pPg; pTmp=pTmp->pNextAll ){} pTmp->pNextAll = pPg->pNextAll; } nReleased += sqliteAllocSize(pPg); @@ -2688,7 +2673,7 @@ pPager->pageSize); } TRACE3("FETCH %d page %d\n", PAGERID(pPager), pPg->pgno); - CODEC(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); + CODEC1(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3); if( rc!=SQLITE_OK ){ i64 fileSize; int rc2 = sqlite3OsFileSize(pPager->fd, &fileSize); @@ -3007,7 +2992,6 @@ if( !pPg->inJournal && (pPager->useJournal || MEMDB) ){ if( (int)pPg->pgno <= pPager->origDbSize ){ int szPg; - u32 saved; if( MEMDB ){ PgHistory *pHist = PGHDR_TO_HIST(pPg, pPager); TRACE3("JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno); @@ -3017,24 +3001,25 @@ memcpy(pHist->pOrig, PGHDR_TO_DATA(pPg), pPager->pageSize); } }else{ - u32 cksum; + u32 cksum, saved; + char *pData2, *pEnd; /* We should never write to the journal file the page that ** contains the database locks. The following assert verifies ** that we do not. */ assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) ); - CODEC(pPager, pData, pPg->pgno, 7); - cksum = pager_cksum(pPager, pPg->pgno, pData); - saved = *(u32*)PGHDR_TO_EXTRA(pPg, pPager); - store32bits(cksum, pPg, pPager->pageSize); + pData2 = CODEC2(pPager, pData, pPg->pgno, 7); + cksum = pager_cksum(pPager, (u8*)pData2); + pEnd = pData2 + pPager->pageSize; + pData2 -= 4; + saved = *(u32*)pEnd; + put32bits(pEnd, cksum); szPg = pPager->pageSize+8; - store32bits(pPg->pgno, pPg, -4); - - rc = sqlite3OsWrite(pPager->jfd, &((char*)pData)[-4], szPg); + put32bits(pData2, pPg->pgno); + rc = sqlite3OsWrite(pPager->jfd, pData2, szPg); pPager->journalOff += szPg; TRACE4("JOURNAL %d page %d needSync=%d\n", PAGERID(pPager), pPg->pgno, pPg->needSync); - CODEC(pPager, pData, pPg->pgno, 0); - *(u32*)PGHDR_TO_EXTRA(pPg, pPager) = saved; + *(u32*)pEnd = saved; /* An error has occured writing to the journal file. The ** transaction will be rolled back by the layer above. @@ -3079,12 +3064,10 @@ } TRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno); }else{ - store32bits(pPg->pgno, pPg, -4); - CODEC(pPager, pData, pPg->pgno, 7); - rc = sqlite3OsWrite(pPager->stfd,((char*)pData)-4, - pPager->pageSize+4); + char *pData2 = CODEC2(pPager, pData, pPg->pgno, 7)-4; + put32bits(pData2, pPg->pgno); + rc = sqlite3OsWrite(pPager->stfd, pData2, pPager->pageSize+4); TRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno); - CODEC(pPager, pData, pPg->pgno, 0); if( rc!=SQLITE_OK ){ return rc; } @@ -3170,8 +3153,9 @@ if( MEMDB ) return; pPg = pager_lookup(pPager, pgno); + assert( pPg!=0 ); /* We never call _dont_write unless the page is in mem */ pPg->alwaysRollback = 1; - if( pPg && pPg->dirty && !pPager->stmtInUse ){ + if( pPg->dirty && !pPager->stmtInUse ){ if( pPager->dbSize==(int)pPg->pgno && pPager->origDbSizedbSize ){ /* If this pages is the last page in the file and the file has grown ** during the current transaction, then do NOT mark the page as clean. @@ -3261,6 +3245,7 @@ pPg->dirty = 0; pPg->inJournal = 0; pPg->inStmt = 0; + pPg->needSync = 0; pPg->pPrevStmt = pPg->pNextStmt = 0; pPg = pPg->pDirty; } @@ -3556,7 +3541,7 @@ */ void sqlite3pager_set_codec( Pager *pPager, - void (*xCodec)(void*,void*,Pgno,int), + void *(*xCodec)(void*,void*,Pgno,int), void *pCodecArg ){ pPager->xCodec = xCodec; @@ -3585,7 +3570,7 @@ /* Increment the value just read and write it back to byte 24. */ change_counter++; - store32bits(change_counter, pPgHdr, 24); + put32bits(((char*)PGHDR_TO_DATA(pPgHdr))+24, change_counter); /* Release the page reference. */ sqlite3pager_unref(pPage); @@ -3675,6 +3660,8 @@ } pPager->state = PAGER_SYNCED; + }else if( MEMDB && nTrunc!=0 ){ + rc = sqlite3pager_truncate(pPager, nTrunc); } sync_exit: ============================================================ --- sqlite/pager.h 425a9e52d5404158de016799715cbc2c3d685178 +++ sqlite/pager.h 43f32f3847421f7502cfbb66f4eb2302b8033818 @@ -13,7 +13,7 @@ ** 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.49 2006/02/11 01:25:51 drh Exp $ +** @(#) $Id: pager.h,v 1.50 2006/03/06 18:23:17 drh Exp $ */ #ifndef _PAGER_H_ @@ -105,7 +105,7 @@ const char *sqlite3pager_journalname(Pager*); int sqlite3pager_nosync(Pager*); int sqlite3pager_rename(Pager*, const char *zNewName); -void sqlite3pager_set_codec(Pager*,void(*)(void*,void*,Pgno,int),void*); +void sqlite3pager_set_codec(Pager*,void*(*)(void*,void*,Pgno,int),void*); int sqlite3pager_movepage(Pager*,void*,Pgno); int sqlite3pager_reset(Pager*); int sqlite3pager_release_memory(int); ============================================================ --- sqlite/parse.c 56d45a7fd03e7c499e1a0bacb81916956b9ec8d7 +++ sqlite/parse.c ba57979ef0f3f4afc8bba8ff550324aa575f243b @@ -1,13 +1,13 @@ /* Driver template for the LEMON parser generator. ** The author disclaims copyright to this source code. */ /* First off, code is include which follows the "include" declaration ** in the input file. */ #include +#line 54 "parse.y" #include "sqliteInt.h" #include "parse.h" -#line 54 "parse.y" /* ** An instance of this structure holds information about the @@ -118,7 +118,7 @@ #define sqlite3ParserARG_PDECL ,Parse *pParse #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse #define sqlite3ParserARG_STORE yypParser->pParse = pParse -#define YYNSTATE 560 +#define YYNSTATE 559 #define YYNRULE 295 #define YYERRORSYMBOL 137 #define YYERRSYMDT yy479 @@ -175,134 +175,134 @@ ** yy_default[] Default action for each state. */ static const YYACTIONTYPE yy_action[] = { - /* 0 */ 279, 68, 283, 70, 148, 166, 546, 419, 62, 62, - /* 10 */ 62, 62, 202, 64, 64, 64, 64, 65, 65, 66, - /* 20 */ 66, 66, 67, 67, 548, 549, 432, 69, 64, 64, - /* 30 */ 64, 64, 65, 65, 66, 66, 66, 67, 68, 454, - /* 40 */ 70, 148, 499, 61, 59, 287, 440, 441, 437, 437, - /* 50 */ 63, 63, 62, 62, 62, 62, 501, 64, 64, 64, - /* 60 */ 64, 65, 65, 66, 66, 66, 67, 279, 371, 283, - /* 70 */ 419, 2, 377, 80, 158, 115, 220, 304, 225, 305, - /* 80 */ 170, 245, 856, 119, 559, 504, 204, 2, 246, 389, - /* 90 */ 496, 219, 22, 432, 514, 21, 419, 58, 493, 171, - /* 100 */ 64, 64, 64, 64, 65, 65, 66, 66, 66, 67, - /* 110 */ 61, 59, 287, 440, 441, 437, 437, 63, 63, 62, - /* 120 */ 62, 62, 62, 512, 64, 64, 64, 64, 65, 65, - /* 130 */ 66, 66, 66, 67, 279, 378, 379, 175, 202, 377, - /* 140 */ 330, 333, 334, 220, 304, 225, 305, 170, 245, 203, - /* 150 */ 146, 357, 335, 281, 377, 246, 55, 301, 373, 419, - /* 160 */ 432, 505, 92, 200, 530, 66, 66, 66, 67, 525, - /* 170 */ 192, 65, 65, 66, 66, 66, 67, 61, 59, 287, - /* 180 */ 440, 441, 437, 437, 63, 63, 62, 62, 62, 62, - /* 190 */ 433, 64, 64, 64, 64, 65, 65, 66, 66, 66, - /* 200 */ 67, 279, 378, 379, 411, 431, 110, 226, 427, 205, - /* 210 */ 435, 436, 308, 358, 261, 260, 175, 378, 379, 330, - /* 220 */ 333, 334, 372, 369, 202, 511, 480, 432, 547, 362, - /* 230 */ 466, 335, 510, 500, 410, 41, 276, 414, 434, 429, - /* 240 */ 503, 162, 233, 527, 61, 59, 287, 440, 441, 437, - /* 250 */ 437, 63, 63, 62, 62, 62, 62, 319, 64, 64, - /* 260 */ 64, 64, 65, 65, 66, 66, 66, 67, 279, 472, - /* 270 */ 416, 416, 416, 308, 322, 236, 308, 68, 308, 70, - /* 280 */ 148, 1, 308, 793, 308, 377, 68, 153, 70, 148, - /* 290 */ 149, 377, 325, 282, 432, 410, 35, 551, 410, 35, - /* 300 */ 410, 36, 427, 205, 410, 35, 410, 35, 286, 422, - /* 310 */ 423, 61, 59, 287, 440, 441, 437, 437, 63, 63, - /* 320 */ 62, 62, 62, 62, 411, 64, 64, 64, 64, 65, - /* 330 */ 65, 66, 66, 66, 67, 308, 504, 466, 290, 255, - /* 340 */ 279, 324, 485, 147, 237, 388, 21, 288, 378, 379, - /* 350 */ 451, 419, 232, 451, 378, 379, 308, 410, 28, 451, - /* 360 */ 175, 450, 486, 330, 333, 334, 432, 215, 347, 145, - /* 370 */ 513, 204, 350, 186, 168, 335, 238, 411, 410, 41, - /* 380 */ 256, 462, 76, 61, 59, 287, 440, 441, 437, 437, - /* 390 */ 63, 63, 62, 62, 62, 62, 309, 64, 64, 64, - /* 400 */ 64, 65, 65, 66, 66, 66, 67, 411, 411, 186, - /* 410 */ 396, 308, 279, 291, 419, 338, 476, 308, 390, 234, - /* 420 */ 169, 154, 397, 475, 396, 327, 493, 311, 422, 423, - /* 430 */ 444, 377, 356, 410, 49, 398, 397, 394, 432, 410, - /* 440 */ 49, 502, 171, 411, 429, 312, 162, 395, 351, 398, - /* 450 */ 497, 318, 470, 352, 79, 61, 59, 287, 440, 441, - /* 460 */ 437, 437, 63, 63, 62, 62, 62, 62, 356, 64, - /* 470 */ 64, 64, 64, 65, 65, 66, 66, 66, 67, 279, - /* 480 */ 298, 445, 376, 479, 532, 405, 299, 11, 504, 352, - /* 490 */ 204, 377, 406, 377, 378, 379, 281, 556, 21, 491, - /* 500 */ 491, 246, 560, 372, 369, 432, 392, 393, 314, 123, - /* 510 */ 443, 443, 166, 289, 419, 314, 116, 443, 443, 251, - /* 520 */ 264, 463, 61, 59, 287, 440, 441, 437, 437, 63, - /* 530 */ 63, 62, 62, 62, 62, 292, 64, 64, 64, 64, - /* 540 */ 65, 65, 66, 66, 66, 67, 279, 459, 328, 474, - /* 550 */ 498, 308, 202, 308, 378, 379, 378, 379, 181, 131, - /* 560 */ 179, 265, 308, 5, 308, 363, 314, 355, 443, 443, - /* 570 */ 410, 3, 432, 410, 29, 410, 24, 419, 243, 244, - /* 580 */ 380, 381, 382, 404, 410, 33, 410, 54, 466, 61, - /* 590 */ 59, 287, 440, 441, 437, 437, 63, 63, 62, 62, - /* 600 */ 62, 62, 308, 64, 64, 64, 64, 65, 65, 66, - /* 610 */ 66, 66, 67, 279, 521, 344, 521, 249, 308, 491, - /* 620 */ 308, 470, 308, 470, 410, 25, 308, 240, 308, 314, - /* 630 */ 308, 443, 443, 213, 172, 173, 174, 142, 266, 432, - /* 640 */ 410, 52, 410, 97, 410, 94, 528, 393, 410, 99, - /* 650 */ 410, 100, 410, 111, 212, 255, 61, 59, 287, 440, - /* 660 */ 441, 437, 437, 63, 63, 62, 62, 62, 62, 308, - /* 670 */ 64, 64, 64, 64, 65, 65, 66, 66, 66, 67, - /* 680 */ 279, 308, 345, 188, 297, 91, 308, 491, 308, 415, - /* 690 */ 308, 410, 112, 308, 428, 308, 537, 308, 244, 165, - /* 700 */ 154, 409, 355, 410, 18, 408, 432, 320, 410, 98, - /* 710 */ 410, 34, 410, 95, 313, 410, 53, 410, 113, 410, - /* 720 */ 114, 255, 293, 61, 59, 287, 440, 441, 437, 437, - /* 730 */ 63, 63, 62, 62, 62, 62, 308, 64, 64, 64, - /* 740 */ 64, 65, 65, 66, 66, 66, 67, 279, 308, 491, - /* 750 */ 491, 523, 308, 452, 308, 522, 308, 461, 410, 26, - /* 760 */ 308, 75, 539, 77, 308, 460, 244, 346, 214, 465, - /* 770 */ 410, 37, 469, 432, 410, 38, 410, 27, 410, 39, - /* 780 */ 242, 82, 410, 40, 294, 296, 410, 42, 438, 329, - /* 790 */ 61, 59, 287, 440, 441, 437, 437, 63, 63, 62, - /* 800 */ 62, 62, 62, 308, 64, 64, 64, 64, 65, 65, - /* 810 */ 66, 66, 66, 67, 279, 308, 409, 190, 221, 308, - /* 820 */ 408, 308, 152, 308, 159, 410, 43, 308, 244, 244, - /* 830 */ 222, 20, 308, 139, 425, 425, 481, 410, 44, 482, - /* 840 */ 432, 410, 30, 410, 31, 410, 45, 487, 461, 410, - /* 850 */ 46, 411, 506, 255, 410, 47, 488, 61, 71, 287, - /* 860 */ 440, 441, 437, 437, 63, 63, 62, 62, 62, 62, - /* 870 */ 308, 64, 64, 64, 64, 65, 65, 66, 66, 66, - /* 880 */ 67, 279, 308, 401, 402, 250, 308, 193, 308, 420, - /* 890 */ 308, 23, 410, 48, 540, 449, 255, 14, 468, 477, - /* 900 */ 167, 14, 484, 483, 410, 32, 252, 432, 410, 12, - /* 910 */ 410, 50, 410, 51, 255, 255, 594, 255, 255, 150, - /* 920 */ 489, 411, 123, 253, 279, 59, 287, 440, 441, 437, - /* 930 */ 437, 63, 63, 62, 62, 62, 62, 541, 64, 64, - /* 940 */ 64, 64, 65, 65, 66, 66, 66, 67, 254, 248, - /* 950 */ 432, 123, 337, 411, 123, 267, 269, 196, 361, 366, - /* 960 */ 183, 177, 180, 519, 520, 526, 534, 123, 167, 287, - /* 970 */ 440, 441, 437, 437, 63, 63, 62, 62, 62, 62, - /* 980 */ 342, 64, 64, 64, 64, 65, 65, 66, 66, 66, - /* 990 */ 67, 72, 315, 259, 4, 411, 411, 535, 285, 89, - /* 1000 */ 544, 349, 89, 353, 354, 19, 310, 72, 315, 368, - /* 1010 */ 4, 386, 262, 263, 285, 223, 545, 270, 364, 273, - /* 1020 */ 274, 141, 310, 317, 227, 316, 555, 424, 426, 480, - /* 1030 */ 455, 458, 490, 431, 332, 492, 533, 157, 543, 317, - /* 1040 */ 375, 383, 384, 385, 8, 302, 303, 391, 284, 431, - /* 1050 */ 404, 399, 74, 73, 224, 403, 407, 82, 323, 321, - /* 1060 */ 72, 306, 307, 400, 231, 414, 81, 206, 74, 73, - /* 1070 */ 473, 57, 78, 164, 453, 412, 72, 306, 307, 72, - /* 1080 */ 315, 414, 4, 228, 202, 229, 285, 235, 230, 456, - /* 1090 */ 457, 413, 207, 120, 310, 83, 326, 102, 416, 416, - /* 1100 */ 416, 417, 418, 13, 239, 495, 467, 241, 277, 208, - /* 1110 */ 471, 317, 494, 210, 416, 416, 416, 417, 418, 13, - /* 1120 */ 211, 431, 156, 278, 339, 507, 508, 216, 217, 218, - /* 1130 */ 106, 509, 515, 178, 343, 84, 341, 182, 517, 456, - /* 1140 */ 74, 73, 86, 198, 518, 271, 257, 184, 72, 306, - /* 1150 */ 307, 348, 272, 414, 118, 529, 187, 127, 536, 359, - /* 1160 */ 128, 136, 129, 542, 195, 130, 530, 133, 300, 552, - /* 1170 */ 553, 194, 137, 197, 431, 90, 554, 557, 96, 209, - /* 1180 */ 101, 374, 387, 117, 201, 56, 416, 416, 416, 417, - /* 1190 */ 418, 13, 93, 143, 144, 595, 596, 109, 160, 161, - /* 1200 */ 60, 439, 500, 421, 430, 442, 414, 138, 446, 151, - /* 1210 */ 6, 447, 155, 448, 163, 360, 268, 260, 15, 7, - /* 1220 */ 14, 280, 121, 464, 122, 478, 202, 103, 104, 331, - /* 1230 */ 247, 85, 105, 336, 222, 176, 340, 140, 516, 416, - /* 1240 */ 416, 416, 124, 295, 125, 167, 524, 258, 107, 185, - /* 1250 */ 365, 9, 531, 10, 126, 189, 16, 538, 191, 132, - /* 1260 */ 134, 87, 88, 135, 17, 108, 275, 550, 367, 199, - /* 1270 */ 370, 536, 558, + /* 0 */ 279, 67, 283, 69, 147, 165, 545, 418, 61, 61, + /* 10 */ 61, 61, 201, 63, 63, 63, 63, 64, 64, 65, + /* 20 */ 65, 65, 66, 66, 547, 548, 431, 68, 63, 63, + /* 30 */ 63, 63, 64, 64, 65, 65, 65, 66, 67, 453, + /* 40 */ 69, 147, 498, 60, 58, 287, 439, 440, 436, 436, + /* 50 */ 62, 62, 61, 61, 61, 61, 500, 63, 63, 63, + /* 60 */ 63, 64, 64, 65, 65, 65, 66, 279, 370, 283, + /* 70 */ 418, 2, 376, 79, 157, 114, 219, 304, 224, 305, + /* 80 */ 169, 244, 855, 118, 558, 503, 203, 2, 245, 388, + /* 90 */ 495, 218, 21, 431, 513, 20, 418, 57, 492, 511, + /* 100 */ 63, 63, 63, 63, 64, 64, 65, 65, 65, 66, + /* 110 */ 60, 58, 287, 439, 440, 436, 436, 62, 62, 61, + /* 120 */ 61, 61, 61, 530, 63, 63, 63, 63, 64, 64, + /* 130 */ 65, 65, 65, 66, 279, 377, 378, 174, 371, 368, + /* 140 */ 330, 333, 334, 219, 304, 224, 305, 169, 244, 510, + /* 150 */ 479, 19, 335, 138, 376, 245, 509, 301, 372, 418, + /* 160 */ 431, 529, 91, 199, 65, 65, 65, 66, 504, 167, + /* 170 */ 191, 64, 64, 65, 65, 65, 66, 60, 58, 287, + /* 180 */ 439, 440, 436, 436, 62, 62, 61, 61, 61, 61, + /* 190 */ 254, 63, 63, 63, 63, 64, 64, 65, 65, 65, + /* 200 */ 66, 279, 250, 410, 410, 430, 109, 395, 426, 204, + /* 210 */ 357, 260, 259, 308, 145, 168, 153, 377, 378, 396, + /* 220 */ 327, 201, 67, 189, 69, 147, 225, 431, 546, 361, + /* 230 */ 465, 365, 397, 499, 318, 409, 40, 413, 428, 312, + /* 240 */ 161, 180, 550, 178, 60, 58, 287, 439, 440, 436, + /* 250 */ 436, 62, 62, 61, 61, 61, 61, 410, 63, 63, + /* 260 */ 63, 63, 64, 64, 65, 65, 65, 66, 279, 471, + /* 270 */ 415, 415, 415, 282, 308, 322, 235, 426, 204, 308, + /* 280 */ 174, 367, 308, 330, 333, 334, 67, 308, 69, 147, + /* 290 */ 148, 559, 371, 368, 431, 335, 409, 34, 165, 465, + /* 300 */ 418, 409, 34, 275, 409, 34, 428, 502, 161, 409, + /* 310 */ 35, 60, 58, 287, 439, 440, 436, 436, 62, 62, + /* 320 */ 61, 61, 61, 61, 410, 63, 63, 63, 63, 64, + /* 330 */ 64, 65, 65, 65, 66, 308, 503, 395, 237, 290, + /* 340 */ 279, 391, 392, 146, 324, 387, 20, 288, 347, 396, + /* 350 */ 174, 450, 350, 330, 333, 334, 450, 409, 27, 450, + /* 360 */ 474, 231, 397, 418, 393, 335, 431, 501, 354, 144, + /* 370 */ 512, 503, 524, 232, 394, 465, 496, 410, 527, 392, + /* 380 */ 555, 20, 75, 60, 58, 287, 439, 440, 436, 436, + /* 390 */ 62, 62, 61, 61, 61, 61, 220, 63, 63, 63, + /* 400 */ 63, 64, 64, 65, 65, 65, 66, 308, 221, 185, + /* 410 */ 338, 254, 279, 308, 239, 443, 475, 308, 319, 308, + /* 420 */ 389, 444, 286, 421, 422, 379, 380, 381, 492, 409, + /* 430 */ 34, 311, 421, 422, 212, 409, 48, 170, 431, 409, + /* 440 */ 40, 409, 48, 410, 122, 314, 526, 442, 442, 1, + /* 450 */ 376, 469, 255, 376, 78, 60, 58, 287, 439, 440, + /* 460 */ 436, 436, 62, 62, 61, 61, 61, 61, 355, 63, + /* 470 */ 63, 63, 63, 64, 64, 65, 65, 65, 66, 279, + /* 480 */ 233, 152, 298, 478, 449, 203, 792, 192, 299, 351, + /* 490 */ 376, 281, 376, 9, 203, 376, 245, 376, 201, 432, + /* 500 */ 314, 376, 442, 442, 490, 431, 314, 325, 442, 442, + /* 510 */ 418, 356, 289, 377, 378, 354, 377, 378, 403, 434, + /* 520 */ 435, 410, 60, 58, 287, 439, 440, 436, 436, 62, + /* 530 */ 62, 61, 61, 61, 61, 263, 63, 63, 63, 63, + /* 540 */ 64, 64, 65, 65, 65, 66, 279, 433, 328, 236, + /* 550 */ 497, 473, 490, 377, 378, 377, 378, 484, 377, 378, + /* 560 */ 377, 378, 308, 522, 377, 378, 314, 521, 442, 442, + /* 570 */ 409, 3, 431, 418, 130, 254, 264, 485, 309, 346, + /* 580 */ 461, 213, 462, 242, 409, 28, 469, 292, 214, 60, + /* 590 */ 58, 287, 439, 440, 436, 436, 62, 62, 61, 61, + /* 600 */ 61, 61, 308, 63, 63, 63, 63, 64, 64, 65, + /* 610 */ 65, 65, 66, 279, 308, 458, 536, 248, 5, 308, + /* 620 */ 201, 308, 469, 308, 409, 23, 308, 202, 291, 308, + /* 630 */ 375, 243, 308, 362, 54, 115, 409, 32, 74, 431, + /* 640 */ 76, 409, 53, 409, 24, 409, 51, 345, 409, 96, + /* 650 */ 149, 409, 93, 265, 409, 98, 60, 58, 287, 439, + /* 660 */ 440, 436, 436, 62, 62, 61, 61, 61, 61, 308, + /* 670 */ 63, 63, 63, 63, 64, 64, 65, 65, 65, 66, + /* 680 */ 279, 308, 404, 297, 410, 90, 308, 176, 308, 405, + /* 690 */ 308, 409, 99, 308, 419, 308, 22, 308, 520, 344, + /* 700 */ 520, 164, 153, 409, 110, 141, 431, 313, 409, 111, + /* 710 */ 409, 16, 409, 97, 254, 409, 33, 409, 94, 409, + /* 720 */ 52, 410, 187, 60, 58, 287, 439, 440, 436, 436, + /* 730 */ 62, 62, 61, 61, 61, 61, 308, 63, 63, 63, + /* 740 */ 63, 64, 64, 65, 65, 65, 66, 279, 308, 490, + /* 750 */ 490, 414, 308, 320, 308, 538, 308, 460, 409, 112, + /* 760 */ 308, 171, 172, 173, 308, 408, 308, 424, 424, 407, + /* 770 */ 409, 113, 427, 431, 409, 25, 409, 36, 409, 37, + /* 780 */ 170, 437, 409, 26, 211, 293, 409, 38, 409, 39, + /* 790 */ 60, 58, 287, 439, 440, 436, 436, 62, 62, 61, + /* 800 */ 61, 61, 61, 308, 63, 63, 63, 63, 64, 64, + /* 810 */ 65, 65, 65, 66, 279, 308, 490, 490, 451, 308, + /* 820 */ 81, 308, 151, 308, 459, 409, 41, 308, 243, 243, + /* 830 */ 400, 401, 308, 448, 281, 12, 464, 409, 42, 468, + /* 840 */ 431, 409, 43, 409, 29, 409, 30, 241, 460, 409, + /* 850 */ 44, 294, 296, 480, 409, 45, 329, 60, 70, 287, + /* 860 */ 439, 440, 436, 436, 62, 62, 61, 61, 61, 61, + /* 870 */ 308, 63, 63, 63, 63, 64, 64, 65, 65, 65, + /* 880 */ 66, 279, 308, 408, 483, 482, 308, 407, 308, 467, + /* 890 */ 308, 166, 409, 46, 308, 243, 243, 476, 488, 12, + /* 900 */ 122, 518, 519, 179, 409, 47, 481, 431, 409, 31, + /* 910 */ 409, 10, 409, 49, 505, 486, 409, 50, 254, 249, + /* 920 */ 254, 254, 254, 158, 279, 58, 287, 439, 440, 436, + /* 930 */ 436, 62, 62, 61, 61, 61, 61, 410, 63, 63, + /* 940 */ 63, 63, 64, 64, 65, 65, 65, 66, 487, 247, + /* 950 */ 431, 122, 254, 337, 525, 122, 122, 251, 533, 539, + /* 960 */ 166, 540, 266, 360, 534, 543, 88, 88, 252, 287, + /* 970 */ 439, 440, 436, 436, 62, 62, 61, 61, 61, 61, + /* 980 */ 195, 63, 63, 63, 63, 64, 64, 65, 65, 65, + /* 990 */ 66, 71, 315, 268, 4, 253, 182, 258, 285, 349, + /* 1000 */ 342, 352, 353, 261, 262, 544, 310, 71, 315, 269, + /* 1010 */ 4, 222, 363, 272, 285, 593, 273, 554, 140, 226, + /* 1020 */ 385, 423, 310, 317, 425, 316, 532, 542, 18, 156, + /* 1030 */ 479, 454, 457, 430, 332, 489, 374, 382, 383, 317, + /* 1040 */ 384, 8, 302, 303, 491, 390, 398, 284, 403, 430, + /* 1050 */ 223, 406, 73, 72, 402, 81, 411, 399, 323, 56, + /* 1060 */ 71, 306, 307, 205, 321, 413, 80, 227, 73, 72, + /* 1070 */ 472, 77, 452, 163, 234, 455, 71, 306, 307, 71, + /* 1080 */ 315, 413, 4, 229, 201, 456, 285, 412, 228, 82, + /* 1090 */ 119, 326, 230, 206, 310, 207, 101, 276, 415, 415, + /* 1100 */ 415, 416, 417, 11, 238, 494, 466, 470, 240, 209, + /* 1110 */ 210, 317, 493, 506, 415, 415, 415, 416, 417, 11, + /* 1120 */ 507, 430, 155, 339, 508, 514, 177, 215, 216, 217, + /* 1130 */ 105, 277, 341, 181, 516, 83, 343, 85, 256, 455, + /* 1140 */ 73, 72, 517, 197, 183, 270, 348, 117, 71, 306, + /* 1150 */ 307, 528, 271, 413, 186, 126, 535, 358, 127, 128, + /* 1160 */ 541, 135, 300, 132, 194, 136, 529, 551, 552, 553, + /* 1170 */ 129, 193, 89, 196, 430, 556, 208, 100, 95, 373, + /* 1180 */ 386, 116, 200, 55, 17, 594, 415, 415, 415, 416, + /* 1190 */ 417, 11, 92, 142, 143, 595, 159, 108, 160, 59, + /* 1200 */ 438, 420, 499, 429, 137, 441, 413, 445, 150, 162, + /* 1210 */ 446, 447, 6, 7, 13, 359, 267, 259, 463, 12, + /* 1220 */ 120, 280, 121, 154, 477, 102, 201, 246, 331, 103, + /* 1230 */ 84, 104, 336, 175, 221, 340, 139, 515, 123, 415, + /* 1240 */ 415, 415, 184, 124, 295, 166, 257, 106, 523, 278, + /* 1250 */ 364, 531, 125, 86, 188, 14, 190, 537, 131, 133, + /* 1260 */ 87, 134, 15, 107, 198, 549, 366, 369, 536, 557, + /* 1270 */ 274, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 16, 216, 16, 218, 219, 21, 146, 23, 68, 69, @@ -314,257 +314,256 @@ /* 60 */ 76, 77, 78, 79, 80, 81, 82, 16, 140, 16, /* 70 */ 86, 143, 23, 22, 88, 89, 90, 91, 92, 93, /* 80 */ 94, 95, 138, 139, 140, 146, 226, 143, 102, 166, - /* 90 */ 167, 152, 19, 42, 155, 156, 23, 46, 175, 43, + /* 90 */ 167, 152, 19, 42, 155, 156, 23, 46, 175, 180, /* 100 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, /* 110 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, - /* 120 */ 69, 70, 71, 180, 73, 74, 75, 76, 77, 78, - /* 130 */ 79, 80, 81, 82, 16, 86, 87, 88, 109, 23, - /* 140 */ 91, 92, 93, 90, 91, 92, 93, 94, 95, 191, - /* 150 */ 22, 122, 103, 97, 23, 102, 198, 141, 142, 86, - /* 160 */ 42, 180, 44, 147, 49, 79, 80, 81, 82, 18, + /* 120 */ 69, 70, 71, 11, 73, 74, 75, 76, 77, 78, + /* 130 */ 79, 80, 81, 82, 16, 86, 87, 88, 1, 2, + /* 140 */ 91, 92, 93, 90, 91, 92, 93, 94, 95, 175, + /* 150 */ 176, 19, 103, 21, 23, 102, 182, 141, 142, 86, + /* 160 */ 42, 49, 44, 147, 79, 80, 81, 82, 180, 154, /* 170 */ 154, 77, 78, 79, 80, 81, 82, 59, 60, 61, /* 180 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - /* 190 */ 42, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 200 */ 82, 16, 86, 87, 188, 58, 21, 189, 77, 78, - /* 210 */ 62, 63, 146, 98, 99, 100, 88, 86, 87, 91, - /* 220 */ 92, 93, 1, 2, 109, 175, 176, 42, 97, 213, - /* 230 */ 160, 103, 182, 86, 168, 169, 157, 90, 90, 160, - /* 240 */ 161, 162, 146, 92, 59, 60, 61, 62, 63, 64, - /* 250 */ 65, 66, 67, 68, 69, 70, 71, 185, 73, 74, + /* 190 */ 146, 73, 74, 75, 76, 77, 78, 79, 80, 81, + /* 200 */ 82, 16, 14, 188, 188, 58, 21, 12, 77, 78, + /* 210 */ 98, 99, 100, 146, 22, 200, 201, 86, 87, 24, + /* 220 */ 205, 109, 216, 154, 218, 219, 189, 42, 97, 213, + /* 230 */ 160, 187, 37, 86, 39, 168, 169, 90, 160, 161, + /* 240 */ 162, 53, 236, 55, 59, 60, 61, 62, 63, 64, + /* 250 */ 65, 66, 67, 68, 69, 70, 71, 188, 73, 74, /* 260 */ 75, 76, 77, 78, 79, 80, 81, 82, 16, 199, - /* 270 */ 123, 124, 125, 146, 208, 209, 146, 216, 146, 218, - /* 280 */ 219, 19, 146, 132, 146, 23, 216, 146, 218, 219, - /* 290 */ 154, 23, 146, 149, 42, 168, 169, 236, 168, 169, - /* 300 */ 168, 169, 77, 78, 168, 169, 168, 169, 163, 164, - /* 310 */ 165, 59, 60, 61, 62, 63, 64, 65, 66, 67, + /* 270 */ 123, 124, 125, 149, 146, 208, 209, 77, 78, 146, + /* 280 */ 88, 237, 146, 91, 92, 93, 216, 146, 218, 219, + /* 290 */ 154, 0, 1, 2, 42, 103, 168, 169, 21, 160, + /* 300 */ 23, 168, 169, 157, 168, 169, 160, 161, 162, 168, + /* 310 */ 169, 59, 60, 61, 62, 63, 64, 65, 66, 67, /* 320 */ 68, 69, 70, 71, 188, 73, 74, 75, 76, 77, - /* 330 */ 78, 79, 80, 81, 82, 146, 146, 160, 211, 146, - /* 340 */ 16, 211, 30, 154, 146, 155, 156, 211, 86, 87, - /* 350 */ 223, 23, 220, 223, 86, 87, 146, 168, 169, 223, - /* 360 */ 88, 223, 50, 91, 92, 93, 42, 144, 224, 179, - /* 370 */ 180, 226, 228, 154, 154, 103, 199, 188, 168, 169, - /* 380 */ 187, 113, 130, 59, 60, 61, 62, 63, 64, 65, - /* 390 */ 66, 67, 68, 69, 70, 71, 146, 73, 74, 75, - /* 400 */ 76, 77, 78, 79, 80, 81, 82, 188, 188, 154, - /* 410 */ 12, 146, 16, 101, 86, 16, 20, 146, 167, 209, - /* 420 */ 200, 201, 24, 20, 12, 205, 175, 163, 164, 165, - /* 430 */ 20, 23, 213, 168, 169, 37, 24, 39, 42, 168, - /* 440 */ 169, 159, 43, 188, 160, 161, 162, 49, 229, 37, - /* 450 */ 168, 39, 146, 234, 130, 59, 60, 61, 62, 63, + /* 330 */ 78, 79, 80, 81, 82, 146, 146, 12, 199, 211, + /* 340 */ 16, 184, 185, 154, 211, 155, 156, 211, 224, 24, + /* 350 */ 88, 223, 228, 91, 92, 93, 223, 168, 169, 223, + /* 360 */ 20, 220, 37, 86, 39, 103, 42, 159, 146, 179, + /* 370 */ 180, 146, 18, 146, 49, 160, 168, 188, 184, 185, + /* 380 */ 155, 156, 130, 59, 60, 61, 62, 63, 64, 65, + /* 390 */ 66, 67, 68, 69, 70, 71, 90, 73, 74, 75, + /* 400 */ 76, 77, 78, 79, 80, 81, 82, 146, 102, 154, + /* 410 */ 16, 146, 16, 146, 199, 20, 20, 146, 185, 146, + /* 420 */ 167, 20, 163, 164, 165, 7, 8, 9, 175, 168, + /* 430 */ 169, 163, 164, 165, 212, 168, 169, 43, 42, 168, + /* 440 */ 169, 168, 169, 188, 22, 105, 92, 107, 108, 19, + /* 450 */ 23, 146, 187, 23, 130, 59, 60, 61, 62, 63, /* 460 */ 64, 65, 66, 67, 68, 69, 70, 71, 213, 73, /* 470 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 16, - /* 480 */ 215, 20, 146, 20, 229, 27, 215, 19, 146, 234, - /* 490 */ 226, 23, 34, 23, 86, 87, 97, 155, 156, 146, - /* 500 */ 146, 102, 0, 1, 2, 42, 184, 185, 105, 22, - /* 510 */ 107, 108, 21, 207, 23, 105, 146, 107, 108, 14, - /* 520 */ 14, 113, 59, 60, 61, 62, 63, 64, 65, 66, - /* 530 */ 67, 68, 69, 70, 71, 181, 73, 74, 75, 76, - /* 540 */ 77, 78, 79, 80, 81, 82, 16, 22, 146, 79, - /* 550 */ 20, 146, 109, 146, 86, 87, 86, 87, 53, 53, - /* 560 */ 55, 55, 146, 190, 146, 122, 105, 146, 107, 108, - /* 570 */ 168, 169, 42, 168, 169, 168, 169, 86, 225, 225, - /* 580 */ 7, 8, 9, 96, 168, 169, 168, 169, 160, 59, + /* 480 */ 209, 146, 215, 20, 223, 226, 132, 154, 215, 234, + /* 490 */ 23, 97, 23, 19, 226, 23, 102, 23, 109, 42, + /* 500 */ 105, 23, 107, 108, 146, 42, 105, 146, 107, 108, + /* 510 */ 23, 122, 207, 86, 87, 146, 86, 87, 96, 62, + /* 520 */ 63, 188, 59, 60, 61, 62, 63, 64, 65, 66, + /* 530 */ 67, 68, 69, 70, 71, 14, 73, 74, 75, 76, + /* 540 */ 77, 78, 79, 80, 81, 82, 16, 90, 146, 146, + /* 550 */ 20, 79, 146, 86, 87, 86, 87, 30, 86, 87, + /* 560 */ 86, 87, 146, 25, 86, 87, 105, 29, 107, 108, + /* 570 */ 168, 169, 42, 86, 53, 146, 55, 50, 146, 41, + /* 580 */ 113, 212, 113, 225, 168, 169, 146, 181, 144, 59, /* 590 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, /* 600 */ 70, 71, 146, 73, 74, 75, 76, 77, 78, 79, - /* 610 */ 80, 81, 82, 16, 98, 99, 100, 20, 146, 146, - /* 620 */ 146, 146, 146, 146, 168, 169, 146, 199, 146, 105, - /* 630 */ 146, 107, 108, 212, 98, 99, 100, 112, 132, 42, - /* 640 */ 168, 169, 168, 169, 168, 169, 184, 185, 168, 169, - /* 650 */ 168, 169, 168, 169, 181, 146, 59, 60, 61, 62, + /* 610 */ 80, 81, 82, 16, 146, 22, 187, 20, 190, 146, + /* 620 */ 109, 146, 146, 146, 168, 169, 146, 191, 101, 146, + /* 630 */ 146, 225, 146, 122, 198, 146, 168, 169, 129, 42, + /* 640 */ 131, 168, 169, 168, 169, 168, 169, 207, 168, 169, + /* 650 */ 154, 168, 169, 132, 168, 169, 59, 60, 61, 62, /* 660 */ 63, 64, 65, 66, 67, 68, 69, 70, 71, 146, /* 670 */ 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, - /* 680 */ 16, 146, 207, 22, 207, 21, 146, 146, 146, 146, - /* 690 */ 146, 168, 169, 146, 160, 146, 187, 146, 225, 200, - /* 700 */ 201, 106, 146, 168, 169, 110, 42, 146, 168, 169, - /* 710 */ 168, 169, 168, 169, 16, 168, 169, 168, 169, 168, - /* 720 */ 169, 146, 181, 59, 60, 61, 62, 63, 64, 65, + /* 680 */ 16, 146, 27, 207, 188, 21, 146, 154, 146, 34, + /* 690 */ 146, 168, 169, 146, 20, 146, 22, 146, 98, 99, + /* 700 */ 100, 200, 201, 168, 169, 112, 42, 16, 168, 169, + /* 710 */ 168, 169, 168, 169, 146, 168, 169, 168, 169, 168, + /* 720 */ 169, 188, 22, 59, 60, 61, 62, 63, 64, 65, /* 730 */ 66, 67, 68, 69, 70, 71, 146, 73, 74, 75, /* 740 */ 76, 77, 78, 79, 80, 81, 82, 16, 146, 146, - /* 750 */ 146, 25, 146, 146, 146, 29, 146, 22, 168, 169, - /* 760 */ 146, 129, 187, 131, 146, 202, 225, 41, 212, 146, - /* 770 */ 168, 169, 146, 42, 168, 169, 168, 169, 168, 169, - /* 780 */ 146, 120, 168, 169, 181, 181, 168, 169, 90, 79, + /* 750 */ 146, 146, 146, 146, 146, 187, 146, 22, 168, 169, + /* 760 */ 146, 98, 99, 100, 146, 106, 146, 123, 124, 110, + /* 770 */ 168, 169, 160, 42, 168, 169, 168, 169, 168, 169, + /* 780 */ 43, 90, 168, 169, 181, 181, 168, 169, 168, 169, /* 790 */ 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, /* 800 */ 69, 70, 71, 146, 73, 74, 75, 76, 77, 78, - /* 810 */ 79, 80, 81, 82, 16, 146, 106, 154, 90, 146, - /* 820 */ 110, 146, 87, 146, 19, 168, 169, 146, 225, 225, - /* 830 */ 102, 19, 146, 21, 123, 124, 146, 168, 169, 177, - /* 840 */ 42, 168, 169, 168, 169, 168, 169, 177, 113, 168, - /* 850 */ 169, 188, 146, 146, 168, 169, 177, 59, 60, 61, + /* 810 */ 79, 80, 81, 82, 16, 146, 146, 146, 146, 146, + /* 820 */ 120, 146, 87, 146, 202, 168, 169, 146, 225, 225, + /* 830 */ 7, 8, 146, 20, 97, 22, 146, 168, 169, 146, + /* 840 */ 42, 168, 169, 168, 169, 168, 169, 146, 113, 168, + /* 850 */ 169, 181, 181, 146, 168, 169, 79, 59, 60, 61, /* 860 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, /* 870 */ 146, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 880 */ 82, 16, 146, 7, 8, 146, 146, 154, 146, 20, - /* 890 */ 146, 22, 168, 169, 187, 20, 146, 22, 20, 20, - /* 900 */ 22, 22, 89, 90, 168, 169, 146, 42, 168, 169, - /* 910 */ 168, 169, 168, 169, 146, 146, 111, 146, 146, 154, - /* 920 */ 20, 188, 22, 146, 16, 60, 61, 62, 63, 64, - /* 930 */ 65, 66, 67, 68, 69, 70, 71, 187, 73, 74, - /* 940 */ 75, 76, 77, 78, 79, 80, 81, 82, 146, 20, - /* 950 */ 42, 22, 20, 188, 22, 187, 187, 19, 187, 187, - /* 960 */ 230, 154, 154, 51, 52, 20, 20, 22, 22, 61, + /* 880 */ 82, 16, 146, 106, 89, 90, 146, 110, 146, 20, + /* 890 */ 146, 22, 168, 169, 146, 225, 225, 20, 20, 22, + /* 900 */ 22, 51, 52, 154, 168, 169, 177, 42, 168, 169, + /* 910 */ 168, 169, 168, 169, 146, 177, 168, 169, 146, 146, + /* 920 */ 146, 146, 146, 19, 16, 60, 61, 62, 63, 64, + /* 930 */ 65, 66, 67, 68, 69, 70, 71, 188, 73, 74, + /* 940 */ 75, 76, 77, 78, 79, 80, 81, 82, 177, 20, + /* 950 */ 42, 22, 146, 20, 20, 22, 22, 146, 20, 187, + /* 960 */ 22, 187, 187, 187, 20, 20, 22, 22, 146, 61, /* 970 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, - /* 980 */ 231, 73, 74, 75, 76, 77, 78, 79, 80, 81, - /* 990 */ 82, 16, 17, 146, 19, 188, 188, 20, 23, 22, - /* 1000 */ 20, 146, 22, 146, 146, 67, 31, 16, 17, 237, - /* 1010 */ 19, 148, 146, 146, 23, 171, 146, 146, 146, 146, - /* 1020 */ 146, 190, 31, 48, 192, 222, 146, 227, 227, 176, - /* 1030 */ 171, 171, 171, 58, 172, 171, 193, 6, 193, 48, - /* 1040 */ 145, 145, 145, 145, 22, 153, 97, 170, 40, 58, - /* 1050 */ 96, 170, 77, 78, 170, 172, 170, 120, 117, 115, - /* 1060 */ 85, 86, 87, 178, 196, 90, 118, 221, 77, 78, - /* 1070 */ 79, 119, 129, 111, 151, 188, 85, 86, 87, 16, - /* 1080 */ 17, 90, 19, 193, 109, 194, 23, 95, 195, 23, - /* 1090 */ 159, 197, 210, 151, 31, 97, 114, 19, 123, 124, - /* 1100 */ 125, 126, 127, 128, 203, 178, 204, 203, 173, 210, - /* 1110 */ 204, 48, 159, 210, 123, 124, 125, 126, 127, 128, - /* 1120 */ 210, 58, 5, 173, 15, 170, 170, 10, 11, 12, - /* 1130 */ 13, 170, 151, 150, 38, 19, 151, 151, 151, 23, - /* 1140 */ 77, 78, 129, 26, 233, 28, 232, 150, 85, 86, - /* 1150 */ 87, 151, 35, 90, 59, 183, 183, 19, 193, 15, - /* 1160 */ 186, 214, 186, 193, 47, 186, 49, 183, 151, 33, - /* 1170 */ 151, 54, 214, 56, 58, 235, 151, 136, 158, 174, - /* 1180 */ 174, 1, 20, 32, 44, 19, 123, 124, 125, 126, - /* 1190 */ 127, 128, 235, 77, 78, 111, 111, 238, 111, 111, - /* 1200 */ 19, 90, 86, 20, 20, 106, 90, 19, 11, 19, - /* 1210 */ 116, 20, 111, 20, 22, 98, 99, 100, 22, 116, - /* 1220 */ 22, 104, 19, 113, 20, 20, 109, 19, 19, 44, - /* 1230 */ 20, 19, 19, 44, 102, 94, 16, 21, 17, 123, - /* 1240 */ 124, 125, 97, 36, 45, 22, 45, 132, 19, 97, - /* 1250 */ 133, 5, 11, 1, 101, 121, 19, 17, 112, 112, - /* 1260 */ 101, 67, 67, 121, 19, 14, 135, 20, 57, 134, - /* 1270 */ 3, 239, 4, + /* 980 */ 19, 73, 74, 75, 76, 77, 78, 79, 80, 81, + /* 990 */ 82, 16, 17, 187, 19, 146, 230, 146, 23, 146, + /* 1000 */ 231, 146, 146, 146, 146, 146, 31, 16, 17, 146, + /* 1010 */ 19, 171, 146, 146, 23, 111, 146, 146, 190, 192, + /* 1020 */ 148, 227, 31, 48, 227, 222, 193, 193, 67, 6, + /* 1030 */ 176, 171, 171, 58, 172, 171, 145, 145, 145, 48, + /* 1040 */ 145, 22, 153, 97, 171, 170, 170, 40, 96, 58, + /* 1050 */ 170, 170, 77, 78, 172, 120, 188, 178, 117, 119, + /* 1060 */ 85, 86, 87, 221, 115, 90, 118, 193, 77, 78, + /* 1070 */ 79, 129, 151, 111, 95, 23, 85, 86, 87, 16, + /* 1080 */ 17, 90, 19, 195, 109, 159, 23, 197, 194, 97, + /* 1090 */ 151, 114, 196, 210, 31, 210, 19, 173, 123, 124, + /* 1100 */ 125, 126, 127, 128, 203, 178, 204, 204, 203, 210, + /* 1110 */ 210, 48, 159, 170, 123, 124, 125, 126, 127, 128, + /* 1120 */ 170, 58, 5, 15, 170, 151, 150, 10, 11, 12, + /* 1130 */ 13, 173, 151, 151, 151, 19, 38, 129, 232, 23, + /* 1140 */ 77, 78, 233, 26, 150, 28, 151, 59, 85, 86, + /* 1150 */ 87, 183, 35, 90, 183, 19, 193, 15, 186, 186, + /* 1160 */ 193, 214, 151, 183, 47, 214, 49, 33, 151, 151, + /* 1170 */ 186, 54, 235, 56, 58, 136, 174, 174, 158, 1, + /* 1180 */ 20, 32, 44, 19, 229, 111, 123, 124, 125, 126, + /* 1190 */ 127, 128, 235, 77, 78, 111, 111, 238, 111, 19, + /* 1200 */ 90, 20, 86, 20, 19, 106, 90, 11, 19, 22, + /* 1210 */ 20, 20, 116, 116, 22, 98, 99, 100, 113, 22, + /* 1220 */ 19, 104, 20, 111, 20, 19, 109, 20, 44, 19, + /* 1230 */ 19, 19, 44, 94, 102, 16, 21, 17, 97, 123, + /* 1240 */ 124, 125, 97, 45, 36, 22, 132, 19, 45, 5, + /* 1250 */ 133, 1, 101, 67, 121, 19, 112, 17, 112, 101, + /* 1260 */ 67, 121, 19, 14, 134, 20, 57, 3, 239, 4, + /* 1270 */ 135, }; #define YY_SHIFT_USE_DFLT (-98) -#define YY_SHIFT_MAX 370 +#define YY_SHIFT_MAX 369 static const short yy_shift_ofst[] = { - /* 0 */ 221, 975, 1117, -16, 975, 1063, 1063, 1063, 49, 115, - /* 10 */ 115, -97, 118, 1063, 1063, 1063, 1063, 1063, -45, 131, - /* 20 */ 116, 328, 225, 225, 51, 185, 252, 324, 396, 463, - /* 30 */ 530, 597, 664, 731, 798, 731, 731, 731, 731, 731, + /* 0 */ 137, 975, 1117, -16, 975, 1063, 1063, 1063, 49, -97, + /* 10 */ 118, 1063, 1063, 1063, 1063, 1063, -45, 112, 131, 478, + /* 20 */ 487, 200, 200, 51, 185, 252, 324, 396, 463, 530, + /* 30 */ 597, 664, 731, 798, 731, 731, 731, 731, 731, 731, /* 40 */ 731, 731, 731, 731, 731, 731, 731, 731, 731, 731, - /* 50 */ 731, 731, 865, 908, 908, 991, 1063, 1063, 1063, 1063, + /* 50 */ 731, 865, 908, 908, 991, 1063, 1063, 1063, 1063, 1063, /* 60 */ 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, /* 70 */ 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, /* 80 */ 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, 1063, - /* 90 */ 1063, 1063, 1063, 1063, -60, -60, -14, 27, 27, 94, - /* 100 */ 86, 399, 116, 116, 116, 116, 151, 116, 116, 116, - /* 110 */ 328, -59, -98, -98, -98, 1116, 53, 398, 398, 502, - /* 120 */ 491, 116, 491, 116, 116, 116, 116, 116, 116, 116, - /* 130 */ 116, 116, 116, 116, 116, 116, 29, 443, -97, -97, - /* 140 */ -97, -98, -98, 147, 147, 128, 272, 403, 262, 410, - /* 150 */ 461, 412, 268, 408, 468, 470, 573, 116, 116, 710, - /* 160 */ 116, 116, 73, 116, 116, 735, 116, 116, 524, 735, - /* 170 */ 116, 116, 312, 312, 312, 116, 116, 524, 116, 116, - /* 180 */ 524, 116, 726, 516, 116, 116, 524, 116, 116, 116, - /* 190 */ 524, 116, 524, 524, 116, 116, 116, 116, 116, 116, - /* 200 */ 812, 458, 595, 525, 711, 711, 632, 458, 458, 56, - /* 210 */ 458, 458, 487, 661, 661, 1031, 1031, 1031, 1031, 1022, - /* 220 */ 949, 949, 1008, 949, 954, 949, -97, 937, 941, 948, - /* 230 */ 944, 952, 943, 962, 992, 1066, 992, 962, 998, 982, - /* 240 */ 998, 982, 1078, 992, 992, 1066, 1008, 949, 949, 949, - /* 250 */ 1078, 1109, 962, 962, 962, 962, 1096, 1013, 1109, 962, - /* 260 */ 1095, 1095, 1138, 937, 1144, 1144, 1144, 937, 1095, 1138, - /* 270 */ 962, 1136, 1136, 962, 962, 1041, -98, -98, -98, 148, - /* 280 */ 506, 536, 505, 728, 876, 805, 869, 698, 875, 878, - /* 290 */ 879, 813, 900, 929, 932, 912, 945, 946, 977, 980, - /* 300 */ 938, 1180, 1162, 1151, 1140, 1166, 1084, 1085, 1087, 1088, - /* 310 */ 1181, 1183, 1184, 1111, 1099, 1188, 1197, 1190, 1191, 1192, - /* 320 */ 1193, 1094, 1196, 1103, 1198, 1110, 1203, 1204, 1101, 1205, - /* 330 */ 1185, 1208, 1210, 1209, 1212, 1189, 1213, 1141, 1132, 1220, - /* 340 */ 1221, 1216, 1145, 1207, 1199, 1223, 1201, 1115, 1152, 1229, - /* 350 */ 1246, 1241, 1252, 1153, 1194, 1195, 1134, 1237, 1146, 1240, - /* 360 */ 1147, 1159, 1142, 1245, 1247, 1251, 1211, 1135, 1131, 1267, - /* 370 */ 1268, + /* 90 */ 1063, 1063, 1063, -60, -60, -14, 27, 27, 94, 85, + /* 100 */ 394, 478, 478, 478, 478, 354, 478, 478, 478, 487, + /* 110 */ -59, -98, -98, -98, 1116, 53, 325, 325, 291, 277, + /* 120 */ 478, 277, 478, 478, 478, 478, 478, 478, 478, 478, + /* 130 */ 478, 478, 478, 478, 478, 389, 511, -97, -97, -97, + /* 140 */ -98, -98, 147, 147, 192, 262, 340, 430, 395, 401, + /* 150 */ 195, 467, 469, 474, 472, 418, 427, 427, 777, 427, + /* 160 */ 427, 73, 427, 427, 735, 427, 427, 461, 735, 427, + /* 170 */ 427, 527, 527, 527, 427, 427, 461, 427, 427, 461, + /* 180 */ 427, 538, 600, 427, 427, 461, 427, 427, 427, 461, + /* 190 */ 427, 461, 461, 427, 427, 427, 427, 427, 427, 132, + /* 200 */ 655, 659, 593, 644, 644, 509, 655, 655, 737, 655, + /* 210 */ 655, 422, 700, 700, 1023, 1023, 1023, 1023, 1019, 946, + /* 220 */ 946, 1007, 946, 952, 946, -97, 935, 941, 948, 949, + /* 230 */ 940, 942, 962, 979, 1052, 979, 962, 992, 977, 992, + /* 240 */ 977, 1077, 979, 979, 1052, 1007, 946, 946, 946, 1077, + /* 250 */ 1108, 962, 962, 962, 962, 1098, 1008, 1108, 962, 1088, + /* 260 */ 1088, 1136, 935, 1142, 1142, 1142, 935, 1088, 1136, 962, + /* 270 */ 1134, 1134, 962, 962, 1039, -98, -98, -98, -98, 457, + /* 280 */ 521, 663, 188, 306, 823, 904, 674, 691, 813, 869, + /* 290 */ 877, 795, 878, 929, 933, 850, 934, 938, 944, 945, + /* 300 */ 961, 1178, 1160, 1149, 1138, 1164, 1074, 1084, 1085, 1087, + /* 310 */ 1180, 1181, 1183, 1110, 1099, 1185, 1196, 1189, 1190, 1187, + /* 320 */ 1191, 1096, 1192, 1097, 1197, 1105, 1201, 1202, 1112, 1204, + /* 330 */ 1184, 1206, 1207, 1210, 1211, 1188, 1212, 1139, 1132, 1219, + /* 340 */ 1220, 1215, 1141, 1208, 1198, 1223, 1203, 1114, 1145, 1228, + /* 350 */ 1244, 1250, 1151, 1186, 1193, 1133, 1236, 1144, 1240, 1146, + /* 360 */ 1158, 1140, 1243, 1245, 1249, 1209, 1130, 1135, 1264, 1265, }; #define YY_REDUCE_USE_DFLT (-216) #define YY_REDUCE_MAX 278 static const short yy_reduce_ofst[] = { - /* 0 */ -56, 136, 16, 70, 189, 127, 66, 130, 190, 219, - /* 10 */ 255, 220, 61, 132, 138, 210, 265, 271, -178, -140, - /* 20 */ -61, 79, 145, 264, -215, -215, -215, -215, -215, -215, + /* 0 */ -56, 136, 16, 70, 189, 128, 67, 133, 190, 15, + /* 10 */ 6, 141, 261, 271, 267, 273, -178, 255, -140, -61, + /* 20 */ 146, 259, 268, -215, -215, -215, -215, -215, -215, -215, /* 30 */ -215, -215, -215, -215, -215, -215, -215, -215, -215, -215, /* 40 */ -215, -215, -215, -215, -215, -215, -215, -215, -215, -215, - /* 50 */ -215, -215, -215, -215, -215, 402, 405, 407, 416, 418, - /* 60 */ 456, 472, 474, 476, 480, 482, 484, 523, 535, 540, - /* 70 */ 542, 544, 547, 549, 551, 590, 602, 606, 608, 610, - /* 80 */ 614, 618, 657, 669, 673, 675, 677, 681, 686, 724, - /* 90 */ 736, 740, 742, 744, -215, -215, -77, -215, -215, -215, - /* 100 */ -215, 50, 354, 473, 541, 603, 144, 604, 772, 342, - /* 110 */ 284, -215, -215, -215, -215, 282, 251, 322, 462, -72, - /* 120 */ 177, 306, 428, 353, 193, 475, 421, 477, 509, 575, - /* 130 */ 707, 750, 768, 771, 556, 769, 663, 733, 765, 807, - /* 140 */ 808, -42, 499, -126, -112, -57, -19, 18, 96, 18, - /* 150 */ 18, 72, 141, 146, 198, 250, 223, 336, 370, 373, - /* 160 */ 250, 543, 534, 561, 607, 563, 623, 626, 18, 563, - /* 170 */ 634, 690, 662, 670, 679, 706, 739, 18, 760, 777, - /* 180 */ 18, 802, 730, 749, 847, 855, 18, 857, 858, 866, - /* 190 */ 18, 867, 18, 18, 870, 871, 872, 873, 874, 880, - /* 200 */ 863, 844, 831, 832, 800, 801, 803, 859, 860, 853, - /* 210 */ 861, 864, 862, 843, 845, 895, 896, 897, 898, 892, - /* 220 */ 877, 881, 885, 884, 883, 886, 887, 890, 891, 893, - /* 230 */ 868, 894, 846, 923, 882, 931, 899, 942, 901, 902, - /* 240 */ 904, 906, 935, 903, 910, 953, 927, 955, 956, 961, - /* 250 */ 950, 983, 981, 985, 986, 987, 914, 911, 997, 1000, - /* 260 */ 972, 973, 947, 965, 974, 976, 979, 970, 984, 958, - /* 270 */ 1017, 940, 957, 1019, 1025, 959, 1020, 1005, 1006, + /* 50 */ -215, -215, -215, -215, 402, 416, 456, 468, 473, 475, + /* 60 */ 477, 480, 483, 486, 523, 535, 540, 542, 544, 547, + /* 70 */ 549, 551, 590, 602, 606, 608, 610, 614, 618, 620, + /* 80 */ 657, 669, 673, 675, 677, 681, 686, 724, 736, 740, + /* 90 */ 742, 744, 748, -215, -215, -77, -215, -215, -215, -215, + /* 100 */ -26, 406, 603, 604, 670, 124, 671, 44, 225, 78, + /* 110 */ -215, -215, -215, -215, 208, 253, 157, 194, -72, 139, + /* 120 */ 305, 215, 358, 265, 440, 222, 476, 429, 568, 772, + /* 130 */ 774, 775, 776, 369, 806, 69, 333, 496, 533, 749, + /* 140 */ 436, 501, -126, -112, -81, -12, 37, 227, 37, 37, + /* 150 */ 233, 335, 361, 403, 432, 444, 484, 489, 428, 432, + /* 160 */ 605, 612, 607, 672, 622, 690, 693, 37, 622, 701, + /* 170 */ 707, 729, 738, 771, 768, 773, 37, 811, 822, 37, + /* 180 */ 849, 766, 769, 851, 853, 37, 855, 856, 857, 37, + /* 190 */ 858, 37, 37, 859, 863, 866, 867, 870, 871, 872, + /* 200 */ 840, 828, 827, 794, 797, 803, 860, 861, 854, 864, + /* 210 */ 873, 862, 833, 834, 891, 892, 893, 895, 889, 875, + /* 220 */ 876, 879, 880, 882, 881, 868, 874, 894, 888, 896, + /* 230 */ 890, 842, 921, 883, 926, 885, 939, 901, 902, 905, + /* 240 */ 903, 924, 899, 900, 953, 927, 943, 950, 954, 958, + /* 250 */ 976, 974, 981, 982, 983, 906, 909, 994, 995, 968, + /* 260 */ 971, 947, 963, 972, 973, 984, 967, 980, 951, 1011, + /* 270 */ 937, 957, 1017, 1018, 959, 1020, 1002, 1003, 955, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 566, 790, 855, 681, 855, 790, 855, 790, 855, 828, - /* 10 */ 828, 685, 841, 786, 790, 855, 855, 855, 761, 812, - /* 20 */ 855, 597, 812, 812, 716, 855, 855, 855, 855, 855, - /* 30 */ 855, 855, 855, 717, 855, 789, 785, 781, 783, 782, - /* 40 */ 718, 705, 714, 721, 697, 826, 723, 724, 729, 730, - /* 50 */ 842, 845, 751, 767, 750, 855, 855, 855, 855, 855, - /* 60 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, - /* 70 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, - /* 80 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, - /* 90 */ 855, 855, 855, 855, 753, 772, 590, 752, 760, 754, - /* 100 */ 755, 650, 855, 855, 855, 855, 585, 855, 855, 855, - /* 110 */ 855, 756, 757, 768, 769, 855, 855, 855, 855, 566, - /* 120 */ 681, 855, 681, 855, 855, 855, 855, 855, 855, 855, - /* 130 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, - /* 140 */ 855, 675, 685, 855, 855, 641, 855, 855, 855, 855, - /* 150 */ 855, 855, 855, 855, 855, 855, 573, 571, 855, 673, - /* 160 */ 855, 855, 599, 855, 855, 683, 855, 855, 688, 689, - /* 170 */ 855, 855, 855, 855, 855, 855, 855, 587, 855, 855, - /* 180 */ 662, 855, 818, 855, 855, 855, 833, 855, 855, 855, - /* 190 */ 831, 855, 664, 726, 800, 855, 855, 846, 848, 855, - /* 200 */ 855, 708, 673, 682, 855, 855, 784, 708, 708, 620, - /* 210 */ 708, 708, 623, 720, 720, 570, 570, 570, 570, 640, - /* 220 */ 652, 652, 637, 652, 623, 652, 855, 720, 711, 713, - /* 230 */ 701, 715, 855, 690, 709, 855, 709, 690, 698, 700, - /* 240 */ 698, 700, 794, 709, 709, 855, 637, 652, 652, 652, - /* 250 */ 794, 582, 690, 690, 690, 690, 822, 825, 582, 690, - /* 260 */ 654, 654, 731, 720, 661, 661, 661, 720, 654, 731, - /* 270 */ 690, 844, 844, 690, 690, 853, 607, 625, 625, 855, - /* 280 */ 855, 855, 855, 855, 855, 738, 855, 855, 855, 855, - /* 290 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, - /* 300 */ 807, 855, 855, 855, 855, 855, 743, 739, 855, 740, - /* 310 */ 855, 855, 855, 855, 667, 855, 855, 855, 855, 855, - /* 320 */ 855, 855, 702, 855, 712, 855, 855, 855, 855, 855, - /* 330 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, - /* 340 */ 855, 855, 855, 855, 820, 821, 855, 855, 855, 855, - /* 350 */ 855, 855, 855, 855, 855, 855, 855, 855, 855, 855, - /* 360 */ 855, 855, 855, 855, 855, 855, 852, 855, 855, 567, - /* 370 */ 855, 561, 564, 563, 565, 569, 572, 594, 595, 596, - /* 380 */ 574, 575, 576, 577, 578, 579, 580, 586, 588, 606, - /* 390 */ 608, 615, 653, 656, 657, 658, 836, 837, 838, 616, - /* 400 */ 635, 638, 639, 617, 624, 706, 707, 618, 671, 672, - /* 410 */ 735, 665, 666, 670, 737, 741, 742, 744, 745, 593, - /* 420 */ 600, 601, 604, 605, 808, 810, 809, 811, 603, 602, - /* 430 */ 746, 749, 758, 759, 765, 771, 774, 763, 764, 766, - /* 440 */ 770, 773, 668, 669, 777, 779, 780, 834, 835, 775, - /* 450 */ 787, 788, 691, 778, 762, 703, 592, 710, 704, 674, - /* 460 */ 684, 693, 694, 695, 696, 679, 680, 686, 699, 733, - /* 470 */ 734, 687, 676, 677, 678, 776, 736, 747, 748, 619, - /* 480 */ 626, 627, 628, 631, 632, 633, 634, 629, 630, 795, - /* 490 */ 796, 798, 797, 621, 622, 636, 609, 610, 611, 612, - /* 500 */ 743, 613, 614, 598, 591, 642, 645, 646, 647, 648, - /* 510 */ 649, 651, 643, 644, 589, 581, 583, 692, 814, 823, - /* 520 */ 824, 819, 815, 816, 817, 584, 791, 792, 655, 727, - /* 530 */ 728, 813, 827, 829, 732, 830, 832, 659, 660, 663, - /* 540 */ 799, 839, 719, 722, 725, 801, 802, 803, 804, 805, - /* 550 */ 806, 840, 843, 847, 849, 850, 851, 854, 568, 562, + /* 0 */ 565, 789, 854, 680, 854, 789, 854, 789, 854, 684, + /* 10 */ 840, 785, 789, 854, 854, 854, 760, 854, 811, 854, + /* 20 */ 596, 811, 811, 715, 854, 854, 854, 854, 854, 854, + /* 30 */ 854, 854, 716, 854, 788, 784, 780, 782, 781, 717, + /* 40 */ 704, 713, 720, 696, 825, 722, 723, 728, 729, 841, + /* 50 */ 844, 750, 766, 749, 854, 854, 854, 854, 854, 854, + /* 60 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, + /* 70 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, + /* 80 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, + /* 90 */ 854, 854, 854, 752, 771, 589, 751, 759, 753, 754, + /* 100 */ 649, 854, 854, 854, 854, 584, 854, 854, 854, 854, + /* 110 */ 755, 756, 767, 768, 854, 854, 854, 854, 565, 680, + /* 120 */ 854, 680, 854, 854, 854, 854, 854, 854, 854, 854, + /* 130 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, + /* 140 */ 674, 684, 854, 854, 640, 854, 854, 854, 854, 854, + /* 150 */ 854, 854, 854, 854, 854, 572, 570, 854, 672, 854, + /* 160 */ 854, 598, 854, 854, 682, 854, 854, 687, 688, 854, + /* 170 */ 854, 854, 854, 854, 854, 854, 586, 854, 854, 661, + /* 180 */ 854, 817, 854, 854, 854, 832, 854, 854, 854, 830, + /* 190 */ 854, 663, 725, 799, 854, 854, 845, 847, 854, 854, + /* 200 */ 707, 672, 681, 854, 854, 783, 707, 707, 619, 707, + /* 210 */ 707, 622, 719, 719, 569, 569, 569, 569, 639, 651, + /* 220 */ 651, 636, 651, 622, 651, 854, 719, 710, 712, 700, + /* 230 */ 714, 854, 689, 708, 854, 708, 689, 697, 699, 697, + /* 240 */ 699, 793, 708, 708, 854, 636, 651, 651, 651, 793, + /* 250 */ 581, 689, 689, 689, 689, 821, 824, 581, 689, 653, + /* 260 */ 653, 730, 719, 660, 660, 660, 719, 653, 730, 689, + /* 270 */ 843, 843, 689, 689, 852, 606, 624, 624, 827, 854, + /* 280 */ 854, 854, 854, 854, 854, 737, 854, 854, 854, 854, + /* 290 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, + /* 300 */ 806, 854, 854, 854, 854, 854, 742, 738, 854, 739, + /* 310 */ 854, 854, 854, 854, 666, 854, 854, 854, 854, 854, + /* 320 */ 854, 854, 701, 854, 711, 854, 854, 854, 854, 854, + /* 330 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, + /* 340 */ 854, 854, 854, 854, 819, 820, 854, 854, 854, 854, + /* 350 */ 854, 854, 854, 854, 854, 854, 854, 854, 854, 854, + /* 360 */ 854, 854, 854, 854, 854, 851, 854, 854, 566, 854, + /* 370 */ 560, 563, 562, 564, 568, 571, 593, 594, 595, 573, + /* 380 */ 574, 575, 576, 577, 578, 579, 585, 587, 605, 607, + /* 390 */ 614, 652, 655, 656, 657, 835, 836, 837, 615, 634, + /* 400 */ 637, 638, 616, 623, 705, 706, 617, 670, 671, 734, + /* 410 */ 664, 665, 669, 736, 740, 741, 743, 744, 592, 599, + /* 420 */ 600, 603, 604, 807, 809, 808, 810, 602, 601, 745, + /* 430 */ 748, 757, 758, 764, 770, 773, 762, 763, 765, 769, + /* 440 */ 772, 667, 668, 776, 778, 779, 833, 834, 774, 786, + /* 450 */ 787, 690, 777, 761, 702, 591, 709, 703, 673, 683, + /* 460 */ 692, 693, 694, 695, 678, 679, 685, 698, 732, 733, + /* 470 */ 686, 675, 676, 677, 775, 735, 746, 747, 618, 625, + /* 480 */ 626, 627, 630, 631, 632, 633, 628, 629, 794, 795, + /* 490 */ 797, 796, 620, 621, 635, 608, 609, 610, 611, 742, + /* 500 */ 612, 613, 597, 590, 641, 644, 645, 646, 647, 648, + /* 510 */ 650, 642, 643, 588, 580, 582, 691, 813, 822, 823, + /* 520 */ 818, 814, 815, 816, 583, 790, 791, 654, 726, 727, + /* 530 */ 812, 826, 828, 731, 829, 831, 658, 659, 662, 798, + /* 540 */ 838, 718, 721, 724, 800, 801, 802, 803, 804, 805, + /* 550 */ 839, 842, 846, 848, 849, 850, 853, 567, 561, }; #define YY_SZ_ACTTAB (sizeof(yy_action)/sizeof(yy_action[0])) @@ -1121,7 +1120,7 @@ /* 264 */ "foreach_clause ::= FOR EACH STATEMENT", /* 265 */ "when_clause ::=", /* 266 */ "when_clause ::= WHEN expr", - /* 267 */ "trigger_cmd_list ::= trigger_cmd SEMI trigger_cmd_list", + /* 267 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", /* 268 */ "trigger_cmd_list ::=", /* 269 */ "trigger_cmd ::= UPDATE orconf nm SET setlist where_opt", /* 270 */ "trigger_cmd ::= insert_cmd INTO nm inscollist_opt VALUES LP itemlist RP", @@ -1209,9 +1208,9 @@ case 154: case 188: case 205: -#line 368 "parse.y" +#line 371 "parse.y" {sqlite3SelectDelete((yypminor->yy239));} -#line 1216 "parse.c" +#line 1215 "parse.c" break; case 168: case 169: @@ -1224,9 +1223,9 @@ case 222: case 223: case 233: -#line 625 "parse.y" +#line 628 "parse.y" {sqlite3ExprDelete((yypminor->yy178));} -#line 1231 "parse.c" +#line 1230 "parse.c" break; case 173: case 181: @@ -1239,48 +1238,48 @@ case 212: case 215: case 221: -#line 855 "parse.y" +#line 859 "parse.y" {sqlite3ExprListDelete((yypminor->yy462));} -#line 1246 "parse.c" +#line 1245 "parse.c" break; case 187: case 192: case 200: case 201: -#line 496 "parse.y" +#line 499 "parse.y" {sqlite3SrcListDelete((yypminor->yy285));} -#line 1254 "parse.c" +#line 1253 "parse.c" break; case 197: -#line 557 "parse.y" +#line 560 "parse.y" { sqlite3ExprDelete((yypminor->yy270).pLimit); sqlite3ExprDelete((yypminor->yy270).pOffset); } -#line 1262 "parse.c" +#line 1261 "parse.c" break; case 204: case 207: case 214: -#line 513 "parse.y" +#line 516 "parse.y" {sqlite3IdListDelete((yypminor->yy160));} -#line 1269 "parse.c" +#line 1268 "parse.c" break; case 229: case 234: -#line 949 "parse.y" +#line 953 "parse.y" {sqlite3DeleteTriggerStep((yypminor->yy247));} -#line 1275 "parse.c" +#line 1274 "parse.c" break; case 231: -#line 933 "parse.y" +#line 937 "parse.y" {sqlite3IdListDelete((yypminor->yy132).b);} -#line 1280 "parse.c" +#line 1279 "parse.c" break; case 236: -#line 1008 "parse.y" +#line 1021 "parse.y" {sqlite3ExprDelete((yypminor->yy292));} -#line 1285 "parse.c" +#line 1284 "parse.c" break; default: break; /* If no destructor action specified: do nothing */ } @@ -1428,6 +1427,10 @@ while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); /* Here code is inserted which will execute if the parser ** stack every overflows */ +#line 43 "parse.y" + + sqlite3ErrorMsg(pParse, "parser stack overflow"); +#line 1436 "parse.c" sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument var */ return; } @@ -1798,61 +1801,61 @@ ** break; */ case 3: -#line 95 "parse.y" +#line 98 "parse.y" { sqlite3FinishCoding(pParse); } -#line 1805 "parse.c" +#line 1809 "parse.c" break; case 6: -#line 98 "parse.y" +#line 101 "parse.y" { sqlite3BeginParse(pParse, 0); } -#line 1810 "parse.c" +#line 1814 "parse.c" break; case 7: -#line 100 "parse.y" +#line 103 "parse.y" { sqlite3BeginParse(pParse, 1); } -#line 1815 "parse.c" +#line 1819 "parse.c" break; case 8: -#line 101 "parse.y" +#line 104 "parse.y" { sqlite3BeginParse(pParse, 2); } -#line 1820 "parse.c" +#line 1824 "parse.c" break; case 9: -#line 107 "parse.y" +#line 110 "parse.y" {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy230);} -#line 1825 "parse.c" +#line 1829 "parse.c" break; case 13: -#line 112 "parse.y" +#line 115 "parse.y" {yygotominor.yy230 = TK_DEFERRED;} -#line 1830 "parse.c" +#line 1834 "parse.c" break; case 14: case 15: case 16: case 107: case 109: -#line 113 "parse.y" +#line 116 "parse.y" {yygotominor.yy230 = yymsp[0].major;} -#line 1839 "parse.c" +#line 1843 "parse.c" break; case 17: case 18: -#line 116 "parse.y" +#line 119 "parse.y" {sqlite3CommitTransaction(pParse);} -#line 1845 "parse.c" +#line 1849 "parse.c" break; case 19: -#line 118 "parse.y" +#line 121 "parse.y" {sqlite3RollbackTransaction(pParse);} -#line 1850 "parse.c" +#line 1854 "parse.c" break; case 21: -#line 123 "parse.y" +#line 126 "parse.y" { - sqlite3StartTable(pParse,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384,yymsp[-4].minor.yy230,0,yymsp[-2].minor.yy230); + sqlite3StartTable(pParse,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384,yymsp[-4].minor.yy230,0,yymsp[-2].minor.yy230); } -#line 1857 "parse.c" +#line 1861 "parse.c" break; case 22: case 25: @@ -1865,9 +1868,9 @@ case 113: case 210: case 213: -#line 127 "parse.y" +#line 130 "parse.y" {yygotominor.yy230 = 0;} -#line 1872 "parse.c" +#line 1876 "parse.c" break; case 23: case 24: @@ -1877,40 +1880,40 @@ case 111: case 211: case 214: -#line 128 "parse.y" +#line 131 "parse.y" {yygotominor.yy230 = 1;} -#line 1884 "parse.c" +#line 1888 "parse.c" break; case 26: -#line 134 "parse.y" +#line 137 "parse.y" { sqlite3EndTable(pParse,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy0,0); } -#line 1891 "parse.c" +#line 1895 "parse.c" break; case 27: -#line 137 "parse.y" +#line 140 "parse.y" { sqlite3EndTable(pParse,0,0,yymsp[0].minor.yy239); sqlite3SelectDelete(yymsp[0].minor.yy239); } -#line 1899 "parse.c" +#line 1903 "parse.c" break; case 30: -#line 149 "parse.y" +#line 152 "parse.y" { yygotominor.yy384.z = yymsp[-2].minor.yy384.z; yygotominor.yy384.n = (pParse->sLastToken.z-yymsp[-2].minor.yy384.z) + pParse->sLastToken.n; } -#line 1907 "parse.c" +#line 1911 "parse.c" break; case 31: -#line 153 "parse.y" +#line 156 "parse.y" { sqlite3AddColumn(pParse,&yymsp[0].minor.yy384); yygotominor.yy384 = yymsp[0].minor.yy384; } -#line 1915 "parse.c" +#line 1919 "parse.c" break; case 32: case 33: @@ -1918,14 +1921,14 @@ case 35: case 36: case 250: -#line 163 "parse.y" +#line 166 "parse.y" {yygotominor.yy384 = yymsp[0].minor.yy0;} -#line 1925 "parse.c" +#line 1929 "parse.c" break; case 38: -#line 222 "parse.y" +#line 225 "parse.y" {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy384);} -#line 1930 "parse.c" +#line 1934 "parse.c" break; case 39: case 42: @@ -1936,152 +1939,152 @@ case 238: case 248: case 249: -#line 223 "parse.y" +#line 226 "parse.y" {yygotominor.yy384 = yymsp[0].minor.yy384;} -#line 1943 "parse.c" +#line 1947 "parse.c" break; case 40: -#line 224 "parse.y" +#line 227 "parse.y" { yygotominor.yy384.z = yymsp[-3].minor.yy384.z; yygotominor.yy384.n = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy384.z; } -#line 1951 "parse.c" +#line 1955 "parse.c" break; case 41: -#line 228 "parse.y" +#line 231 "parse.y" { yygotominor.yy384.z = yymsp[-5].minor.yy384.z; yygotominor.yy384.n = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy384.z; } -#line 1959 "parse.c" +#line 1963 "parse.c" break; case 43: -#line 234 "parse.y" +#line 237 "parse.y" {yygotominor.yy384.z=yymsp[-1].minor.yy384.z; yygotominor.yy384.n=yymsp[0].minor.yy384.n+(yymsp[0].minor.yy384.z-yymsp[-1].minor.yy384.z);} -#line 1964 "parse.c" +#line 1968 "parse.c" break; case 44: -#line 236 "parse.y" +#line 239 "parse.y" { yygotominor.yy230 = atoi((char*)yymsp[0].minor.yy384.z); } -#line 1969 "parse.c" +#line 1973 "parse.c" break; case 45: -#line 237 "parse.y" +#line 240 "parse.y" { yygotominor.yy230 = -atoi((char*)yymsp[0].minor.yy384.z); } -#line 1974 "parse.c" +#line 1978 "parse.c" break; case 50: case 52: -#line 246 "parse.y" +#line 249 "parse.y" {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy178);} -#line 1980 "parse.c" +#line 1984 "parse.c" break; case 51: -#line 247 "parse.y" +#line 250 "parse.y" {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy178);} -#line 1985 "parse.c" +#line 1989 "parse.c" break; case 53: -#line 249 "parse.y" +#line 252 "parse.y" { Expr *p = sqlite3Expr(TK_UMINUS, yymsp[0].minor.yy178, 0, 0); sqlite3AddDefaultValue(pParse,p); } -#line 1993 "parse.c" +#line 1997 "parse.c" break; case 54: -#line 253 "parse.y" +#line 256 "parse.y" { Expr *p = sqlite3Expr(TK_STRING, 0, 0, &yymsp[0].minor.yy384); sqlite3AddDefaultValue(pParse,p); } -#line 2001 "parse.c" +#line 2005 "parse.c" break; case 56: -#line 262 "parse.y" +#line 265 "parse.y" {sqlite3AddNotNull(pParse, yymsp[0].minor.yy230);} -#line 2006 "parse.c" +#line 2010 "parse.c" break; case 57: -#line 264 "parse.y" +#line 267 "parse.y" {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy230,yymsp[0].minor.yy230,yymsp[-2].minor.yy230);} -#line 2011 "parse.c" +#line 2015 "parse.c" break; case 58: -#line 265 "parse.y" +#line 268 "parse.y" {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy230,0,0,0,0);} -#line 2016 "parse.c" +#line 2020 "parse.c" break; case 59: -#line 266 "parse.y" +#line 269 "parse.y" {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy178);} -#line 2021 "parse.c" +#line 2025 "parse.c" break; case 60: -#line 268 "parse.y" +#line 271 "parse.y" {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy384,yymsp[-1].minor.yy462,yymsp[0].minor.yy230);} -#line 2026 "parse.c" +#line 2030 "parse.c" break; case 61: -#line 269 "parse.y" +#line 272 "parse.y" {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy230);} -#line 2031 "parse.c" +#line 2035 "parse.c" break; case 62: -#line 270 "parse.y" +#line 273 "parse.y" {sqlite3AddCollateType(pParse, (char*)yymsp[0].minor.yy384.z, yymsp[0].minor.yy384.n);} -#line 2036 "parse.c" +#line 2040 "parse.c" break; case 65: -#line 283 "parse.y" +#line 286 "parse.y" { yygotominor.yy230 = OE_Restrict * 0x010101; } -#line 2041 "parse.c" +#line 2045 "parse.c" break; case 66: -#line 284 "parse.y" +#line 287 "parse.y" { yygotominor.yy230 = (yymsp[-1].minor.yy230 & yymsp[0].minor.yy13.mask) | yymsp[0].minor.yy13.value; } -#line 2046 "parse.c" +#line 2050 "parse.c" break; case 67: -#line 286 "parse.y" +#line 289 "parse.y" { yygotominor.yy13.value = 0; yygotominor.yy13.mask = 0x000000; } -#line 2051 "parse.c" +#line 2055 "parse.c" break; case 68: -#line 287 "parse.y" +#line 290 "parse.y" { yygotominor.yy13.value = yymsp[0].minor.yy230; yygotominor.yy13.mask = 0x0000ff; } -#line 2056 "parse.c" +#line 2060 "parse.c" break; case 69: -#line 288 "parse.y" +#line 291 "parse.y" { yygotominor.yy13.value = yymsp[0].minor.yy230<<8; yygotominor.yy13.mask = 0x00ff00; } -#line 2061 "parse.c" +#line 2065 "parse.c" break; case 70: -#line 289 "parse.y" +#line 292 "parse.y" { yygotominor.yy13.value = yymsp[0].minor.yy230<<16; yygotominor.yy13.mask = 0xff0000; } -#line 2066 "parse.c" +#line 2070 "parse.c" break; case 71: -#line 291 "parse.y" +#line 294 "parse.y" { yygotominor.yy230 = OE_SetNull; } -#line 2071 "parse.c" +#line 2075 "parse.c" break; case 72: -#line 292 "parse.y" +#line 295 "parse.y" { yygotominor.yy230 = OE_SetDflt; } -#line 2076 "parse.c" +#line 2080 "parse.c" break; case 73: -#line 293 "parse.y" +#line 296 "parse.y" { yygotominor.yy230 = OE_Cascade; } -#line 2081 "parse.c" +#line 2085 "parse.c" break; case 74: -#line 294 "parse.y" +#line 297 "parse.y" { yygotominor.yy230 = OE_Restrict; } -#line 2086 "parse.c" +#line 2090 "parse.c" break; case 75: case 76: @@ -2090,97 +2093,97 @@ case 95: case 96: case 167: -#line 296 "parse.y" +#line 299 "parse.y" {yygotominor.yy230 = yymsp[0].minor.yy230;} -#line 2097 "parse.c" +#line 2101 "parse.c" break; case 80: -#line 306 "parse.y" +#line 309 "parse.y" {yygotominor.yy384.n = 0; yygotominor.yy384.z = 0;} -#line 2102 "parse.c" +#line 2106 "parse.c" break; case 81: -#line 307 "parse.y" +#line 310 "parse.y" {yygotominor.yy384 = yymsp[-1].minor.yy0;} -#line 2107 "parse.c" +#line 2111 "parse.c" break; case 86: -#line 313 "parse.y" +#line 316 "parse.y" {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy462,yymsp[0].minor.yy230,yymsp[-2].minor.yy230,0);} -#line 2112 "parse.c" +#line 2116 "parse.c" break; case 87: -#line 315 "parse.y" +#line 318 "parse.y" {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy462,yymsp[0].minor.yy230,0,0,0,0);} -#line 2117 "parse.c" +#line 2121 "parse.c" break; case 88: -#line 316 "parse.y" +#line 319 "parse.y" {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy178);} -#line 2122 "parse.c" +#line 2126 "parse.c" break; case 89: -#line 318 "parse.y" +#line 321 "parse.y" { sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy462, &yymsp[-3].minor.yy384, yymsp[-2].minor.yy462, yymsp[-1].minor.yy230); sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy230); } -#line 2130 "parse.c" +#line 2134 "parse.c" break; case 92: case 94: -#line 332 "parse.y" +#line 335 "parse.y" {yygotominor.yy230 = OE_Default;} -#line 2136 "parse.c" +#line 2140 "parse.c" break; case 97: -#line 337 "parse.y" +#line 340 "parse.y" {yygotominor.yy230 = OE_Ignore;} -#line 2141 "parse.c" +#line 2145 "parse.c" break; case 98: case 168: -#line 338 "parse.y" +#line 341 "parse.y" {yygotominor.yy230 = OE_Replace;} -#line 2147 "parse.c" +#line 2151 "parse.c" break; case 99: -#line 342 "parse.y" +#line 345 "parse.y" { sqlite3DropTable(pParse, yymsp[0].minor.yy285, 0, yymsp[-1].minor.yy230); } -#line 2154 "parse.c" +#line 2158 "parse.c" break; case 102: -#line 352 "parse.y" +#line 355 "parse.y" { sqlite3CreateView(pParse, &yymsp[-6].minor.yy0, &yymsp[-3].minor.yy384, &yymsp[-2].minor.yy384, yymsp[0].minor.yy239, yymsp[-5].minor.yy230); } -#line 2161 "parse.c" +#line 2165 "parse.c" break; case 103: -#line 355 "parse.y" +#line 358 "parse.y" { sqlite3DropTable(pParse, yymsp[0].minor.yy285, 1, yymsp[-1].minor.yy230); } -#line 2168 "parse.c" +#line 2172 "parse.c" break; case 104: -#line 362 "parse.y" +#line 365 "parse.y" { sqlite3Select(pParse, yymsp[0].minor.yy239, SRT_Callback, 0, 0, 0, 0, 0); sqlite3SelectDelete(yymsp[0].minor.yy239); } -#line 2176 "parse.c" +#line 2180 "parse.c" break; case 105: case 128: -#line 372 "parse.y" +#line 375 "parse.y" {yygotominor.yy239 = yymsp[0].minor.yy239;} -#line 2182 "parse.c" +#line 2186 "parse.c" break; case 106: -#line 374 "parse.y" +#line 377 "parse.y" { if( yymsp[0].minor.yy239 ){ yymsp[0].minor.yy239->op = yymsp[-1].minor.yy230; @@ -2188,87 +2191,87 @@ } yygotominor.yy239 = yymsp[0].minor.yy239; } -#line 2193 "parse.c" +#line 2197 "parse.c" break; case 108: -#line 383 "parse.y" +#line 386 "parse.y" {yygotominor.yy230 = TK_ALL;} -#line 2198 "parse.c" +#line 2202 "parse.c" break; case 110: -#line 387 "parse.y" +#line 390 "parse.y" { yygotominor.yy239 = sqlite3SelectNew(yymsp[-6].minor.yy462,yymsp[-5].minor.yy285,yymsp[-4].minor.yy178,yymsp[-3].minor.yy462,yymsp[-2].minor.yy178,yymsp[-1].minor.yy462,yymsp[-7].minor.yy230,yymsp[0].minor.yy270.pLimit,yymsp[0].minor.yy270.pOffset); } -#line 2205 "parse.c" +#line 2209 "parse.c" break; case 114: case 235: -#line 408 "parse.y" +#line 411 "parse.y" {yygotominor.yy462 = yymsp[-1].minor.yy462;} -#line 2211 "parse.c" +#line 2215 "parse.c" break; case 115: case 141: case 151: case 234: -#line 409 "parse.y" +#line 412 "parse.y" {yygotominor.yy462 = 0;} -#line 2219 "parse.c" +#line 2223 "parse.c" break; case 116: -#line 410 "parse.y" +#line 413 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-2].minor.yy462,yymsp[-1].minor.yy178,yymsp[0].minor.yy384.n?&yymsp[0].minor.yy384:0); } -#line 2226 "parse.c" +#line 2230 "parse.c" break; case 117: -#line 413 "parse.y" +#line 416 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-1].minor.yy462, sqlite3Expr(TK_ALL, 0, 0, 0), 0); } -#line 2233 "parse.c" +#line 2237 "parse.c" break; case 118: -#line 416 "parse.y" +#line 419 "parse.y" { Expr *pRight = sqlite3Expr(TK_ALL, 0, 0, 0); Expr *pLeft = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy384); yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-3].minor.yy462, sqlite3Expr(TK_DOT, pLeft, pRight, 0), 0); } -#line 2242 "parse.c" +#line 2246 "parse.c" break; case 121: -#line 428 "parse.y" +#line 431 "parse.y" {yygotominor.yy384.n = 0;} -#line 2247 "parse.c" +#line 2251 "parse.c" break; case 122: -#line 440 "parse.y" +#line 443 "parse.y" {yygotominor.yy285 = sqliteMalloc(sizeof(*yygotominor.yy285));} -#line 2252 "parse.c" +#line 2256 "parse.c" break; case 123: -#line 441 "parse.y" +#line 444 "parse.y" {yygotominor.yy285 = yymsp[0].minor.yy285;} -#line 2257 "parse.c" +#line 2261 "parse.c" break; case 124: -#line 446 "parse.y" +#line 449 "parse.y" { yygotominor.yy285 = yymsp[-1].minor.yy285; if( yygotominor.yy285 && yygotominor.yy285->nSrc>0 ) yygotominor.yy285->a[yygotominor.yy285->nSrc-1].jointype = yymsp[0].minor.yy230; } -#line 2265 "parse.c" +#line 2269 "parse.c" break; case 125: -#line 450 "parse.y" +#line 453 "parse.y" {yygotominor.yy285 = 0;} -#line 2270 "parse.c" +#line 2274 "parse.c" break; case 126: -#line 451 "parse.y" +#line 454 "parse.y" { yygotominor.yy285 = sqlite3SrcListAppend(yymsp[-5].minor.yy285,&yymsp[-4].minor.yy384,&yymsp[-3].minor.yy384); if( yymsp[-2].minor.yy384.n ) sqlite3SrcListAddAlias(yygotominor.yy285,&yymsp[-2].minor.yy384); @@ -2281,10 +2284,10 @@ else { sqlite3IdListDelete(yymsp[0].minor.yy160); } } } -#line 2286 "parse.c" +#line 2290 "parse.c" break; case 127: -#line 465 "parse.y" +#line 468 "parse.y" { yygotominor.yy285 = sqlite3SrcListAppend(yymsp[-6].minor.yy285,0,0); yygotominor.yy285->a[yygotominor.yy285->nSrc-1].pSelect = yymsp[-4].minor.yy239; @@ -2298,44 +2301,44 @@ else { sqlite3IdListDelete(yymsp[0].minor.yy160); } } } -#line 2303 "parse.c" +#line 2307 "parse.c" break; case 129: -#line 486 "parse.y" +#line 489 "parse.y" { yygotominor.yy239 = sqlite3SelectNew(0,yymsp[0].minor.yy285,0,0,0,0,0,0,0); } -#line 2310 "parse.c" +#line 2314 "parse.c" break; case 130: -#line 492 "parse.y" +#line 495 "parse.y" {yygotominor.yy384.z=0; yygotominor.yy384.n=0;} -#line 2315 "parse.c" +#line 2319 "parse.c" break; case 132: -#line 497 "parse.y" +#line 500 "parse.y" {yygotominor.yy285 = sqlite3SrcListAppend(0,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384);} -#line 2320 "parse.c" +#line 2324 "parse.c" break; case 133: -#line 501 "parse.y" +#line 504 "parse.y" { yygotominor.yy230 = JT_INNER; } -#line 2325 "parse.c" +#line 2329 "parse.c" break; case 134: -#line 502 "parse.y" +#line 505 "parse.y" { yygotominor.yy230 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } -#line 2330 "parse.c" +#line 2334 "parse.c" break; case 135: -#line 503 "parse.y" +#line 506 "parse.y" { yygotominor.yy230 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy384,0); } -#line 2335 "parse.c" +#line 2339 "parse.c" break; case 136: -#line 505 "parse.y" +#line 508 "parse.y" { yygotominor.yy230 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy384,&yymsp[-1].minor.yy384); } -#line 2340 "parse.c" +#line 2344 "parse.c" break; case 137: case 145: @@ -2346,9 +2349,9 @@ case 223: case 225: case 229: -#line 509 "parse.y" +#line 512 "parse.y" {yygotominor.yy178 = yymsp[0].minor.yy178;} -#line 2353 "parse.c" +#line 2357 "parse.c" break; case 138: case 153: @@ -2357,161 +2360,161 @@ case 224: case 226: case 230: -#line 510 "parse.y" +#line 513 "parse.y" {yygotominor.yy178 = 0;} -#line 2364 "parse.c" +#line 2368 "parse.c" break; case 139: case 172: -#line 514 "parse.y" +#line 517 "parse.y" {yygotominor.yy160 = yymsp[-1].minor.yy160;} -#line 2370 "parse.c" +#line 2374 "parse.c" break; case 140: case 171: -#line 515 "parse.y" +#line 518 "parse.y" {yygotominor.yy160 = 0;} -#line 2376 "parse.c" +#line 2380 "parse.c" break; case 142: case 152: -#line 526 "parse.y" +#line 529 "parse.y" {yygotominor.yy462 = yymsp[0].minor.yy462;} -#line 2382 "parse.c" +#line 2386 "parse.c" break; case 143: -#line 527 "parse.y" +#line 530 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462,yymsp[-2].minor.yy178,yymsp[-1].minor.yy384.n>0?&yymsp[-1].minor.yy384:0); if( yygotominor.yy462 ) yygotominor.yy462->a[yygotominor.yy462->nExpr-1].sortOrder = yymsp[0].minor.yy230; } -#line 2390 "parse.c" +#line 2394 "parse.c" break; case 144: -#line 531 "parse.y" +#line 534 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(0,yymsp[-2].minor.yy178,yymsp[-1].minor.yy384.n>0?&yymsp[-1].minor.yy384:0); if( yygotominor.yy462 && yygotominor.yy462->a ) yygotominor.yy462->a[0].sortOrder = yymsp[0].minor.yy230; } -#line 2398 "parse.c" +#line 2402 "parse.c" break; case 146: case 148: -#line 540 "parse.y" +#line 543 "parse.y" {yygotominor.yy230 = SQLITE_SO_ASC;} -#line 2404 "parse.c" +#line 2408 "parse.c" break; case 147: -#line 541 "parse.y" +#line 544 "parse.y" {yygotominor.yy230 = SQLITE_SO_DESC;} -#line 2409 "parse.c" +#line 2413 "parse.c" break; case 149: -#line 543 "parse.y" +#line 546 "parse.y" {yygotominor.yy384.z = 0; yygotominor.yy384.n = 0;} -#line 2414 "parse.c" +#line 2418 "parse.c" break; case 155: -#line 561 "parse.y" +#line 564 "parse.y" {yygotominor.yy270.pLimit = 0; yygotominor.yy270.pOffset = 0;} -#line 2419 "parse.c" +#line 2423 "parse.c" break; case 156: -#line 562 "parse.y" +#line 565 "parse.y" {yygotominor.yy270.pLimit = yymsp[0].minor.yy178; yygotominor.yy270.pOffset = 0;} -#line 2424 "parse.c" +#line 2428 "parse.c" break; case 157: -#line 564 "parse.y" +#line 567 "parse.y" {yygotominor.yy270.pLimit = yymsp[-2].minor.yy178; yygotominor.yy270.pOffset = yymsp[0].minor.yy178;} -#line 2429 "parse.c" +#line 2433 "parse.c" break; case 158: -#line 566 "parse.y" +#line 569 "parse.y" {yygotominor.yy270.pOffset = yymsp[-2].minor.yy178; yygotominor.yy270.pLimit = yymsp[0].minor.yy178;} -#line 2434 "parse.c" +#line 2438 "parse.c" break; case 159: -#line 570 "parse.y" +#line 573 "parse.y" {sqlite3DeleteFrom(pParse,yymsp[-1].minor.yy285,yymsp[0].minor.yy178);} -#line 2439 "parse.c" +#line 2443 "parse.c" break; case 162: -#line 581 "parse.y" +#line 584 "parse.y" {sqlite3Update(pParse,yymsp[-3].minor.yy285,yymsp[-1].minor.yy462,yymsp[0].minor.yy178,yymsp[-4].minor.yy230);} -#line 2444 "parse.c" +#line 2448 "parse.c" break; case 163: -#line 587 "parse.y" +#line 590 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462,yymsp[0].minor.yy178,&yymsp[-2].minor.yy384);} -#line 2449 "parse.c" +#line 2453 "parse.c" break; case 164: -#line 588 "parse.y" +#line 591 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(0,yymsp[0].minor.yy178,&yymsp[-2].minor.yy384);} -#line 2454 "parse.c" +#line 2458 "parse.c" break; case 165: -#line 594 "parse.y" +#line 597 "parse.y" {sqlite3Insert(pParse, yymsp[-5].minor.yy285, yymsp[-1].minor.yy462, 0, yymsp[-4].minor.yy160, yymsp[-7].minor.yy230);} -#line 2459 "parse.c" +#line 2463 "parse.c" break; case 166: -#line 596 "parse.y" +#line 599 "parse.y" {sqlite3Insert(pParse, yymsp[-2].minor.yy285, 0, yymsp[0].minor.yy239, yymsp[-1].minor.yy160, yymsp[-4].minor.yy230);} -#line 2464 "parse.c" +#line 2468 "parse.c" break; case 169: case 227: -#line 606 "parse.y" +#line 609 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-2].minor.yy462,yymsp[0].minor.yy178,0);} -#line 2470 "parse.c" +#line 2474 "parse.c" break; case 170: case 228: -#line 607 "parse.y" +#line 610 "parse.y" {yygotominor.yy462 = sqlite3ExprListAppend(0,yymsp[0].minor.yy178,0);} -#line 2476 "parse.c" +#line 2480 "parse.c" break; case 173: -#line 616 "parse.y" +#line 619 "parse.y" {yygotominor.yy160 = sqlite3IdListAppend(yymsp[-2].minor.yy160,&yymsp[0].minor.yy384);} -#line 2481 "parse.c" +#line 2485 "parse.c" break; case 174: -#line 617 "parse.y" +#line 620 "parse.y" {yygotominor.yy160 = sqlite3IdListAppend(0,&yymsp[0].minor.yy384);} -#line 2486 "parse.c" +#line 2490 "parse.c" break; case 176: -#line 628 "parse.y" +#line 631 "parse.y" {yygotominor.yy178 = yymsp[-1].minor.yy178; sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } -#line 2491 "parse.c" +#line 2495 "parse.c" break; case 177: case 182: case 183: -#line 629 "parse.y" +#line 632 "parse.y" {yygotominor.yy178 = sqlite3Expr(yymsp[0].major, 0, 0, &yymsp[0].minor.yy0);} -#line 2498 "parse.c" +#line 2502 "parse.c" break; case 178: case 179: -#line 630 "parse.y" +#line 633 "parse.y" {yygotominor.yy178 = sqlite3Expr(TK_ID, 0, 0, &yymsp[0].minor.yy0);} -#line 2504 "parse.c" +#line 2508 "parse.c" break; case 180: -#line 632 "parse.y" +#line 635 "parse.y" { Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy384); Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &yymsp[0].minor.yy384); yygotominor.yy178 = sqlite3Expr(TK_DOT, temp1, temp2, 0); } -#line 2513 "parse.c" +#line 2517 "parse.c" break; case 181: -#line 637 "parse.y" +#line 640 "parse.y" { Expr *temp1 = sqlite3Expr(TK_ID, 0, 0, &yymsp[-4].minor.yy384); Expr *temp2 = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy384); @@ -2519,58 +2522,58 @@ Expr *temp4 = sqlite3Expr(TK_DOT, temp2, temp3, 0); yygotominor.yy178 = sqlite3Expr(TK_DOT, temp1, temp4, 0); } -#line 2524 "parse.c" +#line 2528 "parse.c" break; case 184: -#line 646 "parse.y" +#line 649 "parse.y" {yygotominor.yy178 = sqlite3RegisterExpr(pParse, &yymsp[0].minor.yy0);} -#line 2529 "parse.c" +#line 2533 "parse.c" break; case 185: -#line 647 "parse.y" +#line 650 "parse.y" { Token *pToken = &yymsp[0].minor.yy0; Expr *pExpr = yygotominor.yy178 = sqlite3Expr(TK_VARIABLE, 0, 0, pToken); sqlite3ExprAssignVarNumber(pParse, pExpr); } -#line 2538 "parse.c" +#line 2542 "parse.c" break; case 186: -#line 653 "parse.y" +#line 656 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_CAST, yymsp[-3].minor.yy178, 0, &yymsp[-1].minor.yy384); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); } -#line 2546 "parse.c" +#line 2550 "parse.c" break; case 187: -#line 658 "parse.y" +#line 661 "parse.y" { yygotominor.yy178 = sqlite3ExprFunction(yymsp[-1].minor.yy462, &yymsp[-4].minor.yy0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); - if( yymsp[-2].minor.yy230 ){ + if( yymsp[-2].minor.yy230 && yygotominor.yy178 ){ yygotominor.yy178->flags |= EP_Distinct; } } -#line 2557 "parse.c" +#line 2561 "parse.c" break; case 188: -#line 665 "parse.y" +#line 668 "parse.y" { yygotominor.yy178 = sqlite3ExprFunction(0, &yymsp[-3].minor.yy0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); } -#line 2565 "parse.c" +#line 2569 "parse.c" break; case 189: -#line 669 "parse.y" +#line 672 "parse.y" { /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are ** treated as functions that return constants */ yygotominor.yy178 = sqlite3ExprFunction(0,&yymsp[0].minor.yy0); if( yygotominor.yy178 ) yygotominor.yy178->op = TK_CONST_FUNC; } -#line 2575 "parse.c" +#line 2579 "parse.c" break; case 190: case 191: @@ -2580,24 +2583,25 @@ case 195: case 196: case 197: -#line 675 "parse.y" +#line 678 "parse.y" {yygotominor.yy178 = sqlite3Expr(yymsp[-1].major, yymsp[-2].minor.yy178, yymsp[0].minor.yy178, 0);} -#line 2587 "parse.c" +#line 2591 "parse.c" break; case 198: -#line 685 "parse.y" +#line 688 "parse.y" {yygotominor.yy440.eOperator = yymsp[0].minor.yy0; yygotominor.yy440.not = 0;} -#line 2592 "parse.c" +#line 2596 "parse.c" break; case 199: -#line 686 "parse.y" +#line 689 "parse.y" {yygotominor.yy440.eOperator = yymsp[0].minor.yy0; yygotominor.yy440.not = 1;} -#line 2597 "parse.c" +#line 2601 "parse.c" break; case 202: -#line 691 "parse.y" +#line 694 "parse.y" { - ExprList *pList = sqlite3ExprListAppend(0, yymsp[-1].minor.yy178, 0); + ExprList *pList; + pList = sqlite3ExprListAppend(0, yymsp[-1].minor.yy178, 0); pList = sqlite3ExprListAppend(pList, yymsp[-3].minor.yy178, 0); if( yymsp[0].minor.yy178 ){ pList = sqlite3ExprListAppend(pList, yymsp[0].minor.yy178, 0); @@ -2606,66 +2610,66 @@ if( yymsp[-2].minor.yy440.not ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178, &yymsp[-3].minor.yy178->span, &yymsp[-1].minor.yy178->span); } -#line 2611 "parse.c" +#line 2616 "parse.c" break; case 203: -#line 702 "parse.y" +#line 706 "parse.y" { yygotominor.yy178 = sqlite3Expr(yymsp[0].major, yymsp[-1].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy178->span,&yymsp[0].minor.yy0); } -#line 2619 "parse.c" +#line 2624 "parse.c" break; case 204: -#line 706 "parse.y" +#line 710 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_ISNULL, yymsp[-2].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy178->span,&yymsp[0].minor.yy0); } -#line 2627 "parse.c" +#line 2632 "parse.c" break; case 205: -#line 710 "parse.y" +#line 714 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_NOTNULL, yymsp[-2].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy178->span,&yymsp[0].minor.yy0); } -#line 2635 "parse.c" +#line 2640 "parse.c" break; case 206: -#line 714 "parse.y" +#line 718 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_NOTNULL, yymsp[-3].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-3].minor.yy178->span,&yymsp[0].minor.yy0); } -#line 2643 "parse.c" +#line 2648 "parse.c" break; case 207: -#line 718 "parse.y" +#line 722 "parse.y" { yygotominor.yy178 = sqlite3Expr(yymsp[-1].major, yymsp[0].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy178->span); } -#line 2651 "parse.c" +#line 2656 "parse.c" break; case 208: -#line 722 "parse.y" +#line 726 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_UMINUS, yymsp[0].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy178->span); } -#line 2659 "parse.c" +#line 2664 "parse.c" break; case 209: -#line 726 "parse.y" +#line 730 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_UPLUS, yymsp[0].minor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy178->span); } -#line 2667 "parse.c" +#line 2672 "parse.c" break; case 212: -#line 733 "parse.y" +#line 737 "parse.y" { ExprList *pList = sqlite3ExprListAppend(0, yymsp[-2].minor.yy178, 0); pList = sqlite3ExprListAppend(pList, yymsp[0].minor.yy178, 0); @@ -2678,10 +2682,10 @@ if( yymsp[-3].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy178->span,&yymsp[0].minor.yy178->span); } -#line 2683 "parse.c" +#line 2688 "parse.c" break; case 215: -#line 749 "parse.y" +#line 753 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_IN, yymsp[-4].minor.yy178, 0, 0); if( yygotominor.yy178 ){ @@ -2692,10 +2696,10 @@ if( yymsp[-3].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy178->span,&yymsp[0].minor.yy0); } -#line 2697 "parse.c" +#line 2702 "parse.c" break; case 216: -#line 759 "parse.y" +#line 763 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_SELECT, 0, 0, 0); if( yygotominor.yy178 ){ @@ -2705,10 +2709,10 @@ } sqlite3ExprSpan(yygotominor.yy178,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); } -#line 2710 "parse.c" +#line 2715 "parse.c" break; case 217: -#line 768 "parse.y" +#line 772 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_IN, yymsp[-4].minor.yy178, 0, 0); if( yygotominor.yy178 ){ @@ -2719,10 +2723,10 @@ if( yymsp[-3].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-4].minor.yy178->span,&yymsp[0].minor.yy0); } -#line 2724 "parse.c" +#line 2729 "parse.c" break; case 218: -#line 778 "parse.y" +#line 782 "parse.y" { SrcList *pSrc = sqlite3SrcListAppend(0,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384); yygotominor.yy178 = sqlite3Expr(TK_IN, yymsp[-3].minor.yy178, 0, 0); @@ -2734,10 +2738,10 @@ if( yymsp[-2].minor.yy230 ) yygotominor.yy178 = sqlite3Expr(TK_NOT, yygotominor.yy178, 0, 0); sqlite3ExprSpan(yygotominor.yy178,&yymsp[-3].minor.yy178->span,yymsp[0].minor.yy384.z?&yymsp[0].minor.yy384:&yymsp[-1].minor.yy384); } -#line 2739 "parse.c" +#line 2744 "parse.c" break; case 219: -#line 789 "parse.y" +#line 793 "parse.y" { Expr *p = yygotominor.yy178 = sqlite3Expr(TK_EXISTS, 0, 0, 0); if( p ){ @@ -2747,10 +2751,10 @@ sqlite3SelectDelete(yymsp[-1].minor.yy239); } } -#line 2752 "parse.c" +#line 2757 "parse.c" break; case 220: -#line 801 "parse.y" +#line 805 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_CASE, yymsp[-3].minor.yy178, yymsp[-1].minor.yy178, 0); if( yygotominor.yy178 ){ @@ -2760,45 +2764,45 @@ } sqlite3ExprSpan(yygotominor.yy178, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0); } -#line 2765 "parse.c" +#line 2770 "parse.c" break; case 221: -#line 812 "parse.y" +#line 816 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462, yymsp[-2].minor.yy178, 0); yygotominor.yy462 = sqlite3ExprListAppend(yygotominor.yy462, yymsp[0].minor.yy178, 0); } -#line 2773 "parse.c" +#line 2778 "parse.c" break; case 222: -#line 816 "parse.y" +#line 820 "parse.y" { yygotominor.yy462 = sqlite3ExprListAppend(0, yymsp[-2].minor.yy178, 0); yygotominor.yy462 = sqlite3ExprListAppend(yygotominor.yy462, yymsp[0].minor.yy178, 0); } -#line 2781 "parse.c" +#line 2786 "parse.c" break; case 231: -#line 843 "parse.y" +#line 847 "parse.y" { sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy384, &yymsp[-5].minor.yy384, sqlite3SrcListAppend(0,&yymsp[-3].minor.yy384,0), yymsp[-1].minor.yy462, yymsp[-9].minor.yy230, &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy230); } -#line 2789 "parse.c" +#line 2794 "parse.c" break; case 232: case 277: -#line 849 "parse.y" +#line 853 "parse.y" {yygotominor.yy230 = OE_Abort;} -#line 2795 "parse.c" +#line 2800 "parse.c" break; case 233: -#line 850 "parse.y" +#line 854 "parse.y" {yygotominor.yy230 = OE_None;} -#line 2800 "parse.c" +#line 2805 "parse.c" break; case 236: -#line 860 "parse.y" +#line 864 "parse.y" { Expr *p = 0; if( yymsp[-1].minor.yy384.n>0 ){ @@ -2808,10 +2812,10 @@ yygotominor.yy462 = sqlite3ExprListAppend(yymsp[-4].minor.yy462, p, &yymsp[-2].minor.yy384); if( yygotominor.yy462 ) yygotominor.yy462->a[yygotominor.yy462->nExpr-1].sortOrder = yymsp[0].minor.yy230; } -#line 2813 "parse.c" +#line 2818 "parse.c" break; case 237: -#line 869 "parse.y" +#line 873 "parse.y" { Expr *p = 0; if( yymsp[-1].minor.yy384.n>0 ){ @@ -2821,250 +2825,259 @@ yygotominor.yy462 = sqlite3ExprListAppend(0, p, &yymsp[-2].minor.yy384); if( yygotominor.yy462 ) yygotominor.yy462->a[yygotominor.yy462->nExpr-1].sortOrder = yymsp[0].minor.yy230; } -#line 2826 "parse.c" +#line 2831 "parse.c" break; case 239: -#line 883 "parse.y" +#line 887 "parse.y" {sqlite3DropIndex(pParse, yymsp[0].minor.yy285, yymsp[-1].minor.yy230);} -#line 2831 "parse.c" +#line 2836 "parse.c" break; case 240: case 241: -#line 887 "parse.y" -{sqlite3Vacuum(pParse,0);} -#line 2837 "parse.c" +#line 891 "parse.y" +{sqlite3Vacuum(pParse);} +#line 2842 "parse.c" break; case 242: case 244: -#line 893 "parse.y" +#line 897 "parse.y" {sqlite3Pragma(pParse,&yymsp[-3].minor.yy384,&yymsp[-2].minor.yy384,&yymsp[0].minor.yy384,0);} -#line 2843 "parse.c" +#line 2848 "parse.c" break; case 243: -#line 894 "parse.y" +#line 898 "parse.y" {sqlite3Pragma(pParse,&yymsp[-3].minor.yy384,&yymsp[-2].minor.yy384,&yymsp[0].minor.yy0,0);} -#line 2848 "parse.c" +#line 2853 "parse.c" break; case 245: -#line 896 "parse.y" +#line 900 "parse.y" { sqlite3Pragma(pParse,&yymsp[-3].minor.yy384,&yymsp[-2].minor.yy384,&yymsp[0].minor.yy384,1); } -#line 2855 "parse.c" +#line 2860 "parse.c" break; case 246: -#line 899 "parse.y" +#line 903 "parse.y" {sqlite3Pragma(pParse,&yymsp[-4].minor.yy384,&yymsp[-3].minor.yy384,&yymsp[-1].minor.yy384,0);} -#line 2860 "parse.c" +#line 2865 "parse.c" break; case 247: -#line 900 "parse.y" +#line 904 "parse.y" {sqlite3Pragma(pParse,&yymsp[-1].minor.yy384,&yymsp[0].minor.yy384,0,0);} -#line 2865 "parse.c" +#line 2870 "parse.c" break; case 253: -#line 912 "parse.y" +#line 916 "parse.y" { Token all; all.z = yymsp[-3].minor.yy384.z; all.n = (yymsp[0].minor.yy0.z - yymsp[-3].minor.yy384.z) + yymsp[0].minor.yy0.n; sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy247, &all); } -#line 2875 "parse.c" +#line 2880 "parse.c" break; case 254: -#line 921 "parse.y" +#line 925 "parse.y" { sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy384, &yymsp[-6].minor.yy384, yymsp[-5].minor.yy230, yymsp[-4].minor.yy132.a, yymsp[-4].minor.yy132.b, yymsp[-2].minor.yy285, yymsp[-1].minor.yy230, yymsp[0].minor.yy178, yymsp[-9].minor.yy230); yygotominor.yy384 = (yymsp[-6].minor.yy384.n==0?yymsp[-7].minor.yy384:yymsp[-6].minor.yy384); } -#line 2883 "parse.c" +#line 2888 "parse.c" break; case 255: case 258: -#line 927 "parse.y" +#line 931 "parse.y" { yygotominor.yy230 = TK_BEFORE; } -#line 2889 "parse.c" +#line 2894 "parse.c" break; case 256: -#line 928 "parse.y" +#line 932 "parse.y" { yygotominor.yy230 = TK_AFTER; } -#line 2894 "parse.c" +#line 2899 "parse.c" break; case 257: -#line 929 "parse.y" +#line 933 "parse.y" { yygotominor.yy230 = TK_INSTEAD;} -#line 2899 "parse.c" +#line 2904 "parse.c" break; case 259: case 260: -#line 934 "parse.y" +#line 938 "parse.y" {yygotominor.yy132.a = yymsp[0].major; yygotominor.yy132.b = 0;} -#line 2905 "parse.c" +#line 2910 "parse.c" break; case 261: -#line 936 "parse.y" +#line 940 "parse.y" {yygotominor.yy132.a = TK_UPDATE; yygotominor.yy132.b = yymsp[0].minor.yy160;} -#line 2910 "parse.c" +#line 2915 "parse.c" break; case 262: case 263: -#line 939 "parse.y" +#line 943 "parse.y" { yygotominor.yy230 = TK_ROW; } -#line 2916 "parse.c" +#line 2921 "parse.c" break; case 264: -#line 941 "parse.y" +#line 945 "parse.y" { yygotominor.yy230 = TK_STATEMENT; } -#line 2921 "parse.c" +#line 2926 "parse.c" break; case 265: -#line 945 "parse.y" +#line 949 "parse.y" { yygotominor.yy178 = 0; } -#line 2926 "parse.c" +#line 2931 "parse.c" break; case 266: -#line 946 "parse.y" +#line 950 "parse.y" { yygotominor.yy178 = yymsp[0].minor.yy178; } -#line 2931 "parse.c" +#line 2936 "parse.c" break; case 267: -#line 950 "parse.y" +#line 954 "parse.y" { - yymsp[-2].minor.yy247->pNext = yymsp[0].minor.yy247; + if( yymsp[-2].minor.yy247 ){ + yymsp[-2].minor.yy247->pLast->pNext = yymsp[-1].minor.yy247; + }else{ + yymsp[-2].minor.yy247 = yymsp[-1].minor.yy247; + } + yymsp[-2].minor.yy247->pLast = yymsp[-1].minor.yy247; yygotominor.yy247 = yymsp[-2].minor.yy247; } -#line 2939 "parse.c" +#line 2949 "parse.c" break; case 268: -#line 954 "parse.y" +#line 963 "parse.y" { yygotominor.yy247 = 0; } -#line 2944 "parse.c" +#line 2954 "parse.c" break; case 269: -#line 960 "parse.y" +#line 969 "parse.y" { yygotominor.yy247 = sqlite3TriggerUpdateStep(&yymsp[-3].minor.yy384, yymsp[-1].minor.yy462, yymsp[0].minor.yy178, yymsp[-4].minor.yy230); } -#line 2949 "parse.c" +#line 2959 "parse.c" break; case 270: -#line 965 "parse.y" +#line 974 "parse.y" {yygotominor.yy247 = sqlite3TriggerInsertStep(&yymsp[-5].minor.yy384, yymsp[-4].minor.yy160, yymsp[-1].minor.yy462, 0, yymsp[-7].minor.yy230);} -#line 2954 "parse.c" +#line 2964 "parse.c" break; case 271: -#line 968 "parse.y" +#line 977 "parse.y" {yygotominor.yy247 = sqlite3TriggerInsertStep(&yymsp[-2].minor.yy384, yymsp[-1].minor.yy160, 0, yymsp[0].minor.yy239, yymsp[-4].minor.yy230);} -#line 2959 "parse.c" +#line 2969 "parse.c" break; case 272: -#line 972 "parse.y" +#line 981 "parse.y" {yygotominor.yy247 = sqlite3TriggerDeleteStep(&yymsp[-1].minor.yy384, yymsp[0].minor.yy178);} -#line 2964 "parse.c" +#line 2974 "parse.c" break; case 273: -#line 975 "parse.y" +#line 984 "parse.y" {yygotominor.yy247 = sqlite3TriggerSelectStep(yymsp[0].minor.yy239); } -#line 2969 "parse.c" +#line 2979 "parse.c" break; case 274: -#line 978 "parse.y" +#line 987 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_RAISE, 0, 0, 0); - yygotominor.yy178->iColumn = OE_Ignore; - sqlite3ExprSpan(yygotominor.yy178, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); + if( yygotominor.yy178 ){ + yygotominor.yy178->iColumn = OE_Ignore; + sqlite3ExprSpan(yygotominor.yy178, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0); + } } -#line 2978 "parse.c" +#line 2990 "parse.c" break; case 275: -#line 983 "parse.y" +#line 994 "parse.y" { yygotominor.yy178 = sqlite3Expr(TK_RAISE, 0, 0, &yymsp[-1].minor.yy384); - yygotominor.yy178->iColumn = yymsp[-3].minor.yy230; - sqlite3ExprSpan(yygotominor.yy178, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); + if( yygotominor.yy178 ) { + yygotominor.yy178->iColumn = yymsp[-3].minor.yy230; + sqlite3ExprSpan(yygotominor.yy178, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0); + } } -#line 2987 "parse.c" +#line 3001 "parse.c" break; case 276: -#line 991 "parse.y" +#line 1004 "parse.y" {yygotominor.yy230 = OE_Rollback;} -#line 2992 "parse.c" +#line 3006 "parse.c" break; case 278: -#line 993 "parse.y" +#line 1006 "parse.y" {yygotominor.yy230 = OE_Fail;} -#line 2997 "parse.c" +#line 3011 "parse.c" break; case 279: -#line 998 "parse.y" +#line 1011 "parse.y" { sqlite3DropTrigger(pParse,yymsp[0].minor.yy285); } -#line 3004 "parse.c" +#line 3018 "parse.c" break; case 280: -#line 1004 "parse.y" +#line 1017 "parse.y" { sqlite3Attach(pParse, yymsp[-3].minor.yy178, yymsp[-1].minor.yy178, yymsp[0].minor.yy292); } -#line 3011 "parse.c" +#line 3025 "parse.c" break; case 281: -#line 1009 "parse.y" +#line 1022 "parse.y" { yygotominor.yy292 = 0; } -#line 3016 "parse.c" +#line 3030 "parse.c" break; case 282: -#line 1010 "parse.y" +#line 1023 "parse.y" { yygotominor.yy292 = yymsp[0].minor.yy178; } -#line 3021 "parse.c" +#line 3035 "parse.c" break; case 285: -#line 1016 "parse.y" +#line 1029 "parse.y" { sqlite3Detach(pParse, yymsp[0].minor.yy178); } -#line 3028 "parse.c" +#line 3042 "parse.c" break; case 286: -#line 1022 "parse.y" +#line 1035 "parse.y" {sqlite3Reindex(pParse, 0, 0);} -#line 3033 "parse.c" +#line 3047 "parse.c" break; case 287: -#line 1023 "parse.y" +#line 1036 "parse.y" {sqlite3Reindex(pParse, &yymsp[-1].minor.yy384, &yymsp[0].minor.yy384);} -#line 3038 "parse.c" +#line 3052 "parse.c" break; case 288: -#line 1028 "parse.y" +#line 1041 "parse.y" {sqlite3Analyze(pParse, 0, 0);} -#line 3043 "parse.c" +#line 3057 "parse.c" break; case 289: -#line 1029 "parse.y" +#line 1042 "parse.y" {sqlite3Analyze(pParse, &yymsp[-1].minor.yy384, &yymsp[0].minor.yy384);} -#line 3048 "parse.c" +#line 3062 "parse.c" break; case 290: -#line 1034 "parse.y" +#line 1047 "parse.y" { sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy285,&yymsp[0].minor.yy384); } -#line 3055 "parse.c" +#line 3069 "parse.c" break; case 291: -#line 1037 "parse.y" +#line 1050 "parse.y" { sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy384); } -#line 3062 "parse.c" +#line 3076 "parse.c" break; case 292: -#line 1040 "parse.y" +#line 1053 "parse.y" { sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy285); } -#line 3069 "parse.c" +#line 3083 "parse.c" break; }; yygoto = yyRuleInfo[yyruleno].lhs; @@ -3130,7 +3143,7 @@ sqlite3ErrorMsg(pParse, "incomplete SQL statement"); } } -#line 3136 "parse.c" +#line 3150 "parse.c" sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument variable */ } ============================================================ --- sqlite/pragma.c 31d3e1b74cab2172807894e70c674d6a577501fd +++ sqlite/pragma.c 27d5e395c5d950931c7ac4fe610e7c2993e2fa55 @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.118 2006/02/11 01:25:51 drh Exp $ +** $Id: pragma.c,v 1.120 2006/03/03 21:20:17 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -227,6 +227,13 @@ if( iDb<0 ) return; pDb = &db->aDb[iDb]; + /* If the temp database has been explicitly named as part of the + ** pragma, make sure it is open. + */ + if( iDb==1 && sqlite3OpenTempDatabase(pParse) ){ + return; + } + zLeft = sqlite3NameFromToken(pId); if( !zLeft ) return; if( minusFlag ){ @@ -478,7 +485,7 @@ sqlite3VdbeAddOp(v, OP_Integer, i, 0); sqlite3VdbeOp3(v, OP_String8, 0, 0, pCol->zName, 0); sqlite3VdbeOp3(v, OP_String8, 0, 0, - pCol->zType ? pCol->zType : "numeric", 0); + pCol->zType ? pCol->zType : "", 0); sqlite3VdbeAddOp(v, OP_Integer, pCol->notNull, 0); sqlite3ExprCode(pParse, pCol->pDflt); sqlite3VdbeAddOp(v, OP_Integer, pCol->isPrimKey, 0); @@ -948,10 +955,12 @@ ** Reset the safety level, in case the fullfsync flag or synchronous ** setting changed. */ +#ifndef SQLITE_OMIT_PAGER_PRAGMAS if( db->autoCommit ){ sqlite3BtreeSetSafetyLevel(pDb->pBt, pDb->safety_level, (db->flags&SQLITE_FullFSync)!=0); } +#endif } pragma_out: sqliteFree(zLeft); ============================================================ --- sqlite/prepare.c cf0fc8ebaf94409955ecb09ffeb0099c9ef44693 +++ sqlite/prepare.c 6afd730cc8851c0920b5f9050294646b1c2ab28c @@ -13,7 +13,7 @@ ** interface, and routines that contribute to loading the database schema ** from disk. ** -** $Id: prepare.c,v 1.31 2006/02/10 02:27:43 danielk1977 Exp $ +** $Id: prepare.c,v 1.33 2006/03/13 15:06:07 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -74,6 +74,7 @@ db->init.newTnum = atoi(argv[1]); rc = sqlite3_exec(db, argv[2], 0, 0, &zErr); db->init.iDb = 0; + assert( rc!=SQLITE_OK || zErr==0 ); if( SQLITE_OK!=rc ){ if( rc==SQLITE_NOMEM ){ sqlite3FailedMalloc(); @@ -410,57 +411,6 @@ } /* -** Free all resources held by the schema structure. The void* argument points -** at a Schema struct. This function does not call sqliteFree() on the -** pointer itself, it just cleans up subsiduary resources (i.e. the contents -** of the schema hash tables). -*/ -void sqlite3SchemaFree(void *p){ - Hash temp1; - Hash temp2; - HashElem *pElem; - Schema *pSchema = (Schema *)p; - - temp1 = pSchema->tblHash; - temp2 = pSchema->trigHash; - sqlite3HashInit(&pSchema->trigHash, SQLITE_HASH_STRING, 0); - sqlite3HashClear(&pSchema->aFKey); - sqlite3HashClear(&pSchema->idxHash); - for(pElem=sqliteHashFirst(&temp2); pElem; pElem=sqliteHashNext(pElem)){ - sqlite3DeleteTrigger((Trigger*)sqliteHashData(pElem)); - } - sqlite3HashClear(&temp2); - sqlite3HashInit(&pSchema->tblHash, SQLITE_HASH_STRING, 0); - for(pElem=sqliteHashFirst(&temp1); pElem; pElem=sqliteHashNext(pElem)){ - Table *pTab = sqliteHashData(pElem); - sqlite3DeleteTable(0, pTab); - } - sqlite3HashClear(&temp1); - pSchema->pSeqTab = 0; - pSchema->flags &= ~DB_SchemaLoaded; -} - -/* -** Find and return the schema associated with a BTree. Create -** a new one if necessary. -*/ -Schema *sqlite3SchemaGet(Btree *pBt){ - Schema * p; - if( pBt ){ - p = (Schema *)sqlite3BtreeSchema(pBt,sizeof(Schema),sqlite3SchemaFree); - }else{ - p = (Schema *)sqliteMalloc(sizeof(Schema)); - } - if( p && 0==p->file_format ){ - sqlite3HashInit(&p->tblHash, SQLITE_HASH_STRING, 0); - sqlite3HashInit(&p->idxHash, SQLITE_HASH_STRING, 0); - sqlite3HashInit(&p->trigHash, SQLITE_HASH_STRING, 0); - sqlite3HashInit(&p->aFKey, SQLITE_HASH_STRING, 1); - } - return p; -} - -/* ** Convert a schema pointer into the iDb index that indicates ** which database file in db->aDb[] the schema refers to. ** ============================================================ --- sqlite/printf.c c7d6ad9efb71c466305297a448308f467b6e2b6e +++ sqlite/printf.c 358b4b585270f92a228e646e7bbb261c65f2a166 @@ -65,15 +65,14 @@ #define etDYNSTRING 7 /* Dynamically allocated strings. %z */ #define etPERCENT 8 /* Percent symbol. %% */ #define etCHARX 9 /* Characters. %c */ -#define etERROR 10 /* Used to indicate no such conversion type */ /* The rest are extensions, not normally found in printf() */ -#define etCHARLIT 11 /* Literal characters. %' */ -#define etSQLESCAPE 12 /* Strings with '\'' doubled. %q */ -#define etSQLESCAPE2 13 /* Strings with '\'' doubled and enclosed in '', +#define etCHARLIT 10 /* Literal characters. %' */ +#define etSQLESCAPE 11 /* Strings with '\'' doubled. %q */ +#define etSQLESCAPE2 12 /* Strings with '\'' doubled and enclosed in '', NULL pointers replaced by SQL NULL. %Q */ -#define etTOKEN 14 /* a pointer to a Token structure */ -#define etSRCLIST 15 /* a pointer to a SrcList */ -#define etPOINTER 16 /* The %p conversion */ +#define etTOKEN 13 /* a pointer to a Token structure */ +#define etSRCLIST 14 /* a pointer to a SrcList */ +#define etPOINTER 15 /* The %p conversion */ /* @@ -225,7 +224,7 @@ etByte flag_long; /* True if "l" flag is present */ etByte flag_longlong; /* True if the "ll" flag is present */ etByte done; /* Loop termination flag */ - UINT64_TYPE longvalue; /* Value for integer types */ + sqlite_uint64 longvalue; /* Value for integer types */ LONGDOUBLE_TYPE realvalue; /* Value for real types */ const et_info *infop; /* Pointer to the appropriate info structure */ char buf[etBUFSIZE]; /* Conversion buffer */ @@ -329,7 +328,6 @@ } /* Fetch the info entry for the field */ infop = 0; - xtype = etERROR; for(idx=0; idxetBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){ precision = etBUFSIZE-40; @@ -444,7 +446,7 @@ for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1); #else /* It makes more sense to use 0.5 */ - for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1); + for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){} #endif if( xtype==etFLOAT ) realvalue += rounder; /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ @@ -621,7 +623,8 @@ if( needQuote ) bufpt[j++] = '\''; bufpt[j] = 0; length = j; - if( precision>=0 && precision=0 && precisionnExpr; - codeDistinct(v, distinct, iContinue, n, n+1); + assert( pEList!=0 ); + assert( pEList->nExpr==nColumn ); + codeDistinct(v, distinct, iContinue, nColumn); if( pOrderBy==0 ){ codeOffset(v, p, iContinue, nColumn); } @@ -500,7 +497,7 @@ */ #ifndef SQLITE_OMIT_COMPOUND_SELECT case SRT_Union: { - sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, NULL_ALWAYS_DISTINCT); + sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0); if( aff ){ sqlite3VdbeChangeP3(v, -1, aff, P3_STATIC); } @@ -514,7 +511,7 @@ */ case SRT_Except: { int addr; - addr = sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, NULL_ALWAYS_DISTINCT); + addr = sqlite3VdbeAddOp(v, OP_MakeRecord, nColumn, 0); sqlite3VdbeChangeP3(v, -1, aff, P3_STATIC); sqlite3VdbeAddOp(v, OP_NotFound, iParm, addr+3); sqlite3VdbeAddOp(v, OP_Delete, iParm, 0); @@ -680,7 +677,7 @@ ** routine generates the code needed to do that. */ static void generateSortTail( - Parse *pParse, /* The parsing context */ + Parse *pParse, /* Parsing context */ Select *p, /* The SELECT statement */ Vdbe *v, /* Generate code into this VDBE */ int nColumn, /* Number of columns of data */ @@ -691,11 +688,20 @@ int cont = sqlite3VdbeMakeLabel(v); int addr; int iTab; + int pseudoTab; ExprList *pOrderBy = p->pOrderBy; iTab = pOrderBy->iECursor; + if( eDest==SRT_Callback || eDest==SRT_Subroutine ){ + pseudoTab = pParse->nTab++; + sqlite3VdbeAddOp(v, OP_OpenPseudo, pseudoTab, 0); + sqlite3VdbeAddOp(v, OP_SetNumColumns, pseudoTab, nColumn); + } addr = 1 + sqlite3VdbeAddOp(v, OP_Sort, iTab, brk); codeOffset(v, p, cont, 0); + if( eDest==SRT_Callback || eDest==SRT_Subroutine ){ + sqlite3VdbeAddOp(v, OP_Integer, 1, 0); + } sqlite3VdbeAddOp(v, OP_Column, iTab, pOrderBy->nExpr + 1); switch( eDest ){ case SRT_Table: @@ -725,17 +731,15 @@ case SRT_Callback: case SRT_Subroutine: { int i; - sqlite3VdbeAddOp(v, OP_Integer, p->pEList->nExpr, 0); - sqlite3VdbeAddOp(v, OP_Pull, 1, 0); + sqlite3VdbeAddOp(v, OP_Insert, pseudoTab, 0); for(i=0; ipPrior ) pSelect = pSelect->pPrior; if( prepSelectStmt(pParse, pSelect) ){ return 0; } @@ -1535,20 +1544,6 @@ } } -/* -** The opcode at addr is an OP_OpenVirtual that created a sorting -** index tha we ended up not needing. This routine changes that -** opcode to OP_Noop. -*/ -static void uncreateSortingIndex(Parse *pParse, int addr){ - Vdbe *v = pParse->pVdbe; - VdbeOp *pOp = sqlite3VdbeGetOp(v, addr); - sqlite3VdbeChangeP3(v, addr, 0, 0); - pOp->opcode = OP_Noop; - pOp->p1 = 0; - pOp->p2 = 0; -} - #ifndef SQLITE_OMIT_COMPOUND_SELECT /* ** Return the appropriate collating sequence for the iCol-th column of @@ -1771,7 +1766,9 @@ int iCont, iBreak, iStart; assert( p->pEList ); if( eDest==SRT_Callback ){ - generateColumnNames(pParse, 0, p->pEList); + Select *pFirst = p; + while( pFirst->pPrior ) pFirst = pFirst->pPrior; + generateColumnNames(pParse, 0, pFirst->pEList); } iBreak = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(v); @@ -1847,7 +1844,9 @@ */ assert( p->pEList ); if( eDest==SRT_Callback ){ - generateColumnNames(pParse, 0, p->pEList); + Select *pFirst = p; + while( pFirst->pPrior ) pFirst = pFirst->pPrior; + generateColumnNames(pParse, 0, pFirst->pEList); } iBreak = sqlite3VdbeMakeLabel(v); iCont = sqlite3VdbeMakeLabel(v); @@ -2117,7 +2116,6 @@ ** the subquery before this routine runs. */ static int flattenSubquery( - Parse *pParse, /* The parsing context */ Select *p, /* The parent or outer SELECT statement */ int iFrom, /* Index in p->pSrc->a[] of the inner subquery */ int isAgg, /* True if outer SELECT uses aggregate functions */ @@ -2245,7 +2243,6 @@ ** We look at every expression in the outer query and every place we see ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10". */ - substExprList(p->pEList, iParent, pSub->pEList); pList = p->pEList; for(i=0; inExpr; i++){ Expr *pExpr; @@ -2253,6 +2250,7 @@ pList->a[i].zName = sqliteStrNDup((char*)pExpr->span.z, pExpr->span.n); } } + substExprList(p->pEList, iParent, pSub->pEList); if( isAgg ){ substExprList(p->pGroupBy, iParent, pSub->pEList); substExpr(p->pHaving, iParent, pSub->pEList); @@ -2683,13 +2681,14 @@ if( pF->iDistinct>=0 ){ addrNext = sqlite3VdbeMakeLabel(v); assert( nArg==1 ); - codeDistinct(v, pF->iDistinct, addrNext, 1, 2); + codeDistinct(v, pF->iDistinct, addrNext, 1); } if( pF->pFunc->needCollSeq ){ CollSeq *pColl = 0; struct ExprList_item *pItem; int j; - for(j=0, pItem=pList->a; !pColl && jnExpr; j++, pItem++){ + assert( pList!=0 ); /* pList!=0 if pF->pFunc->needCollSeq is true */ + for(j=0, pItem=pList->a; !pColl && jpExpr); } if( !pColl ){ @@ -2902,7 +2901,7 @@ */ #ifndef SQLITE_OMIT_VIEW if( pParent && pParentAgg && - flattenSubquery(pParse, pParent, parentTab, *pParentAgg, isAgg) ){ + flattenSubquery(pParent, parentTab, *pParentAgg, isAgg) ){ if( isAgg ) *pParentAgg = 1; goto select_end; } @@ -2973,7 +2972,7 @@ ** into an OP_Noop. */ if( addrSortIndex>=0 && pOrderBy==0 ){ - uncreateSortingIndex(pParse, addrSortIndex); + sqlite3VdbeChangeToNoop(v, addrSortIndex, 1); p->addrOpenVirt[2] = -1; } @@ -3219,7 +3218,7 @@ sqlite3VdbeAddOp(v, OP_Next, sAggInfo.sortingIdx, addrTopOfLoop); }else{ sqlite3WhereEnd(pWInfo); - uncreateSortingIndex(pParse, addrSortingIdx); + sqlite3VdbeChangeToNoop(v, addrSortingIdx, 1); } /* Output the final row of result ============================================================ --- sqlite/sqlite3.h d0605a62334179d9c38bf587ac38b777d6daee2b +++ sqlite/sqlite3.h 8fce4dddf986e8bca2236a84423b2ba4a4ff4bd1 @@ -12,7 +12,7 @@ ** This header file defines the interface that the SQLite library ** presents to client programs. ** -** @(#) $Id: sqlite.h.in,v 1.162 2006/02/10 03:06:10 danielk1977 Exp $ +** @(#) $Id: sqlite.h.in,v 1.165 2006/04/04 01:54:55 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ @@ -31,7 +31,7 @@ #ifdef SQLITE_VERSION # undef SQLITE_VERSION #endif -#define SQLITE_VERSION "3.3.4" +#define SQLITE_VERSION "3.3.5" /* ** The format of the version string is "X.Y.Z", where @@ -48,7 +48,7 @@ #ifdef SQLITE_VERSION_NUMBER # undef SQLITE_VERSION_NUMBER #endif -#define SQLITE_VERSION_NUMBER 3003004 +#define SQLITE_VERSION_NUMBER 3003005 /* ** The version string is also compiled into the library so that a program @@ -78,7 +78,10 @@ ** to do a typedef that for 64-bit integers that depends on what compiler ** is being used. */ -#if defined(_MSC_VER) || defined(__BORLANDC__) +#ifdef SQLITE_INT64_TYPE + typedef SQLITE_INT64_TYPE sqlite_int64; + typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; +#elif defined(_MSC_VER) || defined(__BORLANDC__) typedef __int64 sqlite_int64; typedef unsigned __int64 sqlite_uint64; #else @@ -1114,11 +1117,12 @@ ** These are the allowed values for the eTextRep argument to ** sqlite3_create_collation and sqlite3_create_function. */ -#define SQLITE_UTF8 1 -#define SQLITE_UTF16LE 2 -#define SQLITE_UTF16BE 3 -#define SQLITE_UTF16 4 /* Use native byte order */ -#define SQLITE_ANY 5 /* sqlite3_create_function only */ +#define SQLITE_UTF8 1 +#define SQLITE_UTF16LE 2 +#define SQLITE_UTF16BE 3 +#define SQLITE_UTF16 4 /* Use native byte order */ +#define SQLITE_ANY 5 /* sqlite3_create_function only */ +#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ /* ** These two functions are used to add new collation sequences to the ============================================================ --- sqlite/sqliteInt.h f61b60f243f1709c943c62cfb6d7a50209080e38 +++ sqlite/sqliteInt.h 9052a26e0467be0ac0c554fb1f8de671eda2ea0d @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.481 2006/02/11 01:25:51 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.493 2006/04/04 01:54:55 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -114,18 +114,6 @@ /* ** If the following macro is set to 1, then NULL values are considered -** distinct for the SELECT DISTINCT statement and for UNION or EXCEPT -** compound queries. No other SQL database engine (among those tested) -** works this way except for OCELOT. But the SQL92 spec implies that -** this is how things should work. -** -** If the following macro is set to 0, then NULLs are indistinct for -** SELECT DISTINCT and for UNION. -*/ -#define NULL_ALWAYS_DISTINCT 0 - -/* -** If the following macro is set to 1, then NULL values are considered ** distinct when determining whether or not two entries are the same ** in a UNIQUE index. This is the way PostgreSQL, Oracle, DB2, MySQL, ** OCELOT, and Firebird all work. The SQL92 spec explicitly says this @@ -180,19 +168,22 @@ #endif /* +** Check to see if this machine uses EBCDIC. (Yes, believe it or +** not, there are still machines out there that use EBCDIC.) +*/ +#if 'A' == '\301' +# define SQLITE_EBCDIC 1 +#else +# define SQLITE_ASCII 1 +#endif + +/* ** Integers of known sizes. These typedefs might change for architectures ** where the sizes very. Preprocessor macros are available so that the ** types can be conveniently redefined at compile-type. Like this: ** ** cc '-DUINTPTR_TYPE=long long int' ... */ -#ifndef UINT64_TYPE -# if defined(_MSC_VER) || defined(__BORLANDC__) -# define UINT64_TYPE unsigned __int64 -# else -# define UINT64_TYPE unsigned long long int -# endif -#endif #ifndef UINT32_TYPE # define UINT32_TYPE unsigned int #endif @@ -212,7 +203,7 @@ # define LONGDOUBLE_TYPE long double #endif typedef sqlite_int64 i64; /* 8-byte signed integer */ -typedef UINT64_TYPE u64; /* 8-byte unsigned integer */ +typedef sqlite_uint64 u64; /* 8-byte unsigned integer */ typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ typedef INT16_TYPE i16; /* 2-byte signed integer */ @@ -251,12 +242,6 @@ #include "btree.h" #include "pager.h" -/* -** This macro casts a pointer to an integer. Useful for doing -** pointer arithmetic. -*/ -#define Addr(X) ((uptr)X) - #ifdef SQLITE_MEMDEBUG /* ** The following global variables are used for testing and debugging @@ -267,7 +252,6 @@ extern int sqlite3_iMallocFail; /* Fail sqliteMalloc() after this many calls */ extern int sqlite3_iMallocReset; /* Set iMallocFail to this when it reaches 0 */ - extern void *sqlite3_pFirst; /* Pointer to linked list of allocations */ extern int sqlite3_nMaxAlloc; /* High water mark of ThreadData.nAlloc */ extern int sqlite3_mallocDisallowed; /* assert() in sqlite3Malloc() if set */ @@ -276,8 +260,8 @@ extern int sqlite3_iLine; /* Line number for debug info */ #define ENTER_MALLOC (sqlite3_zFile = __FILE__, sqlite3_iLine = __LINE__) -#define sqliteMalloc(x) (ENTER_MALLOC, sqlite3Malloc(x)) -#define sqliteMallocRaw(x) (ENTER_MALLOC, sqlite3MallocRaw(x)) +#define sqliteMalloc(x) (ENTER_MALLOC, sqlite3Malloc(x,1)) +#define sqliteMallocRaw(x) (ENTER_MALLOC, sqlite3MallocRaw(x,1)) #define sqliteRealloc(x,y) (ENTER_MALLOC, sqlite3Realloc(x,y)) #define sqliteStrDup(x) (ENTER_MALLOC, sqlite3StrDup(x)) #define sqliteStrNDup(x,y) (ENTER_MALLOC, sqlite3StrNDup(x,y)) @@ -285,8 +269,9 @@ #else -#define sqliteMalloc(x) sqlite3Malloc(x) -#define sqliteMallocRaw(x) sqlite3MallocRaw(x) +#define ENTER_MALLOC 0 +#define sqliteMalloc(x) sqlite3Malloc(x,1) +#define sqliteMallocRaw(x) sqlite3MallocRaw(x,1) #define sqliteRealloc(x,y) sqlite3Realloc(x,y) #define sqliteStrDup(x) sqlite3StrDup(x) #define sqliteStrNDup(x,y) sqlite3StrNDup(x,y) @@ -516,6 +501,9 @@ #endif }; +/* +** A macro to discover the encoding of a database. +*/ #define ENC(db) ((db)->aDb[0].pSchema->enc) /* @@ -1389,8 +1377,8 @@ ExprList *pExprList; /* Valid for UPDATE statements and sometimes INSERT steps (when pSelect == 0) */ IdList *pIdList; /* Valid for INSERT statements only */ - - TriggerStep * pNext; /* Next in the link-list */ + TriggerStep *pNext; /* Next in the link-list */ + TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */ }; /* @@ -1483,8 +1471,8 @@ int sqlite3SortCompare(const char *, const char *); void sqlite3RealToSortable(double r, char *); -void *sqlite3Malloc(int); -void *sqlite3MallocRaw(int); +void *sqlite3Malloc(int,int); +void *sqlite3MallocRaw(int,int); void sqlite3Free(void*); void *sqlite3Realloc(void*,int); char *sqlite3StrDup(const char*); @@ -1525,7 +1513,7 @@ void sqlite3CommitInternalChanges(sqlite3*); Table *sqlite3ResultSetOfSelect(Parse*,char*,Select*); void sqlite3OpenMasterTable(Parse *, int); -void sqlite3StartTable(Parse*,Token*,Token*,Token*,int,int,int); +void sqlite3StartTable(Parse*,Token*,Token*,int,int,int); void sqlite3AddColumn(Parse*,Token*); void sqlite3AddNotNull(Parse*, int); void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); @@ -1581,7 +1569,7 @@ Index *sqlite3FindIndex(sqlite3*,const char*, const char*); void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); -void sqlite3Vacuum(Parse*, Token*); +void sqlite3Vacuum(Parse*); int sqlite3RunVacuum(char**, sqlite3*); char *sqlite3NameFromToken(Token*); int sqlite3ExprCheck(Parse*, Expr*, int, int*); @@ -1602,7 +1590,7 @@ int sqlite3ExprIsInteger(Expr*, int*); int sqlite3IsRowid(const char*); void sqlite3GenerateRowDelete(sqlite3*, Vdbe*, Table*, int, int); -void sqlite3GenerateRowIndexDelete(sqlite3*, Vdbe*, Table*, int, char*); +void sqlite3GenerateRowIndexDelete(Vdbe*, Table*, int, char*); void sqlite3GenerateIndexKey(Vdbe*, Index*, int); void sqlite3GenerateConstraintChecks(Parse*,Table*,int,char*,int,int,int,int); void sqlite3CompleteInsertion(Parse*, Table*, int, char*, int, int, int); @@ -1627,7 +1615,7 @@ int,Expr*,int); void sqlite3FinishTrigger(Parse*, TriggerStep*, Token*); void sqlite3DropTrigger(Parse*, SrcList*); - void sqlite3DropTriggerPtr(Parse*, Trigger*, int); + void sqlite3DropTriggerPtr(Parse*, Trigger*); int sqlite3TriggersExist(Parse*, Table*, int, ExprList*); int sqlite3CodeRowTrigger(Parse*, int, ExprList*, int, Table *, int, int, int, int); @@ -1642,7 +1630,7 @@ #else # define sqlite3TriggersExist(A,B,C,D,E,F) 0 # define sqlite3DeleteTrigger(A) -# define sqlite3DropTriggerPtr(A,B,C) +# define sqlite3DropTriggerPtr(A,B) # define sqlite3UnlinkAndDeleteTrigger(A,B,C) # define sqlite3CodeRowTrigger(A,B,C,D,E,F,G,H,I) 0 #endif @@ -1750,6 +1738,7 @@ int sqlite3MallocFailed(void); void sqlite3FailedMalloc(void); void sqlite3AbortOtherActiveVdbes(sqlite3 *, Vdbe *); +int sqlite3OpenTempDatabase(Parse *); #ifndef SQLITE_OMIT_SHARED_CACHE void sqlite3TableLock(Parse *, int, int, u8, const char *); @@ -1767,6 +1756,14 @@ #define sqlite3MallocAllow() #endif +#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT + void *sqlite3ThreadSafeMalloc(int); + void sqlite3ThreadSafeFree(void *); +#else + #define sqlite3ThreadSafeMalloc sqlite3MallocX + #define sqlite3ThreadSafeFree sqlite3FreeX +#endif + #ifdef SQLITE_SSE #include "sseInt.h" #endif ============================================================ --- sqlite/tokenize.c 382b3bb0ca26eb9153b5d20b246ef512a114a24f +++ sqlite/tokenize.c 91dc520980c0e2fb9265046adf8b7a86eff881dd @@ -15,7 +15,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.117 2006/02/09 22:24:41 drh Exp $ +** $Id: tokenize.c,v 1.118 2006/04/04 01:54:55 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -23,6 +23,39 @@ #include /* +** The charMap() macro maps alphabetic characters into their +** lower-case ASCII equivalent. On ASCII machines, this is just +** an upper-to-lower case map. On EBCDIC machines we also need +** to adjust the encoding. Only alphabetic characters and underscores +** need to be translated. +*/ +#ifdef SQLITE_ASCII +# define charMap(X) sqlite3UpperToLower[(unsigned char)X] +#endif +#ifdef SQLITE_EBCDIC +# define charMap(X) ebcdicToAscii[(unsigned char)X] +const unsigned char ebcdicToAscii[] = { +/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 3x */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 4x */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 5x */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 0, 0, /* 6x */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 7x */ + 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* 8x */ + 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* 9x */ + 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ax */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ + 0, 97, 98, 99,100,101,102,103,104,105, 0, 0, 0, 0, 0, 0, /* Cx */ + 0,106,107,108,109,110,111,112,113,114, 0, 0, 0, 0, 0, 0, /* Dx */ + 0, 0,115,116,117,118,119,120,121,122, 0, 0, 0, 0, 0, 0, /* Ex */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Fx */ +}; +#endif + +/* ** The sqlite3KeywordCode function looks up an identifier to determine if ** it is a keyword. If it is a keyword, the token code of that keyword is ** returned. If the input is not a keyword, TK_ID is returned. @@ -37,24 +70,22 @@ /* -** If X is a character that can be used in an identifier and -** X&0x80==0 then sqlite3IsIdChar[X] will be 1. If X&0x80==0x80 then -** X is always an identifier character. (Hence all UTF-8 -** characters can be part of an identifier). sqlite3IsIdChar[X] will -** be 0 for every character in the lower 128 ASCII characters -** that cannot be used as part of an identifier. +** If X is a character that can be used in an identifier then +** IdChar(X) will be true. Otherwise it is false. ** -** In this implementation, an identifier can be a string of -** alphabetic characters, digits, and "_" plus any character -** with the high-order bit set. The latter rule means that -** any sequence of UTF-8 characters or characters taken from -** an extended ISO8859 character set can form an identifier. +** For ASCII, any character with the high-order bit set is +** allowed in an identifier. For 7-bit characters, +** sqlite3IsIdChar[X] must be 1. ** +** For EBCDIC, the rules are more complex but have the same +** end result. +** ** Ticket #1066. the SQL standard does not allow '$' in the ** middle of identfiers. But many SQL implementations do. ** SQLite will allow '$' in identifiers for compatibility. ** But the feature is undocumented. */ +#ifdef SQLITE_ASCII const char sqlite3IsIdChar[] = { /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ @@ -64,9 +95,28 @@ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 7x */ }; - #define IdChar(C) (((c=C)&0x80)!=0 || (c>0x1f && sqlite3IsIdChar[c-0x20])) +#endif +#ifdef SQLITE_EBCDIC +const char sqlite3IsIdChar[] = { +/* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 4x */ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, /* 5x */ + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, /* 6x */ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, /* 7x */ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, /* 8x */ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, /* 9x */ + 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, /* Ax */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Bx */ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Cx */ + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Dx */ + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, /* Ex */ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, /* Fx */ +}; +#define IdChar(C) (((c=C)>=0x42 && sqlite3IsIdChar[c-0x40])) +#endif + /* ** Return the length of the token that begins at z[0]. ** Store the token type in *tokenType before returning. ============================================================ --- sqlite/trigger.c 4d3644cbd16959b568c95ae73493402be8021b08 +++ sqlite/trigger.c 48bbb94c11954c8e132efcc04478efe8304c4196 @@ -60,9 +60,11 @@ DbFixer sFix; int iTabDb; + assert( pName1!=0 ); /* pName1->z might be NULL, but not pName1 itself */ + assert( pName2!=0 ); if( isTemp ){ /* If TEMP was specified, then the trigger name may not be qualified. */ - if( pName2 && pName2->n>0 ){ + if( pName2->n>0 ){ sqlite3ErrorMsg(pParse, "temporary trigger may not have qualified name"); goto trigger_cleanup; } @@ -108,7 +110,7 @@ if( !zName || SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto trigger_cleanup; } - if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash), zName,pName->n+1) ){ + if( sqlite3HashFind(&(db->aDb[iDb].pSchema->trigHash), zName,strlen(zName)) ){ sqlite3ErrorMsg(pParse, "trigger %T already exists", pName); goto trigger_cleanup; } @@ -255,7 +257,7 @@ Table *pTab; Trigger *pDel; pDel = sqlite3HashInsert(&db->aDb[iDb].pSchema->trigHash, - pTrig->name, strlen(pTrig->name)+1, pTrig); + pTrig->name, strlen(pTrig->name), pTrig); if( pDel ){ assert( sqlite3MallocFailed() && pDel==pTrig ); goto triggerfinish_cleanup; @@ -453,14 +455,14 @@ for(i=OMIT_TEMPDB; inDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ if( zDb && sqlite3StrICmp(db->aDb[j].zName, zDb) ) continue; - pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName, nName+1); + pTrigger = sqlite3HashFind(&(db->aDb[j].pSchema->trigHash), zName, nName); if( pTrigger ) break; } if( !pTrigger ){ sqlite3ErrorMsg(pParse, "no such trigger: %S", pName, 0); goto drop_trigger_cleanup; } - sqlite3DropTriggerPtr(pParse, pTrigger, 0); + sqlite3DropTriggerPtr(pParse, pTrigger); drop_trigger_cleanup: sqlite3SrcListDelete(pName); @@ -470,18 +472,16 @@ ** Return a pointer to the Table structure for the table that a trigger ** is set on. */ -static Table *tableOfTrigger(sqlite3 *db, Trigger *pTrigger){ +static Table *tableOfTrigger(Trigger *pTrigger){ int n = strlen(pTrigger->table) + 1; return sqlite3HashFind(&pTrigger->pTabSchema->tblHash, pTrigger->table, n); } /* -** Drop a trigger given a pointer to that trigger. If nested is false, -** then also generate code to remove the trigger from the SQLITE_MASTER -** table. +** Drop a trigger given a pointer to that trigger. */ -void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger, int nested){ +void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){ Table *pTable; Vdbe *v; sqlite3 *db = pParse->db; @@ -489,8 +489,8 @@ iDb = sqlite3SchemaToIndex(pParse->db, pTrigger->pSchema); assert( iDb>=0 && iDbnDb ); - pTable = tableOfTrigger(db, pTrigger); - assert(pTable); + pTable = tableOfTrigger(pTrigger); + assert( pTable ); assert( pTable->pSchema==pTrigger->pSchema || iDb==1 ); #ifndef SQLITE_OMIT_AUTHORIZATION { @@ -507,7 +507,8 @@ /* Generate code to destroy the database record of the trigger. */ - if( pTable!=0 && (v = sqlite3GetVdbe(pParse))!=0 ){ + assert( pTable!=0 ); + if( (v = sqlite3GetVdbe(pParse))!=0 ){ int base; static const VdbeOpList dropTrigger[] = { { OP_Rewind, 0, ADDR(9), 0}, @@ -537,9 +538,10 @@ void sqlite3UnlinkAndDeleteTrigger(sqlite3 *db, int iDb, const char *zName){ Trigger *pTrigger; int nName = strlen(zName); - pTrigger = sqlite3HashInsert(&(db->aDb[iDb].pSchema->trigHash), zName, nName+1, 0); + pTrigger = sqlite3HashInsert(&(db->aDb[iDb].pSchema->trigHash), + zName, nName, 0); if( pTrigger ){ - Table *pTable = tableOfTrigger(db, pTrigger); + Table *pTable = tableOfTrigger(pTrigger); assert( pTable!=0 ); if( pTable->pTrigger == pTrigger ){ pTable->pTrigger = pTrigger->pNext; @@ -597,14 +599,7 @@ while( pTrigger ){ if( pTrigger->op==op && checkColumnOverLap(pTrigger->pColumns, pChanges) ){ - TriggerStack *ss; - ss = pParse->trigStack; - while( ss && ss->pTrigger!=pTab->pTrigger ){ - ss = ss->pNext; - } - if( ss==0 ){ - mask |= pTrigger->tr_tm; - } + mask |= pTrigger->tr_tm; } pTrigger = pTrigger->pNext; } @@ -761,10 +756,17 @@ (op!=TK_UPDATE||!p->pColumns||checkColumnOverLap(p->pColumns,pChanges)) ){ TriggerStack *pS; /* Pointer to trigger-stack entry */ - for(pS=pParse->trigStack; pS && p!=pS->pTrigger; pS=pS->pNext); + for(pS=pParse->trigStack; pS && p!=pS->pTrigger; pS=pS->pNext){} if( !pS ){ fire_this = 1; } +#if 0 /* Give no warning for recursive triggers. Just do not do them */ + else{ + sqlite3ErrorMsg(pParse, "recursive triggers not supported (%s)", + p->name); + return SQLITE_ERROR; + } +#endif } if( fire_this ){ ============================================================ --- sqlite/update.c 050a7e0ddaac03dec5271712eee62f1a9e699049 +++ sqlite/update.c 34add66fcd3301b33b6e4c4c813f4e408f7ee4a0 @@ -12,7 +12,7 @@ ** This file contains C code routines that are called by the parser ** to handle UPDATE statements. ** -** $Id: update.c,v 1.122 2006/02/10 02:27:43 danielk1977 Exp $ +** $Id: update.c,v 1.123 2006/02/24 02:53:50 drh Exp $ */ #include "sqliteInt.h" @@ -431,7 +431,7 @@ /* Delete the old indices for the current record. */ - sqlite3GenerateRowIndexDelete(db, v, pTab, iCur, aIdxUsed); + sqlite3GenerateRowIndexDelete(v, pTab, iCur, aIdxUsed); /* If changing the record number, delete the old record. */ ============================================================ --- sqlite/utf.c 1199766bbb0157931a83aa6eede6b6381177be64 +++ sqlite/utf.c 1d51225bce1ea8d1978e8ab28e862a0c12c7a8e8 @@ -12,7 +12,7 @@ ** This file contains routines used to translate between UTF-8, ** UTF-16, UTF-16BE, and UTF-16LE. ** -** $Id: utf.c,v 1.37 2006/01/24 10:58:22 danielk1977 Exp $ +** $Id: utf.c,v 1.38 2006/02/24 02:53:50 drh Exp $ ** ** Notes on UTF-8: ** @@ -255,7 +255,7 @@ #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) { char zBuf[100]; - sqlite3VdbeMemPrettyPrint(pMem, zBuf, 100); + sqlite3VdbeMemPrettyPrint(pMem, zBuf); fprintf(stderr, "INPUT: %s\n", zBuf); } #endif @@ -371,7 +371,7 @@ #if defined(TRANSLATE_TRACE) && defined(SQLITE_DEBUG) { char zBuf[100]; - sqlite3VdbeMemPrettyPrint(pMem, zBuf, 100); + sqlite3VdbeMemPrettyPrint(pMem, zBuf); fprintf(stderr, "OUTPUT: %s\n", zBuf); } #endif ============================================================ --- sqlite/util.c 405f46fef062b476826d2c171ec21def29563b75 +++ sqlite/util.c 137e6765825863593095cbbeab0e9e4ba1cf575d @@ -14,7 +14,7 @@ ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.184 2006/02/06 21:22:31 drh Exp $ +** $Id: util.c,v 1.188 2006/04/04 01:54:55 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -443,6 +443,7 @@ ** This is the test layer's wrapper around sqlite3OsMalloc(). */ static void * OSMALLOC(int n){ + sqlite3OsEnterMutex(); #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT sqlite3_nMaxAlloc = MAX(sqlite3_nMaxAlloc, sqlite3ThreadDataReadOnly()->nAlloc); @@ -455,8 +456,10 @@ sqlite3_nMalloc++; applyGuards(p); linkAlloc(p); + sqlite3OsLeaveMutex(); return (void *)(&p[TESTALLOC_NGUARD + 2*sizeof(void *)/sizeof(u32)]); } + sqlite3OsLeaveMutex(); return 0; } @@ -473,12 +476,14 @@ ** pointer to the space allocated for the application to use. */ static void OSFREE(void *pFree){ + sqlite3OsEnterMutex(); u32 *p = (u32 *)getOsPointer(pFree); /* p points to Os level allocation */ checkGuards(p); unlinkAlloc(p); memset(pFree, 0x55, OSSIZEOF(pFree)); sqlite3OsFree(p); sqlite3_nFree++; + sqlite3OsLeaveMutex(); } /* @@ -542,7 +547,7 @@ } assert( pTsd->nAlloc>=0 ); if( n>0 && pTsd->nSoftHeapLimit>0 ){ - while( pTsd->nAlloc+n>pTsd->nSoftHeapLimit && sqlite3_release_memory(n) ); + while( pTsd->nAlloc+n>pTsd->nSoftHeapLimit && sqlite3_release_memory(n) ){} } return 1; } @@ -578,14 +583,14 @@ ** sqlite3OsMalloc(). If the Malloc() call fails, attempt to free memory ** by calling sqlite3_release_memory(). */ -void *sqlite3MallocRaw(int n){ +void *sqlite3MallocRaw(int n, int doMemManage){ void *p = 0; - if( n>0 && !sqlite3MallocFailed() && enforceSoftLimit(n) ){ - while( (p = OSMALLOC(n))==0 && sqlite3_release_memory(n) ); + if( n>0 && !sqlite3MallocFailed() && (!doMemManage || enforceSoftLimit(n)) ){ + while( (p = OSMALLOC(n))==0 && sqlite3_release_memory(n) ){} if( !p ){ sqlite3FailedMalloc(); OSMALLOC_FAILED(); - }else{ + }else if( doMemManage ){ updateMemoryUsedCount(OSSIZEOF(p)); } } @@ -603,14 +608,14 @@ } if( !p ){ - return sqlite3Malloc(n); + return sqlite3Malloc(n, 1); }else{ void *np = 0; #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT int origSize = OSSIZEOF(p); #endif if( enforceSoftLimit(n - origSize) ){ - while( (np = OSREALLOC(p, n))==0 && sqlite3_release_memory(n) ); + while( (np = OSREALLOC(p, n))==0 && sqlite3_release_memory(n) ){} if( !np ){ sqlite3FailedMalloc(); OSMALLOC_FAILED(); @@ -648,8 +653,8 @@ ** These two are implemented as wrappers around sqlite3MallocRaw(), ** sqlite3Realloc() and sqlite3Free(). */ -void *sqlite3Malloc(int n){ - void *p = sqlite3MallocRaw(n); +void *sqlite3Malloc(int n, int doMemManage){ + void *p = sqlite3MallocRaw(n, doMemManage); if( p ){ memset(p, 0, n); } @@ -664,6 +669,33 @@ } /* +** sqlite3ThreadSafeMalloc() and sqlite3ThreadSafeFree() are used in those +** rare scenarios where sqlite may allocate memory in one thread and free +** it in another. They are exactly the same as sqlite3Malloc() and +** sqlite3Free() except that: +** +** * The allocated memory is not included in any calculations with +** respect to the soft-heap-limit, and +** +** * sqlite3ThreadSafeMalloc() must be matched with ThreadSafeFree(), +** not sqlite3Free(). Calling sqlite3Free() on memory obtained from +** ThreadSafeMalloc() will cause an error somewhere down the line. +*/ +#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT +void *sqlite3ThreadSafeMalloc(int n){ + ENTER_MALLOC; + return sqlite3Malloc(n, 0); +} +void sqlite3ThreadSafeFree(void *p){ + ENTER_MALLOC; + if( p ){ + OSFREE(p); + } +} +#endif + + +/* ** Return the number of bytes allocated at location p. p must be either ** a NULL pointer (in which case 0 is returned) or a pointer returned by ** sqlite3Malloc(), sqlite3Realloc() or sqlite3ReallocOrFree(). @@ -689,14 +721,14 @@ char *sqlite3StrDup(const char *z){ char *zNew; if( z==0 ) return 0; - zNew = sqlite3MallocRaw(strlen(z)+1); + zNew = sqlite3MallocRaw(strlen(z)+1, 1); if( zNew ) strcpy(zNew, z); return zNew; } char *sqlite3StrNDup(const char *z, int n){ char *zNew; if( z==0 ) return 0; - zNew = sqlite3MallocRaw(n+1); + zNew = sqlite3MallocRaw(n+1, 1); if( zNew ){ memcpy(zNew, z, n); zNew[n] = 0; @@ -851,6 +883,7 @@ ** lower-case character. */ const unsigned char sqlite3UpperToLower[] = { +#ifdef SQLITE_ASCII 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, @@ -866,6 +899,25 @@ 216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233, 234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251, 252,253,254,255 +#endif +#ifdef SQLITE_EBCDIC + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 0x */ + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 1x */ + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 2x */ + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */ + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */ + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */ + 96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */ + 112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */ + 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */ + 144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */ + 160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */ + 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */ + 192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */ + 208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */ + 224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */ + 239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */ +#endif }; #define UpperToLower sqlite3UpperToLower @@ -939,6 +991,7 @@ int sign = 1; const char *zBegin = z; LONGDOUBLE_TYPE v1 = 0.0; + while( isspace(*z) ) z++; if( *z=='-' ){ sign = -1; z++; @@ -1006,6 +1059,7 @@ i64 v = 0; int neg; int i, c; + while( isspace(*zNum) ) zNum++; if( *zNum=='-' ){ neg = 1; zNum++; ============================================================ --- sqlite/vacuum.c 3865673cc66acd0717ecd517f6b8fdb2a5e7924b +++ sqlite/vacuum.c 5b37d0f436f8e1ffacd17934e44720b38d2247f9 @@ -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.58 2006/01/18 16:51:36 danielk1977 Exp $ +** $Id: vacuum.c,v 1.59 2006/02/24 02:53:50 drh Exp $ */ #include "sqliteInt.h" #include "vdbeInt.h" @@ -43,7 +43,7 @@ if( SQLITE_OK!=sqlite3_prepare(db, zSql, -1, &pStmt, 0) ){ return sqlite3_errcode(db); } - while( SQLITE_ROW==sqlite3_step(pStmt) ); + while( SQLITE_ROW==sqlite3_step(pStmt) ){} return sqlite3_finalize(pStmt); } @@ -81,7 +81,7 @@ ** with 2.0.0, SQLite no longer uses GDBM so this command has ** become a no-op. */ -void sqlite3Vacuum(Parse *pParse, Token *pTableName){ +void sqlite3Vacuum(Parse *pParse){ Vdbe *v = sqlite3GetVdbe(pParse); if( v ){ sqlite3VdbeAddOp(v, OP_Vacuum, 0, 0); ============================================================ --- sqlite/vdbe.c 0a7fd81609429bae2b3c326687b02a60a9c01c49 +++ sqlite/vdbe.c a56ef5de6d91aedf6f1f0db03c65aa01ecbe11ba @@ -43,7 +43,7 @@ ** 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.543 2006/02/10 14:02:07 drh Exp $ +** $Id: vdbe.c,v 1.548 2006/03/22 22:10:08 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -280,7 +280,7 @@ ** Write a nice string representation of the contents of cell pMem ** into buffer zBuf, length nBuf. */ -void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf, int nBuf){ +void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf){ char *zCsr = zBuf; int f = pMem->flags; @@ -1871,13 +1871,6 @@ ** If the KeyAsData opcode has previously executed on this cursor, then the ** field might be extracted from the key rather than the data. ** -** If P1 is negative, then the record is stored on the stack rather than in -** a table. For P1==-1, the top of the stack is used. For P1==-2, the -** next on the stack is used. And so forth. The value pushed is always -** just a pointer into the record which is stored further down on the -** stack. The column value is not copied. The number of columns in the -** record is stored on the stack just above the record itself. -** ** If the column contains fewer than P2 fields, then push a NULL. Or ** if P3 is of type P3_MEM, then push the P3 value. The P3 value will ** be default value for a column that has been added using the ALTER TABLE @@ -1909,31 +1902,19 @@ ** bytes in the record. ** ** zRec is set to be the complete text of the record if it is available. - ** The complete record text is always available for pseudo-tables and - ** when we are decoded a record from the stack. If the record is stored - ** in a cursor, the complete record text might be available in the - ** pC->aRow cache. Or it might not be. If the data is unavailable, - ** zRec is set to NULL. + ** The complete record text is always available for pseudo-tables + ** If the record is stored in a cursor, the complete record text + ** might be available in the pC->aRow cache. Or it might not be. + ** If the data is unavailable, zRec is set to NULL. ** ** We also compute the number of columns in the record. For cursors, ** the number of columns is stored in the Cursor.nField element. For ** records on the stack, the next entry down on the stack is an integer ** which is the number of records. */ - assert( p1<0 || p->apCsr[p1]!=0 ); - if( p1<0 ){ - /* Take the record off of the stack */ - Mem *pRec = &pTos[p1]; - Mem *pCnt = &pRec[-1]; - assert( pRec>=p->aStack ); - assert( pRec->flags & MEM_Blob ); - payloadSize = pRec->n; - zRec = pRec->z; - assert( pCnt>=p->aStack ); - assert( pCnt->flags & MEM_Int ); - nField = pCnt->i; - pCrsr = 0; - }else if( (pC = p->apCsr[p1])->pCursor!=0 ){ + pC = p->apCsr[p1]; + assert( pC!=0 ); + if( pC->pCursor!=0 ){ /* The record is stored in a B-Tree */ rc = sqlite3VdbeCursorMoveto(pC); if( rc ) goto abort_due_to_error; @@ -1952,7 +1933,6 @@ sqlite3BtreeDataSize(pCrsr, &payloadSize); } nField = pC->nField; -#ifndef SQLITE_OMIT_TRIGGER }else if( pC->pseudoTable ){ /* The record is the sole entry of a pseudo-table */ payloadSize = pC->nData; @@ -1961,7 +1941,6 @@ assert( payloadSize==0 || zRec!=0 ); nField = pC->nField; pCrsr = 0; -#endif }else{ zRec = 0; payloadSize = 0; @@ -1989,15 +1968,17 @@ u32 offset; /* Offset into the data */ int szHdrSz; /* Size of the header size field at start of record */ int avail; /* Number of bytes of available data */ - if( pC && pC->aType ){ - aType = pC->aType; - }else{ - aType = sqliteMallocRaw( 2*nField*sizeof(aType) ); + + aType = pC->aType; + if( aType==0 ){ + pC->aType = aType = sqliteMallocRaw( 2*nField*sizeof(aType) ); } - aOffset = &aType[nField]; if( aType==0 ){ goto no_mem; } + pC->aOffset = aOffset = &aType[nField]; + pC->payloadSize = payloadSize; + pC->cacheStatus = p->cacheCtr; /* Figure out how many bytes are in the header */ if( zRec ){ @@ -2070,15 +2051,6 @@ rc = SQLITE_CORRUPT_BKPT; goto op_column_out; } - - /* Remember all aType and aColumn information if we have a cursor - ** to remember it in. */ - if( pC ){ - pC->payloadSize = payloadSize; - pC->aType = aType; - pC->aOffset = aOffset; - pC->cacheStatus = p->cacheCtr; - } } /* Get the column information. If aOffset[p2] is non-zero, then @@ -2111,7 +2083,7 @@ /* If we dynamically allocated space to hold the data (in the ** sqlite3VdbeMemFromBtree() call above) then transfer control of that - ** dynamically allocated space over to the pTos structure rather. + ** dynamically allocated space over to the pTos structure. ** This prevents a memory copy. */ if( (sMem.flags & MEM_Dyn)!=0 ){ @@ -2128,10 +2100,6 @@ rc = sqlite3VdbeMemMakeWriteable(pTos); op_column_out: - /* Release the aType[] memory if we are not dealing with cursor */ - if( !pC || !pC->aType ){ - sqliteFree(aType); - } break; } @@ -2722,7 +2690,6 @@ break; } -#ifndef SQLITE_OMIT_TRIGGER /* Opcode: OpenPseudo P1 * * ** ** Open a new cursor that points to a fake table that contains a single @@ -2731,7 +2698,9 @@ ** closed. ** ** A pseudo-table created by this opcode is useful for holding the -** NEW or OLD tables in a trigger. +** NEW or OLD tables in a trigger. Also used to hold the a single +** row output from the sorter so that the row can be decomposed into +** individual columns using the OP_Column opcode. */ case OP_OpenPseudo: { /* no-push */ int i = pOp->p1; @@ -2746,7 +2715,6 @@ pCx->isIndex = 0; break; } -#endif /* Opcode: Close P1 * * ** @@ -3013,7 +2981,7 @@ zKey = pNos->z; nKey = pNos->n; - szRowid = sqlite3VdbeIdxRowidLen(nKey, (u8*)zKey); + szRowid = sqlite3VdbeIdxRowidLen((u8*)zKey); len = nKey-szRowid; /* Search for an entry in P1 where all but the last four bytes match K. @@ -3320,7 +3288,6 @@ }else{ assert( pTos->flags & (MEM_Blob|MEM_Str) ); } -#ifndef SQLITE_OMIT_TRIGGER if( pC->pseudoTable ){ sqliteFree(pC->pData); pC->iKey = iKey; @@ -3337,11 +3304,8 @@ } pC->nullRow = 0; }else{ -#endif rc = sqlite3BtreeInsert(pC->pCursor, 0, iKey, pTos->z, pTos->n); -#ifndef SQLITE_OMIT_TRIGGER } -#endif pC->rowidIsValid = 0; pC->deferredMoveto = 0; @@ -3498,12 +3462,10 @@ }else{ sqlite3BtreeData(pCrsr, 0, n, pTos->z); } -#ifndef SQLITE_OMIT_TRIGGER }else if( pC->pseudoTable ){ pTos->n = pC->nData; pTos->z = pC->pData; pTos->flags = MEM_Blob|MEM_Ephem; -#endif }else{ pTos->flags = MEM_Null; } @@ -4071,7 +4033,7 @@ break; } -#ifndef SQLITE_OMIT_ANALYZE +#if !defined(SQLITE_OMIT_ANALYZE) && !defined(SQLITE_OMIT_PARSER) /* Opcode: LoadAnalysis P1 * * ** ** Read the sqlite_stat1 table for database P1 and load the content @@ -4084,7 +4046,7 @@ sqlite3AnalysisLoad(db, iDb); break; } -#endif /* SQLITE_OMIT_ANALYZE */ +#endif /* !defined(SQLITE_OMIT_ANALYZE) && !defined(SQLITE_OMIT_PARSER) */ /* Opcode: DropTable P1 * P3 ** @@ -4536,7 +4498,7 @@ ** Obtain a lock on a particular table. This instruction is only used when ** the shared-cache feature is enabled. ** -** If P1 is not negative, then it is the index of the index of the database +** If P1 is not negative, then it is the index of the database ** in sqlite3.aDb[] and a read-lock is required. If P1 is negative, a ** write-lock is required. In this case the index of the database is the ** absolute value of P1 minus one (iDb = abs(P1) - 1;) and a write-lock is @@ -4600,7 +4562,7 @@ #ifndef NDEBUG /* Sanity checking on the top element of the stack */ if( pTos>=p->aStack ){ - sqlite3VdbeMemSanity(pTos, encoding); + sqlite3VdbeMemSanity(pTos); } assert( pc>=-1 && pcnOp ); #ifdef SQLITE_DEBUG @@ -4619,7 +4581,7 @@ fprintf(p->trace, " r:%g", pTos[i].r); }else{ char zBuf[100]; - sqlite3VdbeMemPrettyPrint(&pTos[i], zBuf, 100); + sqlite3VdbeMemPrettyPrint(&pTos[i], zBuf); fprintf(p->trace, " "); fprintf(p->trace, "%s", zBuf); } ============================================================ --- sqlite/vdbe.h 80ba1c391ec28180dd07a630577f50b22c2062da +++ sqlite/vdbe.h 44ff995a8b4e87016794095273e9e7300f0001bb @@ -15,7 +15,7 @@ ** or VDBE. The VDBE implements an abstract machine that runs a ** simple program to access and modify the underlying database. ** -** $Id: vdbe.h,v 1.101 2006/02/10 03:06:10 danielk1977 Exp $ +** $Id: vdbe.h,v 1.102 2006/03/17 13:56:34 drh Exp $ */ #ifndef _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_ @@ -117,6 +117,7 @@ void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); void sqlite3VdbeJumpHere(Vdbe*, int addr); +void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); void sqlite3VdbeChangeP3(Vdbe*, int addr, const char *zP1, int N); VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); int sqlite3VdbeMakeLabel(Vdbe*); ============================================================ --- sqlite/vdbeInt.h eb3f86ab08ef11635bc78eb88c3ff13f923c233b +++ sqlite/vdbeInt.h 85cd5f81d38edb1b8f4786f407c77a7a3ba636fb @@ -317,6 +317,10 @@ u8 minWriteFileFormat; /* Minimum file format for writable database files */ int nChange; /* Number of db changes made since last reset */ i64 startTime; /* Time when query started - used for profiling */ +#ifdef SQLITE_SSE + int fetchId; /* Statement number used by sqlite3_fetch_statement */ + int lru; /* Counter used for LRU cache replacement */ +#endif }; /* @@ -350,7 +354,7 @@ int sqlite3VdbeIdxRowid(BtCursor *, i64 *); int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); int sqlite3VdbeRecordCompare(void*,int,const void*,int, const void*); -int sqlite3VdbeIdxRowidLen(int,const u8*); +int sqlite3VdbeIdxRowidLen(const u8*); int sqlite3VdbeExec(Vdbe*); int sqlite3VdbeList(Vdbe*); int sqlite3VdbeHalt(Vdbe*); @@ -376,11 +380,11 @@ void sqlite3VdbeMemRelease(Mem *p); int sqlite3VdbeMemFinalize(Mem*, FuncDef*); #ifndef NDEBUG -void sqlite3VdbeMemSanity(Mem*, u8); +void sqlite3VdbeMemSanity(Mem*); int sqlite3VdbeOpcodeNoPush(u8); #endif int sqlite3VdbeMemTranslate(Mem*, u8); -void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf, int nBuf); +void sqlite3VdbeMemPrettyPrint(Mem *pMem, char *zBuf); int sqlite3VdbeMemHandleBom(Mem *pMem); void sqlite3VdbeFifoInit(Fifo*); int sqlite3VdbeFifoPush(Fifo*, i64); ============================================================ --- sqlite/vdbeaux.c 95f4ed0bc8ed45f16823d84504310495b5dc587d +++ sqlite/vdbeaux.c 4002e6b19d7c9719cb81f9797316b9ad118e4370 @@ -107,9 +107,11 @@ i = p->nOp; p->nOp++; assert( p->magic==VDBE_MAGIC_INIT ); - resizeOpArray(p, i+1); - if( sqlite3MallocFailed() ){ - return 0; + if( p->nOpAlloc<=i ){ + resizeOpArray(p, i+1); + if( sqlite3MallocFailed() ){ + return 0; + } } pOp = &p->aOp[i]; pOp->opcode = op; @@ -202,11 +204,11 @@ ** IEEE floats. */ static const u32 masks[5] = { - NOPUSH_MASK_0 + (NOPUSH_MASK_1<<16), - NOPUSH_MASK_2 + (NOPUSH_MASK_3<<16), - NOPUSH_MASK_4 + (NOPUSH_MASK_5<<16), - NOPUSH_MASK_6 + (NOPUSH_MASK_7<<16), - NOPUSH_MASK_8 + (NOPUSH_MASK_9<<16) + NOPUSH_MASK_0 + (((unsigned)NOPUSH_MASK_1)<<16), + NOPUSH_MASK_2 + (((unsigned)NOPUSH_MASK_3)<<16), + NOPUSH_MASK_4 + (((unsigned)NOPUSH_MASK_5)<<16), + NOPUSH_MASK_6 + (((unsigned)NOPUSH_MASK_7)<<16), + NOPUSH_MASK_8 + (((unsigned)NOPUSH_MASK_9)<<16) }; assert( op<32*5 ); return (masks[op>>5] & (1<<(op&0x1F))); @@ -340,7 +342,7 @@ ** few minor changes to the program. */ void sqlite3VdbeChangeP1(Vdbe *p, int addr, int val){ - assert( p->magic==VDBE_MAGIC_INIT ); + assert( p==0 || p->magic==VDBE_MAGIC_INIT ); if( p && addr>=0 && p->nOp>addr && p->aOp ){ p->aOp[addr].p1 = val; } @@ -352,14 +354,14 @@ */ void sqlite3VdbeChangeP2(Vdbe *p, int addr, int val){ assert( val>=0 ); - assert( p->magic==VDBE_MAGIC_INIT ); + assert( p==0 || p->magic==VDBE_MAGIC_INIT ); if( p && addr>=0 && p->nOp>addr && p->aOp ){ p->aOp[addr].p2 = val; } } /* -** Change teh P2 operand of instruction addr so that it points to +** Change the P2 operand of instruction addr so that it points to ** the address of the next instruction to be coded. */ void sqlite3VdbeJumpHere(Vdbe *p, int addr){ @@ -394,6 +396,19 @@ /* +** Change N opcodes starting at addr to No-ops. +*/ +void sqlite3VdbeChangeToNoop(Vdbe *p, int addr, int N){ + VdbeOp *pOp = &p->aOp[addr]; + while( N-- ){ + freeP3(pOp->p3type, pOp->p3); + memset(pOp, 0, sizeof(pOp[0])); + pOp->opcode = OP_Noop; + pOp++; + } +} + +/* ** Change the value of the P3 operand for a specific instruction. ** This routine is useful when a large program is loaded from a ** static array using sqlite3VdbeAddOpList but we want to make a @@ -420,7 +435,7 @@ */ void sqlite3VdbeChangeP3(Vdbe *p, int addr, const char *zP3, int n){ Op *pOp; - assert( p->magic==VDBE_MAGIC_INIT ); + assert( p==0 || p->magic==VDBE_MAGIC_INIT ); if( p==0 || p->aOp==0 || sqlite3MallocFailed() ){ if (n != P3_KEYINFO) { freeP3(n, (void*)*(char**)&zP3); @@ -656,8 +671,9 @@ pMem->type = SQLITE_INTEGER; pMem++; - pMem->flags = MEM_Short|MEM_Str|MEM_Term; /* P3 */ + pMem->flags = MEM_Ephem|MEM_Str|MEM_Term; /* P3 */ pMem->z = displayP3(pOp, pMem->zShort, sizeof(pMem->zShort)); + pMem->n = strlen(pMem->z); pMem->type = SQLITE_TEXT; pMem->enc = SQLITE_UTF8; @@ -1841,7 +1857,7 @@ ** an integer rowid). This routine returns the number of bytes in ** that integer. */ -int sqlite3VdbeIdxRowidLen(int nKey, const u8 *aKey){ +int sqlite3VdbeIdxRowidLen(const u8 *aKey){ u32 szHdr; /* Size of the header */ u32 typeRowid; /* Serial type of the rowid */ @@ -1911,7 +1927,7 @@ if( rc ){ return rc; } - lenRowid = sqlite3VdbeIdxRowidLen(m.n, (u8*)m.z); + lenRowid = sqlite3VdbeIdxRowidLen((u8*)m.z); *res = sqlite3VdbeRecordCompare(pC->pKeyInfo, m.n-lenRowid, m.z, nKey, pKey); sqlite3VdbeMemRelease(&m); return SQLITE_OK; ============================================================ --- sqlite/vdbemem.c 2034e93b32c14bda6e306bb54e3a8e930b963027 +++ sqlite/vdbemem.c 5f0afe3b92bb2c037f8d5d697f7c151fa50783a3 @@ -42,6 +42,7 @@ return SQLITE_ERROR; #else + /* MemTranslate() may return SQLITE_OK or SQLITE_NOMEM. If NOMEM is returned, ** then the encoding of the value may not have changed. */ @@ -118,6 +119,7 @@ z[n+1] = 0; pMem->z = (char*)z; pMem->flags &= ~(MEM_Ephem|MEM_Static); + assert(0==(1&(int)pMem->z)); return SQLITE_OK; } @@ -596,19 +598,25 @@ if( pColl ){ if( pMem1->enc==pColl->enc ){ + /* The strings are already in the correct encoding. Call the + ** comparison function directly */ return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z); }else{ u8 origEnc = pMem1->enc; - rc = pColl->xCmp( - pColl->pUser, - sqlite3ValueBytes((sqlite3_value*)pMem1, pColl->enc), - sqlite3ValueText((sqlite3_value*)pMem1, pColl->enc), - sqlite3ValueBytes((sqlite3_value*)pMem2, pColl->enc), - sqlite3ValueText((sqlite3_value*)pMem2, pColl->enc) - ); - sqlite3ValueBytes((sqlite3_value*)pMem1, origEnc); + const void *v1, *v2; + int n1, n2; + /* Convert the strings into the encoding that the comparison + ** function expects */ + v1 = sqlite3ValueText((sqlite3_value*)pMem1, pColl->enc); + n1 = v1==0 ? 0 : pMem1->n; + assert( n1==sqlite3ValueBytes((sqlite3_value*)pMem1, pColl->enc) ); + v2 = sqlite3ValueText((sqlite3_value*)pMem2, pColl->enc); + n2 = v2==0 ? 0 : pMem2->n; + assert( n2==sqlite3ValueBytes((sqlite3_value*)pMem2, pColl->enc) ); + /* Do the comparison */ + rc = pColl->xCmp(pColl->pUser, n1, v1, n2, v2); + /* Convert the strings back into the database encoding */ sqlite3ValueText((sqlite3_value*)pMem1, origEnc); - sqlite3ValueBytes((sqlite3_value*)pMem2, origEnc); sqlite3ValueText((sqlite3_value*)pMem2, origEnc); return rc; } @@ -703,7 +711,7 @@ ** Perform various checks on the memory cell pMem. An assert() will ** fail if pMem is internally inconsistent. */ -void sqlite3VdbeMemSanity(Mem *pMem, u8 db_enc){ +void sqlite3VdbeMemSanity(Mem *pMem){ int flags = pMem->flags; assert( flags!=0 ); /* Must define some type */ if( pMem->flags & (MEM_Str|MEM_Blob) ){ @@ -752,10 +760,14 @@ ** except the data returned is in the encoding specified by the second ** parameter, which must be one of SQLITE_UTF16BE, SQLITE_UTF16LE or ** SQLITE_UTF8. +** +** (2006-02-16:) The enc value can be or-ed with SQLITE_UTF16_ALIGNED. +** If that is the case, then the result must be aligned on an even byte +** boundary. */ const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){ if( !pVal ) return 0; - assert( enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE || enc==SQLITE_UTF8); + assert( (enc&3)==(enc&~SQLITE_UTF16_ALIGNED) ); if( pVal->flags&MEM_Null ){ return 0; @@ -763,12 +775,23 @@ assert( (MEM_Blob>>3) == MEM_Str ); pVal->flags |= (pVal->flags & MEM_Blob)>>3; if( pVal->flags&MEM_Str ){ - sqlite3VdbeChangeEncoding(pVal, enc); + sqlite3VdbeChangeEncoding(pVal, enc & ~SQLITE_UTF16_ALIGNED); + if( (enc & SQLITE_UTF16_ALIGNED)!=0 && 1==(1&(int)pVal->z) ){ + assert( (pVal->flags & (MEM_Ephem|MEM_Static))!=0 ); + if( sqlite3VdbeMemMakeWriteable(pVal)!=SQLITE_OK ){ + return 0; + } + } }else if( !(pVal->flags&MEM_Blob) ){ sqlite3VdbeMemStringify(pVal, enc); + assert( 0==(1&(int)pVal->z) ); } - assert(pVal->enc==enc || sqlite3MallocFailed() ); - return (const void *)(pVal->enc==enc ? (pVal->z) : 0); + assert(pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) || sqlite3MallocFailed() ); + if( pVal->enc==(enc & ~SQLITE_UTF16_ALIGNED) ){ + return pVal->z; + }else{ + return 0; + } } /* ============================================================ --- sqlite/where.c c7d71d5e55c9c4c1e948089280fb0dec7c7d1ef6 +++ sqlite/where.c 1ba8eb02aba7eb8b75d7be0635200a14f0bef73a @@ -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.204 2006/02/01 02:45:02 drh Exp $ +** $Id: where.c,v 1.206 2006/03/28 23:55:58 drh Exp $ */ #include "sqliteInt.h" @@ -771,8 +771,7 @@ static int isSortingIndex( Parse *pParse, /* Parsing context */ Index *pIdx, /* The index we are testing */ - Table *pTab, /* The table to be sorted */ - int base, /* Cursor number for pTab */ + int base, /* Cursor number for the table to be sorted */ ExprList *pOrderBy, /* The ORDER BY clause */ int nEqCol, /* Number of index columns with == constraints */ int *pbRev /* Set to 1 if ORDER BY is DESC */ @@ -927,7 +926,23 @@ TRACE(("bestIndex: tbl=%s notReady=%x\n", pSrc->pTab->zName, notReady)); lowestCost = SQLITE_BIG_DBL; + pProbe = pSrc->pTab->pIndex; + /* If the table has no indices and there are no terms in the where + ** clause that refer to the ROWID, then we will never be able to do + ** anything other than a full table scan on this table. We might as + ** well put it first in the join order. That way, perhaps it can be + ** referenced by other tables in the join. + */ + if( pProbe==0 && + findTerm(pWC, iCur, -1, 0, WO_EQ|WO_IN|WO_LT|WO_LE|WO_GT|WO_GE,0)==0 && + (pOrderBy==0 || !sortableByRowid(iCur, pOrderBy, &rev)) ){ + *pFlags = 0; + *ppIndex = 0; + *pnEq = 0; + return 0.0; + } + /* Check for a rowid=EXPR or rowid IN (...) constraints */ pTerm = findTerm(pWC, iCur, -1, notReady, WO_EQ|WO_IN, 0); @@ -959,7 +974,6 @@ /* Estimate the cost of a table scan. If we do not know how many ** entries are in the table, use 1 million as a guess. */ - pProbe = pSrc->pTab->pIndex; cost = pProbe ? pProbe->aiRowEst[0] : 1000000; TRACE(("... table scan base cost: %.9g\n", cost)); flags = WHERE_ROWID_RANGE; @@ -1057,7 +1071,7 @@ */ if( pOrderBy ){ if( (flags & WHERE_COLUMN_IN)==0 && - isSortingIndex(pParse,pProbe,pSrc->pTab,iCur,pOrderBy,nEq,&rev) ){ + isSortingIndex(pParse,pProbe,iCur,pOrderBy,nEq,&rev) ){ if( flags==0 ){ flags = WHERE_COLUMN_RANGE; } @@ -1591,7 +1605,7 @@ if( pTab->nCol<(sizeof(Bitmask)*8) ){ Bitmask b = pTabItem->colUsed; int n = 0; - for(; b; b=b>>1, n++); + for(; b; b=b>>1, n++){} sqlite3VdbeChangeP2(v, sqlite3VdbeCurrentAddr(v)-1, n); assert( n<=pTab->nCol ); }