Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update SQLite core library to the 3.27.0 release. Update version history docs. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
07c06d7ebe53bb1c4c43fdcb46c246a0 |
User & Date: | mistachkin 2019-02-08 02:07:57.845 |
Context
2019-02-08
| ||
02:11 | Pickup the SQLite core library 3.27.0 docs from upstream. check-in: cf08e3867a user: mistachkin tags: trunk | |
02:07 | Update SQLite core library to the 3.27.0 release. Update version history docs. check-in: 07c06d7ebe user: mistachkin tags: trunk | |
2019-02-01
| ||
00:26 | Update the VsWhere tool in externals to the 2.6.7 release. check-in: 43aae424b9 user: mistachkin tags: trunk | |
Changes
Changes to Doc/Extra/Provider/version.html.
︙ | |||
39 40 41 42 43 44 45 | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | - + - + | </td> </tr> </table> </div> <div id="mainSection"> <div id="mainBody"> <h1 class="heading">Version History</h1> |
︙ |
Changes to SQLite.Interop/props/sqlite3.props.
1 2 3 4 5 6 7 8 9 10 11 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | - - + + | <?xml version="1.0" encoding="utf-8"?> <!-- * * sqlite3.props - * * Written by Joe Mistachkin. * Released to the public domain, use at your own risk! * --> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <PropertyGroup Label="UserMacros"> |
︙ |
Changes to SQLite.Interop/props/sqlite3.vsprops.
︙ | |||
10 11 12 13 14 15 16 | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | - + - + | <VisualStudioPropertySheet ProjectType="Visual C++" Version="8.00" Name="sqlite3" > <UserMacro Name="SQLITE_MANIFEST_VERSION" |
︙ |
Changes to SQLite.Interop/src/core/sqlite3.c.
1 2 | 1 2 3 4 5 6 7 8 9 10 | - + | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite |
︙ | |||
1158 1159 1160 1161 1162 1163 1164 | 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 | - - - + + + | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ |
︙ | |||
1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 | 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 | + + + + + + + + + | ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS ** layer a hint of how large the database file will grow to be during the ** current transaction. This hint is not guaranteed to be accurate but it ** is often close. The underlying VFS might choose to preallocate database ** file space based on this hint in order to help writes to the database ** file run faster. ** ** <li>[[SQLITE_FCNTL_SIZE_LIMIT]] ** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that ** implements [sqlite3_deserialize()] to set an upper bound on the size ** of the in-memory database. The argument is a pointer to a [sqlite3_int64]. ** If the integer pointed to is negative, then it is filled in with the ** current limit. Otherwise the limit is set to the larger of the value ** of the integer pointed to and the current database size. The integer ** pointed to is set to the new limit. ** ** <li>[[SQLITE_FCNTL_CHUNK_SIZE]] ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS ** extends and truncates the database file in chunks of a size specified ** by the user. The fourth argument to [sqlite3_file_control()] should ** point to an integer (type int) containing the new chunk-size to use ** for the nominated database. Allocating database file space in large ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
︙ | |||
2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 | 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 | + | #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 #define SQLITE_FCNTL_LOCK_TIMEOUT 34 #define SQLITE_FCNTL_DATA_VERSION 35 #define SQLITE_FCNTL_SIZE_LIMIT 36 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
︙ | |||
3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 | 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 | + + + + + + + + + + + | ** than the configured sorter-reference size threshold - then a reference ** is stored in each sorted record and the required column values loaded ** from the database as records are returned in sorted order. The default ** value for this option is to never use this optimization. Specifying a ** negative value for this option restores the default behaviour. ** This option is only available if SQLite is compiled with the ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. ** ** [[SQLITE_CONFIG_MEMDB_MAXSIZE]] ** <dt>SQLITE_CONFIG_MEMDB_MAXSIZE ** <dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter ** [sqlite3_int64] parameter which is the default maximum size for an in-memory ** database created using [sqlite3_deserialize()]. This default maximum ** size can be adjusted up or down for individual databases using the ** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control]. If this ** configuration setting is never used, then the default maximum is determined ** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that ** compile-time option is not set, then the default maximum is 1073741824. ** </dl> */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ |
︙ | |||
3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 | 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 | + | #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ #define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */ #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ #define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */ #define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** |
︙ | |||
4026 4027 4028 4029 4030 4031 4032 | 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 | - - - + + + | ** ^The callback function registered by sqlite3_profile() is invoked ** as each SQL statement finishes. ^The profile callback contains ** the original statement text and an estimate of wall-clock time ** of how long that statement took to run. ^The profile callback ** time is in units of nanoseconds, however the current implementation ** is only capable of millisecond resolution so the six least significant ** digits in the time are meaningless. Future versions of SQLite |
︙ | |||
4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 | 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 | + + | ** zero is returned. ** ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and ** is not a database file pathname pointer that SQLite passed into the xOpen ** VFS method, then the behavior of this routine is undefined and probably ** undesirable. ** ** See the [URI filename] documentation for additional information. */ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); /* |
︙ | |||
4664 4665 4666 4667 4668 4669 4670 | 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 | - - + + - - - - - - + + + + + + + + + + + | ** and [sqlite3_prepare16_v3()] assume that the prepared statement will ** be used just once or at most a few times and then destroyed using ** [sqlite3_finalize()] relatively soon. The current implementation acts ** on this hint by avoiding the use of [lookaside memory] so as not to ** deplete the limited store of lookaside memory. Future versions of ** SQLite may act on this hint differently. ** |
︙ | |||
11031 11032 11033 11034 11035 11036 11037 | 11060 11061 11062 11063 11064 11065 11066 11067 11068 11069 11070 11071 11072 11073 11074 | - + | ** ** If argument pzTab is not NULL, then *pzTab is set to point to a ** nul-terminated utf-8 encoded string containing the name of the table ** affected by the current change. The buffer remains valid until either ** sqlite3changeset_next() is called on the iterator or until the ** conflict-handler function returns. If pnCol is not NULL, then *pnCol is ** set to the number of columns in the table affected by the change. If |
︙ | |||
12265 12266 12267 12268 12269 12270 12271 | 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 12304 12305 12306 12307 12308 12309 | - - - - - - + + | ** Query for the details of phrase match iIdx within the current row. ** Phrase matches are numbered starting from zero, so the iIdx argument ** should be greater than or equal to zero and smaller than the value ** output by xInstCount(). ** ** Usually, output parameter *piPhrase is set to the phrase number, *piCol ** to the column in which it occurs and *piOff the token offset of the |
︙ | |||
12559 12560 12561 12562 12563 12564 12565 | 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 | - - - - - + + + + + | ** same token for inputs "first" and "1st". Say that token is in ** fact "first", so that when the user inserts the document "I won ** 1st place" entries are added to the index for tokens "i", "won", ** "first" and "place". If the user then queries for '1st + place', ** the tokenizer substitutes "first" for "1st" and the query works ** as expected. ** |
︙ | |||
12587 12588 12589 12590 12591 12592 12593 | 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 | - + | ** Using this method, when tokenizing document text, the tokenizer ** provides multiple synonyms for each token. So that when a ** document such as "I won first place" is tokenized, entries are ** added to the FTS index for "i", "won", "first", "1st" and ** "place". ** ** This way, even if the tokenizer does not provide synonyms |
︙ | |||
14531 14532 14533 14534 14535 14536 14537 14538 14539 14540 14541 14542 14543 14544 | 14556 14557 14558 14559 14560 14561 14562 14563 14564 14565 14566 14567 14568 14569 14570 | + | SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*); #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*); #endif SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*); SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt); SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*); SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*); SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*); SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*); #ifndef SQLITE_OMIT_INCRBLOB SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor*, u32 offset, u32 amt, void*); |
︙ | |||
14770 14771 14772 14773 14774 14775 14776 | 14796 14797 14798 14799 14800 14801 14802 14803 14804 14805 14806 14807 14808 14809 14810 14811 14812 14813 14814 | - - + + - - + - + | # define COLNAME_N 1 /* Store only the name */ # else # define COLNAME_N 2 /* Store the name and decltype */ # endif #endif /* |
︙ | |||
15051 15052 15053 15054 15055 15056 15057 15058 15059 15060 15061 15062 15063 15064 15065 15066 15067 15068 15069 15070 15071 15072 | 15076 15077 15078 15079 15080 15081 15082 15083 15084 15085 15086 15087 15088 15089 15090 15091 15092 15093 15094 15095 15096 15097 15098 15099 15100 15101 15102 15103 15104 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 15121 15122 15123 15124 15125 15126 15127 15128 15129 15130 15131 15132 15133 15134 15135 | + + + + + + - + + + + + | # define ExplainQueryPlan(P) sqlite3VdbeExplain P # define ExplainQueryPlanPop(P) sqlite3VdbeExplainPop(P) # define ExplainQueryPlanParent(P) sqlite3VdbeExplainParent(P) #else # define ExplainQueryPlan(P) # define ExplainQueryPlanPop(P) # define ExplainQueryPlanParent(P) 0 # define sqlite3ExplainBreakpoint(A,B) /*no-op*/ #endif #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN) SQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char*,const char*); #else # define sqlite3ExplainBreakpoint(A,B) /*no-op*/ #endif SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*); SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8); SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1); SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2); SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3); SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5); SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr); SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op); SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); SQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type); SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*); SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int); SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); |
︙ | |||
16212 16213 16214 16215 16216 16217 16218 | 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 | - + + - + + + | const char*); #endif #ifndef SQLITE_OMIT_DEPRECATED /* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing ** in the style of sqlite3_trace() */ |
︙ | |||
16274 16275 16276 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 | 16312 16313 16314 16315 16316 16317 16318 16319 16320 16321 16322 16323 16324 16325 16326 16327 16328 16329 | + + | int nVdbeWrite; /* Number of active VDBEs that read and write */ int nVdbeExec; /* Number of nested calls to VdbeExec() */ int nVDestroy; /* Number of active OP_VDestroy operations */ int nExtension; /* Number of loaded extensions */ void **aExtension; /* Array of shared library handles */ int (*xTrace)(u32,void*,void*,void*); /* Trace function */ void *pTraceArg; /* Argument to the trace function */ #ifndef SQLITE_OMIT_DEPRECATED void (*xProfile)(void*,const char*,u64); /* Profiling function */ void *pProfileArg; /* Argument to profile function */ #endif void *pCommitArg; /* Argument to xCommitCallback() */ int (*xCommitCallback)(void*); /* Invoked at every commit. */ void *pRollbackArg; /* Argument to xRollbackCallback() */ void (*xRollbackCallback)(void*); /* Invoked at every commit. */ void *pUpdateArg; void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64); #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
︙ | |||
16406 16407 16408 16409 16410 16411 16412 16413 16414 16415 16416 16417 16418 16419 | 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 | + | #define HI(X) ((u64)(X)<<32) #ifdef SQLITE_DEBUG #define SQLITE_SqlTrace HI(0x0001) /* Debug print SQL as it executes */ #define SQLITE_VdbeListing HI(0x0002) /* Debug listings of VDBE progs */ #define SQLITE_VdbeTrace HI(0x0004) /* True to trace VDBE execution */ #define SQLITE_VdbeAddopTrace HI(0x0008) /* Trace sqlite3VdbeAddOp() calls */ #define SQLITE_VdbeEQP HI(0x0010) /* Debug EXPLAIN QUERY PLAN */ #define SQLITE_ParserTrace HI(0x0020) /* PRAGMA parser_trace=ON */ #endif /* ** Allowed values for sqlite3.mDbFlags */ #define DBFLAG_SchemaChange 0x0001 /* Uncommitted Hash table changes */ #define DBFLAG_PreferBuiltin 0x0002 /* Preference to built-in funcs */ |
︙ | |||
16808 16809 16810 16811 16812 16813 16814 | 16849 16850 16851 16852 16853 16854 16855 16856 16857 16858 16859 16860 16861 16862 | - - - | /* ** The schema for each SQL table and view is represented in memory ** by an instance of the following structure. */ struct Table { char *zName; /* Name of the table or view */ Column *aCol; /* Information about each column */ |
︙ | |||
17097 17098 17099 17100 17101 17102 17103 | 17135 17136 17137 17138 17139 17140 17141 17142 17143 17144 17145 17146 17147 17148 17149 | - + | Expr *pPartIdxWhere; /* WHERE clause for partial indices */ ExprList *aColExpr; /* Column expressions */ int tnum; /* DB Page containing root of this index */ LogEst szIdxRow; /* Estimated average row size in bytes */ u16 nKeyCol; /* Number of columns forming the key */ u16 nColumn; /* Number of columns stored in the index */ u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ |
︙ | |||
17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 | 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 | + | /* ** Allowed values for Index.idxType */ #define SQLITE_IDXTYPE_APPDEF 0 /* Created using CREATE INDEX */ #define SQLITE_IDXTYPE_UNIQUE 1 /* Implements a UNIQUE constraint */ #define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */ #define SQLITE_IDXTYPE_IPK 3 /* INTEGER PRIMARY KEY index */ /* Return true if index X is a PRIMARY KEY index */ #define IsPrimaryKeyIndex(X) ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY) /* Return true if index X is a UNIQUE index */ #define IsUniqueIndex(X) ((X)->onError!=OE_None) |
︙ | |||
17339 17340 17341 17342 17343 17344 17345 17346 17347 17348 17349 17350 17351 17352 | 17378 17379 17380 17381 17382 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 | + + + + | ** TK_COLUMN: the value of p5 for OP_Column ** TK_AGG_FUNCTION: nesting depth */ AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */ union { Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL ** for a column of an index on an expression */ Window *pWin; /* TK_FUNCTION: Window definition for the func */ struct { /* TK_IN, TK_SELECT, and TK_EXISTS */ int iAddr; /* Subroutine entry address */ int regReturn; /* Register used to hold return address */ } sub; } y; }; /* ** The following are the meanings of bits in the Expr.flags field. */ #define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */ |
︙ | |||
17370 17371 17372 17373 17374 17375 17376 17377 17378 17379 17380 17381 17382 17383 | 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 | + + | #define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */ #define EP_ConstFunc 0x080000 /* A SQLITE_FUNC_CONSTANT or _SLOCHNG function */ #define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */ #define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */ #define EP_Alias 0x400000 /* Is an alias for a result set column */ #define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */ #define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */ #define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */ #define EP_Quoted 0x4000000 /* TK_ID was originally quoted */ /* ** The EP_Propagate mask is a set of properties that automatically propagate ** upwards into parent nodes. */ #define EP_Propagate (EP_Collate|EP_Subquery|EP_HasFunc) |
︙ | |||
17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 | 17958 17959 17960 17961 17962 17963 17964 17965 17966 17967 17968 17969 17970 17971 17972 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 | + - - + + | u8 nested; /* Number of nested calls to the parser/code generator */ u8 nTempReg; /* Number of temporary registers in aTempReg[] */ u8 isMultiWrite; /* True if statement may modify/insert multiple rows */ u8 mayAbort; /* True if statement may throw an ABORT exception */ u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */ u8 okConstFactor; /* OK to factor out constants */ u8 disableLookaside; /* Number of times lookaside has been disabled */ u8 disableVtab; /* Disable all virtual tables for this parse */ int nRangeReg; /* Size of the temporary register block */ int iRangeReg; /* First register in temporary register block */ int nErr; /* Number of errors seen */ int nTab; /* Number of previously allocated VDBE cursors */ int nMem; /* Number of memory cells used so far */ |
︙ | |||
17982 17983 17984 17985 17986 17987 17988 | 18028 18029 18030 18031 18032 18033 18034 18035 18036 18037 18038 18039 18040 18041 18042 18043 18044 | - + + + | #ifndef SQLITE_OMIT_EXPLAIN int addrExplain; /* Address of current OP_Explain opcode */ #endif VList *pVList; /* Mapping between variable names and numbers */ Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */ const char *zTail; /* All SQL text past the last semicolon parsed */ Table *pNewTable; /* A table being constructed by CREATE TABLE */ |
︙ | |||
18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 | 18258 18259 18260 18261 18262 18263 18264 18265 18266 18267 18268 18269 18270 18271 18272 | + | */ typedef struct { sqlite3 *db; /* The database being initialized */ char **pzErrMsg; /* Error message stored here */ int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */ int rc; /* Result code stored here */ u32 mInitFlags; /* Flags controlling error messages */ u32 nInitRow; /* Number of rows processed */ } InitData; /* ** Allowed values for mInitFlags */ #define INITFLAG_AlterTable 0x0001 /* This is a reparse after ALTER TABLE */ |
︙ | |||
18270 18271 18272 18273 18274 18275 18276 18277 18278 18279 18280 18281 18282 18283 | 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 | + + + | #ifdef SQLITE_VDBE_COVERAGE /* The following callback (if not NULL) is invoked on every VDBE branch ** operation. Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE. */ void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */ void *pVdbeBranchArg; /* 1st argument */ #endif #ifdef SQLITE_ENABLE_DESERIALIZE sqlite3_int64 mxMemdbSize; /* Default max memdb size */ #endif #ifndef SQLITE_UNTESTABLE int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */ #endif int bLocaltimeFault; /* True to fail localtime() calls */ int bInternalFunctions; /* Internal SQL functions are visible */ int iOnceResetThreshold; /* When to reset OP_Once counters */ u32 szSorterRef; /* Min size in bytes to use sorter-refs */ |
︙ | |||
18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 18671 | 18710 18711 18712 18713 18714 18715 18716 18717 18718 18719 18720 18721 18722 18723 18724 | + | #endif #endif SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*); SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...); SQLITE_PRIVATE void sqlite3Dequote(char*); SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*); SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*); SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int); SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **); SQLITE_PRIVATE void sqlite3FinishCoding(Parse*); SQLITE_PRIVATE int sqlite3GetTempReg(Parse*); SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int); SQLITE_PRIVATE int sqlite3GetTempRange(Parse*,int); |
︙ | |||
18686 18687 18688 18689 18690 18691 18692 18693 18694 18695 18696 18697 18698 18699 | 18739 18740 18741 18742 18743 18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 | + | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int); SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*); SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*); SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*); SQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index*); SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**); SQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**); SQLITE_PRIVATE int sqlite3InitOne(sqlite3*, int, char**, u32); SQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int); #ifndef SQLITE_OMIT_VIRTUALTABLE SQLITE_PRIVATE Module *sqlite3PragmaVtabRegister(sqlite3*,const char *zName); #endif |
︙ | |||
18719 18720 18721 18722 18723 18724 18725 18726 18727 18728 18729 18730 18731 18732 | 18773 18774 18775 18776 18777 18778 18779 18780 18781 18782 18783 18784 18785 18786 18787 18788 18789 18790 18791 | + + + + + | SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*); SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*); SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*); SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*); SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*, sqlite3_vfs**,char**,char **); #ifdef SQLITE_HAS_CODEC SQLITE_PRIVATE int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*); #else # define sqlite3CodecQueryParameters(A,B,C) 0 #endif SQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*); #ifdef SQLITE_UNTESTABLE # define sqlite3FaultSim(X) SQLITE_OK #else SQLITE_PRIVATE int sqlite3FaultSim(int); #endif |
︙ | |||
18771 18772 18773 18774 18775 18776 18777 | 18830 18831 18832 18833 18834 18835 18836 18837 18838 18839 18840 18841 18842 18843 18844 18845 | - - + + | # define sqlite3AutoincrementBegin(X) # define sqlite3AutoincrementEnd(X) #endif SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*); SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*); SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*); SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*); |
︙ | |||
18839 18840 18841 18842 18843 18844 18845 | 18898 18899 18900 18901 18902 18903 18904 18905 18906 18907 18908 18909 18910 18911 18912 18913 | - - + + | #define LOCATE_VIEW 0x01 #define LOCATE_NOERR 0x02 SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*); SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *); SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*); SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); |
︙ | |||
18878 18879 18880 18881 18882 18883 18884 | 18937 18938 18939 18940 18941 18942 18943 18944 18945 18946 18947 18948 18949 18950 | - - - | #ifdef SQLITE_ENABLE_CURSOR_HINTS SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*); #endif SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*); SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
︙ | |||
18907 18908 18909 18910 18911 18912 18913 | 18963 18964 18965 18966 18967 18968 18969 18970 18971 18972 18973 18974 18975 18976 18977 | - - + - | SQLITE_PRIVATE void sqlite3UniqueConstraint(Parse*, int, Index*); SQLITE_PRIVATE void sqlite3RowidConstraint(Parse*, int, Table*); SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int); SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*); SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int); |
︙ | |||
19114 19115 19116 19117 19118 19119 19120 | 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 | - - - + - + - + | #endif SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, int, int); SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*); SQLITE_PRIVATE void sqlite3AlterFunctions(void); SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*); SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*); SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *); |
︙ | |||
19275 19276 19277 19278 19279 19280 19281 | 19327 19328 19329 19330 19331 19332 19333 19334 19335 19336 19337 19338 19339 19340 19341 | - + | SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *); SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*); SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*); SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int); SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *); SQLITE_PRIVATE void sqlite3ParserReset(Parse*); #ifdef SQLITE_ENABLE_NORMALIZE |
︙ | |||
19371 19372 19373 19374 19375 19376 19377 | 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 | - + | #define IN_INDEX_NOOP 5 /* No table available. Use comparisons */ /* ** Allowed flags for the 3rd parameter to sqlite3FindInIndex(). */ #define IN_INDEX_NOOP_OK 0x0001 /* OK to return IN_INDEX_NOOP */ #define IN_INDEX_MEMBERSHIP 0x0002 /* IN operator used for membership test */ #define IN_INDEX_LOOP 0x0004 /* IN operator used as a loop */ |
︙ | |||
19687 19688 19689 19690 19691 19692 19693 19694 19695 19696 19697 19698 19699 19700 | 19739 19740 19741 19742 19743 19744 19745 19746 19747 19748 19749 19750 19751 19752 19753 19754 19755 19756 19757 19758 19759 | + + + + + + + | ** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE); */ #ifndef SQLITE_DEFAULT_LOOKASIDE # define SQLITE_DEFAULT_LOOKASIDE 1200,100 #endif /* The default maximum size of an in-memory database created using ** sqlite3_deserialize() */ #ifndef SQLITE_MEMDB_DEFAULT_MAXSIZE # define SQLITE_MEMDB_DEFAULT_MAXSIZE 1073741824 #endif /* ** The following singleton contains the global configuration for ** the SQLite library. */ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = { SQLITE_DEFAULT_MEMSTATUS, /* bMemstat */ 1, /* bCoreMutex */ |
︙ | |||
19734 19735 19736 19737 19738 19739 19740 19741 19742 19743 19744 19745 19746 | 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 | + + + - + | 0, /* xSqllog */ 0, /* pSqllogArg */ #endif #ifdef SQLITE_VDBE_COVERAGE 0, /* xVdbeBranch */ 0, /* pVbeBranchArg */ #endif #ifdef SQLITE_ENABLE_DESERIALIZE SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */ #endif #ifndef SQLITE_UNTESTABLE 0, /* xTestCallback */ #endif 0, /* bLocaltimeFault */ 0, /* bInternalFunctions */ 0x7ffffffe, /* iOnceResetThreshold */ |
︙ | |||
20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 | 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 | + + + + + + + + + + + + + + + + - + + + + + - - + + - - - | }; /* A bitfield type for use inside of structures. Always follow with :N where ** N is the number of bits. */ typedef unsigned bft; /* Bit Field Type */ /* The ScanStatus object holds a single value for the ** sqlite3_stmt_scanstatus() interface. */ typedef struct ScanStatus ScanStatus; struct ScanStatus { int addrExplain; /* OP_Explain for loop */ int addrLoop; /* Address of "loops" counter */ int addrVisit; /* Address of "rows visited" counter */ int iSelectID; /* The "Select-ID" for this loop */ LogEst nEst; /* Estimated output rows per loop */ char *zName; /* Name of table or index */ }; /* The DblquoteStr object holds the text of a double-quoted ** string for a prepared statement. A linked list of these objects ** is constructed during statement parsing and is held on Vdbe.pDblStr. ** When computing a normalized SQL statement for an SQL statement, that ** list is consulted for each double-quoted identifier to see if the ** identifier should really be a string literal. */ typedef struct DblquoteStr DblquoteStr; struct DblquoteStr { DblquoteStr *pNextStr; /* Next string literal in the list */ char z[8]; /* Dequoted value for the string */ }; /* ** An instance of the virtual machine. This structure contains the complete ** state of the virtual machine. ** ** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare() ** is really a pointer to an instance of this structure. */ struct Vdbe { sqlite3 *db; /* The database connection that owns this statement */ Vdbe *pPrev,*pNext; /* Linked list of VDBEs with the same Vdbe.db */ Parse *pParse; /* Parsing context used to create this Vdbe */ ynVar nVar; /* Number of entries in aVar[] */ u32 magic; /* Magic number for sanity checking */ int nMem; /* Number of memory locations currently allocated */ int nCursor; /* Number of slots in apCsr[] */ u32 cacheCtr; /* VdbeCursor row cache generation counter */ int pc; /* The program counter */ int rc; /* Value to return */ int nChange; /* Number of db changes made since last reset */ |
︙ | |||
20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 20245 | 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 | + | bft bIsReader:1; /* True for statements that read */ yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ yDbMask lockMask; /* Subset of btreeMask that requires a lock */ u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */ char *zSql; /* Text of the SQL statement that generated this */ #ifdef SQLITE_ENABLE_NORMALIZE char *zNormSql; /* Normalization of the associated SQL statement */ DblquoteStr *pDblStr; /* List of double-quoted string literals */ #endif void *pFree; /* Free this when deleting the vdbe */ VdbeFrame *pFrame; /* Parent frame */ VdbeFrame *pDelFrame; /* List of frame objects to free on VM reset */ int nFrame; /* Number of frames in pFrame list */ u32 expmask; /* Binding to these vars invalidates VM */ SubProgram *pProgram; /* Linked list of all sub-programs used by VM */ |
︙ | |||
27249 27250 27251 27252 27253 27254 27255 27256 27257 27258 27259 27260 27261 27262 | 27329 27330 27331 27332 27333 27334 27335 27336 27337 27338 27339 27340 27341 27342 27343 27344 27345 27346 27347 27348 27349 27350 27351 27352 27353 27354 27355 27356 27357 27358 27359 27360 27361 27362 27363 | + + + + + + + + + + + + + + + + + + + + + | return sqlite3_value_double(p->apArg[p->nUsed++]); } static char *getTextArg(PrintfArguments *p){ if( p->nArg<=p->nUsed ) return 0; return (char*)sqlite3_value_text(p->apArg[p->nUsed++]); } /* ** Allocate memory for a temporary buffer needed for printf rendering. ** ** If the requested size of the temp buffer is larger than the size ** of the output buffer in pAccum, then cause an SQLITE_TOOBIG error. ** Do the size check before the memory allocation to prevent rogue ** SQL from requesting large allocations using the precision or width ** field of the printf() function. */ static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){ char *z; if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){ setStrAccumError(pAccum, SQLITE_TOOBIG); return 0; } z = sqlite3DbMallocRaw(pAccum->db, n); if( z==0 ){ setStrAccumError(pAccum, SQLITE_NOMEM); } return z; } /* ** On machines with a small stack size, you can redefine the ** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired. */ #ifndef SQLITE_PRINT_BUF_SIZE # define SQLITE_PRINT_BUF_SIZE 70 |
︙ | |||
27331 27332 27333 27334 27335 27336 27337 27338 27339 27340 27341 27342 27343 27344 27345 27346 27347 27348 27349 | 27432 27433 27434 27435 27436 27437 27438 27439 27440 27441 27442 27443 27444 27445 27446 27447 27448 27449 27450 27451 27452 27453 27454 27455 27456 27457 27458 27459 27460 27461 27462 27463 27464 27465 27466 27467 27468 27469 27470 27471 27472 27473 27474 27475 27476 27477 27478 27479 27480 27481 27482 27483 27484 27485 27486 27487 27488 27489 27490 27491 27492 27493 27494 27495 27496 27497 27498 27499 27500 27501 27502 27503 27504 27505 27506 27507 27508 27509 27510 27511 27512 27513 27514 27515 27516 27517 27518 27519 27520 27521 27522 27523 27524 27525 27526 27527 27528 27529 27530 27531 27532 27533 27534 27535 27536 27537 27538 27539 27540 27541 27542 27543 27544 27545 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | sqlite3_str_append(pAccum, "%", 1); break; } /* Find out what flags are present */ flag_leftjustify = flag_prefix = cThousand = flag_alternateform = flag_altform2 = flag_zeropad = 0; done = 0; width = 0; flag_long = 0; precision = -1; do{ switch( c ){ case '-': flag_leftjustify = 1; break; case '+': flag_prefix = '+'; break; case ' ': flag_prefix = ' '; break; case '#': flag_alternateform = 1; break; case '!': flag_altform2 = 1; break; case '0': flag_zeropad = 1; break; case ',': cThousand = ','; break; default: done = 1; break; case 'l': { flag_long = 1; c = *++fmt; if( c=='l' ){ c = *++fmt; flag_long = 2; } done = 1; break; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { unsigned wx = c - '0'; while( (c = *++fmt)>='0' && c<='9' ){ wx = wx*10 + c - '0'; } testcase( wx>0x7fffffff ); width = wx & 0x7fffffff; #ifdef SQLITE_PRINTF_PRECISION_LIMIT if( width>SQLITE_PRINTF_PRECISION_LIMIT ){ width = SQLITE_PRINTF_PRECISION_LIMIT; } #endif if( c!='.' && c!='l' ){ done = 1; }else{ fmt--; } break; } case '*': { if( bArgList ){ width = (int)getIntArg(pArgList); }else{ width = va_arg(ap,int); } if( width<0 ){ flag_leftjustify = 1; width = width >= -2147483647 ? -width : 0; } #ifdef SQLITE_PRINTF_PRECISION_LIMIT if( width>SQLITE_PRINTF_PRECISION_LIMIT ){ width = SQLITE_PRINTF_PRECISION_LIMIT; } #endif if( (c = fmt[1])!='.' && c!='l' ){ c = *++fmt; done = 1; } break; } case '.': { c = *++fmt; if( c=='*' ){ if( bArgList ){ precision = (int)getIntArg(pArgList); }else{ precision = va_arg(ap,int); } if( precision<0 ){ precision = precision >= -2147483647 ? -precision : -1; } c = *++fmt; }else{ unsigned px = 0; while( c>='0' && c<='9' ){ px = px*10 + c - '0'; c = *++fmt; } testcase( px>0x7fffffff ); precision = px & 0x7fffffff; } #ifdef SQLITE_PRINTF_PRECISION_LIMIT if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){ precision = SQLITE_PRINTF_PRECISION_LIMIT; } #endif if( c=='l' ){ --fmt; }else{ done = 1; } break; } } }while( !done && (c=(*++fmt))!=0 ); |
︙ | |||
27499 27500 27501 27502 27503 27504 27505 | 27616 27617 27618 27619 27620 27621 27622 27623 27624 27625 27626 27627 27628 27629 27630 27631 27632 27633 27634 | + - - - + + + + - - - | if( flag_zeropad && precision<width-(prefix!=0) ){ precision = width-(prefix!=0); } if( precision<etBUFSIZE-10-etBUFSIZE/3 ){ nOut = etBUFSIZE; zOut = buf; }else{ u64 n; |
︙ | |||
27623 27624 27625 27626 27627 27628 27629 | 27739 27740 27741 27742 27743 27744 27745 27746 27747 27748 27749 27750 27751 27752 27753 27754 27755 27756 27757 27758 | + + - - + + + - - + - - | flag_rtz = flag_altform2; } if( xtype==etEXP ){ e2 = 0; }else{ e2 = exp; } { i64 szBufNeeded; /* Size of a temporary buffer needed */ |
︙ | |||
27852 27853 27854 27855 27856 27857 27858 | 27968 27969 27970 27971 27972 27973 27974 27975 27976 27977 27978 27979 27980 27981 27982 27983 | - - + + - - - | if( flag_altform2 && (ch&0xc0)==0xc0 ){ while( (escarg[i+1]&0xc0)==0x80 ){ i++; } } } needQuote = !isnull && xtype==etSQLESCAPE2; n += i + 3; if( n>etBUFSIZE ){ |
︙ | |||
28482 28483 28484 28485 28486 28487 28488 | 28595 28596 28597 28598 28599 28600 28601 28602 28603 28604 28605 28606 28607 28608 28609 28610 | - + + | sqlite3_str_appendf(&x, "{%d,*}", pItem->iCursor); if( pItem->zDatabase ){ sqlite3_str_appendf(&x, " %s.%s", pItem->zDatabase, pItem->zName); }else if( pItem->zName ){ sqlite3_str_appendf(&x, " %s", pItem->zName); } if( pItem->pTab ){ |
︙ | |||
30222 30223 30224 30225 30226 30227 30228 | 30336 30337 30338 30339 30340 30341 30342 30343 30344 30345 30346 30347 30348 30349 30350 | - + | ** The input string must be zero-terminated. A new zero-terminator ** is added to the dequoted string. ** ** The return value is -1 if no dequoting occurs or the length of the ** dequoted string, exclusive of the zero terminator, if dequoting does ** occur. ** |
︙ | |||
30247 30248 30249 30250 30251 30252 30253 30254 30255 30256 30257 30258 30259 30260 | 30361 30362 30363 30364 30365 30366 30367 30368 30369 30370 30371 30372 30373 30374 30375 30376 30377 30378 30379 | + + + + + | break; } }else{ z[j++] = z[i]; } } z[j] = 0; } SQLITE_PRIVATE void sqlite3DequoteExpr(Expr *p){ assert( sqlite3Isquote(p->u.zToken[0]) ); p->flags |= p->u.zToken[0]=='"' ? EP_Quoted|EP_DblQuoted : EP_Quoted; sqlite3Dequote(p->u.zToken); } /* ** Generate a Token object from a string */ SQLITE_PRIVATE void sqlite3TokenInit(Token *p, char *z){ p->z = z; |
︙ | |||
31675 31676 31677 31678 31679 31680 31681 | 31794 31795 31796 31797 31798 31799 31800 31801 31802 31803 31804 31805 31806 31807 | - - - - - - - - - - - - - - | ** 0x9e3779b1 is 2654435761 which is the closest prime number to ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */ h += sqlite3UpperToLower[c]; h *= 0x9e3779b1; } return h; } |
︙ | |||
31800 31801 31802 31803 31804 31805 31806 | 31905 31906 31907 31908 31909 31910 31911 31912 31913 31914 31915 31916 31917 31918 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | if( sqlite3StrICmp(elem->pKey,pKey)==0 ){ return elem; } elem = elem->next; } return &nullElement; } |
︙ | |||
31878 31879 31880 31881 31882 31883 31884 | 31949 31950 31951 31952 31953 31954 31955 31956 31957 31958 31959 31960 31961 31962 | - - - - - - - - | ** found, or NULL if there is no match. */ SQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){ assert( pH!=0 ); assert( pKey!=0 ); return findElementWithHash(pH, pKey, 0)->data; } |
︙ | |||
46573 46574 46575 46576 46577 46578 46579 | 46636 46637 46638 46639 46640 46641 46642 46643 46644 46645 46646 46647 46648 46649 46650 46651 | + - + | */ #define ORIGVFS(p) ((sqlite3_vfs*)((p)->pAppData)) /* An open file */ struct MemFile { sqlite3_file base; /* IO methods */ sqlite3_int64 sz; /* Size of the file */ sqlite3_int64 szAlloc; /* Space allocated to aData */ |
︙ | |||
46699 46700 46701 46702 46703 46704 46705 46706 46707 46708 | 46763 46764 46765 46766 46767 46768 46769 46770 46771 46772 46773 46774 46775 46776 46777 46778 46779 46780 46781 46782 46783 46784 46785 46786 46787 46788 46789 46790 46791 46792 46793 46794 46795 46796 46797 46798 46799 46800 46801 46802 46803 | + + + + + - + + - - + + | ** Try to enlarge the memory allocation to hold at least sz bytes */ static int memdbEnlarge(MemFile *p, sqlite3_int64 newSz){ unsigned char *pNew; if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){ return SQLITE_FULL; } if( newSz>p->szMax ){ return SQLITE_FULL; } newSz *= 2; if( newSz>p->szMax ) newSz = p->szMax; pNew = sqlite3_realloc64(p->aData, newSz); if( pNew==0 ) return SQLITE_NOMEM; p->aData = pNew; |
︙ | |||
46765 46766 46767 46768 46769 46770 46771 46772 46773 46774 46775 46776 46777 46778 | 46835 46836 46837 46838 46839 46840 46841 46842 46843 46844 46845 46846 46847 46848 46849 46850 46851 46852 46853 | + + + + + | } /* ** Lock an memdb-file. */ static int memdbLock(sqlite3_file *pFile, int eLock){ MemFile *p = (MemFile *)pFile; if( eLock>SQLITE_LOCK_SHARED && (p->mFlags & SQLITE_DESERIALIZE_READONLY)!=0 ){ return SQLITE_READONLY; } p->eLock = eLock; return SQLITE_OK; } #if 0 /* Never used because memdbAccess() always returns false */ /* ** Check if another file-handle holds a RESERVED lock on an memdb-file. |
︙ | |||
46788 46789 46790 46791 46792 46793 46794 46795 46796 46797 46798 46799 46800 46801 | 46863 46864 46865 46866 46867 46868 46869 46870 46871 46872 46873 46874 46875 46876 46877 46878 46879 46880 46881 46882 46883 46884 46885 46886 46887 46888 46889 | + + + + + + + + + + + + + | */ static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){ MemFile *p = (MemFile *)pFile; int rc = SQLITE_NOTFOUND; if( op==SQLITE_FCNTL_VFSNAME ){ *(char**)pArg = sqlite3_mprintf("memdb(%p,%lld)", p->aData, p->sz); rc = SQLITE_OK; } if( op==SQLITE_FCNTL_SIZE_LIMIT ){ sqlite3_int64 iLimit = *(sqlite3_int64*)pArg; if( iLimit<p->sz ){ if( iLimit<0 ){ iLimit = p->szMax; }else{ iLimit = p->sz; } } p->szMax = iLimit; *(sqlite3_int64*)pArg = iLimit; rc = SQLITE_OK; } return rc; } #if 0 /* Not used because of SQLITE_IOCAP_POWERSAFE_OVERWRITE */ /* ** Return the sector-size in bytes for an memdb-file. |
︙ | |||
46819 46820 46821 46822 46823 46824 46825 | 46907 46908 46909 46910 46911 46912 46913 46914 46915 46916 46917 46918 46919 46920 46921 46922 46923 46924 46925 46926 | + + + - - + + + | static int memdbFetch( sqlite3_file *pFile, sqlite3_int64 iOfst, int iAmt, void **pp ){ MemFile *p = (MemFile *)pFile; if( iOfst+iAmt>p->sz ){ *pp = 0; }else{ |
︙ | |||
46850 46851 46852 46853 46854 46855 46856 46857 46858 46859 46860 46861 46862 46863 | 46942 46943 46944 46945 46946 46947 46948 46949 46950 46951 46952 46953 46954 46955 46956 | + | return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFile, flags, pOutFlags); } memset(p, 0, sizeof(*p)); p->mFlags = SQLITE_DESERIALIZE_RESIZEABLE | SQLITE_DESERIALIZE_FREEONCLOSE; assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */ *pOutFlags = flags | SQLITE_OPEN_MEMORY; p->base.pMethods = &memdb_io_methods; p->szMax = sqlite3GlobalConfig.mxMemdbSize; return SQLITE_OK; } #if 0 /* Only used to delete rollback journals, master journals, and WAL ** files, none of which exist in memdb. So this routine is never used */ /* ** Delete the file located at zPath. If the dirSync argument is true, |
︙ | |||
47099 47100 47101 47102 47103 47104 47105 47106 47107 47108 47109 47110 47111 47112 47113 | 47192 47193 47194 47195 47196 47197 47198 47199 47200 47201 47202 47203 47204 47205 47206 47207 47208 47209 47210 | + + + + | } p = memdbFromDbSchema(db, zSchema); if( p==0 ){ rc = SQLITE_ERROR; }else{ p->aData = pData; p->sz = szDb; p->szAlloc = szBuf; p->szMax = szBuf; if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){ p->szMax = sqlite3GlobalConfig.mxMemdbSize; } p->mFlags = mFlags; rc = SQLITE_OK; } end_deserialize: sqlite3_finalize(pStmt); sqlite3_mutex_leave(db->mutex); |
︙ | |||
48520 48521 48522 48523 48524 48525 48526 48527 48528 48529 48530 | 48617 48618 48619 48620 48621 48622 48623 48624 48625 48626 48627 48628 48629 48630 48631 48632 48633 48634 48635 48636 48637 48638 48639 48640 48641 48642 48643 48644 48645 48646 48647 48648 48649 48650 48651 | + + + + + + + + + + - - + + + | typedef struct PGroup PGroup; /* ** Each cache entry is represented by an instance of the following ** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of ** PgHdr1.pCache->szPage bytes is allocated directly before this structure ** in memory. ** ** Note: Variables isBulkLocal and isAnchor were once type "u8". That works, ** but causes a 2-byte gap in the structure for most architectures (since ** pointers must be either 4 or 8-byte aligned). As this structure is located ** in memory directly after the associated page data, if the database is ** corrupt, code at the b-tree layer may overread the page buffer and ** read part of this structure before the corruption is detected. This ** can cause a valgrind error if the unitialized gap is accessed. Using u16 ** ensures there is no such gap, and therefore no bytes of unitialized memory ** in the structure. */ struct PgHdr1 { sqlite3_pcache_page page; /* Base class. Must be first. pBuf & pExtra */ unsigned int iKey; /* Key value (page number) */ |
︙ | |||
48595 48596 48597 48598 48599 48600 48601 48602 48603 48604 48605 48606 48607 48608 | 48703 48704 48705 48706 48707 48708 48709 48710 48711 48712 48713 48714 48715 48716 48717 | + | int szExtra; /* sizeof(MemPage)+sizeof(PgHdr) */ int szAlloc; /* Total size of one pcache line */ int bPurgeable; /* True if cache is purgeable */ unsigned int nMin; /* Minimum number of pages reserved */ unsigned int nMax; /* Configured "cache_size" value */ unsigned int n90pct; /* nMax*9/10 */ unsigned int iMaxKey; /* Largest key seen since xTruncate() */ unsigned int nPurgeableDummy; /* pnPurgeable points here when not used*/ /* Hash table of all pages. The following variables may only be accessed ** when the accessor is holding the PGroup mutex. */ unsigned int nRecyclable; /* Number of pages in the LRU list */ unsigned int nPage; /* Total number of pages in apHash */ unsigned int nHash; /* Number of slots in apHash[] */ |
︙ | |||
48729 48730 48731 48732 48733 48734 48735 48736 48737 48738 48739 48740 48741 48742 | 48838 48839 48840 48841 48842 48843 48844 48845 48846 48847 48848 48849 48850 48851 48852 | + | do{ PgHdr1 *pX = (PgHdr1*)&zBulk[pCache->szPage]; pX->page.pBuf = zBulk; pX->page.pExtra = &pX[1]; pX->isBulkLocal = 1; pX->isAnchor = 0; pX->pNext = pCache->pFree; pX->pLruPrev = 0; /* Initializing this saves a valgrind error */ pCache->pFree = pX; zBulk += pCache->szAlloc; }while( --nBulk ); } return pCache->pFree!=0; } |
︙ | |||
48904 48905 48906 48907 48908 48909 48910 48911 48912 48913 48914 48915 48916 48917 | 49014 49015 49016 49017 49018 49019 49020 49021 49022 49023 49024 49025 49026 49027 49028 49029 49030 | + + + | /* ** Malloc function used by SQLite to obtain space from the buffer configured ** using sqlite3_config(SQLITE_CONFIG_PAGECACHE) option. If no such buffer ** exists, this function falls back to sqlite3Malloc(). */ SQLITE_PRIVATE void *sqlite3PageMalloc(int sz){ /* During rebalance operations on a corrupt database file, it is sometimes ** (rarely) possible to overread the temporary page buffer by a few bytes. ** Enlarge the allocation slightly so that this does not cause problems. */ return pcache1Alloc(sz); } /* ** Free an allocated buffer obtained from sqlite3PageMalloc(). */ SQLITE_PRIVATE void sqlite3PageFree(void *p){ |
︙ | |||
48998 48999 49000 49001 49002 49003 49004 | 49111 49112 49113 49114 49115 49116 49117 49118 49119 49120 49121 49122 49123 49124 49125 49126 | - + + | assert( PAGE_IS_UNPINNED(pPage) ); assert( pPage->pLruNext ); assert( pPage->pLruPrev ); assert( sqlite3_mutex_held(pPage->pCache->pGroup->mutex) ); pPage->pLruPrev->pLruNext = pPage->pLruNext; pPage->pLruNext->pLruPrev = pPage->pLruPrev; pPage->pLruNext = 0; |
︙ | |||
49208 49209 49210 49211 49212 49213 49214 | 49322 49323 49324 49325 49326 49327 49328 49329 49330 49331 49332 49333 49334 49335 49336 | - - + | pcache1ResizeHash(pCache); if( bPurgeable ){ pCache->nMin = 10; pGroup->nMinPage += pCache->nMin; pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; pCache->pnPurgeable = &pGroup->nPurgeable; }else{ |
︙ | |||
49336 49337 49338 49339 49340 49341 49342 | 49449 49450 49451 49452 49453 49454 49455 49456 49457 49458 49459 49460 49461 49462 49463 49464 49465 | - - + + + | if( pPage ){ unsigned int h = iKey % pCache->nHash; pCache->nPage++; pPage->iKey = iKey; pPage->pNext = pCache->apHash[h]; pPage->pCache = pCache; |
︙ | |||
49497 49498 49499 49500 49501 49502 49503 | 49611 49612 49613 49614 49615 49616 49617 49618 49619 49620 49621 49622 49623 49624 49625 | - + | assert( pPage->pCache==pCache ); pcache1EnterMutex(pGroup); /* It is an error to call this function if the page is already ** part of the PGroup LRU list. */ |
︙ | |||
54188 54189 54190 54191 54192 54193 54194 | 54302 54303 54304 54305 54306 54307 54308 54309 54310 54311 54312 54313 54314 54315 54316 54317 54318 54319 | - + + + + | ** Regardless of mxPage, return the current maximum page count. */ SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){ if( mxPage>0 ){ pPager->mxPgno = mxPage; } assert( pPager->eState!=PAGER_OPEN ); /* Called only by OP_MaxPgcnt */ |
︙ | |||
62427 62428 62429 62430 62431 62432 62433 | 62544 62545 62546 62547 62548 62549 62550 62551 62552 62553 62554 62555 62556 62557 62558 62559 62560 62561 62562 62563 62564 62565 62566 62567 | + + + + + - - - + + + + + | ** but cursors cannot be shared. Each cursor is associated with a ** particular database connection identified BtCursor.pBtree.db. ** ** Fields in this structure are accessed under the BtShared.mutex ** found at self->pBt->mutex. ** ** skipNext meaning: ** The meaning of skipNext depends on the value of eState: ** ** eState Meaning of skipNext ** VALID skipNext is meaningless and is ignored ** INVALID skipNext is meaningless and is ignored |
︙ | |||
63593 63594 63595 63596 63597 63598 63599 | 63717 63718 63719 63720 63721 63722 63723 63724 63725 63726 63727 63728 63729 63730 63731 63732 63733 63734 63735 63736 63737 63738 63739 63740 63741 63742 63743 | - + + + + + + - + + | assert( 0==pCur->pKey ); assert( cursorHoldsMutex(pCur) ); if( pCur->curIntKey ){ /* Only the rowid is required for a table btree */ pCur->nKey = sqlite3BtreeIntegerKey(pCur); }else{ |
︙ | |||
63731 63732 63733 63734 63735 63736 63737 63738 | 63861 63862 63863 63864 63865 63866 63867 63868 63869 63870 63871 63872 63873 63874 63875 63876 63877 63878 63879 63880 | + - + - - + + | int bias, /* Bias search to the high end */ int *pRes /* Write search results here */ ){ int rc; /* Status code */ UnpackedRecord *pIdxKey; /* Unpacked index key */ if( pKey ){ KeyInfo *pKeyInfo = pCur->pKeyInfo; assert( nKey==(i64)(int)nKey ); |
︙ | |||
63771 63772 63773 63774 63775 63776 63777 | 63902 63903 63904 63905 63906 63907 63908 63909 63910 63911 63912 63913 63914 63915 63916 | - + | } pCur->eState = CURSOR_INVALID; rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext); if( rc==SQLITE_OK ){ sqlite3_free(pCur->pKey); pCur->pKey = 0; assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID ); |
︙ | |||
63841 63842 63843 63844 63845 63846 63847 | 63972 63973 63974 63975 63976 63977 63978 63979 63980 63981 63982 63983 63984 63985 | - | if( rc ){ *pDifferentRow = 1; return rc; } if( pCur->eState!=CURSOR_VALID ){ *pDifferentRow = 1; }else{ |
︙ | |||
63924 63925 63926 63927 63928 63929 63930 63931 63932 63933 63934 63935 63936 63937 | 64054 64055 64056 64057 64058 64059 64060 64061 64062 64063 64064 64065 64066 64067 64068 64069 64070 64071 64072 64073 64074 | + + + + + + + | return; } iPtrmap = PTRMAP_PAGENO(pBt, key); rc = sqlite3PagerGet(pBt->pPager, iPtrmap, &pDbPage, 0); if( rc!=SQLITE_OK ){ *pRC = rc; return; } if( ((char*)sqlite3PagerGetExtra(pDbPage))[0]!=0 ){ /* The first byte of the extra data is the MemPage.isInit byte. ** If that byte is set, it means this page is also being used ** as a btree page. */ *pRC = SQLITE_CORRUPT_BKPT; goto ptrmap_exit; } offset = PTRMAP_PTROFFSET(iPtrmap, key); if( offset<0 ){ *pRC = SQLITE_CORRUPT_BKPT; goto ptrmap_exit; } assert( offset <= (int)pBt->usableSize-5 ); |
︙ | |||
63987 63988 63989 63990 63991 63992 63993 | 64124 64125 64126 64127 64128 64129 64130 64131 64132 64133 64134 64135 64136 64137 64138 | - + | if( *pEType<1 || *pEType>5 ) return SQLITE_CORRUPT_PGNO(iPtrmap); return SQLITE_OK; } #else /* if defined SQLITE_OMIT_AUTOVACUUM */ #define ptrmapPut(w,x,y,z,rc) #define ptrmapGet(w,x,y,z) SQLITE_OK |
︙ | |||
64280 64281 64282 64283 64284 64285 64286 | 64417 64418 64419 64420 64421 64422 64423 64424 64425 64426 64427 64428 64429 64430 64431 64432 64433 64434 64435 64436 64437 64438 64439 64440 64441 64442 64443 64444 64445 64446 64447 64448 | - - - + + + + - + + + + + + + - + | static u16 cellSize(MemPage *pPage, int iCell){ return pPage->xCellSize(pPage, findCell(pPage, iCell)); } #endif #ifndef SQLITE_OMIT_AUTOVACUUM /* |
︙ | |||
64345 64346 64347 64348 64349 64350 64351 | 64489 64490 64491 64492 64493 64494 64495 64496 64497 64498 64499 64500 64501 64502 64503 64504 64505 64506 64507 64508 64509 64510 64511 64512 64513 64514 64515 64516 64517 64518 64519 64520 64521 64522 64523 | - - - - - + + + - - - - - - - + + + + - + - + | /* This block handles pages with two or fewer free blocks and nMaxFrag ** or fewer fragmented bytes. In this case it is faster to move the ** two (or one) blocks of cells using memmove() and add the required ** offsets to each pointer in the cell-pointer array than it is to ** reconstruct the entire page. */ if( (int)data[hdr+7]<=nMaxFrag ){ int iFree = get2byte(&data[hdr+1]); |
︙ | |||
65925 65926 65927 65928 65929 65930 65931 | 66064 66065 66066 66067 66068 66069 66070 66071 66072 66073 66074 66075 66076 66077 66078 66079 66080 66081 66082 66083 66084 66085 66086 66087 66088 66089 66090 66091 66092 66093 | - - - + + + - + | ** well-formed database file, then SQLITE_CORRUPT is returned. ** SQLITE_BUSY is returned if the database is locked. SQLITE_NOMEM ** is returned if we run out of memory. */ static int lockBtree(BtShared *pBt){ int rc; /* Result code from subfunctions */ MemPage *pPage1; /* Page 1 of the database file */ |
︙ | |||
66021 66022 66023 66024 66025 66026 66027 66028 66029 66030 66031 66032 66033 66034 | 66160 66161 66162 66163 66164 66165 66166 66167 66168 66169 66170 66171 66172 66173 66174 | + | ** between 512 and 65536 inclusive. */ if( ((pageSize-1)&pageSize)!=0 || pageSize>SQLITE_MAX_PAGE_SIZE || pageSize<=256 ){ goto page1_init_failed; } pBt->btsFlags |= BTS_PAGESIZE_FIXED; assert( (pageSize & 7)==0 ); /* EVIDENCE-OF: R-59310-51205 The "reserved space" size in the 1-byte ** integer at offset 20 is the number of bytes of space at the end of ** each page to reserve for extensions. ** ** EVIDENCE-OF: R-37497-42412 The size of the reserved region is ** determined by the one-byte unsigned integer found at an offset of 20 |
︙ | |||
66411 66412 66413 66414 66415 66416 66417 | 66551 66552 66553 66554 66555 66556 66557 66558 66559 66560 66561 66562 66563 66564 66565 | - + | rc = pPage->isInit ? SQLITE_OK : btreeInitPage(pPage); if( rc!=SQLITE_OK ) return rc; nCell = pPage->nCell; for(i=0; i<nCell; i++){ u8 *pCell = findCell(pPage, i); |
︙ | |||
67337 67338 67339 67340 67341 67342 67343 67344 67345 67346 67347 67348 67349 67350 | 67477 67478 67479 67480 67481 67482 67483 67484 67485 67486 67487 67488 67489 67490 67491 | + | }while( ALWAYS(pPrev) ); } btreeReleaseAllCursorPages(pCur); unlockBtreeIfUnused(pBt); sqlite3_free(pCur->aOverflow); sqlite3_free(pCur->pKey); sqlite3BtreeLeave(pBtree); pCur->pBtree = 0; } return SQLITE_OK; } /* ** Make sure the BtCursor* given in the argument has a valid ** BtCursor.info structure. If it is not already valid, call |
︙ | |||
67434 67435 67436 67437 67438 67439 67440 67441 67442 67443 67444 67445 67446 67447 | 67575 67576 67577 67578 67579 67580 67581 67582 67583 67584 67585 67586 67587 67588 67589 67590 67591 67592 67593 67594 67595 67596 67597 67598 67599 67600 67601 67602 67603 67604 67605 67606 67607 | + + + + + + + + + + + + + + + + + + + | */ SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){ assert( cursorHoldsMutex(pCur) ); assert( pCur->eState==CURSOR_VALID ); getCellInfo(pCur); return pCur->info.nPayload; } /* ** Return an upper bound on the size of any record for the table ** that the cursor is pointing into. ** ** This is an optimization. Everything will still work if this ** routine always returns 2147483647 (which is the largest record ** that SQLite can handle) or more. But returning a smaller value might ** prevent large memory allocations when trying to interpret a ** corrupt datrabase. ** ** The current implementation merely returns the size of the underlying ** database file. */ SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor *pCur){ assert( cursorHoldsMutex(pCur) ); assert( pCur->eState==CURSOR_VALID ); return pCur->pBt->pageSize * (sqlite3_int64)pCur->pBt->nPage; } /* ** Given the page number of an overflow page in the database (parameter ** ovfl), this function finds the page number of the next page in the ** linked list of overflow pages. If possible, it uses the auto-vacuum ** pointer-map data instead of reading the content of page ovfl to do so. ** |
︙ | |||
68249 68250 68251 68252 68253 68254 68255 | 68409 68410 68411 68412 68413 68414 68415 68416 68417 68418 68419 68420 68421 68422 68423 | - + | *pRes = -1; return SQLITE_OK; } /* If the requested key is one more than the previous key, then ** try to get there using sqlite3BtreeNext() rather than a full ** binary search. This is an optimization only. The correct answer ** is still obtained without this case, only a little more slowely */ |
︙ | |||
68391 68392 68393 68394 68395 68396 68397 | 68551 68552 68553 68554 68555 68556 68557 68558 68559 68560 68561 68562 68563 68564 68565 | - + | u8 * const pCellBody = pCell - pPage->childPtrSize; pPage->xParseCell(pPage, pCellBody, &pCur->info); nCell = (int)pCur->info.nKey; testcase( nCell<0 ); /* True if key size is 2^32 or more */ testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */ testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */ testcase( nCell==2 ); /* Minimum legal index key size */ |
︙ | |||
68523 68524 68525 68526 68527 68528 68529 | 68683 68684 68685 68686 68687 68688 68689 68690 68691 68692 68693 68694 68695 68696 68697 68698 68699 68700 68701 68702 68703 68704 68705 68706 68707 68708 | - - - + - + - - - - | */ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){ int rc; int idx; MemPage *pPage; assert( cursorOwnsBtShared(pCur) ); |
︙ | |||
68595 68596 68597 68598 68599 68600 68601 | 68749 68750 68751 68752 68753 68754 68755 68756 68757 68758 68759 68760 68761 68762 | - | } } SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int flags){ MemPage *pPage; UNUSED_PARAMETER( flags ); /* Used in COMDB2 but not native SQLite */ assert( cursorOwnsBtShared(pCur) ); assert( flags==0 || flags==1 ); |
︙ | |||
68636 68637 68638 68639 68640 68641 68642 | 68789 68790 68791 68792 68793 68794 68795 68796 68797 68798 68799 68800 68801 68802 68803 68804 68805 68806 68807 68808 68809 68810 68811 68812 68813 68814 68815 | - - - + - + - - - - | ** use this hint, but COMDB2 does. */ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){ int rc; MemPage *pPage; assert( cursorOwnsBtShared(pCur) ); |
︙ | |||
68689 68690 68691 68692 68693 68694 68695 | 68836 68837 68838 68839 68840 68841 68842 68843 68844 68845 68846 68847 68848 68849 | - | } } return rc; } SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int flags){ assert( cursorOwnsBtShared(pCur) ); assert( flags==0 || flags==1 ); |
︙ | |||
69025 69026 69027 69028 69029 69030 69031 | 69171 69172 69173 69174 69175 69176 69177 69178 69179 69180 69181 69182 69183 69184 69185 | - + | if( rc!=SQLITE_OK ){ releasePage(*ppPage); *ppPage = 0; } TRACE(("ALLOCATE: %d from end of file\n", *pPgno)); } |
︙ | |||
69580 69581 69582 69583 69584 69585 69586 | 69726 69727 69728 69729 69730 69731 69732 69733 69734 69735 69736 69737 69738 69739 69740 69741 69742 69743 69744 69745 69746 69747 69748 69749 69750 69751 69752 69753 69754 69755 69756 69757 69758 69759 69760 69761 69762 69763 69764 69765 69766 69767 69768 69769 69770 69771 69772 69773 69774 69775 69776 69777 69778 69779 69780 69781 69782 69783 69784 69785 69786 69787 69788 69789 69790 69791 69792 69793 69794 69795 69796 69797 69798 69799 69800 69801 69802 69803 69804 69805 69806 69807 69808 69809 69810 69811 69812 69813 69814 69815 69816 69817 69818 69819 69820 69821 69822 69823 69824 69825 69826 69827 69828 69829 69830 69831 69832 69833 69834 69835 69836 69837 69838 69839 69840 69841 69842 69843 69844 69845 69846 69847 69848 69849 69850 69851 69852 69853 69854 | - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | if( rc ){ *pRC = rc; return; } /* The allocateSpace() routine guarantees the following properties ** if it returns successfully */ assert( idx >= 0 ); assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB ); assert( idx+sz <= (int)pPage->pBt->usableSize ); pPage->nFree -= (u16)(2 + sz); |
︙ | |||
69662 69663 69664 69665 69666 69667 69668 | 69891 69892 69893 69894 69895 69896 69897 69898 69899 69900 69901 69902 69903 69904 69905 69906 69907 69908 69909 69910 69911 69912 69913 69914 69915 69916 69917 69918 69919 69920 69921 69922 69923 69924 69925 69926 69927 69928 69929 69930 69931 69932 69933 69934 69935 69936 69937 69938 69939 69940 69941 69942 69943 69944 69945 69946 69947 69948 69949 69950 69951 69952 69953 69954 69955 69956 69957 69958 69959 69960 69961 69962 69963 69964 69965 69966 69967 69968 69969 69970 69971 69972 69973 69974 69975 69976 | + - + - - + + + - + + + + - - + + + + + + - - + + + + + + + + + + - + - - - + + + + + + + + + - + - - - - - + + + + | ** function works around problems caused by this by making a copy of any ** such cells before overwriting the page data. ** ** The MemPage.nFree field is invalidated by this function. It is the ** responsibility of the caller to set it correctly. */ static int rebuildPage( CellArray *pCArray, /* Content to be added to page pPg */ |
︙ | |||
69733 69734 69735 69736 69737 69738 69739 | 69984 69985 69986 69987 69988 69989 69990 69991 69992 69993 69994 69995 69996 69997 69998 69999 70000 70001 70002 70003 70004 70005 70006 70007 70008 70009 70010 70011 70012 70013 70014 70015 70016 70017 70018 70019 70020 70021 70022 70023 70024 70025 70026 70027 70028 70029 70030 70031 70032 70033 70034 70035 70036 70037 70038 70039 70040 70041 70042 70043 70044 70045 70046 70047 70048 70049 70050 70051 70052 70053 70054 70055 | - + - - - - + + + + + + - + + + + + + + + + + + + + + + + + - - - - - + + + + + | ** all cells - not just those inserted by the current call). If the content ** area must be extended to before this point in order to accomodate all ** cells in apCell[], then the cells do not fit and non-zero is returned. */ static int pageInsertArray( MemPage *pPg, /* Page to add cells to */ u8 *pBegin, /* End of cell-pointer array */ |
︙ | |||
69822 69823 69824 69825 69826 69827 69828 | 70091 70092 70093 70094 70095 70096 70097 70098 70099 70100 70101 70102 70103 70104 70105 70106 70107 | - - - + + + | assert( pFree>aData && (pFree - aData)<65536 ); freeSpace(pPg, (u16)(pFree - aData), szFree); } return nRet; } /* |
︙ | |||
69856 69857 69858 69859 69860 69861 69862 69863 69864 69865 69866 69867 69868 | 70125 70126 70127 70128 70129 70130 70131 70132 70133 70134 70135 70136 70137 70138 70139 70140 70141 70142 70143 70144 70145 70146 70147 70148 70149 70150 70151 70152 70153 70154 70155 70156 70157 70158 70159 70160 70161 70162 70163 70164 70165 70166 70167 70168 70169 70170 70171 70172 70173 70174 70175 70176 70177 70178 70179 70180 70181 70182 70183 70184 70185 | + + - + + + + + + | #ifdef SQLITE_DEBUG u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager); memcpy(pTmp, aData, pPg->pBt->usableSize); #endif /* Remove cells from the start and end of the page */ assert( nCell>=0 ); if( iOld<iNew ){ int nShift = pageFreeArray(pPg, iOld, iNew-iOld, pCArray); if( nShift>nCell ) return SQLITE_CORRUPT_BKPT; memmove(pPg->aCellIdx, &pPg->aCellIdx[nShift*2], nCell*2); nCell -= nShift; } if( iNewEnd < iOldEnd ){ |
︙ | |||
69924 69925 69926 69927 69928 69929 69930 | 70200 70201 70202 70203 70204 70205 70206 70207 70208 70209 70210 70211 70212 70213 70214 70215 | - + - - - - - - - - - - - - - - - | } #endif return SQLITE_OK; editpage_fail: /* Unable to edit this page. Rebuild it from scratch instead. */ populateCellCache(pCArray, iNew, nNew); |
︙ | |||
69977 69978 69979 69980 69981 69982 69983 | 70238 70239 70240 70241 70242 70243 70244 70245 70246 70247 70248 70249 70250 70251 70252 70253 70254 70255 70256 70257 70258 70259 70260 70261 70262 70263 70264 70265 70266 70267 70268 70269 70270 70271 70272 70273 70274 70275 70276 70277 70278 70279 70280 70281 70282 70283 70284 70285 70286 70287 70288 70289 70290 70291 70292 70293 70294 70295 70296 | - - + + - + + + + + + + - - + + + + + - + | int rc; /* Return Code */ Pgno pgnoNew; /* Page number of pNew */ assert( sqlite3_mutex_held(pPage->pBt->mutex) ); assert( sqlite3PagerIswriteable(pParent->pDbPage) ); assert( pPage->nOverflow==1 ); |
︙ | |||
70235 70236 70237 70238 70239 70240 70241 | 70505 70506 70507 70508 70509 70510 70511 70512 70513 70514 70515 70516 70517 70518 | - - - - | memset(abDone, 0, sizeof(abDone)); b.nCell = 0; b.apCell = 0; pBt = pParent->pBt; assert( sqlite3_mutex_held(pBt->mutex) ); assert( sqlite3PagerIswriteable(pParent->pDbPage) ); |
︙ | |||
70479 70480 70481 70482 70483 70484 70485 | 70745 70746 70747 70748 70749 70750 70751 70752 70753 70754 70755 70756 70757 70758 70759 70760 70761 70762 70763 70764 70765 70766 70767 | - + + + + + + + + | ** szNew[i]: Spaced used on the i-th sibling page. ** cntNew[i]: Index in b.apCell[] and b.szCell[] for the first cell to ** the right of the i-th sibling page. ** usableSpace: Number of bytes of space available on each sibling. ** */ usableSpace = pBt->usableSize - 12 + leafCorrection; |
︙ | |||
70704 70705 70706 70707 70708 70709 70710 | 70977 70978 70979 70980 70981 70982 70983 70984 70985 70986 70987 70988 70989 70990 70991 70992 70993 70994 70995 70996 70997 70998 70999 71000 71001 71002 | + - + - + | ** ** If the sibling pages are not leaves, then the pointer map entry ** associated with the right-child of each sibling may also need to be ** updated. This happens below, after the sibling pages have been ** populated, not here. */ if( ISAUTOVACUUM ){ MemPage *pOld; |
︙ | |||
70737 70738 70739 70740 70741 70742 70743 | 71011 71012 71013 71014 71015 71016 71017 71018 71019 71020 71021 71022 71023 71024 71025 | - + | || pNew->pgno!=aPgno[iOld] || !SQLITE_WITHIN(pCell,aOld,&aOld[usableSize]) ){ if( !leafCorrection ){ ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc); } if( cachedCellSize(&b,i)>pNew->minLocal ){ |
︙ | |||
71161 71162 71163 71164 71165 71166 71167 | 71435 71436 71437 71438 71439 71440 71441 71442 71443 71444 71445 71446 71447 71448 71449 71450 71451 71452 71453 | + + + + - + | iAmt-nData); if( rc ) return rc; iAmt = nData; } if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){ int rc = sqlite3PagerWrite(pPage->pDbPage); if( rc ) return rc; /* In a corrupt database, it is possible for the source and destination ** buffers to overlap. This is harmless since the database is already ** corrupt but it does cause valgrind and ASAN warnings. So use ** memmove(). */ |
︙ | |||
71556 71557 71558 71559 71560 71561 71562 71563 71564 71565 71566 71567 71568 71569 | 71834 71835 71836 71837 71838 71839 71840 71841 71842 71843 71844 71845 71846 71847 71848 | + | ** ** Or, if the current delete will not cause a rebalance, then the cursor ** will be left in CURSOR_SKIPNEXT state pointing to the entry immediately ** before or after the deleted entry. In this case set bSkipnext to true. */ if( bPreserve ){ if( !pPage->leaf || (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3) || pPage->nCell==1 /* See dbfuzz001.test for a test case */ ){ /* A b-tree rebalance will be required after deleting this entry. ** Save the cursor key. */ rc = saveCursorKey(pCur); if( rc ) return rc; }else{ bSkipnext = 1; |
︙ | |||
72334 72335 72336 72337 72338 72339 72340 | 72613 72614 72615 72616 72617 72618 72619 72620 72621 72622 72623 72624 72625 72626 72627 72628 72629 72630 72631 72632 72633 72634 72635 72636 72637 72638 | - + - + - + | N--; if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){ checkAppendMsg(pCheck, "failed to get page %d", iPage); break; } pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage); if( isFreeList ){ |
︙ | |||
72722 72723 72724 72725 72726 72727 72728 | 73001 73002 73003 73004 73005 73006 73007 73008 73009 73010 73011 73012 73013 73014 73015 | - + | int nRoot, /* Number of entries in aRoot[] */ int mxErr, /* Stop reporting errors after this many */ int *pnErr /* Write number of errors seen to this variable */ ){ Pgno i; IntegrityCk sCheck; BtShared *pBt = p->pBt; |
︙ | |||
72789 72790 72791 72792 72793 72794 72795 | 73068 73069 73070 73071 73072 73073 73074 73075 73076 73077 73078 73079 73080 73081 73082 | - + | }else if( get4byte(&pBt->pPage1->aData[64])!=0 ){ checkAppendMsg(&sCheck, "incremental_vacuum enabled with a max rootpage of zero" ); } #endif testcase( pBt->db->flags & SQLITE_CellSizeCk ); |
︙ | |||
74177 74178 74179 74180 74181 74182 74183 | 74456 74457 74458 74459 74460 74461 74462 74463 74464 74465 74466 74467 74468 74469 74470 | - + | ** and MEM_Blob values may be discarded, MEM_Int, MEM_Real, and MEM_Null ** values are preserved. ** ** Return SQLITE_OK on success or an error code (probably SQLITE_NOMEM) ** if unable to complete the resizing. */ SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){ |
︙ | |||
75058 75059 75060 75061 75062 75063 75064 75065 75066 75067 75068 75069 75070 75071 | 75337 75338 75339 75340 75341 75342 75343 75344 75345 75346 75347 75348 75349 75350 75351 75352 75353 | + + + | BtCursor *pCur, /* Cursor pointing at record to retrieve. */ u32 offset, /* Offset from the start of data to return bytes from. */ u32 amt, /* Number of bytes to return. */ Mem *pMem /* OUT: Return data in this Mem structure. */ ){ int rc; pMem->flags = MEM_Null; if( sqlite3BtreeMaxRecordSize(pCur)<offset+amt ){ return SQLITE_CORRUPT_BKPT; } if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){ rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z); if( rc==SQLITE_OK ){ pMem->z[amt] = 0; /* Overrun area used when reading malformed records */ pMem->flags = MEM_Blob; pMem->n = (int)amt; }else{ |
︙ | |||
75464 75465 75466 75467 75468 75469 75470 | 75746 75747 75748 75749 75750 75751 75752 75753 75754 75755 75756 75757 75758 75759 75760 75761 75762 75763 75764 | - - - + + + + + | #endif #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 else if( op==TK_FUNCTION && pCtx!=0 ){ rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx); } #endif else if( op==TK_TRUEFALSE ){ |
︙ | |||
75859 75860 75861 75862 75863 75864 75865 | 76143 76144 76145 76146 76147 76148 76149 76150 76151 76152 76153 76154 76155 76156 76157 | - + | p->pPrev = 0; db->pVdbe = p; p->magic = VDBE_MAGIC_INIT; p->pParse = pParse; pParse->pVdbe = p; assert( pParse->aLabel==0 ); assert( pParse->nLabel==0 ); |
︙ | |||
75887 75888 75889 75890 75891 75892 75893 75894 | 76171 76172 76173 76174 76175 76176 76177 76178 76179 76180 76181 76182 76183 76184 76185 76186 76187 76188 76189 76190 76191 76192 76193 76194 76195 76196 76197 76198 76199 76200 76201 76202 76203 76204 76205 76206 76207 76208 76209 76210 76211 76212 76213 76214 76215 76216 76217 76218 76219 76220 76221 76222 76223 76224 76225 76226 76227 76228 76229 76230 76231 76232 76233 76234 76235 76236 76237 76238 76239 76240 76241 76242 76243 76244 76245 76246 76247 76248 76249 76250 76251 76252 76253 76254 76255 76256 76257 76258 76259 76260 76261 76262 76263 76264 76265 76266 76267 76268 76269 76270 76271 76272 76273 76274 76275 76276 76277 76278 76279 76280 76281 76282 76283 76284 76285 76286 76287 76288 76289 76290 76291 76292 76293 | + + + + + + - + - - - - + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + | if( p==0 ) return; p->prepFlags = prepFlags; if( (prepFlags & SQLITE_PREPARE_SAVESQL)==0 ){ p->expmask = 0; } assert( p->zSql==0 ); p->zSql = sqlite3DbStrNDup(p->db, z, n); } #ifdef SQLITE_ENABLE_NORMALIZE /* ** Add a new element to the Vdbe->pDblStr list. */ SQLITE_PRIVATE void sqlite3VdbeAddDblquoteStr(sqlite3 *db, Vdbe *p, const char *z){ |
︙ | |||
75999 76000 76001 76002 76003 76004 76005 | 76313 76314 76315 76316 76317 76318 76319 76320 76321 76322 76323 76324 76325 76326 76327 76328 76329 76330 76331 76332 76333 76334 76335 76336 76337 76338 76339 | - + - + - + | ** p1, p2, p3 Operands ** ** Use the sqlite3VdbeResolveLabel() function to fix an address and ** the sqlite3VdbeChangeP4() function to change the value of the P4 ** operand. */ static SQLITE_NOINLINE int growOp3(Vdbe *p, int op, int p1, int p2, int p3){ |
︙ | |||
76143 76144 76145 76146 76147 76148 76149 | 76457 76458 76459 76460 76461 76462 76463 76464 76465 76466 76467 76468 76469 76470 76471 76472 76473 76474 76475 76476 76477 76478 76479 76480 76481 76482 76483 76484 76485 76486 76487 76488 76489 76490 76491 76492 76493 76494 76495 76496 76497 76498 76499 76500 76501 76502 76503 76504 76505 76506 76507 76508 76509 76510 76511 76512 76513 76514 76515 76516 | + + + + + + + + + + + - + + + + - + + + + + - + + + | VdbeOp *pOp; if( pParse->addrExplain==0 ) return 0; pOp = sqlite3VdbeGetOp(pParse->pVdbe, pParse->addrExplain); return pOp->p2; } /* ** Set a debugger breakpoint on the following routine in order to ** monitor the EXPLAIN QUERY PLAN code generation. */ #if defined(SQLITE_DEBUG) SQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char *z1, const char *z2){ (void)z1; (void)z2; } #endif /* |
︙ | |||
76233 76234 76235 76236 76237 76238 76239 76240 | 76567 76568 76569 76570 76571 76572 76573 76574 76575 76576 76577 76578 76579 76580 76581 76582 76583 76584 76585 76586 76587 76588 76589 76590 76591 76592 76593 76594 76595 76596 76597 76598 76599 76600 76601 76602 76603 76604 76605 76606 76607 76608 76609 76610 76611 76612 76613 76614 76615 76616 76617 76618 76619 76620 76621 76622 76623 76624 76625 76626 76627 76628 76629 76630 76631 76632 | + + + - + + + + + + + + + - + - - + - - - - - - - - - + + + + + + + + + + + + + + + - + - - - - + + + + + + | ** the label is resolved to a specific address, the VDBE will scan ** through its operation list and change all values of P2 which match ** the label into the resolved address. ** ** The VDBE knows that a P2 value is a label because labels are ** always negative and P2 values are suppose to be non-negative. ** Hence, a negative P2 value is a label that has yet to be resolved. ** (Later:) This is only true for opcodes that have the OPFLG_JUMP ** property. ** ** Variable usage notes: |
︙ | |||
76391 76392 76393 76394 76395 76396 76397 76398 | 76743 76744 76745 76746 76747 76748 76749 76750 76751 76752 76753 76754 76755 76756 76757 76758 76759 | + - + | VdbeOpIter sIter; memset(&sIter, 0, sizeof(sIter)); sIter.v = v; while( (pOp = opIterNext(&sIter))!=0 ){ int opcode = pOp->opcode; if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename || opcode==OP_VDestroy || ((opcode==OP_Halt || opcode==OP_HaltIfNull) |
︙ | |||
76541 76542 76543 76544 76545 76546 76547 | 76894 76895 76896 76897 76898 76899 76900 76901 76902 76903 76904 76905 76906 76907 76908 | - + | #endif default: { if( pOp->p2<0 ){ /* The mkopcodeh.tcl script has so arranged things that the only ** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to ** have non-negative values for P2. */ assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 ); |
︙ | |||
76580 76581 76582 76583 76584 76585 76586 | 76933 76934 76935 76936 76937 76938 76939 76940 76941 76942 76943 76944 76945 76946 76947 | - + | ** SQLITE_TEST_REALLOC_STRESS). This interface is used during testing ** to verify that certain calls to sqlite3VdbeAddOpList() can never ** fail due to a OOM fault and hence that the return value from ** sqlite3VdbeAddOpList() will always be non-NULL. */ #if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS) SQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){ |
︙ | |||
76652 76653 76654 76655 76656 76657 76658 | 77005 77006 77007 77008 77009 77010 77011 77012 77013 77014 77015 77016 77017 77018 77019 | - + | VdbeOpList const *aOp, /* The opcodes to be added */ int iLineno /* Source-file line number of first opcode */ ){ int i; VdbeOp *pOut, *pFirst; assert( nOp>0 ); assert( p->magic==VDBE_MAGIC_INIT ); |
︙ | |||
77974 77975 77976 77977 77978 77979 77980 | 78327 78328 78329 78330 78331 78332 78333 78334 78335 78336 78337 78338 78339 78340 78341 78342 78343 78344 78345 78346 78347 78348 78349 78350 78351 78352 78353 78354 78355 78356 78357 78358 78359 78360 78361 | - - - - - - + + + + + - + - + - + + + + + + + + + + | ** requirements by reusing the opcode array tail, then the second ** pass will fill in the remainder using a fresh memory allocation. ** ** This two-pass approach that reuses as much memory as possible from ** the leftover memory at the end of the opcode array. This can significantly ** reduce the amount of memory held by a prepared statement. */ |
︙ | |||
78678 78679 78680 78681 78682 78683 78684 | 79039 79040 79041 79042 79043 79044 79045 79046 79047 79048 79049 79050 79051 79052 79053 | - + | }else if( rc!=SQLITE_OK ){ p->rc = rc; sqlite3RollbackAll(db, SQLITE_OK); p->nChange = 0; }else{ db->nDeferredCons = 0; db->nDeferredImmCons = 0; |
︙ | |||
78993 78994 78995 78996 78997 78998 78999 79000 79001 79002 79003 79004 79005 79006 | 79354 79355 79356 79357 79358 79359 79360 79361 79362 79363 79364 79365 79366 79367 79368 79369 79370 79371 79372 79373 79374 | + + + + + + + | sqlite3DbFree(db, p->pFree); } vdbeFreeOpArray(db, p->aOp, p->nOp); sqlite3DbFree(db, p->aColName); sqlite3DbFree(db, p->zSql); #ifdef SQLITE_ENABLE_NORMALIZE sqlite3DbFree(db, p->zNormSql); { DblquoteStr *pThis, *pNext; for(pThis=p->pDblStr; pThis; pThis=pNext){ pNext = pThis->pNextStr; sqlite3DbFree(db, pThis); } } #endif #ifdef SQLITE_ENABLE_STMT_SCANSTATUS { int i; for(i=0; i<p->nScan; i++){ sqlite3DbFree(db, p->aScan[i].zName); } |
︙ | |||
79533 79534 79535 79536 79537 79538 79539 | 79901 79902 79903 79904 79905 79906 79907 79908 79909 79910 79911 79912 79913 79914 79915 79916 79917 79918 79919 79920 79921 79922 79923 79924 79925 79926 79927 79928 79929 79930 79931 79932 79933 79934 79935 79936 79937 79938 79939 79940 79941 79942 79943 79944 79945 | - + - + + + + + + + + | SQLITE_PRIVATE void sqlite3VdbeRecordUnpack( KeyInfo *pKeyInfo, /* Information about the record format */ int nKey, /* Size of the binary record */ const void *pKey, /* The binary record */ UnpackedRecord *p /* Populate this structure before returning. */ ){ const unsigned char *aKey = (const unsigned char *)pKey; |
︙ | |||
79622 79623 79624 79625 79626 79627 79628 | 79997 79998 79999 80000 80001 80002 80003 80004 80005 80006 80007 80008 80009 80010 80011 80012 80013 80014 80015 80016 80017 80018 80019 80020 80021 80022 80023 80024 | - - + + - + + | /* Verify that there is enough key space remaining to avoid ** a buffer overread. The "d1+serial_type1+2" subexpression will ** always be greater than or equal to the amount of required key space. ** Use that approximation to avoid the more expensive call to ** sqlite3VdbeSerialTypeLen() in the common case. */ |
︙ | |||
79990 79991 79992 79993 79994 79995 79996 | 80366 80367 80368 80369 80370 80371 80372 80373 80374 80375 80376 80377 80378 80379 80380 80381 80382 80383 80384 80385 | + + - - - - + + + + - - | szHdr1 = aKey1[0]; d1 = szHdr1 + sqlite3VdbeSerialTypeLen(s1); i = 1; pRhs++; }else{ idx1 = getVarint32(aKey1, szHdr1); d1 = szHdr1; i = 0; } |
︙ | |||
80065 80066 80067 80068 80069 80070 80071 | 80441 80442 80443 80444 80445 80446 80447 80448 80449 80450 80451 80452 80453 80454 80455 80456 80457 80458 80459 80460 | - + + + - + | rc = -1; }else if( !(serial_type & 0x01) ){ rc = +1; }else{ mem1.n = (serial_type - 12) / 2; testcase( (d1+mem1.n)==(unsigned)nKey1 ); testcase( (d1+mem1.n+1)==(unsigned)nKey1 ); |
︙ | |||
80768 80769 80770 80771 80772 80773 80774 | 81146 81147 81148 81149 81150 81151 81152 81153 81154 81155 81156 81157 81158 81159 81160 81161 81162 81163 81164 81165 81166 81167 81168 81169 | - + + + | ** Invoke the profile callback. This routine is only called if we already ** know that the profile callback is defined and needs to be invoked. */ static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){ sqlite3_int64 iNow; sqlite3_int64 iElapse; assert( p->startTime>0 ); |
︙ | |||
81289 81290 81291 81292 81293 81294 81295 | 81669 81670 81671 81672 81673 81674 81675 81676 81677 81678 81679 81680 81681 81682 81683 81684 81685 81686 81687 81688 81689 81690 81691 81692 81693 81694 81695 81696 81697 81698 81699 81700 81701 81702 | - + - + | /* Check that malloc() has not failed. If it has, return early. */ db = p->db; if( db->mallocFailed ){ p->rc = SQLITE_NOMEM; return SQLITE_NOMEM_BKPT; } |
︙ | |||
81335 81336 81337 81338 81339 81340 81341 81342 | 81715 81716 81717 81718 81719 81720 81721 81722 81723 81724 81725 81726 81727 81728 81729 81730 81731 81732 81733 81734 81735 81736 81737 81738 81739 81740 81741 81742 81743 81744 81745 81746 81747 81748 81749 81750 81751 81752 81753 81754 81755 81756 81757 81758 81759 81760 81761 81762 | + - - + + - - - - - + + + + + + - - - + + + | #endif /* SQLITE_OMIT_EXPLAIN */ { db->nVdbeExec++; rc = sqlite3VdbeExec(p); db->nVdbeExec--; } if( rc!=SQLITE_ROW ){ #ifndef SQLITE_OMIT_TRACE |
︙ | |||
81988 81989 81990 81991 81992 81993 81994 | 82370 82371 82372 82373 82374 82375 82376 82377 82378 82379 82380 82381 82382 82383 82384 | - + | sqlite3_mutex_leave(p->db->mutex); return SQLITE_RANGE; } i--; pVar = &p->aVar[i]; sqlite3VdbeMemRelease(pVar); pVar->flags = MEM_Null; |
︙ | |||
82414 82415 82416 82417 82418 82419 82420 | 82796 82797 82798 82799 82800 82801 82802 82803 82804 82805 82806 82807 82808 82809 82810 82811 82812 82813 82814 82815 82816 | + + + + + + - + | #ifdef SQLITE_ENABLE_NORMALIZE /* ** Return the normalized SQL associated with a prepared statement. */ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt){ Vdbe *p = (Vdbe *)pStmt; if( p==0 ) return 0; if( p->zNormSql==0 && ALWAYS(p->zSql!=0) ){ sqlite3_mutex_enter(p->db->mutex); p->zNormSql = sqlite3Normalize(p, p->zSql); sqlite3_mutex_leave(p->db->mutex); } |
︙ | |||
83114 83115 83116 83117 83118 83119 83120 83121 83122 83123 83124 83125 83126 83127 | 83502 83503 83504 83505 83506 83507 83508 83509 83510 83511 83512 83513 83514 83515 83516 83517 83518 83519 83520 | + + + + + | VdbeCursor *pCx = 0; nByte = ROUND8(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField + (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0); assert( iCur>=0 && iCur<p->nCursor ); if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/ /* Before calling sqlite3VdbeFreeCursor(), ensure the isEphemeral flag ** is clear. Otherwise, if this is an ephemeral cursor created by ** OP_OpenDup, the cursor will not be closed and will still be part ** of a BtShared.pCursor list. */ p->apCsr[iCur]->isEphemeral = 0; sqlite3VdbeFreeCursor(p, p->apCsr[iCur]); p->apCsr[iCur] = 0; } if( SQLITE_OK==sqlite3VdbeMemClearAndResize(pMem, nByte) ){ p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->z; memset(pCx, 0, offsetof(VdbeCursor,pAltCursor)); pCx->eCurType = eCurType; |
︙ | |||
83254 83255 83256 83257 83258 83259 83260 83261 83262 83263 83264 83265 83266 83267 | 83647 83648 83649 83650 83651 83652 83653 83654 83655 83656 83657 83658 83659 83660 83661 | + | ** interpret as a string if we want to). Compute its corresponding ** numeric type, if has one. Set the pMem->u.r and pMem->u.i fields ** accordingly. */ static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){ assert( (pMem->flags & (MEM_Int|MEM_Real))==0 ); assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ); ExpandBlob(pMem); if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){ return 0; } if( sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc)==0 ){ return MEM_Int; } return MEM_Real; |
︙ | |||
84541 84542 84543 84544 84545 84546 84547 | 84935 84936 84937 84938 84939 84940 84941 84942 84943 84944 84945 84946 84947 84948 84949 84950 | - - + + | case OP_Divide: { /* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */ if( rA==(double)0 ) goto arithmetic_result_is_null; rB /= rA; break; } default: { |
︙ | |||
84888 84889 84890 84891 84892 84893 84894 | 85282 85283 85284 85285 85286 85287 85288 85289 85290 85291 85292 85293 85294 85295 85296 85297 | - + + | if( pOp->p5 & SQLITE_NULLEQ ){ /* If SQLITE_NULLEQ is set (which will only happen if the operator is ** OP_Eq or OP_Ne) then take the jump or not depending on whether ** or not both operands are null. */ assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne ); assert( (flags1 & MEM_Cleared)==0 ); |
︙ | |||
86572 86573 86574 86575 86576 86577 86578 | 86967 86968 86969 86970 86971 86972 86973 86974 86975 86976 86977 86978 86979 86980 86981 86982 86983 86984 86985 86986 86987 86988 86989 86990 86991 86992 86993 86994 86995 86996 86997 86998 86999 87000 87001 | + - + + + + | pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE); if( pCx==0 ) goto no_mem; pCx->nullRow = 1; pCx->isEphemeral = 1; pCx->pKeyInfo = pOrig->pKeyInfo; pCx->isTable = pOrig->isTable; pCx->pgnoRoot = pOrig->pgnoRoot; |
︙ | |||
86621 86622 86623 86624 86625 86626 86627 | 87020 87021 87022 87023 87024 87025 87026 87027 87028 87029 87030 87031 87032 87033 87034 87035 87036 87037 87038 87039 87040 87041 87042 87043 87044 87045 87046 87047 87048 87049 87050 87051 87052 87053 87054 87055 87056 87057 87058 87059 87060 87061 87062 87063 87064 87065 87066 87067 87068 87069 87070 87071 87072 87073 87074 87075 87076 87077 | + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_EXCLUSIVE | SQLITE_OPEN_DELETEONCLOSE | SQLITE_OPEN_TRANSIENT_DB; assert( pOp->p1>=0 ); assert( pOp->p2>=0 ); pCx = p->apCsr[pOp->p1]; if( pCx ){ /* If the ephermeral table is already open, erase all existing content ** so that the table is empty again, rather than creating a new table. */ rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0); }else{ |
︙ | |||
87305 87306 87307 87308 87309 87310 87311 | 87713 87714 87715 87716 87717 87718 87719 87720 87721 87722 87723 87724 87725 87726 87727 | - + | case OP_NotExists: /* jump, in3 */ pIn3 = &aMem[pOp->p3]; assert( (pIn3->flags & MEM_Int)!=0 || pOp->opcode==OP_SeekRowid ); assert( pOp->p1>=0 && pOp->p1<p->nCursor ); pC = p->apCsr[pOp->p1]; assert( pC!=0 ); #ifdef SQLITE_DEBUG |
︙ | |||
88213 88214 88215 88216 88217 88218 88219 | 88621 88622 88623 88624 88625 88626 88627 88628 88629 88630 88631 88632 88633 88634 88635 | - + | assert( pOp->opcode!=OP_Prev || pOp->p4.xAdvance==sqlite3BtreePrevious ); /* The Next opcode is only used after SeekGT, SeekGE, Rewind, and Found. ** The Prev opcode is only used after SeekLT, SeekLE, and Last. */ assert( pOp->opcode!=OP_Next || pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE || pC->seekOp==OP_Rewind || pC->seekOp==OP_Found |
︙ | |||
88743 88744 88745 88746 88747 88748 88749 88750 88751 88752 88753 88754 88755 88756 88757 88758 88759 | 89151 89152 89153 89154 89155 89156 89157 89158 89159 89160 89161 89162 89163 89164 89165 89166 89167 89168 89169 89170 89171 89172 89173 89174 | + + + + + + + | db->aDb[iDb].zDbSName, zMaster, pOp->p4.z); if( zSql==0 ){ rc = SQLITE_NOMEM_BKPT; }else{ assert( db->init.busy==0 ); db->init.busy = 1; initData.rc = SQLITE_OK; initData.nInitRow = 0; assert( !db->mallocFailed ); rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0); if( rc==SQLITE_OK ) rc = initData.rc; if( rc==SQLITE_OK && initData.nInitRow==0 ){ /* The OP_ParseSchema opcode with a non-NULL P4 argument should parse ** at least one SQL statement. Any less than that indicates that ** the sqlite_master table is corrupt. */ rc = SQLITE_CORRUPT_BKPT; } sqlite3DbFreeNN(db, zSql); db->init.busy = 0; } } if( rc ){ sqlite3ResetAllSchemasOfConnection(db); if( rc==SQLITE_NOMEM ){ |
︙ | |||
89108 89109 89110 89111 89112 89113 89114 89115 89116 89117 89118 89119 89120 89121 | 89523 89524 89525 89526 89527 89528 89529 89530 89531 89532 89533 89534 89535 89536 89537 89538 89539 89540 89541 89542 89543 89544 89545 89546 89547 | + + + + + + + + + + + | p->apCsr = (VdbeCursor **)&aMem[p->nMem]; pFrame->aOnce = (u8*)&p->apCsr[pProgram->nCsr]; memset(pFrame->aOnce, 0, (pProgram->nOp + 7)/8); p->aOp = aOp = pProgram->aOp; p->nOp = pProgram->nOp; #ifdef SQLITE_ENABLE_STMT_SCANSTATUS p->anExec = 0; #endif #ifdef SQLITE_DEBUG /* Verify that second and subsequent executions of the same trigger do not ** try to reuse register values from the first use. */ { int i; for(i=0; i<p->nMem; i++){ aMem[i].pScopyFrom = 0; /* Prevent false-positive AboutToChange() errs */ aMem[i].flags |= MEM_Undefined; /* Cause a fault if this reg is reused */ } } #endif pOp = &aOp[-1]; break; } /* Opcode: Param P1 P2 * * * |
︙ | |||
89647 89648 89649 89650 89651 89652 89653 | 90073 90074 90075 90076 90077 90078 90079 90080 90081 90082 90083 90084 90085 90086 90087 90088 90089 90090 90091 90092 90093 90094 90095 90096 90097 90098 90099 | - + + + + + - + + | sqlite3VdbeChangeEncoding(pOut, encoding); if( rc ) goto abort_due_to_error; break; }; #endif /* SQLITE_OMIT_PRAGMA */ #if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH) |
︙ | |||
89806 89807 89808 89809 89810 89811 89812 89813 89814 89815 89816 89817 89818 89819 | 90237 90238 90239 90240 90241 90242 90243 90244 90245 90246 90247 90248 90249 90250 90251 | + | ** P4 is the name of a virtual table in database P1. Call the xDestroy method ** of that table. */ case OP_VDestroy: { db->nVDestroy++; rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z); db->nVDestroy--; assert( p->errorAction==OE_Abort && p->usesStmtJournal ); if( rc ) goto abort_due_to_error; break; } #endif /* SQLITE_OMIT_VIRTUALTABLE */ #ifndef SQLITE_OMIT_VIRTUALTABLE /* Opcode: VOpen P1 * * P4 * |
︙ | |||
90049 90050 90051 90052 90053 90054 90055 | 90481 90482 90483 90484 90485 90486 90487 90488 90489 90490 90491 90492 90493 90494 90495 | - + | assert( pName->flags & MEM_Str ); testcase( pName->enc==SQLITE_UTF8 ); testcase( pName->enc==SQLITE_UTF16BE ); testcase( pName->enc==SQLITE_UTF16LE ); rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8); if( rc ) goto abort_due_to_error; rc = pVtab->pModule->xRename(pVtab, pName->z); |
︙ | |||
94276 94277 94278 94279 94280 94281 94282 94283 94284 94285 94286 94287 94288 94289 | 94708 94709 94710 94711 94712 94713 94714 94715 94716 94717 94718 94719 94720 94721 94722 94723 94724 94725 94726 94727 94728 94729 94730 94731 94732 94733 94734 94735 94736 94737 | + + + + + + + + + + + + + + + + | ** an SQL statement. */ /* #include "sqliteInt.h" */ /* #include <stdlib.h> */ /* #include <string.h> */ #if !defined(SQLITE_OMIT_WINDOWFUNC) /* ** Walk all expressions linked into the list of Window objects passed ** as the second argument. */ static int walkWindowList(Walker *pWalker, Window *pList){ Window *pWin; for(pWin=pList; pWin; pWin=pWin->pNextWin){ if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort; if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort; if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort; } return WRC_Continue; } #endif /* ** Walk an expression tree. Invoke the callback once for each node ** of the expression, while descending. (In other words, the callback ** is invoked before visiting children.) ** ** The return value from the callback should be one of the WRC_* ** constants to specify how to proceed with the walk. |
︙ | |||
94315 94316 94317 94318 94319 94320 94321 | 94763 94764 94765 94766 94767 94768 94769 94770 94771 94772 94773 94774 94775 94776 94777 | - - - - + | }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){ if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; }else if( pExpr->x.pList ){ if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort; } #ifndef SQLITE_OMIT_WINDOWFUNC if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
︙ | |||
94358 94359 94360 94361 94362 94363 94364 94365 94366 94367 94368 94369 94370 94371 | 94803 94804 94805 94806 94807 94808 94809 94810 94811 94812 94813 94814 94815 94816 94817 94818 94819 94820 94821 94822 94823 94824 94825 94826 | + + + + + + + + + + | SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){ if( sqlite3WalkExprList(pWalker, p->pEList) ) return WRC_Abort; if( sqlite3WalkExpr(pWalker, p->pWhere) ) return WRC_Abort; if( sqlite3WalkExprList(pWalker, p->pGroupBy) ) return WRC_Abort; if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort; if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort; if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort; #if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE) { Parse *pParse = pWalker->pParse; if( pParse && IN_RENAME_OBJECT ){ int rc = walkWindowList(pWalker, p->pWinDefn); assert( rc==WRC_Continue ); return rc; } } #endif return WRC_Continue; } /* ** Walk the parse trees associated with all subqueries in the ** FROM clause of SELECT statement p. Do not invoke the select ** callback on p, but do invoke it on each FROM clause subquery |
︙ | |||
94509 94510 94511 94512 94513 94514 94515 | 94964 94965 94966 94967 94968 94969 94970 94971 94972 94973 94974 94975 94976 94977 | - | db = pParse->db; pDup = sqlite3ExprDup(db, pOrig, 0); if( pDup!=0 ){ if( zType[0]!='G' ) incrAggFunctionDepth(pDup, nSubquery); if( pExpr->op==TK_COLLATE ){ pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); } |
︙ | |||
94903 94904 94905 94906 94907 94908 94909 94910 94911 94912 94913 94914 94915 94916 | 95357 95358 95359 95360 95361 95362 95363 95364 95365 95366 95367 95368 95369 95370 95371 95372 95373 95374 95375 95376 95377 95378 95379 95380 95381 95382 95383 95384 95385 95386 95387 95388 95389 | + + + + + + + + + + + + + + + + + + + | ** ** Because no reference was made to outer contexts, the pNC->nRef ** fields are not changed in any context. */ if( cnt==0 && zTab==0 ){ assert( pExpr->op==TK_ID ); if( ExprHasProperty(pExpr,EP_DblQuoted) ){ /* If a double-quoted identifier does not match any known column name, ** then treat it as a string. ** ** This hack was added in the early days of SQLite in a misguided attempt ** to be compatible with MySQL 3.x, which used double-quotes for strings. ** I now sorely regret putting in this hack. The effect of this hack is ** that misspelled identifier names are silently converted into strings ** rather than causing an error, to the frustration of countless ** programmers. To all those frustrated programmers, my apologies. ** ** Someday, I hope to get rid of this hack. Unfortunately there is ** a huge amount of legacy SQL that uses it. So for now, we just ** issue a warning. */ sqlite3_log(SQLITE_WARNING, "double-quoted string literal: \"%w\"", zCol); #ifdef SQLITE_ENABLE_NORMALIZE sqlite3VdbeAddDblquoteStr(db, pParse->pVdbe, zCol); #endif pExpr->op = TK_STRING; pExpr->y.pTab = 0; return WRC_Prune; } if( sqlite3ExprIdToTrueFalse(pExpr) ){ return WRC_Prune; } |
︙ | |||
95269 95270 95271 95272 95273 95274 95275 95276 95277 95278 | 95742 95743 95744 95745 95746 95747 95748 95749 95750 95751 95752 95753 95754 95755 95756 95757 95758 95759 | + - | } } sqlite3WalkExprList(pWalker, pList); if( is_agg ){ #ifndef SQLITE_OMIT_WINDOWFUNC if( pExpr->y.pWin ){ Select *pSel = pNC->pWinSelect; sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef); sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition); sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy); sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter); |
︙ | |||
95549 95550 95551 95552 95553 95554 95555 | 96022 96023 96024 96025 96026 96027 96028 96029 96030 96031 96032 96033 96034 96035 96036 96037 96038 96039 96040 96041 96042 96043 96044 96045 96046 96047 96048 96049 96050 96051 96052 96053 96054 96055 96056 96057 96058 96059 96060 96061 96062 96063 96064 96065 96066 96067 96068 96069 96070 96071 96072 96073 96074 96075 96076 96077 96078 96079 96080 96081 96082 | + + + + + + + + + + + + + + + + - + + + - + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + | if( iCol<=0 || iCol>pEList->nExpr ){ resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr); return 1; } }else{ iCol = resolveAsName(pParse, pEList, pE); if( iCol==0 ){ /* Now test if expression pE matches one of the values returned ** by pSelect. In the usual case this is done by duplicating the ** expression, resolving any symbols in it, and then comparing ** it against each expression returned by the SELECT statement. ** Once the comparisons are finished, the duplicate expression ** is deleted. ** ** Or, if this is running as part of an ALTER TABLE operation, ** resolve the symbols in the actual expression, not a duplicate. ** And, if one of the comparisons is successful, leave the expression ** as is instead of transforming it to an integer as in the usual ** case. This allows the code in alter.c to modify column ** refererences within the ORDER BY expression as required. */ if( IN_RENAME_OBJECT ){ pDup = pE; }else{ |
︙ | |||
95922 95923 95924 95925 95926 95927 95928 95929 95930 95931 95932 95933 95934 95935 | 96416 96417 96418 96419 96420 96421 96422 96423 96424 96425 96426 96427 96428 96429 96430 96431 96432 96433 96434 96435 96436 96437 96438 96439 96440 | + + + + + + + + + + + | if( ExprHasProperty(pItem->pExpr, EP_Agg) ){ sqlite3ErrorMsg(pParse, "aggregate functions are not allowed in " "the GROUP BY clause"); return WRC_Abort; } } } if( IN_RENAME_OBJECT ){ Window *pWin; for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){ if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy) || sqlite3ResolveExprListNames(&sNC, pWin->pPartition) ){ return WRC_Abort; } } } /* If this is part of a compound SELECT, check that it has the right ** number of expressions in the select list. */ if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){ sqlite3SelectWrongNumTermsError(pParse, p->pNext); return WRC_Abort; } |
︙ | |||
96073 96074 96075 96076 96077 96078 96079 | 96578 96579 96580 96581 96582 96583 96584 96585 96586 96587 96588 96589 96590 96591 96592 96593 96594 96595 96596 96597 96598 96599 96600 96601 96602 96603 96604 96605 96606 96607 96608 96609 96610 96611 96612 96613 96614 96615 96616 96617 96618 96619 96620 96621 96622 96623 96624 96625 96626 96627 96628 96629 96630 96631 96632 | - + + - - + + + + - - + + + - + - - + + + + - + + - - - - + + + + + - - + + + | w.xSelectCallback2 = 0; w.pParse = pParse; w.u.pNC = pOuterNC; sqlite3WalkSelect(&w, p); } /* |
︙ | |||
96252 96253 96254 96255 96256 96257 96258 | 96766 96767 96768 96769 96770 96771 96772 96773 96774 96775 96776 96777 96778 96779 96780 96781 96782 96783 96784 96785 96786 96787 96788 96789 96790 96791 96792 96793 96794 96795 96796 96797 | + - + - - + | SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){ sqlite3 *db = pParse->db; CollSeq *pColl = 0; Expr *p = pExpr; while( p ){ int op = p->op; if( p->flags & EP_Generic ) break; if( op==TK_REGISTER ) op = p->op2; |
︙ | |||
96576 96577 96578 96579 96580 96581 96582 96583 96584 96585 96586 96587 96588 96589 96590 96591 96592 96593 96594 96595 96596 96597 96598 | 97090 97091 97092 97093 97094 97095 97096 97097 97098 97099 97100 97101 97102 97103 97104 97105 97106 97107 97108 97109 97110 97111 97112 97113 97114 97115 97116 97117 97118 97119 97120 97121 | + - + | pRet->iColumn = iField; pRet->pLeft = pVector; } assert( pRet==0 || pRet->iTable==0 ); }else{ if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr; pRet = sqlite3ExprDup(pParse->db, pVector, 0); sqlite3RenameTokenRemap(pParse, pRet, pVector); } return pRet; } /* ** If expression pExpr is of type TK_SELECT, generate code to evaluate ** it. Return the register in which the result is stored (or, if the ** sub-select returns more than one column, the first in an array ** of registers in which the result is stored). ** ** If pExpr is not a TK_SELECT expression, return 0. */ static int exprCodeSubselect(Parse *pParse, Expr *pExpr){ int reg = 0; #ifndef SQLITE_OMIT_SUBQUERY if( pExpr->op==TK_SELECT ){ |
︙ | |||
96664 96665 96666 96667 96668 96669 96670 | 97179 97180 97181 97182 97183 97184 97185 97186 97187 97188 97189 97190 97191 97192 97193 | - + | Expr *pLeft = pExpr->pLeft; Expr *pRight = pExpr->pRight; int nLeft = sqlite3ExprVectorSize(pLeft); int i; int regLeft = 0; int regRight = 0; u8 opx = op; |
︙ | |||
96891 96892 96893 96894 96895 96896 96897 | 97406 97407 97408 97409 97410 97411 97412 97413 97414 97415 97416 97417 97418 97419 97420 | - - + | pNew->u.iValue = iValue; }else{ pNew->u.zToken = (char*)&pNew[1]; assert( pToken->z!=0 || pToken->n==0 ); if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n); pNew->u.zToken[pToken->n] = 0; if( dequote && sqlite3Isquote(pNew->u.zToken[0]) ){ |
︙ | |||
96961 96962 96963 96964 96965 96966 96967 | 97475 97476 97477 97478 97479 97480 97481 97482 97483 97484 97485 97486 97487 97488 97489 | - + | SQLITE_PRIVATE Expr *sqlite3PExpr( Parse *pParse, /* Parsing context */ int op, /* Expression opcode */ Expr *pLeft, /* Left operand */ Expr *pRight /* Right operand */ ){ Expr *p; |
︙ | |||
97209 97210 97211 97212 97213 97214 97215 97216 97217 97218 97219 97220 97221 97222 | 97723 97724 97725 97726 97727 97728 97729 97730 97731 97732 97733 97734 97735 97736 97737 97738 97739 97740 97741 97742 97743 97744 97745 97746 | + + + + + + + + + + | ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. */ static int exprStructSize(Expr *p){ if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE; if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE; return EXPR_FULLSIZE; } /* ** Copy the complete content of an Expr node, taking care not to read ** past the end of the structure for a reduced-size version of the source ** Expr. */ static void exprNodeCopy(Expr *pDest, Expr *pSrc){ memset(pDest, 0, sizeof(Expr)); memcpy(pDest, pSrc, exprStructSize(pSrc)); } /* ** The dupedExpr*Size() routines each return the number of bytes required ** to store a copy of an expression or expression tree. They differ in ** how much of the tree is measured. ** ** dupedExprStructSize() Size of only the Expr structure |
︙ | |||
97440 97441 97442 97443 97444 97445 97446 97447 97448 97449 97450 97451 97452 97453 | 97964 97965 97966 97967 97968 97969 97970 97971 97972 97973 97974 97975 97976 97977 97978 97979 97980 97981 97982 97983 97984 97985 97986 97987 97988 97989 97990 97991 97992 97993 97994 97995 97996 97997 97998 97999 98000 98001 98002 98003 98004 98005 98006 98007 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } } return pRet; } #else # define withDup(x,y) 0 #endif #ifndef SQLITE_OMIT_WINDOWFUNC /* ** The gatherSelectWindows() procedure and its helper routine ** gatherSelectWindowsCallback() are used to scan all the expressions ** an a newly duplicated SELECT statement and gather all of the Window ** objects found there, assembling them onto the linked list at Select->pWin. */ static int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){ if( pExpr->op==TK_FUNCTION && pExpr->y.pWin!=0 ){ assert( ExprHasProperty(pExpr, EP_WinFunc) ); pExpr->y.pWin->pNextWin = pWalker->u.pSelect->pWin; pWalker->u.pSelect->pWin = pExpr->y.pWin; } return WRC_Continue; } static int gatherSelectWindowsSelectCallback(Walker *pWalker, Select *p){ return p==pWalker->u.pSelect ? WRC_Continue : WRC_Prune; } static void gatherSelectWindows(Select *p){ Walker w; w.xExprCallback = gatherSelectWindowsCallback; w.xSelectCallback = gatherSelectWindowsSelectCallback; w.xSelectCallback2 = 0; w.pParse = 0; w.u.pSelect = p; sqlite3WalkSelect(&w, p); } #endif /* ** The following group of routines make deep copies of expressions, ** expression lists, ID lists, and select statements. The copies can ** be deleted (by being passed to their respective ...Delete() routines) ** without effecting the originals. ** |
︙ | |||
97608 97609 97610 97611 97612 97613 97614 97615 97616 97617 97618 97619 97620 97621 | 98162 98163 98164 98165 98166 98167 98168 98169 98170 98171 98172 98173 98174 98175 98176 | + | pNew->addrOpenEphm[0] = -1; pNew->addrOpenEphm[1] = -1; pNew->nSelectRow = p->nSelectRow; pNew->pWith = withDup(db, p->pWith); #ifndef SQLITE_OMIT_WINDOWFUNC pNew->pWin = 0; pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn); if( p->pWin ) gatherSelectWindows(pNew); #endif pNew->selId = p->selId; *pp = pNew; pp = &pNew->pPrior; pNext = pNew; } |
︙ | |||
97740 97741 97742 97743 97744 97745 97746 97747 97748 97749 97750 97751 97752 97753 | 98295 98296 98297 98298 98299 98300 98301 98302 98303 98304 98305 98306 98307 98308 98309 98310 98311 | + + + | /* Remember the size of the LHS in iTable so that we can check that ** the RHS and LHS sizes match during code generation. */ pFirst->iTable = pColumns->nId; } vector_append_error: if( IN_RENAME_OBJECT ){ sqlite3RenameExprUnmap(pParse, pExpr); } sqlite3ExprDelete(db, pExpr); sqlite3IdListDelete(db, pColumns); return pList; } /* ** Set the sort order for the last element on the given ExprList. |
︙ | |||
97883 97884 97885 97886 97887 97888 97889 | 98441 98442 98443 98444 98445 98446 98447 98448 98449 98450 98451 98452 98453 98454 98455 98456 98457 | + - - + + | /* ** If the input expression is an ID with the name "true" or "false" ** then convert it into an TK_TRUEFALSE term. Return non-zero if ** the conversion happened, and zero if the expression is unaltered. */ SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr *pExpr){ assert( pExpr->op==TK_ID || pExpr->op==TK_STRING ); if( !ExprHasProperty(pExpr, EP_Quoted) |
︙ | |||
98193 98194 98195 98196 98197 98198 98199 | 98752 98753 98754 98755 98756 98757 98758 98759 98760 98761 98762 98763 98764 98765 98766 98767 98768 | - + + + | ** be a small performance hit but is otherwise harmless. On the other ** hand, a false negative (returning FALSE when the result could be NULL) ** will likely result in an incorrect answer. So when in doubt, return ** TRUE. */ SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){ u8 op; |
︙ | |||
98260 98261 98262 98263 98264 98265 98266 | 98821 98822 98823 98824 98825 98826 98827 98828 98829 98830 98831 98832 98833 98834 | - - - - - - - - | */ SQLITE_PRIVATE int sqlite3IsRowid(const char *z){ if( sqlite3StrICmp(z, "_ROWID_")==0 ) return 1; if( sqlite3StrICmp(z, "ROWID")==0 ) return 1; if( sqlite3StrICmp(z, "OID")==0 ) return 1; return 0; } |
︙ | |||
98437 98438 98439 98440 98441 98442 98443 | 98990 98991 98992 98993 98994 98995 98996 98997 98998 98999 99000 99001 99002 99003 99004 99005 | - + + | */ #ifndef SQLITE_OMIT_SUBQUERY SQLITE_PRIVATE int sqlite3FindInIndex( Parse *pParse, /* Parsing context */ Expr *pX, /* The right-hand side (RHS) of the IN operator */ u32 inFlags, /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */ int *prRhsHasNull, /* Register holding NULL status. See notes */ |
︙ | |||
98532 98533 98534 98535 98536 98537 98538 98539 98540 98541 98542 98543 98544 98545 | 99086 99087 99088 99089 99090 99091 99092 99093 99094 99095 99096 99097 99098 99099 99100 | + | if( affinity_ok ){ /* Search for an existing index that will work for this IN operator */ for(pIdx=pTab->pIndex; pIdx && eType==0; pIdx=pIdx->pNext){ Bitmask colUsed; /* Columns of the index used */ Bitmask mCol; /* Mask for the current column */ if( pIdx->nColumn<nExpr ) continue; if( pIdx->pPartIdxWhere!=0 ) continue; /* Maximum nColumn is BMS-2, not BMS-1, so that we can compute ** BITMASK(nExpr) without overflowing */ testcase( pIdx->nColumn==BMS-2 ); testcase( pIdx->nColumn==BMS-1 ); if( pIdx->nColumn>=BMS-1 ) continue; if( mustBeUnique ){ if( pIdx->nKeyCol>nExpr |
︙ | |||
98628 98629 98630 98631 98632 98633 98634 | 99183 99184 99185 99186 99187 99188 99189 99190 99191 99192 99193 99194 99195 99196 99197 99198 99199 99200 99201 99202 99203 99204 99205 99206 99207 99208 99209 99210 | + - + + + + - - + | pParse->nQueryLoop = 0; if( pX->pLeft->iColumn<0 && !ExprHasProperty(pX, EP_xIsSelect) ){ eType = IN_INDEX_ROWID; } }else if( prRhsHasNull ){ *prRhsHasNull = rMayHaveNull = ++pParse->nMem; } assert( pX->op==TK_IN ); |
︙ | |||
98712 98713 98714 98715 98716 98717 98718 98719 | 99270 99271 99272 99273 99274 99275 99276 99277 99278 99279 99280 99281 99282 99283 99284 99285 99286 99287 99288 99289 99290 99291 99292 99293 99294 99295 99296 99297 99298 99299 99300 99301 99302 99303 99304 99305 99306 99307 99308 99309 99310 99311 99312 99313 99314 99315 99316 99317 99318 99319 99320 99321 99322 99323 99324 99325 99326 99327 99328 99329 99330 99331 99332 99333 99334 99335 99336 99337 99338 99339 99340 99341 99342 99343 99344 99345 99346 99347 99348 99349 99350 99351 99352 99353 99354 99355 99356 99357 99358 99359 99360 99361 99362 99363 99364 99365 99366 99367 99368 99369 99370 99371 99372 99373 99374 99375 99376 99377 99378 99379 99380 99381 99382 99383 99384 99385 99386 99387 99388 99389 99390 99391 99392 99393 99394 99395 99396 99397 99398 99399 99400 99401 99402 99403 99404 99405 99406 99407 99408 99409 99410 99411 99412 99413 99414 99415 99416 99417 99418 99419 99420 99421 99422 99423 99424 99425 99426 99427 99428 99429 99430 99431 99432 99433 99434 99435 99436 99437 99438 99439 99440 99441 99442 99443 99444 99445 99446 99447 99448 99449 99450 99451 99452 99453 99454 99455 99456 99457 99458 99459 99460 99461 99462 99463 99464 99465 99466 99467 99468 99469 99470 99471 99472 99473 99474 99475 99476 99477 99478 99479 99480 99481 99482 99483 99484 99485 99486 99487 99488 99489 99490 99491 99492 99493 99494 99495 99496 99497 99498 99499 99500 99501 99502 99503 99504 99505 99506 99507 99508 99509 99510 99511 99512 99513 99514 99515 99516 99517 99518 99519 99520 99521 99522 99523 99524 99525 99526 99527 99528 99529 99530 99531 99532 99533 99534 99535 99536 99537 99538 99539 99540 99541 99542 99543 99544 99545 99546 99547 99548 99549 99550 99551 99552 99553 99554 99555 99556 99557 99558 99559 99560 99561 99562 99563 99564 99565 99566 99567 99568 99569 99570 99571 99572 99573 99574 99575 99576 99577 99578 99579 99580 99581 99582 99583 99584 99585 99586 99587 99588 99589 99590 99591 99592 99593 99594 99595 99596 99597 99598 99599 99600 99601 99602 99603 | + - - + + + - - - - + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - + + - - - + + + - - - - - + + + + + + + + + + - + - - - + - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - + - - - - - - - - - - + + - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - + - - - - - - - - + - - - - - - - - - - + - - - + - - - - + - - + - - - - - + - - - - - - - - + + - - + - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + - - - - + + + - - + + | }else #endif { sqlite3ErrorMsg(pParse, "row value misused"); } } #ifndef SQLITE_OMIT_SUBQUERY /* |
︙ | |||
99042 99043 99044 99045 99046 99047 99048 99049 99050 99051 99052 99053 99054 99055 99056 99057 99058 99059 | 99666 99667 99668 99669 99670 99671 99672 99673 99674 99675 99676 99677 99678 99679 99680 99681 99682 99683 99684 99685 99686 99687 99688 99689 99690 99691 99692 99693 99694 99695 99696 99697 99698 99699 99700 99701 | + - + - + + | Expr *pLeft; /* The LHS of the IN operator */ int i; /* loop counter */ int destStep2; /* Where to jump when NULLs seen in step 2 */ int destStep6 = 0; /* Start of code for Step 6 */ int addrTruthOp; /* Address of opcode that determines the IN is true */ int destNotNull; /* Jump here if a comparison is not true in step 6 */ int addrTop; /* Top of the step-6 loop */ int iTab = 0; /* Index to use */ pLeft = pExpr->pLeft; if( sqlite3ExprCheckIN(pParse, pExpr) ) return; zAff = exprINAffinity(pParse, pExpr); nVector = sqlite3ExprVectorSize(pExpr->pLeft); aiMap = (int*)sqlite3DbMallocZero( pParse->db, nVector*(sizeof(int) + sizeof(char)) + 1 ); if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error; /* Attempt to compute the RHS. After this step, if anything other than |
︙ | |||
99107 99108 99109 99110 99111 99112 99113 | 99733 99734 99735 99736 99737 99738 99739 99740 99741 99742 99743 99744 99745 99746 99747 | - + | ** sequence of comparisons. ** ** This is step (1) in the in-operator.md optimized algorithm. */ if( eType==IN_INDEX_NOOP ){ ExprList *pList = pExpr->x.pList; CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft); |
︙ | |||
99151 99152 99153 99154 99155 99156 99157 | 99777 99778 99779 99780 99781 99782 99783 99784 99785 99786 99787 99788 99789 99790 99791 99792 99793 99794 99795 99796 99797 99798 99799 99800 99801 99802 99803 99804 99805 99806 99807 99808 99809 99810 99811 99812 99813 99814 99815 99816 99817 99818 99819 99820 99821 | - + - + - + - + | /* Step 2: Check to see if the LHS contains any NULL columns. If the ** LHS does contain NULLs then the result must be either FALSE or NULL. ** We will then skip the binary search of the RHS. */ if( destIfNull==destIfFalse ){ destStep2 = destIfFalse; }else{ |
︙ | |||
99206 99207 99208 99209 99210 99211 99212 | 99832 99833 99834 99835 99836 99837 99838 99839 99840 99841 99842 99843 99844 99845 99846 99847 99848 99849 99850 99851 99852 99853 99854 99855 99856 99857 99858 99859 99860 99861 99862 99863 99864 99865 99866 99867 99868 99869 99870 | - + - + - + - + | ** If any comparison is NULL, then the result is NULL. If all ** comparisons are FALSE then the final result is FALSE. ** ** For a scalar LHS, it is sufficient to check just the first row ** of the RHS. */ if( destStep6 ) sqlite3VdbeResolveLabel(v, destStep6); |
︙ | |||
99429 99430 99431 99432 99433 99434 99435 | 100055 100056 100057 100058 100059 100060 100061 100062 100063 100064 100065 100066 100067 100068 100069 | - + | iResult = sqlite3ExprCodeTemp(pParse, p, piFreeable); }else{ *piFreeable = 0; if( p->op==TK_SELECT ){ #if SQLITE_OMIT_SUBQUERY iResult = 0; #else |
︙ | |||
99774 99775 99776 99777 99778 99779 99780 | 100400 100401 100402 100403 100404 100405 100406 100407 100408 100409 100410 100411 100412 100413 100414 | - + | } /* Attempt a direct implementation of the built-in COALESCE() and ** IFNULL() functions. This avoids unnecessary evaluation of ** arguments past the first non-NULL argument. */ if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){ |
︙ | |||
99903 99904 99905 99906 99907 99908 99909 | 100529 100530 100531 100532 100533 100534 100535 100536 100537 100538 100539 100540 100541 100542 100543 100544 100545 100546 100547 100548 100549 100550 100551 100552 100553 100554 100555 100556 100557 100558 100559 100560 100561 100562 100563 | - + - + - - + + | case TK_SELECT: { int nCol; testcase( op==TK_EXISTS ); testcase( op==TK_SELECT ); if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){ sqlite3SubselectError(pParse, nCol, 1); }else{ |
︙ | |||
100063 100064 100065 100066 100067 100068 100069 | 100689 100690 100691 100692 100693 100694 100695 100696 100697 100698 100699 100700 100701 100702 100703 100704 100705 100706 100707 100708 100709 100710 100711 100712 100713 100714 100715 100716 100717 100718 100719 100720 100721 100722 100723 100724 100725 100726 | - + - + - + | Expr *pTest = 0; /* X==Ei (form A) or just Ei (form B) */ assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList ); assert(pExpr->x.pList->nExpr > 0); pEList = pExpr->x.pList; aListelem = pEList->a; nExpr = pEList->nExpr; |
︙ | |||
100386 100387 100388 100389 100390 100391 100392 | 101012 101013 101014 101015 101016 101017 101018 101019 101020 101021 101022 101023 101024 101025 101026 101027 101028 101029 101030 101031 | - - + | ){ Expr exprAnd; /* The AND operator in x>=y AND x<=z */ Expr compLeft; /* The x>=y term */ Expr compRight; /* The x<=z term */ Expr exprX; /* The x subexpression */ int regFree1 = 0; /* Temporary use register */ |
︙ | |||
100455 100456 100457 100458 100459 100460 100461 | 101080 101081 101082 101083 101084 101085 101086 101087 101088 101089 101090 101091 101092 101093 101094 | - + | assert( jumpIfNull==SQLITE_JUMPIFNULL || jumpIfNull==0 ); if( NEVER(v==0) ) return; /* Existence of VDBE checked by caller */ if( NEVER(pExpr==0) ) return; /* No way this can happen */ op = pExpr->op; switch( op ){ case TK_AND: { |
︙ | |||
100541 100542 100543 100544 100545 100546 100547 | 101166 101167 101168 101169 101170 101171 101172 101173 101174 101175 101176 101177 101178 101179 101180 | - + | case TK_BETWEEN: { testcase( jumpIfNull==0 ); exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfTrue, jumpIfNull); break; } #ifndef SQLITE_OMIT_SUBQUERY case TK_IN: { |
︙ | |||
100628 100629 100630 100631 100632 100633 100634 | 101253 101254 101255 101256 101257 101258 101259 101260 101261 101262 101263 101264 101265 101266 101267 | - + | case TK_AND: { testcase( jumpIfNull==0 ); sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull); sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull); break; } case TK_OR: { |
︙ | |||
100712 100713 100714 100715 100716 100717 100718 | 101337 101338 101339 101340 101341 101342 101343 101344 101345 101346 101347 101348 101349 101350 101351 | - + | break; } #ifndef SQLITE_OMIT_SUBQUERY case TK_IN: { if( jumpIfNull ){ sqlite3ExprCodeIN(pParse, pExpr, dest, dest); }else{ |
︙ | |||
100833 100834 100835 100836 100837 100838 100839 | 101458 101459 101460 101461 101462 101463 101464 101465 101466 101467 101468 101469 101470 101471 101472 | - + | combinedFlags = pA->flags | pB->flags; if( combinedFlags & EP_IntValue ){ if( (pA->flags&pB->flags&EP_IntValue)!=0 && pA->u.iValue==pB->u.iValue ){ return 0; } return 2; } |
︙ | |||
100859 100860 100861 100862 100863 100864 100865 100866 100867 | 101484 101485 101486 101487 101488 101489 101490 101491 101492 101493 101494 101495 101496 101497 101498 101499 101500 101501 101502 101503 101504 101505 101506 101507 101508 101509 101510 101511 101512 101513 101514 101515 101516 | + + - + - + - - + + + + | ** if we reach this point, either A and B both window functions or ** neither are a window functions. */ assert( ExprHasProperty(pA,EP_WinFunc)==ExprHasProperty(pB,EP_WinFunc) ); if( ExprHasProperty(pA,EP_WinFunc) ){ if( sqlite3WindowCompare(pParse,pA->y.pWin,pB->y.pWin)!=0 ) return 2; } #endif }else if( pA->op==TK_NULL ){ return 0; }else if( pA->op==TK_COLLATE ){ if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; |
︙ | |||
100982 100983 100984 100985 100986 100987 100988 100989 100990 100991 100992 100993 100994 100995 100996 100997 100998 100999 101000 101001 101002 101003 | 101611 101612 101613 101614 101615 101616 101617 101618 101619 101620 101621 101622 101623 101624 101625 101626 101627 101628 101629 101630 101631 101632 101633 101634 | + + | testcase( pExpr->op==TK_AGG_COLUMN ); testcase( pExpr->op==TK_AGG_FUNCTION ); if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune; switch( pExpr->op ){ case TK_ISNOT: case TK_NOT: case TK_ISNULL: case TK_NOTNULL: case TK_IS: case TK_OR: case TK_CASE: case TK_IN: case TK_FUNCTION: testcase( pExpr->op==TK_ISNOT ); testcase( pExpr->op==TK_NOT ); testcase( pExpr->op==TK_ISNULL ); testcase( pExpr->op==TK_NOTNULL ); testcase( pExpr->op==TK_IS ); testcase( pExpr->op==TK_OR ); testcase( pExpr->op==TK_CASE ); testcase( pExpr->op==TK_IN ); testcase( pExpr->op==TK_FUNCTION ); return WRC_Prune; case TK_COLUMN: |
︙ | |||
101363 101364 101365 101366 101367 101368 101369 101370 101371 101372 101373 101374 101375 101376 | 101994 101995 101996 101997 101998 101999 102000 102001 102002 102003 102004 102005 102006 102007 102008 | + | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){ Walker w; w.xExprCallback = analyzeAggregate; w.xSelectCallback = analyzeAggregatesInSelect; w.xSelectCallback2 = analyzeAggregatesInSelectEnd; w.walkerDepth = 0; w.u.pNC = pNC; w.pParse = 0; assert( pNC->pSrcList!=0 ); sqlite3WalkExpr(&w, pExpr); } /* ** Call sqlite3ExprAnalyzeAggregates() for every expression in an ** expression list. Return the number of errors. |
︙ | |||
101494 101495 101496 101497 101498 101499 101500 | 102126 102127 102128 102129 102130 102131 102132 102133 102134 102135 102136 102137 102138 102139 102140 102141 102142 102143 102144 102145 102146 102147 102148 102149 | - - - + + + + + + + + + + | ** Parameter zName is the name of a table that is about to be altered ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN). ** If the table is a system table, this function leaves an error message ** in pParse->zErr (system tables may not be altered) and returns non-zero. ** ** Or, if zName is not a system table, zero is returned. */ |
︙ | |||
101592 101593 101594 101595 101596 101597 101598 | 102231 102232 102233 102234 102235 102236 102237 102238 102239 102240 102241 102242 102243 102244 102245 | - + | "there is already another table or index with this name: %s", zName); goto exit_rename_table; } /* Make sure it is not a system table being altered, or a reserved name ** that the table is being renamed to. */ |
︙ | |||
101890 101891 101892 101893 101894 101895 101896 | 102529 102530 102531 102532 102533 102534 102535 102536 102537 102538 102539 102540 102541 102542 102543 | - + | #endif /* Make sure this is not an attempt to ALTER a view. */ if( pTab->pSelect ){ sqlite3ErrorMsg(pParse, "Cannot add a column to a view"); goto exit_begin_add_column; } |
︙ | |||
101992 101993 101994 101995 101996 101997 101998 | 102631 102632 102633 102634 102635 102636 102637 102638 102639 102640 102641 102642 102643 102644 102645 | - + | int bQuote; /* True to quote the new name */ /* Locate the table to be altered */ pTab = sqlite3LocateTableItem(pParse, 0, &pSrc->a[0]); if( !pTab ) goto exit_rename_column; /* Cannot alter a system table */ |
︙ | |||
102245 102246 102247 102248 102249 102250 102251 102252 102253 102254 102255 102256 102257 102258 | 102884 102885 102886 102887 102888 102889 102890 102891 102892 102893 102894 102895 102896 102897 102898 102899 102900 102901 102902 102903 102904 102905 102906 102907 102908 102909 102910 102911 102912 102913 102914 102915 102916 102917 102918 102919 102920 102921 102922 102923 | + + + + + + + + + + + + + + + + + + - + - | pToken->pNext = pCtx->pList; pCtx->pList = pToken; pCtx->nList++; break; } } } /* ** Iterate through the Select objects that are part of WITH clauses attached ** to select statement pSelect. */ static void renameWalkWith(Walker *pWalker, Select *pSelect){ if( pSelect->pWith ){ int i; for(i=0; i<pSelect->pWith->nCte; i++){ Select *p = pSelect->pWith->a[i].pSelect; NameContext sNC; memset(&sNC, 0, sizeof(sNC)); sNC.pParse = pWalker->pParse; sqlite3SelectPrep(sNC.pParse, p, &sNC); sqlite3WalkSelect(pWalker, p); } } } /* ** This is a Walker select callback. It does nothing. It is only required ** because without a dummy callback, sqlite3WalkExpr() and similar do not ** descend into sub-select statements. */ static int renameColumnSelectCb(Walker *pWalker, Select *p){ |
︙ | |||
102403 102404 102405 102406 102407 102408 102409 | 103059 103060 103061 103062 103063 103064 103065 103066 103067 103068 103069 103070 103071 103072 | - | memset(p, 0, sizeof(Parse)); p->eParseMode = (bTable ? PARSE_MODE_RENAME_TABLE : PARSE_MODE_RENAME_COLUMN); p->db = db; p->nQueryLoop = 1; rc = sqlite3RunParser(p, zSql, &zErr); assert( p->zErrMsg==0 ); assert( rc!=SQLITE_OK || zErr==0 ); |
︙ | |||
102586 102587 102588 102589 102590 102591 102592 102593 102594 102595 102596 102597 102598 102599 | 103241 103242 103243 103244 103245 103246 103247 103248 103249 103250 103251 103252 103253 103254 103255 | + | rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertWhere); } if( rc==SQLITE_OK ){ rc = sqlite3ResolveExprNames(&sNC, pUpsert->pUpsertTargetWhere); } sNC.ncFlags = 0; } sNC.pSrcList = 0; } } } return rc; } /* |
︙ | |||
102623 102624 102625 102626 102627 102628 102629 102630 102631 102632 102633 | 103279 103280 103281 103282 103283 103284 103285 103286 103287 103288 103289 103290 103291 103292 103293 103294 103295 103296 103297 103298 103299 103300 103301 | + + + - + + | /* ** Free the contents of Parse object (*pParse). Do not free the memory ** occupied by the Parse object itself. */ static void renameParseCleanup(Parse *pParse){ sqlite3 *db = pParse->db; Index *pIdx; if( pParse->pVdbe ){ sqlite3VdbeFinalize(pParse->pVdbe); } sqlite3DeleteTable(db, pParse->pNewTable); while( (pIdx = pParse->pNewIndex)!=0 ){ pParse->pNewIndex = pIdx->pNext; |
︙ | |||
102738 102739 102740 102741 102742 102743 102744 102745 102746 102747 102748 102749 102750 102751 | 103398 103399 103400 103401 103402 103403 103404 103405 103406 103407 103408 103409 103410 103411 103412 103413 103414 | + + + | if( sCtx.iCol<0 ){ renameTokenFind(&sParse, &sCtx, (void*)&sParse.pNewTable->iPKey); } sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck); for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){ sqlite3WalkExprList(&sWalker, pIdx->aColExpr); } for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){ sqlite3WalkExprList(&sWalker, pIdx->aColExpr); } } for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){ for(i=0; i<pFKey->nCol; i++){ if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){ renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]); } |
︙ | |||
102824 102825 102826 102827 102828 102829 102830 102831 102832 102833 102834 102835 102836 102837 102838 102839 102840 102841 102842 102843 | 103487 103488 103489 103490 103491 103492 103493 103494 103495 103496 103497 103498 103499 103500 103501 103502 103503 103504 103505 103506 103507 103508 103509 103510 103511 | + + + + + | /* ** Walker select callback used by "RENAME TABLE". */ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){ int i; RenameCtx *p = pWalker->u.pRename; SrcList *pSrc = pSelect->pSrc; if( pSrc==0 ){ assert( pWalker->pParse->db->mallocFailed ); return WRC_Abort; } for(i=0; i<pSrc->nSrc; i++){ struct SrcList_item *pItem = &pSrc->a[i]; if( pItem->pTab==p->pTab ){ renameTokenFind(pWalker->pParse, p, pItem->zName); } } renameWalkWith(pWalker, pSelect); return WRC_Continue; } /* ** This C function implements an SQL user function that is used by SQL code |
︙ | |||
104231 104232 104233 104234 104235 104236 104237 | 104899 104900 104901 104902 104903 104904 104905 104906 104907 104908 104909 104910 104911 104912 104913 | - + | */ addrRewind = sqlite3VdbeAddOp1(v, OP_Rewind, iIdxCur); VdbeCoverage(v); sqlite3VdbeAddOp2(v, OP_Integer, 0, regChng); addrNextRow = sqlite3VdbeCurrentAddr(v); if( nColTest>0 ){ |
︙ | |||
105169 105170 105171 105172 105173 105174 105175 | 105837 105838 105839 105840 105841 105842 105843 105844 105845 105846 105847 105848 105849 105850 105851 105852 | - + | sqlite3_result_error(context, zErr, -1); sqlite3_free(zErr); return; } assert( pVfs ); flags |= SQLITE_OPEN_MAIN_DB; rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags); |
︙ | |||
105198 105199 105200 105201 105202 105203 105204 | 105866 105867 105868 105869 105870 105871 105872 105873 105874 105875 105876 105877 105878 105879 | - | #ifndef SQLITE_OMIT_PAGER_PRAGMAS sqlite3BtreeSetPagerFlags(pNew->pBt, PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK)); #endif sqlite3BtreeLeave(pNew->pBt); } pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1; |
︙ | |||
105226 105227 105228 105229 105230 105231 105232 | 105893 105894 105895 105896 105897 105898 105899 105900 105901 105902 105903 105904 105905 105906 105907 105908 105909 105910 105911 105912 105913 105914 105915 105916 105917 105918 105919 | - - - - + + + + + + + + | case SQLITE_BLOB: nKey = sqlite3_value_bytes(argv[2]); zKey = (char *)sqlite3_value_blob(argv[2]); rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey); break; case SQLITE_NULL: |
︙ | |||
106146 106147 106148 106149 106150 106151 106152 | 106817 106818 106819 106820 106821 106822 106823 106824 106825 106826 106827 106828 106829 106830 106831 | - + | /* Get the VDBE program ready for execution */ if( v && pParse->nErr==0 && !db->mallocFailed ){ /* A minimum of one cursor is required if autoincrement is used * See ticket [a696379c1f08866] */ |
︙ | |||
106273 106274 106275 106276 106277 106278 106279 | 106944 106945 106946 106947 106948 106949 106950 106951 106952 106953 106954 106955 106956 106957 106958 106959 106960 106961 106962 106963 106964 106965 106966 106967 106968 106969 106970 106971 106972 106973 106974 106975 106976 106977 106978 106979 106980 106981 106982 106983 | - + - - - - - - - + + + + + + + + - - - - - + + + + + + + + + + + + - - | && SQLITE_OK!=sqlite3ReadSchema(pParse) ){ return 0; } p = sqlite3FindTable(db, zName, zDbase); if( p==0 ){ |
︙ | |||
106555 106556 106557 106558 106559 106560 106561 | 107232 107233 107234 107235 107236 107237 107238 107239 107240 107241 107242 107243 107244 107245 | - - - - - - | } /* Delete any foreign keys attached to this table. */ sqlite3FkDelete(db, pTable); /* Delete the Table structure itself. */ |
︙ | |||
108557 108558 108559 108560 108561 108562 108563 108564 108565 108566 108567 108568 108569 108570 | 109228 109229 109230 109231 109232 109233 109234 109235 109236 109237 109238 109239 109240 109241 109242 | + | } /* Remove the table entry from SQLite's internal schema and modify ** the schema cookie. */ if( IsVirtual(pTab) ){ sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0); sqlite3MayAbort(pParse); } sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0); sqlite3ChangeCookie(pParse, iDb); sqliteViewResetAll(db, iDb); } /* |
︙ | |||
109385 109386 109387 109388 109389 109390 109391 109392 109393 109394 109395 109396 109397 109398 109399 109400 109401 109402 109403 109404 109405 109406 109407 109408 109409 109410 109411 109412 109413 109414 | 110057 110058 110059 110060 110061 110062 110063 110064 110065 110066 110067 110068 110069 110070 110071 110072 110073 110074 110075 110076 110077 110078 110079 110080 110081 110082 110083 110084 110085 110086 110087 110088 110089 110090 110091 110092 110093 110094 110095 110096 110097 110098 110099 110100 110101 110102 110103 110104 110105 110106 | + + + + + + + + + + + + + - - - | "conflicting ON CONFLICT clauses specified", 0); } if( pIdx->onError==OE_Default ){ pIdx->onError = pIndex->onError; } } if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType; if( IN_RENAME_OBJECT ){ pIndex->pNext = pParse->pNewIndex; pParse->pNewIndex = pIndex; pIndex = 0; } goto exit_create_index; } } } if( !IN_RENAME_OBJECT ){ /* Link the new Index structure to its table and to the other ** in-memory database structures. */ assert( pParse->nErr==0 ); if( db->init.busy ){ Index *p; assert( !IN_SPECIAL_PARSE ); assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) ); if( pTblName!=0 ){ pIndex->tnum = db->init.newTnum; if( sqlite3IndexHasDuplicateRootPage(pIndex) ){ sqlite3ErrorMsg(pParse, "invalid rootpage"); pParse->rc = SQLITE_CORRUPT_BKPT; goto exit_create_index; } } p = sqlite3HashInsert(&pIndex->pSchema->idxHash, pIndex->zName, pIndex); if( p ){ assert( p==pIndex ); /* Malloc must have failed */ sqlite3OomFault(db); goto exit_create_index; } db->mDbFlags |= DBFLAG_SchemaChange; |
︙ | |||
109736 109737 109738 109739 109740 109741 109742 109743 109744 109745 109746 109747 109748 109749 109750 109751 109752 109753 109754 109755 109756 109757 109758 | 110418 110419 110420 110421 110422 110423 110424 110425 110426 110427 110428 110429 110430 110431 110432 110433 110434 110435 110436 110437 110438 110439 110440 110441 110442 110443 110444 110445 110446 110447 110448 110449 110450 110451 110452 110453 110454 110455 110456 110457 110458 110459 110460 110461 110462 110463 110464 110465 110466 110467 110468 110469 110470 110471 110472 110473 110474 110475 110476 110477 110478 110479 110480 110481 110482 110483 110484 110485 110486 110487 110488 110489 110490 110491 110492 110493 110494 110495 110496 110497 | + + + + + + + + + + + + - - + + + - + + - + + + + + + + - + - - + | if( pList==0 ) return -1; for(i=0; i<pList->nId; i++){ if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i; } return -1; } /* ** Maximum size of a SrcList object. ** The SrcList object is used to represent the FROM clause of a ** SELECT statement, and the query planner cannot deal with more ** than 64 tables in a join. So any value larger than 64 here ** is sufficient for most uses. Smaller values, like say 10, are ** appropriate for small and memory-limited applications. */ #ifndef SQLITE_MAX_SRCLIST # define SQLITE_MAX_SRCLIST 200 #endif /* ** Expand the space allocated for the given SrcList object by ** creating nExtra new slots beginning at iStart. iStart is zero based. ** New slots are zeroed. ** ** For example, suppose a SrcList initially contains two entries: A,B. ** To append 3 new entries onto the end, do this: ** ** sqlite3SrcListEnlarge(db, pSrclist, 3, 2); ** ** After the call above it would contain: A, B, nil, nil, nil. ** If the iStart argument had been 1 instead of 2, then the result ** would have been: A, nil, nil, nil, B. To prepend the new slots, ** the iStart value would be 0. The result then would ** be: nil, nil, nil, A, B. ** |
︙ | |||
109807 109808 109809 109810 109811 109812 109813 | 110508 110509 110510 110511 110512 110513 110514 110515 110516 110517 110518 110519 110520 110521 110522 110523 | - + + | } /* ** Append a new table name to the given SrcList. Create a new SrcList if ** need be. A new entry is created in the SrcList even if pTable is NULL. ** |
︙ | |||
109838 109839 109840 109841 109842 109843 109844 | 110540 110541 110542 110543 110544 110545 110546 110547 110548 110549 110550 110551 110552 110553 110554 110555 110556 110557 110558 110559 110560 110561 110562 110563 110564 110565 110566 110567 110568 110569 110570 110571 110572 110573 110574 110575 110576 110577 110578 110579 | - + + - + + + - + - + - - - - + + + + + + | ** ** sqlite3SrcListAppend(D,A,0,C); ** ** Both pTable and pDatabase are assumed to be quoted. They are dequoted ** before being added to the SrcList. */ SQLITE_PRIVATE SrcList *sqlite3SrcListAppend( |
︙ | |||
109947 109948 109949 109950 109951 109952 109953 | 110654 110655 110656 110657 110658 110659 110660 110661 110662 110663 110664 110665 110666 110667 110668 | - + | sqlite3 *db = pParse->db; if( !p && (pOn || pUsing) ){ sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s", (pOn ? "ON" : "USING") ); goto append_from_error; } |
︙ | |||
110336 110337 110338 110339 110340 110341 110342 | 111043 111044 111045 111046 111047 111048 111049 111050 111051 111052 111053 111054 111055 111056 111057 111058 111059 111060 111061 111062 111063 111064 111065 | + - + - - - - - + + + + + + | /* ** Recompute all indices of pTab that use the collating sequence pColl. ** If pColl==0 then recompute all indices of pTab. */ #ifndef SQLITE_OMIT_REINDEX static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){ if( !IsVirtual(pTab) ){ |
︙ | |||
110841 110842 110843 110844 110845 110846 110847 | 111550 111551 111552 111553 111554 111555 111556 111557 111558 111559 111560 111561 111562 111563 111564 111565 111566 111567 111568 111569 111570 111571 111572 111573 111574 111575 111576 111577 111578 111579 111580 111581 111582 111583 111584 111585 111586 111587 111588 111589 111590 111591 | - + - - - - - - - - - - - - - - - - + | return match; } /* ** Search a FuncDefHash for a function with the given name. Return ** a pointer to the matching FuncDef if found, or 0 if there is no match. */ |
︙ | |||
110961 110962 110963 110964 110965 110966 110967 | 111655 111656 111657 111658 111659 111660 111661 111662 111663 111664 111665 111666 111667 111668 111669 | - + | ** have fields overwritten with new information appropriate for the ** new function. But the FuncDefs for built-in functions are read-only. ** So we must not search for built-ins when creating a new function. */ if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){ bestScore = 0; h = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zName[0]], nName); |
︙ | |||
111181 111182 111183 111184 111185 111186 111187 | 111875 111876 111877 111878 111879 111880 111881 111882 111883 111884 111885 111886 111887 111888 111889 | - + | ){ SelectDest dest; Select *pSel; SrcList *pFrom; sqlite3 *db = pParse->db; int iDb = sqlite3SchemaToIndex(db, pView->pSchema); pWhere = sqlite3ExprDup(db, pWhere, 0); |
︙ | |||
111581 111582 111583 111584 111585 111586 111587 | 112275 112276 112277 112278 112279 112280 112281 112282 112283 112284 112285 112286 112287 112288 112289 | - + | sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, iKey); } } /* If this DELETE cannot use the ONEPASS strategy, this is the ** end of the WHERE loop */ if( eOnePass!=ONEPASS_OFF ){ |
︙ | |||
111770 111771 111772 111773 111774 111775 111776 | 112464 112465 112466 112467 112468 112469 112470 112471 112472 112473 112474 112475 112476 112477 112478 | - + | assert( v ); VdbeModuleComment((v, "BEGIN: GenRowDel(%d,%d,%d,%d)", iDataCur, iIdxCur, iPk, (int)nPk)); /* Seek cursor iCur to the row to delete. If this row no longer exists ** (this can happen if a trigger program has already deleted it), do ** not attempt to delete it or fire any DELETE triggers. */ |
︙ | |||
111976 111977 111978 111979 111980 111981 111982 | 112670 112671 112672 112673 112674 112675 112676 112677 112678 112679 112680 112681 112682 112683 112684 | - + | Vdbe *v = pParse->pVdbe; int j; int regBase; int nCol; if( piPartIdxLabel ){ if( pIdx->pPartIdxWhere ){ |
︙ | |||
112232 112233 112234 112235 112236 112237 112238 112239 112240 112241 112242 112243 112244 112245 112246 112247 112248 112249 112250 112251 112252 112253 112254 112255 112256 | 112926 112927 112928 112929 112930 112931 112932 112933 112934 112935 112936 112937 112938 112939 112940 112941 112942 112943 112944 112945 112946 112947 112948 112949 112950 112951 112952 112953 112954 112955 112956 112957 112958 112959 112960 112961 112962 | + + - + + + | const unsigned char *zHaystack; const unsigned char *zNeedle; int nHaystack; int nNeedle; int typeHaystack, typeNeedle; int N = 1; int isText; unsigned char firstChar; UNUSED_PARAMETER(argc); typeHaystack = sqlite3_value_type(argv[0]); typeNeedle = sqlite3_value_type(argv[1]); if( typeHaystack==SQLITE_NULL || typeNeedle==SQLITE_NULL ) return; nHaystack = sqlite3_value_bytes(argv[0]); nNeedle = sqlite3_value_bytes(argv[1]); if( nNeedle>0 ){ if( typeHaystack==SQLITE_BLOB && typeNeedle==SQLITE_BLOB ){ zHaystack = sqlite3_value_blob(argv[0]); zNeedle = sqlite3_value_blob(argv[1]); isText = 0; }else{ zHaystack = sqlite3_value_text(argv[0]); zNeedle = sqlite3_value_text(argv[1]); isText = 1; } if( zNeedle==0 || (nHaystack && zHaystack==0) ) return; firstChar = zNeedle[0]; |
︙ | |||
112541 112542 112543 112544 112545 112546 112547 | 113239 113240 113241 113242 113243 113244 113245 113246 113247 113248 113249 113250 113251 113252 113253 113254 113255 113256 113257 | - + - + | ** that is N bytes long. */ static void randomBlob( sqlite3_context *context, int argc, sqlite3_value **argv ){ |
︙ | |||
114381 114382 114383 114384 114385 114386 114387 | 115079 115080 115081 115082 115083 115084 115085 115086 115087 115088 115089 115090 115091 115092 115093 | - + | int regData, /* Address of array containing child table row */ int nIncr, /* Increment constraint counter by this */ int isIgnore /* If true, pretend pTab contains all NULL values */ ){ int i; /* Iterator variable */ Vdbe *v = sqlite3GetVdbe(pParse); /* Vdbe to add code to */ int iCur = pParse->nTab - 1; /* Cursor number to use */ |
︙ | |||
114654 114655 114656 114657 114658 114659 114660 | 115352 115353 115354 115355 115356 115357 115358 115359 115360 115361 115362 115363 115364 115365 115366 115367 115368 115369 115370 115371 115372 115373 115374 115375 115376 115377 115378 115379 115380 115381 115382 115383 115384 115385 115386 115387 115388 | - - + + + + + - - + - - + + | ** to the WHERE clause that prevent this entry from being scanned. ** The added WHERE clause terms are like this: ** ** $current_rowid!=rowid ** NOT( $current_a==a AND $current_b==b AND ... ) ** ** The first form is used for rowid tables. The second form is used |
︙ | |||
114779 114780 114781 114782 114783 114784 114785 | 115479 115480 115481 115482 115483 115484 115485 115486 115487 115488 115489 115490 115491 115492 115493 | - + | ** the entire DELETE if there are no outstanding deferred constraints ** when this statement is run. */ FKey *p; for(p=pTab->pFKey; p; p=p->pNextFrom){ if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break; } if( !p ) return; |
︙ | |||
115064 115065 115066 115067 115068 115069 115070 | 115764 115765 115766 115767 115768 115769 115770 115771 115772 115773 115774 115775 115776 115777 115778 | - + | if( !isIgnoreErrors || db->mallocFailed ) return; continue; } assert( aiCol || pFKey->nCol==1 ); /* Create a SrcList structure containing the child table. We need the ** child table as a SrcList for sqlite3WhereBegin() */ |
︙ | |||
115341 115342 115343 115344 115345 115346 115347 | 116041 116042 116043 116044 116045 116046 116047 116048 116049 116050 116051 116052 116053 116054 116055 | - + | tFrom.n = nFrom; pRaise = sqlite3Expr(db, TK_RAISE, "FOREIGN KEY constraint failed"); if( pRaise ){ pRaise->affinity = OE_Abort; } pSelect = sqlite3SelectNew(pParse, sqlite3ExprListAppend(pParse, 0, pRaise), |
︙ | |||
115803 115804 115805 115806 115807 115808 115809 115810 115811 115812 115813 115814 115815 115816 | 116503 116504 116505 116506 116507 116508 116509 116510 116511 116512 116513 116514 116515 116516 116517 | + | aOp[3].p5 = SQLITE_JUMPIFNULL; aOp[4].p2 = memId+1; aOp[5].p3 = memId; aOp[6].p1 = memId; aOp[7].p2 = memId+2; aOp[7].p1 = memId; aOp[10].p2 = memId; if( pParse->nTab==0 ) pParse->nTab = 1; } } /* ** Update the maximum rowid for an autoincrement calculation. ** ** This routine should be called when the regRowid register holds a |
︙ | |||
116309 116310 116311 116312 116313 116314 116315 116316 116317 116318 116319 116320 116321 116322 | 117010 117011 117012 117013 117014 117015 117016 117017 117018 117019 117020 117021 117022 117023 117024 117025 117026 117027 117028 | + + + + + | assert( pIdx ); aRegIdx[i] = ++pParse->nMem; pParse->nMem += pIdx->nColumn; } } #ifndef SQLITE_OMIT_UPSERT if( pUpsert ){ if( IsVirtual(pTab) ){ sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"", pTab->zName); goto insert_cleanup; } pTabList->a[0].iCursor = iDataCur; pUpsert->pUpsertSrc = pTabList; pUpsert->regData = regData; pUpsert->iDataCur = iDataCur; pUpsert->iIdxCur = iIdxCur; if( pUpsert->pUpsertTarget ){ sqlite3UpsertAnalyzeTarget(pParse, pTabList, pUpsert); |
︙ | |||
116349 116350 116351 116352 116353 116354 116355 | 117055 117056 117057 117058 117059 117060 117061 117062 117063 117064 117065 117066 117067 117068 117069 | - + | */ addrInsTop = addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); VdbeCoverage(v); } /* Run the BEFORE and INSTEAD OF triggers, if there are any */ |
︙ | |||
116431 116432 116433 116434 116435 116436 116437 | 117137 117138 117139 117140 117141 117142 117143 117144 117145 117146 117147 117148 117149 117150 117151 117152 117153 117154 117155 117156 | - - + - - - + + - - - + + - | } if( ipkColumn>=0 ){ if( useTempTable ){ sqlite3VdbeAddOp3(v, OP_Column, srcTab, ipkColumn, regRowid); }else if( pSelect ){ sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid); }else{ |
︙ | |||
116835 116836 116837 116838 116839 116840 116841 116842 116843 116844 116845 116846 116847 116848 116849 116850 116851 116852 116853 116854 116855 116856 | 117537 117538 117539 117540 117541 117542 117543 117544 117545 117546 117547 117548 117549 117550 117551 117552 117553 117554 117555 117556 117557 117558 117559 117560 117561 117562 117563 117564 117565 117566 117567 117568 117569 117570 117571 117572 117573 117574 117575 117576 117577 117578 117579 117580 117581 117582 117583 117584 117585 117586 117587 117588 117589 117590 117591 117592 117593 117594 117595 117596 117597 117598 117599 117600 117601 117602 117603 117604 117605 117606 | + + + + + + + + + + + + + + + - + - - - - - - - - - + | onError = OE_Abort; } if( onError==OE_Replace && pTab->aCol[i].pDflt==0 ){ onError = OE_Abort; } assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail || onError==OE_Ignore || onError==OE_Replace ); addr1 = 0; switch( onError ){ case OE_Replace: { assert( onError==OE_Replace ); addr1 = sqlite3VdbeMakeLabel(pParse); sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1); VdbeCoverage(v); sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i); sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1); VdbeCoverage(v); onError = OE_Abort; /* Fall through into the OE_Abort case to generate code that runs ** if both the input and the default value are NULL */ } case OE_Abort: sqlite3MayAbort(pParse); /* Fall through */ case OE_Rollback: case OE_Fail: { char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName, pTab->aCol[i].zName); sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, onError, regNewData+1+i); sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC); sqlite3VdbeChangeP5(v, P5_ConstraintNotNull); VdbeCoverage(v); if( addr1 ) sqlite3VdbeResolveLabel(v, addr1); break; } default: { |
︙ | |||
116950 116951 116952 116953 116954 116955 116956 | 117659 117660 117661 117662 117663 117664 117665 117666 117667 117668 117669 117670 117671 117672 117673 | - + | } } /* If rowid is changing, make sure the new rowid does not previously ** exist in the table. */ if( pkChng && pPk==0 ){ |
︙ | |||
117100 117101 117102 117103 117104 117105 117106 | 117809 117810 117811 117812 117813 117814 117815 117816 117817 117818 117819 117820 117821 117822 117823 | - + | if( aRegIdx[ix]==0 ) continue; /* Skip indices that do not change */ if( pUpIdx==pIdx ){ addrUniqueOk = upsertJump+1; upsertBypass = sqlite3VdbeGoto(v, 0); VdbeComment((v, "Skip upsert subroutine")); sqlite3VdbeJumpHere(v, upsertJump); }else{ |
︙ | |||
117183 117184 117185 117186 117187 117188 117189 | 117892 117893 117894 117895 117896 117897 117898 117899 117900 117901 117902 117903 117904 117905 117906 117907 117908 117909 117910 117911 117912 117913 117914 117915 117916 117917 117918 117919 117920 117921 117922 | - + + + + + + | /* Collision detection may be omitted if all of the following are true: ** (1) The conflict resolution algorithm is REPLACE ** (2) The table is a WITHOUT ROWID table ** (3) There are no secondary indexes on the table ** (4) No delete triggers need to be fired if there is a conflict ** (5) No FK constraint counters need to be updated if a conflict occurs. |
︙ | |||
117308 117309 117310 117311 117312 117313 117314 | 118022 118023 118024 118025 118026 118027 118028 118029 118030 118031 118032 118033 118034 118035 118036 | - + | sqlite3VdbeResolveLabel(v, addrUniqueOk); } if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField); } /* If the IPK constraint is a REPLACE, run it last */ if( ipkTop ){ |
︙ | |||
117678 117679 117680 117681 117682 117683 117684 | 118392 118393 118394 118395 118396 118397 118398 118399 118400 118401 118402 118403 118404 118405 118406 118407 | - + + | ** we have to check the semantics. */ pItem = pSelect->pSrc->a; pSrc = sqlite3LocateTableItem(pParse, 0, pItem); if( pSrc==0 ){ return 0; /* FROM clause does not contain a real table */ } |
︙ | |||
117954 117955 117956 117957 117958 117959 117960 | 118669 118670 118671 118672 118673 118674 118675 118676 118677 118678 118679 118680 118681 118682 118683 118684 118685 118686 118687 118688 118689 118690 118691 118692 118693 118694 118695 118696 118697 118698 118699 118700 118701 118702 118703 118704 118705 118706 118707 118708 | - + - - + | if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT; if( zSql==0 ) zSql = ""; sqlite3_mutex_enter(db->mutex); sqlite3Error(db, SQLITE_OK); while( rc==SQLITE_OK && zSql[0] ){ |
︙ | |||
119335 119336 119337 119338 119339 119340 119341 | 120049 120050 120051 120052 120053 120054 120055 120056 120057 120058 120059 120060 120061 120062 120063 | - + | ** default so as not to open security holes in older applications. */ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){ sqlite3_mutex_enter(db->mutex); if( onoff ){ db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc; }else{ |
︙ | |||
119594 119595 119596 119597 119598 119599 119600 | 120308 120309 120310 120311 120312 120313 120314 120315 120316 120317 120318 120319 120320 120321 120322 | - - + | #define PragTyp_THREADS 37 #define PragTyp_WAL_AUTOCHECKPOINT 38 #define PragTyp_WAL_CHECKPOINT 39 #define PragTyp_ACTIVATE_EXTENSIONS 40 #define PragTyp_HEXKEY 41 #define PragTyp_KEY 42 #define PragTyp_LOCK_STATUS 43 |
︙ | |||
120006 120007 120008 120009 120010 120011 120012 | 120719 120720 120721 120722 120723 120724 120725 120726 120727 120728 120729 120730 120731 120732 120733 120734 120735 120736 120737 120738 120739 120740 | + - + - - + + - + + | /* iArg: */ 0 }, {/* zName: */ "page_size", /* ePragTyp: */ PragTyp_PAGE_SIZE, /* ePragFlg: */ PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1, /* ColNames: */ 0, 0, /* iArg: */ 0 }, #endif #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
︙ | |||
121002 121003 121004 121005 121006 121007 121008 | 121717 121718 121719 121720 121721 121722 121723 121724 121725 121726 121727 121728 121729 121730 121731 | - + | int size = 1; if( sqlite3GetInt32(zRight, &size) ){ sqlite3BtreeSetSpillSize(pDb->pBt, size); } if( sqlite3GetBoolean(zRight, size!=0) ){ db->flags |= SQLITE_CacheSpill; }else{ |
︙ | |||
121562 121563 121564 121565 121566 121567 121568 | 122277 122278 122279 122280 122281 122282 122283 122284 122285 122286 122287 122288 122289 122290 122291 | - + | pParent = sqlite3FindTable(db, pFK->zTo, zDb); pIdx = 0; aiCols = 0; if( pParent ){ x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); assert( x==0 ); } |
︙ | |||
121607 121608 121609 121610 121611 121612 121613 | 122322 122323 122324 122325 122326 122327 122328 122329 122330 122331 122332 122333 122334 122335 | - - - - - - - - - - - - - | sqlite3VdbeJumpHere(v, addrTop); } } break; #endif /* !defined(SQLITE_OMIT_TRIGGER) */ #endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */ |
︙ | |||
121782 121783 121784 121785 121786 121787 121788 | 122484 122485 122486 122487 122488 122489 122490 122491 122492 122493 122494 122495 122496 122497 122498 122499 | - - + + | integrityCheckResultRow(v); sqlite3VdbeJumpHere(v, jmp2); } /* Verify CHECK constraints */ if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0); if( db->mallocFailed==0 ){ |
︙ | |||
121806 121807 121808 121809 121810 121811 121812 | 122508 122509 122510 122511 122512 122513 122514 122515 122516 122517 122518 122519 122520 122521 122522 122523 122524 122525 122526 122527 122528 122529 122530 122531 122532 122533 122534 122535 122536 122537 122538 122539 122540 122541 122542 122543 | - + - + | } sqlite3ExprListDelete(db, pCheck); } if( !isQuick ){ /* Omit the remaining tests for quick_check */ /* Validate index entries for the current row */ for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ int jmp2, jmp3, jmp4, jmp5; |
︙ | |||
122740 122741 122742 122743 122744 122745 122746 122747 122748 122749 122750 122751 122752 122753 | 123442 123443 123444 123445 123446 123447 123448 123449 123450 123451 123452 123453 123454 123455 123456 123457 123458 123459 123460 123461 123462 123463 123464 123465 123466 123467 123468 | + + + + + + + + + + + + + | if( zObj==0 ) zObj = "?"; z = sqlite3MPrintf(db, "malformed database schema (%s)", zObj); if( zExtra && zExtra[0] ) z = sqlite3MPrintf(db, "%z - %s", z, zExtra); *pData->pzErrMsg = z; pData->rc = SQLITE_CORRUPT_BKPT; } } /* ** Check to see if any sibling index (another index on the same table) ** of pIndex has the same root page number, and if it does, return true. ** This would indicate a corrupt schema. */ SQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index *pIndex){ Index *p; for(p=pIndex->pTable->pIndex; p; p=p->pNext){ if( p->tnum==pIndex->tnum && p!=pIndex ) return 1; } return 0; } /* ** This is the callback routine for the code that initializes the ** database. See sqlite3Init() below for additional information. ** This routine is also called from the OP_ParseSchema opcode of the VDBE. ** ** Each callback contains the following information: |
︙ | |||
122762 122763 122764 122765 122766 122767 122768 122769 122770 122771 122772 122773 122774 122775 | 123477 123478 123479 123480 123481 123482 123483 123484 123485 123486 123487 123488 123489 123490 123491 | + | sqlite3 *db = pData->db; int iDb = pData->iDb; assert( argc==3 ); UNUSED_PARAMETER2(NotUsed, argc); assert( sqlite3_mutex_held(db->mutex) ); DbClearProperty(db, iDb, DB_Empty); pData->nInitRow++; if( db->mallocFailed ){ corruptSchema(pData, argv[0], 0); return 1; } assert( iDb>=0 && iDb<db->nDb ); if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */ |
︙ | |||
122815 122816 122817 122818 122819 122820 122821 | 123531 123532 123533 123534 123535 123536 123537 123538 123539 123540 123541 123542 123543 123544 123545 123546 123547 123548 123549 123550 | - + - - - - - - - - + + + + + | ** was created to be the PRIMARY KEY or to fulfill a UNIQUE ** constraint for a CREATE TABLE. The index should have already ** been created when we processed the CREATE TABLE. All we have ** to do here is record the root page number for that index. */ Index *pIndex; pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zDbSName); |
︙ | |||
122873 122874 122875 122876 122877 122878 122879 122880 122881 122882 122883 122884 122885 122886 | 123586 123587 123588 123589 123590 123591 123592 123593 123594 123595 123596 123597 123598 123599 123600 | + | "rootpage int,sql text)"; azArg[3] = 0; initData.db = db; initData.iDb = iDb; initData.rc = SQLITE_OK; initData.pzErrMsg = pzErrMsg; initData.mInitFlags = mFlags; initData.nInitRow = 0; sqlite3InitCallback(&initData, 3, (char **)azArg, 0); if( initData.rc ){ rc = initData.rc; goto error_out; } /* Create a cursor to hold the database open |
︙ | |||
122990 122991 122992 122993 122994 122995 122996 | 123704 123705 123706 123707 123708 123709 123710 123711 123712 123713 123714 123715 123716 123717 123718 | - + | /* Ticket #2804: When we open a database in the newer file format, ** clear the legacy_file_format pragma flag so that a VACUUM will ** not downgrade the database and thus invalidate any descending ** indices that the user might have created. */ if( iDb==0 && meta[BTREE_FILE_FORMAT-1]>=4 ){ |
︙ | |||
123242 123243 123244 123245 123246 123247 123248 123249 123250 123251 123252 123253 123254 123255 | 123956 123957 123958 123959 123960 123961 123962 123963 123964 123965 123966 123967 123968 123969 123970 | + | /* For a long-term use prepared statement avoid the use of ** lookaside memory. */ if( prepFlags & SQLITE_PREPARE_PERSISTENT ){ sParse.disableLookaside++; db->lookaside.bDisable++; } sParse.disableVtab = (prepFlags & SQLITE_PREPARE_NO_VTAB)!=0; /* Check to verify that it is possible to get a read lock on all ** database schemas. The inability to get a read lock indicates that ** some other database connection is holding a write-lock, which in ** turn means that the other connection has made uncommitted changes ** to the schema. ** |
︙ | |||
123406 123407 123408 123409 123410 123411 123412 | 124121 124122 124123 124124 124125 124126 124127 124128 124129 124130 124131 124132 124133 124134 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | sqlite3BtreeLeaveAll(db); rc = sqlite3ApiExit(db, rc); assert( (rc&db->errMask)==rc ); sqlite3_mutex_leave(db->mutex); return rc; } |
︙ | |||
124534 124535 124536 124537 124538 124539 124540 | 124962 124963 124964 124965 124966 124967 124968 124969 124970 124971 124972 124973 124974 124975 124976 | - + | regBase = regData - nPrefixReg; }else{ regBase = pParse->nMem + 1; pParse->nMem += nBase; } assert( pSelect->iOffset==0 || pSelect->iLimit!=0 ); iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit; |
︙ | |||
124573 124574 124575 124576 124577 124578 124579 | 125001 125002 125003 125004 125005 125006 125007 125008 125009 125010 125011 125012 125013 125014 125015 | - + | memset(pKI->aSortOrder, 0, pKI->nKeyField); /* Makes OP_Jump testable */ sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO); testcase( pKI->nAllField > pKI->nKeyField+2 ); pOp->p4.pKeyInfo = sqlite3KeyInfoFromExprList(pParse,pSort->pOrderBy,nOBSat, pKI->nAllField-pKI->nKeyField-1); addrJmp = sqlite3VdbeCurrentAddr(v); sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v); |
︙ | |||
125320 125321 125322 125323 125324 125325 125326 | 125748 125749 125750 125751 125752 125753 125754 125755 125756 125757 125758 125759 125760 125761 125762 | - + | Select *p, /* The SELECT statement */ SortCtx *pSort, /* Information on the ORDER BY clause */ int nColumn, /* Number of columns of data */ SelectDest *pDest /* Write the sorted results here */ ){ Vdbe *v = pParse->pVdbe; /* The prepared statement */ int addrBreak = pSort->labelDone; /* Jump here to exit loop */ |
︙ | |||
125360 125361 125362 125363 125364 125365 125366 | 125788 125789 125790 125791 125792 125793 125794 125795 125796 125797 125798 125799 125800 125801 125802 125803 125804 125805 125806 125807 | + + + + - + + | iTab = pSort->iECursor; if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){ regRowid = 0; regRow = pDest->iSdst; }else{ regRowid = sqlite3GetTempReg(pParse); if( eDest==SRT_EphemTab || eDest==SRT_Table ){ regRow = sqlite3GetTempReg(pParse); nColumn = 0; }else{ |
︙ | |||
125440 125441 125442 125443 125444 125445 125446 125447 125448 125449 125450 125451 125452 125453 | 125873 125874 125875 125876 125877 125878 125879 125880 125881 125882 125883 125884 125885 125886 125887 | + | sqlite3VdbeAddOp3(v, OP_Column, iSortTab, iRead, regRow+i); VdbeComment((v, "%s", aOutEx[i].zName?aOutEx[i].zName : aOutEx[i].zSpan)); } } switch( eDest ){ case SRT_Table: case SRT_EphemTab: { sqlite3VdbeAddOp3(v, OP_Column, iSortTab, nKey+bSeq, regRow); sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid); sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid); sqlite3VdbeChangeP5(v, OPFLAG_APPEND); break; } #ifndef SQLITE_OMIT_SUBQUERY case SRT_Set: { |
︙ | |||
125980 125981 125982 125983 125984 125985 125986 | 126414 126415 126416 126417 126418 126419 126420 126421 126422 126423 126424 126425 126426 126427 126428 126429 126430 126431 126432 126433 126434 126435 126436 | - + - + + - | /* ** Given a SELECT statement, generate a Table structure that describes ** the result set of that SELECT. */ SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){ Table *pTab; sqlite3 *db = pParse->db; |
︙ | |||
126232 126233 126234 126235 126236 126237 126238 | 126666 126667 126668 126669 126670 126671 126672 126673 126674 126675 126676 126677 126678 126679 126680 | - + | } #endif /* Obtain authorization to do a recursive query */ if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return; /* Process the LIMIT and OFFSET clauses, if they exist */ |
︙ | |||
126302 126303 126304 126305 126306 126307 126308 | 126736 126737 126738 126739 126740 126741 126742 126743 126744 126745 126746 126747 126748 126749 126750 | - + | sqlite3VdbeAddOp3(v, OP_Column, iQueue, pOrderBy->nExpr+1, regCurrent); }else{ sqlite3VdbeAddOp2(v, OP_RowData, iQueue, regCurrent); } sqlite3VdbeAddOp1(v, OP_Delete, iQueue); /* Output the single row in Current */ |
︙ | |||
126610 126611 126612 126613 126614 126615 126616 | 127044 127045 127046 127047 127048 127049 127050 127051 127052 127053 127054 127055 127056 127057 127058 127059 | - - + + | /* Convert the data in the temporary table into whatever form ** it is that we currently need. */ assert( unionTab==dest.iSDParm || dest.eDest!=priorOp ); if( dest.eDest!=priorOp ){ int iCont, iBreak, iStart; assert( p->pEList ); |
︙ | |||
126679 126680 126681 126682 126683 126684 126685 | 127113 127114 127115 127116 127117 127118 127119 127120 127121 127122 127123 127124 127125 127126 127127 127128 | - - + + | sqlite3ExprDelete(db, p->pLimit); p->pLimit = pLimit; /* Generate code to take the intersection of the two temporary ** tables. */ assert( p->pEList ); |
︙ | |||
126810 126811 126812 126813 126814 126815 126816 | 127244 127245 127246 127247 127248 127249 127250 127251 127252 127253 127254 127255 127256 127257 127258 | - + | int iBreak /* Jump here if we hit the LIMIT */ ){ Vdbe *v = pParse->pVdbe; int iContinue; int addr; addr = sqlite3VdbeCurrentAddr(v); |
︙ | |||
127047 127048 127049 127050 127051 127052 127053 | 127481 127482 127483 127484 127485 127486 127487 127488 127489 127490 127491 127492 127493 127494 127495 127496 | - - + + | int *aPermute; /* Mapping from ORDER BY terms to result set columns */ assert( p->pOrderBy!=0 ); assert( pKeyDup==0 ); /* "Managed" code needs this. Ticket #3382. */ db = pParse->db; v = pParse->pVdbe; assert( v!=0 ); /* Already thrown the error if VDBE alloc failed */ |
︙ | |||
127364 127365 127366 127367 127368 127369 127370 127371 127372 127373 127374 127375 127376 127377 | 127798 127799 127800 127801 127802 127803 127804 127805 127806 127807 127808 127809 127810 127811 127812 | + | if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){ memset(&ifNullRow, 0, sizeof(ifNullRow)); ifNullRow.op = TK_IF_NULL_ROW; ifNullRow.pLeft = pCopy; ifNullRow.iTable = pSubst->iNewTable; pCopy = &ifNullRow; } testcase( ExprHasProperty(pCopy, EP_Subquery) ); pNew = sqlite3ExprDup(db, pCopy, 0); if( pNew && pSubst->isLeftJoin ){ ExprSetProperty(pNew, EP_CanBeNull); } if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){ pNew->iRightJoinTable = pExpr->iRightJoinTable; ExprSetProperty(pNew, EP_FromJoin); |
︙ | |||
127856 127857 127858 127859 127860 127861 127862 | 128291 128292 128293 128294 128295 128296 128297 128298 128299 128300 128301 128302 128303 128304 128305 128306 128307 128308 128309 128310 128311 128312 128313 128314 128315 128316 128317 128318 128319 128320 128321 128322 128323 128324 128325 128326 128327 128328 | - - + + - - + - - + - - + - + | pSrc = pParent->pSrc; /* FROM clause of the outer query */ if( pSrc ){ assert( pParent==p ); /* First time through the loop */ jointype = pSubitem->fg.jointype; }else{ assert( pParent!=p ); /* 2nd and subsequent times through the loop */ |
︙ | |||
127928 127929 127930 127931 127932 127933 127934 | 128360 128361 128362 128363 128364 128365 128366 128367 128368 128369 128370 128371 128372 128373 128374 128375 | + - + | for(i=0; i<pOrderBy->nExpr; i++){ pOrderBy->a[i].u.x.iOrderByCol = 0; } assert( pParent->pOrderBy==0 ); pParent->pOrderBy = pOrderBy; pSub->pOrderBy = 0; } pWhere = pSub->pWhere; |
︙ | |||
129231 129232 129233 129234 129235 129236 129237 | 129664 129665 129666 129667 129668 129669 129670 129671 129672 129673 129674 129675 129676 129677 129678 | - + | regAgg = sqlite3GetTempRange(pParse, nArg); sqlite3ExprCodeExprList(pParse, pList, regAgg, 0, SQLITE_ECEL_DUP); }else{ nArg = 0; regAgg = 0; } if( pF->iDistinct>=0 ){ |
︙ | |||
129367 129368 129369 129370 129371 129372 129373 129374 129375 129376 129377 129378 | 129800 129801 129802 129803 129804 129805 129806 129807 129808 129809 129810 129811 129812 129813 129814 129815 129816 129817 129818 129819 129820 129821 129822 129823 129824 129825 129826 | + + + + + + + - + - - | */ static struct SrcList_item *isSelfJoinView( SrcList *pTabList, /* Search for self-joins in this FROM clause */ struct SrcList_item *pThis /* Search for prior reference to this subquery */ ){ struct SrcList_item *pItem; for(pItem = pTabList->a; pItem<pThis; pItem++){ Select *pS1; if( pItem->pSelect==0 ) continue; if( pItem->fg.viaCoroutine ) continue; if( pItem->zName==0 ) continue; if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue; if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue; pS1 = pItem->pSelect; if( pThis->pSelect->selId!=pS1->selId ){ /* The query flattener left two different CTE tables with identical ** names in the same FROM clause. */ continue; } |
︙ | |||
129636 129637 129638 129639 129640 129641 129642 129643 129644 129645 129646 129647 129648 129649 | 130074 130075 130076 130077 130078 130079 130080 130081 130082 130083 130084 130085 130086 130087 130088 | + | && (pTabList->nSrc==1 || (pTabList->a[1].fg.jointype&(JT_LEFT|JT_CROSS))!=0) ){ continue; } if( flattenSubquery(pParse, p, i, isAgg) ){ if( pParse->nErr ) goto select_end; /* This subquery can be absorbed into its parent. */ i = -1; } pTabList = p->pSrc; if( db->mallocFailed ) goto select_end; if( !IgnorableOrderby(pDest) ){ sSort.pOrderBy = p->pOrderBy; |
︙ | |||
129731 129732 129733 129734 129735 129736 129737 | 130170 130171 130172 130173 130174 130175 130176 130177 130178 130179 130180 130181 130182 130183 130184 130185 130186 130187 130188 130189 | - - - - + + + + - - - + + - - - - - - - - - | #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW) /* Generate code for all sub-queries in the FROM clause */ pSub = pItem->pSelect; if( pSub==0 ) continue; |
︙ | |||
129934 129935 129936 129937 129938 129939 129940 | 130363 130364 130365 130366 130367 130368 130369 130370 130371 130372 130373 130374 130375 130376 130377 | - + | */ if( pDest->eDest==SRT_EphemTab ){ sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr); } /* Set the limiter. */ |
︙ | |||
130001 130002 130003 130004 130005 130006 130007 | 130430 130431 130432 130433 130434 130435 130436 130437 130438 130439 130440 130441 130442 130443 130444 130445 130446 | - - - + + + | if( sSort.addrSortIndex>=0 && sSort.pOrderBy==0 ){ sqlite3VdbeChangeToNoop(v, sSort.addrSortIndex); } assert( p->pEList==pEList ); #ifndef SQLITE_OMIT_WINDOWFUNC if( pWin ){ |
︙ | |||
130078 130079 130080 130081 130082 130083 130084 | 130507 130508 130509 130510 130511 130512 130513 130514 130515 130516 130517 130518 130519 130520 130521 | - + | ** ORDER BY and GROUP BY clauses are the same by setting the orderByGrp ** variable. */ if( sqlite3ExprListCompare(pGroupBy, sSort.pOrderBy, -1)==0 ){ orderByGrp = 1; } /* Create a label to jump to when we want to abort the query */ |
︙ | |||
130167 130168 130169 130170 130171 130172 130173 | 130596 130597 130598 130599 130600 130601 130602 130603 130604 130605 130606 130607 130608 130609 130610 130611 130612 | - + - + | 0, (char*)pKeyInfo, P4_KEYINFO); /* Initialize memory locations used by GROUP BY aggregate processing */ iUseFlag = ++pParse->nMem; iAbortFlag = ++pParse->nMem; regOutputRow = ++pParse->nMem; |
︙ | |||
131456 131457 131458 131459 131460 131461 131462 | 131885 131886 131887 131888 131889 131890 131891 131892 131893 131894 131895 131896 131897 131898 131899 | - + | Parse *pParse, /* The parsing context */ TriggerStep *pStep /* The trigger containing the target token */ ){ sqlite3 *db = pParse->db; int iDb; /* Index of the database to use */ SrcList *pSrc; /* SrcList to be returned */ |
︙ | |||
131641 131642 131643 131644 131645 131646 131647 131648 131649 131650 131651 131652 131653 131654 | 132070 132071 132072 132073 132074 132075 132076 132077 132078 132079 132080 132081 132082 132083 132084 | + | sNC.pParse = pSubParse; pSubParse->db = db; pSubParse->pTriggerTab = pTab; pSubParse->pToplevel = pTop; pSubParse->zAuthContext = pTrigger->zName; pSubParse->eTriggerOp = pTrigger->op; pSubParse->nQueryLoop = pParse->nQueryLoop; pSubParse->disableVtab = pParse->disableVtab; v = sqlite3GetVdbe(pSubParse); if( v ){ VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)", pTrigger->zName, onErrorText(orconf), (pTrigger->tr_tm==TRIGGER_BEFORE ? "BEFORE" : "AFTER"), (pTrigger->op==TK_UPDATE ? "UPDATE" : ""), |
︙ | |||
131668 131669 131670 131671 131672 131673 131674 | 132098 132099 132100 132101 132102 132103 132104 132105 132106 132107 132108 132109 132110 132111 132112 | - + | ** (or NULL) the sub-vdbe is immediately halted by jumping to the ** OP_Halt inserted at the end of the program. */ if( pTrigger->pWhen ){ pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0); if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) && db->mallocFailed==0 ){ |
︙ | |||
132267 132268 132269 132270 132271 132272 132273 132274 132275 132276 132277 132278 132279 132280 132281 132282 132283 132284 132285 132286 | 132697 132698 132699 132700 132701 132702 132703 132704 132705 132706 132707 132708 132709 132710 132711 132712 132713 132714 132715 132716 132717 132718 132719 132720 132721 132722 132723 132724 132725 | + - - + - | hasFK = sqlite3FkRequired(pParse, pTab, aXRef, chngKey); /* There is one entry in the aRegIdx[] array for each index on the table ** being updated. Fill in aRegIdx[] with a register number that will hold ** the key for accessing each index. */ if( onError==OE_Replace ) bReplace = 1; for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){ int reg; if( chngKey || hasFK>1 || pIdx==pPk || indexWhereClauseMightChange(pIdx,aXRef,chngRowid) ){ reg = ++pParse->nMem; pParse->nMem += pIdx->nColumn; }else{ reg = 0; for(i=0; i<pIdx->nKeyCol; i++){ if( indexColumnIsBeingUpdated(pIdx, i, aXRef, chngRowid) ){ reg = ++pParse->nMem; pParse->nMem += pIdx->nColumn; |
︙ | |||
132354 132355 132356 132357 132358 132359 132360 | 132783 132784 132785 132786 132787 132788 132789 132790 132791 132792 132793 132794 132795 132796 132797 | - + | updateVirtualTable(pParse, pTabList, pTab, pChanges, pRowidExpr, aXRef, pWhere, onError); goto update_cleanup; } #endif /* Jump to labelBreak to abandon further processing of this UPDATE */ |
︙ | |||
132489 132490 132491 132492 132493 132494 132495 | 132918 132919 132920 132921 132922 132923 132924 132925 132926 132927 132928 132929 132930 132931 132932 132933 132934 132935 132936 132937 132938 | - + - + | if( eOnePass!=ONEPASS_OFF ){ if( !isView && aiCurOnePass[0]!=iDataCur && aiCurOnePass[1]!=iDataCur ){ assert( pPk ); sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelBreak, regKey,nKey); VdbeCoverage(v); } if( eOnePass!=ONEPASS_SINGLE ){ |
︙ | |||
133263 133264 133265 133266 133267 133268 133269 | 133692 133693 133694 133695 133696 133697 133698 133699 133700 133701 133702 133703 133704 133705 133706 133707 133708 133709 133710 133711 133712 133713 133714 133715 133716 133717 133718 133719 133720 133721 133722 133723 133724 133725 133726 133727 133728 133729 133730 133731 133732 133733 133734 133735 133736 133737 133738 133739 133740 133741 133742 133743 133744 133745 133746 133747 133748 133749 133750 133751 133752 133753 133754 133755 133756 133757 133758 133759 133760 133761 133762 133763 133764 133765 133766 133767 133768 133769 133770 133771 133772 133773 133774 133775 133776 133777 133778 133779 133780 133781 133782 133783 133784 133785 133786 133787 133788 133789 133790 133791 133792 | - + - + - + + + + + + - + + + - + + + + + + - - + + + + + + + + + + + + - + | ** the copy of step (3) were replaced by deleting the original database ** and renaming the transient database as the original. But that will ** not work if other processes are attached to the original database. ** And a power loss in between deleting the original and renaming the ** transient would cause the database file to appear to be deleted ** following reboot. */ |
︙ | |||
133350 133351 133352 133353 133354 133355 133356 | 133801 133802 133803 133804 133805 133806 133807 133808 133809 133810 133811 133812 133813 133814 133815 133816 133817 133818 133819 133820 133821 133822 133823 133824 133825 133826 133827 133828 133829 | - + + + + + + + + - + - - - - - - + | ** that actually made the VACUUM run slower. Very little journalling ** actually occurs when doing a vacuum since the vacuum_db is initially ** empty. Only the journal header is written. Apparently it takes more ** time to parse and run the PRAGMA to turn journalling off than it does ** to write the journal header file. */ nDb = db->nDb; |
︙ | |||
133386 133387 133388 133389 133390 133391 133392 | 133839 133840 133841 133842 133843 133844 133845 133846 133847 133848 133849 133850 133851 133852 133853 | - + | /* Begin a transaction and take an exclusive lock on the main database ** file. This is done before the sqlite3BtreeGetPageSize(pMain) call below, ** to ensure that we do not try to change the page-size on a WAL database. */ rc = execSql(db, pzErrMsg, "BEGIN"); if( rc!=SQLITE_OK ) goto end_of_vacuum; |
︙ | |||
133481 133482 133483 133484 133485 133486 133487 | 133934 133935 133936 133937 133938 133939 133940 133941 133942 133943 133944 133945 133946 133947 133948 133949 133950 133951 133952 133953 133954 133955 133956 133957 133958 133959 133960 133961 133962 133963 133964 133965 133966 133967 133968 133969 133970 133971 133972 133973 133974 133975 | - + + - + + + - + + + - + + | BTREE_DEFAULT_CACHE_SIZE, 0, /* Preserve the default page cache size */ BTREE_TEXT_ENCODING, 0, /* Preserve the text encoding */ BTREE_USER_VERSION, 0, /* Preserve the user version */ BTREE_APPLICATION_ID, 0, /* Preserve the application id */ }; assert( 1==sqlite3BtreeIsInTrans(pTemp) ); |
︙ | |||
134543 134544 134545 134546 134547 134548 134549 134550 134551 134552 134553 134554 134555 134556 134557 134558 134559 134560 134561 134562 134563 134564 134565 134566 134567 134568 134569 134570 134571 | 135002 135003 135004 135005 135006 135007 135008 135009 135010 135011 135012 135013 135014 135015 135016 135017 135018 135019 135020 135021 135022 135023 135024 135025 135026 135027 135028 135029 135030 135031 135032 | + + | if( db->aVTrans ){ int i; for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){ VTable *pVTab = db->aVTrans[i]; const sqlite3_module *pMod = pVTab->pMod->pModule; if( pVTab->pVtab && pMod->iVersion>=2 ){ int (*xMethod)(sqlite3_vtab *, int); sqlite3VtabLock(pVTab); switch( op ){ case SAVEPOINT_BEGIN: xMethod = pMod->xSavepoint; pVTab->iSavepoint = iSavepoint+1; break; case SAVEPOINT_ROLLBACK: xMethod = pMod->xRollbackTo; break; default: xMethod = pMod->xRelease; break; } if( xMethod && pVTab->iSavepoint>iSavepoint ){ rc = xMethod(pVTab->pVtab, iSavepoint); } sqlite3VtabUnlock(pVTab); } } } return rc; } /* |
︙ | |||
135319 135320 135321 135322 135323 135324 135325 135326 135327 135328 135329 135330 135331 135332 135333 135334 | 135780 135781 135782 135783 135784 135785 135786 135787 135788 135789 135790 135791 135792 135793 135794 135795 135796 135797 135798 | + + + | WhereLevel *pLvl, /* Level to add scanstatus() entry for */ int addrExplain /* Address of OP_Explain (or 0) */ ); #else # define sqlite3WhereAddScanStatus(a, b, c, d) ((void)d) #endif SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( Parse *pParse, /* Parsing context */ Vdbe *v, /* Prepared statement under construction */ WhereInfo *pWInfo, /* Complete information about the WHERE clause */ int iLevel, /* Which level of pWInfo->a[] should be coded */ WhereLevel *pLevel, /* The current level pointer */ Bitmask notReady /* Which tables are currently available */ ); /* whereexpr.c: */ SQLITE_PRIVATE void sqlite3WhereClauseInit(WhereClause*,WhereInfo*); SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*); SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause*,Expr*,u8); |
︙ | |||
135590 135591 135592 135593 135594 135595 135596 135597 135598 135599 135600 135601 135602 135603 | 136054 136055 136056 136057 136058 136059 136060 136061 136062 136063 136064 136065 136066 136067 136068 | + | sqlite3_str_appendf(&str, " (~%llu rows)", sqlite3LogEstToInt(pLoop->nOut)); }else{ sqlite3_str_append(&str, " (~1 row)", 9); } #endif zMsg = sqlite3StrAccumFinish(&str); sqlite3ExplainBreakpoint("",zMsg); ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v), pParse->addrExplain, 0, zMsg,P4_DYNAMIC); } return ret; } #endif /* SQLITE_OMIT_EXPLAIN */ |
︙ | |||
135915 135916 135917 135918 135919 135920 135921 135922 | 136380 136381 136382 136383 136384 136385 136386 136387 136388 136389 136390 136391 136392 136393 136394 136395 136396 136397 136398 136399 136400 136401 136402 136403 136404 136405 136406 136407 136408 136409 136410 136411 136412 136413 136414 136415 136416 136417 136418 136419 136420 136421 | + - + - - + + - - + | } } for(i=iEq;i<pLoop->nLTerm; i++){ assert( pLoop->aLTerm[i]!=0 ); if( pLoop->aLTerm[i]->pExpr==pX ) nEq++; } iTab = 0; if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){ |
︙ | |||
136453 136454 136455 136456 136457 136458 136459 | 136918 136919 136920 136921 136922 136923 136924 136925 136926 136927 136928 136929 136930 136931 136932 136933 136934 | + + - + | */ static void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){ assert( nReg>0 ); if( p && sqlite3ExprIsVector(p) ){ #ifndef SQLITE_OMIT_SUBQUERY if( (p->flags & EP_xIsSelect) ){ Vdbe *v = pParse->pVdbe; int iSelect; assert( p->op==TK_SELECT ); |
︙ | |||
136539 136540 136541 136542 136543 136544 136545 136546 136547 136548 136549 136550 136551 136552 | 137006 137007 137008 137009 137010 137011 137012 137013 137014 137015 137016 137017 137018 137019 137020 137021 137022 137023 137024 137025 137026 137027 137028 137029 137030 137031 137032 137033 137034 137035 137036 137037 137038 137039 137040 137041 137042 137043 137044 137045 137046 137047 137048 137049 137050 137051 137052 137053 137054 137055 137056 137057 137058 137059 137060 137061 137062 137063 137064 | + + + - - - - - - - - - - - + + | } /* ** Generate code for the start of the iLevel-th loop in the WHERE clause ** implementation described by pWInfo. */ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( Parse *pParse, /* Parsing context */ Vdbe *v, /* Prepared statement under construction */ WhereInfo *pWInfo, /* Complete information about the WHERE clause */ int iLevel, /* Which level of pWInfo->a[] should be coded */ WhereLevel *pLevel, /* The current level pointer */ Bitmask notReady /* Which tables are currently available */ ){ int j, k; /* Loop counters */ int iCur; /* The VDBE cursor for the table */ int addrNxt; /* Where to jump to continue with the next IN case */ |
︙ | |||
136716 136717 136718 136719 136720 136721 136722 | 137177 137178 137179 137180 137181 137182 137183 137184 137185 137186 137187 137188 137189 137190 137191 137192 137193 137194 137195 137196 137197 137198 137199 137200 137201 137202 137203 137204 137205 137206 137207 137208 | - - | ** we reference multiple rows using a "rowid IN (...)" ** construct. */ assert( pLoop->u.btree.nEq==1 ); pTerm = pLoop->aLTerm[0]; assert( pTerm!=0 ); assert( pTerm->pExpr!=0 ); |
︙ | |||
136899 136900 136901 136902 136903 136904 136905 136906 136907 136908 136909 136910 136911 136912 | 137358 137359 137360 137361 137362 137363 137364 137365 137366 137367 137368 137369 137370 137371 137372 137373 | + + | int iIdxCur; /* The VDBE cursor for the index */ int nExtraReg = 0; /* Number of extra registers needed */ int op; /* Instruction opcode */ char *zStartAff; /* Affinity for start of range constraint */ char *zEndAff = 0; /* Affinity for end of range constraint */ u8 bSeekPastNull = 0; /* True to seek past initial nulls */ u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */ int omitTable; /* True if we use the index only */ pIdx = pLoop->u.btree.pIndex; iIdxCur = pLevel->iIdxCur; assert( nEq>=pLoop->nSkip ); /* If this loop satisfies a sort order (pOrderBy) request that ** was passed to this function to implement a "SELECT min(x) ..." |
︙ | |||
137100 137101 137102 137103 137104 137105 137106 137107 137108 137109 137110 137111 137112 137113 | 137561 137562 137563 137564 137565 137566 137567 137568 137569 137570 137571 137572 137573 137574 137575 137576 | + + | } if( pLoop->wsFlags & WHERE_IN_EARLYOUT ){ sqlite3VdbeAddOp2(v, OP_SeekHit, iIdxCur, 1); } /* Seek the table cursor, if required */ omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0; if( omitTable ){ /* pIdx is a covering index. No need to access the main table. */ }else if( HasRowid(pIdx->pTable) ){ if( (pWInfo->wctrlFlags & WHERE_SEEK_TABLE) || ( (pWInfo->wctrlFlags & WHERE_SEEK_UNIQ_TABLE) && (pWInfo->eOnePass==ONEPASS_SINGLE) )){ |
︙ | |||
137210 137211 137212 137213 137214 137215 137216 | 137673 137674 137675 137676 137677 137678 137679 137680 137681 137682 137683 137684 137685 137686 137687 | - + | SrcList *pOrTab; /* Shortened table list or OR-clause generation */ Index *pCov = 0; /* Potential covering index (or NULL) */ int iCovCur = pParse->nTab++; /* Cursor used for index scans (if any) */ int regReturn = ++pParse->nMem; /* Register used with OP_Gosub */ int regRowset = 0; /* Register for RowSet object */ int regRowid = 0; /* Register holding rowid */ |
︙ | |||
137326 137327 137328 137329 137330 137331 137332 137333 137334 137335 137336 137337 137338 137339 | 137789 137790 137791 137792 137793 137794 137795 137796 137797 137798 137799 137800 137801 137802 137803 | + | || ExprHasProperty(pOrExpr, EP_FromJoin) ); if( pAndExpr ){ pAndExpr->pLeft = pOrExpr; pOrExpr = pAndExpr; } /* Loop through table entries that match term pOrTerm. */ ExplainQueryPlan((pParse, 1, "INDEX %d", ii+1)); WHERETRACE(0xffff, ("Subplan for OR-clause:\n")); pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, wctrlFlags, iCovCur); assert( pSubWInfo || pParse->nErr || db->mallocFailed ); if( pSubWInfo ){ WhereLoop *pSubLoop; int addrExplain = sqlite3WhereExplainOneScan( |
︙ | |||
137429 137430 137431 137432 137433 137434 137435 137436 137437 137438 137439 137440 137441 137442 | 137893 137894 137895 137896 137897 137898 137899 137900 137901 137902 137903 137904 137905 137906 137907 | + | pCov = pSubLoop->u.btree.pIndex; }else{ pCov = 0; } /* Finish the loop through table entries that match term pOrTerm. */ sqlite3WhereEnd(pSubWInfo); ExplainQueryPlanPop(pParse); } } } ExplainQueryPlanPop(pParse); pLevel->u.pCovidx = pCov; if( pCov ) pLevel->iIdxCur = iCovCur; if( pAndExpr ){ |
︙ | |||
138390 138391 138392 138393 138394 138395 138396 138397 138398 138399 138400 138401 138402 138403 | 138855 138856 138857 138858 138859 138860 138861 138862 138863 138864 138865 138866 138867 138868 138869 | + | /* Search for a table and column that appears on one side or the ** other of the == operator in every subterm. That table and column ** will be recorded in iCursor and iColumn. There might not be any ** such table and column. Set okToChngToIN if an appropriate table ** and column is found but leave okToChngToIN false if not found. */ for(j=0; j<2 && !okToChngToIN; j++){ Expr *pLeft = 0; pOrTerm = pOrWc->a; for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){ assert( pOrTerm->eOperator & WO_EQ ); pOrTerm->wtFlags &= ~TERM_OR_OK; if( pOrTerm->leftCursor==iCursor ){ /* This is the 2-bit case and we are on the second iteration and ** current term is from the first iteration. So skip this term. */ |
︙ | |||
138413 138414 138415 138416 138417 138418 138419 138420 138421 138422 138423 138424 138425 138426 138427 138428 138429 138430 138431 138432 138433 138434 138435 138436 138437 138438 | 138879 138880 138881 138882 138883 138884 138885 138886 138887 138888 138889 138890 138891 138892 138893 138894 138895 138896 138897 138898 138899 138900 138901 138902 138903 138904 138905 138906 138907 138908 138909 138910 138911 138912 138913 138914 138915 | + - + + + | testcase( pOrTerm->wtFlags & TERM_COPIED ); testcase( pOrTerm->wtFlags & TERM_VIRTUAL ); assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) ); continue; } iColumn = pOrTerm->u.leftColumn; iCursor = pOrTerm->leftCursor; pLeft = pOrTerm->pExpr->pLeft; break; } if( i<0 ){ /* No candidate table+column was found. This can only occur ** on the second iteration */ assert( j==1 ); assert( IsPowerOfTwo(chngToIN) ); assert( chngToIN==sqlite3WhereGetMask(&pWInfo->sMaskSet, iCursor) ); break; } testcase( j==1 ); /* We have found a candidate table and column. Check to see if that ** table and column is common to every term in the OR clause */ okToChngToIN = 1; for(; i>=0 && okToChngToIN; i--, pOrTerm++){ assert( pOrTerm->eOperator & WO_EQ ); if( pOrTerm->leftCursor!=iCursor ){ pOrTerm->wtFlags &= ~TERM_OR_OK; |
︙ | |||
139519 139520 139521 139522 139523 139524 139525 139526 139527 139528 139529 139530 139531 139532 | 139988 139989 139990 139991 139992 139993 139994 139995 139996 139997 139998 139999 140000 140001 140002 140003 140004 140005 140006 140007 140008 140009 140010 140011 140012 | + + + + + + + + + + + | if( pScan->iEquiv>=pScan->nEquiv ) break; pWC = pScan->pOrigWC; k = 0; pScan->iEquiv++; } return 0; } /* ** This is whereScanInit() for the case of an index on an expression. ** It is factored out into a separate tail-recursion subroutine so that ** the normal whereScanInit() routine, which is a high-runner, does not ** need to push registers onto the stack as part of its prologue. */ static SQLITE_NOINLINE WhereTerm *whereScanInitIndexExpr(WhereScan *pScan){ pScan->idxaff = sqlite3ExprAffinity(pScan->pIdxExpr); return whereScanNext(pScan); } /* ** Initialize a WHERE clause scanner object. Return a pointer to the ** first match. Return NULL if there are no matches. ** ** The scanner will be searching the WHERE clause pWC. It will look ** for terms of the form "X <op> <expr>" where X is column iColumn of table |
︙ | |||
139552 139553 139554 139555 139556 139557 139558 139559 139560 139561 139562 139563 139564 139565 139566 139567 139568 139569 139570 139571 139572 139573 | 140032 140033 140034 140035 140036 140037 140038 140039 140040 140041 140042 140043 140044 140045 140046 140047 140048 140049 140050 140051 140052 140053 140054 140055 140056 140057 140058 140059 140060 140061 140062 140063 140064 140065 140066 140067 140068 | + + + + + + + - - - - - | Index *pIdx /* Must be compatible with this index */ ){ pScan->pOrigWC = pWC; pScan->pWC = pWC; pScan->pIdxExpr = 0; pScan->idxaff = 0; pScan->zCollName = 0; pScan->opMask = opMask; pScan->k = 0; pScan->aiCur[0] = iCur; pScan->nEquiv = 1; pScan->iEquiv = 1; if( pIdx ){ int j = iColumn; iColumn = pIdx->aiColumn[j]; if( iColumn==XN_EXPR ){ pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr; pScan->zCollName = pIdx->azColl[j]; pScan->aiColumn[0] = XN_EXPR; return whereScanInitIndexExpr(pScan); }else if( iColumn==pIdx->pTable->iPKey ){ iColumn = XN_ROWID; }else if( iColumn>=0 ){ pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity; pScan->zCollName = pIdx->azColl[j]; } }else if( iColumn==XN_EXPR ){ return 0; } |
︙ | |||
140047 140048 140049 140050 140051 140052 140053 | 140529 140530 140531 140532 140533 140534 140535 140536 140537 140538 140539 140540 140541 140542 140543 140544 140545 140546 140547 140548 140549 140550 140551 140552 140553 140554 140555 140556 140557 140558 140559 140560 | - + + | addrTop = sqlite3VdbeAddOp1(v, OP_Yield, regYield); VdbeCoverage(v); VdbeComment((v, "next row of %s", pTabItem->pTab->zName)); }else{ addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v); } if( pPartial ){ |
︙ | |||
141419 141420 141421 141422 141423 141424 141425 | 141902 141903 141904 141905 141906 141907 141908 141909 141910 141911 141912 141913 141914 141915 141916 | - + | #endif whereLoopDelete(db, pToDel); } } rc = whereLoopXfer(db, p, pTemplate); if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){ Index *pIndex = p->u.btree.pIndex; |
︙ | |||
141586 141587 141588 141589 141590 141591 141592 | 142069 142070 142071 142072 142073 142074 142075 142076 142077 142078 142079 142080 142081 142082 142083 142084 | - - + + | ** index pIndex. Try to match one more. ** ** When this function is called, pBuilder->pNew->nOut contains the ** number of rows expected to be visited by filtering using the nEq ** terms only. If it is modified, this value is restored before this ** function returns. ** |
︙ | |||
142087 142088 142089 142090 142091 142092 142093 142094 142095 142096 142097 142098 142099 142100 | 142570 142571 142572 142573 142574 142575 142576 142577 142578 142579 142580 142581 142582 142583 142584 | + | sPk.nKeyCol = 1; sPk.nColumn = 1; sPk.aiColumn = &aiColumnPk; sPk.aiRowLogEst = aiRowEstPk; sPk.onError = OE_Replace; sPk.pTable = pTab; sPk.szIdxRow = pTab->szTabRow; sPk.idxType = SQLITE_IDXTYPE_IPK; aiRowEstPk[0] = pTab->nRowLogEst; aiRowEstPk[1] = 0; pFirst = pSrc->pTab->pIndex; if( pSrc->fg.notIndexed==0 ){ /* The real indices of the table are only considered if the ** NOT INDEXED qualifier is omitted from the FROM clause */ sPk.pNext = pFirst; |
︙ | |||
142177 142178 142179 142180 142181 142182 142183 | 142661 142662 142663 142664 142665 142666 142667 142668 142669 142670 142671 142672 142673 142674 142675 | - + | pNew->rSetup = 0; pNew->prereq = mPrereq; pNew->nOut = rSize; pNew->u.btree.pIndex = pProbe; b = indexMightHelpWithOrderBy(pBuilder, pProbe, pSrc->iCursor); /* The ONEPASS_DESIRED flags never occurs together with ORDER BY */ assert( (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || b==0 ); |
︙ | |||
143853 143854 143855 143856 143857 143858 143859 | 144337 144338 144339 144340 144341 144342 144343 144344 144345 144346 144347 144348 144349 144350 144351 | - + | pWInfo->pParse = pParse; pWInfo->pTabList = pTabList; pWInfo->pOrderBy = pOrderBy; pWInfo->pWhere = pWhere; pWInfo->pResultSet = pResultSet; pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1; pWInfo->nLevel = nTabList; |
︙ | |||
144127 144128 144129 144130 144131 144132 144133 144134 144135 | 144611 144612 144613 144614 144615 144616 144617 144618 144619 144620 144621 144622 144623 144624 144625 144626 144627 144628 | + - + | ** use a one-pass approach, and this is not set accurately for scans ** that use the OR optimization. */ assert( (wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || pWInfo->nLevel==1 ); if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){ int wsFlags = pWInfo->a[0].pWLoop->wsFlags; int bOnerow = (wsFlags & WHERE_ONEROW)!=0; assert( !(wsFlags & WHERE_VIRTUALTABLE) || IsVirtual(pTabList->a[0].pTab) ); if( bOnerow || ( 0!=(wctrlFlags & WHERE_ONEPASS_MULTIROW) |
︙ | |||
144284 144285 144286 144287 144288 144289 144290 | 144769 144770 144771 144772 144773 144774 144775 144776 144777 144778 144779 144780 144781 144782 144783 | - + | if( db->mallocFailed ) goto whereBeginError; } #endif addrExplain = sqlite3WhereExplainOneScan( pParse, pTabList, pLevel, wctrlFlags ); pLevel->addrBody = sqlite3VdbeCurrentAddr(v); |
︙ | |||
144468 144469 144470 144471 144472 144473 144474 144475 144476 144477 144478 144479 144480 144481 | 144953 144954 144955 144956 144957 144958 144959 144960 144961 144962 144963 144964 144965 144966 144967 144968 144969 144970 144971 144972 144973 144974 144975 144976 144977 144978 144979 144980 144981 144982 144983 144984 144985 144986 144987 144988 144989 | + + + + + + + + + + + + + + + + + + + + + + + | */ if( pTabItem->fg.viaCoroutine ){ testcase( pParse->db->mallocFailed ); translateColumnToCopy(pParse, pLevel->addrBody, pLevel->iTabCur, pTabItem->regResult, 0); continue; } #ifdef SQLITE_ENABLE_EARLY_CURSOR_CLOSE /* Close all of the cursors that were opened by sqlite3WhereBegin. ** Except, do not close cursors that will be reused by the OR optimization ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors ** created for the ONEPASS optimization. */ if( (pTab->tabFlags & TF_Ephemeral)==0 && pTab->pSelect==0 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){ int ws = pLoop->wsFlags; if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){ sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor); } if( (ws & WHERE_INDEXED)!=0 && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0 && pLevel->iIdxCur!=pWInfo->aiCurOnePass[1] ){ sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur); } } #endif /* If this scan uses an index, make VDBE code substitutions to read data ** from the index instead of from the table where possible. In some cases ** this optimization prevents the table from ever being read, which can ** yield a significant performance boost. ** ** Calls to the code generator in between sqlite3WhereBegin and |
︙ | |||
145368 145369 145370 145371 145372 145373 145374 | 145876 145877 145878 145879 145880 145881 145882 145883 145884 145885 145886 145887 145888 145889 145890 | - + - | sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0) ); } pSub = sqlite3SelectNew( pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0 ); |
︙ | |||
145426 145427 145428 145429 145430 145431 145432 145433 145434 145435 145436 145437 145438 145439 | 145933 145934 145935 145936 145937 145938 145939 145940 145941 145942 145943 145944 145945 145946 145947 | + | ** value should be a non-negative integer. If the value is not a ** constant, change it to NULL. The fact that it is then a non-negative ** integer will be caught later. But it is important not to leave ** variable values in the expression tree. */ static Expr *sqlite3WindowOffsetExpr(Parse *pParse, Expr *pExpr){ if( 0==sqlite3ExprIsConstant(pExpr) ){ if( IN_RENAME_OBJECT ) sqlite3RenameExprUnmap(pParse, pExpr); sqlite3ExprDelete(pParse->db, pExpr); pExpr = sqlite3ExprAlloc(pParse->db, TK_NULL, 0, 0); } return pExpr; } /* |
︙ | |||
145620 145621 145622 145623 145624 145625 145626 145627 145628 145629 145630 145631 145632 145633 | 146128 146129 146130 146131 146132 146133 146134 146135 146136 146137 146138 146139 146140 146141 146142 | + | VdbeCoverageIf(v, eCond==0); VdbeCoverageIf(v, eCond==1); VdbeCoverageIf(v, eCond==2); sqlite3VdbeAddOp3(v, aOp[eCond], regZero, sqlite3VdbeCurrentAddr(v)+2, reg); VdbeCoverageNeverNullIf(v, eCond==0); VdbeCoverageNeverNullIf(v, eCond==1); VdbeCoverageNeverNullIf(v, eCond==2); sqlite3MayAbort(pParse); sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort); sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC); sqlite3ReleaseTempReg(pParse, regZero); } /* ** Return the number of arguments passed to the window-function associated |
︙ | |||
145875 145876 145877 145878 145879 145880 145881 | 146384 146385 146386 146387 146388 146389 146390 146391 146392 146393 146394 146395 146396 146397 146398 | - + | Window *pWin; for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ FuncDef *pFunc = pWin->pFunc; if( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ){ int csr = pWin->csrApp; |
︙ | |||
145898 145899 145900 145901 145902 145903 145904 | 146407 146408 146409 146410 146411 146412 146413 146414 146415 146416 146417 146418 146419 146420 146421 | - + | sqlite3VdbeResolveLabel(v, lbl); sqlite3ReleaseTempReg(pParse, tmpReg); } else if( pFunc->zName==leadName || pFunc->zName==lagName ){ int nArg = pWin->pOwner->x.pList->nExpr; int iEph = pMWin->iEphCsr; int csr = pWin->csrApp; |
︙ | |||
146159 146160 146161 146162 146163 146164 146165 | 146668 146669 146670 146671 146672 146673 146674 146675 146676 146677 146678 146679 146680 146681 146682 146683 | - - + + | || pMWin->eEnd==TK_CURRENT || pMWin->eEnd==TK_UNBOUNDED || pMWin->eEnd==TK_PRECEDING ); /* Allocate register and label for the "flush_partition" sub-routine. */ regFlushPart = ++pParse->nMem; |
︙ | |||
146270 146271 146272 146273 146274 146275 146276 | 146779 146780 146781 146782 146783 146784 146785 146786 146787 146788 146789 146790 146791 146792 146793 | - + | sqlite3VdbeJumpHere(v, addrIfPos2); } if( pMWin->eStart==TK_CURRENT || pMWin->eStart==TK_PRECEDING || pMWin->eStart==TK_FOLLOWING ){ |
︙ | |||
146435 146436 146437 146438 146439 146440 146441 | 146944 146945 146946 146947 146948 146949 146950 146951 146952 146953 146954 146955 146956 146957 146958 146959 146960 146961 146962 146963 146964 | - + - + | assert( (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_CURRENT) || (pMWin->eStart==TK_UNBOUNDED && pMWin->eEnd==TK_UNBOUNDED) || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_CURRENT) || (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED) ); |
︙ | |||
146678 146679 146680 146681 146682 146683 146684 146685 146686 146687 146688 146689 146690 146691 | 147187 147188 147189 147190 147191 147192 147193 147194 147195 147196 147197 147198 147199 147200 147201 | + | SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){ Window *pNew = 0; if( ALWAYS(p) ){ pNew = sqlite3DbMallocZero(db, sizeof(Window)); if( pNew ){ pNew->zName = sqlite3DbStrDup(db, p->zName); pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0); pNew->pFunc = p->pFunc; pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0); pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0); pNew->eType = p->eType; pNew->eEnd = p->eEnd; pNew->eStart = p->eStart; pNew->pStart = sqlite3ExprDup(db, p->pStart, 0); pNew->pEnd = sqlite3ExprDup(db, p->pEnd, 0); |
︙ | |||
146935 146936 146937 146938 146939 146940 146941 | 147445 147446 147447 147448 147449 147450 147451 147452 147453 147454 147455 147456 147457 147458 147459 | - - + | p->op2 = 0; p->iTable = 0; p->iColumn = 0; p->u.zToken = (char*)&p[1]; memcpy(p->u.zToken, t.z, t.n); p->u.zToken[t.n] = 0; if( sqlite3Isquote(p->u.zToken[0]) ){ |
︙ | |||
147045 147046 147047 147048 147049 147050 147051 | 147554 147555 147556 147557 147558 147559 147560 147561 147562 147563 147564 147565 147566 147567 147568 147569 147570 147571 147572 147573 147574 147575 147576 147577 147578 147579 147580 147581 147582 147583 147584 147585 147586 147587 147588 147589 147590 147591 147592 147593 147594 147595 147596 147597 147598 147599 147600 147601 147602 147603 147604 147605 147606 147607 147608 147609 147610 147611 147612 147613 147614 | - + - - - - + + - - - - - - - - - + + + + + + + + + + + + - - - + + - - - - - - - - + + + + + + + + | ** YY_MAX_REDUCE Maximum value for reduce actions */ #ifndef INTERFACE # define INTERFACE 1 #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int |
︙ | |||
147160 147161 147162 147163 147164 147165 147166 | 147669 147670 147671 147672 147673 147674 147675 147676 147677 147678 147679 147680 147681 147682 147683 147684 147685 147686 147687 147688 147689 147690 147691 147692 147693 147694 147695 147696 147697 147698 147699 147700 147701 147702 147703 147704 147705 147706 147707 147708 147709 147710 147711 147712 147713 147714 147715 147716 147717 147718 147719 147720 147721 147722 147723 147724 147725 147726 147727 147728 147729 147730 147731 147732 147733 147734 147735 147736 147737 147738 147739 147740 147741 147742 147743 147744 147745 147746 147747 147748 147749 147750 147751 147752 147753 147754 147755 147756 147757 147758 147759 147760 147761 147762 147763 147764 147765 147766 147767 147768 147769 147770 147771 147772 147773 147774 147775 147776 147777 147778 147779 147780 147781 147782 147783 147784 147785 147786 147787 147788 147789 147790 147791 147792 147793 147794 147795 147796 147797 147798 147799 147800 147801 147802 147803 147804 147805 147806 147807 147808 147809 147810 147811 147812 147813 147814 147815 147816 147817 147818 147819 147820 147821 147822 147823 147824 147825 147826 147827 147828 147829 147830 147831 147832 147833 147834 147835 147836 147837 147838 147839 147840 147841 147842 147843 147844 147845 147846 147847 147848 147849 147850 147851 147852 147853 147854 147855 147856 147857 147858 147859 147860 147861 147862 147863 147864 147865 147866 147867 147868 147869 147870 147871 147872 147873 147874 147875 147876 147877 147878 147879 147880 147881 147882 147883 147884 147885 147886 147887 147888 147889 147890 147891 147892 147893 147894 147895 147896 147897 147898 147899 147900 147901 147902 147903 147904 147905 147906 147907 147908 147909 147910 147911 147912 147913 147914 147915 147916 147917 147918 147919 147920 147921 147922 147923 147924 147925 147926 147927 147928 147929 147930 147931 147932 147933 147934 147935 147936 147937 147938 147939 147940 147941 147942 147943 147944 147945 147946 147947 147948 147949 147950 147951 147952 147953 147954 147955 147956 147957 147958 147959 147960 147961 147962 147963 147964 147965 147966 147967 147968 147969 147970 147971 147972 147973 147974 147975 147976 147977 147978 147979 147980 147981 147982 147983 147984 147985 147986 147987 147988 147989 147990 147991 147992 147993 147994 147995 147996 147997 147998 147999 148000 148001 148002 148003 148004 148005 148006 148007 148008 148009 148010 148011 148012 148013 148014 148015 148016 148017 148018 148019 148020 148021 148022 148023 148024 148025 148026 148027 148028 148029 148030 148031 148032 148033 148034 148035 148036 148037 148038 148039 148040 148041 148042 148043 148044 148045 148046 148047 148048 148049 148050 148051 148052 148053 148054 148055 148056 148057 148058 148059 148060 148061 148062 148063 148064 148065 148066 148067 148068 148069 148070 148071 148072 148073 148074 148075 148076 148077 148078 148079 148080 148081 148082 148083 148084 148085 148086 148087 148088 148089 148090 148091 148092 148093 148094 148095 148096 148097 148098 148099 148100 148101 148102 148103 148104 148105 148106 148107 148108 148109 148110 148111 148112 148113 148114 148115 148116 148117 148118 148119 148120 148121 148122 148123 148124 148125 148126 148127 148128 148129 148130 148131 148132 148133 148134 148135 148136 148137 148138 148139 148140 148141 148142 148143 148144 148145 148146 148147 148148 148149 148150 148151 148152 148153 148154 148155 148156 148157 148158 148159 148160 148161 148162 148163 148164 148165 148166 148167 148168 148169 148170 148171 148172 148173 148174 148175 148176 148177 148178 148179 148180 148181 148182 148183 148184 148185 148186 148187 148188 148189 148190 148191 148192 148193 148194 148195 148196 148197 148198 148199 148200 148201 148202 148203 148204 148205 148206 148207 148208 148209 148210 148211 148212 148213 148214 148215 148216 148217 148218 148219 148220 148221 148222 148223 148224 148225 148226 148227 148228 148229 148230 148231 148232 148233 148234 148235 148236 148237 148238 148239 148240 148241 148242 148243 | - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - + + - + - + - - - - + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - + + + + - + - - - - - - - - - + + + + + + + + + - + - - - - + + + + - - - - - - - + + + + + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ** yy_reduce_ofst[] For each state, the offset into yy_action for ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (2009) static const YYACTIONTYPE yy_action[] = { |
︙ | |||
148164 148165 148166 148167 148168 148169 148170 | 148674 148675 148676 148677 148678 148679 148680 148681 148682 148683 148684 148685 148686 148687 148688 148689 148690 148691 148692 148693 148694 148695 148696 148697 148698 148699 148700 148701 148702 148703 148704 148705 148706 148707 148708 148709 148710 148711 148712 148713 148714 148715 148716 148717 148718 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | /* 240 */ "in_op", /* 241 */ "paren_exprlist", /* 242 */ "case_operand", /* 243 */ "case_exprlist", /* 244 */ "case_else", /* 245 */ "uniqueflag", /* 246 */ "collate", |
︙ | |||
148430 148431 148432 148433 148434 148435 148436 | 148941 148942 148943 148944 148945 148946 148947 148948 148949 148950 148951 148952 148953 148954 148955 148956 148957 148958 148959 148960 148961 148962 148963 148964 148965 148966 148967 148968 148969 148970 148971 148972 148973 148974 148975 148976 148977 148978 148979 148980 148981 148982 148983 148984 148985 148986 148987 148988 148989 148990 148991 148992 148993 148994 148995 148996 148997 148998 148999 149000 149001 149002 149003 149004 149005 149006 149007 149008 149009 149010 149011 149012 149013 149014 149015 149016 149017 149018 149019 149020 149021 149022 149023 149024 149025 149026 149027 149028 149029 149030 149031 149032 149033 149034 149035 149036 149037 149038 149039 149040 149041 149042 149043 149044 149045 149046 149047 149048 149049 149050 149051 149052 149053 149054 149055 149056 149057 149058 149059 149060 149061 149062 149063 149064 149065 149066 149067 149068 149069 149070 149071 149072 149073 149074 149075 149076 149077 149078 149079 149080 149081 149082 149083 149084 149085 149086 149087 149088 149089 149090 149091 149092 149093 149094 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | /* 222 */ "eidlist_opt ::=", /* 223 */ "eidlist_opt ::= LP eidlist RP", /* 224 */ "eidlist ::= eidlist COMMA nm collate sortorder", /* 225 */ "eidlist ::= nm collate sortorder", /* 226 */ "collate ::=", /* 227 */ "collate ::= COLLATE ID|STRING", /* 228 */ "cmd ::= DROP INDEX ifexists fullname", |
︙ | |||
148698 148699 148700 148701 148702 148703 148704 | 149211 149212 149213 149214 149215 149216 149217 149218 149219 149220 149221 149222 149223 149224 149225 149226 149227 149228 149229 149230 149231 149232 149233 149234 149235 149236 149237 149238 149239 149240 149241 149242 149243 149244 149245 149246 149247 149248 149249 149250 149251 149252 149253 149254 149255 149256 149257 149258 149259 149260 149261 149262 149263 149264 149265 149266 149267 149268 149269 149270 149271 149272 149273 149274 149275 149276 149277 149278 149279 149280 149281 149282 149283 149284 149285 149286 149287 149288 149289 149290 149291 149292 149293 149294 149295 149296 149297 149298 149299 149300 149301 149302 149303 149304 149305 149306 149307 149308 149309 149310 | - + + - - - + + + - + - + - + - + - + - + - + - + - - - + + + - + - - + + - + - + - + - - - + + + - + | */ /********* Begin destructor definitions ***************************************/ case 174: /* select */ case 206: /* selectnowith */ case 207: /* oneselect */ case 219: /* values */ { |
︙ | |||
149074 149075 149076 149077 149078 149079 149080 | 149588 149589 149590 149591 149592 149593 149594 149595 149596 149597 149598 149599 149600 149601 149602 149603 149604 149605 149606 149607 149608 149609 149610 149611 149612 149613 149614 149615 149616 149617 149618 149619 149620 149621 149622 149623 149624 149625 149626 149627 149628 149629 149630 149631 149632 149633 149634 149635 149636 149637 149638 149639 149640 149641 149642 149643 149644 149645 149646 149647 149648 149649 149650 149651 149652 149653 149654 149655 149656 149657 149658 149659 149660 149661 149662 149663 149664 149665 149666 149667 149668 149669 149670 149671 149672 149673 149674 149675 149676 149677 149678 149679 149680 149681 149682 149683 149684 149685 149686 149687 149688 149689 149690 149691 149692 149693 149694 149695 149696 149697 149698 149699 149700 149701 149702 149703 149704 149705 149706 149707 149708 149709 149710 149711 149712 149713 149714 149715 149716 149717 149718 149719 149720 149721 149722 149723 149724 149725 149726 149727 149728 149729 149730 149731 149732 149733 149734 149735 149736 149737 149738 149739 149740 149741 149742 149743 149744 149745 149746 149747 149748 149749 149750 149751 149752 149753 149754 149755 149756 149757 149758 149759 149760 149761 149762 149763 149764 149765 149766 149767 149768 149769 149770 149771 149772 149773 149774 149775 149776 149777 149778 149779 149780 149781 149782 149783 149784 149785 149786 149787 149788 149789 149790 149791 149792 149793 149794 149795 149796 149797 149798 149799 149800 149801 149802 149803 149804 149805 149806 149807 149808 149809 149810 149811 149812 149813 149814 149815 149816 149817 149818 149819 149820 149821 149822 149823 149824 149825 149826 149827 149828 149829 149830 149831 149832 149833 149834 149835 149836 149837 149838 149839 149840 149841 149842 149843 149844 149845 149846 149847 149848 149849 149850 149851 149852 149853 149854 149855 149856 149857 149858 149859 149860 149861 149862 149863 149864 149865 149866 149867 149868 149869 149870 149871 149872 149873 149874 149875 149876 149877 149878 149879 149880 149881 149882 149883 149884 149885 149886 149887 149888 149889 149890 149891 149892 149893 149894 149895 149896 149897 149898 149899 149900 149901 149902 149903 149904 149905 149906 149907 149908 149909 149910 149911 149912 149913 149914 149915 149916 149917 149918 149919 149920 149921 149922 149923 149924 149925 149926 149927 149928 149929 149930 149931 149932 149933 149934 149935 149936 149937 149938 149939 149940 149941 149942 149943 149944 149945 149946 149947 149948 149949 149950 149951 149952 149953 149954 149955 149956 149957 149958 149959 149960 149961 149962 149963 149964 149965 149966 149967 149968 149969 149970 149971 149972 149973 149974 149975 149976 149977 149978 149979 149980 149981 149982 149983 149984 149985 149986 149987 149988 149989 149990 149991 149992 149993 149994 149995 149996 149997 149998 149999 150000 150001 150002 150003 150004 150005 150006 150007 150008 150009 150010 150011 150012 150013 150014 150015 150016 150017 150018 150019 150020 150021 150022 150023 150024 150025 150026 150027 150028 150029 150030 150031 150032 150033 150034 150035 150036 150037 150038 150039 150040 150041 150042 150043 150044 150045 150046 150047 150048 150049 150050 150051 150052 150053 150054 150055 150056 150057 150058 150059 150060 150061 150062 150063 150064 150065 150066 150067 150068 150069 150070 150071 150072 150073 150074 150075 150076 150077 150078 150079 150080 150081 150082 150083 150084 150085 150086 150087 150088 150089 150090 150091 150092 150093 150094 150095 150096 150097 150098 150099 150100 150101 150102 150103 150104 150105 150106 150107 150108 150109 150110 150111 150112 150113 150114 150115 150116 150117 150118 150119 150120 150121 150122 150123 150124 150125 150126 150127 150128 150129 150130 150131 150132 150133 150134 150135 150136 150137 150138 150139 150140 150141 150142 150143 150144 150145 150146 150147 150148 150149 150150 150151 150152 150153 150154 150155 150156 150157 150158 150159 150160 150161 150162 150163 150164 150165 150166 150167 150168 150169 150170 150171 150172 150173 150174 150175 150176 150177 150178 150179 150180 150181 150182 150183 150184 150185 150186 150187 150188 150189 150190 150191 150192 150193 150194 150195 150196 150197 150198 150199 150200 150201 150202 150203 150204 150205 150206 150207 150208 150209 150210 150211 150212 150213 150214 150215 150216 150217 150218 150219 150220 150221 150222 150223 150224 150225 150226 150227 150228 150229 150230 150231 150232 150233 150234 150235 150236 150237 150238 150239 150240 150241 150242 150243 150244 150245 150246 150247 150248 150249 150250 150251 150252 150253 150254 150255 150256 150257 150258 150259 150260 150261 150262 150263 150264 150265 150266 150267 150268 150269 150270 150271 150272 150273 150274 150275 150276 150277 150278 150279 150280 150281 150282 150283 150284 150285 150286 150287 150288 150289 150290 150291 150292 150293 150294 150295 150296 150297 150298 150299 150300 150301 150302 150303 150304 150305 150306 150307 150308 150309 150310 150311 150312 150313 150314 150315 150316 150317 150318 150319 150320 150321 150322 150323 150324 150325 150326 150327 150328 150329 150330 150331 150332 150333 150334 150335 150336 150337 150338 150339 150340 150341 150342 150343 150344 150345 150346 150347 | - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + - - + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | yytos = yypParser->yytos; yytos->stateno = yyNewState; yytos->major = yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } |
︙ | |||
149479 149480 149481 149482 149483 149484 149485 | 150365 150366 150367 150368 150369 150370 150371 150372 150373 150374 150375 150376 150377 150378 150379 150380 150381 150382 150383 150384 150385 150386 150387 150388 150389 150390 150391 150392 150393 150394 | - + - + | int yysize; /* Amount to pop the stack */ sqlite3ParserARG_FETCH (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ |
︙ | |||
149544 149545 149546 149547 149548 149549 149550 | 150430 150431 150432 150433 150434 150435 150436 150437 150438 150439 150440 150441 150442 150443 150444 150445 150446 150447 150448 150449 150450 150451 150452 | - + - + - + | case 1: /* explain ::= EXPLAIN QUERY PLAN */ { pParse->explain = 2; } break; case 2: /* cmdx ::= cmd */ { sqlite3FinishCoding(pParse); } break; case 3: /* cmd ::= BEGIN transtype trans_opt */ |
︙ | |||
149575 149576 149577 149578 149579 149580 149581 | 150461 150462 150463 150464 150465 150466 150467 150468 150469 150470 150471 150472 150473 150474 150475 150476 150477 150478 150479 150480 150481 150482 150483 150484 150485 150486 150487 150488 150489 150490 150491 150492 150493 150494 150495 150496 150497 150498 150499 150500 150501 150502 150503 150504 150505 150506 150507 150508 150509 150510 150511 150512 150513 150514 150515 | - + - + - + - + - + - - + + - + - + | case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */ { sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0); } break; case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ { |
︙ | |||
149644 149645 149646 149647 149648 149649 149650 | 150530 150531 150532 150533 150534 150535 150536 150537 150538 150539 150540 150541 150542 150543 150544 150545 150546 150547 150548 150549 150550 150551 150552 150553 150554 150555 150556 150557 150558 150559 150560 150561 150562 150563 150564 150565 150566 150567 150568 150569 150570 150571 150572 150573 150574 150575 150576 150577 150578 150579 150580 150581 150582 150583 150584 150585 150586 150587 150588 150589 150590 150591 150592 150593 150594 150595 150596 150597 150598 150599 150600 150601 150602 150603 150604 150605 150606 150607 150608 150609 150610 150611 150612 150613 150614 150615 150616 150617 150618 150619 150620 150621 150622 150623 150624 150625 150626 150627 150628 150629 150630 150631 150632 150633 150634 150635 150636 150637 150638 150639 150640 150641 150642 150643 150644 150645 150646 150647 150648 150649 150650 150651 150652 150653 150654 150655 150656 150657 150658 150659 150660 150661 150662 150663 150664 150665 150666 150667 150668 150669 150670 150671 150672 150673 150674 150675 150676 150677 150678 150679 150680 150681 150682 150683 150684 150685 150686 150687 150688 150689 150690 150691 150692 150693 150694 150695 150696 150697 150698 150699 150700 150701 150702 150703 150704 150705 150706 150707 150708 150709 150710 150711 150712 150713 150714 150715 150716 150717 150718 150719 150720 150721 150722 150723 150724 150725 150726 150727 150728 150729 150730 150731 150732 150733 150734 150735 150736 150737 150738 150739 150740 150741 150742 150743 150744 150745 150746 150747 150748 150749 150750 150751 150752 150753 150754 150755 150756 150757 150758 150759 150760 150761 150762 150763 150764 150765 150766 150767 150768 150769 150770 150771 150772 150773 150774 150775 150776 150777 150778 150779 150780 150781 150782 150783 150784 150785 150786 150787 150788 150789 150790 150791 150792 150793 150794 150795 150796 150797 150798 150799 150800 150801 150802 150803 150804 150805 150806 150807 150808 150809 150810 150811 150812 150813 150814 150815 150816 150817 150818 150819 150820 150821 150822 150823 150824 150825 150826 150827 150828 150829 150830 150831 150832 150833 150834 150835 150836 150837 150838 150839 150840 150841 150842 150843 150844 150845 150846 150847 150848 150849 150850 150851 150852 150853 150854 150855 150856 150857 150858 150859 150860 150861 150862 150863 150864 150865 150866 150867 150868 150869 150870 150871 150872 150873 150874 150875 150876 150877 150878 150879 150880 150881 150882 150883 150884 150885 150886 150887 150888 150889 150890 150891 150892 150893 150894 150895 150896 150897 150898 150899 150900 150901 150902 150903 150904 150905 150906 150907 150908 150909 150910 150911 150912 150913 150914 150915 150916 150917 150918 150919 150920 150921 150922 150923 150924 150925 150926 150927 150928 150929 150930 150931 150932 150933 150934 150935 150936 150937 150938 150939 150940 150941 150942 150943 150944 150945 150946 150947 150948 150949 150950 150951 150952 150953 150954 150955 150956 150957 150958 150959 150960 150961 150962 150963 150964 150965 150966 150967 150968 150969 150970 150971 150972 150973 150974 150975 150976 150977 150978 150979 150980 150981 150982 150983 150984 150985 150986 150987 150988 150989 150990 150991 150992 150993 150994 150995 150996 150997 150998 150999 151000 151001 151002 151003 151004 151005 151006 151007 151008 151009 151010 151011 151012 151013 151014 151015 151016 151017 151018 151019 151020 151021 151022 151023 151024 151025 151026 151027 151028 151029 151030 151031 151032 151033 151034 151035 151036 151037 151038 151039 151040 151041 151042 151043 151044 151045 151046 151047 151048 151049 151050 151051 151052 151053 151054 151055 151056 151057 151058 151059 151060 151061 151062 151063 151064 151065 151066 151067 151068 151069 151070 151071 151072 151073 151074 151075 151076 151077 151078 151079 151080 151081 151082 151083 151084 151085 151086 151087 151088 151089 151090 151091 151092 151093 151094 151095 151096 151097 151098 151099 151100 151101 151102 151103 151104 151105 151106 151107 151108 151109 151110 151111 151112 151113 151114 151115 151116 151117 151118 151119 151120 151121 151122 151123 151124 151125 151126 151127 151128 151129 151130 151131 151132 151133 151134 151135 151136 151137 151138 151139 151140 151141 151142 151143 151144 151145 151146 151147 151148 151149 151150 151151 151152 151153 151154 151155 151156 151157 151158 151159 151160 151161 151162 151163 151164 151165 151166 151167 151168 151169 151170 151171 151172 151173 151174 151175 151176 151177 151178 151179 151180 151181 151182 151183 151184 151185 151186 151187 151188 151189 151190 151191 151192 151193 151194 151195 151196 151197 151198 151199 151200 151201 151202 151203 151204 151205 151206 151207 151208 151209 151210 151211 151212 151213 151214 151215 151216 151217 151218 151219 151220 151221 151222 151223 151224 151225 151226 151227 151228 151229 151230 151231 151232 151233 151234 151235 151236 151237 151238 151239 151240 151241 151242 151243 151244 151245 151246 151247 151248 151249 151250 151251 151252 151253 151254 151255 151256 151257 151258 151259 151260 151261 151262 151263 151264 151265 151266 151267 151268 151269 151270 151271 151272 151273 151274 151275 151276 151277 151278 151279 151280 151281 151282 151283 151284 151285 151286 151287 151288 151289 151290 151291 151292 151293 151294 151295 151296 151297 151298 151299 151300 151301 151302 151303 151304 151305 151306 151307 151308 151309 151310 151311 151312 151313 151314 151315 151316 151317 151318 151319 151320 151321 151322 151323 151324 151325 151326 151327 151328 151329 151330 151331 151332 151333 151334 151335 151336 151337 151338 151339 151340 151341 151342 151343 151344 151345 151346 151347 151348 151349 151350 151351 151352 151353 151354 151355 151356 151357 151358 151359 151360 151361 151362 151363 151364 151365 151366 151367 151368 151369 151370 151371 151372 151373 151374 151375 151376 151377 151378 151379 151380 151381 151382 151383 151384 151385 151386 151387 151388 151389 151390 151391 151392 151393 151394 151395 151396 151397 151398 151399 151400 151401 151402 151403 151404 151405 151406 151407 151408 151409 151410 151411 151412 151413 151414 151415 151416 151417 151418 151419 151420 151421 151422 151423 151424 151425 151426 151427 151428 151429 151430 151431 151432 151433 151434 151435 151436 151437 151438 151439 151440 151441 151442 151443 151444 151445 151446 151447 151448 151449 151450 151451 151452 151453 151454 151455 151456 151457 151458 151459 151460 151461 151462 151463 151464 151465 151466 151467 151468 151469 151470 151471 151472 151473 151474 151475 151476 151477 151478 151479 151480 151481 151482 151483 151484 151485 151486 151487 151488 151489 151490 151491 151492 151493 151494 151495 151496 151497 151498 151499 151500 151501 151502 151503 151504 151505 151506 151507 151508 151509 151510 151511 151512 151513 151514 151515 151516 151517 151518 151519 151520 151521 151522 151523 151524 151525 151526 151527 151528 151529 151530 151531 151532 151533 151534 151535 151536 151537 151538 151539 151540 151541 151542 151543 151544 151545 151546 151547 151548 151549 151550 151551 151552 151553 151554 151555 151556 151557 151558 151559 151560 151561 151562 151563 151564 151565 151566 151567 151568 151569 151570 151571 151572 151573 151574 151575 151576 151577 151578 151579 151580 151581 151582 151583 151584 151585 151586 151587 151588 151589 151590 151591 151592 151593 151594 151595 151596 151597 151598 151599 151600 151601 151602 151603 151604 151605 151606 151607 151608 151609 151610 151611 151612 151613 151614 151615 151616 151617 151618 151619 151620 151621 151622 151623 151624 151625 151626 151627 151628 151629 151630 151631 151632 151633 151634 151635 151636 151637 151638 151639 151640 151641 151642 151643 151644 151645 151646 151647 151648 151649 151650 151651 151652 151653 151654 151655 151656 151657 151658 151659 151660 151661 151662 151663 151664 151665 151666 151667 151668 151669 151670 151671 151672 151673 151674 151675 151676 151677 151678 151679 151680 151681 151682 151683 151684 151685 151686 151687 151688 151689 151690 151691 151692 151693 151694 151695 151696 151697 151698 151699 151700 151701 151702 151703 151704 151705 151706 151707 151708 151709 151710 151711 151712 151713 151714 151715 151716 151717 151718 151719 151720 151721 151722 151723 151724 151725 151726 151727 151728 151729 151730 151731 151732 151733 151734 151735 151736 151737 151738 151739 151740 151741 151742 151743 151744 151745 151746 151747 151748 151749 151750 151751 151752 151753 151754 151755 151756 151757 151758 151759 151760 151761 151762 151763 151764 151765 151766 151767 151768 151769 151770 151771 151772 151773 151774 151775 151776 151777 151778 151779 151780 151781 151782 151783 151784 151785 151786 151787 151788 151789 151790 151791 151792 151793 151794 151795 151796 151797 151798 151799 151800 151801 151802 151803 151804 151805 151806 151807 151808 151809 151810 151811 151812 151813 151814 151815 151816 151817 151818 151819 151820 151821 151822 151823 151824 | - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - - - + + + - + - + - - + + - + - + - + - + - + - - - + + + - + - + - - + + - + - - + + - + - + - - + + - - + + - + - - - - - - - + + + + + + + + + + + + + - + - - - + + + - - + + - + - - + + - + - + - + - - + + - - + + - + - + - + - + + - + + - + - + - + - + - - + + - - + + - + - + - + - + - + - + - - + + - - - + + + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - + - + - + - - + + - + - - + + - + - + - + - - - - + + + + - + - - - - - + + + + + - - - - - - + + + + + + - + - + - - + + - - + + - + - + - + - - - - - + + + + + - + - + + - - - + + + + - - - + + + - + - - - - + + + + - + - + - - + + - - - + + + - + - - - - + + + + - - + + - - - - + + + + - - + + - - + + - - + + - + - + - + - + - - + + - - + + - + - + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - - + + + - - + + - - - - + + + + - - - + + + - + - - - + + + - + - - + + - + - + - + - - - + + + - + - + - + - - - + + + - - - + + + - + - - - + + + - + - - - + + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - - - + + + - + - + - + - + - - - + + + - + - - - + + + - + - + - - + + - + - + - + - - - - + + + + - - + + - - + + - + - + - + - + - + - + - + - + - - + + - - + + - - - - + + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - + - - - + + + - + - + - - - - + + + + - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + | break; case 27: /* typename ::= typename ID|STRING */ {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} break; case 28: /* scanpt ::= */ { assert( yyLookahead!=YYNOCODE ); |
︙ | |||
152091 152092 152093 152094 152095 152096 152097 | 152987 152988 152989 152990 152991 152992 152993 152994 152995 152996 152997 152998 152999 153000 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | } } while( IdChar(z[i]) ){ i++; } *tokenType = TK_ID; return i; } |
︙ | |||
152185 152186 152187 152188 152189 152190 152191 | 153014 153015 153016 153017 153018 153019 153020 153021 153022 153023 153024 153025 153026 153027 153028 153029 153030 153031 153032 153033 153034 153035 | + + + - + + + + + | mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH]; if( db->nVdbeActive==0 ){ db->u1.isInterrupted = 0; } pParse->rc = SQLITE_OK; pParse->zTail = zSql; assert( pzErrMsg!=0 ); #ifdef SQLITE_DEBUG if( db->flags & SQLITE_ParserTrace ){ printf("parser: [[[%s]]]\n", zSql); |
︙ | |||
152328 152329 152330 152331 152332 152333 152334 152335 152336 152337 152338 152339 152340 152341 | 153164 153165 153166 153167 153168 153169 153170 153171 153172 153173 153174 153175 153176 153177 153178 153179 153180 153181 153182 153183 153184 153185 153186 153187 153188 153189 153190 153191 153192 153193 153194 153195 153196 153197 153198 153199 153200 153201 153202 153203 153204 153205 153206 153207 153208 153209 153210 153211 153212 153213 153214 153215 153216 153217 153218 153219 153220 153221 153222 153223 153224 153225 153226 153227 153228 153229 153230 153231 153232 153233 153234 153235 153236 153237 153238 153239 153240 153241 153242 153243 153244 153245 153246 153247 153248 153249 153250 153251 153252 153253 153254 153255 153256 153257 153258 153259 153260 153261 153262 153263 153264 153265 153266 153267 153268 153269 153270 153271 153272 153273 153274 153275 153276 153277 153278 153279 153280 153281 153282 153283 153284 153285 153286 153287 153288 153289 153290 153291 153292 153293 153294 153295 153296 153297 153298 153299 153300 153301 153302 153303 153304 153305 153306 153307 153308 153309 153310 153311 153312 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | pParse->pZombieTab = p->pNextZombie; sqlite3DeleteTable(db, p); } assert( nErr==0 || pParse->rc!=SQLITE_OK ); return nErr; } #ifdef SQLITE_ENABLE_NORMALIZE /* ** Insert a single space character into pStr if the current string ** ends with an identifier */ static void addSpaceSeparator(sqlite3_str *pStr){ if( pStr->nChar && sqlite3IsIdChar(pStr->zText[pStr->nChar-1]) ){ sqlite3_str_append(pStr, " ", 1); } } /* ** Compute a normalization of the SQL given by zSql[0..nSql-1]. Return ** the normalization in space obtained from sqlite3DbMalloc(). Or return ** NULL if anything goes wrong or if zSql is NULL. */ SQLITE_PRIVATE char *sqlite3Normalize( Vdbe *pVdbe, /* VM being reprepared */ const char *zSql /* The original SQL string */ ){ sqlite3 *db; /* The database connection */ int i; /* Next unread byte of zSql[] */ int n; /* length of current token */ int tokenType; /* type of current token */ int prevType = 0; /* Previous non-whitespace token */ int nParen; /* Number of nested levels of parentheses */ int iStartIN; /* Start of RHS of IN operator in z[] */ int nParenAtIN; /* Value of nParent at start of RHS of IN operator */ int j; /* Bytes of normalized SQL generated so far */ sqlite3_str *pStr; /* The normalized SQL string under construction */ db = sqlite3VdbeDb(pVdbe); tokenType = -1; nParen = iStartIN = nParenAtIN = 0; pStr = sqlite3_str_new(db); assert( pStr!=0 ); /* sqlite3_str_new() never returns NULL */ for(i=0; zSql[i] && pStr->accError==0; i+=n){ if( tokenType!=TK_SPACE ){ prevType = tokenType; } n = sqlite3GetToken((unsigned char*)zSql+i, &tokenType); if( NEVER(n<=0) ) break; switch( tokenType ){ case TK_SPACE: { break; } case TK_NULL: { if( prevType==TK_IS || prevType==TK_NOT ){ sqlite3_str_append(pStr, " NULL", 5); break; } /* Fall through */ } case TK_STRING: case TK_INTEGER: case TK_FLOAT: case TK_VARIABLE: case TK_BLOB: { sqlite3_str_append(pStr, "?", 1); break; } case TK_LP: { nParen++; if( prevType==TK_IN ){ iStartIN = pStr->nChar; nParenAtIN = nParen; } sqlite3_str_append(pStr, "(", 1); break; } case TK_RP: { if( iStartIN>0 && nParen==nParenAtIN ){ assert( pStr->nChar>=iStartIN ); pStr->nChar = iStartIN+1; sqlite3_str_append(pStr, "?,?,?", 5); iStartIN = 0; } nParen--; sqlite3_str_append(pStr, ")", 1); break; } case TK_ID: { iStartIN = 0; j = pStr->nChar; if( sqlite3Isquote(zSql[i]) ){ char *zId = sqlite3DbStrNDup(db, zSql+i, n); int nId; int eType = 0; if( zId==0 ) break; sqlite3Dequote(zId); if( zSql[i]=='"' && sqlite3VdbeUsesDoubleQuotedString(pVdbe, zId) ){ sqlite3_str_append(pStr, "?", 1); sqlite3DbFree(db, zId); break; } nId = sqlite3Strlen30(zId); if( sqlite3GetToken((u8*)zId, &eType)==nId && eType==TK_ID ){ addSpaceSeparator(pStr); sqlite3_str_append(pStr, zId, nId); }else{ sqlite3_str_appendf(pStr, "\"%w\"", zId); } sqlite3DbFree(db, zId); }else{ addSpaceSeparator(pStr); sqlite3_str_append(pStr, zSql+i, n); } while( j<pStr->nChar ){ pStr->zText[j] = sqlite3Tolower(pStr->zText[j]); j++; } break; } case TK_SELECT: { iStartIN = 0; /* fall through */ } default: { if( sqlite3IsIdChar(zSql[i]) ) addSpaceSeparator(pStr); j = pStr->nChar; sqlite3_str_append(pStr, zSql+i, n); while( j<pStr->nChar ){ pStr->zText[j] = sqlite3Toupper(pStr->zText[j]); j++; } break; } } } if( tokenType!=TK_SEMI ) sqlite3_str_append(pStr, ";", 1); return sqlite3_str_finish(pStr); } #endif /* SQLITE_ENABLE_NORMALIZE */ /************** End of tokenize.c ********************************************/ /************** Begin file complete.c ****************************************/ /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: |
︙ | |||
153373 153374 153375 153376 153377 153378 153379 153380 153381 153382 153383 153384 153385 153386 | 154344 154345 154346 154347 154348 154349 154350 154351 154352 154353 154354 154355 154356 154357 154358 154359 154360 154361 154362 154363 154364 | + + + + + + + | iVal = SQLITE_DEFAULT_SORTERREF_SIZE; } sqlite3GlobalConfig.szSorterRef = (u32)iVal; break; } #endif /* SQLITE_ENABLE_SORTER_REFERENCES */ #ifdef SQLITE_ENABLE_DESERIALIZE case SQLITE_CONFIG_MEMDB_MAXSIZE: { sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64); break; } #endif /* SQLITE_ENABLE_DESERIALIZE */ default: { rc = SQLITE_ERROR; break; } } va_end(ap); return rc; |
︙ | |||
153563 153564 153565 153566 153567 153568 153569 | 154541 154542 154543 154544 154545 154546 154547 154548 154549 154550 154551 154552 154553 154554 154555 154556 154557 154558 154559 | - + - + | }; unsigned int i; rc = SQLITE_ERROR; /* IMP: R-42790-23372 */ for(i=0; i<ArraySize(aFlagOp); i++){ if( aFlagOp[i].op==op ){ int onoff = va_arg(ap, int); int *pRes = va_arg(ap, int*); |
︙ | |||
154030 154031 154032 154033 154034 154035 154036 | 155008 155009 155010 155011 155012 155013 155014 155015 155016 155017 155018 155019 155020 155021 155022 | - + | sqlite3ResetAllSchemasOfConnection(db); } sqlite3BtreeLeaveAll(db); /* Any deferred constraint violations have now been resolved. */ db->nDeferredCons = 0; db->nDeferredImmCons = 0; |
︙ | |||
154772 154773 154774 154775 154776 154777 154778 154779 154780 154781 154782 154783 154784 154785 | 155750 155751 155752 155753 155754 155755 155756 155757 155758 155759 155760 155761 155762 155763 155764 155765 | + + | return 0; } #endif sqlite3_mutex_enter(db->mutex); pOld = db->pProfileArg; db->xProfile = xProfile; db->pProfileArg = pArg; db->mTrace &= SQLITE_TRACE_NONLEGACY_MASK; if( db->xProfile ) db->mTrace |= SQLITE_TRACE_XPROFILE; sqlite3_mutex_leave(db->mutex); return pOld; } #endif /* SQLITE_OMIT_DEPRECATED */ #endif /* SQLITE_OMIT_TRACE */ /* |
︙ | |||
155123 155124 155125 155126 155127 155128 155129 | 156103 156104 156105 156106 156107 156108 156109 156110 156111 156112 156113 156114 156115 156116 156117 | - + | return sqlite3ErrStr(SQLITE_MISUSE_BKPT); } sqlite3_mutex_enter(db->mutex); if( db->mallocFailed ){ z = sqlite3ErrStr(SQLITE_NOMEM_BKPT); }else{ testcase( db->pErr==0 ); |
︙ | |||
155653 155654 155655 155656 155657 155658 155659 155660 155661 155662 155663 155664 155665 155666 | 156633 156634 156635 156636 156637 156638 156639 156640 156641 156642 156643 156644 156645 156646 156647 156648 156649 156650 156651 156652 156653 156654 156655 156656 156657 156658 156659 156660 156661 156662 156663 156664 156665 156666 156667 156668 156669 156670 156671 156672 156673 156674 156675 156676 156677 156678 156679 156680 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | zFile = 0; } *pFlags = flags; *pzFile = zFile; return rc; } #if defined(SQLITE_HAS_CODEC) /* ** Process URI filename query parameters relevant to the SQLite Encryption ** Extension. Return true if any of the relevant query parameters are ** seen and return false if not. */ SQLITE_PRIVATE int sqlite3CodecQueryParameters( sqlite3 *db, /* Database connection */ const char *zDb, /* Which schema is being created/attached */ const char *zUri /* URI filename */ ){ const char *zKey; if( (zKey = sqlite3_uri_parameter(zUri, "hexkey"))!=0 && zKey[0] ){ u8 iByte; int i; char zDecoded[40]; for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){ iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]); if( (i&1)!=0 ) zDecoded[i/2] = iByte; } sqlite3_key_v2(db, zDb, zDecoded, i/2); return 1; }else if( (zKey = sqlite3_uri_parameter(zUri, "key"))!=0 ){ sqlite3_key_v2(db, zDb, zKey, sqlite3Strlen30(zKey)); return 1; }else if( (zKey = sqlite3_uri_parameter(zUri, "textkey"))!=0 ){ sqlite3_key_v2(db, zDb, zKey, -1); return 1; }else{ return 0; } } #endif /* ** This routine does the work of opening a database on behalf of ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename" ** is UTF-8 encoded. */ static int openDatabase( |
︙ | |||
155998 155999 156000 156001 156002 156003 156004 | 157012 157013 157014 157015 157016 157017 157018 157019 157020 157021 157022 157023 157024 157025 157026 157027 157028 157029 157030 157031 | - + - - - - - - - - - - - - - - + | if( sqlite3GlobalConfig.xSqllog ){ /* Opening a db handle. Fourth parameter is passed 0. */ void *pArg = sqlite3GlobalConfig.pSqllogArg; sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0); } #endif #if defined(SQLITE_HAS_CODEC) |
︙ | |||
158078 158079 158080 158081 158082 158083 158084 158085 158086 158087 158088 158089 158090 158091 | 159079 159080 159081 159082 159083 159084 159085 159086 159087 159088 159089 159090 159091 159092 159093 159094 | + + | /* ** Maximum length of a varint encoded integer. The varint format is different ** from that used by SQLite, so the maximum length is 10, not 9. */ #define FTS3_VARINT_MAX 10 #define FTS3_BUFFER_PADDING 8 /* ** FTS4 virtual tables may maintain multiple indexes - one index of all terms ** in the document set and zero or more prefix indexes. All indexes are stored ** as one or more b+-trees in the %_segments and %_segdir tables. ** ** It is possible to determine which index a b+-tree belongs to based on the ** value stored in the "%_segdir.level" column. Given this value L, the index |
︙ | |||
158110 158111 158112 158113 158114 158115 158116 158117 158118 158119 158120 158121 158122 158123 | 159113 159114 159115 159116 159117 159118 159119 159120 159121 159122 159123 159124 159125 159126 159127 159128 159129 159130 159131 159132 159133 159134 159135 159136 159137 159138 | + + + + + + + + + + + + | /* ** Terminator values for position-lists and column-lists. */ #define POS_COLUMN (1) /* Column-list terminator */ #define POS_END (0) /* Position-list terminator */ /* ** The assert_fts3_nc() macro is similar to the assert() macro, except that it ** is used for assert() conditions that are true only if it can be ** guranteed that the database is not corrupt. */ #if defined(SQLITE_DEBUG) || defined(SQLITE_TEST) SQLITE_API extern int sqlite3_fts3_may_be_corrupt; # define assert_fts3_nc(x) assert(sqlite3_fts3_may_be_corrupt || (x)) #else # define assert_fts3_nc(x) assert(x) #endif /* ** This section provides definitions to allow the ** FTS3 extension to be compiled outside of the ** amalgamation. */ #ifndef SQLITE_AMALGAMATION /* |
︙ | |||
158634 158635 158636 158637 158638 158639 158640 158641 158642 158643 158644 158645 158646 158647 158648 158649 158650 158651 158652 158653 158654 158655 158656 158657 158658 | 159649 159650 159651 159652 159653 159654 159655 159656 159657 159658 159659 159660 159661 159662 159663 159664 159665 159666 159667 159668 159669 159670 159671 159672 159673 159674 159675 159676 159677 159678 159679 159680 159681 159682 159683 159684 159685 159686 159687 159688 159689 | + + + + + + + + - + | #ifndef SQLITE_AMALGAMATION # if defined(SQLITE_DEBUG) SQLITE_PRIVATE int sqlite3Fts3Always(int b) { assert( b ); return b; } SQLITE_PRIVATE int sqlite3Fts3Never(int b) { assert( !b ); return b; } # endif #endif /* ** This variable is set to false when running tests for which the on disk ** structures should not be corrupt. Otherwise, true. If it is false, extra ** assert() conditions in the fts3 code are activated - conditions that are ** only true if it is guaranteed that the fts3 database is not corrupt. */ SQLITE_API int sqlite3_fts3_may_be_corrupt = 1; /* ** Write a 64-bit variable-length integer to memory starting at p[0]. ** The length of data written will be between 1 and FTS3_VARINT_MAX bytes. ** The number of bytes written is returned. */ SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *p, sqlite_int64 v){ unsigned char *q = (unsigned char *) p; sqlite_uint64 vu = v; do{ *q++ = (unsigned char) ((vu & 0x7f) | 0x80); vu >>= 7; }while( vu!=0 ); q[-1] &= 0x7f; /* turn off high bit in final byte */ assert( q - (unsigned char *)p <= FTS3_VARINT_MAX ); return (int) (q - (unsigned char *)p); } #define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \ |
︙ | |||
158690 158691 158692 158693 158694 158695 158696 158697 158698 158699 | 159713 159714 159715 159716 159717 159718 159719 159720 159721 159722 159723 159724 159725 159726 159727 159728 159729 159730 159731 159732 159733 159734 159735 159736 159737 159738 159739 159740 159741 | + - + - + - - - + + + - + | } /* ** Similar to sqlite3Fts3GetVarint(), except that the output is truncated to ** a non-negative 32-bit integer before it is returned. */ SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){ const unsigned char *ptr = (const unsigned char*)p; u32 a; #ifndef fts3GetVarint32 |
︙ | |||
158874 158875 158876 158877 158878 158879 158880 | 159898 159899 159900 159901 159902 159903 159904 159905 159906 159907 159908 159909 159910 159911 159912 159913 159914 159915 159916 159917 159918 159919 159920 159921 159922 159923 | - - + - - - - - + + + + + + + + + + + | static int fts3DestroyMethod(sqlite3_vtab *pVtab){ Fts3Table *p = (Fts3Table *)pVtab; int rc = SQLITE_OK; /* Return code */ const char *zDb = p->zDb; /* Name of database (e.g. "main", "temp") */ sqlite3 *db = p->db; /* Database handle */ /* Drop the shadow tables */ |
︙ | |||
159112 159113 159114 159115 159116 159117 159118 | 160141 160142 160143 160144 160145 160146 160147 160148 160149 160150 160151 160152 160153 160154 160155 160156 160157 160158 | - + - + | ** fts3QuoteId("un \"zip\"") -> "un \"\"zip\"\"" ** ** The pointer returned points to memory obtained from sqlite3_malloc(). It ** is the callers responsibility to call sqlite3_free() to release this ** memory. */ static char *fts3QuoteId(char const *zInput){ |
︙ | |||
159296 159297 159298 159299 159300 159301 159302 | 160325 160326 160327 160328 160329 160330 160331 160332 160333 160334 160335 160336 160337 160338 160339 | - + | const char *p; nIndex++; for(p=zParam; *p; p++){ if( *p==',' ) nIndex++; } } |
︙ | |||
159375 159376 159377 159378 159379 159380 159381 | 160404 160405 160406 160407 160408 160409 160410 160411 160412 160413 160414 160415 160416 160417 160418 160419 160420 160421 160422 160423 160424 160425 160426 160427 160428 160429 160430 160431 160432 | - + - + - + | sqlite3Fts3ErrMsg(pzErr, "%s", sqlite3_errmsg(db)); } } sqlite3_free(zSql); if( rc==SQLITE_OK ){ const char **azCol; /* Output array */ |
︙ | |||
159437 159438 159439 159440 159441 159442 159443 | 160466 160467 160468 160469 160470 160471 160472 160473 160474 160475 160476 160477 160478 160479 160480 | - + | sqlite3_vtab **ppVTab, /* Write the resulting vtab structure here */ char **pzErr /* Write any error message here */ ){ Fts3Hash *pHash = (Fts3Hash *)pAux; Fts3Table *p = 0; /* Pointer to allocated vtab */ int rc = SQLITE_OK; /* Return code */ int i; /* Iterator variable */ |
︙ | |||
159471 159472 159473 159474 159475 159476 159477 | 160500 160501 160502 160503 160504 160505 160506 160507 160508 160509 160510 160511 160512 160513 160514 160515 160516 160517 | - + - + | || (sqlite3_strnicmp(argv[0], "fts3", 4)==0 && !isFts4) ); nDb = (int)strlen(argv[1]) + 1; nName = (int)strlen(argv[2]) + 1; nByte = sizeof(const char *) * (argc-2); |
︙ | |||
159669 159670 159671 159672 159673 159674 159675 | 160698 160699 160700 160701 160702 160703 160704 160705 160706 160707 160708 160709 160710 160711 160712 | - + | nByte = sizeof(Fts3Table) + /* Fts3Table */ nCol * sizeof(char *) + /* azColumn */ nIndex * sizeof(struct Fts3Index) + /* aIndex */ nCol * sizeof(u8) + /* abNotindexed */ nName + /* zName */ nDb + /* zDb */ nString; /* Space for azColumn strings */ |
︙ | |||
160448 160449 160450 160451 160452 160453 160454 | 161477 161478 161479 161480 161481 161482 161483 161484 161485 161486 161487 161488 161489 161490 161491 161492 161493 161494 161495 161496 161497 161498 161499 161500 161501 161502 161503 161504 161505 161506 161507 161508 161509 161510 161511 161512 161513 161514 | - + - + + + + - + + + + | /* ** Compute the union of two position lists. The output written ** into *pp contains all positions of both *pp1 and *pp2 in sorted ** order and with any duplicates removed. All pointers are ** updated appropriately. The caller is responsible for insuring ** that there is enough space in *pp to hold the complete output. */ |
︙ | |||
160513 160514 160515 160516 160517 160518 160519 160520 160521 160522 160523 160524 160525 160526 | 161548 161549 161550 161551 161552 161553 161554 161555 161556 161557 161558 161559 161560 161561 161562 | + | } } *p++ = POS_END; *pp = p; *pp1 = p1 + 1; *pp2 = p2 + 1; return SQLITE_OK; } /* ** This function is used to merge two position lists into one. When it is ** called, *pp1 and *pp2 must both point to position lists. A position-list is ** the part of a doclist that follows each document id. For example, if a row ** contains: |
︙ | |||
160577 160578 160579 160580 160581 160582 160583 | 161613 161614 161615 161616 161617 161618 161619 161620 161621 161622 161623 161624 161625 161626 161627 161628 161629 | - - + | sqlite3_int64 iPos2 = 0; if( iCol1 ){ *p++ = POS_COLUMN; p += sqlite3Fts3PutVarint(p, iCol1); } |
︙ | |||
160806 160807 160808 160809 160810 160811 160812 160813 160814 160815 160816 160817 160818 160819 | 161841 161842 161843 161844 161845 161846 161847 161848 161849 161850 161851 161852 161853 161854 161855 | + | */ static int fts3DoclistOrMerge( int bDescDoclist, /* True if arguments are desc */ char *a1, int n1, /* First doclist */ char *a2, int n2, /* Second doclist */ char **paOut, int *pnOut /* OUT: Malloc'd doclist */ ){ int rc = SQLITE_OK; sqlite3_int64 i1 = 0; sqlite3_int64 i2 = 0; sqlite3_int64 iPrev = 0; char *pEnd1 = &a1[n1]; char *pEnd2 = &a2[n2]; char *p1 = a1; char *p2 = a2; |
︙ | |||
160849 160850 160851 160852 160853 160854 160855 | 161885 161886 161887 161888 161889 161890 161891 161892 161893 161894 161895 161896 161897 161898 161899 161900 161901 161902 161903 161904 161905 161906 161907 161908 161909 161910 161911 161912 161913 161914 161915 161916 161917 161918 161919 161920 161921 161922 161923 161924 161925 161926 161927 161928 161929 161930 161931 161932 161933 161934 | - + - + + + + + + + + + - - + | ** The space required to store the output is therefore the sum of the ** sizes of the two inputs, plus enough space for exactly one of the input ** docids to grow. ** ** A symetric argument may be made if the doclists are in descending ** order. */ |
︙ | |||
160912 160913 160914 160915 160916 160917 160918 | 161955 161956 161957 161958 161959 161960 161961 161962 161963 161964 161965 161966 161967 161968 161969 | - + | char *p2 = aRight; char *p; int bFirstOut = 0; char *aOut; assert( nDist>0 ); if( bDescDoclist ){ |
︙ | |||
161096 161097 161098 161099 161100 161101 161102 161103 161104 161105 161106 161107 161108 161109 | 162139 162140 162141 162142 162143 162144 162145 162146 162147 162148 162149 162150 162151 162152 162153 | + | ** ** Similar padding is added in the fts3DoclistOrMerge() function. */ pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1); pTS->anOutput[0] = nDoclist; if( pTS->aaOutput[0] ){ memcpy(pTS->aaOutput[0], aDoclist, nDoclist); memset(&pTS->aaOutput[0][nDoclist], 0, FTS3_VARINT_MAX); }else{ return SQLITE_NOMEM; } }else{ char *aMerge = aDoclist; int nMerge = nDoclist; int iOut; |
︙ | |||
161147 161148 161149 161150 161151 161152 161153 | 162191 162192 162193 162194 162195 162196 162197 162198 162199 162200 162201 162202 162203 162204 162205 162206 | - - + + | */ static int fts3SegReaderCursorAppend( Fts3MultiSegReader *pCsr, Fts3SegReader *pNew ){ if( (pCsr->nSegment%16)==0 ){ Fts3SegReader **apNew; |
︙ | |||
161212 161213 161214 161215 161216 161217 161218 | 162256 162257 162258 162259 162260 162261 162262 162263 162264 162265 162266 162267 162268 162269 162270 | - + | sqlite3_int64 iLeavesEndBlock = sqlite3_column_int64(pStmt, 2); sqlite3_int64 iEndBlock = sqlite3_column_int64(pStmt, 3); int nRoot = sqlite3_column_bytes(pStmt, 4); char const *zRoot = sqlite3_column_blob(pStmt, 4); /* If zTerm is not NULL, and this segment is not stored entirely on its ** root node, the range of leaves scanned can be reduced. Do this. */ |
︙ | |||
162154 162155 162156 162157 162158 162159 162160 | 163198 163199 163200 163201 163202 163203 163204 163205 163206 163207 163208 163209 163210 163211 | - | ** ** Discard the contents of the pending terms table. */ static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){ Fts3Table *p = (Fts3Table*)pVtab; UNUSED_PARAMETER(iSavepoint); assert( p->inTransaction ); |
︙ | |||
162929 162930 162931 162932 162933 162934 162935 | 163972 163973 163974 163975 163976 163977 163978 163979 163980 163981 163982 163983 163984 163985 163986 163987 163988 163989 | - + + | } } /* Check if the current entries really are a phrase match */ if( bEof==0 ){ int nList = 0; int nByte = a[p->nToken-1].nList; |
︙ | |||
163322 163323 163324 163325 163326 163327 163328 | 164366 164367 164368 164369 164370 164371 164372 164373 164374 164375 164376 164377 164378 164379 164380 | - + | fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc); /* Determine which, if any, tokens in the expression should be deferred. */ #ifndef SQLITE_DISABLE_FTS4_DEFERRED if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){ Fts3TokenAndCost *aTC; Fts3Expr **apOr; |
︙ | |||
163633 163634 163635 163636 163637 163638 163639 | 164677 164678 164679 164680 164681 164682 164683 164684 164685 164686 164687 164688 164689 164690 164691 164692 164693 164694 164695 164696 164697 164698 164699 164700 | - + - + | ** no exceptions to this - it's the way the parser in fts3_expr.c works. */ if( *pRc==SQLITE_OK && pExpr->eType==FTSQUERY_NEAR && (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR) ){ Fts3Expr *p; |
︙ | |||
163912 163913 163914 163915 163916 163917 163918 | 164956 164957 164958 164959 164960 164961 164962 164963 164964 164965 164966 164967 164968 164969 164970 164971 164972 164973 164974 164975 164976 164977 164978 164979 164980 164981 164982 164983 164984 164985 164986 164987 164988 164989 164990 164991 164992 164993 164994 164995 164996 164997 | - + - - + - + - - + + | ** After allocating the Fts3Expr.aMI[] array for each phrase in the ** expression rooted at pExpr, the cursor iterates through all rows matched ** by pExpr, calling this function for each row. This function increments ** the values in Fts3Expr.aMI[] according to the position-list currently ** found in Fts3Expr.pPhrase->doclist.pList for each of the phrase ** expression nodes. */ |
︙ | |||
163984 163985 163986 163987 163988 163989 163990 | 165027 165028 165029 165030 165031 165032 165033 165034 165035 165036 165037 165038 165039 165040 165041 | - + | bEof = pRoot->bEof; assert( pRoot->bStart ); /* Allocate space for the aMSI[] array of each FTSQUERY_PHRASE node */ for(p=pRoot; p; p=p->pLeft){ Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight); assert( pE->aMI==0 ); |
︙ | |||
164010 164011 164012 164013 164014 164015 164016 | 165053 165054 165055 165056 165057 165058 165059 165060 165061 165062 165063 165064 165065 165066 165067 | - + | pCsr->iPrevId = pRoot->iDocid; }while( pCsr->isEof==0 && pRoot->eType==FTSQUERY_NEAR && sqlite3Fts3EvalTestDeferred(pCsr, &rc) ); if( rc==SQLITE_OK && pCsr->isEof==0 ){ |
︙ | |||
164360 164361 164362 164363 164364 164365 164366 | 165403 165404 165405 165406 165407 165408 165409 165410 165411 165412 165413 165414 165415 165416 165417 | - + | sqlite3_vtab **ppVtab, /* OUT: New sqlite3_vtab object */ char **pzErr /* OUT: sqlite3_malloc'd error message */ ){ char const *zDb; /* Name of database (e.g. "main") */ char const *zFts3; /* Name of fts3 table */ int nDb; /* Result of strlen(zDb) */ int nFts3; /* Result of strlen(zFts3) */ |
︙ | |||
164392 164393 164394 164395 164396 164397 164398 | 165435 165436 165437 165438 165439 165440 165441 165442 165443 165444 165445 165446 165447 165448 165449 | - + | } nFts3 = (int)strlen(zFts3); rc = sqlite3_declare_vtab(db, FTS3_AUX_SCHEMA); if( rc!=SQLITE_OK ) return rc; nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2; |
︙ | |||
164542 164543 164544 164545 164546 164547 164548 | 165585 165586 165587 165588 165589 165590 165591 165592 165593 165594 165595 165596 165597 165598 165599 | - + | sqlite3_free(pCsr); return SQLITE_OK; } static int fts3auxGrowStatArray(Fts3auxCursor *pCsr, int nSize){ if( nSize>pCsr->nStat ){ struct Fts3auxColstats *aNew; |
︙ | |||
164710 164711 164712 164713 164714 164715 164716 | 165753 165754 165755 165756 165757 165758 165759 165760 165761 165762 165763 165764 165765 165766 165767 165768 165769 165770 165771 165772 165773 165774 165775 | - + - + | if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN; if( iEq>=0 || iGe>=0 ){ const unsigned char *zStr = sqlite3_value_text(apVal[0]); assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) ); if( zStr ){ pCsr->filter.zTerm = sqlite3_mprintf("%s", zStr); |
︙ | |||
164970 164971 164972 164973 164974 164975 164976 | 166013 166014 166015 166016 166017 166018 166019 166020 166021 166022 166023 166024 166025 166026 166027 166028 | - - + + | } /* ** Allocate nByte bytes of memory using sqlite3_malloc(). If successful, ** zero the memory before returning a pointer to it. If unsuccessful, ** return NULL. */ |
︙ | |||
165046 165047 165048 165049 165050 165051 165052 | 166089 166090 166091 166092 166093 166094 166095 166096 166097 166098 166099 166100 166101 166102 166103 | - + | } *pnConsumed = i; rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, i, &pCursor); if( rc==SQLITE_OK ){ const char *zToken; int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0; |
︙ | |||
165100 165101 165102 165103 165104 165105 165106 | 166143 166144 166145 166146 166147 166148 166149 166150 166151 166152 166153 166154 166155 166156 166157 166158 | - - + + | } /* ** Enlarge a memory allocation. If an out-of-memory allocation occurs, ** then free the old allocation. */ |
︙ | |||
165345 165346 165347 165348 165349 165350 165351 | 166388 166389 166390 166391 166392 166393 166394 166395 166396 166397 166398 166399 166400 166401 | - | } if( sqlite3_fts3_enable_parentheses ){ if( *zInput=='(' ){ int nConsumed = 0; pParse->nNest++; rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed); |
︙ | |||
165644 165645 165646 165647 165648 165649 165650 | 166686 166687 166688 166689 166690 166691 166692 166693 166694 166695 166696 166697 166698 166699 166700 | - + | if( nMaxDepth==0 ){ rc = SQLITE_ERROR; } if( rc==SQLITE_OK ){ if( (eType==FTSQUERY_AND || eType==FTSQUERY_OR) ){ Fts3Expr **apLeaf; |
︙ | |||
166064 166065 166066 166067 166068 166069 166070 | 167106 167107 167108 167109 167110 167111 167112 167113 167114 167115 167116 167117 167118 167119 167120 | - + | sqlite3_free(zErr); return; } zExpr = (const char *)sqlite3_value_text(argv[1]); nExpr = sqlite3_value_bytes(argv[1]); nCol = argc-2; |
︙ | |||
166178 166179 166180 166181 166182 166183 166184 | 167220 167221 167222 167223 167224 167225 167226 167227 167228 167229 167230 167231 167232 167233 167234 167235 | - - + + | /* #include <string.h> */ /* #include "fts3_hash.h" */ /* ** Malloc and Free functions */ |
︙ | |||
168072 168073 168074 168075 168076 168077 168078 | 169114 169115 169116 169117 169118 169119 169120 169121 169122 169123 169124 169125 169126 169127 169128 | - + | int nByte = 0; char **azDequote; for(i=0; i<argc; i++){ nByte += (int)(strlen(argv[i]) + 1); } |
︙ | |||
168804 168805 168806 168807 168808 168809 168810 168811 168812 168813 168814 168815 168816 168817 168818 168819 168820 168821 | 169846 169847 169848 169849 169850 169851 169852 169853 169854 169855 169856 169857 169858 169859 169860 169861 169862 169863 169864 169865 169866 169867 169868 169869 169870 169871 169872 169873 | + + - + - | sqlite3_stmt *pStmt; assert( SizeofArray(azSql)==SizeofArray(p->aStmt) ); assert( eStmt<SizeofArray(azSql) && eStmt>=0 ); pStmt = p->aStmt[eStmt]; if( !pStmt ){ int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB; char *zSql; if( eStmt==SQL_CONTENT_INSERT ){ zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist); }else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){ f &= ~SQLITE_PREPARE_NO_VTAB; zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist); }else{ zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName); } if( !zSql ){ rc = SQLITE_NOMEM; }else{ |
︙ | |||
168974 168975 168976 168977 168978 168979 168980 | 170017 170018 170019 170020 170021 170022 170023 170024 170025 170026 170027 170028 170029 170030 170031 | - + | static sqlite3_int64 getAbsoluteLevel( Fts3Table *p, /* FTS3 table handle */ int iLangid, /* Language id */ int iIndex, /* Index in p->aIndex[] */ int iLevel /* Level of segments */ ){ sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */ |
︙ | |||
169816 169817 169818 169819 169820 169821 169822 | 170859 170860 170861 170862 170863 170864 170865 170866 170867 170868 170869 170870 170871 170872 170873 | - + | pReader->aDoclist = pNext; pReader->pOffsetList = 0; /* Check that the doclist does not appear to extend past the end of the ** b-tree node. And that the final byte of the doclist is 0x00. If either ** of these statements is untrue, then the data structure is corrupt. */ |
︙ | |||
170016 170017 170018 170019 170020 170021 170022 | 171059 171060 171061 171062 171063 171064 171065 171066 171067 171068 171069 171070 171071 171072 171073 171074 171075 171076 171077 171078 171079 171080 171081 171082 171083 171084 171085 171086 171087 171088 171089 171090 171091 171092 171093 171094 171095 171096 171097 171098 171099 | + + + + - + + - + | const char *zRoot, /* Buffer containing root node */ int nRoot, /* Size of buffer containing root node */ Fts3SegReader **ppReader /* OUT: Allocated Fts3SegReader */ ){ Fts3SegReader *pReader; /* Newly allocated SegReader object */ int nExtra = 0; /* Bytes to allocate segment root node */ assert( zRoot!=0 || nRoot==0 ); #ifdef CORRUPT_DB assert( zRoot!=0 || CORRUPT_DB ); #endif |
︙ | |||
170656 170657 170658 170659 170660 170661 170662 170663 170664 170665 170666 170667 170668 170669 | 171704 171705 171706 171707 171708 171709 171710 171711 171712 171713 171714 171715 171716 171717 171718 171719 171720 171721 171722 | + + + + + | rc = sqlite3_reset(pStmt); if( rc!=SQLITE_OK ) return rc; } nData = pWriter->nData; nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm); nSuffix = nTerm-nPrefix; /* If nSuffix is zero or less, then zTerm/nTerm must be a prefix of ** pWriter->zTerm/pWriter->nTerm. i.e. must be equal to or less than when ** compared with BINARY collation. This indicates corruption. */ if( nSuffix<=0 ) return FTS_CORRUPT_VTAB; /* Figure out how many bytes are required by this new entry */ nReq = sqlite3Fts3VarintLen(nPrefix) + /* varint containing prefix size */ sqlite3Fts3VarintLen(nSuffix) + /* varint containing suffix size */ nSuffix + /* Term suffix */ sqlite3Fts3VarintLen(nDoclist) + /* Size of doclist */ nDoclist; /* Doclist data */ |
︙ | |||
171364 171365 171366 171367 171368 171369 171370 | 172417 172418 172419 172420 172421 172422 172423 172424 172425 172426 172427 172428 172429 172430 172431 172432 172433 | - + + + | ** doclist. */ sqlite3_int64 iDelta; if( p->bDescIdx && nDoclist>0 ){ iDelta = iPrev - iDocid; }else{ iDelta = iDocid - iPrev; } |
︙ | |||
171730 171731 171732 171733 171734 171735 171736 | 172785 172786 172787 172788 172789 172790 172791 172792 172793 172794 172795 172796 172797 172798 172799 172800 172801 172802 172803 172804 172805 172806 172807 172808 | - - - - - + + + + + + - - - + + + + | */ static void fts3DecodeIntArray( int N, /* The number of integers to decode */ u32 *a, /* Write the integer values */ const char *zBuf, /* The BLOB containing the varints */ int nBuf /* size of the BLOB */ ){ |
︙ | |||
172143 172144 172145 172146 172147 172148 172149 | 173200 173201 173202 173203 173204 173205 173206 173207 173208 173209 173210 173211 173212 173213 173214 173215 173216 173217 173218 173219 173220 173221 173222 173223 173224 | - + - + | }else{ if( bFirst==0 ){ p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nPrefix); } p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix); if( nPrefix>p->iOff || nSuffix>p->nNode-p->iOff ){ |
︙ | |||
174283 174284 174285 174286 174287 174288 174289 | 175340 175341 175342 175343 175344 175345 175346 175347 175348 175349 175350 175351 175352 175353 175354 | - + | xRet = fts3MIBufferFree; } else if( p->aRef[2]==0 ){ p->aRef[2] = 1; aOut = &p->aMatchinfo[p->nElem+2]; xRet = fts3MIBufferFree; }else{ |
︙ | |||
174538 174539 174540 174541 174542 174543 174544 | 175595 175596 175597 175598 175599 175600 175601 175602 175603 175604 175605 175606 175607 175608 175609 175610 | - + + | char *pCsr = pPhrase->pTail; int iCsr = pPhrase->iTail; while( iCsr<(iStart+pIter->nSnippet) ){ int j; u64 mPhrase = (u64)1 << i; u64 mPos = (u64)1 << (iCsr - iStart); |
︙ | |||
174580 174581 174582 174583 174584 174585 174586 | 175638 175639 175640 175641 175642 175643 175644 175645 175646 175647 175648 175649 175650 175651 175652 175653 175654 175655 175656 175657 175658 175659 | - - - - - + + + + + + + + | pPhrase->nToken = pExpr->pPhrase->nToken; rc = sqlite3Fts3EvalPhrasePoslist(p->pCsr, pExpr, p->iCol, &pCsr); assert( rc==SQLITE_OK || pCsr==0 ); if( pCsr ){ int iFirst = 0; pPhrase->pList = pCsr; fts3GetDeltaPosition(&pCsr, &iFirst); |
︙ | |||
174621 174622 174623 174624 174625 174626 174627 | 175682 175683 175684 175685 175686 175687 175688 175689 175690 175691 175692 175693 175694 175695 175696 175697 175698 175699 175700 175701 175702 175703 175704 175705 175706 175707 175708 175709 175710 175711 175712 175713 175714 | - + - + | u64 *pmSeen, /* IN/OUT: Mask of phrases seen */ SnippetFragment *pFragment, /* OUT: Best snippet found */ int *piScore /* OUT: Score of snippet pFragment */ ){ int rc; /* Return Code */ int nList; /* Number of phrases in expression */ SnippetIter sIter; /* Iterates through snippet candidates */ |
︙ | |||
174709 174710 174711 174712 174713 174714 174715 | 175770 175771 175772 175773 175774 175775 175776 175777 175778 175779 175780 175781 175782 175783 175784 175785 | - - + + | } /* If there is insufficient space allocated at StrBuffer.z, use realloc() ** to grow the buffer until so that it is big enough to accomadate the ** appended data. */ if( pStr->n+nAppend+1>=pStr->nAlloc ){ |
︙ | |||
174765 174766 174767 174768 174769 174770 174771 174772 174773 174774 174775 174776 174777 174778 | 175826 175827 175828 175829 175830 175831 175832 175833 175834 175835 175836 175837 175838 175839 175840 | + | if( hlmask ){ int nLeft; /* Tokens to the left of first highlight */ int nRight; /* Tokens to the right of last highlight */ int nDesired; /* Ideal number of tokens to shift forward */ for(nLeft=0; !(hlmask & ((u64)1 << nLeft)); nLeft++); for(nRight=0; !(hlmask & ((u64)1 << (nSnippet-1-nRight))); nRight++); assert( (nSnippet-1-nRight)<=63 && (nSnippet-1-nRight)>=0 ); nDesired = (nLeft-nRight)/2; /* Ideally, the start of the snippet should be pushed forward in the ** document nDesired tokens. This block checks if there are actually ** nDesired tokens to the right of the snippet. If so, *piPos and ** *pHlMask are updated to shift the snippet nDesired tokens to the ** right. Otherwise, the snippet is shifted by the number of tokens |
︙ | |||
174957 174958 174959 174960 174961 174962 174963 | 176019 176020 176021 176022 176023 176024 176025 176026 176027 176028 176029 176030 176031 176032 176033 | - + | *ppCollist = pEnd; return nEntry; } /* ** This function gathers 'y' or 'b' data for a single phrase. */ |
︙ | |||
174987 174988 174989 174990 174991 174992 174993 174994 174995 174996 174997 174998 174999 | 176049 176050 176051 176052 176053 176054 176055 176056 176057 176058 176059 176060 176061 176062 176063 176064 176065 176066 176067 176068 176069 176070 176071 176072 176073 176074 176075 176076 176077 176078 176079 176080 176081 176082 176083 176084 176085 | + + - + + - - + + - + + | p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F)); } } assert( *pIter==0x00 || *pIter==0x01 ); if( *pIter!=0x01 ) break; pIter++; pIter += fts3GetVarint32(pIter, &iCol); if( iCol>=p->nCol ) return FTS_CORRUPT_VTAB; } return SQLITE_OK; } /* ** Gather the results for matchinfo directives 'y' and 'b'. */ |
︙ | |||
175222 175223 175224 175225 175226 175227 175228 175229 175230 175231 175232 | 176288 176289 176290 176291 176292 176293 176294 176295 176296 176297 176298 176299 176300 176301 176302 176303 176304 176305 176306 176307 176308 176309 176310 176311 176312 176313 176314 176315 176316 176317 176318 176319 176320 176321 176322 176323 176324 176325 176326 176327 176328 176329 176330 176331 176332 | + - + - - + - + + + + + | ** undefined. */ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){ LcsIterator *aIter; int i; int iCol; int nToken = 0; int rc = SQLITE_OK; /* Allocate and populate the array of LcsIterator objects. The array ** contains one element for each matchable phrase in the query. **/ |
︙ | |||
175280 175281 175282 175283 175284 175285 175286 175287 | 176350 176351 176352 176353 176354 176355 176356 176357 176358 176359 176360 176361 176362 176363 176364 176365 176366 | + - + | } if( fts3LcsIteratorAdvance(pAdv) ) nLive--; } pInfo->aMatchinfo[iCol] = nLcs; } matchinfo_lcs_out: sqlite3_free(aIter); |
︙ | |||
175377 175378 175379 175380 175381 175382 175383 | 176448 176449 176450 176451 176452 176453 176454 176455 176456 176457 176458 176459 176460 176461 176462 | - + | } break; case FTS3_MATCHINFO_LHITS_BM: case FTS3_MATCHINFO_LHITS: { int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32); memset(pInfo->aMatchinfo, 0, nZero); |
︙ | |||
175528 175529 175530 175531 175532 175533 175534 175535 175536 175537 175538 175539 175540 175541 | 176599 176600 176601 176602 176603 176604 176605 176606 176607 176608 176609 176610 176611 176612 176613 176614 176615 176616 | + + + + | SnippetFragment aSnippet[4]; /* Maximum of 4 fragments per snippet */ int nFToken = -1; /* Number of tokens in each fragment */ if( !pCsr->pExpr ){ sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC); return; } /* Limit the snippet length to 64 tokens. */ if( nToken<-64 ) nToken = -64; if( nToken>+64 ) nToken = +64; for(nSnippet=1; 1; nSnippet++){ int iSnip; /* Loop counter 0..nSnippet-1 */ u64 mCovered = 0; /* Bitmask of phrases covered by snippet */ u64 mSeen = 0; /* Bitmask of phrases seen by BestSnippet() */ |
︙ | |||
175671 175672 175673 175674 175675 175676 175677 | 176746 176747 176748 176749 176750 176751 176752 176753 176754 176755 176756 176757 176758 176759 176760 | - + | assert( pCsr->isRequireSeek==0 ); /* Count the number of terms in the query */ rc = fts3ExprLoadDoclists(pCsr, 0, &nToken); if( rc!=SQLITE_OK ) goto offsets_out; /* Allocate the array of TermOffset iterators. */ |
︙ | |||
175896 175897 175898 175899 175900 175901 175902 | 176971 176972 176973 176974 176975 176976 176977 176978 176979 176980 176981 176982 176983 176984 176985 | - + | #endif /* ifndef SQLITE_AMALGAMATION */ typedef struct unicode_tokenizer unicode_tokenizer; typedef struct unicode_cursor unicode_cursor; struct unicode_tokenizer { sqlite3_tokenizer base; |
︙ | |||
175969 175970 175971 175972 175973 175974 175975 | 177044 177045 177046 177047 177048 177049 177050 177051 177052 177053 177054 177055 177056 177057 177058 | - + | } } if( nEntry ){ int *aNew; /* New aiException[] array */ int nNew; /* Number of valid entries in array aNew[] */ |
︙ | |||
176041 176042 176043 176044 176045 176046 176047 | 177116 177117 177118 177119 177120 177121 177122 177123 177124 177125 177126 177127 177128 177129 177130 177131 177132 177133 177134 177135 177136 177137 177138 177139 177140 177141 177142 177143 | - + - + - + + + + | unicode_tokenizer *pNew; /* New tokenizer object */ int i; int rc = SQLITE_OK; pNew = (unicode_tokenizer *) sqlite3_malloc(sizeof(unicode_tokenizer)); if( pNew==NULL ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(unicode_tokenizer)); |
︙ | |||
176155 176156 176157 176158 176159 176160 176161 | 177233 177234 177235 177236 177237 177238 177239 177240 177241 177242 177243 177244 177245 177246 177247 177248 177249 177250 177251 177252 177253 177254 177255 177256 | - + - + | zOut = pCsr->zToken; do { int iOut; /* Grow the output buffer if required. */ if( (zOut-pCsr->zToken)>=(pCsr->nAlloc-4) ){ |
︙ | |||
176209 176210 176211 176212 176213 176214 176215 | 177287 177288 177289 177290 177291 177292 177293 177294 177295 177296 177297 177298 177299 177300 177301 | - + | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ #endif /* ifndef SQLITE_DISABLE_FTS3_UNICODE */ /************** End of fts3_unicode.c ****************************************/ /************** Begin file fts3_unicode2.c ***********************************/ /* |
︙ | |||
176369 176370 176371 176372 176373 176374 176375 | 177447 177448 177449 177450 177451 177452 177453 177454 177455 177456 177457 177458 177459 177460 177461 177462 177463 177464 177465 177466 177467 177468 177469 177470 177471 177472 177473 177474 177475 177476 177477 177478 177479 177480 177481 177482 177483 177484 177485 177486 177487 177488 177489 177490 177491 177492 177493 177494 177495 177496 177497 177498 177499 177500 177501 177502 177503 177504 177505 177506 177507 177508 177509 177510 177511 177512 177513 177514 177515 177516 177517 177518 177519 177520 177521 177522 177523 177524 177525 177526 177527 177528 177529 177530 177531 177532 177533 177534 177535 177536 177537 177538 177539 177540 177541 177542 177543 177544 177545 177546 177547 | - + - - - - - - - - - + + + + + + + + + + + + + - + - - - + + + + + + + + + + + - - - - - - + + + + + + + + + + + - + - - + + - + | ** If the argument is a codepoint corresponding to a lowercase letter ** in the ASCII range with a diacritic added, return the codepoint ** of the ASCII letter only. For example, if passed 235 - "LATIN ** SMALL LETTER E WITH DIAERESIS" - return 65 ("LATIN SMALL LETTER ** E"). The resuls of passing a codepoint that corresponds to an ** uppercase letter are undefined. */ |
︙ | |||
176561 176562 176563 176564 176565 176566 176567 | 177656 177657 177658 177659 177660 177661 177662 177663 177664 177665 177666 177667 177668 177669 177670 177671 177672 | + - + + | assert( iRes>=0 && c>=aEntry[iRes].iCode ); p = &aEntry[iRes]; if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){ ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF; assert( ret>0 ); } if( eRemoveDiacritic ){ |
︙ | |||
177268 177269 177270 177271 177272 177273 177274 | 178365 178366 178367 178368 178369 178370 178371 178372 178373 178374 178375 178376 178377 178378 178379 | - + | const char *zContent /* Content */ ){ u32 nNew; JsonNode *pNew; assert( pParse->nNode>=pParse->nAlloc ); if( pParse->oom ) return -1; nNew = pParse->nAlloc*2 + 10; |
︙ | |||
177542 177543 177544 177545 177546 177547 177548 | 178639 178640 178641 178642 178643 178644 178645 178646 178647 178648 178649 178650 178651 178652 178653 | - + | /* ** Compute the parentage of all nodes in a completed parse. */ static int jsonParseFindParents(JsonParse *pParse){ u32 *aUp; assert( pParse->aUp==0 ); |
︙ | |||
177604 177605 177606 177607 177608 177609 177610 | 178701 178702 178703 178704 178705 178706 178707 178708 178709 178710 178711 178712 178713 178714 178715 | - + | } } if( pMatch ){ pMatch->nErr = 0; pMatch->iHold = iMaxHold+1; return pMatch; } |
︙ | |||
179249 179250 179251 179252 179253 179254 179255 179256 179257 179258 179259 179260 179261 179262 | 180346 180347 180348 180349 180350 180351 180352 180353 180354 180355 180356 180357 180358 180359 180360 180361 180362 | + + + | u8 nDim; /* Number of dimensions */ u8 nDim2; /* Twice the number of dimensions */ u8 eCoordType; /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */ u8 nBytesPerCell; /* Bytes consumed per cell */ u8 inWrTrans; /* True if inside write transaction */ u8 nAux; /* # of auxiliary columns in %_rowid */ u8 nAuxNotNull; /* Number of initial not-null aux columns */ #ifdef SQLITE_DEBUG u8 bCorrupt; /* Shadow table corruption detected */ #endif int iDepth; /* Current depth of the r-tree structure */ char *zDb; /* Name of database containing r-tree table */ char *zName; /* Name of r-tree table */ u32 nBusy; /* Current number of users of this structure */ i64 nRowEst; /* Estimated number of rows in this table */ u32 nCursor; /* Number of open cursors */ u32 nNodeRef; /* Number RtreeNodes with positive nRef */ |
︙ | |||
179308 179309 179310 179311 179312 179313 179314 179315 179316 179317 179318 179319 179320 179321 | 180408 180409 180410 180411 180412 180413 180414 180415 180416 180417 180418 180419 180420 180421 180422 180423 180424 180425 180426 180427 180428 180429 180430 | + + + + + + + + + | # define RTREE_ZERO 0 #else typedef double RtreeDValue; /* High accuracy coordinate */ typedef float RtreeValue; /* Low accuracy coordinate */ # define RTREE_ZERO 0.0 #endif /* ** Set the Rtree.bCorrupt flag */ #ifdef SQLITE_DEBUG # define RTREE_IS_CORRUPT(X) ((X)->bCorrupt = 1) #else # define RTREE_IS_CORRUPT(X) #endif /* ** When doing a search of an r-tree, instances of the following structure ** record intermediate results from the tree walk. ** ** The id is always a node-id. For iLevel>=1 the id is the node-id of ** the node that the RtreeSearchPoint represents. When iLevel==0, however, ** the id is of the parent node and the cell that RtreeSearchPoint |
︙ | |||
179674 179675 179676 179677 179678 179679 179680 | 180783 180784 180785 180786 180787 180788 180789 180790 180791 180792 180793 180794 180795 180796 180797 180798 | - - + + | p->isDirty = 1; } /* ** Given a node number iNode, return the corresponding key to use ** in the Rtree.aHash table. */ |
︙ | |||
179720 179721 179722 179723 179724 179725 179726 | 180829 180830 180831 180832 180833 180834 180835 180836 180837 180838 180839 180840 180841 180842 180843 | - + | ** Allocate and return new r-tree node. Initially, (RtreeNode.iNode==0), ** indicating that node has not yet been assigned a node number. It is ** assigned a node number when nodeWrite() is called to write the ** node contents out to the database. */ static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){ RtreeNode *pNode; |
︙ | |||
179743 179744 179745 179746 179747 179748 179749 179750 179751 179752 179753 179754 179755 179756 179757 179758 179759 179760 179761 179762 179763 179764 179765 179766 179767 179768 179769 179770 179771 179772 179773 179774 179775 | 180852 180853 180854 180855 180856 180857 180858 180859 180860 180861 180862 180863 180864 180865 180866 180867 180868 180869 180870 180871 180872 180873 180874 180875 180876 180877 180878 180879 180880 180881 180882 180883 180884 180885 180886 180887 180888 180889 180890 180891 180892 180893 180894 180895 180896 180897 180898 180899 180900 | + + + + + + + + + + + + + + + + | static void nodeBlobReset(Rtree *pRtree){ if( pRtree->pNodeBlob && pRtree->inWrTrans==0 && pRtree->nCursor==0 ){ sqlite3_blob *pBlob = pRtree->pNodeBlob; pRtree->pNodeBlob = 0; sqlite3_blob_close(pBlob); } } /* ** Check to see if pNode is the same as pParent or any of the parents ** of pParent. */ static int nodeInParentChain(const RtreeNode *pNode, const RtreeNode *pParent){ do{ if( pNode==pParent ) return 1; pParent = pParent->pParent; }while( pParent ); return 0; } /* ** Obtain a reference to an r-tree node. */ static int nodeAcquire( Rtree *pRtree, /* R-tree structure */ i64 iNode, /* Node number to load */ RtreeNode *pParent, /* Either the parent node or NULL */ RtreeNode **ppNode /* OUT: Acquired node */ ){ int rc = SQLITE_OK; RtreeNode *pNode = 0; /* Check if the requested node is already in the hash table. If so, ** increase its reference count and return it. */ if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){ assert( !pParent || !pNode->pParent || pNode->pParent==pParent ); if( pParent && !pNode->pParent ){ if( nodeInParentChain(pNode, pParent) ){ RTREE_IS_CORRUPT(pRtree); return SQLITE_CORRUPT_VTAB; } pParent->nRef++; pNode->pParent = pParent; } pNode->nRef++; *ppNode = pNode; return SQLITE_OK; } |
︙ | |||
179792 179793 179794 179795 179796 179797 179798 | 180917 180918 180919 180920 180921 180922 180923 180924 180925 180926 180927 180928 180929 180930 180931 180932 180933 180934 180935 180936 180937 180938 180939 180940 180941 180942 180943 180944 180945 180946 180947 180948 180949 180950 180951 180952 180953 180954 180955 180956 180957 180958 180959 180960 180961 180962 180963 180964 180965 180966 180967 180968 180969 180970 180971 180972 180973 180974 180975 180976 180977 180978 180979 180980 180981 180982 180983 | - + + + + - + - + + + + | sqlite3_free(zTab); } if( rc ){ nodeBlobReset(pRtree); *ppNode = 0; /* If unable to open an sqlite3_blob on the desired row, that can only ** be because the shadow tables hold erroneous data. */ |
︙ | |||
180064 180065 180066 180067 180068 180069 180070 | 181195 181196 181197 181198 181199 181200 181201 181202 181203 181204 181205 181206 181207 181208 181209 | - + | */ static void rtreeRelease(Rtree *pRtree){ pRtree->nBusy--; if( pRtree->nBusy==0 ){ pRtree->inWrTrans = 0; assert( pRtree->nCursor==0 ); nodeBlobReset(pRtree); |
︙ | |||
180123 180124 180125 180126 180127 180128 180129 | 181254 181255 181256 181257 181258 181259 181260 181261 181262 181263 181264 181265 181266 181267 181268 | - + | ** Rtree virtual table module xOpen method. */ static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ int rc = SQLITE_NOMEM; Rtree *pRtree = (Rtree *)pVTab; RtreeCursor *pCsr; |
︙ | |||
180396 180397 180398 180399 180400 180401 180402 180403 180404 180405 180406 180407 180408 180409 | 181527 181528 181529 181530 181531 181532 181533 181534 181535 181536 181537 181538 181539 181540 181541 | + | assert( nCell<200 ); for(ii=0; ii<nCell; ii++){ if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){ *piIndex = ii; return SQLITE_OK; } } RTREE_IS_CORRUPT(pRtree); return SQLITE_CORRUPT_VTAB; } /* ** Return the index of the cell containing a pointer to node pNode ** in its parent. If pNode is the root node, return -1. */ |
︙ | |||
180489 180490 180491 180492 180493 180494 180495 | 181621 181622 181623 181624 181625 181626 181627 181628 181629 181630 181631 181632 181633 181634 181635 | - + | RtreeDValue rScore, /* Score for the new search point */ u8 iLevel /* Level for the new search point */ ){ int i, j; RtreeSearchPoint *pNew; if( pCur->nPoint>=pCur->nPointAlloc ){ int nNew = pCur->nPointAlloc*2 + 8; |
︙ | |||
180891 180892 180893 180894 180895 180896 180897 | 182023 182024 182025 182026 182027 182028 182029 182030 182031 182032 182033 182034 182035 182036 182037 | - + | } }else{ /* Normal case - r-tree scan. Set up the RtreeCursor.aConstraint array ** with the configured constraints. */ rc = nodeAcquire(pRtree, 1, 0, &pRoot); if( rc==SQLITE_OK && argc>0 ){ |
︙ | |||
181036 181037 181038 181039 181040 181041 181042 | 182168 182169 182170 182171 182172 182173 182174 182175 182176 182177 182178 182179 182180 182181 182182 182183 182184 182185 182186 182187 182188 182189 182190 182191 182192 182193 182194 182195 | - - - - - + + + + + - - + - - + + - - - - + + + + + | if( p->usable && ((p->iColumn>0 && p->iColumn<=pRtree->nDim2) || p->op==SQLITE_INDEX_CONSTRAINT_MATCH) ){ u8 op; switch( p->op ){ |
︙ | |||
181085 181086 181087 181088 181089 181090 181091 | 182217 182218 182219 182220 182221 182222 182223 182224 182225 182226 182227 182228 182229 182230 182231 182232 182233 182234 182235 | - - - - - + + + + + | case 2: area *= p->aCoord[3].f - p->aCoord[2].f; default: area *= p->aCoord[1].f - p->aCoord[0].f; } }else #endif { switch( pRtree->nDim ){ |
︙ | |||
181258 181259 181260 181261 181262 181263 181264 181265 181266 181267 181268 181269 | 182390 182391 182392 182393 182394 182395 182396 182397 182398 182399 182400 182401 182402 182403 182404 182405 182406 182407 182408 182409 182410 182411 | + - + + | */ static int AdjustTree( Rtree *pRtree, /* Rtree table */ RtreeNode *pNode, /* Adjust ancestry of this node. */ RtreeCell *pCell /* This cell was just inserted */ ){ RtreeNode *p = pNode; int cnt = 0; while( p->pParent ){ RtreeNode *pParent = p->pParent; RtreeCell cell; int iCell; |
︙ | |||
181460 181461 181462 181463 181464 181465 181466 | 182594 182595 182596 182597 182598 182599 182600 182601 182602 182603 182604 182605 182606 182607 182608 182609 182610 | - + - + | int *aSpare; int ii; int iBestDim = 0; int iBestSplit = 0; RtreeDValue fBestMargin = RTREE_ZERO; |
︙ | |||
181583 181584 181585 181586 181587 181588 181589 | 182717 182718 182719 182720 182721 182722 182723 182724 182725 182726 182727 182728 182729 182730 182731 | - + | RtreeCell leftbbox; RtreeCell rightbbox; /* Allocate an array and populate it with a copy of pCell and ** all cells from node pLeft. Then zero the original node. */ |
︙ | |||
181731 181732 181733 181734 181735 181736 181737 | 182865 182866 182867 182868 182869 182870 182871 182872 182873 182874 182875 182876 182877 182878 182879 182880 182881 182882 | - + + + + | for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent); if( !pTest ){ rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent); } } rc = sqlite3_reset(pRtree->pReadParent); if( rc==SQLITE_OK ) rc = rc2; |
︙ | |||
181871 181872 181873 181874 181875 181876 181877 | 183008 183009 183010 183011 183012 183013 183014 183015 183016 183017 183018 183019 183020 183021 183022 | - + | nCell = NCELL(pNode)+1; n = (nCell+1)&(~1); /* Allocate the buffers used by this operation. The allocation is ** relinquished before this function returns. */ |
︙ | |||
182044 182045 182046 182047 182048 182049 182050 182051 182052 | 183181 183182 183183 183184 183185 183186 183187 183188 183189 183190 183191 183192 183193 183194 183195 183196 183197 183198 183199 183200 183201 | + + + + - + | /* Obtain a reference to the leaf node that contains the entry ** about to be deleted. */ if( rc==SQLITE_OK ){ rc = findLeafNode(pRtree, iDelete, &pLeaf, 0); } #ifdef CORRUPT_DB assert( pLeaf!=0 || rc!=SQLITE_OK || CORRUPT_DB ); #endif /* Delete the cell in question from the leaf node. */ |
︙ | |||
182318 182319 182320 182321 182322 182323 182324 | 183459 183460 183461 183462 183463 183464 183465 183466 183467 183468 183469 183470 183471 183472 183473 | - + | pRtree->iReinsertHeight = -1; rc = rtreeInsertCell(pRtree, pLeaf, &cell, 0); rc2 = nodeRelease(pRtree, pLeaf); if( rc==SQLITE_OK ){ rc = rc2; } } |
︙ | |||
182516 182517 182518 182519 182520 182521 182522 182523 182524 182525 182526 182527 182528 182529 | 183657 183658 183659 183660 183661 183662 183663 183664 183665 183666 183667 183668 183669 183670 183671 | + | /* Read and write the xxx_parent table */ "SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = ?1", "INSERT OR REPLACE INTO '%q'.'%q_parent' VALUES(?1, ?2)", "DELETE FROM '%q'.'%q_parent' WHERE nodeno = ?1" }; sqlite3_stmt **appStmt[N_STATEMENT]; int i; const int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB; pRtree->db = db; if( isCreate ){ char *zCreate; sqlite3_str *p = sqlite3_str_new(db); int ii; |
︙ | |||
182572 182573 182574 182575 182576 182577 182578 | 183714 183715 183716 183717 183718 183719 183720 183721 183722 183723 183724 183725 183726 183727 183728 | - + - | /* An UPSERT is very slightly slower than REPLACE, but it is needed ** if there are auxiliary columns */ zFormat = "INSERT INTO\"%w\".\"%w_rowid\"(rowid,nodeno)VALUES(?1,?2)" "ON CONFLICT(rowid)DO UPDATE SET nodeno=excluded.nodeno"; } zSql = sqlite3_mprintf(zFormat, zDb, zPrefix); if( zSql ){ |
︙ | |||
182603 182604 182605 182606 182607 182608 182609 | 183744 183745 183746 183747 183748 183749 183750 183751 183752 183753 183754 183755 183756 183757 183758 | - + - | } } sqlite3_str_appendf(p, " WHERE rowid=?1"); zSql = sqlite3_str_finish(p); if( zSql==0 ){ rc = SQLITE_NOMEM; }else{ |
︙ | |||
182680 182681 182682 182683 182684 182685 182686 182687 182688 182689 182690 182691 182692 182693 | 183820 183821 183822 183823 183824 183825 183826 183827 183828 183829 183830 183831 183832 183833 183834 | + | pRtree->zDb, pRtree->zName ); rc = getIntFromStmt(db, zSql, &pRtree->iNodeSize); if( rc!=SQLITE_OK ){ *pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db)); }else if( pRtree->iNodeSize<(512-64) ){ rc = SQLITE_CORRUPT_VTAB; RTREE_IS_CORRUPT(pRtree); *pzErr = sqlite3_mprintf("undersize RTree blobs in \"%q_node\"", pRtree->zName); } } sqlite3_free(zSql); return rc; |
︙ | |||
182735 182736 182737 182738 182739 182740 182741 | 183876 183877 183878 183879 183880 183881 183882 183883 183884 183885 183886 183887 183888 183889 183890 | - + | } sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1); /* Allocate the sqlite3_vtab structure */ nDb = (int)strlen(argv[1]); nName = (int)strlen(argv[2]); |
︙ | |||
183003 183004 183005 183006 183007 183008 183009 | 184144 184145 184146 184147 184148 184149 184150 184151 184152 184153 184154 184155 184156 184157 184158 184159 184160 184161 184162 184163 184164 184165 184166 184167 184168 184169 184170 | - + - - + | ** Or, if an error does occur, NULL is returned and an error code left ** in the RtreeCheck object. The final value of *pnNode is undefined in ** this case. */ static u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){ u8 *pRet = 0; /* Return value */ |
︙ | |||
183494 183495 183496 183497 183498 183499 183500 183501 183502 183503 183504 183505 183506 183507 | 184634 184635 184636 184637 184638 184639 184640 184641 184642 184643 184644 184645 184646 184647 184648 184649 184650 184651 184652 184653 184654 184655 | + + + + + + + + | GeoCoord a[8]; /* 2*nVertex values. X (longitude) first, then Y */ }; /* The size of a memory allocation needed for a GeoPoly object sufficient ** to hold N coordinate pairs. */ #define GEOPOLY_SZ(N) (sizeof(GeoPoly) + sizeof(GeoCoord)*2*((N)-4)) /* Macros to access coordinates of a GeoPoly. ** We have to use these macros, rather than just say p->a[i] in order ** to silence (incorrect) UBSAN warnings if the array index is too large. */ #define GeoX(P,I) (((GeoCoord*)(P)->a)[(I)*2]) #define GeoY(P,I) (((GeoCoord*)(P)->a)[(I)*2+1]) /* ** State of a parse of a GeoJSON input. */ typedef struct GeoParse GeoParse; struct GeoParse { const unsigned char *z; /* Unparsed input */ |
︙ | |||
183687 183688 183689 183690 183691 183692 183693 | 184835 184836 184837 184838 184839 184840 184841 184842 184843 184844 184845 184846 184847 184848 184849 184850 184851 | - - + + + | if( pCtx ) sqlite3_result_error_nomem(pCtx); }else{ int x = 1; p->nVertex = nVertex; memcpy(p->hdr, a, nByte); if( a[0] != *(unsigned char*)&x ){ int ii; |
︙ | |||
183747 183748 183749 183750 183751 183752 183753 | 184896 184897 184898 184899 184900 184901 184902 184903 184904 184905 184906 184907 184908 184909 184910 184911 184912 184913 184914 184915 184916 184917 184918 184919 184920 184921 184922 184923 184924 184925 184926 184927 184928 184929 184930 184931 184932 184933 184934 184935 184936 184937 184938 184939 184940 184941 184942 | - + - + + + - + - + - + | GeoPoly *p = geopolyFuncParam(context, argv[0], 0); if( p ){ sqlite3 *db = sqlite3_context_db_handle(context); sqlite3_str *x = sqlite3_str_new(db); int i; sqlite3_str_append(x, "[", 1); for(i=0; i<p->nVertex; i++){ |
︙ | |||
183822 183823 183824 183825 183826 183827 183828 | 184973 184974 184975 184976 184977 184978 184979 184980 184981 184982 184983 184984 184985 184986 184987 184988 184989 184990 184991 184992 184993 184994 184995 184996 184997 184998 184999 185000 185001 185002 185003 185004 185005 185006 185007 185008 185009 185010 185011 185012 185013 185014 185015 185016 | - - + + - - + + - - + + - - + + | double D = sqlite3_value_double(argv[4]); double E = sqlite3_value_double(argv[5]); double F = sqlite3_value_double(argv[6]); GeoCoord x1, y1, x0, y0; int ii; if( p ){ for(ii=0; ii<p->nVertex; ii++){ |
︙ | |||
183898 183899 183900 183901 183902 183903 183904 | 185049 185050 185051 185052 185053 185054 185055 185056 185057 185058 185059 185060 185061 185062 185063 185064 185065 185066 185067 185068 185069 | - - - - - - - + + + + + + + | int argc, sqlite3_value **argv ){ GeoPoly *p = geopolyFuncParam(context, argv[0], 0); if( p ){ if( geopolyArea(p)<0.0 ){ int ii, jj; |
︙ | |||
183964 183965 183966 183967 183968 183969 183970 | 185115 185116 185117 185118 185119 185120 185121 185122 185123 185124 185125 185126 185127 185128 185129 185130 | - - + + | i = 1; p->hdr[0] = *(unsigned char*)&i; p->hdr[1] = 0; p->hdr[2] = (n>>8)&0xff; p->hdr[3] = n&0xff; for(i=0; i<n; i++){ double rAngle = 2.0*GEOPOLY_PI*i/n; |
︙ | |||
184002 184003 184004 184005 184006 184007 184008 | 185153 185154 185155 185156 185157 185158 185159 185160 185161 185162 185163 185164 185165 185166 185167 185168 185169 185170 185171 185172 185173 185174 185175 185176 185177 185178 185179 185180 185181 185182 185183 185184 185185 185186 185187 185188 185189 185190 185191 185192 185193 185194 185195 185196 185197 185198 185199 185200 | - - + + - + - + - - - - - - - - + + + + + + + + | mxY = aCoord[3].f; goto geopolyBboxFill; }else{ p = geopolyFuncParam(context, pPoly, pRc); } if( p ){ int ii; |
︙ | |||
184173 184174 184175 184176 184177 184178 184179 | 185324 185325 185326 185327 185328 185329 185330 185331 185332 185333 185334 185335 185336 185337 185338 185339 185340 185341 185342 185343 185344 185345 | - - + + - - + + | double x0 = sqlite3_value_double(argv[1]); double y0 = sqlite3_value_double(argv[2]); int v = 0; int cnt = 0; int ii; if( p1==0 ) return; for(ii=0; ii<p1->nVertex-1; ii++){ |
︙ | |||
184302 184303 184304 184305 184306 184307 184308 | 185453 185454 185455 185456 185457 185458 185459 185460 185461 185462 185463 185464 185465 185466 185467 185468 185469 185470 | - + - + | GeoOverlap *p, /* Add segments to this Overlap object */ GeoPoly *pPoly, /* Take all segments from this polygon */ unsigned char side /* The side of pPoly */ ){ unsigned int i; GeoCoord *x; for(i=0; i<(unsigned)pPoly->nVertex-1; i++){ |
︙ | |||
185250 185251 185252 185253 185254 185255 185256 | 186401 186402 186403 186404 186405 186406 186407 186408 186409 186410 186411 186412 186413 186414 186415 186416 186417 186418 186419 186420 | - + - + | ** The R-Tree MATCH operator will read the returned BLOB, deserialize ** the RtreeMatchArg object, and use the RtreeMatchArg object to figure ** out which elements of the R-Tree should be returned by the query. */ static void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){ RtreeGeomCallback *pGeomCtx = (RtreeGeomCallback *)sqlite3_user_data(ctx); RtreeMatchArg *pBlob; |
︙ | |||
185966 185967 185968 185969 185970 185971 185972 | 187117 187118 187119 187120 187121 187122 187123 187124 187125 187126 187127 187128 187129 187130 187131 | - + | ){ IcuTokenizer *p; int n = 0; if( argc>0 ){ n = strlen(argv[0])+1; } |
︙ | |||
186023 186024 186025 186026 186027 186028 186029 | 187174 187175 187176 187177 187178 187179 187180 187181 187182 187183 187184 187185 187186 187187 187188 | - + | if( zInput==0 ){ nInput = 0; zInput = ""; }else if( nInput<0 ){ nInput = strlen(zInput); } nChar = nInput+1; |
︙ | |||
186595 186596 186597 186598 186599 186600 186601 | 187746 187747 187748 187749 187750 187751 187752 187753 187754 187755 187756 187757 187758 187759 187760 187761 187762 187763 187764 | - + + + + + | ** The vacuum can be resumed by calling this function to open a new RBU ** handle specifying the same target and state databases. ** ** If the second argument passed to this function is NULL, then the ** name of the state database is "<database>-vacuum", where <database> ** is the name of the target database file. In this case, on UNIX, if the ** state database is not already present in the file-system, it is created |
︙ | |||
189253 189254 189255 189256 189257 189258 189259 | 190408 190409 190410 190411 190412 190413 190414 190415 190416 190417 190418 190419 190420 190421 190422 | - + | zExtra = &p->zRbu[5]; while( *zExtra ){ if( *zExtra++=='?' ) break; } if( *zExtra=='\0' ) zExtra = 0; } |
︙ | |||
190519 190520 190521 190522 190523 190524 190525 190526 190527 190528 190529 190530 190531 190532 | 191674 191675 191676 191677 191678 191679 191680 191681 191682 191683 191684 191685 191686 191687 191688 191689 191690 191691 191692 191693 | + + + + + + | ** Open a handle to begin or resume an RBU VACUUM operation. */ SQLITE_API sqlite3rbu *sqlite3rbu_vacuum( const char *zTarget, const char *zState ){ if( zTarget==0 ){ return rbuMisuseError(); } if( zState ){ int n = strlen(zState); if( n>=7 && 0==memcmp("-vactmp", &zState[n-7], 7) ){ return rbuMisuseError(); } } /* TODO: Check that both arguments are non-NULL */ return openRbuHandle(0, zTarget, zState); } /* ** Return the database handle used by pRbu. */ |
︙ | |||
190715 190716 190717 190718 190719 190720 190721 | 191876 191877 191878 191879 191880 191881 191882 191883 191884 191885 191886 191887 191888 191889 191890 191891 191892 191893 | - + + + + | p->rc = rc; rbuSaveState(p, p->eStage); rc = p->rc; if( p->eStage==RBU_STAGE_OAL ){ assert( rc!=SQLITE_DONE ); if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, 0); |
︙ | |||
192246 192247 192248 192249 192250 192251 192252 192253 192254 192255 192256 192257 192258 192259 | 193410 193411 193412 193413 193414 193415 193416 193417 193418 193419 193420 193421 193422 193423 193424 193425 193426 193427 | + + + + | if( !p->iRightChildPg || p->iCell>p->nCell ){ statClearPage(p); if( pCsr->iPage==0 ) return statNext(pCursor); pCsr->iPage--; goto statNextRestart; /* Tail recursion */ } pCsr->iPage++; if( pCsr->iPage>=ArraySize(pCsr->aPage) ){ statResetCsr(pCsr); return SQLITE_CORRUPT_BKPT; } assert( p==&pCsr->aPage[pCsr->iPage-1] ); if( p->iCell==p->nCell ){ p[1].iPgno = p->iRightChildPg; }else{ p[1].iPgno = p->aCell[p->iCell].iChildPg; } |
︙ | |||
192317 192318 192319 192320 192321 192322 192323 | 193485 193486 193487 193488 193489 193490 193491 193492 193493 193494 193495 193496 193497 193498 193499 193500 193501 193502 193503 193504 193505 193506 193507 193508 193509 193510 193511 193512 193513 193514 193515 193516 193517 193518 193519 | - - - - + + | int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ StatCursor *pCsr = (StatCursor *)pCursor; StatTable *pTab = (StatTable*)(pCursor->pVtab); char *zSql; int rc = SQLITE_OK; |
︙ | |||
193227 193228 193229 193230 193231 193232 193233 | 194393 194394 194395 194396 194397 194398 194399 194400 194401 194402 194403 194404 194405 194406 194407 | - + | ** If no error occurs, SQLITE_OK is returned. Or, if an OOM error occurs ** within a call to sqlite3_value_text() (may fail if the db is utf-16)) ** SQLITE_NOMEM is returned. */ static int sessionSerializeValue( u8 *aBuf, /* If non-NULL, write serialized value here */ sqlite3_value *pValue, /* Value to serialize */ |
︙ | |||
193768 193769 193770 193771 193772 193773 193774 | 194934 194935 194936 194937 194938 194939 194940 194941 194942 194943 194944 194945 194946 194947 194948 | - + | */ static int sessionGrowHash(int bPatchset, SessionTable *pTab){ if( pTab->nChange==0 || pTab->nEntry>=(pTab->nChange/2) ){ int i; SessionChange **apNew; int nNew = (pTab->nChange ? pTab->nChange : 128) * 2; |
︙ | |||
193834 193835 193836 193837 193838 193839 193840 | 195000 195001 195002 195003 195004 195005 195006 195007 195008 195009 195010 195011 195012 195013 195014 | - + | const char **pzTab, /* OUT: Copy of zThis */ const char ***pazCol, /* OUT: Array of column names for table */ u8 **pabPK /* OUT: Array of booleans - true for PK col */ ){ char *zPragma; sqlite3_stmt *pStmt; int rc; |
︙ | |||
193877 193878 193879 193880 193881 193882 193883 | 195043 195044 195045 195046 195047 195048 195049 195050 195051 195052 195053 195054 195055 195056 195057 | - + | nByte += sqlite3_column_bytes(pStmt, 1); nDbCol++; } rc = sqlite3_reset(pStmt); if( rc==SQLITE_OK ){ nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1); |
︙ | |||
194018 194019 194020 194021 194022 194023 194024 | 195184 195185 195186 195187 195188 195189 195190 195191 195192 195193 195194 195195 195196 195197 195198 | - + | int op, /* One of SQLITE_UPDATE, INSERT, DELETE */ sqlite3_session *pSession, /* Session object pTab is attached to */ SessionTable *pTab /* Table that change applies to */ ){ int iHash; int bNull = 0; int rc = SQLITE_OK; |
︙ | |||
194075 194076 194077 194078 194079 194080 194081 | 195241 195242 195243 195244 195245 195246 195247 195248 195249 195250 195251 195252 195253 195254 195255 | - + | } if( pC==0 ){ /* Create a new change object containing all the old values (if ** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK ** values (if this is an INSERT). */ SessionChange *pChange; /* New change object */ |
︙ | |||
194100 194101 194102 194103 194104 194105 194106 | 195266 195267 195268 195269 195270 195271 195272 195273 195274 195275 195276 195277 195278 195279 195280 | - + | /* This may fail if SQLite value p contains a utf-16 string that must ** be converted to utf-8 and an OOM error occurs while doing so. */ rc = sessionSerializeValue(0, p, &nByte); if( rc!=SQLITE_OK ) goto error_out; } /* Allocate the change object */ |
︙ | |||
194544 194545 194546 194547 194548 194549 194550 | 195710 195711 195712 195713 195714 195715 195716 195717 195718 195719 195720 195721 195722 195723 195724 | - + | sqlite3_session *pOld; /* Session object already attached to db */ int nDb = sqlite3Strlen30(zDb); /* Length of zDb in bytes */ /* Zero the output value in case an error occurs. */ *ppSession = 0; /* Allocate and populate the new session object. */ |
︙ | |||
194663 194664 194665 194666 194667 194668 194669 | 195829 195830 195831 195832 195833 195834 195835 195836 195837 195838 195839 195840 195841 195842 195843 | - + | nName = sqlite3Strlen30(zName); for(pTab=pSession->pTable; pTab; pTab=pTab->pNext){ if( 0==sqlite3_strnicmp(pTab->zName, zName, nName+1) ) break; } if( !pTab ){ /* Allocate new SessionTable object. */ |
︙ | |||
194723 194724 194725 194726 194727 194728 194729 | 195889 195890 195891 195892 195893 195894 195895 195896 195897 195898 195899 195900 195901 195902 195903 | - + | ** This function is a no-op if *pRc is non-zero when it is called. ** Otherwise, if an error occurs, *pRc is set to an SQLite error code ** before returning. */ static void sessionAppendValue(SessionBuffer *p, sqlite3_value *pVal, int *pRc){ int rc = *pRc; if( rc==SQLITE_OK ){ |
︙ | |||
195599 195600 195601 195602 195603 195604 195605 | 196765 196766 196767 196768 196769 196770 196771 196772 196773 196774 196775 196776 196777 196778 196779 | - + | int nData, /* Size of buffer aData[] in bytes */ u8 enc /* String encoding (0 for blobs) */ ){ /* In theory this code could just pass SQLITE_TRANSIENT as the final ** argument to sqlite3ValueSetStr() and have the copy created ** automatically. But doing so makes it difficult to detect any OOM ** error. Hence the code to create the copy externally. */ |
︙ | |||
196212 196213 196214 196215 196216 196217 196218 | 197378 197379 197380 197381 197382 197383 197384 197385 197386 197387 197388 197389 197390 197391 197392 | - + | break; } case SQLITE_UPDATE: { int iCol; if( 0==apVal ){ |
︙ | |||
197485 197486 197487 197488 197489 197490 197491 | 198651 198652 198653 198654 198655 198656 198657 198658 198659 198660 198661 198662 198663 198664 198665 | - + | int nRec, /* Number of bytes in aRec */ SessionChange **ppNew /* OUT: Merged change */ ){ SessionChange *pNew = 0; int rc = SQLITE_OK; if( !pExist ){ |
︙ | |||
197518 197519 197520 197521 197522 197523 197524 | 198684 198685 198686 198687 198688 198689 198690 198691 198692 198693 198694 198695 198696 198697 198698 198699 | - - + + | } pNew->nRecord = pOut - pNew->aRecord; } }else if( bRebase ){ if( pExist->op==SQLITE_DELETE && pExist->bIndirect ){ *ppNew = pExist; }else{ |
︙ | |||
197579 197580 197581 197582 197583 197584 197585 | 198745 198746 198747 198748 198749 198750 198751 198752 198753 198754 198755 198756 198757 198758 198759 198760 198761 198762 198763 198764 198765 198766 | - + - + | ){ pNew = pExist; }else if( op1==SQLITE_INSERT && op2==SQLITE_DELETE ){ sqlite3_free(pExist); assert( pNew==0 ); }else{ u8 *aExist = pExist->aRecord; |
︙ | |||
197692 197693 197694 197695 197696 197697 197698 | 198858 198859 198860 198861 198862 198863 198864 198865 198866 198867 198868 198869 198870 198871 198872 | - + | sqlite3changeset_pk(pIter, &abPK, 0); for(pTab = pGrp->pList; pTab; pTab=pTab->pNext){ if( 0==sqlite3_strnicmp(pTab->zName, zNew, nNew+1) ) break; } if( !pTab ){ SessionTable **ppTab; |
︙ | |||
198466 198467 198468 198469 198470 198471 198472 | 199632 199633 199634 199635 199636 199637 199638 199639 199640 199641 199642 199643 199644 199645 199646 199647 | - - - - - - + + | ** Query for the details of phrase match iIdx within the current row. ** Phrase matches are numbered starting from zero, so the iIdx argument ** should be greater than or equal to zero and smaller than the value ** output by xInstCount(). ** ** Usually, output parameter *piPhrase is set to the phrase number, *piCol ** to the column in which it occurs and *piOff the token offset of the |
︙ | |||
198760 198761 198762 198763 198764 198765 198766 | 199922 199923 199924 199925 199926 199927 199928 199929 199930 199931 199932 199933 199934 199935 199936 199937 199938 199939 199940 | - - - - - + + + + + | ** same token for inputs "first" and "1st". Say that token is in ** fact "first", so that when the user inserts the document "I won ** 1st place" entries are added to the index for tokens "i", "won", ** "first" and "place". If the user then queries for '1st + place', ** the tokenizer substitutes "first" for "1st" and the query works ** as expected. ** |
︙ | |||
198788 198789 198790 198791 198792 198793 198794 | 199950 199951 199952 199953 199954 199955 199956 199957 199958 199959 199960 199961 199962 199963 199964 | - + | ** Using this method, when tokenizing document text, the tokenizer ** provides multiple synonyms for each token. So that when a ** document such as "I won first place" is tokenized, entries are ** added to the FTS index for "i", "won", "first", "1st" and ** "place". ** ** This way, even if the tokenizer does not provide synonyms |
︙ | |||
199013 199014 199015 199016 199017 199018 199019 199020 199021 199022 199023 199024 199025 199026 | 200175 200176 200177 200178 200179 200180 200181 200182 200183 200184 200185 200186 200187 200188 200189 200190 200191 200192 200193 200194 | + + + + + + | #ifdef SQLITE_DEBUG SQLITE_API extern int sqlite3_fts5_may_be_corrupt; # define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x)) #else # define assert_nc(x) assert(x) #endif /* ** A version of memcmp() that does not cause asan errors if one of the pointer ** parameters is NULL and the number of bytes to compare is zero. */ #define fts5Memcmp(s1, s2, n) ((n)==0 ? 0 : memcmp((s1), (s2), (n))) /* Mark a function parameter as unused, to suppress nuisance compiler ** warnings. */ #ifndef UNUSED_PARAM # define UNUSED_PARAM(X) (void)(X) #endif #ifndef UNUSED_PARAM2 |
︙ | |||
199200 199201 199202 199203 199204 199205 199206 | 200368 200369 200370 200371 200372 200373 200374 200375 200376 200377 200378 200379 200380 200381 200382 | - + | ) /* Write and decode big-endian 32-bit integer values */ static void sqlite3Fts5Put32(u8*, int); static int sqlite3Fts5Get32(const u8*); #define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32) |
︙ | |||
199235 199236 199237 199238 199239 199240 199241 | 200403 200404 200405 200406 200407 200408 200409 200410 200411 200412 200413 200414 200415 200416 200417 | - + | static int sqlite3Fts5PoslistNext64( const u8 *a, int n, /* Buffer containing poslist */ int *pi, /* IN/OUT: Offset within a[] */ i64 *piOff /* IN/OUT: Current offset */ ); /* Malloc utility */ |
︙ | |||
199446 199447 199448 199449 199450 199451 199452 | 200614 200615 200616 200617 200618 200619 200620 200621 200622 200623 200624 200625 200626 200627 200628 200629 200630 200631 200632 200633 200634 200635 200636 200637 200638 200639 200640 200641 200642 200643 200644 200645 200646 200647 200648 200649 200650 200651 200652 | - + + + + + + + + + + + - + + + | /* ** End of interface to code in fts5_varint.c. **************************************************************************/ /************************************************************************** |
︙ | |||
199714 199715 199716 199717 199718 199719 199720 | 200894 200895 200896 200897 200898 200899 200900 200901 200902 200903 200904 200905 200906 200907 200908 | - + | /************************************************************************** ** Interface to automatically generated code in fts5_unicode2.c. */ static int sqlite3Fts5UnicodeIsdiacritic(int c); static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic); static int sqlite3Fts5UnicodeCatParse(const char*, u8*); |
︙ | |||
200618 200619 200620 200621 200622 200623 200624 | 201798 201799 201800 201801 201802 201803 201804 201805 201806 201807 201808 201809 201810 201811 201812 201813 201814 201815 201816 201817 201818 201819 201820 201821 201822 201823 201824 201825 201826 201827 201828 201829 201830 201831 201832 201833 201834 201835 201836 201837 201838 201839 201840 201841 201842 201843 201844 201845 201846 201847 201848 201849 201850 201851 201852 201853 201854 201855 201856 201857 201858 201859 201860 201861 201862 201863 201864 201865 201866 201867 201868 201869 201870 201871 201872 201873 201874 201875 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | fts5yytos = fts5yypParser->fts5yytos; fts5yytos->stateno = fts5yyNewState; fts5yytos->major = fts5yyMajor; fts5yytos->minor.fts5yy0 = fts5yyMinor; fts5yyTraceShift(fts5yypParser, fts5yyNewState, "Shift"); } |
︙ | |||
200684 200685 200686 200687 200688 200689 200690 | 201893 201894 201895 201896 201897 201898 201899 201900 201901 201902 201903 201904 201905 201906 201907 201908 201909 201910 201911 201912 201913 201914 201915 201916 201917 201918 201919 201920 201921 201922 | - + - + | int fts5yysize; /* Amount to pop the stack */ sqlite3Fts5ParserARG_FETCH (void)fts5yyLookahead; (void)fts5yyLookaheadToken; fts5yymsp = fts5yypParser->fts5yytos; #ifndef NDEBUG if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){ |
︙ | |||
200883 200884 200885 200886 200887 200888 200889 | 202092 202093 202094 202095 202096 202097 202098 202099 202100 202101 202102 202103 202104 202105 202106 202107 202108 | - - - + + + | case 27: /* star_opt ::= */ { fts5yymsp[1].minor.fts5yy4 = 0; } break; default: break; /********** End reduce actions ************************************************/ }; |
︙ | |||
201316 201317 201318 201319 201320 201321 201322 | 202525 202526 202527 202528 202529 202530 202531 202532 202533 202534 202535 202536 202537 202538 202539 | - + | ** *pRc is set to an error code before returning. */ static void fts5HighlightAppend( int *pRc, HighlightContext *p, const char *z, int n ){ |
︙ | |||
201448 201449 201450 201451 201452 201453 201454 | 202657 202658 202659 202660 202661 202662 202663 202664 202665 202666 202667 202668 202669 202670 202671 | - + | ** error occurs. */ static int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){ if( p->nFirstAlloc==p->nFirst ){ int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64; int *aNew; |
︙ | |||
201515 201516 201517 201518 201519 201520 201521 201522 201523 201524 201525 | 202724 202725 202726 202727 202728 202729 202730 202731 202732 202733 202734 202735 202736 202737 202738 202739 202740 202741 202742 202743 202744 202745 202746 202747 202748 202749 202750 202751 202752 202753 | + - + - + | int ip = 0; int ic = 0; int iOff = 0; int iFirst = -1; int nInst; int nScore = 0; int iLast = 0; sqlite3_int64 iEnd = (sqlite3_int64)iPos + nToken; rc = pApi->xInstCount(pFts, &nInst); for(i=0; i<nInst && rc==SQLITE_OK; i++){ rc = pApi->xInst(pFts, i, &ip, &ic, &iOff); |
︙ | |||
201622 201623 201624 201625 201626 201627 201628 | 202832 202833 202834 202835 202836 202837 202838 202839 202840 202841 202842 202843 202844 202845 202846 202847 202848 | + + - + | for(ii=0; rc==SQLITE_OK && ii<nInst; ii++){ int ip, ic, io; int iAdj; int nScore; int jj; rc = pApi->xInst(pFts, ii, &ip, &ic, &io); if( ic!=i ) continue; if( io>nDocsize ) rc = FTS5_CORRUPT; |
︙ | |||
201748 201749 201750 201751 201752 201753 201754 | 202960 202961 202962 202963 202964 202965 202966 202967 202968 202969 202970 202971 202972 202973 202974 202975 202976 202977 202978 202979 202980 202981 202982 202983 202984 202985 202986 202987 202988 202989 202990 202991 202992 | - + - + + | Fts5Bm25Data *p; /* Object to return */ p = pApi->xGetAuxdata(pFts, 0); if( p==0 ){ int nPhrase; /* Number of phrases in query */ sqlite3_int64 nRow = 0; /* Number of rows in table */ sqlite3_int64 nToken = 0; /* Number of tokens in table */ |
︙ | |||
201891 201892 201893 201894 201895 201896 201897 | 203104 203105 203106 203107 203108 203109 203110 203111 203112 203113 203114 203115 203116 203117 203118 203119 203120 203121 203122 203123 203124 203125 203126 203127 203128 203129 203130 203131 203132 203133 203134 203135 203136 203137 203138 203139 203140 203141 203142 | - - - + - + | aBuiltin[i].xDestroy ); } return rc; } |
︙ | |||
201947 201948 201949 201950 201951 201952 201953 | 203158 203159 203160 203161 203162 203163 203164 203165 203166 203167 203168 203169 203170 203171 203172 | - + | aBuf[0] = (iVal>>24) & 0x00FF; aBuf[1] = (iVal>>16) & 0x00FF; aBuf[2] = (iVal>> 8) & 0x00FF; aBuf[3] = (iVal>> 0) & 0x00FF; } static int sqlite3Fts5Get32(const u8 *aBuf){ |
︙ | |||
202078 202079 202080 202081 202082 202083 202084 | 203289 203290 203291 203292 203293 203294 203295 203296 203297 203298 203299 203300 203301 203302 203303 | - + | int iVal; fts5FastGetVarint32(a, i, iVal); if( iVal==1 ){ fts5FastGetVarint32(a, i, iVal); iOff = ((i64)iVal) << 32; fts5FastGetVarint32(a, i, iVal); } |
︙ | |||
202139 202140 202141 202142 202143 202144 202145 | 203350 203351 203352 203353 203354 203355 203356 203357 203358 203359 203360 203361 203362 203363 203364 203365 203366 203367 | - + - + | ){ int rc = 0; /* Initialized only to suppress erroneous warning from Clang */ if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc; sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos); return SQLITE_OK; } |
︙ | |||
202585 202586 202587 202588 202589 202590 202591 | 203796 203797 203798 203799 203800 203801 203802 203803 203804 203805 203806 203807 203808 203809 203810 | - + | } assert( pConfig->nPrefix<=FTS5_MAX_PREFIX_INDEXES ); return rc; } if( sqlite3_strnicmp("tokenize", zCmd, nCmd)==0 ){ const char *p = (const char*)zArg; |
︙ | |||
202715 202716 202717 202718 202719 202720 202721 | 203926 203927 203928 203929 203930 203931 203932 203933 203934 203935 203936 203937 203938 203939 203940 203941 | - - + + | int *pRc, /* IN/OUT: Error code */ const char *zIn, /* Buffer to gobble string/bareword from */ char **pzOut, /* OUT: malloc'd buffer containing str/bw */ int *pbQuoted /* OUT: Set to true if dequoting required */ ){ const char *zRet = 0; |
︙ | |||
202819 202820 202821 202822 202823 202824 202825 | 204030 204031 204032 204033 204034 204035 204036 204037 204038 204039 204040 204041 204042 204043 204044 | - + | const char **azArg, /* Array of nArg CREATE VIRTUAL TABLE args */ Fts5Config **ppOut, /* OUT: Results of parse */ char **pzErr /* OUT: Error message */ ){ int rc = SQLITE_OK; /* Return code */ Fts5Config *pRet; /* New object to return */ int i; |
︙ | |||
203463 203464 203465 203466 203467 203468 203469 | 204674 204675 204676 204677 204678 204679 204680 204681 204682 204683 204684 204685 204686 204687 204688 | - + | } } *pz = &pToken->p[pToken->n]; return tok; } |
︙ | |||
203608 203609 203610 203611 203612 203613 203614 | 204819 204820 204821 204822 204823 204824 204825 204826 204827 204828 204829 204830 204831 204832 204833 204834 | - - + + | assert( pTerm->pSynonym ); for(p=pTerm; p; p=p->pSynonym){ Fts5IndexIter *pIter = p->pIter; if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){ if( pIter->nData==0 ) continue; if( nIter==nAlloc ){ |
︙ | |||
203689 203690 203691 203692 203693 203694 203695 | 204900 204901 204902 204903 204904 204905 204906 204907 204908 204909 204910 204911 204912 204913 204914 204915 | - - + + | int bFirst = pPhrase->aTerm[0].bFirst; fts5BufferZero(&pPhrase->poslist); /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ if( pPhrase->nTerm>ArraySize(aStatic) ){ |
︙ | |||
203824 203825 203826 203827 203828 203829 203830 | 205035 205036 205037 205038 205039 205040 205041 205042 205043 205044 205045 205046 205047 205048 205049 | - + | int bMatch; assert( pNear->nPhrase>1 ); /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ if( pNear->nPhrase>ArraySize(aStatic) ){ |
︙ | |||
204733 204734 204735 204736 204737 204738 204739 | 205944 205945 205946 205947 205948 205949 205950 205951 205952 205953 205954 205955 205956 205957 205958 205959 205960 205961 205962 205963 205964 205965 205966 205967 205968 205969 205970 205971 | + - - + + - + + - + | Fts5ExprNearset *pRet = 0; if( pParse->rc==SQLITE_OK ){ if( pPhrase==0 ){ return pNear; } if( pNear==0 ){ sqlite3_int64 nByte; |
︙ | |||
204808 204809 204810 204811 204812 204813 204814 | 206021 206022 206023 206024 206025 206026 206027 206028 206029 206030 206031 206032 206033 206034 206035 206036 206037 206038 206039 206040 206041 206042 206043 206044 206045 206046 206047 206048 206049 206050 206051 206052 | - - + + - + | /* If an error has already occurred, this is a no-op */ if( pCtx->rc!=SQLITE_OK ) return pCtx->rc; if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){ Fts5ExprTerm *pSyn; |
︙ | |||
204911 204912 204913 204914 204915 204916 204917 | 206124 206125 206126 206127 206128 206129 206130 206131 206132 206133 206134 206135 206136 206137 206138 206139 206140 | - + - + | pParse->rc = rc; fts5ExprPhraseFree(sCtx.pPhrase); sCtx.pPhrase = 0; }else{ if( pAppend==0 ){ if( (pParse->nPhrase % 8)==0 ){ |
︙ | |||
204968 204969 204970 204971 204972 204973 204974 | 206181 206182 206183 206184 206185 206186 206187 206188 206189 206190 206191 206192 206193 206194 206195 206196 206197 206198 | + + - - + + | if( rc==SQLITE_OK ){ pNew->pRoot->pNear = (Fts5ExprNearset*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprNearset) + sizeof(Fts5ExprPhrase*)); } if( rc==SQLITE_OK ){ Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset; if( pColsetOrig ){ sqlite3_int64 nByte; Fts5Colset *pColset; |
︙ | |||
205089 205090 205091 205092 205093 205094 205095 | 206304 206305 206306 206307 206308 206309 206310 206311 206312 206313 206314 206315 206316 206317 206318 | - + | ){ int nCol = p ? p->nCol : 0; /* Num. columns already in colset object */ Fts5Colset *pNew; /* New colset object to return */ assert( pParse->rc==SQLITE_OK ); assert( iCol>=0 && iCol<pParse->pConfig->nCol ); |
︙ | |||
205185 205186 205187 205188 205189 205190 205191 | 206400 206401 206402 206403 206404 206405 206406 206407 206408 206409 206410 206411 206412 206413 206414 | - + | ** Otherwise, a copy of (*pOrig) is made into memory obtained from ** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation ** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned. */ static Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){ Fts5Colset *pRet; if( pOrig ){ |
︙ | |||
205339 205340 205341 205342 205343 205344 205345 | 206554 206555 206556 206557 206558 206559 206560 206561 206562 206563 206564 206565 206566 206567 206568 | - + | Fts5ExprNode *pRight, /* Right hand child expression */ Fts5ExprNearset *pNear /* For STRING expressions, the near cluster */ ){ Fts5ExprNode *pRet = 0; if( pParse->rc==SQLITE_OK ){ int nChild = 0; /* Number of children of returned node */ |
︙ | |||
205471 205472 205473 205474 205475 205476 205477 | 206686 206687 206688 206689 206690 206691 206692 206693 206694 206695 206696 206697 206698 206699 206700 206701 206702 206703 206704 206705 206706 206707 206708 | - + - + | } } return pRet; } static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){ |
︙ | |||
205719 205720 205721 205722 205723 205724 205725 | 206934 206935 206936 206937 206938 206939 206940 206941 206942 206943 206944 206945 206946 206947 206948 | - + | if( bTcl && nArg>1 ){ zNearsetCmd = (const char*)sqlite3_value_text(apVal[1]); iArg = 2; } nConfig = 3 + (nArg-iArg); |
︙ | |||
205805 205806 205807 205808 205809 205810 205811 | 207020 207021 207022 207023 207024 207025 207026 207027 207028 207029 207030 207031 207032 207033 207034 | - + | return; } memset(aArr, 0, sizeof(aArr)); sqlite3Fts5UnicodeCatParse("L*", aArr); sqlite3Fts5UnicodeCatParse("N*", aArr); sqlite3Fts5UnicodeCatParse("Co", aArr); iCode = sqlite3_value_int(apVal[0]); |
︙ | |||
205900 205901 205902 205903 205904 205905 205906 | 207115 207116 207117 207118 207119 207120 207121 207122 207123 207124 207125 207126 207127 207128 207129 | - + | Fts5PoslistWriter writer; int bOk; /* True if ok to populate */ int bMiss; }; static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){ Fts5PoslistPopulator *pRet; |
︙ | |||
206100 206101 206102 206103 206104 206105 206106 | 207315 207316 207317 207318 207319 207320 207321 207322 207323 207324 207325 207326 207327 207328 | - | *ppCollist = 0; *pnCollist = 0; } return rc; } |
︙ | |||
206193 206194 206195 206196 206197 206198 206199 | 207407 207408 207409 207410 207411 207412 207413 207414 207415 207416 207417 207418 207419 207420 207421 207422 207423 207424 207425 207426 207427 207428 | - + - + | int rc = SQLITE_OK; Fts5Hash *pNew; *ppNew = pNew = (Fts5Hash*)sqlite3_malloc(sizeof(Fts5Hash)); if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ |
︙ | |||
206268 206269 206270 206271 206272 206273 206274 | 207482 207483 207484 207485 207486 207487 207488 207489 207490 207491 207492 207493 207494 207495 207496 | - + | */ static int fts5HashResize(Fts5Hash *pHash){ int nNew = pHash->nSlot*2; int i; Fts5HashEntry **apNew; Fts5HashEntry **apOld = pHash->aSlot; |
︙ | |||
206362 206363 206364 206365 206366 206367 206368 | 207576 207577 207578 207579 207580 207581 207582 207583 207584 207585 207586 207587 207588 207589 207590 207591 207592 207593 207594 207595 207596 207597 207598 207599 207600 207601 | - + - + | } } /* If an existing hash entry cannot be found, create a new one. */ if( p==0 ){ /* Figure out how much space to allocate */ char *zKey; |
︙ | |||
206412 206413 206414 206415 206416 206417 206418 | 207626 207627 207628 207629 207630 207631 207632 207633 207634 207635 207636 207637 207638 207639 207640 207641 207642 207643 207644 207645 | - + - + - + | ** + 9 bytes for a new rowid, ** + 4 byte reserved for the "poslist size" varint. ** + 1 byte for a "new column" byte, ** + 3 bytes for a new column number (16-bit max) as a varint, ** + 5 bytes for the new position offset (32-bit max). */ if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){ |
︙ | |||
206541 206542 206543 206544 206545 206546 206547 | 207755 207756 207757 207758 207759 207760 207761 207762 207763 207764 207765 207766 207767 207768 207769 | - + | const int nMergeSlot = 32; Fts5HashEntry **ap; Fts5HashEntry *pList; int iSlot; int i; *ppSorted = 0; |
︙ | |||
206586 206587 206588 206589 206590 206591 206592 | 207800 207801 207802 207803 207804 207805 207806 207807 207808 207809 207810 207811 207812 207813 207814 207815 | + - + | ){ unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm); char *zKey = 0; Fts5HashEntry *p; for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){ zKey = fts5EntryKey(p); assert( p->nKey+1==(int)strlen(zKey) ); |
︙ | |||
206637 206638 206639 206640 206641 206642 206643 | 207852 207853 207854 207855 207856 207857 207858 207859 207860 207861 207862 207863 207864 207865 | - | *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1); }else{ *pzTerm = 0; *ppDoclist = 0; *pnDoclist = 0; } } |
︙ | |||
207153 207154 207155 207156 207157 207158 207159 | 208367 208368 208369 208370 208371 208372 208373 208374 208375 208376 208377 208378 208379 208380 | - | ** Used by sqlite3Fts5IterPoslist() when the poslist needs to be buffered. ** There is no way to tell if this is populated or not. */ struct Fts5Iter { Fts5IndexIter base; /* Base class containing output vars */ Fts5Index *pIndex; /* Index that owns this iterator */ |
︙ | |||
207214 207215 207216 207217 207218 207219 207220 | 208427 208428 208429 208430 208431 208432 208433 208434 208435 208436 208437 208438 208439 208440 208441 | - + | /* ** Allocate and return a buffer at least nByte bytes in size. ** ** If an OOM error is encountered, return NULL and set the error code in ** the Fts5Index handle passed as the first argument. */ |
︙ | |||
207248 207249 207250 207251 207252 207253 207254 | 208461 208462 208463 208464 208465 208466 208467 208468 208469 208470 208471 208472 208473 208474 208475 | - + | ** Return -ve if pLeft is smaller than pRight, 0 if they are equal or ** +ve if pRight is smaller than pLeft. In other words: ** ** res = *pLeft - *pRight */ static int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){ int nCmp = MIN(pLeft->n, pRight->n); |
︙ | |||
207314 207315 207316 207317 207318 207319 207320 | 208527 208528 208529 208530 208531 208532 208533 208534 208535 208536 208537 208538 208539 208540 208541 208542 208543 208544 208545 208546 208547 208548 208549 208550 208551 208552 208553 208554 208555 208556 208557 208558 | - - + + + | ** table, missing row, non-blob/text in block column - indicate ** backing store corruption. */ if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT; if( rc==SQLITE_OK ){ u8 *aOut = 0; /* Read blob data into this buffer */ int nByte = sqlite3_blob_bytes(p->pReader); |
︙ | |||
207370 207371 207372 207373 207374 207375 207376 | 208584 208585 208586 208587 208588 208589 208590 208591 208592 208593 208594 208595 208596 208597 208598 208599 | - + + | Fts5Index *p, sqlite3_stmt **ppStmt, char *zSql ){ if( p->rc==SQLITE_OK ){ if( zSql ){ p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1, |
︙ | |||
207411 207412 207413 207414 207415 207416 207417 | 208626 208627 208628 208629 208630 208631 208632 208633 208634 208635 208636 208637 208638 208639 208640 208641 208642 208643 208644 208645 | - - - - - - + - - - - - - | ** ** DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast */ static void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){ if( p->rc!=SQLITE_OK ) return; if( p->pDeleter==0 ){ |
︙ | |||
207499 207500 207501 207502 207503 207504 207505 | 208703 208704 208705 208706 208707 208708 208709 208710 208711 208712 208713 208714 208715 208716 208717 208718 208719 208720 208721 208722 208723 208724 208725 208726 208727 208728 208729 208730 208731 208732 | - + + + + + + | Fts5Structure **ppOut /* OUT: Deserialized object */ ){ int rc = SQLITE_OK; int i = 0; int iLvl; int nLevel = 0; int nSegment = 0; |
︙ | |||
207532 207533 207534 207535 207536 207537 207538 | 208741 208742 208743 208744 208745 208746 208747 208748 208749 208750 208751 208752 208753 208754 208755 208756 208757 208758 208759 208760 208761 208762 208763 208764 208765 208766 208767 208768 208769 208770 208771 208772 208773 208774 208775 208776 208777 208778 208779 208780 208781 208782 208783 208784 208785 208786 208787 208788 208789 208790 208791 208792 208793 208794 208795 208796 208797 208798 208799 208800 208801 208802 208803 208804 208805 208806 | - + + + - - - - - - + + + + + + + + + + + + + + - + - + | int iSeg; if( i>=nData ){ rc = FTS5_CORRUPT; }else{ i += fts5GetVarint32(&pData[i], pLvl->nMerge); i += fts5GetVarint32(&pData[i], nTotal); |
︙ | |||
207598 207599 207600 207601 207602 207603 207604 | 208817 208818 208819 208820 208821 208822 208823 208824 208825 208826 208827 208828 208829 208830 208831 208832 208833 208834 | - + - + | int iLvl, int nExtra, int bInsert ){ if( *pRc==SQLITE_OK ){ Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl]; Fts5StructureSegment *aNew; |
︙ | |||
208115 208116 208117 208118 208119 208120 208121 | 209334 209335 209336 209337 209338 209339 209340 209341 209342 209343 209344 209345 209346 209347 209348 209349 209350 209351 | - + - + | int iLeafPg /* Leaf page number to load dlidx for */ ){ Fts5DlidxIter *pIter = 0; int i; int bDone = 0; for(i=0; p->rc==SQLITE_OK && bDone==0; i++){ |
︙ | |||
208288 208289 208290 208291 208292 208293 208294 | 209507 209508 209509 209510 209511 209512 209513 209514 209515 209516 209517 209518 209519 209520 209521 209522 209523 209524 209525 209526 209527 | - + + | */ static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){ u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ int iOff = pIter->iLeafOffset; /* Offset to read at */ int nNew; /* Bytes of new data */ iOff += fts5GetVarint32(&a[iOff], nNew); |
︙ | |||
208358 208359 208360 208361 208362 208363 208364 | 209578 209579 209580 209581 209582 209583 209584 209585 209586 209587 209588 209589 209590 209591 209592 | - + | pIter->iLeafPgno = pSeg->pgnoFirst-1; fts5SegIterNextPage(p, pIter); } if( p->rc==SQLITE_OK ){ pIter->iLeafOffset = 4; assert_nc( pIter->pLeaf->nn>4 ); |
︙ | |||
208414 208415 208416 208417 208418 208419 208420 | 209634 209635 209636 209637 209638 209639 209640 209641 209642 209643 209644 209645 209646 209647 209648 | - + | if( i>=n ) break; i += fts5GetVarint(&a[i], (u64*)&iDelta); pIter->iRowid += iDelta; /* If necessary, grow the pIter->aRowidOffset[] array. */ if( iRowidOffset>=pIter->nRowidOffset ){ int nNew = pIter->nRowidOffset + 8; |
︙ | |||
208868 208869 208870 208871 208872 208873 208874 | 210088 210089 210090 210091 210092 210093 210094 210095 210096 210097 210098 210099 210100 210101 210102 210103 210104 210105 | - - - - + + + + | const u8 *pTerm, int nTerm /* Term to search for */ ){ int iOff; const u8 *a = pIter->pLeaf->p; int szLeaf = pIter->pLeaf->szLeaf; int n = pIter->pLeaf->nn; |
︙ | |||
208895 208896 208897 208898 208899 208900 208901 | 210115 210116 210117 210118 210119 210120 210121 210122 210123 210124 210125 210126 210127 210128 210129 210130 210131 210132 210133 210134 210135 210136 210137 | - - - + + + - + | fts5FastGetVarint32(a, iOff, nNew); if( nKeep<nMatch ){ goto search_failed; } assert( nKeep>=nMatch ); if( nKeep==nMatch ){ |
︙ | |||
208947 208948 208949 208950 208951 208952 208953 208954 208955 208956 208957 208958 208959 208960 208961 208962 208963 208964 208965 | 210167 210168 210169 210170 210171 210172 210173 210174 210175 210176 210177 210178 210179 210180 210181 210182 210183 210184 210185 210186 210187 210188 210189 210190 210191 210192 210193 210194 210195 210196 210197 210198 | + - + + + + | if( pIter->pLeaf==0 ) return; a = pIter->pLeaf->p; if( fts5LeafIsTermless(pIter->pLeaf)==0 ){ iPgidx = pIter->pLeaf->szLeaf; iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff); if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){ p->rc = FTS5_CORRUPT; return; }else{ nKeep = 0; iTermOff = iOff; n = pIter->pLeaf->nn; iOff += fts5GetVarint32(&a[iOff], nNew); break; } } }while( 1 ); } search_success: |
︙ | |||
209067 209068 209069 209070 209071 209072 209073 | 210291 210292 210293 210294 210295 210296 210297 210298 210299 210300 210301 210302 210303 210304 210305 | - + | ** ** 1) an error has occurred, or ** 2) the iterator points to EOF, or ** 3) the iterator points to an entry with term (pTerm/nTerm), or ** 4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points ** to an entry with a term greater than or equal to (pTerm/nTerm). */ |
︙ | |||
209165 209166 209167 209168 209169 209170 209171 | 210389 210390 210391 210392 210393 210394 210395 210396 210397 210398 210399 210400 210401 210402 210403 | - + | if( p1->pLeaf || p2->pLeaf ){ if( p1->pLeaf==0 ){ assert( pRes->iFirst==i2 ); }else if( p2->pLeaf==0 ){ assert( pRes->iFirst==i1 ); }else{ int nMin = MIN(p1->term.n, p2->term.n); |
︙ | |||
209388 209389 209390 209391 209392 209393 209394 | 210612 210613 210614 210615 210616 210617 210618 210619 210620 210621 210622 210623 210624 210625 | - | */ static void fts5MultiIterFree(Fts5Iter *pIter){ if( pIter ){ int i; for(i=0; i<pIter->nSeg; i++){ fts5SegIterClear(&pIter->aSeg[i]); } |
︙ | |||
209736 209737 209738 209739 209740 209741 209742 | 210959 210960 210961 210962 210963 210964 210965 210966 210967 210968 210969 210970 210971 210972 210973 210974 | - + + | */ static void fts5SegiterPoslist( Fts5Index *p, Fts5SegIter *pSeg, Fts5Colset *pColset, Fts5Buffer *pBuf ){ |
︙ | |||
210034 210035 210036 210037 210038 210039 210040 | 211258 211259 211260 211261 211262 211263 211264 211265 211266 211267 211268 211269 211270 211271 211272 | - - | nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment); } } *ppOut = pNew = fts5MultiIterAlloc(p, nSeg); if( pNew==0 ) return; pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC)); pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY)); |
︙ | |||
210214 210215 210216 210217 210218 210219 210220 | 211436 211437 211438 211439 211440 211441 211442 211443 211444 211445 211446 211447 211448 211449 211450 211451 211452 211453 211454 211455 211456 211457 211458 211459 211460 211461 211462 211463 211464 211465 211466 211467 211468 211469 211470 211471 211472 211473 211474 211475 | - - + + - + - + - + - + | int iLvl, iSeg; int i; u32 mask; memset(aUsed, 0, sizeof(aUsed)); for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){ for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){ int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid; |
︙ | |||
210309 210310 210311 210312 210313 210314 210315 | 211531 211532 211533 211534 211535 211536 211537 211538 211539 211540 211541 211542 211543 211544 211545 | - + | */ static int fts5WriteDlidxGrow( Fts5Index *p, Fts5SegWriter *pWriter, int nLvl ){ if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){ |
︙ | |||
210388 210389 210390 210391 210392 210393 210394 | 211610 211611 211612 211613 211614 211615 211616 211617 211618 211619 211620 211621 211622 211623 211624 211625 211626 211627 | + - - + + + | */ static void fts5WriteBtreeTerm( Fts5Index *p, /* FTS5 backend object */ Fts5SegWriter *pWriter, /* Writer object */ int nTerm, const u8 *pTerm /* First term on new page */ ){ fts5WriteFlushBtree(p, pWriter); if( p->rc==SQLITE_OK ){ |
︙ | |||
210540 210541 210542 210543 210544 210545 210546 210547 210548 210549 210550 210551 210552 210553 210554 210555 210556 210557 210558 210559 210560 210561 210562 | 211764 211765 211766 211767 211768 211769 211770 211771 211772 211773 211774 211775 211776 211777 211778 211779 211780 211781 211782 211783 211784 211785 211786 211787 211788 | + + | Fts5Index *p, Fts5SegWriter *pWriter, int nTerm, const u8 *pTerm ){ int nPrefix; /* Bytes of prefix compression for term */ Fts5PageWriter *pPage = &pWriter->writer; Fts5Buffer *pPgidx = &pWriter->writer.pgidx; int nMin = MIN(pPage->term.n, nTerm); assert( p->rc==SQLITE_OK ); assert( pPage->buf.n>=4 ); assert( pPage->buf.n>4 || pWriter->bFirstTermInPage ); /* If the current leaf page is full, flush it to disk. */ if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){ if( pPage->buf.n>4 ){ fts5WriteFlushLeaf(p, pWriter); if( p->rc!=SQLITE_OK ) return; } fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING); } /* TODO1: Updating pgidx here. */ pPgidx->n += sqlite3Fts5PutVarint( &pPgidx->p[pPgidx->n], pPage->buf.n - pPage->iPrevPgidx |
︙ | |||
210581 210582 210583 210584 210585 210586 210587 | 211807 211808 211809 211810 211811 211812 211813 211814 211815 211816 211817 211818 211819 211820 211821 211822 211823 211824 211825 211826 211827 211828 | - + + - + | ** Usually, the previous term is available in pPage->term. The exception ** is if this is the first term written in an incremental-merge step. ** In this case the previous term is not available, so just write a ** copy of (pTerm/nTerm) into the parent node. This is slightly ** inefficient, but still correct. */ int n = nTerm; if( pPage->term.n ){ |
︙ | |||
210634 210635 210636 210637 210638 210639 210640 | 211861 211862 211863 211864 211865 211866 211867 211868 211869 211870 211871 211872 211873 211874 211875 | - + | fts5WriteDlidxAppend(p, pWriter, iRowid); } /* Write the rowid. */ if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){ fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid); }else{ |
︙ | |||
210756 210757 210758 210759 210760 210761 210762 | 211983 211984 211985 211986 211987 211988 211989 211990 211991 211992 211993 211994 211995 211996 211997 211998 211999 212000 212001 212002 212003 212004 212005 212006 212007 212008 212009 212010 212011 212012 212013 212014 212015 212016 212017 212018 212019 212020 212021 212022 212023 212024 212025 212026 212027 212028 212029 212030 212031 212032 212033 212034 212035 212036 212037 212038 212039 212040 212041 212042 212043 212044 212045 212046 212047 212048 212049 212050 212051 | - + - + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + + | ** incremental merge operation. This function is called if the incremental ** merge step has finished but the input has not been completely exhausted. */ static void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){ int i; Fts5Buffer buf; memset(&buf, 0, sizeof(Fts5Buffer)); |
︙ | |||
210894 210895 210896 210897 210898 210899 210900 | 212129 212130 212131 212132 212133 212134 212135 212136 212137 212138 212139 212140 212141 212142 212143 | - + | ){ Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ]; int nPos; /* position-list size field value */ int nTerm; const u8 *pTerm; pTerm = fts5MultiIterTerm(pIter, &nTerm); |
︙ | |||
211149 211150 211151 211152 211153 211154 211155 211156 211157 211158 211159 211160 211161 211162 | 212384 212385 212386 212387 212388 212389 212390 212391 212392 212393 212394 212395 212396 212397 212398 | + | const char *zTerm; /* Buffer containing term */ const u8 *pDoclist; /* Pointer to doclist for this term */ int nDoclist; /* Size of doclist in bytes */ /* Write the term for this entry to disk. */ sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist); fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm); if( p->rc!=SQLITE_OK ) break; assert( writer.bFirstRowidInPage==0 ); if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){ /* The entire doclist will fit on the current leaf. */ fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist); }else{ i64 iRowid = 0; |
︙ | |||
211171 211172 211173 211174 211175 211176 211177 211178 211179 211180 211181 211182 211183 211184 | 212407 212408 212409 212410 212411 212412 212413 212414 212415 212416 212417 212418 212419 212420 212421 | + | iRowid += iDelta; if( writer.bFirstRowidInPage ){ fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */ pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid); writer.bFirstRowidInPage = 0; fts5WriteDlidxAppend(p, &writer, iRowid); if( p->rc!=SQLITE_OK ) break; }else{ pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta); } assert( pBuf->n<=pBuf->nSpace ); if( eDetail==FTS5_DETAIL_NONE ){ if( iOff<nDoclist && pDoclist[iOff]==0 ){ |
︙ | |||
211228 211229 211230 211231 211232 211233 211234 | 212465 212466 212467 212468 212469 212470 212471 212472 212473 212474 212475 212476 212477 212478 212479 | - + | } } } /* TODO2: Doclist terminator written here. */ /* pBuf->p[pBuf->n++] = '\0'; */ assert( pBuf->n<=pBuf->nSpace ); |
︙ | |||
211272 211273 211274 211275 211276 211277 211278 | 212509 212510 212511 212512 212513 212514 212515 212516 212517 212518 212519 212520 212521 212522 212523 | - + | } static Fts5Structure *fts5IndexOptimizeStruct( Fts5Index *p, Fts5Structure *pStruct ){ Fts5Structure *pNew = 0; |
︙ | |||
211402 211403 211404 211405 211406 211407 211408 211409 | 212639 212640 212641 212642 212643 212644 212645 212646 212647 212648 212649 212650 212651 212652 212653 212654 212655 212656 212657 212658 212659 | + - + + | static void fts5AppendPoslist( Fts5Index *p, i64 iDelta, Fts5Iter *pMulti, Fts5Buffer *pBuf ){ int nData = pMulti->base.nData; int nByte = nData + 9 + 9 + FTS5_DATA_ZERO_PADDING; assert( nData>0 ); |
︙ | |||
211587 211588 211589 211590 211591 211592 211593 211594 211595 211596 211597 211598 211599 211600 | 212826 212827 212828 212829 212830 212831 212832 212833 212834 212835 212836 212837 212838 212839 212840 212841 | + + | /* Merge the two position lists. */ i64 iPos1 = 0; i64 iPos2 = 0; int iOff1 = 0; int iOff2 = 0; u8 *a1 = &i1.aPoslist[i1.nSize]; u8 *a2 = &i2.aPoslist[i2.nSize]; int nCopy; u8 *aCopy; i64 iPrev = 0; Fts5PoslistWriter writer; memset(&writer, 0, sizeof(writer)); fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid); fts5BufferZero(&tmp); |
︙ | |||
211618 211619 211620 211621 211622 211623 211624 | 212859 212860 212861 212862 212863 212864 212865 212866 212867 212868 212869 212870 212871 212872 212873 212874 212875 212876 212877 212878 212879 212880 212881 212882 212883 212884 212885 212886 212887 212888 212889 212890 212891 212892 212893 212894 212895 212896 212897 212898 212899 212900 212901 212902 | - + - + + + + + + - + + | if( iPos1<iPos2 ){ if( iPos1!=iPrev ){ sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1); } sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1); if( iPos1<0 ) break; }else{ |
︙ | |||
211743 211744 211745 211746 211747 211748 211749 | 212990 212991 212992 212993 212994 212995 212996 212997 212998 212999 213000 213001 213002 213003 213004 | - + | if( p->rc==SQLITE_OK ){ xMerge(p, &doclist, &aBuf[i]); } fts5BufferFree(&aBuf[i]); } fts5MultiIterFree(p1); |
︙ | |||
212505 212506 212507 212508 212509 212510 212511 | 213752 213753 213754 213755 213756 213757 213758 213759 213760 213761 213762 213763 213764 213765 213766 213767 213768 213769 213770 | - + - + | int iOff; /* Offset of first term on leaf */ int iRowidOff; /* Offset of first rowid on leaf */ int nTerm; /* Size of term on leaf in bytes */ int res; /* Comparison of term and split-key */ iOff = fts5LeafFirstTermOff(pLeaf); iRowidOff = fts5LeafFirstRowidOff(pLeaf); |
︙ | |||
212904 212905 212906 212907 212908 212909 212910 | 214151 214152 214153 214154 214155 214156 214157 214158 214159 214160 214161 214162 214163 214164 214165 214166 214167 214168 214169 214170 214171 214172 214173 214174 214175 214176 214177 214178 214179 214180 214181 | - + - + - | ){ i64 iRowid; /* Rowid for record being decoded */ int iSegid,iHeight,iPgno,bDlidx;/* Rowid components */ const u8 *aBlob; int n; /* Record to decode */ u8 *a = 0; Fts5Buffer s; /* Build up text to return here */ int rc = SQLITE_OK; /* Return code */ |
︙ | |||
213016 213017 213018 213019 213020 213021 213022 213023 213024 213025 213026 213027 213028 213029 213030 213031 213032 213033 213034 213035 213036 213037 213038 213039 213040 | 214262 214263 214264 214265 214266 214267 214268 214269 214270 214271 214272 214273 214274 214275 214276 214277 214278 214279 214280 214281 214282 214283 214284 214285 214286 214287 214288 214289 214290 214291 214292 214293 214294 214295 214296 214297 214298 214299 214300 214301 214302 214303 214304 214305 214306 214307 214308 214309 214310 214311 214312 214313 214314 214315 214316 214317 214318 214319 214320 214321 214322 214323 214324 214325 214326 214327 214328 214329 214330 214331 214332 214333 214334 214335 214336 214337 | + + + + + + + + + + + - + + + + + + + + + + + + + | sqlite3Fts5BufferSet(&rc, &s, 7, (const u8*)"corrupt"); goto decode_out; }else{ iRowidOff = fts5GetU16(&a[0]); iPgidxOff = szLeaf = fts5GetU16(&a[2]); if( iPgidxOff<n ){ fts5GetVarint32(&a[iPgidxOff], iTermOff); }else if( iPgidxOff>n ){ rc = FTS5_CORRUPT; goto decode_out; } } /* Decode the position list tail at the start of the page */ if( iRowidOff!=0 ){ iOff = iRowidOff; }else if( iTermOff!=0 ){ iOff = iTermOff; }else{ iOff = szLeaf; } if( iOff>n ){ rc = FTS5_CORRUPT; goto decode_out; } fts5DecodePoslist(&rc, &s, &a[4], iOff-4); /* Decode any more doclist data that appears on the page before the ** first term. */ nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff; if( nDoclist+iOff>n ){ rc = FTS5_CORRUPT; goto decode_out; } fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist); |
︙ | |||
213178 213179 213180 213181 213182 213183 213184 | 214447 214448 214449 214450 214451 214452 214453 214454 214455 214456 214457 214458 214459 214460 214461 214462 | - - + + | */ SQLITE_API int sqlite3_fts5_may_be_corrupt = 1; typedef struct Fts5Auxdata Fts5Auxdata; typedef struct Fts5Auxiliary Fts5Auxiliary; typedef struct Fts5Cursor Fts5Cursor; |
︙ | |||
213260 213261 213262 213263 213264 213265 213266 | 214529 214530 214531 214532 214533 214534 214535 214536 214537 214538 214539 214540 214541 214542 214543 214544 | - - - - + - - - + | char *zName; /* Name of tokenizer */ void *pUserData; /* User pointer passed to xCreate() */ fts5_tokenizer x; /* Tokenizer functions */ void (*xDestroy)(void*); /* Destructor function */ Fts5TokenizerModule *pNext; /* Next registered tokenizer module */ }; |
︙ | |||
213404 213405 213406 213407 213408 213409 213410 | 214668 214669 214670 214671 214672 214673 214674 214675 214676 214677 214678 214679 214680 214681 214682 | - + | #define FTS5_BEGIN 1 #define FTS5_SYNC 2 #define FTS5_COMMIT 3 #define FTS5_ROLLBACK 4 #define FTS5_SAVEPOINT 5 #define FTS5_RELEASE 6 #define FTS5_ROLLBACKTO 7 |
︙ | |||
213443 213444 213445 213446 213447 213448 213449 | 214707 214708 214709 214710 214711 214712 214713 214714 214715 214716 214717 214718 214719 214720 214721 214722 214723 214724 214725 214726 214727 214728 214729 214730 214731 214732 214733 214734 214735 214736 214737 214738 214739 214740 214741 214742 214743 214744 214745 214746 214747 214748 214749 214750 214751 214752 214753 214754 214755 214756 214757 214758 214759 214760 214761 214762 214763 214764 214765 | - + - - + + - + - + - + - + - + | assert( iSavepoint>=0 ); assert( iSavepoint<=p->ts.iSavepoint ); p->ts.iSavepoint = iSavepoint-1; break; case FTS5_ROLLBACKTO: assert( p->ts.eState==1 ); |
︙ | |||
213516 213517 213518 213519 213520 213521 213522 | 214780 214781 214782 214783 214784 214785 214786 214787 214788 214789 214790 214791 214792 214793 214794 214795 214796 214797 214798 214799 214800 214801 214802 214803 214804 214805 214806 214807 214808 214809 214810 214811 214812 214813 214814 214815 214816 214817 214818 214819 214820 214821 214822 214823 214824 214825 214826 214827 214828 214829 | - + - + - + - + - + - - + + | sqlite3_vtab **ppVTab, /* Write the resulting vtab structure here */ char **pzErr /* Write any error message here */ ){ Fts5Global *pGlobal = (Fts5Global*)pAux; const char **azConfig = (const char**)argv; int rc = SQLITE_OK; /* Return code */ Fts5Config *pConfig = 0; /* Results of parsing argc/argv */ |
︙ | |||
213764 213765 213766 213767 213768 213769 213770 | 215028 215029 215030 215031 215032 215033 215034 215035 215036 215037 215038 215039 215040 215041 215042 215043 215044 215045 215046 215047 215048 215049 215050 215051 215052 215053 215054 215055 215056 215057 215058 215059 215060 215061 215062 215063 | - + - - + + - + - + | } } pInfo->idxNum = idxFlags; return SQLITE_OK; } |
︙ | |||
213823 213824 213825 213826 213827 213828 213829 | 215087 215088 215089 215090 215091 215092 215093 215094 215095 215096 215097 215098 215099 215100 215101 | - + | | FTS5CSR_REQUIRE_DOCSIZE | FTS5CSR_REQUIRE_INST | FTS5CSR_REQUIRE_POSLIST ); } static void fts5FreeCursorComponents(Fts5Cursor *pCsr){ |
︙ | |||
213867 213868 213869 213870 213871 213872 213873 | 215131 215132 215133 215134 215135 215136 215137 215138 215139 215140 215141 215142 215143 215144 215145 | - + | /* ** Close the cursor. For additional information see the documentation ** on the xClose method of the virtual table interface. */ static int fts5CloseMethod(sqlite3_vtab_cursor *pCursor){ if( pCursor ){ |
︙ | |||
213924 213925 213926 213927 213928 213929 213930 | 215188 215189 215190 215191 215192 215193 215194 215195 215196 215197 215198 215199 215200 215201 215202 | - + | } /* ** Set the FTS5CSR_REQUIRE_RESEEK flag on all FTS5_PLAN_MATCH cursors ** open on table pTab. */ |
︙ | |||
213951 213952 213953 213954 213955 213956 213957 | 215215 215216 215217 215218 215219 215220 215221 215222 215223 215224 215225 215226 215227 215228 215229 215230 215231 215232 215233 | - + - + | ** Return SQLITE_OK if successful or if no reseek was required, or an ** error code if an error occurred. */ static int fts5CursorReseek(Fts5Cursor *pCsr, int *pbSkip){ int rc = SQLITE_OK; assert( *pbSkip==0 ); if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_RESEEK) ){ |
︙ | |||
214052 214053 214054 214055 214056 214057 214058 | 215316 215317 215318 215319 215320 215321 215322 215323 215324 215325 215326 215327 215328 215329 215330 215331 215332 215333 215334 215335 215336 215337 215338 215339 215340 215341 215342 215343 215344 215345 | - - + + + + + + - + - + | } va_end(ap); *ppStmt = pRet; return rc; } |
︙ | |||
214100 214101 214102 214103 214104 214105 214106 | 215368 215369 215370 215371 215372 215373 215374 215375 215376 215377 215378 215379 215380 215381 215382 215383 215384 215385 215386 215387 215388 215389 215390 215391 215392 215393 215394 215395 215396 215397 215398 215399 215400 215401 215402 215403 215404 215405 215406 215407 215408 215409 215410 215411 215412 215413 215414 215415 215416 215417 215418 215419 215420 215421 215422 215423 215424 215425 215426 215427 215428 215429 215430 215431 215432 215433 215434 215435 215436 215437 215438 215439 215440 215441 215442 215443 215444 215445 215446 215447 215448 215449 215450 215451 215452 215453 215454 215455 215456 215457 215458 215459 215460 215461 215462 215463 215464 | - + - + - + - + - + - + - + - - + + - + | sqlite3_free(pSorter); pCsr->pSorter = 0; } return rc; } |
︙ | |||
214204 214205 214206 214207 214208 214209 214210 | 215472 215473 215474 215475 215476 215477 215478 215479 215480 215481 215482 215483 215484 215485 215486 215487 | - - + + | } } } if( rc==SQLITE_OK ){ pAux = fts5FindAuxiliary(pTab, zRank); if( pAux==0 ){ |
︙ | |||
214280 214281 214282 214283 214284 214285 214286 | 215548 215549 215550 215551 215552 215553 215554 215555 215556 215557 215558 215559 215560 215561 215562 215563 | - - + + | static int fts5FilterMethod( sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */ int idxNum, /* Strategy index */ const char *zUnused, /* Unused */ int nVal, /* Number of elements in apVal */ sqlite3_value **apVal /* Arguments for the indexing scheme */ ){ |
︙ | |||
214310 214311 214312 214313 214314 214315 214316 | 215578 215579 215580 215581 215582 215583 215584 215585 215586 215587 215588 215589 215590 215591 215592 215593 | - - + + | assert( pCsr->pStmt==0 ); assert( pCsr->pExpr==0 ); assert( pCsr->csrflags==0 ); assert( pCsr->pRank==0 ); assert( pCsr->zRank==0 ); assert( pCsr->zRankArgs==0 ); |
︙ | |||
214377 214378 214379 214380 214381 214382 214383 | 215645 215646 215647 215648 215649 215650 215651 215652 215653 215654 215655 215656 215657 215658 215659 | - + | if( rc==SQLITE_OK ){ if( zExpr[0]=='*' ){ /* The user has issued a query of the form "MATCH '*...'". This ** indicates that the MATCH expression is not a full text query, ** but a request for an internal parameter. */ rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]); }else{ |
︙ | |||
214400 214401 214402 214403 214404 214405 214406 | 215668 215669 215670 215671 215672 215673 215674 215675 215676 215677 215678 215679 215680 215681 215682 | - + | ); rc = SQLITE_ERROR; }else{ /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup ** by rowid (ePlan==FTS5_PLAN_ROWID). */ pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN); rc = sqlite3Fts5StorageStmt( |
︙ | |||
214483 214484 214485 214486 214487 214488 214489 | 215751 215752 215753 215754 215755 215756 215757 215758 215759 215760 215761 215762 215763 215764 215765 215766 215767 215768 215769 215770 | - + - + - + | ** be left in sqlite3_vtab.zErrMsg. */ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){ int rc = SQLITE_OK; /* If the cursor does not yet have a statement handle, obtain one now. */ if( pCsr->pStmt==0 ){ |
︙ | |||
214510 214511 214512 214513 214514 214515 214516 | 215778 215779 215780 215781 215782 215783 215784 215785 215786 215787 215788 215789 215790 215791 215792 215793 215794 215795 215796 215797 215798 215799 215800 215801 215802 215803 215804 215805 215806 215807 215808 215809 215810 215811 215812 215813 215814 215815 215816 215817 215818 215819 215820 | - + - - + + - + - + | rc = FTS5_CORRUPT; } } } return rc; } |
︙ | |||
214573 214574 214575 214576 214577 214578 214579 | 215841 215842 215843 215844 215845 215846 215847 215848 215849 215850 215851 215852 215853 215854 215855 215856 215857 215858 215859 215860 215861 215862 215863 215864 215865 215866 215867 215868 215869 215870 215871 215872 215873 215874 215875 215876 215877 215878 215879 215880 215881 215882 215883 215884 215885 | - + - + - + - + | }else if( 0==sqlite3_stricmp("integrity-check", zCmd) ){ rc = sqlite3Fts5StorageIntegrity(pTab->pStorage); #ifdef SQLITE_DEBUG }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ pConfig->bPrefixIndex = sqlite3_value_int(pVal); #endif }else{ |
︙ | |||
214637 214638 214639 214640 214641 214642 214643 | 215905 215906 215907 215908 215909 215910 215911 215912 215913 215914 215915 215916 215917 215918 215919 215920 215921 215922 215923 215924 215925 215926 215927 215928 215929 215930 215931 215932 215933 | - - + + - - - + + - - + + | */ static int fts5UpdateMethod( sqlite3_vtab *pVtab, /* Virtual table handle */ int nArg, /* Size of argument array */ sqlite3_value **apVal, /* Array of arguments */ sqlite_int64 *pRowid /* OUT: The affected (or effected) rowid */ ){ |
︙ | |||
214693 214694 214695 214696 214697 214698 214699 | 215960 215961 215962 215963 215964 215965 215966 215967 215968 215969 215970 215971 215972 215973 215974 215975 215976 215977 215978 215979 215980 215981 215982 215983 215984 215985 215986 215987 215988 215989 215990 215991 215992 215993 215994 215995 215996 215997 215998 215999 216000 216001 216002 216003 216004 216005 216006 216007 216008 216009 216010 216011 216012 216013 216014 216015 216016 216017 216018 216019 216020 216021 216022 216023 216024 216025 216026 216027 216028 216029 216030 216031 216032 216033 216034 216035 216036 216037 216038 216039 216040 216041 216042 216043 216044 216045 216046 216047 216048 216049 216050 216051 216052 216053 216054 216055 216056 216057 216058 216059 216060 216061 216062 216063 216064 216065 216066 216067 216068 216069 216070 216071 216072 216073 216074 216075 216076 | - + - - - - + + + + + + + + + + + - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - + + - + - + | assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL ); assert( nArg!=1 || eType0==SQLITE_INTEGER ); /* Filter out attempts to run UPDATE or DELETE on contentless tables. ** This is not suported. */ if( eType0==SQLITE_INTEGER && fts5IsContentless(pTab) ){ |
︙ | |||
214813 214814 214815 214816 214817 214818 214819 | 216086 216087 216088 216089 216090 216091 216092 216093 216094 216095 216096 216097 216098 216099 216100 216101 216102 216103 216104 216105 216106 | - + - + | static int fts5ApiColumnTotalSize( Fts5Context *pCtx, int iCol, sqlite3_int64 *pnToken ){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; |
︙ | |||
214854 214855 214856 214857 214858 214859 214860 | 216127 216128 216129 216130 216131 216132 216133 216134 216135 216136 216137 216138 216139 216140 216141 216142 216143 | - + + + | Fts5Context *pCtx, int iCol, const char **pz, int *pn ){ int rc = SQLITE_OK; Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; |
︙ | |||
214923 214924 214925 214926 214927 214928 214929 214930 214931 214932 | 216198 216199 216200 216201 216202 216203 216204 216205 216206 216207 216208 216209 216210 216211 216212 216213 216214 216215 216216 | + - + | ** correctly for the current view. Return SQLITE_OK if successful, or an ** SQLite error code otherwise. */ static int fts5CacheInstArray(Fts5Cursor *pCsr){ int rc = SQLITE_OK; Fts5PoslistReader *aIter; /* One iterator for each phrase */ int nIter; /* Number of iterators/phrases */ int nCol = ((Fts5Table*)pCsr->base.pVtab)->pConfig->nCol; nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr); if( pCsr->aInstIter==0 ){ |
︙ | |||
214961 214962 214963 214964 214965 214966 214967 | 216237 216238 216239 216240 216241 216242 216243 216244 216245 216246 216247 216248 216249 216250 216251 216252 216253 216254 216255 216256 216257 216258 216259 216260 216261 216262 216263 216264 216265 216266 216267 216268 216269 | - + + + + + | } } if( iBest<0 ) break; nInst++; if( nInst>=pCsr->nInstAlloc ){ pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32; |
︙ | |||
215048 215049 215050 215051 215052 215053 215054 | 216328 216329 216330 216331 216332 216333 216334 216335 216336 216337 216338 216339 216340 216341 216342 216343 | - - + + | (*pCnt)++; } return SQLITE_OK; } static int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; |
︙ | |||
215305 215306 215307 215308 215309 215310 215311 | 216585 216586 216587 216588 216589 216590 216591 216592 216593 216594 216595 216596 216597 216598 216599 | - + | static int fts5ApiQueryPhrase( Fts5Context *pCtx, int iPhrase, void *pUserData, int(*xCallback)(const Fts5ExtensionApi*, Fts5Context*, void*) ){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; |
︙ | |||
215382 215383 215384 215385 215386 215387 215388 | 216662 216663 216664 216665 216666 216667 216668 216669 216670 216671 216672 216673 216674 216675 216676 216677 216678 216679 216680 216681 216682 216683 216684 216685 216686 216687 216688 | - + - - - - + - + - - - + - + - - - + + | }else{ fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]); } } /* |
︙ | |||
215480 215481 215482 215483 215484 215485 215486 | 216754 216755 216756 216757 216758 216759 216760 216761 216762 216763 216764 216765 216766 216767 216768 216769 | - - + + | ** the row that the supplied cursor currently points to. */ static int fts5ColumnMethod( sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */ sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */ int iCol /* Index of column to read value from */ ){ |
︙ | |||
215533 215534 215535 215536 215537 215538 215539 | 216807 216808 216809 216810 216811 216812 216813 216814 216815 216816 216817 216818 216819 216820 216821 | - + | static int fts5FindFunctionMethod( sqlite3_vtab *pVtab, /* Virtual table handle */ int nUnused, /* Number of SQL function arguments */ const char *zName, /* Name of SQL function */ void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */ void **ppArg /* OUT: User data for *pxFunc */ ){ |
︙ | |||
215555 215556 215557 215558 215559 215560 215561 | 216829 216830 216831 216832 216833 216834 216835 216836 216837 216838 216839 216840 216841 216842 216843 216844 216845 216846 216847 216848 216849 216850 216851 216852 216853 216854 216855 216856 216857 216858 216859 216860 216861 216862 216863 216864 216865 216866 216867 216868 216869 216870 216871 216872 216873 216874 216875 216876 216877 216878 216879 216880 | - + + + + + + - - + - - + - - + - - + - + | /* ** Implementation of FTS5 xRename method. Rename an fts5 table. */ static int fts5RenameMethod( sqlite3_vtab *pVtab, /* Virtual table handle */ const char *zName /* New name of table */ ){ |
︙ | |||
215792 215793 215794 215795 215796 215797 215798 | 217067 217068 217069 217070 217071 217072 217073 217074 217075 217076 217077 217078 217079 217080 217081 | - + | static void fts5SourceIdFunc( sqlite3_context *pCtx, /* Function call context */ int nArg, /* Number of args */ sqlite3_value **apUnused /* Function arguments */ ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); |
︙ | |||
216041 216042 216043 216044 216045 216046 216047 | 217316 217317 217318 217319 217320 217321 217322 217323 217324 217325 217326 217327 217328 217329 217330 217331 217332 217333 217334 217335 217336 217337 217338 217339 217340 217341 217342 217343 217344 217345 217346 217347 217348 217349 217350 217351 217352 217353 | - + + + - + - | case FTS5_STMT_INSERT_CONTENT: case FTS5_STMT_REPLACE_CONTENT: { int nCol = pC->nCol + 1; char *zBind; int i; |
︙ | |||
216207 216208 216209 216210 216211 216212 216213 | 217483 217484 217485 217486 217487 217488 217489 217490 217491 217492 217493 217494 217495 217496 217497 217498 217499 217500 217501 217502 217503 217504 217505 217506 217507 217508 217509 217510 217511 217512 | - + - + - + | Fts5Index *pIndex, int bCreate, Fts5Storage **pp, char **pzErr /* OUT: Error message */ ){ int rc = SQLITE_OK; Fts5Storage *p; /* New object */ |
︙ | |||
216513 216514 216515 216516 216517 216518 216519 | 217789 217790 217791 217792 217793 217794 217795 217796 217797 217798 217799 217800 217801 217802 217803 | - + | } static int sqlite3Fts5StorageRebuild(Fts5Storage *p){ Fts5Buffer buf = {0,0,0}; Fts5Config *pConfig = p->pConfig; sqlite3_stmt *pScan = 0; Fts5InsertCtx ctx; |
︙ | |||
216552 216553 216554 216555 216556 216557 216558 216559 216560 216561 216562 216563 216564 216565 | 217828 217829 217830 217831 217832 217833 217834 217835 217836 217837 217838 217839 217840 217841 217842 217843 | + + | p->nTotalRow++; if( rc==SQLITE_OK ){ rc = fts5StorageInsertDocsize(p, iRowid, &buf); } } sqlite3_free(buf.p); rc2 = sqlite3_reset(pScan); if( rc==SQLITE_OK ) rc = rc2; /* Write the averages record */ if( rc==SQLITE_OK ){ rc = fts5StorageSaveTotals(p); } return rc; } |
︙ | |||
216801 216802 216803 216804 216805 216806 216807 | 218079 218080 218081 218082 218083 218084 218085 218086 218087 218088 218089 218090 218091 218092 218093 | - + | int *aColSize; /* Array of size pConfig->nCol */ i64 *aTotalSize; /* Array of size pConfig->nCol */ Fts5IntegrityCtx ctx; sqlite3_stmt *pScan; memset(&ctx, 0, sizeof(Fts5IntegrityCtx)); ctx.pConfig = p->pConfig; |
︙ | |||
217001 217002 217003 217004 217005 217006 217007 217008 217009 217010 217011 217012 217013 217014 217015 | 218279 218280 218281 218282 218283 218284 218285 218286 218287 218288 218289 218290 218291 218292 218293 218294 218295 218296 218297 218298 218299 | + + + + + + | } return rc; } static int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow){ int rc = fts5StorageLoadTotals(p, 0); if( rc==SQLITE_OK ){ /* nTotalRow being zero does not necessarily indicate a corrupt ** database - it might be that the FTS5 table really does contain zero ** rows. However this function is only called from the xRowCount() API, ** and there is no way for that API to be invoked if the table contains ** no rows. Hence the FTS5_CORRUPT return. */ *pnRow = p->nTotalRow; if( p->nTotalRow<=0 ) rc = FTS5_CORRUPT; } return rc; } /* ** Flush any data currently held in-memory to disk. */ |
︙ | |||
217211 217212 217213 217214 217215 217216 217217 | 218495 218496 218497 218498 218499 218500 218501 218502 218503 218504 218505 218506 218507 218508 218509 | - + | ie++; } /* Fold to lower case */ nByte = ie-is; if( nByte>nFold ){ if( pFold!=aFold ) sqlite3_free(pFold); |
︙ | |||
217293 217294 217295 217296 217297 217298 217299 | 218577 218578 218579 218580 218581 218582 218583 218584 218585 218586 218587 218588 218589 218590 218591 218592 218593 218594 218595 218596 218597 218598 218599 218600 218601 218602 218603 218604 218605 218606 218607 218608 218609 218610 218611 218612 218613 218614 218615 218616 218617 218618 218619 218620 218621 218622 218623 218624 218625 218626 218627 218628 218629 218630 218631 218632 | - + + + + + + - + + - + - + | #endif /* ifndef SQLITE_AMALGAMATION */ typedef struct Unicode61Tokenizer Unicode61Tokenizer; struct Unicode61Tokenizer { unsigned char aTokenChar[128]; /* ASCII range token characters */ char *aFold; /* Buffer to fold text into */ int nFold; /* Size of aFold[] in bytes */ |
︙ | |||
217420 217421 217422 217423 217424 217425 217426 | 218710 218711 218712 218713 218714 218715 218716 218717 218718 218719 218720 218721 218722 218723 218724 218725 218726 218727 218728 218729 218730 218731 218732 218733 218734 218735 218736 218737 218738 218739 218740 218741 218742 218743 218744 218745 218746 218747 218748 218749 218750 218751 218752 218753 | - + - + + + + + + + - | }else{ p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer)); if( p ){ const char *zCat = "L* N* Co"; int i; memset(p, 0, sizeof(Unicode61Tokenizer)); |
︙ | |||
217478 217479 217480 217481 217482 217483 217484 | 218773 218774 218775 218776 218777 218778 218779 218780 218781 218782 218783 218784 218785 218786 218787 | - + | /* ** Return true if, for the purposes of tokenizing with the tokenizer ** passed as the first argument, codepoint iCode is considered a token ** character (not a separator). */ static int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){ return ( |
︙ | |||
217507 217508 217509 217510 217511 217512 217513 | 218802 218803 218804 218805 218806 218807 218808 218809 218810 218811 218812 218813 218814 218815 218816 | - + | const char *pEnd = &aFold[nFold-6]; UNUSED_PARAM(iUnused); /* Each iteration of this loop gobbles up a contiguous run of separators, ** then the next token. */ while( rc==SQLITE_OK ){ |
︙ | |||
217539 217540 217541 217542 217543 217544 217545 | 218834 218835 218836 218837 218838 218839 218840 218841 218842 218843 218844 218845 218846 218847 218848 218849 218850 218851 218852 218853 218854 218855 218856 218857 218858 218859 218860 218861 218862 218863 218864 218865 218866 218867 | - + - + | /* Run through the tokenchars. Fold them into the output buffer along ** the way. */ while( zCsr<zTerm ){ /* Grow the output buffer so that there is sufficient space to fit the ** largest possible utf-8 character. */ if( zOut>pEnd ){ |
︙ | |||
218334 218335 218336 218337 218338 218339 218340 | 219629 219630 219631 219632 219633 219634 219635 219636 219637 219638 219639 219640 219641 219642 219643 219644 | - - - + | 0 ); } return rc; } |
︙ | |||
218366 218367 218368 218369 218370 218371 218372 | 219659 219660 219661 219662 219663 219664 219665 219666 219667 219668 219669 219670 219671 219672 219673 219674 219675 219676 219677 219678 219679 219680 219681 219682 219683 219684 219685 219686 219687 219688 219689 219690 219691 219692 219693 219694 219695 219696 219697 219698 219699 219700 219701 219702 219703 219704 219705 219706 219707 219708 219709 219710 219711 219712 219713 219714 219715 219716 219717 219718 219719 219720 219721 219722 219723 219724 219725 219726 219727 219728 219729 219730 219731 219732 219733 219734 219735 219736 219737 219738 219739 219740 219741 219742 219743 219744 219745 219746 219747 219748 219749 219750 219751 219752 219753 219754 219755 219756 219757 219758 219759 | - + - - - - - - - - - + + + + + + + + + + + + + - + - - - + + + + + + + + + + + - - - - - - + + + + + + + + + + + - + - - + + - + | ** If the argument is a codepoint corresponding to a lowercase letter ** in the ASCII range with a diacritic added, return the codepoint ** of the ASCII letter only. For example, if passed 235 - "LATIN ** SMALL LETTER E WITH DIAERESIS" - return 65 ("LATIN SMALL LETTER ** E"). The resuls of passing a codepoint that corresponds to an ** uppercase letter are undefined. */ |
︙ | |||
218558 218559 218560 218561 218562 218563 218564 | 219868 219869 219870 219871 219872 219873 219874 219875 219876 219877 219878 219879 219880 219881 219882 219883 219884 219885 219886 219887 219888 219889 219890 219891 219892 219893 219894 | + - + + - - - - - - | assert( iRes>=0 && c>=aEntry[iRes].iCode ); p = &aEntry[iRes]; if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){ ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF; assert( ret>0 ); } if( eRemoveDiacritic ){ |
︙ | |||
219056 219057 219058 219059 219060 219061 219062 | 220362 220363 220364 220365 220366 220367 220368 220369 220370 220371 220372 220373 220374 220375 220376 | - + | 89, 1434, 3226, 506, 474, 506, 506, 367, 1018, 1946, 1402, 954, 1402, 314, 90, 1082, 218, 2266, 666, 1210, 186, 570, 2042, 58, 5850, 154, 2010, 154, 794, 2266, 378, 2266, 3738, 39, 39, 39, 39, 39, 39, 17351, 34, 3074, 7692, 63, 63, }; |
︙ | |||
219094 219095 219096 219097 219098 219099 219100 | 220400 220401 220402 220403 220404 220405 220406 220407 220408 220409 220410 220411 220412 220413 220414 220415 220416 220417 220418 | - + - | static void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){ int i = 0; int iTbl = 0; while( i<128 ){ int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ]; int n = (aFts5UnicodeData[iTbl] >> 5) + i; for(; i<128 && i<n; i++){ |
︙ | |||
219179 219180 219181 219182 219183 219184 219185 | 220484 220485 220486 220487 220488 220489 220490 220491 220492 220493 220494 220495 220496 220497 220498 | - + | ** routine. */ { u64 v64; u8 n; p -= 2; n = sqlite3Fts5GetVarint(p, &v64); |
︙ | |||
219446 219447 219448 219449 219450 219451 219452 | 220751 220752 220753 220754 220755 220756 220757 220758 220759 220760 220761 220762 220763 220764 | - | assert( iVal>=(1 << 7) ); if( iVal<(1 << 14) ) return 2; if( iVal<(1 << 21) ) return 3; if( iVal<(1 << 28) ) return 4; return 5; } |
︙ | |||
219504 219505 219506 219507 219508 219509 219510 | 220808 220809 220810 220811 220812 220813 220814 220815 220816 220817 220818 220819 220820 220821 220822 220823 220824 220825 220826 220827 220828 220829 220830 | - + - | Fts5Global *pGlobal; /* FTS5 global object for this database */ int eType; /* FTS5_VOCAB_COL, ROW or INSTANCE */ }; struct Fts5VocabCursor { sqlite3_vtab_cursor base; sqlite3_stmt *pStmt; /* Statement holding lock on pIndex */ |
︙ | |||
219776 219777 219778 219779 219780 219781 219782 | 221079 221080 221081 221082 221083 221084 221085 221086 221087 221088 221089 221090 221091 221092 221093 221094 221095 221096 221097 221098 221099 221100 221101 221102 221103 221104 221105 221106 221107 221108 221109 221110 221111 221112 221113 221114 221115 221116 221117 221118 221119 221120 221121 221122 221123 221124 221125 221126 221127 221128 221129 221130 221131 221132 221133 221134 221135 221136 221137 221138 221139 221140 221141 221142 221143 221144 221145 221146 221147 221148 221149 221150 221151 221152 221153 221154 221155 | - + - - + - - - - - - - - + + + + + + + + + + + + - + - + - - + + | ** Implementation of xOpen method. */ static int fts5VocabOpenMethod( sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr ){ Fts5VocabTable *pTab = (Fts5VocabTable*)pVTab; |
︙ | |||
219874 219875 219876 219877 219878 219879 219880 | 221180 221181 221182 221183 221184 221185 221186 221187 221188 221189 221190 221191 221192 221193 221194 | - + | sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm); } return rc; } static int fts5VocabInstanceNext(Fts5VocabCursor *pCsr){ |
︙ | |||
219909 219910 219911 219912 219913 219914 219915 | 221215 221216 221217 221218 221219 221220 221221 221222 221223 221224 221225 221226 221227 221228 221229 | - + | /* ** Advance the cursor to the next row in the table. */ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab; int rc = SQLITE_OK; |
︙ | |||
219931 219932 219933 219934 219935 219936 219937 219938 219939 219940 219941 219942 219943 219944 219945 219946 219947 219948 219949 219950 219951 219952 219953 | 221237 221238 221239 221240 221241 221242 221243 221244 221245 221246 221247 221248 221249 221250 221251 221252 221253 221254 221255 221256 221257 221258 221259 221260 221261 221262 221263 221264 221265 221266 221267 221268 | + - + | if( sqlite3Fts5IterEof(pCsr->pIter) ){ pCsr->bEof = 1; }else{ const char *zTerm; int nTerm; zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm); assert( nTerm>=0 ); if( pCsr->nLeTerm>=0 ){ int nCmp = MIN(nTerm, pCsr->nLeTerm); int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp); if( bCmp<0 || (bCmp==0 && pCsr->nLeTerm<nTerm) ){ pCsr->bEof = 1; return SQLITE_OK; } } sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm); memset(pCsr->aCnt, 0, nCol * sizeof(i64)); memset(pCsr->aDoc, 0, nCol * sizeof(i64)); pCsr->iCol = 0; assert( pTab->eType==FTS5_VOCAB_COL || pTab->eType==FTS5_VOCAB_ROW ); while( rc==SQLITE_OK ){ |
︙ | |||
219970 219971 219972 219973 219974 219975 219976 | 221277 221278 221279 221280 221281 221282 221283 221284 221285 221286 221287 221288 221289 221290 221291 221292 221293 221294 221295 221296 221297 221298 221299 | - + | break; case FTS5_VOCAB_COL: if( eDetail==FTS5_DETAIL_FULL ){ int iCol = -1; while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ int ii = FTS5_POS2COLUMN(iPos); |
︙ | |||
220007 220008 220009 220010 220011 220012 220013 | 221314 221315 221316 221317 221318 221319 221320 221321 221322 221323 221324 221325 221326 221327 221328 221329 221330 221331 221332 221333 221334 221335 221336 221337 221338 221339 221340 221341 | - + + + - + | if( rc==SQLITE_OK ){ rc = sqlite3Fts5IterNextScan(pCsr->pIter); } if( pTab->eType==FTS5_VOCAB_INSTANCE ) break; if( rc==SQLITE_OK ){ zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm); |
︙ | |||
220065 220066 220067 220068 220069 220070 220071 220072 220073 220074 220075 220076 220077 220078 220079 220080 220081 220082 | 221374 221375 221376 221377 221378 221379 221380 221381 221382 221383 221384 221385 221386 221387 221388 221389 221390 221391 221392 221393 221394 221395 221396 221397 221398 221399 221400 221401 221402 221403 221404 221405 221406 221407 221408 | + + - + - + - - + + | }else{ if( pGe ){ zTerm = (const char *)sqlite3_value_text(pGe); nTerm = sqlite3_value_bytes(pGe); } if( pLe ){ const char *zCopy = (const char *)sqlite3_value_text(pLe); if( zCopy==0 ) zCopy = ""; pCsr->nLeTerm = sqlite3_value_bytes(pLe); pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1); if( pCsr->zLeTerm==0 ){ rc = SQLITE_NOMEM; }else{ memcpy(pCsr->zLeTerm, zCopy, pCsr->nLeTerm+1); } } } if( rc==SQLITE_OK ){ Fts5Index *pIndex = pCsr->pFts5->pIndex; |
︙ | |||
220106 220107 220108 220109 220110 220111 220112 | 221417 221418 221419 221420 221421 221422 221423 221424 221425 221426 221427 221428 221429 221430 221431 221432 221433 221434 221435 221436 221437 221438 221439 221440 221441 221442 221443 | - + - + | static int fts5VocabColumnMethod( sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */ sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */ int iCol /* Index of column to read value from */ ){ Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; |
︙ | |||
220146 220147 220148 220149 220150 220151 220152 | 221457 221458 221459 221460 221461 221462 221463 221464 221465 221466 221467 221468 221469 221470 221471 221472 | - - + + | case 2: { int ii = -1; if( eDetail==FTS5_DETAIL_FULL ){ ii = FTS5_POS2COLUMN(pCsr->iInstPos); }else if( eDetail==FTS5_DETAIL_COLUMNS ){ ii = (int)pCsr->iInstPos; } |
︙ | |||
220520 220521 220522 220523 220524 220525 220526 | 221831 221832 221833 221834 221835 221836 221837 221838 221839 221840 221841 221842 221843 221844 | - + - + | #endif return rc; } #endif /* SQLITE_CORE */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ /************** End of stmt.c ************************************************/ |
Changes to SQLite.Interop/src/core/sqlite3.h.
︙ | |||
119 120 121 122 123 124 125 | 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | - - - + + + | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ |
︙ | |||
819 820 821 822 823 824 825 826 827 828 829 830 831 832 | 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 | + + + + + + + + + | ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS ** layer a hint of how large the database file will grow to be during the ** current transaction. This hint is not guaranteed to be accurate but it ** is often close. The underlying VFS might choose to preallocate database ** file space based on this hint in order to help writes to the database ** file run faster. ** ** <li>[[SQLITE_FCNTL_SIZE_LIMIT]] ** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that ** implements [sqlite3_deserialize()] to set an upper bound on the size ** of the in-memory database. The argument is a pointer to a [sqlite3_int64]. ** If the integer pointed to is negative, then it is filled in with the ** current limit. Otherwise the limit is set to the larger of the value ** of the integer pointed to and the current database size. The integer ** pointed to is set to the new limit. ** ** <li>[[SQLITE_FCNTL_CHUNK_SIZE]] ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS ** extends and truncates the database file in chunks of a size specified ** by the user. The fourth argument to [sqlite3_file_control()] should ** point to an integer (type int) containing the new chunk-size to use ** for the nominated database. Allocating database file space in large ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
︙ | |||
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 | 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | + | #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 #define SQLITE_FCNTL_LOCK_TIMEOUT 34 #define SQLITE_FCNTL_DATA_VERSION 35 #define SQLITE_FCNTL_SIZE_LIMIT 36 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
︙ | |||
1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 | 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 | + + + + + + + + + + + | ** than the configured sorter-reference size threshold - then a reference ** is stored in each sorted record and the required column values loaded ** from the database as records are returned in sorted order. The default ** value for this option is to never use this optimization. Specifying a ** negative value for this option restores the default behaviour. ** This option is only available if SQLite is compiled with the ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option. ** ** [[SQLITE_CONFIG_MEMDB_MAXSIZE]] ** <dt>SQLITE_CONFIG_MEMDB_MAXSIZE ** <dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter ** [sqlite3_int64] parameter which is the default maximum size for an in-memory ** database created using [sqlite3_deserialize()]. This default maximum ** size can be adjusted up or down for individual databases using the ** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control]. If this ** configuration setting is never used, then the default maximum is determined ** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that ** compile-time option is not set, then the default maximum is 1073741824. ** </dl> */ #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ #define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ #define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ |
︙ | |||
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 | 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 | + | #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */ #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */ #define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */ #define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */ #define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */ #define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */ #define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */ #define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */ /* ** CAPI3REF: Database Connection Configuration Options ** ** These constants are the available integer configuration options that ** can be passed as the second argument to the [sqlite3_db_config()] interface. ** |
︙ | |||
2987 2988 2989 2990 2991 2992 2993 | 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 | - - - + + + | ** ^The callback function registered by sqlite3_profile() is invoked ** as each SQL statement finishes. ^The profile callback contains ** the original statement text and an estimate of wall-clock time ** of how long that statement took to run. ^The profile callback ** time is in units of nanoseconds, however the current implementation ** is only capable of millisecond resolution so the six least significant ** digits in the time are meaningless. Future versions of SQLite |
︙ | |||
3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 | 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 | + + | ** zero is returned. ** ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and ** is not a database file pathname pointer that SQLite passed into the xOpen ** VFS method, then the behavior of this routine is undefined and probably ** undesirable. ** ** See the [URI filename] documentation for additional information. */ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam); SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault); SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64); /* |
︙ | |||
3625 3626 3627 3628 3629 3630 3631 | 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 | - - + + - - - - - - + + + + + + + + + + + | ** and [sqlite3_prepare16_v3()] assume that the prepared statement will ** be used just once or at most a few times and then destroyed using ** [sqlite3_finalize()] relatively soon. The current implementation acts ** on this hint by avoiding the use of [lookaside memory] so as not to ** deplete the limited store of lookaside memory. Future versions of ** SQLite may act on this hint differently. ** |
︙ | |||
9992 9993 9994 9995 9996 9997 9998 | 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 | - + | ** ** If argument pzTab is not NULL, then *pzTab is set to point to a ** nul-terminated utf-8 encoded string containing the name of the table ** affected by the current change. The buffer remains valid until either ** sqlite3changeset_next() is called on the iterator or until the ** conflict-handler function returns. If pnCol is not NULL, then *pnCol is ** set to the number of columns in the table affected by the change. If |
︙ | |||
11226 11227 11228 11229 11230 11231 11232 | 11255 11256 11257 11258 11259 11260 11261 11262 11263 11264 11265 11266 11267 11268 11269 11270 | - - - - - - + + | ** Query for the details of phrase match iIdx within the current row. ** Phrase matches are numbered starting from zero, so the iIdx argument ** should be greater than or equal to zero and smaller than the value ** output by xInstCount(). ** ** Usually, output parameter *piPhrase is set to the phrase number, *piCol ** to the column in which it occurs and *piOff the token offset of the |
︙ | |||
11520 11521 11522 11523 11524 11525 11526 | 11545 11546 11547 11548 11549 11550 11551 11552 11553 11554 11555 11556 11557 11558 11559 11560 11561 11562 11563 | - - - - - + + + + + | ** same token for inputs "first" and "1st". Say that token is in ** fact "first", so that when the user inserts the document "I won ** 1st place" entries are added to the index for tokens "i", "won", ** "first" and "place". If the user then queries for '1st + place', ** the tokenizer substitutes "first" for "1st" and the query works ** as expected. ** |
︙ | |||
11548 11549 11550 11551 11552 11553 11554 | 11573 11574 11575 11576 11577 11578 11579 11580 11581 11582 11583 11584 11585 11586 11587 | - + | ** Using this method, when tokenizing document text, the tokenizer ** provides multiple synonyms for each token. So that when a ** document such as "I won first place" is tokenized, entries are ** added to the FTS index for "i", "won", "first", "1st" and ** "place". ** ** This way, even if the tokenizer does not provide synonyms |
︙ |
Changes to SQLite.Interop/src/ext/fts5.c.
︙ | |||
128 129 130 131 132 133 134 | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | - - - - - - + + | ** Query for the details of phrase match iIdx within the current row. ** Phrase matches are numbered starting from zero, so the iIdx argument ** should be greater than or equal to zero and smaller than the value ** output by xInstCount(). ** ** Usually, output parameter *piPhrase is set to the phrase number, *piCol ** to the column in which it occurs and *piOff the token offset of the |
︙ | |||
422 423 424 425 426 427 428 | 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | - - - - - + + + + + | ** same token for inputs "first" and "1st". Say that token is in ** fact "first", so that when the user inserts the document "I won ** 1st place" entries are added to the index for tokens "i", "won", ** "first" and "place". If the user then queries for '1st + place', ** the tokenizer substitutes "first" for "1st" and the query works ** as expected. ** |
︙ | |||
450 451 452 453 454 455 456 | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | - + | ** Using this method, when tokenizing document text, the tokenizer ** provides multiple synonyms for each token. So that when a ** document such as "I won first place" is tokenized, entries are ** added to the FTS index for "i", "won", "first", "1st" and ** "place". ** ** This way, even if the tokenizer does not provide synonyms |
︙ | |||
676 677 678 679 680 681 682 683 684 685 686 687 688 689 | 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | + + + + + + | #ifdef SQLITE_DEBUG extern int sqlite3_fts5_may_be_corrupt; # define assert_nc(x) assert(sqlite3_fts5_may_be_corrupt || (x)) #else # define assert_nc(x) assert(x) #endif /* ** A version of memcmp() that does not cause asan errors if one of the pointer ** parameters is NULL and the number of bytes to compare is zero. */ #define fts5Memcmp(s1, s2, n) ((n)==0 ? 0 : memcmp((s1), (s2), (n))) /* Mark a function parameter as unused, to suppress nuisance compiler ** warnings. */ #ifndef UNUSED_PARAM # define UNUSED_PARAM(X) (void)(X) #endif #ifndef UNUSED_PARAM2 |
︙ | |||
863 864 865 866 867 868 869 | 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 | - + | ) /* Write and decode big-endian 32-bit integer values */ static void sqlite3Fts5Put32(u8*, int); static int sqlite3Fts5Get32(const u8*); #define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32) |
︙ | |||
898 899 900 901 902 903 904 | 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 | - + | static int sqlite3Fts5PoslistNext64( const u8 *a, int n, /* Buffer containing poslist */ int *pi, /* IN/OUT: Offset within a[] */ i64 *piOff /* IN/OUT: Current offset */ ); /* Malloc utility */ |
︙ | |||
1109 1110 1111 1112 1113 1114 1115 | 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 | - + + + + + + + + + + + - + + + | /* ** End of interface to code in fts5_varint.c. **************************************************************************/ /************************************************************************** |
︙ | |||
1377 1378 1379 1380 1381 1382 1383 | 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 | - + | /************************************************************************** ** Interface to automatically generated code in fts5_unicode2.c. */ static int sqlite3Fts5UnicodeIsdiacritic(int c); static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic); static int sqlite3Fts5UnicodeCatParse(const char*, u8*); |
︙ | |||
2297 2298 2299 2300 2301 2302 2303 | 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | fts5yytos = fts5yypParser->fts5yytos; fts5yytos->stateno = fts5yyNewState; fts5yytos->major = fts5yyMajor; fts5yytos->minor.fts5yy0 = fts5yyMinor; fts5yyTraceShift(fts5yypParser, fts5yyNewState, "Shift"); } |
︙ | |||
2363 2364 2365 2366 2367 2368 2369 | 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 | - + - + | int fts5yysize; /* Amount to pop the stack */ sqlite3Fts5ParserARG_FETCH (void)fts5yyLookahead; (void)fts5yyLookaheadToken; fts5yymsp = fts5yypParser->fts5yytos; #ifndef NDEBUG if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){ |
︙ | |||
2421 2422 2423 2424 2425 2426 2427 | 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 | - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + | ** break; */ /********** Begin reduce actions **********************************************/ fts5YYMINORTYPE fts5yylhsminor; case 0: /* input ::= expr */ #line 82 "fts5parse.y" { sqlite3Fts5ParseFinished(pParse, fts5yymsp[0].minor.fts5yy24); } |
︙ | |||
2678 2679 2680 2681 2682 2683 2684 | 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 | - + | /************ Begin %syntax_error code ****************************************/ #line 30 "fts5parse.y" UNUSED_PARAM(fts5yymajor); /* Silence a compiler warning */ sqlite3Fts5ParseError( pParse, "fts5: syntax error near \"%.*s\"",FTS5TOKEN.n,FTS5TOKEN.p ); |
︙ | |||
3052 3053 3054 3055 3056 3057 3058 | 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 | - + | ** *pRc is set to an error code before returning. */ static void fts5HighlightAppend( int *pRc, HighlightContext *p, const char *z, int n ){ |
︙ | |||
3184 3185 3186 3187 3188 3189 3190 | 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 | - + | ** error occurs. */ static int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){ if( p->nFirstAlloc==p->nFirst ){ int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64; int *aNew; |
︙ | |||
3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 | 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 | + - + - + | int ip = 0; int ic = 0; int iOff = 0; int iFirst = -1; int nInst; int nScore = 0; int iLast = 0; sqlite3_int64 iEnd = (sqlite3_int64)iPos + nToken; rc = pApi->xInstCount(pFts, &nInst); for(i=0; i<nInst && rc==SQLITE_OK; i++){ rc = pApi->xInst(pFts, i, &ip, &ic, &iOff); |
︙ | |||
3358 3359 3360 3361 3362 3363 3364 | 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 | + + - + | for(ii=0; rc==SQLITE_OK && ii<nInst; ii++){ int ip, ic, io; int iAdj; int nScore; int jj; rc = pApi->xInst(pFts, ii, &ip, &ic, &io); if( ic!=i ) continue; if( io>nDocsize ) rc = FTS5_CORRUPT; |
︙ | |||
3484 3485 3486 3487 3488 3489 3490 | 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 | - + - + + | Fts5Bm25Data *p; /* Object to return */ p = pApi->xGetAuxdata(pFts, 0); if( p==0 ){ int nPhrase; /* Number of phrases in query */ sqlite3_int64 nRow = 0; /* Number of rows in table */ sqlite3_int64 nToken = 0; /* Number of tokens in table */ |
︙ | |||
3627 3628 3629 3630 3631 3632 3633 | 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 | - - - + - + | aBuiltin[i].xDestroy ); } return rc; } |
︙ | |||
3684 3685 3686 3687 3688 3689 3690 | 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 | - + | aBuf[0] = (iVal>>24) & 0x00FF; aBuf[1] = (iVal>>16) & 0x00FF; aBuf[2] = (iVal>> 8) & 0x00FF; aBuf[3] = (iVal>> 0) & 0x00FF; } static int sqlite3Fts5Get32(const u8 *aBuf){ |
︙ | |||
3815 3816 3817 3818 3819 3820 3821 | 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 | - + | int iVal; fts5FastGetVarint32(a, i, iVal); if( iVal==1 ){ fts5FastGetVarint32(a, i, iVal); iOff = ((i64)iVal) << 32; fts5FastGetVarint32(a, i, iVal); } |
︙ | |||
3876 3877 3878 3879 3880 3881 3882 | 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 | - + - + | ){ int rc = 0; /* Initialized only to suppress erroneous warning from Clang */ if( fts5BufferGrow(&rc, pBuf, 5+5+5) ) return rc; sqlite3Fts5PoslistSafeAppend(pBuf, &pWriter->iPrev, iPos); return SQLITE_OK; } |
︙ | |||
4323 4324 4325 4326 4327 4328 4329 | 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 | - + | } assert( pConfig->nPrefix<=FTS5_MAX_PREFIX_INDEXES ); return rc; } if( sqlite3_strnicmp("tokenize", zCmd, nCmd)==0 ){ const char *p = (const char*)zArg; |
︙ | |||
4453 4454 4455 4456 4457 4458 4459 | 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 | - - + + | int *pRc, /* IN/OUT: Error code */ const char *zIn, /* Buffer to gobble string/bareword from */ char **pzOut, /* OUT: malloc'd buffer containing str/bw */ int *pbQuoted /* OUT: Set to true if dequoting required */ ){ const char *zRet = 0; |
︙ | |||
4557 4558 4559 4560 4561 4562 4563 | 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 | - + | const char **azArg, /* Array of nArg CREATE VIRTUAL TABLE args */ Fts5Config **ppOut, /* OUT: Results of parse */ char **pzErr /* OUT: Error message */ ){ int rc = SQLITE_OK; /* Return code */ Fts5Config *pRet; /* New object to return */ int i; |
︙ | |||
5202 5203 5204 5205 5206 5207 5208 | 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 | - + | } } *pz = &pToken->p[pToken->n]; return tok; } |
︙ | |||
5347 5348 5349 5350 5351 5352 5353 | 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 | - - + + | assert( pTerm->pSynonym ); for(p=pTerm; p; p=p->pSynonym){ Fts5IndexIter *pIter = p->pIter; if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){ if( pIter->nData==0 ) continue; if( nIter==nAlloc ){ |
︙ | |||
5428 5429 5430 5431 5432 5433 5434 | 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 | - - + + | int bFirst = pPhrase->aTerm[0].bFirst; fts5BufferZero(&pPhrase->poslist); /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ if( pPhrase->nTerm>ArraySize(aStatic) ){ |
︙ | |||
5563 5564 5565 5566 5567 5568 5569 | 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 | - + | int bMatch; assert( pNear->nPhrase>1 ); /* If the aStatic[] array is not large enough, allocate a large array ** using sqlite3_malloc(). This approach could be improved upon. */ if( pNear->nPhrase>ArraySize(aStatic) ){ |
︙ | |||
6472 6473 6474 6475 6476 6477 6478 | 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 | + - - + + - + + - + | Fts5ExprNearset *pRet = 0; if( pParse->rc==SQLITE_OK ){ if( pPhrase==0 ){ return pNear; } if( pNear==0 ){ sqlite3_int64 nByte; |
︙ | |||
6547 6548 6549 6550 6551 6552 6553 | 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 | - - + + - + | /* If an error has already occurred, this is a no-op */ if( pCtx->rc!=SQLITE_OK ) return pCtx->rc; if( nToken>FTS5_MAX_TOKEN_SIZE ) nToken = FTS5_MAX_TOKEN_SIZE; if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){ Fts5ExprTerm *pSyn; |
︙ | |||
6650 6651 6652 6653 6654 6655 6656 | 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 | - + - + | pParse->rc = rc; fts5ExprPhraseFree(sCtx.pPhrase); sCtx.pPhrase = 0; }else{ if( pAppend==0 ){ if( (pParse->nPhrase % 8)==0 ){ |
︙ | |||
6707 6708 6709 6710 6711 6712 6713 | 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 | + + - - + + | if( rc==SQLITE_OK ){ pNew->pRoot->pNear = (Fts5ExprNearset*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprNearset) + sizeof(Fts5ExprPhrase*)); } if( rc==SQLITE_OK ){ Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset; if( pColsetOrig ){ sqlite3_int64 nByte; Fts5Colset *pColset; |
︙ | |||
6828 6829 6830 6831 6832 6833 6834 | 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 | - + | ){ int nCol = p ? p->nCol : 0; /* Num. columns already in colset object */ Fts5Colset *pNew; /* New colset object to return */ assert( pParse->rc==SQLITE_OK ); assert( iCol>=0 && iCol<pParse->pConfig->nCol ); |
︙ | |||
6924 6925 6926 6927 6928 6929 6930 | 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 | - + | ** Otherwise, a copy of (*pOrig) is made into memory obtained from ** sqlite3Fts5MallocZero() and a pointer to it returned. If the allocation ** fails, (*pRc) is set to SQLITE_NOMEM and NULL is returned. */ static Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){ Fts5Colset *pRet; if( pOrig ){ |
︙ | |||
7078 7079 7080 7081 7082 7083 7084 | 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 | - + | Fts5ExprNode *pRight, /* Right hand child expression */ Fts5ExprNearset *pNear /* For STRING expressions, the near cluster */ ){ Fts5ExprNode *pRet = 0; if( pParse->rc==SQLITE_OK ){ int nChild = 0; /* Number of children of returned node */ |
︙ | |||
7210 7211 7212 7213 7214 7215 7216 | 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 | - + - + | } } return pRet; } static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){ |
︙ | |||
7458 7459 7460 7461 7462 7463 7464 | 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 | - + | if( bTcl && nArg>1 ){ zNearsetCmd = (const char*)sqlite3_value_text(apVal[1]); iArg = 2; } nConfig = 3 + (nArg-iArg); |
︙ | |||
7544 7545 7546 7547 7548 7549 7550 | 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 | - + | return; } memset(aArr, 0, sizeof(aArr)); sqlite3Fts5UnicodeCatParse("L*", aArr); sqlite3Fts5UnicodeCatParse("N*", aArr); sqlite3Fts5UnicodeCatParse("Co", aArr); iCode = sqlite3_value_int(apVal[0]); |
︙ | |||
7639 7640 7641 7642 7643 7644 7645 | 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 | - + | Fts5PoslistWriter writer; int bOk; /* True if ok to populate */ int bMiss; }; static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){ Fts5PoslistPopulator *pRet; |
︙ | |||
7839 7840 7841 7842 7843 7844 7845 | 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 | - | *ppCollist = 0; *pnCollist = 0; } return rc; } |
︙ | |||
7933 7934 7935 7936 7937 7938 7939 | 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 | - + - + | int rc = SQLITE_OK; Fts5Hash *pNew; *ppNew = pNew = (Fts5Hash*)sqlite3_malloc(sizeof(Fts5Hash)); if( pNew==0 ){ rc = SQLITE_NOMEM; }else{ |
︙ | |||
8008 8009 8010 8011 8012 8013 8014 | 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 | - + | */ static int fts5HashResize(Fts5Hash *pHash){ int nNew = pHash->nSlot*2; int i; Fts5HashEntry **apNew; Fts5HashEntry **apOld = pHash->aSlot; |
︙ | |||
8102 8103 8104 8105 8106 8107 8108 | 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 | - + - + | } } /* If an existing hash entry cannot be found, create a new one. */ if( p==0 ){ /* Figure out how much space to allocate */ char *zKey; |
︙ | |||
8152 8153 8154 8155 8156 8157 8158 | 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 | - + - + - + | ** + 9 bytes for a new rowid, ** + 4 byte reserved for the "poslist size" varint. ** + 1 byte for a "new column" byte, ** + 3 bytes for a new column number (16-bit max) as a varint, ** + 5 bytes for the new position offset (32-bit max). */ if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){ |
︙ | |||
8281 8282 8283 8284 8285 8286 8287 | 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 | - + | const int nMergeSlot = 32; Fts5HashEntry **ap; Fts5HashEntry *pList; int iSlot; int i; *ppSorted = 0; |
︙ | |||
8326 8327 8328 8329 8330 8331 8332 | 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 | + - + | ){ unsigned int iHash = fts5HashKey(pHash->nSlot, (const u8*)pTerm, nTerm); char *zKey = 0; Fts5HashEntry *p; for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){ zKey = fts5EntryKey(p); assert( p->nKey+1==(int)strlen(zKey) ); |
︙ | |||
8377 8378 8379 8380 8381 8382 8383 | 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 | - | *pnDoclist = p->nData - (sizeof(Fts5HashEntry) + nTerm + 1); }else{ *pzTerm = 0; *ppDoclist = 0; *pnDoclist = 0; } } |
︙ | |||
8894 8895 8896 8897 8898 8899 8900 | 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 | - | ** Used by sqlite3Fts5IterPoslist() when the poslist needs to be buffered. ** There is no way to tell if this is populated or not. */ struct Fts5Iter { Fts5IndexIter base; /* Base class containing output vars */ Fts5Index *pIndex; /* Index that owns this iterator */ |
︙ | |||
8955 8956 8957 8958 8959 8960 8961 | 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 | - + | /* ** Allocate and return a buffer at least nByte bytes in size. ** ** If an OOM error is encountered, return NULL and set the error code in ** the Fts5Index handle passed as the first argument. */ |
︙ | |||
8989 8990 8991 8992 8993 8994 8995 | 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 | - + | ** Return -ve if pLeft is smaller than pRight, 0 if they are equal or ** +ve if pRight is smaller than pLeft. In other words: ** ** res = *pLeft - *pRight */ static int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){ int nCmp = MIN(pLeft->n, pRight->n); |
︙ | |||
9055 9056 9057 9058 9059 9060 9061 | 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 | - - + + + | ** table, missing row, non-blob/text in block column - indicate ** backing store corruption. */ if( rc==SQLITE_ERROR ) rc = FTS5_CORRUPT; if( rc==SQLITE_OK ){ u8 *aOut = 0; /* Read blob data into this buffer */ int nByte = sqlite3_blob_bytes(p->pReader); |
︙ | |||
9111 9112 9113 9114 9115 9116 9117 | 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 | - + + | Fts5Index *p, sqlite3_stmt **ppStmt, char *zSql ){ if( p->rc==SQLITE_OK ){ if( zSql ){ p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1, |
︙ | |||
9152 9153 9154 9155 9156 9157 9158 | 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 | - - - - - - + - - - - - - | ** ** DELETE FROM %_data WHERE id BETWEEN $iFirst AND $iLast */ static void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){ if( p->rc!=SQLITE_OK ) return; if( p->pDeleter==0 ){ |
︙ | |||
9240 9241 9242 9243 9244 9245 9246 | 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 | - + + + + + + | Fts5Structure **ppOut /* OUT: Deserialized object */ ){ int rc = SQLITE_OK; int i = 0; int iLvl; int nLevel = 0; int nSegment = 0; |
︙ | |||
9273 9274 9275 9276 9277 9278 9279 | 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 9343 9344 9345 9346 9347 9348 9349 9350 9351 9352 9353 9354 9355 9356 9357 9358 9359 9360 9361 9362 9363 9364 9365 9366 9367 9368 9369 9370 9371 9372 9373 9374 9375 9376 9377 9378 9379 9380 9381 | - + + + - - - - - - + + + + + + + + + + + + + + - + - + | int iSeg; if( i>=nData ){ rc = FTS5_CORRUPT; }else{ i += fts5GetVarint32(&pData[i], pLvl->nMerge); i += fts5GetVarint32(&pData[i], nTotal); |
︙ | |||
9339 9340 9341 9342 9343 9344 9345 | 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 | - + - + | int iLvl, int nExtra, int bInsert ){ if( *pRc==SQLITE_OK ){ Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl]; Fts5StructureSegment *aNew; |
︙ | |||
9856 9857 9858 9859 9860 9861 9862 | 9909 9910 9911 9912 9913 9914 9915 9916 9917 9918 9919 9920 9921 9922 9923 9924 9925 9926 | - + - + | int iLeafPg /* Leaf page number to load dlidx for */ ){ Fts5DlidxIter *pIter = 0; int i; int bDone = 0; for(i=0; p->rc==SQLITE_OK && bDone==0; i++){ |
︙ | |||
10029 10030 10031 10032 10033 10034 10035 | 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 | - + + | */ static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){ u8 *a = pIter->pLeaf->p; /* Buffer to read data from */ int iOff = pIter->iLeafOffset; /* Offset to read at */ int nNew; /* Bytes of new data */ iOff += fts5GetVarint32(&a[iOff], nNew); |
︙ | |||
10099 10100 10101 10102 10103 10104 10105 | 10153 10154 10155 10156 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 10167 | - + | pIter->iLeafPgno = pSeg->pgnoFirst-1; fts5SegIterNextPage(p, pIter); } if( p->rc==SQLITE_OK ){ pIter->iLeafOffset = 4; assert_nc( pIter->pLeaf->nn>4 ); |
︙ | |||
10155 10156 10157 10158 10159 10160 10161 | 10209 10210 10211 10212 10213 10214 10215 10216 10217 10218 10219 10220 10221 10222 10223 | - + | if( i>=n ) break; i += fts5GetVarint(&a[i], (u64*)&iDelta); pIter->iRowid += iDelta; /* If necessary, grow the pIter->aRowidOffset[] array. */ if( iRowidOffset>=pIter->nRowidOffset ){ int nNew = pIter->nRowidOffset + 8; |
︙ | |||
10609 10610 10611 10612 10613 10614 10615 | 10663 10664 10665 10666 10667 10668 10669 10670 10671 10672 10673 10674 10675 10676 10677 10678 10679 10680 | - - - - + + + + | const u8 *pTerm, int nTerm /* Term to search for */ ){ int iOff; const u8 *a = pIter->pLeaf->p; int szLeaf = pIter->pLeaf->szLeaf; int n = pIter->pLeaf->nn; |
︙ | |||
10636 10637 10638 10639 10640 10641 10642 | 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 | - - - + + + - + | fts5FastGetVarint32(a, iOff, nNew); if( nKeep<nMatch ){ goto search_failed; } assert( nKeep>=nMatch ); if( nKeep==nMatch ){ |
︙ | |||
10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 | 10742 10743 10744 10745 10746 10747 10748 10749 10750 10751 10752 10753 10754 10755 10756 10757 10758 10759 10760 10761 10762 10763 10764 10765 10766 10767 10768 10769 10770 10771 10772 10773 | + - + + + + | if( pIter->pLeaf==0 ) return; a = pIter->pLeaf->p; if( fts5LeafIsTermless(pIter->pLeaf)==0 ){ iPgidx = pIter->pLeaf->szLeaf; iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff); if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){ p->rc = FTS5_CORRUPT; return; }else{ nKeep = 0; iTermOff = iOff; n = pIter->pLeaf->nn; iOff += fts5GetVarint32(&a[iOff], nNew); break; } } }while( 1 ); } search_success: |
︙ | |||
10808 10809 10810 10811 10812 10813 10814 | 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 | - + | ** ** 1) an error has occurred, or ** 2) the iterator points to EOF, or ** 3) the iterator points to an entry with term (pTerm/nTerm), or ** 4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points ** to an entry with a term greater than or equal to (pTerm/nTerm). */ |
︙ | |||
10906 10907 10908 10909 10910 10911 10912 | 10964 10965 10966 10967 10968 10969 10970 10971 10972 10973 10974 10975 10976 10977 10978 | - + | if( p1->pLeaf || p2->pLeaf ){ if( p1->pLeaf==0 ){ assert( pRes->iFirst==i2 ); }else if( p2->pLeaf==0 ){ assert( pRes->iFirst==i1 ); }else{ int nMin = MIN(p1->term.n, p2->term.n); |
︙ | |||
11129 11130 11131 11132 11133 11134 11135 | 11187 11188 11189 11190 11191 11192 11193 11194 11195 11196 11197 11198 11199 11200 | - | */ static void fts5MultiIterFree(Fts5Iter *pIter){ if( pIter ){ int i; for(i=0; i<pIter->nSeg; i++){ fts5SegIterClear(&pIter->aSeg[i]); } |
︙ | |||
11477 11478 11479 11480 11481 11482 11483 | 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 11547 11548 11549 | - + + | */ static void fts5SegiterPoslist( Fts5Index *p, Fts5SegIter *pSeg, Fts5Colset *pColset, Fts5Buffer *pBuf ){ |
︙ | |||
11775 11776 11777 11778 11779 11780 11781 | 11833 11834 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 | - - | nSeg = MIN(pStruct->aLevel[iLevel].nSeg, nSegment); } } *ppOut = pNew = fts5MultiIterAlloc(p, nSeg); if( pNew==0 ) return; pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC)); pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY)); |
︙ | |||
11955 11956 11957 11958 11959 11960 11961 | 12011 12012 12013 12014 12015 12016 12017 12018 12019 12020 12021 12022 12023 12024 12025 12026 12027 12028 12029 12030 12031 12032 12033 12034 12035 12036 12037 12038 12039 12040 12041 12042 12043 12044 12045 12046 12047 12048 12049 12050 | - - + + - + - + - + - + | int iLvl, iSeg; int i; u32 mask; memset(aUsed, 0, sizeof(aUsed)); for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){ for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){ int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid; |
︙ | |||
12050 12051 12052 12053 12054 12055 12056 | 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 | - + | */ static int fts5WriteDlidxGrow( Fts5Index *p, Fts5SegWriter *pWriter, int nLvl ){ if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){ |
︙ | |||
12129 12130 12131 12132 12133 12134 12135 | 12185 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 | + - - + + + | */ static void fts5WriteBtreeTerm( Fts5Index *p, /* FTS5 backend object */ Fts5SegWriter *pWriter, /* Writer object */ int nTerm, const u8 *pTerm /* First term on new page */ ){ fts5WriteFlushBtree(p, pWriter); if( p->rc==SQLITE_OK ){ |
︙ | |||
12281 12282 12283 12284 12285 12286 12287 12288 12289 12290 12291 12292 12293 12294 12295 12296 12297 12298 12299 12300 12301 12302 12303 | 12339 12340 12341 12342 12343 12344 12345 12346 12347 12348 12349 12350 12351 12352 12353 12354 12355 12356 12357 12358 12359 12360 12361 12362 12363 | + + | Fts5Index *p, Fts5SegWriter *pWriter, int nTerm, const u8 *pTerm ){ int nPrefix; /* Bytes of prefix compression for term */ Fts5PageWriter *pPage = &pWriter->writer; Fts5Buffer *pPgidx = &pWriter->writer.pgidx; int nMin = MIN(pPage->term.n, nTerm); assert( p->rc==SQLITE_OK ); assert( pPage->buf.n>=4 ); assert( pPage->buf.n>4 || pWriter->bFirstTermInPage ); /* If the current leaf page is full, flush it to disk. */ if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){ if( pPage->buf.n>4 ){ fts5WriteFlushLeaf(p, pWriter); if( p->rc!=SQLITE_OK ) return; } fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING); } /* TODO1: Updating pgidx here. */ pPgidx->n += sqlite3Fts5PutVarint( &pPgidx->p[pPgidx->n], pPage->buf.n - pPage->iPrevPgidx |
︙ | |||
12322 12323 12324 12325 12326 12327 12328 | 12382 12383 12384 12385 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 | - + + - + | ** Usually, the previous term is available in pPage->term. The exception ** is if this is the first term written in an incremental-merge step. ** In this case the previous term is not available, so just write a ** copy of (pTerm/nTerm) into the parent node. This is slightly ** inefficient, but still correct. */ int n = nTerm; if( pPage->term.n ){ |
︙ | |||
12375 12376 12377 12378 12379 12380 12381 | 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 | - + | fts5WriteDlidxAppend(p, pWriter, iRowid); } /* Write the rowid. */ if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){ fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid); }else{ |
︙ | |||
12497 12498 12499 12500 12501 12502 12503 | 12558 12559 12560 12561 12562 12563 12564 12565 12566 12567 12568 12569 12570 12571 12572 12573 12574 12575 12576 12577 12578 12579 12580 12581 12582 12583 12584 12585 12586 12587 12588 12589 12590 12591 12592 12593 12594 12595 12596 12597 12598 12599 12600 12601 12602 12603 12604 12605 12606 12607 12608 12609 12610 12611 12612 12613 12614 12615 12616 12617 12618 12619 12620 12621 12622 12623 12624 12625 12626 | - + - + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + + | ** incremental merge operation. This function is called if the incremental ** merge step has finished but the input has not been completely exhausted. */ static void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){ int i; Fts5Buffer buf; memset(&buf, 0, sizeof(Fts5Buffer)); |
︙ | |||
12635 12636 12637 12638 12639 12640 12641 | 12704 12705 12706 12707 12708 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 | - + | ){ Fts5SegIter *pSegIter = &pIter->aSeg[ pIter->aFirst[1].iFirst ]; int nPos; /* position-list size field value */ int nTerm; const u8 *pTerm; pTerm = fts5MultiIterTerm(pIter, &nTerm); |
︙ | |||
12890 12891 12892 12893 12894 12895 12896 12897 12898 12899 12900 12901 12902 12903 | 12959 12960 12961 12962 12963 12964 12965 12966 12967 12968 12969 12970 12971 12972 12973 | + | const char *zTerm; /* Buffer containing term */ const u8 *pDoclist; /* Pointer to doclist for this term */ int nDoclist; /* Size of doclist in bytes */ /* Write the term for this entry to disk. */ sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist); fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm); if( p->rc!=SQLITE_OK ) break; assert( writer.bFirstRowidInPage==0 ); if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){ /* The entire doclist will fit on the current leaf. */ fts5BufferSafeAppendBlob(pBuf, pDoclist, nDoclist); }else{ i64 iRowid = 0; |
︙ | |||
12912 12913 12914 12915 12916 12917 12918 12919 12920 12921 12922 12923 12924 12925 | 12982 12983 12984 12985 12986 12987 12988 12989 12990 12991 12992 12993 12994 12995 12996 | + | iRowid += iDelta; if( writer.bFirstRowidInPage ){ fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */ pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid); writer.bFirstRowidInPage = 0; fts5WriteDlidxAppend(p, &writer, iRowid); if( p->rc!=SQLITE_OK ) break; }else{ pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta); } assert( pBuf->n<=pBuf->nSpace ); if( eDetail==FTS5_DETAIL_NONE ){ if( iOff<nDoclist && pDoclist[iOff]==0 ){ |
︙ | |||
12969 12970 12971 12972 12973 12974 12975 | 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 | - + | } } } /* TODO2: Doclist terminator written here. */ /* pBuf->p[pBuf->n++] = '\0'; */ assert( pBuf->n<=pBuf->nSpace ); |
︙ | |||
13013 13014 13015 13016 13017 13018 13019 | 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 | - + | } static Fts5Structure *fts5IndexOptimizeStruct( Fts5Index *p, Fts5Structure *pStruct ){ Fts5Structure *pNew = 0; |
︙ | |||
13143 13144 13145 13146 13147 13148 13149 13150 | 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 | + - + + | static void fts5AppendPoslist( Fts5Index *p, i64 iDelta, Fts5Iter *pMulti, Fts5Buffer *pBuf ){ int nData = pMulti->base.nData; int nByte = nData + 9 + 9 + FTS5_DATA_ZERO_PADDING; assert( nData>0 ); |
︙ | |||
13328 13329 13330 13331 13332 13333 13334 13335 13336 13337 13338 13339 13340 13341 | 13401 13402 13403 13404 13405 13406 13407 13408 13409 13410 13411 13412 13413 13414 13415 13416 | + + | /* Merge the two position lists. */ i64 iPos1 = 0; i64 iPos2 = 0; int iOff1 = 0; int iOff2 = 0; u8 *a1 = &i1.aPoslist[i1.nSize]; u8 *a2 = &i2.aPoslist[i2.nSize]; int nCopy; u8 *aCopy; i64 iPrev = 0; Fts5PoslistWriter writer; memset(&writer, 0, sizeof(writer)); fts5MergeAppendDocid(&out, iLastRowid, i2.iRowid); fts5BufferZero(&tmp); |
︙ | |||
13359 13360 13361 13362 13363 13364 13365 | 13434 13435 13436 13437 13438 13439 13440 13441 13442 13443 13444 13445 13446 13447 13448 13449 13450 13451 13452 13453 13454 13455 13456 13457 13458 13459 13460 13461 13462 13463 13464 13465 13466 13467 13468 13469 13470 13471 13472 13473 13474 13475 13476 13477 | - + - + + + + + + - + + | if( iPos1<iPos2 ){ if( iPos1!=iPrev ){ sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1); } sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1); if( iPos1<0 ) break; }else{ |
︙ | |||
13484 13485 13486 13487 13488 13489 13490 | 13565 13566 13567 13568 13569 13570 13571 13572 13573 13574 13575 13576 13577 13578 13579 | - + | if( p->rc==SQLITE_OK ){ xMerge(p, &doclist, &aBuf[i]); } fts5BufferFree(&aBuf[i]); } fts5MultiIterFree(p1); |
︙ | |||
14246 14247 14248 14249 14250 14251 14252 | 14327 14328 14329 14330 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 14345 | - + - + | int iOff; /* Offset of first term on leaf */ int iRowidOff; /* Offset of first rowid on leaf */ int nTerm; /* Size of term on leaf in bytes */ int res; /* Comparison of term and split-key */ iOff = fts5LeafFirstTermOff(pLeaf); iRowidOff = fts5LeafFirstRowidOff(pLeaf); |
︙ | |||
14645 14646 14647 14648 14649 14650 14651 | 14726 14727 14728 14729 14730 14731 14732 14733 14734 14735 14736 14737 14738 14739 14740 14741 14742 14743 14744 14745 14746 14747 14748 14749 14750 14751 14752 14753 14754 14755 14756 | - + - + - | ){ i64 iRowid; /* Rowid for record being decoded */ int iSegid,iHeight,iPgno,bDlidx;/* Rowid components */ const u8 *aBlob; int n; /* Record to decode */ u8 *a = 0; Fts5Buffer s; /* Build up text to return here */ int rc = SQLITE_OK; /* Return code */ |
︙ | |||
14757 14758 14759 14760 14761 14762 14763 14764 14765 14766 14767 14768 14769 14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 | 14837 14838 14839 14840 14841 14842 14843 14844 14845 14846 14847 14848 14849 14850 14851 14852 14853 14854 14855 14856 14857 14858 14859 14860 14861 14862 14863 14864 14865 14866 14867 14868 14869 14870 14871 14872 14873 14874 14875 14876 14877 14878 14879 14880 14881 14882 14883 14884 14885 14886 14887 14888 14889 14890 14891 14892 14893 14894 14895 14896 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 | + + + + + + + + + + + - + + + + + + + + + + + + + | sqlite3Fts5BufferSet(&rc, &s, 7, (const u8*)"corrupt"); goto decode_out; }else{ iRowidOff = fts5GetU16(&a[0]); iPgidxOff = szLeaf = fts5GetU16(&a[2]); if( iPgidxOff<n ){ fts5GetVarint32(&a[iPgidxOff], iTermOff); }else if( iPgidxOff>n ){ rc = FTS5_CORRUPT; goto decode_out; } } /* Decode the position list tail at the start of the page */ if( iRowidOff!=0 ){ iOff = iRowidOff; }else if( iTermOff!=0 ){ iOff = iTermOff; }else{ iOff = szLeaf; } if( iOff>n ){ rc = FTS5_CORRUPT; goto decode_out; } fts5DecodePoslist(&rc, &s, &a[4], iOff-4); /* Decode any more doclist data that appears on the page before the ** first term. */ nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff; if( nDoclist+iOff>n ){ rc = FTS5_CORRUPT; goto decode_out; } fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist); |
︙ | |||
14920 14921 14922 14923 14924 14925 14926 | 15023 15024 15025 15026 15027 15028 15029 15030 15031 15032 15033 15034 15035 15036 15037 15038 | - - + + | */ int sqlite3_fts5_may_be_corrupt = 1; typedef struct Fts5Auxdata Fts5Auxdata; typedef struct Fts5Auxiliary Fts5Auxiliary; typedef struct Fts5Cursor Fts5Cursor; |
︙ | |||
15002 15003 15004 15005 15006 15007 15008 | 15105 15106 15107 15108 15109 15110 15111 15112 15113 15114 15115 15116 15117 15118 15119 15120 | - - - - + - - - + | char *zName; /* Name of tokenizer */ void *pUserData; /* User pointer passed to xCreate() */ fts5_tokenizer x; /* Tokenizer functions */ void (*xDestroy)(void*); /* Destructor function */ Fts5TokenizerModule *pNext; /* Next registered tokenizer module */ }; |
︙ | |||
15146 15147 15148 15149 15150 15151 15152 | 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 | - + | #define FTS5_BEGIN 1 #define FTS5_SYNC 2 #define FTS5_COMMIT 3 #define FTS5_ROLLBACK 4 #define FTS5_SAVEPOINT 5 #define FTS5_RELEASE 6 #define FTS5_ROLLBACKTO 7 |
︙ | |||
15185 15186 15187 15188 15189 15190 15191 | 15283 15284 15285 15286 15287 15288 15289 15290 15291 15292 15293 15294 15295 15296 15297 15298 15299 15300 15301 15302 15303 15304 15305 15306 15307 15308 15309 15310 15311 15312 15313 15314 15315 15316 15317 15318 15319 15320 15321 15322 15323 15324 15325 15326 15327 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 | - + - - + + - + - + - + - + - + | assert( iSavepoint>=0 ); assert( iSavepoint<=p->ts.iSavepoint ); p->ts.iSavepoint = iSavepoint-1; break; case FTS5_ROLLBACKTO: assert( p->ts.eState==1 ); |
︙ | |||
15258 15259 15260 15261 15262 15263 15264 | 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 15389 15390 15391 15392 15393 15394 15395 15396 15397 15398 15399 15400 15401 15402 15403 15404 15405 | - + - + - + - + - + - - + + | sqlite3_vtab **ppVTab, /* Write the resulting vtab structure here */ char **pzErr /* Write any error message here */ ){ Fts5Global *pGlobal = (Fts5Global*)pAux; const char **azConfig = (const char**)argv; int rc = SQLITE_OK; /* Return code */ Fts5Config *pConfig = 0; /* Results of parsing argc/argv */ |
︙ | |||
15506 15507 15508 15509 15510 15511 15512 | 15604 15605 15606 15607 15608 15609 15610 15611 15612 15613 15614 15615 15616 15617 15618 15619 15620 15621 15622 15623 15624 15625 15626 15627 15628 15629 15630 15631 15632 15633 15634 15635 15636 15637 15638 15639 | - + - - + + - + - + | } } pInfo->idxNum = idxFlags; return SQLITE_OK; } |
︙ | |||
15565 15566 15567 15568 15569 15570 15571 | 15663 15664 15665 15666 15667 15668 15669 15670 15671 15672 15673 15674 15675 15676 15677 | - + | | FTS5CSR_REQUIRE_DOCSIZE | FTS5CSR_REQUIRE_INST | FTS5CSR_REQUIRE_POSLIST ); } static void fts5FreeCursorComponents(Fts5Cursor *pCsr){ |
︙ | |||
15609 15610 15611 15612 15613 15614 15615 | 15707 15708 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 | - + | /* ** Close the cursor. For additional information see the documentation ** on the xClose method of the virtual table interface. */ static int fts5CloseMethod(sqlite3_vtab_cursor *pCursor){ if( pCursor ){ |
︙ | |||
15666 15667 15668 15669 15670 15671 15672 | 15764 15765 15766 15767 15768 15769 15770 15771 15772 15773 15774 15775 15776 15777 15778 | - + | } /* ** Set the FTS5CSR_REQUIRE_RESEEK flag on all FTS5_PLAN_MATCH cursors ** open on table pTab. */ |
︙ | |||
15693 15694 15695 15696 15697 15698 15699 | 15791 15792 15793 15794 15795 15796 15797 15798 15799 15800 15801 15802 15803 15804 15805 15806 15807 15808 15809 | - + - + | ** Return SQLITE_OK if successful or if no reseek was required, or an ** error code if an error occurred. */ static int fts5CursorReseek(Fts5Cursor *pCsr, int *pbSkip){ int rc = SQLITE_OK; assert( *pbSkip==0 ); if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_RESEEK) ){ |
︙ | |||
15794 15795 15796 15797 15798 15799 15800 | 15892 15893 15894 15895 15896 15897 15898 15899 15900 15901 15902 15903 15904 15905 15906 15907 15908 15909 15910 15911 15912 15913 15914 15915 15916 15917 15918 15919 15920 15921 | - - + + + + + + - + - + | } va_end(ap); *ppStmt = pRet; return rc; } |
︙ | |||
15842 15843 15844 15845 15846 15847 15848 | 15944 15945 15946 15947 15948 15949 15950 15951 15952 15953 15954 15955 15956 15957 15958 15959 15960 15961 15962 15963 15964 15965 15966 15967 15968 15969 15970 15971 15972 15973 15974 15975 15976 15977 15978 15979 15980 15981 15982 15983 15984 15985 15986 15987 15988 15989 15990 15991 15992 15993 15994 15995 15996 15997 15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 16012 16013 16014 16015 16016 16017 16018 16019 16020 16021 16022 16023 16024 16025 16026 16027 16028 16029 16030 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 | - + - + - + - + - + - + - + - - + + - + | sqlite3_free(pSorter); pCsr->pSorter = 0; } return rc; } |
︙ | |||
15946 15947 15948 15949 15950 15951 15952 | 16048 16049 16050 16051 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 | - - + + | } } } if( rc==SQLITE_OK ){ pAux = fts5FindAuxiliary(pTab, zRank); if( pAux==0 ){ |
︙ | |||
16022 16023 16024 16025 16026 16027 16028 | 16124 16125 16126 16127 16128 16129 16130 16131 16132 16133 16134 16135 16136 16137 16138 16139 | - - + + | static int fts5FilterMethod( sqlite3_vtab_cursor *pCursor, /* The cursor used for this query */ int idxNum, /* Strategy index */ const char *zUnused, /* Unused */ int nVal, /* Number of elements in apVal */ sqlite3_value **apVal /* Arguments for the indexing scheme */ ){ |
︙ | |||
16052 16053 16054 16055 16056 16057 16058 | 16154 16155 16156 16157 16158 16159 16160 16161 16162 16163 16164 16165 16166 16167 16168 16169 | - - + + | assert( pCsr->pStmt==0 ); assert( pCsr->pExpr==0 ); assert( pCsr->csrflags==0 ); assert( pCsr->pRank==0 ); assert( pCsr->zRank==0 ); assert( pCsr->zRankArgs==0 ); |
︙ | |||
16119 16120 16121 16122 16123 16124 16125 | 16221 16222 16223 16224 16225 16226 16227 16228 16229 16230 16231 16232 16233 16234 16235 | - + | if( rc==SQLITE_OK ){ if( zExpr[0]=='*' ){ /* The user has issued a query of the form "MATCH '*...'". This ** indicates that the MATCH expression is not a full text query, ** but a request for an internal parameter. */ rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]); }else{ |
︙ | |||
16142 16143 16144 16145 16146 16147 16148 | 16244 16245 16246 16247 16248 16249 16250 16251 16252 16253 16254 16255 16256 16257 16258 | - + | ); rc = SQLITE_ERROR; }else{ /* This is either a full-table scan (ePlan==FTS5_PLAN_SCAN) or a lookup ** by rowid (ePlan==FTS5_PLAN_ROWID). */ pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN); rc = sqlite3Fts5StorageStmt( |
︙ | |||
16225 16226 16227 16228 16229 16230 16231 | 16327 16328 16329 16330 16331 16332 16333 16334 16335 16336 16337 16338 16339 16340 16341 16342 16343 16344 16345 16346 | - + - + - + | ** be left in sqlite3_vtab.zErrMsg. */ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){ int rc = SQLITE_OK; /* If the cursor does not yet have a statement handle, obtain one now. */ if( pCsr->pStmt==0 ){ |
︙ | |||
16252 16253 16254 16255 16256 16257 16258 | 16354 16355 16356 16357 16358 16359 16360 16361 16362 16363 16364 16365 16366 16367 16368 16369 16370 16371 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 16383 16384 16385 16386 16387 16388 16389 16390 16391 16392 16393 16394 16395 16396 | - + - - + + - + - + | rc = FTS5_CORRUPT; } } } return rc; } |
︙ | |||
16315 16316 16317 16318 16319 16320 16321 | 16417 16418 16419 16420 16421 16422 16423 16424 16425 16426 16427 16428 16429 16430 16431 16432 16433 16434 16435 16436 16437 16438 16439 16440 16441 16442 16443 16444 16445 16446 16447 16448 16449 16450 16451 16452 16453 16454 16455 16456 16457 16458 16459 16460 16461 | - + - + - + - + | }else if( 0==sqlite3_stricmp("integrity-check", zCmd) ){ rc = sqlite3Fts5StorageIntegrity(pTab->pStorage); #ifdef SQLITE_DEBUG }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){ pConfig->bPrefixIndex = sqlite3_value_int(pVal); #endif }else{ |
︙ | |||
16379 16380 16381 16382 16383 16384 16385 | 16481 16482 16483 16484 16485 16486 16487 16488 16489 16490 16491 16492 16493 16494 16495 16496 16497 16498 16499 16500 16501 16502 16503 16504 16505 16506 16507 16508 16509 | - - + + - - - + + - - + + | */ static int fts5UpdateMethod( sqlite3_vtab *pVtab, /* Virtual table handle */ int nArg, /* Size of argument array */ sqlite3_value **apVal, /* Array of arguments */ sqlite_int64 *pRowid /* OUT: The affected (or effected) rowid */ ){ |
︙ | |||
16435 16436 16437 16438 16439 16440 16441 | 16536 16537 16538 16539 16540 16541 16542 16543 16544 16545 16546 16547 16548 16549 16550 16551 16552 16553 16554 16555 16556 16557 16558 16559 16560 16561 16562 16563 16564 16565 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 16578 16579 16580 16581 16582 16583 16584 16585 16586 16587 16588 16589 16590 16591 16592 16593 16594 16595 16596 16597 16598 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 16615 16616 16617 16618 16619 16620 16621 16622 16623 16624 16625 16626 16627 16628 16629 16630 16631 16632 16633 16634 16635 16636 16637 16638 16639 16640 16641 16642 16643 16644 16645 16646 16647 16648 16649 16650 16651 16652 | - + - - - - + + + + + + + + + + + - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - + + - + - + | assert( eType0==SQLITE_INTEGER || eType0==SQLITE_NULL ); assert( nArg!=1 || eType0==SQLITE_INTEGER ); /* Filter out attempts to run UPDATE or DELETE on contentless tables. ** This is not suported. */ if( eType0==SQLITE_INTEGER && fts5IsContentless(pTab) ){ |
︙ | |||
16555 16556 16557 16558 16559 16560 16561 | 16662 16663 16664 16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 16675 16676 16677 16678 16679 16680 16681 16682 | - + - + | static int fts5ApiColumnTotalSize( Fts5Context *pCtx, int iCol, sqlite3_int64 *pnToken ){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; |
︙ | |||
16596 16597 16598 16599 16600 16601 16602 | 16703 16704 16705 16706 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 16718 16719 | - + + + | Fts5Context *pCtx, int iCol, const char **pz, int *pn ){ int rc = SQLITE_OK; Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; |
︙ | |||
16665 16666 16667 16668 16669 16670 16671 16672 16673 16674 | 16774 16775 16776 16777 16778 16779 16780 16781 16782 16783 16784 16785 16786 16787 16788 16789 16790 16791 16792 | + - + | ** correctly for the current view. Return SQLITE_OK if successful, or an ** SQLite error code otherwise. */ static int fts5CacheInstArray(Fts5Cursor *pCsr){ int rc = SQLITE_OK; Fts5PoslistReader *aIter; /* One iterator for each phrase */ int nIter; /* Number of iterators/phrases */ int nCol = ((Fts5Table*)pCsr->base.pVtab)->pConfig->nCol; nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr); if( pCsr->aInstIter==0 ){ |
︙ | |||
16703 16704 16705 16706 16707 16708 16709 | 16813 16814 16815 16816 16817 16818 16819 16820 16821 16822 16823 16824 16825 16826 16827 16828 16829 16830 16831 16832 16833 16834 16835 16836 16837 16838 16839 16840 16841 16842 16843 16844 16845 | - + + + + + | } } if( iBest<0 ) break; nInst++; if( nInst>=pCsr->nInstAlloc ){ pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32; |
︙ | |||
16790 16791 16792 16793 16794 16795 16796 | 16904 16905 16906 16907 16908 16909 16910 16911 16912 16913 16914 16915 16916 16917 16918 16919 | - - + + | (*pCnt)++; } return SQLITE_OK; } static int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; |
︙ | |||
17047 17048 17049 17050 17051 17052 17053 | 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 | - + | static int fts5ApiQueryPhrase( Fts5Context *pCtx, int iPhrase, void *pUserData, int(*xCallback)(const Fts5ExtensionApi*, Fts5Context*, void*) ){ Fts5Cursor *pCsr = (Fts5Cursor*)pCtx; |
︙ | |||
17124 17125 17126 17127 17128 17129 17130 | 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 | - + - - - - + - + - - - + - + - - - + + | }else{ fts5ApiInvoke(pAux, pCsr, context, argc-1, &argv[1]); } } /* |
︙ | |||
17222 17223 17224 17225 17226 17227 17228 | 17330 17331 17332 17333 17334 17335 17336 17337 17338 17339 17340 17341 17342 17343 17344 17345 | - - + + | ** the row that the supplied cursor currently points to. */ static int fts5ColumnMethod( sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */ sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */ int iCol /* Index of column to read value from */ ){ |
︙ | |||
17275 17276 17277 17278 17279 17280 17281 | 17383 17384 17385 17386 17387 17388 17389 17390 17391 17392 17393 17394 17395 17396 17397 | - + | static int fts5FindFunctionMethod( sqlite3_vtab *pVtab, /* Virtual table handle */ int nUnused, /* Number of SQL function arguments */ const char *zName, /* Name of SQL function */ void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */ void **ppArg /* OUT: User data for *pxFunc */ ){ |
︙ | |||
17297 17298 17299 17300 17301 17302 17303 | 17405 17406 17407 17408 17409 17410 17411 17412 17413 17414 17415 17416 17417 17418 17419 17420 17421 17422 17423 17424 17425 17426 17427 17428 17429 17430 17431 17432 17433 17434 17435 17436 17437 17438 17439 17440 17441 17442 17443 17444 17445 17446 17447 17448 17449 17450 17451 17452 17453 17454 17455 17456 | - + + + + + + - - + - - + - - + - - + - + | /* ** Implementation of FTS5 xRename method. Rename an fts5 table. */ static int fts5RenameMethod( sqlite3_vtab *pVtab, /* Virtual table handle */ const char *zName /* New name of table */ ){ |
︙ | |||
17534 17535 17536 17537 17538 17539 17540 | 17643 17644 17645 17646 17647 17648 17649 17650 17651 17652 17653 17654 17655 17656 17657 | - + | static void fts5SourceIdFunc( sqlite3_context *pCtx, /* Function call context */ int nArg, /* Number of args */ sqlite3_value **apUnused /* Function arguments */ ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); |
︙ | |||
17784 17785 17786 17787 17788 17789 17790 | 17893 17894 17895 17896 17897 17898 17899 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 17921 17922 17923 17924 17925 17926 17927 17928 17929 17930 | - + + + - + - | case FTS5_STMT_INSERT_CONTENT: case FTS5_STMT_REPLACE_CONTENT: { int nCol = pC->nCol + 1; char *zBind; int i; |
︙ | |||
17950 17951 17952 17953 17954 17955 17956 | 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 18073 18074 18075 18076 18077 18078 18079 18080 18081 18082 18083 18084 18085 18086 18087 18088 18089 | - + - + - + | Fts5Index *pIndex, int bCreate, Fts5Storage **pp, char **pzErr /* OUT: Error message */ ){ int rc = SQLITE_OK; Fts5Storage *p; /* New object */ |
︙ | |||
18256 18257 18258 18259 18260 18261 18262 | 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 | - + | } static int sqlite3Fts5StorageRebuild(Fts5Storage *p){ Fts5Buffer buf = {0,0,0}; Fts5Config *pConfig = p->pConfig; sqlite3_stmt *pScan = 0; Fts5InsertCtx ctx; |
︙ | |||
18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 | 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 | + + | p->nTotalRow++; if( rc==SQLITE_OK ){ rc = fts5StorageInsertDocsize(p, iRowid, &buf); } } sqlite3_free(buf.p); rc2 = sqlite3_reset(pScan); if( rc==SQLITE_OK ) rc = rc2; /* Write the averages record */ if( rc==SQLITE_OK ){ rc = fts5StorageSaveTotals(p); } return rc; } |
︙ | |||
18544 18545 18546 18547 18548 18549 18550 | 18656 18657 18658 18659 18660 18661 18662 18663 18664 18665 18666 18667 18668 18669 18670 | - + | int *aColSize; /* Array of size pConfig->nCol */ i64 *aTotalSize; /* Array of size pConfig->nCol */ Fts5IntegrityCtx ctx; sqlite3_stmt *pScan; memset(&ctx, 0, sizeof(Fts5IntegrityCtx)); ctx.pConfig = p->pConfig; |
︙ | |||
18744 18745 18746 18747 18748 18749 18750 18751 18752 18753 18754 18755 18756 18757 18758 | 18856 18857 18858 18859 18860 18861 18862 18863 18864 18865 18866 18867 18868 18869 18870 18871 18872 18873 18874 18875 18876 | + + + + + + | } return rc; } static int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow){ int rc = fts5StorageLoadTotals(p, 0); if( rc==SQLITE_OK ){ /* nTotalRow being zero does not necessarily indicate a corrupt ** database - it might be that the FTS5 table really does contain zero ** rows. However this function is only called from the xRowCount() API, ** and there is no way for that API to be invoked if the table contains ** no rows. Hence the FTS5_CORRUPT return. */ *pnRow = p->nTotalRow; if( p->nTotalRow<=0 ) rc = FTS5_CORRUPT; } return rc; } /* ** Flush any data currently held in-memory to disk. */ |
︙ | |||
18955 18956 18957 18958 18959 18960 18961 | 19073 19074 19075 19076 19077 19078 19079 19080 19081 19082 19083 19084 19085 19086 19087 | - + | ie++; } /* Fold to lower case */ nByte = ie-is; if( nByte>nFold ){ if( pFold!=aFold ) sqlite3_free(pFold); |
︙ | |||
19037 19038 19039 19040 19041 19042 19043 | 19155 19156 19157 19158 19159 19160 19161 19162 19163 19164 19165 19166 19167 19168 19169 19170 19171 19172 19173 19174 19175 19176 19177 19178 19179 19180 19181 19182 19183 19184 19185 19186 19187 19188 19189 19190 19191 19192 19193 19194 19195 19196 19197 19198 19199 19200 19201 19202 19203 19204 19205 19206 19207 19208 19209 19210 | - + + + + + + - + + - + - + | #endif /* ifndef SQLITE_AMALGAMATION */ typedef struct Unicode61Tokenizer Unicode61Tokenizer; struct Unicode61Tokenizer { unsigned char aTokenChar[128]; /* ASCII range token characters */ char *aFold; /* Buffer to fold text into */ int nFold; /* Size of aFold[] in bytes */ |
︙ | |||
19164 19165 19166 19167 19168 19169 19170 | 19288 19289 19290 19291 19292 19293 19294 19295 19296 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 19312 19313 19314 19315 19316 19317 19318 19319 19320 19321 19322 19323 19324 19325 19326 19327 19328 19329 19330 19331 | - + - + + + + + + + - | }else{ p = (Unicode61Tokenizer*)sqlite3_malloc(sizeof(Unicode61Tokenizer)); if( p ){ const char *zCat = "L* N* Co"; int i; memset(p, 0, sizeof(Unicode61Tokenizer)); |
︙ | |||
19222 19223 19224 19225 19226 19227 19228 | 19351 19352 19353 19354 19355 19356 19357 19358 19359 19360 19361 19362 19363 19364 19365 | - + | /* ** Return true if, for the purposes of tokenizing with the tokenizer ** passed as the first argument, codepoint iCode is considered a token ** character (not a separator). */ static int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){ return ( |
︙ | |||
19251 19252 19253 19254 19255 19256 19257 | 19380 19381 19382 19383 19384 19385 19386 19387 19388 19389 19390 19391 19392 19393 19394 | - + | const char *pEnd = &aFold[nFold-6]; UNUSED_PARAM(iUnused); /* Each iteration of this loop gobbles up a contiguous run of separators, ** then the next token. */ while( rc==SQLITE_OK ){ |
︙ | |||
19283 19284 19285 19286 19287 19288 19289 | 19412 19413 19414 19415 19416 19417 19418 19419 19420 19421 19422 19423 19424 19425 19426 19427 19428 19429 19430 19431 19432 19433 19434 19435 19436 19437 19438 19439 19440 19441 19442 19443 19444 19445 | - + - + | /* Run through the tokenchars. Fold them into the output buffer along ** the way. */ while( zCsr<zTerm ){ /* Grow the output buffer so that there is sufficient space to fit the ** largest possible utf-8 character. */ if( zOut>pEnd ){ |
︙ | |||
20078 20079 20080 20081 20082 20083 20084 | 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 | - - - + | 0 ); } return rc; } |
︙ | |||
20111 20112 20113 20114 20115 20116 20117 | 20238 20239 20240 20241 20242 20243 20244 20245 20246 20247 20248 20249 20250 20251 20252 20253 20254 20255 20256 20257 20258 20259 20260 20261 20262 20263 20264 20265 20266 20267 20268 20269 20270 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 20285 20286 20287 20288 20289 20290 20291 20292 20293 20294 20295 20296 20297 20298 20299 20300 20301 20302 20303 20304 20305 20306 20307 20308 20309 20310 20311 20312 20313 20314 20315 20316 20317 20318 20319 20320 20321 20322 20323 20324 20325 20326 20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 | - + - - - - - - - - - + + + + + + + + + + + + + - + - - - + + + + + + + + + + + - - - - - - + + + + + + + + + + + - + - - + + - + | ** If the argument is a codepoint corresponding to a lowercase letter ** in the ASCII range with a diacritic added, return the codepoint ** of the ASCII letter only. For example, if passed 235 - "LATIN ** SMALL LETTER E WITH DIAERESIS" - return 65 ("LATIN SMALL LETTER ** E"). The resuls of passing a codepoint that corresponds to an ** uppercase letter are undefined. */ |
︙ | |||
20303 20304 20305 20306 20307 20308 20309 | 20447 20448 20449 20450 20451 20452 20453 20454 20455 20456 20457 20458 20459 20460 20461 20462 20463 20464 20465 20466 20467 20468 20469 20470 20471 20472 20473 | + - + + - - - - - - | assert( iRes>=0 && c>=aEntry[iRes].iCode ); p = &aEntry[iRes]; if( c<(p->iCode + p->nRange) && 0==(0x01 & p->flags & (p->iCode ^ c)) ){ ret = (c + (aiOff[p->flags>>1])) & 0x0000FFFF; assert( ret>0 ); } if( eRemoveDiacritic ){ |
︙ | |||
20801 20802 20803 20804 20805 20806 20807 | 20941 20942 20943 20944 20945 20946 20947 20948 20949 20950 20951 20952 20953 20954 20955 | - + | 89, 1434, 3226, 506, 474, 506, 506, 367, 1018, 1946, 1402, 954, 1402, 314, 90, 1082, 218, 2266, 666, 1210, 186, 570, 2042, 58, 5850, 154, 2010, 154, 794, 2266, 378, 2266, 3738, 39, 39, 39, 39, 39, 39, 17351, 34, 3074, 7692, 63, 63, }; |
︙ | |||
20839 20840 20841 20842 20843 20844 20845 | 20979 20980 20981 20982 20983 20984 20985 20986 20987 20988 20989 20990 20991 20992 20993 20994 20995 20996 20997 | - + - | static void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){ int i = 0; int iTbl = 0; while( i<128 ){ int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ]; int n = (aFts5UnicodeData[iTbl] >> 5) + i; for(; i<128 && i<n; i++){ |
︙ | |||
20925 20926 20927 20928 20929 20930 20931 | 21064 21065 21066 21067 21068 21069 21070 21071 21072 21073 21074 21075 21076 21077 21078 | - + | ** routine. */ { u64 v64; u8 n; p -= 2; n = sqlite3Fts5GetVarint(p, &v64); |
︙ | |||
21192 21193 21194 21195 21196 21197 21198 | 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 | - | assert( iVal>=(1 << 7) ); if( iVal<(1 << 14) ) return 2; if( iVal<(1 << 21) ) return 3; if( iVal<(1 << 28) ) return 4; return 5; } |
︙ | |||
21251 21252 21253 21254 21255 21256 21257 | 21389 21390 21391 21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 21403 21404 21405 21406 21407 21408 21409 21410 21411 | - + - | Fts5Global *pGlobal; /* FTS5 global object for this database */ int eType; /* FTS5_VOCAB_COL, ROW or INSTANCE */ }; struct Fts5VocabCursor { sqlite3_vtab_cursor base; sqlite3_stmt *pStmt; /* Statement holding lock on pIndex */ |
︙ | |||
21523 21524 21525 21526 21527 21528 21529 | 21660 21661 21662 21663 21664 21665 21666 21667 21668 21669 21670 21671 21672 21673 21674 21675 21676 21677 21678 21679 21680 21681 21682 21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 21699 21700 21701 21702 21703 21704 21705 21706 21707 21708 21709 21710 21711 21712 21713 21714 21715 21716 21717 21718 21719 21720 21721 21722 21723 21724 21725 21726 21727 21728 21729 21730 21731 21732 21733 21734 21735 21736 | - + - - + - - - - - - - - + + + + + + + + + + + + - + - + - - + + | ** Implementation of xOpen method. */ static int fts5VocabOpenMethod( sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr ){ Fts5VocabTable *pTab = (Fts5VocabTable*)pVTab; |
︙ | |||
21621 21622 21623 21624 21625 21626 21627 | 21761 21762 21763 21764 21765 21766 21767 21768 21769 21770 21771 21772 21773 21774 21775 | - + | sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm); } return rc; } static int fts5VocabInstanceNext(Fts5VocabCursor *pCsr){ |
︙ | |||
21656 21657 21658 21659 21660 21661 21662 | 21796 21797 21798 21799 21800 21801 21802 21803 21804 21805 21806 21807 21808 21809 21810 | - + | /* ** Advance the cursor to the next row in the table. */ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab; int rc = SQLITE_OK; |
︙ | |||
21678 21679 21680 21681 21682 21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 21699 21700 | 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 21830 21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 21844 21845 21846 21847 21848 21849 | + - + | if( sqlite3Fts5IterEof(pCsr->pIter) ){ pCsr->bEof = 1; }else{ const char *zTerm; int nTerm; zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm); assert( nTerm>=0 ); if( pCsr->nLeTerm>=0 ){ int nCmp = MIN(nTerm, pCsr->nLeTerm); int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp); if( bCmp<0 || (bCmp==0 && pCsr->nLeTerm<nTerm) ){ pCsr->bEof = 1; return SQLITE_OK; } } sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm); memset(pCsr->aCnt, 0, nCol * sizeof(i64)); memset(pCsr->aDoc, 0, nCol * sizeof(i64)); pCsr->iCol = 0; assert( pTab->eType==FTS5_VOCAB_COL || pTab->eType==FTS5_VOCAB_ROW ); while( rc==SQLITE_OK ){ |
︙ | |||
21717 21718 21719 21720 21721 21722 21723 | 21858 21859 21860 21861 21862 21863 21864 21865 21866 21867 21868 21869 21870 21871 21872 21873 21874 21875 21876 21877 21878 21879 21880 | - + | break; case FTS5_VOCAB_COL: if( eDetail==FTS5_DETAIL_FULL ){ int iCol = -1; while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){ int ii = FTS5_POS2COLUMN(iPos); |
︙ | |||
21754 21755 21756 21757 21758 21759 21760 | 21895 21896 21897 21898 21899 21900 21901 21902 21903 21904 21905 21906 21907 21908 21909 21910 21911 21912 21913 21914 21915 21916 21917 21918 21919 21920 21921 21922 | - + + + - + | if( rc==SQLITE_OK ){ rc = sqlite3Fts5IterNextScan(pCsr->pIter); } if( pTab->eType==FTS5_VOCAB_INSTANCE ) break; if( rc==SQLITE_OK ){ zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm); |
︙ | |||
21812 21813 21814 21815 21816 21817 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 | 21955 21956 21957 21958 21959 21960 21961 21962 21963 21964 21965 21966 21967 21968 21969 21970 21971 21972 21973 21974 21975 21976 21977 21978 21979 21980 21981 21982 21983 21984 21985 21986 21987 21988 21989 | + + - + - + - - + + | }else{ if( pGe ){ zTerm = (const char *)sqlite3_value_text(pGe); nTerm = sqlite3_value_bytes(pGe); } if( pLe ){ const char *zCopy = (const char *)sqlite3_value_text(pLe); if( zCopy==0 ) zCopy = ""; pCsr->nLeTerm = sqlite3_value_bytes(pLe); pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1); if( pCsr->zLeTerm==0 ){ rc = SQLITE_NOMEM; }else{ memcpy(pCsr->zLeTerm, zCopy, pCsr->nLeTerm+1); } } } if( rc==SQLITE_OK ){ Fts5Index *pIndex = pCsr->pFts5->pIndex; |
︙ | |||
21853 21854 21855 21856 21857 21858 21859 | 21998 21999 22000 22001 22002 22003 22004 22005 22006 22007 22008 22009 22010 22011 22012 22013 22014 22015 22016 22017 22018 22019 22020 22021 22022 22023 22024 | - + - + | static int fts5VocabColumnMethod( sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */ sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */ int iCol /* Index of column to read value from */ ){ Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; |
︙ | |||
21893 21894 21895 21896 21897 21898 21899 | 22038 22039 22040 22041 22042 22043 22044 22045 22046 22047 22048 22049 22050 22051 22052 22053 | - - + + | case 2: { int ii = -1; if( eDetail==FTS5_DETAIL_FULL ){ ii = FTS5_POS2COLUMN(pCsr->iInstPos); }else if( eDetail==FTS5_DETAIL_COLUMNS ){ ii = (int)pCsr->iInstPos; } |
︙ |
Changes to SQLite.Interop/src/ext/json1.c.
︙ | |||
687 688 689 690 691 692 693 | 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 | - + | const char *zContent /* Content */ ){ u32 nNew; JsonNode *pNew; assert( pParse->nNode>=pParse->nAlloc ); if( pParse->oom ) return -1; nNew = pParse->nAlloc*2 + 10; |
︙ | |||
961 962 963 964 965 966 967 | 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 | - + | /* ** Compute the parentage of all nodes in a completed parse. */ static int jsonParseFindParents(JsonParse *pParse){ u32 *aUp; assert( pParse->aUp==0 ); |
︙ | |||
1023 1024 1025 1026 1027 1028 1029 | 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 | - + | } } if( pMatch ){ pMatch->nErr = 0; pMatch->iHold = iMaxHold+1; return pMatch; } |
︙ |
Changes to SQLite.Interop/src/ext/percentile.c.
︙ | |||
147 148 149 150 151 152 153 | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | - + | sqlite3_result_error(pCtx, "Inf input to percentile()", -1); return; } /* Allocate and store the Y */ if( p->nUsed>=p->nAlloc ){ unsigned n = p->nAlloc*2 + 250; |
︙ |
Changes to SQLite.Interop/src/ext/regexp.c.
︙ | |||
221 222 223 224 225 226 227 | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | - + | if( in.i+pRe->nInit>in.mx ) return 0; } if( pRe->nState<=(sizeof(aSpace)/(sizeof(aSpace[0])*2)) ){ pToFree = 0; aStateSet[0].aState = aSpace; }else{ |
︙ | |||
333 334 335 336 337 338 339 | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | - + - + | } /* Resize the opcode and argument arrays for an RE under construction. */ static int re_resize(ReCompiled *p, int N){ char *aOp; int *aArg; |
︙ |
Changes to readme.htm.
1 2 3 4 5 6 7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | - - + + | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> ADO.NET SQLite Data Provider<br /> |
︙ | |||
204 205 206 207 208 209 210 | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | - + - + | designed for robustness and maximum backward compatibility with previously released versions of System.Data.SQLite. </p> <h2><b>Version History</b></h2> <p> |
︙ |
Changes to www/news.wiki.
︙ | |||
41 42 43 44 45 46 47 | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | - + - + | Access to archived release packages will be granted on a case-by-case basis. </li> </ul> <div align="center"><h2><b>Version History</b></h2></div> <p> |
︙ |