| | @@ -202,23 +202,31 @@ |
| 202 | 202 | # define _FILE_OFFSET_BITS 64 |
| 203 | 203 | # endif |
| 204 | 204 | # define _LARGEFILE_SOURCE 1 |
| 205 | 205 | #endif |
| 206 | 206 | |
| 207 | | -/* What version of GCC is being used. 0 means GCC is not being used */ |
| 208 | | -#ifdef __GNUC__ |
| 207 | +/* The GCC_VERSION, CLANG_VERSION, and MSVC_VERSION macros are used to |
| 208 | +** conditionally include optimizations for each of these compilers. A |
| 209 | +** value of 0 means that compiler is not being used. The |
| 210 | +** SQLITE_DISABLE_INTRINSIC macro means do not use any compiler-specific |
| 211 | +** optimizations, and hence set all compiler macros to 0 |
| 212 | +*/ |
| 213 | +#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC) |
| 209 | 214 | # define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__) |
| 210 | 215 | #else |
| 211 | 216 | # define GCC_VERSION 0 |
| 212 | 217 | #endif |
| 213 | | - |
| 214 | | -/* What version of CLANG is being used. 0 means CLANG is not being used */ |
| 215 | | -#if defined(__clang__) && !defined(_WIN32) |
| 218 | +#if defined(__clang__) && !defined(_WIN32) && !defined(SQLITE_DISABLE_INTRINSIC) |
| 216 | 219 | # define CLANG_VERSION \ |
| 217 | 220 | (__clang_major__*1000000+__clang_minor__*1000+__clang_patchlevel__) |
| 218 | 221 | #else |
| 219 | 222 | # define CLANG_VERSION 0 |
| 223 | +#endif |
| 224 | +#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC) |
| 225 | +# define MSVC_VERSION _MSC_VER |
| 226 | +#else |
| 227 | +# define MSVC_VERSION 0 |
| 220 | 228 | #endif |
| 221 | 229 | |
| 222 | 230 | /* Needed for various definitions... */ |
| 223 | 231 | #if defined(__GNUC__) && !defined(_GNU_SOURCE) |
| 224 | 232 | # define _GNU_SOURCE |
| | @@ -389,11 +397,11 @@ |
| 389 | 397 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 390 | 398 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 391 | 399 | */ |
| 392 | 400 | #define SQLITE_VERSION "3.17.0" |
| 393 | 401 | #define SQLITE_VERSION_NUMBER 3017000 |
| 394 | | -#define SQLITE_SOURCE_ID "2017-02-07 13:51:48 a136609c98ed3cc673c5a3c2578d49db3f2518d1" |
| 402 | +#define SQLITE_SOURCE_ID "2017-02-09 17:12:22 798fb9d70d2e5f95e64237b04d6692360133381a" |
| 395 | 403 | |
| 396 | 404 | /* |
| 397 | 405 | ** CAPI3REF: Run-Time Library Version Numbers |
| 398 | 406 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 399 | 407 | ** |
| | @@ -8916,11 +8924,11 @@ |
| 8916 | 8924 | ** The session object will be used to create changesets for tables in |
| 8917 | 8925 | ** database zDb, where zDb is either "main", or "temp", or the name of an |
| 8918 | 8926 | ** attached database. It is not an error if database zDb is not attached |
| 8919 | 8927 | ** to the database when the session object is created. |
| 8920 | 8928 | */ |
| 8921 | | -int sqlite3session_create( |
| 8929 | +SQLITE_API int sqlite3session_create( |
| 8922 | 8930 | sqlite3 *db, /* Database handle */ |
| 8923 | 8931 | const char *zDb, /* Name of db (e.g. "main") */ |
| 8924 | 8932 | sqlite3_session **ppSession /* OUT: New session object */ |
| 8925 | 8933 | ); |
| 8926 | 8934 | |
| | @@ -8934,11 +8942,11 @@ |
| 8934 | 8942 | ** |
| 8935 | 8943 | ** Session objects must be deleted before the database handle to which they |
| 8936 | 8944 | ** are attached is closed. Refer to the documentation for |
| 8937 | 8945 | ** [sqlite3session_create()] for details. |
| 8938 | 8946 | */ |
| 8939 | | -void sqlite3session_delete(sqlite3_session *pSession); |
| 8947 | +SQLITE_API void sqlite3session_delete(sqlite3_session *pSession); |
| 8940 | 8948 | |
| 8941 | 8949 | |
| 8942 | 8950 | /* |
| 8943 | 8951 | ** CAPI3REF: Enable Or Disable A Session Object |
| 8944 | 8952 | ** |
| | @@ -8954,11 +8962,11 @@ |
| 8954 | 8962 | ** no-op, and may be used to query the current state of the session. |
| 8955 | 8963 | ** |
| 8956 | 8964 | ** The return value indicates the final state of the session object: 0 if |
| 8957 | 8965 | ** the session is disabled, or 1 if it is enabled. |
| 8958 | 8966 | */ |
| 8959 | | -int sqlite3session_enable(sqlite3_session *pSession, int bEnable); |
| 8967 | +SQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable); |
| 8960 | 8968 | |
| 8961 | 8969 | /* |
| 8962 | 8970 | ** CAPI3REF: Set Or Clear the Indirect Change Flag |
| 8963 | 8971 | ** |
| 8964 | 8972 | ** Each change recorded by a session object is marked as either direct or |
| | @@ -8983,11 +8991,11 @@ |
| 8983 | 8991 | ** indirect flag for the specified session object. |
| 8984 | 8992 | ** |
| 8985 | 8993 | ** The return value indicates the final state of the indirect flag: 0 if |
| 8986 | 8994 | ** it is clear, or 1 if it is set. |
| 8987 | 8995 | */ |
| 8988 | | -int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect); |
| 8996 | +SQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect); |
| 8989 | 8997 | |
| 8990 | 8998 | /* |
| 8991 | 8999 | ** CAPI3REF: Attach A Table To A Session Object |
| 8992 | 9000 | ** |
| 8993 | 9001 | ** If argument zTab is not NULL, then it is the name of a table to attach |
| | @@ -9013,11 +9021,11 @@ |
| 9013 | 9021 | ** in one or more of their PRIMARY KEY columns. |
| 9014 | 9022 | ** |
| 9015 | 9023 | ** SQLITE_OK is returned if the call completes without error. Or, if an error |
| 9016 | 9024 | ** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned. |
| 9017 | 9025 | */ |
| 9018 | | -int sqlite3session_attach( |
| 9026 | +SQLITE_API int sqlite3session_attach( |
| 9019 | 9027 | sqlite3_session *pSession, /* Session object */ |
| 9020 | 9028 | const char *zTab /* Table name */ |
| 9021 | 9029 | ); |
| 9022 | 9030 | |
| 9023 | 9031 | /* |
| | @@ -9027,11 +9035,11 @@ |
| 9027 | 9035 | ** in tables that are not attached to the Session object, the filter is called |
| 9028 | 9036 | ** to determine whether changes to the table's rows should be tracked or not. |
| 9029 | 9037 | ** If xFilter returns 0, changes is not tracked. Note that once a table is |
| 9030 | 9038 | ** attached, xFilter will not be called again. |
| 9031 | 9039 | */ |
| 9032 | | -void sqlite3session_table_filter( |
| 9040 | +SQLITE_API void sqlite3session_table_filter( |
| 9033 | 9041 | sqlite3_session *pSession, /* Session object */ |
| 9034 | 9042 | int(*xFilter)( |
| 9035 | 9043 | void *pCtx, /* Copy of third arg to _filter_table() */ |
| 9036 | 9044 | const char *zTab /* Table name */ |
| 9037 | 9045 | ), |
| | @@ -9140,11 +9148,11 @@ |
| 9140 | 9148 | ** changeset, even though the delete took place while the session was disabled. |
| 9141 | 9149 | ** Or, if one field of a row is updated while a session is disabled, and |
| 9142 | 9150 | ** another field of the same row is updated while the session is enabled, the |
| 9143 | 9151 | ** resulting changeset will contain an UPDATE change that updates both fields. |
| 9144 | 9152 | */ |
| 9145 | | -int sqlite3session_changeset( |
| 9153 | +SQLITE_API int sqlite3session_changeset( |
| 9146 | 9154 | sqlite3_session *pSession, /* Session object */ |
| 9147 | 9155 | int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */ |
| 9148 | 9156 | void **ppChangeset /* OUT: Buffer containing changeset */ |
| 9149 | 9157 | ); |
| 9150 | 9158 | |
| | @@ -9202,11 +9210,11 @@ |
| 9202 | 9210 | ** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg |
| 9203 | 9211 | ** may be set to point to a buffer containing an English language error |
| 9204 | 9212 | ** message. It is the responsibility of the caller to free this buffer using |
| 9205 | 9213 | ** sqlite3_free(). |
| 9206 | 9214 | */ |
| 9207 | | -int sqlite3session_diff( |
| 9215 | +SQLITE_API int sqlite3session_diff( |
| 9208 | 9216 | sqlite3_session *pSession, |
| 9209 | 9217 | const char *zFromDb, |
| 9210 | 9218 | const char *zTbl, |
| 9211 | 9219 | char **pzErrMsg |
| 9212 | 9220 | ); |
| | @@ -9238,11 +9246,11 @@ |
| 9238 | 9246 | ** Changes within a patchset are ordered in the same way as for changesets |
| 9239 | 9247 | ** generated by the sqlite3session_changeset() function (i.e. all changes for |
| 9240 | 9248 | ** a single table are grouped together, tables appear in the order in which |
| 9241 | 9249 | ** they were attached to the session object). |
| 9242 | 9250 | */ |
| 9243 | | -int sqlite3session_patchset( |
| 9251 | +SQLITE_API int sqlite3session_patchset( |
| 9244 | 9252 | sqlite3_session *pSession, /* Session object */ |
| 9245 | 9253 | int *pnPatchset, /* OUT: Size of buffer at *ppChangeset */ |
| 9246 | 9254 | void **ppPatchset /* OUT: Buffer containing changeset */ |
| 9247 | 9255 | ); |
| 9248 | 9256 | |
| | @@ -9259,11 +9267,11 @@ |
| 9259 | 9267 | ** an attached table is modified and then later on the original values |
| 9260 | 9268 | ** are restored. However, if this function returns non-zero, then it is |
| 9261 | 9269 | ** guaranteed that a call to sqlite3session_changeset() will return a |
| 9262 | 9270 | ** changeset containing zero changes. |
| 9263 | 9271 | */ |
| 9264 | | -int sqlite3session_isempty(sqlite3_session *pSession); |
| 9272 | +SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession); |
| 9265 | 9273 | |
| 9266 | 9274 | /* |
| 9267 | 9275 | ** CAPI3REF: Create An Iterator To Traverse A Changeset |
| 9268 | 9276 | ** |
| 9269 | 9277 | ** Create an iterator used to iterate through the contents of a changeset. |
| | @@ -9294,11 +9302,11 @@ |
| 9294 | 9302 | ** this function, all changes that relate to a single table are visited |
| 9295 | 9303 | ** consecutively. There is no chance that the iterator will visit a change |
| 9296 | 9304 | ** the applies to table X, then one for table Y, and then later on visit |
| 9297 | 9305 | ** another change for table X. |
| 9298 | 9306 | */ |
| 9299 | | -int sqlite3changeset_start( |
| 9307 | +SQLITE_API int sqlite3changeset_start( |
| 9300 | 9308 | sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */ |
| 9301 | 9309 | int nChangeset, /* Size of changeset blob in bytes */ |
| 9302 | 9310 | void *pChangeset /* Pointer to blob containing changeset */ |
| 9303 | 9311 | ); |
| 9304 | 9312 | |
| | @@ -9323,11 +9331,11 @@ |
| 9323 | 9331 | ** |
| 9324 | 9332 | ** If an error occurs, an SQLite error code is returned. Possible error |
| 9325 | 9333 | ** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or |
| 9326 | 9334 | ** SQLITE_NOMEM. |
| 9327 | 9335 | */ |
| 9328 | | -int sqlite3changeset_next(sqlite3_changeset_iter *pIter); |
| 9336 | +SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter); |
| 9329 | 9337 | |
| 9330 | 9338 | /* |
| 9331 | 9339 | ** CAPI3REF: Obtain The Current Operation From A Changeset Iterator |
| 9332 | 9340 | ** |
| 9333 | 9341 | ** The pIter argument passed to this function may either be an iterator |
| | @@ -9351,11 +9359,11 @@ |
| 9351 | 9359 | ** |
| 9352 | 9360 | ** If no error occurs, SQLITE_OK is returned. If an error does occur, an |
| 9353 | 9361 | ** SQLite error code is returned. The values of the output variables may not |
| 9354 | 9362 | ** be trusted in this case. |
| 9355 | 9363 | */ |
| 9356 | | -int sqlite3changeset_op( |
| 9364 | +SQLITE_API int sqlite3changeset_op( |
| 9357 | 9365 | sqlite3_changeset_iter *pIter, /* Iterator object */ |
| 9358 | 9366 | const char **pzTab, /* OUT: Pointer to table name */ |
| 9359 | 9367 | int *pnCol, /* OUT: Number of columns in table */ |
| 9360 | 9368 | int *pOp, /* OUT: SQLITE_INSERT, DELETE or UPDATE */ |
| 9361 | 9369 | int *pbIndirect /* OUT: True for an 'indirect' change */ |
| | @@ -9384,11 +9392,11 @@ |
| 9384 | 9392 | ** If this function is called when the iterator does not point to a valid |
| 9385 | 9393 | ** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise, |
| 9386 | 9394 | ** SQLITE_OK is returned and the output variables populated as described |
| 9387 | 9395 | ** above. |
| 9388 | 9396 | */ |
| 9389 | | -int sqlite3changeset_pk( |
| 9397 | +SQLITE_API int sqlite3changeset_pk( |
| 9390 | 9398 | sqlite3_changeset_iter *pIter, /* Iterator object */ |
| 9391 | 9399 | unsigned char **pabPK, /* OUT: Array of boolean - true for PK cols */ |
| 9392 | 9400 | int *pnCol /* OUT: Number of entries in output array */ |
| 9393 | 9401 | ); |
| 9394 | 9402 | |
| | @@ -9414,11 +9422,11 @@ |
| 9414 | 9422 | ** is similar to the "old.*" columns available to update or delete triggers. |
| 9415 | 9423 | ** |
| 9416 | 9424 | ** If some other error occurs (e.g. an OOM condition), an SQLite error code |
| 9417 | 9425 | ** is returned and *ppValue is set to NULL. |
| 9418 | 9426 | */ |
| 9419 | | -int sqlite3changeset_old( |
| 9427 | +SQLITE_API int sqlite3changeset_old( |
| 9420 | 9428 | sqlite3_changeset_iter *pIter, /* Changeset iterator */ |
| 9421 | 9429 | int iVal, /* Column number */ |
| 9422 | 9430 | sqlite3_value **ppValue /* OUT: Old value (or NULL pointer) */ |
| 9423 | 9431 | ); |
| 9424 | 9432 | |
| | @@ -9447,11 +9455,11 @@ |
| 9447 | 9455 | ** triggers. |
| 9448 | 9456 | ** |
| 9449 | 9457 | ** If some other error occurs (e.g. an OOM condition), an SQLite error code |
| 9450 | 9458 | ** is returned and *ppValue is set to NULL. |
| 9451 | 9459 | */ |
| 9452 | | -int sqlite3changeset_new( |
| 9460 | +SQLITE_API int sqlite3changeset_new( |
| 9453 | 9461 | sqlite3_changeset_iter *pIter, /* Changeset iterator */ |
| 9454 | 9462 | int iVal, /* Column number */ |
| 9455 | 9463 | sqlite3_value **ppValue /* OUT: New value (or NULL pointer) */ |
| 9456 | 9464 | ); |
| 9457 | 9465 | |
| | @@ -9474,11 +9482,11 @@ |
| 9474 | 9482 | ** and returns SQLITE_OK. |
| 9475 | 9483 | ** |
| 9476 | 9484 | ** If some other error occurs (e.g. an OOM condition), an SQLite error code |
| 9477 | 9485 | ** is returned and *ppValue is set to NULL. |
| 9478 | 9486 | */ |
| 9479 | | -int sqlite3changeset_conflict( |
| 9487 | +SQLITE_API int sqlite3changeset_conflict( |
| 9480 | 9488 | sqlite3_changeset_iter *pIter, /* Changeset iterator */ |
| 9481 | 9489 | int iVal, /* Column number */ |
| 9482 | 9490 | sqlite3_value **ppValue /* OUT: Value from conflicting row */ |
| 9483 | 9491 | ); |
| 9484 | 9492 | |
| | @@ -9490,11 +9498,11 @@ |
| 9490 | 9498 | ** it sets the output variable to the total number of known foreign key |
| 9491 | 9499 | ** violations in the destination database and returns SQLITE_OK. |
| 9492 | 9500 | ** |
| 9493 | 9501 | ** In all other cases this function returns SQLITE_MISUSE. |
| 9494 | 9502 | */ |
| 9495 | | -int sqlite3changeset_fk_conflicts( |
| 9503 | +SQLITE_API int sqlite3changeset_fk_conflicts( |
| 9496 | 9504 | sqlite3_changeset_iter *pIter, /* Changeset iterator */ |
| 9497 | 9505 | int *pnOut /* OUT: Number of FK violations */ |
| 9498 | 9506 | ); |
| 9499 | 9507 | |
| 9500 | 9508 | |
| | @@ -9523,11 +9531,11 @@ |
| 9523 | 9531 | ** rc = sqlite3changeset_finalize(); |
| 9524 | 9532 | ** if( rc!=SQLITE_OK ){ |
| 9525 | 9533 | ** // An error has occurred |
| 9526 | 9534 | ** } |
| 9527 | 9535 | */ |
| 9528 | | -int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter); |
| 9536 | +SQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter); |
| 9529 | 9537 | |
| 9530 | 9538 | /* |
| 9531 | 9539 | ** CAPI3REF: Invert A Changeset |
| 9532 | 9540 | ** |
| 9533 | 9541 | ** This function is used to "invert" a changeset object. Applying an inverted |
| | @@ -9553,11 +9561,11 @@ |
| 9553 | 9561 | ** call to this function. |
| 9554 | 9562 | ** |
| 9555 | 9563 | ** WARNING/TODO: This function currently assumes that the input is a valid |
| 9556 | 9564 | ** changeset. If it is not, the results are undefined. |
| 9557 | 9565 | */ |
| 9558 | | -int sqlite3changeset_invert( |
| 9566 | +SQLITE_API int sqlite3changeset_invert( |
| 9559 | 9567 | int nIn, const void *pIn, /* Input changeset */ |
| 9560 | 9568 | int *pnOut, void **ppOut /* OUT: Inverse of input */ |
| 9561 | 9569 | ); |
| 9562 | 9570 | |
| 9563 | 9571 | /* |
| | @@ -9582,11 +9590,11 @@ |
| 9582 | 9590 | ** *pnOut = 0; |
| 9583 | 9591 | ** } |
| 9584 | 9592 | ** |
| 9585 | 9593 | ** Refer to the sqlite3_changegroup documentation below for details. |
| 9586 | 9594 | */ |
| 9587 | | -int sqlite3changeset_concat( |
| 9595 | +SQLITE_API int sqlite3changeset_concat( |
| 9588 | 9596 | int nA, /* Number of bytes in buffer pA */ |
| 9589 | 9597 | void *pA, /* Pointer to buffer containing changeset A */ |
| 9590 | 9598 | int nB, /* Number of bytes in buffer pB */ |
| 9591 | 9599 | void *pB, /* Pointer to buffer containing changeset B */ |
| 9592 | 9600 | int *pnOut, /* OUT: Number of bytes in output changeset */ |
| | @@ -9888,11 +9896,11 @@ |
| 9888 | 9896 | ** If any other error (aside from a constraint failure when attempting to |
| 9889 | 9897 | ** write to the target database) occurs, then the savepoint transaction is |
| 9890 | 9898 | ** rolled back, restoring the target database to its original state, and an |
| 9891 | 9899 | ** SQLite error code returned. |
| 9892 | 9900 | */ |
| 9893 | | -int sqlite3changeset_apply( |
| 9901 | +SQLITE_API int sqlite3changeset_apply( |
| 9894 | 9902 | sqlite3 *db, /* Apply change to "main" db of this handle */ |
| 9895 | 9903 | int nChangeset, /* Size of changeset in bytes */ |
| 9896 | 9904 | void *pChangeset, /* Changeset blob */ |
| 9897 | 9905 | int(*xFilter)( |
| 9898 | 9906 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| | @@ -10089,11 +10097,11 @@ |
| 10089 | 10097 | ** |
| 10090 | 10098 | ** The sessions module never invokes an xOutput callback with the third |
| 10091 | 10099 | ** parameter set to a value less than or equal to zero. Other than this, |
| 10092 | 10100 | ** no guarantees are made as to the size of the chunks of data returned. |
| 10093 | 10101 | */ |
| 10094 | | -int sqlite3changeset_apply_strm( |
| 10102 | +SQLITE_API int sqlite3changeset_apply_strm( |
| 10095 | 10103 | sqlite3 *db, /* Apply change to "main" db of this handle */ |
| 10096 | 10104 | int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ |
| 10097 | 10105 | void *pIn, /* First arg for xInput */ |
| 10098 | 10106 | int(*xFilter)( |
| 10099 | 10107 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| | @@ -10104,35 +10112,35 @@ |
| 10104 | 10112 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 10105 | 10113 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 10106 | 10114 | ), |
| 10107 | 10115 | void *pCtx /* First argument passed to xConflict */ |
| 10108 | 10116 | ); |
| 10109 | | -int sqlite3changeset_concat_strm( |
| 10117 | +SQLITE_API int sqlite3changeset_concat_strm( |
| 10110 | 10118 | int (*xInputA)(void *pIn, void *pData, int *pnData), |
| 10111 | 10119 | void *pInA, |
| 10112 | 10120 | int (*xInputB)(void *pIn, void *pData, int *pnData), |
| 10113 | 10121 | void *pInB, |
| 10114 | 10122 | int (*xOutput)(void *pOut, const void *pData, int nData), |
| 10115 | 10123 | void *pOut |
| 10116 | 10124 | ); |
| 10117 | | -int sqlite3changeset_invert_strm( |
| 10125 | +SQLITE_API int sqlite3changeset_invert_strm( |
| 10118 | 10126 | int (*xInput)(void *pIn, void *pData, int *pnData), |
| 10119 | 10127 | void *pIn, |
| 10120 | 10128 | int (*xOutput)(void *pOut, const void *pData, int nData), |
| 10121 | 10129 | void *pOut |
| 10122 | 10130 | ); |
| 10123 | | -int sqlite3changeset_start_strm( |
| 10131 | +SQLITE_API int sqlite3changeset_start_strm( |
| 10124 | 10132 | sqlite3_changeset_iter **pp, |
| 10125 | 10133 | int (*xInput)(void *pIn, void *pData, int *pnData), |
| 10126 | 10134 | void *pIn |
| 10127 | 10135 | ); |
| 10128 | | -int sqlite3session_changeset_strm( |
| 10136 | +SQLITE_API int sqlite3session_changeset_strm( |
| 10129 | 10137 | sqlite3_session *pSession, |
| 10130 | 10138 | int (*xOutput)(void *pOut, const void *pData, int nData), |
| 10131 | 10139 | void *pOut |
| 10132 | 10140 | ); |
| 10133 | | -int sqlite3session_patchset_strm( |
| 10141 | +SQLITE_API int sqlite3session_patchset_strm( |
| 10134 | 10142 | sqlite3_session *pSession, |
| 10135 | 10143 | int (*xOutput)(void *pOut, const void *pData, int nData), |
| 10136 | 10144 | void *pOut |
| 10137 | 10145 | ); |
| 10138 | 10146 | int sqlite3changegroup_add_strm(sqlite3_changegroup*, |
| | @@ -11035,10 +11043,11 @@ |
| 11035 | 11043 | # if defined(_MSC_VER) && _MSC_VER>=1400 |
| 11036 | 11044 | # if !defined(_WIN32_WCE) |
| 11037 | 11045 | # include <intrin.h> |
| 11038 | 11046 | # pragma intrinsic(_byteswap_ushort) |
| 11039 | 11047 | # pragma intrinsic(_byteswap_ulong) |
| 11048 | +# pragma intrinsic(_byteswap_uint64) |
| 11040 | 11049 | # pragma intrinsic(_ReadWriteBarrier) |
| 11041 | 11050 | # else |
| 11042 | 11051 | # include <cmnintrin.h> |
| 11043 | 11052 | # endif |
| 11044 | 11053 | # endif |
| | @@ -11849,36 +11858,39 @@ |
| 11849 | 11858 | ** Macros to determine whether the machine is big or little endian, |
| 11850 | 11859 | ** and whether or not that determination is run-time or compile-time. |
| 11851 | 11860 | ** |
| 11852 | 11861 | ** For best performance, an attempt is made to guess at the byte-order |
| 11853 | 11862 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 11854 | | -** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined |
| 11863 | +** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined |
| 11855 | 11864 | ** at run-time. |
| 11856 | 11865 | */ |
| 11857 | | -#if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 11866 | +#ifndef SQLITE_BYTEORDER |
| 11867 | +# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 11858 | 11868 | defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 11859 | 11869 | defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 11860 | | - defined(__arm__)) && !defined(SQLITE_RUNTIME_BYTEORDER) |
| 11861 | | -# define SQLITE_BYTEORDER 1234 |
| 11862 | | -# define SQLITE_BIGENDIAN 0 |
| 11863 | | -# define SQLITE_LITTLEENDIAN 1 |
| 11864 | | -# define SQLITE_UTF16NATIVE SQLITE_UTF16LE |
| 11870 | + defined(__arm__) |
| 11871 | +# define SQLITE_BYTEORDER 1234 |
| 11872 | +# elif defined(sparc) || defined(__ppc__) |
| 11873 | +# define SQLITE_BYTEORDER 4321 |
| 11874 | +# else |
| 11875 | +# define SQLITE_BYTEORDER 0 |
| 11876 | +# endif |
| 11865 | 11877 | #endif |
| 11866 | | -#if (defined(sparc) || defined(__ppc__)) \ |
| 11867 | | - && !defined(SQLITE_RUNTIME_BYTEORDER) |
| 11868 | | -# define SQLITE_BYTEORDER 4321 |
| 11878 | +#if SQLITE_BYTEORDER==4321 |
| 11869 | 11879 | # define SQLITE_BIGENDIAN 1 |
| 11870 | 11880 | # define SQLITE_LITTLEENDIAN 0 |
| 11871 | 11881 | # define SQLITE_UTF16NATIVE SQLITE_UTF16BE |
| 11872 | | -#endif |
| 11873 | | -#if !defined(SQLITE_BYTEORDER) |
| 11882 | +#elif SQLITE_BYTEORDER==1234 |
| 11883 | +# define SQLITE_BIGENDIAN 0 |
| 11884 | +# define SQLITE_LITTLEENDIAN 1 |
| 11885 | +# define SQLITE_UTF16NATIVE SQLITE_UTF16LE |
| 11886 | +#else |
| 11874 | 11887 | # ifdef SQLITE_AMALGAMATION |
| 11875 | 11888 | const int sqlite3one = 1; |
| 11876 | 11889 | # else |
| 11877 | 11890 | extern const int sqlite3one; |
| 11878 | 11891 | # endif |
| 11879 | | -# define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ |
| 11880 | 11892 | # define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) |
| 11881 | 11893 | # define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) |
| 11882 | 11894 | # define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) |
| 11883 | 11895 | #endif |
| 11884 | 11896 | |
| | @@ -20693,20 +20705,22 @@ |
| 20693 | 20705 | ** cases of nByte<=0 will be intercepted and dealt with by higher level |
| 20694 | 20706 | ** routines. |
| 20695 | 20707 | */ |
| 20696 | 20708 | static void *sqlite3MemMalloc(int nByte){ |
| 20697 | 20709 | #ifdef SQLITE_MALLOCSIZE |
| 20698 | | - void *p = SQLITE_MALLOC( nByte ); |
| 20710 | + void *p; |
| 20711 | + testcase( ROUND8(nByte)==nByte ); |
| 20712 | + p = SQLITE_MALLOC( nByte ); |
| 20699 | 20713 | if( p==0 ){ |
| 20700 | 20714 | testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 20701 | 20715 | sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte); |
| 20702 | 20716 | } |
| 20703 | 20717 | return p; |
| 20704 | 20718 | #else |
| 20705 | 20719 | sqlite3_int64 *p; |
| 20706 | 20720 | assert( nByte>0 ); |
| 20707 | | - nByte = ROUND8(nByte); |
| 20721 | + testcase( ROUND8(nByte)!=nByte ); |
| 20708 | 20722 | p = SQLITE_MALLOC( nByte+8 ); |
| 20709 | 20723 | if( p ){ |
| 20710 | 20724 | p[0] = nByte; |
| 20711 | 20725 | p++; |
| 20712 | 20726 | }else{ |
| | @@ -23824,12 +23838,11 @@ |
| 23824 | 23838 | SQLITE_PRIVATE void sqlite3MemoryBarrier(void){ |
| 23825 | 23839 | #if defined(SQLITE_MEMORY_BARRIER) |
| 23826 | 23840 | SQLITE_MEMORY_BARRIER; |
| 23827 | 23841 | #elif defined(__GNUC__) |
| 23828 | 23842 | __sync_synchronize(); |
| 23829 | | -#elif !defined(SQLITE_DISABLE_INTRINSIC) && \ |
| 23830 | | - defined(_MSC_VER) && _MSC_VER>=1300 |
| 23843 | +#elif MSCV_VERSION>=1300 |
| 23831 | 23844 | _ReadWriteBarrier(); |
| 23832 | 23845 | #elif defined(MemoryBarrier) |
| 23833 | 23846 | MemoryBarrier(); |
| 23834 | 23847 | #endif |
| 23835 | 23848 | } |
| | @@ -24359,28 +24372,36 @@ |
| 24359 | 24372 | ** Do a memory allocation with statistics and alarms. Assume the |
| 24360 | 24373 | ** lock is already held. |
| 24361 | 24374 | */ |
| 24362 | 24375 | static void mallocWithAlarm(int n, void **pp){ |
| 24363 | 24376 | void *p; |
| 24364 | | - int nFull = 0; |
| 24377 | + int nFull; |
| 24365 | 24378 | assert( sqlite3_mutex_held(mem0.mutex) ); |
| 24379 | + assert( n>0 ); |
| 24380 | + |
| 24381 | + /* In Firefox (circa 2017-02-08), xRoundup() is remapped to an internal |
| 24382 | + ** implementation of malloc_good_size(), which must be called in debug |
| 24383 | + ** mode and specifically when the DMD "Dark Matter Detector" is enabled |
| 24384 | + ** or else a crash results. Hence, do not attempt to optimize out the |
| 24385 | + ** following xRoundup() call. */ |
| 24386 | + nFull = sqlite3GlobalConfig.m.xRoundup(n); |
| 24387 | + |
| 24366 | 24388 | sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n); |
| 24367 | 24389 | if( mem0.alarmThreshold>0 ){ |
| 24368 | 24390 | sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED); |
| 24369 | | - nFull = sqlite3GlobalConfig.m.xRoundup(n); |
| 24370 | 24391 | if( nUsed >= mem0.alarmThreshold - nFull ){ |
| 24371 | 24392 | mem0.nearlyFull = 1; |
| 24372 | 24393 | sqlite3MallocAlarm(nFull); |
| 24373 | 24394 | }else{ |
| 24374 | 24395 | mem0.nearlyFull = 0; |
| 24375 | 24396 | } |
| 24376 | 24397 | } |
| 24377 | | - p = sqlite3GlobalConfig.m.xMalloc(n); |
| 24398 | + p = sqlite3GlobalConfig.m.xMalloc(nFull); |
| 24378 | 24399 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT |
| 24379 | 24400 | if( p==0 && mem0.alarmThreshold>0 ){ |
| 24380 | 24401 | sqlite3MallocAlarm(nFull); |
| 24381 | | - p = sqlite3GlobalConfig.m.xMalloc(n); |
| 24402 | + p = sqlite3GlobalConfig.m.xMalloc(nFull); |
| 24382 | 24403 | } |
| 24383 | 24404 | #endif |
| 24384 | 24405 | if( p ){ |
| 24385 | 24406 | nFull = sqlite3MallocSize(p); |
| 24386 | 24407 | sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull); |
| | @@ -28674,17 +28695,15 @@ |
| 28674 | 28695 | SQLITE_PRIVATE u32 sqlite3Get4byte(const u8 *p){ |
| 28675 | 28696 | #if SQLITE_BYTEORDER==4321 |
| 28676 | 28697 | u32 x; |
| 28677 | 28698 | memcpy(&x,p,4); |
| 28678 | 28699 | return x; |
| 28679 | | -#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 28680 | | - && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) |
| 28700 | +#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) |
| 28681 | 28701 | u32 x; |
| 28682 | 28702 | memcpy(&x,p,4); |
| 28683 | 28703 | return __builtin_bswap32(x); |
| 28684 | | -#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 28685 | | - && defined(_MSC_VER) && _MSC_VER>=1300 |
| 28704 | +#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 28686 | 28705 | u32 x; |
| 28687 | 28706 | memcpy(&x,p,4); |
| 28688 | 28707 | return _byteswap_ulong(x); |
| 28689 | 28708 | #else |
| 28690 | 28709 | testcase( p[0]&0x80 ); |
| | @@ -28692,16 +28711,14 @@ |
| 28692 | 28711 | #endif |
| 28693 | 28712 | } |
| 28694 | 28713 | SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){ |
| 28695 | 28714 | #if SQLITE_BYTEORDER==4321 |
| 28696 | 28715 | memcpy(p,&v,4); |
| 28697 | | -#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 28698 | | - && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) |
| 28716 | +#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) |
| 28699 | 28717 | u32 x = __builtin_bswap32(v); |
| 28700 | 28718 | memcpy(p,&x,4); |
| 28701 | | -#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 28702 | | - && defined(_MSC_VER) && _MSC_VER>=1300 |
| 28719 | +#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 28703 | 28720 | u32 x = _byteswap_ulong(v); |
| 28704 | 28721 | memcpy(p,&x,4); |
| 28705 | 28722 | #else |
| 28706 | 28723 | p[0] = (u8)(v>>24); |
| 28707 | 28724 | p[1] = (u8)(v>>16); |
| | @@ -28813,12 +28830,11 @@ |
| 28813 | 28830 | ** the other 64-bit signed integer at *pA and store the result in *pA. |
| 28814 | 28831 | ** Return 0 on success. Or if the operation would have resulted in an |
| 28815 | 28832 | ** overflow, leave *pA unchanged and return 1. |
| 28816 | 28833 | */ |
| 28817 | 28834 | SQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){ |
| 28818 | | -#if !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 28819 | | - && (GCC_VERSION>=5004000 || CLANG_VERSION>=4000000) |
| 28835 | +#if GCC_VERSION>=5004000 || CLANG_VERSION>=4000000 |
| 28820 | 28836 | return __builtin_add_overflow(*pA, iB, pA); |
| 28821 | 28837 | #else |
| 28822 | 28838 | i64 iA = *pA; |
| 28823 | 28839 | testcase( iA==0 ); testcase( iA==1 ); |
| 28824 | 28840 | testcase( iB==-1 ); testcase( iB==0 ); |
| | @@ -28834,12 +28850,11 @@ |
| 28834 | 28850 | *pA += iB; |
| 28835 | 28851 | return 0; |
| 28836 | 28852 | #endif |
| 28837 | 28853 | } |
| 28838 | 28854 | SQLITE_PRIVATE int sqlite3SubInt64(i64 *pA, i64 iB){ |
| 28839 | | -#if !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 28840 | | - && (GCC_VERSION>=5004000 || CLANG_VERSION>=4000000) |
| 28855 | +#if GCC_VERSION>=5004000 || CLANG_VERSION>=4000000 |
| 28841 | 28856 | return __builtin_sub_overflow(*pA, iB, pA); |
| 28842 | 28857 | #else |
| 28843 | 28858 | testcase( iB==SMALLEST_INT64+1 ); |
| 28844 | 28859 | if( iB==SMALLEST_INT64 ){ |
| 28845 | 28860 | testcase( (*pA)==(-1) ); testcase( (*pA)==0 ); |
| | @@ -28850,12 +28865,11 @@ |
| 28850 | 28865 | return sqlite3AddInt64(pA, -iB); |
| 28851 | 28866 | } |
| 28852 | 28867 | #endif |
| 28853 | 28868 | } |
| 28854 | 28869 | SQLITE_PRIVATE int sqlite3MulInt64(i64 *pA, i64 iB){ |
| 28855 | | -#if !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 28856 | | - && (GCC_VERSION>=5004000 || CLANG_VERSION>=4000000) |
| 28870 | +#if GCC_VERSION>=5004000 || CLANG_VERSION>=4000000 |
| 28857 | 28871 | return __builtin_mul_overflow(*pA, iB, pA); |
| 28858 | 28872 | #else |
| 28859 | 28873 | i64 iA = *pA; |
| 28860 | 28874 | if( iB>0 ){ |
| 28861 | 28875 | if( iA>LARGEST_INT64/iB ) return 1; |
| | @@ -58540,15 +58554,13 @@ |
| 58540 | 58554 | ** two-byte aligned address. get2bytea() is only used for accessing the |
| 58541 | 58555 | ** cell addresses in a btree header. |
| 58542 | 58556 | */ |
| 58543 | 58557 | #if SQLITE_BYTEORDER==4321 |
| 58544 | 58558 | # define get2byteAligned(x) (*(u16*)(x)) |
| 58545 | | -#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 58546 | | - && GCC_VERSION>=4008000 |
| 58559 | +#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4008000 |
| 58547 | 58560 | # define get2byteAligned(x) __builtin_bswap16(*(u16*)(x)) |
| 58548 | | -#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \ |
| 58549 | | - && defined(_MSC_VER) && _MSC_VER>=1300 |
| 58561 | +#elif SQLITE_BYTEORDER==1234 && MSCV_VERSION>=1300 |
| 58550 | 58562 | # define get2byteAligned(x) _byteswap_ushort(*(u16*)(x)) |
| 58551 | 58563 | #else |
| 58552 | 58564 | # define get2byteAligned(x) ((x)[0]<<8 | (x)[1]) |
| 58553 | 58565 | #endif |
| 58554 | 58566 | |
| | @@ -144588,10 +144600,11 @@ |
| 144588 | 144600 | |
| 144589 | 144601 | /* Precompiled statements used by the implementation. Each of these |
| 144590 | 144602 | ** statements is run and reset within a single virtual table API call. |
| 144591 | 144603 | */ |
| 144592 | 144604 | sqlite3_stmt *aStmt[40]; |
| 144605 | + sqlite3_stmt *pSeekStmt; /* Cache for fts3CursorSeekStmt() */ |
| 144593 | 144606 | |
| 144594 | 144607 | char *zReadExprlist; |
| 144595 | 144608 | char *zWriteExprlist; |
| 144596 | 144609 | |
| 144597 | 144610 | int nNodeSize; /* Soft limit for node size */ |
| | @@ -144657,10 +144670,11 @@ |
| 144657 | 144670 | struct Fts3Cursor { |
| 144658 | 144671 | sqlite3_vtab_cursor base; /* Base class used by SQLite core */ |
| 144659 | 144672 | i16 eSearch; /* Search strategy (see below) */ |
| 144660 | 144673 | u8 isEof; /* True if at End Of Results */ |
| 144661 | 144674 | u8 isRequireSeek; /* True if must seek pStmt to %_content row */ |
| 144675 | + u8 bSeekStmt; /* True if pStmt is a seek */ |
| 144662 | 144676 | sqlite3_stmt *pStmt; /* Prepared statement in use by the cursor */ |
| 144663 | 144677 | Fts3Expr *pExpr; /* Parsed MATCH query string */ |
| 144664 | 144678 | int iLangid; /* Language being queried for */ |
| 144665 | 144679 | int nPhrase; /* Number of matchable phrases in query */ |
| 144666 | 144680 | Fts3DeferredToken *pDeferred; /* Deferred search tokens, if any */ |
| | @@ -145179,10 +145193,11 @@ |
| 145179 | 145193 | |
| 145180 | 145194 | assert( p->nPendingData==0 ); |
| 145181 | 145195 | assert( p->pSegments==0 ); |
| 145182 | 145196 | |
| 145183 | 145197 | /* Free any prepared statements held */ |
| 145198 | + sqlite3_finalize(p->pSeekStmt); |
| 145184 | 145199 | for(i=0; i<SizeofArray(p->aStmt); i++){ |
| 145185 | 145200 | sqlite3_finalize(p->aStmt[i]); |
| 145186 | 145201 | } |
| 145187 | 145202 | sqlite3_free(p->zSegmentsTbl); |
| 145188 | 145203 | sqlite3_free(p->zReadExprlist); |
| | @@ -146366,19 +146381,39 @@ |
| 146366 | 146381 | return SQLITE_NOMEM; |
| 146367 | 146382 | } |
| 146368 | 146383 | memset(pCsr, 0, sizeof(Fts3Cursor)); |
| 146369 | 146384 | return SQLITE_OK; |
| 146370 | 146385 | } |
| 146386 | + |
| 146387 | +/* |
| 146388 | +** Finalize the statement handle at pCsr->pStmt. |
| 146389 | +** |
| 146390 | +** Or, if that statement handle is one created by fts3CursorSeekStmt(), |
| 146391 | +** and the Fts3Table.pSeekStmt slot is currently NULL, save the statement |
| 146392 | +** pointer there instead of finalizing it. |
| 146393 | +*/ |
| 146394 | +static void fts3CursorFinalizeStmt(Fts3Cursor *pCsr){ |
| 146395 | + if( pCsr->bSeekStmt ){ |
| 146396 | + Fts3Table *p = (Fts3Table *)pCsr->base.pVtab; |
| 146397 | + if( p->pSeekStmt==0 ){ |
| 146398 | + p->pSeekStmt = pCsr->pStmt; |
| 146399 | + sqlite3_reset(pCsr->pStmt); |
| 146400 | + pCsr->pStmt = 0; |
| 146401 | + } |
| 146402 | + pCsr->bSeekStmt = 0; |
| 146403 | + } |
| 146404 | + sqlite3_finalize(pCsr->pStmt); |
| 146405 | +} |
| 146371 | 146406 | |
| 146372 | 146407 | /* |
| 146373 | 146408 | ** Close the cursor. For additional information see the documentation |
| 146374 | 146409 | ** on the xClose method of the virtual table interface. |
| 146375 | 146410 | */ |
| 146376 | 146411 | static int fts3CloseMethod(sqlite3_vtab_cursor *pCursor){ |
| 146377 | 146412 | Fts3Cursor *pCsr = (Fts3Cursor *)pCursor; |
| 146378 | 146413 | assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 ); |
| 146379 | | - sqlite3_finalize(pCsr->pStmt); |
| 146414 | + fts3CursorFinalizeStmt(pCsr); |
| 146380 | 146415 | sqlite3Fts3ExprFree(pCsr->pExpr); |
| 146381 | 146416 | sqlite3Fts3FreeDeferredTokens(pCsr); |
| 146382 | 146417 | sqlite3_free(pCsr->aDoclist); |
| 146383 | 146418 | sqlite3Fts3MIBufferFree(pCsr->pMIBuffer); |
| 146384 | 146419 | assert( ((Fts3Table *)pCsr->base.pVtab)->pSegments==0 ); |
| | @@ -146392,24 +146427,27 @@ |
| 146392 | 146427 | ** |
| 146393 | 146428 | ** "SELECT <columns> FROM %_content WHERE rowid = ?" |
| 146394 | 146429 | ** |
| 146395 | 146430 | ** (or the equivalent for a content=xxx table) and set pCsr->pStmt to |
| 146396 | 146431 | ** it. If an error occurs, return an SQLite error code. |
| 146397 | | -** |
| 146398 | | -** Otherwise, set *ppStmt to point to pCsr->pStmt and return SQLITE_OK. |
| 146399 | 146432 | */ |
| 146400 | | -static int fts3CursorSeekStmt(Fts3Cursor *pCsr, sqlite3_stmt **ppStmt){ |
| 146433 | +static int fts3CursorSeekStmt(Fts3Cursor *pCsr){ |
| 146401 | 146434 | int rc = SQLITE_OK; |
| 146402 | 146435 | if( pCsr->pStmt==0 ){ |
| 146403 | 146436 | Fts3Table *p = (Fts3Table *)pCsr->base.pVtab; |
| 146404 | 146437 | char *zSql; |
| 146405 | | - zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist); |
| 146406 | | - if( !zSql ) return SQLITE_NOMEM; |
| 146407 | | - rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0); |
| 146408 | | - sqlite3_free(zSql); |
| 146438 | + if( p->pSeekStmt ){ |
| 146439 | + pCsr->pStmt = p->pSeekStmt; |
| 146440 | + p->pSeekStmt = 0; |
| 146441 | + }else{ |
| 146442 | + zSql = sqlite3_mprintf("SELECT %s WHERE rowid = ?", p->zReadExprlist); |
| 146443 | + if( !zSql ) return SQLITE_NOMEM; |
| 146444 | + rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0); |
| 146445 | + sqlite3_free(zSql); |
| 146446 | + } |
| 146447 | + if( rc==SQLITE_OK ) pCsr->bSeekStmt = 1; |
| 146409 | 146448 | } |
| 146410 | | - *ppStmt = pCsr->pStmt; |
| 146411 | 146449 | return rc; |
| 146412 | 146450 | } |
| 146413 | 146451 | |
| 146414 | 146452 | /* |
| 146415 | 146453 | ** Position the pCsr->pStmt statement so that it is on the row |
| | @@ -146417,13 +146455,11 @@ |
| 146417 | 146455 | ** SQLITE_OK on success. |
| 146418 | 146456 | */ |
| 146419 | 146457 | static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ |
| 146420 | 146458 | int rc = SQLITE_OK; |
| 146421 | 146459 | if( pCsr->isRequireSeek ){ |
| 146422 | | - sqlite3_stmt *pStmt = 0; |
| 146423 | | - |
| 146424 | | - rc = fts3CursorSeekStmt(pCsr, &pStmt); |
| 146460 | + rc = fts3CursorSeekStmt(pCsr); |
| 146425 | 146461 | if( rc==SQLITE_OK ){ |
| 146426 | 146462 | sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId); |
| 146427 | 146463 | pCsr->isRequireSeek = 0; |
| 146428 | 146464 | if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ |
| 146429 | 146465 | return SQLITE_OK; |
| | @@ -147877,11 +147913,11 @@ |
| 147877 | 147913 | if( idxNum & FTS3_HAVE_DOCID_GE ) pDocidGe = apVal[iIdx++]; |
| 147878 | 147914 | if( idxNum & FTS3_HAVE_DOCID_LE ) pDocidLe = apVal[iIdx++]; |
| 147879 | 147915 | assert( iIdx==nVal ); |
| 147880 | 147916 | |
| 147881 | 147917 | /* In case the cursor has been used before, clear it now. */ |
| 147882 | | - sqlite3_finalize(pCsr->pStmt); |
| 147918 | + fts3CursorFinalizeStmt(pCsr); |
| 147883 | 147919 | sqlite3_free(pCsr->aDoclist); |
| 147884 | 147920 | sqlite3Fts3MIBufferFree(pCsr->pMIBuffer); |
| 147885 | 147921 | sqlite3Fts3ExprFree(pCsr->pExpr); |
| 147886 | 147922 | memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor)); |
| 147887 | 147923 | |
| | @@ -147945,11 +147981,11 @@ |
| 147945 | 147981 | sqlite3_free(zSql); |
| 147946 | 147982 | }else{ |
| 147947 | 147983 | rc = SQLITE_NOMEM; |
| 147948 | 147984 | } |
| 147949 | 147985 | }else if( eSearch==FTS3_DOCID_SEARCH ){ |
| 147950 | | - rc = fts3CursorSeekStmt(pCsr, &pCsr->pStmt); |
| 147986 | + rc = fts3CursorSeekStmt(pCsr); |
| 147951 | 147987 | if( rc==SQLITE_OK ){ |
| 147952 | 147988 | rc = sqlite3_bind_value(pCsr->pStmt, 1, pCons); |
| 147953 | 147989 | } |
| 147954 | 147990 | } |
| 147955 | 147991 | if( rc!=SQLITE_OK ) return rc; |
| | @@ -162965,10 +163001,11 @@ |
| 162965 | 163001 | /* #include <stdio.h> */ |
| 162966 | 163002 | |
| 162967 | 163003 | #ifndef SQLITE_AMALGAMATION |
| 162968 | 163004 | #include "sqlite3rtree.h" |
| 162969 | 163005 | typedef sqlite3_int64 i64; |
| 163006 | +typedef sqlite3_uint64 u64; |
| 162970 | 163007 | typedef unsigned char u8; |
| 162971 | 163008 | typedef unsigned short u16; |
| 162972 | 163009 | typedef unsigned int u32; |
| 162973 | 163010 | #endif |
| 162974 | 163011 | |
| | @@ -163266,20 +163303,20 @@ |
| 163266 | 163303 | # define MIN(x,y) ((x) > (y) ? (y) : (x)) |
| 163267 | 163304 | #endif |
| 163268 | 163305 | |
| 163269 | 163306 | /* What version of GCC is being used. 0 means GCC is not being used */ |
| 163270 | 163307 | #ifndef GCC_VERSION |
| 163271 | | -#ifdef __GNUC__ |
| 163308 | +#if defined(__GNUC__) && !defined(SQLITE_DISABLE_INTRINSIC) |
| 163272 | 163309 | # define GCC_VERSION (__GNUC__*1000000+__GNUC_MINOR__*1000+__GNUC_PATCHLEVEL__) |
| 163273 | 163310 | #else |
| 163274 | 163311 | # define GCC_VERSION 0 |
| 163275 | 163312 | #endif |
| 163276 | 163313 | #endif |
| 163277 | 163314 | |
| 163278 | 163315 | /* What version of CLANG is being used. 0 means CLANG is not being used */ |
| 163279 | 163316 | #ifndef CLANG_VERSION |
| 163280 | | -#if defined(__clang__) && !defined(_WIN32) |
| 163317 | +#if defined(__clang__) && !defined(_WIN32) && !defined(SQLITE_DISABLE_INTRINSIC) |
| 163281 | 163318 | # define CLANG_VERSION \ |
| 163282 | 163319 | (__clang_major__*1000000+__clang_minor__*1000+__clang_patchlevel__) |
| 163283 | 163320 | #else |
| 163284 | 163321 | # define CLANG_VERSION 0 |
| 163285 | 163322 | #endif |
| | @@ -163300,27 +163337,26 @@ |
| 163300 | 163337 | ** using C-preprocessor macros. If that is unsuccessful, or if |
| 163301 | 163338 | ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined |
| 163302 | 163339 | ** at run-time. |
| 163303 | 163340 | */ |
| 163304 | 163341 | #ifndef SQLITE_BYTEORDER |
| 163305 | | -#if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 163306 | | - defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 163307 | | - defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 163308 | | - defined(__arm__)) && !defined(SQLITE_RUNTIME_BYTEORDER) |
| 163342 | +#if defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 163343 | + defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \ |
| 163344 | + defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \ |
| 163345 | + defined(__arm__) |
| 163309 | 163346 | # define SQLITE_BYTEORDER 1234 |
| 163310 | | -#elif (defined(sparc) || defined(__ppc__)) \ |
| 163311 | | - && !defined(SQLITE_RUNTIME_BYTEORDER) |
| 163347 | +#elif defined(sparc) || defined(__ppc__) |
| 163312 | 163348 | # define SQLITE_BYTEORDER 4321 |
| 163313 | 163349 | #else |
| 163314 | 163350 | # define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */ |
| 163315 | 163351 | #endif |
| 163316 | 163352 | #endif |
| 163317 | 163353 | |
| 163318 | 163354 | |
| 163319 | 163355 | /* What version of MSVC is being used. 0 means MSVC is not being used */ |
| 163320 | 163356 | #ifndef MSVC_VERSION |
| 163321 | | -#if defined(_MSC_VER) |
| 163357 | +#if defined(_MSC_VER) && !defined(SQLITE_DISABLE_INTRINSIC) |
| 163322 | 163358 | # define MSVC_VERSION _MSC_VER |
| 163323 | 163359 | #else |
| 163324 | 163360 | # define MSVC_VERSION 0 |
| 163325 | 163361 | #endif |
| 163326 | 163362 | #endif |
| | @@ -163336,13 +163372,10 @@ |
| 163336 | 163372 | assert( ((((char*)p) - (char*)0)&3)==0 ); /* p is always 4-byte aligned */ |
| 163337 | 163373 | #if SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300 |
| 163338 | 163374 | pCoord->u = _byteswap_ulong(*(u32*)p); |
| 163339 | 163375 | #elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000) |
| 163340 | 163376 | pCoord->u = __builtin_bswap32(*(u32*)p); |
| 163341 | | -#elif SQLITE_BYTEORDER==1234 |
| 163342 | | - pCoord->u = ((pCoord->u>>24)&0xff)|((pCoord->u>>8)&0xff00)| |
| 163343 | | - ((pCoord->u&0xff)<<24)|((pCoord->u&0xff00)<<8); |
| 163344 | 163377 | #elif SQLITE_BYTEORDER==4321 |
| 163345 | 163378 | pCoord->u = *(u32*)p; |
| 163346 | 163379 | #else |
| 163347 | 163380 | pCoord->u = ( |
| 163348 | 163381 | (((u32)p[0]) << 24) + |
| | @@ -163382,14 +163415,13 @@ |
| 163382 | 163415 | /* |
| 163383 | 163416 | ** Functions to serialize a 16 bit integer, 32 bit real number and |
| 163384 | 163417 | ** 64 bit integer. The value returned is the number of bytes written |
| 163385 | 163418 | ** to the argument buffer (always 2, 4 and 8 respectively). |
| 163386 | 163419 | */ |
| 163387 | | -static int writeInt16(u8 *p, int i){ |
| 163420 | +static void writeInt16(u8 *p, int i){ |
| 163388 | 163421 | p[0] = (i>> 8)&0xFF; |
| 163389 | 163422 | p[1] = (i>> 0)&0xFF; |
| 163390 | | - return 2; |
| 163391 | 163423 | } |
| 163392 | 163424 | static int writeCoord(u8 *p, RtreeCoord *pCoord){ |
| 163393 | 163425 | u32 i; |
| 163394 | 163426 | assert( ((((char*)p) - (char*)0)&3)==0 ); /* p is always 4-byte aligned */ |
| 163395 | 163427 | assert( sizeof(RtreeCoord)==4 ); |
| | @@ -197506,11 +197538,11 @@ |
| 197506 | 197538 | int nArg, /* Number of args */ |
| 197507 | 197539 | sqlite3_value **apUnused /* Function arguments */ |
| 197508 | 197540 | ){ |
| 197509 | 197541 | assert( nArg==0 ); |
| 197510 | 197542 | UNUSED_PARAM2(nArg, apUnused); |
| 197511 | | - sqlite3_result_text(pCtx, "fts5: 2017-02-07 12:58:38 07fe6228208684d579c4f6c334c90eb6262a9233", -1, SQLITE_TRANSIENT); |
| 197543 | + sqlite3_result_text(pCtx, "fts5: 2017-02-08 19:12:36 1afec5758b624e6a066d4e7ef50695095e9d7ff1", -1, SQLITE_TRANSIENT); |
| 197512 | 197544 | } |
| 197513 | 197545 | |
| 197514 | 197546 | static int fts5Init(sqlite3 *db){ |
| 197515 | 197547 | static const sqlite3_module fts5Mod = { |
| 197516 | 197548 | /* iVersion */ 2, |
| 197517 | 197549 | |