# # # rename "sqlite/limits.h" # to "sqlite/sqliteLimit.h" # # patch "sqlite/alter.c" # from [1b1deeb97446ed87f2fa17a3eb6236548841a348] # to [24c81ed6734304326922d42430567d1ee368c81d] # # patch "sqlite/analyze.c" # from [e8fcb1c35ace8418615eb18d9601f321ac86b2ec] # to [8d345472e0f4e44fc88f5cf489c16dcb77904525] # # patch "sqlite/btree.c" # from [bde03df933f8295e984b831779a318cc7c38f339] # to [c1cc6660b01d9e9f4329a9ab559d6a991c2be638] # # patch "sqlite/build.c" # from [50992d92e131a9aa9aa6657fb1ddc13e176fd70c] # to [59fd5782a728686148a6d30a5df283c177d22c1f] # # patch "sqlite/expr.c" # from [b68f1b208be50413b407da92bd7b0fce840999cf] # to [de9f55b1baed00199466028ad96967208d487798] # # patch "sqlite/func.c" # from [4668843e6f0d27653939e12fc32276fb8e38d21a] # to [6b45261aa2c514f642201b90493af68469c04af6] # # patch "sqlite/insert.c" # from [e595ca26805dfb3a9ebaabc28e7947c479f3b14d] # to [89d184422d85db0418e0f66032ccea3657078ecd] # # patch "sqlite/loadext.c" # from [afe4f4755dc49c36ef505748bbdddecb9f1d02a2] # to [6c24ee62adfe7fbfb2f2dd43ff18e5534b19010f] # # patch "sqlite/main.c" # from [797dc983716c1480f6af78a36be3add8806211a1] # to [65fc7de0b3c2e5b637c000ecf419c35de2525ef9] # # patch "sqlite/opcodes.c" # from [ecbfbd2a8f3a4e4a5b68075a4b15616b063cd461] # to [b93ef3d1434c2c01929aba8b16e30099a2a92fff] # # patch "sqlite/opcodes.h" # from [f6c44489cc16671f6f7702d99b6eefa64d08b5cd] # to [4f9886d41ea360432705b78f78b4e48524a471ee] # # patch "sqlite/os.h" # from [213dd1f8f7ab9159c04a893eadc0cdd52515df16] # to [cea2e179bb33f4fc09dbb9fcd51b2246544bd2db] # # patch "sqlite/os_os2.c" # from [2ce97909b926a598823f97338027dbec1dcf4165] # to [cba4e96fadb949076c717108fe0599d1a3c2e446] # # patch "sqlite/os_unix.c" # from [f2ccf2e9a925fc679faf7a8fe85700e0f13cf0e1] # to [4099d05dc4b01997e80a289f3c6a220688e5cff5] # # patch "sqlite/pager.c" # from [39352b58ee840cae715a4f0d20e446aa5e1445fe] # to [79a4587cc5e84a7ca1e211fa273bb2071a78447b] # # patch "sqlite/parse.c" # from [5fda95dfe0c8391ffc7826da7d5cea986bd66bee] # to [5c215aefe040e1ced6d1848371c454cfda7cda78] # # patch "sqlite/pragma.c" # from [0d25dad58bdfd6789943a10f1b9663c2eb85b96d] # to [7914a6b9ea05f158800116dfcae11e52ab8e39c4] # # patch "sqlite/prepare.c" # from [87c23644986b5e41a58bc76f05abebd899e00089] # to [609bb27860ce98ab39889fecc0998dfd8220891b] # # patch "sqlite/printf.c" # from [711908d6ff3385f9882df8ff405b9e0a2a4d04df] # to [9b3048d270e8bb2f8b910b491ac3aadece6cfab2] # # patch "sqlite/select.c" # from [33a258fc9c9dccb28ae2d3a02f1e1148d6433148] # to [3b167744fc375bddfddcef87feb18f5171737677] # # patch "sqlite/sqlite3.h" # from [2d972843072bbc136f0b0e5398e7a7aeedee9f87] # to [535f235f65b21ca83ff426b755a49e4ca3624dee] # # patch "sqlite/sqlite3ext.h" # from [7d0d363ea7327e817ef0dfe1b7eee1f171b72890] # to [a27bedc222df5e5f0f458ac99726d0483b953a91] # # patch "sqlite/sqliteInt.h" # from [208c40b6e11925a321ec159d889e0ec06b618359] # to [81183ae71162818bf60478e738ff68604128bb06] # # patch "sqlite/sqliteLimit.h" # from [31eba3f797d751a42dc81f2f509f8bb6056cfd81] # to [ee8903fcebd2a83f9c6192f1e869b6e09e927226] # # patch "sqlite/tokenize.c" # from [6cef9e6fc454d789a32c5b509ccb193a2b01977b] # to [0f0955ef7b8ab99ba2d3099faa89b80ccba3733a] # # patch "sqlite/update.c" # from [3359041db390a8f856d67272f299600e2104f350] # to [6b10becb6235ea314ed245fbfbf8b38755e3166e] # # patch "sqlite/util.c" # from [80cdf6b68d03b8f0ab3237a390842e039cff66c6] # to [9e81d417fc60bd2fe156f8f2317aa4845bc6cc90] # # patch "sqlite/vdbe.c" # from [68d7f4e47b07d89c4ea246ae87b69f8fb81f7da1] # to [a96ce3799f037b8f4e185a01823072320fd9ccb3] # # patch "sqlite/vdbeInt.h" # from [7d2bf163d6d4e815724a457f2216dd8e38c3955c] # to [c3514903cad9e36d6b3242be20261351d09db56c] # # patch "sqlite/vdbeapi.c" # from [3747e4c3bc3139ff688bb3df462b10e42c084d16] # to [fe3b713d5d37f8dfff1aa7546dae213a0e492f10] # # patch "sqlite/vdbeaux.c" # from [b4eda47b713aa8fbe70dce4922852fd48b919555] # to [ca1d673fd5e45fe9ba994391b11568c48a7e1b59] # # patch "sqlite/vdbeblob.c" # from [96f3572fdc45eda5be06e6372b612bc30742d9f0] # to [bb30b3e387c35ba869949494b2736aff97159470] # # patch "sqlite/vdbemem.c" # from [d86c25bbfe8102499ff7505fca44a779c68694d8] # to [ca4d3994507cb0a9504820293af69f5c778b4abd] # # patch "sqlite/vtab.c" # from [c5ebebf615b2f29499fbe97a584c4bb342632aa0] # to [60dc6d881c3049ec0e9f780e6beb953dbd78673d] # ============================================================ --- sqlite/alter.c 1b1deeb97446ed87f2fa17a3eb6236548841a348 +++ sqlite/alter.c 24c81ed6734304326922d42430567d1ee368c81d @@ -12,7 +12,7 @@ ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** -** $Id: alter.c,v 1.25 2007/05/15 14:34:32 drh Exp $ +** $Id: alter.c,v 1.27 2007/06/27 17:09:24 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -53,7 +53,7 @@ static void renameTableFunc( /* The principle used to locate the table name in the CREATE TABLE ** statement is that the table name is the first token that is immediatedly - ** followed by a left parenthesis - TK_LP. + ** followed by a left parenthesis - TK_LP - or "USING" TK_USING. */ if( zSql ){ do { @@ -74,7 +74,7 @@ static void renameTableFunc( len = sqlite3GetToken(zCsr, &token); } while( token==TK_SPACE ); assert( len>0 ); - } while( token!=TK_LP ); + } while( token!=TK_LP && token!=TK_USING ); zRet = sqlite3MPrintf("%.*s%Q%s", tname.z - zSql, zSql, zTableName, tname.z+tname.n); @@ -279,18 +279,13 @@ void sqlite3AlterRenameTable( #ifndef SQLITE_OMIT_TRIGGER char *zWhere = 0; /* Where clause to locate temp triggers */ #endif + int isVirtualRename = 0; /* True if this is a v-table with an xRename() */ if( sqlite3MallocFailed() ) goto exit_rename_table; assert( pSrc->nSrc==1 ); pTab = sqlite3LocateTable(pParse, pSrc->a[0].zName, pSrc->a[0].zDatabase); if( !pTab ) goto exit_rename_table; -#ifndef SQLITE_OMIT_VIRTUALTABLE - if( IsVirtual(pTab) ){ - sqlite3ErrorMsg(pParse, "virtual tables may not be altered"); - goto exit_rename_table; - } -#endif iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); zDb = db->aDb[iDb].zName; @@ -325,17 +320,39 @@ void sqlite3AlterRenameTable( } #endif +#ifndef SQLITE_OMIT_VIRTUALTABLE + if( sqlite3ViewGetColumnNames(pParse, pTab) ){ + goto exit_rename_table; + } + if( IsVirtual(pTab) && pTab->pMod->pModule->xRename ){ + isVirtualRename = 1; + } +#endif + /* Begin a transaction and code the VerifyCookie for database iDb. ** Then modify the schema cookie (since the ALTER TABLE modifies the - ** schema). + ** schema). Open a statement transaction if the table is a virtual + ** table. */ v = sqlite3GetVdbe(pParse); if( v==0 ){ goto exit_rename_table; } - sqlite3BeginWriteOperation(pParse, 0, iDb); + sqlite3BeginWriteOperation(pParse, isVirtualRename, iDb); sqlite3ChangeCookie(db, v, iDb); + /* If this is a virtual table, invoke the xRename() function if + ** one is defined. The xRename() callback will modify the names + ** of any resources used by the v-table implementation (including other + ** SQLite tables) that are identified by the name of the virtual table. + */ +#ifndef SQLITE_OMIT_VIRTUALTABLE + if( isVirtualRename ){ + sqlite3VdbeOp3(v, OP_String8, 0, 0, zName, 0); + sqlite3VdbeOp3(v, OP_VRename, 0, 0, (const char*)pTab->pVtab, P3_VTAB); + } +#endif + /* figure out how many UTF-8 characters are in zName */ zTabName = pTab->zName; nTabName = sqlite3Utf8CharLen(zTabName, -1); ============================================================ --- sqlite/analyze.c e8fcb1c35ace8418615eb18d9601f321ac86b2ec +++ sqlite/analyze.c 8d345472e0f4e44fc88f5cf489c16dcb77904525 @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code associated with the ANALYZE command. ** -** @(#) $Id: analyze.c,v 1.18 2007/05/12 12:08:51 drh Exp $ +** @(#) $Id: analyze.c,v 1.19 2007/06/20 13:37:31 drh Exp $ */ #ifndef SQLITE_OMIT_ANALYZE #include "sqliteInt.h" @@ -174,7 +174,7 @@ static void analyzeOneTable( /* Store the results. ** - ** The result is a single row of the sqlite_stmt1 table. The first + ** The result is a single row of the sqlite_stat1 table. The first ** two columns are the names of the table and index. The third column ** is a string composed of a list of integer statistics about the ** index. The first integer in the list is the total number of entires ============================================================ --- sqlite/btree.c bde03df933f8295e984b831779a318cc7c38f339 +++ sqlite/btree.c c1cc6660b01d9e9f4329a9ab559d6a991c2be638 @@ -9,7 +9,7 @@ ** May you share freely, never taking more than you give. ** ************************************************************************* -** $Id: btree.c,v 1.388 2007/05/24 09:20:16 danielk1977 Exp $ +** $Id: btree.c,v 1.392 2007/06/26 01:04:49 drh Exp $ ** ** This file implements a external (disk-based) database using BTrees. ** See the header comment on "btreeInt.h" for additional information. @@ -422,9 +422,8 @@ u8 *sqlite3BtreeFindCell(MemPage *pPage, #define findCell(pPage, iCell) \ ((pPage)->aData + get2byte(&(pPage)->aData[(pPage)->cellOffset+2*(iCell)])) u8 *sqlite3BtreeFindCell(MemPage *pPage, int iCell){ - u8 *data = pPage->aData; assert( iCell>=0 ); - assert( iCellhdrOffset+3]) ); + assert( iCellaData[pPage->hdrOffset+3]) ); return findCell(pPage, iCell); } @@ -1139,6 +1138,7 @@ int sqlite3BtreeOpen( pBt->pageSizeFixed = 1; #ifndef SQLITE_OMIT_AUTOVACUUM pBt->autoVacuum = (get4byte(&zDbHeader[36 + 4*4])?1:0); + pBt->incrVacuum = (get4byte(&zDbHeader[36 + 7*4])?1:0); #endif } pBt->usableSize = pBt->pageSize - nReserve; @@ -1362,12 +1362,10 @@ int sqlite3BtreeSetAutoVacuum(Btree *p, #else BtShared *pBt = p->pBt; int av = (autoVacuum?1:0); - int iv = (autoVacuum==BTREE_AUTOVACUUM_INCR?1:0); if( pBt->pageSizeFixed && av!=pBt->autoVacuum ){ return SQLITE_READONLY; } pBt->autoVacuum = av; - pBt->incrVacuum = iv; return SQLITE_OK; #endif } @@ -1436,6 +1434,7 @@ static int lockBtree(BtShared *pBt){ pBt->minLeafFrac = page1[23]; #ifndef SQLITE_OMIT_AUTOVACUUM pBt->autoVacuum = (get4byte(&page1[36 + 4*4])?1:0); + pBt->incrVacuum = (get4byte(&page1[36 + 7*4])?1:0); #endif } @@ -1544,7 +1543,9 @@ static int newDatabase(BtShared *pBt){ pBt->pageSizeFixed = 1; #ifndef SQLITE_OMIT_AUTOVACUUM assert( pBt->autoVacuum==1 || pBt->autoVacuum==0 ); + assert( pBt->incrVacuum==1 || pBt->incrVacuum==0 ); put4byte(&data[36 + 4*4], pBt->autoVacuum); + put4byte(&data[36 + 7*4], pBt->incrVacuum); #endif return SQLITE_OK; } @@ -2465,13 +2466,19 @@ void sqlite3BtreeReleaseTempCursor(BtCur } /* -** The GET_CELL_INFO() macro. Takes one argument, a pointer to a valid -** btree cursor (type BtCursor*). This macro makes sure the BtCursor.info -** field of the given cursor is valid. If it is not already valid, call +** Make sure the BtCursor* given in the argument has a valid +** BtCursor.info structure. If it is not already valid, call ** sqlite3BtreeParseCell() to fill it in. ** ** BtCursor.info is a cache of the information in the current cell. ** Using this cache reduces the number of calls to sqlite3BtreeParseCell(). +** +** 2007-06-25: There is a bug in some versions of MSVC that cause the +** compiler to crash when getCellInfo() is implemented as a macro. +** But there is a measureable speed advantage to using the macro on gcc +** (when less compiler optimizations like -Os or -O0 are used and the +** compiler is not doing agressive inlining.) So we use a real function +** for MSVC and a macro for everything else. Ticket #2457. */ #ifndef NDEBUG static void assertCellInfo(BtCursor *pCur){ @@ -2483,13 +2490,24 @@ void sqlite3BtreeReleaseTempCursor(BtCur #else #define assertCellInfo(x) #endif - -#define GET_CELL_INFO(pCur) \ - if( pCur->info.nSize==0 ) \ +#ifdef _MSC_VER + /* Use a real function in MSVC to work around bugs in that compiler. */ + static void getCellInfo(BtCursor *pCur){ + if( pCur->info.nSize==0 ){ + sqlite3BtreeParseCell(pCur->pPage, pCur->idx, &pCur->info); + }else{ + assertCellInfo(pCur); + } + } +#else /* if not _MSC_VER */ + /* Use a macro in all other compilers so that the function is inlined */ +#define getCellInfo(pCur) \ + if( pCur->info.nSize==0 ){ \ sqlite3BtreeParseCell(pCur->pPage, pCur->idx, &pCur->info); \ - else \ - assertCellInfo(pCur); - + }else{ \ + assertCellInfo(pCur); \ + } +#endif /* _MSC_VER */ /* ** Set *pSize to the size of the buffer needed to hold the value of @@ -2506,7 +2524,7 @@ int sqlite3BtreeKeySize(BtCursor *pCur, if( pCur->eState==CURSOR_INVALID ){ *pSize = 0; }else{ - GET_CELL_INFO(pCur); + getCellInfo(pCur); *pSize = pCur->info.nKey; } } @@ -2528,7 +2546,7 @@ int sqlite3BtreeDataSize(BtCursor *pCur, /* Not pointing at a valid entry - set *pSize to 0. */ *pSize = 0; }else{ - GET_CELL_INFO(pCur); + getCellInfo(pCur); *pSize = pCur->info.nData; } } @@ -2701,7 +2719,7 @@ static int accessPayload( assert( pCur->idx>=0 && pCur->idxnCell ); assert( offset>=0 ); - GET_CELL_INFO(pCur); + getCellInfo(pCur); aPayload = pCur->info.pCell + pCur->info.nHeader; nKey = (pPage->intKey ? 0 : pCur->info.nKey); @@ -2890,7 +2908,7 @@ static const unsigned char *fetchPayload assert( pCur->eState==CURSOR_VALID ); pPage = pCur->pPage; assert( pCur->idx>=0 && pCur->idxnCell ); - GET_CELL_INFO(pCur); + getCellInfo(pCur); aPayload = pCur->info.pCell; aPayload += pCur->info.nHeader; if( pPage->intKey ){ @@ -5677,6 +5695,11 @@ int sqlite3BtreeUpdateMeta(Btree *p, int rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); if( rc ) return rc; put4byte(&pP1[36 + idx*4], iMeta); + if( idx==7 ){ + assert( pBt->autoVacuum || iMeta==0 ); + assert( iMeta==0 || iMeta==1 ); + pBt->incrVacuum = iMeta; + } return SQLITE_OK; } ============================================================ --- sqlite/build.c 50992d92e131a9aa9aa6657fb1ddc13e176fd70c +++ sqlite/build.c 59fd5782a728686148a6d30a5df283c177d22c1f @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.432 2007/05/15 14:34:32 drh Exp $ +** $Id: build.c,v 1.433 2007/07/02 19:31:27 drh Exp $ */ #include "sqliteInt.h" #include @@ -2239,7 +2239,7 @@ void sqlite3CreateIndex( SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */ ExprList *pList, /* A list of columns to be indexed */ int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ - Token *pStart, /* The CREATE token that begins a CREATE TABLE statement */ + Token *pStart, /* The CREATE token that begins this statement */ Token *pEnd, /* The ")" that closes the CREATE INDEX statement */ int sortOrder, /* Sort order of primary key when pList==NULL */ int ifNotExist /* Omit error if index already exists */ ============================================================ --- sqlite/expr.c b68f1b208be50413b407da92bd7b0fce840999cf +++ sqlite/expr.c de9f55b1baed00199466028ad96967208d487798 @@ -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.298 2007/06/15 16:37:29 danielk1977 Exp $ +** $Id: expr.c,v 1.300 2007/06/25 16:29:34 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -71,8 +71,10 @@ CollSeq *sqlite3ExprCollSeq(Parse *pPars CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){ CollSeq *pColl = 0; if( pExpr ){ + int op; pColl = pExpr->pColl; - if( pExpr->op==TK_CAST && !pColl ){ + op = pExpr->op; + if( (op==TK_CAST || op==TK_UPLUS) && !pColl ){ return sqlite3ExprCollSeq(pParse, pExpr->pLeft); } } @@ -1152,6 +1154,7 @@ static int lookupName( memcpy(pExpr, pDup, sizeof(*pExpr)); sqliteFree(pDup); cnt = 1; + pMatch = 0; assert( zTab==0 && zDb==0 ); goto lookupname_end_2; } ============================================================ --- sqlite/func.c 4668843e6f0d27653939e12fc32276fb8e38d21a +++ sqlite/func.c 6b45261aa2c514f642201b90493af68469c04af6 @@ -16,7 +16,7 @@ ** sqliteRegisterBuildinFunctions() found at the bottom of the file. ** All other code has file scope. ** -** $Id: func.c,v 1.160 2007/06/07 19:08:33 drh Exp $ +** $Id: func.c,v 1.161 2007/06/22 15:21:16 danielk1977 Exp $ */ #include "sqliteInt.h" #include @@ -1410,7 +1410,13 @@ void sqlite3RegisterBuiltinFunctions(sql } } sqlite3RegisterDateTimeFunctions(db); - sqlite3_overload_function(db, "MATCH", 2); + if( !sqlite3MallocFailed() ){ + int rc = sqlite3_overload_function(db, "MATCH", 2); + assert( rc==SQLITE_NOMEM || rc==SQLITE_OK ); + if( rc==SQLITE_NOMEM ){ + sqlite3FailedMalloc(); + } + } #ifdef SQLITE_SSE (void)sqlite3SseFunctions(db); #endif ============================================================ --- sqlite/insert.c e595ca26805dfb3a9ebaabc28e7947c479f3b14d +++ sqlite/insert.c 89d184422d85db0418e0f66032ccea3657078ecd @@ -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.186 2007/05/04 13:15:56 drh Exp $ +** $Id: insert.c,v 1.187 2007/06/26 10:38:55 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -349,6 +349,8 @@ void sqlite3Insert( int appendFlag = 0; /* True if the insert is likely to be an append */ int iDb; + int nHidden = 0; + #ifndef SQLITE_OMIT_TRIGGER int isView; /* True if attempting to insert into a view */ int triggers_exist = 0; /* True if there are FOR EACH ROW triggers */ @@ -525,7 +527,12 @@ void sqlite3Insert( /* Make sure the number of columns in the source data matches the number ** of columns to be inserted into the table. */ - if( pColumn==0 && nColumn && nColumn!=pTab->nCol ){ + if( IsVirtual(pTab) ){ + for(i=0; inCol; i++){ + nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0); + } + } + if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){ sqlite3ErrorMsg(pParse, "table %S has %d columns but %d values were supplied", pTabList, 0, pTab->nCol, nColumn); @@ -640,6 +647,11 @@ void sqlite3Insert( sqlite3VdbeAddOp(v, OP_MustBeInt, 0, 0); } + /* Cannot have triggers on a virtual table. If it were possible, + ** this block would have to account for hidden column. + */ + assert(!IsVirtual(pTab)); + /* Create the new column data */ for(i=0; inCol; i++){ @@ -732,6 +744,7 @@ void sqlite3Insert( /* Push onto the stack, data for all columns of the new entry, beginning ** with the first column. */ + nHidden = 0; for(i=0; inCol; i++){ if( i==pTab->iPKey ){ /* The value of the INTEGER PRIMARY KEY column is always a NULL. @@ -742,13 +755,19 @@ void sqlite3Insert( continue; } if( pColumn==0 ){ - j = i; + if( IsHiddenColumn(&pTab->aCol[i]) ){ + assert( IsVirtual(pTab) ); + j = -1; + nHidden++; + }else{ + j = i - nHidden; + } }else{ for(j=0; jnId; j++){ if( pColumn->a[j].idx==i ) break; } } - if( nColumn==0 || (pColumn && j>=pColumn->nId) ){ + if( j<0 || nColumn==0 || (pColumn && j>=pColumn->nId) ){ sqlite3ExprCode(pParse, pTab->aCol[i].pDflt); }else if( useTempTable ){ sqlite3VdbeAddOp(v, OP_Column, srcTab, j); ============================================================ --- sqlite/loadext.c afe4f4755dc49c36ef505748bbdddecb9f1d02a2 +++ sqlite/loadext.c 6c24ee62adfe7fbfb2f2dd43ff18e5534b19010f @@ -76,6 +76,7 @@ #ifdef SQLITE_OMIT_VIRTUALTABLE # define sqlite3_create_module 0 +# define sqlite3_create_module_v2 0 # define sqlite3_declare_vtab 0 #endif @@ -240,6 +241,12 @@ const sqlite3_api_routines sqlite3_apis sqlite3_prepare_v2, sqlite3_prepare16_v2, sqlite3_clear_bindings, + + /* + ** Added for 3.4.1 + */ + sqlite3_create_module_v2, + }; /* ============================================================ --- sqlite/main.c 797dc983716c1480f6af78a36be3add8806211a1 +++ sqlite/main.c 65fc7de0b3c2e5b637c000ecf419c35de2525ef9 @@ -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.376 2007/05/08 20:37:39 drh Exp $ +** $Id: main.c,v 1.377 2007/06/22 15:21:16 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -194,6 +194,9 @@ int sqlite3_close(sqlite3 *db){ #ifndef SQLITE_OMIT_VIRTUALTABLE for(i=sqliteHashFirst(&db->aModule); i; i=sqliteHashNext(i)){ Module *pMod = (Module *)sqliteHashData(i); + if( pMod->xDestroy ){ + pMod->xDestroy(pMod->pAux); + } sqliteFree(pMod); } sqlite3HashClear(&db->aModule); @@ -986,41 +989,47 @@ static int openDatabase( db->aDb[1].safety_level = 1; #endif + db->magic = SQLITE_MAGIC_OPEN; + if( sqlite3MallocFailed() ){ + goto opendb_out; + } + /* Register all built-in functions, but do not attempt to read the ** database schema yet. This is delayed until the first time the database ** is accessed. */ - if( !sqlite3MallocFailed() ){ - sqlite3Error(db, SQLITE_OK, 0); - sqlite3RegisterBuiltinFunctions(db); - } - db->magic = SQLITE_MAGIC_OPEN; + sqlite3Error(db, SQLITE_OK, 0); + sqlite3RegisterBuiltinFunctions(db); /* Load automatic extensions - extensions that have been registered ** using the sqlite3_automatic_extension() API. */ (void)sqlite3AutoLoadExtensions(db); + if( sqlite3_errcode(db)!=SQLITE_OK ){ + goto opendb_out; + } #ifdef SQLITE_ENABLE_FTS1 - { + if( !sqlite3MallocFailed() ){ extern int sqlite3Fts1Init(sqlite3*); - sqlite3Fts1Init(db); + rc = sqlite3Fts1Init(db); } #endif #ifdef SQLITE_ENABLE_FTS2 - { + if( !sqlite3MallocFailed() && rc==SQLITE_OK ){ extern int sqlite3Fts2Init(sqlite3*); - sqlite3Fts2Init(db); + rc = sqlite3Fts2Init(db); } #endif #ifdef SQLITE_ENABLE_ICU - if( !sqlite3MallocFailed() ){ + if( !sqlite3MallocFailed() && rc==SQLITE_OK ){ extern int sqlite3IcuInit(sqlite3*); - sqlite3IcuInit(db); + rc = sqlite3IcuInit(db); } #endif + sqlite3Error(db, rc, 0); /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking ============================================================ --- sqlite/opcodes.c ecbfbd2a8f3a4e4a5b68075a4b15616b063cd461 +++ sqlite/opcodes.c b93ef3d1434c2c01929aba8b16e30099a2a92fff @@ -29,43 +29,43 @@ const char *const sqlite3OpcodeNames[] = /* 25 */ "Variable", /* 26 */ "String", /* 27 */ "RealAffinity", - /* 28 */ "ParseSchema", - /* 29 */ "VOpen", - /* 30 */ "Close", - /* 31 */ "CreateIndex", - /* 32 */ "IsUnique", - /* 33 */ "NotFound", - /* 34 */ "Int64", - /* 35 */ "MustBeInt", - /* 36 */ "Halt", - /* 37 */ "Rowid", - /* 38 */ "IdxLT", - /* 39 */ "AddImm", - /* 40 */ "Statement", - /* 41 */ "RowData", - /* 42 */ "MemMax", - /* 43 */ "Push", - /* 44 */ "NotExists", - /* 45 */ "MemIncr", - /* 46 */ "Gosub", - /* 47 */ "Integer", - /* 48 */ "MemInt", - /* 49 */ "Prev", - /* 50 */ "VColumn", - /* 51 */ "CreateTable", - /* 52 */ "Last", - /* 53 */ "IncrVacuum", - /* 54 */ "IdxRowid", - /* 55 */ "MakeIdxRec", - /* 56 */ "ResetCount", - /* 57 */ "FifoWrite", - /* 58 */ "Callback", - /* 59 */ "ContextPush", + /* 28 */ "VRename", + /* 29 */ "ParseSchema", + /* 30 */ "VOpen", + /* 31 */ "Close", + /* 32 */ "CreateIndex", + /* 33 */ "IsUnique", + /* 34 */ "NotFound", + /* 35 */ "Int64", + /* 36 */ "MustBeInt", + /* 37 */ "Halt", + /* 38 */ "Rowid", + /* 39 */ "IdxLT", + /* 40 */ "AddImm", + /* 41 */ "Statement", + /* 42 */ "RowData", + /* 43 */ "MemMax", + /* 44 */ "Push", + /* 45 */ "NotExists", + /* 46 */ "MemIncr", + /* 47 */ "Gosub", + /* 48 */ "Integer", + /* 49 */ "MemInt", + /* 50 */ "Prev", + /* 51 */ "VColumn", + /* 52 */ "CreateTable", + /* 53 */ "Last", + /* 54 */ "IncrVacuum", + /* 55 */ "IdxRowid", + /* 56 */ "MakeIdxRec", + /* 57 */ "ResetCount", + /* 58 */ "FifoWrite", + /* 59 */ "Callback", /* 60 */ "Or", /* 61 */ "And", - /* 62 */ "DropTrigger", - /* 63 */ "DropIndex", - /* 64 */ "IdxGE", + /* 62 */ "ContextPush", + /* 63 */ "DropTrigger", + /* 64 */ "DropIndex", /* 65 */ "IsNull", /* 66 */ "NotNull", /* 67 */ "Ne", @@ -74,7 +74,7 @@ const char *const sqlite3OpcodeNames[] = /* 70 */ "Le", /* 71 */ "Lt", /* 72 */ "Ge", - /* 73 */ "IdxDelete", + /* 73 */ "IdxGE", /* 74 */ "BitAnd", /* 75 */ "BitOr", /* 76 */ "ShiftLeft", @@ -85,59 +85,59 @@ const char *const sqlite3OpcodeNames[] = /* 81 */ "Divide", /* 82 */ "Remainder", /* 83 */ "Concat", - /* 84 */ "Vacuum", + /* 84 */ "IdxDelete", /* 85 */ "Negative", - /* 86 */ "MoveLe", + /* 86 */ "Vacuum", /* 87 */ "BitNot", /* 88 */ "String8", - /* 89 */ "IfNot", - /* 90 */ "DropTable", - /* 91 */ "MakeRecord", - /* 92 */ "Delete", - /* 93 */ "AggFinal", - /* 94 */ "Dup", - /* 95 */ "Goto", - /* 96 */ "TableLock", - /* 97 */ "FifoRead", - /* 98 */ "Clear", - /* 99 */ "IdxGT", - /* 100 */ "MoveLt", - /* 101 */ "VerifyCookie", - /* 102 */ "AggStep", - /* 103 */ "Pull", - /* 104 */ "SetNumColumns", - /* 105 */ "AbsValue", - /* 106 */ "Transaction", - /* 107 */ "VFilter", - /* 108 */ "VDestroy", - /* 109 */ "ContextPop", - /* 110 */ "Next", - /* 111 */ "IdxInsert", - /* 112 */ "Distinct", - /* 113 */ "Insert", - /* 114 */ "Destroy", - /* 115 */ "ReadCookie", - /* 116 */ "ForceInt", - /* 117 */ "LoadAnalysis", - /* 118 */ "Explain", - /* 119 */ "IfMemZero", - /* 120 */ "OpenPseudo", - /* 121 */ "OpenEphemeral", - /* 122 */ "Null", - /* 123 */ "Blob", - /* 124 */ "MemStore", + /* 89 */ "MoveLe", + /* 90 */ "IfNot", + /* 91 */ "DropTable", + /* 92 */ "MakeRecord", + /* 93 */ "Delete", + /* 94 */ "AggFinal", + /* 95 */ "Dup", + /* 96 */ "Goto", + /* 97 */ "TableLock", + /* 98 */ "FifoRead", + /* 99 */ "Clear", + /* 100 */ "IdxGT", + /* 101 */ "MoveLt", + /* 102 */ "VerifyCookie", + /* 103 */ "AggStep", + /* 104 */ "Pull", + /* 105 */ "SetNumColumns", + /* 106 */ "AbsValue", + /* 107 */ "Transaction", + /* 108 */ "VFilter", + /* 109 */ "VDestroy", + /* 110 */ "ContextPop", + /* 111 */ "Next", + /* 112 */ "IdxInsert", + /* 113 */ "Distinct", + /* 114 */ "Insert", + /* 115 */ "Destroy", + /* 116 */ "ReadCookie", + /* 117 */ "ForceInt", + /* 118 */ "LoadAnalysis", + /* 119 */ "Explain", + /* 120 */ "IfMemZero", + /* 121 */ "OpenPseudo", + /* 122 */ "OpenEphemeral", + /* 123 */ "Null", + /* 124 */ "Blob", /* 125 */ "Real", /* 126 */ "HexBlob", - /* 127 */ "Rewind", - /* 128 */ "MoveGe", - /* 129 */ "VBegin", - /* 130 */ "VUpdate", - /* 131 */ "VCreate", - /* 132 */ "MemMove", - /* 133 */ "MemNull", - /* 134 */ "Found", - /* 135 */ "NullRow", - /* 136 */ "NotUsed_136", + /* 127 */ "MemStore", + /* 128 */ "Rewind", + /* 129 */ "MoveGe", + /* 130 */ "VBegin", + /* 131 */ "VUpdate", + /* 132 */ "VCreate", + /* 133 */ "MemMove", + /* 134 */ "MemNull", + /* 135 */ "Found", + /* 136 */ "NullRow", /* 137 */ "NotUsed_137", /* 138 */ "ToText", /* 139 */ "ToBlob", ============================================================ --- sqlite/opcodes.h f6c44489cc16671f6f7702d99b6eefa64d08b5cd +++ sqlite/opcodes.h 4f9886d41ea360432705b78f78b4e48524a471ee @@ -38,123 +38,123 @@ #define OP_Variable 25 #define OP_String 26 #define OP_RealAffinity 27 -#define OP_ParseSchema 28 -#define OP_VOpen 29 -#define OP_Close 30 -#define OP_CreateIndex 31 -#define OP_IsUnique 32 -#define OP_NotFound 33 -#define OP_Int64 34 -#define OP_MustBeInt 35 -#define OP_Halt 36 -#define OP_Rowid 37 -#define OP_IdxLT 38 -#define OP_AddImm 39 -#define OP_Statement 40 -#define OP_RowData 41 -#define OP_MemMax 42 -#define OP_Push 43 +#define OP_VRename 28 +#define OP_ParseSchema 29 +#define OP_VOpen 30 +#define OP_Close 31 +#define OP_CreateIndex 32 +#define OP_IsUnique 33 +#define OP_NotFound 34 +#define OP_Int64 35 +#define OP_MustBeInt 36 +#define OP_Halt 37 +#define OP_Rowid 38 +#define OP_IdxLT 39 +#define OP_AddImm 40 +#define OP_Statement 41 +#define OP_RowData 42 +#define OP_MemMax 43 +#define OP_Push 44 #define OP_Or 60 /* same as TK_OR */ -#define OP_NotExists 44 -#define OP_MemIncr 45 -#define OP_Gosub 46 +#define OP_NotExists 45 +#define OP_MemIncr 46 +#define OP_Gosub 47 #define OP_Divide 81 /* same as TK_SLASH */ -#define OP_Integer 47 +#define OP_Integer 48 #define OP_ToNumeric 140 /* same as TK_TO_NUMERIC*/ -#define OP_MemInt 48 -#define OP_Prev 49 +#define OP_MemInt 49 +#define OP_Prev 50 #define OP_Concat 83 /* same as TK_CONCAT */ #define OP_BitAnd 74 /* same as TK_BITAND */ -#define OP_VColumn 50 -#define OP_CreateTable 51 -#define OP_Last 52 +#define OP_VColumn 51 +#define OP_CreateTable 52 +#define OP_Last 53 #define OP_IsNull 65 /* same as TK_ISNULL */ -#define OP_IncrVacuum 53 -#define OP_IdxRowid 54 -#define OP_MakeIdxRec 55 +#define OP_IncrVacuum 54 +#define OP_IdxRowid 55 +#define OP_MakeIdxRec 56 #define OP_ShiftRight 77 /* same as TK_RSHIFT */ -#define OP_ResetCount 56 -#define OP_FifoWrite 57 -#define OP_Callback 58 -#define OP_ContextPush 59 -#define OP_DropTrigger 62 -#define OP_DropIndex 63 -#define OP_IdxGE 64 -#define OP_IdxDelete 73 -#define OP_Vacuum 84 -#define OP_MoveLe 86 -#define OP_IfNot 89 -#define OP_DropTable 90 -#define OP_MakeRecord 91 +#define OP_ResetCount 57 +#define OP_FifoWrite 58 +#define OP_Callback 59 +#define OP_ContextPush 62 +#define OP_DropTrigger 63 +#define OP_DropIndex 64 +#define OP_IdxGE 73 +#define OP_IdxDelete 84 +#define OP_Vacuum 86 +#define OP_MoveLe 89 +#define OP_IfNot 90 +#define OP_DropTable 91 +#define OP_MakeRecord 92 #define OP_ToBlob 139 /* same as TK_TO_BLOB */ -#define OP_Delete 92 -#define OP_AggFinal 93 +#define OP_Delete 93 +#define OP_AggFinal 94 #define OP_ShiftLeft 76 /* same as TK_LSHIFT */ -#define OP_Dup 94 -#define OP_Goto 95 -#define OP_TableLock 96 -#define OP_FifoRead 97 -#define OP_Clear 98 -#define OP_IdxGT 99 -#define OP_MoveLt 100 +#define OP_Dup 95 +#define OP_Goto 96 +#define OP_TableLock 97 +#define OP_FifoRead 98 +#define OP_Clear 99 +#define OP_IdxGT 100 +#define OP_MoveLt 101 #define OP_Le 70 /* same as TK_LE */ -#define OP_VerifyCookie 101 -#define OP_AggStep 102 -#define OP_Pull 103 +#define OP_VerifyCookie 102 +#define OP_AggStep 103 +#define OP_Pull 104 #define OP_ToText 138 /* same as TK_TO_TEXT */ #define OP_Not 16 /* same as TK_NOT */ #define OP_ToReal 142 /* same as TK_TO_REAL */ -#define OP_SetNumColumns 104 -#define OP_AbsValue 105 -#define OP_Transaction 106 -#define OP_VFilter 107 +#define OP_SetNumColumns 105 +#define OP_AbsValue 106 +#define OP_Transaction 107 +#define OP_VFilter 108 #define OP_Negative 85 /* same as TK_UMINUS */ #define OP_Ne 67 /* same as TK_NE */ -#define OP_VDestroy 108 -#define OP_ContextPop 109 +#define OP_VDestroy 109 +#define OP_ContextPop 110 #define OP_BitOr 75 /* same as TK_BITOR */ -#define OP_Next 110 -#define OP_IdxInsert 111 -#define OP_Distinct 112 +#define OP_Next 111 +#define OP_IdxInsert 112 +#define OP_Distinct 113 #define OP_Lt 71 /* same as TK_LT */ -#define OP_Insert 113 -#define OP_Destroy 114 -#define OP_ReadCookie 115 -#define OP_ForceInt 116 -#define OP_LoadAnalysis 117 -#define OP_Explain 118 -#define OP_IfMemZero 119 -#define OP_OpenPseudo 120 -#define OP_OpenEphemeral 121 -#define OP_Null 122 -#define OP_Blob 123 +#define OP_Insert 114 +#define OP_Destroy 115 +#define OP_ReadCookie 116 +#define OP_ForceInt 117 +#define OP_LoadAnalysis 118 +#define OP_Explain 119 +#define OP_IfMemZero 120 +#define OP_OpenPseudo 121 +#define OP_OpenEphemeral 122 +#define OP_Null 123 +#define OP_Blob 124 #define OP_Add 78 /* same as TK_PLUS */ -#define OP_MemStore 124 -#define OP_Rewind 127 -#define OP_MoveGe 128 -#define OP_VBegin 129 -#define OP_VUpdate 130 +#define OP_MemStore 127 +#define OP_Rewind 128 +#define OP_MoveGe 129 +#define OP_VBegin 130 +#define OP_VUpdate 131 #define OP_BitNot 87 /* same as TK_BITNOT */ -#define OP_VCreate 131 -#define OP_MemMove 132 -#define OP_MemNull 133 -#define OP_Found 134 -#define OP_NullRow 135 +#define OP_VCreate 132 +#define OP_MemMove 133 +#define OP_MemNull 134 +#define OP_Found 135 +#define OP_NullRow 136 /* The following opcode values are never used */ -#define OP_NotUsed_136 136 #define OP_NotUsed_137 137 /* Opcodes that are guaranteed to never push a value onto the stack ** contain a 1 their corresponding position of the following mask ** set. See the opcodeNoPush() function in vdbeaux.c */ #define NOPUSH_MASK_0 0xeeb4 -#define NOPUSH_MASK_1 0x796b -#define NOPUSH_MASK_2 0x7ddb -#define NOPUSH_MASK_3 0xff32 +#define NOPUSH_MASK_1 0xf96b +#define NOPUSH_MASK_2 0xfbb6 +#define NOPUSH_MASK_3 0xfe64 #define NOPUSH_MASK_4 0xffff -#define NOPUSH_MASK_5 0xb6f7 -#define NOPUSH_MASK_6 0xfdfd -#define NOPUSH_MASK_7 0x93b3 -#define NOPUSH_MASK_8 0x7ccf +#define NOPUSH_MASK_5 0x6ef7 +#define NOPUSH_MASK_6 0xfbfb +#define NOPUSH_MASK_7 0x8767 +#define NOPUSH_MASK_8 0x7d9f #define NOPUSH_MASK_9 0x0000 ============================================================ --- sqlite/os.h 213dd1f8f7ab9159c04a893eadc0cdd52515df16 +++ sqlite/os.h cea2e179bb33f4fc09dbb9fcd51b2246544bd2db @@ -40,7 +40,7 @@ # define OS_WIN 1 # define OS_UNIX 0 # define OS_OS2 0 -# elif defined(_EMX_) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) +# elif defined(__EMX__) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) # define OS_WIN 0 # define OS_UNIX 0 # define OS_OS2 1 @@ -67,11 +67,15 @@ # include # define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) #elif OS_OS2 +# if (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && defined(OS2_HIGH_MEMORY) +# include /* has to be included before os2.h for linking to work */ +# endif # define INCL_DOSDATETIME # define INCL_DOSFILEMGR # define INCL_DOSERRORS # define INCL_DOSMISC # define INCL_DOSPROCESS +# define INCL_DOSMODULEMGR # include # define SQLITE_TEMPNAME_SIZE (CCHMAXPATHCOMP) #else ============================================================ --- sqlite/os_os2.c 2ce97909b926a598823f97338027dbec1dcf4165 +++ sqlite/os_os2.c cba4e96fadb949076c717108fe0599d1a3c2e446 @@ -13,11 +13,6 @@ ** This file contains code that is specific to OS/2. */ -#if (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && defined(OS2_HIGH_MEMORY) -/* os2safe.h has to be included before os2.h, needed for high mem */ -#include -#endif - #include "sqliteInt.h" #include "os.h" @@ -166,7 +161,7 @@ int sqlite3Os2OpenExclusive( const char f.delOnClose = delFlag ? 1 : 0; f.pathToDel = delFlag ? sqlite3OsFullPathname( zFilename ) : NULL; OpenCounter( +1 ); - if( delFlag ) DosForceDelete( sqlite3OsFullPathname( zFilename ) ); + if( delFlag ) DosForceDelete( (PSZ)sqlite3OsFullPathname( zFilename ) ); OSTRACE3( "OPEN EX %d \"%s\"\n", hf, sqlite3OsFullPathname ( zFilename ) ); return allocateOs2File( &f, pld ); } @@ -235,12 +230,12 @@ int sqlite3Os2TempFileName( char *zBuf ) "0123456789"; int i, j; PSZ zTempPath = 0; - if( DosScanEnv( "TEMP", &zTempPath ) ){ - if( DosScanEnv( "TMP", &zTempPath ) ){ - if( DosScanEnv( "TMPDIR", &zTempPath ) ){ + if( DosScanEnv( (PSZ)"TEMP", &zTempPath ) ){ + if( DosScanEnv( (PSZ)"TMP", &zTempPath ) ){ + if( DosScanEnv( (PSZ)"TMPDIR", &zTempPath ) ){ ULONG ulDriveNum = 0, ulDriveMap = 0; DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap ); - sprintf( zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) ); + sprintf( (char*)zTempPath, "%c:", (char)( 'A' + ulDriveNum - 1 ) ); } } } @@ -269,7 +264,7 @@ int os2Close( OsFile **pld ){ rc = DosClose( pFile->h ); pFile->locktype = NO_LOCK; if( pFile->delOnClose != 0 ){ - rc = DosForceDelete( pFile->pathToDel ); + rc = DosForceDelete( (PSZ)pFile->pathToDel ); } *pld = 0; OpenCounter( -1 ); @@ -291,7 +286,7 @@ int os2Read( OsFile *id, void *pBuf, int DosRead( ((os2File*)id)->h, pBuf, amt, &got ); if (got == (ULONG)amt) return SQLITE_OK; - else if (got < 0) + else if (got == 0) return SQLITE_IOERR_READ; else { memset(&((char*)pBuf)[got], 0, amt-got); @@ -687,16 +682,22 @@ char *sqlite3Os2FullPathname( const char if( strchr(zRelative, ':') ){ sqlite3SetString( &zFull, zRelative, (char*)0 ); }else{ - char zBuff[SQLITE_TEMPNAME_SIZE - 2] = {0}; - char zDrive[1] = {0}; - ULONG cbzFullLen = SQLITE_TEMPNAME_SIZE; ULONG ulDriveNum = 0; ULONG ulDriveMap = 0; - DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap ); - DosQueryCurrentDir( 0L, zBuff, &cbzFullLen ); - zFull = sqliteMalloc( cbzFullLen ); - sprintf( zDrive, "%c", (char)('A' + ulDriveNum - 1) ); - sqlite3SetString( &zFull, zDrive, ":\\", zBuff, "\\", zRelative, (char*)0 ); + ULONG cbzBufLen = SQLITE_TEMPNAME_SIZE; + char zDrive[2]; + char *zBuff; + + zBuff = sqliteMalloc( cbzBufLen ); + if( zBuff != 0 ){ + DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap ); + if( DosQueryCurrentDir( ulDriveNum, (PBYTE)zBuff, &cbzBufLen ) == NO_ERROR ){ + sprintf( zDrive, "%c", (char)('A' + ulDriveNum - 1) ); + sqlite3SetString( &zFull, zDrive, ":\\", zBuff, + "\\", zRelative, (char*)0 ); + } + sqliteFree( zBuff ); + } } return zFull; } @@ -798,7 +799,7 @@ void *sqlite3Os2Dlopen(const char *zFile UCHAR loadErr[256]; HMODULE hmod; APIRET rc; - rc = DosLoadModule(loadErr, sizeof(loadErr), zFilename, &hmod); + rc = DosLoadModule((PSZ)loadErr, sizeof(loadErr), zFilename, &hmod); if (rc != NO_ERROR) return 0; return (void*)hmod; } @@ -815,7 +816,7 @@ void *sqlite3Os2Dlsym(void *pHandle, con rc = DosQueryProcAddr((HMODULE)pHandle, 0L, _zSymbol, &pfn); } if (rc != NO_ERROR) return 0; - return pfn; + return (void *)pfn; } int sqlite3Os2Dlclose(void *pHandle){ return DosFreeModule((HMODULE)pHandle); @@ -871,8 +872,8 @@ void sqlite3Os2EnterMutex(){ ** code and what little there is executes quickly and without blocking. */ void sqlite3Os2EnterMutex(){ +#ifdef SQLITE_OS2_THREADS PTIB ptib; -#ifdef SQLITE_OS2_THREADS DosEnterCritSec(); DosGetInfoBlocks( &ptib, NULL ); mutexOwner = ptib->tib_ptib2->tib2_ultid; @@ -881,7 +882,9 @@ void sqlite3Os2LeaveMutex(){ inMutex = 1; } void sqlite3Os2LeaveMutex(){ +#ifdef SQLITE_OS2_THREADS PTIB ptib; +#endif assert( inMutex ); inMutex = 0; #ifdef SQLITE_OS2_THREADS ============================================================ --- sqlite/os_unix.c f2ccf2e9a925fc679faf7a8fe85700e0f13cf0e1 +++ sqlite/os_unix.c 4099d05dc4b01997e80a289f3c6a220688e5cff5 @@ -918,15 +918,19 @@ static int unixOpenDirectory( OsFile *id, const char *zDirname ){ + int h; unixFile *pFile = (unixFile*)id; assert( pFile!=0 ); SET_THREADID(pFile); assert( pFile->dirfd<0 ); - pFile->dirfd = open(zDirname, O_RDONLY|O_BINARY, 0); - if( pFile->dirfd<0 ){ + pFile->dirfd = h = open(zDirname, O_RDONLY|O_BINARY, 0); + if( h<0 ){ return SQLITE_CANTOPEN; } - OSTRACE3("OPENDIR %-3d %s\n", pFile->dirfd, zDirname); +#ifdef FD_CLOEXEC + fcntl(h, F_SETFD, fcntl(h, F_GETFD, 0) | FD_CLOEXEC); +#endif + OSTRACE3("OPENDIR %-3d %s\n", h, zDirname); return SQLITE_OK; } @@ -1271,7 +1275,7 @@ static int unixTruncate(OsFile *id, i64 static int unixTruncate(OsFile *id, i64 nByte){ int rc; assert( id ); - rc = ftruncate(((unixFile*)id)->h, nByte); + rc = ftruncate(((unixFile*)id)->h, (off_t)nByte); SimulateIOError( rc=1 ); if( rc ){ return SQLITE_IOERR_TRUNCATE; @@ -2577,6 +2581,9 @@ static int allocateUnixFile( unixFile f; int rc; +#ifdef FD_CLOEXEC + fcntl(h, F_SETFD, fcntl(h, F_GETFD, 0) | FD_CLOEXEC); +#endif memset(&f, 0, sizeof(f)); sqlite3OsEnterMutex(); rc = findLockInfo(h, &f.pLock, &f.pOpen); ============================================================ --- sqlite/pager.c 39352b58ee840cae715a4f0d20e446aa5e1445fe +++ sqlite/pager.c 79a4587cc5e84a7ca1e211fa273bb2071a78447b @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.348 2007/06/18 17:25:18 drh Exp $ +** @(#) $Id: pager.c,v 1.351 2007/07/20 00:33:36 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -551,17 +551,6 @@ static int write32bits(OsFile *fd, u32 v } /* -** Read a 32-bit integer at offset 'offset' from the page identified by -** page header 'p'. -*/ -static u32 retrieve32bits(PgHdr *p, int offset){ - unsigned char *ac; - ac = &((unsigned char*)PGHDR_TO_DATA(p))[offset]; - return sqlite3Get4byte(ac); -} - - -/* ** This function should be called when an error occurs within the pager ** code. The first argument is a pointer to the pager structure, the ** second the error-code about to be returned by a pager API function. @@ -3872,13 +3861,10 @@ static int pager_incr_changecounter(Page rc = sqlite3PagerWrite(pPgHdr); if( rc!=SQLITE_OK ) return rc; - /* Read the current value at byte 24. */ - change_counter = retrieve32bits(pPgHdr, 24); - /* Increment the value just read and write it back to byte 24. */ + change_counter = sqlite3Get4byte((u8*)pPager->dbFileVers); change_counter++; put32bits(((char*)PGHDR_TO_DATA(pPgHdr))+24, change_counter); - /* Release the page reference. */ sqlite3PagerUnref(pPgHdr); pPager->changeCountDone = 1; ============================================================ --- sqlite/parse.c 5fda95dfe0c8391ffc7826da7d5cea986bd66bee +++ sqlite/parse.c 5c215aefe040e1ced6d1848371c454cfda7cda78 @@ -179,402 +179,402 @@ static const YYACTIONTYPE yy_action[] = ** yy_default[] Default action for each state. */ static const YYACTIONTYPE yy_action[] = { - /* 0 */ 289, 898, 121, 585, 405, 169, 2, 435, 61, 61, + /* 0 */ 290, 898, 122, 585, 407, 170, 2, 437, 61, 61, /* 10 */ 61, 61, 517, 63, 63, 63, 63, 64, 64, 65, - /* 20 */ 65, 65, 66, 230, 387, 384, 420, 426, 68, 63, - /* 30 */ 63, 63, 63, 64, 64, 65, 65, 65, 66, 230, - /* 40 */ 443, 208, 392, 447, 60, 59, 294, 430, 431, 427, - /* 50 */ 427, 62, 62, 61, 61, 61, 61, 205, 63, 63, - /* 60 */ 63, 63, 64, 64, 65, 65, 65, 66, 230, 289, - /* 70 */ 368, 316, 435, 487, 205, 80, 67, 415, 69, 151, + /* 20 */ 65, 65, 66, 231, 445, 209, 422, 428, 68, 63, + /* 30 */ 63, 63, 63, 64, 64, 65, 65, 65, 66, 231, + /* 40 */ 389, 386, 394, 449, 60, 59, 295, 432, 433, 429, + /* 50 */ 429, 62, 62, 61, 61, 61, 61, 261, 63, 63, + /* 60 */ 63, 63, 64, 64, 65, 65, 65, 66, 231, 290, + /* 70 */ 491, 492, 437, 487, 206, 81, 67, 417, 69, 152, /* 80 */ 63, 63, 63, 63, 64, 64, 65, 65, 65, 66, - /* 90 */ 230, 515, 162, 410, 35, 420, 426, 443, 571, 58, - /* 100 */ 64, 64, 65, 65, 65, 66, 230, 393, 394, 417, - /* 110 */ 417, 417, 289, 60, 59, 294, 430, 431, 427, 427, - /* 120 */ 62, 62, 61, 61, 61, 61, 302, 63, 63, 63, - /* 130 */ 63, 64, 64, 65, 65, 65, 66, 230, 420, 426, - /* 140 */ 92, 65, 65, 65, 66, 230, 392, 456, 472, 67, - /* 150 */ 56, 69, 151, 169, 406, 435, 60, 59, 294, 430, - /* 160 */ 431, 427, 427, 62, 62, 61, 61, 61, 61, 247, + /* 90 */ 231, 67, 460, 69, 152, 422, 428, 571, 262, 58, + /* 100 */ 64, 64, 65, 65, 65, 66, 231, 395, 396, 419, + /* 110 */ 419, 419, 290, 60, 59, 295, 432, 433, 429, 429, + /* 120 */ 62, 62, 61, 61, 61, 61, 315, 63, 63, 63, + /* 130 */ 63, 64, 64, 65, 65, 65, 66, 231, 422, 428, + /* 140 */ 93, 65, 65, 65, 66, 231, 394, 231, 412, 34, + /* 150 */ 56, 296, 440, 441, 408, 486, 60, 59, 295, 432, + /* 160 */ 433, 429, 429, 62, 62, 61, 61, 61, 61, 488, /* 170 */ 63, 63, 63, 63, 64, 64, 65, 65, 65, 66, - /* 180 */ 230, 289, 569, 522, 292, 620, 111, 478, 515, 447, - /* 190 */ 230, 316, 403, 21, 67, 460, 69, 151, 66, 230, - /* 200 */ 568, 443, 208, 67, 224, 69, 151, 420, 426, 146, - /* 210 */ 147, 393, 394, 410, 41, 386, 148, 531, 2, 487, - /* 220 */ 435, 566, 232, 415, 289, 60, 59, 294, 430, 431, - /* 230 */ 427, 427, 62, 62, 61, 61, 61, 61, 316, 63, - /* 240 */ 63, 63, 63, 64, 64, 65, 65, 65, 66, 230, - /* 250 */ 420, 426, 486, 330, 211, 417, 417, 417, 359, 270, - /* 260 */ 410, 41, 378, 207, 362, 542, 245, 289, 60, 59, - /* 270 */ 294, 430, 431, 427, 427, 62, 62, 61, 61, 61, - /* 280 */ 61, 392, 63, 63, 63, 63, 64, 64, 65, 65, - /* 290 */ 65, 66, 230, 420, 426, 260, 299, 273, 522, 271, - /* 300 */ 522, 210, 370, 319, 223, 433, 433, 532, 21, 576, - /* 310 */ 21, 60, 59, 294, 430, 431, 427, 427, 62, 62, - /* 320 */ 61, 61, 61, 61, 191, 63, 63, 63, 63, 64, - /* 330 */ 64, 65, 65, 65, 66, 230, 261, 316, 239, 76, - /* 340 */ 289, 544, 299, 149, 482, 150, 393, 394, 178, 240, - /* 350 */ 569, 341, 344, 345, 404, 520, 445, 322, 165, 410, - /* 360 */ 28, 540, 346, 517, 248, 539, 420, 426, 568, 567, - /* 370 */ 161, 115, 238, 339, 243, 340, 173, 358, 272, 411, - /* 380 */ 821, 488, 79, 249, 60, 59, 294, 430, 431, 427, - /* 390 */ 427, 62, 62, 61, 61, 61, 61, 530, 63, 63, - /* 400 */ 63, 63, 64, 64, 65, 65, 65, 66, 230, 289, - /* 410 */ 248, 178, 465, 485, 341, 344, 345, 115, 238, 339, - /* 420 */ 243, 340, 173, 82, 316, 346, 316, 491, 492, 249, - /* 430 */ 565, 207, 152, 523, 489, 420, 426, 178, 529, 503, - /* 440 */ 341, 344, 345, 407, 472, 528, 410, 35, 410, 35, - /* 450 */ 171, 346, 198, 60, 59, 294, 430, 431, 427, 427, - /* 460 */ 62, 62, 61, 61, 61, 61, 411, 63, 63, 63, - /* 470 */ 63, 64, 64, 65, 65, 65, 66, 230, 289, 548, - /* 480 */ 579, 288, 502, 234, 411, 316, 411, 316, 296, 283, - /* 490 */ 298, 316, 445, 521, 165, 476, 172, 157, 421, 422, - /* 500 */ 457, 335, 457, 144, 420, 426, 366, 410, 35, 410, - /* 510 */ 36, 435, 1, 410, 49, 327, 392, 547, 193, 424, - /* 520 */ 425, 156, 60, 59, 294, 430, 431, 427, 427, 62, - /* 530 */ 62, 61, 61, 61, 61, 333, 63, 63, 63, 63, - /* 540 */ 64, 64, 65, 65, 65, 66, 230, 289, 423, 332, - /* 550 */ 452, 252, 411, 295, 438, 439, 297, 316, 349, 307, - /* 560 */ 231, 457, 453, 321, 438, 439, 392, 369, 266, 265, - /* 570 */ 189, 217, 392, 420, 426, 454, 435, 493, 205, 410, - /* 580 */ 49, 393, 394, 583, 889, 174, 889, 494, 545, 492, - /* 590 */ 392, 60, 59, 294, 430, 431, 427, 427, 62, 62, - /* 600 */ 61, 61, 61, 61, 411, 63, 63, 63, 63, 64, - /* 610 */ 64, 65, 65, 65, 66, 230, 289, 207, 586, 387, - /* 620 */ 384, 91, 10, 580, 336, 308, 392, 207, 367, 480, - /* 630 */ 316, 393, 394, 583, 888, 219, 888, 393, 394, 476, - /* 640 */ 291, 233, 420, 426, 481, 249, 410, 3, 434, 260, - /* 650 */ 317, 363, 410, 29, 448, 393, 394, 468, 260, 289, - /* 660 */ 60, 59, 294, 430, 431, 427, 427, 62, 62, 61, - /* 670 */ 61, 61, 61, 580, 63, 63, 63, 63, 64, 64, - /* 680 */ 65, 65, 65, 66, 230, 420, 426, 391, 312, 388, - /* 690 */ 555, 393, 394, 75, 204, 77, 395, 396, 397, 557, - /* 700 */ 357, 197, 289, 60, 59, 294, 430, 431, 427, 427, - /* 710 */ 62, 62, 61, 61, 61, 61, 316, 63, 63, 63, - /* 720 */ 63, 64, 64, 65, 65, 65, 66, 230, 420, 426, - /* 730 */ 319, 116, 433, 433, 319, 411, 433, 433, 410, 24, - /* 740 */ 319, 515, 433, 433, 515, 289, 60, 70, 294, 430, - /* 750 */ 431, 427, 427, 62, 62, 61, 61, 61, 61, 375, + /* 180 */ 231, 290, 255, 522, 293, 569, 112, 406, 520, 449, + /* 190 */ 329, 315, 405, 20, 437, 338, 517, 394, 530, 529, + /* 200 */ 503, 445, 209, 568, 567, 206, 528, 422, 428, 147, + /* 210 */ 148, 395, 396, 412, 41, 208, 149, 531, 370, 487, + /* 220 */ 259, 566, 257, 417, 290, 60, 59, 295, 432, 433, + /* 230 */ 429, 429, 62, 62, 61, 61, 61, 61, 315, 63, + /* 240 */ 63, 63, 63, 64, 64, 65, 65, 65, 66, 231, + /* 250 */ 422, 428, 445, 331, 212, 419, 419, 419, 361, 437, + /* 260 */ 412, 41, 395, 396, 364, 565, 208, 290, 60, 59, + /* 270 */ 295, 432, 433, 429, 429, 62, 62, 61, 61, 61, + /* 280 */ 61, 394, 63, 63, 63, 63, 64, 64, 65, 65, + /* 290 */ 65, 66, 231, 422, 428, 489, 298, 522, 472, 66, + /* 300 */ 231, 211, 472, 224, 409, 284, 532, 20, 447, 521, + /* 310 */ 166, 60, 59, 295, 432, 433, 429, 429, 62, 62, + /* 320 */ 61, 61, 61, 61, 472, 63, 63, 63, 63, 64, + /* 330 */ 64, 65, 65, 65, 66, 231, 207, 478, 315, 76, + /* 340 */ 290, 235, 298, 55, 482, 225, 395, 396, 179, 545, + /* 350 */ 492, 343, 346, 347, 67, 150, 69, 152, 337, 522, + /* 360 */ 412, 35, 348, 237, 249, 368, 422, 428, 576, 20, + /* 370 */ 162, 116, 239, 341, 244, 342, 174, 320, 440, 441, + /* 380 */ 412, 3, 79, 250, 60, 59, 295, 432, 433, 429, + /* 390 */ 429, 62, 62, 61, 61, 61, 61, 172, 63, 63, + /* 400 */ 63, 63, 64, 64, 65, 65, 65, 66, 231, 290, + /* 410 */ 249, 548, 232, 485, 508, 351, 315, 116, 239, 341, + /* 420 */ 244, 342, 174, 179, 315, 523, 343, 346, 347, 250, + /* 430 */ 218, 413, 153, 462, 509, 422, 428, 348, 412, 34, + /* 440 */ 463, 208, 175, 173, 158, 233, 412, 34, 336, 547, + /* 450 */ 447, 321, 166, 60, 59, 295, 432, 433, 429, 429, + /* 460 */ 62, 62, 61, 61, 61, 61, 413, 63, 63, 63, + /* 470 */ 63, 64, 64, 65, 65, 65, 66, 231, 290, 540, + /* 480 */ 333, 515, 502, 539, 454, 569, 300, 19, 329, 142, + /* 490 */ 315, 388, 315, 328, 2, 360, 455, 292, 481, 371, + /* 500 */ 267, 266, 250, 568, 422, 428, 586, 389, 386, 456, + /* 510 */ 206, 493, 412, 49, 412, 49, 301, 583, 889, 157, + /* 520 */ 889, 494, 60, 59, 295, 432, 433, 429, 429, 62, + /* 530 */ 62, 61, 61, 61, 61, 199, 63, 63, 63, 63, + /* 540 */ 64, 64, 65, 65, 65, 66, 231, 290, 315, 179, + /* 550 */ 436, 253, 343, 346, 347, 368, 151, 580, 306, 248, + /* 560 */ 307, 450, 75, 348, 77, 380, 208, 423, 424, 413, + /* 570 */ 412, 27, 317, 422, 428, 438, 1, 22, 583, 888, + /* 580 */ 394, 888, 542, 476, 318, 261, 435, 435, 426, 427, + /* 590 */ 413, 60, 59, 295, 432, 433, 429, 429, 62, 62, + /* 600 */ 61, 61, 61, 61, 326, 63, 63, 63, 63, 64, + /* 610 */ 64, 65, 65, 65, 66, 231, 290, 425, 580, 372, + /* 620 */ 219, 92, 515, 9, 334, 394, 555, 394, 454, 67, + /* 630 */ 394, 69, 152, 397, 398, 399, 318, 234, 435, 435, + /* 640 */ 455, 316, 422, 428, 297, 395, 396, 318, 430, 435, + /* 650 */ 435, 579, 289, 456, 220, 325, 5, 217, 544, 290, + /* 660 */ 60, 59, 295, 432, 433, 429, 429, 62, 62, 61, + /* 670 */ 61, 61, 61, 393, 63, 63, 63, 63, 64, 64, + /* 680 */ 65, 65, 65, 66, 231, 422, 428, 480, 311, 390, + /* 690 */ 395, 396, 395, 396, 205, 395, 396, 821, 271, 515, + /* 700 */ 248, 198, 290, 60, 59, 295, 432, 433, 429, 429, + /* 710 */ 62, 62, 61, 61, 61, 61, 468, 63, 63, 63, + /* 720 */ 63, 64, 64, 65, 65, 65, 66, 231, 422, 428, + /* 730 */ 169, 158, 261, 261, 302, 413, 274, 117, 272, 261, + /* 740 */ 515, 515, 261, 515, 190, 290, 60, 70, 295, 432, + /* 750 */ 433, 429, 429, 62, 62, 61, 61, 61, 61, 377, /* 760 */ 63, 63, 63, 63, 64, 64, 65, 65, 65, 66, - /* 770 */ 230, 420, 426, 538, 356, 538, 216, 260, 472, 303, - /* 780 */ 175, 176, 177, 254, 476, 515, 260, 383, 289, 5, - /* 790 */ 59, 294, 430, 431, 427, 427, 62, 62, 61, 61, - /* 800 */ 61, 61, 316, 63, 63, 63, 63, 64, 64, 65, - /* 810 */ 65, 65, 66, 230, 420, 426, 392, 236, 380, 247, - /* 820 */ 304, 258, 247, 256, 410, 33, 260, 558, 125, 467, - /* 830 */ 515, 416, 168, 157, 294, 430, 431, 427, 427, 62, - /* 840 */ 62, 61, 61, 61, 61, 306, 63, 63, 63, 63, - /* 850 */ 64, 64, 65, 65, 65, 66, 230, 72, 323, 452, - /* 860 */ 4, 153, 22, 247, 293, 305, 435, 559, 316, 382, - /* 870 */ 316, 453, 320, 72, 323, 316, 4, 366, 316, 180, - /* 880 */ 293, 393, 394, 20, 454, 141, 326, 316, 320, 325, - /* 890 */ 410, 53, 410, 52, 316, 411, 155, 410, 96, 447, - /* 900 */ 410, 94, 316, 500, 316, 325, 328, 469, 247, 410, - /* 910 */ 99, 444, 260, 411, 318, 447, 410, 100, 316, 74, - /* 920 */ 73, 467, 183, 260, 410, 110, 410, 112, 72, 314, - /* 930 */ 315, 435, 337, 415, 458, 74, 73, 479, 316, 377, - /* 940 */ 410, 17, 218, 19, 72, 314, 315, 72, 323, 415, - /* 950 */ 4, 205, 316, 274, 293, 316, 411, 466, 205, 409, - /* 960 */ 410, 97, 320, 408, 374, 417, 417, 417, 418, 419, - /* 970 */ 12, 376, 316, 206, 410, 34, 174, 410, 95, 325, - /* 980 */ 55, 417, 417, 417, 418, 419, 12, 310, 120, 447, - /* 990 */ 428, 159, 9, 260, 410, 25, 220, 221, 222, 102, - /* 1000 */ 441, 441, 316, 471, 409, 316, 475, 316, 408, 74, - /* 1010 */ 73, 436, 202, 23, 278, 455, 244, 13, 72, 314, - /* 1020 */ 315, 279, 316, 415, 410, 54, 316, 410, 113, 410, - /* 1030 */ 114, 291, 581, 200, 276, 547, 462, 497, 498, 199, - /* 1040 */ 316, 504, 201, 463, 410, 26, 316, 524, 410, 37, - /* 1050 */ 316, 474, 316, 170, 253, 417, 417, 417, 418, 419, - /* 1060 */ 12, 505, 410, 38, 510, 483, 316, 13, 410, 27, - /* 1070 */ 508, 582, 410, 39, 410, 40, 316, 255, 507, 506, - /* 1080 */ 512, 316, 125, 316, 511, 373, 275, 265, 410, 42, - /* 1090 */ 509, 290, 316, 251, 316, 125, 205, 257, 410, 43, - /* 1100 */ 316, 259, 316, 410, 44, 410, 30, 348, 316, 125, - /* 1110 */ 316, 353, 186, 316, 410, 31, 410, 45, 316, 543, - /* 1120 */ 379, 125, 410, 46, 410, 47, 316, 551, 264, 170, - /* 1130 */ 410, 48, 410, 32, 401, 410, 11, 552, 440, 89, - /* 1140 */ 410, 50, 301, 562, 578, 89, 287, 361, 410, 51, - /* 1150 */ 364, 365, 267, 268, 269, 554, 143, 564, 277, 324, - /* 1160 */ 280, 281, 575, 225, 442, 461, 464, 503, 241, 513, - /* 1170 */ 516, 550, 343, 160, 561, 390, 8, 313, 398, 399, - /* 1180 */ 400, 412, 82, 226, 331, 329, 81, 406, 57, 78, - /* 1190 */ 209, 167, 83, 459, 122, 414, 227, 334, 228, 338, - /* 1200 */ 300, 500, 103, 496, 246, 519, 514, 490, 495, 242, - /* 1210 */ 214, 518, 499, 229, 501, 413, 350, 533, 284, 525, - /* 1220 */ 526, 527, 235, 181, 473, 237, 285, 477, 182, 354, - /* 1230 */ 352, 184, 86, 185, 118, 535, 187, 546, 360, 190, - /* 1240 */ 129, 553, 139, 371, 372, 130, 215, 309, 560, 131, - /* 1250 */ 132, 133, 572, 577, 135, 573, 98, 574, 389, 262, - /* 1260 */ 402, 621, 536, 213, 101, 622, 432, 163, 164, 429, - /* 1270 */ 138, 71, 449, 437, 446, 140, 470, 154, 6, 450, - /* 1280 */ 7, 158, 166, 451, 14, 123, 13, 124, 484, 212, - /* 1290 */ 84, 342, 104, 105, 90, 250, 85, 117, 106, 347, - /* 1300 */ 179, 240, 351, 142, 534, 126, 18, 170, 93, 263, - /* 1310 */ 188, 107, 355, 286, 109, 127, 549, 541, 128, 119, - /* 1320 */ 537, 192, 15, 194, 195, 136, 196, 134, 556, 563, - /* 1330 */ 311, 137, 16, 108, 570, 203, 145, 385, 381, 282, - /* 1340 */ 584, 899, 899, 899, 899, 899, 87, 899, 88, + /* 770 */ 231, 422, 428, 382, 557, 303, 304, 248, 413, 318, + /* 780 */ 558, 435, 435, 559, 538, 358, 538, 385, 290, 194, + /* 790 */ 59, 295, 432, 433, 429, 429, 62, 62, 61, 61, + /* 800 */ 61, 61, 369, 63, 63, 63, 63, 64, 64, 65, + /* 810 */ 65, 65, 66, 231, 422, 428, 394, 273, 248, 248, + /* 820 */ 170, 246, 437, 413, 384, 365, 176, 177, 178, 467, + /* 830 */ 309, 121, 154, 126, 295, 432, 433, 429, 429, 62, + /* 840 */ 62, 61, 61, 61, 61, 315, 63, 63, 63, 63, + /* 850 */ 64, 64, 65, 65, 65, 66, 231, 72, 322, 175, + /* 860 */ 4, 315, 261, 315, 294, 261, 413, 412, 28, 315, + /* 870 */ 261, 315, 319, 72, 322, 315, 4, 418, 443, 443, + /* 880 */ 294, 395, 396, 412, 23, 412, 32, 437, 319, 324, + /* 890 */ 327, 412, 53, 412, 52, 315, 156, 412, 97, 449, + /* 900 */ 315, 192, 315, 275, 315, 324, 376, 469, 500, 315, + /* 910 */ 476, 277, 476, 163, 292, 449, 315, 412, 95, 74, + /* 920 */ 73, 467, 412, 100, 412, 101, 412, 111, 72, 313, + /* 930 */ 314, 412, 113, 417, 446, 74, 73, 479, 412, 16, + /* 940 */ 379, 315, 181, 465, 72, 313, 314, 72, 322, 417, + /* 950 */ 4, 206, 315, 184, 294, 315, 497, 498, 474, 206, + /* 960 */ 171, 339, 319, 412, 98, 419, 419, 419, 420, 421, + /* 970 */ 11, 359, 378, 305, 412, 33, 413, 412, 96, 324, + /* 980 */ 458, 419, 419, 419, 420, 421, 11, 413, 411, 449, + /* 990 */ 411, 160, 410, 315, 410, 466, 221, 222, 223, 103, + /* 1000 */ 83, 471, 315, 507, 506, 315, 620, 475, 315, 74, + /* 1010 */ 73, 245, 203, 21, 279, 412, 24, 437, 72, 313, + /* 1020 */ 314, 280, 315, 417, 412, 54, 505, 412, 114, 315, + /* 1030 */ 412, 115, 504, 201, 145, 547, 240, 510, 524, 200, + /* 1040 */ 315, 511, 202, 315, 412, 25, 315, 241, 315, 18, + /* 1050 */ 315, 412, 36, 315, 254, 419, 419, 419, 420, 421, + /* 1060 */ 11, 256, 412, 37, 258, 412, 26, 315, 412, 38, + /* 1070 */ 412, 39, 412, 40, 260, 412, 42, 315, 512, 315, + /* 1080 */ 126, 315, 437, 315, 187, 375, 276, 266, 265, 412, + /* 1090 */ 43, 291, 315, 252, 315, 126, 206, 581, 8, 412, + /* 1100 */ 44, 412, 29, 412, 30, 412, 45, 350, 363, 126, + /* 1110 */ 315, 543, 315, 126, 412, 46, 412, 47, 315, 355, + /* 1120 */ 381, 551, 315, 171, 552, 315, 90, 562, 578, 90, + /* 1130 */ 288, 366, 412, 48, 412, 31, 582, 367, 268, 269, + /* 1140 */ 412, 10, 270, 554, 412, 50, 564, 412, 51, 278, + /* 1150 */ 281, 282, 575, 144, 442, 403, 323, 226, 444, 461, + /* 1160 */ 464, 242, 503, 550, 561, 513, 161, 392, 400, 516, + /* 1170 */ 401, 345, 402, 7, 312, 83, 227, 332, 228, 82, + /* 1180 */ 330, 57, 408, 416, 168, 78, 459, 123, 210, 414, + /* 1190 */ 84, 335, 340, 299, 496, 500, 490, 229, 495, 243, + /* 1200 */ 104, 247, 499, 501, 230, 285, 415, 215, 514, 518, + /* 1210 */ 525, 526, 519, 236, 527, 473, 238, 352, 477, 286, + /* 1220 */ 182, 356, 533, 354, 119, 183, 185, 87, 546, 130, + /* 1230 */ 186, 535, 188, 140, 362, 191, 553, 216, 373, 374, + /* 1240 */ 131, 560, 308, 132, 133, 572, 577, 136, 263, 134, + /* 1250 */ 139, 536, 573, 391, 91, 94, 404, 574, 99, 214, + /* 1260 */ 102, 621, 622, 431, 164, 434, 165, 71, 141, 17, + /* 1270 */ 439, 448, 451, 155, 6, 452, 470, 110, 167, 453, + /* 1280 */ 457, 124, 13, 213, 120, 80, 12, 125, 159, 483, + /* 1290 */ 484, 85, 310, 105, 180, 251, 106, 118, 86, 107, + /* 1300 */ 241, 344, 349, 353, 143, 534, 127, 357, 171, 189, + /* 1310 */ 264, 108, 287, 128, 549, 129, 193, 537, 541, 14, + /* 1320 */ 195, 88, 196, 556, 197, 137, 138, 135, 15, 563, + /* 1330 */ 570, 109, 283, 146, 204, 383, 387, 899, 584, 899, + /* 1340 */ 899, 899, 899, 899, 89, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 16, 139, 140, 141, 168, 21, 144, 23, 69, 70, /* 10 */ 71, 72, 176, 74, 75, 76, 77, 78, 79, 80, - /* 20 */ 81, 82, 83, 84, 1, 2, 42, 43, 73, 74, + /* 20 */ 81, 82, 83, 84, 78, 79, 42, 43, 73, 74, /* 30 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - /* 40 */ 78, 79, 23, 58, 60, 61, 62, 63, 64, 65, - /* 50 */ 66, 67, 68, 69, 70, 71, 72, 110, 74, 75, + /* 40 */ 1, 2, 23, 58, 60, 61, 62, 63, 64, 65, + /* 50 */ 66, 67, 68, 69, 70, 71, 72, 147, 74, 75, /* 60 */ 76, 77, 78, 79, 80, 81, 82, 83, 84, 16, - /* 70 */ 123, 147, 88, 88, 110, 22, 216, 92, 218, 219, + /* 70 */ 185, 186, 88, 88, 110, 22, 217, 92, 219, 220, /* 80 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - /* 90 */ 84, 147, 19, 169, 170, 42, 43, 78, 238, 46, + /* 90 */ 84, 217, 218, 219, 220, 42, 43, 238, 188, 46, /* 100 */ 78, 79, 80, 81, 82, 83, 84, 88, 89, 124, /* 110 */ 125, 126, 16, 60, 61, 62, 63, 64, 65, 66, - /* 120 */ 67, 68, 69, 70, 71, 72, 182, 74, 75, 76, + /* 120 */ 67, 68, 69, 70, 71, 72, 147, 74, 75, 76, /* 130 */ 77, 78, 79, 80, 81, 82, 83, 84, 42, 43, - /* 140 */ 44, 80, 81, 82, 83, 84, 23, 223, 161, 216, - /* 150 */ 19, 218, 219, 21, 23, 23, 60, 61, 62, 63, - /* 160 */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 225, + /* 140 */ 44, 80, 81, 82, 83, 84, 23, 84, 169, 170, + /* 150 */ 19, 164, 165, 166, 23, 169, 60, 61, 62, 63, + /* 160 */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 169, /* 170 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - /* 180 */ 84, 16, 147, 147, 150, 112, 21, 200, 147, 58, - /* 190 */ 84, 147, 156, 157, 216, 217, 218, 219, 83, 84, - /* 200 */ 165, 78, 79, 216, 190, 218, 219, 42, 43, 78, - /* 210 */ 79, 88, 89, 169, 170, 141, 180, 181, 144, 88, - /* 220 */ 88, 98, 147, 92, 16, 60, 61, 62, 63, 64, + /* 180 */ 84, 16, 14, 147, 150, 147, 21, 167, 168, 58, + /* 190 */ 211, 147, 156, 157, 23, 216, 176, 23, 181, 176, + /* 200 */ 177, 78, 79, 165, 166, 110, 183, 42, 43, 78, + /* 210 */ 79, 88, 89, 169, 170, 228, 180, 181, 123, 88, + /* 220 */ 52, 98, 54, 92, 16, 60, 61, 62, 63, 64, /* 230 */ 65, 66, 67, 68, 69, 70, 71, 72, 147, 74, /* 240 */ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, - /* 250 */ 42, 43, 169, 209, 210, 124, 125, 126, 224, 14, - /* 260 */ 169, 170, 227, 228, 230, 18, 225, 16, 60, 61, + /* 250 */ 42, 43, 78, 209, 210, 124, 125, 126, 224, 88, + /* 260 */ 169, 170, 88, 89, 230, 227, 228, 16, 60, 61, /* 270 */ 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, /* 280 */ 72, 23, 74, 75, 76, 77, 78, 79, 80, 81, - /* 290 */ 82, 83, 84, 42, 43, 147, 16, 52, 147, 54, - /* 300 */ 147, 210, 55, 106, 153, 108, 109, 156, 157, 156, - /* 310 */ 157, 60, 61, 62, 63, 64, 65, 66, 67, 68, - /* 320 */ 69, 70, 71, 72, 22, 74, 75, 76, 77, 78, - /* 330 */ 79, 80, 81, 82, 83, 84, 188, 147, 92, 131, - /* 340 */ 16, 94, 16, 22, 20, 155, 88, 89, 90, 103, - /* 350 */ 147, 93, 94, 95, 167, 168, 161, 162, 163, 169, - /* 360 */ 170, 25, 104, 176, 84, 29, 42, 43, 165, 166, - /* 370 */ 90, 91, 92, 93, 94, 95, 96, 41, 133, 189, - /* 380 */ 133, 169, 131, 103, 60, 61, 62, 63, 64, 65, - /* 390 */ 66, 67, 68, 69, 70, 71, 72, 181, 74, 75, + /* 290 */ 82, 83, 84, 42, 43, 160, 16, 147, 161, 83, + /* 300 */ 84, 210, 161, 153, 169, 158, 156, 157, 161, 162, + /* 310 */ 163, 60, 61, 62, 63, 64, 65, 66, 67, 68, + /* 320 */ 69, 70, 71, 72, 161, 74, 75, 76, 77, 78, + /* 330 */ 79, 80, 81, 82, 83, 84, 192, 200, 147, 131, + /* 340 */ 16, 200, 16, 199, 20, 190, 88, 89, 90, 185, + /* 350 */ 186, 93, 94, 95, 217, 22, 219, 220, 147, 147, + /* 360 */ 169, 170, 104, 200, 84, 147, 42, 43, 156, 157, + /* 370 */ 90, 91, 92, 93, 94, 95, 96, 164, 165, 166, + /* 380 */ 169, 170, 131, 103, 60, 61, 62, 63, 64, 65, + /* 390 */ 66, 67, 68, 69, 70, 71, 72, 155, 74, 75, /* 400 */ 76, 77, 78, 79, 80, 81, 82, 83, 84, 16, - /* 410 */ 84, 90, 22, 20, 93, 94, 95, 91, 92, 93, - /* 420 */ 94, 95, 96, 121, 147, 104, 147, 185, 186, 103, - /* 430 */ 227, 228, 155, 181, 160, 42, 43, 90, 176, 177, - /* 440 */ 93, 94, 95, 169, 161, 183, 169, 170, 169, 170, - /* 450 */ 155, 104, 155, 60, 61, 62, 63, 64, 65, 66, + /* 410 */ 84, 11, 221, 20, 30, 16, 147, 91, 92, 93, + /* 420 */ 94, 95, 96, 90, 147, 181, 93, 94, 95, 103, + /* 430 */ 212, 189, 155, 27, 50, 42, 43, 104, 169, 170, + /* 440 */ 34, 228, 43, 201, 202, 147, 169, 170, 206, 49, + /* 450 */ 161, 162, 163, 60, 61, 62, 63, 64, 65, 66, /* 460 */ 67, 68, 69, 70, 71, 72, 189, 74, 75, 76, - /* 470 */ 77, 78, 79, 80, 81, 82, 83, 84, 16, 11, - /* 480 */ 244, 245, 20, 200, 189, 147, 189, 147, 211, 158, - /* 490 */ 211, 147, 161, 162, 163, 147, 201, 202, 42, 43, - /* 500 */ 223, 206, 223, 113, 42, 43, 147, 169, 170, 169, - /* 510 */ 170, 23, 19, 169, 170, 186, 23, 49, 155, 63, - /* 520 */ 64, 147, 60, 61, 62, 63, 64, 65, 66, 67, - /* 530 */ 68, 69, 70, 71, 72, 147, 74, 75, 76, 77, - /* 540 */ 78, 79, 80, 81, 82, 83, 84, 16, 92, 211, - /* 550 */ 12, 20, 189, 164, 165, 166, 208, 147, 16, 215, - /* 560 */ 220, 223, 24, 164, 165, 166, 23, 99, 100, 101, - /* 570 */ 155, 212, 23, 42, 43, 37, 88, 39, 110, 169, - /* 580 */ 170, 88, 89, 19, 20, 43, 22, 49, 185, 186, - /* 590 */ 23, 60, 61, 62, 63, 64, 65, 66, 67, 68, - /* 600 */ 69, 70, 71, 72, 189, 74, 75, 76, 77, 78, - /* 610 */ 79, 80, 81, 82, 83, 84, 16, 228, 0, 1, - /* 620 */ 2, 21, 19, 59, 147, 215, 23, 228, 213, 80, - /* 630 */ 147, 88, 89, 19, 20, 145, 22, 88, 89, 147, - /* 640 */ 98, 147, 42, 43, 20, 103, 169, 170, 20, 147, - /* 650 */ 147, 236, 169, 170, 20, 88, 89, 114, 147, 16, + /* 470 */ 77, 78, 79, 80, 81, 82, 83, 84, 16, 25, + /* 480 */ 211, 147, 20, 29, 12, 147, 102, 19, 211, 21, + /* 490 */ 147, 141, 147, 216, 144, 41, 24, 98, 20, 99, + /* 500 */ 100, 101, 103, 165, 42, 43, 0, 1, 2, 37, + /* 510 */ 110, 39, 169, 170, 169, 170, 182, 19, 20, 147, + /* 520 */ 22, 49, 60, 61, 62, 63, 64, 65, 66, 67, + /* 530 */ 68, 69, 70, 71, 72, 155, 74, 75, 76, 77, + /* 540 */ 78, 79, 80, 81, 82, 83, 84, 16, 147, 90, + /* 550 */ 20, 20, 93, 94, 95, 147, 155, 59, 215, 225, + /* 560 */ 215, 20, 130, 104, 132, 227, 228, 42, 43, 189, + /* 570 */ 169, 170, 16, 42, 43, 20, 19, 22, 19, 20, + /* 580 */ 23, 22, 18, 147, 106, 147, 108, 109, 63, 64, + /* 590 */ 189, 60, 61, 62, 63, 64, 65, 66, 67, 68, + /* 600 */ 69, 70, 71, 72, 186, 74, 75, 76, 77, 78, + /* 610 */ 79, 80, 81, 82, 83, 84, 16, 92, 59, 55, + /* 620 */ 212, 21, 147, 19, 147, 23, 188, 23, 12, 217, + /* 630 */ 23, 219, 220, 7, 8, 9, 106, 147, 108, 109, + /* 640 */ 24, 147, 42, 43, 208, 88, 89, 106, 92, 108, + /* 650 */ 109, 244, 245, 37, 145, 39, 191, 182, 94, 16, /* 660 */ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - /* 670 */ 70, 71, 72, 59, 74, 75, 76, 77, 78, 79, - /* 680 */ 80, 81, 82, 83, 84, 42, 43, 147, 142, 143, - /* 690 */ 188, 88, 89, 130, 148, 132, 7, 8, 9, 188, - /* 700 */ 208, 155, 16, 60, 61, 62, 63, 64, 65, 66, - /* 710 */ 67, 68, 69, 70, 71, 72, 147, 74, 75, 76, + /* 670 */ 70, 71, 72, 147, 74, 75, 76, 77, 78, 79, + /* 680 */ 80, 81, 82, 83, 84, 42, 43, 80, 142, 143, + /* 690 */ 88, 89, 88, 89, 148, 88, 89, 133, 14, 147, + /* 700 */ 225, 155, 16, 60, 61, 62, 63, 64, 65, 66, + /* 710 */ 67, 68, 69, 70, 71, 72, 114, 74, 75, 76, /* 720 */ 77, 78, 79, 80, 81, 82, 83, 84, 42, 43, - /* 730 */ 106, 147, 108, 109, 106, 189, 108, 109, 169, 170, - /* 740 */ 106, 147, 108, 109, 147, 16, 60, 61, 62, 63, + /* 730 */ 201, 202, 147, 147, 182, 189, 52, 147, 54, 147, + /* 740 */ 147, 147, 147, 147, 155, 16, 60, 61, 62, 63, /* 750 */ 64, 65, 66, 67, 68, 69, 70, 71, 72, 213, /* 760 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - /* 770 */ 84, 42, 43, 99, 100, 101, 182, 147, 161, 182, - /* 780 */ 99, 100, 101, 14, 147, 147, 147, 241, 16, 191, + /* 770 */ 84, 42, 43, 188, 188, 182, 182, 225, 189, 106, + /* 780 */ 188, 108, 109, 188, 99, 100, 101, 241, 16, 155, /* 790 */ 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, - /* 800 */ 71, 72, 147, 74, 75, 76, 77, 78, 79, 80, - /* 810 */ 81, 82, 83, 84, 42, 43, 23, 200, 188, 225, - /* 820 */ 182, 52, 225, 54, 169, 170, 147, 188, 22, 22, - /* 830 */ 147, 147, 201, 202, 62, 63, 64, 65, 66, 67, - /* 840 */ 68, 69, 70, 71, 72, 208, 74, 75, 76, 77, - /* 850 */ 78, 79, 80, 81, 82, 83, 84, 16, 17, 12, - /* 860 */ 19, 155, 19, 225, 23, 182, 23, 188, 147, 239, - /* 870 */ 147, 24, 31, 16, 17, 147, 19, 147, 147, 155, - /* 880 */ 23, 88, 89, 19, 37, 21, 39, 147, 31, 48, - /* 890 */ 169, 170, 169, 170, 147, 189, 89, 169, 170, 58, - /* 900 */ 169, 170, 147, 97, 147, 48, 147, 114, 225, 169, - /* 910 */ 170, 161, 147, 189, 16, 58, 169, 170, 147, 78, - /* 920 */ 79, 114, 155, 147, 169, 170, 169, 170, 87, 88, - /* 930 */ 89, 88, 80, 92, 147, 78, 79, 80, 147, 91, - /* 940 */ 169, 170, 212, 19, 87, 88, 89, 16, 17, 92, - /* 950 */ 19, 110, 147, 188, 23, 147, 189, 203, 110, 107, - /* 960 */ 169, 170, 31, 111, 188, 124, 125, 126, 127, 128, - /* 970 */ 129, 123, 147, 192, 169, 170, 43, 169, 170, 48, - /* 980 */ 199, 124, 125, 126, 127, 128, 129, 242, 243, 58, - /* 990 */ 92, 5, 68, 147, 169, 170, 10, 11, 12, 13, - /* 1000 */ 124, 125, 147, 147, 107, 147, 147, 147, 111, 78, - /* 1010 */ 79, 20, 26, 22, 28, 20, 147, 22, 87, 88, - /* 1020 */ 89, 35, 147, 92, 169, 170, 147, 169, 170, 169, - /* 1030 */ 170, 98, 20, 47, 188, 49, 27, 7, 8, 53, - /* 1040 */ 147, 147, 56, 34, 169, 170, 147, 147, 169, 170, - /* 1050 */ 147, 20, 147, 22, 147, 124, 125, 126, 127, 128, - /* 1060 */ 129, 178, 169, 170, 178, 20, 147, 22, 169, 170, - /* 1070 */ 30, 59, 169, 170, 169, 170, 147, 147, 91, 92, - /* 1080 */ 20, 147, 22, 147, 178, 99, 100, 101, 169, 170, - /* 1090 */ 50, 105, 147, 20, 147, 22, 110, 147, 169, 170, - /* 1100 */ 147, 147, 147, 169, 170, 169, 170, 20, 147, 22, - /* 1110 */ 147, 233, 232, 147, 169, 170, 169, 170, 147, 20, - /* 1120 */ 134, 22, 169, 170, 169, 170, 147, 20, 147, 22, - /* 1130 */ 169, 170, 169, 170, 149, 169, 170, 20, 229, 22, - /* 1140 */ 169, 170, 102, 20, 20, 22, 22, 147, 169, 170, - /* 1150 */ 147, 147, 147, 147, 147, 147, 191, 147, 147, 222, - /* 1160 */ 147, 147, 147, 193, 229, 172, 172, 177, 172, 172, - /* 1170 */ 172, 194, 173, 6, 194, 146, 22, 154, 146, 146, - /* 1180 */ 146, 189, 121, 194, 118, 116, 119, 23, 120, 130, - /* 1190 */ 221, 112, 98, 152, 152, 160, 195, 115, 196, 98, - /* 1200 */ 40, 97, 19, 179, 84, 179, 160, 171, 171, 171, - /* 1210 */ 226, 160, 173, 197, 171, 198, 15, 152, 174, 171, - /* 1220 */ 171, 171, 204, 151, 205, 204, 174, 205, 151, 38, - /* 1230 */ 152, 151, 130, 152, 60, 152, 151, 184, 152, 184, - /* 1240 */ 19, 194, 214, 152, 15, 187, 226, 152, 194, 187, - /* 1250 */ 187, 187, 33, 137, 184, 152, 159, 152, 1, 234, - /* 1260 */ 20, 112, 235, 175, 175, 112, 107, 112, 112, 92, - /* 1270 */ 214, 19, 11, 20, 20, 19, 114, 19, 117, 20, - /* 1280 */ 117, 112, 22, 20, 22, 19, 22, 20, 20, 44, - /* 1290 */ 19, 44, 19, 19, 237, 20, 19, 32, 19, 44, - /* 1300 */ 96, 103, 16, 21, 17, 98, 231, 22, 237, 133, - /* 1310 */ 98, 19, 36, 5, 240, 45, 1, 45, 102, 243, - /* 1320 */ 51, 122, 19, 113, 14, 102, 115, 113, 17, 123, - /* 1330 */ 246, 122, 19, 14, 20, 135, 19, 3, 57, 136, - /* 1340 */ 4, 247, 247, 247, 247, 247, 68, 247, 68, + /* 800 */ 71, 72, 213, 74, 75, 76, 77, 78, 79, 80, + /* 810 */ 81, 82, 83, 84, 42, 43, 23, 133, 225, 225, + /* 820 */ 21, 225, 23, 189, 239, 236, 99, 100, 101, 22, + /* 830 */ 242, 243, 155, 22, 62, 63, 64, 65, 66, 67, + /* 840 */ 68, 69, 70, 71, 72, 147, 74, 75, 76, 77, + /* 850 */ 78, 79, 80, 81, 82, 83, 84, 16, 17, 43, + /* 860 */ 19, 147, 147, 147, 23, 147, 189, 169, 170, 147, + /* 870 */ 147, 147, 31, 16, 17, 147, 19, 147, 124, 125, + /* 880 */ 23, 88, 89, 169, 170, 169, 170, 88, 31, 48, + /* 890 */ 147, 169, 170, 169, 170, 147, 89, 169, 170, 58, + /* 900 */ 147, 22, 147, 188, 147, 48, 188, 114, 97, 147, + /* 910 */ 147, 188, 147, 19, 98, 58, 147, 169, 170, 78, + /* 920 */ 79, 114, 169, 170, 169, 170, 169, 170, 87, 88, + /* 930 */ 89, 169, 170, 92, 161, 78, 79, 80, 169, 170, + /* 940 */ 91, 147, 155, 22, 87, 88, 89, 16, 17, 92, + /* 950 */ 19, 110, 147, 155, 23, 147, 7, 8, 20, 110, + /* 960 */ 22, 80, 31, 169, 170, 124, 125, 126, 127, 128, + /* 970 */ 129, 208, 123, 208, 169, 170, 189, 169, 170, 48, + /* 980 */ 147, 124, 125, 126, 127, 128, 129, 189, 107, 58, + /* 990 */ 107, 5, 111, 147, 111, 203, 10, 11, 12, 13, + /* 1000 */ 121, 147, 147, 91, 92, 147, 112, 147, 147, 78, + /* 1010 */ 79, 147, 26, 19, 28, 169, 170, 23, 87, 88, + /* 1020 */ 89, 35, 147, 92, 169, 170, 178, 169, 170, 147, + /* 1030 */ 169, 170, 147, 47, 113, 49, 92, 178, 147, 53, + /* 1040 */ 147, 178, 56, 147, 169, 170, 147, 103, 147, 19, + /* 1050 */ 147, 169, 170, 147, 147, 124, 125, 126, 127, 128, + /* 1060 */ 129, 147, 169, 170, 147, 169, 170, 147, 169, 170, + /* 1070 */ 169, 170, 169, 170, 147, 169, 170, 147, 20, 147, + /* 1080 */ 22, 147, 88, 147, 232, 99, 100, 101, 147, 169, + /* 1090 */ 170, 105, 147, 20, 147, 22, 110, 20, 68, 169, + /* 1100 */ 170, 169, 170, 169, 170, 169, 170, 20, 147, 22, + /* 1110 */ 147, 20, 147, 22, 169, 170, 169, 170, 147, 233, + /* 1120 */ 134, 20, 147, 22, 20, 147, 22, 20, 20, 22, + /* 1130 */ 22, 147, 169, 170, 169, 170, 59, 147, 147, 147, + /* 1140 */ 169, 170, 147, 147, 169, 170, 147, 169, 170, 147, + /* 1150 */ 147, 147, 147, 191, 229, 149, 223, 193, 229, 172, + /* 1160 */ 172, 172, 177, 194, 194, 172, 6, 146, 146, 172, + /* 1170 */ 146, 173, 146, 22, 154, 121, 194, 118, 195, 119, + /* 1180 */ 116, 120, 23, 160, 112, 130, 152, 152, 222, 189, + /* 1190 */ 98, 115, 98, 40, 179, 97, 171, 196, 171, 171, + /* 1200 */ 19, 84, 173, 171, 197, 174, 198, 226, 160, 160, + /* 1210 */ 171, 171, 179, 204, 171, 205, 204, 15, 205, 174, + /* 1220 */ 151, 38, 152, 152, 60, 151, 151, 130, 184, 19, + /* 1230 */ 152, 152, 151, 214, 152, 184, 194, 226, 152, 15, + /* 1240 */ 187, 194, 152, 187, 187, 33, 137, 184, 234, 187, + /* 1250 */ 214, 235, 152, 1, 237, 237, 20, 152, 159, 175, + /* 1260 */ 175, 112, 112, 92, 112, 107, 112, 19, 19, 231, + /* 1270 */ 20, 20, 11, 19, 117, 20, 114, 240, 22, 20, + /* 1280 */ 20, 19, 117, 44, 243, 22, 22, 20, 112, 20, + /* 1290 */ 20, 19, 246, 19, 96, 20, 19, 32, 19, 19, + /* 1300 */ 103, 44, 44, 16, 21, 17, 98, 36, 22, 98, + /* 1310 */ 133, 19, 5, 45, 1, 102, 122, 51, 45, 19, + /* 1320 */ 113, 68, 14, 17, 115, 102, 122, 113, 19, 123, + /* 1330 */ 20, 14, 136, 19, 135, 57, 3, 247, 4, 247, + /* 1340 */ 247, 247, 247, 247, 68, }; #define YY_SHIFT_USE_DFLT (-62) -#define YY_SHIFT_MAX 385 +#define YY_SHIFT_MAX 387 static const short yy_shift_ofst[] = { - /* 0 */ 23, 841, 986, -16, 841, 931, 931, 931, 258, 123, - /* 10 */ -36, 96, 931, 931, 931, 931, 931, -45, 468, 19, - /* 20 */ 567, 488, -38, -38, 53, 165, 208, 251, 324, 393, - /* 30 */ 462, 531, 600, 643, 686, 643, 643, 643, 643, 643, + /* 0 */ 39, 841, 986, -16, 841, 931, 931, 258, 123, -36, + /* 10 */ 96, 931, 931, 931, 931, 931, -45, 400, 174, 19, + /* 20 */ 171, -54, -54, 53, 165, 208, 251, 324, 393, 462, + /* 30 */ 531, 600, 643, 686, 643, 643, 643, 643, 643, 643, /* 40 */ 643, 643, 643, 643, 643, 643, 643, 643, 643, 643, /* 50 */ 643, 643, 729, 772, 772, 857, 931, 931, 931, 931, /* 60 */ 931, 931, 931, 931, 931, 931, 931, 931, 931, 931, /* 70 */ 931, 931, 931, 931, 931, 931, 931, 931, 931, 931, /* 80 */ 931, 931, 931, 931, 931, 931, 931, 931, 931, 931, - /* 90 */ 931, 931, 931, 931, -61, -61, 6, 6, 280, 22, - /* 100 */ 61, 542, 247, 567, 567, 567, 567, 567, 567, 567, - /* 110 */ 115, 488, 106, -62, -62, 131, 326, 538, 538, 564, - /* 120 */ 614, 618, 132, 567, 132, 567, 567, 567, 567, 567, - /* 130 */ 567, 567, 567, 567, 567, 567, 567, 567, 848, -53, - /* 140 */ -36, -36, -36, -62, -62, -62, -15, -15, 321, 347, - /* 150 */ 624, 493, 628, 634, 847, 543, 793, 603, 549, 689, - /* 160 */ 567, 567, 852, 567, 567, 843, 567, 567, 807, 567, - /* 170 */ 567, 197, 807, 567, 567, 1040, 1040, 1040, 567, 567, - /* 180 */ 197, 567, 567, 197, 567, 336, 674, 567, 567, 197, - /* 190 */ 567, 567, 567, 197, 567, 567, 567, 197, 197, 567, - /* 200 */ 567, 567, 567, 567, 864, 897, 390, 876, 876, 563, - /* 210 */ 1009, 1009, 1009, 933, 1009, 1009, 806, 302, 302, 1167, - /* 220 */ 1167, 1167, 1167, 1154, -36, 1061, 1066, 1067, 1069, 1068, - /* 230 */ 1164, 1059, 1079, 1079, 1094, 1082, 1094, 1082, 1101, 1101, - /* 240 */ 1160, 1101, 1104, 1101, 1183, 1120, 1164, 1120, 1164, 1160, - /* 250 */ 1101, 1101, 1101, 1183, 1201, 1079, 1201, 1079, 1201, 1079, - /* 260 */ 1079, 1191, 1102, 1201, 1079, 1174, 1174, 1221, 1061, 1079, - /* 270 */ 1229, 1229, 1229, 1229, 1061, 1174, 1221, 1079, 1219, 1219, - /* 280 */ 1079, 1079, 1116, -62, -62, -62, -62, -62, -62, 456, - /* 290 */ 245, 681, 769, 73, 898, 991, 995, 1031, 1045, 246, - /* 300 */ 1030, 987, 1060, 1073, 1087, 1099, 1107, 1117, 1123, 924, - /* 310 */ 1124, 1012, 1257, 1240, 1149, 1153, 1155, 1156, 1177, 1159, - /* 320 */ 1252, 1253, 1254, 1256, 1261, 1258, 1259, 1260, 1263, 1161, - /* 330 */ 1262, 1163, 1264, 1162, 1266, 1267, 1169, 1268, 1265, 1245, - /* 340 */ 1271, 1247, 1273, 1275, 1274, 1277, 1255, 1279, 1204, 1198, - /* 350 */ 1286, 1287, 1282, 1207, 1276, 1269, 1270, 1285, 1272, 1176, - /* 360 */ 1212, 1292, 1308, 1315, 1216, 1278, 1280, 1199, 1303, 1210, - /* 370 */ 1310, 1211, 1311, 1214, 1223, 1209, 1313, 1206, 1314, 1319, - /* 380 */ 1281, 1200, 1203, 1317, 1334, 1336, + /* 90 */ 931, 931, 931, 931, 931, -61, -61, 6, 6, 280, + /* 100 */ 22, 61, 399, 564, 19, 19, 19, 19, 19, 19, + /* 110 */ 19, 216, 171, 63, -62, -62, 131, 326, 472, 472, + /* 120 */ 498, 559, 506, 799, 19, 799, 19, 19, 19, 19, + /* 130 */ 19, 19, 19, 19, 19, 19, 19, 19, 19, 849, + /* 140 */ 95, -36, -36, -36, -62, -62, -62, -15, -15, 333, + /* 150 */ 459, 478, 557, 530, 541, 616, 602, 793, 604, 607, + /* 160 */ 626, 19, 19, 881, 19, 19, 994, 19, 19, 807, + /* 170 */ 19, 19, 673, 807, 19, 19, 384, 384, 384, 19, + /* 180 */ 19, 673, 19, 19, 673, 19, 454, 685, 19, 19, + /* 190 */ 673, 19, 19, 19, 673, 19, 19, 19, 673, 673, + /* 200 */ 19, 19, 19, 19, 19, 468, 883, 921, 754, 754, + /* 210 */ 432, 406, 406, 406, 816, 406, 406, 811, 879, 879, + /* 220 */ 1160, 1160, 1160, 1160, 1151, -36, 1054, 1059, 1060, 1064, + /* 230 */ 1061, 1159, 1055, 1072, 1072, 1092, 1076, 1092, 1076, 1094, + /* 240 */ 1094, 1153, 1094, 1098, 1094, 1181, 1117, 1159, 1117, 1159, + /* 250 */ 1153, 1094, 1094, 1094, 1181, 1202, 1072, 1202, 1072, 1202, + /* 260 */ 1072, 1072, 1183, 1097, 1202, 1072, 1164, 1164, 1210, 1054, + /* 270 */ 1072, 1224, 1224, 1224, 1224, 1054, 1164, 1210, 1072, 1212, + /* 280 */ 1212, 1072, 1072, 1109, -62, -62, -62, -62, -62, -62, + /* 290 */ 525, 684, 727, 168, 894, 556, 555, 938, 944, 949, + /* 300 */ 912, 1058, 1073, 1087, 1091, 1101, 1104, 1107, 1030, 1108, + /* 310 */ 1077, 1252, 1236, 1149, 1150, 1152, 1154, 1171, 1158, 1248, + /* 320 */ 1250, 1251, 1249, 1261, 1254, 1255, 1256, 1259, 1260, 1263, + /* 330 */ 1157, 1264, 1165, 1263, 1162, 1262, 1267, 1176, 1269, 1270, + /* 340 */ 1265, 1239, 1272, 1257, 1274, 1275, 1277, 1279, 1258, 1280, + /* 350 */ 1198, 1197, 1287, 1288, 1283, 1208, 1271, 1266, 1268, 1286, + /* 360 */ 1273, 1177, 1211, 1292, 1307, 1313, 1213, 1253, 1276, 1194, + /* 370 */ 1300, 1207, 1308, 1209, 1306, 1214, 1223, 1204, 1309, 1206, + /* 380 */ 1310, 1317, 1278, 1199, 1196, 1314, 1333, 1334, }; #define YY_REDUCE_USE_DFLT (-165) -#define YY_REDUCE_MAX 288 +#define YY_REDUCE_MAX 289 static const short yy_reduce_ofst[] = { - /* 0 */ -138, 277, 546, -13, 190, 279, 44, 338, 36, 203, - /* 10 */ 295, -140, 340, -76, 91, 344, 410, -22, 415, 35, - /* 20 */ 151, 331, 389, 399, -67, -67, -67, -67, -67, -67, - /* 30 */ -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - /* 40 */ -67, -67, -67, -67, -67, -67, -67, -67, -67, -67, - /* 50 */ -67, -67, -67, -67, -67, 477, 483, 569, 655, 721, - /* 60 */ 723, 728, 731, 740, 747, 755, 757, 771, 791, 805, - /* 70 */ 808, 825, 855, 858, 860, 875, 879, 893, 899, 903, - /* 80 */ 905, 919, 929, 934, 936, 945, 947, 953, 955, 961, - /* 90 */ 963, 966, 971, 979, -67, -67, -67, -67, 187, -67, - /* 100 */ -67, 262, 34, -56, 594, 597, 638, 683, 630, 153, - /* 110 */ -67, 195, -67, -67, -67, 274, -164, 242, 403, 236, - /* 120 */ 236, 74, 283, 348, 617, 41, 148, 492, 359, 637, - /* 130 */ 502, 511, 639, 679, 765, 776, 730, 846, 297, 363, - /* 140 */ 706, 724, 767, 781, 631, 745, 83, 212, 216, 252, - /* 150 */ 14, 75, 14, 14, 329, 374, 388, 494, 503, 490, - /* 160 */ 540, 584, 598, 503, 684, 750, 759, 787, 754, 856, - /* 170 */ 859, 14, 754, 869, 894, 883, 886, 906, 900, 907, - /* 180 */ 14, 930, 950, 14, 954, 880, 878, 981, 1000, 14, - /* 190 */ 1003, 1004, 1005, 14, 1006, 1007, 1008, 14, 14, 1010, - /* 200 */ 1011, 1013, 1014, 1015, 985, 965, 970, 909, 935, 937, - /* 210 */ 993, 994, 996, 990, 997, 998, 999, 977, 980, 1029, - /* 220 */ 1032, 1033, 1034, 1023, 992, 989, 1001, 1002, 1016, 1017, - /* 230 */ 1035, 969, 1041, 1042, 1018, 1019, 1021, 1022, 1036, 1037, - /* 240 */ 1024, 1038, 1039, 1043, 1044, 984, 1046, 1020, 1051, 1026, - /* 250 */ 1048, 1049, 1050, 1052, 1072, 1065, 1077, 1078, 1080, 1081, - /* 260 */ 1083, 1025, 1027, 1085, 1086, 1053, 1055, 1028, 1047, 1091, - /* 270 */ 1058, 1062, 1063, 1064, 1054, 1070, 1056, 1095, 1057, 1071, - /* 280 */ 1103, 1105, 1074, 1097, 1088, 1089, 1075, 1076, 1084, + /* 0 */ -138, 277, 546, 137, 401, -21, 44, 36, 38, 242, + /* 10 */ -141, 191, 91, 269, 343, 345, -126, 589, 338, 150, + /* 20 */ 147, -13, 213, 412, 412, 412, 412, 412, 412, 412, + /* 30 */ 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + /* 40 */ 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, + /* 50 */ 412, 412, 412, 412, 412, 211, 698, 714, 716, 722, + /* 60 */ 724, 728, 748, 753, 755, 757, 762, 769, 794, 805, + /* 70 */ 808, 846, 855, 858, 861, 875, 882, 893, 896, 899, + /* 80 */ 901, 903, 906, 920, 930, 932, 934, 936, 945, 947, + /* 90 */ 963, 965, 971, 975, 978, 412, 412, 412, 412, 20, + /* 100 */ 412, 412, 23, 34, 334, 475, 552, 593, 594, 585, + /* 110 */ 212, 412, 289, 412, 412, 412, 135, -164, -115, 164, + /* 120 */ 407, 407, 350, 141, 436, 163, 596, -90, 763, 218, + /* 130 */ 765, 438, 586, 592, 595, 715, 718, 408, 723, 380, + /* 140 */ 634, 677, 787, 798, 144, 529, 588, -14, 0, 17, + /* 150 */ 244, 155, 298, 155, 155, 418, 372, 477, 490, 494, + /* 160 */ 509, 526, 590, 465, 494, 730, 773, 743, 833, 792, + /* 170 */ 854, 860, 155, 792, 864, 885, 848, 859, 863, 891, + /* 180 */ 907, 155, 914, 917, 155, 927, 852, 886, 941, 961, + /* 190 */ 155, 984, 990, 991, 155, 992, 995, 996, 155, 155, + /* 200 */ 999, 1002, 1003, 1004, 1005, 1006, 962, 964, 925, 929, + /* 210 */ 933, 987, 988, 989, 985, 993, 997, 998, 969, 970, + /* 220 */ 1021, 1022, 1024, 1026, 1020, 1000, 982, 983, 1001, 1007, + /* 230 */ 1008, 1023, 966, 1034, 1035, 1009, 1010, 1012, 1013, 1025, + /* 240 */ 1027, 1015, 1028, 1029, 1032, 1031, 981, 1048, 1011, 1049, + /* 250 */ 1033, 1039, 1040, 1043, 1045, 1069, 1070, 1074, 1071, 1075, + /* 260 */ 1078, 1079, 1014, 1016, 1081, 1082, 1044, 1051, 1019, 1042, + /* 270 */ 1086, 1053, 1056, 1057, 1062, 1047, 1063, 1036, 1090, 1017, + /* 280 */ 1018, 1100, 1105, 1037, 1099, 1084, 1085, 1038, 1041, 1046, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 592, 818, 897, 707, 897, 818, 897, 818, 897, 843, - /* 10 */ 711, 872, 814, 818, 897, 897, 897, 789, 897, 843, - /* 20 */ 897, 623, 843, 843, 740, 897, 897, 897, 897, 897, - /* 30 */ 897, 897, 897, 741, 897, 817, 813, 809, 811, 810, + /* 0 */ 592, 816, 897, 707, 897, 816, 897, 897, 843, 711, + /* 10 */ 872, 814, 897, 897, 897, 897, 789, 897, 843, 897, + /* 20 */ 623, 843, 843, 740, 897, 897, 897, 897, 897, 897, + /* 30 */ 897, 897, 741, 897, 818, 813, 809, 811, 810, 817, /* 40 */ 742, 731, 738, 745, 723, 856, 747, 748, 754, 755, /* 50 */ 873, 871, 777, 776, 795, 897, 897, 897, 897, 897, /* 60 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, /* 70 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, /* 80 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, - /* 90 */ 897, 897, 897, 897, 779, 800, 778, 788, 616, 780, - /* 100 */ 781, 676, 611, 897, 897, 897, 897, 897, 897, 897, - /* 110 */ 782, 897, 783, 796, 797, 897, 897, 897, 897, 897, - /* 120 */ 897, 592, 707, 897, 707, 897, 897, 897, 897, 897, + /* 90 */ 897, 897, 897, 897, 897, 779, 800, 778, 788, 616, + /* 100 */ 780, 781, 676, 611, 897, 897, 897, 897, 897, 897, + /* 110 */ 897, 782, 897, 783, 796, 797, 897, 897, 897, 897, + /* 120 */ 897, 897, 592, 707, 897, 707, 897, 897, 897, 897, /* 130 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, - /* 140 */ 897, 897, 897, 701, 711, 890, 897, 897, 667, 897, - /* 150 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 599, - /* 160 */ 597, 897, 699, 897, 897, 625, 897, 897, 709, 897, - /* 170 */ 897, 714, 715, 897, 897, 897, 897, 897, 897, 897, - /* 180 */ 613, 897, 897, 688, 897, 849, 897, 897, 897, 863, - /* 190 */ 897, 897, 897, 861, 897, 897, 897, 690, 750, 830, - /* 200 */ 897, 876, 878, 897, 897, 699, 708, 897, 897, 812, - /* 210 */ 734, 734, 734, 646, 734, 734, 649, 744, 744, 596, - /* 220 */ 596, 596, 596, 666, 897, 744, 735, 737, 727, 739, - /* 230 */ 897, 897, 716, 716, 724, 726, 724, 726, 678, 678, - /* 240 */ 663, 678, 649, 678, 822, 827, 897, 827, 897, 663, - /* 250 */ 678, 678, 678, 822, 608, 716, 608, 716, 608, 716, - /* 260 */ 716, 853, 855, 608, 716, 680, 680, 756, 744, 716, - /* 270 */ 687, 687, 687, 687, 744, 680, 756, 716, 875, 875, - /* 280 */ 716, 716, 883, 633, 651, 651, 858, 890, 895, 897, - /* 290 */ 897, 897, 897, 763, 897, 897, 897, 897, 897, 897, - /* 300 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 836, - /* 310 */ 897, 897, 897, 897, 768, 764, 897, 765, 897, 693, - /* 320 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, - /* 330 */ 728, 897, 736, 897, 897, 897, 897, 897, 897, 897, + /* 140 */ 897, 897, 897, 897, 701, 711, 890, 897, 897, 667, + /* 150 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, + /* 160 */ 599, 597, 897, 699, 897, 897, 625, 897, 897, 709, + /* 170 */ 897, 897, 714, 715, 897, 897, 897, 897, 897, 897, + /* 180 */ 897, 613, 897, 897, 688, 897, 849, 897, 897, 897, + /* 190 */ 863, 897, 897, 897, 861, 897, 897, 897, 690, 750, + /* 200 */ 830, 897, 876, 878, 897, 897, 699, 708, 897, 897, + /* 210 */ 812, 734, 734, 734, 646, 734, 734, 649, 744, 744, + /* 220 */ 596, 596, 596, 596, 666, 897, 744, 735, 737, 727, + /* 230 */ 739, 897, 897, 716, 716, 724, 726, 724, 726, 678, + /* 240 */ 678, 663, 678, 649, 678, 822, 827, 897, 827, 897, + /* 250 */ 663, 678, 678, 678, 822, 608, 716, 608, 716, 608, + /* 260 */ 716, 716, 853, 855, 608, 716, 680, 680, 756, 744, + /* 270 */ 716, 687, 687, 687, 687, 744, 680, 756, 716, 875, + /* 280 */ 875, 716, 716, 883, 633, 651, 651, 858, 890, 895, + /* 290 */ 897, 897, 897, 897, 763, 897, 897, 897, 897, 897, + /* 300 */ 897, 897, 897, 897, 897, 897, 897, 897, 836, 897, + /* 310 */ 897, 897, 897, 768, 764, 897, 765, 897, 693, 897, + /* 320 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 815, + /* 330 */ 897, 728, 897, 736, 897, 897, 897, 897, 897, 897, /* 340 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, - /* 350 */ 897, 897, 897, 897, 897, 897, 851, 852, 897, 897, + /* 350 */ 897, 897, 897, 897, 897, 897, 897, 897, 851, 852, /* 360 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, /* 370 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, - /* 380 */ 882, 897, 897, 885, 593, 897, 587, 590, 589, 591, - /* 390 */ 595, 598, 620, 621, 622, 600, 601, 602, 603, 604, - /* 400 */ 605, 606, 612, 614, 632, 634, 618, 636, 697, 698, - /* 410 */ 760, 691, 692, 696, 771, 762, 766, 767, 769, 770, - /* 420 */ 784, 785, 787, 793, 799, 802, 786, 791, 792, 794, - /* 430 */ 798, 801, 694, 695, 805, 619, 626, 627, 630, 631, - /* 440 */ 839, 841, 840, 842, 629, 628, 772, 775, 807, 808, - /* 450 */ 864, 865, 866, 867, 868, 803, 815, 816, 717, 806, + /* 380 */ 897, 897, 882, 897, 897, 885, 593, 897, 587, 590, + /* 390 */ 589, 591, 595, 598, 620, 621, 622, 600, 601, 602, + /* 400 */ 603, 604, 605, 606, 612, 614, 632, 634, 618, 636, + /* 410 */ 697, 698, 760, 691, 692, 696, 771, 762, 766, 767, + /* 420 */ 769, 770, 784, 785, 787, 793, 799, 802, 786, 791, + /* 430 */ 792, 794, 798, 801, 694, 695, 805, 619, 626, 627, + /* 440 */ 630, 631, 839, 841, 840, 842, 629, 628, 772, 775, + /* 450 */ 807, 808, 864, 865, 866, 867, 868, 803, 717, 806, /* 460 */ 790, 729, 732, 733, 730, 700, 710, 719, 720, 721, /* 470 */ 722, 705, 706, 712, 725, 758, 759, 713, 702, 703, /* 480 */ 704, 804, 761, 773, 774, 637, 638, 768, 639, 640, @@ -868,10 +868,10 @@ static const char *const yyTokenName[] = "having_opt", "orderby_opt", "limit_opt", "sclp", "as", "seltablist", "stl_prefix", "joinop", "on_opt", "using_opt", "seltablist_paren", "joinop2", - "inscollist", "sortlist", "sortitem", "exprlist", + "inscollist", "sortlist", "sortitem", "nexprlist", "setlist", "insert_cmd", "inscollist_opt", "itemlist", - "likeop", "escape", "between_op", "in_op", - "case_operand", "case_exprlist", "case_else", "expritem", + "exprlist", "likeop", "escape", "between_op", + "in_op", "case_operand", "case_exprlist", "case_else", "uniqueflag", "idxitem", "collate", "nmnum", "plus_opt", "number", "trigger_decl", "trigger_cmd_list", "trigger_time", "trigger_event", "foreach_clause", "when_clause", @@ -1035,7 +1035,7 @@ static const char *const yyRuleName[] = /* 147 */ "sortorder ::= DESC", /* 148 */ "sortorder ::=", /* 149 */ "groupby_opt ::=", - /* 150 */ "groupby_opt ::= GROUP BY exprlist", + /* 150 */ "groupby_opt ::= GROUP BY nexprlist", /* 151 */ "having_opt ::=", /* 152 */ "having_opt ::= HAVING expr", /* 153 */ "limit_opt ::=", @@ -1114,10 +1114,10 @@ static const char *const yyRuleName[] = /* 226 */ "case_else ::=", /* 227 */ "case_operand ::= expr", /* 228 */ "case_operand ::=", - /* 229 */ "exprlist ::= exprlist COMMA expritem", - /* 230 */ "exprlist ::= expritem", - /* 231 */ "expritem ::= expr", - /* 232 */ "expritem ::=", + /* 229 */ "exprlist ::= nexprlist", + /* 230 */ "exprlist ::=", + /* 231 */ "nexprlist ::= nexprlist COMMA expr", + /* 232 */ "nexprlist ::= expr", /* 233 */ "cmd ::= CREATE uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP", /* 234 */ "uniqueflag ::= UNIQUE", /* 235 */ "uniqueflag ::=", @@ -1277,14 +1277,13 @@ static void yy_destructor(YYCODETYPE yym case 196: case 204: case 210: - case 217: - case 220: - case 222: + case 218: + case 221: case 223: case 235: #line 627 "parse.y" {sqlite3ExprDelete((yypminor->yy172));} -#line 1289 "parse.c" +#line 1288 "parse.c" break; case 174: case 182: @@ -1296,7 +1295,8 @@ static void yy_destructor(YYCODETYPE yym case 211: case 212: case 215: - case 221: + case 216: + case 222: #line 876 "parse.y" {sqlite3ExprListDelete((yypminor->yy174));} #line 1304 "parse.c" @@ -1743,12 +1743,12 @@ static const struct { { 170, 3 }, { 170, 3 }, { 170, 3 }, - { 216, 1 }, - { 216, 2 }, - { 216, 1 }, - { 216, 2 }, + { 217, 1 }, { 217, 2 }, - { 217, 0 }, + { 217, 1 }, + { 217, 2 }, + { 218, 2 }, + { 218, 0 }, { 170, 4 }, { 170, 2 }, { 170, 3 }, @@ -1757,27 +1757,27 @@ static const struct { { 170, 2 }, { 170, 2 }, { 170, 2 }, - { 218, 1 }, - { 218, 2 }, - { 170, 5 }, { 219, 1 }, { 219, 2 }, { 170, 5 }, + { 220, 1 }, + { 220, 2 }, + { 170, 5 }, { 170, 3 }, { 170, 5 }, { 170, 4 }, { 170, 4 }, { 170, 5 }, - { 221, 5 }, - { 221, 4 }, - { 222, 2 }, - { 222, 0 }, - { 220, 1 }, - { 220, 0 }, + { 222, 5 }, + { 222, 4 }, + { 223, 2 }, + { 223, 0 }, + { 221, 1 }, + { 221, 0 }, + { 216, 1 }, + { 216, 0 }, { 211, 3 }, { 211, 1 }, - { 223, 1 }, - { 223, 0 }, { 143, 11 }, { 224, 1 }, { 224, 0 }, @@ -2357,24 +2357,25 @@ static void yy_reduce( case 115: case 141: case 149: + case 230: case 236: #line 417 "parse.y" {yygotominor.yy174 = 0;} -#line 2366 "parse.c" +#line 2367 "parse.c" break; case 116: #line 418 "parse.y" { yygotominor.yy174 = sqlite3ExprListAppend(yymsp[-2].minor.yy174,yymsp[-1].minor.yy172,yymsp[0].minor.yy410.n?&yymsp[0].minor.yy410:0); } -#line 2373 "parse.c" +#line 2374 "parse.c" break; case 117: #line 421 "parse.y" { yygotominor.yy174 = sqlite3ExprListAppend(yymsp[-1].minor.yy174, sqlite3Expr(TK_ALL, 0, 0, 0), 0); } -#line 2380 "parse.c" +#line 2381 "parse.c" break; case 118: #line 424 "parse.y" @@ -2383,17 +2384,17 @@ static void yy_reduce( Expr *pLeft = sqlite3Expr(TK_ID, 0, 0, &yymsp[-2].minor.yy410); yygotominor.yy174 = sqlite3ExprListAppend(yymsp[-3].minor.yy174, sqlite3Expr(TK_DOT, pLeft, pRight, 0), 0); } -#line 2389 "parse.c" +#line 2390 "parse.c" break; case 121: #line 436 "parse.y" {yygotominor.yy410.n = 0;} -#line 2394 "parse.c" +#line 2395 "parse.c" break; case 122: #line 448 "parse.y" {yygotominor.yy373 = sqliteMalloc(sizeof(*yygotominor.yy373));} -#line 2399 "parse.c" +#line 2400 "parse.c" break; case 123: #line 449 "parse.y" @@ -2401,7 +2402,7 @@ static void yy_reduce( yygotominor.yy373 = yymsp[0].minor.yy373; sqlite3SrcListShiftJoinType(yygotominor.yy373); } -#line 2407 "parse.c" +#line 2408 "parse.c" break; case 124: #line 457 "parse.y" @@ -2409,26 +2410,26 @@ static void yy_reduce( yygotominor.yy373 = yymsp[-1].minor.yy373; if( yygotominor.yy373 && yygotominor.yy373->nSrc>0 ) yygotominor.yy373->a[yygotominor.yy373->nSrc-1].jointype = yymsp[0].minor.yy46; } -#line 2415 "parse.c" +#line 2416 "parse.c" break; case 125: #line 461 "parse.y" {yygotominor.yy373 = 0;} -#line 2420 "parse.c" +#line 2421 "parse.c" break; case 126: #line 462 "parse.y" { yygotominor.yy373 = sqlite3SrcListAppendFromTerm(yymsp[-5].minor.yy373,&yymsp[-4].minor.yy410,&yymsp[-3].minor.yy410,&yymsp[-2].minor.yy410,0,yymsp[-1].minor.yy172,yymsp[0].minor.yy432); } -#line 2427 "parse.c" +#line 2428 "parse.c" break; case 127: #line 467 "parse.y" { yygotominor.yy373 = sqlite3SrcListAppendFromTerm(yymsp[-6].minor.yy373,0,0,&yymsp[-2].minor.yy410,yymsp[-4].minor.yy219,yymsp[-1].minor.yy172,yymsp[0].minor.yy432); } -#line 2434 "parse.c" +#line 2435 "parse.c" break; case 129: #line 478 "parse.y" @@ -2436,37 +2437,37 @@ static void yy_reduce( sqlite3SrcListShiftJoinType(yymsp[0].minor.yy373); yygotominor.yy219 = sqlite3SelectNew(0,yymsp[0].minor.yy373,0,0,0,0,0,0,0); } -#line 2442 "parse.c" +#line 2443 "parse.c" break; case 130: #line 485 "parse.y" {yygotominor.yy410.z=0; yygotominor.yy410.n=0;} -#line 2447 "parse.c" +#line 2448 "parse.c" break; case 132: #line 490 "parse.y" {yygotominor.yy373 = sqlite3SrcListAppend(0,&yymsp[-1].minor.yy410,&yymsp[0].minor.yy410);} -#line 2452 "parse.c" +#line 2453 "parse.c" break; case 133: #line 494 "parse.y" { yygotominor.yy46 = JT_INNER; } -#line 2457 "parse.c" +#line 2458 "parse.c" break; case 134: #line 495 "parse.y" { yygotominor.yy46 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } -#line 2462 "parse.c" +#line 2463 "parse.c" break; case 135: #line 496 "parse.y" { yygotominor.yy46 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy410,0); } -#line 2467 "parse.c" +#line 2468 "parse.c" break; case 136: #line 498 "parse.y" { yygotominor.yy46 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy410,&yymsp[-1].minor.yy410); } -#line 2472 "parse.c" +#line 2473 "parse.c" break; case 137: case 145: @@ -2476,7 +2477,6 @@ static void yy_reduce( case 202: case 225: case 227: - case 231: #line 502 "parse.y" {yygotominor.yy172 = yymsp[0].minor.yy172;} #line 2485 "parse.c" @@ -2487,25 +2487,25 @@ static void yy_reduce( case 203: case 226: case 228: - case 232: #line 503 "parse.y" {yygotominor.yy172 = 0;} -#line 2496 "parse.c" +#line 2495 "parse.c" break; case 139: case 171: #line 507 "parse.y" {yygotominor.yy432 = yymsp[-1].minor.yy432;} -#line 2502 "parse.c" +#line 2501 "parse.c" break; case 140: case 170: #line 508 "parse.y" {yygotominor.yy432 = 0;} -#line 2508 "parse.c" +#line 2507 "parse.c" break; case 142: case 150: + case 229: #line 519 "parse.y" {yygotominor.yy174 = yymsp[0].minor.yy174;} #line 2514 "parse.c" @@ -2596,13 +2596,13 @@ static void yy_reduce( #line 2599 "parse.c" break; case 168: - case 229: + case 231: #line 608 "parse.y" {yygotominor.yy174 = sqlite3ExprListAppend(yymsp[-2].minor.yy174,yymsp[0].minor.yy172,0);} #line 2605 "parse.c" break; case 169: - case 230: + case 232: #line 609 "parse.y" {yygotominor.yy174 = sqlite3ExprListAppend(0,yymsp[0].minor.yy172,0);} #line 2611 "parse.c" ============================================================ --- sqlite/pragma.c 0d25dad58bdfd6789943a10f1b9663c2eb85b96d +++ sqlite/pragma.c 7914a6b9ea05f158800116dfcae11e52ab8e39c4 @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the PRAGMA command. ** -** $Id: pragma.c,v 1.139 2007/05/23 13:50:24 danielk1977 Exp $ +** $Id: pragma.c,v 1.142 2007/06/26 10:38:55 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -424,6 +424,9 @@ void sqlite3Pragma( #ifndef SQLITE_OMIT_AUTOVACUUM if( sqlite3StrICmp(zLeft,"auto_vacuum")==0 ){ Btree *pBt = pDb->pBt; + if( sqlite3ReadSchema(pParse) ){ + goto pragma_out; + } if( !zRight ){ int auto_vacuum = pBt ? sqlite3BtreeGetAutoVacuum(pBt) : SQLITE_DEFAULT_AUTOVACUUM; @@ -431,7 +434,34 @@ void sqlite3Pragma( }else{ int eAuto = getAutoVacuum(zRight); if( eAuto>=0 ){ - sqlite3BtreeSetAutoVacuum(pBt, eAuto); + /* Call SetAutoVacuum() to set initialize the internal auto and + ** incr-vacuum flags. This is required in case this connection + ** creates the database file. It is important that it is created + ** as an auto-vacuum capable db. + */ + int rc = sqlite3BtreeSetAutoVacuum(pBt, eAuto); + if( rc==SQLITE_OK && (eAuto==1 || eAuto==2) ){ + /* When setting the auto_vacuum mode to either "full" or + ** "incremental", write the value of meta[6] in the database + ** file. Before writing to meta[6], check that meta[3] indicates + ** that this really is an auto-vacuum capable database. + */ + static const VdbeOpList setMeta6[] = { + { OP_Transaction, 0, 1, 0}, /* 0 */ + { OP_ReadCookie, 0, 3, 0}, /* 1 */ + { OP_If, 0, 0, 0}, /* 2 */ + { OP_Halt, SQLITE_OK, OE_Abort, 0}, /* 3 */ + { OP_Integer, 0, 0, 0}, /* 4 */ + { OP_SetCookie, 0, 6, 0}, /* 5 */ + }; + int iAddr; + iAddr = sqlite3VdbeAddOpList(v, ArraySize(setMeta6), setMeta6); + sqlite3VdbeChangeP1(v, iAddr, iDb); + sqlite3VdbeChangeP1(v, iAddr+1, iDb); + sqlite3VdbeChangeP2(v, iAddr+2, iAddr+4); + sqlite3VdbeChangeP1(v, iAddr+4, eAuto-1); + sqlite3VdbeChangeP1(v, iAddr+5, iDb); + } } } }else @@ -597,6 +627,7 @@ void sqlite3Pragma( pTab = sqlite3FindTable(db, zRight, zDb); if( pTab ){ int i; + int nHidden = 0; Column *pCol; sqlite3VdbeSetNumCols(v, 6); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "cid", P3_STATIC); @@ -608,7 +639,11 @@ void sqlite3Pragma( sqlite3ViewGetColumnNames(pParse, pTab); for(i=0, pCol=pTab->aCol; inCol; i++, pCol++){ const Token *pDflt; - sqlite3VdbeAddOp(v, OP_Integer, i, 0); + if( IsHiddenColumn(pCol) ){ + nHidden++; + continue; + } + sqlite3VdbeAddOp(v, OP_Integer, i-nHidden, 0); sqlite3VdbeOp3(v, OP_String8, 0, 0, pCol->zName, 0); sqlite3VdbeOp3(v, OP_String8, 0, 0, pCol->zType ? pCol->zType : "", 0); @@ -1006,17 +1041,27 @@ void sqlite3Pragma( ** The user-version is not used internally by SQLite. It may be used by ** applications for any purpose. */ - if( sqlite3StrICmp(zLeft, "schema_version")==0 || - sqlite3StrICmp(zLeft, "user_version")==0 ){ + if( sqlite3StrICmp(zLeft, "schema_version")==0 + || sqlite3StrICmp(zLeft, "user_version")==0 + || sqlite3StrICmp(zLeft, "freelist_count")==0 + ){ int iCookie; /* Cookie index. 0 for schema-cookie, 6 for user-cookie. */ - if( zLeft[0]=='s' || zLeft[0]=='S' ){ - iCookie = 0; - }else{ - iCookie = 5; + switch( zLeft[0] ){ + case 's': case 'S': + iCookie = 0; + break; + case 'f': case 'F': + iCookie = 1; + iDb = (-1*(iDb+1)); + assert(iDb<=0); + break; + default: + iCookie = 5; + break; } - if( zRight ){ + if( zRight && iDb>=0 ){ /* Write the specified cookie value */ static const VdbeOpList setCookie[] = { { OP_Transaction, 0, 1, 0}, /* 0 */ ============================================================ --- sqlite/prepare.c 87c23644986b5e41a58bc76f05abebd899e00089 +++ sqlite/prepare.c 609bb27860ce98ab39889fecc0998dfd8220891b @@ -13,7 +13,7 @@ ** interface, and routines that contribute to loading the database schema ** from disk. ** -** $Id: prepare.c,v 1.50 2007/05/08 20:37:39 drh Exp $ +** $Id: prepare.c,v 1.51 2007/06/24 10:14:00 danielk1977 Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -213,7 +213,7 @@ static int sqlite3InitOne(sqlite3 *db, i ** meta[3] Use freelist if 0. Autovacuum if greater than zero. ** meta[4] Db text encoding. 1:UTF-8 2:UTF-16LE 3:UTF-16BE ** meta[5] The user cookie. Used by the application. - ** meta[6] + ** meta[6] Incremental-vacuum flag. ** meta[7] ** meta[8] ** meta[9] ============================================================ --- sqlite/printf.c 711908d6ff3385f9882df8ff405b9e0a2a4d04df +++ sqlite/printf.c 9b3048d270e8bb2f8b910b491ac3aadece6cfab2 @@ -74,6 +74,7 @@ #define etTOKEN 13 /* a pointer to a Token structure */ #define etSRCLIST 14 /* a pointer to a SrcList */ #define etPOINTER 15 /* The %p conversion */ +#define etSQLESCAPE3 16 /* %w -> Strings with '\"' doubled */ /* @@ -115,6 +116,7 @@ static const et_info fmtinfo[] = { { 'z', 0, 6, etDYNSTRING, 0, 0 }, { 'q', 0, 4, etSQLESCAPE, 0, 0 }, { 'Q', 0, 4, etSQLESCAPE2, 0, 0 }, + { 'w', 0, 4, etSQLESCAPE3, 0, 0 }, { 'c', 0, 0, etCHARX, 0, 0 }, { 'o', 8, 0, etRADIX, 0, 2 }, { 'u', 10, 0, etRADIX, 0, 0 }, @@ -454,7 +456,7 @@ static int vxprintf( if( xtype==etFLOAT ) realvalue += rounder; /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */ exp = 0; - if( isnan(realvalue) ){ + if( sqlite3_isnan(realvalue) ){ bufpt = "NaN"; length = 3; break; @@ -611,14 +613,16 @@ static int vxprintf( if( precision>=0 && precision {"a""bc"} +*/ +static void setQuotedToken(Token *p, const char *z){ + p->z = (u8 *)sqlite3MPrintf("\"%w\"", z); + p->dyn = 1; + if( p->z ){ + p->n = strlen((char *)p->z); + } +} + +/* ** Create an expression node for an identifier with the name of zName */ Expr *sqlite3CreateIdExpr(const char *zName){ @@ -1320,6 +1334,15 @@ static int prepSelectStmt(Parse *pParse, Expr *pExpr, *pRight; char *zName = pTab->aCol[j].zName; + /* If a column is marked as 'hidden' (currently only possible + ** for virtual tables), do not include it in the expanded + ** result-set list. + */ + if( IsHiddenColumn(&pTab->aCol[j]) ){ + assert(IsVirtual(pTab)); + continue; + } + if( i>0 ){ struct SrcList_item *pLeft = &pTabList->a[i-1]; if( (pLeft[1].jointype & JT_NATURAL)!=0 && @@ -1336,12 +1359,12 @@ static int prepSelectStmt(Parse *pParse, } pRight = sqlite3Expr(TK_ID, 0, 0, 0); if( pRight==0 ) break; - setToken(&pRight->token, zName); + setQuotedToken(&pRight->token, zName); if( zTabName && (longNames || pTabList->nSrc>1) ){ Expr *pLeft = sqlite3Expr(TK_ID, 0, 0, 0); pExpr = sqlite3Expr(TK_DOT, pLeft, pRight, 0); if( pExpr==0 ) break; - setToken(&pLeft->token, zTabName); + setQuotedToken(&pLeft->token, zTabName); setToken(&pExpr->span, sqlite3MPrintf("%s.%s", zTabName, zName)); pExpr->span.dyn = 1; pExpr->token.z = 0; @@ -1350,6 +1373,7 @@ static int prepSelectStmt(Parse *pParse, }else{ pExpr = pRight; pExpr->span = pExpr->token; + pExpr->span.dyn = 0; } if( longNames ){ pNew = sqlite3ExprListAppend(pNew, pExpr, &pExpr->span); @@ -1376,6 +1400,9 @@ static int prepSelectStmt(Parse *pParse, sqlite3ErrorMsg(pParse, "too many columns in result set"); rc = SQLITE_ERROR; } + if( sqlite3MallocFailed() ){ + rc = SQLITE_NOMEM; + } return rc; } @@ -2487,6 +2514,16 @@ static int simpleMinMaxQuery(Parse *pPar sqlite3VdbeAddOp(v, OP_MakeRecord, 1, 0); seekOp = OP_MoveGt; } + if( pIdx->aSortOrder[0]==SQLITE_SO_DESC ){ + /* Ticket #2514: invert the seek operator if we are using + ** a descending index. */ + if( seekOp==OP_Last ){ + seekOp = OP_Rewind; + }else{ + assert( seekOp==OP_MoveGt ); + seekOp = OP_MoveLt; + } + } sqlite3VdbeAddOp(v, seekOp, iIdx, 0); sqlite3VdbeAddOp(v, OP_IdxRowid, iIdx, 0); sqlite3VdbeAddOp(v, OP_Close, iIdx, 0); ============================================================ --- sqlite/sqlite3.h 2d972843072bbc136f0b0e5398e7a7aeedee9f87 +++ sqlite/sqlite3.h 535f235f65b21ca83ff426b755a49e4ca3624dee @@ -30,7 +30,7 @@ ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** -** @(#) $Id: sqlite.h.in,v 1.212 2007/06/14 20:57:19 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.218 2007/07/19 12:41:40 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ @@ -81,8 +81,8 @@ extern "C" { ** ** See also: [sqlite3_libversion()] and [sqlite3_libversion_number()]. */ -#define SQLITE_VERSION "3.4.0" -#define SQLITE_VERSION_NUMBER 3004000 +#define SQLITE_VERSION "3.4.1" +#define SQLITE_VERSION_NUMBER 3004001 /* ** CAPI3REF: Run-Time Library Version Numbers @@ -369,7 +369,7 @@ sqlite_int64 sqlite3_last_insert_rowid(s ** ** SQLite implements the command "DELETE FROM table" without a WHERE clause ** by dropping and recreating the table. (This is much faster than going -** through and deleting individual elements form the table.) Because of +** through and deleting individual elements from the table.) Because of ** this optimization, the change count for "DELETE FROM table" will be ** zero regardless of the number of elements that were originally in the ** table. To get an accurate count of the number of rows deleted, use @@ -963,10 +963,14 @@ typedef struct sqlite3_stmt sqlite3_stmt ** The second argument "zSql" is the statement to be compiled, encoded ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() ** interfaces uses UTF-8 and sqlite3_prepare16() and sqlite3_prepare16_v2() -** use UTF-16. If the next argument, "nBytes", is less +** use UTF-16. +** +** If the nByte argument is less ** than zero, then zSql is read up to the first zero terminator. If -** "nBytes" is not less than zero, then it is the length of the string zSql -** in bytes (not characters). +** nByte is non-negative, then it is the maximum number of +** bytes read from zSql. When nByte is non-negative, the +** zSql string ends at either the first '\000' character or +** until the nByte-th byte, whichever comes first. ** ** *pzTail is made to point to the first byte past the end of the first ** SQL statement in zSql. This routine only compiles the first statement @@ -1019,28 +1023,28 @@ int sqlite3_prepare( int sqlite3_prepare( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ - int nBytes, /* Length of zSql in bytes. */ + int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); int sqlite3_prepare_v2( sqlite3 *db, /* Database handle */ const char *zSql, /* SQL statement, UTF-8 encoded */ - int nBytes, /* Length of zSql in bytes. */ + int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const char **pzTail /* OUT: Pointer to unused portion of zSql */ ); int sqlite3_prepare16( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ - int nBytes, /* Length of zSql in bytes. */ + int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); int sqlite3_prepare16_v2( sqlite3 *db, /* Database handle */ const void *zSql, /* SQL statement, UTF-16 encoded */ - int nBytes, /* Length of zSql in bytes. */ + int nByte, /* Maximum length of zSql in bytes. */ sqlite3_stmt **ppStmt, /* OUT: Statement handle */ const void **pzTail /* OUT: Pointer to unused portion of zSql */ ); @@ -1237,11 +1241,17 @@ const void *sqlite3_column_name16(sqlite ** These routines provide a means to determine what column of what ** table in which database a result of a SELECT statement comes from. ** The name of the database or table or column can be returned as -** either a UTF8 or UTF16 string. The returned string is valid until +** either a UTF8 or UTF16 string. The _database_ routines return +** the database name, the _table_ routines return the table name, and +** the origin_ routines return the column name. +** The returned string is valid until ** the [sqlite3_stmt | prepared statement] is destroyed using ** [sqlite3_finalize()] or until the same information is requested -** again about the same column. +** again in a different encoding. ** +** The names returned are the original un-aliased names of the +** database, table, and column. +** ** The first argument to the following calls is a ** [sqlite3_stmt | compiled SQL statement]. ** These functions return information about the Nth column returned by @@ -1440,8 +1450,6 @@ int sqlite3_data_count(sqlite3_stmt *pSt ** versions of SQLite may change the behavior of sqlite3_column_type() ** following a type conversion. ** -*** The sqlite3_column_nm -** ** If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() ** routine returns the number of bytes in that BLOB or string. ** If the result is a UTF-16 string, then sqlite3_column_bytes() converts @@ -1988,7 +1996,7 @@ int sqlite3_rekey( /* ** CAPI3REF: Suspend Execution For A Short Time ** -** This function causes the current thread to suspect execution +** This function causes the current thread to suspend execution ** a number of milliseconds specified in its parameter. ** ** If the operating system does not support sleep requests with @@ -2399,6 +2407,8 @@ struct sqlite3_module { int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), void **ppArg); + + int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); }; /* @@ -2494,6 +2504,19 @@ int sqlite3_create_module( ); /* +** This routine is identical to the sqlite3_create_module() method above, +** except that it allows a destructor function to be specified. It is +** even more experimental than the rest of the virtual tables API. +*/ +int sqlite3_create_module_v2( + sqlite3 *db, /* SQLite connection to register module with */ + const char *zName, /* Name of the module */ + const sqlite3_module *, /* Methods for the module */ + void *, /* Client data for xCreate/xConnect */ + void(*xDestroy)(void*) /* Module destructor function */ +); + +/* ** Every module implementation uses a subclass of the following structure ** to describe a particular instance of the module. Each subclass will ** be taylored to the specific needs of the module implementation. The ============================================================ --- sqlite/sqlite3ext.h 7d0d363ea7327e817ef0dfe1b7eee1f171b72890 +++ sqlite/sqlite3ext.h a27bedc222df5e5f0f458ac99726d0483b953a91 @@ -15,7 +15,7 @@ ** as extensions by SQLite should #include this file instead of ** sqlite3.h. ** -** @(#) $Id: sqlite3ext.h,v 1.10 2007/03/29 18:46:01 drh Exp $ +** @(#) $Id: sqlite3ext.h,v 1.12 2007/07/20 10:48:36 drh Exp $ */ #ifndef _SQLITE3EXT_H_ #define _SQLITE3EXT_H_ @@ -26,6 +26,12 @@ typedef struct sqlite3_api_routines sqli /* ** The following structure hold pointers to all of the SQLite API ** routines. +** +** WARNING: In order to maintain backwards compatibility, add new +** interfaces to the end of this structure only. If you insert new +** interfaces in the middle of this structure, then older different +** versions of SQLite will not be able to load each others shared +** libraries! */ struct sqlite3_api_routines { void * (*aggregate_context)(sqlite3_context*,int nBytes); @@ -147,6 +153,7 @@ struct sqlite3_api_routines { int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**); int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); int (*clear_bindings)(sqlite3_stmt*); + int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,void (*xDestroy)(void *)); }; /* @@ -209,6 +216,7 @@ struct sqlite3_api_routines { #define sqlite3_create_function sqlite3_api->create_function #define sqlite3_create_function16 sqlite3_api->create_function16 #define sqlite3_create_module sqlite3_api->create_module +#define sqlite3_create_module_v2 sqlite3_api->create_module_v2 #define sqlite3_data_count sqlite3_api->data_count #define sqlite3_db_handle sqlite3_api->db_handle #define sqlite3_declare_vtab sqlite3_api->declare_vtab ============================================================ --- sqlite/sqliteInt.h 208c40b6e11925a321ec159d889e0ec06b618359 +++ sqlite/sqliteInt.h 81183ae71162818bf60478e738ff68604128bb06 @@ -11,11 +11,11 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.572 2007/06/10 22:57:33 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.578 2007/06/26 10:38:55 danielk1977 Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ -#include "limits.h" +#include "sqliteLimit.h" #if defined(SQLITE_TCL) || defined(TCLSH) @@ -65,9 +65,7 @@ #include #include -#if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) -# define isnan(X) ((X)!=(X)) -#endif +#define sqlite3_isnan(X) ((X)!=(X)) /* ** If compiling for a processor that lacks floating point support, @@ -586,6 +584,7 @@ struct Module { const sqlite3_module *pModule; /* Callback pointers */ const char *zName; /* Name passed to create_module() */ void *pAux; /* pAux passed to create_module() */ + void (*xDestroy)(void *); /* Module destructor function */ }; /* @@ -607,6 +606,9 @@ struct Column { u8 notNull; /* True if there is a NOT NULL constraint */ u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */ char affinity; /* One of the SQLITE_AFF_... values */ +#ifndef SQLITE_OMIT_VIRTUALTABLE + u8 isHidden; /* True if this column is 'hidden' */ +#endif }; /* @@ -745,9 +747,11 @@ struct Table { ** table support is omitted from the build. */ #ifndef SQLITE_OMIT_VIRTUALTABLE -# define IsVirtual(X) ((X)->isVirtual) +# define IsVirtual(X) ((X)->isVirtual) +# define IsHiddenColumn(X) ((X)->isHidden) #else -# define IsVirtual(X) 0 +# define IsVirtual(X) 0 +# define IsHiddenColumn(X) 0 #endif /* ============================================================ --- sqlite/limits.h 31eba3f797d751a42dc81f2f509f8bb6056cfd81 +++ sqlite/sqliteLimit.h ee8903fcebd2a83f9c6192f1e869b6e09e927226 @@ -12,7 +12,7 @@ ** ** This file defines various limits of what SQLite can process. ** -** @(#) $Id: limits.h,v 1.9 2007/06/09 09:53:51 drh Exp $ +** @(#) $Id: sqliteLimit.h,v 1.1 2007/06/19 15:23:48 drh Exp $ */ /* ============================================================ --- sqlite/tokenize.c 6cef9e6fc454d789a32c5b509ccb193a2b01977b +++ sqlite/tokenize.c 0f0955ef7b8ab99ba2d3099faa89b80ccba3733a @@ -15,7 +15,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.129 2007/05/15 14:34:32 drh Exp $ +** $Id: tokenize.c,v 1.130 2007/07/13 10:26:08 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -381,6 +381,13 @@ int sqlite3GetToken(const unsigned char } /* +** The interface to the LEMON-generated parser +*/ +void *sqlite3ParserAlloc(void*(*)(size_t)); +void sqlite3ParserFree(void*, void(*)(void*)); +void sqlite3Parser(void*, int, Token, Parse*); + +/* ** Run the parser on the given SQL string. The parser structure is ** passed in. An SQLITE_ status code is returned. If an error occurs ** and pzErrMsg!=NULL then an error message might be written into @@ -394,9 +401,6 @@ int sqlite3RunParser(Parse *pParse, cons int tokenType; int lastTokenParsed = -1; sqlite3 *db = pParse->db; - extern void *sqlite3ParserAlloc(void*(*)(size_t)); - extern void sqlite3ParserFree(void*, void(*)(void*)); - extern void sqlite3Parser(void*, int, Token, Parse*); if( db->activeVdbeCnt==0 ){ db->u1.isInterrupted = 0; ============================================================ --- sqlite/update.c 3359041db390a8f856d67272f299600e2104f350 +++ sqlite/update.c 6b10becb6235ea314ed245fbfbf8b38755e3166e @@ -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.137 2007/03/29 05:51:49 drh Exp $ +** $Id: update.c,v 1.138 2007/06/25 16:29:34 danielk1977 Exp $ */ #include "sqliteInt.h" @@ -59,6 +59,7 @@ void sqlite3ColumnDefault(Vdbe *v, Table sqlite3_value *pValue; u8 enc = ENC(sqlite3VdbeDb(v)); Column *pCol = &pTab->aCol[i]; + assert( inCol ); sqlite3ValueFromExpr(pCol->pDflt, enc, pCol->affinity, &pValue); if( pValue ){ sqlite3VdbeChangeP3(v, -1, (const char *)pValue, P3_MEM); ============================================================ --- sqlite/util.c 80cdf6b68d03b8f0ab3237a390842e039cff66c6 +++ sqlite/util.c 9e81d417fc60bd2fe156f8f2317aa4845bc6cc90 @@ -14,7 +14,7 @@ ** This file contains functions for allocating memory, comparing ** strings, and stuff like that. ** -** $Id: util.c,v 1.205 2007/05/16 17:50:46 danielk1977 Exp $ +** $Id: util.c,v 1.207 2007/06/26 00:37:28 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -300,11 +300,33 @@ int sqlite3AtoF(const char *z, double *p } /* +** Compare the 19-character string zNum against the text representation +** value 2^63: 9223372036854775808. Return negative, zero, or positive +** if zNum is less than, equal to, or greater than the string. +** +** Unlike memcmp() this routine is guaranteed to return the difference +** in the values of the last digit if the only difference is in the +** last digit. So, for example, +** +** compare2pow63("9223372036854775800") +** +** will return -8. +*/ +static int compare2pow63(const char *zNum){ + int c; + c = memcmp(zNum,"922337203685477580",18); + if( c==0 ){ + c = zNum[18] - '8'; + } + return c; +} + + +/* ** Return TRUE if zNum is a 64-bit signed integer and write ** the value of the integer into *pNum. If zNum is not an integer ** or is an integer that is too large to be expressed with 64 bits, -** then return false. If n>0 and the integer is string is not -** exactly n bytes long, return false. +** then return false. ** ** When this routine was originally written it dealt with only ** 32-bit numbers. At that time, it was much faster than the @@ -324,63 +346,97 @@ int sqlite3Atoi64(const char *zNum, i64 }else{ neg = 0; } + while( zNum[0]=='0' ){ zNum++; } /* Skip over leading zeros. Ticket #2454 */ for(i=0; (c=zNum[i])>='0' && c<='9'; i++){ v = v*10 + c - '0'; } *pNum = neg ? -v : v; - return c==0 && i>0 && - (i<19 || (i==19 && memcmp(zNum,"9223372036854775807",19)<=0)); + if( c!=0 || i==0 || i>19 ){ + /* zNum is empty or contains non-numeric text or is longer + ** than 19 digits (thus guaranting that it is too large) */ + return 0; + }else if( i<19 ){ + /* Less than 19 digits, so we know that it fits in 64 bits */ + return 1; + }else{ + /* 19-digit numbers must be no larger than 9223372036854775807 if positive + ** or 9223372036854775808 if negative. Note that 9223372036854665808 + ** is 2^63. */ + return compare2pow63(zNum)='0' && c<='9'; i++){} - return i<10 || (i==10 && memcmp(zNum,"2147483647",10)<=0); + if( i<19 ){ + /* Guaranteed to fit if less than 19 digits */ + return 1; + }else if( i>19 ){ + /* Guaranteed to be too big if greater than 19 digits */ + return 0; + }else{ + /* Compare against 2^63. */ + return compare2pow63(zNum)='0' && c<='9'; i++){} - return i<19 || (i==19 && memcmp(zNum,"9223372036854775807",19)<=0); + int neg = 0; + if( zNum[0]=='-' ){ + neg = 1; + zNum++; + }else if( zNum[0]=='+' ){ + zNum++; + } + while( zNum[0]=='0' ) zNum++; + for(i=0; i<10 && (c = zNum[i] - '0')>=0 && c<=9; i++){ + v = v*10 + c; + } + if( i>9 ){ + return 0; + } + if( v-neg>2147483647 ){ + return 0; + } + if( neg ){ + v = -v; + } + *pValue = (int)v; + return 1; } - /* ** Check to make sure we have a valid db pointer. This test is not ** foolproof but it does provide some measure of protection against ============================================================ --- sqlite/vdbe.c 68d7f4e47b07d89c4ea246ae87b69f8fb81f7da1 +++ sqlite/vdbe.c a96ce3799f037b8f4e185a01823072320fd9ccb3 @@ -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.626 2007/06/15 14:53:53 danielk1977 Exp $ +** $Id: vdbe.c,v 1.636 2007/07/01 21:18:40 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -1153,11 +1153,20 @@ case OP_Remainder: { /* same a case OP_Multiply: b *= a; break; case OP_Divide: { if( a==0 ) goto divide_by_zero; + /* Dividing the largest possible negative 64-bit integer (1<<63) by + ** -1 returns an integer to large to store in a 64-bit data-type. On + ** some architectures, the value overflows to (1<<63). On others, + ** a SIGFPE is issued. The following statement normalizes this + ** behaviour so that all architectures behave as if integer + ** overflow occured. + */ + if( a==-1 && b==(((i64)1)<<63) ) a = 1; b /= a; break; } default: { if( a==0 ) goto divide_by_zero; + if( a==-1 ) a = 1; b %= a; break; } @@ -1184,11 +1193,12 @@ case OP_Remainder: { /* same a i64 ia = (i64)a; i64 ib = (i64)b; if( ia==0 ) goto divide_by_zero; + if( ia==-1 ) ia = 1; b = ib % ia; break; } } - if( isnan(b) ){ + if( sqlite3_isnan(b) ){ goto divide_by_zero; } Release(pTos); @@ -2398,6 +2408,7 @@ case OP_Statement: { /* no-push */ assert( sqlite3BtreeIsInTrans(pBt) ); if( !sqlite3BtreeIsInStmt(pBt) ){ rc = sqlite3BtreeBeginStmt(pBt); + p->openedStatement = 1; } } break; @@ -2509,15 +2520,27 @@ case OP_Transaction: { /* no-push ** the main database file and P1==1 is the database file used to store ** temporary tables. ** +** If P1 is negative, then this is a request to read the size of a +** databases free-list. P2 must be set to 1 in this case. The actual +** database accessed is ((P1+1)*-1). For example, a P1 parameter of -1 +** corresponds to database 0 ("main"), a P1 of -2 is database 1 ("temp"). +** ** There must be a read-lock on the database (either a transaction ** must be started or there must be an open cursor) before ** executing this instruction. */ case OP_ReadCookie: { int iMeta; + int iDb = pOp->p1; + int iCookie = pOp->p2; + assert( pOp->p2p1>=0 && pOp->p1nDb ); - assert( db->aDb[pOp->p1].pBt!=0 ); + if( iDb<0 ){ + iDb = (-1*(iDb+1)); + iCookie *= -1; + } + assert( iDb>=0 && iDbnDb ); + assert( db->aDb[iDb].pBt!=0 ); /* The indexing of meta values at the schema layer is off by one from ** the indexing in the btree layer. The btree considers meta[0] to ** be the number of free pages in the database (a read-only value) @@ -2525,7 +2548,7 @@ case OP_ReadCookie: { ** meta[1] to be the schema cookie. So we have to shift the index ** by one in the following statement. */ - rc = sqlite3BtreeGetMeta(db->aDb[pOp->p1].pBt, 1 + pOp->p2, (u32 *)&iMeta); + rc = sqlite3BtreeGetMeta(db->aDb[iDb].pBt, 1 + iCookie, (u32 *)&iMeta); pTos++; pTos->u.i = iMeta; pTos->flags = MEM_Int; @@ -4283,7 +4306,7 @@ case OP_IntegrityCk: { pnErr = &p->aMem[j]; assert( (pnErr->flags & MEM_Int)!=0 ); for(j=0; ju.i; + aRoot[j] = pTos[-j].u.i; } aRoot[j] = 0; popStack(&pTos, nRoot); @@ -4976,7 +4999,31 @@ case OP_VNext: { /* no-push */ } #endif /* SQLITE_OMIT_VIRTUALTABLE */ +#ifndef SQLITE_OMIT_VIRTUALTABLE +/* Opcode: VRename * * P3 +** +** P3 is a pointer to a virtual table object, an sqlite3_vtab structure. +** This opcode invokes the corresponding xRename method. The value +** on the top of the stack is popped and passed as the zName argument +** to the xRename method. +*/ +case OP_VRename: { /* no-push */ + sqlite3_vtab *pVtab = (sqlite3_vtab *)(pOp->p3); + assert( pVtab->pModule->xRename ); + Stringify(pTos, encoding); + + if( sqlite3SafetyOff(db) ) goto abort_due_to_misuse; + sqlite3VtabLock(pVtab); + rc = pVtab->pModule->xRename(pVtab, pTos->z); + sqlite3VtabUnlock(db, pVtab); + if( sqlite3SafetyOn(db) ) goto abort_due_to_misuse; + + popStack(&pTos, 1); + break; +} +#endif + #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VUpdate P1 P2 P3 ** ============================================================ --- sqlite/vdbeInt.h 7d2bf163d6d4e815724a457f2216dd8e38c3955c +++ sqlite/vdbeInt.h c3514903cad9e36d6b3242be20261351d09db56c @@ -343,6 +343,7 @@ struct Vdbe { #ifdef SQLITE_DEBUG FILE *trace; /* Write an execution trace here, if not NULL */ #endif + int openedStatement; /* True if this VM has opened a statement journal */ #ifdef SQLITE_SSE int fetchId; /* Statement number used by sqlite3_fetch_statement */ int lru; /* Counter used for LRU cache replacement */ ============================================================ --- sqlite/vdbeapi.c 3747e4c3bc3139ff688bb3df462b10e42c084d16 +++ sqlite/vdbeapi.c fe3b713d5d37f8dfff1aa7546dae213a0e492f10 @@ -275,6 +275,7 @@ end_of_step: if( p->zSql && (rc&0xff)db, p->rc, 0); return p->rc; }else{ /* This is for legacy sqlite3_prepare() builds and when the code @@ -453,7 +454,7 @@ static Mem *columnMem(sqlite3_stmt *pStm static Mem *columnMem(sqlite3_stmt *pStmt, int i){ Vdbe *pVm = (Vdbe *)pStmt; int vals = sqlite3_data_count(pStmt); - if( i>=vals || i<0 ){ + if( pVm==0 || pVm->resOnStack==0 || i>=pVm->nResColumn || i<0 ){ static const Mem nullMem = {{0}, 0.0, "", 0, MEM_Null, SQLITE_NULL }; sqlite3Error(pVm->db, SQLITE_RANGE, 0); return (Mem*)&nullMem; ============================================================ --- sqlite/vdbeaux.c b4eda47b713aa8fbe70dce4922852fd48b919555 +++ sqlite/vdbeaux.c ca1d673fd5e45fe9ba994391b11568c48a7e1b59 @@ -299,18 +299,23 @@ static void resolveP2Values(Vdbe *p, int #endif ){ if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; - }else if( opcode==OP_Halt ){ + } + if( opcode==OP_Halt ){ if( pOp->p1==SQLITE_CONSTRAINT && pOp->p2==OE_Abort ){ doesStatementRollback = 1; } }else if( opcode==OP_Statement ){ hasStatementBegin = 1; +#ifndef SQLITE_OMIT_VIRTUALTABLE + }else if( opcode==OP_VUpdate || opcode==OP_VRename ){ + doesStatementRollback = 1; }else if( opcode==OP_VFilter ){ int n; assert( p->nOp - i >= 3 ); assert( pOp[-2].opcode==OP_Integer ); n = pOp[-2].p1; if( n>nMaxArgs ) nMaxArgs = n; +#endif } if( opcodeNoPush(opcode) ){ nMaxStack--; @@ -898,6 +903,7 @@ void sqlite3VdbeMakeReady( p->nChange = 0; p->cacheCtr = 1; p->minWriteFileFormat = 255; + p->openedStatement = 0; #ifdef VDBE_PROFILE { int i; @@ -980,6 +986,7 @@ static void Cleanup(Vdbe *p){ p->contextStackTop = 0; sqliteFree(p->zErrMsg); p->zErrMsg = 0; + p->resOnStack = 0; } /* @@ -1446,7 +1453,9 @@ int sqlite3VdbeHalt(Vdbe *p){ } }else if( !xFunc ){ if( p->rc==SQLITE_OK || p->errorAction==OE_Fail ){ - xFunc = sqlite3BtreeCommitStmt; + if( p->openedStatement ){ + xFunc = sqlite3BtreeCommitStmt; + } }else if( p->errorAction==OE_Abort ){ xFunc = sqlite3BtreeRollbackStmt; }else{ ============================================================ --- sqlite/vdbeblob.c 96f3572fdc45eda5be06e6372b612bc30742d9f0 +++ sqlite/vdbeblob.c bb30b3e387c35ba869949494b2736aff97159470 @@ -12,7 +12,7 @@ ** ** This file contains code used to implement incremental BLOB I/O. ** -** $Id: vdbeblob.c,v 1.10 2007/05/08 20:37:40 drh Exp $ +** $Id: vdbeblob.c,v 1.11 2007/06/27 00:36:14 drh Exp $ */ #include "sqliteInt.h" @@ -278,6 +278,7 @@ static int blobReadWrite( sqlite3VdbeFinalize(v); p->pStmt = 0; }else{ + db->errCode = rc; v->rc = rc; } ============================================================ --- sqlite/vdbemem.c d86c25bbfe8102499ff7505fca44a779c68694d8 +++ sqlite/vdbemem.c ca4d3994507cb0a9504820293af69f5c778b4abd @@ -436,7 +436,7 @@ void sqlite3VdbeMemSetDouble(Mem *pMem, ** manifest type REAL. */ void sqlite3VdbeMemSetDouble(Mem *pMem, double val){ - if( isnan(val) ){ + if( sqlite3_isnan(val) ){ sqlite3VdbeMemSetNull(pMem); }else{ sqlite3VdbeMemRelease(pMem); ============================================================ --- sqlite/vtab.c c5ebebf615b2f29499fbe97a584c4bb342632aa0 +++ sqlite/vtab.c 60dc6d881c3049ec0e9f780e6beb953dbd78673d @@ -11,20 +11,18 @@ ************************************************************************* ** This file contains code used to help implement virtual tables. ** -** $Id: vtab.c,v 1.46 2007/05/04 13:15:57 drh Exp $ +** $Id: vtab.c,v 1.48 2007/06/26 10:38:55 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_VIRTUALTABLE #include "sqliteInt.h" -/* -** External API function used to create a new virtual-table module. -*/ -int sqlite3_create_module( +static int createModule( sqlite3 *db, /* Database in which module is registered */ const char *zName, /* Name assigned to this module */ const sqlite3_module *pModule, /* The definition of the module */ - void *pAux /* Context pointer for xCreate/xConnect */ -){ + void *pAux, /* Context pointer for xCreate/xConnect */ + void (*xDestroy)(void *) /* Module destructor function */ +) { int nName = strlen(zName); Module *pMod = (Module *)sqliteMallocRaw(sizeof(Module) + nName + 1); if( pMod ){ @@ -33,14 +31,44 @@ int sqlite3_create_module( pMod->zName = zCopy; pMod->pModule = pModule; pMod->pAux = pAux; + pMod->xDestroy = xDestroy; pMod = (Module *)sqlite3HashInsert(&db->aModule, zCopy, nName, (void*)pMod); + if( pMod && pMod->xDestroy ){ + pMod->xDestroy(pMod->pAux); + } sqliteFree(pMod); sqlite3ResetInternalSchema(db, 0); } return sqlite3ApiExit(db, SQLITE_OK); } + /* +** External API function used to create a new virtual-table module. +*/ +int sqlite3_create_module( + sqlite3 *db, /* Database in which module is registered */ + const char *zName, /* Name assigned to this module */ + const sqlite3_module *pModule, /* The definition of the module */ + void *pAux /* Context pointer for xCreate/xConnect */ +){ + return createModule(db, zName, pModule, pAux, 0); +} + +/* +** External API function used to create a new virtual-table module. +*/ +int sqlite3_create_module_v2( + sqlite3 *db, /* Database in which module is registered */ + const char *zName, /* Name assigned to this module */ + const sqlite3_module *pModule, /* The definition of the module */ + void *pAux, /* Context pointer for xCreate/xConnect */ + void (*xDestroy)(void *) /* Module destructor function */ +){ + return createModule(db, zName, pModule, pAux, xDestroy); +} + +/* ** Lock the virtual table so that it cannot be disconnected. ** Locks nest. Every lock should have a corresponding unlock. ** If an unlock is omitted, resources leaks will occur. @@ -348,6 +376,44 @@ static int vtabCallConstructor( } db->pVTab = 0; sqliteFree(zModuleName); + + /* If everything went according to plan, loop through the columns + ** of the table to see if any of them contain the token "hidden". + ** If so, set the Column.isHidden flag and remove the token from + ** the type string. + */ + if( rc==SQLITE_OK ){ + int iCol; + for(iCol=0; iColnCol; iCol++){ + char *zType = pTab->aCol[iCol].zType; + int nType; + int i = 0; + if( !zType ) continue; + nType = strlen(zType); + if( sqlite3StrNICmp("hidden", zType, 6) || (zType[6] && zType[6]!=' ') ){ + for(i=0; i0 ){ + assert(zType[i-1]==' '); + zType[i-1] = '\0'; + } + pTab->aCol[iCol].isHidden = 1; + } + } + } return rc; }