| | @@ -222,11 +222,11 @@ |
| 222 | 222 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 223 | 223 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 224 | 224 | */ |
| 225 | 225 | #define SQLITE_VERSION "3.8.6" |
| 226 | 226 | #define SQLITE_VERSION_NUMBER 3008006 |
| 227 | | -#define SQLITE_SOURCE_ID "2014-07-01 11:54:02 21981e35062cc6b30e9576786cbf55265a7a4d41" |
| 227 | +#define SQLITE_SOURCE_ID "2014-07-24 12:39:59 fb1048cb2b613a0dbfe625a5df05e9dcd736a433" |
| 228 | 228 | |
| 229 | 229 | /* |
| 230 | 230 | ** CAPI3REF: Run-Time Library Version Numbers |
| 231 | 231 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 232 | 232 | ** |
| | @@ -2150,31 +2150,37 @@ |
| 2150 | 2150 | SQLITE_API int sqlite3_complete16(const void *sql); |
| 2151 | 2151 | |
| 2152 | 2152 | /* |
| 2153 | 2153 | ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors |
| 2154 | 2154 | ** |
| 2155 | | -** ^This routine sets a callback function that might be invoked whenever |
| 2156 | | -** an attempt is made to open a database table that another thread |
| 2157 | | -** or process has locked. |
| 2155 | +** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X |
| 2156 | +** that might be invoked with argument P whenever |
| 2157 | +** an attempt is made to access a database table associated with |
| 2158 | +** [database connection] D when another thread |
| 2159 | +** or process has the table locked. |
| 2160 | +** The sqlite3_busy_handler() interface is used to implement |
| 2161 | +** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout]. |
| 2158 | 2162 | ** |
| 2159 | 2163 | ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] |
| 2160 | 2164 | ** is returned immediately upon encountering the lock. ^If the busy callback |
| 2161 | 2165 | ** is not NULL, then the callback might be invoked with two arguments. |
| 2162 | 2166 | ** |
| 2163 | 2167 | ** ^The first argument to the busy handler is a copy of the void* pointer which |
| 2164 | 2168 | ** is the third argument to sqlite3_busy_handler(). ^The second argument to |
| 2165 | 2169 | ** the busy handler callback is the number of times that the busy handler has |
| 2166 | | -** been invoked for this locking event. ^If the |
| 2170 | +** been invoked for the same locking event. ^If the |
| 2167 | 2171 | ** busy callback returns 0, then no additional attempts are made to |
| 2168 | | -** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. |
| 2172 | +** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned |
| 2173 | +** to the application. |
| 2169 | 2174 | ** ^If the callback returns non-zero, then another attempt |
| 2170 | | -** is made to open the database for reading and the cycle repeats. |
| 2175 | +** is made to access the database and the cycle repeats. |
| 2171 | 2176 | ** |
| 2172 | 2177 | ** The presence of a busy handler does not guarantee that it will be invoked |
| 2173 | 2178 | ** when there is lock contention. ^If SQLite determines that invoking the busy |
| 2174 | 2179 | ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] |
| 2175 | | -** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. |
| 2180 | +** or [SQLITE_IOERR_BLOCKED] to the application instead of invoking the |
| 2181 | +** busy handler. |
| 2176 | 2182 | ** Consider a scenario where one process is holding a read lock that |
| 2177 | 2183 | ** it is trying to promote to a reserved lock and |
| 2178 | 2184 | ** a second process is holding a reserved lock that it is trying |
| 2179 | 2185 | ** to promote to an exclusive lock. The first process cannot proceed |
| 2180 | 2186 | ** because it is blocked by the second and the second process cannot |
| | @@ -2202,14 +2208,16 @@ |
| 2202 | 2208 | ** this is important. |
| 2203 | 2209 | ** |
| 2204 | 2210 | ** ^(There can only be a single busy handler defined for each |
| 2205 | 2211 | ** [database connection]. Setting a new busy handler clears any |
| 2206 | 2212 | ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] |
| 2207 | | -** will also set or clear the busy handler. |
| 2213 | +** or evaluating [PRAGMA busy_timeout=N] will change the |
| 2214 | +** busy handler and thus clear any previously set busy handler. |
| 2208 | 2215 | ** |
| 2209 | 2216 | ** The busy callback should not take any actions which modify the |
| 2210 | | -** database connection that invoked the busy handler. Any such actions |
| 2217 | +** database connection that invoked the busy handler. In other words, |
| 2218 | +** the busy handler is not reentrant. Any such actions |
| 2211 | 2219 | ** result in undefined behavior. |
| 2212 | 2220 | ** |
| 2213 | 2221 | ** A busy handler must not close the database connection |
| 2214 | 2222 | ** or [prepared statement] that invoked the busy handler. |
| 2215 | 2223 | */ |
| | @@ -2230,10 +2238,12 @@ |
| 2230 | 2238 | ** |
| 2231 | 2239 | ** ^(There can only be a single busy handler for a particular |
| 2232 | 2240 | ** [database connection] any any given moment. If another busy handler |
| 2233 | 2241 | ** was defined (using [sqlite3_busy_handler()]) prior to calling |
| 2234 | 2242 | ** this routine, that other busy handler is cleared.)^ |
| 2243 | +** |
| 2244 | +** See also: [PRAGMA busy_timeout] |
| 2235 | 2245 | */ |
| 2236 | 2246 | SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); |
| 2237 | 2247 | |
| 2238 | 2248 | /* |
| 2239 | 2249 | ** CAPI3REF: Convenience Routines For Running Queries |
| | @@ -4818,10 +4828,17 @@ |
| 4818 | 4828 | ** the name of a folder (a.k.a. directory), then all temporary files |
| 4819 | 4829 | ** created by SQLite when using a built-in [sqlite3_vfs | VFS] |
| 4820 | 4830 | ** will be placed in that directory.)^ ^If this variable |
| 4821 | 4831 | ** is a NULL pointer, then SQLite performs a search for an appropriate |
| 4822 | 4832 | ** temporary file directory. |
| 4833 | +** |
| 4834 | +** Applications are strongly discouraged from using this global variable. |
| 4835 | +** It is required to set a temporary folder on Windows Runtime (WinRT). |
| 4836 | +** But for all other platforms, it is highly recommended that applications |
| 4837 | +** neither read nor write this variable. This global variable is a relic |
| 4838 | +** that exists for backwards compatibility of legacy applications and should |
| 4839 | +** be avoided in new projects. |
| 4823 | 4840 | ** |
| 4824 | 4841 | ** It is not safe to read or modify this variable in more than one |
| 4825 | 4842 | ** thread at a time. It is not safe to read or modify this variable |
| 4826 | 4843 | ** if a [database connection] is being used at the same time in a separate |
| 4827 | 4844 | ** thread. |
| | @@ -4837,10 +4854,15 @@ |
| 4837 | 4854 | ** [sqlite3_malloc] and the pragma may attempt to free that memory |
| 4838 | 4855 | ** using [sqlite3_free]. |
| 4839 | 4856 | ** Hence, if this variable is modified directly, either it should be |
| 4840 | 4857 | ** made NULL or made to point to memory obtained from [sqlite3_malloc] |
| 4841 | 4858 | ** or else the use of the [temp_store_directory pragma] should be avoided. |
| 4859 | +** Except when requested by the [temp_store_directory pragma], SQLite |
| 4860 | +** does not free the memory that sqlite3_temp_directory points to. If |
| 4861 | +** the application wants that memory to be freed, it must do |
| 4862 | +** so itself, taking care to only do so after all [database connection] |
| 4863 | +** objects have been destroyed. |
| 4842 | 4864 | ** |
| 4843 | 4865 | ** <b>Note to Windows Runtime users:</b> The temporary directory must be set |
| 4844 | 4866 | ** prior to calling [sqlite3_open] or [sqlite3_open_v2]. Otherwise, various |
| 4845 | 4867 | ** features that require the use of temporary files may fail. Here is an |
| 4846 | 4868 | ** example of how to do this using C++ with the Windows Runtime: |
| | @@ -7256,10 +7278,13 @@ |
| 7256 | 7278 | ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism |
| 7257 | 7279 | ** configured by this function. |
| 7258 | 7280 | ** |
| 7259 | 7281 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 7260 | 7282 | ** from SQL. |
| 7283 | +** |
| 7284 | +** ^Checkpoints initiated by this mechanism are |
| 7285 | +** [sqlite3_wal_checkpoint_v2|PASSIVE]. |
| 7261 | 7286 | ** |
| 7262 | 7287 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 7263 | 7288 | ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] |
| 7264 | 7289 | ** pages. The use of this interface |
| 7265 | 7290 | ** is only necessary if the default setting is found to be suboptimal |
| | @@ -7273,10 +7298,14 @@ |
| 7273 | 7298 | ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X |
| 7274 | 7299 | ** on [database connection] D to be [checkpointed]. ^If X is NULL or an |
| 7275 | 7300 | ** empty string, then a checkpoint is run on all databases of |
| 7276 | 7301 | ** connection D. ^If the database connection D is not in |
| 7277 | 7302 | ** [WAL | write-ahead log mode] then this interface is a harmless no-op. |
| 7303 | +** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a |
| 7304 | +** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint. |
| 7305 | +** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL |
| 7306 | +** or RESET checkpoint. |
| 7278 | 7307 | ** |
| 7279 | 7308 | ** ^The [wal_checkpoint pragma] can be used to invoke this interface |
| 7280 | 7309 | ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the |
| 7281 | 7310 | ** [wal_autocheckpoint pragma] can be used to cause this interface to be |
| 7282 | 7311 | ** run whenever the WAL reaches a certain size threshold. |
| | @@ -7295,22 +7324,25 @@ |
| 7295 | 7324 | ** <dl> |
| 7296 | 7325 | ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd> |
| 7297 | 7326 | ** Checkpoint as many frames as possible without waiting for any database |
| 7298 | 7327 | ** readers or writers to finish. Sync the db file if all frames in the log |
| 7299 | 7328 | ** are checkpointed. This mode is the same as calling |
| 7300 | | -** sqlite3_wal_checkpoint(). The busy-handler callback is never invoked. |
| 7329 | +** sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback] |
| 7330 | +** is never invoked. |
| 7301 | 7331 | ** |
| 7302 | 7332 | ** <dt>SQLITE_CHECKPOINT_FULL<dd> |
| 7303 | | -** This mode blocks (calls the busy-handler callback) until there is no |
| 7333 | +** This mode blocks (it invokes the |
| 7334 | +** [sqlite3_busy_handler|busy-handler callback]) until there is no |
| 7304 | 7335 | ** database writer and all readers are reading from the most recent database |
| 7305 | 7336 | ** snapshot. It then checkpoints all frames in the log file and syncs the |
| 7306 | 7337 | ** database file. This call blocks database writers while it is running, |
| 7307 | 7338 | ** but not database readers. |
| 7308 | 7339 | ** |
| 7309 | 7340 | ** <dt>SQLITE_CHECKPOINT_RESTART<dd> |
| 7310 | 7341 | ** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after |
| 7311 | | -** checkpointing the log file it blocks (calls the busy-handler callback) |
| 7342 | +** checkpointing the log file it blocks (calls the |
| 7343 | +** [sqlite3_busy_handler|busy-handler callback]) |
| 7312 | 7344 | ** until all readers are reading from the database file only. This ensures |
| 7313 | 7345 | ** that the next client to write to the database file restarts the log file |
| 7314 | 7346 | ** from the beginning. This call blocks database writers while it is running, |
| 7315 | 7347 | ** but not database readers. |
| 7316 | 7348 | ** </dl> |
| | @@ -9285,43 +9317,43 @@ |
| 9285 | 9317 | #define OP_Affinity 47 /* synopsis: affinity(r[P1@P2]) */ |
| 9286 | 9318 | #define OP_MakeRecord 48 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 9287 | 9319 | #define OP_Count 49 /* synopsis: r[P2]=count() */ |
| 9288 | 9320 | #define OP_ReadCookie 50 |
| 9289 | 9321 | #define OP_SetCookie 51 |
| 9290 | | -#define OP_OpenRead 52 /* synopsis: root=P2 iDb=P3 */ |
| 9291 | | -#define OP_OpenWrite 53 /* synopsis: root=P2 iDb=P3 */ |
| 9292 | | -#define OP_OpenAutoindex 54 /* synopsis: nColumn=P2 */ |
| 9293 | | -#define OP_OpenEphemeral 55 /* synopsis: nColumn=P2 */ |
| 9294 | | -#define OP_SorterOpen 56 |
| 9295 | | -#define OP_OpenPseudo 57 /* synopsis: P3 columns in r[P2] */ |
| 9296 | | -#define OP_Close 58 |
| 9297 | | -#define OP_SeekLT 59 |
| 9298 | | -#define OP_SeekLE 60 |
| 9299 | | -#define OP_SeekGE 61 |
| 9300 | | -#define OP_SeekGT 62 |
| 9301 | | -#define OP_Seek 63 /* synopsis: intkey=r[P2] */ |
| 9302 | | -#define OP_NoConflict 64 /* synopsis: key=r[P3@P4] */ |
| 9303 | | -#define OP_NotFound 65 /* synopsis: key=r[P3@P4] */ |
| 9304 | | -#define OP_Found 66 /* synopsis: key=r[P3@P4] */ |
| 9305 | | -#define OP_NotExists 67 /* synopsis: intkey=r[P3] */ |
| 9306 | | -#define OP_Sequence 68 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 9307 | | -#define OP_NewRowid 69 /* synopsis: r[P2]=rowid */ |
| 9308 | | -#define OP_Insert 70 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 9322 | +#define OP_ReopenIdx 52 /* synopsis: root=P2 iDb=P3 */ |
| 9323 | +#define OP_OpenRead 53 /* synopsis: root=P2 iDb=P3 */ |
| 9324 | +#define OP_OpenWrite 54 /* synopsis: root=P2 iDb=P3 */ |
| 9325 | +#define OP_OpenAutoindex 55 /* synopsis: nColumn=P2 */ |
| 9326 | +#define OP_OpenEphemeral 56 /* synopsis: nColumn=P2 */ |
| 9327 | +#define OP_SorterOpen 57 |
| 9328 | +#define OP_OpenPseudo 58 /* synopsis: P3 columns in r[P2] */ |
| 9329 | +#define OP_Close 59 |
| 9330 | +#define OP_SeekLT 60 |
| 9331 | +#define OP_SeekLE 61 |
| 9332 | +#define OP_SeekGE 62 |
| 9333 | +#define OP_SeekGT 63 |
| 9334 | +#define OP_Seek 64 /* synopsis: intkey=r[P2] */ |
| 9335 | +#define OP_NoConflict 65 /* synopsis: key=r[P3@P4] */ |
| 9336 | +#define OP_NotFound 66 /* synopsis: key=r[P3@P4] */ |
| 9337 | +#define OP_Found 67 /* synopsis: key=r[P3@P4] */ |
| 9338 | +#define OP_NotExists 68 /* synopsis: intkey=r[P3] */ |
| 9339 | +#define OP_Sequence 69 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 9340 | +#define OP_NewRowid 70 /* synopsis: r[P2]=rowid */ |
| 9309 | 9341 | #define OP_Or 71 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 9310 | 9342 | #define OP_And 72 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 9311 | | -#define OP_InsertInt 73 /* synopsis: intkey=P3 data=r[P2] */ |
| 9312 | | -#define OP_Delete 74 |
| 9313 | | -#define OP_ResetCount 75 |
| 9343 | +#define OP_Insert 73 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 9344 | +#define OP_InsertInt 74 /* synopsis: intkey=P3 data=r[P2] */ |
| 9345 | +#define OP_Delete 75 |
| 9314 | 9346 | #define OP_IsNull 76 /* same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 9315 | 9347 | #define OP_NotNull 77 /* same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 9316 | 9348 | #define OP_Ne 78 /* same as TK_NE, synopsis: if r[P1]!=r[P3] goto P2 */ |
| 9317 | 9349 | #define OP_Eq 79 /* same as TK_EQ, synopsis: if r[P1]==r[P3] goto P2 */ |
| 9318 | 9350 | #define OP_Gt 80 /* same as TK_GT, synopsis: if r[P1]>r[P3] goto P2 */ |
| 9319 | 9351 | #define OP_Le 81 /* same as TK_LE, synopsis: if r[P1]<=r[P3] goto P2 */ |
| 9320 | 9352 | #define OP_Lt 82 /* same as TK_LT, synopsis: if r[P1]<r[P3] goto P2 */ |
| 9321 | 9353 | #define OP_Ge 83 /* same as TK_GE, synopsis: if r[P1]>=r[P3] goto P2 */ |
| 9322 | | -#define OP_SorterCompare 84 /* synopsis: if key(P1)!=rtrim(r[P3],P4) goto P2 */ |
| 9354 | +#define OP_ResetCount 84 |
| 9323 | 9355 | #define OP_BitAnd 85 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 9324 | 9356 | #define OP_BitOr 86 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 9325 | 9357 | #define OP_ShiftLeft 87 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 9326 | 9358 | #define OP_ShiftRight 88 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 9327 | 9359 | #define OP_Add 89 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| | @@ -9328,73 +9360,74 @@ |
| 9328 | 9360 | #define OP_Subtract 90 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 9329 | 9361 | #define OP_Multiply 91 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 9330 | 9362 | #define OP_Divide 92 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 9331 | 9363 | #define OP_Remainder 93 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 9332 | 9364 | #define OP_Concat 94 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 9333 | | -#define OP_SorterData 95 /* synopsis: r[P2]=data */ |
| 9365 | +#define OP_SorterCompare 95 /* synopsis: if key(P1)!=rtrim(r[P3],P4) goto P2 */ |
| 9334 | 9366 | #define OP_BitNot 96 /* same as TK_BITNOT, synopsis: r[P1]= ~r[P1] */ |
| 9335 | 9367 | #define OP_String8 97 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 9336 | | -#define OP_RowKey 98 /* synopsis: r[P2]=key */ |
| 9337 | | -#define OP_RowData 99 /* synopsis: r[P2]=data */ |
| 9338 | | -#define OP_Rowid 100 /* synopsis: r[P2]=rowid */ |
| 9339 | | -#define OP_NullRow 101 |
| 9340 | | -#define OP_Last 102 |
| 9341 | | -#define OP_SorterSort 103 |
| 9342 | | -#define OP_Sort 104 |
| 9343 | | -#define OP_Rewind 105 |
| 9344 | | -#define OP_SorterInsert 106 |
| 9345 | | -#define OP_IdxInsert 107 /* synopsis: key=r[P2] */ |
| 9346 | | -#define OP_IdxDelete 108 /* synopsis: key=r[P2@P3] */ |
| 9347 | | -#define OP_IdxRowid 109 /* synopsis: r[P2]=rowid */ |
| 9348 | | -#define OP_IdxLE 110 /* synopsis: key=r[P3@P4] */ |
| 9349 | | -#define OP_IdxGT 111 /* synopsis: key=r[P3@P4] */ |
| 9350 | | -#define OP_IdxLT 112 /* synopsis: key=r[P3@P4] */ |
| 9351 | | -#define OP_IdxGE 113 /* synopsis: key=r[P3@P4] */ |
| 9352 | | -#define OP_Destroy 114 |
| 9353 | | -#define OP_Clear 115 |
| 9354 | | -#define OP_ResetSorter 116 |
| 9355 | | -#define OP_CreateIndex 117 /* synopsis: r[P2]=root iDb=P1 */ |
| 9356 | | -#define OP_CreateTable 118 /* synopsis: r[P2]=root iDb=P1 */ |
| 9357 | | -#define OP_ParseSchema 119 |
| 9358 | | -#define OP_LoadAnalysis 120 |
| 9359 | | -#define OP_DropTable 121 |
| 9360 | | -#define OP_DropIndex 122 |
| 9361 | | -#define OP_DropTrigger 123 |
| 9362 | | -#define OP_IntegrityCk 124 |
| 9363 | | -#define OP_RowSetAdd 125 /* synopsis: rowset(P1)=r[P2] */ |
| 9364 | | -#define OP_RowSetRead 126 /* synopsis: r[P3]=rowset(P1) */ |
| 9365 | | -#define OP_RowSetTest 127 /* synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 9366 | | -#define OP_Program 128 |
| 9367 | | -#define OP_Param 129 |
| 9368 | | -#define OP_FkCounter 130 /* synopsis: fkctr[P1]+=P2 */ |
| 9369 | | -#define OP_FkIfZero 131 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 9370 | | -#define OP_MemMax 132 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 9368 | +#define OP_SorterData 98 /* synopsis: r[P2]=data */ |
| 9369 | +#define OP_RowKey 99 /* synopsis: r[P2]=key */ |
| 9370 | +#define OP_RowData 100 /* synopsis: r[P2]=data */ |
| 9371 | +#define OP_Rowid 101 /* synopsis: r[P2]=rowid */ |
| 9372 | +#define OP_NullRow 102 |
| 9373 | +#define OP_Last 103 |
| 9374 | +#define OP_SorterSort 104 |
| 9375 | +#define OP_Sort 105 |
| 9376 | +#define OP_Rewind 106 |
| 9377 | +#define OP_SorterInsert 107 |
| 9378 | +#define OP_IdxInsert 108 /* synopsis: key=r[P2] */ |
| 9379 | +#define OP_IdxDelete 109 /* synopsis: key=r[P2@P3] */ |
| 9380 | +#define OP_IdxRowid 110 /* synopsis: r[P2]=rowid */ |
| 9381 | +#define OP_IdxLE 111 /* synopsis: key=r[P3@P4] */ |
| 9382 | +#define OP_IdxGT 112 /* synopsis: key=r[P3@P4] */ |
| 9383 | +#define OP_IdxLT 113 /* synopsis: key=r[P3@P4] */ |
| 9384 | +#define OP_IdxGE 114 /* synopsis: key=r[P3@P4] */ |
| 9385 | +#define OP_Destroy 115 |
| 9386 | +#define OP_Clear 116 |
| 9387 | +#define OP_ResetSorter 117 |
| 9388 | +#define OP_CreateIndex 118 /* synopsis: r[P2]=root iDb=P1 */ |
| 9389 | +#define OP_CreateTable 119 /* synopsis: r[P2]=root iDb=P1 */ |
| 9390 | +#define OP_ParseSchema 120 |
| 9391 | +#define OP_LoadAnalysis 121 |
| 9392 | +#define OP_DropTable 122 |
| 9393 | +#define OP_DropIndex 123 |
| 9394 | +#define OP_DropTrigger 124 |
| 9395 | +#define OP_IntegrityCk 125 |
| 9396 | +#define OP_RowSetAdd 126 /* synopsis: rowset(P1)=r[P2] */ |
| 9397 | +#define OP_RowSetRead 127 /* synopsis: r[P3]=rowset(P1) */ |
| 9398 | +#define OP_RowSetTest 128 /* synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 9399 | +#define OP_Program 129 |
| 9400 | +#define OP_Param 130 |
| 9401 | +#define OP_FkCounter 131 /* synopsis: fkctr[P1]+=P2 */ |
| 9402 | +#define OP_FkIfZero 132 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 9371 | 9403 | #define OP_Real 133 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 9372 | | -#define OP_IfPos 134 /* synopsis: if r[P1]>0 goto P2 */ |
| 9373 | | -#define OP_IfNeg 135 /* synopsis: if r[P1]<0 goto P2 */ |
| 9374 | | -#define OP_IfZero 136 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2 */ |
| 9375 | | -#define OP_AggFinal 137 /* synopsis: accum=r[P1] N=P2 */ |
| 9376 | | -#define OP_IncrVacuum 138 |
| 9377 | | -#define OP_Expire 139 |
| 9378 | | -#define OP_TableLock 140 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 9379 | | -#define OP_VBegin 141 |
| 9380 | | -#define OP_VCreate 142 |
| 9404 | +#define OP_MemMax 134 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 9405 | +#define OP_IfPos 135 /* synopsis: if r[P1]>0 goto P2 */ |
| 9406 | +#define OP_IfNeg 136 /* synopsis: if r[P1]<0 goto P2 */ |
| 9407 | +#define OP_IfZero 137 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2 */ |
| 9408 | +#define OP_AggFinal 138 /* synopsis: accum=r[P1] N=P2 */ |
| 9409 | +#define OP_IncrVacuum 139 |
| 9410 | +#define OP_Expire 140 |
| 9411 | +#define OP_TableLock 141 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 9412 | +#define OP_VBegin 142 |
| 9381 | 9413 | #define OP_ToText 143 /* same as TK_TO_TEXT */ |
| 9382 | 9414 | #define OP_ToBlob 144 /* same as TK_TO_BLOB */ |
| 9383 | 9415 | #define OP_ToNumeric 145 /* same as TK_TO_NUMERIC */ |
| 9384 | 9416 | #define OP_ToInt 146 /* same as TK_TO_INT */ |
| 9385 | 9417 | #define OP_ToReal 147 /* same as TK_TO_REAL */ |
| 9386 | | -#define OP_VDestroy 148 |
| 9387 | | -#define OP_VOpen 149 |
| 9388 | | -#define OP_VColumn 150 /* synopsis: r[P3]=vcolumn(P2) */ |
| 9389 | | -#define OP_VNext 151 |
| 9390 | | -#define OP_VRename 152 |
| 9391 | | -#define OP_Pagecount 153 |
| 9392 | | -#define OP_MaxPgcnt 154 |
| 9393 | | -#define OP_Init 155 /* synopsis: Start at P2 */ |
| 9394 | | -#define OP_Noop 156 |
| 9395 | | -#define OP_Explain 157 |
| 9418 | +#define OP_VCreate 148 |
| 9419 | +#define OP_VDestroy 149 |
| 9420 | +#define OP_VOpen 150 |
| 9421 | +#define OP_VColumn 151 /* synopsis: r[P3]=vcolumn(P2) */ |
| 9422 | +#define OP_VNext 152 |
| 9423 | +#define OP_VRename 153 |
| 9424 | +#define OP_Pagecount 154 |
| 9425 | +#define OP_MaxPgcnt 155 |
| 9426 | +#define OP_Init 156 /* synopsis: Start at P2 */ |
| 9427 | +#define OP_Noop 157 |
| 9428 | +#define OP_Explain 158 |
| 9396 | 9429 | |
| 9397 | 9430 | |
| 9398 | 9431 | /* Properties such as "out2" or "jump" that are specified in |
| 9399 | 9432 | ** comments following the "case" for each opcode in the vdbe.c |
| 9400 | 9433 | ** are encoded into bitvectors as follows: |
| | @@ -9412,23 +9445,23 @@ |
| 9412 | 9445 | /* 16 */ 0x01, 0x01, 0x04, 0x24, 0x01, 0x04, 0x05, 0x10,\ |
| 9413 | 9446 | /* 24 */ 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02,\ |
| 9414 | 9447 | /* 32 */ 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x05, 0x04,\ |
| 9415 | 9448 | /* 40 */ 0x00, 0x00, 0x01, 0x01, 0x05, 0x05, 0x00, 0x00,\ |
| 9416 | 9449 | /* 48 */ 0x00, 0x02, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00,\ |
| 9417 | | -/* 56 */ 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x08,\ |
| 9418 | | -/* 64 */ 0x11, 0x11, 0x11, 0x11, 0x02, 0x02, 0x00, 0x4c,\ |
| 9450 | +/* 56 */ 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11,\ |
| 9451 | +/* 64 */ 0x08, 0x11, 0x11, 0x11, 0x11, 0x02, 0x02, 0x4c,\ |
| 9419 | 9452 | /* 72 */ 0x4c, 0x00, 0x00, 0x00, 0x05, 0x05, 0x15, 0x15,\ |
| 9420 | 9453 | /* 80 */ 0x15, 0x15, 0x15, 0x15, 0x00, 0x4c, 0x4c, 0x4c,\ |
| 9421 | 9454 | /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x00,\ |
| 9422 | | -/* 96 */ 0x24, 0x02, 0x00, 0x00, 0x02, 0x00, 0x01, 0x01,\ |
| 9423 | | -/* 104 */ 0x01, 0x01, 0x08, 0x08, 0x00, 0x02, 0x01, 0x01,\ |
| 9424 | | -/* 112 */ 0x01, 0x01, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00,\ |
| 9425 | | -/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45, 0x15,\ |
| 9426 | | -/* 128 */ 0x01, 0x02, 0x00, 0x01, 0x08, 0x02, 0x05, 0x05,\ |
| 9427 | | -/* 136 */ 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04,\ |
| 9428 | | -/* 144 */ 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x01,\ |
| 9429 | | -/* 152 */ 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,} |
| 9455 | +/* 96 */ 0x24, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,\ |
| 9456 | +/* 104 */ 0x01, 0x01, 0x01, 0x08, 0x08, 0x00, 0x02, 0x01,\ |
| 9457 | +/* 112 */ 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x02, 0x02,\ |
| 9458 | +/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x45,\ |
| 9459 | +/* 128 */ 0x15, 0x01, 0x02, 0x00, 0x01, 0x02, 0x08, 0x05,\ |
| 9460 | +/* 136 */ 0x05, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04,\ |
| 9461 | +/* 144 */ 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00,\ |
| 9462 | +/* 152 */ 0x01, 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,} |
| 9430 | 9463 | |
| 9431 | 9464 | /************** End of opcodes.h *********************************************/ |
| 9432 | 9465 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 9433 | 9466 | |
| 9434 | 9467 | /* |
| | @@ -10932,10 +10965,13 @@ |
| 10932 | 10965 | int tnum; /* Root BTree node for this table (see note above) */ |
| 10933 | 10966 | i16 iPKey; /* If not negative, use aCol[iPKey] as the primary key */ |
| 10934 | 10967 | i16 nCol; /* Number of columns in this table */ |
| 10935 | 10968 | u16 nRef; /* Number of pointers to this Table */ |
| 10936 | 10969 | LogEst szTabRow; /* Estimated size of each table row in bytes */ |
| 10970 | +#ifdef SQLITE_ENABLE_COSTMULT |
| 10971 | + LogEst costMult; /* Cost multiplier for using this table */ |
| 10972 | +#endif |
| 10937 | 10973 | u8 tabFlags; /* Mask of TF_* values */ |
| 10938 | 10974 | u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ |
| 10939 | 10975 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 10940 | 10976 | int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ |
| 10941 | 10977 | #endif |
| | @@ -11591,10 +11627,11 @@ |
| 11591 | 11627 | #define WHERE_AND_ONLY 0x0080 /* Don't use indices for OR terms */ |
| 11592 | 11628 | #define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */ |
| 11593 | 11629 | #define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */ |
| 11594 | 11630 | #define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */ |
| 11595 | 11631 | #define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */ |
| 11632 | +#define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */ |
| 11596 | 11633 | |
| 11597 | 11634 | /* Allowed return values from sqlite3WhereIsDistinct() |
| 11598 | 11635 | */ |
| 11599 | 11636 | #define WHERE_DISTINCT_NOOP 0 /* DISTINCT keyword not used */ |
| 11600 | 11637 | #define WHERE_DISTINCT_UNIQUE 1 /* No duplicates */ |
| | @@ -11847,13 +11884,23 @@ |
| 11847 | 11884 | |
| 11848 | 11885 | /* |
| 11849 | 11886 | ** The yDbMask datatype for the bitmask of all attached databases. |
| 11850 | 11887 | */ |
| 11851 | 11888 | #if SQLITE_MAX_ATTACHED>30 |
| 11852 | | - typedef sqlite3_uint64 yDbMask; |
| 11889 | + typedef unsigned char yDbMask[(SQLITE_MAX_ATTACHED+9)/8]; |
| 11890 | +# define DbMaskTest(M,I) (((M)[(I)/8]&(1<<((I)&7)))!=0) |
| 11891 | +# define DbMaskZero(M) memset((M),0,sizeof(M)) |
| 11892 | +# define DbMaskSet(M,I) (M)[(I)/8]|=(1<<((I)&7)) |
| 11893 | +# define DbMaskAllZero(M) sqlite3DbMaskAllZero(M) |
| 11894 | +# define DbMaskNonZero(M) (sqlite3DbMaskAllZero(M)==0) |
| 11853 | 11895 | #else |
| 11854 | 11896 | typedef unsigned int yDbMask; |
| 11897 | +# define DbMaskTest(M,I) (((M)&(((yDbMask)1)<<(I)))!=0) |
| 11898 | +# define DbMaskZero(M) (M)=0 |
| 11899 | +# define DbMaskSet(M,I) (M)|=(((yDbMask)1)<<(I)) |
| 11900 | +# define DbMaskAllZero(M) (M)==0 |
| 11901 | +# define DbMaskNonZero(M) (M)!=0 |
| 11855 | 11902 | #endif |
| 11856 | 11903 | |
| 11857 | 11904 | /* |
| 11858 | 11905 | ** An SQL parser context. A copy of this structure is passed through |
| 11859 | 11906 | ** the parser and down into all the parser action routine in order to |
| | @@ -12522,10 +12569,13 @@ |
| 12522 | 12569 | SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse*,Table*); |
| 12523 | 12570 | #else |
| 12524 | 12571 | # define sqlite3ViewGetColumnNames(A,B) 0 |
| 12525 | 12572 | #endif |
| 12526 | 12573 | |
| 12574 | +#if SQLITE_MAX_ATTACHED>30 |
| 12575 | +SQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask); |
| 12576 | +#endif |
| 12527 | 12577 | SQLITE_PRIVATE void sqlite3DropTable(Parse*, SrcList*, int, int); |
| 12528 | 12578 | SQLITE_PRIVATE void sqlite3CodeDropTable(Parse*, Table*, int, int); |
| 12529 | 12579 | SQLITE_PRIVATE void sqlite3DeleteTable(sqlite3*, Table*); |
| 12530 | 12580 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| 12531 | 12581 | SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse); |
| | @@ -12772,10 +12822,11 @@ |
| 12772 | 12822 | SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int); |
| 12773 | 12823 | SQLITE_PRIVATE char sqlite3CompareAffinity(Expr *pExpr, char aff2); |
| 12774 | 12824 | SQLITE_PRIVATE int sqlite3IndexAffinityOk(Expr *pExpr, char idx_affinity); |
| 12775 | 12825 | SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr); |
| 12776 | 12826 | SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8); |
| 12827 | +SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*); |
| 12777 | 12828 | SQLITE_PRIVATE void sqlite3Error(sqlite3*, int, const char*,...); |
| 12778 | 12829 | SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n); |
| 12779 | 12830 | SQLITE_PRIVATE u8 sqlite3HexToInt(int h); |
| 12780 | 12831 | SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **); |
| 12781 | 12832 | |
| | @@ -13884,10 +13935,11 @@ |
| 13884 | 13935 | u8 deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */ |
| 13885 | 13936 | Bool isEphemeral:1; /* True for an ephemeral table */ |
| 13886 | 13937 | Bool useRandomRowid:1;/* Generate new record numbers semi-randomly */ |
| 13887 | 13938 | Bool isTable:1; /* True if a table requiring integer keys */ |
| 13888 | 13939 | Bool isOrdered:1; /* True if the underlying table is BTREE_UNORDERED */ |
| 13940 | + Pgno pgnoRoot; /* Root page of the open btree cursor */ |
| 13889 | 13941 | sqlite3_vtab_cursor *pVtabCursor; /* The cursor for a virtual table */ |
| 13890 | 13942 | i64 seqCount; /* Sequence counter */ |
| 13891 | 13943 | i64 movetoTarget; /* Argument to the deferred sqlite3BtreeMoveto() */ |
| 13892 | 13944 | i64 lastRowid; /* Rowid being deleted by OP_Delete */ |
| 13893 | 13945 | VdbeSorter *pSorter; /* Sorter object for OP_SorterOpen cursors */ |
| | @@ -22422,13 +22474,13 @@ |
| 22422 | 22474 | testcase( c==(+1) ); |
| 22423 | 22475 | } |
| 22424 | 22476 | return c; |
| 22425 | 22477 | } |
| 22426 | 22478 | |
| 22427 | | - |
| 22428 | 22479 | /* |
| 22429 | | -** Convert zNum to a 64-bit signed integer. |
| 22480 | +** Convert zNum to a 64-bit signed integer. zNum must be decimal. This |
| 22481 | +** routine does *not* accept hexadecimal notation. |
| 22430 | 22482 | ** |
| 22431 | 22483 | ** If the zNum value is representable as a 64-bit twos-complement |
| 22432 | 22484 | ** integer, then write that value into *pNum and return 0. |
| 22433 | 22485 | ** |
| 22434 | 22486 | ** If zNum is exactly 9223372036854775808, return 2. This special |
| | @@ -22511,14 +22563,48 @@ |
| 22511 | 22563 | assert( u-1==LARGEST_INT64 ); |
| 22512 | 22564 | return neg ? 0 : 2; |
| 22513 | 22565 | } |
| 22514 | 22566 | } |
| 22515 | 22567 | } |
| 22568 | + |
| 22569 | +/* |
| 22570 | +** Transform a UTF-8 integer literal, in either decimal or hexadecimal, |
| 22571 | +** into a 64-bit signed integer. This routine accepts hexadecimal literals, |
| 22572 | +** whereas sqlite3Atoi64() does not. |
| 22573 | +** |
| 22574 | +** Returns: |
| 22575 | +** |
| 22576 | +** 0 Successful transformation. Fits in a 64-bit signed integer. |
| 22577 | +** 1 Integer too large for a 64-bit signed integer or is malformed |
| 22578 | +** 2 Special case of 9223372036854775808 |
| 22579 | +*/ |
| 22580 | +SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char *z, i64 *pOut){ |
| 22581 | +#ifndef SQLITE_OMIT_HEX_INTEGER |
| 22582 | + if( z[0]=='0' |
| 22583 | + && (z[1]=='x' || z[1]=='X') |
| 22584 | + && sqlite3Isxdigit(z[2]) |
| 22585 | + ){ |
| 22586 | + u64 u = 0; |
| 22587 | + int i, k; |
| 22588 | + for(i=2; z[i]=='0'; i++){} |
| 22589 | + for(k=i; sqlite3Isxdigit(z[k]); k++){ |
| 22590 | + u = u*16 + sqlite3HexToInt(z[k]); |
| 22591 | + } |
| 22592 | + memcpy(pOut, &u, 8); |
| 22593 | + return (z[k]==0 && k-i<=16) ? 0 : 1; |
| 22594 | + }else |
| 22595 | +#endif /* SQLITE_OMIT_HEX_INTEGER */ |
| 22596 | + { |
| 22597 | + return sqlite3Atoi64(z, pOut, sqlite3Strlen30(z), SQLITE_UTF8); |
| 22598 | + } |
| 22599 | +} |
| 22516 | 22600 | |
| 22517 | 22601 | /* |
| 22518 | 22602 | ** If zNum represents an integer that will fit in 32-bits, then set |
| 22519 | 22603 | ** *pValue to that integer and return true. Otherwise return false. |
| 22604 | +** |
| 22605 | +** This routine accepts both decimal and hexadecimal notation for integers. |
| 22520 | 22606 | ** |
| 22521 | 22607 | ** Any non-numeric characters that following zNum are ignored. |
| 22522 | 22608 | ** This is different from sqlite3Atoi64() which requires the |
| 22523 | 22609 | ** input number to be zero-terminated. |
| 22524 | 22610 | */ |
| | @@ -22530,11 +22616,29 @@ |
| 22530 | 22616 | neg = 1; |
| 22531 | 22617 | zNum++; |
| 22532 | 22618 | }else if( zNum[0]=='+' ){ |
| 22533 | 22619 | zNum++; |
| 22534 | 22620 | } |
| 22535 | | - while( zNum[0]=='0' ) zNum++; |
| 22621 | +#ifndef SQLITE_OMIT_HEX_INTEGER |
| 22622 | + else if( zNum[0]=='0' |
| 22623 | + && (zNum[1]=='x' || zNum[1]=='X') |
| 22624 | + && sqlite3Isxdigit(zNum[2]) |
| 22625 | + ){ |
| 22626 | + u32 u = 0; |
| 22627 | + zNum += 2; |
| 22628 | + while( zNum[0]=='0' ) zNum++; |
| 22629 | + for(i=0; sqlite3Isxdigit(zNum[i]) && i<8; i++){ |
| 22630 | + u = u*16 + sqlite3HexToInt(zNum[i]); |
| 22631 | + } |
| 22632 | + if( (u&0x80000000)==0 && sqlite3Isxdigit(zNum[i])==0 ){ |
| 22633 | + memcpy(pValue, &u, 4); |
| 22634 | + return 1; |
| 22635 | + }else{ |
| 22636 | + return 0; |
| 22637 | + } |
| 22638 | + } |
| 22639 | +#endif |
| 22536 | 22640 | for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){ |
| 22537 | 22641 | v = v*10 + c; |
| 22538 | 22642 | } |
| 22539 | 22643 | |
| 22540 | 22644 | /* The longest decimal representation of a 32 bit integer is 10 digits: |
| | @@ -23606,43 +23710,43 @@ |
| 23606 | 23710 | /* 47 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 23607 | 23711 | /* 48 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 23608 | 23712 | /* 49 */ "Count" OpHelp("r[P2]=count()"), |
| 23609 | 23713 | /* 50 */ "ReadCookie" OpHelp(""), |
| 23610 | 23714 | /* 51 */ "SetCookie" OpHelp(""), |
| 23611 | | - /* 52 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 23612 | | - /* 53 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 23613 | | - /* 54 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 23614 | | - /* 55 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 23615 | | - /* 56 */ "SorterOpen" OpHelp(""), |
| 23616 | | - /* 57 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 23617 | | - /* 58 */ "Close" OpHelp(""), |
| 23618 | | - /* 59 */ "SeekLT" OpHelp(""), |
| 23619 | | - /* 60 */ "SeekLE" OpHelp(""), |
| 23620 | | - /* 61 */ "SeekGE" OpHelp(""), |
| 23621 | | - /* 62 */ "SeekGT" OpHelp(""), |
| 23622 | | - /* 63 */ "Seek" OpHelp("intkey=r[P2]"), |
| 23623 | | - /* 64 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 23624 | | - /* 65 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 23625 | | - /* 66 */ "Found" OpHelp("key=r[P3@P4]"), |
| 23626 | | - /* 67 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 23627 | | - /* 68 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 23628 | | - /* 69 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 23629 | | - /* 70 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 23715 | + /* 52 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 23716 | + /* 53 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 23717 | + /* 54 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 23718 | + /* 55 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 23719 | + /* 56 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 23720 | + /* 57 */ "SorterOpen" OpHelp(""), |
| 23721 | + /* 58 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 23722 | + /* 59 */ "Close" OpHelp(""), |
| 23723 | + /* 60 */ "SeekLT" OpHelp(""), |
| 23724 | + /* 61 */ "SeekLE" OpHelp(""), |
| 23725 | + /* 62 */ "SeekGE" OpHelp(""), |
| 23726 | + /* 63 */ "SeekGT" OpHelp(""), |
| 23727 | + /* 64 */ "Seek" OpHelp("intkey=r[P2]"), |
| 23728 | + /* 65 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 23729 | + /* 66 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 23730 | + /* 67 */ "Found" OpHelp("key=r[P3@P4]"), |
| 23731 | + /* 68 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 23732 | + /* 69 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 23733 | + /* 70 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 23630 | 23734 | /* 71 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 23631 | 23735 | /* 72 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 23632 | | - /* 73 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 23633 | | - /* 74 */ "Delete" OpHelp(""), |
| 23634 | | - /* 75 */ "ResetCount" OpHelp(""), |
| 23736 | + /* 73 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 23737 | + /* 74 */ "InsertInt" OpHelp("intkey=P3 data=r[P2]"), |
| 23738 | + /* 75 */ "Delete" OpHelp(""), |
| 23635 | 23739 | /* 76 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 23636 | 23740 | /* 77 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 23637 | 23741 | /* 78 */ "Ne" OpHelp("if r[P1]!=r[P3] goto P2"), |
| 23638 | 23742 | /* 79 */ "Eq" OpHelp("if r[P1]==r[P3] goto P2"), |
| 23639 | 23743 | /* 80 */ "Gt" OpHelp("if r[P1]>r[P3] goto P2"), |
| 23640 | 23744 | /* 81 */ "Le" OpHelp("if r[P1]<=r[P3] goto P2"), |
| 23641 | 23745 | /* 82 */ "Lt" OpHelp("if r[P1]<r[P3] goto P2"), |
| 23642 | 23746 | /* 83 */ "Ge" OpHelp("if r[P1]>=r[P3] goto P2"), |
| 23643 | | - /* 84 */ "SorterCompare" OpHelp("if key(P1)!=rtrim(r[P3],P4) goto P2"), |
| 23747 | + /* 84 */ "ResetCount" OpHelp(""), |
| 23644 | 23748 | /* 85 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 23645 | 23749 | /* 86 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 23646 | 23750 | /* 87 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 23647 | 23751 | /* 88 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 23648 | 23752 | /* 89 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| | @@ -23649,73 +23753,74 @@ |
| 23649 | 23753 | /* 90 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 23650 | 23754 | /* 91 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 23651 | 23755 | /* 92 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 23652 | 23756 | /* 93 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 23653 | 23757 | /* 94 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 23654 | | - /* 95 */ "SorterData" OpHelp("r[P2]=data"), |
| 23758 | + /* 95 */ "SorterCompare" OpHelp("if key(P1)!=rtrim(r[P3],P4) goto P2"), |
| 23655 | 23759 | /* 96 */ "BitNot" OpHelp("r[P1]= ~r[P1]"), |
| 23656 | 23760 | /* 97 */ "String8" OpHelp("r[P2]='P4'"), |
| 23657 | | - /* 98 */ "RowKey" OpHelp("r[P2]=key"), |
| 23658 | | - /* 99 */ "RowData" OpHelp("r[P2]=data"), |
| 23659 | | - /* 100 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 23660 | | - /* 101 */ "NullRow" OpHelp(""), |
| 23661 | | - /* 102 */ "Last" OpHelp(""), |
| 23662 | | - /* 103 */ "SorterSort" OpHelp(""), |
| 23663 | | - /* 104 */ "Sort" OpHelp(""), |
| 23664 | | - /* 105 */ "Rewind" OpHelp(""), |
| 23665 | | - /* 106 */ "SorterInsert" OpHelp(""), |
| 23666 | | - /* 107 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 23667 | | - /* 108 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 23668 | | - /* 109 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 23669 | | - /* 110 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 23670 | | - /* 111 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 23671 | | - /* 112 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 23672 | | - /* 113 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 23673 | | - /* 114 */ "Destroy" OpHelp(""), |
| 23674 | | - /* 115 */ "Clear" OpHelp(""), |
| 23675 | | - /* 116 */ "ResetSorter" OpHelp(""), |
| 23676 | | - /* 117 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 23677 | | - /* 118 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 23678 | | - /* 119 */ "ParseSchema" OpHelp(""), |
| 23679 | | - /* 120 */ "LoadAnalysis" OpHelp(""), |
| 23680 | | - /* 121 */ "DropTable" OpHelp(""), |
| 23681 | | - /* 122 */ "DropIndex" OpHelp(""), |
| 23682 | | - /* 123 */ "DropTrigger" OpHelp(""), |
| 23683 | | - /* 124 */ "IntegrityCk" OpHelp(""), |
| 23684 | | - /* 125 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 23685 | | - /* 126 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 23686 | | - /* 127 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 23687 | | - /* 128 */ "Program" OpHelp(""), |
| 23688 | | - /* 129 */ "Param" OpHelp(""), |
| 23689 | | - /* 130 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 23690 | | - /* 131 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 23691 | | - /* 132 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 23761 | + /* 98 */ "SorterData" OpHelp("r[P2]=data"), |
| 23762 | + /* 99 */ "RowKey" OpHelp("r[P2]=key"), |
| 23763 | + /* 100 */ "RowData" OpHelp("r[P2]=data"), |
| 23764 | + /* 101 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 23765 | + /* 102 */ "NullRow" OpHelp(""), |
| 23766 | + /* 103 */ "Last" OpHelp(""), |
| 23767 | + /* 104 */ "SorterSort" OpHelp(""), |
| 23768 | + /* 105 */ "Sort" OpHelp(""), |
| 23769 | + /* 106 */ "Rewind" OpHelp(""), |
| 23770 | + /* 107 */ "SorterInsert" OpHelp(""), |
| 23771 | + /* 108 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 23772 | + /* 109 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 23773 | + /* 110 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 23774 | + /* 111 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 23775 | + /* 112 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 23776 | + /* 113 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 23777 | + /* 114 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 23778 | + /* 115 */ "Destroy" OpHelp(""), |
| 23779 | + /* 116 */ "Clear" OpHelp(""), |
| 23780 | + /* 117 */ "ResetSorter" OpHelp(""), |
| 23781 | + /* 118 */ "CreateIndex" OpHelp("r[P2]=root iDb=P1"), |
| 23782 | + /* 119 */ "CreateTable" OpHelp("r[P2]=root iDb=P1"), |
| 23783 | + /* 120 */ "ParseSchema" OpHelp(""), |
| 23784 | + /* 121 */ "LoadAnalysis" OpHelp(""), |
| 23785 | + /* 122 */ "DropTable" OpHelp(""), |
| 23786 | + /* 123 */ "DropIndex" OpHelp(""), |
| 23787 | + /* 124 */ "DropTrigger" OpHelp(""), |
| 23788 | + /* 125 */ "IntegrityCk" OpHelp(""), |
| 23789 | + /* 126 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 23790 | + /* 127 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 23791 | + /* 128 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 23792 | + /* 129 */ "Program" OpHelp(""), |
| 23793 | + /* 130 */ "Param" OpHelp(""), |
| 23794 | + /* 131 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 23795 | + /* 132 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 23692 | 23796 | /* 133 */ "Real" OpHelp("r[P2]=P4"), |
| 23693 | | - /* 134 */ "IfPos" OpHelp("if r[P1]>0 goto P2"), |
| 23694 | | - /* 135 */ "IfNeg" OpHelp("if r[P1]<0 goto P2"), |
| 23695 | | - /* 136 */ "IfZero" OpHelp("r[P1]+=P3, if r[P1]==0 goto P2"), |
| 23696 | | - /* 137 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 23697 | | - /* 138 */ "IncrVacuum" OpHelp(""), |
| 23698 | | - /* 139 */ "Expire" OpHelp(""), |
| 23699 | | - /* 140 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 23700 | | - /* 141 */ "VBegin" OpHelp(""), |
| 23701 | | - /* 142 */ "VCreate" OpHelp(""), |
| 23797 | + /* 134 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 23798 | + /* 135 */ "IfPos" OpHelp("if r[P1]>0 goto P2"), |
| 23799 | + /* 136 */ "IfNeg" OpHelp("if r[P1]<0 goto P2"), |
| 23800 | + /* 137 */ "IfZero" OpHelp("r[P1]+=P3, if r[P1]==0 goto P2"), |
| 23801 | + /* 138 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 23802 | + /* 139 */ "IncrVacuum" OpHelp(""), |
| 23803 | + /* 140 */ "Expire" OpHelp(""), |
| 23804 | + /* 141 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 23805 | + /* 142 */ "VBegin" OpHelp(""), |
| 23702 | 23806 | /* 143 */ "ToText" OpHelp(""), |
| 23703 | 23807 | /* 144 */ "ToBlob" OpHelp(""), |
| 23704 | 23808 | /* 145 */ "ToNumeric" OpHelp(""), |
| 23705 | 23809 | /* 146 */ "ToInt" OpHelp(""), |
| 23706 | 23810 | /* 147 */ "ToReal" OpHelp(""), |
| 23707 | | - /* 148 */ "VDestroy" OpHelp(""), |
| 23708 | | - /* 149 */ "VOpen" OpHelp(""), |
| 23709 | | - /* 150 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 23710 | | - /* 151 */ "VNext" OpHelp(""), |
| 23711 | | - /* 152 */ "VRename" OpHelp(""), |
| 23712 | | - /* 153 */ "Pagecount" OpHelp(""), |
| 23713 | | - /* 154 */ "MaxPgcnt" OpHelp(""), |
| 23714 | | - /* 155 */ "Init" OpHelp("Start at P2"), |
| 23715 | | - /* 156 */ "Noop" OpHelp(""), |
| 23716 | | - /* 157 */ "Explain" OpHelp(""), |
| 23811 | + /* 148 */ "VCreate" OpHelp(""), |
| 23812 | + /* 149 */ "VDestroy" OpHelp(""), |
| 23813 | + /* 150 */ "VOpen" OpHelp(""), |
| 23814 | + /* 151 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 23815 | + /* 152 */ "VNext" OpHelp(""), |
| 23816 | + /* 153 */ "VRename" OpHelp(""), |
| 23817 | + /* 154 */ "Pagecount" OpHelp(""), |
| 23818 | + /* 155 */ "MaxPgcnt" OpHelp(""), |
| 23819 | + /* 156 */ "Init" OpHelp("Start at P2"), |
| 23820 | + /* 157 */ "Noop" OpHelp(""), |
| 23821 | + /* 158 */ "Explain" OpHelp(""), |
| 23717 | 23822 | }; |
| 23718 | 23823 | return azName[i]; |
| 23719 | 23824 | } |
| 23720 | 23825 | #endif |
| 23721 | 23826 | |
| | @@ -62343,11 +62448,11 @@ |
| 62343 | 62448 | } |
| 62344 | 62449 | sqlite3DbFree(p->db, pParse->aLabel); |
| 62345 | 62450 | pParse->aLabel = 0; |
| 62346 | 62451 | pParse->nLabel = 0; |
| 62347 | 62452 | *pMaxFuncArgs = nMaxArgs; |
| 62348 | | - assert( p->bIsReader!=0 || p->btreeMask==0 ); |
| 62453 | + assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) ); |
| 62349 | 62454 | } |
| 62350 | 62455 | |
| 62351 | 62456 | /* |
| 62352 | 62457 | ** Return the address of the next instruction to be inserted. |
| 62353 | 62458 | */ |
| | @@ -62370,11 +62475,11 @@ |
| 62370 | 62475 | SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe *p, int *pnOp, int *pnMaxArg){ |
| 62371 | 62476 | VdbeOp *aOp = p->aOp; |
| 62372 | 62477 | assert( aOp && !p->db->mallocFailed ); |
| 62373 | 62478 | |
| 62374 | 62479 | /* Check that sqlite3VdbeUsesBtree() was not called on this VM */ |
| 62375 | | - assert( p->btreeMask==0 ); |
| 62480 | + assert( DbMaskAllZero(p->btreeMask) ); |
| 62376 | 62481 | |
| 62377 | 62482 | resolveP2Values(p, pnMaxArg); |
| 62378 | 62483 | *pnOp = p->nOp; |
| 62379 | 62484 | p->aOp = 0; |
| 62380 | 62485 | return aOp; |
| | @@ -62955,13 +63060,13 @@ |
| 62955 | 63060 | ** p->btreeMask of databases that will require a lock. |
| 62956 | 63061 | */ |
| 62957 | 63062 | SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe *p, int i){ |
| 62958 | 63063 | assert( i>=0 && i<p->db->nDb && i<(int)sizeof(yDbMask)*8 ); |
| 62959 | 63064 | assert( i<(int)sizeof(p->btreeMask)*8 ); |
| 62960 | | - p->btreeMask |= ((yDbMask)1)<<i; |
| 63065 | + DbMaskSet(p->btreeMask, i); |
| 62961 | 63066 | if( i!=1 && sqlite3BtreeSharable(p->db->aDb[i].pBt) ){ |
| 62962 | | - p->lockMask |= ((yDbMask)1)<<i; |
| 63067 | + DbMaskSet(p->lockMask, i); |
| 62963 | 63068 | } |
| 62964 | 63069 | } |
| 62965 | 63070 | |
| 62966 | 63071 | #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0 |
| 62967 | 63072 | /* |
| | @@ -62985,20 +63090,19 @@ |
| 62985 | 63090 | ** this routine is N*N. But as N is rarely more than 1, this should not |
| 62986 | 63091 | ** be a problem. |
| 62987 | 63092 | */ |
| 62988 | 63093 | SQLITE_PRIVATE void sqlite3VdbeEnter(Vdbe *p){ |
| 62989 | 63094 | int i; |
| 62990 | | - yDbMask mask; |
| 62991 | 63095 | sqlite3 *db; |
| 62992 | 63096 | Db *aDb; |
| 62993 | 63097 | int nDb; |
| 62994 | | - if( p->lockMask==0 ) return; /* The common case */ |
| 63098 | + if( DbMaskAllZero(p->lockMask) ) return; /* The common case */ |
| 62995 | 63099 | db = p->db; |
| 62996 | 63100 | aDb = db->aDb; |
| 62997 | 63101 | nDb = db->nDb; |
| 62998 | | - for(i=0, mask=1; i<nDb; i++, mask += mask){ |
| 62999 | | - if( i!=1 && (mask & p->lockMask)!=0 && ALWAYS(aDb[i].pBt!=0) ){ |
| 63102 | + for(i=0; i<nDb; i++){ |
| 63103 | + if( i!=1 && DbMaskTest(p->lockMask,i) && ALWAYS(aDb[i].pBt!=0) ){ |
| 63000 | 63104 | sqlite3BtreeEnter(aDb[i].pBt); |
| 63001 | 63105 | } |
| 63002 | 63106 | } |
| 63003 | 63107 | } |
| 63004 | 63108 | #endif |
| | @@ -63007,20 +63111,19 @@ |
| 63007 | 63111 | /* |
| 63008 | 63112 | ** Unlock all of the btrees previously locked by a call to sqlite3VdbeEnter(). |
| 63009 | 63113 | */ |
| 63010 | 63114 | SQLITE_PRIVATE void sqlite3VdbeLeave(Vdbe *p){ |
| 63011 | 63115 | int i; |
| 63012 | | - yDbMask mask; |
| 63013 | 63116 | sqlite3 *db; |
| 63014 | 63117 | Db *aDb; |
| 63015 | 63118 | int nDb; |
| 63016 | | - if( p->lockMask==0 ) return; /* The common case */ |
| 63119 | + if( DbMaskAllZero(p->lockMask) ) return; /* The common case */ |
| 63017 | 63120 | db = p->db; |
| 63018 | 63121 | aDb = db->aDb; |
| 63019 | 63122 | nDb = db->nDb; |
| 63020 | | - for(i=0, mask=1; i<nDb; i++, mask += mask){ |
| 63021 | | - if( i!=1 && (mask & p->lockMask)!=0 && ALWAYS(aDb[i].pBt!=0) ){ |
| 63123 | + for(i=0; i<nDb; i++){ |
| 63124 | + if( i!=1 && DbMaskTest(p->lockMask,i) && ALWAYS(aDb[i].pBt!=0) ){ |
| 63022 | 63125 | sqlite3BtreeLeave(aDb[i].pBt); |
| 63023 | 63126 | } |
| 63024 | 63127 | } |
| 63025 | 63128 | } |
| 63026 | 63129 | #endif |
| | @@ -63987,11 +64090,11 @@ |
| 63987 | 64090 | int cnt = 0; |
| 63988 | 64091 | int nWrite = 0; |
| 63989 | 64092 | int nRead = 0; |
| 63990 | 64093 | p = db->pVdbe; |
| 63991 | 64094 | while( p ){ |
| 63992 | | - if( p->magic==VDBE_MAGIC_RUN && p->pc>=0 ){ |
| 64095 | + if( sqlite3_stmt_busy((sqlite3_stmt*)p) ){ |
| 63993 | 64096 | cnt++; |
| 63994 | 64097 | if( p->readOnly==0 ) nWrite++; |
| 63995 | 64098 | if( p->bIsReader ) nRead++; |
| 63996 | 64099 | } |
| 63997 | 64100 | p = p->pNext; |
| | @@ -67184,11 +67287,11 @@ |
| 67184 | 67287 | /* |
| 67185 | 67288 | ** Return true if the prepared statement is in need of being reset. |
| 67186 | 67289 | */ |
| 67187 | 67290 | SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){ |
| 67188 | 67291 | Vdbe *v = (Vdbe*)pStmt; |
| 67189 | | - return v!=0 && v->pc>0 && v->magic==VDBE_MAGIC_RUN; |
| 67292 | + return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN; |
| 67190 | 67293 | } |
| 67191 | 67294 | |
| 67192 | 67295 | /* |
| 67193 | 67296 | ** Return a pointer to the next prepared statement after pStmt associated |
| 67194 | 67297 | ** with database connection pDb. If pStmt is NULL, return the first |
| | @@ -70641,11 +70744,11 @@ |
| 70641 | 70744 | int iGen; |
| 70642 | 70745 | |
| 70643 | 70746 | assert( p->bIsReader ); |
| 70644 | 70747 | assert( p->readOnly==0 || pOp->p2==0 ); |
| 70645 | 70748 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); |
| 70646 | | - assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 ); |
| 70749 | + assert( DbMaskTest(p->btreeMask, pOp->p1) ); |
| 70647 | 70750 | if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){ |
| 70648 | 70751 | rc = SQLITE_READONLY; |
| 70649 | 70752 | goto abort_due_to_error; |
| 70650 | 70753 | } |
| 70651 | 70754 | pBt = db->aDb[pOp->p1].pBt; |
| | @@ -70736,11 +70839,11 @@ |
| 70736 | 70839 | iDb = pOp->p1; |
| 70737 | 70840 | iCookie = pOp->p3; |
| 70738 | 70841 | assert( pOp->p3<SQLITE_N_BTREE_META ); |
| 70739 | 70842 | assert( iDb>=0 && iDb<db->nDb ); |
| 70740 | 70843 | assert( db->aDb[iDb].pBt!=0 ); |
| 70741 | | - assert( (p->btreeMask & (((yDbMask)1)<<iDb))!=0 ); |
| 70844 | + assert( DbMaskTest(p->btreeMask, iDb) ); |
| 70742 | 70845 | |
| 70743 | 70846 | sqlite3BtreeGetMeta(db->aDb[iDb].pBt, iCookie, (u32 *)&iMeta); |
| 70744 | 70847 | pOut->u.i = iMeta; |
| 70745 | 70848 | break; |
| 70746 | 70849 | } |
| | @@ -70757,11 +70860,11 @@ |
| 70757 | 70860 | */ |
| 70758 | 70861 | case OP_SetCookie: { /* in3 */ |
| 70759 | 70862 | Db *pDb; |
| 70760 | 70863 | assert( pOp->p2<SQLITE_N_BTREE_META ); |
| 70761 | 70864 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); |
| 70762 | | - assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 ); |
| 70865 | + assert( DbMaskTest(p->btreeMask, pOp->p1) ); |
| 70763 | 70866 | assert( p->readOnly==0 ); |
| 70764 | 70867 | pDb = &db->aDb[pOp->p1]; |
| 70765 | 70868 | assert( pDb->pBt!=0 ); |
| 70766 | 70869 | assert( sqlite3SchemaMutexHeld(db, pOp->p1, 0) ); |
| 70767 | 70870 | pIn3 = &aMem[pOp->p3]; |
| | @@ -70812,11 +70915,25 @@ |
| 70812 | 70915 | ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo |
| 70813 | 70916 | ** structure, then said structure defines the content and collating |
| 70814 | 70917 | ** sequence of the index being opened. Otherwise, if P4 is an integer |
| 70815 | 70918 | ** value, it is set to the number of columns in the table. |
| 70816 | 70919 | ** |
| 70817 | | -** See also OpenWrite. |
| 70920 | +** See also: OpenWrite, ReopenIdx |
| 70921 | +*/ |
| 70922 | +/* Opcode: ReopenIdx P1 P2 P3 P4 P5 |
| 70923 | +** Synopsis: root=P2 iDb=P3 |
| 70924 | +** |
| 70925 | +** The ReopenIdx opcode works exactly like ReadOpen except that it first |
| 70926 | +** checks to see if the cursor on P1 is already open with a root page |
| 70927 | +** number of P2 and if it is this opcode becomes a no-op. In other words, |
| 70928 | +** if the cursor is already open, do not reopen it. |
| 70929 | +** |
| 70930 | +** The ReopenIdx opcode may only be used with P5==0 and with P4 being |
| 70931 | +** a P4_KEYINFO object. Furthermore, the P3 value must be the same as |
| 70932 | +** every other ReopenIdx or OpenRead for the same cursor number. |
| 70933 | +** |
| 70934 | +** See the OpenRead opcode documentation for additional information. |
| 70818 | 70935 | */ |
| 70819 | 70936 | /* Opcode: OpenWrite P1 P2 P3 P4 P5 |
| 70820 | 70937 | ** Synopsis: root=P2 iDb=P3 |
| 70821 | 70938 | ** |
| 70822 | 70939 | ** Open a read/write cursor named P1 on the table or index whose root |
| | @@ -70834,10 +70951,23 @@ |
| 70834 | 70951 | ** in read/write mode. For a given table, there can be one or more read-only |
| 70835 | 70952 | ** cursors or a single read/write cursor but not both. |
| 70836 | 70953 | ** |
| 70837 | 70954 | ** See also OpenRead. |
| 70838 | 70955 | */ |
| 70956 | +case OP_ReopenIdx: { |
| 70957 | + VdbeCursor *pCur; |
| 70958 | + |
| 70959 | + assert( pOp->p5==0 ); |
| 70960 | + assert( pOp->p4type==P4_KEYINFO ); |
| 70961 | + pCur = p->apCsr[pOp->p1]; |
| 70962 | + if( pCur && pCur->pgnoRoot==pOp->p2 ){ |
| 70963 | + assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */ |
| 70964 | + break; |
| 70965 | + } |
| 70966 | + /* If the cursor is not currently open or is open on a different |
| 70967 | + ** index, then fall through into OP_OpenRead to force a reopen */ |
| 70968 | +} |
| 70839 | 70969 | case OP_OpenRead: |
| 70840 | 70970 | case OP_OpenWrite: { |
| 70841 | 70971 | int nField; |
| 70842 | 70972 | KeyInfo *pKeyInfo; |
| 70843 | 70973 | int p2; |
| | @@ -70848,11 +70978,12 @@ |
| 70848 | 70978 | Db *pDb; |
| 70849 | 70979 | |
| 70850 | 70980 | assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 ); |
| 70851 | 70981 | assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 ); |
| 70852 | 70982 | assert( p->bIsReader ); |
| 70853 | | - assert( pOp->opcode==OP_OpenRead || p->readOnly==0 ); |
| 70983 | + assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx |
| 70984 | + || p->readOnly==0 ); |
| 70854 | 70985 | |
| 70855 | 70986 | if( p->expired ){ |
| 70856 | 70987 | rc = SQLITE_ABORT; |
| 70857 | 70988 | break; |
| 70858 | 70989 | } |
| | @@ -70860,11 +70991,11 @@ |
| 70860 | 70991 | nField = 0; |
| 70861 | 70992 | pKeyInfo = 0; |
| 70862 | 70993 | p2 = pOp->p2; |
| 70863 | 70994 | iDb = pOp->p3; |
| 70864 | 70995 | assert( iDb>=0 && iDb<db->nDb ); |
| 70865 | | - assert( (p->btreeMask & (((yDbMask)1)<<iDb))!=0 ); |
| 70996 | + assert( DbMaskTest(p->btreeMask, iDb) ); |
| 70866 | 70997 | pDb = &db->aDb[iDb]; |
| 70867 | 70998 | pX = pDb->pBt; |
| 70868 | 70999 | assert( pX!=0 ); |
| 70869 | 71000 | if( pOp->opcode==OP_OpenWrite ){ |
| 70870 | 71001 | wrFlag = 1; |
| | @@ -70905,10 +71036,11 @@ |
| 70905 | 71036 | testcase( nField==0 ); /* Table with INTEGER PRIMARY KEY and nothing else */ |
| 70906 | 71037 | pCur = allocateCursor(p, pOp->p1, nField, iDb, 1); |
| 70907 | 71038 | if( pCur==0 ) goto no_mem; |
| 70908 | 71039 | pCur->nullRow = 1; |
| 70909 | 71040 | pCur->isOrdered = 1; |
| 71041 | + pCur->pgnoRoot = p2; |
| 70910 | 71042 | rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->pCursor); |
| 70911 | 71043 | pCur->pKeyInfo = pKeyInfo; |
| 70912 | 71044 | assert( OPFLAG_BULKCSR==BTREE_BULKLOAD ); |
| 70913 | 71045 | sqlite3BtreeCursorHints(pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR)); |
| 70914 | 71046 | |
| | @@ -72451,11 +72583,11 @@ |
| 72451 | 72583 | rc = SQLITE_LOCKED; |
| 72452 | 72584 | p->errorAction = OE_Abort; |
| 72453 | 72585 | }else{ |
| 72454 | 72586 | iDb = pOp->p3; |
| 72455 | 72587 | assert( iCnt==1 ); |
| 72456 | | - assert( (p->btreeMask & (((yDbMask)1)<<iDb))!=0 ); |
| 72588 | + assert( DbMaskTest(p->btreeMask, iDb) ); |
| 72457 | 72589 | iMoved = 0; /* Not needed. Only to silence a warning. */ |
| 72458 | 72590 | rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved); |
| 72459 | 72591 | pOut->flags = MEM_Int; |
| 72460 | 72592 | pOut->u.i = iMoved; |
| 72461 | 72593 | #ifndef SQLITE_OMIT_AUTOVACUUM |
| | @@ -72491,11 +72623,11 @@ |
| 72491 | 72623 | case OP_Clear: { |
| 72492 | 72624 | int nChange; |
| 72493 | 72625 | |
| 72494 | 72626 | nChange = 0; |
| 72495 | 72627 | assert( p->readOnly==0 ); |
| 72496 | | - assert( (p->btreeMask & (((yDbMask)1)<<pOp->p2))!=0 ); |
| 72628 | + assert( DbMaskTest(p->btreeMask, pOp->p2) ); |
| 72497 | 72629 | rc = sqlite3BtreeClearTable( |
| 72498 | 72630 | db->aDb[pOp->p2].pBt, pOp->p1, (pOp->p3 ? &nChange : 0) |
| 72499 | 72631 | ); |
| 72500 | 72632 | if( pOp->p3 ){ |
| 72501 | 72633 | p->nChange += nChange; |
| | @@ -72561,11 +72693,11 @@ |
| 72561 | 72693 | int flags; |
| 72562 | 72694 | Db *pDb; |
| 72563 | 72695 | |
| 72564 | 72696 | pgno = 0; |
| 72565 | 72697 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); |
| 72566 | | - assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 ); |
| 72698 | + assert( DbMaskTest(p->btreeMask, pOp->p1) ); |
| 72567 | 72699 | assert( p->readOnly==0 ); |
| 72568 | 72700 | pDb = &db->aDb[pOp->p1]; |
| 72569 | 72701 | assert( pDb->pBt!=0 ); |
| 72570 | 72702 | if( pOp->opcode==OP_CreateTable ){ |
| 72571 | 72703 | /* flags = BTREE_INTKEY; */ |
| | @@ -72726,11 +72858,11 @@ |
| 72726 | 72858 | for(j=0; j<nRoot; j++){ |
| 72727 | 72859 | aRoot[j] = (int)sqlite3VdbeIntValue(&pIn1[j]); |
| 72728 | 72860 | } |
| 72729 | 72861 | aRoot[j] = 0; |
| 72730 | 72862 | assert( pOp->p5<db->nDb ); |
| 72731 | | - assert( (p->btreeMask & (((yDbMask)1)<<pOp->p5))!=0 ); |
| 72863 | + assert( DbMaskTest(p->btreeMask, pOp->p5) ); |
| 72732 | 72864 | z = sqlite3BtreeIntegrityCheck(db->aDb[pOp->p5].pBt, aRoot, nRoot, |
| 72733 | 72865 | (int)pnErr->u.i, &nErr); |
| 72734 | 72866 | sqlite3DbFree(db, aRoot); |
| 72735 | 72867 | pnErr->u.i -= nErr; |
| 72736 | 72868 | sqlite3VdbeMemSetNull(pIn1); |
| | @@ -73386,11 +73518,11 @@ |
| 73386 | 73518 | */ |
| 73387 | 73519 | case OP_IncrVacuum: { /* jump */ |
| 73388 | 73520 | Btree *pBt; |
| 73389 | 73521 | |
| 73390 | 73522 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); |
| 73391 | | - assert( (p->btreeMask & (((yDbMask)1)<<pOp->p1))!=0 ); |
| 73523 | + assert( DbMaskTest(p->btreeMask, pOp->p1) ); |
| 73392 | 73524 | assert( p->readOnly==0 ); |
| 73393 | 73525 | pBt = db->aDb[pOp->p1].pBt; |
| 73394 | 73526 | rc = sqlite3BtreeIncrVacuum(pBt); |
| 73395 | 73527 | VdbeBranchTaken(rc==SQLITE_DONE,2); |
| 73396 | 73528 | if( rc==SQLITE_DONE ){ |
| | @@ -73401,16 +73533,17 @@ |
| 73401 | 73533 | } |
| 73402 | 73534 | #endif |
| 73403 | 73535 | |
| 73404 | 73536 | /* Opcode: Expire P1 * * * * |
| 73405 | 73537 | ** |
| 73406 | | -** Cause precompiled statements to become expired. An expired statement |
| 73407 | | -** fails with an error code of SQLITE_SCHEMA if it is ever executed |
| 73408 | | -** (via sqlite3_step()). |
| 73538 | +** Cause precompiled statements to expire. When an expired statement |
| 73539 | +** is executed using sqlite3_step() it will either automatically |
| 73540 | +** reprepare itself (if it was originally created using sqlite3_prepare_v2()) |
| 73541 | +** or it will fail with SQLITE_SCHEMA. |
| 73409 | 73542 | ** |
| 73410 | 73543 | ** If P1 is 0, then all SQL statements become expired. If P1 is non-zero, |
| 73411 | | -** then only the currently executing statement is affected. |
| 73544 | +** then only the currently executing statement is expired. |
| 73412 | 73545 | */ |
| 73413 | 73546 | case OP_Expire: { |
| 73414 | 73547 | if( !pOp->p1 ){ |
| 73415 | 73548 | sqlite3ExpirePreparedStatements(db); |
| 73416 | 73549 | }else{ |
| | @@ -73438,11 +73571,11 @@ |
| 73438 | 73571 | case OP_TableLock: { |
| 73439 | 73572 | u8 isWriteLock = (u8)pOp->p3; |
| 73440 | 73573 | if( isWriteLock || 0==(db->flags&SQLITE_ReadUncommitted) ){ |
| 73441 | 73574 | int p1 = pOp->p1; |
| 73442 | 73575 | assert( p1>=0 && p1<db->nDb ); |
| 73443 | | - assert( (p->btreeMask & (((yDbMask)1)<<p1))!=0 ); |
| 73576 | + assert( DbMaskTest(p->btreeMask, p1) ); |
| 73444 | 73577 | assert( isWriteLock==0 || isWriteLock==1 ); |
| 73445 | 73578 | rc = sqlite3BtreeLockTable(db->aDb[p1].pBt, pOp->p2, isWriteLock); |
| 73446 | 73579 | if( (rc&0xFF)==SQLITE_LOCKED ){ |
| 73447 | 73580 | const char *z = pOp->p4.z; |
| 73448 | 73581 | sqlite3SetString(&p->zErrMsg, db, "database table is locked: %s", z); |
| | @@ -73888,11 +74021,11 @@ |
| 73888 | 74021 | #ifdef SQLITE_USE_FCNTL_TRACE |
| 73889 | 74022 | zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql); |
| 73890 | 74023 | if( zTrace ){ |
| 73891 | 74024 | int i; |
| 73892 | 74025 | for(i=0; i<db->nDb; i++){ |
| 73893 | | - if( (MASKBIT(i) & p->btreeMask)==0 ) continue; |
| 74026 | + if( DbMaskTest(p->btreeMask, i)==0 ) continue; |
| 73894 | 74027 | sqlite3_file_control(db, db->aDb[i].zName, SQLITE_FCNTL_TRACE, zTrace); |
| 73895 | 74028 | } |
| 73896 | 74029 | } |
| 73897 | 74030 | #endif /* SQLITE_USE_FCNTL_TRACE */ |
| 73898 | 74031 | #ifdef SQLITE_DEBUG |
| | @@ -79792,21 +79925,28 @@ |
| 79792 | 79925 | }else{ |
| 79793 | 79926 | int c; |
| 79794 | 79927 | i64 value; |
| 79795 | 79928 | const char *z = pExpr->u.zToken; |
| 79796 | 79929 | assert( z!=0 ); |
| 79797 | | - c = sqlite3Atoi64(z, &value, sqlite3Strlen30(z), SQLITE_UTF8); |
| 79930 | + c = sqlite3DecOrHexToI64(z, &value); |
| 79798 | 79931 | if( c==0 || (c==2 && negFlag) ){ |
| 79799 | 79932 | char *zV; |
| 79800 | 79933 | if( negFlag ){ value = c==2 ? SMALLEST_INT64 : -value; } |
| 79801 | 79934 | zV = dup8bytes(v, (char*)&value); |
| 79802 | 79935 | sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, zV, P4_INT64); |
| 79803 | 79936 | }else{ |
| 79804 | 79937 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 79805 | 79938 | sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z); |
| 79806 | 79939 | #else |
| 79807 | | - codeReal(v, z, negFlag, iMem); |
| 79940 | +#ifndef SQLITE_OMIT_HEX_INTEGER |
| 79941 | + if( sqlite3_strnicmp(z,"0x",2)==0 ){ |
| 79942 | + sqlite3ErrorMsg(pParse, "hex literal too big: %s", z); |
| 79943 | + }else |
| 79944 | +#endif |
| 79945 | + { |
| 79946 | + codeReal(v, z, negFlag, iMem); |
| 79947 | + } |
| 79808 | 79948 | #endif |
| 79809 | 79949 | } |
| 79810 | 79950 | } |
| 79811 | 79951 | } |
| 79812 | 79952 | |
| | @@ -83913,20 +84053,20 @@ |
| 83913 | 84053 | ** ... |
| 83914 | 84054 | ** regChng = N |
| 83915 | 84055 | ** goto chng_addr_N |
| 83916 | 84056 | */ |
| 83917 | 84057 | addrNextRow = sqlite3VdbeCurrentAddr(v); |
| 83918 | | - for(i=0; i<nCol; i++){ |
| 84058 | + for(i=0; i<nCol-1; i++){ |
| 83919 | 84059 | char *pColl = (char*)sqlite3LocateCollSeq(pParse, pIdx->azColl[i]); |
| 83920 | 84060 | sqlite3VdbeAddOp2(v, OP_Integer, i, regChng); |
| 83921 | 84061 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regTemp); |
| 83922 | 84062 | aGotoChng[i] = |
| 83923 | 84063 | sqlite3VdbeAddOp4(v, OP_Ne, regTemp, 0, regPrev+i, pColl, P4_COLLSEQ); |
| 83924 | 84064 | sqlite3VdbeChangeP5(v, SQLITE_NULLEQ); |
| 83925 | 84065 | VdbeCoverage(v); |
| 83926 | 84066 | } |
| 83927 | | - sqlite3VdbeAddOp2(v, OP_Integer, nCol, regChng); |
| 84067 | + sqlite3VdbeAddOp2(v, OP_Integer, nCol-1, regChng); |
| 83928 | 84068 | aGotoChng[nCol] = sqlite3VdbeAddOp0(v, OP_Goto); |
| 83929 | 84069 | |
| 83930 | 84070 | /* |
| 83931 | 84071 | ** chng_addr_0: |
| 83932 | 84072 | ** regPrev(0) = idx(0) |
| | @@ -83933,11 +84073,11 @@ |
| 83933 | 84073 | ** chng_addr_1: |
| 83934 | 84074 | ** regPrev(1) = idx(1) |
| 83935 | 84075 | ** ... |
| 83936 | 84076 | */ |
| 83937 | 84077 | sqlite3VdbeJumpHere(v, addrGotoChng0); |
| 83938 | | - for(i=0; i<nCol; i++){ |
| 84078 | + for(i=0; i<nCol-1; i++){ |
| 83939 | 84079 | sqlite3VdbeJumpHere(v, aGotoChng[i]); |
| 83940 | 84080 | sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, i, regPrev+i); |
| 83941 | 84081 | } |
| 83942 | 84082 | |
| 83943 | 84083 | /* |
| | @@ -84124,10 +84264,11 @@ |
| 84124 | 84264 | int i; |
| 84125 | 84265 | char *z, *zDb; |
| 84126 | 84266 | Table *pTab; |
| 84127 | 84267 | Index *pIdx; |
| 84128 | 84268 | Token *pTableName; |
| 84269 | + Vdbe *v; |
| 84129 | 84270 | |
| 84130 | 84271 | /* Read the database schema. If an error occurs, leave an error message |
| 84131 | 84272 | ** and code in pParse and return NULL. */ |
| 84132 | 84273 | assert( sqlite3BtreeHoldsAllMutexes(pParse->db) ); |
| 84133 | 84274 | if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){ |
| | @@ -84171,10 +84312,12 @@ |
| 84171 | 84312 | } |
| 84172 | 84313 | sqlite3DbFree(db, z); |
| 84173 | 84314 | } |
| 84174 | 84315 | } |
| 84175 | 84316 | } |
| 84317 | + v = sqlite3GetVdbe(pParse); |
| 84318 | + if( v ) sqlite3VdbeAddOp0(v, OP_Expire); |
| 84176 | 84319 | } |
| 84177 | 84320 | |
| 84178 | 84321 | /* |
| 84179 | 84322 | ** Used to pass information from the analyzer reader through to the |
| 84180 | 84323 | ** callback routine. |
| | @@ -84229,18 +84372,23 @@ |
| 84229 | 84372 | #ifndef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 84230 | 84373 | assert( pIndex!=0 ); |
| 84231 | 84374 | #else |
| 84232 | 84375 | if( pIndex ) |
| 84233 | 84376 | #endif |
| 84234 | | - { |
| 84235 | | - if( strcmp(z, "unordered")==0 ){ |
| 84377 | + while( z[0] ){ |
| 84378 | + if( sqlite3_strglob("unordered*", z)==0 ){ |
| 84236 | 84379 | pIndex->bUnordered = 1; |
| 84237 | 84380 | }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){ |
| 84238 | | - int v32 = 0; |
| 84239 | | - sqlite3GetInt32(z+3, &v32); |
| 84240 | | - pIndex->szIdxRow = sqlite3LogEst(v32); |
| 84381 | + pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3)); |
| 84241 | 84382 | } |
| 84383 | +#ifdef SQLITE_ENABLE_COSTMULT |
| 84384 | + else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){ |
| 84385 | + pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9)); |
| 84386 | + } |
| 84387 | +#endif |
| 84388 | + while( z[0]!=0 && z[0]!=' ' ) z++; |
| 84389 | + while( z[0]==' ' ) z++; |
| 84242 | 84390 | } |
| 84243 | 84391 | } |
| 84244 | 84392 | |
| 84245 | 84393 | /* |
| 84246 | 84394 | ** This callback is invoked once for each index when reading the |
| | @@ -84277,15 +84425,19 @@ |
| 84277 | 84425 | pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase); |
| 84278 | 84426 | } |
| 84279 | 84427 | z = argv[2]; |
| 84280 | 84428 | |
| 84281 | 84429 | if( pIndex ){ |
| 84430 | + pIndex->bUnordered = 0; |
| 84282 | 84431 | decodeIntArray((char*)z, pIndex->nKeyCol+1, 0, pIndex->aiRowLogEst, pIndex); |
| 84283 | 84432 | if( pIndex->pPartIdxWhere==0 ) pTable->nRowLogEst = pIndex->aiRowLogEst[0]; |
| 84284 | 84433 | }else{ |
| 84285 | 84434 | Index fakeIdx; |
| 84286 | 84435 | fakeIdx.szIdxRow = pTable->szTabRow; |
| 84436 | +#ifdef SQLITE_ENABLE_COSTMULT |
| 84437 | + fakeIdx.pTable = pTable; |
| 84438 | +#endif |
| 84287 | 84439 | decodeIntArray((char*)z, 1, 0, &pTable->nRowLogEst, &fakeIdx); |
| 84288 | 84440 | pTable->szTabRow = fakeIdx.szIdxRow; |
| 84289 | 84441 | } |
| 84290 | 84442 | |
| 84291 | 84443 | return 0; |
| | @@ -85557,10 +85709,23 @@ |
| 85557 | 85709 | } |
| 85558 | 85710 | #else |
| 85559 | 85711 | #define codeTableLocks(x) |
| 85560 | 85712 | #endif |
| 85561 | 85713 | |
| 85714 | +/* |
| 85715 | +** Return TRUE if the given yDbMask object is empty - if it contains no |
| 85716 | +** 1 bits. This routine is used by the DbMaskAllZero() and DbMaskNotZero() |
| 85717 | +** macros when SQLITE_MAX_ATTACHED is greater than 30. |
| 85718 | +*/ |
| 85719 | +#if SQLITE_MAX_ATTACHED>30 |
| 85720 | +SQLITE_PRIVATE int sqlite3DbMaskAllZero(yDbMask m){ |
| 85721 | + int i; |
| 85722 | + for(i=0; i<sizeof(yDbMask); i++) if( m[i] ) return 0; |
| 85723 | + return 1; |
| 85724 | +} |
| 85725 | +#endif |
| 85726 | + |
| 85562 | 85727 | /* |
| 85563 | 85728 | ** This routine is called after a single SQL statement has been |
| 85564 | 85729 | ** parsed and a VDBE program to execute that statement has been |
| 85565 | 85730 | ** prepared. This routine puts the finishing touches on the |
| 85566 | 85731 | ** VDBE program and resets the pParse structure for the next |
| | @@ -85593,22 +85758,23 @@ |
| 85593 | 85758 | ** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are |
| 85594 | 85759 | ** set for each database that is used. Generate code to start a |
| 85595 | 85760 | ** transaction on each used database and to verify the schema cookie |
| 85596 | 85761 | ** on each used database. |
| 85597 | 85762 | */ |
| 85598 | | - if( db->mallocFailed==0 && (pParse->cookieMask || pParse->pConstExpr) ){ |
| 85599 | | - yDbMask mask; |
| 85763 | + if( db->mallocFailed==0 |
| 85764 | + && (DbMaskNonZero(pParse->cookieMask) || pParse->pConstExpr) |
| 85765 | + ){ |
| 85600 | 85766 | int iDb, i; |
| 85601 | 85767 | assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init ); |
| 85602 | 85768 | sqlite3VdbeJumpHere(v, 0); |
| 85603 | | - for(iDb=0, mask=1; iDb<db->nDb; mask<<=1, iDb++){ |
| 85604 | | - if( (mask & pParse->cookieMask)==0 ) continue; |
| 85769 | + for(iDb=0; iDb<db->nDb; iDb++){ |
| 85770 | + if( DbMaskTest(pParse->cookieMask, iDb)==0 ) continue; |
| 85605 | 85771 | sqlite3VdbeUsesBtree(v, iDb); |
| 85606 | 85772 | sqlite3VdbeAddOp4Int(v, |
| 85607 | 85773 | OP_Transaction, /* Opcode */ |
| 85608 | 85774 | iDb, /* P1 */ |
| 85609 | | - (mask & pParse->writeMask)!=0, /* P2 */ |
| 85775 | + DbMaskTest(pParse->writeMask,iDb), /* P2 */ |
| 85610 | 85776 | pParse->cookieValue[iDb], /* P3 */ |
| 85611 | 85777 | db->aDb[iDb].pSchema->iGeneration /* P4 */ |
| 85612 | 85778 | ); |
| 85613 | 85779 | if( db->init.busy==0 ) sqlite3VdbeChangeP5(v, 1); |
| 85614 | 85780 | } |
| | @@ -85660,11 +85826,11 @@ |
| 85660 | 85826 | } |
| 85661 | 85827 | pParse->nTab = 0; |
| 85662 | 85828 | pParse->nMem = 0; |
| 85663 | 85829 | pParse->nSet = 0; |
| 85664 | 85830 | pParse->nVar = 0; |
| 85665 | | - pParse->cookieMask = 0; |
| 85831 | + DbMaskZero(pParse->cookieMask); |
| 85666 | 85832 | } |
| 85667 | 85833 | |
| 85668 | 85834 | /* |
| 85669 | 85835 | ** Run the parser and code generator recursively in order to generate |
| 85670 | 85836 | ** code for the SQL statement given onto the end of the pParse context |
| | @@ -89287,19 +89453,17 @@ |
| 89287 | 89453 | ** later, by sqlite3FinishCoding(). |
| 89288 | 89454 | */ |
| 89289 | 89455 | SQLITE_PRIVATE void sqlite3CodeVerifySchema(Parse *pParse, int iDb){ |
| 89290 | 89456 | Parse *pToplevel = sqlite3ParseToplevel(pParse); |
| 89291 | 89457 | sqlite3 *db = pToplevel->db; |
| 89292 | | - yDbMask mask; |
| 89293 | 89458 | |
| 89294 | 89459 | assert( iDb>=0 && iDb<db->nDb ); |
| 89295 | 89460 | assert( db->aDb[iDb].pBt!=0 || iDb==1 ); |
| 89296 | 89461 | assert( iDb<SQLITE_MAX_ATTACHED+2 ); |
| 89297 | 89462 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 89298 | | - mask = ((yDbMask)1)<<iDb; |
| 89299 | | - if( (pToplevel->cookieMask & mask)==0 ){ |
| 89300 | | - pToplevel->cookieMask |= mask; |
| 89463 | + if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){ |
| 89464 | + DbMaskSet(pToplevel->cookieMask, iDb); |
| 89301 | 89465 | pToplevel->cookieValue[iDb] = db->aDb[iDb].pSchema->schema_cookie; |
| 89302 | 89466 | if( !OMIT_TEMPDB && iDb==1 ){ |
| 89303 | 89467 | sqlite3OpenTempDatabase(pToplevel); |
| 89304 | 89468 | } |
| 89305 | 89469 | } |
| | @@ -89334,11 +89498,11 @@ |
| 89334 | 89498 | ** necessary to undo a write and the checkpoint should not be set. |
| 89335 | 89499 | */ |
| 89336 | 89500 | SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){ |
| 89337 | 89501 | Parse *pToplevel = sqlite3ParseToplevel(pParse); |
| 89338 | 89502 | sqlite3CodeVerifySchema(pParse, iDb); |
| 89339 | | - pToplevel->writeMask |= ((yDbMask)1)<<iDb; |
| 89503 | + DbMaskSet(pToplevel->writeMask, iDb); |
| 89340 | 89504 | pToplevel->isMultiWrite |= setStatement; |
| 89341 | 89505 | } |
| 89342 | 89506 | |
| 89343 | 89507 | /* |
| 89344 | 89508 | ** Indicate that the statement currently under construction might write |
| | @@ -98590,11 +98754,11 @@ |
| 98590 | 98754 | */ |
| 98591 | 98755 | case PragTyp_JOURNAL_SIZE_LIMIT: { |
| 98592 | 98756 | Pager *pPager = sqlite3BtreePager(pDb->pBt); |
| 98593 | 98757 | i64 iLimit = -2; |
| 98594 | 98758 | if( zRight ){ |
| 98595 | | - sqlite3Atoi64(zRight, &iLimit, sqlite3Strlen30(zRight), SQLITE_UTF8); |
| 98759 | + sqlite3DecOrHexToI64(zRight, &iLimit); |
| 98596 | 98760 | if( iLimit<-1 ) iLimit = -1; |
| 98597 | 98761 | } |
| 98598 | 98762 | iLimit = sqlite3PagerJournalSizeLimit(pPager, iLimit); |
| 98599 | 98763 | returnSingleInt(pParse, "journal_size_limit", iLimit); |
| 98600 | 98764 | break; |
| | @@ -98718,11 +98882,11 @@ |
| 98718 | 98882 | sqlite3_int64 sz; |
| 98719 | 98883 | #if SQLITE_MAX_MMAP_SIZE>0 |
| 98720 | 98884 | assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); |
| 98721 | 98885 | if( zRight ){ |
| 98722 | 98886 | int ii; |
| 98723 | | - sqlite3Atoi64(zRight, &sz, sqlite3Strlen30(zRight), SQLITE_UTF8); |
| 98887 | + sqlite3DecOrHexToI64(zRight, &sz); |
| 98724 | 98888 | if( sz<0 ) sz = sqlite3GlobalConfig.szMmap; |
| 98725 | 98889 | if( pId2->n==0 ) db->szMmap = sz; |
| 98726 | 98890 | for(ii=db->nDb-1; ii>=0; ii--){ |
| 98727 | 98891 | if( db->aDb[ii].pBt && (ii==iDb || pId2->n==0) ){ |
| 98728 | 98892 | sqlite3BtreeSetMmapLimit(db->aDb[ii].pBt, sz); |
| | @@ -99761,11 +99925,11 @@ |
| 99761 | 99925 | ** Call sqlite3_soft_heap_limit64(N). Return the result. If N is omitted, |
| 99762 | 99926 | ** use -1. |
| 99763 | 99927 | */ |
| 99764 | 99928 | case PragTyp_SOFT_HEAP_LIMIT: { |
| 99765 | 99929 | sqlite3_int64 N; |
| 99766 | | - if( zRight && sqlite3Atoi64(zRight, &N, 1000000, SQLITE_UTF8)==SQLITE_OK ){ |
| 99930 | + if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){ |
| 99767 | 99931 | sqlite3_soft_heap_limit64(N); |
| 99768 | 99932 | } |
| 99769 | 99933 | returnSingleInt(pParse, "soft_heap_limit", sqlite3_soft_heap_limit64(-1)); |
| 99770 | 99934 | break; |
| 99771 | 99935 | } |
| | @@ -113609,10 +113773,11 @@ |
| 113609 | 113773 | int regRowid = 0; /* Register holding rowid */ |
| 113610 | 113774 | int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */ |
| 113611 | 113775 | int iRetInit; /* Address of regReturn init */ |
| 113612 | 113776 | int untestedTerms = 0; /* Some terms not completely tested */ |
| 113613 | 113777 | int ii; /* Loop counter */ |
| 113778 | + u16 wctrlFlags; /* Flags for sub-WHERE clause */ |
| 113614 | 113779 | Expr *pAndExpr = 0; /* An ".. AND (...)" expression */ |
| 113615 | 113780 | Table *pTab = pTabItem->pTab; |
| 113616 | 113781 | |
| 113617 | 113782 | pTerm = pLoop->aLTerm[0]; |
| 113618 | 113783 | assert( pTerm!=0 ); |
| | @@ -113704,10 +113869,12 @@ |
| 113704 | 113869 | |
| 113705 | 113870 | /* Run a separate WHERE clause for each term of the OR clause. After |
| 113706 | 113871 | ** eliminating duplicates from other WHERE clauses, the action for each |
| 113707 | 113872 | ** sub-WHERE clause is to to invoke the main loop body as a subroutine. |
| 113708 | 113873 | */ |
| 113874 | + wctrlFlags = WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY | |
| 113875 | + WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY; |
| 113709 | 113876 | for(ii=0; ii<pOrWc->nTerm; ii++){ |
| 113710 | 113877 | WhereTerm *pOrTerm = &pOrWc->a[ii]; |
| 113711 | 113878 | if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 113712 | 113879 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ |
| 113713 | 113880 | Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */ |
| | @@ -113716,12 +113883,11 @@ |
| 113716 | 113883 | pAndExpr->pLeft = pOrExpr; |
| 113717 | 113884 | pOrExpr = pAndExpr; |
| 113718 | 113885 | } |
| 113719 | 113886 | /* Loop through table entries that match term pOrTerm. */ |
| 113720 | 113887 | pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, |
| 113721 | | - WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY | |
| 113722 | | - WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur); |
| 113888 | + wctrlFlags, iCovCur); |
| 113723 | 113889 | assert( pSubWInfo || pParse->nErr || db->mallocFailed ); |
| 113724 | 113890 | if( pSubWInfo ){ |
| 113725 | 113891 | WhereLoop *pSubLoop; |
| 113726 | 113892 | explainOneScan( |
| 113727 | 113893 | pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0 |
| | @@ -113808,10 +113974,11 @@ |
| 113808 | 113974 | && (ii==0 || pSubLoop->u.btree.pIndex==pCov) |
| 113809 | 113975 | && (HasRowid(pTab) || !IsPrimaryKeyIndex(pSubLoop->u.btree.pIndex)) |
| 113810 | 113976 | ){ |
| 113811 | 113977 | assert( pSubWInfo->a[0].iIdxCur==iCovCur ); |
| 113812 | 113978 | pCov = pSubLoop->u.btree.pIndex; |
| 113979 | + wctrlFlags |= WHERE_REOPEN_IDX; |
| 113813 | 113980 | }else{ |
| 113814 | 113981 | pCov = 0; |
| 113815 | 113982 | } |
| 113816 | 113983 | |
| 113817 | 113984 | /* Finish the loop through table entries that match term pOrTerm. */ |
| | @@ -114414,10 +114581,20 @@ |
| 114414 | 114581 | pLoop->nOut += (pTerm->truthProb<=0 ? pTerm->truthProb : -1); |
| 114415 | 114582 | } |
| 114416 | 114583 | } |
| 114417 | 114584 | } |
| 114418 | 114585 | |
| 114586 | +/* |
| 114587 | +** Adjust the cost C by the costMult facter T. This only occurs if |
| 114588 | +** compiled with -DSQLITE_ENABLE_COSTMULT |
| 114589 | +*/ |
| 114590 | +#ifdef SQLITE_ENABLE_COSTMULT |
| 114591 | +# define ApplyCostMultiplier(C,T) C += T |
| 114592 | +#else |
| 114593 | +# define ApplyCostMultiplier(C,T) |
| 114594 | +#endif |
| 114595 | + |
| 114419 | 114596 | /* |
| 114420 | 114597 | ** We have so far matched pBuilder->pNew->u.btree.nEq terms of the |
| 114421 | 114598 | ** index pIndex. Try to match one more. |
| 114422 | 114599 | ** |
| 114423 | 114600 | ** When this function is called, pBuilder->pNew->nOut contains the |
| | @@ -114610,11 +114787,10 @@ |
| 114610 | 114787 | testcase( eOp & WO_ISNULL ); |
| 114611 | 114788 | rc = whereEqualScanEst(pParse, pBuilder, pExpr->pRight, &nOut); |
| 114612 | 114789 | }else{ |
| 114613 | 114790 | rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut); |
| 114614 | 114791 | } |
| 114615 | | - assert( rc!=SQLITE_OK || nOut>0 ); |
| 114616 | 114792 | if( rc==SQLITE_NOTFOUND ) rc = SQLITE_OK; |
| 114617 | 114793 | if( rc!=SQLITE_OK ) break; /* Jump out of the pTerm loop */ |
| 114618 | 114794 | if( nOut ){ |
| 114619 | 114795 | pNew->nOut = sqlite3LogEst(nOut); |
| 114620 | 114796 | if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut; |
| | @@ -114642,10 +114818,11 @@ |
| 114642 | 114818 | rCostIdx = pNew->nOut + 1 + (15*pProbe->szIdxRow)/pSrc->pTab->szTabRow; |
| 114643 | 114819 | pNew->rRun = sqlite3LogEstAdd(rLogSize, rCostIdx); |
| 114644 | 114820 | if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){ |
| 114645 | 114821 | pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut + 16); |
| 114646 | 114822 | } |
| 114823 | + ApplyCostMultiplier(pNew->rRun, pProbe->pTable->costMult); |
| 114647 | 114824 | |
| 114648 | 114825 | nOutUnadjusted = pNew->nOut; |
| 114649 | 114826 | pNew->rRun += nInMul + nIn; |
| 114650 | 114827 | pNew->nOut += nInMul + nIn; |
| 114651 | 114828 | whereLoopOutputAdjust(pBuilder->pWC, pNew); |
| | @@ -114761,10 +114938,18 @@ |
| 114761 | 114938 | ** cost = nSeek * (log(nRow) + (K+3.0) * nVisit) // non-covering index |
| 114762 | 114939 | ** |
| 114763 | 114940 | ** Normally, nSeek is 1. nSeek values greater than 1 come about if the |
| 114764 | 114941 | ** WHERE clause includes "x IN (....)" terms used in place of "x=?". Or when |
| 114765 | 114942 | ** implicit "x IN (SELECT x FROM tbl)" terms are added for skip-scans. |
| 114943 | +** |
| 114944 | +** The estimated values (nRow, nVisit, nSeek) often contain a large amount |
| 114945 | +** of uncertainty. For this reason, scoring is designed to pick plans that |
| 114946 | +** "do the least harm" if the estimates are inaccurate. For example, a |
| 114947 | +** log(nRow) factor is omitted from a non-covering index scan in order to |
| 114948 | +** bias the scoring in favor of using an index, since the worst-case |
| 114949 | +** performance of using an index is far better than the worst-case performance |
| 114950 | +** of a full table scan. |
| 114766 | 114951 | */ |
| 114767 | 114952 | static int whereLoopAddBtree( |
| 114768 | 114953 | WhereLoopBuilder *pBuilder, /* WHERE clause information */ |
| 114769 | 114954 | Bitmask mExtra /* Extra prerequesites for using this table */ |
| 114770 | 114955 | ){ |
| | @@ -114848,10 +115033,11 @@ |
| 114848 | 115033 | pNew->aLTerm[0] = pTerm; |
| 114849 | 115034 | /* TUNING: One-time cost for computing the automatic index is |
| 114850 | 115035 | ** approximately 7*N*log2(N) where N is the number of rows in |
| 114851 | 115036 | ** the table being indexed. */ |
| 114852 | 115037 | pNew->rSetup = rLogSize + rSize + 28; assert( 28==sqlite3LogEst(7) ); |
| 115038 | + ApplyCostMultiplier(pNew->rSetup, pTab->costMult); |
| 114853 | 115039 | /* TUNING: Each index lookup yields 20 rows in the table. This |
| 114854 | 115040 | ** is more than the usual guess of 10 rows, since we have no way |
| 114855 | 115041 | ** of knowning how selective the index will ultimately be. It would |
| 114856 | 115042 | ** not be unreasonable to make this value much larger. */ |
| 114857 | 115043 | pNew->nOut = 43; assert( 43==sqlite3LogEst(20) ); |
| | @@ -114889,10 +115075,11 @@ |
| 114889 | 115075 | |
| 114890 | 115076 | /* Full table scan */ |
| 114891 | 115077 | pNew->iSortIdx = b ? iSortIdx : 0; |
| 114892 | 115078 | /* TUNING: Cost of full table scan is (N*3.0). */ |
| 114893 | 115079 | pNew->rRun = rSize + 16; |
| 115080 | + ApplyCostMultiplier(pNew->rRun, pTab->costMult); |
| 114894 | 115081 | whereLoopOutputAdjust(pWC, pNew); |
| 114895 | 115082 | rc = whereLoopInsert(pBuilder, pNew); |
| 114896 | 115083 | pNew->nOut = rSize; |
| 114897 | 115084 | if( rc ) break; |
| 114898 | 115085 | }else{ |
| | @@ -114924,11 +115111,11 @@ |
| 114924 | 115111 | ** also add the cost of visiting table rows (N*3.0). */ |
| 114925 | 115112 | pNew->rRun = rSize + 1 + (15*pProbe->szIdxRow)/pTab->szTabRow; |
| 114926 | 115113 | if( m!=0 ){ |
| 114927 | 115114 | pNew->rRun = sqlite3LogEstAdd(pNew->rRun, rSize+16); |
| 114928 | 115115 | } |
| 114929 | | - |
| 115116 | + ApplyCostMultiplier(pNew->rRun, pTab->costMult); |
| 114930 | 115117 | whereLoopOutputAdjust(pWC, pNew); |
| 114931 | 115118 | rc = whereLoopInsert(pBuilder, pNew); |
| 114932 | 115119 | pNew->nOut = rSize; |
| 114933 | 115120 | if( rc ) break; |
| 114934 | 115121 | } |
| | @@ -116399,10 +116586,11 @@ |
| 116399 | 116586 | } |
| 116400 | 116587 | op = OP_OpenWrite; |
| 116401 | 116588 | pWInfo->aiCurOnePass[1] = iIndexCur; |
| 116402 | 116589 | }else if( iIdxCur && (wctrlFlags & WHERE_ONETABLE_ONLY)!=0 ){ |
| 116403 | 116590 | iIndexCur = iIdxCur; |
| 116591 | + if( wctrlFlags & WHERE_REOPEN_IDX ) op = OP_ReopenIdx; |
| 116404 | 116592 | }else{ |
| 116405 | 116593 | iIndexCur = pParse->nTab++; |
| 116406 | 116594 | } |
| 116407 | 116595 | pLevel->iIdxCur = iIndexCur; |
| 116408 | 116596 | assert( pIx->pSchema==pTab->pSchema ); |
| | @@ -120723,10 +120911,16 @@ |
| 120723 | 120911 | testcase( z[0]=='0' ); testcase( z[0]=='1' ); testcase( z[0]=='2' ); |
| 120724 | 120912 | testcase( z[0]=='3' ); testcase( z[0]=='4' ); testcase( z[0]=='5' ); |
| 120725 | 120913 | testcase( z[0]=='6' ); testcase( z[0]=='7' ); testcase( z[0]=='8' ); |
| 120726 | 120914 | testcase( z[0]=='9' ); |
| 120727 | 120915 | *tokenType = TK_INTEGER; |
| 120916 | +#ifndef SQLITE_OMIT_HEX_INTEGER |
| 120917 | + if( z[0]=='0' && (z[1]=='x' || z[1]=='X') && sqlite3Isxdigit(z[2]) ){ |
| 120918 | + for(i=3; sqlite3Isxdigit(z[i]); i++){} |
| 120919 | + return i; |
| 120920 | + } |
| 120921 | +#endif |
| 120728 | 120922 | for(i=0; sqlite3Isdigit(z[i]); i++){} |
| 120729 | 120923 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 120730 | 120924 | if( z[i]=='.' ){ |
| 120731 | 120925 | i++; |
| 120732 | 120926 | while( sqlite3Isdigit(z[i]) ){ i++; } |
| | @@ -123444,12 +123638,12 @@ |
| 123444 | 123638 | # error SQLITE_MAX_VDBE_OP must be at least 40 |
| 123445 | 123639 | #endif |
| 123446 | 123640 | #if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>1000 |
| 123447 | 123641 | # error SQLITE_MAX_FUNCTION_ARG must be between 0 and 1000 |
| 123448 | 123642 | #endif |
| 123449 | | -#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>62 |
| 123450 | | -# error SQLITE_MAX_ATTACHED must be between 0 and 62 |
| 123643 | +#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>125 |
| 123644 | +# error SQLITE_MAX_ATTACHED must be between 0 and 125 |
| 123451 | 123645 | #endif |
| 123452 | 123646 | #if SQLITE_MAX_LIKE_PATTERN_LENGTH<1 |
| 123453 | 123647 | # error SQLITE_MAX_LIKE_PATTERN_LENGTH must be at least 1 |
| 123454 | 123648 | #endif |
| 123455 | 123649 | #if SQLITE_MAX_COLUMN>32767 |
| | @@ -124752,11 +124946,11 @@ |
| 124752 | 124946 | const char *zParam, /* URI parameter sought */ |
| 124753 | 124947 | sqlite3_int64 bDflt /* return if parameter is missing */ |
| 124754 | 124948 | ){ |
| 124755 | 124949 | const char *z = sqlite3_uri_parameter(zFilename, zParam); |
| 124756 | 124950 | sqlite3_int64 v; |
| 124757 | | - if( z && sqlite3Atoi64(z, &v, sqlite3Strlen30(z), SQLITE_UTF8)==SQLITE_OK ){ |
| 124951 | + if( z && sqlite3DecOrHexToI64(z, &v)==SQLITE_OK ){ |
| 124758 | 124952 | bDflt = v; |
| 124759 | 124953 | } |
| 124760 | 124954 | return bDflt; |
| 124761 | 124955 | } |
| 124762 | 124956 | |
| | @@ -126283,11 +126477,11 @@ |
| 126283 | 126477 | |
| 126284 | 126478 | /* fts3_tokenize_vtab.c */ |
| 126285 | 126479 | SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *); |
| 126286 | 126480 | |
| 126287 | 126481 | /* fts3_unicode2.c (functions generated by parsing unicode text files) */ |
| 126288 | | -#ifdef SQLITE_ENABLE_FTS4_UNICODE61 |
| 126482 | +#ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 126289 | 126483 | SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int, int); |
| 126290 | 126484 | SQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int); |
| 126291 | 126485 | SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int); |
| 126292 | 126486 | #endif |
| 126293 | 126487 | |
| | @@ -129753,11 +129947,11 @@ |
| 129753 | 129947 | ** to by the argument to point to the "simple" tokenizer implementation. |
| 129754 | 129948 | ** And so on. |
| 129755 | 129949 | */ |
| 129756 | 129950 | SQLITE_PRIVATE void sqlite3Fts3SimpleTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
| 129757 | 129951 | SQLITE_PRIVATE void sqlite3Fts3PorterTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
| 129758 | | -#ifdef SQLITE_ENABLE_FTS4_UNICODE61 |
| 129952 | +#ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 129759 | 129953 | SQLITE_PRIVATE void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const**ppModule); |
| 129760 | 129954 | #endif |
| 129761 | 129955 | #ifdef SQLITE_ENABLE_ICU |
| 129762 | 129956 | SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule); |
| 129763 | 129957 | #endif |
| | @@ -129771,20 +129965,20 @@ |
| 129771 | 129965 | SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ |
| 129772 | 129966 | int rc = SQLITE_OK; |
| 129773 | 129967 | Fts3Hash *pHash = 0; |
| 129774 | 129968 | const sqlite3_tokenizer_module *pSimple = 0; |
| 129775 | 129969 | const sqlite3_tokenizer_module *pPorter = 0; |
| 129776 | | -#ifdef SQLITE_ENABLE_FTS4_UNICODE61 |
| 129970 | +#ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 129777 | 129971 | const sqlite3_tokenizer_module *pUnicode = 0; |
| 129778 | 129972 | #endif |
| 129779 | 129973 | |
| 129780 | 129974 | #ifdef SQLITE_ENABLE_ICU |
| 129781 | 129975 | const sqlite3_tokenizer_module *pIcu = 0; |
| 129782 | 129976 | sqlite3Fts3IcuTokenizerModule(&pIcu); |
| 129783 | 129977 | #endif |
| 129784 | 129978 | |
| 129785 | | -#ifdef SQLITE_ENABLE_FTS4_UNICODE61 |
| 129979 | +#ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 129786 | 129980 | sqlite3Fts3UnicodeTokenizer(&pUnicode); |
| 129787 | 129981 | #endif |
| 129788 | 129982 | |
| 129789 | 129983 | #ifdef SQLITE_TEST |
| 129790 | 129984 | rc = sqlite3Fts3InitTerm(db); |
| | @@ -129808,11 +130002,11 @@ |
| 129808 | 130002 | /* Load the built-in tokenizers into the hash table */ |
| 129809 | 130003 | if( rc==SQLITE_OK ){ |
| 129810 | 130004 | if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple) |
| 129811 | 130005 | || sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter) |
| 129812 | 130006 | |
| 129813 | | -#ifdef SQLITE_ENABLE_FTS4_UNICODE61 |
| 130007 | +#ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 129814 | 130008 | || sqlite3Fts3HashInsert(pHash, "unicode61", 10, (void *)pUnicode) |
| 129815 | 130009 | #endif |
| 129816 | 130010 | #ifdef SQLITE_ENABLE_ICU |
| 129817 | 130011 | || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu)) |
| 129818 | 130012 | #endif |
| | @@ -143068,11 +143262,11 @@ |
| 143068 | 143262 | ****************************************************************************** |
| 143069 | 143263 | ** |
| 143070 | 143264 | ** Implementation of the "unicode" full-text-search tokenizer. |
| 143071 | 143265 | */ |
| 143072 | 143266 | |
| 143073 | | -#ifdef SQLITE_ENABLE_FTS4_UNICODE61 |
| 143267 | +#ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 143074 | 143268 | |
| 143075 | 143269 | #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) |
| 143076 | 143270 | |
| 143077 | 143271 | /* #include <assert.h> */ |
| 143078 | 143272 | /* #include <stdlib.h> */ |
| | @@ -143284,11 +143478,11 @@ |
| 143284 | 143478 | memset(pNew, 0, sizeof(unicode_tokenizer)); |
| 143285 | 143479 | pNew->bRemoveDiacritic = 1; |
| 143286 | 143480 | |
| 143287 | 143481 | for(i=0; rc==SQLITE_OK && i<nArg; i++){ |
| 143288 | 143482 | const char *z = azArg[i]; |
| 143289 | | - int n = strlen(z); |
| 143483 | + int n = (int)strlen(z); |
| 143290 | 143484 | |
| 143291 | 143485 | if( n==19 && memcmp("remove_diacritics=1", z, 19)==0 ){ |
| 143292 | 143486 | pNew->bRemoveDiacritic = 1; |
| 143293 | 143487 | } |
| 143294 | 143488 | else if( n==19 && memcmp("remove_diacritics=0", z, 19)==0 ){ |
| | @@ -143416,15 +143610,15 @@ |
| 143416 | 143610 | }while( unicodeIsAlnum(p, iCode) |
| 143417 | 143611 | || sqlite3FtsUnicodeIsdiacritic(iCode) |
| 143418 | 143612 | ); |
| 143419 | 143613 | |
| 143420 | 143614 | /* Set the output variables and return. */ |
| 143421 | | - pCsr->iOff = (z - pCsr->aInput); |
| 143615 | + pCsr->iOff = (int)(z - pCsr->aInput); |
| 143422 | 143616 | *paToken = pCsr->zToken; |
| 143423 | | - *pnToken = zOut - pCsr->zToken; |
| 143424 | | - *piStart = (zStart - pCsr->aInput); |
| 143425 | | - *piEnd = (zEnd - pCsr->aInput); |
| 143617 | + *pnToken = (int)(zOut - pCsr->zToken); |
| 143618 | + *piStart = (int)(zStart - pCsr->aInput); |
| 143619 | + *piEnd = (int)(zEnd - pCsr->aInput); |
| 143426 | 143620 | *piPos = pCsr->iToken++; |
| 143427 | 143621 | return SQLITE_OK; |
| 143428 | 143622 | } |
| 143429 | 143623 | |
| 143430 | 143624 | /* |
| | @@ -143443,11 +143637,11 @@ |
| 143443 | 143637 | }; |
| 143444 | 143638 | *ppModule = &module; |
| 143445 | 143639 | } |
| 143446 | 143640 | |
| 143447 | 143641 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 143448 | | -#endif /* ifndef SQLITE_ENABLE_FTS4_UNICODE61 */ |
| 143642 | +#endif /* ifndef SQLITE_DISABLE_FTS3_UNICODE */ |
| 143449 | 143643 | |
| 143450 | 143644 | /************** End of fts3_unicode.c ****************************************/ |
| 143451 | 143645 | /************** Begin file fts3_unicode2.c ***********************************/ |
| 143452 | 143646 | /* |
| 143453 | 143647 | ** 2012 May 25 |
| | @@ -143464,11 +143658,11 @@ |
| 143464 | 143658 | |
| 143465 | 143659 | /* |
| 143466 | 143660 | ** DO NOT EDIT THIS MACHINE GENERATED FILE. |
| 143467 | 143661 | */ |
| 143468 | 143662 | |
| 143469 | | -#if defined(SQLITE_ENABLE_FTS4_UNICODE61) |
| 143663 | +#ifndef SQLITE_DISABLE_FTS3_UNICODE |
| 143470 | 143664 | #if defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) |
| 143471 | 143665 | |
| 143472 | 143666 | /* #include <assert.h> */ |
| 143473 | 143667 | |
| 143474 | 143668 | /* |
| | @@ -143811,11 +144005,11 @@ |
| 143811 | 144005 | } |
| 143812 | 144006 | |
| 143813 | 144007 | return ret; |
| 143814 | 144008 | } |
| 143815 | 144009 | #endif /* defined(SQLITE_ENABLE_FTS3) || defined(SQLITE_ENABLE_FTS4) */ |
| 143816 | | -#endif /* !defined(SQLITE_ENABLE_FTS4_UNICODE61) */ |
| 144010 | +#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */ |
| 143817 | 144011 | |
| 143818 | 144012 | /************** End of fts3_unicode2.c ***************************************/ |
| 143819 | 144013 | /************** Begin file rtree.c *******************************************/ |
| 143820 | 144014 | /* |
| 143821 | 144015 | ** 2001 September 15 |
| 143822 | 144016 | |