1 |
1 |
/******************************************************************************
|
2 |
2 |
** This file is an amalgamation of many separate C source files from SQLite
|
3 |
|
** version 3.16.2. By combining all the individual C code files into this
|
|
3 |
** version 3.17.0. By combining all the individual C code files into this
|
4 |
4 |
** single large file, the entire code can be compiled as a single translation
|
5 |
5 |
** unit. This allows many compilers to do optimizations that would not be
|
6 |
6 |
** possible if the files were compiled separately. Performance improvements
|
... | ... | |
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
|
|
218 |
#if defined(__clang__) && !defined(_WIN32) && !defined(SQLITE_DISABLE_INTRINSIC)
|
|
219 |
# define CLANG_VERSION \
|
|
220 |
(__clang_major__*1000000+__clang_minor__*1000+__clang_patchlevel__)
|
|
221 |
#else
|
|
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
|
|
228 |
#endif
|
213 |
229 |
|
214 |
230 |
/* Needed for various definitions... */
|
215 |
231 |
#if defined(__GNUC__) && !defined(_GNU_SOURCE)
|
... | ... | |
381 |
397 |
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
382 |
398 |
** [sqlite_version()] and [sqlite_source_id()].
|
383 |
399 |
*/
|
384 |
|
#define SQLITE_VERSION "3.16.2"
|
385 |
|
#define SQLITE_VERSION_NUMBER 3016002
|
386 |
|
#define SQLITE_SOURCE_ID "2017-01-06 16:32:41 a65a62893ca8319e89e48b8a38cf8a59c69a8209"
|
|
400 |
#define SQLITE_VERSION "3.17.0"
|
|
401 |
#define SQLITE_VERSION_NUMBER 3017000
|
|
402 |
#define SQLITE_SOURCE_ID "2017-02-13 16:02:40 ada05cfa86ad7f5645450ac7a2a21c9aa6e57d2c"
|
387 |
403 |
|
388 |
404 |
/*
|
389 |
405 |
** CAPI3REF: Run-Time Library Version Numbers
|
... | ... | |
519 |
535 |
*/
|
520 |
536 |
#ifdef SQLITE_INT64_TYPE
|
521 |
537 |
typedef SQLITE_INT64_TYPE sqlite_int64;
|
522 |
|
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
|
|
538 |
# ifdef SQLITE_UINT64_TYPE
|
|
539 |
typedef SQLITE_UINT64_TYPE sqlite_uint64;
|
|
540 |
# else
|
|
541 |
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
|
|
542 |
# endif
|
523 |
543 |
#elif defined(_MSC_VER) || defined(__BORLANDC__)
|
524 |
544 |
typedef __int64 sqlite_int64;
|
525 |
545 |
typedef unsigned __int64 sqlite_uint64;
|
... | ... | |
832 |
852 |
** file that were written at the application level might have changed
|
833 |
853 |
** and that adjacent bytes, even bytes within the same sector are
|
834 |
854 |
** guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
|
835 |
|
** flag indicate that a file cannot be deleted when open. The
|
|
855 |
** flag indicates that a file cannot be deleted when open. The
|
836 |
856 |
** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on
|
837 |
857 |
** read-only media and cannot be changed even by processes with
|
838 |
858 |
** elevated privileges.
|
... | ... | |
982 |
1002 |
** <li> [SQLITE_IOCAP_ATOMIC64K]
|
983 |
1003 |
** <li> [SQLITE_IOCAP_SAFE_APPEND]
|
984 |
1004 |
** <li> [SQLITE_IOCAP_SEQUENTIAL]
|
|
1005 |
** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN]
|
|
1006 |
** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
|
|
1007 |
** <li> [SQLITE_IOCAP_IMMUTABLE]
|
985 |
1008 |
** </ul>
|
986 |
1009 |
**
|
987 |
1010 |
** The SQLITE_IOCAP_ATOMIC property means that all writes of
|
... | ... | |
5670 |
5693 |
** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.
|
5671 |
5694 |
**
|
5672 |
5695 |
** ^In the current implementation, the update hook
|
5673 |
|
** is not invoked when duplication rows are deleted because of an
|
|
5696 |
** is not invoked when conflicting rows are deleted because of an
|
5674 |
5697 |
** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook
|
5675 |
5698 |
** invoked when rows are deleted using the [truncate optimization].
|
5676 |
5699 |
** The exceptions defined in this paragraph might change in a future
|
... | ... | |
6452 |
6475 |
** [database connection] error code and message accessible via
|
6453 |
6476 |
** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions.
|
6454 |
6477 |
**
|
|
6478 |
** A BLOB referenced by sqlite3_blob_open() may be read using the
|
|
6479 |
** [sqlite3_blob_read()] interface and modified by using
|
|
6480 |
** [sqlite3_blob_write()]. The [BLOB handle] can be moved to a
|
|
6481 |
** different row of the same table using the [sqlite3_blob_reopen()]
|
|
6482 |
** interface. However, the column, table, or database of a [BLOB handle]
|
|
6483 |
** cannot be changed after the [BLOB handle] is opened.
|
6455 |
6484 |
**
|
6456 |
6485 |
** ^(If the row that a BLOB handle points to is modified by an
|
6457 |
6486 |
** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
|
... | ... | |
6475 |
6504 |
**
|
6476 |
6505 |
** To avoid a resource leak, every open [BLOB handle] should eventually
|
6477 |
6506 |
** be released by a call to [sqlite3_blob_close()].
|
|
6507 |
**
|
|
6508 |
** See also: [sqlite3_blob_close()],
|
|
6509 |
** [sqlite3_blob_reopen()], [sqlite3_blob_read()],
|
|
6510 |
** [sqlite3_blob_bytes()], [sqlite3_blob_write()].
|
6478 |
6511 |
*/
|
6479 |
6512 |
SQLITE_API int sqlite3_blob_open(
|
6480 |
6513 |
sqlite3*,
|
... | ... | |
6490 |
6523 |
** CAPI3REF: Move a BLOB Handle to a New Row
|
6491 |
6524 |
** METHOD: sqlite3_blob
|
6492 |
6525 |
**
|
6493 |
|
** ^This function is used to move an existing blob handle so that it points
|
|
6526 |
** ^This function is used to move an existing [BLOB handle] so that it points
|
6494 |
6527 |
** to a different row of the same database table. ^The new row is identified
|
6495 |
6528 |
** by the rowid value passed as the second argument. Only the row can be
|
6496 |
6529 |
** changed. ^The database, table and column on which the blob handle is open
|
6497 |
|
** remain the same. Moving an existing blob handle to a new row can be
|
|
6530 |
** remain the same. Moving an existing [BLOB handle] to a new row is
|
6498 |
6531 |
** faster than closing the existing handle and opening a new one.
|
6499 |
6532 |
**
|
6500 |
6533 |
** ^(The new row must meet the same criteria as for [sqlite3_blob_open()] -
|
... | ... | |
8423 |
8456 |
**
|
8424 |
8457 |
** ^The [sqlite3_preupdate_hook()] interface registers a callback function
|
8425 |
8458 |
** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation
|
8426 |
|
** on a [rowid table].
|
|
8459 |
** on a database table.
|
8427 |
8460 |
** ^At most one preupdate hook may be registered at a time on a single
|
8428 |
8461 |
** [database connection]; each call to [sqlite3_preupdate_hook()] overrides
|
8429 |
8462 |
** the previous setting.
|
... | ... | |
8432 |
8465 |
** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as
|
8433 |
8466 |
** the first parameter to callbacks.
|
8434 |
8467 |
**
|
8435 |
|
** ^The preupdate hook only fires for changes to [rowid tables]; the preupdate
|
8436 |
|
** hook is not invoked for changes to [virtual tables] or [WITHOUT ROWID]
|
8437 |
|
** tables.
|
|
8468 |
** ^The preupdate hook only fires for changes to real database tables; the
|
|
8469 |
** preupdate hook is not invoked for changes to [virtual tables] or to
|
|
8470 |
** system tables like sqlite_master or sqlite_stat1.
|
8438 |
8471 |
**
|
8439 |
8472 |
** ^The second parameter to the preupdate callback is a pointer to
|
8440 |
8473 |
** the [database connection] that registered the preupdate hook.
|
... | ... | |
8448 |
8481 |
** databases.)^
|
8449 |
8482 |
** ^The fifth parameter to the preupdate callback is the name of the
|
8450 |
8483 |
** table that is being modified.
|
8451 |
|
** ^The sixth parameter to the preupdate callback is the initial [rowid] of the
|
8452 |
|
** row being changes for SQLITE_UPDATE and SQLITE_DELETE changes and is
|
8453 |
|
** undefined for SQLITE_INSERT changes.
|
8454 |
|
** ^The seventh parameter to the preupdate callback is the final [rowid] of
|
8455 |
|
** the row being changed for SQLITE_UPDATE and SQLITE_INSERT changes and is
|
8456 |
|
** undefined for SQLITE_DELETE changes.
|
|
8484 |
**
|
|
8485 |
** For an UPDATE or DELETE operation on a [rowid table], the sixth
|
|
8486 |
** parameter passed to the preupdate callback is the initial [rowid] of the
|
|
8487 |
** row being modified or deleted. For an INSERT operation on a rowid table,
|
|
8488 |
** or any operation on a WITHOUT ROWID table, the value of the sixth
|
|
8489 |
** parameter is undefined. For an INSERT or UPDATE on a rowid table the
|
|
8490 |
** seventh parameter is the final rowid value of the row being inserted
|
|
8491 |
** or updated. The value of the seventh parameter passed to the callback
|
|
8492 |
** function is not defined for operations on WITHOUT ROWID tables, or for
|
|
8493 |
** INSERT operations on rowid tables.
|
8457 |
8494 |
**
|
8458 |
8495 |
** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],
|
8459 |
8496 |
** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces
|
... | ... | |
8889 |
8926 |
** attached database. It is not an error if database zDb is not attached
|
8890 |
8927 |
** to the database when the session object is created.
|
8891 |
8928 |
*/
|
8892 |
|
int sqlite3session_create(
|
|
8929 |
SQLITE_API int sqlite3session_create(
|
8893 |
8930 |
sqlite3 *db, /* Database handle */
|
8894 |
8931 |
const char *zDb, /* Name of db (e.g. "main") */
|
8895 |
8932 |
sqlite3_session **ppSession /* OUT: New session object */
|
... | ... | |
8907 |
8944 |
** are attached is closed. Refer to the documentation for
|
8908 |
8945 |
** [sqlite3session_create()] for details.
|
8909 |
8946 |
*/
|
8910 |
|
void sqlite3session_delete(sqlite3_session *pSession);
|
|
8947 |
SQLITE_API void sqlite3session_delete(sqlite3_session *pSession);
|
8911 |
8948 |
|
8912 |
8949 |
|
8913 |
8950 |
/*
|
... | ... | |
8927 |
8964 |
** The return value indicates the final state of the session object: 0 if
|
8928 |
8965 |
** the session is disabled, or 1 if it is enabled.
|
8929 |
8966 |
*/
|
8930 |
|
int sqlite3session_enable(sqlite3_session *pSession, int bEnable);
|
|
8967 |
SQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable);
|
8931 |
8968 |
|
8932 |
8969 |
/*
|
8933 |
8970 |
** CAPI3REF: Set Or Clear the Indirect Change Flag
|
... | ... | |
8956 |
8993 |
** The return value indicates the final state of the indirect flag: 0 if
|
8957 |
8994 |
** it is clear, or 1 if it is set.
|
8958 |
8995 |
*/
|
8959 |
|
int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);
|
|
8996 |
SQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);
|
8960 |
8997 |
|
8961 |
8998 |
/*
|
8962 |
8999 |
** CAPI3REF: Attach A Table To A Session Object
|
... | ... | |
8986 |
9023 |
** SQLITE_OK is returned if the call completes without error. Or, if an error
|
8987 |
9024 |
** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.
|
8988 |
9025 |
*/
|
8989 |
|
int sqlite3session_attach(
|
|
9026 |
SQLITE_API int sqlite3session_attach(
|
8990 |
9027 |
sqlite3_session *pSession, /* Session object */
|
8991 |
9028 |
const char *zTab /* Table name */
|
8992 |
9029 |
);
|
... | ... | |
9000 |
9037 |
** If xFilter returns 0, changes is not tracked. Note that once a table is
|
9001 |
9038 |
** attached, xFilter will not be called again.
|
9002 |
9039 |
*/
|
9003 |
|
void sqlite3session_table_filter(
|
|
9040 |
SQLITE_API void sqlite3session_table_filter(
|
9004 |
9041 |
sqlite3_session *pSession, /* Session object */
|
9005 |
9042 |
int(*xFilter)(
|
9006 |
9043 |
void *pCtx, /* Copy of third arg to _filter_table() */
|
... | ... | |
9113 |
9150 |
** another field of the same row is updated while the session is enabled, the
|
9114 |
9151 |
** resulting changeset will contain an UPDATE change that updates both fields.
|
9115 |
9152 |
*/
|
9116 |
|
int sqlite3session_changeset(
|
|
9153 |
SQLITE_API int sqlite3session_changeset(
|
9117 |
9154 |
sqlite3_session *pSession, /* Session object */
|
9118 |
9155 |
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
|
9119 |
9156 |
void **ppChangeset /* OUT: Buffer containing changeset */
|
... | ... | |
9157 |
9194 |
** the from-table, a DELETE record is added to the session object.
|
9158 |
9195 |
**
|
9159 |
9196 |
** <li> For each row (primary key) that exists in both tables, but features
|
9160 |
|
** different in each, an UPDATE record is added to the session.
|
|
9197 |
** different non-PK values in each, an UPDATE record is added to the
|
|
9198 |
** session.
|
9161 |
9199 |
** </ul>
|
9162 |
9200 |
**
|
9163 |
9201 |
** To clarify, if this function is called and then a changeset constructed
|
... | ... | |
9174 |
9212 |
** message. It is the responsibility of the caller to free this buffer using
|
9175 |
9213 |
** sqlite3_free().
|
9176 |
9214 |
*/
|
9177 |
|
int sqlite3session_diff(
|
|
9215 |
SQLITE_API int sqlite3session_diff(
|
9178 |
9216 |
sqlite3_session *pSession,
|
9179 |
9217 |
const char *zFromDb,
|
9180 |
9218 |
const char *zTbl,
|
... | ... | |
9210 |
9248 |
** a single table are grouped together, tables appear in the order in which
|
9211 |
9249 |
** they were attached to the session object).
|
9212 |
9250 |
*/
|
9213 |
|
int sqlite3session_patchset(
|
|
9251 |
SQLITE_API int sqlite3session_patchset(
|
9214 |
9252 |
sqlite3_session *pSession, /* Session object */
|
9215 |
9253 |
int *pnPatchset, /* OUT: Size of buffer at *ppChangeset */
|
9216 |
9254 |
void **ppPatchset /* OUT: Buffer containing changeset */
|
... | ... | |
9231 |
9269 |
** guaranteed that a call to sqlite3session_changeset() will return a
|
9232 |
9270 |
** changeset containing zero changes.
|
9233 |
9271 |
*/
|
9234 |
|
int sqlite3session_isempty(sqlite3_session *pSession);
|
|
9272 |
SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession);
|
9235 |
9273 |
|
9236 |
9274 |
/*
|
9237 |
9275 |
** CAPI3REF: Create An Iterator To Traverse A Changeset
|
... | ... | |
9266 |
9304 |
** the applies to table X, then one for table Y, and then later on visit
|
9267 |
9305 |
** another change for table X.
|
9268 |
9306 |
*/
|
9269 |
|
int sqlite3changeset_start(
|
|
9307 |
SQLITE_API int sqlite3changeset_start(
|
9270 |
9308 |
sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
|
9271 |
9309 |
int nChangeset, /* Size of changeset blob in bytes */
|
9272 |
9310 |
void *pChangeset /* Pointer to blob containing changeset */
|
... | ... | |
9295 |
9333 |
** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or
|
9296 |
9334 |
** SQLITE_NOMEM.
|
9297 |
9335 |
*/
|
9298 |
|
int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
|
|
9336 |
SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
|
9299 |
9337 |
|
9300 |
9338 |
/*
|
9301 |
9339 |
** CAPI3REF: Obtain The Current Operation From A Changeset Iterator
|
... | ... | |
9323 |
9361 |
** SQLite error code is returned. The values of the output variables may not
|
9324 |
9362 |
** be trusted in this case.
|
9325 |
9363 |
*/
|
9326 |
|
int sqlite3changeset_op(
|
|
9364 |
SQLITE_API int sqlite3changeset_op(
|
9327 |
9365 |
sqlite3_changeset_iter *pIter, /* Iterator object */
|
9328 |
9366 |
const char **pzTab, /* OUT: Pointer to table name */
|
9329 |
9367 |
int *pnCol, /* OUT: Number of columns in table */
|
... | ... | |
9356 |
9394 |
** SQLITE_OK is returned and the output variables populated as described
|
9357 |
9395 |
** above.
|
9358 |
9396 |
*/
|
9359 |
|
int sqlite3changeset_pk(
|
|
9397 |
SQLITE_API int sqlite3changeset_pk(
|
9360 |
9398 |
sqlite3_changeset_iter *pIter, /* Iterator object */
|
9361 |
9399 |
unsigned char **pabPK, /* OUT: Array of boolean - true for PK cols */
|
9362 |
9400 |
int *pnCol /* OUT: Number of entries in output array */
|
... | ... | |
9386 |
9424 |
** If some other error occurs (e.g. an OOM condition), an SQLite error code
|
9387 |
9425 |
** is returned and *ppValue is set to NULL.
|
9388 |
9426 |
*/
|
9389 |
|
int sqlite3changeset_old(
|
|
9427 |
SQLITE_API int sqlite3changeset_old(
|
9390 |
9428 |
sqlite3_changeset_iter *pIter, /* Changeset iterator */
|
9391 |
9429 |
int iVal, /* Column number */
|
9392 |
9430 |
sqlite3_value **ppValue /* OUT: Old value (or NULL pointer) */
|
... | ... | |
9419 |
9457 |
** If some other error occurs (e.g. an OOM condition), an SQLite error code
|
9420 |
9458 |
** is returned and *ppValue is set to NULL.
|
9421 |
9459 |
*/
|
9422 |
|
int sqlite3changeset_new(
|
|
9460 |
SQLITE_API int sqlite3changeset_new(
|
9423 |
9461 |
sqlite3_changeset_iter *pIter, /* Changeset iterator */
|
9424 |
9462 |
int iVal, /* Column number */
|
9425 |
9463 |
sqlite3_value **ppValue /* OUT: New value (or NULL pointer) */
|
... | ... | |
9446 |
9484 |
** If some other error occurs (e.g. an OOM condition), an SQLite error code
|
9447 |
9485 |
** is returned and *ppValue is set to NULL.
|
9448 |
9486 |
*/
|
9449 |
|
int sqlite3changeset_conflict(
|
|
9487 |
SQLITE_API int sqlite3changeset_conflict(
|
9450 |
9488 |
sqlite3_changeset_iter *pIter, /* Changeset iterator */
|
9451 |
9489 |
int iVal, /* Column number */
|
9452 |
9490 |
sqlite3_value **ppValue /* OUT: Value from conflicting row */
|
... | ... | |
9462 |
9500 |
**
|
9463 |
9501 |
** In all other cases this function returns SQLITE_MISUSE.
|
9464 |
9502 |
*/
|
9465 |
|
int sqlite3changeset_fk_conflicts(
|
|
9503 |
SQLITE_API int sqlite3changeset_fk_conflicts(
|
9466 |
9504 |
sqlite3_changeset_iter *pIter, /* Changeset iterator */
|
9467 |
9505 |
int *pnOut /* OUT: Number of FK violations */
|
9468 |
9506 |
);
|
... | ... | |
9495 |
9533 |
** // An error has occurred
|
9496 |
9534 |
** }
|
9497 |
9535 |
*/
|
9498 |
|
int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);
|
|
9536 |
SQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);
|
9499 |
9537 |
|
9500 |
9538 |
/*
|
9501 |
9539 |
** CAPI3REF: Invert A Changeset
|
... | ... | |
9525 |
9563 |
** WARNING/TODO: This function currently assumes that the input is a valid
|
9526 |
9564 |
** changeset. If it is not, the results are undefined.
|
9527 |
9565 |
*/
|
9528 |
|
int sqlite3changeset_invert(
|
|
9566 |
SQLITE_API int sqlite3changeset_invert(
|
9529 |
9567 |
int nIn, const void *pIn, /* Input changeset */
|
9530 |
9568 |
int *pnOut, void **ppOut /* OUT: Inverse of input */
|
9531 |
9569 |
);
|
... | ... | |
9554 |
9592 |
**
|
9555 |
9593 |
** Refer to the sqlite3_changegroup documentation below for details.
|
9556 |
9594 |
*/
|
9557 |
|
int sqlite3changeset_concat(
|
|
9595 |
SQLITE_API int sqlite3changeset_concat(
|
9558 |
9596 |
int nA, /* Number of bytes in buffer pA */
|
9559 |
9597 |
void *pA, /* Pointer to buffer containing changeset A */
|
9560 |
9598 |
int nB, /* Number of bytes in buffer pB */
|
... | ... | |
9742 |
9780 |
** <ul>
|
9743 |
9781 |
** <li> The table has the same name as the name recorded in the
|
9744 |
9782 |
** changeset, and
|
9745 |
|
** <li> The table has the same number of columns as recorded in the
|
|
9783 |
** <li> The table has at least as many columns as recorded in the
|
9746 |
9784 |
** changeset, and
|
9747 |
9785 |
** <li> The table has primary key columns in the same position as
|
9748 |
9786 |
** recorded in the changeset.
|
... | ... | |
9787 |
9825 |
** If a row with matching primary key values is found, but one or more of
|
9788 |
9826 |
** the non-primary key fields contains a value different from the original
|
9789 |
9827 |
** row value stored in the changeset, the conflict-handler function is
|
9790 |
|
** invoked with [SQLITE_CHANGESET_DATA] as the second argument.
|
|
9828 |
** invoked with [SQLITE_CHANGESET_DATA] as the second argument. If the
|
|
9829 |
** database table has more columns than are recorded in the changeset,
|
|
9830 |
** only the values of those non-primary key fields are compared against
|
|
9831 |
** the current database contents - any trailing database table columns
|
|
9832 |
** are ignored.
|
9791 |
9833 |
**
|
9792 |
9834 |
** If no row with matching primary key values is found in the database,
|
9793 |
9835 |
** the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]
|
... | ... | |
9802 |
9844 |
**
|
9803 |
9845 |
** <dt>INSERT Changes<dd>
|
9804 |
9846 |
** For each INSERT change, an attempt is made to insert the new row into
|
9805 |
|
** the database.
|
|
9847 |
** the database. If the changeset row contains fewer fields than the
|
|
9848 |
** database table, the trailing fields are populated with their default
|
|
9849 |
** values.
|
9806 |
9850 |
**
|
9807 |
9851 |
** If the attempt to insert the row fails because the database already
|
9808 |
9852 |
** contains a row with the same primary key values, the conflict handler
|
... | ... | |
9820 |
9864 |
** For each UPDATE change, this function checks if the target database
|
9821 |
9865 |
** contains a row with the same primary key value (or values) as the
|
9822 |
9866 |
** original row values stored in the changeset. If it does, and the values
|
9823 |
|
** stored in all non-primary key columns also match the values stored in
|
9824 |
|
** the changeset the row is updated within the target database.
|
|
9867 |
** stored in all modified non-primary key columns also match the values
|
|
9868 |
** stored in the changeset the row is updated within the target database.
|
9825 |
9869 |
**
|
9826 |
9870 |
** If a row with matching primary key values is found, but one or more of
|
9827 |
|
** the non-primary key fields contains a value different from an original
|
9828 |
|
** row value stored in the changeset, the conflict-handler function is
|
9829 |
|
** invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since
|
|
9871 |
** the modified non-primary key fields contains a value different from an
|
|
9872 |
** original row value stored in the changeset, the conflict-handler function
|
|
9873 |
** is invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since
|
9830 |
9874 |
** UPDATE changes only contain values for non-primary key fields that are
|
9831 |
9875 |
** to be modified, only those fields need to match the original values to
|
9832 |
9876 |
** avoid the SQLITE_CHANGESET_DATA conflict-handler callback.
|
... | ... | |
9854 |
9898 |
** rolled back, restoring the target database to its original state, and an
|
9855 |
9899 |
** SQLite error code returned.
|
9856 |
9900 |
*/
|
9857 |
|
int sqlite3changeset_apply(
|
|
9901 |
SQLITE_API int sqlite3changeset_apply(
|
9858 |
9902 |
sqlite3 *db, /* Apply change to "main" db of this handle */
|
9859 |
9903 |
int nChangeset, /* Size of changeset in bytes */
|
9860 |
9904 |
void *pChangeset, /* Changeset blob */
|
... | ... | |
10055 |
10099 |
** parameter set to a value less than or equal to zero. Other than this,
|
10056 |
10100 |
** no guarantees are made as to the size of the chunks of data returned.
|
10057 |
10101 |
*/
|
10058 |
|
int sqlite3changeset_apply_strm(
|
|
10102 |
SQLITE_API int sqlite3changeset_apply_strm(
|
10059 |
10103 |
sqlite3 *db, /* Apply change to "main" db of this handle */
|
10060 |
10104 |
int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
|
10061 |
10105 |
void *pIn, /* First arg for xInput */
|
... | ... | |
10070 |
10114 |
),
|
10071 |
10115 |
void *pCtx /* First argument passed to xConflict */
|
10072 |
10116 |
);
|
10073 |
|
int sqlite3changeset_concat_strm(
|
|
10117 |
SQLITE_API int sqlite3changeset_concat_strm(
|
10074 |
10118 |
int (*xInputA)(void *pIn, void *pData, int *pnData),
|
10075 |
10119 |
void *pInA,
|
10076 |
10120 |
int (*xInputB)(void *pIn, void *pData, int *pnData),
|
... | ... | |
10078 |
10122 |
int (*xOutput)(void *pOut, const void *pData, int nData),
|
10079 |
10123 |
void *pOut
|
10080 |
10124 |
);
|
10081 |
|
int sqlite3changeset_invert_strm(
|
|
10125 |
SQLITE_API int sqlite3changeset_invert_strm(
|
10082 |
10126 |
int (*xInput)(void *pIn, void *pData, int *pnData),
|
10083 |
10127 |
void *pIn,
|
10084 |
10128 |
int (*xOutput)(void *pOut, const void *pData, int nData),
|
10085 |
10129 |
void *pOut
|
10086 |
10130 |
);
|
10087 |
|
int sqlite3changeset_start_strm(
|
|
10131 |
SQLITE_API int sqlite3changeset_start_strm(
|
10088 |
10132 |
sqlite3_changeset_iter **pp,
|
10089 |
10133 |
int (*xInput)(void *pIn, void *pData, int *pnData),
|
10090 |
10134 |
void *pIn
|
10091 |
10135 |
);
|
10092 |
|
int sqlite3session_changeset_strm(
|
|
10136 |
SQLITE_API int sqlite3session_changeset_strm(
|
10093 |
10137 |
sqlite3_session *pSession,
|
10094 |
10138 |
int (*xOutput)(void *pOut, const void *pData, int nData),
|
10095 |
10139 |
void *pOut
|
10096 |
10140 |
);
|
10097 |
|
int sqlite3session_patchset_strm(
|
|
10141 |
SQLITE_API int sqlite3session_patchset_strm(
|
10098 |
10142 |
sqlite3_session *pSession,
|
10099 |
10143 |
int (*xOutput)(void *pOut, const void *pData, int nData),
|
10100 |
10144 |
void *pOut
|
... | ... | |
11001 |
11045 |
# include <intrin.h>
|
11002 |
11046 |
# pragma intrinsic(_byteswap_ushort)
|
11003 |
11047 |
# pragma intrinsic(_byteswap_ulong)
|
|
11048 |
# pragma intrinsic(_byteswap_uint64)
|
11004 |
11049 |
# pragma intrinsic(_ReadWriteBarrier)
|
11005 |
11050 |
# else
|
11006 |
11051 |
# include <cmnintrin.h>
|
... | ... | |
11540 |
11585 |
#include <stddef.h>
|
11541 |
11586 |
|
11542 |
11587 |
/*
|
|
11588 |
** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY.
|
|
11589 |
** This allows better measurements of where memcpy() is used when running
|
|
11590 |
** cachegrind. But this macro version of memcpy() is very slow so it
|
|
11591 |
** should not be used in production. This is a performance measurement
|
|
11592 |
** hack only.
|
|
11593 |
*/
|
|
11594 |
#ifdef SQLITE_INLINE_MEMCPY
|
|
11595 |
# define memcpy(D,S,N) {char*xxd=(char*)(D);const char*xxs=(const char*)(S);\
|
|
11596 |
int xxn=(N);while(xxn-->0)*(xxd++)=*(xxs++);}
|
|
11597 |
#endif
|
|
11598 |
|
|
11599 |
/*
|
11543 |
11600 |
** If compiling for a processor that lacks floating point support,
|
11544 |
11601 |
** substitute integer for floating-point
|
11545 |
11602 |
*/
|
... | ... | |
11623 |
11680 |
** pagecaches for each database connection. A positive number is the
|
11624 |
11681 |
** number of pages. A negative number N translations means that a buffer
|
11625 |
11682 |
** of -1024*N bytes is allocated and used for as many pages as it will hold.
|
|
11683 |
**
|
|
11684 |
** The default value of "20" was choosen to minimize the run-time of the
|
|
11685 |
** speedtest1 test program with options: --shrink-memory --reprepare
|
11626 |
11686 |
*/
|
11627 |
11687 |
#ifndef SQLITE_DEFAULT_PCACHE_INITSZ
|
11628 |
|
# define SQLITE_DEFAULT_PCACHE_INITSZ 100
|
|
11688 |
# define SQLITE_DEFAULT_PCACHE_INITSZ 20
|
11629 |
11689 |
#endif
|
11630 |
11690 |
|
11631 |
11691 |
/*
|
... | ... | |
11800 |
11860 |
**
|
11801 |
11861 |
** For best performance, an attempt is made to guess at the byte-order
|
11802 |
11862 |
** using C-preprocessor macros. If that is unsuccessful, or if
|
11803 |
|
** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined
|
|
11863 |
** -DSQLITE_BYTEORDER=0 is set, then byte-order is determined
|
11804 |
11864 |
** at run-time.
|
11805 |
11865 |
*/
|
11806 |
|
#if (defined(i386) || defined(__i386__) || defined(_M_IX86) || \
|
|
11866 |
#ifndef SQLITE_BYTEORDER
|
|
11867 |
# if defined(i386) || defined(__i386__) || defined(_M_IX86) || \
|
11807 |
11868 |
defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || \
|
11808 |
11869 |
defined(_M_AMD64) || defined(_M_ARM) || defined(__x86) || \
|
11809 |
|
defined(__arm__)) && !defined(SQLITE_RUNTIME_BYTEORDER)
|
11810 |
|
# define SQLITE_BYTEORDER 1234
|
11811 |
|
# define SQLITE_BIGENDIAN 0
|
11812 |
|
# define SQLITE_LITTLEENDIAN 1
|
11813 |
|
# 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
|
11814 |
11877 |
#endif
|
11815 |
|
#if (defined(sparc) || defined(__ppc__)) \
|
11816 |
|
&& !defined(SQLITE_RUNTIME_BYTEORDER)
|
11817 |
|
# define SQLITE_BYTEORDER 4321
|
|
11878 |
#if SQLITE_BYTEORDER==4321
|
11818 |
11879 |
# define SQLITE_BIGENDIAN 1
|
11819 |
11880 |
# define SQLITE_LITTLEENDIAN 0
|
11820 |
11881 |
# define SQLITE_UTF16NATIVE SQLITE_UTF16BE
|
11821 |
|
#endif
|
11822 |
|
#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
|
11823 |
11887 |
# ifdef SQLITE_AMALGAMATION
|
11824 |
11888 |
const int sqlite3one = 1;
|
11825 |
11889 |
# else
|
11826 |
11890 |
extern const int sqlite3one;
|
11827 |
11891 |
# endif
|
11828 |
|
# define SQLITE_BYTEORDER 0 /* 0 means "unknown at compile-time" */
|
11829 |
11892 |
# define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0)
|
11830 |
11893 |
# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1)
|
11831 |
11894 |
# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE)
|
... | ... | |
12348 |
12411 |
SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*);
|
12349 |
12412 |
SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);
|
12350 |
12413 |
|
12351 |
|
/* Allowed flags for the 2nd argument to sqlite3BtreeDelete() */
|
|
12414 |
/* Allowed flags for sqlite3BtreeDelete() and sqlite3BtreeInsert() */
|
12352 |
12415 |
#define BTREE_SAVEPOSITION 0x02 /* Leave cursor pointing at NEXT or PREV */
|
12353 |
12416 |
#define BTREE_AUXDELETE 0x04 /* not the primary delete operation */
|
|
12417 |
#define BTREE_APPEND 0x08 /* Insert is likely an append */
|
12354 |
12418 |
|
12355 |
12419 |
/* An instance of the BtreePayload object describes the content of a single
|
12356 |
12420 |
** entry in either an index or table btree.
|
... | ... | |
12381 |
12445 |
};
|
12382 |
12446 |
|
12383 |
12447 |
SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload,
|
12384 |
|
int bias, int seekResult);
|
|
12448 |
int flags, int seekResult);
|
12385 |
12449 |
SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes);
|
12386 |
12450 |
SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes);
|
12387 |
12451 |
SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes);
|
... | ... | |
12514 |
12578 |
struct VdbeOp {
|
12515 |
12579 |
u8 opcode; /* What operation to perform */
|
12516 |
12580 |
signed char p4type; /* One of the P4_xxx constants for p4 */
|
12517 |
|
u8 notUsed1;
|
12518 |
|
u8 p5; /* Fifth parameter is an unsigned character */
|
|
12581 |
u16 p5; /* Fifth parameter is an unsigned 16-bit integer */
|
12519 |
12582 |
int p1; /* First operand */
|
12520 |
12583 |
int p2; /* Second parameter (often the jump destination) */
|
12521 |
12584 |
int p3; /* The third parameter */
|
... | ... | |
12876 |
12939 |
SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, u32 addr, int P1);
|
12877 |
12940 |
SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, u32 addr, int P2);
|
12878 |
12941 |
SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, u32 addr, int P3);
|
12879 |
|
SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5);
|
|
12942 |
SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u16 P5);
|
12880 |
12943 |
SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr);
|
12881 |
12944 |
SQLITE_PRIVATE int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
|
12882 |
12945 |
SQLITE_PRIVATE int sqlite3VdbeDeletePriorOpcode(Vdbe*, u8 op);
|
... | ... | |
13178 |
13241 |
SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
|
13179 |
13242 |
SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
|
13180 |
13243 |
SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager, sqlite3*);
|
13181 |
|
SQLITE_PRIVATE int sqlite3PagerUseWal(Pager *pPager);
|
|
13244 |
# ifdef SQLITE_DIRECT_OVERFLOW_READ
|
|
13245 |
SQLITE_PRIVATE int sqlite3PagerUseWal(Pager *pPager, Pgno);
|
|
13246 |
# endif
|
13182 |
13247 |
# ifdef SQLITE_ENABLE_SNAPSHOT
|
13183 |
13248 |
SQLITE_PRIVATE int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);
|
13184 |
13249 |
SQLITE_PRIVATE int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);
|
13185 |
13250 |
SQLITE_PRIVATE int sqlite3PagerSnapshotRecover(Pager *pPager);
|
13186 |
13251 |
# endif
|
13187 |
13252 |
#else
|
13188 |
|
# define sqlite3PagerUseWal(x) 0
|
|
13253 |
# define sqlite3PagerUseWal(x,y) 0
|
13189 |
13254 |
#endif
|
13190 |
13255 |
|
13191 |
13256 |
#ifdef SQLITE_ENABLE_ZIPVFS
|
... | ... | |
14009 |
14074 |
u8 vtabOnConflict; /* Value to return for s3_vtab_on_conflict() */
|
14010 |
14075 |
u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */
|
14011 |
14076 |
u8 mTrace; /* zero or more SQLITE_TRACE flags */
|
|
14077 |
u8 skipBtreeMutex; /* True if no shared-cache backends */
|
14012 |
14078 |
int nextPagesize; /* Pagesize after VACUUM if >0 */
|
14013 |
14079 |
u32 magic; /* Magic number for detect library misuse */
|
14014 |
14080 |
int nChange; /* Value returned by sqlite3_changes() */
|
... | ... | |
14274 |
14340 |
#define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */
|
14275 |
14341 |
#define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
|
14276 |
14342 |
** single query - might change over time */
|
|
14343 |
#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
|
14277 |
14344 |
|
14278 |
14345 |
/*
|
14279 |
14346 |
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
|
... | ... | |
15280 |
15347 |
#define WHERE_SORTBYGROUP 0x0200 /* Support sqlite3WhereIsSorted() */
|
15281 |
15348 |
#define WHERE_SEEK_TABLE 0x0400 /* Do not defer seeks on main table */
|
15282 |
15349 |
#define WHERE_ORDERBY_LIMIT 0x0800 /* ORDERBY+LIMIT on the inner loop */
|
15283 |
|
/* 0x1000 not currently used */
|
|
15350 |
#define WHERE_SEEK_UNIQ_TABLE 0x1000 /* Do not defer seeks if unique */
|
15284 |
15351 |
/* 0x2000 not currently used */
|
15285 |
15352 |
#define WHERE_USE_LIMIT 0x4000 /* Use the LIMIT in cost estimates */
|
15286 |
15353 |
/* 0x8000 not currently used */
|
... | ... | |
15741 |
15808 |
#define OPFLAG_NCHANGE 0x01 /* OP_Insert: Set to update db->nChange */
|
15742 |
15809 |
/* Also used in P2 (not P5) of OP_Delete */
|
15743 |
15810 |
#define OPFLAG_EPHEM 0x01 /* OP_Column: Ephemeral output is ok */
|
15744 |
|
#define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */
|
|
15811 |
#define OPFLAG_LASTROWID 0x20 /* Set to update db->lastRowid */
|
15745 |
15812 |
#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
|
15746 |
15813 |
#define OPFLAG_APPEND 0x08 /* This is likely to be an append */
|
15747 |
15814 |
#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
|
15748 |
|
#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
|
15749 |
15815 |
#define OPFLAG_ISNOOP 0x40 /* OP_Delete does pre-update-hook only */
|
15750 |
|
#endif
|
15751 |
15816 |
#define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
|
15752 |
15817 |
#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
|
15753 |
15818 |
#define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */
|
... | ... | |
15755 |
15820 |
#define OPFLAG_FORDELETE 0x08 /* OP_Open should use BTREE_FORDELETE */
|
15756 |
15821 |
#define OPFLAG_P2ISREG 0x10 /* P2 to OP_Open** is a register number */
|
15757 |
15822 |
#define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */
|
15758 |
|
#define OPFLAG_SAVEPOSITION 0x02 /* OP_Delete: keep cursor position */
|
|
15823 |
#define OPFLAG_SAVEPOSITION 0x02 /* OP_Delete/Insert: save cursor pos */
|
15759 |
15824 |
#define OPFLAG_AUXDELETE 0x04 /* OP_Delete: index in a DELETE op */
|
15760 |
15825 |
|
15761 |
15826 |
/*
|
... | ... | |
16416 |
16481 |
SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
|
16417 |
16482 |
SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
|
16418 |
16483 |
SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
|
16419 |
|
SQLITE_PRIVATE void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8);
|
|
16484 |
SQLITE_PRIVATE int sqlite3ExprCodeAtInit(Parse*, Expr*, int);
|
16420 |
16485 |
SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
|
16421 |
16486 |
SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
|
16422 |
16487 |
SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
|
... | ... | |
16478 |
16543 |
SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse*,int);
|
16479 |
16544 |
SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(Parse*,Table*,int*,int,int,int,int,
|
16480 |
16545 |
u8,u8,int,int*,int*);
|
|
16546 |
#ifdef SQLITE_ENABLE_NULL_TRIM
|
|
16547 |
SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe*,Table*);
|
|
16548 |
#else
|
|
16549 |
# define sqlite3SetMakeRecordP5(A,B)
|
|
16550 |
#endif
|
16481 |
16551 |
SQLITE_PRIVATE void sqlite3CompleteInsertion(Parse*,Table*,int,int,int,int*,int,int,int);
|
16482 |
16552 |
SQLITE_PRIVATE int sqlite3OpenTableAndIndices(Parse*, Table*, int, u8, int, u8*, int*, int*);
|
16483 |
16553 |
SQLITE_PRIVATE void sqlite3BeginWriteOperation(Parse*, int, int);
|
... | ... | |
16756 |
16826 |
/*
|
16757 |
16827 |
** The interface to the LEMON-generated parser
|
16758 |
16828 |
*/
|
16759 |
|
SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64));
|
16760 |
|
SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*));
|
|
16829 |
#ifndef SQLITE_AMALGAMATION
|
|
16830 |
SQLITE_PRIVATE void *sqlite3ParserAlloc(void*(*)(u64));
|
|
16831 |
SQLITE_PRIVATE void sqlite3ParserFree(void*, void(*)(void*));
|
|
16832 |
#endif
|
16761 |
16833 |
SQLITE_PRIVATE void sqlite3Parser(void*, int, Token, Parse*);
|
16762 |
16834 |
#ifdef YYTRACKMAXSTACKDEPTH
|
16763 |
16835 |
SQLITE_PRIVATE int sqlite3ParserStackPeak(void*);
|
... | ... | |
16867 |
16939 |
#define sqlite3FkDropTable(a,b,c)
|
16868 |
16940 |
#define sqlite3FkOldmask(a,b) 0
|
16869 |
16941 |
#define sqlite3FkRequired(a,b,c,d) 0
|
|
16942 |
#define sqlite3FkReferences(a) 0
|
16870 |
16943 |
#endif
|
16871 |
16944 |
#ifndef SQLITE_OMIT_FOREIGN_KEY
|
16872 |
16945 |
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
|
... | ... | |
17197 |
17270 |
#endif
|
17198 |
17271 |
|
17199 |
17272 |
/*
|
|
17273 |
** The default lookaside-configuration, the format "SZ,N". SZ is the
|
|
17274 |
** number of bytes in each lookaside slot (should be a multiple of 8)
|
|
17275 |
** and N is the number of slots. The lookaside-configuration can be
|
|
17276 |
** changed as start-time using sqlite3_config(SQLITE_CONFIG_LOOKASIDE)
|
|
17277 |
** or at run-time for an individual database connection using
|
|
17278 |
** sqlite3_db_config(db, SQLITE_DBCONFIG_LOOKASIDE);
|
|
17279 |
*/
|
|
17280 |
#ifndef SQLITE_DEFAULT_LOOKASIDE
|
|
17281 |
# define SQLITE_DEFAULT_LOOKASIDE 1200,100
|
|
17282 |
#endif
|
|
17283 |
|
|
17284 |
|
|
17285 |
/*
|
17200 |
17286 |
** The following singleton contains the global configuration for
|
17201 |
17287 |
** the SQLite library.
|
17202 |
17288 |
*/
|
... | ... | |
17208 |
17294 |
SQLITE_ALLOW_COVERING_INDEX_SCAN, /* bUseCis */
|
17209 |
17295 |
0x7ffffffe, /* mxStrlen */
|
17210 |
17296 |
0, /* neverCorrupt */
|
17211 |
|
512, /* szLookaside */
|
17212 |
|
125, /* nLookaside */
|
|
17297 |
SQLITE_DEFAULT_LOOKASIDE, /* szLookaside, nLookaside */
|
17213 |
17298 |
SQLITE_STMTJRNL_SPILL, /* nStmtSpill */
|
17214 |
17299 |
{0,0,0,0,0,0,0,0}, /* m */
|
17215 |
17300 |
{0,0,0,0,0,0,0,0,0}, /* mutex */
|
... | ... | |
18221 |
18306 |
i64 iKey2; /* Second key value passed to hook */
|
18222 |
18307 |
Mem *aNew; /* Array of new.* values */
|
18223 |
18308 |
Table *pTab; /* Schema object being upated */
|
|
18309 |
Index *pPk; /* PK index if pTab is WITHOUT ROWID */
|
18224 |
18310 |
};
|
18225 |
18311 |
|
18226 |
18312 |
/*
|
... | ... | |
20621 |
20707 |
*/
|
20622 |
20708 |
static void *sqlite3MemMalloc(int nByte){
|
20623 |
20709 |
#ifdef SQLITE_MALLOCSIZE
|
20624 |
|
void *p = SQLITE_MALLOC( nByte );
|
|
20710 |
void *p;
|
|
20711 |
testcase( ROUND8(nByte)==nByte );
|
|
20712 |
p = SQLITE_MALLOC( nByte );
|
20625 |
20713 |
if( p==0 ){
|
20626 |
20714 |
testcase( sqlite3GlobalConfig.xLog!=0 );
|
20627 |
20715 |
sqlite3_log(SQLITE_NOMEM, "failed to allocate %u bytes of memory", nByte);
|
... | ... | |
20630 |
20718 |
#else
|
20631 |
20719 |
sqlite3_int64 *p;
|
20632 |
20720 |
assert( nByte>0 );
|
20633 |
|
nByte = ROUND8(nByte);
|
|
20721 |
testcase( ROUND8(nByte)!=nByte );
|
20634 |
20722 |
p = SQLITE_MALLOC( nByte+8 );
|
20635 |
20723 |
if( p ){
|
20636 |
20724 |
p[0] = nByte;
|
... | ... | |
23752 |
23840 |
SQLITE_MEMORY_BARRIER;
|
23753 |
23841 |
#elif defined(__GNUC__)
|
23754 |
23842 |
__sync_synchronize();
|
23755 |
|
#elif !defined(SQLITE_DISABLE_INTRINSIC) && \
|
23756 |
|
defined(_MSC_VER) && _MSC_VER>=1300
|
|
23843 |
#elif MSVC_VERSION>=1300
|
23757 |
23844 |
_ReadWriteBarrier();
|
23758 |
23845 |
#elif defined(MemoryBarrier)
|
23759 |
23846 |
MemoryBarrier();
|
... | ... | |
24285 |
24372 |
** Do a memory allocation with statistics and alarms. Assume the
|
24286 |
24373 |
** lock is already held.
|
24287 |
24374 |
*/
|
24288 |
|
static int mallocWithAlarm(int n, void **pp){
|
24289 |
|
int nFull;
|
|
24375 |
static void mallocWithAlarm(int n, void **pp){
|
24290 |
24376 |
void *p;
|
|
24377 |
int nFull;
|
24291 |
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. */
|
24292 |
24386 |
nFull = sqlite3GlobalConfig.m.xRoundup(n);
|
|
24387 |
|
24293 |
24388 |
sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, n);
|
24294 |
24389 |
if( mem0.alarmThreshold>0 ){
|
24295 |
24390 |
sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
|
... | ... | |
24313 |
24408 |
sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);
|
24314 |
24409 |
}
|
24315 |
24410 |
*pp = p;
|
24316 |
|
return nFull;
|
24317 |
24411 |
}
|
24318 |
24412 |
|
24319 |
24413 |
/*
|
... | ... | |
24953 |
25047 |
** Allowed values for et_info.flags
|
24954 |
25048 |
*/
|
24955 |
25049 |
#define FLAG_SIGNED 1 /* True if the value to convert is signed */
|
24956 |
|
#define FLAG_INTERN 2 /* True if for internal use only */
|
24957 |
25050 |
#define FLAG_STRING 4 /* Allow infinity precision */
|
24958 |
25051 |
|
24959 |
25052 |
|
... | ... | |
24987 |
25080 |
{ '%', 0, 0, etPERCENT, 0, 0 },
|
24988 |
25081 |
{ 'p', 16, 0, etPOINTER, 0, 1 },
|
24989 |
25082 |
|
24990 |
|
/* All the rest have the FLAG_INTERN bit set and are thus for internal
|
24991 |
|
** use only */
|
24992 |
|
{ 'T', 0, 2, etTOKEN, 0, 0 },
|
24993 |
|
{ 'S', 0, 2, etSRCLIST, 0, 0 },
|
24994 |
|
{ 'r', 10, 3, etORDINAL, 0, 0 },
|
|
25083 |
/* All the rest are undocumented and are for internal use only */
|
|
25084 |
{ 'T', 0, 0, etTOKEN, 0, 0 },
|
|
25085 |
{ 'S', 0, 0, etSRCLIST, 0, 0 },
|
|
25086 |
{ 'r', 10, 1, etORDINAL, 0, 0 },
|
24995 |
25087 |
};
|
24996 |
25088 |
|
24997 |
25089 |
/*
|
... | ... | |
25085 |
25177 |
etByte done; /* Loop termination flag */
|
25086 |
25178 |
etByte xtype = etINVALID; /* Conversion paradigm */
|
25087 |
25179 |
u8 bArgList; /* True for SQLITE_PRINTF_SQLFUNC */
|
25088 |
|
u8 useIntern; /* Ok to use internal conversions (ex: %T) */
|
25089 |
25180 |
char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */
|
25090 |
25181 |
sqlite_uint64 longvalue; /* Value for integer types */
|
25091 |
25182 |
LONGDOUBLE_TYPE realvalue; /* Value for real types */
|
... | ... | |
25104 |
25195 |
char buf[etBUFSIZE]; /* Conversion buffer */
|
25105 |
25196 |
|
25106 |
25197 |
bufpt = 0;
|
25107 |
|
if( pAccum->printfFlags ){
|
25108 |
|
if( (bArgList = (pAccum->printfFlags & SQLITE_PRINTF_SQLFUNC))!=0 ){
|
25109 |
|
pArgList = va_arg(ap, PrintfArguments*);
|
25110 |
|
}
|
25111 |
|
useIntern = pAccum->printfFlags & SQLITE_PRINTF_INTERNAL;
|
|
25198 |
if( (pAccum->printfFlags & SQLITE_PRINTF_SQLFUNC)!=0 ){
|
|
25199 |
pArgList = va_arg(ap, PrintfArguments*);
|
|
25200 |
bArgList = 1;
|
25112 |
25201 |
}else{
|
25113 |
|
bArgList = useIntern = 0;
|
|
25202 |
bArgList = 0;
|
25114 |
25203 |
}
|
25115 |
25204 |
for(; (c=(*fmt))!=0; ++fmt){
|
25116 |
25205 |
if( c!='%' ){
|
... | ... | |
25222 |
25311 |
for(idx=0; idx<ArraySize(fmtinfo); idx++){
|
25223 |
25312 |
if( c==fmtinfo[idx].fmttype ){
|
25224 |
25313 |
infop = &fmtinfo[idx];
|
25225 |
|
if( useIntern || (infop->flags & FLAG_INTERN)==0 ){
|
25226 |
|
xtype = infop->type;
|
25227 |
|
}else{
|
25228 |
|
return;
|
25229 |
|
}
|
|
25314 |
xtype = infop->type;
|
25230 |
25315 |
break;
|
25231 |
25316 |
}
|
25232 |
25317 |
}
|
... | ... | |
25595 |
25680 |
break;
|
25596 |
25681 |
}
|
25597 |
25682 |
case etTOKEN: {
|
25598 |
|
Token *pToken = va_arg(ap, Token*);
|
|
25683 |
Token *pToken;
|
|
25684 |
if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;
|
|
25685 |
pToken = va_arg(ap, Token*);
|
25599 |
25686 |
assert( bArgList==0 );
|
25600 |
25687 |
if( pToken && pToken->n ){
|
25601 |
25688 |
sqlite3StrAccumAppend(pAccum, (const char*)pToken->z, pToken->n);
|
... | ... | |
25604 |
25691 |
break;
|
25605 |
25692 |
}
|
25606 |
25693 |
case etSRCLIST: {
|
25607 |
|
SrcList *pSrc = va_arg(ap, SrcList*);
|
25608 |
|
int k = va_arg(ap, int);
|
25609 |
|
struct SrcList_item *pItem = &pSrc->a[k];
|
|
25694 |
SrcList *pSrc;
|
|
25695 |
int k;
|
|
25696 |
struct SrcList_item *pItem;
|
|
25697 |
if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;
|
|
25698 |
pSrc = va_arg(ap, SrcList*);
|
|
25699 |
k = va_arg(ap, int);
|
|
25700 |
pItem = &pSrc->a[k];
|
25610 |
25701 |
assert( bArgList==0 );
|
25611 |
25702 |
assert( k>=0 && k<pSrc->nSrc );
|
25612 |
25703 |
if( pItem->zDatabase ){
|
... | ... | |
25628 |
25719 |
** the output.
|
25629 |
25720 |
*/
|
25630 |
25721 |
width -= length;
|
25631 |
|
if( width>0 && !flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
|
25632 |
|
sqlite3StrAccumAppend(pAccum, bufpt, length);
|
25633 |
|
if( width>0 && flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
|
|
25722 |
if( width>0 ){
|
|
25723 |
if( !flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
|
|
25724 |
sqlite3StrAccumAppend(pAccum, bufpt, length);
|
|
25725 |
if( flag_leftjustify ) sqlite3AppendChar(pAccum, width, ' ');
|
|
25726 |
}else{
|
|
25727 |
sqlite3StrAccumAppend(pAccum, bufpt, length);
|
|
25728 |
}
|
25634 |
25729 |
|
25635 |
25730 |
if( zExtra ){
|
25636 |
25731 |
sqlite3DbFree(pAccum->db, zExtra);
|
... | ... | |
28602 |
28697 |
u32 x;
|
28603 |
28698 |
memcpy(&x,p,4);
|
28604 |
28699 |
return x;
|
28605 |
|
#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \
|
28606 |
|
&& defined(__GNUC__) && GCC_VERSION>=4003000
|
|
28700 |
#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000)
|
28607 |
28701 |
u32 x;
|
28608 |
28702 |
memcpy(&x,p,4);
|
28609 |
28703 |
return __builtin_bswap32(x);
|
28610 |
|
#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \
|
28611 |
|
&& defined(_MSC_VER) && _MSC_VER>=1300
|
|
28704 |
#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300
|
28612 |
28705 |
u32 x;
|
28613 |
28706 |
memcpy(&x,p,4);
|
28614 |
28707 |
return _byteswap_ulong(x);
|
... | ... | |
28620 |
28713 |
SQLITE_PRIVATE void sqlite3Put4byte(unsigned char *p, u32 v){
|
28621 |
28714 |
#if SQLITE_BYTEORDER==4321
|
28622 |
28715 |
memcpy(p,&v,4);
|
28623 |
|
#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \
|
28624 |
|
&& defined(__GNUC__) && GCC_VERSION>=4003000
|
|
28716 |
#elif SQLITE_BYTEORDER==1234 && (GCC_VERSION>=4003000 || CLANG_VERSION>=3000000)
|
28625 |
28717 |
u32 x = __builtin_bswap32(v);
|
28626 |
28718 |
memcpy(p,&x,4);
|
28627 |
|
#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \
|
28628 |
|
&& defined(_MSC_VER) && _MSC_VER>=1300
|
|
28719 |
#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300
|
28629 |
28720 |
u32 x = _byteswap_ulong(v);
|
28630 |
28721 |
memcpy(p,&x,4);
|
28631 |
28722 |
#else
|
... | ... | |
28741 |
28832 |
** overflow, leave *pA unchanged and return 1.
|
28742 |
28833 |
*/
|
28743 |
28834 |
SQLITE_PRIVATE int sqlite3AddInt64(i64 *pA, i64 iB){
|
|
28835 |
#if GCC_VERSION>=5004000 || CLANG_VERSION>=4000000
|
|
28836 |
return __builtin_add_overflow(*pA, iB, pA);
|
|
28837 |
#else
|
28744 |
28838 |
i64 iA = *pA;
|
28745 |
28839 |
testcase( iA==0 ); testcase( iA==1 );
|
28746 |
28840 |
testcase( iB==-1 ); testcase( iB==0 );
|
... | ... | |
28755 |
28849 |
}
|
28756 |
28850 |
*pA += iB;
|
28757 |
28851 |
return 0;
|
|
28852 |
#endif
|
28758 |
28853 |
}
|
28759 |
28854 |
SQLITE_PRIVATE int sqlite3SubInt64(i64 *pA, i64 iB){
|
|
28855 |
#if GCC_VERSION>=5004000 || CLANG_VERSION>=4000000
|
|
28856 |
return __builtin_sub_overflow(*pA, iB, pA);
|
|
28857 |
#else
|
28760 |
28858 |
testcase( iB==SMALLEST_INT64+1 );
|
28761 |
28859 |
if( iB==SMALLEST_INT64 ){
|
28762 |
28860 |
testcase( (*pA)==(-1) ); testcase( (*pA)==0 );
|
... | ... | |
28766 |
28864 |
}else{
|
28767 |
28865 |
return sqlite3AddInt64(pA, -iB);
|
28768 |
28866 |
}
|
|
28867 |
#endif
|
28769 |
28868 |
}
|
28770 |
28869 |
SQLITE_PRIVATE int sqlite3MulInt64(i64 *pA, i64 iB){
|
|
28870 |
#if GCC_VERSION>=5004000 || CLANG_VERSION>=4000000
|
|
28871 |
return __builtin_mul_overflow(*pA, iB, pA);
|
|
28872 |
#else
|
28771 |
28873 |
i64 iA = *pA;
|
28772 |
28874 |
if( iB>0 ){
|
28773 |
28875 |
if( iA>LARGEST_INT64/iB ) return 1;
|
... | ... | |
28783 |
28885 |
}
|
28784 |
28886 |
*pA = iA*iB;
|
28785 |
28887 |
return 0;
|
|
28888 |
#endif
|
28786 |
28889 |
}
|
28787 |
28890 |
|
28788 |
28891 |
/*
|
... | ... | |
47487 |
47590 |
#define isOpen(pFd) ((pFd)->pMethods!=0)
|
47488 |
47591 |
|
47489 |
47592 |
/*
|
47490 |
|
** Return true if this pager uses a write-ahead log instead of the usual
|
47491 |
|
** rollback journal. Otherwise false.
|
|
47593 |
** Return true if this pager uses a write-ahead log to read page pgno.
|
|
47594 |
** Return false if the pager reads pgno directly from the database.
|
47492 |
47595 |
*/
|
47493 |
|
#ifndef SQLITE_OMIT_WAL
|
47494 |
|
SQLITE_PRIVATE int sqlite3PagerUseWal(Pager *pPager){
|
47495 |
|
return (pPager->pWal!=0);
|
|
47596 |
#if !defined(SQLITE_OMIT_WAL) && defined(SQLITE_DIRECT_OVERFLOW_READ)
|
|
47597 |
SQLITE_PRIVATE int sqlite3PagerUseWal(Pager *pPager, Pgno pgno){
|
|
47598 |
u32 iRead = 0;
|
|
47599 |
int rc;
|
|
47600 |
if( pPager->pWal==0 ) return 0;
|
|
47601 |
rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
|
|
47602 |
return rc || iRead;
|
47496 |
47603 |
}
|
47497 |
|
# define pagerUseWal(x) sqlite3PagerUseWal(x)
|
|
47604 |
#endif
|
|
47605 |
#ifndef SQLITE_OMIT_WAL
|
|
47606 |
# define pagerUseWal(x) ((x)->pWal!=0)
|
47498 |
47607 |
#else
|
47499 |
47608 |
# define pagerUseWal(x) 0
|
47500 |
47609 |
# define pagerRollbackWal(x) 0
|
... | ... | |
58447 |
58556 |
*/
|
58448 |
58557 |
#if SQLITE_BYTEORDER==4321
|
58449 |
58558 |
# define get2byteAligned(x) (*(u16*)(x))
|
58450 |
|
#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \
|
58451 |
|
&& GCC_VERSION>=4008000
|
|
58559 |
#elif SQLITE_BYTEORDER==1234 && GCC_VERSION>=4008000
|
58452 |
58560 |
# define get2byteAligned(x) __builtin_bswap16(*(u16*)(x))
|
58453 |
|
#elif SQLITE_BYTEORDER==1234 && !defined(SQLITE_DISABLE_INTRINSIC) \
|
58454 |
|
&& defined(_MSC_VER) && _MSC_VER>=1300
|
|
58561 |
#elif SQLITE_BYTEORDER==1234 && MSVC_VERSION>=1300
|
58455 |
58562 |
# define get2byteAligned(x) _byteswap_ushort(*(u16*)(x))
|
58456 |
58563 |
#else
|
58457 |
58564 |
# define get2byteAligned(x) ((x)[0]<<8 | (x)[1])
|
... | ... | |
58626 |
58733 |
** two or more btrees in common both try to lock all their btrees
|
58627 |
58734 |
** at the same instant.
|
58628 |
58735 |
*/
|
58629 |
|
SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
|
|
58736 |
static void SQLITE_NOINLINE btreeEnterAll(sqlite3 *db){
|
58630 |
58737 |
int i;
|
|
58738 |
int skipOk = 1;
|
58631 |
58739 |
Btree *p;
|
58632 |
58740 |
assert( sqlite3_mutex_held(db->mutex) );
|
58633 |
58741 |
for(i=0; i<db->nDb; i++){
|
58634 |
58742 |
p = db->aDb[i].pBt;
|
58635 |
|
if( p ) sqlite3BtreeEnter(p);
|
|
58743 |
if( p && p->sharable ){
|
|
58744 |
sqlite3BtreeEnter(p);
|
|
58745 |
skipOk = 0;
|
|
58746 |
}
|
58636 |
58747 |
}
|
|
58748 |
db->skipBtreeMutex = skipOk;
|
58637 |
58749 |
}
|
58638 |
|
SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){
|
|
58750 |
SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3 *db){
|
|
58751 |
if( db->skipBtreeMutex==0 ) btreeEnterAll(db);
|
|
58752 |
}
|
|
58753 |
static void SQLITE_NOINLINE btreeLeaveAll(sqlite3 *db){
|
58639 |
58754 |
int i;
|
58640 |
58755 |
Btree *p;
|
58641 |
58756 |
assert( sqlite3_mutex_held(db->mutex) );
|
... | ... | |
58644 |
58759 |
if( p ) sqlite3BtreeLeave(p);
|
58645 |
58760 |
}
|
58646 |
58761 |
}
|
|
58762 |
SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){
|
|
58763 |
if( db->skipBtreeMutex==0 ) btreeLeaveAll(db);
|
|
58764 |
}
|
58647 |
58765 |
|
58648 |
58766 |
#ifndef NDEBUG
|
58649 |
58767 |
/*
|
... | ... | |
62099 |
62217 |
if( eType==PTRMAP_OVERFLOW1 ){
|
62100 |
62218 |
CellInfo info;
|
62101 |
62219 |
pPage->xParseCell(pPage, pCell, &info);
|
62102 |
|
if( info.nLocal<info.nPayload
|
62103 |
|
&& pCell+info.nSize-1<=pPage->aData+pPage->maskPage
|
62104 |
|
&& iFrom==get4byte(pCell+info.nSize-4)
|
62105 |
|
){
|
62106 |
|
put4byte(pCell+info.nSize-4, iTo);
|
62107 |
|
break;
|
|
62220 |
if( info.nLocal<info.nPayload ){
|
|
62221 |
if( pCell+info.nSize > pPage->aData+pPage->pBt->usableSize ){
|
|
62222 |
return SQLITE_CORRUPT_BKPT;
|
|
62223 |
}
|
|
62224 |
if( iFrom==get4byte(pCell+info.nSize-4) ){
|
|
62225 |
put4byte(pCell+info.nSize-4, iTo);
|
|
62226 |
break;
|
|
62227 |
}
|
62108 |
62228 |
}
|
62109 |
62229 |
}else{
|
62110 |
62230 |
if( get4byte(pCell)==iFrom ){
|
... | ... | |
62779 |
62899 |
assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
|
62780 |
62900 |
assert( iSavepoint>=0 || (iSavepoint==-1 && op==SAVEPOINT_ROLLBACK) );
|
62781 |
62901 |
sqlite3BtreeEnter(p);
|
62782 |
|
rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);
|
|
62902 |
if( op==SAVEPOINT_ROLLBACK ){
|
|
62903 |
rc = saveAllCursors(pBt, 0, 0);
|
|
62904 |
}
|
|
62905 |
if( rc==SQLITE_OK ){
|
|
62906 |
rc = sqlite3PagerSavepoint(pBt->pPager, op, iSavepoint);
|
|
62907 |
}
|
62783 |
62908 |
if( rc==SQLITE_OK ){
|
62784 |
62909 |
if( iSavepoint<0 && (pBt->btsFlags & BTS_INITIALLY_EMPTY)!=0 ){
|
62785 |
62910 |
pBt->nPage = 0;
|
... | ... | |
63165 |
63290 |
**
|
63166 |
63291 |
** 0: The operation is a read. Populate the overflow cache.
|
63167 |
63292 |
** 1: The operation is a write. Populate the overflow cache.
|
63168 |
|
** 2: The operation is a read. Do not populate the overflow cache.
|
63169 |
63293 |
**
|
63170 |
63294 |
** A total of "amt" bytes are read or written beginning at "offset".
|
63171 |
63295 |
** Data is read to or from the buffer pBuf.
|
... | ... | |
63173 |
63297 |
** The content being read or written might appear on the main page
|
63174 |
63298 |
** or be scattered out on multiple overflow pages.
|
63175 |
63299 |
**
|
63176 |
|
** If the current cursor entry uses one or more overflow pages and the
|
63177 |
|
** eOp argument is not 2, this function may allocate space for and lazily
|
63178 |
|
** populates the overflow page-list cache array (BtCursor.aOverflow).
|
|
63300 |
** If the current cursor entry uses one or more overflow pages
|
|
63301 |
** this function may allocate space for and lazily populate
|
|
63302 |
** the overflow page-list cache array (BtCursor.aOverflow).
|
63179 |
63303 |
** Subsequent calls use this cache to make seeking to the supplied offset
|
63180 |
63304 |
** more efficient.
|
63181 |
63305 |
**
|
63182 |
|
** Once an overflow page-list cache has been allocated, it may be
|
|
63306 |
** Once an overflow page-list cache has been allocated, it must be
|
63183 |
63307 |
** invalidated if some other cursor writes to the same table, or if
|
63184 |
63308 |
** the cursor is moved to a different row. Additionally, in auto-vacuum
|
63185 |
63309 |
** mode, the following events may invalidate an overflow page-list cache.
|
... | ... | |
63201 |
63325 |
MemPage *pPage = pCur->apPage[pCur->iPage]; /* Btree page of current entry */
|
63202 |
63326 |
BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */
|
63203 |
63327 |
#ifdef SQLITE_DIRECT_OVERFLOW_READ
|
63204 |
|
unsigned char * const pBufStart = pBuf;
|
63205 |
|
int bEnd; /* True if reading to end of data */
|
|
63328 |
unsigned char * const pBufStart = pBuf; /* Start of original out buffer */
|
63206 |
63329 |
#endif
|
63207 |
63330 |
|
63208 |
63331 |
assert( pPage );
|
|
63332 |
assert( eOp==0 || eOp==1 );
|
63209 |
63333 |
assert( pCur->eState==CURSOR_VALID );
|
63210 |
63334 |
assert( pCur->aiIdx[pCur->iPage]<pPage->nCell );
|
63211 |
63335 |
assert( cursorHoldsMutex(pCur) );
|
63212 |
|
assert( eOp!=2 || offset==0 ); /* Always start from beginning for eOp==2 */
|
63213 |
63336 |
|
63214 |
63337 |
getCellInfo(pCur);
|
63215 |
63338 |
aPayload = pCur->info.pPayload;
|
63216 |
|
#ifdef SQLITE_DIRECT_OVERFLOW_READ
|
63217 |
|
bEnd = offset+amt==pCur->info.nPayload;
|
63218 |
|
#endif
|
63219 |
63339 |
assert( offset+amt <= pCur->info.nPayload );
|
63220 |
63340 |
|
63221 |
63341 |
assert( aPayload > pPage->aData );
|
... | ... | |
63234 |
63354 |
if( a+offset>pCur->info.nLocal ){
|
63235 |
63355 |
a = pCur->info.nLocal - offset;
|
63236 |
63356 |
}
|
63237 |
|
rc = copyPayload(&aPayload[offset], pBuf, a, (eOp & 0x01), pPage->pDbPage);
|
|
63357 |
rc = copyPayload(&aPayload[offset], pBuf, a, eOp, pPage->pDbPage);
|
63238 |
63358 |
offset = 0;
|
63239 |
63359 |
pBuf += a;
|
63240 |
63360 |
amt -= a;
|
... | ... | |
63250 |
63370 |
nextPage = get4byte(&aPayload[pCur->info.nLocal]);
|
63251 |
63371 |
|
63252 |
63372 |
/* If the BtCursor.aOverflow[] has not been allocated, allocate it now.
|
63253 |
|
** Except, do not allocate aOverflow[] for eOp==2.
|
63254 |
63373 |
**
|
63255 |
63374 |
** The aOverflow[] array is sized at one entry for each overflow page
|
63256 |
63375 |
** in the overflow chain. The page number of the first overflow page is
|
63257 |
63376 |
** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array
|
63258 |
63377 |
** means "not yet known" (the cache is lazily populated).
|
63259 |
63378 |
*/
|
63260 |
|
if( eOp!=2 && (pCur->curFlags & BTCF_ValidOvfl)==0 ){
|
|
63379 |
if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){
|
63261 |
63380 |
int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;
|
63262 |
63381 |
if( nOvfl>pCur->nOvflAlloc ){
|
63263 |
63382 |
Pgno *aNew = (Pgno*)sqlite3Realloc(
|
63264 |
63383 |
pCur->aOverflow, nOvfl*2*sizeof(Pgno)
|
63265 |
63384 |
);
|
63266 |
63385 |
if( aNew==0 ){
|
63267 |
|
rc = SQLITE_NOMEM_BKPT;
|
|
63386 |
return SQLITE_NOMEM_BKPT;
|
63268 |
63387 |
}else{
|
63269 |
63388 |
pCur->nOvflAlloc = nOvfl*2;
|
63270 |
63389 |
pCur->aOverflow = aNew;
|
63271 |
63390 |
}
|
63272 |
63391 |
}
|
63273 |
|
if( rc==SQLITE_OK ){
|
63274 |
|
memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));
|
63275 |
|
pCur->curFlags |= BTCF_ValidOvfl;
|
|
63392 |
memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno));
|
|
63393 |
pCur->curFlags |= BTCF_ValidOvfl;
|
|
63394 |
}else{
|
|
63395 |
/* If the overflow page-list cache has been allocated and the
|
|
63396 |
** entry for the first required overflow page is valid, skip
|
|
63397 |
** directly to it.
|
|
63398 |
*/
|
|
63399 |
if( pCur->aOverflow[offset/ovflSize] ){
|
|
63400 |
iIdx = (offset/ovflSize);
|
|
63401 |
nextPage = pCur->aOverflow[iIdx];
|
|
63402 |
offset = (offset%ovflSize);
|
63276 |
63403 |
}
|
63277 |
63404 |
}
|
63278 |
63405 |
|
63279 |
|
/* If the overflow page-list cache has been allocated and the
|
63280 |
|
** entry for the first required overflow page is valid, skip
|
63281 |
|
** directly to it.
|
63282 |
|
*/
|
63283 |
|
if( (pCur->curFlags & BTCF_ValidOvfl)!=0
|
63284 |
|
&& pCur->aOverflow[offset/ovflSize]
|
63285 |
|
){
|
63286 |
|
iIdx = (offset/ovflSize);
|
63287 |
|
nextPage = pCur->aOverflow[iIdx];
|
63288 |
|
offset = (offset%ovflSize);
|
63289 |
|
}
|
63290 |
|
|
63291 |
|
for( ; rc==SQLITE_OK && amt>0 && nextPage; iIdx++){
|
63292 |
|
|
|
63406 |
assert( rc==SQLITE_OK && amt>0 );
|
|
63407 |
while( nextPage ){
|
63293 |
63408 |
/* If required, populate the overflow page-list cache. */
|
63294 |
|
if( (pCur->curFlags & BTCF_ValidOvfl)!=0 ){
|
63295 |
|
assert( pCur->aOverflow[iIdx]==0
|
63296 |
|
|| pCur->aOverflow[iIdx]==nextPage
|
63297 |
|
|| CORRUPT_DB );
|
63298 |
|
pCur->aOverflow[iIdx] = nextPage;
|
63299 |
|
}
|
|
63409 |
assert( pCur->aOverflow[iIdx]==0
|
|
63410 |
|| pCur->aOverflow[iIdx]==nextPage
|
|
63411 |
|| CORRUPT_DB );
|
|
63412 |
pCur->aOverflow[iIdx] = nextPage;
|
63300 |
63413 |
|
63301 |
63414 |
if( offset>=ovflSize ){
|
63302 |
63415 |
/* The only reason to read this page is to obtain the page
|
... | ... | |
63304 |
63417 |
** data is not required. So first try to lookup the overflow
|
63305 |
63418 |
** page-list cache, if any, then fall back to the getOverflowPage()
|
63306 |
63419 |
** function.
|
63307 |
|
**
|
63308 |
|
** Note that the aOverflow[] array must be allocated because eOp!=2
|
63309 |
|
** here. If eOp==2, then offset==0 and this branch is never taken.
|
63310 |
63420 |
*/
|
63311 |
|
assert( eOp!=2 );
|
63312 |
63421 |
assert( pCur->curFlags & BTCF_ValidOvfl );
|
63313 |
63422 |
assert( pCur->pBtree->db==pBt->db );
|
63314 |
63423 |
if( pCur->aOverflow[iIdx+1] ){
|
... | ... | |
63322 |
63431 |
** range of data that is being read (eOp==0) or written (eOp!=0).
|
63323 |
63432 |
*/
|
63324 |
63433 |
#ifdef SQLITE_DIRECT_OVERFLOW_READ
|
63325 |
|
sqlite3_file *fd;
|
|
63434 |
sqlite3_file *fd; /* File from which to do direct overflow read */
|
63326 |
63435 |
#endif
|
63327 |
63436 |
int a = amt;
|
63328 |
63437 |
if( a + offset > ovflSize ){
|
... | ... | |
63334 |
63443 |
**
|
63335 |
63444 |
** 1) this is a read operation, and
|
63336 |
63445 |
** 2) data is required from the start of this overflow page, and
|
63337 |
|
** 3) the database is file-backed, and
|
63338 |
|
** 4) there is no open write-transaction, and
|
63339 |
|
** 5) the database is not a WAL database,
|
63340 |
|
** 6) all data from the page is being read.
|
63341 |
|
** 7) at least 4 bytes have already been read into the output buffer
|
|
63446 |
** 3) there is no open write-transaction, and
|
|
63447 |
** 4) the database is file-backed, and
|
|
63448 |
** 5) the page is not in the WAL file
|
|
63449 |
** 6) at least 4 bytes have already been read into the output buffer
|
63342 |
63450 |
**
|
63343 |
63451 |
** then data can be read directly from the database file into the
|
63344 |
63452 |
** output buffer, bypassing the page-cache altogether. This speeds
|
63345 |
63453 |
** up loading large records that span many overflow pages.
|
63346 |
63454 |
*/
|
63347 |
|
if( (eOp&0x01)==0 /* (1) */
|
|
63455 |
if( eOp==0 /* (1) */
|
63348 |
63456 |
&& offset==0 /* (2) */
|
63349 |
|
&& (bEnd || a==ovflSize) /* (6) */
|
63350 |
|
&& pBt->inTransaction==TRANS_READ /* (4) */
|
63351 |
|
&& (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (3) */
|
63352 |
|
&& 0==sqlite3PagerUseWal(pBt->pPager) /* (5) */
|
63353 |
|
&& &pBuf[-4]>=pBufStart /* (7) */
|
|
63457 |
&& pBt->inTransaction==TRANS_READ /* (3) */
|
|
63458 |
&& (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (4) */
|
|
63459 |
&& 0==sqlite3PagerUseWal(pBt->pPager, nextPage) /* (5) */
|
|
63460 |
&& &pBuf[-4]>=pBufStart /* (6) */
|
63354 |
63461 |
){
|
63355 |
63462 |
u8 aSave[4];
|
63356 |
63463 |
u8 *aWrite = &pBuf[-4];
|
63357 |
|
assert( aWrite>=pBufStart ); /* hence (7) */
|
|
63464 |
assert( aWrite>=pBufStart ); /* due to (6) */
|
63358 |
63465 |
memcpy(aSave, aWrite, 4);
|
63359 |
63466 |
rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
|
63360 |
63467 |
nextPage = get4byte(aWrite);
|
... | ... | |
63365 |
63472 |
{
|
63366 |
63473 |
DbPage *pDbPage;
|
63367 |
63474 |
rc = sqlite3PagerGet(pBt->pPager, nextPage, &pDbPage,
|
63368 |
|
((eOp&0x01)==0 ? PAGER_GET_READONLY : 0)
|
|
63475 |
(eOp==0 ? PAGER_GET_READONLY : 0)
|
63369 |
63476 |
);
|
63370 |
63477 |
if( rc==SQLITE_OK ){
|
63371 |
63478 |
aPayload = sqlite3PagerGetData(pDbPage);
|
63372 |
63479 |
nextPage = get4byte(aPayload);
|
63373 |
|
rc = copyPayload(&aPayload[offset+4], pBuf, a, (eOp&0x01), pDbPage);
|
|
63480 |
rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage);
|
63374 |
63481 |
sqlite3PagerUnref(pDbPage);
|
63375 |
63482 |
offset = 0;
|
63376 |
63483 |
}
|
63377 |
63484 |
}
|
63378 |
63485 |
amt -= a;
|
|
63486 |
if( amt==0 ) return rc;
|
63379 |
63487 |
pBuf += a;
|
63380 |
63488 |
}
|
|
63489 |
if( rc ) break;
|
|
63490 |
iIdx++;
|
63381 |
63491 |
}
|
63382 |
63492 |
}
|
63383 |
63493 |
|
63384 |
63494 |
if( rc==SQLITE_OK && amt>0 ){
|
63385 |
|
return SQLITE_CORRUPT_BKPT;
|
|
63495 |
return SQLITE_CORRUPT_BKPT; /* Overflow chain ends prematurely */
|
63386 |
63496 |
}
|
63387 |
63497 |
return rc;
|
63388 |
63498 |
}
|
... | ... | |
63411 |
63521 |
assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
|
63412 |
63522 |
return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0);
|
63413 |
63523 |
}
|
|
63524 |
|
|
63525 |
/*
|
|
63526 |
** This variant of sqlite3BtreePayload() works even if the cursor has not
|
|
63527 |
** in the CURSOR_VALID state. It is only used by the sqlite3_blob_read()
|
|
63528 |
** interface.
|
|
63529 |
*/
|
63414 |
63530 |
#ifndef SQLITE_OMIT_INCRBLOB
|
63415 |
|
SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
|
63531 |
static SQLITE_NOINLINE int accessPayloadChecked(
|
|
63532 |
BtCursor *pCur,
|
|
63533 |
u32 offset,
|
|
63534 |
u32 amt,
|
|
63535 |
void *pBuf
|
|
63536 |
){
|
63416 |
63537 |
int rc;
|
63417 |
63538 |
if ( pCur->eState==CURSOR_INVALID ){
|
63418 |
63539 |
return SQLITE_ABORT;
|
63419 |
63540 |
}
|
63420 |
63541 |
assert( cursorOwnsBtShared(pCur) );
|
63421 |
|
rc = restoreCursorPosition(pCur);
|
63422 |
|
if( rc==SQLITE_OK ){
|
63423 |
|
assert( pCur->eState==CURSOR_VALID );
|
63424 |
|
assert( pCur->iPage>=0 && pCur->apPage[pCur->iPage] );
|
63425 |
|
assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
|
63426 |
|
rc = accessPayload(pCur, offset, amt, pBuf, 0);
|
|
63542 |
rc = btreeRestoreCursorPosition(pCur);
|
|
63543 |
return rc ? rc : accessPayload(pCur, offset, amt, pBuf, 0);
|
|
63544 |
}
|
|
63545 |
SQLITE_PRIVATE int sqlite3BtreePayloadChecked(BtCursor *pCur, u32 offset, u32 amt, void *pBuf){
|
|
63546 |
if( pCur->eState==CURSOR_VALID ){
|
|
63547 |
assert( cursorOwnsBtShared(pCur) );
|
|
63548 |
return accessPayload(pCur, offset, amt, pBuf, 0);
|
|
63549 |
}else{
|
|
63550 |
return accessPayloadChecked(pCur, offset, amt, pBuf);
|
63427 |
63551 |
}
|
63428 |
|
return rc;
|
63429 |
63552 |
}
|
63430 |
63553 |
#endif /* SQLITE_OMIT_INCRBLOB */
|
63431 |
63554 |
|
... | ... | |
63831 |
63954 |
*pRes = 0;
|
63832 |
63955 |
return SQLITE_OK;
|
63833 |
63956 |
}
|
63834 |
|
if( (pCur->curFlags & BTCF_AtLast)!=0 && pCur->info.nKey<intKey ){
|
63835 |
|
*pRes = -1;
|
63836 |
|
return SQLITE_OK;
|
|
63957 |
if( pCur->info.nKey<intKey ){
|
|
63958 |
if( (pCur->curFlags & BTCF_AtLast)!=0 ){
|
|
63959 |
*pRes = -1;
|
|
63960 |
return SQLITE_OK;
|
|
63961 |
}
|
|
63962 |
/* If the requested key is one more than the previous key, then
|
|
63963 |
** try to get there using sqlite3BtreeNext() rather than a full
|
|
63964 |
** binary search. This is an optimization only. The correct answer
|
|
63965 |
** is still obtained without this ase, only a little more slowely */
|
|
63966 |
if( pCur->info.nKey+1==intKey && !pCur->skipNext ){
|
|
63967 |
*pRes = 0;
|
|
63968 |
rc = sqlite3BtreeNext(pCur, pRes);
|
|
63969 |
if( rc ) return rc;
|
|
63970 |
if( *pRes==0 ){
|
|
63971 |
getCellInfo(pCur);
|
|
63972 |
if( pCur->info.nKey==intKey ){
|
|
63973 |
return SQLITE_OK;
|
|
63974 |
}
|
|
63975 |
}
|
|
63976 |
}
|
63837 |
63977 |
}
|
63838 |
63978 |
}
|
63839 |
63979 |
|
... | ... | |
63969 |
64109 |
goto moveto_finish;
|
63970 |
64110 |
}
|
63971 |
64111 |
pCur->aiIdx[pCur->iPage] = (u16)idx;
|
63972 |
|
rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 2);
|
|
64112 |
rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
|
|
64113 |
pCur->curFlags &= ~BTCF_ValidOvfl;
|
63973 |
64114 |
if( rc ){
|
63974 |
64115 |
sqlite3_free(pCellKey);
|
63975 |
64116 |
goto moveto_finish;
|
... | ... | |
66012 |
66153 |
for(i=0; i<nOld; i++){
|
66013 |
66154 |
MemPage *p = apOld[i];
|
66014 |
66155 |
szNew[i] = usableSpace - p->nFree;
|
66015 |
|
if( szNew[i]<0 ){ rc = SQLITE_CORRUPT_BKPT; goto balance_cleanup; }
|
66016 |
66156 |
for(j=0; j<p->nOverflow; j++){
|
66017 |
66157 |
szNew[i] += 2 + p->xCellSize(p, p->apOvfl[j]);
|
66018 |
66158 |
}
|
... | ... | |
66691 |
66831 |
SQLITE_PRIVATE int sqlite3BtreeInsert(
|
66692 |
66832 |
BtCursor *pCur, /* Insert data into the table of this cursor */
|
66693 |
66833 |
const BtreePayload *pX, /* Content of the row to be inserted */
|
66694 |
|
int appendBias, /* True if this is likely an append */
|
|
66834 |
int flags, /* True if this is likely an append */
|
66695 |
66835 |
int seekResult /* Result of prior MovetoUnpacked() call */
|
66696 |
66836 |
){
|
66697 |
66837 |
int rc;
|
... | ... | |
66704 |
66844 |
unsigned char *oldCell;
|
66705 |
66845 |
unsigned char *newCell = 0;
|
66706 |
66846 |
|
|
66847 |
assert( (flags & (BTREE_SAVEPOSITION|BTREE_APPEND))==flags );
|
|
66848 |
|
66707 |
66849 |
if( pCur->eState==CURSOR_FAULT ){
|
66708 |
66850 |
assert( pCur->skipNext!=SQLITE_OK );
|
66709 |
66851 |
return pCur->skipNext;
|
... | ... | |
66744 |
66886 |
** cursors open on the row being replaced */
|
66745 |
66887 |
invalidateIncrblobCursors(p, pX->nKey, 0);
|
66746 |
66888 |
|
|
66889 |
/* If BTREE_SAVEPOSITION is set, the cursor must already be pointing
|
|
66890 |
** to a row with the same key as the new entry being inserted. */
|
|
66891 |
assert( (flags & BTREE_SAVEPOSITION)==0 ||
|
|
66892 |
((pCur->curFlags&BTCF_ValidNKey)!=0 && pX->nKey==pCur->info.nKey) );
|
|
66893 |
|
66747 |
66894 |
/* If the cursor is currently on the last row and we are appending a
|
66748 |
66895 |
** new row onto the end, set the "loc" to avoid an unnecessary
|
66749 |
66896 |
** btreeMoveto() call */
|
... | ... | |
66753 |
66900 |
&& pCur->info.nKey==pX->nKey-1 ){
|
66754 |
66901 |
loc = -1;
|
66755 |
66902 |
}else if( loc==0 ){
|
66756 |
|
rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, appendBias, &loc);
|
|
66903 |
rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);
|
66757 |
66904 |
if( rc ) return rc;
|
66758 |
66905 |
}
|
66759 |
|
}else if( loc==0 ){
|
|
66906 |
}else if( loc==0 && (flags & BTREE_SAVEPOSITION)==0 ){
|
66760 |
66907 |
if( pX->nMem ){
|
66761 |
66908 |
UnpackedRecord r;
|
66762 |
66909 |
r.pKeyInfo = pCur->pKeyInfo;
|
... | ... | |
66767 |
66914 |
r.r1 = 0;
|
66768 |
66915 |
r.r2 = 0;
|
66769 |
66916 |
r.eqSeen = 0;
|
66770 |
|
rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, appendBias, &loc);
|
|
66917 |
rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);
|
66771 |
66918 |
}else{
|
66772 |
|
rc = btreeMoveto(pCur, pX->pKey, pX->nKey, appendBias, &loc);
|
|
66919 |
rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);
|
66773 |
66920 |
}
|
66774 |
66921 |
if( rc ) return rc;
|
66775 |
66922 |
}
|
... | ... | |
66857 |
67004 |
** from trying to save the current position of the cursor. */
|
66858 |
67005 |
pCur->apPage[pCur->iPage]->nOverflow = 0;
|
66859 |
67006 |
pCur->eState = CURSOR_INVALID;
|
|
67007 |
if( (flags & BTREE_SAVEPOSITION) && rc==SQLITE_OK ){
|
|
67008 |
rc = moveToRoot(pCur);
|
|
67009 |
if( pCur->pKeyInfo ){
|
|
67010 |
assert( pCur->pKey==0 );
|
|
67011 |
pCur->pKey = sqlite3Malloc( pX->nKey );
|
|
67012 |
if( pCur->pKey==0 ){
|
|
67013 |
rc = SQLITE_NOMEM;
|
|
67014 |
}else{
|
|
67015 |
memcpy(pCur->pKey, pX->pKey, pX->nKey);
|