Fossil SCM
Update the built-in SQLite to 3.12.0 final.
Commit
996705f5aa7c643bd4e8a008888ab3ec9dc86f4a
Parent
57f1eaecb80dcf2…
2 files changed
+95
-56
+1
-1
+95
-56
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -336,11 +336,11 @@ | ||
| 336 | 336 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 337 | 337 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 338 | 338 | */ |
| 339 | 339 | #define SQLITE_VERSION "3.12.0" |
| 340 | 340 | #define SQLITE_VERSION_NUMBER 3012000 |
| 341 | -#define SQLITE_SOURCE_ID "2016-03-22 15:26:03 142cd359d37f1d8d53de32e329523d9a93c7d6e5" | |
| 341 | +#define SQLITE_SOURCE_ID "2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b" | |
| 342 | 342 | |
| 343 | 343 | /* |
| 344 | 344 | ** CAPI3REF: Run-Time Library Version Numbers |
| 345 | 345 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 346 | 346 | ** |
| @@ -9071,12 +9071,12 @@ | ||
| 9071 | 9071 | |
| 9072 | 9072 | /* |
| 9073 | 9073 | ** The suggested maximum number of in-memory pages to use for |
| 9074 | 9074 | ** the main database table and for temporary tables. |
| 9075 | 9075 | ** |
| 9076 | -** IMPLEMENTATION-OF: R-31093-59126 The default suggested cache size | |
| 9077 | -** is 2000*1024 bytes. | |
| 9076 | +** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000, | |
| 9077 | +** which means the cache size is limited to 2048000 bytes of memory. | |
| 9078 | 9078 | ** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be |
| 9079 | 9079 | ** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options. |
| 9080 | 9080 | */ |
| 9081 | 9081 | #ifndef SQLITE_DEFAULT_CACHE_SIZE |
| 9082 | 9082 | # define SQLITE_DEFAULT_CACHE_SIZE -2000 |
| @@ -12538,10 +12538,11 @@ | ||
| 12538 | 12538 | |
| 12539 | 12539 | /* Allowed values for Column.colFlags: |
| 12540 | 12540 | */ |
| 12541 | 12541 | #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ |
| 12542 | 12542 | #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ |
| 12543 | +#define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */ | |
| 12543 | 12544 | |
| 12544 | 12545 | /* |
| 12545 | 12546 | ** A "Collating Sequence" is defined by an instance of the following |
| 12546 | 12547 | ** structure. Conceptually, a collating sequence consists of a name and |
| 12547 | 12548 | ** a comparison routine that defines the order of that sequence. |
| @@ -14241,11 +14242,11 @@ | ||
| 14241 | 14242 | /* |
| 14242 | 14243 | ** Internal function prototypes |
| 14243 | 14244 | */ |
| 14244 | 14245 | SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*); |
| 14245 | 14246 | SQLITE_PRIVATE int sqlite3Strlen30(const char*); |
| 14246 | -SQLITE_PRIVATE const char *sqlite3StrNext(const char*); | |
| 14247 | +SQLITE_PRIVATE char *sqlite3ColumnType(Column*,char*); | |
| 14247 | 14248 | #define sqlite3StrNICmp sqlite3_strnicmp |
| 14248 | 14249 | |
| 14249 | 14250 | SQLITE_PRIVATE int sqlite3MallocInit(void); |
| 14250 | 14251 | SQLITE_PRIVATE void sqlite3MallocEnd(void); |
| 14251 | 14252 | SQLITE_PRIVATE void *sqlite3Malloc(u64); |
| @@ -25497,15 +25498,19 @@ | ||
| 25497 | 25498 | if( z==0 ) return 0; |
| 25498 | 25499 | return 0x3fffffff & (int)strlen(z); |
| 25499 | 25500 | } |
| 25500 | 25501 | |
| 25501 | 25502 | /* |
| 25502 | -** The string z[] is followed immediately by another string. Return | |
| 25503 | -** a poiner to that other string. | |
| 25503 | +** Return the declared type of a column. Or return zDflt if the column | |
| 25504 | +** has no declared type. | |
| 25505 | +** | |
| 25506 | +** The column type is an extra string stored after the zero-terminator on | |
| 25507 | +** the column name if and only if the COLFLAG_HASTYPE flag is set. | |
| 25504 | 25508 | */ |
| 25505 | -SQLITE_PRIVATE const char *sqlite3StrNext(const char *z){ | |
| 25506 | - return z + strlen(z) + 1; | |
| 25509 | +SQLITE_PRIVATE char *sqlite3ColumnType(Column *pCol, char *zDflt){ | |
| 25510 | + if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt; | |
| 25511 | + return pCol->zName + strlen(pCol->zName) + 1; | |
| 25507 | 25512 | } |
| 25508 | 25513 | |
| 25509 | 25514 | /* |
| 25510 | 25515 | ** Helper function for sqlite3Error() - called rarely. Broken out into |
| 25511 | 25516 | ** a separate routine to avoid unnecessary register saves on entry to |
| @@ -35627,15 +35632,27 @@ | ||
| 35627 | 35632 | */ |
| 35628 | 35633 | #ifndef SQLITE_WIN32_HEAP_CREATE |
| 35629 | 35634 | # define SQLITE_WIN32_HEAP_CREATE (TRUE) |
| 35630 | 35635 | #endif |
| 35631 | 35636 | |
| 35637 | +/* | |
| 35638 | + * This is cache size used in the calculation of the initial size of the | |
| 35639 | + * Win32-specific heap. It cannot be negative. | |
| 35640 | + */ | |
| 35641 | +#ifndef SQLITE_WIN32_CACHE_SIZE | |
| 35642 | +# if SQLITE_DEFAULT_CACHE_SIZE>=0 | |
| 35643 | +# define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE) | |
| 35644 | +# else | |
| 35645 | +# define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE)) | |
| 35646 | +# endif | |
| 35647 | +#endif | |
| 35648 | + | |
| 35632 | 35649 | /* |
| 35633 | 35650 | * The initial size of the Win32-specific heap. This value may be zero. |
| 35634 | 35651 | */ |
| 35635 | 35652 | #ifndef SQLITE_WIN32_HEAP_INIT_SIZE |
| 35636 | -# define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_DEFAULT_CACHE_SIZE) * \ | |
| 35653 | +# define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \ | |
| 35637 | 35654 | (SQLITE_DEFAULT_PAGE_SIZE) + 4194304) |
| 35638 | 35655 | #endif |
| 35639 | 35656 | |
| 35640 | 35657 | /* |
| 35641 | 35658 | * The maximum size of the Win32-specific heap. This value may be zero. |
| @@ -40707,11 +40724,11 @@ | ||
| 40707 | 40724 | return nBuf; |
| 40708 | 40725 | #else |
| 40709 | 40726 | EntropyGatherer e; |
| 40710 | 40727 | UNUSED_PARAMETER(pVfs); |
| 40711 | 40728 | memset(zBuf, 0, nBuf); |
| 40712 | -#if defined(_MSC_VER) && _MSC_VER>=1400 | |
| 40729 | +#if defined(_MSC_VER) && _MSC_VER>=1400 && !SQLITE_OS_WINCE | |
| 40713 | 40730 | rand_s((unsigned int*)zBuf); /* rand_s() is not available with MinGW */ |
| 40714 | 40731 | #endif /* defined(_MSC_VER) && _MSC_VER>=1400 */ |
| 40715 | 40732 | e.a = (unsigned char*)zBuf; |
| 40716 | 40733 | e.na = nBuf; |
| 40717 | 40734 | e.nXor = 0; |
| @@ -76978,23 +76995,25 @@ | ||
| 76978 | 76995 | pC->aType[i++] = t; |
| 76979 | 76996 | aOffset[i] = (u32)(offset64 & 0xffffffff); |
| 76980 | 76997 | }while( i<=p2 && zHdr<zEndHdr ); |
| 76981 | 76998 | pC->nHdrParsed = i; |
| 76982 | 76999 | pC->iHdrOffset = (u32)(zHdr - zData); |
| 76983 | - if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); | |
| 76984 | 77000 | |
| 76985 | 77001 | /* The record is corrupt if any of the following are true: |
| 76986 | 77002 | ** (1) the bytes of the header extend past the declared header size |
| 76987 | 77003 | ** (2) the entire header was used but not all data was used |
| 76988 | 77004 | ** (3) the end of the data extends beyond the end of the record. |
| 76989 | 77005 | */ |
| 76990 | 77006 | if( (zHdr>=zEndHdr && (zHdr>zEndHdr || offset64!=pC->payloadSize)) |
| 76991 | 77007 | || (offset64 > pC->payloadSize) |
| 76992 | 77008 | ){ |
| 77009 | + if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); | |
| 76993 | 77010 | rc = SQLITE_CORRUPT_BKPT; |
| 76994 | 77011 | goto abort_due_to_error; |
| 76995 | 77012 | } |
| 77013 | + if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); | |
| 77014 | + | |
| 76996 | 77015 | }else{ |
| 76997 | 77016 | t = 0; |
| 76998 | 77017 | } |
| 76999 | 77018 | |
| 77000 | 77019 | /* If after trying to extract new entries from the header, nHdrParsed is |
| @@ -95509,13 +95528,10 @@ | ||
| 95509 | 95528 | z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2); |
| 95510 | 95529 | if( z==0 ) return; |
| 95511 | 95530 | memcpy(z, pName->z, pName->n); |
| 95512 | 95531 | z[pName->n] = 0; |
| 95513 | 95532 | sqlite3Dequote(z); |
| 95514 | - zType = z + sqlite3Strlen30(z) + 1; | |
| 95515 | - memcpy(zType, pType->z, pType->n); | |
| 95516 | - zType[pType->n] = 0; | |
| 95517 | 95533 | for(i=0; i<p->nCol; i++){ |
| 95518 | 95534 | if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){ |
| 95519 | 95535 | sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); |
| 95520 | 95536 | sqlite3DbFree(db, z); |
| 95521 | 95537 | return; |
| @@ -95539,11 +95555,15 @@ | ||
| 95539 | 95555 | /* If there is no type specified, columns have the default affinity |
| 95540 | 95556 | ** 'BLOB'. */ |
| 95541 | 95557 | pCol->affinity = SQLITE_AFF_BLOB; |
| 95542 | 95558 | pCol->szEst = 1; |
| 95543 | 95559 | }else{ |
| 95560 | + zType = z + sqlite3Strlen30(z) + 1; | |
| 95561 | + memcpy(zType, pType->z, pType->n); | |
| 95562 | + zType[pType->n] = 0; | |
| 95544 | 95563 | pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst); |
| 95564 | + pCol->colFlags |= COLFLAG_HASTYPE; | |
| 95545 | 95565 | } |
| 95546 | 95566 | p->nCol++; |
| 95547 | 95567 | pParse->constraintName.n = 0; |
| 95548 | 95568 | } |
| 95549 | 95569 | |
| @@ -95735,11 +95755,11 @@ | ||
| 95735 | 95755 | int onError, /* What to do with a uniqueness conflict */ |
| 95736 | 95756 | int autoInc, /* True if the AUTOINCREMENT keyword is present */ |
| 95737 | 95757 | int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */ |
| 95738 | 95758 | ){ |
| 95739 | 95759 | Table *pTab = pParse->pNewTable; |
| 95740 | - const char *zName = 0; | |
| 95760 | + Column *pCol = 0; | |
| 95741 | 95761 | int iCol = -1, i; |
| 95742 | 95762 | int nTerm; |
| 95743 | 95763 | if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit; |
| 95744 | 95764 | if( pTab->tabFlags & TF_HasPrimaryKey ){ |
| 95745 | 95765 | sqlite3ErrorMsg(pParse, |
| @@ -95747,12 +95767,12 @@ | ||
| 95747 | 95767 | goto primary_key_exit; |
| 95748 | 95768 | } |
| 95749 | 95769 | pTab->tabFlags |= TF_HasPrimaryKey; |
| 95750 | 95770 | if( pList==0 ){ |
| 95751 | 95771 | iCol = pTab->nCol - 1; |
| 95752 | - pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; | |
| 95753 | - zName = pTab->aCol[iCol].zName; | |
| 95772 | + pCol = &pTab->aCol[iCol]; | |
| 95773 | + pCol->colFlags |= COLFLAG_PRIMKEY; | |
| 95754 | 95774 | nTerm = 1; |
| 95755 | 95775 | }else{ |
| 95756 | 95776 | nTerm = pList->nExpr; |
| 95757 | 95777 | for(i=0; i<nTerm; i++){ |
| 95758 | 95778 | Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr); |
| @@ -95760,21 +95780,21 @@ | ||
| 95760 | 95780 | sqlite3StringToId(pCExpr); |
| 95761 | 95781 | if( pCExpr->op==TK_ID ){ |
| 95762 | 95782 | const char *zCName = pCExpr->u.zToken; |
| 95763 | 95783 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 95764 | 95784 | if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){ |
| 95765 | - pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; | |
| 95766 | - zName = pTab->aCol[iCol].zName; | |
| 95785 | + pCol = &pTab->aCol[iCol]; | |
| 95786 | + pCol->colFlags |= COLFLAG_PRIMKEY; | |
| 95767 | 95787 | break; |
| 95768 | 95788 | } |
| 95769 | 95789 | } |
| 95770 | 95790 | } |
| 95771 | 95791 | } |
| 95772 | 95792 | } |
| 95773 | 95793 | if( nTerm==1 |
| 95774 | - && zName | |
| 95775 | - && sqlite3StrICmp(sqlite3StrNext(zName), "INTEGER")==0 | |
| 95794 | + && pCol | |
| 95795 | + && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0 | |
| 95776 | 95796 | && sortOrder!=SQLITE_SO_DESC |
| 95777 | 95797 | ){ |
| 95778 | 95798 | pTab->iPKey = iCol; |
| 95779 | 95799 | pTab->keyConf = (u8)onError; |
| 95780 | 95800 | assert( autoInc==0 || autoInc==1 ); |
| @@ -108679,11 +108699,10 @@ | ||
| 108679 | 108699 | pParse->nMem = 6; |
| 108680 | 108700 | sqlite3CodeVerifySchema(pParse, iDb); |
| 108681 | 108701 | setAllColumnNames(v, 6, azCol); assert( 6==ArraySize(azCol) ); |
| 108682 | 108702 | sqlite3ViewGetColumnNames(pParse, pTab); |
| 108683 | 108703 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ |
| 108684 | - const char *zName; | |
| 108685 | 108704 | if( IsHiddenColumn(pCol) ){ |
| 108686 | 108705 | nHidden++; |
| 108687 | 108706 | continue; |
| 108688 | 108707 | } |
| 108689 | 108708 | if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){ |
| @@ -108692,15 +108711,14 @@ | ||
| 108692 | 108711 | k = 1; |
| 108693 | 108712 | }else{ |
| 108694 | 108713 | for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){} |
| 108695 | 108714 | } |
| 108696 | 108715 | assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN ); |
| 108697 | - zName = pCol->zName; | |
| 108698 | 108716 | sqlite3VdbeMultiLoad(v, 1, "issisi", |
| 108699 | 108717 | i-nHidden, |
| 108700 | - zName, | |
| 108701 | - sqlite3StrNext(zName), | |
| 108718 | + pCol->zName, | |
| 108719 | + sqlite3ColumnType(pCol,""), | |
| 108702 | 108720 | pCol->notNull ? 1 : 0, |
| 108703 | 108721 | pCol->pDflt ? pCol->pDflt->u.zToken : 0, |
| 108704 | 108722 | k); |
| 108705 | 108723 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); |
| 108706 | 108724 | } |
| @@ -111899,11 +111917,11 @@ | ||
| 111899 | 111917 | if( iCol<0 ){ |
| 111900 | 111918 | zType = "INTEGER"; |
| 111901 | 111919 | zOrigCol = "rowid"; |
| 111902 | 111920 | }else{ |
| 111903 | 111921 | zOrigCol = pTab->aCol[iCol].zName; |
| 111904 | - zType = sqlite3StrNext(zOrigCol); | |
| 111922 | + zType = sqlite3ColumnType(&pTab->aCol[iCol],0); | |
| 111905 | 111923 | estWidth = pTab->aCol[iCol].szEst; |
| 111906 | 111924 | } |
| 111907 | 111925 | zOrigTab = pTab->zName; |
| 111908 | 111926 | if( pNC->pParse ){ |
| 111909 | 111927 | int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema); |
| @@ -111911,11 +111929,11 @@ | ||
| 111911 | 111929 | } |
| 111912 | 111930 | #else |
| 111913 | 111931 | if( iCol<0 ){ |
| 111914 | 111932 | zType = "INTEGER"; |
| 111915 | 111933 | }else{ |
| 111916 | - zType = sqlite3StrNext(pTab->aCol[iCol].zName); | |
| 111934 | + zType = sqlite3ColumnType(&pTab->aCol[iCol],0); | |
| 111917 | 111935 | estWidth = pTab->aCol[iCol].szEst; |
| 111918 | 111936 | } |
| 111919 | 111937 | #endif |
| 111920 | 111938 | } |
| 111921 | 111939 | break; |
| @@ -119190,26 +119208,20 @@ | ||
| 119190 | 119208 | ** the type string. */ |
| 119191 | 119209 | pVTable->pNext = pTab->pVTable; |
| 119192 | 119210 | pTab->pVTable = pVTable; |
| 119193 | 119211 | |
| 119194 | 119212 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 119195 | - char *zType = (char*)sqlite3StrNext(pTab->aCol[iCol].zName); | |
| 119213 | + char *zType = sqlite3ColumnType(&pTab->aCol[iCol], ""); | |
| 119196 | 119214 | int nType; |
| 119197 | 119215 | int i = 0; |
| 119198 | - if( !zType[0] ){ | |
| 119199 | - pTab->tabFlags |= oooHidden; | |
| 119200 | - continue; | |
| 119201 | - } | |
| 119202 | 119216 | nType = sqlite3Strlen30(zType); |
| 119203 | - if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){ | |
| 119204 | - for(i=0; i<nType; i++){ | |
| 119205 | - if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7)) | |
| 119206 | - && (zType[i+7]=='\0' || zType[i+7]==' ') | |
| 119207 | - ){ | |
| 119208 | - i++; | |
| 119209 | - break; | |
| 119210 | - } | |
| 119217 | + for(i=0; i<nType; i++){ | |
| 119218 | + if( 0==sqlite3StrNICmp("hidden", &zType[i], 6) | |
| 119219 | + && (i==0 || zType[i-1]==' ') | |
| 119220 | + && (zType[i+6]=='\0' || zType[i+6]==' ') | |
| 119221 | + ){ | |
| 119222 | + break; | |
| 119211 | 119223 | } |
| 119212 | 119224 | } |
| 119213 | 119225 | if( i<nType ){ |
| 119214 | 119226 | int j; |
| 119215 | 119227 | int nDel = 6 + (zType[i+6] ? 1 : 0); |
| @@ -136523,12 +136535,11 @@ | ||
| 136523 | 136535 | ** |
| 136524 | 136536 | ** 2. The table is not a view and the column name identified an |
| 136525 | 136537 | ** explicitly declared column. Copy meta information from *pCol. |
| 136526 | 136538 | */ |
| 136527 | 136539 | if( pCol ){ |
| 136528 | - zDataType = sqlite3StrNext(pCol->zName); | |
| 136529 | - if( zDataType[0]==0 ) zDataType = 0; | |
| 136540 | + zDataType = sqlite3ColumnType(pCol,0); | |
| 136530 | 136541 | zCollSeq = pCol->zColl; |
| 136531 | 136542 | notnull = pCol->notNull!=0; |
| 136532 | 136543 | primarykey = (pCol->colFlags & COLFLAG_PRIMKEY)!=0; |
| 136533 | 136544 | autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0; |
| 136534 | 136545 | }else{ |
| @@ -169247,10 +169258,14 @@ | ||
| 169247 | 169258 | # define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) |
| 169248 | 169259 | # define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) |
| 169249 | 169260 | |
| 169250 | 169261 | #endif |
| 169251 | 169262 | |
| 169263 | +/* Truncate very long tokens to this many bytes. Hard limit is | |
| 169264 | +** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset | |
| 169265 | +** field that occurs at the start of each leaf page (see fts5_index.c). */ | |
| 169266 | +#define FTS5_MAX_TOKEN_SIZE 32768 | |
| 169252 | 169267 | |
| 169253 | 169268 | /* |
| 169254 | 169269 | ** Maximum number of prefix indexes on single FTS5 table. This must be |
| 169255 | 169270 | ** less than 32. If it is set to anything large than that, an #error |
| 169256 | 169271 | ** directive in fts5_index.c will cause the build to fail. |
| @@ -174637,10 +174652,11 @@ | ||
| 174637 | 174652 | |
| 174638 | 174653 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 174639 | 174654 | |
| 174640 | 174655 | /* If an error has already occurred, this is a no-op */ |
| 174641 | 174656 | if( pCtx->rc!=SQLITE_OK ) return pCtx->rc; |
| 174657 | + if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; | |
| 174642 | 174658 | |
| 174643 | 174659 | if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){ |
| 174644 | 174660 | Fts5ExprTerm *pSyn; |
| 174645 | 174661 | int nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1; |
| 174646 | 174662 | pSyn = (Fts5ExprTerm*)sqlite3_malloc(nByte); |
| @@ -175639,10 +175655,11 @@ | ||
| 175639 | 175655 | Fts5Expr *pExpr = p->pExpr; |
| 175640 | 175656 | int i; |
| 175641 | 175657 | |
| 175642 | 175658 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 175643 | 175659 | |
| 175660 | + if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; | |
| 175644 | 175661 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++; |
| 175645 | 175662 | for(i=0; i<pExpr->nPhrase; i++){ |
| 175646 | 175663 | Fts5ExprTerm *pTerm; |
| 175647 | 175664 | if( p->aPopulator[i].bOk==0 ) continue; |
| 175648 | 175665 | for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){ |
| @@ -178648,10 +178665,22 @@ | ||
| 178648 | 178665 | pIter->iPgidxOff = iPgidx; |
| 178649 | 178666 | |
| 178650 | 178667 | fts5SegIterLoadRowid(p, pIter); |
| 178651 | 178668 | fts5SegIterLoadNPos(p, pIter); |
| 178652 | 178669 | } |
| 178670 | + | |
| 178671 | +static sqlite3_stmt *fts5IdxSelectStmt(Fts5Index *p){ | |
| 178672 | + if( p->pIdxSelect==0 ){ | |
| 178673 | + Fts5Config *pConfig = p->pConfig; | |
| 178674 | + fts5IndexPrepareStmt(p, &p->pIdxSelect, sqlite3_mprintf( | |
| 178675 | + "SELECT pgno FROM '%q'.'%q_idx' WHERE " | |
| 178676 | + "segid=? AND term<=? ORDER BY term DESC LIMIT 1", | |
| 178677 | + pConfig->zDb, pConfig->zName | |
| 178678 | + )); | |
| 178679 | + } | |
| 178680 | + return p->pIdxSelect; | |
| 178681 | +} | |
| 178653 | 178682 | |
| 178654 | 178683 | /* |
| 178655 | 178684 | ** Initialize the object pIter to point to term pTerm/nTerm within segment |
| 178656 | 178685 | ** pSeg. If there is no such term in the index, the iterator is set to EOF. |
| 178657 | 178686 | ** |
| @@ -178666,35 +178695,29 @@ | ||
| 178666 | 178695 | Fts5SegIter *pIter /* Object to populate */ |
| 178667 | 178696 | ){ |
| 178668 | 178697 | int iPg = 1; |
| 178669 | 178698 | int bGe = (flags & FTS5INDEX_QUERY_SCAN); |
| 178670 | 178699 | int bDlidx = 0; /* True if there is a doclist-index */ |
| 178700 | + sqlite3_stmt *pIdxSelect = 0; | |
| 178671 | 178701 | |
| 178672 | 178702 | assert( bGe==0 || (flags & FTS5INDEX_QUERY_DESC)==0 ); |
| 178673 | 178703 | assert( pTerm && nTerm ); |
| 178674 | 178704 | memset(pIter, 0, sizeof(*pIter)); |
| 178675 | 178705 | pIter->pSeg = pSeg; |
| 178676 | 178706 | |
| 178677 | 178707 | /* This block sets stack variable iPg to the leaf page number that may |
| 178678 | 178708 | ** contain term (pTerm/nTerm), if it is present in the segment. */ |
| 178679 | - if( p->pIdxSelect==0 ){ | |
| 178680 | - Fts5Config *pConfig = p->pConfig; | |
| 178681 | - fts5IndexPrepareStmt(p, &p->pIdxSelect, sqlite3_mprintf( | |
| 178682 | - "SELECT pgno FROM '%q'.'%q_idx' WHERE " | |
| 178683 | - "segid=? AND term<=? ORDER BY term DESC LIMIT 1", | |
| 178684 | - pConfig->zDb, pConfig->zName | |
| 178685 | - )); | |
| 178686 | - } | |
| 178709 | + pIdxSelect = fts5IdxSelectStmt(p); | |
| 178687 | 178710 | if( p->rc ) return; |
| 178688 | - sqlite3_bind_int(p->pIdxSelect, 1, pSeg->iSegid); | |
| 178689 | - sqlite3_bind_blob(p->pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC); | |
| 178690 | - if( SQLITE_ROW==sqlite3_step(p->pIdxSelect) ){ | |
| 178691 | - i64 val = sqlite3_column_int(p->pIdxSelect, 0); | |
| 178711 | + sqlite3_bind_int(pIdxSelect, 1, pSeg->iSegid); | |
| 178712 | + sqlite3_bind_blob(pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC); | |
| 178713 | + if( SQLITE_ROW==sqlite3_step(pIdxSelect) ){ | |
| 178714 | + i64 val = sqlite3_column_int(pIdxSelect, 0); | |
| 178692 | 178715 | iPg = (int)(val>>1); |
| 178693 | 178716 | bDlidx = (val & 0x0001); |
| 178694 | 178717 | } |
| 178695 | - p->rc = sqlite3_reset(p->pIdxSelect); | |
| 178718 | + p->rc = sqlite3_reset(pIdxSelect); | |
| 178696 | 178719 | |
| 178697 | 178720 | if( iPg<pSeg->pgnoFirst ){ |
| 178698 | 178721 | iPg = pSeg->pgnoFirst; |
| 178699 | 178722 | bDlidx = 0; |
| 178700 | 178723 | } |
| @@ -179880,10 +179903,21 @@ | ||
| 179880 | 179903 | for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){ |
| 179881 | 179904 | assert( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid ); |
| 179882 | 179905 | } |
| 179883 | 179906 | } |
| 179884 | 179907 | assert( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT ); |
| 179908 | + | |
| 179909 | + { | |
| 179910 | + sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p); | |
| 179911 | + if( p->rc==SQLITE_OK ){ | |
| 179912 | + u8 aBlob[2] = {0xff, 0xff}; | |
| 179913 | + sqlite3_bind_int(pIdxSelect, 1, iSegid); | |
| 179914 | + sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC); | |
| 179915 | + assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW ); | |
| 179916 | + p->rc = sqlite3_reset(pIdxSelect); | |
| 179917 | + } | |
| 179918 | + } | |
| 179885 | 179919 | #endif |
| 179886 | 179920 | } |
| 179887 | 179921 | } |
| 179888 | 179922 | |
| 179889 | 179923 | return iSegid; |
| @@ -180125,10 +180159,13 @@ | ||
| 180125 | 180159 | |
| 180126 | 180160 | static void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){ |
| 180127 | 180161 | static const u8 zero[] = { 0x00, 0x00, 0x00, 0x00 }; |
| 180128 | 180162 | Fts5PageWriter *pPage = &pWriter->writer; |
| 180129 | 180163 | i64 iRowid; |
| 180164 | + | |
| 180165 | +static int nCall = 0; | |
| 180166 | +nCall++; | |
| 180130 | 180167 | |
| 180131 | 180168 | assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) ); |
| 180132 | 180169 | |
| 180133 | 180170 | /* Set the szLeaf header field. */ |
| 180134 | 180171 | assert( 0==fts5GetU16(&pPage->buf.p[2]) ); |
| @@ -185385,11 +185422,11 @@ | ||
| 185385 | 185422 | int nArg, /* Number of args */ |
| 185386 | 185423 | sqlite3_value **apUnused /* Function arguments */ |
| 185387 | 185424 | ){ |
| 185388 | 185425 | assert( nArg==0 ); |
| 185389 | 185426 | UNUSED_PARAM2(nArg, apUnused); |
| 185390 | - sqlite3_result_text(pCtx, "fts5: 2016-03-22 15:01:54 e1ab2d376a72786098125a41c1ea8140fcbd15c6", -1, SQLITE_TRANSIENT); | |
| 185427 | + sqlite3_result_text(pCtx, "fts5: 2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b", -1, SQLITE_TRANSIENT); | |
| 185391 | 185428 | } |
| 185392 | 185429 | |
| 185393 | 185430 | static int fts5Init(sqlite3 *db){ |
| 185394 | 185431 | static const sqlite3_module fts5Mod = { |
| 185395 | 185432 | /* iVersion */ 2, |
| @@ -185872,10 +185909,11 @@ | ||
| 185872 | 185909 | int iUnused2 /* End offset of token */ |
| 185873 | 185910 | ){ |
| 185874 | 185911 | Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext; |
| 185875 | 185912 | Fts5Index *pIdx = pCtx->pStorage->pIndex; |
| 185876 | 185913 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 185914 | + if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; | |
| 185877 | 185915 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ |
| 185878 | 185916 | pCtx->szCol++; |
| 185879 | 185917 | } |
| 185880 | 185918 | return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken); |
| 185881 | 185919 | } |
| @@ -186318,10 +186356,11 @@ | ||
| 186318 | 186356 | int rc = SQLITE_OK; |
| 186319 | 186357 | int iPos; |
| 186320 | 186358 | int iCol; |
| 186321 | 186359 | |
| 186322 | 186360 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 186361 | + if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; | |
| 186323 | 186362 | |
| 186324 | 186363 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ |
| 186325 | 186364 | pCtx->szCol++; |
| 186326 | 186365 | } |
| 186327 | 186366 | |
| 186328 | 186367 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -336,11 +336,11 @@ | |
| 336 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 337 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 338 | */ |
| 339 | #define SQLITE_VERSION "3.12.0" |
| 340 | #define SQLITE_VERSION_NUMBER 3012000 |
| 341 | #define SQLITE_SOURCE_ID "2016-03-22 15:26:03 142cd359d37f1d8d53de32e329523d9a93c7d6e5" |
| 342 | |
| 343 | /* |
| 344 | ** CAPI3REF: Run-Time Library Version Numbers |
| 345 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 346 | ** |
| @@ -9071,12 +9071,12 @@ | |
| 9071 | |
| 9072 | /* |
| 9073 | ** The suggested maximum number of in-memory pages to use for |
| 9074 | ** the main database table and for temporary tables. |
| 9075 | ** |
| 9076 | ** IMPLEMENTATION-OF: R-31093-59126 The default suggested cache size |
| 9077 | ** is 2000*1024 bytes. |
| 9078 | ** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be |
| 9079 | ** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options. |
| 9080 | */ |
| 9081 | #ifndef SQLITE_DEFAULT_CACHE_SIZE |
| 9082 | # define SQLITE_DEFAULT_CACHE_SIZE -2000 |
| @@ -12538,10 +12538,11 @@ | |
| 12538 | |
| 12539 | /* Allowed values for Column.colFlags: |
| 12540 | */ |
| 12541 | #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ |
| 12542 | #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ |
| 12543 | |
| 12544 | /* |
| 12545 | ** A "Collating Sequence" is defined by an instance of the following |
| 12546 | ** structure. Conceptually, a collating sequence consists of a name and |
| 12547 | ** a comparison routine that defines the order of that sequence. |
| @@ -14241,11 +14242,11 @@ | |
| 14241 | /* |
| 14242 | ** Internal function prototypes |
| 14243 | */ |
| 14244 | SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*); |
| 14245 | SQLITE_PRIVATE int sqlite3Strlen30(const char*); |
| 14246 | SQLITE_PRIVATE const char *sqlite3StrNext(const char*); |
| 14247 | #define sqlite3StrNICmp sqlite3_strnicmp |
| 14248 | |
| 14249 | SQLITE_PRIVATE int sqlite3MallocInit(void); |
| 14250 | SQLITE_PRIVATE void sqlite3MallocEnd(void); |
| 14251 | SQLITE_PRIVATE void *sqlite3Malloc(u64); |
| @@ -25497,15 +25498,19 @@ | |
| 25497 | if( z==0 ) return 0; |
| 25498 | return 0x3fffffff & (int)strlen(z); |
| 25499 | } |
| 25500 | |
| 25501 | /* |
| 25502 | ** The string z[] is followed immediately by another string. Return |
| 25503 | ** a poiner to that other string. |
| 25504 | */ |
| 25505 | SQLITE_PRIVATE const char *sqlite3StrNext(const char *z){ |
| 25506 | return z + strlen(z) + 1; |
| 25507 | } |
| 25508 | |
| 25509 | /* |
| 25510 | ** Helper function for sqlite3Error() - called rarely. Broken out into |
| 25511 | ** a separate routine to avoid unnecessary register saves on entry to |
| @@ -35627,15 +35632,27 @@ | |
| 35627 | */ |
| 35628 | #ifndef SQLITE_WIN32_HEAP_CREATE |
| 35629 | # define SQLITE_WIN32_HEAP_CREATE (TRUE) |
| 35630 | #endif |
| 35631 | |
| 35632 | /* |
| 35633 | * The initial size of the Win32-specific heap. This value may be zero. |
| 35634 | */ |
| 35635 | #ifndef SQLITE_WIN32_HEAP_INIT_SIZE |
| 35636 | # define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_DEFAULT_CACHE_SIZE) * \ |
| 35637 | (SQLITE_DEFAULT_PAGE_SIZE) + 4194304) |
| 35638 | #endif |
| 35639 | |
| 35640 | /* |
| 35641 | * The maximum size of the Win32-specific heap. This value may be zero. |
| @@ -40707,11 +40724,11 @@ | |
| 40707 | return nBuf; |
| 40708 | #else |
| 40709 | EntropyGatherer e; |
| 40710 | UNUSED_PARAMETER(pVfs); |
| 40711 | memset(zBuf, 0, nBuf); |
| 40712 | #if defined(_MSC_VER) && _MSC_VER>=1400 |
| 40713 | rand_s((unsigned int*)zBuf); /* rand_s() is not available with MinGW */ |
| 40714 | #endif /* defined(_MSC_VER) && _MSC_VER>=1400 */ |
| 40715 | e.a = (unsigned char*)zBuf; |
| 40716 | e.na = nBuf; |
| 40717 | e.nXor = 0; |
| @@ -76978,23 +76995,25 @@ | |
| 76978 | pC->aType[i++] = t; |
| 76979 | aOffset[i] = (u32)(offset64 & 0xffffffff); |
| 76980 | }while( i<=p2 && zHdr<zEndHdr ); |
| 76981 | pC->nHdrParsed = i; |
| 76982 | pC->iHdrOffset = (u32)(zHdr - zData); |
| 76983 | if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); |
| 76984 | |
| 76985 | /* The record is corrupt if any of the following are true: |
| 76986 | ** (1) the bytes of the header extend past the declared header size |
| 76987 | ** (2) the entire header was used but not all data was used |
| 76988 | ** (3) the end of the data extends beyond the end of the record. |
| 76989 | */ |
| 76990 | if( (zHdr>=zEndHdr && (zHdr>zEndHdr || offset64!=pC->payloadSize)) |
| 76991 | || (offset64 > pC->payloadSize) |
| 76992 | ){ |
| 76993 | rc = SQLITE_CORRUPT_BKPT; |
| 76994 | goto abort_due_to_error; |
| 76995 | } |
| 76996 | }else{ |
| 76997 | t = 0; |
| 76998 | } |
| 76999 | |
| 77000 | /* If after trying to extract new entries from the header, nHdrParsed is |
| @@ -95509,13 +95528,10 @@ | |
| 95509 | z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2); |
| 95510 | if( z==0 ) return; |
| 95511 | memcpy(z, pName->z, pName->n); |
| 95512 | z[pName->n] = 0; |
| 95513 | sqlite3Dequote(z); |
| 95514 | zType = z + sqlite3Strlen30(z) + 1; |
| 95515 | memcpy(zType, pType->z, pType->n); |
| 95516 | zType[pType->n] = 0; |
| 95517 | for(i=0; i<p->nCol; i++){ |
| 95518 | if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){ |
| 95519 | sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); |
| 95520 | sqlite3DbFree(db, z); |
| 95521 | return; |
| @@ -95539,11 +95555,15 @@ | |
| 95539 | /* If there is no type specified, columns have the default affinity |
| 95540 | ** 'BLOB'. */ |
| 95541 | pCol->affinity = SQLITE_AFF_BLOB; |
| 95542 | pCol->szEst = 1; |
| 95543 | }else{ |
| 95544 | pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst); |
| 95545 | } |
| 95546 | p->nCol++; |
| 95547 | pParse->constraintName.n = 0; |
| 95548 | } |
| 95549 | |
| @@ -95735,11 +95755,11 @@ | |
| 95735 | int onError, /* What to do with a uniqueness conflict */ |
| 95736 | int autoInc, /* True if the AUTOINCREMENT keyword is present */ |
| 95737 | int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */ |
| 95738 | ){ |
| 95739 | Table *pTab = pParse->pNewTable; |
| 95740 | const char *zName = 0; |
| 95741 | int iCol = -1, i; |
| 95742 | int nTerm; |
| 95743 | if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit; |
| 95744 | if( pTab->tabFlags & TF_HasPrimaryKey ){ |
| 95745 | sqlite3ErrorMsg(pParse, |
| @@ -95747,12 +95767,12 @@ | |
| 95747 | goto primary_key_exit; |
| 95748 | } |
| 95749 | pTab->tabFlags |= TF_HasPrimaryKey; |
| 95750 | if( pList==0 ){ |
| 95751 | iCol = pTab->nCol - 1; |
| 95752 | pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; |
| 95753 | zName = pTab->aCol[iCol].zName; |
| 95754 | nTerm = 1; |
| 95755 | }else{ |
| 95756 | nTerm = pList->nExpr; |
| 95757 | for(i=0; i<nTerm; i++){ |
| 95758 | Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr); |
| @@ -95760,21 +95780,21 @@ | |
| 95760 | sqlite3StringToId(pCExpr); |
| 95761 | if( pCExpr->op==TK_ID ){ |
| 95762 | const char *zCName = pCExpr->u.zToken; |
| 95763 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 95764 | if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){ |
| 95765 | pTab->aCol[iCol].colFlags |= COLFLAG_PRIMKEY; |
| 95766 | zName = pTab->aCol[iCol].zName; |
| 95767 | break; |
| 95768 | } |
| 95769 | } |
| 95770 | } |
| 95771 | } |
| 95772 | } |
| 95773 | if( nTerm==1 |
| 95774 | && zName |
| 95775 | && sqlite3StrICmp(sqlite3StrNext(zName), "INTEGER")==0 |
| 95776 | && sortOrder!=SQLITE_SO_DESC |
| 95777 | ){ |
| 95778 | pTab->iPKey = iCol; |
| 95779 | pTab->keyConf = (u8)onError; |
| 95780 | assert( autoInc==0 || autoInc==1 ); |
| @@ -108679,11 +108699,10 @@ | |
| 108679 | pParse->nMem = 6; |
| 108680 | sqlite3CodeVerifySchema(pParse, iDb); |
| 108681 | setAllColumnNames(v, 6, azCol); assert( 6==ArraySize(azCol) ); |
| 108682 | sqlite3ViewGetColumnNames(pParse, pTab); |
| 108683 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ |
| 108684 | const char *zName; |
| 108685 | if( IsHiddenColumn(pCol) ){ |
| 108686 | nHidden++; |
| 108687 | continue; |
| 108688 | } |
| 108689 | if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){ |
| @@ -108692,15 +108711,14 @@ | |
| 108692 | k = 1; |
| 108693 | }else{ |
| 108694 | for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){} |
| 108695 | } |
| 108696 | assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN ); |
| 108697 | zName = pCol->zName; |
| 108698 | sqlite3VdbeMultiLoad(v, 1, "issisi", |
| 108699 | i-nHidden, |
| 108700 | zName, |
| 108701 | sqlite3StrNext(zName), |
| 108702 | pCol->notNull ? 1 : 0, |
| 108703 | pCol->pDflt ? pCol->pDflt->u.zToken : 0, |
| 108704 | k); |
| 108705 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); |
| 108706 | } |
| @@ -111899,11 +111917,11 @@ | |
| 111899 | if( iCol<0 ){ |
| 111900 | zType = "INTEGER"; |
| 111901 | zOrigCol = "rowid"; |
| 111902 | }else{ |
| 111903 | zOrigCol = pTab->aCol[iCol].zName; |
| 111904 | zType = sqlite3StrNext(zOrigCol); |
| 111905 | estWidth = pTab->aCol[iCol].szEst; |
| 111906 | } |
| 111907 | zOrigTab = pTab->zName; |
| 111908 | if( pNC->pParse ){ |
| 111909 | int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema); |
| @@ -111911,11 +111929,11 @@ | |
| 111911 | } |
| 111912 | #else |
| 111913 | if( iCol<0 ){ |
| 111914 | zType = "INTEGER"; |
| 111915 | }else{ |
| 111916 | zType = sqlite3StrNext(pTab->aCol[iCol].zName); |
| 111917 | estWidth = pTab->aCol[iCol].szEst; |
| 111918 | } |
| 111919 | #endif |
| 111920 | } |
| 111921 | break; |
| @@ -119190,26 +119208,20 @@ | |
| 119190 | ** the type string. */ |
| 119191 | pVTable->pNext = pTab->pVTable; |
| 119192 | pTab->pVTable = pVTable; |
| 119193 | |
| 119194 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 119195 | char *zType = (char*)sqlite3StrNext(pTab->aCol[iCol].zName); |
| 119196 | int nType; |
| 119197 | int i = 0; |
| 119198 | if( !zType[0] ){ |
| 119199 | pTab->tabFlags |= oooHidden; |
| 119200 | continue; |
| 119201 | } |
| 119202 | nType = sqlite3Strlen30(zType); |
| 119203 | if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){ |
| 119204 | for(i=0; i<nType; i++){ |
| 119205 | if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7)) |
| 119206 | && (zType[i+7]=='\0' || zType[i+7]==' ') |
| 119207 | ){ |
| 119208 | i++; |
| 119209 | break; |
| 119210 | } |
| 119211 | } |
| 119212 | } |
| 119213 | if( i<nType ){ |
| 119214 | int j; |
| 119215 | int nDel = 6 + (zType[i+6] ? 1 : 0); |
| @@ -136523,12 +136535,11 @@ | |
| 136523 | ** |
| 136524 | ** 2. The table is not a view and the column name identified an |
| 136525 | ** explicitly declared column. Copy meta information from *pCol. |
| 136526 | */ |
| 136527 | if( pCol ){ |
| 136528 | zDataType = sqlite3StrNext(pCol->zName); |
| 136529 | if( zDataType[0]==0 ) zDataType = 0; |
| 136530 | zCollSeq = pCol->zColl; |
| 136531 | notnull = pCol->notNull!=0; |
| 136532 | primarykey = (pCol->colFlags & COLFLAG_PRIMKEY)!=0; |
| 136533 | autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0; |
| 136534 | }else{ |
| @@ -169247,10 +169258,14 @@ | |
| 169247 | # define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) |
| 169248 | # define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) |
| 169249 | |
| 169250 | #endif |
| 169251 | |
| 169252 | |
| 169253 | /* |
| 169254 | ** Maximum number of prefix indexes on single FTS5 table. This must be |
| 169255 | ** less than 32. If it is set to anything large than that, an #error |
| 169256 | ** directive in fts5_index.c will cause the build to fail. |
| @@ -174637,10 +174652,11 @@ | |
| 174637 | |
| 174638 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 174639 | |
| 174640 | /* If an error has already occurred, this is a no-op */ |
| 174641 | if( pCtx->rc!=SQLITE_OK ) return pCtx->rc; |
| 174642 | |
| 174643 | if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){ |
| 174644 | Fts5ExprTerm *pSyn; |
| 174645 | int nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1; |
| 174646 | pSyn = (Fts5ExprTerm*)sqlite3_malloc(nByte); |
| @@ -175639,10 +175655,11 @@ | |
| 175639 | Fts5Expr *pExpr = p->pExpr; |
| 175640 | int i; |
| 175641 | |
| 175642 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 175643 | |
| 175644 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++; |
| 175645 | for(i=0; i<pExpr->nPhrase; i++){ |
| 175646 | Fts5ExprTerm *pTerm; |
| 175647 | if( p->aPopulator[i].bOk==0 ) continue; |
| 175648 | for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){ |
| @@ -178648,10 +178665,22 @@ | |
| 178648 | pIter->iPgidxOff = iPgidx; |
| 178649 | |
| 178650 | fts5SegIterLoadRowid(p, pIter); |
| 178651 | fts5SegIterLoadNPos(p, pIter); |
| 178652 | } |
| 178653 | |
| 178654 | /* |
| 178655 | ** Initialize the object pIter to point to term pTerm/nTerm within segment |
| 178656 | ** pSeg. If there is no such term in the index, the iterator is set to EOF. |
| 178657 | ** |
| @@ -178666,35 +178695,29 @@ | |
| 178666 | Fts5SegIter *pIter /* Object to populate */ |
| 178667 | ){ |
| 178668 | int iPg = 1; |
| 178669 | int bGe = (flags & FTS5INDEX_QUERY_SCAN); |
| 178670 | int bDlidx = 0; /* True if there is a doclist-index */ |
| 178671 | |
| 178672 | assert( bGe==0 || (flags & FTS5INDEX_QUERY_DESC)==0 ); |
| 178673 | assert( pTerm && nTerm ); |
| 178674 | memset(pIter, 0, sizeof(*pIter)); |
| 178675 | pIter->pSeg = pSeg; |
| 178676 | |
| 178677 | /* This block sets stack variable iPg to the leaf page number that may |
| 178678 | ** contain term (pTerm/nTerm), if it is present in the segment. */ |
| 178679 | if( p->pIdxSelect==0 ){ |
| 178680 | Fts5Config *pConfig = p->pConfig; |
| 178681 | fts5IndexPrepareStmt(p, &p->pIdxSelect, sqlite3_mprintf( |
| 178682 | "SELECT pgno FROM '%q'.'%q_idx' WHERE " |
| 178683 | "segid=? AND term<=? ORDER BY term DESC LIMIT 1", |
| 178684 | pConfig->zDb, pConfig->zName |
| 178685 | )); |
| 178686 | } |
| 178687 | if( p->rc ) return; |
| 178688 | sqlite3_bind_int(p->pIdxSelect, 1, pSeg->iSegid); |
| 178689 | sqlite3_bind_blob(p->pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC); |
| 178690 | if( SQLITE_ROW==sqlite3_step(p->pIdxSelect) ){ |
| 178691 | i64 val = sqlite3_column_int(p->pIdxSelect, 0); |
| 178692 | iPg = (int)(val>>1); |
| 178693 | bDlidx = (val & 0x0001); |
| 178694 | } |
| 178695 | p->rc = sqlite3_reset(p->pIdxSelect); |
| 178696 | |
| 178697 | if( iPg<pSeg->pgnoFirst ){ |
| 178698 | iPg = pSeg->pgnoFirst; |
| 178699 | bDlidx = 0; |
| 178700 | } |
| @@ -179880,10 +179903,21 @@ | |
| 179880 | for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){ |
| 179881 | assert( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid ); |
| 179882 | } |
| 179883 | } |
| 179884 | assert( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT ); |
| 179885 | #endif |
| 179886 | } |
| 179887 | } |
| 179888 | |
| 179889 | return iSegid; |
| @@ -180125,10 +180159,13 @@ | |
| 180125 | |
| 180126 | static void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){ |
| 180127 | static const u8 zero[] = { 0x00, 0x00, 0x00, 0x00 }; |
| 180128 | Fts5PageWriter *pPage = &pWriter->writer; |
| 180129 | i64 iRowid; |
| 180130 | |
| 180131 | assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) ); |
| 180132 | |
| 180133 | /* Set the szLeaf header field. */ |
| 180134 | assert( 0==fts5GetU16(&pPage->buf.p[2]) ); |
| @@ -185385,11 +185422,11 @@ | |
| 185385 | int nArg, /* Number of args */ |
| 185386 | sqlite3_value **apUnused /* Function arguments */ |
| 185387 | ){ |
| 185388 | assert( nArg==0 ); |
| 185389 | UNUSED_PARAM2(nArg, apUnused); |
| 185390 | sqlite3_result_text(pCtx, "fts5: 2016-03-22 15:01:54 e1ab2d376a72786098125a41c1ea8140fcbd15c6", -1, SQLITE_TRANSIENT); |
| 185391 | } |
| 185392 | |
| 185393 | static int fts5Init(sqlite3 *db){ |
| 185394 | static const sqlite3_module fts5Mod = { |
| 185395 | /* iVersion */ 2, |
| @@ -185872,10 +185909,11 @@ | |
| 185872 | int iUnused2 /* End offset of token */ |
| 185873 | ){ |
| 185874 | Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext; |
| 185875 | Fts5Index *pIdx = pCtx->pStorage->pIndex; |
| 185876 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 185877 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ |
| 185878 | pCtx->szCol++; |
| 185879 | } |
| 185880 | return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken); |
| 185881 | } |
| @@ -186318,10 +186356,11 @@ | |
| 186318 | int rc = SQLITE_OK; |
| 186319 | int iPos; |
| 186320 | int iCol; |
| 186321 | |
| 186322 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 186323 | |
| 186324 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ |
| 186325 | pCtx->szCol++; |
| 186326 | } |
| 186327 | |
| 186328 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -336,11 +336,11 @@ | |
| 336 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 337 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 338 | */ |
| 339 | #define SQLITE_VERSION "3.12.0" |
| 340 | #define SQLITE_VERSION_NUMBER 3012000 |
| 341 | #define SQLITE_SOURCE_ID "2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b" |
| 342 | |
| 343 | /* |
| 344 | ** CAPI3REF: Run-Time Library Version Numbers |
| 345 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 346 | ** |
| @@ -9071,12 +9071,12 @@ | |
| 9071 | |
| 9072 | /* |
| 9073 | ** The suggested maximum number of in-memory pages to use for |
| 9074 | ** the main database table and for temporary tables. |
| 9075 | ** |
| 9076 | ** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000, |
| 9077 | ** which means the cache size is limited to 2048000 bytes of memory. |
| 9078 | ** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be |
| 9079 | ** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options. |
| 9080 | */ |
| 9081 | #ifndef SQLITE_DEFAULT_CACHE_SIZE |
| 9082 | # define SQLITE_DEFAULT_CACHE_SIZE -2000 |
| @@ -12538,10 +12538,11 @@ | |
| 12538 | |
| 12539 | /* Allowed values for Column.colFlags: |
| 12540 | */ |
| 12541 | #define COLFLAG_PRIMKEY 0x0001 /* Column is part of the primary key */ |
| 12542 | #define COLFLAG_HIDDEN 0x0002 /* A hidden column in a virtual table */ |
| 12543 | #define COLFLAG_HASTYPE 0x0004 /* Type name follows column name */ |
| 12544 | |
| 12545 | /* |
| 12546 | ** A "Collating Sequence" is defined by an instance of the following |
| 12547 | ** structure. Conceptually, a collating sequence consists of a name and |
| 12548 | ** a comparison routine that defines the order of that sequence. |
| @@ -14241,11 +14242,11 @@ | |
| 14242 | /* |
| 14243 | ** Internal function prototypes |
| 14244 | */ |
| 14245 | SQLITE_PRIVATE int sqlite3StrICmp(const char*,const char*); |
| 14246 | SQLITE_PRIVATE int sqlite3Strlen30(const char*); |
| 14247 | SQLITE_PRIVATE char *sqlite3ColumnType(Column*,char*); |
| 14248 | #define sqlite3StrNICmp sqlite3_strnicmp |
| 14249 | |
| 14250 | SQLITE_PRIVATE int sqlite3MallocInit(void); |
| 14251 | SQLITE_PRIVATE void sqlite3MallocEnd(void); |
| 14252 | SQLITE_PRIVATE void *sqlite3Malloc(u64); |
| @@ -25497,15 +25498,19 @@ | |
| 25498 | if( z==0 ) return 0; |
| 25499 | return 0x3fffffff & (int)strlen(z); |
| 25500 | } |
| 25501 | |
| 25502 | /* |
| 25503 | ** Return the declared type of a column. Or return zDflt if the column |
| 25504 | ** has no declared type. |
| 25505 | ** |
| 25506 | ** The column type is an extra string stored after the zero-terminator on |
| 25507 | ** the column name if and only if the COLFLAG_HASTYPE flag is set. |
| 25508 | */ |
| 25509 | SQLITE_PRIVATE char *sqlite3ColumnType(Column *pCol, char *zDflt){ |
| 25510 | if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt; |
| 25511 | return pCol->zName + strlen(pCol->zName) + 1; |
| 25512 | } |
| 25513 | |
| 25514 | /* |
| 25515 | ** Helper function for sqlite3Error() - called rarely. Broken out into |
| 25516 | ** a separate routine to avoid unnecessary register saves on entry to |
| @@ -35627,15 +35632,27 @@ | |
| 35632 | */ |
| 35633 | #ifndef SQLITE_WIN32_HEAP_CREATE |
| 35634 | # define SQLITE_WIN32_HEAP_CREATE (TRUE) |
| 35635 | #endif |
| 35636 | |
| 35637 | /* |
| 35638 | * This is cache size used in the calculation of the initial size of the |
| 35639 | * Win32-specific heap. It cannot be negative. |
| 35640 | */ |
| 35641 | #ifndef SQLITE_WIN32_CACHE_SIZE |
| 35642 | # if SQLITE_DEFAULT_CACHE_SIZE>=0 |
| 35643 | # define SQLITE_WIN32_CACHE_SIZE (SQLITE_DEFAULT_CACHE_SIZE) |
| 35644 | # else |
| 35645 | # define SQLITE_WIN32_CACHE_SIZE (-(SQLITE_DEFAULT_CACHE_SIZE)) |
| 35646 | # endif |
| 35647 | #endif |
| 35648 | |
| 35649 | /* |
| 35650 | * The initial size of the Win32-specific heap. This value may be zero. |
| 35651 | */ |
| 35652 | #ifndef SQLITE_WIN32_HEAP_INIT_SIZE |
| 35653 | # define SQLITE_WIN32_HEAP_INIT_SIZE ((SQLITE_WIN32_CACHE_SIZE) * \ |
| 35654 | (SQLITE_DEFAULT_PAGE_SIZE) + 4194304) |
| 35655 | #endif |
| 35656 | |
| 35657 | /* |
| 35658 | * The maximum size of the Win32-specific heap. This value may be zero. |
| @@ -40707,11 +40724,11 @@ | |
| 40724 | return nBuf; |
| 40725 | #else |
| 40726 | EntropyGatherer e; |
| 40727 | UNUSED_PARAMETER(pVfs); |
| 40728 | memset(zBuf, 0, nBuf); |
| 40729 | #if defined(_MSC_VER) && _MSC_VER>=1400 && !SQLITE_OS_WINCE |
| 40730 | rand_s((unsigned int*)zBuf); /* rand_s() is not available with MinGW */ |
| 40731 | #endif /* defined(_MSC_VER) && _MSC_VER>=1400 */ |
| 40732 | e.a = (unsigned char*)zBuf; |
| 40733 | e.na = nBuf; |
| 40734 | e.nXor = 0; |
| @@ -76978,23 +76995,25 @@ | |
| 76995 | pC->aType[i++] = t; |
| 76996 | aOffset[i] = (u32)(offset64 & 0xffffffff); |
| 76997 | }while( i<=p2 && zHdr<zEndHdr ); |
| 76998 | pC->nHdrParsed = i; |
| 76999 | pC->iHdrOffset = (u32)(zHdr - zData); |
| 77000 | |
| 77001 | /* The record is corrupt if any of the following are true: |
| 77002 | ** (1) the bytes of the header extend past the declared header size |
| 77003 | ** (2) the entire header was used but not all data was used |
| 77004 | ** (3) the end of the data extends beyond the end of the record. |
| 77005 | */ |
| 77006 | if( (zHdr>=zEndHdr && (zHdr>zEndHdr || offset64!=pC->payloadSize)) |
| 77007 | || (offset64 > pC->payloadSize) |
| 77008 | ){ |
| 77009 | if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); |
| 77010 | rc = SQLITE_CORRUPT_BKPT; |
| 77011 | goto abort_due_to_error; |
| 77012 | } |
| 77013 | if( pC->aRow==0 ) sqlite3VdbeMemRelease(&sMem); |
| 77014 | |
| 77015 | }else{ |
| 77016 | t = 0; |
| 77017 | } |
| 77018 | |
| 77019 | /* If after trying to extract new entries from the header, nHdrParsed is |
| @@ -95509,13 +95528,10 @@ | |
| 95528 | z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2); |
| 95529 | if( z==0 ) return; |
| 95530 | memcpy(z, pName->z, pName->n); |
| 95531 | z[pName->n] = 0; |
| 95532 | sqlite3Dequote(z); |
| 95533 | for(i=0; i<p->nCol; i++){ |
| 95534 | if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){ |
| 95535 | sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); |
| 95536 | sqlite3DbFree(db, z); |
| 95537 | return; |
| @@ -95539,11 +95555,15 @@ | |
| 95555 | /* If there is no type specified, columns have the default affinity |
| 95556 | ** 'BLOB'. */ |
| 95557 | pCol->affinity = SQLITE_AFF_BLOB; |
| 95558 | pCol->szEst = 1; |
| 95559 | }else{ |
| 95560 | zType = z + sqlite3Strlen30(z) + 1; |
| 95561 | memcpy(zType, pType->z, pType->n); |
| 95562 | zType[pType->n] = 0; |
| 95563 | pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst); |
| 95564 | pCol->colFlags |= COLFLAG_HASTYPE; |
| 95565 | } |
| 95566 | p->nCol++; |
| 95567 | pParse->constraintName.n = 0; |
| 95568 | } |
| 95569 | |
| @@ -95735,11 +95755,11 @@ | |
| 95755 | int onError, /* What to do with a uniqueness conflict */ |
| 95756 | int autoInc, /* True if the AUTOINCREMENT keyword is present */ |
| 95757 | int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */ |
| 95758 | ){ |
| 95759 | Table *pTab = pParse->pNewTable; |
| 95760 | Column *pCol = 0; |
| 95761 | int iCol = -1, i; |
| 95762 | int nTerm; |
| 95763 | if( pTab==0 || IN_DECLARE_VTAB ) goto primary_key_exit; |
| 95764 | if( pTab->tabFlags & TF_HasPrimaryKey ){ |
| 95765 | sqlite3ErrorMsg(pParse, |
| @@ -95747,12 +95767,12 @@ | |
| 95767 | goto primary_key_exit; |
| 95768 | } |
| 95769 | pTab->tabFlags |= TF_HasPrimaryKey; |
| 95770 | if( pList==0 ){ |
| 95771 | iCol = pTab->nCol - 1; |
| 95772 | pCol = &pTab->aCol[iCol]; |
| 95773 | pCol->colFlags |= COLFLAG_PRIMKEY; |
| 95774 | nTerm = 1; |
| 95775 | }else{ |
| 95776 | nTerm = pList->nExpr; |
| 95777 | for(i=0; i<nTerm; i++){ |
| 95778 | Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr); |
| @@ -95760,21 +95780,21 @@ | |
| 95780 | sqlite3StringToId(pCExpr); |
| 95781 | if( pCExpr->op==TK_ID ){ |
| 95782 | const char *zCName = pCExpr->u.zToken; |
| 95783 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 95784 | if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){ |
| 95785 | pCol = &pTab->aCol[iCol]; |
| 95786 | pCol->colFlags |= COLFLAG_PRIMKEY; |
| 95787 | break; |
| 95788 | } |
| 95789 | } |
| 95790 | } |
| 95791 | } |
| 95792 | } |
| 95793 | if( nTerm==1 |
| 95794 | && pCol |
| 95795 | && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0 |
| 95796 | && sortOrder!=SQLITE_SO_DESC |
| 95797 | ){ |
| 95798 | pTab->iPKey = iCol; |
| 95799 | pTab->keyConf = (u8)onError; |
| 95800 | assert( autoInc==0 || autoInc==1 ); |
| @@ -108679,11 +108699,10 @@ | |
| 108699 | pParse->nMem = 6; |
| 108700 | sqlite3CodeVerifySchema(pParse, iDb); |
| 108701 | setAllColumnNames(v, 6, azCol); assert( 6==ArraySize(azCol) ); |
| 108702 | sqlite3ViewGetColumnNames(pParse, pTab); |
| 108703 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ |
| 108704 | if( IsHiddenColumn(pCol) ){ |
| 108705 | nHidden++; |
| 108706 | continue; |
| 108707 | } |
| 108708 | if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){ |
| @@ -108692,15 +108711,14 @@ | |
| 108711 | k = 1; |
| 108712 | }else{ |
| 108713 | for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){} |
| 108714 | } |
| 108715 | assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN ); |
| 108716 | sqlite3VdbeMultiLoad(v, 1, "issisi", |
| 108717 | i-nHidden, |
| 108718 | pCol->zName, |
| 108719 | sqlite3ColumnType(pCol,""), |
| 108720 | pCol->notNull ? 1 : 0, |
| 108721 | pCol->pDflt ? pCol->pDflt->u.zToken : 0, |
| 108722 | k); |
| 108723 | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); |
| 108724 | } |
| @@ -111899,11 +111917,11 @@ | |
| 111917 | if( iCol<0 ){ |
| 111918 | zType = "INTEGER"; |
| 111919 | zOrigCol = "rowid"; |
| 111920 | }else{ |
| 111921 | zOrigCol = pTab->aCol[iCol].zName; |
| 111922 | zType = sqlite3ColumnType(&pTab->aCol[iCol],0); |
| 111923 | estWidth = pTab->aCol[iCol].szEst; |
| 111924 | } |
| 111925 | zOrigTab = pTab->zName; |
| 111926 | if( pNC->pParse ){ |
| 111927 | int iDb = sqlite3SchemaToIndex(pNC->pParse->db, pTab->pSchema); |
| @@ -111911,11 +111929,11 @@ | |
| 111929 | } |
| 111930 | #else |
| 111931 | if( iCol<0 ){ |
| 111932 | zType = "INTEGER"; |
| 111933 | }else{ |
| 111934 | zType = sqlite3ColumnType(&pTab->aCol[iCol],0); |
| 111935 | estWidth = pTab->aCol[iCol].szEst; |
| 111936 | } |
| 111937 | #endif |
| 111938 | } |
| 111939 | break; |
| @@ -119190,26 +119208,20 @@ | |
| 119208 | ** the type string. */ |
| 119209 | pVTable->pNext = pTab->pVTable; |
| 119210 | pTab->pVTable = pVTable; |
| 119211 | |
| 119212 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 119213 | char *zType = sqlite3ColumnType(&pTab->aCol[iCol], ""); |
| 119214 | int nType; |
| 119215 | int i = 0; |
| 119216 | nType = sqlite3Strlen30(zType); |
| 119217 | for(i=0; i<nType; i++){ |
| 119218 | if( 0==sqlite3StrNICmp("hidden", &zType[i], 6) |
| 119219 | && (i==0 || zType[i-1]==' ') |
| 119220 | && (zType[i+6]=='\0' || zType[i+6]==' ') |
| 119221 | ){ |
| 119222 | break; |
| 119223 | } |
| 119224 | } |
| 119225 | if( i<nType ){ |
| 119226 | int j; |
| 119227 | int nDel = 6 + (zType[i+6] ? 1 : 0); |
| @@ -136523,12 +136535,11 @@ | |
| 136535 | ** |
| 136536 | ** 2. The table is not a view and the column name identified an |
| 136537 | ** explicitly declared column. Copy meta information from *pCol. |
| 136538 | */ |
| 136539 | if( pCol ){ |
| 136540 | zDataType = sqlite3ColumnType(pCol,0); |
| 136541 | zCollSeq = pCol->zColl; |
| 136542 | notnull = pCol->notNull!=0; |
| 136543 | primarykey = (pCol->colFlags & COLFLAG_PRIMKEY)!=0; |
| 136544 | autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0; |
| 136545 | }else{ |
| @@ -169247,10 +169258,14 @@ | |
| 169258 | # define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) |
| 169259 | # define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) |
| 169260 | |
| 169261 | #endif |
| 169262 | |
| 169263 | /* Truncate very long tokens to this many bytes. Hard limit is |
| 169264 | ** (65536-1-1-4-9)==65521 bytes. The limiting factor is the 16-bit offset |
| 169265 | ** field that occurs at the start of each leaf page (see fts5_index.c). */ |
| 169266 | #define FTS5_MAX_TOKEN_SIZE 32768 |
| 169267 | |
| 169268 | /* |
| 169269 | ** Maximum number of prefix indexes on single FTS5 table. This must be |
| 169270 | ** less than 32. If it is set to anything large than that, an #error |
| 169271 | ** directive in fts5_index.c will cause the build to fail. |
| @@ -174637,10 +174652,11 @@ | |
| 174652 | |
| 174653 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 174654 | |
| 174655 | /* If an error has already occurred, this is a no-op */ |
| 174656 | if( pCtx->rc!=SQLITE_OK ) return pCtx->rc; |
| 174657 | if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; |
| 174658 | |
| 174659 | if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){ |
| 174660 | Fts5ExprTerm *pSyn; |
| 174661 | int nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1; |
| 174662 | pSyn = (Fts5ExprTerm*)sqlite3_malloc(nByte); |
| @@ -175639,10 +175655,11 @@ | |
| 175655 | Fts5Expr *pExpr = p->pExpr; |
| 175656 | int i; |
| 175657 | |
| 175658 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 175659 | |
| 175660 | if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; |
| 175661 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 ) p->iOff++; |
| 175662 | for(i=0; i<pExpr->nPhrase; i++){ |
| 175663 | Fts5ExprTerm *pTerm; |
| 175664 | if( p->aPopulator[i].bOk==0 ) continue; |
| 175665 | for(pTerm=&pExpr->apExprPhrase[i]->aTerm[0]; pTerm; pTerm=pTerm->pSynonym){ |
| @@ -178648,10 +178665,22 @@ | |
| 178665 | pIter->iPgidxOff = iPgidx; |
| 178666 | |
| 178667 | fts5SegIterLoadRowid(p, pIter); |
| 178668 | fts5SegIterLoadNPos(p, pIter); |
| 178669 | } |
| 178670 | |
| 178671 | static sqlite3_stmt *fts5IdxSelectStmt(Fts5Index *p){ |
| 178672 | if( p->pIdxSelect==0 ){ |
| 178673 | Fts5Config *pConfig = p->pConfig; |
| 178674 | fts5IndexPrepareStmt(p, &p->pIdxSelect, sqlite3_mprintf( |
| 178675 | "SELECT pgno FROM '%q'.'%q_idx' WHERE " |
| 178676 | "segid=? AND term<=? ORDER BY term DESC LIMIT 1", |
| 178677 | pConfig->zDb, pConfig->zName |
| 178678 | )); |
| 178679 | } |
| 178680 | return p->pIdxSelect; |
| 178681 | } |
| 178682 | |
| 178683 | /* |
| 178684 | ** Initialize the object pIter to point to term pTerm/nTerm within segment |
| 178685 | ** pSeg. If there is no such term in the index, the iterator is set to EOF. |
| 178686 | ** |
| @@ -178666,35 +178695,29 @@ | |
| 178695 | Fts5SegIter *pIter /* Object to populate */ |
| 178696 | ){ |
| 178697 | int iPg = 1; |
| 178698 | int bGe = (flags & FTS5INDEX_QUERY_SCAN); |
| 178699 | int bDlidx = 0; /* True if there is a doclist-index */ |
| 178700 | sqlite3_stmt *pIdxSelect = 0; |
| 178701 | |
| 178702 | assert( bGe==0 || (flags & FTS5INDEX_QUERY_DESC)==0 ); |
| 178703 | assert( pTerm && nTerm ); |
| 178704 | memset(pIter, 0, sizeof(*pIter)); |
| 178705 | pIter->pSeg = pSeg; |
| 178706 | |
| 178707 | /* This block sets stack variable iPg to the leaf page number that may |
| 178708 | ** contain term (pTerm/nTerm), if it is present in the segment. */ |
| 178709 | pIdxSelect = fts5IdxSelectStmt(p); |
| 178710 | if( p->rc ) return; |
| 178711 | sqlite3_bind_int(pIdxSelect, 1, pSeg->iSegid); |
| 178712 | sqlite3_bind_blob(pIdxSelect, 2, pTerm, nTerm, SQLITE_STATIC); |
| 178713 | if( SQLITE_ROW==sqlite3_step(pIdxSelect) ){ |
| 178714 | i64 val = sqlite3_column_int(pIdxSelect, 0); |
| 178715 | iPg = (int)(val>>1); |
| 178716 | bDlidx = (val & 0x0001); |
| 178717 | } |
| 178718 | p->rc = sqlite3_reset(pIdxSelect); |
| 178719 | |
| 178720 | if( iPg<pSeg->pgnoFirst ){ |
| 178721 | iPg = pSeg->pgnoFirst; |
| 178722 | bDlidx = 0; |
| 178723 | } |
| @@ -179880,10 +179903,21 @@ | |
| 179903 | for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){ |
| 179904 | assert( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid ); |
| 179905 | } |
| 179906 | } |
| 179907 | assert( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT ); |
| 179908 | |
| 179909 | { |
| 179910 | sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p); |
| 179911 | if( p->rc==SQLITE_OK ){ |
| 179912 | u8 aBlob[2] = {0xff, 0xff}; |
| 179913 | sqlite3_bind_int(pIdxSelect, 1, iSegid); |
| 179914 | sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC); |
| 179915 | assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW ); |
| 179916 | p->rc = sqlite3_reset(pIdxSelect); |
| 179917 | } |
| 179918 | } |
| 179919 | #endif |
| 179920 | } |
| 179921 | } |
| 179922 | |
| 179923 | return iSegid; |
| @@ -180125,10 +180159,13 @@ | |
| 180159 | |
| 180160 | static void fts5WriteFlushLeaf(Fts5Index *p, Fts5SegWriter *pWriter){ |
| 180161 | static const u8 zero[] = { 0x00, 0x00, 0x00, 0x00 }; |
| 180162 | Fts5PageWriter *pPage = &pWriter->writer; |
| 180163 | i64 iRowid; |
| 180164 | |
| 180165 | static int nCall = 0; |
| 180166 | nCall++; |
| 180167 | |
| 180168 | assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) ); |
| 180169 | |
| 180170 | /* Set the szLeaf header field. */ |
| 180171 | assert( 0==fts5GetU16(&pPage->buf.p[2]) ); |
| @@ -185385,11 +185422,11 @@ | |
| 185422 | int nArg, /* Number of args */ |
| 185423 | sqlite3_value **apUnused /* Function arguments */ |
| 185424 | ){ |
| 185425 | assert( nArg==0 ); |
| 185426 | UNUSED_PARAM2(nArg, apUnused); |
| 185427 | sqlite3_result_text(pCtx, "fts5: 2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b", -1, SQLITE_TRANSIENT); |
| 185428 | } |
| 185429 | |
| 185430 | static int fts5Init(sqlite3 *db){ |
| 185431 | static const sqlite3_module fts5Mod = { |
| 185432 | /* iVersion */ 2, |
| @@ -185872,10 +185909,11 @@ | |
| 185909 | int iUnused2 /* End offset of token */ |
| 185910 | ){ |
| 185911 | Fts5InsertCtx *pCtx = (Fts5InsertCtx*)pContext; |
| 185912 | Fts5Index *pIdx = pCtx->pStorage->pIndex; |
| 185913 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 185914 | if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; |
| 185915 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ |
| 185916 | pCtx->szCol++; |
| 185917 | } |
| 185918 | return sqlite3Fts5IndexWrite(pIdx, pCtx->iCol, pCtx->szCol-1, pToken, nToken); |
| 185919 | } |
| @@ -186318,10 +186356,11 @@ | |
| 186356 | int rc = SQLITE_OK; |
| 186357 | int iPos; |
| 186358 | int iCol; |
| 186359 | |
| 186360 | UNUSED_PARAM2(iUnused1, iUnused2); |
| 186361 | if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; |
| 186362 | |
| 186363 | if( (tflags & FTS5_TOKEN_COLOCATED)==0 || pCtx->szCol==0 ){ |
| 186364 | pCtx->szCol++; |
| 186365 | } |
| 186366 | |
| 186367 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -111,11 +111,11 @@ | ||
| 111 | 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | 113 | */ |
| 114 | 114 | #define SQLITE_VERSION "3.12.0" |
| 115 | 115 | #define SQLITE_VERSION_NUMBER 3012000 |
| 116 | -#define SQLITE_SOURCE_ID "2016-03-22 15:26:03 142cd359d37f1d8d53de32e329523d9a93c7d6e5" | |
| 116 | +#define SQLITE_SOURCE_ID "2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b" | |
| 117 | 117 | |
| 118 | 118 | /* |
| 119 | 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | 121 | ** |
| 122 | 122 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -111,11 +111,11 @@ | |
| 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | */ |
| 114 | #define SQLITE_VERSION "3.12.0" |
| 115 | #define SQLITE_VERSION_NUMBER 3012000 |
| 116 | #define SQLITE_SOURCE_ID "2016-03-22 15:26:03 142cd359d37f1d8d53de32e329523d9a93c7d6e5" |
| 117 | |
| 118 | /* |
| 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | ** |
| 122 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -111,11 +111,11 @@ | |
| 111 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 112 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 113 | */ |
| 114 | #define SQLITE_VERSION "3.12.0" |
| 115 | #define SQLITE_VERSION_NUMBER 3012000 |
| 116 | #define SQLITE_SOURCE_ID "2016-03-29 10:14:15 e9bb4cf40f4971974a74468ef922bdee481c988b" |
| 117 | |
| 118 | /* |
| 119 | ** CAPI3REF: Run-Time Library Version Numbers |
| 120 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 121 | ** |
| 122 |