| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.7.11. By combining all the individual C code files into this |
| 3 | +** version 3.7.12. By combining all the individual C code files into this |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| | @@ -655,13 +655,13 @@ |
| 655 | 655 | ** |
| 656 | 656 | ** See also: [sqlite3_libversion()], |
| 657 | 657 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 658 | 658 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 659 | 659 | */ |
| 660 | | -#define SQLITE_VERSION "3.7.11" |
| 661 | | -#define SQLITE_VERSION_NUMBER 3007011 |
| 662 | | -#define SQLITE_SOURCE_ID "2012-03-16 00:28:11 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e" |
| 660 | +#define SQLITE_VERSION "3.7.12" |
| 661 | +#define SQLITE_VERSION_NUMBER 3007012 |
| 662 | +#define SQLITE_SOURCE_ID "2012-03-31 19:12:23 af602d87736b52802a4e760ffeeaa28112b99d9a" |
| 663 | 663 | |
| 664 | 664 | /* |
| 665 | 665 | ** CAPI3REF: Run-Time Library Version Numbers |
| 666 | 666 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 667 | 667 | ** |
| | @@ -6554,10 +6554,21 @@ |
| 6554 | 6554 | ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt> |
| 6555 | 6555 | ** <dd>This parameter returns the number of pager cache misses that have |
| 6556 | 6556 | ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS |
| 6557 | 6557 | ** is always 0. |
| 6558 | 6558 | ** </dd> |
| 6559 | +** |
| 6560 | +** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt> |
| 6561 | +** <dd>This parameter returns the number of dirty cache entries that have |
| 6562 | +** been written to disk. Specifically, the number of pages written to the |
| 6563 | +** wal file in wal mode databases, or the number of pages written to the |
| 6564 | +** database file in rollback mode databases. Any pages written as part of |
| 6565 | +** transaction rollback or database recovery operations are not included. |
| 6566 | +** If an IO or other error occurs while writing a page to disk, the effect |
| 6567 | +** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The |
| 6568 | +** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0. |
| 6569 | +** </dd> |
| 6559 | 6570 | ** </dl> |
| 6560 | 6571 | */ |
| 6561 | 6572 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 6562 | 6573 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 6563 | 6574 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| | @@ -6565,11 +6576,12 @@ |
| 6565 | 6576 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 6566 | 6577 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 6567 | 6578 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 6568 | 6579 | #define SQLITE_DBSTATUS_CACHE_HIT 7 |
| 6569 | 6580 | #define SQLITE_DBSTATUS_CACHE_MISS 8 |
| 6570 | | -#define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */ |
| 6581 | +#define SQLITE_DBSTATUS_CACHE_WRITE 9 |
| 6582 | +#define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */ |
| 6571 | 6583 | |
| 6572 | 6584 | |
| 6573 | 6585 | /* |
| 6574 | 6586 | ** CAPI3REF: Prepared Statement Status |
| 6575 | 6587 | ** |
| | @@ -9919,18 +9931,22 @@ |
| 9919 | 9931 | void (*xDestroy)(void *); |
| 9920 | 9932 | void *pUserData; |
| 9921 | 9933 | }; |
| 9922 | 9934 | |
| 9923 | 9935 | /* |
| 9924 | | -** Possible values for FuncDef.flags |
| 9936 | +** Possible values for FuncDef.flags. Note that the _LENGTH and _TYPEOF |
| 9937 | +** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. There |
| 9938 | +** are assert() statements in the code to verify this. |
| 9925 | 9939 | */ |
| 9926 | 9940 | #define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ |
| 9927 | 9941 | #define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ |
| 9928 | 9942 | #define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */ |
| 9929 | 9943 | #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */ |
| 9930 | | -#define SQLITE_FUNC_COUNT 0x20 /* Built-in count(*) aggregate */ |
| 9931 | | -#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */ |
| 9944 | +#define SQLITE_FUNC_COUNT 0x10 /* Built-in count(*) aggregate */ |
| 9945 | +#define SQLITE_FUNC_COALESCE 0x20 /* Built-in coalesce() or ifnull() function */ |
| 9946 | +#define SQLITE_FUNC_LENGTH 0x40 /* Built-in length() function */ |
| 9947 | +#define SQLITE_FUNC_TYPEOF 0x80 /* Built-in typeof() function */ |
| 9932 | 9948 | |
| 9933 | 9949 | /* |
| 9934 | 9950 | ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are |
| 9935 | 9951 | ** used to create the initializers for the FuncDef structures. |
| 9936 | 9952 | ** |
| | @@ -9954,11 +9970,14 @@ |
| 9954 | 9970 | ** available as the function user-data (sqlite3_user_data()). The |
| 9955 | 9971 | ** FuncDef.flags variable is set to the value passed as the flags |
| 9956 | 9972 | ** parameter. |
| 9957 | 9973 | */ |
| 9958 | 9974 | #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 9959 | | - {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ |
| 9975 | + {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 9976 | + SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
| 9977 | +#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ |
| 9978 | + {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags, \ |
| 9960 | 9979 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0} |
| 9961 | 9980 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
| 9962 | 9981 | {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ |
| 9963 | 9982 | pArg, 0, xFunc, 0, 0, #zName, 0, 0} |
| 9964 | 9983 | #define LIKEFUNC(zName, nArg, arg, flags) \ |
| | @@ -10184,11 +10203,11 @@ |
| 10184 | 10203 | u8 tabFlags; /* Mask of TF_* values */ |
| 10185 | 10204 | u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ |
| 10186 | 10205 | FKey *pFKey; /* Linked list of all foreign keys in this table */ |
| 10187 | 10206 | char *zColAff; /* String defining the affinity of each column */ |
| 10188 | 10207 | #ifndef SQLITE_OMIT_CHECK |
| 10189 | | - Expr *pCheck; /* The AND of all CHECK constraints */ |
| 10208 | + ExprList *pCheck; /* All CHECK constraints */ |
| 10190 | 10209 | #endif |
| 10191 | 10210 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 10192 | 10211 | int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ |
| 10193 | 10212 | #endif |
| 10194 | 10213 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| | @@ -10577,10 +10596,11 @@ |
| 10577 | 10596 | ** TK_VARIABLE: variable number (always >= 1). */ |
| 10578 | 10597 | i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */ |
| 10579 | 10598 | i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */ |
| 10580 | 10599 | u8 flags2; /* Second set of flags. EP2_... */ |
| 10581 | 10600 | u8 op2; /* If a TK_REGISTER, the original value of Expr.op */ |
| 10601 | + /* If TK_COLUMN, the value of p5 for OP_Column */ |
| 10582 | 10602 | AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ |
| 10583 | 10603 | Table *pTab; /* Table for TK_COLUMN expressions. */ |
| 10584 | 10604 | #if SQLITE_MAX_EXPR_DEPTH>0 |
| 10585 | 10605 | int nHeight; /* Height of the tree headed by this node */ |
| 10586 | 10606 | #endif |
| | @@ -10599,11 +10619,11 @@ |
| 10599 | 10619 | #define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */ |
| 10600 | 10620 | #define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */ |
| 10601 | 10621 | #define EP_FixedDest 0x0200 /* Result needed in a specific register */ |
| 10602 | 10622 | #define EP_IntValue 0x0400 /* Integer value contained in u.iValue */ |
| 10603 | 10623 | #define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */ |
| 10604 | | -#define EP_Hint 0x1000 /* Optimizer hint. Not required for correctness */ |
| 10624 | +#define EP_Hint 0x1000 /* Not used */ |
| 10605 | 10625 | #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */ |
| 10606 | 10626 | #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */ |
| 10607 | 10627 | #define EP_Static 0x8000 /* Held in memory not obtained from malloc() */ |
| 10608 | 10628 | |
| 10609 | 10629 | /* |
| | @@ -11118,10 +11138,11 @@ |
| 11118 | 11138 | int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */ |
| 11119 | 11139 | int cookieValue[SQLITE_MAX_ATTACHED+2]; /* Values of cookies to verify */ |
| 11120 | 11140 | int regRowid; /* Register holding rowid of CREATE TABLE entry */ |
| 11121 | 11141 | int regRoot; /* Register holding root page number for new objects */ |
| 11122 | 11142 | int nMaxArg; /* Max args passed to user function by sub-program */ |
| 11143 | + Token constraintName;/* Name of the constraint currently being parsed */ |
| 11123 | 11144 | #ifndef SQLITE_OMIT_SHARED_CACHE |
| 11124 | 11145 | int nTableLock; /* Number of locks in aTableLock */ |
| 11125 | 11146 | TableLock *aTableLock; /* Required table locks for shared-cache mode */ |
| 11126 | 11147 | #endif |
| 11127 | 11148 | AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ |
| | @@ -11186,18 +11207,20 @@ |
| 11186 | 11207 | const char *zAuthContext; /* Put saved Parse.zAuthContext here */ |
| 11187 | 11208 | Parse *pParse; /* The Parse structure */ |
| 11188 | 11209 | }; |
| 11189 | 11210 | |
| 11190 | 11211 | /* |
| 11191 | | -** Bitfield flags for P5 value in OP_Insert and OP_Delete |
| 11212 | +** Bitfield flags for P5 value in various opcodes. |
| 11192 | 11213 | */ |
| 11193 | 11214 | #define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */ |
| 11194 | 11215 | #define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */ |
| 11195 | 11216 | #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */ |
| 11196 | 11217 | #define OPFLAG_APPEND 0x08 /* This is likely to be an append */ |
| 11197 | 11218 | #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */ |
| 11198 | 11219 | #define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */ |
| 11220 | +#define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */ |
| 11221 | +#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */ |
| 11199 | 11222 | |
| 11200 | 11223 | /* |
| 11201 | 11224 | * Each trigger present in the database schema is stored as an instance of |
| 11202 | 11225 | * struct Trigger. |
| 11203 | 11226 | * |
| | @@ -11677,11 +11700,11 @@ |
| 11677 | 11700 | #endif |
| 11678 | 11701 | SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*); |
| 11679 | 11702 | SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); |
| 11680 | 11703 | SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16); |
| 11681 | 11704 | SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*); |
| 11682 | | -SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int); |
| 11705 | +SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8); |
| 11683 | 11706 | SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int); |
| 11684 | 11707 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int); |
| 11685 | 11708 | SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int); |
| 11686 | 11709 | SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int); |
| 11687 | 11710 | SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*); |
| | @@ -13509,14 +13532,16 @@ |
| 13509 | 13532 | ** Set *pCurrent to the total cache hits or misses encountered by all |
| 13510 | 13533 | ** pagers the database handle is connected to. *pHighwater is always set |
| 13511 | 13534 | ** to zero. |
| 13512 | 13535 | */ |
| 13513 | 13536 | case SQLITE_DBSTATUS_CACHE_HIT: |
| 13514 | | - case SQLITE_DBSTATUS_CACHE_MISS: { |
| 13537 | + case SQLITE_DBSTATUS_CACHE_MISS: |
| 13538 | + case SQLITE_DBSTATUS_CACHE_WRITE:{ |
| 13515 | 13539 | int i; |
| 13516 | 13540 | int nRet = 0; |
| 13517 | 13541 | assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 ); |
| 13542 | + assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 ); |
| 13518 | 13543 | |
| 13519 | 13544 | for(i=0; i<db->nDb; i++){ |
| 13520 | 13545 | if( db->aDb[i].pBt ){ |
| 13521 | 13546 | Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt); |
| 13522 | 13547 | sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet); |
| | @@ -21259,15 +21284,15 @@ |
| 21259 | 21284 | |
| 21260 | 21285 | /* |
| 21261 | 21286 | ** Some systems have stricmp(). Others have strcasecmp(). Because |
| 21262 | 21287 | ** there is no consistency, we will define our own. |
| 21263 | 21288 | ** |
| 21264 | | -** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows |
| 21265 | | -** applications and extensions to compare the contents of two buffers |
| 21266 | | -** containing UTF-8 strings in a case-independent fashion, using the same |
| 21267 | | -** definition of case independence that SQLite uses internally when |
| 21268 | | -** comparing identifiers. |
| 21289 | +** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and |
| 21290 | +** sqlite3_strnicmp() APIs allow applications and extensions to compare |
| 21291 | +** the contents of two buffers containing UTF-8 strings in a |
| 21292 | +** case-independent fashion, using the same definition of "case |
| 21293 | +** independence" that SQLite uses internally when comparing identifiers. |
| 21269 | 21294 | */ |
| 21270 | 21295 | SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){ |
| 21271 | 21296 | register unsigned char *a, *b; |
| 21272 | 21297 | a = (unsigned char *)zLeft; |
| 21273 | 21298 | b = (unsigned char *)zRight; |
| | @@ -33727,10 +33752,13 @@ |
| 33727 | 33752 | } |
| 33728 | 33753 | sqlite3_free(pFile->zDeleteOnClose); |
| 33729 | 33754 | } |
| 33730 | 33755 | #endif |
| 33731 | 33756 | OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed")); |
| 33757 | + if( rc ){ |
| 33758 | + pFile->h = NULL; |
| 33759 | + } |
| 33732 | 33760 | OpenCounter(-1); |
| 33733 | 33761 | return rc ? SQLITE_OK |
| 33734 | 33762 | : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(), |
| 33735 | 33763 | "winClose", pFile->zPath); |
| 33736 | 33764 | } |
| | @@ -33744,22 +33772,33 @@ |
| 33744 | 33772 | sqlite3_file *id, /* File to read from */ |
| 33745 | 33773 | void *pBuf, /* Write content into this buffer */ |
| 33746 | 33774 | int amt, /* Number of bytes to read */ |
| 33747 | 33775 | sqlite3_int64 offset /* Begin reading at this offset */ |
| 33748 | 33776 | ){ |
| 33777 | +#if !SQLITE_OS_WINCE |
| 33778 | + OVERLAPPED overlapped; /* The offset for ReadFile. */ |
| 33779 | +#endif |
| 33749 | 33780 | winFile *pFile = (winFile*)id; /* file handle */ |
| 33750 | 33781 | DWORD nRead; /* Number of bytes actually read from file */ |
| 33751 | 33782 | int nRetry = 0; /* Number of retrys */ |
| 33752 | 33783 | |
| 33753 | 33784 | assert( id!=0 ); |
| 33754 | 33785 | SimulateIOError(return SQLITE_IOERR_READ); |
| 33755 | 33786 | OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype)); |
| 33756 | 33787 | |
| 33788 | +#if SQLITE_OS_WINCE |
| 33757 | 33789 | if( seekWinFile(pFile, offset) ){ |
| 33758 | 33790 | return SQLITE_FULL; |
| 33759 | 33791 | } |
| 33760 | 33792 | while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){ |
| 33793 | +#else |
| 33794 | + memset(&overlapped, 0, sizeof(OVERLAPPED)); |
| 33795 | + overlapped.Offset = (LONG)(offset & 0xffffffff); |
| 33796 | + overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff); |
| 33797 | + while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) && |
| 33798 | + osGetLastError()!=ERROR_HANDLE_EOF ){ |
| 33799 | +#endif |
| 33761 | 33800 | DWORD lastErrno; |
| 33762 | 33801 | if( retryIoerr(&nRetry, &lastErrno) ) continue; |
| 33763 | 33802 | pFile->lastErrno = lastErrno; |
| 33764 | 33803 | return winLogError(SQLITE_IOERR_READ, pFile->lastErrno, |
| 33765 | 33804 | "winRead", pFile->zPath); |
| | @@ -33782,11 +33821,11 @@ |
| 33782 | 33821 | sqlite3_file *id, /* File to write into */ |
| 33783 | 33822 | const void *pBuf, /* The bytes to be written */ |
| 33784 | 33823 | int amt, /* Number of bytes to write */ |
| 33785 | 33824 | sqlite3_int64 offset /* Offset into the file to begin writing at */ |
| 33786 | 33825 | ){ |
| 33787 | | - int rc; /* True if error has occured, else false */ |
| 33826 | + int rc = 0; /* True if error has occured, else false */ |
| 33788 | 33827 | winFile *pFile = (winFile*)id; /* File handle */ |
| 33789 | 33828 | int nRetry = 0; /* Number of retries */ |
| 33790 | 33829 | |
| 33791 | 33830 | assert( amt>0 ); |
| 33792 | 33831 | assert( pFile ); |
| | @@ -33793,23 +33832,48 @@ |
| 33793 | 33832 | SimulateIOError(return SQLITE_IOERR_WRITE); |
| 33794 | 33833 | SimulateDiskfullError(return SQLITE_FULL); |
| 33795 | 33834 | |
| 33796 | 33835 | OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype)); |
| 33797 | 33836 | |
| 33837 | +#if SQLITE_OS_WINCE |
| 33798 | 33838 | rc = seekWinFile(pFile, offset); |
| 33799 | 33839 | if( rc==0 ){ |
| 33840 | +#else |
| 33841 | + { |
| 33842 | +#endif |
| 33843 | +#if !SQLITE_OS_WINCE |
| 33844 | + OVERLAPPED overlapped; /* The offset for WriteFile. */ |
| 33845 | +#endif |
| 33800 | 33846 | u8 *aRem = (u8 *)pBuf; /* Data yet to be written */ |
| 33801 | 33847 | int nRem = amt; /* Number of bytes yet to be written */ |
| 33802 | 33848 | DWORD nWrite; /* Bytes written by each WriteFile() call */ |
| 33803 | 33849 | DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */ |
| 33850 | + |
| 33851 | +#if !SQLITE_OS_WINCE |
| 33852 | + memset(&overlapped, 0, sizeof(OVERLAPPED)); |
| 33853 | + overlapped.Offset = (LONG)(offset & 0xffffffff); |
| 33854 | + overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff); |
| 33855 | +#endif |
| 33804 | 33856 | |
| 33805 | 33857 | while( nRem>0 ){ |
| 33858 | +#if SQLITE_OS_WINCE |
| 33806 | 33859 | if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){ |
| 33860 | +#else |
| 33861 | + if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){ |
| 33862 | +#endif |
| 33807 | 33863 | if( retryIoerr(&nRetry, &lastErrno) ) continue; |
| 33808 | 33864 | break; |
| 33809 | 33865 | } |
| 33810 | | - if( nWrite<=0 ) break; |
| 33866 | + if( nWrite<=0 ){ |
| 33867 | + lastErrno = osGetLastError(); |
| 33868 | + break; |
| 33869 | + } |
| 33870 | +#if !SQLITE_OS_WINCE |
| 33871 | + offset += nWrite; |
| 33872 | + overlapped.Offset = (LONG)(offset & 0xffffffff); |
| 33873 | + overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff); |
| 33874 | +#endif |
| 33811 | 33875 | aRem += nWrite; |
| 33812 | 33876 | nRem -= nWrite; |
| 33813 | 33877 | } |
| 33814 | 33878 | if( nRem>0 ){ |
| 33815 | 33879 | pFile->lastErrno = lastErrno; |
| | @@ -39094,13 +39158,13 @@ |
| 39094 | 39158 | i64 journalSizeLimit; /* Size limit for persistent journal files */ |
| 39095 | 39159 | char *zFilename; /* Name of the database file */ |
| 39096 | 39160 | char *zJournal; /* Name of the journal file */ |
| 39097 | 39161 | int (*xBusyHandler)(void*); /* Function to call when busy */ |
| 39098 | 39162 | void *pBusyHandlerArg; /* Context argument for xBusyHandler */ |
| 39099 | | - int nHit, nMiss; /* Total cache hits and misses */ |
| 39163 | + int aStat[3]; /* Total cache hits, misses and writes */ |
| 39100 | 39164 | #ifdef SQLITE_TEST |
| 39101 | | - int nRead, nWrite; /* Database pages read/written */ |
| 39165 | + int nRead; /* Database pages read */ |
| 39102 | 39166 | #endif |
| 39103 | 39167 | void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */ |
| 39104 | 39168 | #ifdef SQLITE_HAS_CODEC |
| 39105 | 39169 | void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */ |
| 39106 | 39170 | void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */ |
| | @@ -39113,10 +39177,19 @@ |
| 39113 | 39177 | Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */ |
| 39114 | 39178 | char *zWal; /* File name for write-ahead log */ |
| 39115 | 39179 | #endif |
| 39116 | 39180 | }; |
| 39117 | 39181 | |
| 39182 | +/* |
| 39183 | +** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains |
| 39184 | +** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS |
| 39185 | +** or CACHE_WRITE to sqlite3_db_status(). |
| 39186 | +*/ |
| 39187 | +#define PAGER_STAT_HIT 0 |
| 39188 | +#define PAGER_STAT_MISS 1 |
| 39189 | +#define PAGER_STAT_WRITE 2 |
| 39190 | + |
| 39118 | 39191 | /* |
| 39119 | 39192 | ** The following global variables hold counters used for |
| 39120 | 39193 | ** testing purposes only. These variables do not exist in |
| 39121 | 39194 | ** a non-testing build. These variables are not thread-safe. |
| 39122 | 39195 | */ |
| | @@ -41395,10 +41468,11 @@ |
| 41395 | 41468 | PgHdr *pList, /* List of frames to log */ |
| 41396 | 41469 | Pgno nTruncate, /* Database size after this commit */ |
| 41397 | 41470 | int isCommit /* True if this is a commit */ |
| 41398 | 41471 | ){ |
| 41399 | 41472 | int rc; /* Return code */ |
| 41473 | + int nList; /* Number of pages in pList */ |
| 41400 | 41474 | #if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES) |
| 41401 | 41475 | PgHdr *p; /* For looping over pages */ |
| 41402 | 41476 | #endif |
| 41403 | 41477 | |
| 41404 | 41478 | assert( pPager->pWal ); |
| | @@ -41408,22 +41482,30 @@ |
| 41408 | 41482 | for(p=pList; p && p->pDirty; p=p->pDirty){ |
| 41409 | 41483 | assert( p->pgno < p->pDirty->pgno ); |
| 41410 | 41484 | } |
| 41411 | 41485 | #endif |
| 41412 | 41486 | |
| 41487 | + assert( pList->pDirty==0 || isCommit ); |
| 41413 | 41488 | if( isCommit ){ |
| 41414 | 41489 | /* If a WAL transaction is being committed, there is no point in writing |
| 41415 | 41490 | ** any pages with page numbers greater than nTruncate into the WAL file. |
| 41416 | 41491 | ** They will never be read by any client. So remove them from the pDirty |
| 41417 | 41492 | ** list here. */ |
| 41418 | 41493 | PgHdr *p; |
| 41419 | 41494 | PgHdr **ppNext = &pList; |
| 41495 | + nList = 0; |
| 41420 | 41496 | for(p=pList; (*ppNext = p); p=p->pDirty){ |
| 41421 | | - if( p->pgno<=nTruncate ) ppNext = &p->pDirty; |
| 41497 | + if( p->pgno<=nTruncate ){ |
| 41498 | + ppNext = &p->pDirty; |
| 41499 | + nList++; |
| 41500 | + } |
| 41422 | 41501 | } |
| 41423 | 41502 | assert( pList ); |
| 41503 | + }else{ |
| 41504 | + nList = 1; |
| 41424 | 41505 | } |
| 41506 | + pPager->aStat[PAGER_STAT_WRITE] += nList; |
| 41425 | 41507 | |
| 41426 | 41508 | if( pList->pgno==1 ) pager_write_changecounter(pList); |
| 41427 | 41509 | rc = sqlite3WalFrames(pPager->pWal, |
| 41428 | 41510 | pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags |
| 41429 | 41511 | ); |
| | @@ -42487,19 +42569,19 @@ |
| 42487 | 42569 | memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers)); |
| 42488 | 42570 | } |
| 42489 | 42571 | if( pgno>pPager->dbFileSize ){ |
| 42490 | 42572 | pPager->dbFileSize = pgno; |
| 42491 | 42573 | } |
| 42574 | + pPager->aStat[PAGER_STAT_WRITE]++; |
| 42492 | 42575 | |
| 42493 | 42576 | /* Update any backup objects copying the contents of this pager. */ |
| 42494 | 42577 | sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData); |
| 42495 | 42578 | |
| 42496 | 42579 | PAGERTRACE(("STORE %d page %d hash(%08x)\n", |
| 42497 | 42580 | PAGERID(pPager), pgno, pager_pagehash(pList))); |
| 42498 | 42581 | IOTRACE(("PGOUT %p %d\n", pPager, pgno)); |
| 42499 | 42582 | PAGER_INCR(sqlite3_pager_writedb_count); |
| 42500 | | - PAGER_INCR(pPager->nWrite); |
| 42501 | 42583 | }else{ |
| 42502 | 42584 | PAGERTRACE(("NOSTORE %d page %d\n", PAGERID(pPager), pgno)); |
| 42503 | 42585 | } |
| 42504 | 42586 | pager_set_pagehash(pList); |
| 42505 | 42587 | pList = pList->pDirty; |
| | @@ -43453,11 +43535,11 @@ |
| 43453 | 43535 | |
| 43454 | 43536 | if( (*ppPage)->pPager && !noContent ){ |
| 43455 | 43537 | /* In this case the pcache already contains an initialized copy of |
| 43456 | 43538 | ** the page. Return without further ado. */ |
| 43457 | 43539 | assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) ); |
| 43458 | | - pPager->nHit++; |
| 43540 | + pPager->aStat[PAGER_STAT_HIT]++; |
| 43459 | 43541 | return SQLITE_OK; |
| 43460 | 43542 | |
| 43461 | 43543 | }else{ |
| 43462 | 43544 | /* The pager cache has created a new page. Its content needs to |
| 43463 | 43545 | ** be initialized. */ |
| | @@ -43495,11 +43577,11 @@ |
| 43495 | 43577 | } |
| 43496 | 43578 | memset(pPg->pData, 0, pPager->pageSize); |
| 43497 | 43579 | IOTRACE(("ZERO %p %d\n", pPager, pgno)); |
| 43498 | 43580 | }else{ |
| 43499 | 43581 | assert( pPg->pPager==pPager ); |
| 43500 | | - pPager->nMiss++; |
| 43582 | + pPager->aStat[PAGER_STAT_MISS]++; |
| 43501 | 43583 | rc = readDbPage(pPg); |
| 43502 | 43584 | if( rc!=SQLITE_OK ){ |
| 43503 | 43585 | goto pager_acquire_err; |
| 43504 | 43586 | } |
| 43505 | 43587 | } |
| | @@ -44080,10 +44162,11 @@ |
| 44080 | 44162 | const void *zBuf; |
| 44081 | 44163 | assert( pPager->dbFileSize>0 ); |
| 44082 | 44164 | CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf); |
| 44083 | 44165 | if( rc==SQLITE_OK ){ |
| 44084 | 44166 | rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0); |
| 44167 | + pPager->aStat[PAGER_STAT_WRITE]++; |
| 44085 | 44168 | } |
| 44086 | 44169 | if( rc==SQLITE_OK ){ |
| 44087 | 44170 | pPager->changeCountDone = 1; |
| 44088 | 44171 | } |
| 44089 | 44172 | }else{ |
| | @@ -44523,15 +44606,15 @@ |
| 44523 | 44606 | a[1] = sqlite3PcachePagecount(pPager->pPCache); |
| 44524 | 44607 | a[2] = sqlite3PcacheGetCachesize(pPager->pPCache); |
| 44525 | 44608 | a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize; |
| 44526 | 44609 | a[4] = pPager->eState; |
| 44527 | 44610 | a[5] = pPager->errCode; |
| 44528 | | - a[6] = pPager->nHit; |
| 44529 | | - a[7] = pPager->nMiss; |
| 44611 | + a[6] = pPager->aStat[PAGER_STAT_HIT]; |
| 44612 | + a[7] = pPager->aStat[PAGER_STAT_MISS]; |
| 44530 | 44613 | a[8] = 0; /* Used to be pPager->nOvfl */ |
| 44531 | 44614 | a[9] = pPager->nRead; |
| 44532 | | - a[10] = pPager->nWrite; |
| 44615 | + a[10] = pPager->aStat[PAGER_STAT_WRITE]; |
| 44533 | 44616 | return a; |
| 44534 | 44617 | } |
| 44535 | 44618 | #endif |
| 44536 | 44619 | |
| 44537 | 44620 | /* |
| | @@ -44540,24 +44623,23 @@ |
| 44540 | 44623 | ** current cache hit or miss count, according to the value of eStat. If the |
| 44541 | 44624 | ** reset parameter is non-zero, the cache hit or miss count is zeroed before |
| 44542 | 44625 | ** returning. |
| 44543 | 44626 | */ |
| 44544 | 44627 | SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){ |
| 44545 | | - int *piStat; |
| 44546 | 44628 | |
| 44547 | 44629 | assert( eStat==SQLITE_DBSTATUS_CACHE_HIT |
| 44548 | 44630 | || eStat==SQLITE_DBSTATUS_CACHE_MISS |
| 44631 | + || eStat==SQLITE_DBSTATUS_CACHE_WRITE |
| 44549 | 44632 | ); |
| 44550 | | - if( eStat==SQLITE_DBSTATUS_CACHE_HIT ){ |
| 44551 | | - piStat = &pPager->nHit; |
| 44552 | | - }else{ |
| 44553 | | - piStat = &pPager->nMiss; |
| 44554 | | - } |
| 44555 | 44633 | |
| 44556 | | - *pnVal += *piStat; |
| 44634 | + assert( SQLITE_DBSTATUS_CACHE_HIT+1==SQLITE_DBSTATUS_CACHE_MISS ); |
| 44635 | + assert( SQLITE_DBSTATUS_CACHE_HIT+2==SQLITE_DBSTATUS_CACHE_WRITE ); |
| 44636 | + assert( PAGER_STAT_HIT==0 && PAGER_STAT_MISS==1 && PAGER_STAT_WRITE==2 ); |
| 44637 | + |
| 44638 | + *pnVal += pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT]; |
| 44557 | 44639 | if( reset ){ |
| 44558 | | - *piStat = 0; |
| 44640 | + pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT] = 0; |
| 44559 | 44641 | } |
| 44560 | 44642 | } |
| 44561 | 44643 | |
| 44562 | 44644 | /* |
| 44563 | 44645 | ** Return true if this is an in-memory pager. |
| | @@ -56151,17 +56233,10 @@ |
| 56151 | 56233 | ** keys with no associated data. If the cursor was opened expecting an |
| 56152 | 56234 | ** intkey table, the caller should be inserting integer keys with a |
| 56153 | 56235 | ** blob of associated data. */ |
| 56154 | 56236 | assert( (pKey==0)==(pCur->pKeyInfo==0) ); |
| 56155 | 56237 | |
| 56156 | | - /* If this is an insert into a table b-tree, invalidate any incrblob |
| 56157 | | - ** cursors open on the row being replaced (assuming this is a replace |
| 56158 | | - ** operation - if it is not, the following is a no-op). */ |
| 56159 | | - if( pCur->pKeyInfo==0 ){ |
| 56160 | | - invalidateIncrblobCursors(p, nKey, 0); |
| 56161 | | - } |
| 56162 | | - |
| 56163 | 56238 | /* Save the positions of any other cursors open on this table. |
| 56164 | 56239 | ** |
| 56165 | 56240 | ** In some cases, the call to btreeMoveto() below is a no-op. For |
| 56166 | 56241 | ** example, when inserting data into a table with auto-generated integer |
| 56167 | 56242 | ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the |
| | @@ -56171,10 +56246,18 @@ |
| 56171 | 56246 | ** doing any work. To avoid thwarting these optimizations, it is important |
| 56172 | 56247 | ** not to clear the cursor here. |
| 56173 | 56248 | */ |
| 56174 | 56249 | rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur); |
| 56175 | 56250 | if( rc ) return rc; |
| 56251 | + |
| 56252 | + /* If this is an insert into a table b-tree, invalidate any incrblob |
| 56253 | + ** cursors open on the row being replaced (assuming this is a replace |
| 56254 | + ** operation - if it is not, the following is a no-op). */ |
| 56255 | + if( pCur->pKeyInfo==0 ){ |
| 56256 | + invalidateIncrblobCursors(p, nKey, 0); |
| 56257 | + } |
| 56258 | + |
| 56176 | 56259 | if( !loc ){ |
| 56177 | 56260 | rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc); |
| 56178 | 56261 | if( rc ) return rc; |
| 56179 | 56262 | } |
| 56180 | 56263 | assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) ); |
| | @@ -56281,16 +56364,10 @@ |
| 56281 | 56364 | || NEVER(pCur->eState!=CURSOR_VALID) |
| 56282 | 56365 | ){ |
| 56283 | 56366 | return SQLITE_ERROR; /* Something has gone awry. */ |
| 56284 | 56367 | } |
| 56285 | 56368 | |
| 56286 | | - /* If this is a delete operation to remove a row from a table b-tree, |
| 56287 | | - ** invalidate any incrblob cursors open on the row being deleted. */ |
| 56288 | | - if( pCur->pKeyInfo==0 ){ |
| 56289 | | - invalidateIncrblobCursors(p, pCur->info.nKey, 0); |
| 56290 | | - } |
| 56291 | | - |
| 56292 | 56369 | iCellDepth = pCur->iPage; |
| 56293 | 56370 | iCellIdx = pCur->aiIdx[iCellDepth]; |
| 56294 | 56371 | pPage = pCur->apPage[iCellDepth]; |
| 56295 | 56372 | pCell = findCell(pPage, iCellIdx); |
| 56296 | 56373 | |
| | @@ -56312,10 +56389,17 @@ |
| 56312 | 56389 | ** deleted writable. Then free any overflow pages associated with the |
| 56313 | 56390 | ** entry and finally remove the cell itself from within the page. |
| 56314 | 56391 | */ |
| 56315 | 56392 | rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur); |
| 56316 | 56393 | if( rc ) return rc; |
| 56394 | + |
| 56395 | + /* If this is a delete operation to remove a row from a table b-tree, |
| 56396 | + ** invalidate any incrblob cursors open on the row being deleted. */ |
| 56397 | + if( pCur->pKeyInfo==0 ){ |
| 56398 | + invalidateIncrblobCursors(p, pCur->info.nKey, 0); |
| 56399 | + } |
| 56400 | + |
| 56317 | 56401 | rc = sqlite3PagerWrite(pPage->pDbPage); |
| 56318 | 56402 | if( rc ) return rc; |
| 56319 | 56403 | rc = clearCell(pPage, pCell); |
| 56320 | 56404 | dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), &rc); |
| 56321 | 56405 | if( rc ) return rc; |
| | @@ -56593,17 +56677,17 @@ |
| 56593 | 56677 | int rc; |
| 56594 | 56678 | BtShared *pBt = p->pBt; |
| 56595 | 56679 | sqlite3BtreeEnter(p); |
| 56596 | 56680 | assert( p->inTrans==TRANS_WRITE ); |
| 56597 | 56681 | |
| 56598 | | - /* Invalidate all incrblob cursors open on table iTable (assuming iTable |
| 56599 | | - ** is the root of a table b-tree - if it is not, the following call is |
| 56600 | | - ** a no-op). */ |
| 56601 | | - invalidateIncrblobCursors(p, 0, 1); |
| 56602 | | - |
| 56603 | 56682 | rc = saveAllCursors(pBt, (Pgno)iTable, 0); |
| 56683 | + |
| 56604 | 56684 | if( SQLITE_OK==rc ){ |
| 56685 | + /* Invalidate all incrblob cursors open on table iTable (assuming iTable |
| 56686 | + ** is the root of a table b-tree - if it is not, the following call is |
| 56687 | + ** a no-op). */ |
| 56688 | + invalidateIncrblobCursors(p, 0, 1); |
| 56605 | 56689 | rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange); |
| 56606 | 56690 | } |
| 56607 | 56691 | sqlite3BtreeLeave(p); |
| 56608 | 56692 | return rc; |
| 56609 | 56693 | } |
| | @@ -58411,14 +58495,14 @@ |
| 58411 | 58495 | |
| 58412 | 58496 | /* |
| 58413 | 58497 | ** Make sure pMem->z points to a writable allocation of at least |
| 58414 | 58498 | ** n bytes. |
| 58415 | 58499 | ** |
| 58416 | | -** If the memory cell currently contains string or blob data |
| 58417 | | -** and the third argument passed to this function is true, the |
| 58418 | | -** current content of the cell is preserved. Otherwise, it may |
| 58419 | | -** be discarded. |
| 58500 | +** If the third argument passed to this function is true, then memory |
| 58501 | +** cell pMem must contain a string or blob. In this case the content is |
| 58502 | +** preserved. Otherwise, if the third parameter to this function is false, |
| 58503 | +** any current string or blob value may be discarded. |
| 58420 | 58504 | ** |
| 58421 | 58505 | ** This function sets the MEM_Dyn flag and clears any xDel callback. |
| 58422 | 58506 | ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is |
| 58423 | 58507 | ** not set, Mem.n is zeroed. |
| 58424 | 58508 | */ |
| | @@ -58428,10 +58512,14 @@ |
| 58428 | 58512 | (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) + |
| 58429 | 58513 | ((pMem->flags&MEM_Ephem) ? 1 : 0) + |
| 58430 | 58514 | ((pMem->flags&MEM_Static) ? 1 : 0) |
| 58431 | 58515 | ); |
| 58432 | 58516 | assert( (pMem->flags&MEM_RowSet)==0 ); |
| 58517 | + |
| 58518 | + /* If the preserve flag is set to true, then the memory cell must already |
| 58519 | + ** contain a valid string or blob value. */ |
| 58520 | + assert( preserve==0 || pMem->flags&(MEM_Blob|MEM_Str) ); |
| 58433 | 58521 | |
| 58434 | 58522 | if( n<32 ) n = 32; |
| 58435 | 58523 | if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){ |
| 58436 | 58524 | if( preserve && pMem->z==pMem->zMalloc ){ |
| 58437 | 58525 | pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n); |
| | @@ -60747,11 +60835,11 @@ |
| 60747 | 60835 | int nByte = (nSub+1)*sizeof(SubProgram*); |
| 60748 | 60836 | int j; |
| 60749 | 60837 | for(j=0; j<nSub; j++){ |
| 60750 | 60838 | if( apSub[j]==pOp->p4.pProgram ) break; |
| 60751 | 60839 | } |
| 60752 | | - if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){ |
| 60840 | + if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){ |
| 60753 | 60841 | apSub = (SubProgram **)pSub->z; |
| 60754 | 60842 | apSub[nSub++] = pOp->p4.pProgram; |
| 60755 | 60843 | pSub->flags |= MEM_Blob; |
| 60756 | 60844 | pSub->n = nSub*sizeof(SubProgram*); |
| 60757 | 60845 | } |
| | @@ -66996,10 +67084,15 @@ |
| 66996 | 67084 | ** |
| 66997 | 67085 | ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor, |
| 66998 | 67086 | ** then the cache of the cursor is reset prior to extracting the column. |
| 66999 | 67087 | ** The first OP_Column against a pseudo-table after the value of the content |
| 67000 | 67088 | ** register has changed should have this bit set. |
| 67089 | +** |
| 67090 | +** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 when |
| 67091 | +** the result is guaranteed to only be used as the argument of a length() |
| 67092 | +** or typeof() function, respectively. The loading of large blobs can be |
| 67093 | +** skipped for length() and all content loading can be skipped for typeof(). |
| 67001 | 67094 | */ |
| 67002 | 67095 | case OP_Column: { |
| 67003 | 67096 | #if 0 /* local variables moved into u.an */ |
| 67004 | 67097 | u32 payloadSize; /* Number of bytes in the record */ |
| 67005 | 67098 | i64 payloadSize64; /* Number of bytes in the record */ |
| | @@ -67138,11 +67231,11 @@ |
| 67138 | 67231 | u.an.pC->aRow = (u8*)u.an.zData; |
| 67139 | 67232 | }else{ |
| 67140 | 67233 | u.an.pC->aRow = 0; |
| 67141 | 67234 | } |
| 67142 | 67235 | } |
| 67143 | | - /* The following assert is true in all cases accept when |
| 67236 | + /* The following assert is true in all cases except when |
| 67144 | 67237 | ** the database file has been corrupted externally. |
| 67145 | 67238 | ** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */ |
| 67146 | 67239 | u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset); |
| 67147 | 67240 | |
| 67148 | 67241 | /* Make sure a corrupt database has not given us an oversize header. |
| | @@ -67213,15 +67306,15 @@ |
| 67213 | 67306 | if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */ |
| 67214 | 67307 | u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */ |
| 67215 | 67308 | break; |
| 67216 | 67309 | } |
| 67217 | 67310 | }else{ |
| 67218 | | - /* If u.an.i is less that u.an.nField, then there are less fields in this |
| 67311 | + /* If u.an.i is less that u.an.nField, then there are fewer fields in this |
| 67219 | 67312 | ** record than SetNumColumns indicated there are columns in the |
| 67220 | 67313 | ** table. Set the u.an.offset for any extra columns not present in |
| 67221 | | - ** the record to 0. This tells code below to store a NULL |
| 67222 | | - ** instead of deserializing a value from the record. |
| 67314 | + ** the record to 0. This tells code below to store the default value |
| 67315 | + ** for the column instead of deserializing a value from the record. |
| 67223 | 67316 | */ |
| 67224 | 67317 | u.an.aOffset[u.an.i] = 0; |
| 67225 | 67318 | } |
| 67226 | 67319 | } |
| 67227 | 67320 | sqlite3VdbeMemRelease(&u.an.sMem); |
| | @@ -67247,21 +67340,36 @@ |
| 67247 | 67340 | ** a pointer to a Mem object. |
| 67248 | 67341 | */ |
| 67249 | 67342 | if( u.an.aOffset[u.an.p2] ){ |
| 67250 | 67343 | assert( rc==SQLITE_OK ); |
| 67251 | 67344 | if( u.an.zRec ){ |
| 67345 | + /* This is the common case where the whole row fits on a single page */ |
| 67252 | 67346 | VdbeMemRelease(u.an.pDest); |
| 67253 | 67347 | sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest); |
| 67254 | 67348 | }else{ |
| 67255 | | - u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]); |
| 67256 | | - sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest); |
| 67257 | | - rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem); |
| 67258 | | - if( rc!=SQLITE_OK ){ |
| 67259 | | - goto op_column_out; |
| 67260 | | - } |
| 67261 | | - u.an.zData = u.an.sMem.z; |
| 67262 | | - sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.aType[u.an.p2], u.an.pDest); |
| 67349 | + /* This branch happens only when the row overflows onto multiple pages */ |
| 67350 | + u.an.t = u.an.aType[u.an.p2]; |
| 67351 | + if( (pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0 |
| 67352 | + && ((u.an.t>=12 && (u.an.t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0) |
| 67353 | + ){ |
| 67354 | + /* Content is irrelevant for the typeof() function and for |
| 67355 | + ** the length(X) function if X is a blob. So we might as well use |
| 67356 | + ** bogus content rather than reading content from disk. NULL works |
| 67357 | + ** for text and blob and whatever is in the u.an.payloadSize64 variable |
| 67358 | + ** will work for everything else. */ |
| 67359 | + u.an.zData = u.an.t<12 ? (char*)&u.an.payloadSize64 : 0; |
| 67360 | + }else{ |
| 67361 | + u.an.len = sqlite3VdbeSerialTypeLen(u.an.t); |
| 67362 | + sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest); |
| 67363 | + rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, |
| 67364 | + &u.an.sMem); |
| 67365 | + if( rc!=SQLITE_OK ){ |
| 67366 | + goto op_column_out; |
| 67367 | + } |
| 67368 | + u.an.zData = u.an.sMem.z; |
| 67369 | + } |
| 67370 | + sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.t, u.an.pDest); |
| 67263 | 67371 | } |
| 67264 | 67372 | u.an.pDest->enc = encoding; |
| 67265 | 67373 | }else{ |
| 67266 | 67374 | if( pOp->p4type==P4_MEM ){ |
| 67267 | 67375 | sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static); |
| | @@ -67593,12 +67701,14 @@ |
| 67593 | 67701 | } |
| 67594 | 67702 | db->isTransactionSavepoint = 0; |
| 67595 | 67703 | rc = p->rc; |
| 67596 | 67704 | }else{ |
| 67597 | 67705 | u.ar.iSavepoint = db->nSavepoint - u.ar.iSavepoint - 1; |
| 67598 | | - for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){ |
| 67599 | | - sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT); |
| 67706 | + if( u.ar.p1==SAVEPOINT_ROLLBACK ){ |
| 67707 | + for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){ |
| 67708 | + sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT); |
| 67709 | + } |
| 67600 | 67710 | } |
| 67601 | 67711 | for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){ |
| 67602 | 67712 | rc = sqlite3BtreeSavepoint(db->aDb[u.ar.ii].pBt, u.ar.p1, u.ar.iSavepoint); |
| 67603 | 67713 | if( rc!=SQLITE_OK ){ |
| 67604 | 67714 | goto abort_due_to_error; |
| | @@ -74873,27 +74983,59 @@ |
| 74873 | 74983 | int op, /* Expression opcode */ |
| 74874 | 74984 | Expr *pLeft, /* Left operand */ |
| 74875 | 74985 | Expr *pRight, /* Right operand */ |
| 74876 | 74986 | const Token *pToken /* Argument token */ |
| 74877 | 74987 | ){ |
| 74878 | | - Expr *p = sqlite3ExprAlloc(pParse->db, op, pToken, 1); |
| 74879 | | - sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight); |
| 74988 | + Expr *p; |
| 74989 | + if( op==TK_AND && pLeft && pRight ){ |
| 74990 | + /* Take advantage of short-circuit false optimization for AND */ |
| 74991 | + p = sqlite3ExprAnd(pParse->db, pLeft, pRight); |
| 74992 | + }else{ |
| 74993 | + p = sqlite3ExprAlloc(pParse->db, op, pToken, 1); |
| 74994 | + sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight); |
| 74995 | + } |
| 74880 | 74996 | if( p ) { |
| 74881 | 74997 | sqlite3ExprCheckHeight(pParse, p->nHeight); |
| 74882 | 74998 | } |
| 74883 | 74999 | return p; |
| 74884 | 75000 | } |
| 75001 | + |
| 75002 | +/* |
| 75003 | +** Return 1 if an expression must be FALSE in all cases and 0 if the |
| 75004 | +** expression might be true. This is an optimization. If is OK to |
| 75005 | +** return 0 here even if the expression really is always false (a |
| 75006 | +** false negative). But it is a bug to return 1 if the expression |
| 75007 | +** might be true in some rare circumstances (a false positive.) |
| 75008 | +** |
| 75009 | +** Note that if the expression is part of conditional for a |
| 75010 | +** LEFT JOIN, then we cannot determine at compile-time whether or not |
| 75011 | +** is it true or false, so always return 0. |
| 75012 | +*/ |
| 75013 | +static int exprAlwaysFalse(Expr *p){ |
| 75014 | + int v = 0; |
| 75015 | + if( ExprHasProperty(p, EP_FromJoin) ) return 0; |
| 75016 | + if( !sqlite3ExprIsInteger(p, &v) ) return 0; |
| 75017 | + return v==0; |
| 75018 | +} |
| 74885 | 75019 | |
| 74886 | 75020 | /* |
| 74887 | 75021 | ** Join two expressions using an AND operator. If either expression is |
| 74888 | 75022 | ** NULL, then just return the other expression. |
| 75023 | +** |
| 75024 | +** If one side or the other of the AND is known to be false, then instead |
| 75025 | +** of returning an AND expression, just return a constant expression with |
| 75026 | +** a value of false. |
| 74889 | 75027 | */ |
| 74890 | 75028 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){ |
| 74891 | 75029 | if( pLeft==0 ){ |
| 74892 | 75030 | return pRight; |
| 74893 | 75031 | }else if( pRight==0 ){ |
| 74894 | 75032 | return pLeft; |
| 75033 | + }else if( exprAlwaysFalse(pLeft) || exprAlwaysFalse(pRight) ){ |
| 75034 | + sqlite3ExprDelete(db, pLeft); |
| 75035 | + sqlite3ExprDelete(db, pRight); |
| 75036 | + return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0); |
| 74895 | 75037 | }else{ |
| 74896 | 75038 | Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0); |
| 74897 | 75039 | sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight); |
| 74898 | 75040 | return pNew; |
| 74899 | 75041 | } |
| | @@ -76421,19 +76563,10 @@ |
| 76421 | 76563 | ** Actually, the way the column cache is currently used, we are guaranteed |
| 76422 | 76564 | ** that the object will never already be in cache. Verify this guarantee. |
| 76423 | 76565 | */ |
| 76424 | 76566 | #ifndef NDEBUG |
| 76425 | 76567 | for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 76426 | | -#if 0 /* This code wold remove the entry from the cache if it existed */ |
| 76427 | | - if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){ |
| 76428 | | - cacheEntryClear(pParse, p); |
| 76429 | | - p->iLevel = pParse->iCacheLevel; |
| 76430 | | - p->iReg = iReg; |
| 76431 | | - p->lru = pParse->iCacheCnt++; |
| 76432 | | - return; |
| 76433 | | - } |
| 76434 | | -#endif |
| 76435 | 76568 | assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol ); |
| 76436 | 76569 | } |
| 76437 | 76570 | #endif |
| 76438 | 76571 | |
| 76439 | 76572 | /* Find an empty slot and replace it */ |
| | @@ -76564,11 +76697,12 @@ |
| 76564 | 76697 | SQLITE_PRIVATE int sqlite3ExprCodeGetColumn( |
| 76565 | 76698 | Parse *pParse, /* Parsing and code generating context */ |
| 76566 | 76699 | Table *pTab, /* Description of the table we are reading from */ |
| 76567 | 76700 | int iColumn, /* Index of the table column */ |
| 76568 | 76701 | int iTable, /* The cursor pointing to the table */ |
| 76569 | | - int iReg /* Store results here */ |
| 76702 | + int iReg, /* Store results here */ |
| 76703 | + u8 p5 /* P5 value for OP_Column */ |
| 76570 | 76704 | ){ |
| 76571 | 76705 | Vdbe *v = pParse->pVdbe; |
| 76572 | 76706 | int i; |
| 76573 | 76707 | struct yColCache *p; |
| 76574 | 76708 | |
| | @@ -76579,11 +76713,15 @@ |
| 76579 | 76713 | return p->iReg; |
| 76580 | 76714 | } |
| 76581 | 76715 | } |
| 76582 | 76716 | assert( v!=0 ); |
| 76583 | 76717 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg); |
| 76584 | | - sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg); |
| 76718 | + if( p5 ){ |
| 76719 | + sqlite3VdbeChangeP5(v, p5); |
| 76720 | + }else{ |
| 76721 | + sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg); |
| 76722 | + } |
| 76585 | 76723 | return iReg; |
| 76586 | 76724 | } |
| 76587 | 76725 | |
| 76588 | 76726 | /* |
| 76589 | 76727 | ** Clear all column cache entries. |
| | @@ -76707,11 +76845,12 @@ |
| 76707 | 76845 | /* This only happens when coding check constraints */ |
| 76708 | 76846 | assert( pParse->ckBase>0 ); |
| 76709 | 76847 | inReg = pExpr->iColumn + pParse->ckBase; |
| 76710 | 76848 | }else{ |
| 76711 | 76849 | inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab, |
| 76712 | | - pExpr->iColumn, pExpr->iTable, target); |
| 76850 | + pExpr->iColumn, pExpr->iTable, target, |
| 76851 | + pExpr->op2); |
| 76713 | 76852 | } |
| 76714 | 76853 | break; |
| 76715 | 76854 | } |
| 76716 | 76855 | case TK_INTEGER: { |
| 76717 | 76856 | codeInteger(pParse, pExpr, 0, target); |
| | @@ -76984,10 +77123,29 @@ |
| 76984 | 77123 | } |
| 76985 | 77124 | |
| 76986 | 77125 | |
| 76987 | 77126 | if( pFarg ){ |
| 76988 | 77127 | r1 = sqlite3GetTempRange(pParse, nFarg); |
| 77128 | + |
| 77129 | + /* For length() and typeof() functions with a column argument, |
| 77130 | + ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG |
| 77131 | + ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data |
| 77132 | + ** loading. |
| 77133 | + */ |
| 77134 | + if( (pDef->flags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){ |
| 77135 | + u8 exprOp; |
| 77136 | + assert( nFarg==1 ); |
| 77137 | + assert( pFarg->a[0].pExpr!=0 ); |
| 77138 | + exprOp = pFarg->a[0].pExpr->op; |
| 77139 | + if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){ |
| 77140 | + assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG ); |
| 77141 | + assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG ); |
| 77142 | + testcase( pDef->flags==SQLITE_FUNC_LENGTH ); |
| 77143 | + pFarg->a[0].pExpr->op2 = pDef->flags; |
| 77144 | + } |
| 77145 | + } |
| 77146 | + |
| 76989 | 77147 | sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */ |
| 76990 | 77148 | sqlite3ExprCodeExprList(pParse, pFarg, r1, 1); |
| 76991 | 77149 | sqlite3ExprCachePop(pParse, 1); /* Ticket 2ea2425d34be */ |
| 76992 | 77150 | }else{ |
| 76993 | 77151 | r1 = 0; |
| | @@ -80189,10 +80347,11 @@ |
| 80189 | 80347 | Index *pPrevIdx = 0; /* Previous index in the loop */ |
| 80190 | 80348 | int idx = 0; /* slot in pIdx->aSample[] for next sample */ |
| 80191 | 80349 | int eType; /* Datatype of a sample */ |
| 80192 | 80350 | IndexSample *pSample; /* A slot in pIdx->aSample[] */ |
| 80193 | 80351 | |
| 80352 | + assert( db->lookaside.bEnabled==0 ); |
| 80194 | 80353 | if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){ |
| 80195 | 80354 | return SQLITE_OK; |
| 80196 | 80355 | } |
| 80197 | 80356 | |
| 80198 | 80357 | zSql = sqlite3MPrintf(db, |
| | @@ -80215,11 +80374,11 @@ |
| 80215 | 80374 | nSample = sqlite3_column_int(pStmt, 1); |
| 80216 | 80375 | pIdx = sqlite3FindIndex(db, zIndex, zDb); |
| 80217 | 80376 | if( pIdx==0 ) continue; |
| 80218 | 80377 | assert( pIdx->nSample==0 ); |
| 80219 | 80378 | pIdx->nSample = nSample; |
| 80220 | | - pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) ); |
| 80379 | + pIdx->aSample = sqlite3DbMallocZero(db, nSample*sizeof(IndexSample)); |
| 80221 | 80380 | pIdx->avgEq = pIdx->aiRowEst[1]; |
| 80222 | 80381 | if( pIdx->aSample==0 ){ |
| 80223 | 80382 | db->mallocFailed = 1; |
| 80224 | 80383 | sqlite3_finalize(pStmt); |
| 80225 | 80384 | return SQLITE_NOMEM; |
| | @@ -80288,11 +80447,11 @@ |
| 80288 | 80447 | int n = z ? sqlite3_column_bytes(pStmt, 4) : 0; |
| 80289 | 80448 | pSample->nByte = n; |
| 80290 | 80449 | if( n < 1){ |
| 80291 | 80450 | pSample->u.z = 0; |
| 80292 | 80451 | }else{ |
| 80293 | | - pSample->u.z = sqlite3Malloc(n); |
| 80452 | + pSample->u.z = sqlite3DbMallocRaw(db, n); |
| 80294 | 80453 | if( pSample->u.z==0 ){ |
| 80295 | 80454 | db->mallocFailed = 1; |
| 80296 | 80455 | sqlite3_finalize(pStmt); |
| 80297 | 80456 | return SQLITE_NOMEM; |
| 80298 | 80457 | } |
| | @@ -80364,11 +80523,14 @@ |
| 80364 | 80523 | |
| 80365 | 80524 | |
| 80366 | 80525 | /* Load the statistics from the sqlite_stat3 table. */ |
| 80367 | 80526 | #ifdef SQLITE_ENABLE_STAT3 |
| 80368 | 80527 | if( rc==SQLITE_OK ){ |
| 80528 | + int lookasideEnabled = db->lookaside.bEnabled; |
| 80529 | + db->lookaside.bEnabled = 0; |
| 80369 | 80530 | rc = loadStat3(db, sInfo.zDatabase); |
| 80531 | + db->lookaside.bEnabled = lookasideEnabled; |
| 80370 | 80532 | } |
| 80371 | 80533 | #endif |
| 80372 | 80534 | |
| 80373 | 80535 | if( rc==SQLITE_NOMEM ){ |
| 80374 | 80536 | db->mallocFailed = 1; |
| | @@ -81727,11 +81889,11 @@ |
| 81727 | 81889 | sqliteDeleteColumnNames(db, pTable); |
| 81728 | 81890 | sqlite3DbFree(db, pTable->zName); |
| 81729 | 81891 | sqlite3DbFree(db, pTable->zColAff); |
| 81730 | 81892 | sqlite3SelectDelete(db, pTable->pSelect); |
| 81731 | 81893 | #ifndef SQLITE_OMIT_CHECK |
| 81732 | | - sqlite3ExprDelete(db, pTable->pCheck); |
| 81894 | + sqlite3ExprListDelete(db, pTable->pCheck); |
| 81733 | 81895 | #endif |
| 81734 | 81896 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 81735 | 81897 | sqlite3VtabClear(db, pTable); |
| 81736 | 81898 | #endif |
| 81737 | 81899 | sqlite3DbFree(db, pTable); |
| | @@ -82390,19 +82552,21 @@ |
| 82390 | 82552 | */ |
| 82391 | 82553 | SQLITE_PRIVATE void sqlite3AddCheckConstraint( |
| 82392 | 82554 | Parse *pParse, /* Parsing context */ |
| 82393 | 82555 | Expr *pCheckExpr /* The check expression */ |
| 82394 | 82556 | ){ |
| 82395 | | - sqlite3 *db = pParse->db; |
| 82396 | 82557 | #ifndef SQLITE_OMIT_CHECK |
| 82397 | 82558 | Table *pTab = pParse->pNewTable; |
| 82398 | 82559 | if( pTab && !IN_DECLARE_VTAB ){ |
| 82399 | | - pTab->pCheck = sqlite3ExprAnd(db, pTab->pCheck, pCheckExpr); |
| 82560 | + pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr); |
| 82561 | + if( pParse->constraintName.n ){ |
| 82562 | + sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1); |
| 82563 | + } |
| 82400 | 82564 | }else |
| 82401 | 82565 | #endif |
| 82402 | 82566 | { |
| 82403 | | - sqlite3ExprDelete(db, pCheckExpr); |
| 82567 | + sqlite3ExprDelete(pParse->db, pCheckExpr); |
| 82404 | 82568 | } |
| 82405 | 82569 | } |
| 82406 | 82570 | |
| 82407 | 82571 | /* |
| 82408 | 82572 | ** Set the collation function of the most recently parsed table column |
| | @@ -82668,10 +82832,12 @@ |
| 82668 | 82832 | /* Resolve names in all CHECK constraint expressions. |
| 82669 | 82833 | */ |
| 82670 | 82834 | if( p->pCheck ){ |
| 82671 | 82835 | SrcList sSrc; /* Fake SrcList for pParse->pNewTable */ |
| 82672 | 82836 | NameContext sNC; /* Name context for pParse->pNewTable */ |
| 82837 | + ExprList *pList; /* List of all CHECK constraints */ |
| 82838 | + int i; /* Loop counter */ |
| 82673 | 82839 | |
| 82674 | 82840 | memset(&sNC, 0, sizeof(sNC)); |
| 82675 | 82841 | memset(&sSrc, 0, sizeof(sSrc)); |
| 82676 | 82842 | sSrc.nSrc = 1; |
| 82677 | 82843 | sSrc.a[0].zName = p->zName; |
| | @@ -82678,12 +82844,15 @@ |
| 82678 | 82844 | sSrc.a[0].pTab = p; |
| 82679 | 82845 | sSrc.a[0].iCursor = -1; |
| 82680 | 82846 | sNC.pParse = pParse; |
| 82681 | 82847 | sNC.pSrcList = &sSrc; |
| 82682 | 82848 | sNC.isCheck = 1; |
| 82683 | | - if( sqlite3ResolveExprNames(&sNC, p->pCheck) ){ |
| 82684 | | - return; |
| 82849 | + pList = p->pCheck; |
| 82850 | + for(i=0; i<pList->nExpr; i++){ |
| 82851 | + if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){ |
| 82852 | + return; |
| 82853 | + } |
| 82685 | 82854 | } |
| 82686 | 82855 | } |
| 82687 | 82856 | #endif /* !defined(SQLITE_OMIT_CHECK) */ |
| 82688 | 82857 | |
| 82689 | 82858 | /* If the db->init.busy is 1 it means we are reading the SQL off the |
| | @@ -84230,23 +84399,25 @@ |
| 84230 | 84399 | exit_drop_index: |
| 84231 | 84400 | sqlite3SrcListDelete(db, pName); |
| 84232 | 84401 | } |
| 84233 | 84402 | |
| 84234 | 84403 | /* |
| 84235 | | -** pArray is a pointer to an array of objects. Each object in the |
| 84236 | | -** array is szEntry bytes in size. This routine allocates a new |
| 84237 | | -** object on the end of the array. |
| 84238 | | -** |
| 84239 | | -** *pnEntry is the number of entries already in use. *pnAlloc is |
| 84240 | | -** the previously allocated size of the array. initSize is the |
| 84241 | | -** suggested initial array size allocation. |
| 84242 | | -** |
| 84243 | | -** The index of the new entry is returned in *pIdx. |
| 84244 | | -** |
| 84245 | | -** This routine returns a pointer to the array of objects. This |
| 84246 | | -** might be the same as the pArray parameter or it might be a different |
| 84247 | | -** pointer if the array was resized. |
| 84404 | +** pArray is a pointer to an array of objects. Each object in the |
| 84405 | +** array is szEntry bytes in size. This routine uses sqlite3DbRealloc() |
| 84406 | +** to extend the array so that there is space for a new object at the end. |
| 84407 | +** |
| 84408 | +** When this function is called, *pnEntry contains the current size of |
| 84409 | +** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes |
| 84410 | +** in total). |
| 84411 | +** |
| 84412 | +** If the realloc() is successful (i.e. if no OOM condition occurs), the |
| 84413 | +** space allocated for the new object is zeroed, *pnEntry updated to |
| 84414 | +** reflect the new size of the array and a pointer to the new allocation |
| 84415 | +** returned. *pIdx is set to the index of the new array entry in this case. |
| 84416 | +** |
| 84417 | +** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains |
| 84418 | +** unchanged and a copy of pArray returned. |
| 84248 | 84419 | */ |
| 84249 | 84420 | SQLITE_PRIVATE void *sqlite3ArrayAllocate( |
| 84250 | 84421 | sqlite3 *db, /* Connection to notify of malloc failures */ |
| 84251 | 84422 | void *pArray, /* Array of objects. Might be reallocated */ |
| 84252 | 84423 | int szEntry, /* Size of each object in the array */ |
| | @@ -85839,11 +86010,11 @@ |
| 85839 | 86010 | sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet); |
| 85840 | 86011 | pWInfo = sqlite3WhereBegin( |
| 85841 | 86012 | pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK |
| 85842 | 86013 | ); |
| 85843 | 86014 | if( pWInfo==0 ) goto delete_from_cleanup; |
| 85844 | | - regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid); |
| 86015 | + regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0); |
| 85845 | 86016 | sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid); |
| 85846 | 86017 | if( db->flags & SQLITE_CountRows ){ |
| 85847 | 86018 | sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1); |
| 85848 | 86019 | } |
| 85849 | 86020 | sqlite3WhereEnd(pWInfo); |
| | @@ -87659,12 +87830,12 @@ |
| 87659 | 87830 | FUNCTION(min, 0, 0, 1, 0 ), |
| 87660 | 87831 | AGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize ), |
| 87661 | 87832 | FUNCTION(max, -1, 1, 1, minmaxFunc ), |
| 87662 | 87833 | FUNCTION(max, 0, 1, 1, 0 ), |
| 87663 | 87834 | AGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize ), |
| 87664 | | - FUNCTION(typeof, 1, 0, 0, typeofFunc ), |
| 87665 | | - FUNCTION(length, 1, 0, 0, lengthFunc ), |
| 87835 | + FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF), |
| 87836 | + FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH), |
| 87666 | 87837 | FUNCTION(substr, 2, 0, 0, substrFunc ), |
| 87667 | 87838 | FUNCTION(substr, 3, 0, 0, substrFunc ), |
| 87668 | 87839 | FUNCTION(abs, 1, 0, 0, absFunc ), |
| 87669 | 87840 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 87670 | 87841 | FUNCTION(round, 1, 0, 0, roundFunc ), |
| | @@ -87672,15 +87843,13 @@ |
| 87672 | 87843 | #endif |
| 87673 | 87844 | FUNCTION(upper, 1, 0, 0, upperFunc ), |
| 87674 | 87845 | FUNCTION(lower, 1, 0, 0, lowerFunc ), |
| 87675 | 87846 | FUNCTION(coalesce, 1, 0, 0, 0 ), |
| 87676 | 87847 | FUNCTION(coalesce, 0, 0, 0, 0 ), |
| 87677 | | -/* FUNCTION(coalesce, -1, 0, 0, ifnullFunc ), */ |
| 87678 | | - {-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"coalesce",0,0}, |
| 87848 | + FUNCTION2(coalesce, -1, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE), |
| 87679 | 87849 | FUNCTION(hex, 1, 0, 0, hexFunc ), |
| 87680 | | -/* FUNCTION(ifnull, 2, 0, 0, ifnullFunc ), */ |
| 87681 | | - {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0,0}, |
| 87850 | + FUNCTION2(ifnull, 2, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE), |
| 87682 | 87851 | FUNCTION(random, 0, 0, 0, randomFunc ), |
| 87683 | 87852 | FUNCTION(randomblob, 1, 0, 0, randomBlob ), |
| 87684 | 87853 | FUNCTION(nullif, 2, 0, 1, nullifFunc ), |
| 87685 | 87854 | FUNCTION(sqlite_version, 0, 0, 0, versionFunc ), |
| 87686 | 87855 | FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ), |
| | @@ -90113,13 +90282,15 @@ |
| 90113 | 90282 | int j1; /* Addresss of jump instruction */ |
| 90114 | 90283 | int j2 = 0, j3; /* Addresses of jump instructions */ |
| 90115 | 90284 | int regData; /* Register containing first data column */ |
| 90116 | 90285 | int iCur; /* Table cursor number */ |
| 90117 | 90286 | Index *pIdx; /* Pointer to one of the indices */ |
| 90287 | + sqlite3 *db; /* Database connection */ |
| 90118 | 90288 | int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */ |
| 90119 | 90289 | int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid; |
| 90120 | 90290 | |
| 90291 | + db = pParse->db; |
| 90121 | 90292 | v = sqlite3GetVdbe(pParse); |
| 90122 | 90293 | assert( v!=0 ); |
| 90123 | 90294 | assert( pTab->pSelect==0 ); /* This table is not a VIEW */ |
| 90124 | 90295 | nCol = pTab->nCol; |
| 90125 | 90296 | regData = regRowid + 1; |
| | @@ -90148,11 +90319,11 @@ |
| 90148 | 90319 | case OE_Rollback: |
| 90149 | 90320 | case OE_Fail: { |
| 90150 | 90321 | char *zMsg; |
| 90151 | 90322 | sqlite3VdbeAddOp3(v, OP_HaltIfNull, |
| 90152 | 90323 | SQLITE_CONSTRAINT, onError, regData+i); |
| 90153 | | - zMsg = sqlite3MPrintf(pParse->db, "%s.%s may not be NULL", |
| 90324 | + zMsg = sqlite3MPrintf(db, "%s.%s may not be NULL", |
| 90154 | 90325 | pTab->zName, pTab->aCol[i].zName); |
| 90155 | 90326 | sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC); |
| 90156 | 90327 | break; |
| 90157 | 90328 | } |
| 90158 | 90329 | case OE_Ignore: { |
| | @@ -90170,22 +90341,31 @@ |
| 90170 | 90341 | } |
| 90171 | 90342 | |
| 90172 | 90343 | /* Test all CHECK constraints |
| 90173 | 90344 | */ |
| 90174 | 90345 | #ifndef SQLITE_OMIT_CHECK |
| 90175 | | - if( pTab->pCheck && (pParse->db->flags & SQLITE_IgnoreChecks)==0 ){ |
| 90176 | | - int allOk = sqlite3VdbeMakeLabel(v); |
| 90346 | + if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ |
| 90347 | + ExprList *pCheck = pTab->pCheck; |
| 90177 | 90348 | pParse->ckBase = regData; |
| 90178 | | - sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, SQLITE_JUMPIFNULL); |
| 90179 | 90349 | onError = overrideError!=OE_Default ? overrideError : OE_Abort; |
| 90180 | | - if( onError==OE_Ignore ){ |
| 90181 | | - sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); |
| 90182 | | - }else{ |
| 90183 | | - if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */ |
| 90184 | | - sqlite3HaltConstraint(pParse, onError, 0, 0); |
| 90350 | + for(i=0; i<pCheck->nExpr; i++){ |
| 90351 | + int allOk = sqlite3VdbeMakeLabel(v); |
| 90352 | + sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL); |
| 90353 | + if( onError==OE_Ignore ){ |
| 90354 | + sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest); |
| 90355 | + }else{ |
| 90356 | + char *zConsName = pCheck->a[i].zName; |
| 90357 | + if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */ |
| 90358 | + if( zConsName ){ |
| 90359 | + zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName); |
| 90360 | + }else{ |
| 90361 | + zConsName = 0; |
| 90362 | + } |
| 90363 | + sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC); |
| 90364 | + } |
| 90365 | + sqlite3VdbeResolveLabel(v, allOk); |
| 90185 | 90366 | } |
| 90186 | | - sqlite3VdbeResolveLabel(v, allOk); |
| 90187 | 90367 | } |
| 90188 | 90368 | #endif /* !defined(SQLITE_OMIT_CHECK) */ |
| 90189 | 90369 | |
| 90190 | 90370 | /* If we have an INTEGER PRIMARY KEY, make sure the primary key |
| 90191 | 90371 | ** of the new record does not previously exist. Except, if this |
| | @@ -90237,11 +90417,11 @@ |
| 90237 | 90417 | ** |
| 90238 | 90418 | ** to run without a statement journal if there are no indexes on the |
| 90239 | 90419 | ** table. |
| 90240 | 90420 | */ |
| 90241 | 90421 | Trigger *pTrigger = 0; |
| 90242 | | - if( pParse->db->flags&SQLITE_RecTriggers ){ |
| 90422 | + if( db->flags&SQLITE_RecTriggers ){ |
| 90243 | 90423 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); |
| 90244 | 90424 | } |
| 90245 | 90425 | if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){ |
| 90246 | 90426 | sqlite3MultiWrite(pParse); |
| 90247 | 90427 | sqlite3GenerateRowDelete( |
| | @@ -90326,11 +90506,11 @@ |
| 90326 | 90506 | StrAccum errMsg; |
| 90327 | 90507 | const char *zSep; |
| 90328 | 90508 | char *zErr; |
| 90329 | 90509 | |
| 90330 | 90510 | sqlite3StrAccumInit(&errMsg, 0, 0, 200); |
| 90331 | | - errMsg.db = pParse->db; |
| 90511 | + errMsg.db = db; |
| 90332 | 90512 | zSep = pIdx->nColumn>1 ? "columns " : "column "; |
| 90333 | 90513 | for(j=0; j<pIdx->nColumn; j++){ |
| 90334 | 90514 | char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName; |
| 90335 | 90515 | sqlite3StrAccumAppend(&errMsg, zSep, -1); |
| 90336 | 90516 | zSep = ", "; |
| | @@ -90350,11 +90530,11 @@ |
| 90350 | 90530 | } |
| 90351 | 90531 | default: { |
| 90352 | 90532 | Trigger *pTrigger = 0; |
| 90353 | 90533 | assert( onError==OE_Replace ); |
| 90354 | 90534 | sqlite3MultiWrite(pParse); |
| 90355 | | - if( pParse->db->flags&SQLITE_RecTriggers ){ |
| 90535 | + if( db->flags&SQLITE_RecTriggers ){ |
| 90356 | 90536 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); |
| 90357 | 90537 | } |
| 90358 | 90538 | sqlite3GenerateRowDelete( |
| 90359 | 90539 | pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace |
| 90360 | 90540 | ); |
| | @@ -90680,11 +90860,11 @@ |
| 90680 | 90860 | if( pSrcIdx==0 ){ |
| 90681 | 90861 | return 0; /* pDestIdx has no corresponding index in pSrc */ |
| 90682 | 90862 | } |
| 90683 | 90863 | } |
| 90684 | 90864 | #ifndef SQLITE_OMIT_CHECK |
| 90685 | | - if( pDest->pCheck && sqlite3ExprCompare(pSrc->pCheck, pDest->pCheck) ){ |
| 90865 | + if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){ |
| 90686 | 90866 | return 0; /* Tables have different CHECK constraints. Ticket #2252 */ |
| 90687 | 90867 | } |
| 90688 | 90868 | #endif |
| 90689 | 90869 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 90690 | 90870 | /* Disallow the transfer optimization if the destination table constains |
| | @@ -95753,13 +95933,21 @@ |
| 95753 | 95933 | int nCol; /* Number of columns in the result set */ |
| 95754 | 95934 | Expr *p; /* Expression for a single result column */ |
| 95755 | 95935 | char *zName; /* Column name */ |
| 95756 | 95936 | int nName; /* Size of name in zName[] */ |
| 95757 | 95937 | |
| 95758 | | - *pnCol = nCol = pEList ? pEList->nExpr : 0; |
| 95759 | | - aCol = *paCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); |
| 95760 | | - if( aCol==0 ) return SQLITE_NOMEM; |
| 95938 | + if( pEList ){ |
| 95939 | + nCol = pEList->nExpr; |
| 95940 | + aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol); |
| 95941 | + testcase( aCol==0 ); |
| 95942 | + }else{ |
| 95943 | + nCol = 0; |
| 95944 | + aCol = 0; |
| 95945 | + } |
| 95946 | + *pnCol = nCol; |
| 95947 | + *paCol = aCol; |
| 95948 | + |
| 95761 | 95949 | for(i=0, pCol=aCol; i<nCol; i++, pCol++){ |
| 95762 | 95950 | /* Get an appropriate name for the column |
| 95763 | 95951 | */ |
| 95764 | 95952 | p = pEList->a[i].pExpr; |
| 95765 | 95953 | assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue) |
| | @@ -98723,11 +98911,11 @@ |
| 98723 | 98911 | if( pCol->iSorterColumn>=j ){ |
| 98724 | 98912 | int r1 = j + regBase; |
| 98725 | 98913 | int r2; |
| 98726 | 98914 | |
| 98727 | 98915 | r2 = sqlite3ExprCodeGetColumn(pParse, |
| 98728 | | - pCol->pTab, pCol->iColumn, pCol->iTable, r1); |
| 98916 | + pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0); |
| 98729 | 98917 | if( r1!=r2 ){ |
| 98730 | 98918 | sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1); |
| 98731 | 98919 | } |
| 98732 | 98920 | j++; |
| 98733 | 98921 | } |
| | @@ -103212,11 +103400,14 @@ |
| 103212 | 103400 | #ifdef SQLITE_EBCDIC |
| 103213 | 103401 | if( *pnoCase ) return 0; |
| 103214 | 103402 | #endif |
| 103215 | 103403 | pList = pExpr->x.pList; |
| 103216 | 103404 | pLeft = pList->a[1].pExpr; |
| 103217 | | - if( pLeft->op!=TK_COLUMN || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT ){ |
| 103405 | + if( pLeft->op!=TK_COLUMN |
| 103406 | + || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT |
| 103407 | + || IsVirtual(pLeft->pTab) |
| 103408 | + ){ |
| 103218 | 103409 | /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must |
| 103219 | 103410 | ** be the name of an indexed column with TEXT affinity. */ |
| 103220 | 103411 | return 0; |
| 103221 | 103412 | } |
| 103222 | 103413 | assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */ |
| | @@ -106909,11 +107100,11 @@ |
| 106909 | 107100 | ); |
| 106910 | 107101 | if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){ |
| 106911 | 107102 | int iSet = ((ii==pOrWc->nTerm-1)?-1:ii); |
| 106912 | 107103 | int r; |
| 106913 | 107104 | r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur, |
| 106914 | | - regRowid); |
| 107105 | + regRowid, 0); |
| 106915 | 107106 | sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, |
| 106916 | 107107 | sqlite3VdbeCurrentAddr(v)+2, r, iSet); |
| 106917 | 107108 | } |
| 106918 | 107109 | sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody); |
| 106919 | 107110 | |
| | @@ -107822,11 +108013,11 @@ |
| 107822 | 108013 | ** An instance of this structure is used to store the LIKE, |
| 107823 | 108014 | ** GLOB, NOT LIKE, and NOT GLOB operators. |
| 107824 | 108015 | */ |
| 107825 | 108016 | struct LikeOp { |
| 107826 | 108017 | Token eOperator; /* "like" or "glob" or "regexp" */ |
| 107827 | | - int not; /* True if the NOT keyword is present */ |
| 108018 | + int bNot; /* True if the NOT keyword is present */ |
| 107828 | 108019 | }; |
| 107829 | 108020 | |
| 107830 | 108021 | /* |
| 107831 | 108022 | ** An instance of the following structure describes the event of a |
| 107832 | 108023 | ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, |
| | @@ -108001,12 +108192,12 @@ |
| 108001 | 108192 | #endif |
| 108002 | 108193 | #define sqlite3ParserARG_SDECL Parse *pParse; |
| 108003 | 108194 | #define sqlite3ParserARG_PDECL ,Parse *pParse |
| 108004 | 108195 | #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse |
| 108005 | 108196 | #define sqlite3ParserARG_STORE yypParser->pParse = pParse |
| 108006 | | -#define YYNSTATE 629 |
| 108007 | | -#define YYNRULE 327 |
| 108197 | +#define YYNSTATE 627 |
| 108198 | +#define YYNRULE 325 |
| 108008 | 108199 | #define YYFALLBACK 1 |
| 108009 | 108200 | #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
| 108010 | 108201 | #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
| 108011 | 108202 | #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
| 108012 | 108203 | |
| | @@ -108072,480 +108263,478 @@ |
| 108072 | 108263 | ** shifting terminals. |
| 108073 | 108264 | ** yy_reduce_ofst[] For each state, the offset into yy_action for |
| 108074 | 108265 | ** shifting non-terminals after a reduce. |
| 108075 | 108266 | ** yy_default[] Default action for each state. |
| 108076 | 108267 | */ |
| 108077 | | -#define YY_ACTTAB_COUNT (1580) |
| 108268 | +#define YY_ACTTAB_COUNT (1561) |
| 108078 | 108269 | static const YYACTIONTYPE yy_action[] = { |
| 108079 | | - /* 0 */ 310, 328, 574, 573, 15, 172, 187, 596, 56, 56, |
| 108270 | + /* 0 */ 310, 328, 573, 572, 15, 171, 185, 595, 56, 56, |
| 108080 | 108271 | /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52, |
| 108081 | | - /* 20 */ 52, 52, 51, 234, 622, 621, 626, 622, 621, 299, |
| 108082 | | - /* 30 */ 589, 583, 56, 56, 56, 56, 236, 54, 54, 54, |
| 108083 | | - /* 40 */ 54, 53, 53, 52, 52, 52, 51, 234, 351, 57, |
| 108084 | | - /* 50 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56, |
| 108085 | | - /* 60 */ 56, 56, 570, 54, 54, 54, 54, 53, 53, 52, |
| 108086 | | - /* 70 */ 52, 52, 51, 234, 310, 596, 326, 607, 233, 232, |
| 108272 | + /* 20 */ 52, 52, 51, 233, 52, 52, 52, 51, 233, 624, |
| 108273 | + /* 30 */ 588, 582, 56, 56, 56, 56, 314, 54, 54, 54, |
| 108274 | + /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 299, 57, |
| 108275 | + /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 108276 | + /* 60 */ 56, 56, 569, 54, 54, 54, 54, 53, 53, 52, |
| 108277 | + /* 70 */ 52, 52, 51, 233, 310, 595, 326, 575, 663, 65, |
| 108087 | 108278 | /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 108088 | | - /* 90 */ 51, 234, 619, 618, 326, 619, 618, 166, 605, 492, |
| 108089 | | - /* 100 */ 381, 378, 377, 235, 589, 583, 554, 495, 1, 59, |
| 108090 | | - /* 110 */ 19, 376, 622, 621, 53, 53, 52, 52, 52, 51, |
| 108091 | | - /* 120 */ 234, 571, 571, 57, 58, 48, 581, 580, 582, 582, |
| 108092 | | - /* 130 */ 55, 55, 56, 56, 56, 56, 215, 54, 54, 54, |
| 108093 | | - /* 140 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 224, |
| 108094 | | - /* 150 */ 50, 47, 147, 177, 139, 281, 384, 276, 383, 169, |
| 108095 | | - /* 160 */ 408, 553, 578, 578, 622, 621, 272, 224, 439, 550, |
| 108096 | | - /* 170 */ 552, 410, 139, 281, 384, 276, 383, 169, 589, 583, |
| 108097 | | - /* 180 */ 619, 618, 280, 620, 272, 195, 413, 309, 440, 441, |
| 108098 | | - /* 190 */ 567, 491, 214, 279, 560, 600, 92, 57, 58, 48, |
| 108099 | | - /* 200 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56, |
| 108100 | | - /* 210 */ 559, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 108101 | | - /* 220 */ 51, 234, 310, 464, 233, 232, 558, 133, 519, 50, |
| 108102 | | - /* 230 */ 47, 147, 619, 618, 565, 436, 397, 515, 514, 518, |
| 108103 | | - /* 240 */ 410, 387, 438, 389, 437, 622, 621, 442, 570, 433, |
| 108104 | | - /* 250 */ 203, 390, 589, 583, 6, 413, 166, 670, 250, 381, |
| 108105 | | - /* 260 */ 378, 377, 525, 190, 600, 92, 594, 571, 571, 465, |
| 108106 | | - /* 270 */ 376, 57, 58, 48, 581, 580, 582, 582, 55, 55, |
| 108107 | | - /* 280 */ 56, 56, 56, 56, 599, 54, 54, 54, 54, 53, |
| 108108 | | - /* 290 */ 53, 52, 52, 52, 51, 234, 310, 592, 592, 592, |
| 108109 | | - /* 300 */ 490, 182, 247, 548, 249, 397, 273, 410, 7, 439, |
| 108110 | | - /* 310 */ 398, 606, 67, 619, 618, 620, 472, 256, 347, 255, |
| 108111 | | - /* 320 */ 473, 620, 413, 576, 620, 65, 589, 583, 236, 440, |
| 108112 | | - /* 330 */ 336, 600, 92, 68, 364, 192, 481, 622, 621, 547, |
| 108113 | | - /* 340 */ 622, 621, 560, 323, 207, 57, 58, 48, 581, 580, |
| 108114 | | - /* 350 */ 582, 582, 55, 55, 56, 56, 56, 56, 559, 54, |
| 108115 | | - /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 108116 | | - /* 370 */ 310, 410, 397, 146, 558, 531, 401, 348, 599, 166, |
| 108117 | | - /* 380 */ 248, 204, 381, 378, 377, 541, 413, 171, 337, 570, |
| 108118 | | - /* 390 */ 622, 621, 40, 376, 38, 600, 74, 465, 548, 490, |
| 108119 | | - /* 400 */ 589, 583, 532, 350, 579, 619, 618, 297, 619, 618, |
| 108120 | | - /* 410 */ 480, 67, 470, 39, 620, 599, 406, 574, 573, 57, |
| 108121 | | - /* 420 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56, |
| 108122 | | - /* 430 */ 56, 56, 577, 54, 54, 54, 54, 53, 53, 52, |
| 108123 | | - /* 440 */ 52, 52, 51, 234, 310, 256, 347, 255, 530, 52, |
| 108124 | | - /* 450 */ 52, 52, 51, 234, 345, 564, 236, 386, 619, 618, |
| 108125 | | - /* 460 */ 957, 185, 418, 2, 408, 410, 578, 578, 198, 197, |
| 108126 | | - /* 470 */ 196, 499, 183, 167, 589, 583, 671, 570, 505, 506, |
| 108127 | | - /* 480 */ 413, 267, 601, 672, 546, 208, 602, 36, 601, 600, |
| 108128 | | - /* 490 */ 91, 468, 602, 57, 58, 48, 581, 580, 582, 582, |
| 108129 | | - /* 500 */ 55, 55, 56, 56, 56, 56, 202, 54, 54, 54, |
| 108130 | | - /* 510 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 599, |
| 108131 | | - /* 520 */ 157, 408, 527, 578, 578, 263, 490, 265, 410, 873, |
| 108132 | | - /* 530 */ 410, 474, 474, 366, 373, 410, 504, 428, 67, 290, |
| 108133 | | - /* 540 */ 599, 620, 352, 413, 408, 413, 578, 578, 589, 583, |
| 108134 | | - /* 550 */ 413, 382, 600, 92, 600, 16, 543, 62, 503, 600, |
| 108135 | | - /* 560 */ 92, 408, 346, 578, 578, 168, 45, 57, 58, 48, |
| 108136 | | - /* 570 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56, |
| 108137 | | - /* 580 */ 200, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 108138 | | - /* 590 */ 51, 234, 310, 393, 395, 534, 510, 617, 616, 615, |
| 108139 | | - /* 600 */ 318, 314, 172, 66, 596, 410, 338, 596, 324, 571, |
| 108140 | | - /* 610 */ 571, 50, 47, 147, 599, 629, 627, 330, 539, 315, |
| 108141 | | - /* 620 */ 413, 30, 589, 583, 272, 236, 199, 144, 176, 600, |
| 108142 | | - /* 630 */ 73, 420, 947, 620, 947, 420, 946, 351, 946, 175, |
| 108143 | | - /* 640 */ 596, 57, 58, 48, 581, 580, 582, 582, 55, 55, |
| 108144 | | - /* 650 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53, |
| 108145 | | - /* 660 */ 53, 52, 52, 52, 51, 234, 310, 261, 410, 413, |
| 108146 | | - /* 670 */ 269, 208, 596, 363, 410, 596, 424, 360, 600, 69, |
| 108147 | | - /* 680 */ 424, 327, 620, 413, 50, 47, 147, 410, 358, 413, |
| 108148 | | - /* 690 */ 575, 553, 600, 94, 483, 509, 589, 583, 600, 97, |
| 108149 | | - /* 700 */ 552, 484, 413, 620, 188, 599, 551, 563, 596, 566, |
| 108150 | | - /* 710 */ 334, 600, 95, 205, 201, 57, 58, 48, 581, 580, |
| 108151 | | - /* 720 */ 582, 582, 55, 55, 56, 56, 56, 56, 352, 54, |
| 108152 | | - /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 108153 | | - /* 740 */ 310, 410, 261, 410, 167, 22, 356, 599, 359, 623, |
| 108154 | | - /* 750 */ 50, 47, 147, 548, 357, 562, 413, 620, 413, 332, |
| 108155 | | - /* 760 */ 523, 270, 410, 167, 620, 600, 104, 600, 103, 603, |
| 108156 | | - /* 770 */ 589, 583, 339, 539, 304, 423, 222, 413, 174, 304, |
| 108157 | | - /* 780 */ 422, 561, 567, 405, 214, 260, 600, 106, 620, 57, |
| 108158 | | - /* 790 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56, |
| 108159 | | - /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52, |
| 108160 | | - /* 810 */ 52, 52, 51, 234, 310, 410, 557, 413, 410, 421, |
| 108161 | | - /* 820 */ 273, 35, 512, 146, 421, 12, 600, 107, 213, 144, |
| 108162 | | - /* 830 */ 413, 410, 32, 413, 410, 620, 365, 353, 358, 600, |
| 108163 | | - /* 840 */ 134, 11, 600, 135, 589, 583, 413, 21, 548, 413, |
| 108164 | | - /* 850 */ 316, 148, 620, 620, 170, 600, 98, 223, 600, 102, |
| 108165 | | - /* 860 */ 374, 168, 167, 57, 58, 48, 581, 580, 582, 582, |
| 108166 | | - /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54, |
| 108167 | | - /* 880 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 410, |
| 108168 | | - /* 890 */ 273, 413, 410, 273, 212, 469, 410, 167, 628, 2, |
| 108169 | | - /* 900 */ 600, 101, 545, 221, 413, 620, 130, 413, 620, 410, |
| 108170 | | - /* 910 */ 539, 413, 537, 600, 93, 315, 600, 100, 589, 583, |
| 108171 | | - /* 920 */ 600, 77, 425, 305, 413, 620, 254, 322, 599, 458, |
| 108172 | | - /* 930 */ 320, 171, 543, 600, 96, 521, 520, 57, 58, 48, |
| 108173 | | - /* 940 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56, |
| 108174 | | - /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 108175 | | - /* 960 */ 51, 234, 310, 410, 273, 413, 410, 457, 358, 35, |
| 108176 | | - /* 970 */ 426, 230, 306, 319, 600, 138, 467, 520, 413, 620, |
| 108177 | | - /* 980 */ 143, 413, 410, 620, 410, 353, 529, 600, 137, 142, |
| 108178 | | - /* 990 */ 600, 136, 589, 583, 604, 261, 528, 413, 229, 413, |
| 108179 | | - /* 1000 */ 620, 321, 495, 28, 543, 543, 600, 76, 600, 90, |
| 108180 | | - /* 1010 */ 620, 57, 46, 48, 581, 580, 582, 582, 55, 55, |
| 108181 | | - /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53, |
| 108182 | | - /* 1030 */ 53, 52, 52, 52, 51, 234, 310, 261, 451, 413, |
| 108183 | | - /* 1040 */ 410, 211, 611, 285, 283, 610, 609, 502, 600, 89, |
| 108184 | | - /* 1050 */ 380, 217, 620, 128, 140, 413, 220, 620, 410, 409, |
| 108185 | | - /* 1060 */ 620, 620, 588, 587, 600, 75, 589, 583, 271, 620, |
| 108186 | | - /* 1070 */ 51, 234, 127, 413, 620, 599, 627, 330, 27, 375, |
| 108187 | | - /* 1080 */ 449, 279, 600, 88, 585, 584, 58, 48, 581, 580, |
| 108188 | | - /* 1090 */ 582, 582, 55, 55, 56, 56, 56, 56, 410, 54, |
| 108189 | | - /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234, |
| 108190 | | - /* 1110 */ 310, 586, 410, 413, 410, 261, 593, 165, 399, 556, |
| 108191 | | - /* 1120 */ 126, 371, 600, 87, 478, 186, 123, 413, 367, 413, |
| 108192 | | - /* 1130 */ 620, 620, 410, 620, 620, 410, 600, 99, 600, 86, |
| 108193 | | - /* 1140 */ 589, 583, 475, 122, 258, 171, 471, 413, 160, 121, |
| 108194 | | - /* 1150 */ 413, 14, 159, 463, 25, 24, 600, 17, 448, 600, |
| 108195 | | - /* 1160 */ 85, 48, 581, 580, 582, 582, 55, 55, 56, 56, |
| 108196 | | - /* 1170 */ 56, 56, 158, 54, 54, 54, 54, 53, 53, 52, |
| 108197 | | - /* 1180 */ 52, 52, 51, 234, 44, 404, 261, 3, 544, 261, |
| 108198 | | - /* 1190 */ 540, 414, 621, 460, 119, 118, 538, 275, 10, 349, |
| 108199 | | - /* 1200 */ 4, 620, 407, 620, 620, 620, 116, 44, 404, 410, |
| 108200 | | - /* 1210 */ 3, 620, 620, 410, 414, 621, 456, 454, 252, 450, |
| 108201 | | - /* 1220 */ 508, 402, 111, 109, 413, 407, 155, 444, 413, 447, |
| 108202 | | - /* 1230 */ 435, 565, 219, 600, 84, 620, 108, 600, 83, 64, |
| 108203 | | - /* 1240 */ 434, 417, 625, 150, 402, 333, 410, 237, 238, 124, |
| 108204 | | - /* 1250 */ 274, 41, 42, 533, 565, 206, 189, 261, 43, 412, |
| 108205 | | - /* 1260 */ 411, 413, 261, 594, 488, 620, 329, 149, 419, 268, |
| 108206 | | - /* 1270 */ 600, 72, 620, 266, 41, 42, 181, 620, 410, 620, |
| 108207 | | - /* 1280 */ 105, 43, 412, 411, 620, 624, 594, 614, 620, 599, |
| 108208 | | - /* 1290 */ 228, 125, 313, 413, 592, 592, 592, 591, 590, 13, |
| 108209 | | - /* 1300 */ 218, 410, 600, 71, 236, 244, 44, 404, 264, 3, |
| 108210 | | - /* 1310 */ 312, 613, 340, 414, 621, 180, 413, 592, 592, 592, |
| 108211 | | - /* 1320 */ 591, 590, 13, 620, 407, 600, 82, 410, 416, 34, |
| 108212 | | - /* 1330 */ 404, 410, 3, 410, 262, 410, 414, 621, 612, 331, |
| 108213 | | - /* 1340 */ 178, 415, 413, 402, 8, 236, 413, 407, 413, 620, |
| 108214 | | - /* 1350 */ 413, 600, 81, 565, 257, 600, 80, 600, 70, 600, |
| 108215 | | - /* 1360 */ 18, 598, 361, 462, 461, 30, 402, 294, 31, 620, |
| 108216 | | - /* 1370 */ 293, 354, 251, 41, 42, 410, 565, 620, 620, 620, |
| 108217 | | - /* 1380 */ 43, 412, 411, 453, 396, 594, 620, 620, 394, 61, |
| 108218 | | - /* 1390 */ 413, 292, 443, 622, 621, 243, 41, 42, 620, 600, |
| 108219 | | - /* 1400 */ 79, 597, 291, 43, 412, 411, 60, 620, 594, 240, |
| 108220 | | - /* 1410 */ 620, 410, 231, 37, 555, 173, 592, 592, 592, 591, |
| 108221 | | - /* 1420 */ 590, 13, 216, 239, 620, 184, 413, 302, 301, 300, |
| 108222 | | - /* 1430 */ 179, 298, 388, 565, 452, 600, 78, 286, 620, 592, |
| 108223 | | - /* 1440 */ 592, 592, 591, 590, 13, 429, 29, 413, 151, 289, |
| 108224 | | - /* 1450 */ 242, 145, 392, 194, 193, 288, 600, 9, 542, 241, |
| 108225 | | - /* 1460 */ 620, 525, 391, 284, 620, 594, 620, 620, 522, 536, |
| 108226 | | - /* 1470 */ 620, 535, 153, 385, 465, 516, 282, 325, 154, 517, |
| 108227 | | - /* 1480 */ 277, 152, 512, 511, 513, 129, 226, 308, 487, 486, |
| 108228 | | - /* 1490 */ 485, 164, 372, 493, 307, 227, 592, 592, 592, 225, |
| 108229 | | - /* 1500 */ 479, 163, 368, 370, 162, 476, 210, 477, 26, 259, |
| 108230 | | - /* 1510 */ 161, 466, 362, 141, 132, 120, 117, 455, 156, 115, |
| 108231 | | - /* 1520 */ 344, 343, 256, 342, 245, 114, 113, 446, 311, 112, |
| 108232 | | - /* 1530 */ 23, 317, 432, 236, 131, 431, 110, 430, 20, 427, |
| 108233 | | - /* 1540 */ 608, 595, 295, 63, 379, 287, 509, 191, 278, 403, |
| 108234 | | - /* 1550 */ 572, 569, 497, 498, 496, 494, 335, 459, 445, 303, |
| 108235 | | - /* 1560 */ 296, 246, 341, 355, 5, 568, 369, 507, 253, 549, |
| 108236 | | - /* 1570 */ 526, 209, 400, 501, 500, 524, 234, 958, 489, 482, |
| 108279 | + /* 90 */ 51, 233, 53, 53, 52, 52, 52, 51, 233, 489, |
| 108280 | + /* 100 */ 663, 440, 663, 235, 588, 582, 553, 297, 363, 59, |
| 108281 | + /* 110 */ 481, 67, 360, 1, 618, 351, 618, 620, 619, 207, |
| 108282 | + /* 120 */ 6, 441, 442, 57, 58, 48, 580, 579, 581, 581, |
| 108283 | + /* 130 */ 55, 55, 56, 56, 56, 56, 605, 54, 54, 54, |
| 108284 | + /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223, |
| 108285 | + /* 150 */ 50, 47, 146, 598, 138, 281, 385, 276, 384, 168, |
| 108286 | + /* 160 */ 489, 552, 620, 619, 620, 619, 272, 214, 440, 411, |
| 108287 | + /* 170 */ 551, 604, 67, 165, 7, 618, 352, 353, 588, 582, |
| 108288 | + /* 180 */ 443, 569, 192, 618, 414, 617, 616, 668, 441, 336, |
| 108289 | + /* 190 */ 669, 62, 618, 599, 92, 382, 346, 57, 58, 48, |
| 108290 | + /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 108291 | + /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 108292 | + /* 220 */ 51, 233, 310, 465, 232, 231, 373, 132, 514, 513, |
| 108293 | + /* 230 */ 617, 616, 617, 616, 398, 437, 411, 66, 280, 388, |
| 108294 | + /* 240 */ 411, 595, 439, 220, 438, 620, 619, 337, 569, 279, |
| 108295 | + /* 250 */ 201, 414, 588, 582, 166, 414, 546, 167, 68, 234, |
| 108296 | + /* 260 */ 599, 92, 620, 619, 599, 92, 19, 570, 570, 466, |
| 108297 | + /* 270 */ 564, 57, 58, 48, 580, 579, 581, 581, 55, 55, |
| 108298 | + /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53, |
| 108299 | + /* 290 */ 53, 52, 52, 52, 51, 233, 310, 411, 524, 232, |
| 108300 | + /* 300 */ 231, 398, 593, 547, 559, 398, 348, 202, 175, 595, |
| 108301 | + /* 310 */ 399, 315, 414, 617, 616, 387, 272, 255, 347, 254, |
| 108302 | + /* 320 */ 558, 599, 74, 620, 619, 45, 588, 582, 235, 466, |
| 108303 | + /* 330 */ 617, 616, 511, 591, 591, 591, 557, 578, 402, 545, |
| 108304 | + /* 340 */ 600, 598, 570, 570, 601, 57, 58, 48, 580, 579, |
| 108305 | + /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 550, 54, |
| 108306 | + /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 108307 | + /* 370 */ 310, 309, 411, 145, 566, 490, 213, 255, 347, 254, |
| 108308 | + /* 380 */ 196, 195, 194, 587, 586, 531, 600, 414, 235, 174, |
| 108309 | + /* 390 */ 601, 617, 616, 411, 620, 619, 599, 91, 547, 574, |
| 108310 | + /* 400 */ 588, 582, 50, 47, 146, 584, 583, 471, 414, 249, |
| 108311 | + /* 410 */ 565, 542, 186, 39, 304, 424, 562, 599, 16, 57, |
| 108312 | + /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 108313 | + /* 430 */ 56, 56, 585, 54, 54, 54, 54, 53, 53, 52, |
| 108314 | + /* 440 */ 52, 52, 51, 233, 310, 559, 290, 530, 529, 345, |
| 108315 | + /* 450 */ 533, 576, 540, 246, 170, 248, 411, 396, 411, 422, |
| 108316 | + /* 460 */ 199, 558, 617, 616, 165, 563, 50, 47, 146, 181, |
| 108317 | + /* 470 */ 498, 414, 166, 414, 588, 582, 269, 557, 166, 518, |
| 108318 | + /* 480 */ 599, 92, 599, 92, 561, 595, 469, 36, 173, 409, |
| 108319 | + /* 490 */ 517, 577, 577, 57, 58, 48, 580, 579, 581, 581, |
| 108320 | + /* 500 */ 55, 55, 56, 56, 56, 56, 338, 54, 54, 54, |
| 108321 | + /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 304, |
| 108322 | + /* 520 */ 423, 394, 526, 318, 869, 235, 167, 180, 473, 547, |
| 108323 | + /* 530 */ 503, 247, 474, 381, 378, 377, 409, 351, 577, 577, |
| 108324 | + /* 540 */ 409, 560, 577, 577, 376, 383, 364, 603, 588, 582, |
| 108325 | + /* 550 */ 620, 619, 502, 595, 409, 494, 577, 577, 409, 266, |
| 108326 | + /* 560 */ 577, 577, 421, 943, 422, 943, 198, 57, 58, 48, |
| 108327 | + /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 108328 | + /* 580 */ 315, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 108329 | + /* 590 */ 51, 233, 310, 390, 421, 942, 509, 942, 556, 145, |
| 108330 | + /* 600 */ 598, 391, 324, 262, 549, 264, 411, 425, 407, 573, |
| 108331 | + /* 610 */ 572, 12, 197, 143, 489, 50, 47, 146, 617, 616, |
| 108332 | + /* 620 */ 206, 414, 588, 582, 547, 429, 67, 212, 143, 618, |
| 108333 | + /* 630 */ 599, 73, 504, 505, 207, 434, 475, 475, 366, 425, |
| 108334 | + /* 640 */ 35, 57, 58, 48, 580, 579, 581, 581, 55, 55, |
| 108335 | + /* 650 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53, |
| 108336 | + /* 660 */ 53, 52, 52, 52, 51, 233, 310, 260, 598, 569, |
| 108337 | + /* 670 */ 268, 615, 614, 613, 171, 411, 595, 11, 411, 350, |
| 108338 | + /* 680 */ 411, 32, 618, 953, 183, 419, 2, 627, 625, 330, |
| 108339 | + /* 690 */ 414, 352, 552, 414, 538, 414, 588, 582, 188, 599, |
| 108340 | + /* 700 */ 69, 551, 599, 94, 599, 97, 374, 544, 166, 618, |
| 108341 | + /* 710 */ 334, 359, 50, 47, 146, 57, 58, 48, 580, 579, |
| 108342 | + /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54, |
| 108343 | + /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 108344 | + /* 740 */ 310, 411, 129, 414, 595, 22, 273, 156, 411, 566, |
| 108345 | + /* 750 */ 406, 213, 599, 95, 570, 570, 414, 327, 169, 332, |
| 108346 | + /* 760 */ 411, 618, 536, 414, 358, 599, 104, 483, 508, 356, |
| 108347 | + /* 770 */ 588, 582, 599, 103, 484, 414, 470, 357, 166, 618, |
| 108348 | + /* 780 */ 626, 2, 204, 323, 599, 105, 40, 528, 38, 57, |
| 108349 | + /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 108350 | + /* 800 */ 56, 56, 411, 54, 54, 54, 54, 53, 53, 52, |
| 108351 | + /* 810 */ 52, 52, 51, 233, 310, 411, 598, 414, 411, 260, |
| 108352 | + /* 820 */ 273, 273, 273, 273, 426, 305, 599, 106, 520, 519, |
| 108353 | + /* 830 */ 414, 411, 142, 414, 618, 618, 618, 618, 618, 599, |
| 108354 | + /* 840 */ 133, 339, 599, 134, 588, 582, 414, 21, 30, 316, |
| 108355 | + /* 850 */ 147, 459, 221, 170, 527, 599, 98, 222, 322, 321, |
| 108356 | + /* 860 */ 320, 141, 259, 57, 58, 48, 580, 579, 581, 581, |
| 108357 | + /* 870 */ 55, 55, 56, 56, 56, 56, 411, 54, 54, 54, |
| 108358 | + /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 411, |
| 108359 | + /* 890 */ 260, 414, 411, 458, 200, 35, 411, 358, 211, 228, |
| 108360 | + /* 900 */ 599, 102, 468, 519, 414, 618, 28, 414, 538, 501, |
| 108361 | + /* 910 */ 411, 414, 618, 599, 101, 358, 599, 93, 588, 582, |
| 108362 | + /* 920 */ 599, 100, 522, 618, 427, 414, 306, 271, 598, 380, |
| 108363 | + /* 930 */ 618, 602, 598, 452, 599, 77, 210, 57, 58, 48, |
| 108364 | + /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56, |
| 108365 | + /* 950 */ 411, 54, 54, 54, 54, 53, 53, 52, 52, 52, |
| 108366 | + /* 960 */ 51, 233, 310, 411, 621, 414, 411, 127, 609, 270, |
| 108367 | + /* 970 */ 598, 365, 51, 233, 599, 96, 625, 330, 414, 618, |
| 108368 | + /* 980 */ 126, 414, 411, 618, 411, 253, 608, 599, 137, 27, |
| 108369 | + /* 990 */ 599, 136, 588, 582, 375, 260, 125, 414, 164, 414, |
| 108370 | + /* 1000 */ 371, 618, 279, 219, 542, 542, 599, 135, 599, 76, |
| 108371 | + /* 1010 */ 618, 57, 46, 48, 580, 579, 581, 581, 55, 55, |
| 108372 | + /* 1020 */ 56, 56, 56, 56, 411, 54, 54, 54, 54, 53, |
| 108373 | + /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 411, 450, 414, |
| 108374 | + /* 1040 */ 411, 260, 542, 229, 285, 607, 479, 184, 599, 90, |
| 108375 | + /* 1050 */ 367, 122, 414, 476, 121, 414, 618, 170, 411, 353, |
| 108376 | + /* 1060 */ 618, 599, 89, 410, 599, 75, 588, 582, 472, 257, |
| 108377 | + /* 1070 */ 538, 120, 159, 414, 618, 14, 464, 158, 618, 157, |
| 108378 | + /* 1080 */ 461, 283, 599, 88, 449, 618, 58, 48, 580, 579, |
| 108379 | + /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54, |
| 108380 | + /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233, |
| 108381 | + /* 1110 */ 310, 411, 260, 414, 411, 592, 260, 118, 25, 400, |
| 108382 | + /* 1120 */ 10, 24, 599, 87, 117, 216, 414, 618, 349, 414, |
| 108383 | + /* 1130 */ 618, 618, 411, 319, 618, 599, 99, 555, 599, 86, |
| 108384 | + /* 1140 */ 588, 582, 4, 260, 457, 455, 115, 414, 251, 154, |
| 108385 | + /* 1150 */ 451, 108, 618, 110, 436, 448, 599, 17, 618, 218, |
| 108386 | + /* 1160 */ 107, 48, 580, 579, 581, 581, 55, 55, 56, 56, |
| 108387 | + /* 1170 */ 56, 56, 435, 54, 54, 54, 54, 53, 53, 52, |
| 108388 | + /* 1180 */ 52, 52, 51, 233, 44, 405, 217, 3, 411, 260, |
| 108389 | + /* 1190 */ 543, 415, 619, 445, 64, 149, 539, 237, 333, 329, |
| 108390 | + /* 1200 */ 203, 187, 408, 414, 618, 618, 420, 44, 405, 411, |
| 108391 | + /* 1210 */ 3, 618, 599, 85, 415, 619, 148, 227, 622, 179, |
| 108392 | + /* 1220 */ 313, 403, 312, 612, 414, 408, 611, 124, 417, 178, |
| 108393 | + /* 1230 */ 610, 564, 243, 599, 84, 537, 8, 176, 235, 416, |
| 108394 | + /* 1240 */ 294, 418, 623, 30, 403, 597, 411, 236, 293, 123, |
| 108395 | + /* 1250 */ 618, 41, 42, 532, 564, 205, 292, 275, 43, 413, |
| 108396 | + /* 1260 */ 412, 414, 395, 593, 507, 274, 31, 397, 291, 37, |
| 108397 | + /* 1270 */ 599, 83, 618, 491, 41, 42, 267, 411, 265, 618, |
| 108398 | + /* 1280 */ 618, 43, 413, 412, 596, 263, 593, 60, 618, 598, |
| 108399 | + /* 1290 */ 261, 618, 414, 618, 591, 591, 591, 590, 589, 13, |
| 108400 | + /* 1300 */ 618, 599, 72, 554, 235, 618, 44, 405, 256, 3, |
| 108401 | + /* 1310 */ 361, 172, 340, 415, 619, 230, 411, 591, 591, 591, |
| 108402 | + /* 1320 */ 590, 589, 13, 618, 408, 618, 182, 411, 286, 34, |
| 108403 | + /* 1330 */ 405, 414, 3, 411, 463, 411, 415, 619, 29, 331, |
| 108404 | + /* 1340 */ 599, 71, 414, 403, 392, 386, 284, 408, 414, 618, |
| 108405 | + /* 1350 */ 414, 599, 82, 564, 411, 462, 354, 599, 81, 599, |
| 108406 | + /* 1360 */ 80, 541, 250, 535, 282, 521, 403, 534, 516, 414, |
| 108407 | + /* 1370 */ 618, 618, 454, 41, 42, 411, 564, 618, 599, 70, |
| 108408 | + /* 1380 */ 43, 413, 412, 444, 515, 593, 242, 618, 325, 61, |
| 108409 | + /* 1390 */ 414, 277, 239, 620, 619, 238, 41, 42, 618, 599, |
| 108410 | + /* 1400 */ 18, 618, 512, 43, 413, 412, 511, 618, 593, 430, |
| 108411 | + /* 1410 */ 618, 411, 128, 510, 308, 226, 591, 591, 591, 590, |
| 108412 | + /* 1420 */ 589, 13, 215, 289, 618, 225, 414, 302, 301, 300, |
| 108413 | + /* 1430 */ 177, 298, 411, 564, 453, 599, 79, 224, 618, 591, |
| 108414 | + /* 1440 */ 591, 591, 590, 589, 13, 389, 492, 414, 150, 144, |
| 108415 | + /* 1450 */ 241, 393, 288, 191, 190, 193, 599, 78, 165, 240, |
| 108416 | + /* 1460 */ 414, 524, 487, 307, 618, 593, 618, 618, 486, 599, |
| 108417 | + /* 1470 */ 9, 163, 152, 485, 466, 372, 480, 162, 153, 370, |
| 108418 | + /* 1480 */ 161, 151, 209, 478, 258, 368, 477, 26, 160, 467, |
| 108419 | + /* 1490 */ 140, 362, 131, 119, 116, 456, 591, 591, 591, 155, |
| 108420 | + /* 1500 */ 114, 344, 343, 113, 112, 111, 447, 109, 130, 23, |
| 108421 | + /* 1510 */ 317, 433, 20, 432, 431, 428, 606, 594, 63, 189, |
| 108422 | + /* 1520 */ 404, 571, 255, 342, 244, 295, 287, 278, 311, 508, |
| 108423 | + /* 1530 */ 496, 497, 495, 235, 493, 568, 379, 355, 460, 245, |
| 108424 | + /* 1540 */ 341, 446, 303, 567, 5, 252, 548, 208, 139, 506, |
| 108425 | + /* 1550 */ 369, 401, 500, 499, 296, 525, 335, 488, 482, 523, |
| 108426 | + /* 1560 */ 233, |
| 108237 | 108427 | }; |
| 108238 | 108428 | static const YYCODETYPE yy_lookahead[] = { |
| 108239 | 108429 | /* 0 */ 19, 169, 170, 171, 22, 24, 24, 26, 77, 78, |
| 108240 | 108430 | /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, |
| 108241 | | - /* 20 */ 89, 90, 91, 92, 26, 27, 1, 26, 27, 15, |
| 108242 | | - /* 30 */ 49, 50, 77, 78, 79, 80, 116, 82, 83, 84, |
| 108243 | | - /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 128, 68, |
| 108431 | + /* 20 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 1, |
| 108432 | + /* 30 */ 49, 50, 77, 78, 79, 80, 155, 82, 83, 84, |
| 108433 | + /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 15, 68, |
| 108244 | 108434 | /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 108245 | 108435 | /* 60 */ 79, 80, 230, 82, 83, 84, 85, 86, 87, 88, |
| 108246 | | - /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 86, 87, |
| 108436 | + /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 1, 25, |
| 108247 | 108437 | /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 108248 | | - /* 90 */ 91, 92, 94, 95, 19, 94, 95, 96, 172, 173, |
| 108249 | | - /* 100 */ 99, 100, 101, 197, 49, 50, 177, 181, 22, 54, |
| 108250 | | - /* 110 */ 204, 110, 26, 27, 86, 87, 88, 89, 90, 91, |
| 108251 | | - /* 120 */ 92, 129, 130, 68, 69, 70, 71, 72, 73, 74, |
| 108252 | | - /* 130 */ 75, 76, 77, 78, 79, 80, 22, 82, 83, 84, |
| 108438 | + /* 90 */ 91, 92, 86, 87, 88, 89, 90, 91, 92, 150, |
| 108439 | + /* 100 */ 23, 150, 25, 116, 49, 50, 177, 158, 227, 54, |
| 108440 | + /* 110 */ 161, 162, 231, 22, 165, 128, 165, 26, 27, 160, |
| 108441 | + /* 120 */ 22, 170, 171, 68, 69, 70, 71, 72, 73, 74, |
| 108442 | + /* 130 */ 75, 76, 77, 78, 79, 80, 23, 82, 83, 84, |
| 108253 | 108443 | /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92, |
| 108254 | | - /* 150 */ 221, 222, 223, 96, 97, 98, 99, 100, 101, 102, |
| 108255 | | - /* 160 */ 112, 32, 114, 115, 26, 27, 109, 92, 150, 25, |
| 108256 | | - /* 170 */ 41, 150, 97, 98, 99, 100, 101, 102, 49, 50, |
| 108257 | | - /* 180 */ 94, 95, 98, 165, 109, 25, 165, 163, 170, 171, |
| 108258 | | - /* 190 */ 166, 167, 168, 109, 12, 174, 175, 68, 69, 70, |
| 108444 | + /* 150 */ 221, 222, 223, 194, 97, 98, 99, 100, 101, 102, |
| 108445 | + /* 160 */ 150, 32, 26, 27, 26, 27, 109, 22, 150, 150, |
| 108446 | + /* 170 */ 41, 161, 162, 96, 76, 165, 217, 150, 49, 50, |
| 108447 | + /* 180 */ 229, 230, 172, 165, 165, 94, 95, 118, 170, 171, |
| 108448 | + /* 190 */ 118, 232, 165, 174, 175, 185, 237, 68, 69, 70, |
| 108259 | 108449 | /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 108260 | | - /* 210 */ 28, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 108261 | | - /* 220 */ 91, 92, 19, 11, 86, 87, 44, 24, 46, 221, |
| 108262 | | - /* 230 */ 222, 223, 94, 95, 66, 97, 215, 7, 8, 57, |
| 108263 | | - /* 240 */ 150, 220, 104, 19, 106, 26, 27, 229, 230, 241, |
| 108264 | | - /* 250 */ 160, 27, 49, 50, 22, 165, 96, 118, 16, 99, |
| 108265 | | - /* 260 */ 100, 101, 94, 119, 174, 175, 98, 129, 130, 57, |
| 108266 | | - /* 270 */ 110, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 108450 | + /* 210 */ 118, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 108451 | + /* 220 */ 91, 92, 19, 11, 86, 87, 19, 24, 7, 8, |
| 108452 | + /* 230 */ 94, 95, 94, 95, 215, 97, 150, 22, 98, 220, |
| 108453 | + /* 240 */ 150, 26, 104, 216, 106, 26, 27, 229, 230, 109, |
| 108454 | + /* 250 */ 160, 165, 49, 50, 25, 165, 120, 50, 22, 197, |
| 108455 | + /* 260 */ 174, 175, 26, 27, 174, 175, 204, 129, 130, 57, |
| 108456 | + /* 270 */ 66, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 108267 | 108457 | /* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86, |
| 108268 | | - /* 290 */ 87, 88, 89, 90, 91, 92, 19, 129, 130, 131, |
| 108269 | | - /* 300 */ 150, 23, 60, 25, 62, 215, 150, 150, 76, 150, |
| 108270 | | - /* 310 */ 220, 161, 162, 94, 95, 165, 30, 105, 106, 107, |
| 108271 | | - /* 320 */ 34, 165, 165, 23, 165, 25, 49, 50, 116, 170, |
| 108272 | | - /* 330 */ 171, 174, 175, 22, 48, 185, 186, 26, 27, 120, |
| 108273 | | - /* 340 */ 26, 27, 12, 187, 160, 68, 69, 70, 71, 72, |
| 108274 | | - /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 28, 82, |
| 108458 | + /* 290 */ 87, 88, 89, 90, 91, 92, 19, 150, 94, 86, |
| 108459 | + /* 300 */ 87, 215, 98, 25, 12, 215, 220, 160, 118, 94, |
| 108460 | + /* 310 */ 220, 104, 165, 94, 95, 88, 109, 105, 106, 107, |
| 108461 | + /* 320 */ 28, 174, 175, 26, 27, 22, 49, 50, 116, 57, |
| 108462 | + /* 330 */ 94, 95, 103, 129, 130, 131, 44, 113, 46, 120, |
| 108463 | + /* 340 */ 113, 194, 129, 130, 117, 68, 69, 70, 71, 72, |
| 108464 | + /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 177, 82, |
| 108275 | 108465 | /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 108276 | | - /* 370 */ 19, 150, 215, 95, 44, 23, 46, 220, 194, 96, |
| 108277 | | - /* 380 */ 138, 160, 99, 100, 101, 23, 165, 25, 229, 230, |
| 108278 | | - /* 390 */ 26, 27, 135, 110, 137, 174, 175, 57, 120, 150, |
| 108279 | | - /* 400 */ 49, 50, 88, 219, 113, 94, 95, 158, 94, 95, |
| 108280 | | - /* 410 */ 161, 162, 21, 136, 165, 194, 169, 170, 171, 68, |
| 108466 | + /* 370 */ 19, 163, 150, 95, 166, 167, 168, 105, 106, 107, |
| 108467 | + /* 380 */ 105, 106, 107, 49, 50, 88, 113, 165, 116, 118, |
| 108468 | + /* 390 */ 117, 94, 95, 150, 26, 27, 174, 175, 120, 23, |
| 108469 | + /* 400 */ 49, 50, 221, 222, 223, 71, 72, 21, 165, 16, |
| 108470 | + /* 410 */ 23, 166, 22, 136, 22, 23, 11, 174, 175, 68, |
| 108281 | 108471 | /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 108282 | | - /* 430 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88, |
| 108283 | | - /* 440 */ 89, 90, 91, 92, 19, 105, 106, 107, 23, 88, |
| 108284 | | - /* 450 */ 89, 90, 91, 92, 63, 23, 116, 88, 94, 95, |
| 108285 | | - /* 460 */ 142, 143, 144, 145, 112, 150, 114, 115, 105, 106, |
| 108286 | | - /* 470 */ 107, 23, 23, 25, 49, 50, 118, 230, 97, 98, |
| 108287 | | - /* 480 */ 165, 16, 113, 118, 120, 160, 117, 136, 113, 174, |
| 108288 | | - /* 490 */ 175, 100, 117, 68, 69, 70, 71, 72, 73, 74, |
| 108289 | | - /* 500 */ 75, 76, 77, 78, 79, 80, 160, 82, 83, 84, |
| 108290 | | - /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 194, |
| 108291 | | - /* 520 */ 25, 112, 23, 114, 115, 60, 150, 62, 150, 138, |
| 108292 | | - /* 530 */ 150, 105, 106, 107, 19, 150, 36, 161, 162, 224, |
| 108293 | | - /* 540 */ 194, 165, 217, 165, 112, 165, 114, 115, 49, 50, |
| 108294 | | - /* 550 */ 165, 51, 174, 175, 174, 175, 166, 232, 58, 174, |
| 108295 | | - /* 560 */ 175, 112, 237, 114, 115, 50, 22, 68, 69, 70, |
| 108472 | + /* 430 */ 79, 80, 98, 82, 83, 84, 85, 86, 87, 88, |
| 108473 | + /* 440 */ 89, 90, 91, 92, 19, 12, 224, 23, 23, 63, |
| 108474 | + /* 450 */ 205, 23, 23, 60, 25, 62, 150, 214, 150, 67, |
| 108475 | + /* 460 */ 22, 28, 94, 95, 96, 23, 221, 222, 223, 23, |
| 108476 | + /* 470 */ 23, 165, 25, 165, 49, 50, 23, 44, 25, 46, |
| 108477 | + /* 480 */ 174, 175, 174, 175, 23, 26, 100, 136, 25, 112, |
| 108478 | + /* 490 */ 57, 114, 115, 68, 69, 70, 71, 72, 73, 74, |
| 108479 | + /* 500 */ 75, 76, 77, 78, 79, 80, 97, 82, 83, 84, |
| 108480 | + /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 22, |
| 108481 | + /* 520 */ 23, 215, 23, 215, 138, 116, 50, 23, 30, 25, |
| 108482 | + /* 530 */ 36, 138, 34, 99, 100, 101, 112, 128, 114, 115, |
| 108483 | + /* 540 */ 112, 23, 114, 115, 110, 51, 48, 173, 49, 50, |
| 108484 | + /* 550 */ 26, 27, 58, 94, 112, 181, 114, 115, 112, 16, |
| 108485 | + /* 560 */ 114, 115, 22, 23, 67, 25, 160, 68, 69, 70, |
| 108296 | 108486 | /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 108297 | | - /* 580 */ 160, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 108298 | | - /* 590 */ 91, 92, 19, 215, 214, 205, 23, 7, 8, 9, |
| 108299 | | - /* 600 */ 215, 155, 24, 22, 26, 150, 97, 26, 108, 129, |
| 108300 | | - /* 610 */ 130, 221, 222, 223, 194, 0, 1, 2, 150, 104, |
| 108301 | | - /* 620 */ 165, 126, 49, 50, 109, 116, 206, 207, 118, 174, |
| 108302 | | - /* 630 */ 175, 22, 23, 165, 25, 22, 23, 128, 25, 118, |
| 108303 | | - /* 640 */ 26, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 108304 | | - /* 650 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86, |
| 108305 | | - /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 150, 165, |
| 108306 | | - /* 670 */ 23, 160, 94, 227, 150, 94, 67, 231, 174, 175, |
| 108307 | | - /* 680 */ 67, 213, 165, 165, 221, 222, 223, 150, 150, 165, |
| 108308 | | - /* 690 */ 23, 32, 174, 175, 181, 182, 49, 50, 174, 175, |
| 108309 | | - /* 700 */ 41, 188, 165, 165, 22, 194, 177, 11, 94, 23, |
| 108310 | | - /* 710 */ 193, 174, 175, 160, 22, 68, 69, 70, 71, 72, |
| 108311 | | - /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 217, 82, |
| 108487 | + /* 580 */ 104, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 108488 | + /* 590 */ 91, 92, 19, 19, 22, 23, 23, 25, 23, 95, |
| 108489 | + /* 600 */ 194, 27, 108, 60, 25, 62, 150, 67, 169, 170, |
| 108490 | + /* 610 */ 171, 35, 206, 207, 150, 221, 222, 223, 94, 95, |
| 108491 | + /* 620 */ 160, 165, 49, 50, 120, 161, 162, 206, 207, 165, |
| 108492 | + /* 630 */ 174, 175, 97, 98, 160, 241, 105, 106, 107, 67, |
| 108493 | + /* 640 */ 25, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 108494 | + /* 650 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86, |
| 108495 | + /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 194, 230, |
| 108496 | + /* 670 */ 23, 7, 8, 9, 24, 150, 26, 35, 150, 219, |
| 108497 | + /* 680 */ 150, 25, 165, 142, 143, 144, 145, 0, 1, 2, |
| 108498 | + /* 690 */ 165, 217, 32, 165, 150, 165, 49, 50, 119, 174, |
| 108499 | + /* 700 */ 175, 41, 174, 175, 174, 175, 23, 120, 25, 165, |
| 108500 | + /* 710 */ 193, 237, 221, 222, 223, 68, 69, 70, 71, 72, |
| 108501 | + /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82, |
| 108312 | 108502 | /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 108313 | | - /* 740 */ 19, 150, 150, 150, 25, 24, 19, 194, 237, 150, |
| 108314 | | - /* 750 */ 221, 222, 223, 25, 27, 23, 165, 165, 165, 242, |
| 108315 | | - /* 760 */ 165, 23, 150, 25, 165, 174, 175, 174, 175, 174, |
| 108316 | | - /* 770 */ 49, 50, 219, 150, 22, 23, 238, 165, 25, 22, |
| 108317 | | - /* 780 */ 23, 23, 166, 167, 168, 193, 174, 175, 165, 68, |
| 108503 | + /* 740 */ 19, 150, 22, 165, 94, 24, 150, 25, 150, 166, |
| 108504 | + /* 750 */ 167, 168, 174, 175, 129, 130, 165, 213, 35, 242, |
| 108505 | + /* 760 */ 150, 165, 27, 165, 150, 174, 175, 181, 182, 19, |
| 108506 | + /* 770 */ 49, 50, 174, 175, 188, 165, 23, 27, 25, 165, |
| 108507 | + /* 780 */ 144, 145, 160, 187, 174, 175, 135, 23, 137, 68, |
| 108318 | 108508 | /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 108319 | 108509 | /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88, |
| 108320 | | - /* 810 */ 89, 90, 91, 92, 19, 150, 23, 165, 150, 67, |
| 108321 | | - /* 820 */ 150, 25, 103, 95, 67, 35, 174, 175, 206, 207, |
| 108322 | | - /* 830 */ 165, 150, 25, 165, 150, 165, 213, 150, 150, 174, |
| 108323 | | - /* 840 */ 175, 35, 174, 175, 49, 50, 165, 52, 120, 165, |
| 108324 | | - /* 850 */ 245, 246, 165, 165, 35, 174, 175, 187, 174, 175, |
| 108325 | | - /* 860 */ 23, 50, 25, 68, 69, 70, 71, 72, 73, 74, |
| 108510 | + /* 810 */ 89, 90, 91, 92, 19, 150, 194, 165, 150, 150, |
| 108511 | + /* 820 */ 150, 150, 150, 150, 247, 248, 174, 175, 190, 191, |
| 108512 | + /* 830 */ 165, 150, 118, 165, 165, 165, 165, 165, 165, 174, |
| 108513 | + /* 840 */ 175, 219, 174, 175, 49, 50, 165, 52, 126, 245, |
| 108514 | + /* 850 */ 246, 23, 238, 25, 23, 174, 175, 187, 187, 187, |
| 108515 | + /* 860 */ 187, 39, 193, 68, 69, 70, 71, 72, 73, 74, |
| 108326 | 108516 | /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84, |
| 108327 | 108517 | /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150, |
| 108328 | | - /* 890 */ 150, 165, 150, 150, 160, 23, 150, 25, 144, 145, |
| 108329 | | - /* 900 */ 174, 175, 120, 216, 165, 165, 22, 165, 165, 150, |
| 108330 | | - /* 910 */ 150, 165, 27, 174, 175, 104, 174, 175, 49, 50, |
| 108331 | | - /* 920 */ 174, 175, 247, 248, 165, 165, 238, 187, 194, 23, |
| 108332 | | - /* 930 */ 187, 25, 166, 174, 175, 190, 191, 68, 69, 70, |
| 108518 | + /* 890 */ 150, 165, 150, 23, 160, 25, 150, 150, 160, 52, |
| 108519 | + /* 900 */ 174, 175, 190, 191, 165, 165, 22, 165, 150, 29, |
| 108520 | + /* 910 */ 150, 165, 165, 174, 175, 150, 174, 175, 49, 50, |
| 108521 | + /* 920 */ 174, 175, 165, 165, 23, 165, 25, 25, 194, 52, |
| 108522 | + /* 930 */ 165, 174, 194, 193, 174, 175, 160, 68, 69, 70, |
| 108333 | 108523 | /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 108334 | 108524 | /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90, |
| 108335 | | - /* 960 */ 91, 92, 19, 150, 150, 165, 150, 23, 150, 25, |
| 108336 | | - /* 970 */ 23, 205, 25, 213, 174, 175, 190, 191, 165, 165, |
| 108337 | | - /* 980 */ 118, 165, 150, 165, 150, 150, 23, 174, 175, 39, |
| 108338 | | - /* 990 */ 174, 175, 49, 50, 173, 150, 23, 165, 52, 165, |
| 108339 | | - /* 1000 */ 165, 187, 181, 22, 166, 166, 174, 175, 174, 175, |
| 108525 | + /* 960 */ 91, 92, 19, 150, 150, 165, 150, 22, 150, 23, |
| 108526 | + /* 970 */ 194, 213, 91, 92, 174, 175, 1, 2, 165, 165, |
| 108527 | + /* 980 */ 22, 165, 150, 165, 150, 238, 150, 174, 175, 22, |
| 108528 | + /* 990 */ 174, 175, 49, 50, 52, 150, 22, 165, 102, 165, |
| 108529 | + /* 1000 */ 19, 165, 109, 238, 166, 166, 174, 175, 174, 175, |
| 108340 | 108530 | /* 1010 */ 165, 68, 69, 70, 71, 72, 73, 74, 75, 76, |
| 108341 | 108531 | /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86, |
| 108342 | 108532 | /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 193, 165, |
| 108343 | | - /* 1040 */ 150, 160, 150, 205, 205, 150, 150, 29, 174, 175, |
| 108344 | | - /* 1050 */ 52, 216, 165, 22, 150, 165, 238, 165, 150, 150, |
| 108345 | | - /* 1060 */ 165, 165, 49, 50, 174, 175, 49, 50, 23, 165, |
| 108346 | | - /* 1070 */ 91, 92, 22, 165, 165, 194, 1, 2, 22, 52, |
| 108347 | | - /* 1080 */ 193, 109, 174, 175, 71, 72, 69, 70, 71, 72, |
| 108533 | + /* 1040 */ 150, 150, 166, 205, 205, 150, 20, 24, 174, 175, |
| 108534 | + /* 1050 */ 43, 104, 165, 59, 53, 165, 165, 25, 150, 150, |
| 108535 | + /* 1060 */ 165, 174, 175, 150, 174, 175, 49, 50, 53, 138, |
| 108536 | + /* 1070 */ 150, 22, 104, 165, 165, 5, 1, 118, 165, 35, |
| 108537 | + /* 1080 */ 27, 205, 174, 175, 193, 165, 69, 70, 71, 72, |
| 108348 | 108538 | /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82, |
| 108349 | 108539 | /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, |
| 108350 | | - /* 1110 */ 19, 98, 150, 165, 150, 150, 150, 102, 150, 150, |
| 108351 | | - /* 1120 */ 22, 19, 174, 175, 20, 24, 104, 165, 43, 165, |
| 108352 | | - /* 1130 */ 165, 165, 150, 165, 165, 150, 174, 175, 174, 175, |
| 108353 | | - /* 1140 */ 49, 50, 59, 53, 138, 25, 53, 165, 104, 22, |
| 108354 | | - /* 1150 */ 165, 5, 118, 1, 76, 76, 174, 175, 193, 174, |
| 108355 | | - /* 1160 */ 175, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 108356 | | - /* 1170 */ 79, 80, 35, 82, 83, 84, 85, 86, 87, 88, |
| 108357 | | - /* 1180 */ 89, 90, 91, 92, 19, 20, 150, 22, 150, 150, |
| 108358 | | - /* 1190 */ 150, 26, 27, 27, 108, 127, 150, 150, 22, 25, |
| 108359 | | - /* 1200 */ 22, 165, 37, 165, 165, 165, 119, 19, 20, 150, |
| 108360 | | - /* 1210 */ 22, 165, 165, 150, 26, 27, 23, 1, 16, 20, |
| 108361 | | - /* 1220 */ 150, 56, 119, 108, 165, 37, 121, 128, 165, 193, |
| 108362 | | - /* 1230 */ 23, 66, 193, 174, 175, 165, 127, 174, 175, 16, |
| 108363 | | - /* 1240 */ 23, 146, 147, 15, 56, 65, 150, 152, 140, 154, |
| 108364 | | - /* 1250 */ 150, 86, 87, 88, 66, 160, 22, 150, 93, 94, |
| 108365 | | - /* 1260 */ 95, 165, 150, 98, 150, 165, 3, 246, 4, 150, |
| 108366 | | - /* 1270 */ 174, 175, 165, 150, 86, 87, 6, 165, 150, 165, |
| 108367 | | - /* 1280 */ 164, 93, 94, 95, 165, 149, 98, 149, 165, 194, |
| 108368 | | - /* 1290 */ 180, 180, 249, 165, 129, 130, 131, 132, 133, 134, |
| 108369 | | - /* 1300 */ 193, 150, 174, 175, 116, 193, 19, 20, 150, 22, |
| 108370 | | - /* 1310 */ 249, 149, 217, 26, 27, 151, 165, 129, 130, 131, |
| 108371 | | - /* 1320 */ 132, 133, 134, 165, 37, 174, 175, 150, 149, 19, |
| 108372 | | - /* 1330 */ 20, 150, 22, 150, 150, 150, 26, 27, 13, 244, |
| 108373 | | - /* 1340 */ 151, 159, 165, 56, 25, 116, 165, 37, 165, 165, |
| 108374 | | - /* 1350 */ 165, 174, 175, 66, 150, 174, 175, 174, 175, 174, |
| 108375 | | - /* 1360 */ 175, 194, 150, 150, 150, 126, 56, 199, 124, 165, |
| 108376 | | - /* 1370 */ 200, 150, 150, 86, 87, 150, 66, 165, 165, 165, |
| 108377 | | - /* 1380 */ 93, 94, 95, 150, 122, 98, 165, 165, 123, 22, |
| 108378 | | - /* 1390 */ 165, 201, 150, 26, 27, 150, 86, 87, 165, 174, |
| 108379 | | - /* 1400 */ 175, 203, 202, 93, 94, 95, 125, 165, 98, 150, |
| 108380 | | - /* 1410 */ 165, 150, 225, 135, 157, 118, 129, 130, 131, 132, |
| 108381 | | - /* 1420 */ 133, 134, 5, 150, 165, 157, 165, 10, 11, 12, |
| 108382 | | - /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 210, 165, 129, |
| 108383 | | - /* 1440 */ 130, 131, 132, 133, 134, 150, 104, 165, 31, 150, |
| 108384 | | - /* 1450 */ 33, 150, 150, 86, 87, 150, 174, 175, 211, 42, |
| 108385 | | - /* 1460 */ 165, 94, 121, 210, 165, 98, 165, 165, 176, 211, |
| 108386 | | - /* 1470 */ 165, 211, 55, 104, 57, 184, 210, 47, 61, 176, |
| 108387 | | - /* 1480 */ 176, 64, 103, 176, 178, 22, 92, 179, 176, 176, |
| 108388 | | - /* 1490 */ 176, 156, 18, 184, 179, 228, 129, 130, 131, 228, |
| 108389 | | - /* 1500 */ 157, 156, 45, 157, 156, 236, 157, 157, 135, 235, |
| 108390 | | - /* 1510 */ 156, 189, 157, 68, 218, 189, 22, 199, 156, 192, |
| 108391 | | - /* 1520 */ 157, 18, 105, 106, 107, 192, 192, 199, 111, 192, |
| 108392 | | - /* 1530 */ 240, 157, 40, 116, 218, 157, 189, 157, 240, 38, |
| 108393 | | - /* 1540 */ 153, 166, 198, 243, 178, 209, 182, 196, 177, 226, |
| 108394 | | - /* 1550 */ 230, 230, 166, 177, 177, 166, 139, 199, 199, 148, |
| 108395 | | - /* 1560 */ 195, 209, 209, 239, 196, 166, 234, 183, 239, 208, |
| 108396 | | - /* 1570 */ 174, 233, 191, 183, 183, 174, 92, 250, 186, 186, |
| 108540 | + /* 1110 */ 19, 150, 150, 165, 150, 150, 150, 108, 76, 150, |
| 108541 | + /* 1120 */ 22, 76, 174, 175, 127, 216, 165, 165, 25, 165, |
| 108542 | + /* 1130 */ 165, 165, 150, 213, 165, 174, 175, 150, 174, 175, |
| 108543 | + /* 1140 */ 49, 50, 22, 150, 23, 1, 119, 165, 16, 121, |
| 108544 | + /* 1150 */ 20, 108, 165, 119, 23, 193, 174, 175, 165, 193, |
| 108545 | + /* 1160 */ 127, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 108546 | + /* 1170 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88, |
| 108547 | + /* 1180 */ 89, 90, 91, 92, 19, 20, 193, 22, 150, 150, |
| 108548 | + /* 1190 */ 150, 26, 27, 128, 16, 15, 150, 140, 65, 3, |
| 108549 | + /* 1200 */ 164, 22, 37, 165, 165, 165, 4, 19, 20, 150, |
| 108550 | + /* 1210 */ 22, 165, 174, 175, 26, 27, 246, 180, 149, 6, |
| 108551 | + /* 1220 */ 249, 56, 249, 149, 165, 37, 149, 180, 149, 151, |
| 108552 | + /* 1230 */ 13, 66, 193, 174, 175, 150, 25, 151, 116, 159, |
| 108553 | + /* 1240 */ 199, 146, 147, 126, 56, 194, 150, 152, 200, 154, |
| 108554 | + /* 1250 */ 165, 86, 87, 88, 66, 160, 201, 150, 93, 94, |
| 108555 | + /* 1260 */ 95, 165, 123, 98, 150, 150, 124, 122, 202, 135, |
| 108556 | + /* 1270 */ 174, 175, 165, 150, 86, 87, 150, 150, 150, 165, |
| 108557 | + /* 1280 */ 165, 93, 94, 95, 203, 150, 98, 125, 165, 194, |
| 108558 | + /* 1290 */ 150, 165, 165, 165, 129, 130, 131, 132, 133, 134, |
| 108559 | + /* 1300 */ 165, 174, 175, 157, 116, 165, 19, 20, 150, 22, |
| 108560 | + /* 1310 */ 150, 118, 217, 26, 27, 225, 150, 129, 130, 131, |
| 108561 | + /* 1320 */ 132, 133, 134, 165, 37, 165, 157, 150, 210, 19, |
| 108562 | + /* 1330 */ 20, 165, 22, 150, 150, 150, 26, 27, 104, 244, |
| 108563 | + /* 1340 */ 174, 175, 165, 56, 121, 104, 210, 37, 165, 165, |
| 108564 | + /* 1350 */ 165, 174, 175, 66, 150, 150, 150, 174, 175, 174, |
| 108565 | + /* 1360 */ 175, 211, 150, 211, 210, 176, 56, 211, 176, 165, |
| 108566 | + /* 1370 */ 165, 165, 150, 86, 87, 150, 66, 165, 174, 175, |
| 108567 | + /* 1380 */ 93, 94, 95, 150, 184, 98, 150, 165, 47, 22, |
| 108568 | + /* 1390 */ 165, 176, 150, 26, 27, 150, 86, 87, 165, 174, |
| 108569 | + /* 1400 */ 175, 165, 178, 93, 94, 95, 103, 165, 98, 150, |
| 108570 | + /* 1410 */ 165, 150, 22, 176, 179, 228, 129, 130, 131, 132, |
| 108571 | + /* 1420 */ 133, 134, 5, 150, 165, 92, 165, 10, 11, 12, |
| 108572 | + /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 228, 165, 129, |
| 108573 | + /* 1440 */ 130, 131, 132, 133, 134, 150, 184, 165, 31, 150, |
| 108574 | + /* 1450 */ 33, 150, 150, 86, 87, 172, 174, 175, 96, 42, |
| 108575 | + /* 1460 */ 165, 94, 176, 179, 165, 98, 165, 165, 176, 174, |
| 108576 | + /* 1470 */ 175, 156, 55, 176, 57, 18, 157, 156, 61, 157, |
| 108577 | + /* 1480 */ 156, 64, 157, 157, 235, 45, 236, 135, 156, 189, |
| 108578 | + /* 1490 */ 68, 157, 218, 189, 22, 199, 129, 130, 131, 156, |
| 108579 | + /* 1500 */ 192, 157, 18, 192, 192, 192, 199, 189, 218, 240, |
| 108580 | + /* 1510 */ 157, 40, 240, 157, 157, 38, 153, 166, 243, 196, |
| 108581 | + /* 1520 */ 226, 230, 105, 106, 107, 198, 209, 177, 111, 182, |
| 108582 | + /* 1530 */ 166, 177, 177, 116, 166, 230, 178, 239, 199, 209, |
| 108583 | + /* 1540 */ 209, 199, 148, 166, 196, 239, 208, 233, 172, 183, |
| 108584 | + /* 1550 */ 234, 191, 183, 183, 195, 174, 139, 186, 186, 174, |
| 108585 | + /* 1560 */ 92, |
| 108397 | 108586 | }; |
| 108398 | | -#define YY_SHIFT_USE_DFLT (-81) |
| 108399 | | -#define YY_SHIFT_COUNT (417) |
| 108400 | | -#define YY_SHIFT_MIN (-80) |
| 108401 | | -#define YY_SHIFT_MAX (1503) |
| 108587 | +#define YY_SHIFT_USE_DFLT (-70) |
| 108588 | +#define YY_SHIFT_COUNT (418) |
| 108589 | +#define YY_SHIFT_MIN (-69) |
| 108590 | +#define YY_SHIFT_MAX (1484) |
| 108402 | 108591 | static const short yy_shift_ofst[] = { |
| 108403 | | - /* 0 */ 1075, 1188, 1417, 1188, 1287, 1287, 138, 138, 1, -19, |
| 108404 | | - /* 10 */ 1287, 1287, 1287, 1287, 340, -2, 129, 129, 795, 1165, |
| 108592 | + /* 0 */ 975, 1188, 1417, 1188, 1287, 1287, 138, 138, 368, -19, |
| 108593 | + /* 10 */ 1287, 1287, 1287, 1287, 272, 524, 129, 129, 795, 1165, |
| 108405 | 108594 | /* 20 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, |
| 108406 | 108595 | /* 30 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, |
| 108407 | 108596 | /* 40 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1310, 1287, |
| 108408 | 108597 | /* 50 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, |
| 108409 | | - /* 60 */ 1287, 1287, 212, -2, -2, -8, -8, 614, 1229, 55, |
| 108598 | + /* 60 */ 1287, 1287, 212, 524, 524, 213, 213, 459, 1122, 55, |
| 108410 | 108599 | /* 70 */ 721, 647, 573, 499, 425, 351, 277, 203, 869, 869, |
| 108411 | 108600 | /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869, |
| 108412 | 108601 | /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45, |
| 108413 | | - /* 100 */ -45, -45, -45, -45, -1, 57, 28, 361, -2, -2, |
| 108414 | | - /* 110 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, |
| 108415 | | - /* 120 */ -2, -2, -2, -2, 391, 515, -2, -2, -2, -2, |
| 108416 | | - /* 130 */ -2, 509, -80, 614, 979, 1484, -81, -81, -81, 1367, |
| 108417 | | - /* 140 */ 75, 182, 182, 314, 311, 364, 219, 86, 613, 609, |
| 108418 | | - /* 150 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, |
| 108419 | | - /* 160 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, |
| 108420 | | - /* 170 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, |
| 108421 | | - /* 180 */ -2, -2, 578, 578, 578, 615, 1229, 1229, 1229, -81, |
| 108422 | | - /* 190 */ -81, -81, 160, 168, 168, 283, 500, 500, 500, 278, |
| 108423 | | - /* 200 */ 449, 330, 432, 409, 352, 48, 48, 48, 48, 426, |
| 108424 | | - /* 210 */ 286, 48, 48, 728, 581, 369, 590, 495, 224, 224, |
| 108425 | | - /* 220 */ 727, 495, 727, 719, 614, 659, 614, 659, 811, 659, |
| 108426 | | - /* 230 */ 224, 257, 480, 480, 614, 144, 375, -18, 1501, 1297, |
| 108427 | | - /* 240 */ 1297, 1492, 1492, 1297, 1494, 1445, 1239, 1503, 1503, 1503, |
| 108428 | | - /* 250 */ 1503, 1297, 1474, 1239, 1494, 1445, 1445, 1297, 1474, 1373, |
| 108429 | | - /* 260 */ 1457, 1297, 1297, 1474, 1297, 1474, 1297, 1474, 1463, 1369, |
| 108430 | | - /* 270 */ 1369, 1369, 1430, 1394, 1394, 1463, 1369, 1379, 1369, 1430, |
| 108431 | | - /* 280 */ 1369, 1369, 1341, 1342, 1341, 1342, 1341, 1342, 1297, 1297, |
| 108432 | | - /* 290 */ 1278, 1281, 1262, 1244, 1265, 1239, 1229, 1319, 1325, 1325, |
| 108433 | | - /* 300 */ 1270, 1270, 1270, 1270, -81, -81, -81, -81, -81, -81, |
| 108434 | | - /* 310 */ 1013, 242, 757, 752, 465, 363, 947, 232, 944, 906, |
| 108435 | | - /* 320 */ 872, 837, 738, 448, 381, 230, 84, 362, 300, 1264, |
| 108436 | | - /* 330 */ 1263, 1234, 1108, 1228, 1180, 1223, 1217, 1207, 1099, 1174, |
| 108437 | | - /* 340 */ 1109, 1115, 1103, 1199, 1105, 1202, 1216, 1087, 1193, 1178, |
| 108438 | | - /* 350 */ 1174, 1176, 1068, 1079, 1078, 1086, 1166, 1137, 1034, 1152, |
| 108439 | | - /* 360 */ 1146, 1127, 1044, 1006, 1093, 1120, 1090, 1083, 1085, 1022, |
| 108440 | | - /* 370 */ 1101, 1104, 1102, 972, 1015, 1098, 1027, 1056, 1050, 1045, |
| 108441 | | - /* 380 */ 1031, 998, 1018, 981, 946, 950, 973, 963, 862, 885, |
| 108442 | | - /* 390 */ 819, 884, 782, 796, 806, 807, 790, 796, 793, 758, |
| 108443 | | - /* 400 */ 753, 732, 692, 696, 682, 686, 667, 544, 291, 521, |
| 108444 | | - /* 410 */ 510, 365, 358, 139, 114, 54, 14, 25, |
| 108602 | + /* 100 */ -45, -45, -45, -45, -1, 6, -64, 524, 524, 524, |
| 108603 | + /* 110 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, |
| 108604 | + /* 120 */ 524, 524, 524, 386, 207, 524, 524, 524, 524, 524, |
| 108605 | + /* 130 */ 409, -13, 459, 881, 1468, -70, -70, -70, 1367, 57, |
| 108606 | + /* 140 */ 433, 433, 297, 236, 219, 136, 91, 572, 540, 524, |
| 108607 | + /* 150 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, |
| 108608 | + /* 160 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, |
| 108609 | + /* 170 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, |
| 108610 | + /* 180 */ 650, 650, 650, 687, 1122, 1122, 1122, -70, -70, -70, |
| 108611 | + /* 190 */ 204, 204, 434, 434, 494, 494, 494, 504, 446, 292, |
| 108612 | + /* 200 */ 442, 428, 424, 77, 377, 377, 377, 377, 531, 498, |
| 108613 | + /* 210 */ 377, 377, 278, 215, 227, 664, 722, 574, 574, 750, |
| 108614 | + /* 220 */ 722, 750, 229, 459, 660, 459, 660, 476, 660, 574, |
| 108615 | + /* 230 */ 651, 625, 625, 459, 579, 273, -18, 1477, 1193, 1193, |
| 108616 | + /* 240 */ 1471, 1471, 1193, 1472, 1422, 1117, 1484, 1484, 1484, 1484, |
| 108617 | + /* 250 */ 1193, 1457, 1117, 1472, 1422, 1422, 1193, 1457, 1352, 1440, |
| 108618 | + /* 260 */ 1193, 1193, 1457, 1193, 1457, 1193, 1457, 1390, 1241, 1241, |
| 108619 | + /* 270 */ 1241, 1362, 1341, 1333, 1333, 1390, 1241, 1303, 1241, 1341, |
| 108620 | + /* 280 */ 1241, 1241, 1223, 1234, 1223, 1234, 1223, 1234, 1193, 1193, |
| 108621 | + /* 290 */ 1134, 1162, 1145, 1142, 1139, 1117, 1122, 1211, 1217, 1217, |
| 108622 | + /* 300 */ 1213, 1213, 1213, 1213, -70, -70, -70, -70, -70, -70, |
| 108623 | + /* 310 */ 334, 393, 497, 392, 543, 275, 901, 98, 870, 828, |
| 108624 | + /* 320 */ 753, 683, 453, 447, 535, 221, 140, 429, 54, 1202, |
| 108625 | + /* 330 */ 1196, 1179, 1057, 1180, 1133, 1178, 1149, 1131, 1065, 1103, |
| 108626 | + /* 340 */ 1033, 1043, 1034, 1130, 1028, 1132, 1144, 1027, 1121, 1120, |
| 108627 | + /* 350 */ 1103, 1098, 997, 1045, 1042, 1009, 1053, 1044, 959, 1075, |
| 108628 | + /* 360 */ 1070, 1049, 968, 931, 1015, 1032, 1001, 994, 1007, 947, |
| 108629 | + /* 370 */ 1023, 1026, 981, 893, 896, 974, 942, 967, 958, 946, |
| 108630 | + /* 380 */ 945, 877, 902, 880, 884, 847, 822, 831, 764, 714, |
| 108631 | + /* 390 */ 735, 723, 720, 587, 615, 642, 656, 576, 615, 575, |
| 108632 | + /* 400 */ 518, 463, 461, 438, 405, 390, 387, 376, 303, 224, |
| 108633 | + /* 410 */ 271, 190, 92, 72, 69, 145, 113, 33, 28, |
| 108445 | 108634 | }; |
| 108446 | 108635 | #define YY_REDUCE_USE_DFLT (-169) |
| 108447 | 108636 | #define YY_REDUCE_COUNT (309) |
| 108448 | 108637 | #define YY_REDUCE_MIN (-168) |
| 108449 | | -#define YY_REDUCE_MAX (1411) |
| 108638 | +#define YY_REDUCE_MAX (1394) |
| 108450 | 108639 | static const short yy_reduce_ofst[] = { |
| 108451 | | - /* 0 */ 318, 90, 1095, 221, 157, 21, 159, 18, 150, 390, |
| 108452 | | - /* 10 */ 385, 378, 380, 315, 325, 249, 529, -71, 8, 1282, |
| 108453 | | - /* 20 */ 1261, 1225, 1185, 1183, 1181, 1177, 1151, 1128, 1096, 1063, |
| 108454 | | - /* 30 */ 1059, 985, 982, 964, 962, 948, 908, 890, 874, 834, |
| 108455 | | - /* 40 */ 832, 816, 813, 800, 759, 746, 742, 739, 726, 684, |
| 108456 | | - /* 50 */ 681, 668, 665, 652, 612, 593, 591, 537, 524, 518, |
| 108457 | | - /* 60 */ 504, 455, 511, 376, 517, 247, -168, 24, 420, 463, |
| 108458 | | - /* 70 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, |
| 108459 | | - /* 80 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, |
| 108460 | | - /* 90 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463, |
| 108461 | | - /* 100 */ 463, 463, 463, 463, 463, -74, 463, 463, 1112, 835, |
| 108462 | | - /* 110 */ 1107, 1039, 1036, 965, 887, 845, 818, 760, 688, 687, |
| 108463 | | - /* 120 */ 538, 743, 623, 592, 446, 513, 814, 740, 670, 156, |
| 108464 | | - /* 130 */ 468, 553, 184, 616, 463, 463, 463, 463, 463, 595, |
| 108465 | | - /* 140 */ 821, 786, 745, 909, 1305, 1302, 1301, 1299, 675, 675, |
| 108466 | | - /* 150 */ 1295, 1273, 1259, 1245, 1242, 1233, 1222, 1221, 1214, 1213, |
| 108467 | | - /* 160 */ 1212, 1204, 1184, 1158, 1123, 1119, 1114, 1100, 1070, 1047, |
| 108468 | | - /* 170 */ 1046, 1040, 1038, 969, 968, 966, 909, 904, 896, 895, |
| 108469 | | - /* 180 */ 892, 599, 839, 838, 766, 754, 881, 734, 346, 605, |
| 108470 | | - /* 190 */ 622, -94, 1393, 1401, 1396, 1392, 1391, 1390, 1384, 1361, |
| 108471 | | - /* 200 */ 1365, 1381, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1332, |
| 108472 | | - /* 210 */ 1338, 1365, 1365, 1361, 1399, 1368, 1411, 1359, 1353, 1352, |
| 108473 | | - /* 220 */ 1329, 1358, 1324, 1366, 1389, 1377, 1386, 1376, 1364, 1371, |
| 108474 | | - /* 230 */ 1336, 1323, 1321, 1320, 1375, 1344, 1351, 1387, 1300, 1380, |
| 108475 | | - /* 240 */ 1378, 1298, 1290, 1374, 1316, 1347, 1328, 1337, 1334, 1333, |
| 108476 | | - /* 250 */ 1327, 1363, 1362, 1318, 1296, 1326, 1322, 1355, 1354, 1269, |
| 108477 | | - /* 260 */ 1274, 1350, 1349, 1348, 1346, 1345, 1343, 1335, 1315, 1314, |
| 108478 | | - /* 270 */ 1313, 1312, 1309, 1271, 1267, 1308, 1307, 1306, 1304, 1291, |
| 108479 | | - /* 280 */ 1303, 1292, 1260, 1266, 1258, 1253, 1247, 1227, 1268, 1257, |
| 108480 | | - /* 290 */ 1187, 1198, 1200, 1190, 1170, 1168, 1167, 1182, 1189, 1164, |
| 108481 | | - /* 300 */ 1179, 1162, 1138, 1136, 1061, 1043, 1021, 1111, 1110, 1116, |
| 108640 | + /* 0 */ 541, 90, 1095, 147, 86, 19, 18, -49, 10, 245, |
| 108641 | + /* 10 */ 308, 306, 243, 222, -41, -51, 181, -71, 394, 1295, |
| 108642 | + /* 20 */ 1282, 1261, 1225, 1204, 1185, 1183, 1177, 1166, 1127, 1096, |
| 108643 | + /* 30 */ 1059, 1038, 982, 964, 961, 948, 908, 890, 887, 874, |
| 108644 | + /* 40 */ 834, 832, 816, 813, 800, 760, 746, 742, 739, 726, |
| 108645 | + /* 50 */ 681, 668, 665, 652, 610, 598, 591, 578, 530, 528, |
| 108646 | + /* 60 */ 525, 456, 474, 464, 517, 439, -168, 208, 406, 491, |
| 108647 | + /* 70 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, |
| 108648 | + /* 80 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, |
| 108649 | + /* 90 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, |
| 108650 | + /* 100 */ 491, 491, 491, 491, 491, 491, 491, 1039, 909, 993, |
| 108651 | + /* 110 */ 966, 962, 891, 845, 740, 765, 920, 747, 27, 614, |
| 108652 | + /* 120 */ 673, 758, 669, -119, 586, 672, 671, 670, 596, 544, |
| 108653 | + /* 130 */ 622, 460, 583, 491, 491, 491, 491, 491, 757, 374, |
| 108654 | + /* 140 */ 712, 638, 913, 1302, 1301, 1299, 1273, 577, 577, 1259, |
| 108655 | + /* 150 */ 1245, 1242, 1236, 1233, 1222, 1212, 1206, 1205, 1184, 1160, |
| 108656 | + /* 160 */ 1158, 1140, 1135, 1128, 1126, 1123, 1115, 1114, 1107, 1085, |
| 108657 | + /* 170 */ 1046, 1040, 987, 969, 965, 913, 895, 836, 818, 814, |
| 108658 | + /* 180 */ 876, 839, 838, 636, 776, 738, 734, 604, 421, 62, |
| 108659 | + /* 190 */ 1385, 1381, 1372, 1371, 1370, 1369, 1366, 1338, 1359, 1360, |
| 108660 | + /* 200 */ 1359, 1359, 1359, 1376, 1359, 1359, 1359, 1359, 1316, 1314, |
| 108661 | + /* 210 */ 1359, 1359, 1338, 1377, 1348, 1394, 1342, 1331, 1330, 1306, |
| 108662 | + /* 220 */ 1339, 1298, 1358, 1368, 1355, 1364, 1354, 1347, 1350, 1317, |
| 108663 | + /* 230 */ 1294, 1305, 1291, 1351, 1327, 1323, 1363, 1275, 1357, 1356, |
| 108664 | + /* 240 */ 1272, 1269, 1353, 1290, 1318, 1307, 1313, 1312, 1311, 1308, |
| 108665 | + /* 250 */ 1344, 1343, 1296, 1274, 1304, 1300, 1334, 1332, 1250, 1249, |
| 108666 | + /* 260 */ 1326, 1325, 1324, 1322, 1321, 1319, 1315, 1284, 1297, 1292, |
| 108667 | + /* 270 */ 1286, 1283, 1262, 1209, 1187, 1235, 1237, 1224, 1215, 1200, |
| 108668 | + /* 280 */ 1192, 1189, 1156, 1154, 1152, 1136, 1150, 1118, 1169, 1146, |
| 108669 | + /* 290 */ 1090, 1081, 1066, 1055, 1048, 1041, 1051, 1080, 1086, 1078, |
| 108670 | + /* 300 */ 1079, 1077, 1074, 1069, 973, 971, 970, 1047, 1037, 1036, |
| 108482 | 108671 | }; |
| 108483 | 108672 | static const YYACTIONTYPE yy_default[] = { |
| 108484 | | - /* 0 */ 634, 868, 956, 956, 868, 868, 956, 956, 956, 758, |
| 108485 | | - /* 10 */ 956, 956, 956, 866, 956, 956, 786, 786, 930, 956, |
| 108486 | | - /* 20 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108487 | | - /* 30 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108488 | | - /* 40 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108489 | | - /* 50 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108490 | | - /* 60 */ 956, 956, 956, 956, 956, 956, 956, 673, 762, 792, |
| 108491 | | - /* 70 */ 956, 956, 956, 956, 956, 956, 956, 956, 929, 931, |
| 108492 | | - /* 80 */ 800, 799, 909, 773, 797, 790, 794, 869, 862, 863, |
| 108493 | | - /* 90 */ 861, 865, 870, 956, 793, 829, 846, 828, 840, 845, |
| 108494 | | - /* 100 */ 852, 844, 841, 831, 830, 665, 832, 833, 956, 956, |
| 108495 | | - /* 110 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108496 | | - /* 120 */ 956, 956, 956, 956, 660, 727, 956, 956, 956, 956, |
| 108497 | | - /* 130 */ 956, 956, 956, 956, 834, 835, 849, 848, 847, 956, |
| 108498 | | - /* 140 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108499 | | - /* 150 */ 956, 936, 934, 956, 881, 956, 956, 956, 956, 956, |
| 108500 | | - /* 160 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108501 | | - /* 170 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108502 | | - /* 180 */ 956, 640, 758, 758, 758, 634, 956, 956, 956, 948, |
| 108503 | | - /* 190 */ 762, 752, 718, 956, 956, 956, 956, 956, 956, 956, |
| 108504 | | - /* 200 */ 956, 956, 956, 956, 956, 802, 741, 919, 921, 956, |
| 108505 | | - /* 210 */ 902, 739, 662, 760, 675, 750, 642, 796, 775, 775, |
| 108506 | | - /* 220 */ 914, 796, 914, 699, 956, 786, 956, 786, 696, 786, |
| 108507 | | - /* 230 */ 775, 864, 956, 956, 956, 759, 750, 956, 941, 766, |
| 108508 | | - /* 240 */ 766, 933, 933, 766, 808, 731, 796, 738, 738, 738, |
| 108509 | | - /* 250 */ 738, 766, 657, 796, 808, 731, 731, 766, 657, 908, |
| 108510 | | - /* 260 */ 906, 766, 766, 657, 766, 657, 766, 657, 874, 729, |
| 108511 | | - /* 270 */ 729, 729, 714, 878, 878, 874, 729, 699, 729, 714, |
| 108512 | | - /* 280 */ 729, 729, 779, 774, 779, 774, 779, 774, 766, 766, |
| 108513 | | - /* 290 */ 956, 791, 780, 789, 787, 796, 956, 717, 650, 650, |
| 108514 | | - /* 300 */ 639, 639, 639, 639, 953, 953, 948, 701, 701, 683, |
| 108515 | | - /* 310 */ 956, 956, 956, 956, 956, 956, 956, 883, 956, 956, |
| 108516 | | - /* 320 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108517 | | - /* 330 */ 635, 943, 956, 956, 940, 956, 956, 956, 956, 801, |
| 108518 | | - /* 340 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108519 | | - /* 350 */ 918, 956, 956, 956, 956, 956, 956, 956, 912, 956, |
| 108520 | | - /* 360 */ 956, 956, 956, 956, 956, 905, 904, 956, 956, 956, |
| 108521 | | - /* 370 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108522 | | - /* 380 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956, |
| 108523 | | - /* 390 */ 956, 956, 956, 788, 956, 781, 956, 867, 956, 956, |
| 108524 | | - /* 400 */ 956, 956, 956, 956, 956, 956, 956, 956, 744, 817, |
| 108525 | | - /* 410 */ 956, 816, 820, 815, 667, 956, 648, 956, 631, 636, |
| 108526 | | - /* 420 */ 952, 955, 954, 951, 950, 949, 944, 942, 939, 938, |
| 108527 | | - /* 430 */ 937, 935, 932, 928, 887, 885, 892, 891, 890, 889, |
| 108528 | | - /* 440 */ 888, 886, 884, 882, 803, 798, 795, 927, 880, 740, |
| 108529 | | - /* 450 */ 737, 736, 656, 945, 911, 920, 807, 806, 809, 917, |
| 108530 | | - /* 460 */ 916, 915, 913, 910, 897, 805, 804, 732, 872, 871, |
| 108531 | | - /* 470 */ 659, 901, 900, 899, 903, 907, 898, 768, 658, 655, |
| 108532 | | - /* 480 */ 664, 721, 720, 728, 726, 725, 724, 723, 722, 719, |
| 108533 | | - /* 490 */ 666, 674, 685, 713, 698, 697, 877, 879, 876, 875, |
| 108534 | | - /* 500 */ 706, 705, 711, 710, 709, 708, 707, 704, 703, 702, |
| 108535 | | - /* 510 */ 695, 694, 700, 693, 716, 715, 712, 692, 735, 734, |
| 108536 | | - /* 520 */ 733, 730, 691, 690, 689, 820, 688, 687, 826, 825, |
| 108537 | | - /* 530 */ 813, 856, 755, 754, 753, 765, 764, 777, 776, 811, |
| 108538 | | - /* 540 */ 810, 778, 763, 757, 756, 772, 771, 770, 769, 761, |
| 108539 | | - /* 550 */ 751, 783, 785, 784, 782, 858, 767, 855, 926, 925, |
| 108540 | | - /* 560 */ 924, 923, 922, 860, 859, 827, 824, 678, 679, 895, |
| 108541 | | - /* 570 */ 894, 896, 893, 681, 680, 677, 676, 857, 746, 745, |
| 108542 | | - /* 580 */ 853, 850, 842, 838, 854, 851, 843, 839, 837, 836, |
| 108543 | | - /* 590 */ 822, 821, 819, 818, 814, 823, 669, 747, 743, 742, |
| 108544 | | - /* 600 */ 812, 749, 748, 686, 684, 682, 663, 661, 654, 652, |
| 108545 | | - /* 610 */ 651, 653, 649, 647, 646, 645, 644, 643, 672, 671, |
| 108546 | | - /* 620 */ 670, 668, 667, 641, 638, 637, 633, 632, 630, |
| 108673 | + /* 0 */ 632, 864, 952, 952, 864, 864, 952, 952, 683, 754, |
| 108674 | + /* 10 */ 952, 952, 952, 862, 952, 952, 782, 782, 926, 952, |
| 108675 | + /* 20 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108676 | + /* 30 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108677 | + /* 40 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108678 | + /* 50 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108679 | + /* 60 */ 952, 952, 952, 952, 952, 952, 952, 671, 758, 788, |
| 108680 | + /* 70 */ 952, 952, 952, 952, 952, 952, 952, 952, 925, 927, |
| 108681 | + /* 80 */ 796, 795, 905, 769, 793, 786, 790, 865, 858, 859, |
| 108682 | + /* 90 */ 857, 861, 866, 952, 789, 825, 842, 824, 836, 841, |
| 108683 | + /* 100 */ 848, 840, 837, 827, 826, 828, 829, 952, 952, 952, |
| 108684 | + /* 110 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108685 | + /* 120 */ 952, 952, 952, 658, 723, 952, 952, 952, 952, 952, |
| 108686 | + /* 130 */ 952, 952, 952, 830, 831, 845, 844, 843, 952, 952, |
| 108687 | + /* 140 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108688 | + /* 150 */ 932, 930, 952, 877, 952, 952, 952, 952, 952, 952, |
| 108689 | + /* 160 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108690 | + /* 170 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 638, |
| 108691 | + /* 180 */ 754, 754, 754, 632, 952, 952, 952, 944, 758, 748, |
| 108692 | + /* 190 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108693 | + /* 200 */ 952, 952, 952, 683, 798, 737, 915, 917, 952, 898, |
| 108694 | + /* 210 */ 735, 660, 756, 673, 746, 640, 792, 771, 771, 910, |
| 108695 | + /* 220 */ 792, 910, 697, 952, 782, 952, 782, 694, 782, 771, |
| 108696 | + /* 230 */ 860, 952, 952, 952, 755, 746, 952, 937, 762, 762, |
| 108697 | + /* 240 */ 929, 929, 762, 804, 727, 792, 734, 734, 734, 734, |
| 108698 | + /* 250 */ 762, 655, 792, 804, 727, 727, 762, 655, 904, 902, |
| 108699 | + /* 260 */ 762, 762, 655, 762, 655, 762, 655, 870, 725, 725, |
| 108700 | + /* 270 */ 725, 683, 712, 874, 874, 870, 725, 697, 725, 712, |
| 108701 | + /* 280 */ 725, 725, 775, 770, 775, 770, 775, 770, 762, 762, |
| 108702 | + /* 290 */ 952, 787, 776, 785, 783, 792, 952, 715, 648, 648, |
| 108703 | + /* 300 */ 637, 637, 637, 637, 949, 949, 944, 699, 699, 681, |
| 108704 | + /* 310 */ 952, 952, 952, 952, 952, 952, 952, 879, 952, 952, |
| 108705 | + /* 320 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108706 | + /* 330 */ 633, 939, 952, 952, 936, 952, 952, 952, 952, 797, |
| 108707 | + /* 340 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108708 | + /* 350 */ 914, 952, 952, 952, 952, 952, 952, 952, 908, 952, |
| 108709 | + /* 360 */ 952, 952, 952, 952, 952, 901, 900, 952, 952, 952, |
| 108710 | + /* 370 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952, |
| 108711 | + /* 380 */ 952, 952, 716, 952, 952, 952, 952, 952, 952, 952, |
| 108712 | + /* 390 */ 952, 952, 952, 952, 784, 952, 777, 952, 863, 952, |
| 108713 | + /* 400 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 740, |
| 108714 | + /* 410 */ 813, 952, 812, 816, 811, 665, 952, 646, 952, 629, |
| 108715 | + /* 420 */ 634, 948, 951, 950, 947, 946, 945, 940, 938, 935, |
| 108716 | + /* 430 */ 934, 933, 931, 928, 924, 883, 881, 888, 887, 886, |
| 108717 | + /* 440 */ 885, 884, 882, 880, 878, 799, 794, 791, 923, 876, |
| 108718 | + /* 450 */ 736, 733, 732, 654, 941, 907, 916, 803, 802, 805, |
| 108719 | + /* 460 */ 913, 912, 911, 909, 906, 893, 801, 800, 728, 868, |
| 108720 | + /* 470 */ 867, 657, 897, 896, 895, 899, 903, 894, 764, 656, |
| 108721 | + /* 480 */ 653, 662, 718, 724, 722, 721, 720, 719, 717, 664, |
| 108722 | + /* 490 */ 672, 682, 711, 696, 695, 873, 875, 872, 871, 704, |
| 108723 | + /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693, |
| 108724 | + /* 510 */ 692, 698, 691, 714, 713, 710, 690, 731, 730, 729, |
| 108725 | + /* 520 */ 726, 689, 688, 687, 816, 686, 685, 822, 821, 809, |
| 108726 | + /* 530 */ 852, 751, 750, 749, 761, 760, 773, 772, 807, 806, |
| 108727 | + /* 540 */ 774, 759, 753, 752, 768, 767, 766, 765, 757, 747, |
| 108728 | + /* 550 */ 779, 781, 780, 778, 854, 763, 851, 922, 921, 920, |
| 108729 | + /* 560 */ 919, 918, 856, 855, 823, 820, 676, 677, 891, 890, |
| 108730 | + /* 570 */ 892, 889, 679, 678, 675, 674, 853, 742, 741, 849, |
| 108731 | + /* 580 */ 846, 838, 834, 850, 847, 839, 835, 833, 832, 818, |
| 108732 | + /* 590 */ 817, 815, 814, 810, 819, 667, 743, 739, 738, 808, |
| 108733 | + /* 600 */ 745, 744, 684, 680, 661, 659, 652, 650, 649, 651, |
| 108734 | + /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666, |
| 108735 | + /* 620 */ 665, 639, 636, 635, 631, 630, 628, |
| 108547 | 108736 | }; |
| 108548 | 108737 | |
| 108549 | 108738 | /* The next table maps tokens into fallback tokens. If a construct |
| 108550 | 108739 | ** like the following: |
| 108551 | 108740 | ** |
| | @@ -108744,11 +108933,11 @@ |
| 108744 | 108933 | "create_table", "create_table_args", "createkw", "temp", |
| 108745 | 108934 | "ifnotexists", "dbnm", "columnlist", "conslist_opt", |
| 108746 | 108935 | "select", "column", "columnid", "type", |
| 108747 | 108936 | "carglist", "id", "ids", "typetoken", |
| 108748 | 108937 | "typename", "signed", "plus_num", "minus_num", |
| 108749 | | - "carg", "ccons", "term", "expr", |
| 108938 | + "cname", "ccons", "term", "expr", |
| 108750 | 108939 | "onconf", "sortorder", "autoinc", "idxlist_opt", |
| 108751 | 108940 | "refargs", "defer_subclause", "refarg", "refact", |
| 108752 | 108941 | "init_deferred_pred_opt", "conslist", "tcons", "idxlist", |
| 108753 | 108942 | "defer_subclause_opt", "orconf", "resolvetype", "raisetype", |
| 108754 | 108943 | "ifexists", "fullname", "oneselect", "multiselect_op", |
| | @@ -108824,14 +109013,14 @@ |
| 108824 | 109013 | /* 48 */ "typetoken ::= typename LP signed COMMA signed RP", |
| 108825 | 109014 | /* 49 */ "typename ::= ids", |
| 108826 | 109015 | /* 50 */ "typename ::= typename ids", |
| 108827 | 109016 | /* 51 */ "signed ::= plus_num", |
| 108828 | 109017 | /* 52 */ "signed ::= minus_num", |
| 108829 | | - /* 53 */ "carglist ::= carglist carg", |
| 109018 | + /* 53 */ "carglist ::= carglist cname ccons", |
| 108830 | 109019 | /* 54 */ "carglist ::=", |
| 108831 | | - /* 55 */ "carg ::= CONSTRAINT nm ccons", |
| 108832 | | - /* 56 */ "carg ::= ccons", |
| 109020 | + /* 55 */ "cname ::= CONSTRAINT nm", |
| 109021 | + /* 56 */ "cname ::=", |
| 108833 | 109022 | /* 57 */ "ccons ::= DEFAULT term", |
| 108834 | 109023 | /* 58 */ "ccons ::= DEFAULT LP expr RP", |
| 108835 | 109024 | /* 59 */ "ccons ::= DEFAULT PLUS term", |
| 108836 | 109025 | /* 60 */ "ccons ::= DEFAULT MINUS term", |
| 108837 | 109026 | /* 61 */ "ccons ::= DEFAULT id", |
| | @@ -108861,247 +109050,245 @@ |
| 108861 | 109050 | /* 85 */ "init_deferred_pred_opt ::=", |
| 108862 | 109051 | /* 86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED", |
| 108863 | 109052 | /* 87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE", |
| 108864 | 109053 | /* 88 */ "conslist_opt ::=", |
| 108865 | 109054 | /* 89 */ "conslist_opt ::= COMMA conslist", |
| 108866 | | - /* 90 */ "conslist ::= conslist COMMA tcons", |
| 108867 | | - /* 91 */ "conslist ::= conslist tcons", |
| 108868 | | - /* 92 */ "conslist ::= tcons", |
| 108869 | | - /* 93 */ "tcons ::= CONSTRAINT nm", |
| 108870 | | - /* 94 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf", |
| 108871 | | - /* 95 */ "tcons ::= UNIQUE LP idxlist RP onconf", |
| 108872 | | - /* 96 */ "tcons ::= CHECK LP expr RP onconf", |
| 108873 | | - /* 97 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt", |
| 108874 | | - /* 98 */ "defer_subclause_opt ::=", |
| 108875 | | - /* 99 */ "defer_subclause_opt ::= defer_subclause", |
| 108876 | | - /* 100 */ "onconf ::=", |
| 108877 | | - /* 101 */ "onconf ::= ON CONFLICT resolvetype", |
| 108878 | | - /* 102 */ "orconf ::=", |
| 108879 | | - /* 103 */ "orconf ::= OR resolvetype", |
| 108880 | | - /* 104 */ "resolvetype ::= raisetype", |
| 108881 | | - /* 105 */ "resolvetype ::= IGNORE", |
| 108882 | | - /* 106 */ "resolvetype ::= REPLACE", |
| 108883 | | - /* 107 */ "cmd ::= DROP TABLE ifexists fullname", |
| 108884 | | - /* 108 */ "ifexists ::= IF EXISTS", |
| 108885 | | - /* 109 */ "ifexists ::=", |
| 108886 | | - /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select", |
| 108887 | | - /* 111 */ "cmd ::= DROP VIEW ifexists fullname", |
| 108888 | | - /* 112 */ "cmd ::= select", |
| 108889 | | - /* 113 */ "select ::= oneselect", |
| 108890 | | - /* 114 */ "select ::= select multiselect_op oneselect", |
| 108891 | | - /* 115 */ "multiselect_op ::= UNION", |
| 108892 | | - /* 116 */ "multiselect_op ::= UNION ALL", |
| 108893 | | - /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT", |
| 108894 | | - /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", |
| 108895 | | - /* 119 */ "distinct ::= DISTINCT", |
| 108896 | | - /* 120 */ "distinct ::= ALL", |
| 108897 | | - /* 121 */ "distinct ::=", |
| 108898 | | - /* 122 */ "sclp ::= selcollist COMMA", |
| 108899 | | - /* 123 */ "sclp ::=", |
| 108900 | | - /* 124 */ "selcollist ::= sclp expr as", |
| 108901 | | - /* 125 */ "selcollist ::= sclp STAR", |
| 108902 | | - /* 126 */ "selcollist ::= sclp nm DOT STAR", |
| 108903 | | - /* 127 */ "as ::= AS nm", |
| 108904 | | - /* 128 */ "as ::= ids", |
| 108905 | | - /* 129 */ "as ::=", |
| 108906 | | - /* 130 */ "from ::=", |
| 108907 | | - /* 131 */ "from ::= FROM seltablist", |
| 108908 | | - /* 132 */ "stl_prefix ::= seltablist joinop", |
| 108909 | | - /* 133 */ "stl_prefix ::=", |
| 108910 | | - /* 134 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", |
| 108911 | | - /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", |
| 108912 | | - /* 136 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", |
| 108913 | | - /* 137 */ "dbnm ::=", |
| 108914 | | - /* 138 */ "dbnm ::= DOT nm", |
| 108915 | | - /* 139 */ "fullname ::= nm dbnm", |
| 108916 | | - /* 140 */ "joinop ::= COMMA|JOIN", |
| 108917 | | - /* 141 */ "joinop ::= JOIN_KW JOIN", |
| 108918 | | - /* 142 */ "joinop ::= JOIN_KW nm JOIN", |
| 108919 | | - /* 143 */ "joinop ::= JOIN_KW nm nm JOIN", |
| 108920 | | - /* 144 */ "on_opt ::= ON expr", |
| 108921 | | - /* 145 */ "on_opt ::=", |
| 108922 | | - /* 146 */ "indexed_opt ::=", |
| 108923 | | - /* 147 */ "indexed_opt ::= INDEXED BY nm", |
| 108924 | | - /* 148 */ "indexed_opt ::= NOT INDEXED", |
| 108925 | | - /* 149 */ "using_opt ::= USING LP inscollist RP", |
| 108926 | | - /* 150 */ "using_opt ::=", |
| 108927 | | - /* 151 */ "orderby_opt ::=", |
| 108928 | | - /* 152 */ "orderby_opt ::= ORDER BY sortlist", |
| 108929 | | - /* 153 */ "sortlist ::= sortlist COMMA expr sortorder", |
| 108930 | | - /* 154 */ "sortlist ::= expr sortorder", |
| 108931 | | - /* 155 */ "sortorder ::= ASC", |
| 108932 | | - /* 156 */ "sortorder ::= DESC", |
| 108933 | | - /* 157 */ "sortorder ::=", |
| 108934 | | - /* 158 */ "groupby_opt ::=", |
| 108935 | | - /* 159 */ "groupby_opt ::= GROUP BY nexprlist", |
| 108936 | | - /* 160 */ "having_opt ::=", |
| 108937 | | - /* 161 */ "having_opt ::= HAVING expr", |
| 108938 | | - /* 162 */ "limit_opt ::=", |
| 108939 | | - /* 163 */ "limit_opt ::= LIMIT expr", |
| 108940 | | - /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr", |
| 108941 | | - /* 165 */ "limit_opt ::= LIMIT expr COMMA expr", |
| 108942 | | - /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt", |
| 108943 | | - /* 167 */ "where_opt ::=", |
| 108944 | | - /* 168 */ "where_opt ::= WHERE expr", |
| 108945 | | - /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt", |
| 108946 | | - /* 170 */ "setlist ::= setlist COMMA nm EQ expr", |
| 108947 | | - /* 171 */ "setlist ::= nm EQ expr", |
| 108948 | | - /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist", |
| 108949 | | - /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select", |
| 108950 | | - /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES", |
| 108951 | | - /* 175 */ "insert_cmd ::= INSERT orconf", |
| 108952 | | - /* 176 */ "insert_cmd ::= REPLACE", |
| 108953 | | - /* 177 */ "valuelist ::= VALUES LP nexprlist RP", |
| 108954 | | - /* 178 */ "valuelist ::= valuelist COMMA LP exprlist RP", |
| 108955 | | - /* 179 */ "inscollist_opt ::=", |
| 108956 | | - /* 180 */ "inscollist_opt ::= LP inscollist RP", |
| 108957 | | - /* 181 */ "inscollist ::= inscollist COMMA nm", |
| 108958 | | - /* 182 */ "inscollist ::= nm", |
| 108959 | | - /* 183 */ "expr ::= term", |
| 108960 | | - /* 184 */ "expr ::= LP expr RP", |
| 108961 | | - /* 185 */ "term ::= NULL", |
| 108962 | | - /* 186 */ "expr ::= id", |
| 108963 | | - /* 187 */ "expr ::= JOIN_KW", |
| 108964 | | - /* 188 */ "expr ::= nm DOT nm", |
| 108965 | | - /* 189 */ "expr ::= nm DOT nm DOT nm", |
| 108966 | | - /* 190 */ "term ::= INTEGER|FLOAT|BLOB", |
| 108967 | | - /* 191 */ "term ::= STRING", |
| 108968 | | - /* 192 */ "expr ::= REGISTER", |
| 108969 | | - /* 193 */ "expr ::= VARIABLE", |
| 108970 | | - /* 194 */ "expr ::= expr COLLATE ids", |
| 108971 | | - /* 195 */ "expr ::= CAST LP expr AS typetoken RP", |
| 108972 | | - /* 196 */ "expr ::= ID LP distinct exprlist RP", |
| 108973 | | - /* 197 */ "expr ::= ID LP STAR RP", |
| 108974 | | - /* 198 */ "term ::= CTIME_KW", |
| 108975 | | - /* 199 */ "expr ::= expr AND expr", |
| 108976 | | - /* 200 */ "expr ::= expr OR expr", |
| 108977 | | - /* 201 */ "expr ::= expr LT|GT|GE|LE expr", |
| 108978 | | - /* 202 */ "expr ::= expr EQ|NE expr", |
| 108979 | | - /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 108980 | | - /* 204 */ "expr ::= expr PLUS|MINUS expr", |
| 108981 | | - /* 205 */ "expr ::= expr STAR|SLASH|REM expr", |
| 108982 | | - /* 206 */ "expr ::= expr CONCAT expr", |
| 108983 | | - /* 207 */ "likeop ::= LIKE_KW", |
| 108984 | | - /* 208 */ "likeop ::= NOT LIKE_KW", |
| 108985 | | - /* 209 */ "likeop ::= MATCH", |
| 108986 | | - /* 210 */ "likeop ::= NOT MATCH", |
| 108987 | | - /* 211 */ "expr ::= expr likeop expr", |
| 108988 | | - /* 212 */ "expr ::= expr likeop expr ESCAPE expr", |
| 108989 | | - /* 213 */ "expr ::= expr ISNULL|NOTNULL", |
| 108990 | | - /* 214 */ "expr ::= expr NOT NULL", |
| 108991 | | - /* 215 */ "expr ::= expr IS expr", |
| 108992 | | - /* 216 */ "expr ::= expr IS NOT expr", |
| 108993 | | - /* 217 */ "expr ::= NOT expr", |
| 108994 | | - /* 218 */ "expr ::= BITNOT expr", |
| 108995 | | - /* 219 */ "expr ::= MINUS expr", |
| 108996 | | - /* 220 */ "expr ::= PLUS expr", |
| 108997 | | - /* 221 */ "between_op ::= BETWEEN", |
| 108998 | | - /* 222 */ "between_op ::= NOT BETWEEN", |
| 108999 | | - /* 223 */ "expr ::= expr between_op expr AND expr", |
| 109000 | | - /* 224 */ "in_op ::= IN", |
| 109001 | | - /* 225 */ "in_op ::= NOT IN", |
| 109002 | | - /* 226 */ "expr ::= expr in_op LP exprlist RP", |
| 109003 | | - /* 227 */ "expr ::= LP select RP", |
| 109004 | | - /* 228 */ "expr ::= expr in_op LP select RP", |
| 109005 | | - /* 229 */ "expr ::= expr in_op nm dbnm", |
| 109006 | | - /* 230 */ "expr ::= EXISTS LP select RP", |
| 109007 | | - /* 231 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 109008 | | - /* 232 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 109009 | | - /* 233 */ "case_exprlist ::= WHEN expr THEN expr", |
| 109010 | | - /* 234 */ "case_else ::= ELSE expr", |
| 109011 | | - /* 235 */ "case_else ::=", |
| 109012 | | - /* 236 */ "case_operand ::= expr", |
| 109013 | | - /* 237 */ "case_operand ::=", |
| 109014 | | - /* 238 */ "exprlist ::= nexprlist", |
| 109015 | | - /* 239 */ "exprlist ::=", |
| 109016 | | - /* 240 */ "nexprlist ::= nexprlist COMMA expr", |
| 109017 | | - /* 241 */ "nexprlist ::= expr", |
| 109018 | | - /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP", |
| 109019 | | - /* 243 */ "uniqueflag ::= UNIQUE", |
| 109020 | | - /* 244 */ "uniqueflag ::=", |
| 109021 | | - /* 245 */ "idxlist_opt ::=", |
| 109022 | | - /* 246 */ "idxlist_opt ::= LP idxlist RP", |
| 109023 | | - /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder", |
| 109024 | | - /* 248 */ "idxlist ::= nm collate sortorder", |
| 109025 | | - /* 249 */ "collate ::=", |
| 109026 | | - /* 250 */ "collate ::= COLLATE ids", |
| 109027 | | - /* 251 */ "cmd ::= DROP INDEX ifexists fullname", |
| 109028 | | - /* 252 */ "cmd ::= VACUUM", |
| 109029 | | - /* 253 */ "cmd ::= VACUUM nm", |
| 109030 | | - /* 254 */ "cmd ::= PRAGMA nm dbnm", |
| 109031 | | - /* 255 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 109032 | | - /* 256 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 109033 | | - /* 257 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 109034 | | - /* 258 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 109035 | | - /* 259 */ "nmnum ::= plus_num", |
| 109036 | | - /* 260 */ "nmnum ::= nm", |
| 109037 | | - /* 261 */ "nmnum ::= ON", |
| 109038 | | - /* 262 */ "nmnum ::= DELETE", |
| 109039 | | - /* 263 */ "nmnum ::= DEFAULT", |
| 109040 | | - /* 264 */ "plus_num ::= PLUS number", |
| 109041 | | - /* 265 */ "plus_num ::= number", |
| 109042 | | - /* 266 */ "minus_num ::= MINUS number", |
| 109043 | | - /* 267 */ "number ::= INTEGER|FLOAT", |
| 109044 | | - /* 268 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 109045 | | - /* 269 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 109046 | | - /* 270 */ "trigger_time ::= BEFORE", |
| 109047 | | - /* 271 */ "trigger_time ::= AFTER", |
| 109048 | | - /* 272 */ "trigger_time ::= INSTEAD OF", |
| 109049 | | - /* 273 */ "trigger_time ::=", |
| 109050 | | - /* 274 */ "trigger_event ::= DELETE|INSERT", |
| 109051 | | - /* 275 */ "trigger_event ::= UPDATE", |
| 109052 | | - /* 276 */ "trigger_event ::= UPDATE OF inscollist", |
| 109053 | | - /* 277 */ "foreach_clause ::=", |
| 109054 | | - /* 278 */ "foreach_clause ::= FOR EACH ROW", |
| 109055 | | - /* 279 */ "when_clause ::=", |
| 109056 | | - /* 280 */ "when_clause ::= WHEN expr", |
| 109057 | | - /* 281 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 109058 | | - /* 282 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 109059 | | - /* 283 */ "trnm ::= nm", |
| 109060 | | - /* 284 */ "trnm ::= nm DOT nm", |
| 109061 | | - /* 285 */ "tridxby ::=", |
| 109062 | | - /* 286 */ "tridxby ::= INDEXED BY nm", |
| 109063 | | - /* 287 */ "tridxby ::= NOT INDEXED", |
| 109064 | | - /* 288 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", |
| 109065 | | - /* 289 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist", |
| 109066 | | - /* 290 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select", |
| 109067 | | - /* 291 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", |
| 109068 | | - /* 292 */ "trigger_cmd ::= select", |
| 109069 | | - /* 293 */ "expr ::= RAISE LP IGNORE RP", |
| 109070 | | - /* 294 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 109071 | | - /* 295 */ "raisetype ::= ROLLBACK", |
| 109072 | | - /* 296 */ "raisetype ::= ABORT", |
| 109073 | | - /* 297 */ "raisetype ::= FAIL", |
| 109074 | | - /* 298 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 109075 | | - /* 299 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 109076 | | - /* 300 */ "cmd ::= DETACH database_kw_opt expr", |
| 109077 | | - /* 301 */ "key_opt ::=", |
| 109078 | | - /* 302 */ "key_opt ::= KEY expr", |
| 109079 | | - /* 303 */ "database_kw_opt ::= DATABASE", |
| 109080 | | - /* 304 */ "database_kw_opt ::=", |
| 109081 | | - /* 305 */ "cmd ::= REINDEX", |
| 109082 | | - /* 306 */ "cmd ::= REINDEX nm dbnm", |
| 109083 | | - /* 307 */ "cmd ::= ANALYZE", |
| 109084 | | - /* 308 */ "cmd ::= ANALYZE nm dbnm", |
| 109085 | | - /* 309 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 109086 | | - /* 310 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column", |
| 109087 | | - /* 311 */ "add_column_fullname ::= fullname", |
| 109088 | | - /* 312 */ "kwcolumn_opt ::=", |
| 109089 | | - /* 313 */ "kwcolumn_opt ::= COLUMNKW", |
| 109090 | | - /* 314 */ "cmd ::= create_vtab", |
| 109091 | | - /* 315 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 109092 | | - /* 316 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 109093 | | - /* 317 */ "vtabarglist ::= vtabarg", |
| 109094 | | - /* 318 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 109095 | | - /* 319 */ "vtabarg ::=", |
| 109096 | | - /* 320 */ "vtabarg ::= vtabarg vtabargtoken", |
| 109097 | | - /* 321 */ "vtabargtoken ::= ANY", |
| 109098 | | - /* 322 */ "vtabargtoken ::= lp anylist RP", |
| 109099 | | - /* 323 */ "lp ::= LP", |
| 109100 | | - /* 324 */ "anylist ::=", |
| 109101 | | - /* 325 */ "anylist ::= anylist LP anylist RP", |
| 109102 | | - /* 326 */ "anylist ::= anylist ANY", |
| 109055 | + /* 90 */ "conslist ::= conslist COMMA cname tcons", |
| 109056 | + /* 91 */ "conslist ::= cname tcons", |
| 109057 | + /* 92 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf", |
| 109058 | + /* 93 */ "tcons ::= UNIQUE LP idxlist RP onconf", |
| 109059 | + /* 94 */ "tcons ::= CHECK LP expr RP onconf", |
| 109060 | + /* 95 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt", |
| 109061 | + /* 96 */ "defer_subclause_opt ::=", |
| 109062 | + /* 97 */ "defer_subclause_opt ::= defer_subclause", |
| 109063 | + /* 98 */ "onconf ::=", |
| 109064 | + /* 99 */ "onconf ::= ON CONFLICT resolvetype", |
| 109065 | + /* 100 */ "orconf ::=", |
| 109066 | + /* 101 */ "orconf ::= OR resolvetype", |
| 109067 | + /* 102 */ "resolvetype ::= raisetype", |
| 109068 | + /* 103 */ "resolvetype ::= IGNORE", |
| 109069 | + /* 104 */ "resolvetype ::= REPLACE", |
| 109070 | + /* 105 */ "cmd ::= DROP TABLE ifexists fullname", |
| 109071 | + /* 106 */ "ifexists ::= IF EXISTS", |
| 109072 | + /* 107 */ "ifexists ::=", |
| 109073 | + /* 108 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select", |
| 109074 | + /* 109 */ "cmd ::= DROP VIEW ifexists fullname", |
| 109075 | + /* 110 */ "cmd ::= select", |
| 109076 | + /* 111 */ "select ::= oneselect", |
| 109077 | + /* 112 */ "select ::= select multiselect_op oneselect", |
| 109078 | + /* 113 */ "multiselect_op ::= UNION", |
| 109079 | + /* 114 */ "multiselect_op ::= UNION ALL", |
| 109080 | + /* 115 */ "multiselect_op ::= EXCEPT|INTERSECT", |
| 109081 | + /* 116 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", |
| 109082 | + /* 117 */ "distinct ::= DISTINCT", |
| 109083 | + /* 118 */ "distinct ::= ALL", |
| 109084 | + /* 119 */ "distinct ::=", |
| 109085 | + /* 120 */ "sclp ::= selcollist COMMA", |
| 109086 | + /* 121 */ "sclp ::=", |
| 109087 | + /* 122 */ "selcollist ::= sclp expr as", |
| 109088 | + /* 123 */ "selcollist ::= sclp STAR", |
| 109089 | + /* 124 */ "selcollist ::= sclp nm DOT STAR", |
| 109090 | + /* 125 */ "as ::= AS nm", |
| 109091 | + /* 126 */ "as ::= ids", |
| 109092 | + /* 127 */ "as ::=", |
| 109093 | + /* 128 */ "from ::=", |
| 109094 | + /* 129 */ "from ::= FROM seltablist", |
| 109095 | + /* 130 */ "stl_prefix ::= seltablist joinop", |
| 109096 | + /* 131 */ "stl_prefix ::=", |
| 109097 | + /* 132 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", |
| 109098 | + /* 133 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", |
| 109099 | + /* 134 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", |
| 109100 | + /* 135 */ "dbnm ::=", |
| 109101 | + /* 136 */ "dbnm ::= DOT nm", |
| 109102 | + /* 137 */ "fullname ::= nm dbnm", |
| 109103 | + /* 138 */ "joinop ::= COMMA|JOIN", |
| 109104 | + /* 139 */ "joinop ::= JOIN_KW JOIN", |
| 109105 | + /* 140 */ "joinop ::= JOIN_KW nm JOIN", |
| 109106 | + /* 141 */ "joinop ::= JOIN_KW nm nm JOIN", |
| 109107 | + /* 142 */ "on_opt ::= ON expr", |
| 109108 | + /* 143 */ "on_opt ::=", |
| 109109 | + /* 144 */ "indexed_opt ::=", |
| 109110 | + /* 145 */ "indexed_opt ::= INDEXED BY nm", |
| 109111 | + /* 146 */ "indexed_opt ::= NOT INDEXED", |
| 109112 | + /* 147 */ "using_opt ::= USING LP inscollist RP", |
| 109113 | + /* 148 */ "using_opt ::=", |
| 109114 | + /* 149 */ "orderby_opt ::=", |
| 109115 | + /* 150 */ "orderby_opt ::= ORDER BY sortlist", |
| 109116 | + /* 151 */ "sortlist ::= sortlist COMMA expr sortorder", |
| 109117 | + /* 152 */ "sortlist ::= expr sortorder", |
| 109118 | + /* 153 */ "sortorder ::= ASC", |
| 109119 | + /* 154 */ "sortorder ::= DESC", |
| 109120 | + /* 155 */ "sortorder ::=", |
| 109121 | + /* 156 */ "groupby_opt ::=", |
| 109122 | + /* 157 */ "groupby_opt ::= GROUP BY nexprlist", |
| 109123 | + /* 158 */ "having_opt ::=", |
| 109124 | + /* 159 */ "having_opt ::= HAVING expr", |
| 109125 | + /* 160 */ "limit_opt ::=", |
| 109126 | + /* 161 */ "limit_opt ::= LIMIT expr", |
| 109127 | + /* 162 */ "limit_opt ::= LIMIT expr OFFSET expr", |
| 109128 | + /* 163 */ "limit_opt ::= LIMIT expr COMMA expr", |
| 109129 | + /* 164 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt", |
| 109130 | + /* 165 */ "where_opt ::=", |
| 109131 | + /* 166 */ "where_opt ::= WHERE expr", |
| 109132 | + /* 167 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt", |
| 109133 | + /* 168 */ "setlist ::= setlist COMMA nm EQ expr", |
| 109134 | + /* 169 */ "setlist ::= nm EQ expr", |
| 109135 | + /* 170 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist", |
| 109136 | + /* 171 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select", |
| 109137 | + /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES", |
| 109138 | + /* 173 */ "insert_cmd ::= INSERT orconf", |
| 109139 | + /* 174 */ "insert_cmd ::= REPLACE", |
| 109140 | + /* 175 */ "valuelist ::= VALUES LP nexprlist RP", |
| 109141 | + /* 176 */ "valuelist ::= valuelist COMMA LP exprlist RP", |
| 109142 | + /* 177 */ "inscollist_opt ::=", |
| 109143 | + /* 178 */ "inscollist_opt ::= LP inscollist RP", |
| 109144 | + /* 179 */ "inscollist ::= inscollist COMMA nm", |
| 109145 | + /* 180 */ "inscollist ::= nm", |
| 109146 | + /* 181 */ "expr ::= term", |
| 109147 | + /* 182 */ "expr ::= LP expr RP", |
| 109148 | + /* 183 */ "term ::= NULL", |
| 109149 | + /* 184 */ "expr ::= id", |
| 109150 | + /* 185 */ "expr ::= JOIN_KW", |
| 109151 | + /* 186 */ "expr ::= nm DOT nm", |
| 109152 | + /* 187 */ "expr ::= nm DOT nm DOT nm", |
| 109153 | + /* 188 */ "term ::= INTEGER|FLOAT|BLOB", |
| 109154 | + /* 189 */ "term ::= STRING", |
| 109155 | + /* 190 */ "expr ::= REGISTER", |
| 109156 | + /* 191 */ "expr ::= VARIABLE", |
| 109157 | + /* 192 */ "expr ::= expr COLLATE ids", |
| 109158 | + /* 193 */ "expr ::= CAST LP expr AS typetoken RP", |
| 109159 | + /* 194 */ "expr ::= ID LP distinct exprlist RP", |
| 109160 | + /* 195 */ "expr ::= ID LP STAR RP", |
| 109161 | + /* 196 */ "term ::= CTIME_KW", |
| 109162 | + /* 197 */ "expr ::= expr AND expr", |
| 109163 | + /* 198 */ "expr ::= expr OR expr", |
| 109164 | + /* 199 */ "expr ::= expr LT|GT|GE|LE expr", |
| 109165 | + /* 200 */ "expr ::= expr EQ|NE expr", |
| 109166 | + /* 201 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 109167 | + /* 202 */ "expr ::= expr PLUS|MINUS expr", |
| 109168 | + /* 203 */ "expr ::= expr STAR|SLASH|REM expr", |
| 109169 | + /* 204 */ "expr ::= expr CONCAT expr", |
| 109170 | + /* 205 */ "likeop ::= LIKE_KW", |
| 109171 | + /* 206 */ "likeop ::= NOT LIKE_KW", |
| 109172 | + /* 207 */ "likeop ::= MATCH", |
| 109173 | + /* 208 */ "likeop ::= NOT MATCH", |
| 109174 | + /* 209 */ "expr ::= expr likeop expr", |
| 109175 | + /* 210 */ "expr ::= expr likeop expr ESCAPE expr", |
| 109176 | + /* 211 */ "expr ::= expr ISNULL|NOTNULL", |
| 109177 | + /* 212 */ "expr ::= expr NOT NULL", |
| 109178 | + /* 213 */ "expr ::= expr IS expr", |
| 109179 | + /* 214 */ "expr ::= expr IS NOT expr", |
| 109180 | + /* 215 */ "expr ::= NOT expr", |
| 109181 | + /* 216 */ "expr ::= BITNOT expr", |
| 109182 | + /* 217 */ "expr ::= MINUS expr", |
| 109183 | + /* 218 */ "expr ::= PLUS expr", |
| 109184 | + /* 219 */ "between_op ::= BETWEEN", |
| 109185 | + /* 220 */ "between_op ::= NOT BETWEEN", |
| 109186 | + /* 221 */ "expr ::= expr between_op expr AND expr", |
| 109187 | + /* 222 */ "in_op ::= IN", |
| 109188 | + /* 223 */ "in_op ::= NOT IN", |
| 109189 | + /* 224 */ "expr ::= expr in_op LP exprlist RP", |
| 109190 | + /* 225 */ "expr ::= LP select RP", |
| 109191 | + /* 226 */ "expr ::= expr in_op LP select RP", |
| 109192 | + /* 227 */ "expr ::= expr in_op nm dbnm", |
| 109193 | + /* 228 */ "expr ::= EXISTS LP select RP", |
| 109194 | + /* 229 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 109195 | + /* 230 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 109196 | + /* 231 */ "case_exprlist ::= WHEN expr THEN expr", |
| 109197 | + /* 232 */ "case_else ::= ELSE expr", |
| 109198 | + /* 233 */ "case_else ::=", |
| 109199 | + /* 234 */ "case_operand ::= expr", |
| 109200 | + /* 235 */ "case_operand ::=", |
| 109201 | + /* 236 */ "exprlist ::= nexprlist", |
| 109202 | + /* 237 */ "exprlist ::=", |
| 109203 | + /* 238 */ "nexprlist ::= nexprlist COMMA expr", |
| 109204 | + /* 239 */ "nexprlist ::= expr", |
| 109205 | + /* 240 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP", |
| 109206 | + /* 241 */ "uniqueflag ::= UNIQUE", |
| 109207 | + /* 242 */ "uniqueflag ::=", |
| 109208 | + /* 243 */ "idxlist_opt ::=", |
| 109209 | + /* 244 */ "idxlist_opt ::= LP idxlist RP", |
| 109210 | + /* 245 */ "idxlist ::= idxlist COMMA nm collate sortorder", |
| 109211 | + /* 246 */ "idxlist ::= nm collate sortorder", |
| 109212 | + /* 247 */ "collate ::=", |
| 109213 | + /* 248 */ "collate ::= COLLATE ids", |
| 109214 | + /* 249 */ "cmd ::= DROP INDEX ifexists fullname", |
| 109215 | + /* 250 */ "cmd ::= VACUUM", |
| 109216 | + /* 251 */ "cmd ::= VACUUM nm", |
| 109217 | + /* 252 */ "cmd ::= PRAGMA nm dbnm", |
| 109218 | + /* 253 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 109219 | + /* 254 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 109220 | + /* 255 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 109221 | + /* 256 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 109222 | + /* 257 */ "nmnum ::= plus_num", |
| 109223 | + /* 258 */ "nmnum ::= nm", |
| 109224 | + /* 259 */ "nmnum ::= ON", |
| 109225 | + /* 260 */ "nmnum ::= DELETE", |
| 109226 | + /* 261 */ "nmnum ::= DEFAULT", |
| 109227 | + /* 262 */ "plus_num ::= PLUS number", |
| 109228 | + /* 263 */ "plus_num ::= number", |
| 109229 | + /* 264 */ "minus_num ::= MINUS number", |
| 109230 | + /* 265 */ "number ::= INTEGER|FLOAT", |
| 109231 | + /* 266 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 109232 | + /* 267 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 109233 | + /* 268 */ "trigger_time ::= BEFORE", |
| 109234 | + /* 269 */ "trigger_time ::= AFTER", |
| 109235 | + /* 270 */ "trigger_time ::= INSTEAD OF", |
| 109236 | + /* 271 */ "trigger_time ::=", |
| 109237 | + /* 272 */ "trigger_event ::= DELETE|INSERT", |
| 109238 | + /* 273 */ "trigger_event ::= UPDATE", |
| 109239 | + /* 274 */ "trigger_event ::= UPDATE OF inscollist", |
| 109240 | + /* 275 */ "foreach_clause ::=", |
| 109241 | + /* 276 */ "foreach_clause ::= FOR EACH ROW", |
| 109242 | + /* 277 */ "when_clause ::=", |
| 109243 | + /* 278 */ "when_clause ::= WHEN expr", |
| 109244 | + /* 279 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 109245 | + /* 280 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 109246 | + /* 281 */ "trnm ::= nm", |
| 109247 | + /* 282 */ "trnm ::= nm DOT nm", |
| 109248 | + /* 283 */ "tridxby ::=", |
| 109249 | + /* 284 */ "tridxby ::= INDEXED BY nm", |
| 109250 | + /* 285 */ "tridxby ::= NOT INDEXED", |
| 109251 | + /* 286 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt", |
| 109252 | + /* 287 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist", |
| 109253 | + /* 288 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select", |
| 109254 | + /* 289 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt", |
| 109255 | + /* 290 */ "trigger_cmd ::= select", |
| 109256 | + /* 291 */ "expr ::= RAISE LP IGNORE RP", |
| 109257 | + /* 292 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 109258 | + /* 293 */ "raisetype ::= ROLLBACK", |
| 109259 | + /* 294 */ "raisetype ::= ABORT", |
| 109260 | + /* 295 */ "raisetype ::= FAIL", |
| 109261 | + /* 296 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 109262 | + /* 297 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 109263 | + /* 298 */ "cmd ::= DETACH database_kw_opt expr", |
| 109264 | + /* 299 */ "key_opt ::=", |
| 109265 | + /* 300 */ "key_opt ::= KEY expr", |
| 109266 | + /* 301 */ "database_kw_opt ::= DATABASE", |
| 109267 | + /* 302 */ "database_kw_opt ::=", |
| 109268 | + /* 303 */ "cmd ::= REINDEX", |
| 109269 | + /* 304 */ "cmd ::= REINDEX nm dbnm", |
| 109270 | + /* 305 */ "cmd ::= ANALYZE", |
| 109271 | + /* 306 */ "cmd ::= ANALYZE nm dbnm", |
| 109272 | + /* 307 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 109273 | + /* 308 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column", |
| 109274 | + /* 309 */ "add_column_fullname ::= fullname", |
| 109275 | + /* 310 */ "kwcolumn_opt ::=", |
| 109276 | + /* 311 */ "kwcolumn_opt ::= COLUMNKW", |
| 109277 | + /* 312 */ "cmd ::= create_vtab", |
| 109278 | + /* 313 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 109279 | + /* 314 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 109280 | + /* 315 */ "vtabarglist ::= vtabarg", |
| 109281 | + /* 316 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 109282 | + /* 317 */ "vtabarg ::=", |
| 109283 | + /* 318 */ "vtabarg ::= vtabarg vtabargtoken", |
| 109284 | + /* 319 */ "vtabargtoken ::= ANY", |
| 109285 | + /* 320 */ "vtabargtoken ::= lp anylist RP", |
| 109286 | + /* 321 */ "lp ::= LP", |
| 109287 | + /* 322 */ "anylist ::=", |
| 109288 | + /* 323 */ "anylist ::= anylist LP anylist RP", |
| 109289 | + /* 324 */ "anylist ::= anylist ANY", |
| 109103 | 109290 | }; |
| 109104 | 109291 | #endif /* NDEBUG */ |
| 109105 | 109292 | |
| 109106 | 109293 | |
| 109107 | 109294 | #if YYSTACKDEPTH<=0 |
| | @@ -109543,14 +109730,14 @@ |
| 109543 | 109730 | { 167, 6 }, |
| 109544 | 109731 | { 168, 1 }, |
| 109545 | 109732 | { 168, 2 }, |
| 109546 | 109733 | { 169, 1 }, |
| 109547 | 109734 | { 169, 1 }, |
| 109548 | | - { 164, 2 }, |
| 109735 | + { 164, 3 }, |
| 109549 | 109736 | { 164, 0 }, |
| 109550 | | - { 172, 3 }, |
| 109551 | | - { 172, 1 }, |
| 109737 | + { 172, 2 }, |
| 109738 | + { 172, 0 }, |
| 109552 | 109739 | { 173, 2 }, |
| 109553 | 109740 | { 173, 4 }, |
| 109554 | 109741 | { 173, 3 }, |
| 109555 | 109742 | { 173, 3 }, |
| 109556 | 109743 | { 173, 2 }, |
| | @@ -109580,14 +109767,12 @@ |
| 109580 | 109767 | { 184, 0 }, |
| 109581 | 109768 | { 184, 2 }, |
| 109582 | 109769 | { 184, 2 }, |
| 109583 | 109770 | { 159, 0 }, |
| 109584 | 109771 | { 159, 2 }, |
| 109585 | | - { 185, 3 }, |
| 109772 | + { 185, 4 }, |
| 109586 | 109773 | { 185, 2 }, |
| 109587 | | - { 185, 1 }, |
| 109588 | | - { 186, 2 }, |
| 109589 | 109774 | { 186, 7 }, |
| 109590 | 109775 | { 186, 5 }, |
| 109591 | 109776 | { 186, 5 }, |
| 109592 | 109777 | { 186, 10 }, |
| 109593 | 109778 | { 188, 0 }, |
| | @@ -109892,12 +110077,12 @@ |
| 109892 | 110077 | {yygotominor.yy392 = TK_DEFERRED;} |
| 109893 | 110078 | break; |
| 109894 | 110079 | case 14: /* transtype ::= DEFERRED */ |
| 109895 | 110080 | case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15); |
| 109896 | 110081 | case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16); |
| 109897 | | - case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115); |
| 109898 | | - case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117); |
| 110082 | + case 113: /* multiselect_op ::= UNION */ yytestcase(yyruleno==113); |
| 110083 | + case 115: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==115); |
| 109899 | 110084 | {yygotominor.yy392 = yymsp[0].major;} |
| 109900 | 110085 | break; |
| 109901 | 110086 | case 17: /* cmd ::= COMMIT trans_opt */ |
| 109902 | 110087 | case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18); |
| 109903 | 110088 | {sqlite3CommitTransaction(pParse);} |
| | @@ -109935,26 +110120,26 @@ |
| 109935 | 110120 | case 31: /* temp ::= */ yytestcase(yyruleno==31); |
| 109936 | 110121 | case 70: /* autoinc ::= */ yytestcase(yyruleno==70); |
| 109937 | 110122 | case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83); |
| 109938 | 110123 | case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85); |
| 109939 | 110124 | case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87); |
| 109940 | | - case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98); |
| 109941 | | - case 109: /* ifexists ::= */ yytestcase(yyruleno==109); |
| 109942 | | - case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120); |
| 109943 | | - case 121: /* distinct ::= */ yytestcase(yyruleno==121); |
| 109944 | | - case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221); |
| 109945 | | - case 224: /* in_op ::= IN */ yytestcase(yyruleno==224); |
| 110125 | + case 96: /* defer_subclause_opt ::= */ yytestcase(yyruleno==96); |
| 110126 | + case 107: /* ifexists ::= */ yytestcase(yyruleno==107); |
| 110127 | + case 118: /* distinct ::= ALL */ yytestcase(yyruleno==118); |
| 110128 | + case 119: /* distinct ::= */ yytestcase(yyruleno==119); |
| 110129 | + case 219: /* between_op ::= BETWEEN */ yytestcase(yyruleno==219); |
| 110130 | + case 222: /* in_op ::= IN */ yytestcase(yyruleno==222); |
| 109946 | 110131 | {yygotominor.yy392 = 0;} |
| 109947 | 110132 | break; |
| 109948 | 110133 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 109949 | 110134 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 109950 | 110135 | case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71); |
| 109951 | 110136 | case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86); |
| 109952 | | - case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108); |
| 109953 | | - case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119); |
| 109954 | | - case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222); |
| 109955 | | - case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225); |
| 110137 | + case 106: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==106); |
| 110138 | + case 117: /* distinct ::= DISTINCT */ yytestcase(yyruleno==117); |
| 110139 | + case 220: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==220); |
| 110140 | + case 223: /* in_op ::= NOT IN */ yytestcase(yyruleno==223); |
| 109956 | 110141 | {yygotominor.yy392 = 1;} |
| 109957 | 110142 | break; |
| 109958 | 110143 | case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ |
| 109959 | 110144 | { |
| 109960 | 110145 | sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0); |
| | @@ -109984,25 +110169,25 @@ |
| 109984 | 110169 | case 41: /* nm ::= id */ yytestcase(yyruleno==41); |
| 109985 | 110170 | case 42: /* nm ::= STRING */ yytestcase(yyruleno==42); |
| 109986 | 110171 | case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43); |
| 109987 | 110172 | case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46); |
| 109988 | 110173 | case 49: /* typename ::= ids */ yytestcase(yyruleno==49); |
| 109989 | | - case 127: /* as ::= AS nm */ yytestcase(yyruleno==127); |
| 109990 | | - case 128: /* as ::= ids */ yytestcase(yyruleno==128); |
| 109991 | | - case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138); |
| 109992 | | - case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147); |
| 109993 | | - case 250: /* collate ::= COLLATE ids */ yytestcase(yyruleno==250); |
| 109994 | | - case 259: /* nmnum ::= plus_num */ yytestcase(yyruleno==259); |
| 109995 | | - case 260: /* nmnum ::= nm */ yytestcase(yyruleno==260); |
| 109996 | | - case 261: /* nmnum ::= ON */ yytestcase(yyruleno==261); |
| 109997 | | - case 262: /* nmnum ::= DELETE */ yytestcase(yyruleno==262); |
| 109998 | | - case 263: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==263); |
| 109999 | | - case 264: /* plus_num ::= PLUS number */ yytestcase(yyruleno==264); |
| 110000 | | - case 265: /* plus_num ::= number */ yytestcase(yyruleno==265); |
| 110001 | | - case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266); |
| 110002 | | - case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267); |
| 110003 | | - case 283: /* trnm ::= nm */ yytestcase(yyruleno==283); |
| 110174 | + case 125: /* as ::= AS nm */ yytestcase(yyruleno==125); |
| 110175 | + case 126: /* as ::= ids */ yytestcase(yyruleno==126); |
| 110176 | + case 136: /* dbnm ::= DOT nm */ yytestcase(yyruleno==136); |
| 110177 | + case 145: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==145); |
| 110178 | + case 248: /* collate ::= COLLATE ids */ yytestcase(yyruleno==248); |
| 110179 | + case 257: /* nmnum ::= plus_num */ yytestcase(yyruleno==257); |
| 110180 | + case 258: /* nmnum ::= nm */ yytestcase(yyruleno==258); |
| 110181 | + case 259: /* nmnum ::= ON */ yytestcase(yyruleno==259); |
| 110182 | + case 260: /* nmnum ::= DELETE */ yytestcase(yyruleno==260); |
| 110183 | + case 261: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==261); |
| 110184 | + case 262: /* plus_num ::= PLUS number */ yytestcase(yyruleno==262); |
| 110185 | + case 263: /* plus_num ::= number */ yytestcase(yyruleno==263); |
| 110186 | + case 264: /* minus_num ::= MINUS number */ yytestcase(yyruleno==264); |
| 110187 | + case 265: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==265); |
| 110188 | + case 281: /* trnm ::= nm */ yytestcase(yyruleno==281); |
| 110004 | 110189 | {yygotominor.yy0 = yymsp[0].minor.yy0;} |
| 110005 | 110190 | break; |
| 110006 | 110191 | case 45: /* type ::= typetoken */ |
| 110007 | 110192 | {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);} |
| 110008 | 110193 | break; |
| | @@ -110018,10 +110203,16 @@ |
| 110018 | 110203 | yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z); |
| 110019 | 110204 | } |
| 110020 | 110205 | break; |
| 110021 | 110206 | case 50: /* typename ::= typename ids */ |
| 110022 | 110207 | {yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} |
| 110208 | + break; |
| 110209 | + case 55: /* cname ::= CONSTRAINT nm */ |
| 110210 | +{pParse->constraintName = yymsp[0].minor.yy0;} |
| 110211 | + break; |
| 110212 | + case 56: /* cname ::= */ |
| 110213 | +{pParse->constraintName.n = 0;} |
| 110023 | 110214 | break; |
| 110024 | 110215 | case 57: /* ccons ::= DEFAULT term */ |
| 110025 | 110216 | case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59); |
| 110026 | 110217 | {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);} |
| 110027 | 110218 | break; |
| | @@ -110095,80 +110286,80 @@ |
| 110095 | 110286 | break; |
| 110096 | 110287 | case 82: /* refact ::= NO ACTION */ |
| 110097 | 110288 | { yygotominor.yy392 = OE_None; /* EV: R-33326-45252 */} |
| 110098 | 110289 | break; |
| 110099 | 110290 | case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 110100 | | - case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99); |
| 110101 | | - case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101); |
| 110102 | | - case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104); |
| 110291 | + case 97: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==97); |
| 110292 | + case 99: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==99); |
| 110293 | + case 102: /* resolvetype ::= raisetype */ yytestcase(yyruleno==102); |
| 110103 | 110294 | {yygotominor.yy392 = yymsp[0].minor.yy392;} |
| 110104 | 110295 | break; |
| 110105 | 110296 | case 88: /* conslist_opt ::= */ |
| 110106 | 110297 | {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;} |
| 110107 | 110298 | break; |
| 110108 | 110299 | case 89: /* conslist_opt ::= COMMA conslist */ |
| 110109 | 110300 | {yygotominor.yy0 = yymsp[-1].minor.yy0;} |
| 110110 | 110301 | break; |
| 110111 | | - case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ |
| 110302 | + case 92: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ |
| 110112 | 110303 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);} |
| 110113 | 110304 | break; |
| 110114 | | - case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ |
| 110305 | + case 93: /* tcons ::= UNIQUE LP idxlist RP onconf */ |
| 110115 | 110306 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);} |
| 110116 | 110307 | break; |
| 110117 | | - case 96: /* tcons ::= CHECK LP expr RP onconf */ |
| 110308 | + case 94: /* tcons ::= CHECK LP expr RP onconf */ |
| 110118 | 110309 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);} |
| 110119 | 110310 | break; |
| 110120 | | - case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ |
| 110311 | + case 95: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */ |
| 110121 | 110312 | { |
| 110122 | 110313 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392); |
| 110123 | 110314 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392); |
| 110124 | 110315 | } |
| 110125 | 110316 | break; |
| 110126 | | - case 100: /* onconf ::= */ |
| 110317 | + case 98: /* onconf ::= */ |
| 110127 | 110318 | {yygotominor.yy392 = OE_Default;} |
| 110128 | 110319 | break; |
| 110129 | | - case 102: /* orconf ::= */ |
| 110320 | + case 100: /* orconf ::= */ |
| 110130 | 110321 | {yygotominor.yy258 = OE_Default;} |
| 110131 | 110322 | break; |
| 110132 | | - case 103: /* orconf ::= OR resolvetype */ |
| 110323 | + case 101: /* orconf ::= OR resolvetype */ |
| 110133 | 110324 | {yygotominor.yy258 = (u8)yymsp[0].minor.yy392;} |
| 110134 | 110325 | break; |
| 110135 | | - case 105: /* resolvetype ::= IGNORE */ |
| 110326 | + case 103: /* resolvetype ::= IGNORE */ |
| 110136 | 110327 | {yygotominor.yy392 = OE_Ignore;} |
| 110137 | 110328 | break; |
| 110138 | | - case 106: /* resolvetype ::= REPLACE */ |
| 110329 | + case 104: /* resolvetype ::= REPLACE */ |
| 110139 | 110330 | {yygotominor.yy392 = OE_Replace;} |
| 110140 | 110331 | break; |
| 110141 | | - case 107: /* cmd ::= DROP TABLE ifexists fullname */ |
| 110332 | + case 105: /* cmd ::= DROP TABLE ifexists fullname */ |
| 110142 | 110333 | { |
| 110143 | 110334 | sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392); |
| 110144 | 110335 | } |
| 110145 | 110336 | break; |
| 110146 | | - case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ |
| 110337 | + case 108: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */ |
| 110147 | 110338 | { |
| 110148 | 110339 | sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy159, yymsp[-6].minor.yy392, yymsp[-4].minor.yy392); |
| 110149 | 110340 | } |
| 110150 | 110341 | break; |
| 110151 | | - case 111: /* cmd ::= DROP VIEW ifexists fullname */ |
| 110342 | + case 109: /* cmd ::= DROP VIEW ifexists fullname */ |
| 110152 | 110343 | { |
| 110153 | 110344 | sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392); |
| 110154 | 110345 | } |
| 110155 | 110346 | break; |
| 110156 | | - case 112: /* cmd ::= select */ |
| 110347 | + case 110: /* cmd ::= select */ |
| 110157 | 110348 | { |
| 110158 | 110349 | SelectDest dest = {SRT_Output, 0, 0, 0, 0}; |
| 110159 | 110350 | sqlite3Select(pParse, yymsp[0].minor.yy159, &dest); |
| 110160 | 110351 | sqlite3ExplainBegin(pParse->pVdbe); |
| 110161 | 110352 | sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy159); |
| 110162 | 110353 | sqlite3ExplainFinish(pParse->pVdbe); |
| 110163 | 110354 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159); |
| 110164 | 110355 | } |
| 110165 | 110356 | break; |
| 110166 | | - case 113: /* select ::= oneselect */ |
| 110357 | + case 111: /* select ::= oneselect */ |
| 110167 | 110358 | {yygotominor.yy159 = yymsp[0].minor.yy159;} |
| 110168 | 110359 | break; |
| 110169 | | - case 114: /* select ::= select multiselect_op oneselect */ |
| 110360 | + case 112: /* select ::= select multiselect_op oneselect */ |
| 110170 | 110361 | { |
| 110171 | 110362 | if( yymsp[0].minor.yy159 ){ |
| 110172 | 110363 | yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392; |
| 110173 | 110364 | yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159; |
| 110174 | 110365 | }else{ |
| | @@ -110175,83 +110366,83 @@ |
| 110175 | 110366 | sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159); |
| 110176 | 110367 | } |
| 110177 | 110368 | yygotominor.yy159 = yymsp[0].minor.yy159; |
| 110178 | 110369 | } |
| 110179 | 110370 | break; |
| 110180 | | - case 116: /* multiselect_op ::= UNION ALL */ |
| 110371 | + case 114: /* multiselect_op ::= UNION ALL */ |
| 110181 | 110372 | {yygotominor.yy392 = TK_ALL;} |
| 110182 | 110373 | break; |
| 110183 | | - case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 110374 | + case 116: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 110184 | 110375 | { |
| 110185 | 110376 | yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset); |
| 110186 | 110377 | } |
| 110187 | 110378 | break; |
| 110188 | | - case 122: /* sclp ::= selcollist COMMA */ |
| 110189 | | - case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246); |
| 110379 | + case 120: /* sclp ::= selcollist COMMA */ |
| 110380 | + case 244: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==244); |
| 110190 | 110381 | {yygotominor.yy442 = yymsp[-1].minor.yy442;} |
| 110191 | 110382 | break; |
| 110192 | | - case 123: /* sclp ::= */ |
| 110193 | | - case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151); |
| 110194 | | - case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158); |
| 110195 | | - case 239: /* exprlist ::= */ yytestcase(yyruleno==239); |
| 110196 | | - case 245: /* idxlist_opt ::= */ yytestcase(yyruleno==245); |
| 110383 | + case 121: /* sclp ::= */ |
| 110384 | + case 149: /* orderby_opt ::= */ yytestcase(yyruleno==149); |
| 110385 | + case 156: /* groupby_opt ::= */ yytestcase(yyruleno==156); |
| 110386 | + case 237: /* exprlist ::= */ yytestcase(yyruleno==237); |
| 110387 | + case 243: /* idxlist_opt ::= */ yytestcase(yyruleno==243); |
| 110197 | 110388 | {yygotominor.yy442 = 0;} |
| 110198 | 110389 | break; |
| 110199 | | - case 124: /* selcollist ::= sclp expr as */ |
| 110390 | + case 122: /* selcollist ::= sclp expr as */ |
| 110200 | 110391 | { |
| 110201 | 110392 | yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr); |
| 110202 | 110393 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[0].minor.yy0, 1); |
| 110203 | 110394 | sqlite3ExprListSetSpan(pParse,yygotominor.yy442,&yymsp[-1].minor.yy342); |
| 110204 | 110395 | } |
| 110205 | 110396 | break; |
| 110206 | | - case 125: /* selcollist ::= sclp STAR */ |
| 110397 | + case 123: /* selcollist ::= sclp STAR */ |
| 110207 | 110398 | { |
| 110208 | 110399 | Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0); |
| 110209 | 110400 | yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p); |
| 110210 | 110401 | } |
| 110211 | 110402 | break; |
| 110212 | | - case 126: /* selcollist ::= sclp nm DOT STAR */ |
| 110403 | + case 124: /* selcollist ::= sclp nm DOT STAR */ |
| 110213 | 110404 | { |
| 110214 | 110405 | Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0); |
| 110215 | 110406 | Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 110216 | 110407 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); |
| 110217 | 110408 | yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot); |
| 110218 | 110409 | } |
| 110219 | 110410 | break; |
| 110220 | | - case 129: /* as ::= */ |
| 110411 | + case 127: /* as ::= */ |
| 110221 | 110412 | {yygotominor.yy0.n = 0;} |
| 110222 | 110413 | break; |
| 110223 | | - case 130: /* from ::= */ |
| 110414 | + case 128: /* from ::= */ |
| 110224 | 110415 | {yygotominor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy347));} |
| 110225 | 110416 | break; |
| 110226 | | - case 131: /* from ::= FROM seltablist */ |
| 110417 | + case 129: /* from ::= FROM seltablist */ |
| 110227 | 110418 | { |
| 110228 | 110419 | yygotominor.yy347 = yymsp[0].minor.yy347; |
| 110229 | 110420 | sqlite3SrcListShiftJoinType(yygotominor.yy347); |
| 110230 | 110421 | } |
| 110231 | 110422 | break; |
| 110232 | | - case 132: /* stl_prefix ::= seltablist joinop */ |
| 110423 | + case 130: /* stl_prefix ::= seltablist joinop */ |
| 110233 | 110424 | { |
| 110234 | 110425 | yygotominor.yy347 = yymsp[-1].minor.yy347; |
| 110235 | 110426 | if( ALWAYS(yygotominor.yy347 && yygotominor.yy347->nSrc>0) ) yygotominor.yy347->a[yygotominor.yy347->nSrc-1].jointype = (u8)yymsp[0].minor.yy392; |
| 110236 | 110427 | } |
| 110237 | 110428 | break; |
| 110238 | | - case 133: /* stl_prefix ::= */ |
| 110429 | + case 131: /* stl_prefix ::= */ |
| 110239 | 110430 | {yygotominor.yy347 = 0;} |
| 110240 | 110431 | break; |
| 110241 | | - case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 110432 | + case 132: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 110242 | 110433 | { |
| 110243 | 110434 | yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 110244 | 110435 | sqlite3SrcListIndexedBy(pParse, yygotominor.yy347, &yymsp[-2].minor.yy0); |
| 110245 | 110436 | } |
| 110246 | 110437 | break; |
| 110247 | | - case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 110438 | + case 133: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 110248 | 110439 | { |
| 110249 | 110440 | yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 110250 | 110441 | } |
| 110251 | 110442 | break; |
| 110252 | | - case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 110443 | + case 134: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 110253 | 110444 | { |
| 110254 | 110445 | if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){ |
| 110255 | 110446 | yygotominor.yy347 = yymsp[-4].minor.yy347; |
| 110256 | 110447 | }else{ |
| 110257 | 110448 | Select *pSubquery; |
| | @@ -110259,137 +110450,137 @@ |
| 110259 | 110450 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,0,0,0); |
| 110260 | 110451 | yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180); |
| 110261 | 110452 | } |
| 110262 | 110453 | } |
| 110263 | 110454 | break; |
| 110264 | | - case 137: /* dbnm ::= */ |
| 110265 | | - case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146); |
| 110455 | + case 135: /* dbnm ::= */ |
| 110456 | + case 144: /* indexed_opt ::= */ yytestcase(yyruleno==144); |
| 110266 | 110457 | {yygotominor.yy0.z=0; yygotominor.yy0.n=0;} |
| 110267 | 110458 | break; |
| 110268 | | - case 139: /* fullname ::= nm dbnm */ |
| 110459 | + case 137: /* fullname ::= nm dbnm */ |
| 110269 | 110460 | {yygotominor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} |
| 110270 | 110461 | break; |
| 110271 | | - case 140: /* joinop ::= COMMA|JOIN */ |
| 110462 | + case 138: /* joinop ::= COMMA|JOIN */ |
| 110272 | 110463 | { yygotominor.yy392 = JT_INNER; } |
| 110273 | 110464 | break; |
| 110274 | | - case 141: /* joinop ::= JOIN_KW JOIN */ |
| 110465 | + case 139: /* joinop ::= JOIN_KW JOIN */ |
| 110275 | 110466 | { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } |
| 110276 | 110467 | break; |
| 110277 | | - case 142: /* joinop ::= JOIN_KW nm JOIN */ |
| 110468 | + case 140: /* joinop ::= JOIN_KW nm JOIN */ |
| 110278 | 110469 | { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); } |
| 110279 | 110470 | break; |
| 110280 | | - case 143: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 110471 | + case 141: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 110281 | 110472 | { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); } |
| 110282 | 110473 | break; |
| 110283 | | - case 144: /* on_opt ::= ON expr */ |
| 110284 | | - case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161); |
| 110285 | | - case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168); |
| 110286 | | - case 234: /* case_else ::= ELSE expr */ yytestcase(yyruleno==234); |
| 110287 | | - case 236: /* case_operand ::= expr */ yytestcase(yyruleno==236); |
| 110474 | + case 142: /* on_opt ::= ON expr */ |
| 110475 | + case 159: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==159); |
| 110476 | + case 166: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==166); |
| 110477 | + case 232: /* case_else ::= ELSE expr */ yytestcase(yyruleno==232); |
| 110478 | + case 234: /* case_operand ::= expr */ yytestcase(yyruleno==234); |
| 110288 | 110479 | {yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;} |
| 110289 | 110480 | break; |
| 110290 | | - case 145: /* on_opt ::= */ |
| 110291 | | - case 160: /* having_opt ::= */ yytestcase(yyruleno==160); |
| 110292 | | - case 167: /* where_opt ::= */ yytestcase(yyruleno==167); |
| 110293 | | - case 235: /* case_else ::= */ yytestcase(yyruleno==235); |
| 110294 | | - case 237: /* case_operand ::= */ yytestcase(yyruleno==237); |
| 110481 | + case 143: /* on_opt ::= */ |
| 110482 | + case 158: /* having_opt ::= */ yytestcase(yyruleno==158); |
| 110483 | + case 165: /* where_opt ::= */ yytestcase(yyruleno==165); |
| 110484 | + case 233: /* case_else ::= */ yytestcase(yyruleno==233); |
| 110485 | + case 235: /* case_operand ::= */ yytestcase(yyruleno==235); |
| 110295 | 110486 | {yygotominor.yy122 = 0;} |
| 110296 | 110487 | break; |
| 110297 | | - case 148: /* indexed_opt ::= NOT INDEXED */ |
| 110488 | + case 146: /* indexed_opt ::= NOT INDEXED */ |
| 110298 | 110489 | {yygotominor.yy0.z=0; yygotominor.yy0.n=1;} |
| 110299 | 110490 | break; |
| 110300 | | - case 149: /* using_opt ::= USING LP inscollist RP */ |
| 110301 | | - case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180); |
| 110491 | + case 147: /* using_opt ::= USING LP inscollist RP */ |
| 110492 | + case 178: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==178); |
| 110302 | 110493 | {yygotominor.yy180 = yymsp[-1].minor.yy180;} |
| 110303 | 110494 | break; |
| 110304 | | - case 150: /* using_opt ::= */ |
| 110305 | | - case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179); |
| 110495 | + case 148: /* using_opt ::= */ |
| 110496 | + case 177: /* inscollist_opt ::= */ yytestcase(yyruleno==177); |
| 110306 | 110497 | {yygotominor.yy180 = 0;} |
| 110307 | 110498 | break; |
| 110308 | | - case 152: /* orderby_opt ::= ORDER BY sortlist */ |
| 110309 | | - case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159); |
| 110310 | | - case 238: /* exprlist ::= nexprlist */ yytestcase(yyruleno==238); |
| 110499 | + case 150: /* orderby_opt ::= ORDER BY sortlist */ |
| 110500 | + case 157: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==157); |
| 110501 | + case 236: /* exprlist ::= nexprlist */ yytestcase(yyruleno==236); |
| 110311 | 110502 | {yygotominor.yy442 = yymsp[0].minor.yy442;} |
| 110312 | 110503 | break; |
| 110313 | | - case 153: /* sortlist ::= sortlist COMMA expr sortorder */ |
| 110504 | + case 151: /* sortlist ::= sortlist COMMA expr sortorder */ |
| 110314 | 110505 | { |
| 110315 | 110506 | yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr); |
| 110316 | 110507 | if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392; |
| 110317 | 110508 | } |
| 110318 | 110509 | break; |
| 110319 | | - case 154: /* sortlist ::= expr sortorder */ |
| 110510 | + case 152: /* sortlist ::= expr sortorder */ |
| 110320 | 110511 | { |
| 110321 | 110512 | yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr); |
| 110322 | 110513 | if( yygotominor.yy442 && ALWAYS(yygotominor.yy442->a) ) yygotominor.yy442->a[0].sortOrder = (u8)yymsp[0].minor.yy392; |
| 110323 | 110514 | } |
| 110324 | 110515 | break; |
| 110325 | | - case 155: /* sortorder ::= ASC */ |
| 110326 | | - case 157: /* sortorder ::= */ yytestcase(yyruleno==157); |
| 110516 | + case 153: /* sortorder ::= ASC */ |
| 110517 | + case 155: /* sortorder ::= */ yytestcase(yyruleno==155); |
| 110327 | 110518 | {yygotominor.yy392 = SQLITE_SO_ASC;} |
| 110328 | 110519 | break; |
| 110329 | | - case 156: /* sortorder ::= DESC */ |
| 110520 | + case 154: /* sortorder ::= DESC */ |
| 110330 | 110521 | {yygotominor.yy392 = SQLITE_SO_DESC;} |
| 110331 | 110522 | break; |
| 110332 | | - case 162: /* limit_opt ::= */ |
| 110523 | + case 160: /* limit_opt ::= */ |
| 110333 | 110524 | {yygotominor.yy64.pLimit = 0; yygotominor.yy64.pOffset = 0;} |
| 110334 | 110525 | break; |
| 110335 | | - case 163: /* limit_opt ::= LIMIT expr */ |
| 110526 | + case 161: /* limit_opt ::= LIMIT expr */ |
| 110336 | 110527 | {yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;} |
| 110337 | 110528 | break; |
| 110338 | | - case 164: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 110529 | + case 162: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 110339 | 110530 | {yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;} |
| 110340 | 110531 | break; |
| 110341 | | - case 165: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 110532 | + case 163: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 110342 | 110533 | {yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;} |
| 110343 | 110534 | break; |
| 110344 | | - case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ |
| 110535 | + case 164: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ |
| 110345 | 110536 | { |
| 110346 | 110537 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0); |
| 110347 | 110538 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122); |
| 110348 | 110539 | } |
| 110349 | 110540 | break; |
| 110350 | | - case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 110541 | + case 167: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */ |
| 110351 | 110542 | { |
| 110352 | 110543 | sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0); |
| 110353 | 110544 | sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list"); |
| 110354 | 110545 | sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy258); |
| 110355 | 110546 | } |
| 110356 | 110547 | break; |
| 110357 | | - case 170: /* setlist ::= setlist COMMA nm EQ expr */ |
| 110548 | + case 168: /* setlist ::= setlist COMMA nm EQ expr */ |
| 110358 | 110549 | { |
| 110359 | 110550 | yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr); |
| 110360 | 110551 | sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1); |
| 110361 | 110552 | } |
| 110362 | 110553 | break; |
| 110363 | | - case 171: /* setlist ::= nm EQ expr */ |
| 110554 | + case 169: /* setlist ::= nm EQ expr */ |
| 110364 | 110555 | { |
| 110365 | 110556 | yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr); |
| 110366 | 110557 | sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1); |
| 110367 | 110558 | } |
| 110368 | 110559 | break; |
| 110369 | | - case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */ |
| 110560 | + case 170: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */ |
| 110370 | 110561 | {sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);} |
| 110371 | 110562 | break; |
| 110372 | | - case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ |
| 110563 | + case 171: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ |
| 110373 | 110564 | {sqlite3Insert(pParse, yymsp[-2].minor.yy347, 0, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);} |
| 110374 | 110565 | break; |
| 110375 | | - case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ |
| 110566 | + case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */ |
| 110376 | 110567 | {sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy258);} |
| 110377 | 110568 | break; |
| 110378 | | - case 175: /* insert_cmd ::= INSERT orconf */ |
| 110569 | + case 173: /* insert_cmd ::= INSERT orconf */ |
| 110379 | 110570 | {yygotominor.yy258 = yymsp[0].minor.yy258;} |
| 110380 | 110571 | break; |
| 110381 | | - case 176: /* insert_cmd ::= REPLACE */ |
| 110572 | + case 174: /* insert_cmd ::= REPLACE */ |
| 110382 | 110573 | {yygotominor.yy258 = OE_Replace;} |
| 110383 | 110574 | break; |
| 110384 | | - case 177: /* valuelist ::= VALUES LP nexprlist RP */ |
| 110575 | + case 175: /* valuelist ::= VALUES LP nexprlist RP */ |
| 110385 | 110576 | { |
| 110386 | 110577 | yygotominor.yy487.pList = yymsp[-1].minor.yy442; |
| 110387 | 110578 | yygotominor.yy487.pSelect = 0; |
| 110388 | 110579 | } |
| 110389 | 110580 | break; |
| 110390 | | - case 178: /* valuelist ::= valuelist COMMA LP exprlist RP */ |
| 110581 | + case 176: /* valuelist ::= valuelist COMMA LP exprlist RP */ |
| 110391 | 110582 | { |
| 110392 | 110583 | Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy442, 0, 0, 0, 0, 0, 0, 0, 0); |
| 110393 | 110584 | if( yymsp[-4].minor.yy487.pList ){ |
| 110394 | 110585 | yymsp[-4].minor.yy487.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy487.pList, 0, 0, 0, 0, 0, 0, 0, 0); |
| 110395 | 110586 | yymsp[-4].minor.yy487.pList = 0; |
| | @@ -110406,50 +110597,50 @@ |
| 110406 | 110597 | pRight->pPrior->selFlags |= SF_Values; |
| 110407 | 110598 | yygotominor.yy487.pSelect = pRight; |
| 110408 | 110599 | } |
| 110409 | 110600 | } |
| 110410 | 110601 | break; |
| 110411 | | - case 181: /* inscollist ::= inscollist COMMA nm */ |
| 110602 | + case 179: /* inscollist ::= inscollist COMMA nm */ |
| 110412 | 110603 | {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);} |
| 110413 | 110604 | break; |
| 110414 | | - case 182: /* inscollist ::= nm */ |
| 110605 | + case 180: /* inscollist ::= nm */ |
| 110415 | 110606 | {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);} |
| 110416 | 110607 | break; |
| 110417 | | - case 183: /* expr ::= term */ |
| 110608 | + case 181: /* expr ::= term */ |
| 110418 | 110609 | {yygotominor.yy342 = yymsp[0].minor.yy342;} |
| 110419 | 110610 | break; |
| 110420 | | - case 184: /* expr ::= LP expr RP */ |
| 110611 | + case 182: /* expr ::= LP expr RP */ |
| 110421 | 110612 | {yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);} |
| 110422 | 110613 | break; |
| 110423 | | - case 185: /* term ::= NULL */ |
| 110424 | | - case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190); |
| 110425 | | - case 191: /* term ::= STRING */ yytestcase(yyruleno==191); |
| 110614 | + case 183: /* term ::= NULL */ |
| 110615 | + case 188: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==188); |
| 110616 | + case 189: /* term ::= STRING */ yytestcase(yyruleno==189); |
| 110426 | 110617 | {spanExpr(&yygotominor.yy342, pParse, yymsp[0].major, &yymsp[0].minor.yy0);} |
| 110427 | 110618 | break; |
| 110428 | | - case 186: /* expr ::= id */ |
| 110429 | | - case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187); |
| 110619 | + case 184: /* expr ::= id */ |
| 110620 | + case 185: /* expr ::= JOIN_KW */ yytestcase(yyruleno==185); |
| 110430 | 110621 | {spanExpr(&yygotominor.yy342, pParse, TK_ID, &yymsp[0].minor.yy0);} |
| 110431 | 110622 | break; |
| 110432 | | - case 188: /* expr ::= nm DOT nm */ |
| 110623 | + case 186: /* expr ::= nm DOT nm */ |
| 110433 | 110624 | { |
| 110434 | 110625 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 110435 | 110626 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 110436 | 110627 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 110437 | 110628 | spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 110438 | 110629 | } |
| 110439 | 110630 | break; |
| 110440 | | - case 189: /* expr ::= nm DOT nm DOT nm */ |
| 110631 | + case 187: /* expr ::= nm DOT nm DOT nm */ |
| 110441 | 110632 | { |
| 110442 | 110633 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0); |
| 110443 | 110634 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 110444 | 110635 | Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 110445 | 110636 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); |
| 110446 | 110637 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 110447 | 110638 | spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 110448 | 110639 | } |
| 110449 | 110640 | break; |
| 110450 | | - case 192: /* expr ::= REGISTER */ |
| 110641 | + case 190: /* expr ::= REGISTER */ |
| 110451 | 110642 | { |
| 110452 | 110643 | /* When doing a nested parse, one can include terms in an expression |
| 110453 | 110644 | ** that look like this: #1 #2 ... These terms refer to registers |
| 110454 | 110645 | ** in the virtual machine. #N is the N-th register. */ |
| 110455 | 110646 | if( pParse->nested==0 ){ |
| | @@ -110460,31 +110651,31 @@ |
| 110460 | 110651 | if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable); |
| 110461 | 110652 | } |
| 110462 | 110653 | spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 110463 | 110654 | } |
| 110464 | 110655 | break; |
| 110465 | | - case 193: /* expr ::= VARIABLE */ |
| 110656 | + case 191: /* expr ::= VARIABLE */ |
| 110466 | 110657 | { |
| 110467 | 110658 | spanExpr(&yygotominor.yy342, pParse, TK_VARIABLE, &yymsp[0].minor.yy0); |
| 110468 | 110659 | sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr); |
| 110469 | 110660 | spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 110470 | 110661 | } |
| 110471 | 110662 | break; |
| 110472 | | - case 194: /* expr ::= expr COLLATE ids */ |
| 110663 | + case 192: /* expr ::= expr COLLATE ids */ |
| 110473 | 110664 | { |
| 110474 | 110665 | yygotominor.yy342.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0); |
| 110475 | 110666 | yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart; |
| 110476 | 110667 | yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 110477 | 110668 | } |
| 110478 | 110669 | break; |
| 110479 | | - case 195: /* expr ::= CAST LP expr AS typetoken RP */ |
| 110670 | + case 193: /* expr ::= CAST LP expr AS typetoken RP */ |
| 110480 | 110671 | { |
| 110481 | 110672 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0); |
| 110482 | 110673 | spanSet(&yygotominor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); |
| 110483 | 110674 | } |
| 110484 | 110675 | break; |
| 110485 | | - case 196: /* expr ::= ID LP distinct exprlist RP */ |
| 110676 | + case 194: /* expr ::= ID LP distinct exprlist RP */ |
| 110486 | 110677 | { |
| 110487 | 110678 | if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 110488 | 110679 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 110489 | 110680 | } |
| 110490 | 110681 | yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0); |
| | @@ -110492,17 +110683,17 @@ |
| 110492 | 110683 | if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){ |
| 110493 | 110684 | yygotominor.yy342.pExpr->flags |= EP_Distinct; |
| 110494 | 110685 | } |
| 110495 | 110686 | } |
| 110496 | 110687 | break; |
| 110497 | | - case 197: /* expr ::= ID LP STAR RP */ |
| 110688 | + case 195: /* expr ::= ID LP STAR RP */ |
| 110498 | 110689 | { |
| 110499 | 110690 | yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 110500 | 110691 | spanSet(&yygotominor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 110501 | 110692 | } |
| 110502 | 110693 | break; |
| 110503 | | - case 198: /* term ::= CTIME_KW */ |
| 110694 | + case 196: /* term ::= CTIME_KW */ |
| 110504 | 110695 | { |
| 110505 | 110696 | /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are |
| 110506 | 110697 | ** treated as functions that return constants */ |
| 110507 | 110698 | yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0); |
| 110508 | 110699 | if( yygotominor.yy342.pExpr ){ |
| | @@ -110509,82 +110700,82 @@ |
| 110509 | 110700 | yygotominor.yy342.pExpr->op = TK_CONST_FUNC; |
| 110510 | 110701 | } |
| 110511 | 110702 | spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 110512 | 110703 | } |
| 110513 | 110704 | break; |
| 110514 | | - case 199: /* expr ::= expr AND expr */ |
| 110515 | | - case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200); |
| 110516 | | - case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201); |
| 110517 | | - case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202); |
| 110518 | | - case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203); |
| 110519 | | - case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204); |
| 110520 | | - case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205); |
| 110521 | | - case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206); |
| 110705 | + case 197: /* expr ::= expr AND expr */ |
| 110706 | + case 198: /* expr ::= expr OR expr */ yytestcase(yyruleno==198); |
| 110707 | + case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199); |
| 110708 | + case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200); |
| 110709 | + case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201); |
| 110710 | + case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202); |
| 110711 | + case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203); |
| 110712 | + case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204); |
| 110522 | 110713 | {spanBinaryExpr(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);} |
| 110523 | 110714 | break; |
| 110524 | | - case 207: /* likeop ::= LIKE_KW */ |
| 110525 | | - case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209); |
| 110526 | | -{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 0;} |
| 110527 | | - break; |
| 110528 | | - case 208: /* likeop ::= NOT LIKE_KW */ |
| 110529 | | - case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210); |
| 110530 | | -{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 1;} |
| 110531 | | - break; |
| 110532 | | - case 211: /* expr ::= expr likeop expr */ |
| 110715 | + case 205: /* likeop ::= LIKE_KW */ |
| 110716 | + case 207: /* likeop ::= MATCH */ yytestcase(yyruleno==207); |
| 110717 | +{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 0;} |
| 110718 | + break; |
| 110719 | + case 206: /* likeop ::= NOT LIKE_KW */ |
| 110720 | + case 208: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==208); |
| 110721 | +{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 1;} |
| 110722 | + break; |
| 110723 | + case 209: /* expr ::= expr likeop expr */ |
| 110533 | 110724 | { |
| 110534 | 110725 | ExprList *pList; |
| 110535 | 110726 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr); |
| 110536 | 110727 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr); |
| 110537 | 110728 | yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator); |
| 110538 | | - if( yymsp[-1].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 110729 | + if( yymsp[-1].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 110539 | 110730 | yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart; |
| 110540 | 110731 | yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd; |
| 110541 | 110732 | if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc; |
| 110542 | 110733 | } |
| 110543 | 110734 | break; |
| 110544 | | - case 212: /* expr ::= expr likeop expr ESCAPE expr */ |
| 110735 | + case 210: /* expr ::= expr likeop expr ESCAPE expr */ |
| 110545 | 110736 | { |
| 110546 | 110737 | ExprList *pList; |
| 110547 | 110738 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr); |
| 110548 | 110739 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr); |
| 110549 | 110740 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr); |
| 110550 | 110741 | yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator); |
| 110551 | | - if( yymsp[-3].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 110742 | + if( yymsp[-3].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 110552 | 110743 | yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart; |
| 110553 | 110744 | yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd; |
| 110554 | 110745 | if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc; |
| 110555 | 110746 | } |
| 110556 | 110747 | break; |
| 110557 | | - case 213: /* expr ::= expr ISNULL|NOTNULL */ |
| 110748 | + case 211: /* expr ::= expr ISNULL|NOTNULL */ |
| 110558 | 110749 | {spanUnaryPostfix(&yygotominor.yy342,pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);} |
| 110559 | 110750 | break; |
| 110560 | | - case 214: /* expr ::= expr NOT NULL */ |
| 110751 | + case 212: /* expr ::= expr NOT NULL */ |
| 110561 | 110752 | {spanUnaryPostfix(&yygotominor.yy342,pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);} |
| 110562 | 110753 | break; |
| 110563 | | - case 215: /* expr ::= expr IS expr */ |
| 110754 | + case 213: /* expr ::= expr IS expr */ |
| 110564 | 110755 | { |
| 110565 | 110756 | spanBinaryExpr(&yygotominor.yy342,pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342); |
| 110566 | 110757 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL); |
| 110567 | 110758 | } |
| 110568 | 110759 | break; |
| 110569 | | - case 216: /* expr ::= expr IS NOT expr */ |
| 110760 | + case 214: /* expr ::= expr IS NOT expr */ |
| 110570 | 110761 | { |
| 110571 | 110762 | spanBinaryExpr(&yygotominor.yy342,pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342); |
| 110572 | 110763 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL); |
| 110573 | 110764 | } |
| 110574 | 110765 | break; |
| 110575 | | - case 217: /* expr ::= NOT expr */ |
| 110576 | | - case 218: /* expr ::= BITNOT expr */ yytestcase(yyruleno==218); |
| 110766 | + case 215: /* expr ::= NOT expr */ |
| 110767 | + case 216: /* expr ::= BITNOT expr */ yytestcase(yyruleno==216); |
| 110577 | 110768 | {spanUnaryPrefix(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);} |
| 110578 | 110769 | break; |
| 110579 | | - case 219: /* expr ::= MINUS expr */ |
| 110770 | + case 217: /* expr ::= MINUS expr */ |
| 110580 | 110771 | {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);} |
| 110581 | 110772 | break; |
| 110582 | | - case 220: /* expr ::= PLUS expr */ |
| 110773 | + case 218: /* expr ::= PLUS expr */ |
| 110583 | 110774 | {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);} |
| 110584 | 110775 | break; |
| 110585 | | - case 223: /* expr ::= expr between_op expr AND expr */ |
| 110776 | + case 221: /* expr ::= expr between_op expr AND expr */ |
| 110586 | 110777 | { |
| 110587 | 110778 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr); |
| 110588 | 110779 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr); |
| 110589 | 110780 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0); |
| 110590 | 110781 | if( yygotominor.yy342.pExpr ){ |
| | @@ -110595,11 +110786,11 @@ |
| 110595 | 110786 | if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 110596 | 110787 | yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart; |
| 110597 | 110788 | yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd; |
| 110598 | 110789 | } |
| 110599 | 110790 | break; |
| 110600 | | - case 226: /* expr ::= expr in_op LP exprlist RP */ |
| 110791 | + case 224: /* expr ::= expr in_op LP exprlist RP */ |
| 110601 | 110792 | { |
| 110602 | 110793 | if( yymsp[-1].minor.yy442==0 ){ |
| 110603 | 110794 | /* Expressions of the form |
| 110604 | 110795 | ** |
| 110605 | 110796 | ** expr1 IN () |
| | @@ -110622,11 +110813,11 @@ |
| 110622 | 110813 | } |
| 110623 | 110814 | yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart; |
| 110624 | 110815 | yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 110625 | 110816 | } |
| 110626 | 110817 | break; |
| 110627 | | - case 227: /* expr ::= LP select RP */ |
| 110818 | + case 225: /* expr ::= LP select RP */ |
| 110628 | 110819 | { |
| 110629 | 110820 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 110630 | 110821 | if( yygotominor.yy342.pExpr ){ |
| 110631 | 110822 | yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159; |
| 110632 | 110823 | ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect); |
| | @@ -110636,11 +110827,11 @@ |
| 110636 | 110827 | } |
| 110637 | 110828 | yygotominor.yy342.zStart = yymsp[-2].minor.yy0.z; |
| 110638 | 110829 | yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 110639 | 110830 | } |
| 110640 | 110831 | break; |
| 110641 | | - case 228: /* expr ::= expr in_op LP select RP */ |
| 110832 | + case 226: /* expr ::= expr in_op LP select RP */ |
| 110642 | 110833 | { |
| 110643 | 110834 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0); |
| 110644 | 110835 | if( yygotominor.yy342.pExpr ){ |
| 110645 | 110836 | yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159; |
| 110646 | 110837 | ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect); |
| | @@ -110651,11 +110842,11 @@ |
| 110651 | 110842 | if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 110652 | 110843 | yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart; |
| 110653 | 110844 | yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 110654 | 110845 | } |
| 110655 | 110846 | break; |
| 110656 | | - case 229: /* expr ::= expr in_op nm dbnm */ |
| 110847 | + case 227: /* expr ::= expr in_op nm dbnm */ |
| 110657 | 110848 | { |
| 110658 | 110849 | SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); |
| 110659 | 110850 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0); |
| 110660 | 110851 | if( yygotominor.yy342.pExpr ){ |
| 110661 | 110852 | yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| | @@ -110667,11 +110858,11 @@ |
| 110667 | 110858 | if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0); |
| 110668 | 110859 | yygotominor.yy342.zStart = yymsp[-3].minor.yy342.zStart; |
| 110669 | 110860 | yygotominor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]; |
| 110670 | 110861 | } |
| 110671 | 110862 | break; |
| 110672 | | - case 230: /* expr ::= EXISTS LP select RP */ |
| 110863 | + case 228: /* expr ::= EXISTS LP select RP */ |
| 110673 | 110864 | { |
| 110674 | 110865 | Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 110675 | 110866 | if( p ){ |
| 110676 | 110867 | p->x.pSelect = yymsp[-1].minor.yy159; |
| 110677 | 110868 | ExprSetProperty(p, EP_xIsSelect); |
| | @@ -110681,11 +110872,11 @@ |
| 110681 | 110872 | } |
| 110682 | 110873 | yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z; |
| 110683 | 110874 | yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 110684 | 110875 | } |
| 110685 | 110876 | break; |
| 110686 | | - case 231: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 110877 | + case 229: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 110687 | 110878 | { |
| 110688 | 110879 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0); |
| 110689 | 110880 | if( yygotominor.yy342.pExpr ){ |
| 110690 | 110881 | yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442; |
| 110691 | 110882 | sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr); |
| | @@ -110694,43 +110885,43 @@ |
| 110694 | 110885 | } |
| 110695 | 110886 | yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z; |
| 110696 | 110887 | yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 110697 | 110888 | } |
| 110698 | 110889 | break; |
| 110699 | | - case 232: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 110890 | + case 230: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 110700 | 110891 | { |
| 110701 | 110892 | yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr); |
| 110702 | 110893 | yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr); |
| 110703 | 110894 | } |
| 110704 | 110895 | break; |
| 110705 | | - case 233: /* case_exprlist ::= WHEN expr THEN expr */ |
| 110896 | + case 231: /* case_exprlist ::= WHEN expr THEN expr */ |
| 110706 | 110897 | { |
| 110707 | 110898 | yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr); |
| 110708 | 110899 | yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr); |
| 110709 | 110900 | } |
| 110710 | 110901 | break; |
| 110711 | | - case 240: /* nexprlist ::= nexprlist COMMA expr */ |
| 110902 | + case 238: /* nexprlist ::= nexprlist COMMA expr */ |
| 110712 | 110903 | {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);} |
| 110713 | 110904 | break; |
| 110714 | | - case 241: /* nexprlist ::= expr */ |
| 110905 | + case 239: /* nexprlist ::= expr */ |
| 110715 | 110906 | {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);} |
| 110716 | 110907 | break; |
| 110717 | | - case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ |
| 110908 | + case 240: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */ |
| 110718 | 110909 | { |
| 110719 | 110910 | sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, |
| 110720 | 110911 | sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392, |
| 110721 | 110912 | &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392); |
| 110722 | 110913 | } |
| 110723 | 110914 | break; |
| 110724 | | - case 243: /* uniqueflag ::= UNIQUE */ |
| 110725 | | - case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296); |
| 110915 | + case 241: /* uniqueflag ::= UNIQUE */ |
| 110916 | + case 294: /* raisetype ::= ABORT */ yytestcase(yyruleno==294); |
| 110726 | 110917 | {yygotominor.yy392 = OE_Abort;} |
| 110727 | 110918 | break; |
| 110728 | | - case 244: /* uniqueflag ::= */ |
| 110919 | + case 242: /* uniqueflag ::= */ |
| 110729 | 110920 | {yygotominor.yy392 = OE_None;} |
| 110730 | 110921 | break; |
| 110731 | | - case 247: /* idxlist ::= idxlist COMMA nm collate sortorder */ |
| 110922 | + case 245: /* idxlist ::= idxlist COMMA nm collate sortorder */ |
| 110732 | 110923 | { |
| 110733 | 110924 | Expr *p = 0; |
| 110734 | 110925 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 110735 | 110926 | p = sqlite3Expr(pParse->db, TK_COLUMN, 0); |
| 110736 | 110927 | sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0); |
| | @@ -110739,11 +110930,11 @@ |
| 110739 | 110930 | sqlite3ExprListSetName(pParse,yygotominor.yy442,&yymsp[-2].minor.yy0,1); |
| 110740 | 110931 | sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index"); |
| 110741 | 110932 | if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392; |
| 110742 | 110933 | } |
| 110743 | 110934 | break; |
| 110744 | | - case 248: /* idxlist ::= nm collate sortorder */ |
| 110935 | + case 246: /* idxlist ::= nm collate sortorder */ |
| 110745 | 110936 | { |
| 110746 | 110937 | Expr *p = 0; |
| 110747 | 110938 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 110748 | 110939 | p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0); |
| 110749 | 110940 | sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0); |
| | @@ -110752,212 +110943,212 @@ |
| 110752 | 110943 | sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1); |
| 110753 | 110944 | sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index"); |
| 110754 | 110945 | if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392; |
| 110755 | 110946 | } |
| 110756 | 110947 | break; |
| 110757 | | - case 249: /* collate ::= */ |
| 110948 | + case 247: /* collate ::= */ |
| 110758 | 110949 | {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;} |
| 110759 | 110950 | break; |
| 110760 | | - case 251: /* cmd ::= DROP INDEX ifexists fullname */ |
| 110951 | + case 249: /* cmd ::= DROP INDEX ifexists fullname */ |
| 110761 | 110952 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);} |
| 110762 | 110953 | break; |
| 110763 | | - case 252: /* cmd ::= VACUUM */ |
| 110764 | | - case 253: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==253); |
| 110954 | + case 250: /* cmd ::= VACUUM */ |
| 110955 | + case 251: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==251); |
| 110765 | 110956 | {sqlite3Vacuum(pParse);} |
| 110766 | 110957 | break; |
| 110767 | | - case 254: /* cmd ::= PRAGMA nm dbnm */ |
| 110958 | + case 252: /* cmd ::= PRAGMA nm dbnm */ |
| 110768 | 110959 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 110769 | 110960 | break; |
| 110770 | | - case 255: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 110961 | + case 253: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 110771 | 110962 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 110772 | 110963 | break; |
| 110773 | | - case 256: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 110964 | + case 254: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 110774 | 110965 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 110775 | 110966 | break; |
| 110776 | | - case 257: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 110967 | + case 255: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 110777 | 110968 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 110778 | 110969 | break; |
| 110779 | | - case 258: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 110970 | + case 256: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 110780 | 110971 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 110781 | 110972 | break; |
| 110782 | | - case 268: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 110973 | + case 266: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 110783 | 110974 | { |
| 110784 | 110975 | Token all; |
| 110785 | 110976 | all.z = yymsp[-3].minor.yy0.z; |
| 110786 | 110977 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 110787 | 110978 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all); |
| 110788 | 110979 | } |
| 110789 | 110980 | break; |
| 110790 | | - case 269: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 110981 | + case 267: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 110791 | 110982 | { |
| 110792 | 110983 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392); |
| 110793 | 110984 | yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); |
| 110794 | 110985 | } |
| 110795 | 110986 | break; |
| 110796 | | - case 270: /* trigger_time ::= BEFORE */ |
| 110797 | | - case 273: /* trigger_time ::= */ yytestcase(yyruleno==273); |
| 110987 | + case 268: /* trigger_time ::= BEFORE */ |
| 110988 | + case 271: /* trigger_time ::= */ yytestcase(yyruleno==271); |
| 110798 | 110989 | { yygotominor.yy392 = TK_BEFORE; } |
| 110799 | 110990 | break; |
| 110800 | | - case 271: /* trigger_time ::= AFTER */ |
| 110991 | + case 269: /* trigger_time ::= AFTER */ |
| 110801 | 110992 | { yygotominor.yy392 = TK_AFTER; } |
| 110802 | 110993 | break; |
| 110803 | | - case 272: /* trigger_time ::= INSTEAD OF */ |
| 110994 | + case 270: /* trigger_time ::= INSTEAD OF */ |
| 110804 | 110995 | { yygotominor.yy392 = TK_INSTEAD;} |
| 110805 | 110996 | break; |
| 110806 | | - case 274: /* trigger_event ::= DELETE|INSERT */ |
| 110807 | | - case 275: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==275); |
| 110997 | + case 272: /* trigger_event ::= DELETE|INSERT */ |
| 110998 | + case 273: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==273); |
| 110808 | 110999 | {yygotominor.yy410.a = yymsp[0].major; yygotominor.yy410.b = 0;} |
| 110809 | 111000 | break; |
| 110810 | | - case 276: /* trigger_event ::= UPDATE OF inscollist */ |
| 111001 | + case 274: /* trigger_event ::= UPDATE OF inscollist */ |
| 110811 | 111002 | {yygotominor.yy410.a = TK_UPDATE; yygotominor.yy410.b = yymsp[0].minor.yy180;} |
| 110812 | 111003 | break; |
| 110813 | | - case 279: /* when_clause ::= */ |
| 110814 | | - case 301: /* key_opt ::= */ yytestcase(yyruleno==301); |
| 111004 | + case 277: /* when_clause ::= */ |
| 111005 | + case 299: /* key_opt ::= */ yytestcase(yyruleno==299); |
| 110815 | 111006 | { yygotominor.yy122 = 0; } |
| 110816 | 111007 | break; |
| 110817 | | - case 280: /* when_clause ::= WHEN expr */ |
| 110818 | | - case 302: /* key_opt ::= KEY expr */ yytestcase(yyruleno==302); |
| 111008 | + case 278: /* when_clause ::= WHEN expr */ |
| 111009 | + case 300: /* key_opt ::= KEY expr */ yytestcase(yyruleno==300); |
| 110819 | 111010 | { yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; } |
| 110820 | 111011 | break; |
| 110821 | | - case 281: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 111012 | + case 279: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 110822 | 111013 | { |
| 110823 | 111014 | assert( yymsp[-2].minor.yy327!=0 ); |
| 110824 | 111015 | yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327; |
| 110825 | 111016 | yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327; |
| 110826 | 111017 | yygotominor.yy327 = yymsp[-2].minor.yy327; |
| 110827 | 111018 | } |
| 110828 | 111019 | break; |
| 110829 | | - case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 111020 | + case 280: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 110830 | 111021 | { |
| 110831 | 111022 | assert( yymsp[-1].minor.yy327!=0 ); |
| 110832 | 111023 | yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327; |
| 110833 | 111024 | yygotominor.yy327 = yymsp[-1].minor.yy327; |
| 110834 | 111025 | } |
| 110835 | 111026 | break; |
| 110836 | | - case 284: /* trnm ::= nm DOT nm */ |
| 111027 | + case 282: /* trnm ::= nm DOT nm */ |
| 110837 | 111028 | { |
| 110838 | 111029 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 110839 | 111030 | sqlite3ErrorMsg(pParse, |
| 110840 | 111031 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 110841 | 111032 | "statements within triggers"); |
| 110842 | 111033 | } |
| 110843 | 111034 | break; |
| 110844 | | - case 286: /* tridxby ::= INDEXED BY nm */ |
| 111035 | + case 284: /* tridxby ::= INDEXED BY nm */ |
| 110845 | 111036 | { |
| 110846 | 111037 | sqlite3ErrorMsg(pParse, |
| 110847 | 111038 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 110848 | 111039 | "within triggers"); |
| 110849 | 111040 | } |
| 110850 | 111041 | break; |
| 110851 | | - case 287: /* tridxby ::= NOT INDEXED */ |
| 111042 | + case 285: /* tridxby ::= NOT INDEXED */ |
| 110852 | 111043 | { |
| 110853 | 111044 | sqlite3ErrorMsg(pParse, |
| 110854 | 111045 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 110855 | 111046 | "within triggers"); |
| 110856 | 111047 | } |
| 110857 | 111048 | break; |
| 110858 | | - case 288: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 111049 | + case 286: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */ |
| 110859 | 111050 | { yygotominor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy258); } |
| 110860 | 111051 | break; |
| 110861 | | - case 289: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */ |
| 111052 | + case 287: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */ |
| 110862 | 111053 | {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-4].minor.yy258);} |
| 110863 | 111054 | break; |
| 110864 | | - case 290: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ |
| 111055 | + case 288: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */ |
| 110865 | 111056 | {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, 0, yymsp[0].minor.yy159, yymsp[-4].minor.yy258);} |
| 110866 | 111057 | break; |
| 110867 | | - case 291: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 111058 | + case 289: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ |
| 110868 | 111059 | {yygotominor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);} |
| 110869 | 111060 | break; |
| 110870 | | - case 292: /* trigger_cmd ::= select */ |
| 111061 | + case 290: /* trigger_cmd ::= select */ |
| 110871 | 111062 | {yygotominor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); } |
| 110872 | 111063 | break; |
| 110873 | | - case 293: /* expr ::= RAISE LP IGNORE RP */ |
| 111064 | + case 291: /* expr ::= RAISE LP IGNORE RP */ |
| 110874 | 111065 | { |
| 110875 | 111066 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 110876 | 111067 | if( yygotominor.yy342.pExpr ){ |
| 110877 | 111068 | yygotominor.yy342.pExpr->affinity = OE_Ignore; |
| 110878 | 111069 | } |
| 110879 | 111070 | yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z; |
| 110880 | 111071 | yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 110881 | 111072 | } |
| 110882 | 111073 | break; |
| 110883 | | - case 294: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 111074 | + case 292: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 110884 | 111075 | { |
| 110885 | 111076 | yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 110886 | 111077 | if( yygotominor.yy342.pExpr ) { |
| 110887 | 111078 | yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392; |
| 110888 | 111079 | } |
| 110889 | 111080 | yygotominor.yy342.zStart = yymsp[-5].minor.yy0.z; |
| 110890 | 111081 | yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 110891 | 111082 | } |
| 110892 | 111083 | break; |
| 110893 | | - case 295: /* raisetype ::= ROLLBACK */ |
| 111084 | + case 293: /* raisetype ::= ROLLBACK */ |
| 110894 | 111085 | {yygotominor.yy392 = OE_Rollback;} |
| 110895 | 111086 | break; |
| 110896 | | - case 297: /* raisetype ::= FAIL */ |
| 111087 | + case 295: /* raisetype ::= FAIL */ |
| 110897 | 111088 | {yygotominor.yy392 = OE_Fail;} |
| 110898 | 111089 | break; |
| 110899 | | - case 298: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 111090 | + case 296: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 110900 | 111091 | { |
| 110901 | 111092 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392); |
| 110902 | 111093 | } |
| 110903 | 111094 | break; |
| 110904 | | - case 299: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 111095 | + case 297: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 110905 | 111096 | { |
| 110906 | 111097 | sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122); |
| 110907 | 111098 | } |
| 110908 | 111099 | break; |
| 110909 | | - case 300: /* cmd ::= DETACH database_kw_opt expr */ |
| 111100 | + case 298: /* cmd ::= DETACH database_kw_opt expr */ |
| 110910 | 111101 | { |
| 110911 | 111102 | sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr); |
| 110912 | 111103 | } |
| 110913 | 111104 | break; |
| 110914 | | - case 305: /* cmd ::= REINDEX */ |
| 111105 | + case 303: /* cmd ::= REINDEX */ |
| 110915 | 111106 | {sqlite3Reindex(pParse, 0, 0);} |
| 110916 | 111107 | break; |
| 110917 | | - case 306: /* cmd ::= REINDEX nm dbnm */ |
| 111108 | + case 304: /* cmd ::= REINDEX nm dbnm */ |
| 110918 | 111109 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 110919 | 111110 | break; |
| 110920 | | - case 307: /* cmd ::= ANALYZE */ |
| 111111 | + case 305: /* cmd ::= ANALYZE */ |
| 110921 | 111112 | {sqlite3Analyze(pParse, 0, 0);} |
| 110922 | 111113 | break; |
| 110923 | | - case 308: /* cmd ::= ANALYZE nm dbnm */ |
| 111114 | + case 306: /* cmd ::= ANALYZE nm dbnm */ |
| 110924 | 111115 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 110925 | 111116 | break; |
| 110926 | | - case 309: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 111117 | + case 307: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 110927 | 111118 | { |
| 110928 | 111119 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0); |
| 110929 | 111120 | } |
| 110930 | 111121 | break; |
| 110931 | | - case 310: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ |
| 111122 | + case 308: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */ |
| 110932 | 111123 | { |
| 110933 | 111124 | sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0); |
| 110934 | 111125 | } |
| 110935 | 111126 | break; |
| 110936 | | - case 311: /* add_column_fullname ::= fullname */ |
| 111127 | + case 309: /* add_column_fullname ::= fullname */ |
| 110937 | 111128 | { |
| 110938 | 111129 | pParse->db->lookaside.bEnabled = 0; |
| 110939 | 111130 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347); |
| 110940 | 111131 | } |
| 110941 | 111132 | break; |
| 110942 | | - case 314: /* cmd ::= create_vtab */ |
| 111133 | + case 312: /* cmd ::= create_vtab */ |
| 110943 | 111134 | {sqlite3VtabFinishParse(pParse,0);} |
| 110944 | 111135 | break; |
| 110945 | | - case 315: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 111136 | + case 313: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 110946 | 111137 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 110947 | 111138 | break; |
| 110948 | | - case 316: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 111139 | + case 314: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 110949 | 111140 | { |
| 110950 | 111141 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392); |
| 110951 | 111142 | } |
| 110952 | 111143 | break; |
| 110953 | | - case 319: /* vtabarg ::= */ |
| 111144 | + case 317: /* vtabarg ::= */ |
| 110954 | 111145 | {sqlite3VtabArgInit(pParse);} |
| 110955 | 111146 | break; |
| 110956 | | - case 321: /* vtabargtoken ::= ANY */ |
| 110957 | | - case 322: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==322); |
| 110958 | | - case 323: /* lp ::= LP */ yytestcase(yyruleno==323); |
| 111147 | + case 319: /* vtabargtoken ::= ANY */ |
| 111148 | + case 320: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==320); |
| 111149 | + case 321: /* lp ::= LP */ yytestcase(yyruleno==321); |
| 110959 | 111150 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 110960 | 111151 | break; |
| 110961 | 111152 | default: |
| 110962 | 111153 | /* (0) input ::= cmdlist */ yytestcase(yyruleno==0); |
| 110963 | 111154 | /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1); |
| | @@ -110973,32 +111164,28 @@ |
| 110973 | 111164 | /* (34) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==34); |
| 110974 | 111165 | /* (35) columnlist ::= column */ yytestcase(yyruleno==35); |
| 110975 | 111166 | /* (44) type ::= */ yytestcase(yyruleno==44); |
| 110976 | 111167 | /* (51) signed ::= plus_num */ yytestcase(yyruleno==51); |
| 110977 | 111168 | /* (52) signed ::= minus_num */ yytestcase(yyruleno==52); |
| 110978 | | - /* (53) carglist ::= carglist carg */ yytestcase(yyruleno==53); |
| 111169 | + /* (53) carglist ::= carglist cname ccons */ yytestcase(yyruleno==53); |
| 110979 | 111170 | /* (54) carglist ::= */ yytestcase(yyruleno==54); |
| 110980 | | - /* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55); |
| 110981 | | - /* (56) carg ::= ccons */ yytestcase(yyruleno==56); |
| 110982 | 111171 | /* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62); |
| 110983 | | - /* (90) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==90); |
| 110984 | | - /* (91) conslist ::= conslist tcons */ yytestcase(yyruleno==91); |
| 110985 | | - /* (92) conslist ::= tcons */ yytestcase(yyruleno==92); |
| 110986 | | - /* (93) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93); |
| 110987 | | - /* (277) foreach_clause ::= */ yytestcase(yyruleno==277); |
| 110988 | | - /* (278) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==278); |
| 110989 | | - /* (285) tridxby ::= */ yytestcase(yyruleno==285); |
| 110990 | | - /* (303) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==303); |
| 110991 | | - /* (304) database_kw_opt ::= */ yytestcase(yyruleno==304); |
| 110992 | | - /* (312) kwcolumn_opt ::= */ yytestcase(yyruleno==312); |
| 110993 | | - /* (313) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==313); |
| 110994 | | - /* (317) vtabarglist ::= vtabarg */ yytestcase(yyruleno==317); |
| 110995 | | - /* (318) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==318); |
| 110996 | | - /* (320) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==320); |
| 110997 | | - /* (324) anylist ::= */ yytestcase(yyruleno==324); |
| 110998 | | - /* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325); |
| 110999 | | - /* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326); |
| 111172 | + /* (90) conslist ::= conslist COMMA cname tcons */ yytestcase(yyruleno==90); |
| 111173 | + /* (91) conslist ::= cname tcons */ yytestcase(yyruleno==91); |
| 111174 | + /* (275) foreach_clause ::= */ yytestcase(yyruleno==275); |
| 111175 | + /* (276) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==276); |
| 111176 | + /* (283) tridxby ::= */ yytestcase(yyruleno==283); |
| 111177 | + /* (301) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==301); |
| 111178 | + /* (302) database_kw_opt ::= */ yytestcase(yyruleno==302); |
| 111179 | + /* (310) kwcolumn_opt ::= */ yytestcase(yyruleno==310); |
| 111180 | + /* (311) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==311); |
| 111181 | + /* (315) vtabarglist ::= vtabarg */ yytestcase(yyruleno==315); |
| 111182 | + /* (316) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==316); |
| 111183 | + /* (318) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==318); |
| 111184 | + /* (322) anylist ::= */ yytestcase(yyruleno==322); |
| 111185 | + /* (323) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==323); |
| 111186 | + /* (324) anylist ::= anylist ANY */ yytestcase(yyruleno==324); |
| 111000 | 111187 | break; |
| 111001 | 111188 | }; |
| 111002 | 111189 | yygoto = yyRuleInfo[yyruleno].lhs; |
| 111003 | 111190 | yysize = yyRuleInfo[yyruleno].nrhs; |
| 111004 | 111191 | yypParser->yyidx -= yysize; |
| | @@ -115889,11 +116076,11 @@ |
| 115889 | 116076 | ** option. But that functionality is no longer supported. |
| 115890 | 116077 | ** |
| 115891 | 116078 | ** A doclist is stored like this: |
| 115892 | 116079 | ** |
| 115893 | 116080 | ** array { |
| 115894 | | -** varint docid; |
| 116081 | +** varint docid; (delta from previous doclist) |
| 115895 | 116082 | ** array { (position list for column 0) |
| 115896 | 116083 | ** varint position; (2 more than the delta from previous position) |
| 115897 | 116084 | ** } |
| 115898 | 116085 | ** array { |
| 115899 | 116086 | ** varint POS_COLUMN; (marks start of position list for new column) |
| | @@ -115920,12 +116107,12 @@ |
| 115920 | 116107 | ** The 123 value is the first docid. For column zero in this document |
| 115921 | 116108 | ** there are two matches at positions 3 and 10 (5-2 and 9-2+3). The 1 |
| 115922 | 116109 | ** at D signals the start of a new column; the 1 at E indicates that the |
| 115923 | 116110 | ** new column is column number 1. There are two positions at 12 and 45 |
| 115924 | 116111 | ** (14-2 and 35-2+12). The 0 at H indicate the end-of-document. The |
| 115925 | | -** 234 at I is the next docid. It has one position 72 (72-2) and then |
| 115926 | | -** terminates with the 0 at K. |
| 116112 | +** 234 at I is the delta to next docid (357). It has one position 70 |
| 116113 | +** (72-2) and then terminates with the 0 at K. |
| 115927 | 116114 | ** |
| 115928 | 116115 | ** A "position-list" is the list of positions for multiple columns for |
| 115929 | 116116 | ** a single docid. A "column-list" is the set of positions for a single |
| 115930 | 116117 | ** column. Hence, a position-list consists of one or more column-lists, |
| 115931 | 116118 | ** a document record consists of a docid followed by a position-list and |
| | @@ -116456,10 +116643,13 @@ |
| 116456 | 116643 | |
| 116457 | 116644 | |
| 116458 | 116645 | #ifndef MIN |
| 116459 | 116646 | # define MIN(x,y) ((x)<(y)?(x):(y)) |
| 116460 | 116647 | #endif |
| 116648 | +#ifndef MAX |
| 116649 | +# define MAX(x,y) ((x)>(y)?(x):(y)) |
| 116650 | +#endif |
| 116461 | 116651 | |
| 116462 | 116652 | /* |
| 116463 | 116653 | ** Maximum length of a varint encoded integer. The varint format is different |
| 116464 | 116654 | ** from that used by SQLite, so the maximum length is 10, not 9. |
| 116465 | 116655 | */ |
| | @@ -116510,20 +116700,21 @@ |
| 116510 | 116700 | #ifdef SQLITE_COVERAGE_TEST |
| 116511 | 116701 | # define ALWAYS(x) (1) |
| 116512 | 116702 | # define NEVER(X) (0) |
| 116513 | 116703 | #else |
| 116514 | 116704 | # define ALWAYS(x) (x) |
| 116515 | | -# define NEVER(X) (x) |
| 116705 | +# define NEVER(x) (x) |
| 116516 | 116706 | #endif |
| 116517 | 116707 | |
| 116518 | 116708 | /* |
| 116519 | 116709 | ** Internal types used by SQLite. |
| 116520 | 116710 | */ |
| 116521 | 116711 | typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */ |
| 116522 | 116712 | typedef short int i16; /* 2-byte (or larger) signed integer */ |
| 116523 | 116713 | typedef unsigned int u32; /* 4-byte unsigned integer */ |
| 116524 | 116714 | typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */ |
| 116715 | +typedef sqlite3_int64 i64; /* 8-byte signed integer */ |
| 116525 | 116716 | |
| 116526 | 116717 | /* |
| 116527 | 116718 | ** Macro used to suppress compiler warnings for unused parameters. |
| 116528 | 116719 | */ |
| 116529 | 116720 | #define UNUSED_PARAMETER(x) (void)(x) |
| | @@ -116582,40 +116773,47 @@ |
| 116582 | 116773 | int nColumn; /* number of named columns in virtual table */ |
| 116583 | 116774 | char **azColumn; /* column names. malloced */ |
| 116584 | 116775 | sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */ |
| 116585 | 116776 | char *zContentTbl; /* content=xxx option, or NULL */ |
| 116586 | 116777 | char *zLanguageid; /* languageid=xxx option, or NULL */ |
| 116778 | + u8 bAutoincrmerge; /* True if automerge=1 */ |
| 116779 | + u32 nLeafAdd; /* Number of leaf blocks added this trans */ |
| 116587 | 116780 | |
| 116588 | 116781 | /* Precompiled statements used by the implementation. Each of these |
| 116589 | 116782 | ** statements is run and reset within a single virtual table API call. |
| 116590 | 116783 | */ |
| 116591 | | - sqlite3_stmt *aStmt[28]; |
| 116784 | + sqlite3_stmt *aStmt[37]; |
| 116592 | 116785 | |
| 116593 | 116786 | char *zReadExprlist; |
| 116594 | 116787 | char *zWriteExprlist; |
| 116595 | 116788 | |
| 116596 | 116789 | int nNodeSize; /* Soft limit for node size */ |
| 116790 | + u8 bFts4; /* True for FTS4, false for FTS3 */ |
| 116597 | 116791 | u8 bHasStat; /* True if %_stat table exists */ |
| 116598 | 116792 | u8 bHasDocsize; /* True if %_docsize table exists */ |
| 116599 | 116793 | u8 bDescIdx; /* True if doclists are in reverse order */ |
| 116794 | + u8 bIgnoreSavepoint; /* True to ignore xSavepoint invocations */ |
| 116600 | 116795 | int nPgsz; /* Page size for host database */ |
| 116601 | 116796 | char *zSegmentsTbl; /* Name of %_segments table */ |
| 116602 | 116797 | sqlite3_blob *pSegments; /* Blob handle open on %_segments table */ |
| 116603 | 116798 | |
| 116604 | | - /* TODO: Fix the first paragraph of this comment. |
| 116605 | | - ** |
| 116799 | + /* |
| 116606 | 116800 | ** The following array of hash tables is used to buffer pending index |
| 116607 | | - ** updates during transactions. Variable nPendingData estimates the memory |
| 116608 | | - ** size of the pending data, including hash table overhead, not including |
| 116609 | | - ** malloc overhead. When nPendingData exceeds nMaxPendingData, the buffer |
| 116610 | | - ** is flushed automatically. Variable iPrevDocid is the docid of the most |
| 116611 | | - ** recently inserted record. |
| 116801 | + ** updates during transactions. All pending updates buffered at any one |
| 116802 | + ** time must share a common language-id (see the FTS4 langid= feature). |
| 116803 | + ** The current language id is stored in variable iPrevLangid. |
| 116612 | 116804 | ** |
| 116613 | 116805 | ** A single FTS4 table may have multiple full-text indexes. For each index |
| 116614 | 116806 | ** there is an entry in the aIndex[] array. Index 0 is an index of all the |
| 116615 | 116807 | ** terms that appear in the document set. Each subsequent index in aIndex[] |
| 116616 | 116808 | ** is an index of prefixes of a specific length. |
| 116809 | + ** |
| 116810 | + ** Variable nPendingData contains an estimate the memory consumed by the |
| 116811 | + ** pending data structures, including hash table overhead, but not including |
| 116812 | + ** malloc overhead. When nPendingData exceeds nMaxPendingData, all hash |
| 116813 | + ** tables are flushed to disk. Variable iPrevDocid is the docid of the most |
| 116814 | + ** recently inserted record. |
| 116617 | 116815 | */ |
| 116618 | 116816 | int nIndex; /* Size of aIndex[] */ |
| 116619 | 116817 | struct Fts3Index { |
| 116620 | 116818 | int nPrefix; /* Prefix length (0 for main terms index) */ |
| 116621 | 116819 | Fts3Hash hPending; /* Pending terms table for this index */ |
| | @@ -116810,10 +117008,11 @@ |
| 116810 | 117008 | SQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *); |
| 116811 | 117009 | SQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int); |
| 116812 | 117010 | SQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *); |
| 116813 | 117011 | SQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *); |
| 116814 | 117012 | SQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *); |
| 117013 | +SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *, int *); |
| 116815 | 117014 | |
| 116816 | 117015 | /* Special values interpreted by sqlite3SegReaderCursor() */ |
| 116817 | 117016 | #define FTS3_SEGCURSOR_PENDING -1 |
| 116818 | 117017 | #define FTS3_SEGCURSOR_ALL -2 |
| 116819 | 117018 | |
| | @@ -116861,19 +117060,22 @@ |
| 116861 | 117060 | int nTerm; /* Size of zTerm in bytes */ |
| 116862 | 117061 | char *aDoclist; /* Pointer to doclist buffer */ |
| 116863 | 117062 | int nDoclist; /* Size of aDoclist[] in bytes */ |
| 116864 | 117063 | }; |
| 116865 | 117064 | |
| 117065 | +SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int); |
| 117066 | + |
| 116866 | 117067 | /* fts3.c */ |
| 116867 | 117068 | SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64); |
| 116868 | 117069 | SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *); |
| 116869 | 117070 | SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *); |
| 116870 | 117071 | SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64); |
| 116871 | 117072 | SQLITE_PRIVATE void sqlite3Fts3Dequote(char *); |
| 116872 | 117073 | SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*); |
| 116873 | 117074 | SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *); |
| 116874 | 117075 | SQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *); |
| 117076 | +SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int*, Fts3Table*); |
| 116875 | 117077 | |
| 116876 | 117078 | /* fts3_tokenizer.c */ |
| 116877 | 117079 | SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *); |
| 116878 | 117080 | SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *); |
| 116879 | 117081 | SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *, |
| | @@ -117198,10 +117400,22 @@ |
| 117198 | 117400 | sqlite3_free(zSql); |
| 117199 | 117401 | sqlite3_free(zCols); |
| 117200 | 117402 | *pRc = rc; |
| 117201 | 117403 | } |
| 117202 | 117404 | } |
| 117405 | + |
| 117406 | +/* |
| 117407 | +** Create the %_stat table if it does not already exist. |
| 117408 | +*/ |
| 117409 | +SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int *pRc, Fts3Table *p){ |
| 117410 | + fts3DbExec(pRc, p->db, |
| 117411 | + "CREATE TABLE IF NOT EXISTS %Q.'%q_stat'" |
| 117412 | + "(id INTEGER PRIMARY KEY, value BLOB);", |
| 117413 | + p->zDb, p->zName |
| 117414 | + ); |
| 117415 | + if( (*pRc)==SQLITE_OK ) p->bHasStat = 1; |
| 117416 | +} |
| 117203 | 117417 | |
| 117204 | 117418 | /* |
| 117205 | 117419 | ** Create the backing store tables (%_content, %_segments and %_segdir) |
| 117206 | 117420 | ** required by the FTS3 table passed as the only argument. This is done |
| 117207 | 117421 | ** as part of the vtab xCreate() method. |
| | @@ -117259,15 +117473,13 @@ |
| 117259 | 117473 | fts3DbExec(&rc, db, |
| 117260 | 117474 | "CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);", |
| 117261 | 117475 | p->zDb, p->zName |
| 117262 | 117476 | ); |
| 117263 | 117477 | } |
| 117478 | + assert( p->bHasStat==p->bFts4 ); |
| 117264 | 117479 | if( p->bHasStat ){ |
| 117265 | | - fts3DbExec(&rc, db, |
| 117266 | | - "CREATE TABLE %Q.'%q_stat'(id INTEGER PRIMARY KEY, value BLOB);", |
| 117267 | | - p->zDb, p->zName |
| 117268 | | - ); |
| 117480 | + sqlite3Fts3CreateStatTable(&rc, p); |
| 117269 | 117481 | } |
| 117270 | 117482 | return rc; |
| 117271 | 117483 | } |
| 117272 | 117484 | |
| 117273 | 117485 | /* |
| | @@ -117370,11 +117582,11 @@ |
| 117370 | 117582 | ** memory. |
| 117371 | 117583 | */ |
| 117372 | 117584 | static char *fts3QuoteId(char const *zInput){ |
| 117373 | 117585 | int nRet; |
| 117374 | 117586 | char *zRet; |
| 117375 | | - nRet = 2 + strlen(zInput)*2 + 1; |
| 117587 | + nRet = 2 + (int)strlen(zInput)*2 + 1; |
| 117376 | 117588 | zRet = sqlite3_malloc(nRet); |
| 117377 | 117589 | if( zRet ){ |
| 117378 | 117590 | int i; |
| 117379 | 117591 | char *z = zRet; |
| 117380 | 117592 | *(z++) = '"'; |
| | @@ -117626,11 +117838,11 @@ |
| 117626 | 117838 | ** space required to store a copy of each column name, including the |
| 117627 | 117839 | ** nul-terminator byte. */ |
| 117628 | 117840 | nCol = sqlite3_column_count(pStmt); |
| 117629 | 117841 | for(i=0; i<nCol; i++){ |
| 117630 | 117842 | const char *zCol = sqlite3_column_name(pStmt, i); |
| 117631 | | - nStr += strlen(zCol) + 1; |
| 117843 | + nStr += (int)strlen(zCol) + 1; |
| 117632 | 117844 | } |
| 117633 | 117845 | |
| 117634 | 117846 | /* Allocate and populate the array to return. */ |
| 117635 | 117847 | azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr); |
| 117636 | 117848 | if( azCol==0 ){ |
| | @@ -117637,11 +117849,11 @@ |
| 117637 | 117849 | rc = SQLITE_NOMEM; |
| 117638 | 117850 | }else{ |
| 117639 | 117851 | char *p = (char *)&azCol[nCol]; |
| 117640 | 117852 | for(i=0; i<nCol; i++){ |
| 117641 | 117853 | const char *zCol = sqlite3_column_name(pStmt, i); |
| 117642 | | - int n = strlen(zCol)+1; |
| 117854 | + int n = (int)strlen(zCol)+1; |
| 117643 | 117855 | memcpy(p, zCol, n); |
| 117644 | 117856 | azCol[i] = p; |
| 117645 | 117857 | p += n; |
| 117646 | 117858 | } |
| 117647 | 117859 | } |
| | @@ -117852,11 +118064,12 @@ |
| 117852 | 118064 | ** column from the aCol[] array. */ |
| 117853 | 118065 | if( rc==SQLITE_OK && zLanguageid ){ |
| 117854 | 118066 | int j; |
| 117855 | 118067 | for(j=0; j<nCol; j++){ |
| 117856 | 118068 | if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){ |
| 117857 | | - memmove(&aCol[j], &aCol[j+1], (nCol-j) * sizeof(aCol[0])); |
| 118069 | + int k; |
| 118070 | + for(k=j; k<nCol; k++) aCol[k] = aCol[k+1]; |
| 117858 | 118071 | nCol--; |
| 117859 | 118072 | break; |
| 117860 | 118073 | } |
| 117861 | 118074 | } |
| 117862 | 118075 | } |
| | @@ -117903,11 +118116,13 @@ |
| 117903 | 118116 | p->azColumn = (char **)&p[1]; |
| 117904 | 118117 | p->pTokenizer = pTokenizer; |
| 117905 | 118118 | p->nMaxPendingData = FTS3_MAX_PENDING_DATA; |
| 117906 | 118119 | p->bHasDocsize = (isFts4 && bNoDocsize==0); |
| 117907 | 118120 | p->bHasStat = isFts4; |
| 118121 | + p->bFts4 = isFts4; |
| 117908 | 118122 | p->bDescIdx = bDescIdx; |
| 118123 | + p->bAutoincrmerge = 0xff; /* 0xff means setting unknown */ |
| 117909 | 118124 | p->zContentTbl = zContent; |
| 117910 | 118125 | p->zLanguageid = zLanguageid; |
| 117911 | 118126 | zContent = 0; |
| 117912 | 118127 | zLanguageid = 0; |
| 117913 | 118128 | TESTONLY( p->inTransaction = -1 ); |
| | @@ -117955,10 +118170,20 @@ |
| 117955 | 118170 | ** database. TODO: For xConnect(), it could verify that said tables exist. |
| 117956 | 118171 | */ |
| 117957 | 118172 | if( isCreate ){ |
| 117958 | 118173 | rc = fts3CreateTables(p); |
| 117959 | 118174 | } |
| 118175 | + |
| 118176 | + /* Check to see if a legacy fts3 table has been "upgraded" by the |
| 118177 | + ** addition of a %_stat table so that it can use incremental merge. |
| 118178 | + */ |
| 118179 | + if( !isFts4 && !isCreate ){ |
| 118180 | + int rc2 = SQLITE_OK; |
| 118181 | + fts3DbExec(&rc2, db, "SELECT 1 FROM %Q.'%q_stat' WHERE id=2", |
| 118182 | + p->zDb, p->zName); |
| 118183 | + if( rc2==SQLITE_OK ) p->bHasStat = 1; |
| 118184 | + } |
| 117960 | 118185 | |
| 117961 | 118186 | /* Figure out the page-size for the database. This is required in order to |
| 117962 | 118187 | ** estimate the cost of loading large doclists from the database. */ |
| 117963 | 118188 | fts3DatabasePageSize(&rc, p); |
| 117964 | 118189 | p->nNodeSize = p->nPgsz-35; |
| | @@ -118959,11 +119184,11 @@ |
| 118959 | 119184 | fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2); |
| 118960 | 119185 | } |
| 118961 | 119186 | } |
| 118962 | 119187 | |
| 118963 | 119188 | *paOut = aOut; |
| 118964 | | - *pnOut = (p-aOut); |
| 119189 | + *pnOut = (int)(p-aOut); |
| 118965 | 119190 | assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 ); |
| 118966 | 119191 | return SQLITE_OK; |
| 118967 | 119192 | } |
| 118968 | 119193 | |
| 118969 | 119194 | /* |
| | @@ -119023,11 +119248,11 @@ |
| 119023 | 119248 | fts3PoslistCopy(0, &p2); |
| 119024 | 119249 | fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2); |
| 119025 | 119250 | } |
| 119026 | 119251 | } |
| 119027 | 119252 | |
| 119028 | | - *pnRight = p - aOut; |
| 119253 | + *pnRight = (int)(p - aOut); |
| 119029 | 119254 | } |
| 119030 | 119255 | |
| 119031 | 119256 | /* |
| 119032 | 119257 | ** Argument pList points to a position list nList bytes in size. This |
| 119033 | 119258 | ** function checks to see if the position list contains any entries for |
| | @@ -119299,11 +119524,11 @@ |
| 119299 | 119524 | ** Set up a cursor object for iterating through a full-text index or a |
| 119300 | 119525 | ** single level therein. |
| 119301 | 119526 | */ |
| 119302 | 119527 | SQLITE_PRIVATE int sqlite3Fts3SegReaderCursor( |
| 119303 | 119528 | Fts3Table *p, /* FTS3 table handle */ |
| 119304 | | - int iLangid, |
| 119529 | + int iLangid, /* Language-id to search */ |
| 119305 | 119530 | int iIndex, /* Index to search (from 0 to p->nIndex-1) */ |
| 119306 | 119531 | int iLevel, /* Level of segments to scan */ |
| 119307 | 119532 | const char *zTerm, /* Term to query for */ |
| 119308 | 119533 | int nTerm, /* Size of zTerm in bytes */ |
| 119309 | 119534 | int isPrefix, /* True for a prefix search */ |
| | @@ -119317,16 +119542,11 @@ |
| 119317 | 119542 | ); |
| 119318 | 119543 | assert( iLevel<FTS3_SEGDIR_MAXLEVEL ); |
| 119319 | 119544 | assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 ); |
| 119320 | 119545 | assert( isPrefix==0 || isScan==0 ); |
| 119321 | 119546 | |
| 119322 | | - /* "isScan" is only set to true by the ft4aux module, an ordinary |
| 119323 | | - ** full-text tables. */ |
| 119324 | | - assert( isScan==0 || p->aIndex==0 ); |
| 119325 | | - |
| 119326 | 119547 | memset(pCsr, 0, sizeof(Fts3MultiSegReader)); |
| 119327 | | - |
| 119328 | 119548 | return fts3SegReaderCursor( |
| 119329 | 119549 | p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr |
| 119330 | 119550 | ); |
| 119331 | 119551 | } |
| 119332 | 119552 | |
| | @@ -119587,11 +119807,11 @@ |
| 119587 | 119807 | |
| 119588 | 119808 | pCsr->iLangid = 0; |
| 119589 | 119809 | if( nVal==2 ) pCsr->iLangid = sqlite3_value_int(apVal[1]); |
| 119590 | 119810 | |
| 119591 | 119811 | rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid, |
| 119592 | | - p->azColumn, p->bHasStat, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr |
| 119812 | + p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr |
| 119593 | 119813 | ); |
| 119594 | 119814 | if( rc!=SQLITE_OK ){ |
| 119595 | 119815 | if( rc==SQLITE_ERROR ){ |
| 119596 | 119816 | static const char *zErr = "malformed MATCH expression: [%s]"; |
| 119597 | 119817 | p->base.zErrMsg = sqlite3_mprintf(zErr, zQuery); |
| | @@ -119730,26 +119950,61 @@ |
| 119730 | 119950 | /* |
| 119731 | 119951 | ** Implementation of xSync() method. Flush the contents of the pending-terms |
| 119732 | 119952 | ** hash-table to the database. |
| 119733 | 119953 | */ |
| 119734 | 119954 | static int fts3SyncMethod(sqlite3_vtab *pVtab){ |
| 119735 | | - int rc = sqlite3Fts3PendingTermsFlush((Fts3Table *)pVtab); |
| 119736 | | - sqlite3Fts3SegmentsClose((Fts3Table *)pVtab); |
| 119955 | + |
| 119956 | + /* Following an incremental-merge operation, assuming that the input |
| 119957 | + ** segments are not completely consumed (the usual case), they are updated |
| 119958 | + ** in place to remove the entries that have already been merged. This |
| 119959 | + ** involves updating the leaf block that contains the smallest unmerged |
| 119960 | + ** entry and each block (if any) between the leaf and the root node. So |
| 119961 | + ** if the height of the input segment b-trees is N, and input segments |
| 119962 | + ** are merged eight at a time, updating the input segments at the end |
| 119963 | + ** of an incremental-merge requires writing (8*(1+N)) blocks. N is usually |
| 119964 | + ** small - often between 0 and 2. So the overhead of the incremental |
| 119965 | + ** merge is somewhere between 8 and 24 blocks. To avoid this overhead |
| 119966 | + ** dwarfing the actual productive work accomplished, the incremental merge |
| 119967 | + ** is only attempted if it will write at least 64 leaf blocks. Hence |
| 119968 | + ** nMinMerge. |
| 119969 | + ** |
| 119970 | + ** Of course, updating the input segments also involves deleting a bunch |
| 119971 | + ** of blocks from the segments table. But this is not considered overhead |
| 119972 | + ** as it would also be required by a crisis-merge that used the same input |
| 119973 | + ** segments. |
| 119974 | + */ |
| 119975 | + const u32 nMinMerge = 64; /* Minimum amount of incr-merge work to do */ |
| 119976 | + |
| 119977 | + Fts3Table *p = (Fts3Table*)pVtab; |
| 119978 | + int rc = sqlite3Fts3PendingTermsFlush(p); |
| 119979 | + |
| 119980 | + if( rc==SQLITE_OK && p->bAutoincrmerge==1 && p->nLeafAdd>(nMinMerge/16) ){ |
| 119981 | + int mxLevel = 0; /* Maximum relative level value in db */ |
| 119982 | + int A; /* Incr-merge parameter A */ |
| 119983 | + |
| 119984 | + rc = sqlite3Fts3MaxLevel(p, &mxLevel); |
| 119985 | + assert( rc==SQLITE_OK || mxLevel==0 ); |
| 119986 | + A = p->nLeafAdd * mxLevel; |
| 119987 | + A += (A/2); |
| 119988 | + if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, 8); |
| 119989 | + } |
| 119990 | + sqlite3Fts3SegmentsClose(p); |
| 119737 | 119991 | return rc; |
| 119738 | 119992 | } |
| 119739 | 119993 | |
| 119740 | 119994 | /* |
| 119741 | 119995 | ** Implementation of xBegin() method. This is a no-op. |
| 119742 | 119996 | */ |
| 119743 | 119997 | static int fts3BeginMethod(sqlite3_vtab *pVtab){ |
| 119744 | | - TESTONLY( Fts3Table *p = (Fts3Table*)pVtab ); |
| 119998 | + Fts3Table *p = (Fts3Table*)pVtab; |
| 119745 | 119999 | UNUSED_PARAMETER(pVtab); |
| 119746 | 120000 | assert( p->pSegments==0 ); |
| 119747 | 120001 | assert( p->nPendingData==0 ); |
| 119748 | 120002 | assert( p->inTransaction!=1 ); |
| 119749 | 120003 | TESTONLY( p->inTransaction = 1 ); |
| 119750 | 120004 | TESTONLY( p->mxSavepoint = -1; ); |
| 120005 | + p->nLeafAdd = 0; |
| 119751 | 120006 | return SQLITE_OK; |
| 119752 | 120007 | } |
| 119753 | 120008 | |
| 119754 | 120009 | /* |
| 119755 | 120010 | ** Implementation of xCommit() method. This is a no-op. The contents of |
| | @@ -120040,15 +120295,19 @@ |
| 120040 | 120295 | ** The xSavepoint() method. |
| 120041 | 120296 | ** |
| 120042 | 120297 | ** Flush the contents of the pending-terms table to disk. |
| 120043 | 120298 | */ |
| 120044 | 120299 | static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){ |
| 120300 | + int rc = SQLITE_OK; |
| 120045 | 120301 | UNUSED_PARAMETER(iSavepoint); |
| 120046 | 120302 | assert( ((Fts3Table *)pVtab)->inTransaction ); |
| 120047 | 120303 | assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint ); |
| 120048 | 120304 | TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint ); |
| 120049 | | - return fts3SyncMethod(pVtab); |
| 120305 | + if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){ |
| 120306 | + rc = fts3SyncMethod(pVtab); |
| 120307 | + } |
| 120308 | + return rc; |
| 120050 | 120309 | } |
| 120051 | 120310 | |
| 120052 | 120311 | /* |
| 120053 | 120312 | ** The xRelease() method. |
| 120054 | 120313 | ** |
| | @@ -120404,11 +120663,11 @@ |
| 120404 | 120663 | |
| 120405 | 120664 | assert( iPrev>=0 ); |
| 120406 | 120665 | fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2); |
| 120407 | 120666 | sqlite3_free(aPoslist); |
| 120408 | 120667 | aPoslist = pList; |
| 120409 | | - nPoslist = aOut - aPoslist; |
| 120668 | + nPoslist = (int)(aOut - aPoslist); |
| 120410 | 120669 | if( nPoslist==0 ){ |
| 120411 | 120670 | sqlite3_free(aPoslist); |
| 120412 | 120671 | pPhrase->doclist.pList = 0; |
| 120413 | 120672 | pPhrase->doclist.nList = 0; |
| 120414 | 120673 | return SQLITE_OK; |
| | @@ -120448,11 +120707,11 @@ |
| 120448 | 120707 | } |
| 120449 | 120708 | |
| 120450 | 120709 | pPhrase->doclist.pList = aOut; |
| 120451 | 120710 | if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){ |
| 120452 | 120711 | pPhrase->doclist.bFreeList = 1; |
| 120453 | | - pPhrase->doclist.nList = (aOut - pPhrase->doclist.pList); |
| 120712 | + pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList); |
| 120454 | 120713 | }else{ |
| 120455 | 120714 | sqlite3_free(aOut); |
| 120456 | 120715 | pPhrase->doclist.pList = 0; |
| 120457 | 120716 | pPhrase->doclist.nList = 0; |
| 120458 | 120717 | } |
| | @@ -120544,11 +120803,11 @@ |
| 120544 | 120803 | fts3PoslistCopy(0, &pDocid); |
| 120545 | 120804 | while( pDocid<pEnd && *pDocid==0 ) pDocid++; |
| 120546 | 120805 | iMul = (bDescIdx ? -1 : 1); |
| 120547 | 120806 | } |
| 120548 | 120807 | |
| 120549 | | - *pnList = pEnd - pNext; |
| 120808 | + *pnList = (int)(pEnd - pNext); |
| 120550 | 120809 | *ppIter = pNext; |
| 120551 | 120810 | *piDocid = iDocid; |
| 120552 | 120811 | }else{ |
| 120553 | 120812 | int iMul = (bDescIdx ? -1 : 1); |
| 120554 | 120813 | sqlite3_int64 iDelta; |
| | @@ -120558,11 +120817,11 @@ |
| 120558 | 120817 | if( p==aDoclist ){ |
| 120559 | 120818 | *pbEof = 1; |
| 120560 | 120819 | }else{ |
| 120561 | 120820 | char *pSave = p; |
| 120562 | 120821 | fts3ReversePoslist(aDoclist, &p); |
| 120563 | | - *pnList = (pSave - p); |
| 120822 | + *pnList = (int)(pSave - p); |
| 120564 | 120823 | } |
| 120565 | 120824 | *ppIter = p; |
| 120566 | 120825 | } |
| 120567 | 120826 | } |
| 120568 | 120827 | |
| | @@ -120618,11 +120877,11 @@ |
| 120618 | 120877 | }else{ |
| 120619 | 120878 | pDL->iDocid -= iDelta; |
| 120620 | 120879 | } |
| 120621 | 120880 | pDL->pList = pIter; |
| 120622 | 120881 | fts3PoslistCopy(0, &pIter); |
| 120623 | | - pDL->nList = (pIter - pDL->pList); |
| 120882 | + pDL->nList = (int)(pIter - pDL->pList); |
| 120624 | 120883 | |
| 120625 | 120884 | /* pIter now points just past the 0x00 that terminates the position- |
| 120626 | 120885 | ** list for document pDL->iDocid. However, if this position-list was |
| 120627 | 120886 | ** edited in place by fts3EvalNearTrim(), then pIter may not actually |
| 120628 | 120887 | ** point to the start of the next docid value. The following line deals |
| | @@ -120959,11 +121218,11 @@ |
| 120959 | 121218 | |
| 120960 | 121219 | /* Allocate a MultiSegReader for each token in the expression. */ |
| 120961 | 121220 | fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc); |
| 120962 | 121221 | |
| 120963 | 121222 | /* Determine which, if any, tokens in the expression should be deferred. */ |
| 120964 | | - if( rc==SQLITE_OK && nToken>1 && pTab->bHasStat ){ |
| 121223 | + if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){ |
| 120965 | 121224 | Fts3TokenAndCost *aTC; |
| 120966 | 121225 | Fts3Expr **apOr; |
| 120967 | 121226 | aTC = (Fts3TokenAndCost *)sqlite3_malloc( |
| 120968 | 121227 | sizeof(Fts3TokenAndCost) * nToken |
| 120969 | 121228 | + sizeof(Fts3Expr *) * nOr * 2 |
| | @@ -120976,12 +121235,12 @@ |
| 120976 | 121235 | int ii; |
| 120977 | 121236 | Fts3TokenAndCost *pTC = aTC; |
| 120978 | 121237 | Fts3Expr **ppOr = apOr; |
| 120979 | 121238 | |
| 120980 | 121239 | fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc); |
| 120981 | | - nToken = pTC-aTC; |
| 120982 | | - nOr = ppOr-apOr; |
| 121240 | + nToken = (int)(pTC-aTC); |
| 121241 | + nOr = (int)(ppOr-apOr); |
| 120983 | 121242 | |
| 120984 | 121243 | if( rc==SQLITE_OK ){ |
| 120985 | 121244 | rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken); |
| 120986 | 121245 | for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){ |
| 120987 | 121246 | rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken); |
| | @@ -121049,11 +121308,11 @@ |
| 121049 | 121308 | p2 = pOut = pPhrase->doclist.pList; |
| 121050 | 121309 | res = fts3PoslistNearMerge( |
| 121051 | 121310 | &pOut, aTmp, nParam1, nParam2, paPoslist, &p2 |
| 121052 | 121311 | ); |
| 121053 | 121312 | if( res ){ |
| 121054 | | - nNew = (pOut - pPhrase->doclist.pList) - 1; |
| 121313 | + nNew = (int)(pOut - pPhrase->doclist.pList) - 1; |
| 121055 | 121314 | assert( pPhrase->doclist.pList[nNew]=='\0' ); |
| 121056 | 121315 | assert( nNew<=pPhrase->doclist.nList && nNew>0 ); |
| 121057 | 121316 | memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew); |
| 121058 | 121317 | pPhrase->doclist.nList = nNew; |
| 121059 | 121318 | *paPoslist = pPhrase->doclist.pList; |
| | @@ -121774,10 +122033,11 @@ |
| 121774 | 122033 | fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr); |
| 121775 | 122034 | pPhrase->aToken[i].pSegcsr = 0; |
| 121776 | 122035 | } |
| 121777 | 122036 | } |
| 121778 | 122037 | } |
| 122038 | + |
| 121779 | 122039 | |
| 121780 | 122040 | /* |
| 121781 | 122041 | ** Return SQLITE_CORRUPT_VTAB. |
| 121782 | 122042 | */ |
| 121783 | 122043 | #ifdef SQLITE_DEBUG |
| | @@ -121882,13 +122142,13 @@ |
| 121882 | 122142 | ); |
| 121883 | 122143 | return SQLITE_ERROR; |
| 121884 | 122144 | } |
| 121885 | 122145 | |
| 121886 | 122146 | zDb = argv[1]; |
| 121887 | | - nDb = strlen(zDb); |
| 122147 | + nDb = (int)strlen(zDb); |
| 121888 | 122148 | zFts3 = argv[3]; |
| 121889 | | - nFts3 = strlen(zFts3); |
| 122149 | + nFts3 = (int)strlen(zFts3); |
| 121890 | 122150 | |
| 121891 | 122151 | rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA); |
| 121892 | 122152 | if( rc!=SQLITE_OK ) return rc; |
| 121893 | 122153 | |
| 121894 | 122154 | nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2; |
| | @@ -125074,10 +125334,13 @@ |
| 125074 | 125334 | |
| 125075 | 125335 | /* #include <string.h> */ |
| 125076 | 125336 | /* #include <assert.h> */ |
| 125077 | 125337 | /* #include <stdlib.h> */ |
| 125078 | 125338 | |
| 125339 | + |
| 125340 | +#define FTS_MAX_APPENDABLE_HEIGHT 16 |
| 125341 | + |
| 125079 | 125342 | /* |
| 125080 | 125343 | ** When full-text index nodes are loaded from disk, the buffer that they |
| 125081 | 125344 | ** are loaded into has the following number of bytes of padding at the end |
| 125082 | 125345 | ** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer |
| 125083 | 125346 | ** of 920 bytes is allocated for it. |
| | @@ -125112,10 +125375,33 @@ |
| 125112 | 125375 | # define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold |
| 125113 | 125376 | #else |
| 125114 | 125377 | # define FTS3_NODE_CHUNKSIZE (4*1024) |
| 125115 | 125378 | # define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4) |
| 125116 | 125379 | #endif |
| 125380 | + |
| 125381 | +/* |
| 125382 | +** The two values that may be meaningfully bound to the :1 parameter in |
| 125383 | +** statements SQL_REPLACE_STAT and SQL_SELECT_STAT. |
| 125384 | +*/ |
| 125385 | +#define FTS_STAT_DOCTOTAL 0 |
| 125386 | +#define FTS_STAT_INCRMERGEHINT 1 |
| 125387 | +#define FTS_STAT_AUTOINCRMERGE 2 |
| 125388 | + |
| 125389 | +/* |
| 125390 | +** If FTS_LOG_MERGES is defined, call sqlite3_log() to report each automatic |
| 125391 | +** and incremental merge operation that takes place. This is used for |
| 125392 | +** debugging FTS only, it should not usually be turned on in production |
| 125393 | +** systems. |
| 125394 | +*/ |
| 125395 | +#ifdef FTS3_LOG_MERGES |
| 125396 | +static void fts3LogMerge(int nMerge, sqlite3_int64 iAbsLevel){ |
| 125397 | + sqlite3_log(SQLITE_OK, "%d-way merge from level %d", nMerge, (int)iAbsLevel); |
| 125398 | +} |
| 125399 | +#else |
| 125400 | +#define fts3LogMerge(x, y) |
| 125401 | +#endif |
| 125402 | + |
| 125117 | 125403 | |
| 125118 | 125404 | typedef struct PendingList PendingList; |
| 125119 | 125405 | typedef struct SegmentNode SegmentNode; |
| 125120 | 125406 | typedef struct SegmentWriter SegmentWriter; |
| 125121 | 125407 | |
| | @@ -125274,19 +125560,26 @@ |
| 125274 | 125560 | #define SQL_DELETE_SEGMENTS_RANGE 17 |
| 125275 | 125561 | #define SQL_CONTENT_INSERT 18 |
| 125276 | 125562 | #define SQL_DELETE_DOCSIZE 19 |
| 125277 | 125563 | #define SQL_REPLACE_DOCSIZE 20 |
| 125278 | 125564 | #define SQL_SELECT_DOCSIZE 21 |
| 125279 | | -#define SQL_SELECT_DOCTOTAL 22 |
| 125280 | | -#define SQL_REPLACE_DOCTOTAL 23 |
| 125565 | +#define SQL_SELECT_STAT 22 |
| 125566 | +#define SQL_REPLACE_STAT 23 |
| 125281 | 125567 | |
| 125282 | 125568 | #define SQL_SELECT_ALL_PREFIX_LEVEL 24 |
| 125283 | 125569 | #define SQL_DELETE_ALL_TERMS_SEGDIR 25 |
| 125284 | | - |
| 125285 | 125570 | #define SQL_DELETE_SEGDIR_RANGE 26 |
| 125286 | | - |
| 125287 | 125571 | #define SQL_SELECT_ALL_LANGID 27 |
| 125572 | +#define SQL_FIND_MERGE_LEVEL 28 |
| 125573 | +#define SQL_MAX_LEAF_NODE_ESTIMATE 29 |
| 125574 | +#define SQL_DELETE_SEGDIR_ENTRY 30 |
| 125575 | +#define SQL_SHIFT_SEGDIR_ENTRY 31 |
| 125576 | +#define SQL_SELECT_SEGDIR 32 |
| 125577 | +#define SQL_CHOMP_SEGDIR 33 |
| 125578 | +#define SQL_SEGMENT_IS_APPENDABLE 34 |
| 125579 | +#define SQL_SELECT_INDEXES 35 |
| 125580 | +#define SQL_SELECT_MXLEVEL 36 |
| 125288 | 125581 | |
| 125289 | 125582 | /* |
| 125290 | 125583 | ** This function is used to obtain an SQLite prepared statement handle |
| 125291 | 125584 | ** for the statement identified by the second argument. If successful, |
| 125292 | 125585 | ** *pp is set to the requested statement handle and SQLITE_OK returned. |
| | @@ -125311,13 +125604,13 @@ |
| 125311 | 125604 | /* 4 */ "DELETE FROM %Q.'%q_segdir'", |
| 125312 | 125605 | /* 5 */ "DELETE FROM %Q.'%q_docsize'", |
| 125313 | 125606 | /* 6 */ "DELETE FROM %Q.'%q_stat'", |
| 125314 | 125607 | /* 7 */ "SELECT %s WHERE rowid=?", |
| 125315 | 125608 | /* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1", |
| 125316 | | -/* 9 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)", |
| 125609 | +/* 9 */ "REPLACE INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)", |
| 125317 | 125610 | /* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)", |
| 125318 | | -/* 11 */ "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)", |
| 125611 | +/* 11 */ "REPLACE INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)", |
| 125319 | 125612 | |
| 125320 | 125613 | /* Return segments in order from oldest to newest.*/ |
| 125321 | 125614 | /* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root " |
| 125322 | 125615 | "FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC", |
| 125323 | 125616 | /* 13 */ "SELECT idx, start_block, leaves_end_block, end_block, root " |
| | @@ -125331,18 +125624,65 @@ |
| 125331 | 125624 | /* 17 */ "DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?", |
| 125332 | 125625 | /* 18 */ "INSERT INTO %Q.'%q_content' VALUES(%s)", |
| 125333 | 125626 | /* 19 */ "DELETE FROM %Q.'%q_docsize' WHERE docid = ?", |
| 125334 | 125627 | /* 20 */ "REPLACE INTO %Q.'%q_docsize' VALUES(?,?)", |
| 125335 | 125628 | /* 21 */ "SELECT size FROM %Q.'%q_docsize' WHERE docid=?", |
| 125336 | | -/* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=0", |
| 125337 | | -/* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(0,?)", |
| 125629 | +/* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=?", |
| 125630 | +/* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(?,?)", |
| 125338 | 125631 | /* 24 */ "", |
| 125339 | 125632 | /* 25 */ "", |
| 125340 | 125633 | |
| 125341 | 125634 | /* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?", |
| 125342 | 125635 | /* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'", |
| 125343 | 125636 | |
| 125637 | +/* This statement is used to determine which level to read the input from |
| 125638 | +** when performing an incremental merge. It returns the absolute level number |
| 125639 | +** of the oldest level in the db that contains at least ? segments. Or, |
| 125640 | +** if no level in the FTS index contains more than ? segments, the statement |
| 125641 | +** returns zero rows. */ |
| 125642 | +/* 28 */ "SELECT level FROM %Q.'%q_segdir' GROUP BY level HAVING count(*)>=?" |
| 125643 | + " ORDER BY (level %% 1024) ASC LIMIT 1", |
| 125644 | + |
| 125645 | +/* Estimate the upper limit on the number of leaf nodes in a new segment |
| 125646 | +** created by merging the oldest :2 segments from absolute level :1. See |
| 125647 | +** function sqlite3Fts3Incrmerge() for details. */ |
| 125648 | +/* 29 */ "SELECT 2 * total(1 + leaves_end_block - start_block) " |
| 125649 | + " FROM %Q.'%q_segdir' WHERE level = ? AND idx < ?", |
| 125650 | + |
| 125651 | +/* SQL_DELETE_SEGDIR_ENTRY |
| 125652 | +** Delete the %_segdir entry on absolute level :1 with index :2. */ |
| 125653 | +/* 30 */ "DELETE FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?", |
| 125654 | + |
| 125655 | +/* SQL_SHIFT_SEGDIR_ENTRY |
| 125656 | +** Modify the idx value for the segment with idx=:3 on absolute level :2 |
| 125657 | +** to :1. */ |
| 125658 | +/* 31 */ "UPDATE %Q.'%q_segdir' SET idx = ? WHERE level=? AND idx=?", |
| 125659 | + |
| 125660 | +/* SQL_SELECT_SEGDIR |
| 125661 | +** Read a single entry from the %_segdir table. The entry from absolute |
| 125662 | +** level :1 with index value :2. */ |
| 125663 | +/* 32 */ "SELECT idx, start_block, leaves_end_block, end_block, root " |
| 125664 | + "FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?", |
| 125665 | + |
| 125666 | +/* SQL_CHOMP_SEGDIR |
| 125667 | +** Update the start_block (:1) and root (:2) fields of the %_segdir |
| 125668 | +** entry located on absolute level :3 with index :4. */ |
| 125669 | +/* 33 */ "UPDATE %Q.'%q_segdir' SET start_block = ?, root = ?" |
| 125670 | + "WHERE level = ? AND idx = ?", |
| 125671 | + |
| 125672 | +/* SQL_SEGMENT_IS_APPENDABLE |
| 125673 | +** Return a single row if the segment with end_block=? is appendable. Or |
| 125674 | +** no rows otherwise. */ |
| 125675 | +/* 34 */ "SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL", |
| 125676 | + |
| 125677 | +/* SQL_SELECT_INDEXES |
| 125678 | +** Return the list of valid segment indexes for absolute level ? */ |
| 125679 | +/* 35 */ "SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC", |
| 125680 | + |
| 125681 | +/* SQL_SELECT_MXLEVEL |
| 125682 | +** Return the largest relative level in the FTS index or indexes. */ |
| 125683 | +/* 36 */ "SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'" |
| 125344 | 125684 | }; |
| 125345 | 125685 | int rc = SQLITE_OK; |
| 125346 | 125686 | sqlite3_stmt *pStmt; |
| 125347 | 125687 | |
| 125348 | 125688 | assert( SizeofArray(azSql)==SizeofArray(p->aStmt) ); |
| | @@ -125375,27 +125715,23 @@ |
| 125375 | 125715 | } |
| 125376 | 125716 | } |
| 125377 | 125717 | *pp = pStmt; |
| 125378 | 125718 | return rc; |
| 125379 | 125719 | } |
| 125720 | + |
| 125380 | 125721 | |
| 125381 | 125722 | static int fts3SelectDocsize( |
| 125382 | 125723 | Fts3Table *pTab, /* FTS3 table handle */ |
| 125383 | | - int eStmt, /* Either SQL_SELECT_DOCSIZE or DOCTOTAL */ |
| 125384 | 125724 | sqlite3_int64 iDocid, /* Docid to bind for SQL_SELECT_DOCSIZE */ |
| 125385 | 125725 | sqlite3_stmt **ppStmt /* OUT: Statement handle */ |
| 125386 | 125726 | ){ |
| 125387 | 125727 | sqlite3_stmt *pStmt = 0; /* Statement requested from fts3SqlStmt() */ |
| 125388 | 125728 | int rc; /* Return code */ |
| 125389 | 125729 | |
| 125390 | | - assert( eStmt==SQL_SELECT_DOCSIZE || eStmt==SQL_SELECT_DOCTOTAL ); |
| 125391 | | - |
| 125392 | | - rc = fts3SqlStmt(pTab, eStmt, &pStmt, 0); |
| 125730 | + rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0); |
| 125393 | 125731 | if( rc==SQLITE_OK ){ |
| 125394 | | - if( eStmt==SQL_SELECT_DOCSIZE ){ |
| 125395 | | - sqlite3_bind_int64(pStmt, 1, iDocid); |
| 125396 | | - } |
| 125732 | + sqlite3_bind_int64(pStmt, 1, iDocid); |
| 125397 | 125733 | rc = sqlite3_step(pStmt); |
| 125398 | 125734 | if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){ |
| 125399 | 125735 | rc = sqlite3_reset(pStmt); |
| 125400 | 125736 | if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB; |
| 125401 | 125737 | pStmt = 0; |
| | @@ -125410,19 +125746,33 @@ |
| 125410 | 125746 | |
| 125411 | 125747 | SQLITE_PRIVATE int sqlite3Fts3SelectDoctotal( |
| 125412 | 125748 | Fts3Table *pTab, /* Fts3 table handle */ |
| 125413 | 125749 | sqlite3_stmt **ppStmt /* OUT: Statement handle */ |
| 125414 | 125750 | ){ |
| 125415 | | - return fts3SelectDocsize(pTab, SQL_SELECT_DOCTOTAL, 0, ppStmt); |
| 125751 | + sqlite3_stmt *pStmt = 0; |
| 125752 | + int rc; |
| 125753 | + rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0); |
| 125754 | + if( rc==SQLITE_OK ){ |
| 125755 | + sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL); |
| 125756 | + if( sqlite3_step(pStmt)!=SQLITE_ROW |
| 125757 | + || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB |
| 125758 | + ){ |
| 125759 | + rc = sqlite3_reset(pStmt); |
| 125760 | + if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB; |
| 125761 | + pStmt = 0; |
| 125762 | + } |
| 125763 | + } |
| 125764 | + *ppStmt = pStmt; |
| 125765 | + return rc; |
| 125416 | 125766 | } |
| 125417 | 125767 | |
| 125418 | 125768 | SQLITE_PRIVATE int sqlite3Fts3SelectDocsize( |
| 125419 | 125769 | Fts3Table *pTab, /* Fts3 table handle */ |
| 125420 | 125770 | sqlite3_int64 iDocid, /* Docid to read size data for */ |
| 125421 | 125771 | sqlite3_stmt **ppStmt /* OUT: Statement handle */ |
| 125422 | 125772 | ){ |
| 125423 | | - return fts3SelectDocsize(pTab, SQL_SELECT_DOCSIZE, iDocid, ppStmt); |
| 125773 | + return fts3SelectDocsize(pTab, iDocid, ppStmt); |
| 125424 | 125774 | } |
| 125425 | 125775 | |
| 125426 | 125776 | /* |
| 125427 | 125777 | ** Similar to fts3SqlStmt(). Except, after binding the parameters in |
| 125428 | 125778 | ** array apVal[] to the SQL statement identified by eStmt, the statement |
| | @@ -125484,22 +125834,47 @@ |
| 125484 | 125834 | } |
| 125485 | 125835 | |
| 125486 | 125836 | return rc; |
| 125487 | 125837 | } |
| 125488 | 125838 | |
| 125839 | +/* |
| 125840 | +** FTS maintains a separate indexes for each language-id (a 32-bit integer). |
| 125841 | +** Within each language id, a separate index is maintained to store the |
| 125842 | +** document terms, and each configured prefix size (configured the FTS |
| 125843 | +** "prefix=" option). And each index consists of multiple levels ("relative |
| 125844 | +** levels"). |
| 125845 | +** |
| 125846 | +** All three of these values (the language id, the specific index and the |
| 125847 | +** level within the index) are encoded in 64-bit integer values stored |
| 125848 | +** in the %_segdir table on disk. This function is used to convert three |
| 125849 | +** separate component values into the single 64-bit integer value that |
| 125850 | +** can be used to query the %_segdir table. |
| 125851 | +** |
| 125852 | +** Specifically, each language-id/index combination is allocated 1024 |
| 125853 | +** 64-bit integer level values ("absolute levels"). The main terms index |
| 125854 | +** for language-id 0 is allocate values 0-1023. The first prefix index |
| 125855 | +** (if any) for language-id 0 is allocated values 1024-2047. And so on. |
| 125856 | +** Language 1 indexes are allocated immediately following language 0. |
| 125857 | +** |
| 125858 | +** So, for a system with nPrefix prefix indexes configured, the block of |
| 125859 | +** absolute levels that corresponds to language-id iLangid and index |
| 125860 | +** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024). |
| 125861 | +*/ |
| 125489 | 125862 | static sqlite3_int64 getAbsoluteLevel( |
| 125490 | | - Fts3Table *p, |
| 125491 | | - int iLangid, |
| 125492 | | - int iIndex, |
| 125493 | | - int iLevel |
| 125863 | + Fts3Table *p, /* FTS3 table handle */ |
| 125864 | + int iLangid, /* Language id */ |
| 125865 | + int iIndex, /* Index in p->aIndex[] */ |
| 125866 | + int iLevel /* Level of segments */ |
| 125494 | 125867 | ){ |
| 125868 | + sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */ |
| 125495 | 125869 | assert( iLangid>=0 ); |
| 125496 | 125870 | assert( p->nIndex>0 ); |
| 125497 | 125871 | assert( iIndex>=0 && iIndex<p->nIndex ); |
| 125498 | | - return (iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL + iLevel; |
| 125872 | + |
| 125873 | + iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL; |
| 125874 | + return iBase + iLevel; |
| 125499 | 125875 | } |
| 125500 | | - |
| 125501 | 125876 | |
| 125502 | 125877 | /* |
| 125503 | 125878 | ** Set *ppStmt to a statement handle that may be used to iterate through |
| 125504 | 125879 | ** all rows in the %_segdir table, from oldest to newest. If successful, |
| 125505 | 125880 | ** return SQLITE_OK. If an error occurs while preparing the statement, |
| | @@ -125518,11 +125893,11 @@ |
| 125518 | 125893 | */ |
| 125519 | 125894 | SQLITE_PRIVATE int sqlite3Fts3AllSegdirs( |
| 125520 | 125895 | Fts3Table *p, /* FTS3 table */ |
| 125521 | 125896 | int iLangid, /* Language being queried */ |
| 125522 | 125897 | int iIndex, /* Index for p->aIndex[] */ |
| 125523 | | - int iLevel, /* Level to select */ |
| 125898 | + int iLevel, /* Level to select (relative level) */ |
| 125524 | 125899 | sqlite3_stmt **ppStmt /* OUT: Compiled statement */ |
| 125525 | 125900 | ){ |
| 125526 | 125901 | int rc; |
| 125527 | 125902 | sqlite3_stmt *pStmt = 0; |
| 125528 | 125903 | |
| | @@ -125533,19 +125908,19 @@ |
| 125533 | 125908 | if( iLevel<0 ){ |
| 125534 | 125909 | /* "SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ..." */ |
| 125535 | 125910 | rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0); |
| 125536 | 125911 | if( rc==SQLITE_OK ){ |
| 125537 | 125912 | sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); |
| 125538 | | - sqlite3_bind_int(pStmt, 2, |
| 125913 | + sqlite3_bind_int64(pStmt, 2, |
| 125539 | 125914 | getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1) |
| 125540 | 125915 | ); |
| 125541 | 125916 | } |
| 125542 | 125917 | }else{ |
| 125543 | 125918 | /* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */ |
| 125544 | 125919 | rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0); |
| 125545 | 125920 | if( rc==SQLITE_OK ){ |
| 125546 | | - sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)); |
| 125921 | + sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel)); |
| 125547 | 125922 | } |
| 125548 | 125923 | } |
| 125549 | 125924 | *ppStmt = pStmt; |
| 125550 | 125925 | return rc; |
| 125551 | 125926 | } |
| | @@ -126062,10 +126437,11 @@ |
| 126062 | 126437 | ** full, merge all segments in level iLevel into a single iLevel+1 |
| 126063 | 126438 | ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise, |
| 126064 | 126439 | ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext. |
| 126065 | 126440 | */ |
| 126066 | 126441 | if( iNext>=FTS3_MERGE_COUNT ){ |
| 126442 | + fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel)); |
| 126067 | 126443 | rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel); |
| 126068 | 126444 | *piIdx = 0; |
| 126069 | 126445 | }else{ |
| 126070 | 126446 | *piIdx = iNext; |
| 126071 | 126447 | } |
| | @@ -126109,11 +126485,11 @@ |
| 126109 | 126485 | int *pnLoad /* OUT: Bytes actually loaded */ |
| 126110 | 126486 | ){ |
| 126111 | 126487 | int rc; /* Return code */ |
| 126112 | 126488 | |
| 126113 | 126489 | /* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */ |
| 126114 | | - assert( pnBlob); |
| 126490 | + assert( pnBlob ); |
| 126115 | 126491 | |
| 126116 | 126492 | if( p->pSegments ){ |
| 126117 | 126493 | rc = sqlite3_blob_reopen(p->pSegments, iBlockid); |
| 126118 | 126494 | }else{ |
| 126119 | 126495 | if( 0==p->zSegmentsTbl ){ |
| | @@ -126450,11 +126826,11 @@ |
| 126450 | 126826 | int nOvfl = 0; |
| 126451 | 126827 | int ii; |
| 126452 | 126828 | int rc = SQLITE_OK; |
| 126453 | 126829 | int pgsz = p->nPgsz; |
| 126454 | 126830 | |
| 126455 | | - assert( p->bHasStat ); |
| 126831 | + assert( p->bFts4 ); |
| 126456 | 126832 | assert( pgsz>0 ); |
| 126457 | 126833 | |
| 126458 | 126834 | for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){ |
| 126459 | 126835 | Fts3SegReader *pReader = pMsr->apSegment[ii]; |
| 126460 | 126836 | if( !fts3SegReaderIsPending(pReader) |
| | @@ -126807,17 +127183,38 @@ |
| 126807 | 127183 | sqlite3_step(pStmt); |
| 126808 | 127184 | rc = sqlite3_reset(pStmt); |
| 126809 | 127185 | } |
| 126810 | 127186 | return rc; |
| 126811 | 127187 | } |
| 127188 | + |
| 127189 | +/* |
| 127190 | +** Find the largest relative level number in the table. If successful, set |
| 127191 | +** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs, |
| 127192 | +** set *pnMax to zero and return an SQLite error code. |
| 127193 | +*/ |
| 127194 | +SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){ |
| 127195 | + int rc; |
| 127196 | + int mxLevel = 0; |
| 127197 | + sqlite3_stmt *pStmt = 0; |
| 127198 | + |
| 127199 | + rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0); |
| 127200 | + if( rc==SQLITE_OK ){ |
| 127201 | + if( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 127202 | + mxLevel = sqlite3_column_int(pStmt, 0); |
| 127203 | + } |
| 127204 | + rc = sqlite3_reset(pStmt); |
| 127205 | + } |
| 127206 | + *pnMax = mxLevel; |
| 127207 | + return rc; |
| 127208 | +} |
| 126812 | 127209 | |
| 126813 | 127210 | /* |
| 126814 | 127211 | ** Insert a record into the %_segdir table. |
| 126815 | 127212 | */ |
| 126816 | 127213 | static int fts3WriteSegdir( |
| 126817 | 127214 | Fts3Table *p, /* Virtual table handle */ |
| 126818 | | - int iLevel, /* Value for "level" field */ |
| 127215 | + sqlite3_int64 iLevel, /* Value for "level" field (absolute level) */ |
| 126819 | 127216 | int iIdx, /* Value for "idx" field */ |
| 126820 | 127217 | sqlite3_int64 iStartBlock, /* Value for "start_block" field */ |
| 126821 | 127218 | sqlite3_int64 iLeafEndBlock, /* Value for "leaves_end_block" field */ |
| 126822 | 127219 | sqlite3_int64 iEndBlock, /* Value for "end_block" field */ |
| 126823 | 127220 | char *zRoot, /* Blob value for "root" field */ |
| | @@ -126824,11 +127221,11 @@ |
| 126824 | 127221 | int nRoot /* Number of bytes in buffer zRoot */ |
| 126825 | 127222 | ){ |
| 126826 | 127223 | sqlite3_stmt *pStmt; |
| 126827 | 127224 | int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0); |
| 126828 | 127225 | if( rc==SQLITE_OK ){ |
| 126829 | | - sqlite3_bind_int(pStmt, 1, iLevel); |
| 127226 | + sqlite3_bind_int64(pStmt, 1, iLevel); |
| 126830 | 127227 | sqlite3_bind_int(pStmt, 2, iIdx); |
| 126831 | 127228 | sqlite3_bind_int64(pStmt, 3, iStartBlock); |
| 126832 | 127229 | sqlite3_bind_int64(pStmt, 4, iLeafEndBlock); |
| 126833 | 127230 | sqlite3_bind_int64(pStmt, 5, iEndBlock); |
| 126834 | 127231 | sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC); |
| | @@ -127124,10 +127521,11 @@ |
| 127124 | 127521 | int rc; |
| 127125 | 127522 | |
| 127126 | 127523 | /* The current leaf node is full. Write it out to the database. */ |
| 127127 | 127524 | rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData); |
| 127128 | 127525 | if( rc!=SQLITE_OK ) return rc; |
| 127526 | + p->nLeafAdd++; |
| 127129 | 127527 | |
| 127130 | 127528 | /* Add the current term to the interior node tree. The term added to |
| 127131 | 127529 | ** the interior tree must: |
| 127132 | 127530 | ** |
| 127133 | 127531 | ** a) be greater than the largest term on the leaf node just written |
| | @@ -127207,11 +127605,11 @@ |
| 127207 | 127605 | ** returned. Otherwise, an SQLite error code. |
| 127208 | 127606 | */ |
| 127209 | 127607 | static int fts3SegWriterFlush( |
| 127210 | 127608 | Fts3Table *p, /* Virtual table handle */ |
| 127211 | 127609 | SegmentWriter *pWriter, /* SegmentWriter to flush to the db */ |
| 127212 | | - int iLevel, /* Value for 'level' column of %_segdir */ |
| 127610 | + sqlite3_int64 iLevel, /* Value for 'level' column of %_segdir */ |
| 127213 | 127611 | int iIdx /* Value for 'idx' column of %_segdir */ |
| 127214 | 127612 | ){ |
| 127215 | 127613 | int rc; /* Return code */ |
| 127216 | 127614 | if( pWriter->pTree ){ |
| 127217 | 127615 | sqlite3_int64 iLast = 0; /* Largest block id written to database */ |
| | @@ -127232,10 +127630,11 @@ |
| 127232 | 127630 | }else{ |
| 127233 | 127631 | /* The entire tree fits on the root node. Write it to the segdir table. */ |
| 127234 | 127632 | rc = fts3WriteSegdir( |
| 127235 | 127633 | p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData); |
| 127236 | 127634 | } |
| 127635 | + p->nLeafAdd++; |
| 127237 | 127636 | return rc; |
| 127238 | 127637 | } |
| 127239 | 127638 | |
| 127240 | 127639 | /* |
| 127241 | 127640 | ** Release all memory held by the SegmentWriter object passed as the |
| | @@ -127289,11 +127688,11 @@ |
| 127289 | 127688 | */ |
| 127290 | 127689 | static int fts3SegmentMaxLevel( |
| 127291 | 127690 | Fts3Table *p, |
| 127292 | 127691 | int iLangid, |
| 127293 | 127692 | int iIndex, |
| 127294 | | - int *pnMax |
| 127693 | + sqlite3_int64 *pnMax |
| 127295 | 127694 | ){ |
| 127296 | 127695 | sqlite3_stmt *pStmt; |
| 127297 | 127696 | int rc; |
| 127298 | 127697 | assert( iIndex>=0 && iIndex<p->nIndex ); |
| 127299 | 127698 | |
| | @@ -127303,19 +127702,42 @@ |
| 127303 | 127702 | ** |
| 127304 | 127703 | ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR). |
| 127305 | 127704 | */ |
| 127306 | 127705 | rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0); |
| 127307 | 127706 | if( rc!=SQLITE_OK ) return rc; |
| 127308 | | - sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); |
| 127309 | | - sqlite3_bind_int(pStmt, 2, |
| 127707 | + sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); |
| 127708 | + sqlite3_bind_int64(pStmt, 2, |
| 127310 | 127709 | getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1) |
| 127311 | 127710 | ); |
| 127312 | 127711 | if( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 127313 | | - *pnMax = sqlite3_column_int(pStmt, 0); |
| 127712 | + *pnMax = sqlite3_column_int64(pStmt, 0); |
| 127314 | 127713 | } |
| 127315 | 127714 | return sqlite3_reset(pStmt); |
| 127316 | 127715 | } |
| 127716 | + |
| 127717 | +/* |
| 127718 | +** Delete all entries in the %_segments table associated with the segment |
| 127719 | +** opened with seg-reader pSeg. This function does not affect the contents |
| 127720 | +** of the %_segdir table. |
| 127721 | +*/ |
| 127722 | +static int fts3DeleteSegment( |
| 127723 | + Fts3Table *p, /* FTS table handle */ |
| 127724 | + Fts3SegReader *pSeg /* Segment to delete */ |
| 127725 | +){ |
| 127726 | + int rc = SQLITE_OK; /* Return code */ |
| 127727 | + if( pSeg->iStartBlock ){ |
| 127728 | + sqlite3_stmt *pDelete; /* SQL statement to delete rows */ |
| 127729 | + rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0); |
| 127730 | + if( rc==SQLITE_OK ){ |
| 127731 | + sqlite3_bind_int64(pDelete, 1, pSeg->iStartBlock); |
| 127732 | + sqlite3_bind_int64(pDelete, 2, pSeg->iEndBlock); |
| 127733 | + sqlite3_step(pDelete); |
| 127734 | + rc = sqlite3_reset(pDelete); |
| 127735 | + } |
| 127736 | + } |
| 127737 | + return rc; |
| 127738 | +} |
| 127317 | 127739 | |
| 127318 | 127740 | /* |
| 127319 | 127741 | ** This function is used after merging multiple segments into a single large |
| 127320 | 127742 | ** segment to delete the old, now redundant, segment b-trees. Specifically, |
| 127321 | 127743 | ** it: |
| | @@ -127335,41 +127757,36 @@ |
| 127335 | 127757 | int iIndex, /* Index for p->aIndex */ |
| 127336 | 127758 | int iLevel, /* Level of %_segdir entries to delete */ |
| 127337 | 127759 | Fts3SegReader **apSegment, /* Array of SegReader objects */ |
| 127338 | 127760 | int nReader /* Size of array apSegment */ |
| 127339 | 127761 | ){ |
| 127340 | | - int rc; /* Return Code */ |
| 127762 | + int rc = SQLITE_OK; /* Return Code */ |
| 127341 | 127763 | int i; /* Iterator variable */ |
| 127342 | | - sqlite3_stmt *pDelete; /* SQL statement to delete rows */ |
| 127764 | + sqlite3_stmt *pDelete = 0; /* SQL statement to delete rows */ |
| 127343 | 127765 | |
| 127344 | | - rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0); |
| 127345 | 127766 | for(i=0; rc==SQLITE_OK && i<nReader; i++){ |
| 127346 | | - Fts3SegReader *pSegment = apSegment[i]; |
| 127347 | | - if( pSegment->iStartBlock ){ |
| 127348 | | - sqlite3_bind_int64(pDelete, 1, pSegment->iStartBlock); |
| 127349 | | - sqlite3_bind_int64(pDelete, 2, pSegment->iEndBlock); |
| 127350 | | - sqlite3_step(pDelete); |
| 127351 | | - rc = sqlite3_reset(pDelete); |
| 127352 | | - } |
| 127767 | + rc = fts3DeleteSegment(p, apSegment[i]); |
| 127353 | 127768 | } |
| 127354 | 127769 | if( rc!=SQLITE_OK ){ |
| 127355 | 127770 | return rc; |
| 127356 | 127771 | } |
| 127357 | 127772 | |
| 127358 | 127773 | assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL ); |
| 127359 | 127774 | if( iLevel==FTS3_SEGCURSOR_ALL ){ |
| 127360 | 127775 | rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0); |
| 127361 | 127776 | if( rc==SQLITE_OK ){ |
| 127362 | | - sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); |
| 127363 | | - sqlite3_bind_int(pDelete, 2, |
| 127777 | + sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0)); |
| 127778 | + sqlite3_bind_int64(pDelete, 2, |
| 127364 | 127779 | getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1) |
| 127365 | 127780 | ); |
| 127366 | 127781 | } |
| 127367 | 127782 | }else{ |
| 127368 | 127783 | rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0); |
| 127369 | 127784 | if( rc==SQLITE_OK ){ |
| 127370 | | - sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel)); |
| 127785 | + sqlite3_bind_int64( |
| 127786 | + pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel) |
| 127787 | + ); |
| 127371 | 127788 | } |
| 127372 | 127789 | } |
| 127373 | 127790 | |
| 127374 | 127791 | if( rc==SQLITE_OK ){ |
| 127375 | 127792 | sqlite3_step(pDelete); |
| | @@ -127842,11 +128259,11 @@ |
| 127842 | 128259 | int iIndex, /* Index in p->aIndex[] to merge */ |
| 127843 | 128260 | int iLevel /* Level to merge */ |
| 127844 | 128261 | ){ |
| 127845 | 128262 | int rc; /* Return code */ |
| 127846 | 128263 | int iIdx = 0; /* Index of new segment */ |
| 127847 | | - int iNewLevel = 0; /* Level/index to create new segment at */ |
| 128264 | + sqlite3_int64 iNewLevel = 0; /* Level/index to create new segment at */ |
| 127848 | 128265 | SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */ |
| 127849 | 128266 | Fts3SegFilter filter; /* Segment term filter condition */ |
| 127850 | 128267 | Fts3MultiSegReader csr; /* Cursor to iterate through level(s) */ |
| 127851 | 128268 | int bIgnoreEmpty = 0; /* True to ignore empty segments */ |
| 127852 | 128269 | |
| | @@ -127921,15 +128338,32 @@ |
| 127921 | 128338 | ** Flush the contents of pendingTerms to level 0 segments. |
| 127922 | 128339 | */ |
| 127923 | 128340 | SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){ |
| 127924 | 128341 | int rc = SQLITE_OK; |
| 127925 | 128342 | int i; |
| 128343 | + |
| 127926 | 128344 | for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){ |
| 127927 | 128345 | rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING); |
| 127928 | 128346 | if( rc==SQLITE_DONE ) rc = SQLITE_OK; |
| 127929 | 128347 | } |
| 127930 | 128348 | sqlite3Fts3PendingTermsClear(p); |
| 128349 | + |
| 128350 | + /* Determine the auto-incr-merge setting if unknown. If enabled, |
| 128351 | + ** estimate the number of leaf blocks of content to be written |
| 128352 | + */ |
| 128353 | + if( rc==SQLITE_OK && p->bHasStat |
| 128354 | + && p->bAutoincrmerge==0xff && p->nLeafAdd>0 |
| 128355 | + ){ |
| 128356 | + sqlite3_stmt *pStmt = 0; |
| 128357 | + rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0); |
| 128358 | + if( rc==SQLITE_OK ){ |
| 128359 | + sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE); |
| 128360 | + rc = sqlite3_step(pStmt); |
| 128361 | + p->bAutoincrmerge = (rc==SQLITE_ROW && sqlite3_column_int(pStmt, 0)); |
| 128362 | + rc = sqlite3_reset(pStmt); |
| 128363 | + } |
| 128364 | + } |
| 127931 | 128365 | return rc; |
| 127932 | 128366 | } |
| 127933 | 128367 | |
| 127934 | 128368 | /* |
| 127935 | 128369 | ** Encode N integers as varints into a blob. |
| | @@ -128036,16 +128470,17 @@ |
| 128036 | 128470 | if( a==0 ){ |
| 128037 | 128471 | *pRC = SQLITE_NOMEM; |
| 128038 | 128472 | return; |
| 128039 | 128473 | } |
| 128040 | 128474 | pBlob = (char*)&a[nStat]; |
| 128041 | | - rc = fts3SqlStmt(p, SQL_SELECT_DOCTOTAL, &pStmt, 0); |
| 128475 | + rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0); |
| 128042 | 128476 | if( rc ){ |
| 128043 | 128477 | sqlite3_free(a); |
| 128044 | 128478 | *pRC = rc; |
| 128045 | 128479 | return; |
| 128046 | 128480 | } |
| 128481 | + sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL); |
| 128047 | 128482 | if( sqlite3_step(pStmt)==SQLITE_ROW ){ |
| 128048 | 128483 | fts3DecodeIntArray(nStat, a, |
| 128049 | 128484 | sqlite3_column_blob(pStmt, 0), |
| 128050 | 128485 | sqlite3_column_bytes(pStmt, 0)); |
| 128051 | 128486 | }else{ |
| | @@ -128065,17 +128500,18 @@ |
| 128065 | 128500 | x = x + aSzIns[i] - aSzDel[i]; |
| 128066 | 128501 | } |
| 128067 | 128502 | a[i+1] = x; |
| 128068 | 128503 | } |
| 128069 | 128504 | fts3EncodeIntArray(nStat, a, pBlob, &nBlob); |
| 128070 | | - rc = fts3SqlStmt(p, SQL_REPLACE_DOCTOTAL, &pStmt, 0); |
| 128505 | + rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0); |
| 128071 | 128506 | if( rc ){ |
| 128072 | 128507 | sqlite3_free(a); |
| 128073 | 128508 | *pRC = rc; |
| 128074 | 128509 | return; |
| 128075 | 128510 | } |
| 128076 | | - sqlite3_bind_blob(pStmt, 1, pBlob, nBlob, SQLITE_STATIC); |
| 128511 | + sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL); |
| 128512 | + sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC); |
| 128077 | 128513 | sqlite3_step(pStmt); |
| 128078 | 128514 | *pRC = sqlite3_reset(pStmt); |
| 128079 | 128515 | sqlite3_free(a); |
| 128080 | 128516 | } |
| 128081 | 128517 | |
| | @@ -128176,11 +128612,11 @@ |
| 128176 | 128612 | for(iCol=0; iCol<=p->nColumn; iCol++){ |
| 128177 | 128613 | aSzIns[iCol] += aSz[iCol]; |
| 128178 | 128614 | } |
| 128179 | 128615 | } |
| 128180 | 128616 | } |
| 128181 | | - if( p->bHasStat ){ |
| 128617 | + if( p->bFts4 ){ |
| 128182 | 128618 | fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry); |
| 128183 | 128619 | } |
| 128184 | 128620 | sqlite3_free(aSz); |
| 128185 | 128621 | |
| 128186 | 128622 | if( pStmt ){ |
| | @@ -128192,10 +128628,1692 @@ |
| 128192 | 128628 | } |
| 128193 | 128629 | |
| 128194 | 128630 | return rc; |
| 128195 | 128631 | } |
| 128196 | 128632 | |
| 128633 | + |
| 128634 | +/* |
| 128635 | +** This function opens a cursor used to read the input data for an |
| 128636 | +** incremental merge operation. Specifically, it opens a cursor to scan |
| 128637 | +** the oldest nSeg segments (idx=0 through idx=(nSeg-1)) in absolute |
| 128638 | +** level iAbsLevel. |
| 128639 | +*/ |
| 128640 | +static int fts3IncrmergeCsr( |
| 128641 | + Fts3Table *p, /* FTS3 table handle */ |
| 128642 | + sqlite3_int64 iAbsLevel, /* Absolute level to open */ |
| 128643 | + int nSeg, /* Number of segments to merge */ |
| 128644 | + Fts3MultiSegReader *pCsr /* Cursor object to populate */ |
| 128645 | +){ |
| 128646 | + int rc; /* Return Code */ |
| 128647 | + sqlite3_stmt *pStmt = 0; /* Statement used to read %_segdir entry */ |
| 128648 | + int nByte; /* Bytes allocated at pCsr->apSegment[] */ |
| 128649 | + |
| 128650 | + /* Allocate space for the Fts3MultiSegReader.aCsr[] array */ |
| 128651 | + memset(pCsr, 0, sizeof(*pCsr)); |
| 128652 | + nByte = sizeof(Fts3SegReader *) * nSeg; |
| 128653 | + pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte); |
| 128654 | + |
| 128655 | + if( pCsr->apSegment==0 ){ |
| 128656 | + rc = SQLITE_NOMEM; |
| 128657 | + }else{ |
| 128658 | + memset(pCsr->apSegment, 0, nByte); |
| 128659 | + rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0); |
| 128660 | + } |
| 128661 | + if( rc==SQLITE_OK ){ |
| 128662 | + int i; |
| 128663 | + int rc2; |
| 128664 | + sqlite3_bind_int64(pStmt, 1, iAbsLevel); |
| 128665 | + assert( pCsr->nSegment==0 ); |
| 128666 | + for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){ |
| 128667 | + rc = sqlite3Fts3SegReaderNew(i, 0, |
| 128668 | + sqlite3_column_int64(pStmt, 1), /* segdir.start_block */ |
| 128669 | + sqlite3_column_int64(pStmt, 2), /* segdir.leaves_end_block */ |
| 128670 | + sqlite3_column_int64(pStmt, 3), /* segdir.end_block */ |
| 128671 | + sqlite3_column_blob(pStmt, 4), /* segdir.root */ |
| 128672 | + sqlite3_column_bytes(pStmt, 4), /* segdir.root */ |
| 128673 | + &pCsr->apSegment[i] |
| 128674 | + ); |
| 128675 | + pCsr->nSegment++; |
| 128676 | + } |
| 128677 | + rc2 = sqlite3_reset(pStmt); |
| 128678 | + if( rc==SQLITE_OK ) rc = rc2; |
| 128679 | + } |
| 128680 | + |
| 128681 | + return rc; |
| 128682 | +} |
| 128683 | + |
| 128684 | +typedef struct IncrmergeWriter IncrmergeWriter; |
| 128685 | +typedef struct NodeWriter NodeWriter; |
| 128686 | +typedef struct Blob Blob; |
| 128687 | +typedef struct NodeReader NodeReader; |
| 128688 | + |
| 128689 | +/* |
| 128690 | +** An instance of the following structure is used as a dynamic buffer |
| 128691 | +** to build up nodes or other blobs of data in. |
| 128692 | +** |
| 128693 | +** The function blobGrowBuffer() is used to extend the allocation. |
| 128694 | +*/ |
| 128695 | +struct Blob { |
| 128696 | + char *a; /* Pointer to allocation */ |
| 128697 | + int n; /* Number of valid bytes of data in a[] */ |
| 128698 | + int nAlloc; /* Allocated size of a[] (nAlloc>=n) */ |
| 128699 | +}; |
| 128700 | + |
| 128701 | +/* |
| 128702 | +** This structure is used to build up buffers containing segment b-tree |
| 128703 | +** nodes (blocks). |
| 128704 | +*/ |
| 128705 | +struct NodeWriter { |
| 128706 | + sqlite3_int64 iBlock; /* Current block id */ |
| 128707 | + Blob key; /* Last key written to the current block */ |
| 128708 | + Blob block; /* Current block image */ |
| 128709 | +}; |
| 128710 | + |
| 128711 | +/* |
| 128712 | +** An object of this type contains the state required to create or append |
| 128713 | +** to an appendable b-tree segment. |
| 128714 | +*/ |
| 128715 | +struct IncrmergeWriter { |
| 128716 | + int nLeafEst; /* Space allocated for leaf blocks */ |
| 128717 | + int nWork; /* Number of leaf pages flushed */ |
| 128718 | + sqlite3_int64 iAbsLevel; /* Absolute level of input segments */ |
| 128719 | + int iIdx; /* Index of *output* segment in iAbsLevel+1 */ |
| 128720 | + sqlite3_int64 iStart; /* Block number of first allocated block */ |
| 128721 | + sqlite3_int64 iEnd; /* Block number of last allocated block */ |
| 128722 | + NodeWriter aNodeWriter[FTS_MAX_APPENDABLE_HEIGHT]; |
| 128723 | +}; |
| 128724 | + |
| 128725 | +/* |
| 128726 | +** An object of the following type is used to read data from a single |
| 128727 | +** FTS segment node. See the following functions: |
| 128728 | +** |
| 128729 | +** nodeReaderInit() |
| 128730 | +** nodeReaderNext() |
| 128731 | +** nodeReaderRelease() |
| 128732 | +*/ |
| 128733 | +struct NodeReader { |
| 128734 | + const char *aNode; |
| 128735 | + int nNode; |
| 128736 | + int iOff; /* Current offset within aNode[] */ |
| 128737 | + |
| 128738 | + /* Output variables. Containing the current node entry. */ |
| 128739 | + sqlite3_int64 iChild; /* Pointer to child node */ |
| 128740 | + Blob term; /* Current term */ |
| 128741 | + const char *aDoclist; /* Pointer to doclist */ |
| 128742 | + int nDoclist; /* Size of doclist in bytes */ |
| 128743 | +}; |
| 128744 | + |
| 128745 | +/* |
| 128746 | +** If *pRc is not SQLITE_OK when this function is called, it is a no-op. |
| 128747 | +** Otherwise, if the allocation at pBlob->a is not already at least nMin |
| 128748 | +** bytes in size, extend (realloc) it to be so. |
| 128749 | +** |
| 128750 | +** If an OOM error occurs, set *pRc to SQLITE_NOMEM and leave pBlob->a |
| 128751 | +** unmodified. Otherwise, if the allocation succeeds, update pBlob->nAlloc |
| 128752 | +** to reflect the new size of the pBlob->a[] buffer. |
| 128753 | +*/ |
| 128754 | +static void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){ |
| 128755 | + if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){ |
| 128756 | + int nAlloc = nMin; |
| 128757 | + char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc); |
| 128758 | + if( a ){ |
| 128759 | + pBlob->nAlloc = nAlloc; |
| 128760 | + pBlob->a = a; |
| 128761 | + }else{ |
| 128762 | + *pRc = SQLITE_NOMEM; |
| 128763 | + } |
| 128764 | + } |
| 128765 | +} |
| 128766 | + |
| 128767 | +/* |
| 128768 | +** Attempt to advance the node-reader object passed as the first argument to |
| 128769 | +** the next entry on the node. |
| 128770 | +** |
| 128771 | +** Return an error code if an error occurs (SQLITE_NOMEM is possible). |
| 128772 | +** Otherwise return SQLITE_OK. If there is no next entry on the node |
| 128773 | +** (e.g. because the current entry is the last) set NodeReader->aNode to |
| 128774 | +** NULL to indicate EOF. Otherwise, populate the NodeReader structure output |
| 128775 | +** variables for the new entry. |
| 128776 | +*/ |
| 128777 | +static int nodeReaderNext(NodeReader *p){ |
| 128778 | + int bFirst = (p->term.n==0); /* True for first term on the node */ |
| 128779 | + int nPrefix = 0; /* Bytes to copy from previous term */ |
| 128780 | + int nSuffix = 0; /* Bytes to append to the prefix */ |
| 128781 | + int rc = SQLITE_OK; /* Return code */ |
| 128782 | + |
| 128783 | + assert( p->aNode ); |
| 128784 | + if( p->iChild && bFirst==0 ) p->iChild++; |
| 128785 | + if( p->iOff>=p->nNode ){ |
| 128786 | + /* EOF */ |
| 128787 | + p->aNode = 0; |
| 128788 | + }else{ |
| 128789 | + if( bFirst==0 ){ |
| 128790 | + p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nPrefix); |
| 128791 | + } |
| 128792 | + p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nSuffix); |
| 128793 | + |
| 128794 | + blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc); |
| 128795 | + if( rc==SQLITE_OK ){ |
| 128796 | + memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix); |
| 128797 | + p->term.n = nPrefix+nSuffix; |
| 128798 | + p->iOff += nSuffix; |
| 128799 | + if( p->iChild==0 ){ |
| 128800 | + p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist); |
| 128801 | + p->aDoclist = &p->aNode[p->iOff]; |
| 128802 | + p->iOff += p->nDoclist; |
| 128803 | + } |
| 128804 | + } |
| 128805 | + } |
| 128806 | + |
| 128807 | + assert( p->iOff<=p->nNode ); |
| 128808 | + |
| 128809 | + return rc; |
| 128810 | +} |
| 128811 | + |
| 128812 | +/* |
| 128813 | +** Release all dynamic resources held by node-reader object *p. |
| 128814 | +*/ |
| 128815 | +static void nodeReaderRelease(NodeReader *p){ |
| 128816 | + sqlite3_free(p->term.a); |
| 128817 | +} |
| 128818 | + |
| 128819 | +/* |
| 128820 | +** Initialize a node-reader object to read the node in buffer aNode/nNode. |
| 128821 | +** |
| 128822 | +** If successful, SQLITE_OK is returned and the NodeReader object set to |
| 128823 | +** point to the first entry on the node (if any). Otherwise, an SQLite |
| 128824 | +** error code is returned. |
| 128825 | +*/ |
| 128826 | +static int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){ |
| 128827 | + memset(p, 0, sizeof(NodeReader)); |
| 128828 | + p->aNode = aNode; |
| 128829 | + p->nNode = nNode; |
| 128830 | + |
| 128831 | + /* Figure out if this is a leaf or an internal node. */ |
| 128832 | + if( p->aNode[0] ){ |
| 128833 | + /* An internal node. */ |
| 128834 | + p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild); |
| 128835 | + }else{ |
| 128836 | + p->iOff = 1; |
| 128837 | + } |
| 128838 | + |
| 128839 | + return nodeReaderNext(p); |
| 128840 | +} |
| 128841 | + |
| 128842 | +/* |
| 128843 | +** This function is called while writing an FTS segment each time a leaf o |
| 128844 | +** node is finished and written to disk. The key (zTerm/nTerm) is guaranteed |
| 128845 | +** to be greater than the largest key on the node just written, but smaller |
| 128846 | +** than or equal to the first key that will be written to the next leaf |
| 128847 | +** node. |
| 128848 | +** |
| 128849 | +** The block id of the leaf node just written to disk may be found in |
| 128850 | +** (pWriter->aNodeWriter[0].iBlock) when this function is called. |
| 128851 | +*/ |
| 128852 | +static int fts3IncrmergePush( |
| 128853 | + Fts3Table *p, /* Fts3 table handle */ |
| 128854 | + IncrmergeWriter *pWriter, /* Writer object */ |
| 128855 | + const char *zTerm, /* Term to write to internal node */ |
| 128856 | + int nTerm /* Bytes at zTerm */ |
| 128857 | +){ |
| 128858 | + sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock; |
| 128859 | + int iLayer; |
| 128860 | + |
| 128861 | + assert( nTerm>0 ); |
| 128862 | + for(iLayer=1; ALWAYS(iLayer<FTS_MAX_APPENDABLE_HEIGHT); iLayer++){ |
| 128863 | + sqlite3_int64 iNextPtr = 0; |
| 128864 | + NodeWriter *pNode = &pWriter->aNodeWriter[iLayer]; |
| 128865 | + int rc = SQLITE_OK; |
| 128866 | + int nPrefix; |
| 128867 | + int nSuffix; |
| 128868 | + int nSpace; |
| 128869 | + |
| 128870 | + /* Figure out how much space the key will consume if it is written to |
| 128871 | + ** the current node of layer iLayer. Due to the prefix compression, |
| 128872 | + ** the space required changes depending on which node the key is to |
| 128873 | + ** be added to. */ |
| 128874 | + nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm); |
| 128875 | + nSuffix = nTerm - nPrefix; |
| 128876 | + nSpace = sqlite3Fts3VarintLen(nPrefix); |
| 128877 | + nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix; |
| 128878 | + |
| 128879 | + if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){ |
| 128880 | + /* If the current node of layer iLayer contains zero keys, or if adding |
| 128881 | + ** the key to it will not cause it to grow to larger than nNodeSize |
| 128882 | + ** bytes in size, write the key here. */ |
| 128883 | + |
| 128884 | + Blob *pBlk = &pNode->block; |
| 128885 | + if( pBlk->n==0 ){ |
| 128886 | + blobGrowBuffer(pBlk, p->nNodeSize, &rc); |
| 128887 | + if( rc==SQLITE_OK ){ |
| 128888 | + pBlk->a[0] = (char)iLayer; |
| 128889 | + pBlk->n = 1 + sqlite3Fts3PutVarint(&pBlk->a[1], iPtr); |
| 128890 | + } |
| 128891 | + } |
| 128892 | + blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc); |
| 128893 | + blobGrowBuffer(&pNode->key, nTerm, &rc); |
| 128894 | + |
| 128895 | + if( rc==SQLITE_OK ){ |
| 128896 | + if( pNode->key.n ){ |
| 128897 | + pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix); |
| 128898 | + } |
| 128899 | + pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix); |
| 128900 | + memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix); |
| 128901 | + pBlk->n += nSuffix; |
| 128902 | + |
| 128903 | + memcpy(pNode->key.a, zTerm, nTerm); |
| 128904 | + pNode->key.n = nTerm; |
| 128905 | + } |
| 128906 | + }else{ |
| 128907 | + /* Otherwise, flush the the current node of layer iLayer to disk. |
| 128908 | + ** Then allocate a new, empty sibling node. The key will be written |
| 128909 | + ** into the parent of this node. */ |
| 128910 | + rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n); |
| 128911 | + |
| 128912 | + assert( pNode->block.nAlloc>=p->nNodeSize ); |
| 128913 | + pNode->block.a[0] = (char)iLayer; |
| 128914 | + pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1); |
| 128915 | + |
| 128916 | + iNextPtr = pNode->iBlock; |
| 128917 | + pNode->iBlock++; |
| 128918 | + pNode->key.n = 0; |
| 128919 | + } |
| 128920 | + |
| 128921 | + if( rc!=SQLITE_OK || iNextPtr==0 ) return rc; |
| 128922 | + iPtr = iNextPtr; |
| 128923 | + } |
| 128924 | + |
| 128925 | + assert( 0 ); |
| 128926 | + return 0; |
| 128927 | +} |
| 128928 | + |
| 128929 | +/* |
| 128930 | +** Append a term and (optionally) doclist to the FTS segment node currently |
| 128931 | +** stored in blob *pNode. The node need not contain any terms, but the |
| 128932 | +** header must be written before this function is called. |
| 128933 | +** |
| 128934 | +** A node header is a single 0x00 byte for a leaf node, or a height varint |
| 128935 | +** followed by the left-hand-child varint for an internal node. |
| 128936 | +** |
| 128937 | +** The term to be appended is passed via arguments zTerm/nTerm. For a |
| 128938 | +** leaf node, the doclist is passed as aDoclist/nDoclist. For an internal |
| 128939 | +** node, both aDoclist and nDoclist must be passed 0. |
| 128940 | +** |
| 128941 | +** If the size of the value in blob pPrev is zero, then this is the first |
| 128942 | +** term written to the node. Otherwise, pPrev contains a copy of the |
| 128943 | +** previous term. Before this function returns, it is updated to contain a |
| 128944 | +** copy of zTerm/nTerm. |
| 128945 | +** |
| 128946 | +** It is assumed that the buffer associated with pNode is already large |
| 128947 | +** enough to accommodate the new entry. The buffer associated with pPrev |
| 128948 | +** is extended by this function if requrired. |
| 128949 | +** |
| 128950 | +** If an error (i.e. OOM condition) occurs, an SQLite error code is |
| 128951 | +** returned. Otherwise, SQLITE_OK. |
| 128952 | +*/ |
| 128953 | +static int fts3AppendToNode( |
| 128954 | + Blob *pNode, /* Current node image to append to */ |
| 128955 | + Blob *pPrev, /* Buffer containing previous term written */ |
| 128956 | + const char *zTerm, /* New term to write */ |
| 128957 | + int nTerm, /* Size of zTerm in bytes */ |
| 128958 | + const char *aDoclist, /* Doclist (or NULL) to write */ |
| 128959 | + int nDoclist /* Size of aDoclist in bytes */ |
| 128960 | +){ |
| 128961 | + int rc = SQLITE_OK; /* Return code */ |
| 128962 | + int bFirst = (pPrev->n==0); /* True if this is the first term written */ |
| 128963 | + int nPrefix; /* Size of term prefix in bytes */ |
| 128964 | + int nSuffix; /* Size of term suffix in bytes */ |
| 128965 | + |
| 128966 | + /* Node must have already been started. There must be a doclist for a |
| 128967 | + ** leaf node, and there must not be a doclist for an internal node. */ |
| 128968 | + assert( pNode->n>0 ); |
| 128969 | + assert( (pNode->a[0]=='\0')==(aDoclist!=0) ); |
| 128970 | + |
| 128971 | + blobGrowBuffer(pPrev, nTerm, &rc); |
| 128972 | + if( rc!=SQLITE_OK ) return rc; |
| 128973 | + |
| 128974 | + nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm); |
| 128975 | + nSuffix = nTerm - nPrefix; |
| 128976 | + memcpy(pPrev->a, zTerm, nTerm); |
| 128977 | + pPrev->n = nTerm; |
| 128978 | + |
| 128979 | + if( bFirst==0 ){ |
| 128980 | + pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix); |
| 128981 | + } |
| 128982 | + pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix); |
| 128983 | + memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix); |
| 128984 | + pNode->n += nSuffix; |
| 128985 | + |
| 128986 | + if( aDoclist ){ |
| 128987 | + pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist); |
| 128988 | + memcpy(&pNode->a[pNode->n], aDoclist, nDoclist); |
| 128989 | + pNode->n += nDoclist; |
| 128990 | + } |
| 128991 | + |
| 128992 | + assert( pNode->n<=pNode->nAlloc ); |
| 128993 | + |
| 128994 | + return SQLITE_OK; |
| 128995 | +} |
| 128996 | + |
| 128997 | +/* |
| 128998 | +** Append the current term and doclist pointed to by cursor pCsr to the |
| 128999 | +** appendable b-tree segment opened for writing by pWriter. |
| 129000 | +** |
| 129001 | +** Return SQLITE_OK if successful, or an SQLite error code otherwise. |
| 129002 | +*/ |
| 129003 | +static int fts3IncrmergeAppend( |
| 129004 | + Fts3Table *p, /* Fts3 table handle */ |
| 129005 | + IncrmergeWriter *pWriter, /* Writer object */ |
| 129006 | + Fts3MultiSegReader *pCsr /* Cursor containing term and doclist */ |
| 129007 | +){ |
| 129008 | + const char *zTerm = pCsr->zTerm; |
| 129009 | + int nTerm = pCsr->nTerm; |
| 129010 | + const char *aDoclist = pCsr->aDoclist; |
| 129011 | + int nDoclist = pCsr->nDoclist; |
| 129012 | + int rc = SQLITE_OK; /* Return code */ |
| 129013 | + int nSpace; /* Total space in bytes required on leaf */ |
| 129014 | + int nPrefix; /* Size of prefix shared with previous term */ |
| 129015 | + int nSuffix; /* Size of suffix (nTerm - nPrefix) */ |
| 129016 | + NodeWriter *pLeaf; /* Object used to write leaf nodes */ |
| 129017 | + |
| 129018 | + pLeaf = &pWriter->aNodeWriter[0]; |
| 129019 | + nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm); |
| 129020 | + nSuffix = nTerm - nPrefix; |
| 129021 | + |
| 129022 | + nSpace = sqlite3Fts3VarintLen(nPrefix); |
| 129023 | + nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix; |
| 129024 | + nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; |
| 129025 | + |
| 129026 | + /* If the current block is not empty, and if adding this term/doclist |
| 129027 | + ** to the current block would make it larger than Fts3Table.nNodeSize |
| 129028 | + ** bytes, write this block out to the database. */ |
| 129029 | + if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){ |
| 129030 | + rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n); |
| 129031 | + pWriter->nWork++; |
| 129032 | + |
| 129033 | + /* Add the current term to the parent node. The term added to the |
| 129034 | + ** parent must: |
| 129035 | + ** |
| 129036 | + ** a) be greater than the largest term on the leaf node just written |
| 129037 | + ** to the database (still available in pLeaf->key), and |
| 129038 | + ** |
| 129039 | + ** b) be less than or equal to the term about to be added to the new |
| 129040 | + ** leaf node (zTerm/nTerm). |
| 129041 | + ** |
| 129042 | + ** In other words, it must be the prefix of zTerm 1 byte longer than |
| 129043 | + ** the common prefix (if any) of zTerm and pWriter->zTerm. |
| 129044 | + */ |
| 129045 | + if( rc==SQLITE_OK ){ |
| 129046 | + rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1); |
| 129047 | + } |
| 129048 | + |
| 129049 | + /* Advance to the next output block */ |
| 129050 | + pLeaf->iBlock++; |
| 129051 | + pLeaf->key.n = 0; |
| 129052 | + pLeaf->block.n = 0; |
| 129053 | + |
| 129054 | + nPrefix = 0; |
| 129055 | + nSuffix = nTerm; |
| 129056 | + nSpace = 1; |
| 129057 | + nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix; |
| 129058 | + nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist; |
| 129059 | + } |
| 129060 | + |
| 129061 | + blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc); |
| 129062 | + |
| 129063 | + if( rc==SQLITE_OK ){ |
| 129064 | + if( pLeaf->block.n==0 ){ |
| 129065 | + pLeaf->block.n = 1; |
| 129066 | + pLeaf->block.a[0] = '\0'; |
| 129067 | + } |
| 129068 | + rc = fts3AppendToNode( |
| 129069 | + &pLeaf->block, &pLeaf->key, zTerm, nTerm, aDoclist, nDoclist |
| 129070 | + ); |
| 129071 | + } |
| 129072 | + |
| 129073 | + return rc; |
| 129074 | +} |
| 129075 | + |
| 129076 | +/* |
| 129077 | +** This function is called to release all dynamic resources held by the |
| 129078 | +** merge-writer object pWriter, and if no error has occurred, to flush |
| 129079 | +** all outstanding node buffers held by pWriter to disk. |
| 129080 | +** |
| 129081 | +** If *pRc is not SQLITE_OK when this function is called, then no attempt |
| 129082 | +** is made to write any data to disk. Instead, this function serves only |
| 129083 | +** to release outstanding resources. |
| 129084 | +** |
| 129085 | +** Otherwise, if *pRc is initially SQLITE_OK and an error occurs while |
| 129086 | +** flushing buffers to disk, *pRc is set to an SQLite error code before |
| 129087 | +** returning. |
| 129088 | +*/ |
| 129089 | +static void fts3IncrmergeRelease( |
| 129090 | + Fts3Table *p, /* FTS3 table handle */ |
| 129091 | + IncrmergeWriter *pWriter, /* Merge-writer object */ |
| 129092 | + int *pRc /* IN/OUT: Error code */ |
| 129093 | +){ |
| 129094 | + int i; /* Used to iterate through non-root layers */ |
| 129095 | + int iRoot; /* Index of root in pWriter->aNodeWriter */ |
| 129096 | + NodeWriter *pRoot; /* NodeWriter for root node */ |
| 129097 | + int rc = *pRc; /* Error code */ |
| 129098 | + |
| 129099 | + /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment |
| 129100 | + ** root node. If the segment fits entirely on a single leaf node, iRoot |
| 129101 | + ** will be set to 0. If the root node is the parent of the leaves, iRoot |
| 129102 | + ** will be 1. And so on. */ |
| 129103 | + for(iRoot=FTS_MAX_APPENDABLE_HEIGHT-1; iRoot>=0; iRoot--){ |
| 129104 | + NodeWriter *pNode = &pWriter->aNodeWriter[iRoot]; |
| 129105 | + if( pNode->block.n>0 ) break; |
| 129106 | + assert( *pRc || pNode->block.nAlloc==0 ); |
| 129107 | + assert( *pRc || pNode->key.nAlloc==0 ); |
| 129108 | + sqlite3_free(pNode->block.a); |
| 129109 | + sqlite3_free(pNode->key.a); |
| 129110 | + } |
| 129111 | + |
| 129112 | + /* Empty output segment. This is a no-op. */ |
| 129113 | + if( iRoot<0 ) return; |
| 129114 | + |
| 129115 | + /* The entire output segment fits on a single node. Normally, this means |
| 129116 | + ** the node would be stored as a blob in the "root" column of the %_segdir |
| 129117 | + ** table. However, this is not permitted in this case. The problem is that |
| 129118 | + ** space has already been reserved in the %_segments table, and so the |
| 129119 | + ** start_block and end_block fields of the %_segdir table must be populated. |
| 129120 | + ** And, by design or by accident, released versions of FTS cannot handle |
| 129121 | + ** segments that fit entirely on the root node with start_block!=0. |
| 129122 | + ** |
| 129123 | + ** Instead, create a synthetic root node that contains nothing but a |
| 129124 | + ** pointer to the single content node. So that the segment consists of a |
| 129125 | + ** single leaf and a single interior (root) node. |
| 129126 | + ** |
| 129127 | + ** Todo: Better might be to defer allocating space in the %_segments |
| 129128 | + ** table until we are sure it is needed. |
| 129129 | + */ |
| 129130 | + if( iRoot==0 ){ |
| 129131 | + Blob *pBlock = &pWriter->aNodeWriter[1].block; |
| 129132 | + blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc); |
| 129133 | + if( rc==SQLITE_OK ){ |
| 129134 | + pBlock->a[0] = 0x01; |
| 129135 | + pBlock->n = 1 + sqlite3Fts3PutVarint( |
| 129136 | + &pBlock->a[1], pWriter->aNodeWriter[0].iBlock |
| 129137 | + ); |
| 129138 | + } |
| 129139 | + iRoot = 1; |
| 129140 | + } |
| 129141 | + pRoot = &pWriter->aNodeWriter[iRoot]; |
| 129142 | + |
| 129143 | + /* Flush all currently outstanding nodes to disk. */ |
| 129144 | + for(i=0; i<iRoot; i++){ |
| 129145 | + NodeWriter *pNode = &pWriter->aNodeWriter[i]; |
| 129146 | + if( pNode->block.n>0 && rc==SQLITE_OK ){ |
| 129147 | + rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n); |
| 129148 | + } |
| 129149 | + sqlite3_free(pNode->block.a); |
| 129150 | + sqlite3_free(pNode->key.a); |
| 129151 | + } |
| 129152 | + |
| 129153 | + /* Write the %_segdir record. */ |
| 129154 | + if( rc==SQLITE_OK ){ |
| 129155 | + rc = fts3WriteSegdir(p, |
| 129156 | + pWriter->iAbsLevel+1, /* level */ |
| 129157 | + pWriter->iIdx, /* idx */ |
| 129158 | + pWriter->iStart, /* start_block */ |
| 129159 | + pWriter->aNodeWriter[0].iBlock, /* leaves_end_block */ |
| 129160 | + pWriter->iEnd, /* end_block */ |
| 129161 | + pRoot->block.a, pRoot->block.n /* root */ |
| 129162 | + ); |
| 129163 | + } |
| 129164 | + sqlite3_free(pRoot->block.a); |
| 129165 | + sqlite3_free(pRoot->key.a); |
| 129166 | + |
| 129167 | + *pRc = rc; |
| 129168 | +} |
| 129169 | + |
| 129170 | +/* |
| 129171 | +** Compare the term in buffer zLhs (size in bytes nLhs) with that in |
| 129172 | +** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of |
| 129173 | +** the other, it is considered to be smaller than the other. |
| 129174 | +** |
| 129175 | +** Return -ve if zLhs is smaller than zRhs, 0 if it is equal, or +ve |
| 129176 | +** if it is greater. |
| 129177 | +*/ |
| 129178 | +static int fts3TermCmp( |
| 129179 | + const char *zLhs, int nLhs, /* LHS of comparison */ |
| 129180 | + const char *zRhs, int nRhs /* RHS of comparison */ |
| 129181 | +){ |
| 129182 | + int nCmp = MIN(nLhs, nRhs); |
| 129183 | + int res; |
| 129184 | + |
| 129185 | + res = memcmp(zLhs, zRhs, nCmp); |
| 129186 | + if( res==0 ) res = nLhs - nRhs; |
| 129187 | + |
| 129188 | + return res; |
| 129189 | +} |
| 129190 | + |
| 129191 | + |
| 129192 | +/* |
| 129193 | +** Query to see if the entry in the %_segments table with blockid iEnd is |
| 129194 | +** NULL. If no error occurs and the entry is NULL, set *pbRes 1 before |
| 129195 | +** returning. Otherwise, set *pbRes to 0. |
| 129196 | +** |
| 129197 | +** Or, if an error occurs while querying the database, return an SQLite |
| 129198 | +** error code. The final value of *pbRes is undefined in this case. |
| 129199 | +** |
| 129200 | +** This is used to test if a segment is an "appendable" segment. If it |
| 129201 | +** is, then a NULL entry has been inserted into the %_segments table |
| 129202 | +** with blockid %_segdir.end_block. |
| 129203 | +*/ |
| 129204 | +static int fts3IsAppendable(Fts3Table *p, sqlite3_int64 iEnd, int *pbRes){ |
| 129205 | + int bRes = 0; /* Result to set *pbRes to */ |
| 129206 | + sqlite3_stmt *pCheck = 0; /* Statement to query database with */ |
| 129207 | + int rc; /* Return code */ |
| 129208 | + |
| 129209 | + rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0); |
| 129210 | + if( rc==SQLITE_OK ){ |
| 129211 | + sqlite3_bind_int64(pCheck, 1, iEnd); |
| 129212 | + if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1; |
| 129213 | + rc = sqlite3_reset(pCheck); |
| 129214 | + } |
| 129215 | + |
| 129216 | + *pbRes = bRes; |
| 129217 | + return rc; |
| 129218 | +} |
| 129219 | + |
| 129220 | +/* |
| 129221 | +** This function is called when initializing an incremental-merge operation. |
| 129222 | +** It checks if the existing segment with index value iIdx at absolute level |
| 129223 | +** (iAbsLevel+1) can be appended to by the incremental merge. If it can, the |
| 129224 | +** merge-writer object *pWriter is initialized to write to it. |
| 129225 | +** |
| 129226 | +** An existing segment can be appended to by an incremental merge if: |
| 129227 | +** |
| 129228 | +** * It was initially created as an appendable segment (with all required |
| 129229 | +** space pre-allocated), and |
| 129230 | +** |
| 129231 | +** * The first key read from the input (arguments zKey and nKey) is |
| 129232 | +** greater than the largest key currently stored in the potential |
| 129233 | +** output segment. |
| 129234 | +*/ |
| 129235 | +static int fts3IncrmergeLoad( |
| 129236 | + Fts3Table *p, /* Fts3 table handle */ |
| 129237 | + sqlite3_int64 iAbsLevel, /* Absolute level of input segments */ |
| 129238 | + int iIdx, /* Index of candidate output segment */ |
| 129239 | + const char *zKey, /* First key to write */ |
| 129240 | + int nKey, /* Number of bytes in nKey */ |
| 129241 | + IncrmergeWriter *pWriter /* Populate this object */ |
| 129242 | +){ |
| 129243 | + int rc; /* Return code */ |
| 129244 | + sqlite3_stmt *pSelect = 0; /* SELECT to read %_segdir entry */ |
| 129245 | + |
| 129246 | + rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0); |
| 129247 | + if( rc==SQLITE_OK ){ |
| 129248 | + sqlite3_int64 iStart = 0; /* Value of %_segdir.start_block */ |
| 129249 | + sqlite3_int64 iLeafEnd = 0; /* Value of %_segdir.leaves_end_block */ |
| 129250 | + sqlite3_int64 iEnd = 0; /* Value of %_segdir.end_block */ |
| 129251 | + const char *aRoot = 0; /* Pointer to %_segdir.root buffer */ |
| 129252 | + int nRoot = 0; /* Size of aRoot[] in bytes */ |
| 129253 | + int rc2; /* Return code from sqlite3_reset() */ |
| 129254 | + int bAppendable = 0; /* Set to true if segment is appendable */ |
| 129255 | + |
| 129256 | + /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */ |
| 129257 | + sqlite3_bind_int64(pSelect, 1, iAbsLevel+1); |
| 129258 | + sqlite3_bind_int(pSelect, 2, iIdx); |
| 129259 | + if( sqlite3_step(pSelect)==SQLITE_ROW ){ |
| 129260 | + iStart = sqlite3_column_int64(pSelect, 1); |
| 129261 | + iLeafEnd = sqlite3_column_int64(pSelect, 2); |
| 129262 | + iEnd = sqlite3_column_int64(pSelect, 3); |
| 129263 | + nRoot = sqlite3_column_bytes(pSelect, 4); |
| 129264 | + aRoot = sqlite3_column_blob(pSelect, 4); |
| 129265 | + }else{ |
| 129266 | + return sqlite3_reset(pSelect); |
| 129267 | + } |
| 129268 | + |
| 129269 | + /* Check for the zero-length marker in the %_segments table */ |
| 129270 | + rc = fts3IsAppendable(p, iEnd, &bAppendable); |
| 129271 | + |
| 129272 | + /* Check that zKey/nKey is larger than the largest key the candidate */ |
| 129273 | + if( rc==SQLITE_OK && bAppendable ){ |
| 129274 | + char *aLeaf = 0; |
| 129275 | + int nLeaf = 0; |
| 129276 | + |
| 129277 | + rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0); |
| 129278 | + if( rc==SQLITE_OK ){ |
| 129279 | + NodeReader reader; |
| 129280 | + for(rc = nodeReaderInit(&reader, aLeaf, nLeaf); |
| 129281 | + rc==SQLITE_OK && reader.aNode; |
| 129282 | + rc = nodeReaderNext(&reader) |
| 129283 | + ){ |
| 129284 | + assert( reader.aNode ); |
| 129285 | + } |
| 129286 | + if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){ |
| 129287 | + bAppendable = 0; |
| 129288 | + } |
| 129289 | + nodeReaderRelease(&reader); |
| 129290 | + } |
| 129291 | + sqlite3_free(aLeaf); |
| 129292 | + } |
| 129293 | + |
| 129294 | + if( rc==SQLITE_OK && bAppendable ){ |
| 129295 | + /* It is possible to append to this segment. Set up the IncrmergeWriter |
| 129296 | + ** object to do so. */ |
| 129297 | + int i; |
| 129298 | + int nHeight = (int)aRoot[0]; |
| 129299 | + NodeWriter *pNode; |
| 129300 | + |
| 129301 | + pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT; |
| 129302 | + pWriter->iStart = iStart; |
| 129303 | + pWriter->iEnd = iEnd; |
| 129304 | + pWriter->iAbsLevel = iAbsLevel; |
| 129305 | + pWriter->iIdx = iIdx; |
| 129306 | + |
| 129307 | + for(i=nHeight+1; i<FTS_MAX_APPENDABLE_HEIGHT; i++){ |
| 129308 | + pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst; |
| 129309 | + } |
| 129310 | + |
| 129311 | + pNode = &pWriter->aNodeWriter[nHeight]; |
| 129312 | + pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight; |
| 129313 | + blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc); |
| 129314 | + if( rc==SQLITE_OK ){ |
| 129315 | + memcpy(pNode->block.a, aRoot, nRoot); |
| 129316 | + pNode->block.n = nRoot; |
| 129317 | + } |
| 129318 | + |
| 129319 | + for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){ |
| 129320 | + NodeReader reader; |
| 129321 | + pNode = &pWriter->aNodeWriter[i]; |
| 129322 | + |
| 129323 | + rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n); |
| 129324 | + while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader); |
| 129325 | + blobGrowBuffer(&pNode->key, reader.term.n, &rc); |
| 129326 | + if( rc==SQLITE_OK ){ |
| 129327 | + memcpy(pNode->key.a, reader.term.a, reader.term.n); |
| 129328 | + pNode->key.n = reader.term.n; |
| 129329 | + if( i>0 ){ |
| 129330 | + char *aBlock = 0; |
| 129331 | + int nBlock = 0; |
| 129332 | + pNode = &pWriter->aNodeWriter[i-1]; |
| 129333 | + pNode->iBlock = reader.iChild; |
| 129334 | + rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0); |
| 129335 | + blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc); |
| 129336 | + if( rc==SQLITE_OK ){ |
| 129337 | + memcpy(pNode->block.a, aBlock, nBlock); |
| 129338 | + pNode->block.n = nBlock; |
| 129339 | + } |
| 129340 | + sqlite3_free(aBlock); |
| 129341 | + } |
| 129342 | + } |
| 129343 | + nodeReaderRelease(&reader); |
| 129344 | + } |
| 129345 | + } |
| 129346 | + |
| 129347 | + rc2 = sqlite3_reset(pSelect); |
| 129348 | + if( rc==SQLITE_OK ) rc = rc2; |
| 129349 | + } |
| 129350 | + |
| 129351 | + return rc; |
| 129352 | +} |
| 129353 | + |
| 129354 | +/* |
| 129355 | +** Determine the largest segment index value that exists within absolute |
| 129356 | +** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus |
| 129357 | +** one before returning SQLITE_OK. Or, if there are no segments at all |
| 129358 | +** within level iAbsLevel, set *piIdx to zero. |
| 129359 | +** |
| 129360 | +** If an error occurs, return an SQLite error code. The final value of |
| 129361 | +** *piIdx is undefined in this case. |
| 129362 | +*/ |
| 129363 | +static int fts3IncrmergeOutputIdx( |
| 129364 | + Fts3Table *p, /* FTS Table handle */ |
| 129365 | + sqlite3_int64 iAbsLevel, /* Absolute index of input segments */ |
| 129366 | + int *piIdx /* OUT: Next free index at iAbsLevel+1 */ |
| 129367 | +){ |
| 129368 | + int rc; |
| 129369 | + sqlite3_stmt *pOutputIdx = 0; /* SQL used to find output index */ |
| 129370 | + |
| 129371 | + rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0); |
| 129372 | + if( rc==SQLITE_OK ){ |
| 129373 | + sqlite3_bind_int64(pOutputIdx, 1, iAbsLevel+1); |
| 129374 | + sqlite3_step(pOutputIdx); |
| 129375 | + *piIdx = sqlite3_column_int(pOutputIdx, 0); |
| 129376 | + rc = sqlite3_reset(pOutputIdx); |
| 129377 | + } |
| 129378 | + |
| 129379 | + return rc; |
| 129380 | +} |
| 129381 | + |
| 129382 | +/* |
| 129383 | +** Allocate an appendable output segment on absolute level iAbsLevel+1 |
| 129384 | +** with idx value iIdx. |
| 129385 | +** |
| 129386 | +** In the %_segdir table, a segment is defined by the values in three |
| 129387 | +** columns: |
| 129388 | +** |
| 129389 | +** start_block |
| 129390 | +** leaves_end_block |
| 129391 | +** end_block |
| 129392 | +** |
| 129393 | +** When an appendable segment is allocated, it is estimated that the |
| 129394 | +** maximum number of leaf blocks that may be required is the sum of the |
| 129395 | +** number of leaf blocks consumed by the input segments, plus the number |
| 129396 | +** of input segments, multiplied by two. This value is stored in stack |
| 129397 | +** variable nLeafEst. |
| 129398 | +** |
| 129399 | +** A total of 16*nLeafEst blocks are allocated when an appendable segment |
| 129400 | +** is created ((1 + end_block - start_block)==16*nLeafEst). The contiguous |
| 129401 | +** array of leaf nodes starts at the first block allocated. The array |
| 129402 | +** of interior nodes that are parents of the leaf nodes start at block |
| 129403 | +** (start_block + (1 + end_block - start_block) / 16). And so on. |
| 129404 | +** |
| 129405 | +** In the actual code below, the value "16" is replaced with the |
| 129406 | +** pre-processor macro FTS_MAX_APPENDABLE_HEIGHT. |
| 129407 | +*/ |
| 129408 | +static int fts3IncrmergeWriter( |
| 129409 | + Fts3Table *p, /* Fts3 table handle */ |
| 129410 | + sqlite3_int64 iAbsLevel, /* Absolute level of input segments */ |
| 129411 | + int iIdx, /* Index of new output segment */ |
| 129412 | + Fts3MultiSegReader *pCsr, /* Cursor that data will be read from */ |
| 129413 | + IncrmergeWriter *pWriter /* Populate this object */ |
| 129414 | +){ |
| 129415 | + int rc; /* Return Code */ |
| 129416 | + int i; /* Iterator variable */ |
| 129417 | + int nLeafEst = 0; /* Blocks allocated for leaf nodes */ |
| 129418 | + sqlite3_stmt *pLeafEst = 0; /* SQL used to determine nLeafEst */ |
| 129419 | + sqlite3_stmt *pFirstBlock = 0; /* SQL used to determine first block */ |
| 129420 | + |
| 129421 | + /* Calculate nLeafEst. */ |
| 129422 | + rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0); |
| 129423 | + if( rc==SQLITE_OK ){ |
| 129424 | + sqlite3_bind_int64(pLeafEst, 1, iAbsLevel); |
| 129425 | + sqlite3_bind_int64(pLeafEst, 2, pCsr->nSegment); |
| 129426 | + if( SQLITE_ROW==sqlite3_step(pLeafEst) ){ |
| 129427 | + nLeafEst = sqlite3_column_int(pLeafEst, 0); |
| 129428 | + } |
| 129429 | + rc = sqlite3_reset(pLeafEst); |
| 129430 | + } |
| 129431 | + if( rc!=SQLITE_OK ) return rc; |
| 129432 | + |
| 129433 | + /* Calculate the first block to use in the output segment */ |
| 129434 | + rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0); |
| 129435 | + if( rc==SQLITE_OK ){ |
| 129436 | + if( SQLITE_ROW==sqlite3_step(pFirstBlock) ){ |
| 129437 | + pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0); |
| 129438 | + pWriter->iEnd = pWriter->iStart - 1; |
| 129439 | + pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT; |
| 129440 | + } |
| 129441 | + rc = sqlite3_reset(pFirstBlock); |
| 129442 | + } |
| 129443 | + if( rc!=SQLITE_OK ) return rc; |
| 129444 | + |
| 129445 | + /* Insert the marker in the %_segments table to make sure nobody tries |
| 129446 | + ** to steal the space just allocated. This is also used to identify |
| 129447 | + ** appendable segments. */ |
| 129448 | + rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0); |
| 129449 | + if( rc!=SQLITE_OK ) return rc; |
| 129450 | + |
| 129451 | + pWriter->iAbsLevel = iAbsLevel; |
| 129452 | + pWriter->nLeafEst = nLeafEst; |
| 129453 | + pWriter->iIdx = iIdx; |
| 129454 | + |
| 129455 | + /* Set up the array of NodeWriter objects */ |
| 129456 | + for(i=0; i<FTS_MAX_APPENDABLE_HEIGHT; i++){ |
| 129457 | + pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst; |
| 129458 | + } |
| 129459 | + return SQLITE_OK; |
| 129460 | +} |
| 129461 | + |
| 129462 | +/* |
| 129463 | +** Remove an entry from the %_segdir table. This involves running the |
| 129464 | +** following two statements: |
| 129465 | +** |
| 129466 | +** DELETE FROM %_segdir WHERE level = :iAbsLevel AND idx = :iIdx |
| 129467 | +** UPDATE %_segdir SET idx = idx - 1 WHERE level = :iAbsLevel AND idx > :iIdx |
| 129468 | +** |
| 129469 | +** The DELETE statement removes the specific %_segdir level. The UPDATE |
| 129470 | +** statement ensures that the remaining segments have contiguously allocated |
| 129471 | +** idx values. |
| 129472 | +*/ |
| 129473 | +static int fts3RemoveSegdirEntry( |
| 129474 | + Fts3Table *p, /* FTS3 table handle */ |
| 129475 | + sqlite3_int64 iAbsLevel, /* Absolute level to delete from */ |
| 129476 | + int iIdx /* Index of %_segdir entry to delete */ |
| 129477 | +){ |
| 129478 | + int rc; /* Return code */ |
| 129479 | + sqlite3_stmt *pDelete = 0; /* DELETE statement */ |
| 129480 | + |
| 129481 | + rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0); |
| 129482 | + if( rc==SQLITE_OK ){ |
| 129483 | + sqlite3_bind_int64(pDelete, 1, iAbsLevel); |
| 129484 | + sqlite3_bind_int(pDelete, 2, iIdx); |
| 129485 | + sqlite3_step(pDelete); |
| 129486 | + rc = sqlite3_reset(pDelete); |
| 129487 | + } |
| 129488 | + |
| 129489 | + return rc; |
| 129490 | +} |
| 129491 | + |
| 129492 | +/* |
| 129493 | +** One or more segments have just been removed from absolute level iAbsLevel. |
| 129494 | +** Update the 'idx' values of the remaining segments in the level so that |
| 129495 | +** the idx values are a contiguous sequence starting from 0. |
| 129496 | +*/ |
| 129497 | +static int fts3RepackSegdirLevel( |
| 129498 | + Fts3Table *p, /* FTS3 table handle */ |
| 129499 | + sqlite3_int64 iAbsLevel /* Absolute level to repack */ |
| 129500 | +){ |
| 129501 | + int rc; /* Return code */ |
| 129502 | + int *aIdx = 0; /* Array of remaining idx values */ |
| 129503 | + int nIdx = 0; /* Valid entries in aIdx[] */ |
| 129504 | + int nAlloc = 0; /* Allocated size of aIdx[] */ |
| 129505 | + int i; /* Iterator variable */ |
| 129506 | + sqlite3_stmt *pSelect = 0; /* Select statement to read idx values */ |
| 129507 | + sqlite3_stmt *pUpdate = 0; /* Update statement to modify idx values */ |
| 129508 | + |
| 129509 | + rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0); |
| 129510 | + if( rc==SQLITE_OK ){ |
| 129511 | + int rc2; |
| 129512 | + sqlite3_bind_int64(pSelect, 1, iAbsLevel); |
| 129513 | + while( SQLITE_ROW==sqlite3_step(pSelect) ){ |
| 129514 | + if( nIdx>=nAlloc ){ |
| 129515 | + int *aNew; |
| 129516 | + nAlloc += 16; |
| 129517 | + aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int)); |
| 129518 | + if( !aNew ){ |
| 129519 | + rc = SQLITE_NOMEM; |
| 129520 | + break; |
| 129521 | + } |
| 129522 | + aIdx = aNew; |
| 129523 | + } |
| 129524 | + aIdx[nIdx++] = sqlite3_column_int(pSelect, 0); |
| 129525 | + } |
| 129526 | + rc2 = sqlite3_reset(pSelect); |
| 129527 | + if( rc==SQLITE_OK ) rc = rc2; |
| 129528 | + } |
| 129529 | + |
| 129530 | + if( rc==SQLITE_OK ){ |
| 129531 | + rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0); |
| 129532 | + } |
| 129533 | + if( rc==SQLITE_OK ){ |
| 129534 | + sqlite3_bind_int64(pUpdate, 2, iAbsLevel); |
| 129535 | + } |
| 129536 | + |
| 129537 | + assert( p->bIgnoreSavepoint==0 ); |
| 129538 | + p->bIgnoreSavepoint = 1; |
| 129539 | + for(i=0; rc==SQLITE_OK && i<nIdx; i++){ |
| 129540 | + if( aIdx[i]!=i ){ |
| 129541 | + sqlite3_bind_int(pUpdate, 3, aIdx[i]); |
| 129542 | + sqlite3_bind_int(pUpdate, 1, i); |
| 129543 | + sqlite3_step(pUpdate); |
| 129544 | + rc = sqlite3_reset(pUpdate); |
| 129545 | + } |
| 129546 | + } |
| 129547 | + p->bIgnoreSavepoint = 0; |
| 129548 | + |
| 129549 | + sqlite3_free(aIdx); |
| 129550 | + return rc; |
| 129551 | +} |
| 129552 | + |
| 129553 | +static void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){ |
| 129554 | + pNode->a[0] = (char)iHeight; |
| 129555 | + if( iChild ){ |
| 129556 | + assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) ); |
| 129557 | + pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild); |
| 129558 | + }else{ |
| 129559 | + assert( pNode->nAlloc>=1 ); |
| 129560 | + pNode->n = 1; |
| 129561 | + } |
| 129562 | +} |
| 129563 | + |
| 129564 | +/* |
| 129565 | +** The first two arguments are a pointer to and the size of a segment b-tree |
| 129566 | +** node. The node may be a leaf or an internal node. |
| 129567 | +** |
| 129568 | +** This function creates a new node image in blob object *pNew by copying |
| 129569 | +** all terms that are greater than or equal to zTerm/nTerm (for leaf nodes) |
| 129570 | +** or greater than zTerm/nTerm (for internal nodes) from aNode/nNode. |
| 129571 | +*/ |
| 129572 | +static int fts3TruncateNode( |
| 129573 | + const char *aNode, /* Current node image */ |
| 129574 | + int nNode, /* Size of aNode in bytes */ |
| 129575 | + Blob *pNew, /* OUT: Write new node image here */ |
| 129576 | + const char *zTerm, /* Omit all terms smaller than this */ |
| 129577 | + int nTerm, /* Size of zTerm in bytes */ |
| 129578 | + sqlite3_int64 *piBlock /* OUT: Block number in next layer down */ |
| 129579 | +){ |
| 129580 | + NodeReader reader; /* Reader object */ |
| 129581 | + Blob prev = {0, 0, 0}; /* Previous term written to new node */ |
| 129582 | + int rc = SQLITE_OK; /* Return code */ |
| 129583 | + int bLeaf = aNode[0]=='\0'; /* True for a leaf node */ |
| 129584 | + |
| 129585 | + /* Allocate required output space */ |
| 129586 | + blobGrowBuffer(pNew, nNode, &rc); |
| 129587 | + if( rc!=SQLITE_OK ) return rc; |
| 129588 | + pNew->n = 0; |
| 129589 | + |
| 129590 | + /* Populate new node buffer */ |
| 129591 | + for(rc = nodeReaderInit(&reader, aNode, nNode); |
| 129592 | + rc==SQLITE_OK && reader.aNode; |
| 129593 | + rc = nodeReaderNext(&reader) |
| 129594 | + ){ |
| 129595 | + if( pNew->n==0 ){ |
| 129596 | + int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm); |
| 129597 | + if( res<0 || (bLeaf==0 && res==0) ) continue; |
| 129598 | + fts3StartNode(pNew, (int)aNode[0], reader.iChild); |
| 129599 | + *piBlock = reader.iChild; |
| 129600 | + } |
| 129601 | + rc = fts3AppendToNode( |
| 129602 | + pNew, &prev, reader.term.a, reader.term.n, |
| 129603 | + reader.aDoclist, reader.nDoclist |
| 129604 | + ); |
| 129605 | + if( rc!=SQLITE_OK ) break; |
| 129606 | + } |
| 129607 | + if( pNew->n==0 ){ |
| 129608 | + fts3StartNode(pNew, (int)aNode[0], reader.iChild); |
| 129609 | + *piBlock = reader.iChild; |
| 129610 | + } |
| 129611 | + assert( pNew->n<=pNew->nAlloc ); |
| 129612 | + |
| 129613 | + nodeReaderRelease(&reader); |
| 129614 | + sqlite3_free(prev.a); |
| 129615 | + return rc; |
| 129616 | +} |
| 129617 | + |
| 129618 | +/* |
| 129619 | +** Remove all terms smaller than zTerm/nTerm from segment iIdx in absolute |
| 129620 | +** level iAbsLevel. This may involve deleting entries from the %_segments |
| 129621 | +** table, and modifying existing entries in both the %_segments and %_segdir |
| 129622 | +** tables. |
| 129623 | +** |
| 129624 | +** SQLITE_OK is returned if the segment is updated successfully. Or an |
| 129625 | +** SQLite error code otherwise. |
| 129626 | +*/ |
| 129627 | +static int fts3TruncateSegment( |
| 129628 | + Fts3Table *p, /* FTS3 table handle */ |
| 129629 | + sqlite3_int64 iAbsLevel, /* Absolute level of segment to modify */ |
| 129630 | + int iIdx, /* Index within level of segment to modify */ |
| 129631 | + const char *zTerm, /* Remove terms smaller than this */ |
| 129632 | + int nTerm /* Number of bytes in buffer zTerm */ |
| 129633 | +){ |
| 129634 | + int rc = SQLITE_OK; /* Return code */ |
| 129635 | + Blob root = {0,0,0}; /* New root page image */ |
| 129636 | + Blob block = {0,0,0}; /* Buffer used for any other block */ |
| 129637 | + sqlite3_int64 iBlock = 0; /* Block id */ |
| 129638 | + sqlite3_int64 iNewStart = 0; /* New value for iStartBlock */ |
| 129639 | + sqlite3_int64 iOldStart = 0; /* Old value for iStartBlock */ |
| 129640 | + sqlite3_stmt *pFetch = 0; /* Statement used to fetch segdir */ |
| 129641 | + |
| 129642 | + rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0); |
| 129643 | + if( rc==SQLITE_OK ){ |
| 129644 | + int rc2; /* sqlite3_reset() return code */ |
| 129645 | + sqlite3_bind_int64(pFetch, 1, iAbsLevel); |
| 129646 | + sqlite3_bind_int(pFetch, 2, iIdx); |
| 129647 | + if( SQLITE_ROW==sqlite3_step(pFetch) ){ |
| 129648 | + const char *aRoot = sqlite3_column_blob(pFetch, 4); |
| 129649 | + int nRoot = sqlite3_column_bytes(pFetch, 4); |
| 129650 | + iOldStart = sqlite3_column_int64(pFetch, 1); |
| 129651 | + rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock); |
| 129652 | + } |
| 129653 | + rc2 = sqlite3_reset(pFetch); |
| 129654 | + if( rc==SQLITE_OK ) rc = rc2; |
| 129655 | + } |
| 129656 | + |
| 129657 | + while( rc==SQLITE_OK && iBlock ){ |
| 129658 | + char *aBlock = 0; |
| 129659 | + int nBlock = 0; |
| 129660 | + iNewStart = iBlock; |
| 129661 | + |
| 129662 | + rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0); |
| 129663 | + if( rc==SQLITE_OK ){ |
| 129664 | + rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock); |
| 129665 | + } |
| 129666 | + if( rc==SQLITE_OK ){ |
| 129667 | + rc = fts3WriteSegment(p, iNewStart, block.a, block.n); |
| 129668 | + } |
| 129669 | + sqlite3_free(aBlock); |
| 129670 | + } |
| 129671 | + |
| 129672 | + /* Variable iNewStart now contains the first valid leaf node. */ |
| 129673 | + if( rc==SQLITE_OK && iNewStart ){ |
| 129674 | + sqlite3_stmt *pDel = 0; |
| 129675 | + rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0); |
| 129676 | + if( rc==SQLITE_OK ){ |
| 129677 | + sqlite3_bind_int64(pDel, 1, iOldStart); |
| 129678 | + sqlite3_bind_int64(pDel, 2, iNewStart-1); |
| 129679 | + sqlite3_step(pDel); |
| 129680 | + rc = sqlite3_reset(pDel); |
| 129681 | + } |
| 129682 | + } |
| 129683 | + |
| 129684 | + if( rc==SQLITE_OK ){ |
| 129685 | + sqlite3_stmt *pChomp = 0; |
| 129686 | + rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0); |
| 129687 | + if( rc==SQLITE_OK ){ |
| 129688 | + sqlite3_bind_int64(pChomp, 1, iNewStart); |
| 129689 | + sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC); |
| 129690 | + sqlite3_bind_int64(pChomp, 3, iAbsLevel); |
| 129691 | + sqlite3_bind_int(pChomp, 4, iIdx); |
| 129692 | + sqlite3_step(pChomp); |
| 129693 | + rc = sqlite3_reset(pChomp); |
| 129694 | + } |
| 129695 | + } |
| 129696 | + |
| 129697 | + sqlite3_free(root.a); |
| 129698 | + sqlite3_free(block.a); |
| 129699 | + return rc; |
| 129700 | +} |
| 129701 | + |
| 129702 | +/* |
| 129703 | +** This function is called after an incrmental-merge operation has run to |
| 129704 | +** merge (or partially merge) two or more segments from absolute level |
| 129705 | +** iAbsLevel. |
| 129706 | +** |
| 129707 | +** Each input segment is either removed from the db completely (if all of |
| 129708 | +** its data was copied to the output segment by the incrmerge operation) |
| 129709 | +** or modified in place so that it no longer contains those entries that |
| 129710 | +** have been duplicated in the output segment. |
| 129711 | +*/ |
| 129712 | +static int fts3IncrmergeChomp( |
| 129713 | + Fts3Table *p, /* FTS table handle */ |
| 129714 | + sqlite3_int64 iAbsLevel, /* Absolute level containing segments */ |
| 129715 | + Fts3MultiSegReader *pCsr, /* Chomp all segments opened by this cursor */ |
| 129716 | + int *pnRem /* Number of segments not deleted */ |
| 129717 | +){ |
| 129718 | + int i; |
| 129719 | + int nRem = 0; |
| 129720 | + int rc = SQLITE_OK; |
| 129721 | + |
| 129722 | + for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){ |
| 129723 | + Fts3SegReader *pSeg = 0; |
| 129724 | + int j; |
| 129725 | + |
| 129726 | + /* Find the Fts3SegReader object with Fts3SegReader.iIdx==i. It is hiding |
| 129727 | + ** somewhere in the pCsr->apSegment[] array. */ |
| 129728 | + for(j=0; ALWAYS(j<pCsr->nSegment); j++){ |
| 129729 | + pSeg = pCsr->apSegment[j]; |
| 129730 | + if( pSeg->iIdx==i ) break; |
| 129731 | + } |
| 129732 | + assert( j<pCsr->nSegment && pSeg->iIdx==i ); |
| 129733 | + |
| 129734 | + if( pSeg->aNode==0 ){ |
| 129735 | + /* Seg-reader is at EOF. Remove the entire input segment. */ |
| 129736 | + rc = fts3DeleteSegment(p, pSeg); |
| 129737 | + if( rc==SQLITE_OK ){ |
| 129738 | + rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx); |
| 129739 | + } |
| 129740 | + *pnRem = 0; |
| 129741 | + }else{ |
| 129742 | + /* The incremental merge did not copy all the data from this |
| 129743 | + ** segment to the upper level. The segment is modified in place |
| 129744 | + ** so that it contains no keys smaller than zTerm/nTerm. */ |
| 129745 | + const char *zTerm = pSeg->zTerm; |
| 129746 | + int nTerm = pSeg->nTerm; |
| 129747 | + rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm); |
| 129748 | + nRem++; |
| 129749 | + } |
| 129750 | + } |
| 129751 | + |
| 129752 | + if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){ |
| 129753 | + rc = fts3RepackSegdirLevel(p, iAbsLevel); |
| 129754 | + } |
| 129755 | + |
| 129756 | + *pnRem = nRem; |
| 129757 | + return rc; |
| 129758 | +} |
| 129759 | + |
| 129760 | +/* |
| 129761 | +** Store an incr-merge hint in the database. |
| 129762 | +*/ |
| 129763 | +static int fts3IncrmergeHintStore(Fts3Table *p, Blob *pHint){ |
| 129764 | + sqlite3_stmt *pReplace = 0; |
| 129765 | + int rc; /* Return code */ |
| 129766 | + |
| 129767 | + rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0); |
| 129768 | + if( rc==SQLITE_OK ){ |
| 129769 | + sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT); |
| 129770 | + sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC); |
| 129771 | + sqlite3_step(pReplace); |
| 129772 | + rc = sqlite3_reset(pReplace); |
| 129773 | + } |
| 129774 | + |
| 129775 | + return rc; |
| 129776 | +} |
| 129777 | + |
| 129778 | +/* |
| 129779 | +** Load an incr-merge hint from the database. The incr-merge hint, if one |
| 129780 | +** exists, is stored in the rowid==1 row of the %_stat table. |
| 129781 | +** |
| 129782 | +** If successful, populate blob *pHint with the value read from the %_stat |
| 129783 | +** table and return SQLITE_OK. Otherwise, if an error occurs, return an |
| 129784 | +** SQLite error code. |
| 129785 | +*/ |
| 129786 | +static int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){ |
| 129787 | + sqlite3_stmt *pSelect = 0; |
| 129788 | + int rc; |
| 129789 | + |
| 129790 | + pHint->n = 0; |
| 129791 | + rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0); |
| 129792 | + if( rc==SQLITE_OK ){ |
| 129793 | + int rc2; |
| 129794 | + sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT); |
| 129795 | + if( SQLITE_ROW==sqlite3_step(pSelect) ){ |
| 129796 | + const char *aHint = sqlite3_column_blob(pSelect, 0); |
| 129797 | + int nHint = sqlite3_column_bytes(pSelect, 0); |
| 129798 | + if( aHint ){ |
| 129799 | + blobGrowBuffer(pHint, nHint, &rc); |
| 129800 | + if( rc==SQLITE_OK ){ |
| 129801 | + memcpy(pHint->a, aHint, nHint); |
| 129802 | + pHint->n = nHint; |
| 129803 | + } |
| 129804 | + } |
| 129805 | + } |
| 129806 | + rc2 = sqlite3_reset(pSelect); |
| 129807 | + if( rc==SQLITE_OK ) rc = rc2; |
| 129808 | + } |
| 129809 | + |
| 129810 | + return rc; |
| 129811 | +} |
| 129812 | + |
| 129813 | +/* |
| 129814 | +** If *pRc is not SQLITE_OK when this function is called, it is a no-op. |
| 129815 | +** Otherwise, append an entry to the hint stored in blob *pHint. Each entry |
| 129816 | +** consists of two varints, the absolute level number of the input segments |
| 129817 | +** and the number of input segments. |
| 129818 | +** |
| 129819 | +** If successful, leave *pRc set to SQLITE_OK and return. If an error occurs, |
| 129820 | +** set *pRc to an SQLite error code before returning. |
| 129821 | +*/ |
| 129822 | +static void fts3IncrmergeHintPush( |
| 129823 | + Blob *pHint, /* Hint blob to append to */ |
| 129824 | + i64 iAbsLevel, /* First varint to store in hint */ |
| 129825 | + int nInput, /* Second varint to store in hint */ |
| 129826 | + int *pRc /* IN/OUT: Error code */ |
| 129827 | +){ |
| 129828 | + blobGrowBuffer(pHint, pHint->n + 2*FTS3_VARINT_MAX, pRc); |
| 129829 | + if( *pRc==SQLITE_OK ){ |
| 129830 | + pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], iAbsLevel); |
| 129831 | + pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], (i64)nInput); |
| 129832 | + } |
| 129833 | +} |
| 129834 | + |
| 129835 | +/* |
| 129836 | +** Read the last entry (most recently pushed) from the hint blob *pHint |
| 129837 | +** and then remove the entry. Write the two values read to *piAbsLevel and |
| 129838 | +** *pnInput before returning. |
| 129839 | +** |
| 129840 | +** If no error occurs, return SQLITE_OK. If the hint blob in *pHint does |
| 129841 | +** not contain at least two valid varints, return SQLITE_CORRUPT_VTAB. |
| 129842 | +*/ |
| 129843 | +static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){ |
| 129844 | + const int nHint = pHint->n; |
| 129845 | + int i; |
| 129846 | + |
| 129847 | + i = pHint->n-2; |
| 129848 | + while( i>0 && (pHint->a[i-1] & 0x80) ) i--; |
| 129849 | + while( i>0 && (pHint->a[i-1] & 0x80) ) i--; |
| 129850 | + |
| 129851 | + pHint->n = i; |
| 129852 | + i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel); |
| 129853 | + i += sqlite3Fts3GetVarint32(&pHint->a[i], pnInput); |
| 129854 | + if( i!=nHint ) return SQLITE_CORRUPT_VTAB; |
| 129855 | + |
| 129856 | + return SQLITE_OK; |
| 129857 | +} |
| 129858 | + |
| 129859 | + |
| 129860 | +/* |
| 129861 | +** Attempt an incremental merge that writes nMerge leaf blocks. |
| 129862 | +** |
| 129863 | +** Incremental merges happen nMin segments at a time. The two |
| 129864 | +** segments to be merged are the nMin oldest segments (the ones with |
| 129865 | +** the smallest indexes) in the highest level that contains at least |
| 129866 | +** nMin segments. Multiple merges might occur in an attempt to write the |
| 129867 | +** quota of nMerge leaf blocks. |
| 129868 | +*/ |
| 129869 | +SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){ |
| 129870 | + int rc; /* Return code */ |
| 129871 | + int nRem = nMerge; /* Number of leaf pages yet to be written */ |
| 129872 | + Fts3MultiSegReader *pCsr; /* Cursor used to read input data */ |
| 129873 | + Fts3SegFilter *pFilter; /* Filter used with cursor pCsr */ |
| 129874 | + IncrmergeWriter *pWriter; /* Writer object */ |
| 129875 | + int nSeg = 0; /* Number of input segments */ |
| 129876 | + sqlite3_int64 iAbsLevel = 0; /* Absolute level number to work on */ |
| 129877 | + Blob hint = {0, 0, 0}; /* Hint read from %_stat table */ |
| 129878 | + int bDirtyHint = 0; /* True if blob 'hint' has been modified */ |
| 129879 | + |
| 129880 | + /* Allocate space for the cursor, filter and writer objects */ |
| 129881 | + const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter); |
| 129882 | + pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc); |
| 129883 | + if( !pWriter ) return SQLITE_NOMEM; |
| 129884 | + pFilter = (Fts3SegFilter *)&pWriter[1]; |
| 129885 | + pCsr = (Fts3MultiSegReader *)&pFilter[1]; |
| 129886 | + |
| 129887 | + rc = fts3IncrmergeHintLoad(p, &hint); |
| 129888 | + while( rc==SQLITE_OK && nRem>0 ){ |
| 129889 | + const i64 nMod = FTS3_SEGDIR_MAXLEVEL * p->nIndex; |
| 129890 | + sqlite3_stmt *pFindLevel = 0; /* SQL used to determine iAbsLevel */ |
| 129891 | + int bUseHint = 0; /* True if attempting to append */ |
| 129892 | + |
| 129893 | + /* Search the %_segdir table for the absolute level with the smallest |
| 129894 | + ** relative level number that contains at least nMin segments, if any. |
| 129895 | + ** If one is found, set iAbsLevel to the absolute level number and |
| 129896 | + ** nSeg to nMin. If no level with at least nMin segments can be found, |
| 129897 | + ** set nSeg to -1. |
| 129898 | + */ |
| 129899 | + rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0); |
| 129900 | + sqlite3_bind_int(pFindLevel, 1, nMin); |
| 129901 | + if( sqlite3_step(pFindLevel)==SQLITE_ROW ){ |
| 129902 | + iAbsLevel = sqlite3_column_int64(pFindLevel, 0); |
| 129903 | + nSeg = nMin; |
| 129904 | + }else{ |
| 129905 | + nSeg = -1; |
| 129906 | + } |
| 129907 | + rc = sqlite3_reset(pFindLevel); |
| 129908 | + |
| 129909 | + /* If the hint read from the %_stat table is not empty, check if the |
| 129910 | + ** last entry in it specifies a relative level smaller than or equal |
| 129911 | + ** to the level identified by the block above (if any). If so, this |
| 129912 | + ** iteration of the loop will work on merging at the hinted level. |
| 129913 | + */ |
| 129914 | + if( rc==SQLITE_OK && hint.n ){ |
| 129915 | + int nHint = hint.n; |
| 129916 | + sqlite3_int64 iHintAbsLevel = 0; /* Hint level */ |
| 129917 | + int nHintSeg = 0; /* Hint number of segments */ |
| 129918 | + |
| 129919 | + rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg); |
| 129920 | + if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){ |
| 129921 | + iAbsLevel = iHintAbsLevel; |
| 129922 | + nSeg = nHintSeg; |
| 129923 | + bUseHint = 1; |
| 129924 | + bDirtyHint = 1; |
| 129925 | + }else{ |
| 129926 | + /* This undoes the effect of the HintPop() above - so that no entry |
| 129927 | + ** is removed from the hint blob. */ |
| 129928 | + hint.n = nHint; |
| 129929 | + } |
| 129930 | + } |
| 129931 | + |
| 129932 | + /* If nSeg is less that zero, then there is no level with at least |
| 129933 | + ** nMin segments and no hint in the %_stat table. No work to do. |
| 129934 | + ** Exit early in this case. */ |
| 129935 | + if( nSeg<0 ) break; |
| 129936 | + |
| 129937 | + /* Open a cursor to iterate through the contents of the oldest nSeg |
| 129938 | + ** indexes of absolute level iAbsLevel. If this cursor is opened using |
| 129939 | + ** the 'hint' parameters, it is possible that there are less than nSeg |
| 129940 | + ** segments available in level iAbsLevel. In this case, no work is |
| 129941 | + ** done on iAbsLevel - fall through to the next iteration of the loop |
| 129942 | + ** to start work on some other level. */ |
| 129943 | + memset(pWriter, 0, nAlloc); |
| 129944 | + pFilter->flags = FTS3_SEGMENT_REQUIRE_POS; |
| 129945 | + if( rc==SQLITE_OK ){ |
| 129946 | + rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr); |
| 129947 | + } |
| 129948 | + if( SQLITE_OK==rc && pCsr->nSegment==nSeg |
| 129949 | + && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter)) |
| 129950 | + && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr)) |
| 129951 | + ){ |
| 129952 | + int iIdx = 0; /* Largest idx in level (iAbsLevel+1) */ |
| 129953 | + rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx); |
| 129954 | + if( rc==SQLITE_OK ){ |
| 129955 | + if( bUseHint && iIdx>0 ){ |
| 129956 | + const char *zKey = pCsr->zTerm; |
| 129957 | + int nKey = pCsr->nTerm; |
| 129958 | + rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter); |
| 129959 | + }else{ |
| 129960 | + rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter); |
| 129961 | + } |
| 129962 | + } |
| 129963 | + |
| 129964 | + if( rc==SQLITE_OK && pWriter->nLeafEst ){ |
| 129965 | + fts3LogMerge(nSeg, iAbsLevel); |
| 129966 | + do { |
| 129967 | + rc = fts3IncrmergeAppend(p, pWriter, pCsr); |
| 129968 | + if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr); |
| 129969 | + if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK; |
| 129970 | + }while( rc==SQLITE_ROW ); |
| 129971 | + |
| 129972 | + /* Update or delete the input segments */ |
| 129973 | + if( rc==SQLITE_OK ){ |
| 129974 | + nRem -= (1 + pWriter->nWork); |
| 129975 | + rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg); |
| 129976 | + if( nSeg!=0 ){ |
| 129977 | + bDirtyHint = 1; |
| 129978 | + fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc); |
| 129979 | + } |
| 129980 | + } |
| 129981 | + } |
| 129982 | + |
| 129983 | + fts3IncrmergeRelease(p, pWriter, &rc); |
| 129984 | + } |
| 129985 | + |
| 129986 | + sqlite3Fts3SegReaderFinish(pCsr); |
| 129987 | + } |
| 129988 | + |
| 129989 | + /* Write the hint values into the %_stat table for the next incr-merger */ |
| 129990 | + if( bDirtyHint && rc==SQLITE_OK ){ |
| 129991 | + rc = fts3IncrmergeHintStore(p, &hint); |
| 129992 | + } |
| 129993 | + |
| 129994 | + sqlite3_free(pWriter); |
| 129995 | + sqlite3_free(hint.a); |
| 129996 | + return rc; |
| 129997 | +} |
| 129998 | + |
| 129999 | +/* |
| 130000 | +** Convert the text beginning at *pz into an integer and return |
| 130001 | +** its value. Advance *pz to point to the first character past |
| 130002 | +** the integer. |
| 130003 | +*/ |
| 130004 | +static int fts3Getint(const char **pz){ |
| 130005 | + const char *z = *pz; |
| 130006 | + int i = 0; |
| 130007 | + while( (*z)>='0' && (*z)<='9' ) i = 10*i + *(z++) - '0'; |
| 130008 | + *pz = z; |
| 130009 | + return i; |
| 130010 | +} |
| 130011 | + |
| 130012 | +/* |
| 130013 | +** Process statements of the form: |
| 130014 | +** |
| 130015 | +** INSERT INTO table(table) VALUES('merge=A,B'); |
| 130016 | +** |
| 130017 | +** A and B are integers that decode to be the number of leaf pages |
| 130018 | +** written for the merge, and the minimum number of segments on a level |
| 130019 | +** before it will be selected for a merge, respectively. |
| 130020 | +*/ |
| 130021 | +static int fts3DoIncrmerge( |
| 130022 | + Fts3Table *p, /* FTS3 table handle */ |
| 130023 | + const char *zParam /* Nul-terminated string containing "A,B" */ |
| 130024 | +){ |
| 130025 | + int rc; |
| 130026 | + int nMin = (FTS3_MERGE_COUNT / 2); |
| 130027 | + int nMerge = 0; |
| 130028 | + const char *z = zParam; |
| 130029 | + |
| 130030 | + /* Read the first integer value */ |
| 130031 | + nMerge = fts3Getint(&z); |
| 130032 | + |
| 130033 | + /* If the first integer value is followed by a ',', read the second |
| 130034 | + ** integer value. */ |
| 130035 | + if( z[0]==',' && z[1]!='\0' ){ |
| 130036 | + z++; |
| 130037 | + nMin = fts3Getint(&z); |
| 130038 | + } |
| 130039 | + |
| 130040 | + if( z[0]!='\0' || nMin<2 ){ |
| 130041 | + rc = SQLITE_ERROR; |
| 130042 | + }else{ |
| 130043 | + rc = SQLITE_OK; |
| 130044 | + if( !p->bHasStat ){ |
| 130045 | + assert( p->bFts4==0 ); |
| 130046 | + sqlite3Fts3CreateStatTable(&rc, p); |
| 130047 | + } |
| 130048 | + if( rc==SQLITE_OK ){ |
| 130049 | + rc = sqlite3Fts3Incrmerge(p, nMerge, nMin); |
| 130050 | + } |
| 130051 | + sqlite3Fts3SegmentsClose(p); |
| 130052 | + } |
| 130053 | + return rc; |
| 130054 | +} |
| 130055 | + |
| 130056 | +/* |
| 130057 | +** Process statements of the form: |
| 130058 | +** |
| 130059 | +** INSERT INTO table(table) VALUES('automerge=X'); |
| 130060 | +** |
| 130061 | +** where X is an integer. X==0 means to turn automerge off. X!=0 means |
| 130062 | +** turn it on. The setting is persistent. |
| 130063 | +*/ |
| 130064 | +static int fts3DoAutoincrmerge( |
| 130065 | + Fts3Table *p, /* FTS3 table handle */ |
| 130066 | + const char *zParam /* Nul-terminated string containing boolean */ |
| 130067 | +){ |
| 130068 | + int rc = SQLITE_OK; |
| 130069 | + sqlite3_stmt *pStmt = 0; |
| 130070 | + p->bAutoincrmerge = fts3Getint(&zParam)!=0; |
| 130071 | + if( !p->bHasStat ){ |
| 130072 | + assert( p->bFts4==0 ); |
| 130073 | + sqlite3Fts3CreateStatTable(&rc, p); |
| 130074 | + if( rc ) return rc; |
| 130075 | + } |
| 130076 | + rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0); |
| 130077 | + if( rc ) return rc;; |
| 130078 | + sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE); |
| 130079 | + sqlite3_bind_int(pStmt, 2, p->bAutoincrmerge); |
| 130080 | + sqlite3_step(pStmt); |
| 130081 | + rc = sqlite3_reset(pStmt); |
| 130082 | + return rc; |
| 130083 | +} |
| 130084 | + |
| 130085 | +/* |
| 130086 | +** Return a 64-bit checksum for the FTS index entry specified by the |
| 130087 | +** arguments to this function. |
| 130088 | +*/ |
| 130089 | +static u64 fts3ChecksumEntry( |
| 130090 | + const char *zTerm, /* Pointer to buffer containing term */ |
| 130091 | + int nTerm, /* Size of zTerm in bytes */ |
| 130092 | + int iLangid, /* Language id for current row */ |
| 130093 | + int iIndex, /* Index (0..Fts3Table.nIndex-1) */ |
| 130094 | + i64 iDocid, /* Docid for current row. */ |
| 130095 | + int iCol, /* Column number */ |
| 130096 | + int iPos /* Position */ |
| 130097 | +){ |
| 130098 | + int i; |
| 130099 | + u64 ret = (u64)iDocid; |
| 130100 | + |
| 130101 | + ret += (ret<<3) + iLangid; |
| 130102 | + ret += (ret<<3) + iIndex; |
| 130103 | + ret += (ret<<3) + iCol; |
| 130104 | + ret += (ret<<3) + iPos; |
| 130105 | + for(i=0; i<nTerm; i++) ret += (ret<<3) + zTerm[i]; |
| 130106 | + |
| 130107 | + return ret; |
| 130108 | +} |
| 130109 | + |
| 130110 | +/* |
| 130111 | +** Return a checksum of all entries in the FTS index that correspond to |
| 130112 | +** language id iLangid. The checksum is calculated by XORing the checksums |
| 130113 | +** of each individual entry (see fts3ChecksumEntry()) together. |
| 130114 | +** |
| 130115 | +** If successful, the checksum value is returned and *pRc set to SQLITE_OK. |
| 130116 | +** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The |
| 130117 | +** return value is undefined in this case. |
| 130118 | +*/ |
| 130119 | +static u64 fts3ChecksumIndex( |
| 130120 | + Fts3Table *p, /* FTS3 table handle */ |
| 130121 | + int iLangid, /* Language id to return cksum for */ |
| 130122 | + int iIndex, /* Index to cksum (0..p->nIndex-1) */ |
| 130123 | + int *pRc /* OUT: Return code */ |
| 130124 | +){ |
| 130125 | + Fts3SegFilter filter; |
| 130126 | + Fts3MultiSegReader csr; |
| 130127 | + int rc; |
| 130128 | + u64 cksum = 0; |
| 130129 | + |
| 130130 | + assert( *pRc==SQLITE_OK ); |
| 130131 | + |
| 130132 | + memset(&filter, 0, sizeof(filter)); |
| 130133 | + memset(&csr, 0, sizeof(csr)); |
| 130134 | + filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY; |
| 130135 | + filter.flags |= FTS3_SEGMENT_SCAN; |
| 130136 | + |
| 130137 | + rc = sqlite3Fts3SegReaderCursor( |
| 130138 | + p, iLangid, iIndex, FTS3_SEGCURSOR_ALL, 0, 0, 0, 1,&csr |
| 130139 | + ); |
| 130140 | + if( rc==SQLITE_OK ){ |
| 130141 | + rc = sqlite3Fts3SegReaderStart(p, &csr, &filter); |
| 130142 | + } |
| 130143 | + |
| 130144 | + if( rc==SQLITE_OK ){ |
| 130145 | + while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){ |
| 130146 | + char *pCsr = csr.aDoclist; |
| 130147 | + char *pEnd = &pCsr[csr.nDoclist]; |
| 130148 | + |
| 130149 | + i64 iDocid = 0; |
| 130150 | + i64 iCol = 0; |
| 130151 | + i64 iPos = 0; |
| 130152 | + |
| 130153 | + pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid); |
| 130154 | + while( pCsr<pEnd ){ |
| 130155 | + i64 iVal = 0; |
| 130156 | + pCsr += sqlite3Fts3GetVarint(pCsr, &iVal); |
| 130157 | + if( pCsr<pEnd ){ |
| 130158 | + if( iVal==0 || iVal==1 ){ |
| 130159 | + iCol = 0; |
| 130160 | + iPos = 0; |
| 130161 | + if( iVal ){ |
| 130162 | + pCsr += sqlite3Fts3GetVarint(pCsr, &iCol); |
| 130163 | + }else{ |
| 130164 | + pCsr += sqlite3Fts3GetVarint(pCsr, &iVal); |
| 130165 | + iDocid += iVal; |
| 130166 | + } |
| 130167 | + }else{ |
| 130168 | + iPos += (iVal - 2); |
| 130169 | + cksum = cksum ^ fts3ChecksumEntry( |
| 130170 | + csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid, |
| 130171 | + (int)iCol, (int)iPos |
| 130172 | + ); |
| 130173 | + } |
| 130174 | + } |
| 130175 | + } |
| 130176 | + } |
| 130177 | + } |
| 130178 | + sqlite3Fts3SegReaderFinish(&csr); |
| 130179 | + |
| 130180 | + *pRc = rc; |
| 130181 | + return cksum; |
| 130182 | +} |
| 130183 | + |
| 130184 | +/* |
| 130185 | +** Check if the contents of the FTS index match the current contents of the |
| 130186 | +** content table. If no error occurs and the contents do match, set *pbOk |
| 130187 | +** to true and return SQLITE_OK. Or if the contents do not match, set *pbOk |
| 130188 | +** to false before returning. |
| 130189 | +** |
| 130190 | +** If an error occurs (e.g. an OOM or IO error), return an SQLite error |
| 130191 | +** code. The final value of *pbOk is undefined in this case. |
| 130192 | +*/ |
| 130193 | +static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){ |
| 130194 | + int rc = SQLITE_OK; /* Return code */ |
| 130195 | + u64 cksum1 = 0; /* Checksum based on FTS index contents */ |
| 130196 | + u64 cksum2 = 0; /* Checksum based on %_content contents */ |
| 130197 | + sqlite3_stmt *pAllLangid = 0; /* Statement to return all language-ids */ |
| 130198 | + |
| 130199 | + /* This block calculates the checksum according to the FTS index. */ |
| 130200 | + rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0); |
| 130201 | + if( rc==SQLITE_OK ){ |
| 130202 | + int rc2; |
| 130203 | + sqlite3_bind_int(pAllLangid, 1, p->nIndex); |
| 130204 | + while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){ |
| 130205 | + int iLangid = sqlite3_column_int(pAllLangid, 0); |
| 130206 | + int i; |
| 130207 | + for(i=0; i<p->nIndex; i++){ |
| 130208 | + cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc); |
| 130209 | + } |
| 130210 | + } |
| 130211 | + rc2 = sqlite3_reset(pAllLangid); |
| 130212 | + if( rc==SQLITE_OK ) rc = rc2; |
| 130213 | + } |
| 130214 | + |
| 130215 | + /* This block calculates the checksum according to the %_content table */ |
| 130216 | + rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0); |
| 130217 | + if( rc==SQLITE_OK ){ |
| 130218 | + sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule; |
| 130219 | + sqlite3_stmt *pStmt = 0; |
| 130220 | + char *zSql; |
| 130221 | + |
| 130222 | + zSql = sqlite3_mprintf("SELECT %s" , p->zReadExprlist); |
| 130223 | + if( !zSql ){ |
| 130224 | + rc = SQLITE_NOMEM; |
| 130225 | + }else{ |
| 130226 | + rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 130227 | + sqlite3_free(zSql); |
| 130228 | + } |
| 130229 | + |
| 130230 | + while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){ |
| 130231 | + i64 iDocid = sqlite3_column_int64(pStmt, 0); |
| 130232 | + int iLang = langidFromSelect(p, pStmt); |
| 130233 | + int iCol; |
| 130234 | + |
| 130235 | + for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){ |
| 130236 | + const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1); |
| 130237 | + int nText = sqlite3_column_bytes(pStmt, iCol+1); |
| 130238 | + sqlite3_tokenizer_cursor *pT = 0; |
| 130239 | + |
| 130240 | + rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT); |
| 130241 | + while( rc==SQLITE_OK ){ |
| 130242 | + char const *zToken; /* Buffer containing token */ |
| 130243 | + int nToken; /* Number of bytes in token */ |
| 130244 | + int iDum1, iDum2; /* Dummy variables */ |
| 130245 | + int iPos; /* Position of token in zText */ |
| 130246 | + |
| 130247 | + rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos); |
| 130248 | + if( rc==SQLITE_OK ){ |
| 130249 | + int i; |
| 130250 | + cksum2 = cksum2 ^ fts3ChecksumEntry( |
| 130251 | + zToken, nToken, iLang, 0, iDocid, iCol, iPos |
| 130252 | + ); |
| 130253 | + for(i=1; i<p->nIndex; i++){ |
| 130254 | + if( p->aIndex[i].nPrefix<=nToken ){ |
| 130255 | + cksum2 = cksum2 ^ fts3ChecksumEntry( |
| 130256 | + zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos |
| 130257 | + ); |
| 130258 | + } |
| 130259 | + } |
| 130260 | + } |
| 130261 | + } |
| 130262 | + if( pT ) pModule->xClose(pT); |
| 130263 | + if( rc==SQLITE_DONE ) rc = SQLITE_OK; |
| 130264 | + } |
| 130265 | + } |
| 130266 | + |
| 130267 | + sqlite3_finalize(pStmt); |
| 130268 | + } |
| 130269 | + |
| 130270 | + *pbOk = (cksum1==cksum2); |
| 130271 | + return rc; |
| 130272 | +} |
| 130273 | + |
| 130274 | +/* |
| 130275 | +** Run the integrity-check. If no error occurs and the current contents of |
| 130276 | +** the FTS index are correct, return SQLITE_OK. Or, if the contents of the |
| 130277 | +** FTS index are incorrect, return SQLITE_CORRUPT_VTAB. |
| 130278 | +** |
| 130279 | +** Or, if an error (e.g. an OOM or IO error) occurs, return an SQLite |
| 130280 | +** error code. |
| 130281 | +** |
| 130282 | +** The integrity-check works as follows. For each token and indexed token |
| 130283 | +** prefix in the document set, a 64-bit checksum is calculated (by code |
| 130284 | +** in fts3ChecksumEntry()) based on the following: |
| 130285 | +** |
| 130286 | +** + The index number (0 for the main index, 1 for the first prefix |
| 130287 | +** index etc.), |
| 130288 | +** + The token (or token prefix) text itself, |
| 130289 | +** + The language-id of the row it appears in, |
| 130290 | +** + The docid of the row it appears in, |
| 130291 | +** + The column it appears in, and |
| 130292 | +** + The tokens position within that column. |
| 130293 | +** |
| 130294 | +** The checksums for all entries in the index are XORed together to create |
| 130295 | +** a single checksum for the entire index. |
| 130296 | +** |
| 130297 | +** The integrity-check code calculates the same checksum in two ways: |
| 130298 | +** |
| 130299 | +** 1. By scanning the contents of the FTS index, and |
| 130300 | +** 2. By scanning and tokenizing the content table. |
| 130301 | +** |
| 130302 | +** If the two checksums are identical, the integrity-check is deemed to have |
| 130303 | +** passed. |
| 130304 | +*/ |
| 130305 | +static int fts3DoIntegrityCheck( |
| 130306 | + Fts3Table *p /* FTS3 table handle */ |
| 130307 | +){ |
| 130308 | + int rc; |
| 130309 | + int bOk = 0; |
| 130310 | + rc = fts3IntegrityCheck(p, &bOk); |
| 130311 | + if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_CORRUPT_VTAB; |
| 130312 | + return rc; |
| 130313 | +} |
| 130314 | + |
| 128197 | 130315 | /* |
| 128198 | 130316 | ** Handle a 'special' INSERT of the form: |
| 128199 | 130317 | ** |
| 128200 | 130318 | ** "INSERT INTO tbl(tbl) VALUES(<expr>)" |
| 128201 | 130319 | ** |
| | @@ -128211,10 +130329,16 @@ |
| 128211 | 130329 | return SQLITE_NOMEM; |
| 128212 | 130330 | }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){ |
| 128213 | 130331 | rc = fts3DoOptimize(p, 0); |
| 128214 | 130332 | }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, "rebuild", 7) ){ |
| 128215 | 130333 | rc = fts3DoRebuild(p); |
| 130334 | + }else if( nVal==15 && 0==sqlite3_strnicmp(zVal, "integrity-check", 15) ){ |
| 130335 | + rc = fts3DoIntegrityCheck(p); |
| 130336 | + }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){ |
| 130337 | + rc = fts3DoIncrmerge(p, &zVal[6]); |
| 130338 | + }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){ |
| 130339 | + rc = fts3DoAutoincrmerge(p, &zVal[10]); |
| 128216 | 130340 | #ifdef SQLITE_TEST |
| 128217 | 130341 | }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){ |
| 128218 | 130342 | p->nNodeSize = atoi(&zVal[9]); |
| 128219 | 130343 | rc = SQLITE_OK; |
| 128220 | 130344 | }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){ |
| | @@ -128406,11 +130530,11 @@ |
| 128406 | 130530 | /* |
| 128407 | 130531 | ** This function does the work for the xUpdate method of FTS3 virtual |
| 128408 | 130532 | ** tables. The schema of the virtual table being: |
| 128409 | 130533 | ** |
| 128410 | 130534 | ** CREATE TABLE <table name>( |
| 128411 | | -** <user COLUMns>, |
| 130535 | +** <user columns>, |
| 128412 | 130536 | ** <table name> HIDDEN, |
| 128413 | 130537 | ** docid HIDDEN, |
| 128414 | 130538 | ** <langid> HIDDEN |
| 128415 | 130539 | ** ); |
| 128416 | 130540 | ** |
| | @@ -128538,11 +130662,11 @@ |
| 128538 | 130662 | fts3InsertDocsize(&rc, p, aSzIns); |
| 128539 | 130663 | } |
| 128540 | 130664 | nChng++; |
| 128541 | 130665 | } |
| 128542 | 130666 | |
| 128543 | | - if( p->bHasStat ){ |
| 130667 | + if( p->bFts4 ){ |
| 128544 | 130668 | fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng); |
| 128545 | 130669 | } |
| 128546 | 130670 | |
| 128547 | 130671 | update_out: |
| 128548 | 130672 | sqlite3_free(aSzIns); |
| | @@ -129369,12 +131493,12 @@ |
| 129369 | 131493 | char cArg, |
| 129370 | 131494 | char **pzErr |
| 129371 | 131495 | ){ |
| 129372 | 131496 | if( (cArg==FTS3_MATCHINFO_NPHRASE) |
| 129373 | 131497 | || (cArg==FTS3_MATCHINFO_NCOL) |
| 129374 | | - || (cArg==FTS3_MATCHINFO_NDOC && pTab->bHasStat) |
| 129375 | | - || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bHasStat) |
| 131498 | + || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4) |
| 131499 | + || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4) |
| 129376 | 131500 | || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize) |
| 129377 | 131501 | || (cArg==FTS3_MATCHINFO_LCS) |
| 129378 | 131502 | || (cArg==FTS3_MATCHINFO_HITS) |
| 129379 | 131503 | ){ |
| 129380 | 131504 | return SQLITE_OK; |
| | @@ -133134,12 +135258,12 @@ |
| 133134 | 135258 | } |
| 133135 | 135259 | |
| 133136 | 135260 | sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); |
| 133137 | 135261 | |
| 133138 | 135262 | /* Allocate the sqlite3_vtab structure */ |
| 133139 | | - nDb = strlen(argv[1]); |
| 133140 | | - nName = strlen(argv[2]); |
| 135263 | + nDb = (int)strlen(argv[1]); |
| 135264 | + nName = (int)strlen(argv[2]); |
| 133141 | 135265 | pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2); |
| 133142 | 135266 | if( !pRtree ){ |
| 133143 | 135267 | return SQLITE_NOMEM; |
| 133144 | 135268 | } |
| 133145 | 135269 | memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2); |
| | @@ -133230,14 +135354,14 @@ |
| 133230 | 135354 | RtreeCell cell; |
| 133231 | 135355 | int jj; |
| 133232 | 135356 | |
| 133233 | 135357 | nodeGetCell(&tree, &node, ii, &cell); |
| 133234 | 135358 | sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid); |
| 133235 | | - nCell = strlen(zCell); |
| 135359 | + nCell = (int)strlen(zCell); |
| 133236 | 135360 | for(jj=0; jj<tree.nDim*2; jj++){ |
| 133237 | 135361 | sqlite3_snprintf(512-nCell,&zCell[nCell]," %f",(double)cell.aCoord[jj].f); |
| 133238 | | - nCell = strlen(zCell); |
| 135362 | + nCell = (int)strlen(zCell); |
| 133239 | 135363 | } |
| 133240 | 135364 | |
| 133241 | 135365 | if( zText ){ |
| 133242 | 135366 | char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell); |
| 133243 | 135367 | sqlite3_free(zText); |
| | @@ -133976,11 +136100,14 @@ |
| 133976 | 136100 | int iInput = 0; |
| 133977 | 136101 | int iOut = 0; |
| 133978 | 136102 | |
| 133979 | 136103 | *ppCursor = 0; |
| 133980 | 136104 | |
| 133981 | | - if( nInput<0 ){ |
| 136105 | + if( zInput==0 ){ |
| 136106 | + nInput = 0; |
| 136107 | + zInput = ""; |
| 136108 | + }else if( nInput<0 ){ |
| 133982 | 136109 | nInput = strlen(zInput); |
| 133983 | 136110 | } |
| 133984 | 136111 | nChar = nInput+1; |
| 133985 | 136112 | pCsr = (IcuCursor *)sqlite3_malloc( |
| 133986 | 136113 | sizeof(IcuCursor) + /* IcuCursor */ |
| 133987 | 136114 | |