Fossil SCM
Merge into trunk from experimental the lookaside hit and miss stats associated with the --sqltrace option.
Commit
b41d0f61204a36150fe0ce415bbfb20ac7219be4
Parent
1bea7f6959795ef…
5 files changed
+6
+177
-78
+177
-78
+75
-25
+75
-25
M
src/db.c
+6
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -945,10 +945,16 @@ | ||
| 945 | 945 | if( g.db==0 ) return; |
| 946 | 946 | if( g.fSqlTrace ){ |
| 947 | 947 | int cur, hiwtr; |
| 948 | 948 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &cur, &hiwtr, 0); |
| 949 | 949 | fprintf(stderr, "-- LOOKASIDE_USED %10d %10d\n", cur, hiwtr); |
| 950 | + sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &cur, &hiwtr, 0); | |
| 951 | + fprintf(stderr, "-- LOOKASIDE_HIT %10d\n", hiwtr); | |
| 952 | + sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &cur,&hiwtr,0); | |
| 953 | + fprintf(stderr, "-- LOOKASIDE_MISS_SIZE %10d\n", hiwtr); | |
| 954 | + sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &cur,&hiwtr,0); | |
| 955 | + fprintf(stderr, "-- LOOKASIDE_MISS_FULL %10d\n", hiwtr); | |
| 950 | 956 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_USED, &cur, &hiwtr, 0); |
| 951 | 957 | fprintf(stderr, "-- CACHE_USED %10d\n", cur); |
| 952 | 958 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_SCHEMA_USED, &cur, &hiwtr, 0); |
| 953 | 959 | fprintf(stderr, "-- SCHEMA_USED %10d\n", cur); |
| 954 | 960 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_STMT_USED, &cur, &hiwtr, 0); |
| 955 | 961 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -945,10 +945,16 @@ | |
| 945 | if( g.db==0 ) return; |
| 946 | if( g.fSqlTrace ){ |
| 947 | int cur, hiwtr; |
| 948 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &cur, &hiwtr, 0); |
| 949 | fprintf(stderr, "-- LOOKASIDE_USED %10d %10d\n", cur, hiwtr); |
| 950 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_USED, &cur, &hiwtr, 0); |
| 951 | fprintf(stderr, "-- CACHE_USED %10d\n", cur); |
| 952 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_SCHEMA_USED, &cur, &hiwtr, 0); |
| 953 | fprintf(stderr, "-- SCHEMA_USED %10d\n", cur); |
| 954 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_STMT_USED, &cur, &hiwtr, 0); |
| 955 |
| --- src/db.c | |
| +++ src/db.c | |
| @@ -945,10 +945,16 @@ | |
| 945 | if( g.db==0 ) return; |
| 946 | if( g.fSqlTrace ){ |
| 947 | int cur, hiwtr; |
| 948 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &cur, &hiwtr, 0); |
| 949 | fprintf(stderr, "-- LOOKASIDE_USED %10d %10d\n", cur, hiwtr); |
| 950 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &cur, &hiwtr, 0); |
| 951 | fprintf(stderr, "-- LOOKASIDE_HIT %10d\n", hiwtr); |
| 952 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &cur,&hiwtr,0); |
| 953 | fprintf(stderr, "-- LOOKASIDE_MISS_SIZE %10d\n", hiwtr); |
| 954 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &cur,&hiwtr,0); |
| 955 | fprintf(stderr, "-- LOOKASIDE_MISS_FULL %10d\n", hiwtr); |
| 956 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_CACHE_USED, &cur, &hiwtr, 0); |
| 957 | fprintf(stderr, "-- CACHE_USED %10d\n", cur); |
| 958 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_SCHEMA_USED, &cur, &hiwtr, 0); |
| 959 | fprintf(stderr, "-- SCHEMA_USED %10d\n", cur); |
| 960 | sqlite3_db_status(g.db, SQLITE_DBSTATUS_STMT_USED, &cur, &hiwtr, 0); |
| 961 |
+177
-78
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -650,11 +650,11 @@ | ||
| 650 | 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | 652 | */ |
| 653 | 653 | #define SQLITE_VERSION "3.7.4" |
| 654 | 654 | #define SQLITE_VERSION_NUMBER 3007004 |
| 655 | -#define SQLITE_SOURCE_ID "2010-12-06 21:09:59 fabcb6b95e1d4059d1e6c6183f65846f6cbd5749" | |
| 655 | +#define SQLITE_SOURCE_ID "2010-12-21 21:28:38 b0888047bb6d9ac55e29b9224df2ff650728bb78" | |
| 656 | 656 | |
| 657 | 657 | /* |
| 658 | 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | 660 | ** |
| @@ -1256,10 +1256,15 @@ | ||
| 1256 | 1256 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 1257 | 1257 | ** point to an integer (type int) containing the new chunk-size to use |
| 1258 | 1258 | ** for the nominated database. Allocating database file space in large |
| 1259 | 1259 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 1260 | 1260 | ** improve performance on some systems. |
| 1261 | +** | |
| 1262 | +** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer | |
| 1263 | +** to the [sqlite3_file] object associated with a particular database | |
| 1264 | +** connection. See the [sqlite3_file_control()] documentation for | |
| 1265 | +** additional information. | |
| 1261 | 1266 | */ |
| 1262 | 1267 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1263 | 1268 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1264 | 1269 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1265 | 1270 | #define SQLITE_LAST_ERRNO 4 |
| @@ -3191,18 +3196,35 @@ | ||
| 3191 | 3196 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 3192 | 3197 | |
| 3193 | 3198 | /* |
| 3194 | 3199 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 3195 | 3200 | ** |
| 3196 | -** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if | |
| 3197 | -** the [prepared statement] X is [SELECT] statement and false (zero) if | |
| 3198 | -** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], | |
| 3199 | -** [ALTER], or [REINDEX] statement. | |
| 3200 | -** If X is a NULL pointer or any other kind of statement, including but | |
| 3201 | -** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], | |
| 3202 | -** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is | |
| 3203 | -** undefined. | |
| 3201 | +** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if | |
| 3202 | +** and only if the [prepared statement] X is makes no direct changes to | |
| 3203 | +** the content of the database file. | |
| 3204 | +** | |
| 3205 | +** Note that [application-defined SQL functions] or | |
| 3206 | +** [virtual tables] might change the database indirectly as a side effect. | |
| 3207 | +** ^(For example, if an application defines a function "eval()" that | |
| 3208 | +** calls [sqlite3_exec()], then the following SQL statement would | |
| 3209 | +** change the database file through side-effects: | |
| 3210 | +** | |
| 3211 | +** <blockquote><pre> | |
| 3212 | +** SELECT eval('DELETE FROM t1') FROM t2; | |
| 3213 | +** </pre></blockquote> | |
| 3214 | +** | |
| 3215 | +** But because the [SELECT] statement does not change the database file | |
| 3216 | +** directly, sqlite3_stmt_readonly() would still return true.)^ | |
| 3217 | +** | |
| 3218 | +** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], | |
| 3219 | +** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, | |
| 3220 | +** since the statements themselves do not actually modify the database but | |
| 3221 | +** rather they control the timing of when other statements modify the | |
| 3222 | +** database. ^The [ATTACH] and [DETACH] statements also cause | |
| 3223 | +** sqlite3_stmt_readonly() to return true since, while those statements | |
| 3224 | +** change the configuration of a database connection, they do not make | |
| 3225 | +** changes to the content of the database files on disk. | |
| 3204 | 3226 | */ |
| 3205 | 3227 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 3206 | 3228 | |
| 3207 | 3229 | /* |
| 3208 | 3230 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5927,11 +5949,12 @@ | ||
| 5927 | 5949 | ** internal equivalents). Only the value returned in the |
| 5928 | 5950 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5929 | 5951 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5930 | 5952 | ** |
| 5931 | 5953 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5932 | -** <dd>This parameter records the number of separate memory allocations.</dd>)^ | |
| 5954 | +** <dd>This parameter records the number of separate memory allocations | |
| 5955 | +** currently checked out.</dd>)^ | |
| 5933 | 5956 | ** |
| 5934 | 5957 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5935 | 5958 | ** <dd>This parameter returns the number of pages used out of the |
| 5936 | 5959 | ** [pagecache memory allocator] that was configured using |
| 5937 | 5960 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -6032,10 +6055,32 @@ | ||
| 6032 | 6055 | ** |
| 6033 | 6056 | ** <dl> |
| 6034 | 6057 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 6035 | 6058 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 6036 | 6059 | ** checked out.</dd>)^ |
| 6060 | +** | |
| 6061 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> | |
| 6062 | +** <dd>This parameter returns the number malloc attempts that were | |
| 6063 | +** satisfied using lookaside memory. Only the high-water value is meaningful; | |
| 6064 | +** the current value is always zero. | |
| 6065 | +** checked out.</dd>)^ | |
| 6066 | +** | |
| 6067 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> | |
| 6068 | +** <dd>This parameter returns the number malloc attempts that might have | |
| 6069 | +** been satisfied using lookaside memory but failed due to the amount of | |
| 6070 | +** memory requested being larger than the lookaside slot size. | |
| 6071 | +** Only the high-water value is meaningful; | |
| 6072 | +** the current value is always zero. | |
| 6073 | +** checked out.</dd>)^ | |
| 6074 | +** | |
| 6075 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> | |
| 6076 | +** <dd>This parameter returns the number malloc attempts that might have | |
| 6077 | +** been satisfied using lookaside memory but failed due to all lookaside | |
| 6078 | +** memory already being in use. | |
| 6079 | +** Only the high-water value is meaningful; | |
| 6080 | +** the current value is always zero. | |
| 6081 | +** checked out.</dd>)^ | |
| 6037 | 6082 | ** |
| 6038 | 6083 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 6039 | 6084 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6040 | 6085 | ** memory used by all pager caches associated with the database connection.)^ |
| 6041 | 6086 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -6055,15 +6100,18 @@ | ||
| 6055 | 6100 | ** the database connection.)^ |
| 6056 | 6101 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 6057 | 6102 | ** </dd> |
| 6058 | 6103 | ** </dl> |
| 6059 | 6104 | */ |
| 6060 | -#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 | |
| 6061 | -#define SQLITE_DBSTATUS_CACHE_USED 1 | |
| 6062 | -#define SQLITE_DBSTATUS_SCHEMA_USED 2 | |
| 6063 | -#define SQLITE_DBSTATUS_STMT_USED 3 | |
| 6064 | -#define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ | |
| 6105 | +#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 | |
| 6106 | +#define SQLITE_DBSTATUS_CACHE_USED 1 | |
| 6107 | +#define SQLITE_DBSTATUS_SCHEMA_USED 2 | |
| 6108 | +#define SQLITE_DBSTATUS_STMT_USED 3 | |
| 6109 | +#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 | |
| 6110 | +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 | |
| 6111 | +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 | |
| 6112 | +#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ | |
| 6065 | 6113 | |
| 6066 | 6114 | |
| 6067 | 6115 | /* |
| 6068 | 6116 | ** CAPI3REF: Prepared Statement Status |
| 6069 | 6117 | ** |
| @@ -6307,15 +6355,16 @@ | ||
| 6307 | 6355 | ** It is useful either for creating backups of databases or |
| 6308 | 6356 | ** for copying in-memory databases to or from persistent files. |
| 6309 | 6357 | ** |
| 6310 | 6358 | ** See Also: [Using the SQLite Online Backup API] |
| 6311 | 6359 | ** |
| 6312 | -** ^Exclusive access is required to the destination database for the | |
| 6313 | -** duration of the operation. ^However the source database is only | |
| 6314 | -** read-locked while it is actually being read; it is not locked | |
| 6315 | -** continuously for the entire backup operation. ^Thus, the backup may be | |
| 6316 | -** performed on a live source database without preventing other users from | |
| 6360 | +** ^SQLite holds a write transaction open on the destination database file | |
| 6361 | +** for the duration of the backup operation. | |
| 6362 | +** ^The source database is read-locked only while it is being read; | |
| 6363 | +** it is not locked continuously for the entire backup operation. | |
| 6364 | +** ^Thus, the backup may be performed on a live source database without | |
| 6365 | +** preventing other database connections from | |
| 6317 | 6366 | ** reading or writing to the source database while the backup is underway. |
| 6318 | 6367 | ** |
| 6319 | 6368 | ** ^(To perform a backup operation: |
| 6320 | 6369 | ** <ol> |
| 6321 | 6370 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -6338,15 +6387,15 @@ | ||
| 6338 | 6387 | ** an [ATTACH] statement for an attached database. |
| 6339 | 6388 | ** ^The S and M arguments passed to |
| 6340 | 6389 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 6341 | 6390 | ** and database name of the source database, respectively. |
| 6342 | 6391 | ** ^The source and destination [database connections] (parameters S and D) |
| 6343 | -** must be different or else sqlite3_backup_init(D,N,S,M) will file with | |
| 6392 | +** must be different or else sqlite3_backup_init(D,N,S,M) will fail with | |
| 6344 | 6393 | ** an error. |
| 6345 | 6394 | ** |
| 6346 | 6395 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 6347 | -** returned and an error code and error message are store3d in the | |
| 6396 | +** returned and an error code and error message are stored in the | |
| 6348 | 6397 | ** destination [database connection] D. |
| 6349 | 6398 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 6350 | 6399 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 6351 | 6400 | ** [sqlite3_errmsg16()] functions. |
| 6352 | 6401 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -6359,11 +6408,11 @@ | ||
| 6359 | 6408 | ** |
| 6360 | 6409 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 6361 | 6410 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 6362 | 6411 | ** ^If N is negative, all remaining source pages are copied. |
| 6363 | 6412 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 6364 | -** are still more pages to be copied, then the function resturns [SQLITE_OK]. | |
| 6413 | +** are still more pages to be copied, then the function returns [SQLITE_OK]. | |
| 6365 | 6414 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 6366 | 6415 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 6367 | 6416 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 6368 | 6417 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 6369 | 6418 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -6373,11 +6422,11 @@ | ||
| 6373 | 6422 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 6374 | 6423 | ** <ol> |
| 6375 | 6424 | ** <li> the destination database was opened read-only, or |
| 6376 | 6425 | ** <li> the destination database is using write-ahead-log journaling |
| 6377 | 6426 | ** and the destination and source page sizes differ, or |
| 6378 | -** <li> The destination database is an in-memory database and the | |
| 6427 | +** <li> the destination database is an in-memory database and the | |
| 6379 | 6428 | ** destination and source page sizes differ. |
| 6380 | 6429 | ** </ol>)^ |
| 6381 | 6430 | ** |
| 6382 | 6431 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 6383 | 6432 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6704,11 +6753,12 @@ | ||
| 6704 | 6753 | ** |
| 6705 | 6754 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6706 | 6755 | ** from SQL. |
| 6707 | 6756 | ** |
| 6708 | 6757 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6709 | -** enabled with a threshold of 1000 pages. The use of this interface | |
| 6758 | +** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] | |
| 6759 | +** pages. The use of this interface | |
| 6710 | 6760 | ** is only necessary if the default setting is found to be suboptimal |
| 6711 | 6761 | ** for a particular application. |
| 6712 | 6762 | */ |
| 6713 | 6763 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6714 | 6764 | |
| @@ -8875,10 +8925,11 @@ | ||
| 8875 | 8925 | u16 sz; /* Size of each buffer in bytes */ |
| 8876 | 8926 | u8 bEnabled; /* False to disable new lookaside allocations */ |
| 8877 | 8927 | u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ |
| 8878 | 8928 | int nOut; /* Number of buffers currently checked out */ |
| 8879 | 8929 | int mxOut; /* Highwater mark for nOut */ |
| 8930 | + int anStat[3]; /* 0: hits. 1: size misses. 2: full misses */ | |
| 8880 | 8931 | LookasideSlot *pFree; /* List of available buffers */ |
| 8881 | 8932 | void *pStart; /* First byte of available memory space */ |
| 8882 | 8933 | void *pEnd; /* First byte past end of available space */ |
| 8883 | 8934 | }; |
| 8884 | 8935 | struct LookasideSlot { |
| @@ -12506,10 +12557,26 @@ | ||
| 12506 | 12557 | if( resetFlag ){ |
| 12507 | 12558 | db->lookaside.mxOut = db->lookaside.nOut; |
| 12508 | 12559 | } |
| 12509 | 12560 | break; |
| 12510 | 12561 | } |
| 12562 | + | |
| 12563 | + case SQLITE_DBSTATUS_LOOKASIDE_HIT: | |
| 12564 | + case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: | |
| 12565 | + case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: { | |
| 12566 | + testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT ); | |
| 12567 | + testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE ); | |
| 12568 | + testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL ); | |
| 12569 | + assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 ); | |
| 12570 | + assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 ); | |
| 12571 | + *pCurrent = 0; | |
| 12572 | + *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT]; | |
| 12573 | + if( resetFlag ){ | |
| 12574 | + db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0; | |
| 12575 | + } | |
| 12576 | + break; | |
| 12577 | + } | |
| 12511 | 12578 | |
| 12512 | 12579 | /* |
| 12513 | 12580 | ** Return an approximation for the amount of memory currently used |
| 12514 | 12581 | ** by all pagers associated with the given database connection. The |
| 12515 | 12582 | ** highwater mark is meaningless and is returned as zero. |
| @@ -18068,18 +18135,24 @@ | ||
| 18068 | 18135 | if( db ){ |
| 18069 | 18136 | LookasideSlot *pBuf; |
| 18070 | 18137 | if( db->mallocFailed ){ |
| 18071 | 18138 | return 0; |
| 18072 | 18139 | } |
| 18073 | - if( db->lookaside.bEnabled && n<=db->lookaside.sz | |
| 18074 | - && (pBuf = db->lookaside.pFree)!=0 ){ | |
| 18075 | - db->lookaside.pFree = pBuf->pNext; | |
| 18076 | - db->lookaside.nOut++; | |
| 18077 | - if( db->lookaside.nOut>db->lookaside.mxOut ){ | |
| 18078 | - db->lookaside.mxOut = db->lookaside.nOut; | |
| 18079 | - } | |
| 18080 | - return (void*)pBuf; | |
| 18140 | + if( db->lookaside.bEnabled ){ | |
| 18141 | + if( n>db->lookaside.sz ){ | |
| 18142 | + db->lookaside.anStat[1]++; | |
| 18143 | + }else if( (pBuf = db->lookaside.pFree)==0 ){ | |
| 18144 | + db->lookaside.anStat[2]++; | |
| 18145 | + }else{ | |
| 18146 | + db->lookaside.pFree = pBuf->pNext; | |
| 18147 | + db->lookaside.nOut++; | |
| 18148 | + db->lookaside.anStat[0]++; | |
| 18149 | + if( db->lookaside.nOut>db->lookaside.mxOut ){ | |
| 18150 | + db->lookaside.mxOut = db->lookaside.nOut; | |
| 18151 | + } | |
| 18152 | + return (void*)pBuf; | |
| 18153 | + } | |
| 18081 | 18154 | } |
| 18082 | 18155 | } |
| 18083 | 18156 | #else |
| 18084 | 18157 | if( db && db->mallocFailed ){ |
| 18085 | 18158 | return 0; |
| @@ -28391,22 +28464,23 @@ | ||
| 28391 | 28464 | |
| 28392 | 28465 | /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN |
| 28393 | 28466 | ** bytes of writable memory. |
| 28394 | 28467 | */ |
| 28395 | 28468 | static int proxyGetHostID(unsigned char *pHostID, int *pError){ |
| 28396 | - struct timespec timeout = {1, 0}; /* 1 sec timeout */ | |
| 28397 | - | |
| 28398 | 28469 | assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); |
| 28399 | 28470 | memset(pHostID, 0, PROXY_HOSTIDLEN); |
| 28400 | 28471 | #if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\ |
| 28401 | 28472 | && __MAC_OS_X_VERSION_MIN_REQUIRED<1050 |
| 28402 | - if( gethostuuid(pHostID, &timeout) ){ | |
| 28403 | - int err = errno; | |
| 28404 | - if( pError ){ | |
| 28405 | - *pError = err; | |
| 28473 | + { | |
| 28474 | + static const struct timespec timeout = {1, 0}; /* 1 sec timeout */ | |
| 28475 | + if( gethostuuid(pHostID, &timeout) ){ | |
| 28476 | + int err = errno; | |
| 28477 | + if( pError ){ | |
| 28478 | + *pError = err; | |
| 28479 | + } | |
| 28480 | + return SQLITE_IOERR; | |
| 28406 | 28481 | } |
| 28407 | - return SQLITE_IOERR; | |
| 28408 | 28482 | } |
| 28409 | 28483 | #endif |
| 28410 | 28484 | #ifdef SQLITE_TEST |
| 28411 | 28485 | /* simulate multiple hosts by creating unique hostid file paths */ |
| 28412 | 28486 | if( sqlite3_hostid_num != 0){ |
| @@ -41896,18 +41970,18 @@ | ||
| 41896 | 41970 | ** |
| 41897 | 41971 | ** This functionality is used by the checkpoint code (see walCheckpoint()). |
| 41898 | 41972 | */ |
| 41899 | 41973 | struct WalIterator { |
| 41900 | 41974 | int iPrior; /* Last result returned from the iterator */ |
| 41901 | - int nSegment; /* Size of the aSegment[] array */ | |
| 41975 | + int nSegment; /* Number of entries in aSegment[] */ | |
| 41902 | 41976 | struct WalSegment { |
| 41903 | 41977 | int iNext; /* Next slot in aIndex[] not yet returned */ |
| 41904 | 41978 | ht_slot *aIndex; /* i0, i1, i2... such that aPgno[iN] ascend */ |
| 41905 | 41979 | u32 *aPgno; /* Array of page numbers. */ |
| 41906 | - int nEntry; /* Max size of aPgno[] and aIndex[] arrays */ | |
| 41980 | + int nEntry; /* Nr. of entries in aPgno[] and aIndex[] */ | |
| 41907 | 41981 | int iZero; /* Frame number associated with aPgno[0] */ |
| 41908 | - } aSegment[1]; /* One for every 32KB page in the WAL */ | |
| 41982 | + } aSegment[1]; /* One for every 32KB page in the wal-index */ | |
| 41909 | 41983 | }; |
| 41910 | 41984 | |
| 41911 | 41985 | /* |
| 41912 | 41986 | ** Define the parameters of the hash tables in the wal-index file. There |
| 41913 | 41987 | ** is a hash-table following every HASHTABLE_NPAGE page numbers in the |
| @@ -42767,13 +42841,33 @@ | ||
| 42767 | 42841 | return (iRet==0xFFFFFFFF); |
| 42768 | 42842 | } |
| 42769 | 42843 | |
| 42770 | 42844 | /* |
| 42771 | 42845 | ** This function merges two sorted lists into a single sorted list. |
| 42846 | +** | |
| 42847 | +** aLeft[] and aRight[] are arrays of indices. The sort key is | |
| 42848 | +** aContent[aLeft[]] and aContent[aRight[]]. Upon entry, the following | |
| 42849 | +** is guaranteed for all J<K: | |
| 42850 | +** | |
| 42851 | +** aContent[aLeft[J]] < aContent[aLeft[K]] | |
| 42852 | +** aContent[aRight[J]] < aContent[aRight[K]] | |
| 42853 | +** | |
| 42854 | +** This routine overwrites aRight[] with a new (probably longer) sequence | |
| 42855 | +** of indices such that the aRight[] contains every index that appears in | |
| 42856 | +** either aLeft[] or the old aRight[] and such that the second condition | |
| 42857 | +** above is still met. | |
| 42858 | +** | |
| 42859 | +** The aContent[aLeft[X]] values will be unique for all X. And the | |
| 42860 | +** aContent[aRight[X]] values will be unique too. But there might be | |
| 42861 | +** one or more combinations of X and Y such that | |
| 42862 | +** | |
| 42863 | +** aLeft[X]!=aRight[Y] && aContent[aLeft[X]] == aContent[aRight[Y]] | |
| 42864 | +** | |
| 42865 | +** When that happens, omit the aLeft[X] and use the aRight[Y] index. | |
| 42772 | 42866 | */ |
| 42773 | 42867 | static void walMerge( |
| 42774 | - u32 *aContent, /* Pages in wal */ | |
| 42868 | + const u32 *aContent, /* Pages in wal - keys for the sort */ | |
| 42775 | 42869 | ht_slot *aLeft, /* IN: Left hand input list */ |
| 42776 | 42870 | int nLeft, /* IN: Elements in array *paLeft */ |
| 42777 | 42871 | ht_slot **paRight, /* IN/OUT: Right hand input list */ |
| 42778 | 42872 | int *pnRight, /* IN/OUT: Elements in *paRight */ |
| 42779 | 42873 | ht_slot *aTmp /* Temporary buffer */ |
| @@ -42809,14 +42903,28 @@ | ||
| 42809 | 42903 | *pnRight = iOut; |
| 42810 | 42904 | memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut); |
| 42811 | 42905 | } |
| 42812 | 42906 | |
| 42813 | 42907 | /* |
| 42814 | -** Sort the elements in list aList, removing any duplicates. | |
| 42908 | +** Sort the elements in list aList using aContent[] as the sort key. | |
| 42909 | +** Remove elements with duplicate keys, preferring to keep the | |
| 42910 | +** larger aList[] values. | |
| 42911 | +** | |
| 42912 | +** The aList[] entries are indices into aContent[]. The values in | |
| 42913 | +** aList[] are to be sorted so that for all J<K: | |
| 42914 | +** | |
| 42915 | +** aContent[aList[J]] < aContent[aList[K]] | |
| 42916 | +** | |
| 42917 | +** For any X and Y such that | |
| 42918 | +** | |
| 42919 | +** aContent[aList[X]] == aContent[aList[Y]] | |
| 42920 | +** | |
| 42921 | +** Keep the larger of the two values aList[X] and aList[Y] and discard | |
| 42922 | +** the smaller. | |
| 42815 | 42923 | */ |
| 42816 | 42924 | static void walMergesort( |
| 42817 | - u32 *aContent, /* Pages in wal */ | |
| 42925 | + const u32 *aContent, /* Pages in wal */ | |
| 42818 | 42926 | ht_slot *aBuffer, /* Buffer of at least *pnList items to use */ |
| 42819 | 42927 | ht_slot *aList, /* IN/OUT: List to sort */ |
| 42820 | 42928 | int *pnList /* IN/OUT: Number of elements in aList[] */ |
| 42821 | 42929 | ){ |
| 42822 | 42930 | struct Sublist { |
| @@ -42877,10 +42985,11 @@ | ||
| 42877 | 42985 | } |
| 42878 | 42986 | |
| 42879 | 42987 | /* |
| 42880 | 42988 | ** Construct a WalInterator object that can be used to loop over all |
| 42881 | 42989 | ** pages in the WAL in ascending order. The caller must hold the checkpoint |
| 42990 | +** lock. | |
| 42882 | 42991 | ** |
| 42883 | 42992 | ** On success, make *pp point to the newly allocated WalInterator object |
| 42884 | 42993 | ** return SQLITE_OK. Otherwise, return an error code. If this routine |
| 42885 | 42994 | ** returns an error, the value of *pp is undefined. |
| 42886 | 42995 | ** |
| @@ -43011,11 +43120,12 @@ | ||
| 43011 | 43120 | volatile WalCkptInfo *pInfo; /* The checkpoint status information */ |
| 43012 | 43121 | |
| 43013 | 43122 | szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16); |
| 43014 | 43123 | testcase( szPage<=32768 ); |
| 43015 | 43124 | testcase( szPage>=65536 ); |
| 43016 | - if( pWal->hdr.mxFrame==0 ) return SQLITE_OK; | |
| 43125 | + pInfo = walCkptInfo(pWal); | |
| 43126 | + if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK; | |
| 43017 | 43127 | |
| 43018 | 43128 | /* Allocate the iterator */ |
| 43019 | 43129 | rc = walIteratorInit(pWal, &pIter); |
| 43020 | 43130 | if( rc!=SQLITE_OK ){ |
| 43021 | 43131 | return rc; |
| @@ -43033,11 +43143,10 @@ | ||
| 43033 | 43143 | ** overwrite database pages that are in use by active readers and thus |
| 43034 | 43144 | ** cannot be backfilled from the WAL. |
| 43035 | 43145 | */ |
| 43036 | 43146 | mxSafeFrame = pWal->hdr.mxFrame; |
| 43037 | 43147 | mxPage = pWal->hdr.nPage; |
| 43038 | - pInfo = walCkptInfo(pWal); | |
| 43039 | 43148 | for(i=1; i<WAL_NREADER; i++){ |
| 43040 | 43149 | u32 y = pInfo->aReadMark[i]; |
| 43041 | 43150 | if( mxSafeFrame>=y ){ |
| 43042 | 43151 | assert( y<=pWal->hdr.mxFrame ); |
| 43043 | 43152 | rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| @@ -55556,11 +55665,11 @@ | ||
| 55556 | 55665 | u8 opcode = pOp->opcode; |
| 55557 | 55666 | |
| 55558 | 55667 | pOp->opflags = sqlite3OpcodeProperty[opcode]; |
| 55559 | 55668 | if( opcode==OP_Function || opcode==OP_AggStep ){ |
| 55560 | 55669 | if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; |
| 55561 | - }else if( opcode==OP_Transaction && pOp->p2!=0 ){ | |
| 55670 | + }else if( (opcode==OP_Transaction && pOp->p2!=0) || opcode==OP_Vacuum ){ | |
| 55562 | 55671 | p->readOnly = 0; |
| 55563 | 55672 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 55564 | 55673 | }else if( opcode==OP_VUpdate ){ |
| 55565 | 55674 | if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; |
| 55566 | 55675 | }else if( opcode==OP_VFilter ){ |
| @@ -80921,13 +81030,13 @@ | ||
| 80921 | 81030 | if( caseSensitive ){ |
| 80922 | 81031 | pInfo = (struct compareInfo*)&likeInfoAlt; |
| 80923 | 81032 | }else{ |
| 80924 | 81033 | pInfo = (struct compareInfo*)&likeInfoNorm; |
| 80925 | 81034 | } |
| 80926 | - sqlite3CreateFunc(db, "like", 2, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); | |
| 80927 | - sqlite3CreateFunc(db, "like", 3, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); | |
| 80928 | - sqlite3CreateFunc(db, "glob", 2, SQLITE_ANY, | |
| 81035 | + sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); | |
| 81036 | + sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); | |
| 81037 | + sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, | |
| 80929 | 81038 | (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0); |
| 80930 | 81039 | setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); |
| 80931 | 81040 | setLikeOptFlag(db, "like", |
| 80932 | 81041 | caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE); |
| 80933 | 81042 | } |
| @@ -97673,14 +97782,13 @@ | ||
| 97673 | 97782 | Parse *pParse, |
| 97674 | 97783 | Expr *pExpr, |
| 97675 | 97784 | u8 aff, |
| 97676 | 97785 | sqlite3_value **pp |
| 97677 | 97786 | ){ |
| 97678 | - /* The evalConstExpr() function will have already converted any TK_VARIABLE | |
| 97679 | - ** expression involved in an comparison into a TK_REGISTER. */ | |
| 97680 | - assert( pExpr->op!=TK_VARIABLE ); | |
| 97681 | - if( pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE ){ | |
| 97787 | + if( pExpr->op==TK_VARIABLE | |
| 97788 | + || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) | |
| 97789 | + ){ | |
| 97682 | 97790 | int iVar = pExpr->iColumn; |
| 97683 | 97791 | sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-23257-02778 */ |
| 97684 | 97792 | *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); |
| 97685 | 97793 | return SQLITE_OK; |
| 97686 | 97794 | } |
| @@ -106470,10 +106578,13 @@ | ||
| 106470 | 106578 | | SQLITE_LoadExtension |
| 106471 | 106579 | #endif |
| 106472 | 106580 | #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS |
| 106473 | 106581 | | SQLITE_RecTriggers |
| 106474 | 106582 | #endif |
| 106583 | +#if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS | |
| 106584 | + | SQLITE_ForeignKeys | |
| 106585 | +#endif | |
| 106475 | 106586 | ; |
| 106476 | 106587 | sqlite3HashInit(&db->aCollSeq); |
| 106477 | 106588 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 106478 | 106589 | sqlite3HashInit(&db->aModule); |
| 106479 | 106590 | #endif |
| @@ -111307,13 +111418,20 @@ | ||
| 111307 | 111418 | int iCol /* Column of requested pos-list */ |
| 111308 | 111419 | ){ |
| 111309 | 111420 | assert( pExpr->isLoaded ); |
| 111310 | 111421 | if( pExpr->aDoclist ){ |
| 111311 | 111422 | char *pEnd = &pExpr->aDoclist[pExpr->nDoclist]; |
| 111312 | - char *pCsr = pExpr->pCurrent; | |
| 111423 | + char *pCsr; | |
| 111313 | 111424 | |
| 111425 | + if( pExpr->pCurrent==0 ){ | |
| 111426 | + pExpr->pCurrent = pExpr->aDoclist; | |
| 111427 | + pExpr->iCurrent = 0; | |
| 111428 | + pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent,&pExpr->iCurrent); | |
| 111429 | + } | |
| 111430 | + pCsr = pExpr->pCurrent; | |
| 111314 | 111431 | assert( pCsr ); |
| 111432 | + | |
| 111315 | 111433 | while( pCsr<pEnd ){ |
| 111316 | 111434 | if( pExpr->iCurrent<iDocid ){ |
| 111317 | 111435 | fts3PoslistCopy(0, &pCsr); |
| 111318 | 111436 | if( pCsr<pEnd ){ |
| 111319 | 111437 | fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent); |
| @@ -117513,11 +117631,11 @@ | ||
| 117513 | 117631 | /* |
| 117514 | 117632 | ** This is an fts3ExprIterate() callback used while loading the doclists |
| 117515 | 117633 | ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also |
| 117516 | 117634 | ** fts3ExprLoadDoclists(). |
| 117517 | 117635 | */ |
| 117518 | -static int fts3ExprLoadDoclistsCb1(Fts3Expr *pExpr, int iPhrase, void *ctx){ | |
| 117636 | +static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){ | |
| 117519 | 117637 | int rc = SQLITE_OK; |
| 117520 | 117638 | LoadDoclistCtx *p = (LoadDoclistCtx *)ctx; |
| 117521 | 117639 | |
| 117522 | 117640 | UNUSED_PARAMETER(iPhrase); |
| 117523 | 117641 | |
| @@ -117533,26 +117651,10 @@ | ||
| 117533 | 117651 | } |
| 117534 | 117652 | |
| 117535 | 117653 | return rc; |
| 117536 | 117654 | } |
| 117537 | 117655 | |
| 117538 | -/* | |
| 117539 | -** This is an fts3ExprIterate() callback used while loading the doclists | |
| 117540 | -** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also | |
| 117541 | -** fts3ExprLoadDoclists(). | |
| 117542 | -*/ | |
| 117543 | -static int fts3ExprLoadDoclistsCb2(Fts3Expr *pExpr, int iPhrase, void *ctx){ | |
| 117544 | - UNUSED_PARAMETER(iPhrase); | |
| 117545 | - UNUSED_PARAMETER(ctx); | |
| 117546 | - if( pExpr->aDoclist ){ | |
| 117547 | - pExpr->pCurrent = pExpr->aDoclist; | |
| 117548 | - pExpr->iCurrent = 0; | |
| 117549 | - pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent, &pExpr->iCurrent); | |
| 117550 | - } | |
| 117551 | - return SQLITE_OK; | |
| 117552 | -} | |
| 117553 | - | |
| 117554 | 117656 | /* |
| 117555 | 117657 | ** Load the doclists for each phrase in the query associated with FTS3 cursor |
| 117556 | 117658 | ** pCsr. |
| 117557 | 117659 | ** |
| 117558 | 117660 | ** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable |
| @@ -117567,14 +117669,11 @@ | ||
| 117567 | 117669 | int *pnToken /* OUT: Number of tokens in query */ |
| 117568 | 117670 | ){ |
| 117569 | 117671 | int rc; /* Return Code */ |
| 117570 | 117672 | LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */ |
| 117571 | 117673 | sCtx.pCsr = pCsr; |
| 117572 | - rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb1, (void *)&sCtx); | |
| 117573 | - if( rc==SQLITE_OK ){ | |
| 117574 | - (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb2, 0); | |
| 117575 | - } | |
| 117674 | + rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx); | |
| 117576 | 117675 | if( pnPhrase ) *pnPhrase = sCtx.nPhrase; |
| 117577 | 117676 | if( pnToken ) *pnToken = sCtx.nToken; |
| 117578 | 117677 | return rc; |
| 117579 | 117678 | } |
| 117580 | 117679 | |
| 117581 | 117680 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.4" |
| 654 | #define SQLITE_VERSION_NUMBER 3007004 |
| 655 | #define SQLITE_SOURCE_ID "2010-12-06 21:09:59 fabcb6b95e1d4059d1e6c6183f65846f6cbd5749" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -1256,10 +1256,15 @@ | |
| 1256 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 1257 | ** point to an integer (type int) containing the new chunk-size to use |
| 1258 | ** for the nominated database. Allocating database file space in large |
| 1259 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 1260 | ** improve performance on some systems. |
| 1261 | */ |
| 1262 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1263 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1264 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1265 | #define SQLITE_LAST_ERRNO 4 |
| @@ -3191,18 +3196,35 @@ | |
| 3191 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 3192 | |
| 3193 | /* |
| 3194 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 3195 | ** |
| 3196 | ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if |
| 3197 | ** the [prepared statement] X is [SELECT] statement and false (zero) if |
| 3198 | ** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], |
| 3199 | ** [ALTER], or [REINDEX] statement. |
| 3200 | ** If X is a NULL pointer or any other kind of statement, including but |
| 3201 | ** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], |
| 3202 | ** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is |
| 3203 | ** undefined. |
| 3204 | */ |
| 3205 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 3206 | |
| 3207 | /* |
| 3208 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5927,11 +5949,12 @@ | |
| 5927 | ** internal equivalents). Only the value returned in the |
| 5928 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5929 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5930 | ** |
| 5931 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5932 | ** <dd>This parameter records the number of separate memory allocations.</dd>)^ |
| 5933 | ** |
| 5934 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5935 | ** <dd>This parameter returns the number of pages used out of the |
| 5936 | ** [pagecache memory allocator] that was configured using |
| 5937 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -6032,10 +6055,32 @@ | |
| 6032 | ** |
| 6033 | ** <dl> |
| 6034 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 6035 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 6036 | ** checked out.</dd>)^ |
| 6037 | ** |
| 6038 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 6039 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6040 | ** memory used by all pager caches associated with the database connection.)^ |
| 6041 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -6055,15 +6100,18 @@ | |
| 6055 | ** the database connection.)^ |
| 6056 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 6057 | ** </dd> |
| 6058 | ** </dl> |
| 6059 | */ |
| 6060 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 6061 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 6062 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 6063 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 6064 | #define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ |
| 6065 | |
| 6066 | |
| 6067 | /* |
| 6068 | ** CAPI3REF: Prepared Statement Status |
| 6069 | ** |
| @@ -6307,15 +6355,16 @@ | |
| 6307 | ** It is useful either for creating backups of databases or |
| 6308 | ** for copying in-memory databases to or from persistent files. |
| 6309 | ** |
| 6310 | ** See Also: [Using the SQLite Online Backup API] |
| 6311 | ** |
| 6312 | ** ^Exclusive access is required to the destination database for the |
| 6313 | ** duration of the operation. ^However the source database is only |
| 6314 | ** read-locked while it is actually being read; it is not locked |
| 6315 | ** continuously for the entire backup operation. ^Thus, the backup may be |
| 6316 | ** performed on a live source database without preventing other users from |
| 6317 | ** reading or writing to the source database while the backup is underway. |
| 6318 | ** |
| 6319 | ** ^(To perform a backup operation: |
| 6320 | ** <ol> |
| 6321 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -6338,15 +6387,15 @@ | |
| 6338 | ** an [ATTACH] statement for an attached database. |
| 6339 | ** ^The S and M arguments passed to |
| 6340 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 6341 | ** and database name of the source database, respectively. |
| 6342 | ** ^The source and destination [database connections] (parameters S and D) |
| 6343 | ** must be different or else sqlite3_backup_init(D,N,S,M) will file with |
| 6344 | ** an error. |
| 6345 | ** |
| 6346 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 6347 | ** returned and an error code and error message are store3d in the |
| 6348 | ** destination [database connection] D. |
| 6349 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 6350 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 6351 | ** [sqlite3_errmsg16()] functions. |
| 6352 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -6359,11 +6408,11 @@ | |
| 6359 | ** |
| 6360 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 6361 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 6362 | ** ^If N is negative, all remaining source pages are copied. |
| 6363 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 6364 | ** are still more pages to be copied, then the function resturns [SQLITE_OK]. |
| 6365 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 6366 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 6367 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 6368 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 6369 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -6373,11 +6422,11 @@ | |
| 6373 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 6374 | ** <ol> |
| 6375 | ** <li> the destination database was opened read-only, or |
| 6376 | ** <li> the destination database is using write-ahead-log journaling |
| 6377 | ** and the destination and source page sizes differ, or |
| 6378 | ** <li> The destination database is an in-memory database and the |
| 6379 | ** destination and source page sizes differ. |
| 6380 | ** </ol>)^ |
| 6381 | ** |
| 6382 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 6383 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6704,11 +6753,12 @@ | |
| 6704 | ** |
| 6705 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6706 | ** from SQL. |
| 6707 | ** |
| 6708 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6709 | ** enabled with a threshold of 1000 pages. The use of this interface |
| 6710 | ** is only necessary if the default setting is found to be suboptimal |
| 6711 | ** for a particular application. |
| 6712 | */ |
| 6713 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6714 | |
| @@ -8875,10 +8925,11 @@ | |
| 8875 | u16 sz; /* Size of each buffer in bytes */ |
| 8876 | u8 bEnabled; /* False to disable new lookaside allocations */ |
| 8877 | u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ |
| 8878 | int nOut; /* Number of buffers currently checked out */ |
| 8879 | int mxOut; /* Highwater mark for nOut */ |
| 8880 | LookasideSlot *pFree; /* List of available buffers */ |
| 8881 | void *pStart; /* First byte of available memory space */ |
| 8882 | void *pEnd; /* First byte past end of available space */ |
| 8883 | }; |
| 8884 | struct LookasideSlot { |
| @@ -12506,10 +12557,26 @@ | |
| 12506 | if( resetFlag ){ |
| 12507 | db->lookaside.mxOut = db->lookaside.nOut; |
| 12508 | } |
| 12509 | break; |
| 12510 | } |
| 12511 | |
| 12512 | /* |
| 12513 | ** Return an approximation for the amount of memory currently used |
| 12514 | ** by all pagers associated with the given database connection. The |
| 12515 | ** highwater mark is meaningless and is returned as zero. |
| @@ -18068,18 +18135,24 @@ | |
| 18068 | if( db ){ |
| 18069 | LookasideSlot *pBuf; |
| 18070 | if( db->mallocFailed ){ |
| 18071 | return 0; |
| 18072 | } |
| 18073 | if( db->lookaside.bEnabled && n<=db->lookaside.sz |
| 18074 | && (pBuf = db->lookaside.pFree)!=0 ){ |
| 18075 | db->lookaside.pFree = pBuf->pNext; |
| 18076 | db->lookaside.nOut++; |
| 18077 | if( db->lookaside.nOut>db->lookaside.mxOut ){ |
| 18078 | db->lookaside.mxOut = db->lookaside.nOut; |
| 18079 | } |
| 18080 | return (void*)pBuf; |
| 18081 | } |
| 18082 | } |
| 18083 | #else |
| 18084 | if( db && db->mallocFailed ){ |
| 18085 | return 0; |
| @@ -28391,22 +28464,23 @@ | |
| 28391 | |
| 28392 | /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN |
| 28393 | ** bytes of writable memory. |
| 28394 | */ |
| 28395 | static int proxyGetHostID(unsigned char *pHostID, int *pError){ |
| 28396 | struct timespec timeout = {1, 0}; /* 1 sec timeout */ |
| 28397 | |
| 28398 | assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); |
| 28399 | memset(pHostID, 0, PROXY_HOSTIDLEN); |
| 28400 | #if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\ |
| 28401 | && __MAC_OS_X_VERSION_MIN_REQUIRED<1050 |
| 28402 | if( gethostuuid(pHostID, &timeout) ){ |
| 28403 | int err = errno; |
| 28404 | if( pError ){ |
| 28405 | *pError = err; |
| 28406 | } |
| 28407 | return SQLITE_IOERR; |
| 28408 | } |
| 28409 | #endif |
| 28410 | #ifdef SQLITE_TEST |
| 28411 | /* simulate multiple hosts by creating unique hostid file paths */ |
| 28412 | if( sqlite3_hostid_num != 0){ |
| @@ -41896,18 +41970,18 @@ | |
| 41896 | ** |
| 41897 | ** This functionality is used by the checkpoint code (see walCheckpoint()). |
| 41898 | */ |
| 41899 | struct WalIterator { |
| 41900 | int iPrior; /* Last result returned from the iterator */ |
| 41901 | int nSegment; /* Size of the aSegment[] array */ |
| 41902 | struct WalSegment { |
| 41903 | int iNext; /* Next slot in aIndex[] not yet returned */ |
| 41904 | ht_slot *aIndex; /* i0, i1, i2... such that aPgno[iN] ascend */ |
| 41905 | u32 *aPgno; /* Array of page numbers. */ |
| 41906 | int nEntry; /* Max size of aPgno[] and aIndex[] arrays */ |
| 41907 | int iZero; /* Frame number associated with aPgno[0] */ |
| 41908 | } aSegment[1]; /* One for every 32KB page in the WAL */ |
| 41909 | }; |
| 41910 | |
| 41911 | /* |
| 41912 | ** Define the parameters of the hash tables in the wal-index file. There |
| 41913 | ** is a hash-table following every HASHTABLE_NPAGE page numbers in the |
| @@ -42767,13 +42841,33 @@ | |
| 42767 | return (iRet==0xFFFFFFFF); |
| 42768 | } |
| 42769 | |
| 42770 | /* |
| 42771 | ** This function merges two sorted lists into a single sorted list. |
| 42772 | */ |
| 42773 | static void walMerge( |
| 42774 | u32 *aContent, /* Pages in wal */ |
| 42775 | ht_slot *aLeft, /* IN: Left hand input list */ |
| 42776 | int nLeft, /* IN: Elements in array *paLeft */ |
| 42777 | ht_slot **paRight, /* IN/OUT: Right hand input list */ |
| 42778 | int *pnRight, /* IN/OUT: Elements in *paRight */ |
| 42779 | ht_slot *aTmp /* Temporary buffer */ |
| @@ -42809,14 +42903,28 @@ | |
| 42809 | *pnRight = iOut; |
| 42810 | memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut); |
| 42811 | } |
| 42812 | |
| 42813 | /* |
| 42814 | ** Sort the elements in list aList, removing any duplicates. |
| 42815 | */ |
| 42816 | static void walMergesort( |
| 42817 | u32 *aContent, /* Pages in wal */ |
| 42818 | ht_slot *aBuffer, /* Buffer of at least *pnList items to use */ |
| 42819 | ht_slot *aList, /* IN/OUT: List to sort */ |
| 42820 | int *pnList /* IN/OUT: Number of elements in aList[] */ |
| 42821 | ){ |
| 42822 | struct Sublist { |
| @@ -42877,10 +42985,11 @@ | |
| 42877 | } |
| 42878 | |
| 42879 | /* |
| 42880 | ** Construct a WalInterator object that can be used to loop over all |
| 42881 | ** pages in the WAL in ascending order. The caller must hold the checkpoint |
| 42882 | ** |
| 42883 | ** On success, make *pp point to the newly allocated WalInterator object |
| 42884 | ** return SQLITE_OK. Otherwise, return an error code. If this routine |
| 42885 | ** returns an error, the value of *pp is undefined. |
| 42886 | ** |
| @@ -43011,11 +43120,12 @@ | |
| 43011 | volatile WalCkptInfo *pInfo; /* The checkpoint status information */ |
| 43012 | |
| 43013 | szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16); |
| 43014 | testcase( szPage<=32768 ); |
| 43015 | testcase( szPage>=65536 ); |
| 43016 | if( pWal->hdr.mxFrame==0 ) return SQLITE_OK; |
| 43017 | |
| 43018 | /* Allocate the iterator */ |
| 43019 | rc = walIteratorInit(pWal, &pIter); |
| 43020 | if( rc!=SQLITE_OK ){ |
| 43021 | return rc; |
| @@ -43033,11 +43143,10 @@ | |
| 43033 | ** overwrite database pages that are in use by active readers and thus |
| 43034 | ** cannot be backfilled from the WAL. |
| 43035 | */ |
| 43036 | mxSafeFrame = pWal->hdr.mxFrame; |
| 43037 | mxPage = pWal->hdr.nPage; |
| 43038 | pInfo = walCkptInfo(pWal); |
| 43039 | for(i=1; i<WAL_NREADER; i++){ |
| 43040 | u32 y = pInfo->aReadMark[i]; |
| 43041 | if( mxSafeFrame>=y ){ |
| 43042 | assert( y<=pWal->hdr.mxFrame ); |
| 43043 | rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| @@ -55556,11 +55665,11 @@ | |
| 55556 | u8 opcode = pOp->opcode; |
| 55557 | |
| 55558 | pOp->opflags = sqlite3OpcodeProperty[opcode]; |
| 55559 | if( opcode==OP_Function || opcode==OP_AggStep ){ |
| 55560 | if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; |
| 55561 | }else if( opcode==OP_Transaction && pOp->p2!=0 ){ |
| 55562 | p->readOnly = 0; |
| 55563 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 55564 | }else if( opcode==OP_VUpdate ){ |
| 55565 | if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; |
| 55566 | }else if( opcode==OP_VFilter ){ |
| @@ -80921,13 +81030,13 @@ | |
| 80921 | if( caseSensitive ){ |
| 80922 | pInfo = (struct compareInfo*)&likeInfoAlt; |
| 80923 | }else{ |
| 80924 | pInfo = (struct compareInfo*)&likeInfoNorm; |
| 80925 | } |
| 80926 | sqlite3CreateFunc(db, "like", 2, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); |
| 80927 | sqlite3CreateFunc(db, "like", 3, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); |
| 80928 | sqlite3CreateFunc(db, "glob", 2, SQLITE_ANY, |
| 80929 | (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0); |
| 80930 | setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); |
| 80931 | setLikeOptFlag(db, "like", |
| 80932 | caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE); |
| 80933 | } |
| @@ -97673,14 +97782,13 @@ | |
| 97673 | Parse *pParse, |
| 97674 | Expr *pExpr, |
| 97675 | u8 aff, |
| 97676 | sqlite3_value **pp |
| 97677 | ){ |
| 97678 | /* The evalConstExpr() function will have already converted any TK_VARIABLE |
| 97679 | ** expression involved in an comparison into a TK_REGISTER. */ |
| 97680 | assert( pExpr->op!=TK_VARIABLE ); |
| 97681 | if( pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE ){ |
| 97682 | int iVar = pExpr->iColumn; |
| 97683 | sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-23257-02778 */ |
| 97684 | *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); |
| 97685 | return SQLITE_OK; |
| 97686 | } |
| @@ -106470,10 +106578,13 @@ | |
| 106470 | | SQLITE_LoadExtension |
| 106471 | #endif |
| 106472 | #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS |
| 106473 | | SQLITE_RecTriggers |
| 106474 | #endif |
| 106475 | ; |
| 106476 | sqlite3HashInit(&db->aCollSeq); |
| 106477 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 106478 | sqlite3HashInit(&db->aModule); |
| 106479 | #endif |
| @@ -111307,13 +111418,20 @@ | |
| 111307 | int iCol /* Column of requested pos-list */ |
| 111308 | ){ |
| 111309 | assert( pExpr->isLoaded ); |
| 111310 | if( pExpr->aDoclist ){ |
| 111311 | char *pEnd = &pExpr->aDoclist[pExpr->nDoclist]; |
| 111312 | char *pCsr = pExpr->pCurrent; |
| 111313 | |
| 111314 | assert( pCsr ); |
| 111315 | while( pCsr<pEnd ){ |
| 111316 | if( pExpr->iCurrent<iDocid ){ |
| 111317 | fts3PoslistCopy(0, &pCsr); |
| 111318 | if( pCsr<pEnd ){ |
| 111319 | fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent); |
| @@ -117513,11 +117631,11 @@ | |
| 117513 | /* |
| 117514 | ** This is an fts3ExprIterate() callback used while loading the doclists |
| 117515 | ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also |
| 117516 | ** fts3ExprLoadDoclists(). |
| 117517 | */ |
| 117518 | static int fts3ExprLoadDoclistsCb1(Fts3Expr *pExpr, int iPhrase, void *ctx){ |
| 117519 | int rc = SQLITE_OK; |
| 117520 | LoadDoclistCtx *p = (LoadDoclistCtx *)ctx; |
| 117521 | |
| 117522 | UNUSED_PARAMETER(iPhrase); |
| 117523 | |
| @@ -117533,26 +117651,10 @@ | |
| 117533 | } |
| 117534 | |
| 117535 | return rc; |
| 117536 | } |
| 117537 | |
| 117538 | /* |
| 117539 | ** This is an fts3ExprIterate() callback used while loading the doclists |
| 117540 | ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also |
| 117541 | ** fts3ExprLoadDoclists(). |
| 117542 | */ |
| 117543 | static int fts3ExprLoadDoclistsCb2(Fts3Expr *pExpr, int iPhrase, void *ctx){ |
| 117544 | UNUSED_PARAMETER(iPhrase); |
| 117545 | UNUSED_PARAMETER(ctx); |
| 117546 | if( pExpr->aDoclist ){ |
| 117547 | pExpr->pCurrent = pExpr->aDoclist; |
| 117548 | pExpr->iCurrent = 0; |
| 117549 | pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent, &pExpr->iCurrent); |
| 117550 | } |
| 117551 | return SQLITE_OK; |
| 117552 | } |
| 117553 | |
| 117554 | /* |
| 117555 | ** Load the doclists for each phrase in the query associated with FTS3 cursor |
| 117556 | ** pCsr. |
| 117557 | ** |
| 117558 | ** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable |
| @@ -117567,14 +117669,11 @@ | |
| 117567 | int *pnToken /* OUT: Number of tokens in query */ |
| 117568 | ){ |
| 117569 | int rc; /* Return Code */ |
| 117570 | LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */ |
| 117571 | sCtx.pCsr = pCsr; |
| 117572 | rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb1, (void *)&sCtx); |
| 117573 | if( rc==SQLITE_OK ){ |
| 117574 | (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb2, 0); |
| 117575 | } |
| 117576 | if( pnPhrase ) *pnPhrase = sCtx.nPhrase; |
| 117577 | if( pnToken ) *pnToken = sCtx.nToken; |
| 117578 | return rc; |
| 117579 | } |
| 117580 | |
| 117581 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.4" |
| 654 | #define SQLITE_VERSION_NUMBER 3007004 |
| 655 | #define SQLITE_SOURCE_ID "2010-12-21 21:28:38 b0888047bb6d9ac55e29b9224df2ff650728bb78" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -1256,10 +1256,15 @@ | |
| 1256 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 1257 | ** point to an integer (type int) containing the new chunk-size to use |
| 1258 | ** for the nominated database. Allocating database file space in large |
| 1259 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 1260 | ** improve performance on some systems. |
| 1261 | ** |
| 1262 | ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer |
| 1263 | ** to the [sqlite3_file] object associated with a particular database |
| 1264 | ** connection. See the [sqlite3_file_control()] documentation for |
| 1265 | ** additional information. |
| 1266 | */ |
| 1267 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1268 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1269 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1270 | #define SQLITE_LAST_ERRNO 4 |
| @@ -3191,18 +3196,35 @@ | |
| 3196 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 3197 | |
| 3198 | /* |
| 3199 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 3200 | ** |
| 3201 | ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if |
| 3202 | ** and only if the [prepared statement] X is makes no direct changes to |
| 3203 | ** the content of the database file. |
| 3204 | ** |
| 3205 | ** Note that [application-defined SQL functions] or |
| 3206 | ** [virtual tables] might change the database indirectly as a side effect. |
| 3207 | ** ^(For example, if an application defines a function "eval()" that |
| 3208 | ** calls [sqlite3_exec()], then the following SQL statement would |
| 3209 | ** change the database file through side-effects: |
| 3210 | ** |
| 3211 | ** <blockquote><pre> |
| 3212 | ** SELECT eval('DELETE FROM t1') FROM t2; |
| 3213 | ** </pre></blockquote> |
| 3214 | ** |
| 3215 | ** But because the [SELECT] statement does not change the database file |
| 3216 | ** directly, sqlite3_stmt_readonly() would still return true.)^ |
| 3217 | ** |
| 3218 | ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], |
| 3219 | ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, |
| 3220 | ** since the statements themselves do not actually modify the database but |
| 3221 | ** rather they control the timing of when other statements modify the |
| 3222 | ** database. ^The [ATTACH] and [DETACH] statements also cause |
| 3223 | ** sqlite3_stmt_readonly() to return true since, while those statements |
| 3224 | ** change the configuration of a database connection, they do not make |
| 3225 | ** changes to the content of the database files on disk. |
| 3226 | */ |
| 3227 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 3228 | |
| 3229 | /* |
| 3230 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5927,11 +5949,12 @@ | |
| 5949 | ** internal equivalents). Only the value returned in the |
| 5950 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5951 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5952 | ** |
| 5953 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5954 | ** <dd>This parameter records the number of separate memory allocations |
| 5955 | ** currently checked out.</dd>)^ |
| 5956 | ** |
| 5957 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5958 | ** <dd>This parameter returns the number of pages used out of the |
| 5959 | ** [pagecache memory allocator] that was configured using |
| 5960 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -6032,10 +6055,32 @@ | |
| 6055 | ** |
| 6056 | ** <dl> |
| 6057 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 6058 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 6059 | ** checked out.</dd>)^ |
| 6060 | ** |
| 6061 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> |
| 6062 | ** <dd>This parameter returns the number malloc attempts that were |
| 6063 | ** satisfied using lookaside memory. Only the high-water value is meaningful; |
| 6064 | ** the current value is always zero. |
| 6065 | ** checked out.</dd>)^ |
| 6066 | ** |
| 6067 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> |
| 6068 | ** <dd>This parameter returns the number malloc attempts that might have |
| 6069 | ** been satisfied using lookaside memory but failed due to the amount of |
| 6070 | ** memory requested being larger than the lookaside slot size. |
| 6071 | ** Only the high-water value is meaningful; |
| 6072 | ** the current value is always zero. |
| 6073 | ** checked out.</dd>)^ |
| 6074 | ** |
| 6075 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> |
| 6076 | ** <dd>This parameter returns the number malloc attempts that might have |
| 6077 | ** been satisfied using lookaside memory but failed due to all lookaside |
| 6078 | ** memory already being in use. |
| 6079 | ** Only the high-water value is meaningful; |
| 6080 | ** the current value is always zero. |
| 6081 | ** checked out.</dd>)^ |
| 6082 | ** |
| 6083 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 6084 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6085 | ** memory used by all pager caches associated with the database connection.)^ |
| 6086 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -6055,15 +6100,18 @@ | |
| 6100 | ** the database connection.)^ |
| 6101 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 6102 | ** </dd> |
| 6103 | ** </dl> |
| 6104 | */ |
| 6105 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 6106 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 6107 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 6108 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 6109 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 6110 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 6111 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 6112 | #define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ |
| 6113 | |
| 6114 | |
| 6115 | /* |
| 6116 | ** CAPI3REF: Prepared Statement Status |
| 6117 | ** |
| @@ -6307,15 +6355,16 @@ | |
| 6355 | ** It is useful either for creating backups of databases or |
| 6356 | ** for copying in-memory databases to or from persistent files. |
| 6357 | ** |
| 6358 | ** See Also: [Using the SQLite Online Backup API] |
| 6359 | ** |
| 6360 | ** ^SQLite holds a write transaction open on the destination database file |
| 6361 | ** for the duration of the backup operation. |
| 6362 | ** ^The source database is read-locked only while it is being read; |
| 6363 | ** it is not locked continuously for the entire backup operation. |
| 6364 | ** ^Thus, the backup may be performed on a live source database without |
| 6365 | ** preventing other database connections from |
| 6366 | ** reading or writing to the source database while the backup is underway. |
| 6367 | ** |
| 6368 | ** ^(To perform a backup operation: |
| 6369 | ** <ol> |
| 6370 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -6338,15 +6387,15 @@ | |
| 6387 | ** an [ATTACH] statement for an attached database. |
| 6388 | ** ^The S and M arguments passed to |
| 6389 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 6390 | ** and database name of the source database, respectively. |
| 6391 | ** ^The source and destination [database connections] (parameters S and D) |
| 6392 | ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with |
| 6393 | ** an error. |
| 6394 | ** |
| 6395 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 6396 | ** returned and an error code and error message are stored in the |
| 6397 | ** destination [database connection] D. |
| 6398 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 6399 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 6400 | ** [sqlite3_errmsg16()] functions. |
| 6401 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -6359,11 +6408,11 @@ | |
| 6408 | ** |
| 6409 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 6410 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 6411 | ** ^If N is negative, all remaining source pages are copied. |
| 6412 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 6413 | ** are still more pages to be copied, then the function returns [SQLITE_OK]. |
| 6414 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 6415 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 6416 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 6417 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 6418 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -6373,11 +6422,11 @@ | |
| 6422 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 6423 | ** <ol> |
| 6424 | ** <li> the destination database was opened read-only, or |
| 6425 | ** <li> the destination database is using write-ahead-log journaling |
| 6426 | ** and the destination and source page sizes differ, or |
| 6427 | ** <li> the destination database is an in-memory database and the |
| 6428 | ** destination and source page sizes differ. |
| 6429 | ** </ol>)^ |
| 6430 | ** |
| 6431 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 6432 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6704,11 +6753,12 @@ | |
| 6753 | ** |
| 6754 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6755 | ** from SQL. |
| 6756 | ** |
| 6757 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6758 | ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] |
| 6759 | ** pages. The use of this interface |
| 6760 | ** is only necessary if the default setting is found to be suboptimal |
| 6761 | ** for a particular application. |
| 6762 | */ |
| 6763 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6764 | |
| @@ -8875,10 +8925,11 @@ | |
| 8925 | u16 sz; /* Size of each buffer in bytes */ |
| 8926 | u8 bEnabled; /* False to disable new lookaside allocations */ |
| 8927 | u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ |
| 8928 | int nOut; /* Number of buffers currently checked out */ |
| 8929 | int mxOut; /* Highwater mark for nOut */ |
| 8930 | int anStat[3]; /* 0: hits. 1: size misses. 2: full misses */ |
| 8931 | LookasideSlot *pFree; /* List of available buffers */ |
| 8932 | void *pStart; /* First byte of available memory space */ |
| 8933 | void *pEnd; /* First byte past end of available space */ |
| 8934 | }; |
| 8935 | struct LookasideSlot { |
| @@ -12506,10 +12557,26 @@ | |
| 12557 | if( resetFlag ){ |
| 12558 | db->lookaside.mxOut = db->lookaside.nOut; |
| 12559 | } |
| 12560 | break; |
| 12561 | } |
| 12562 | |
| 12563 | case SQLITE_DBSTATUS_LOOKASIDE_HIT: |
| 12564 | case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: |
| 12565 | case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: { |
| 12566 | testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT ); |
| 12567 | testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE ); |
| 12568 | testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL ); |
| 12569 | assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 ); |
| 12570 | assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 ); |
| 12571 | *pCurrent = 0; |
| 12572 | *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT]; |
| 12573 | if( resetFlag ){ |
| 12574 | db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0; |
| 12575 | } |
| 12576 | break; |
| 12577 | } |
| 12578 | |
| 12579 | /* |
| 12580 | ** Return an approximation for the amount of memory currently used |
| 12581 | ** by all pagers associated with the given database connection. The |
| 12582 | ** highwater mark is meaningless and is returned as zero. |
| @@ -18068,18 +18135,24 @@ | |
| 18135 | if( db ){ |
| 18136 | LookasideSlot *pBuf; |
| 18137 | if( db->mallocFailed ){ |
| 18138 | return 0; |
| 18139 | } |
| 18140 | if( db->lookaside.bEnabled ){ |
| 18141 | if( n>db->lookaside.sz ){ |
| 18142 | db->lookaside.anStat[1]++; |
| 18143 | }else if( (pBuf = db->lookaside.pFree)==0 ){ |
| 18144 | db->lookaside.anStat[2]++; |
| 18145 | }else{ |
| 18146 | db->lookaside.pFree = pBuf->pNext; |
| 18147 | db->lookaside.nOut++; |
| 18148 | db->lookaside.anStat[0]++; |
| 18149 | if( db->lookaside.nOut>db->lookaside.mxOut ){ |
| 18150 | db->lookaside.mxOut = db->lookaside.nOut; |
| 18151 | } |
| 18152 | return (void*)pBuf; |
| 18153 | } |
| 18154 | } |
| 18155 | } |
| 18156 | #else |
| 18157 | if( db && db->mallocFailed ){ |
| 18158 | return 0; |
| @@ -28391,22 +28464,23 @@ | |
| 28464 | |
| 28465 | /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN |
| 28466 | ** bytes of writable memory. |
| 28467 | */ |
| 28468 | static int proxyGetHostID(unsigned char *pHostID, int *pError){ |
| 28469 | assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); |
| 28470 | memset(pHostID, 0, PROXY_HOSTIDLEN); |
| 28471 | #if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\ |
| 28472 | && __MAC_OS_X_VERSION_MIN_REQUIRED<1050 |
| 28473 | { |
| 28474 | static const struct timespec timeout = {1, 0}; /* 1 sec timeout */ |
| 28475 | if( gethostuuid(pHostID, &timeout) ){ |
| 28476 | int err = errno; |
| 28477 | if( pError ){ |
| 28478 | *pError = err; |
| 28479 | } |
| 28480 | return SQLITE_IOERR; |
| 28481 | } |
| 28482 | } |
| 28483 | #endif |
| 28484 | #ifdef SQLITE_TEST |
| 28485 | /* simulate multiple hosts by creating unique hostid file paths */ |
| 28486 | if( sqlite3_hostid_num != 0){ |
| @@ -41896,18 +41970,18 @@ | |
| 41970 | ** |
| 41971 | ** This functionality is used by the checkpoint code (see walCheckpoint()). |
| 41972 | */ |
| 41973 | struct WalIterator { |
| 41974 | int iPrior; /* Last result returned from the iterator */ |
| 41975 | int nSegment; /* Number of entries in aSegment[] */ |
| 41976 | struct WalSegment { |
| 41977 | int iNext; /* Next slot in aIndex[] not yet returned */ |
| 41978 | ht_slot *aIndex; /* i0, i1, i2... such that aPgno[iN] ascend */ |
| 41979 | u32 *aPgno; /* Array of page numbers. */ |
| 41980 | int nEntry; /* Nr. of entries in aPgno[] and aIndex[] */ |
| 41981 | int iZero; /* Frame number associated with aPgno[0] */ |
| 41982 | } aSegment[1]; /* One for every 32KB page in the wal-index */ |
| 41983 | }; |
| 41984 | |
| 41985 | /* |
| 41986 | ** Define the parameters of the hash tables in the wal-index file. There |
| 41987 | ** is a hash-table following every HASHTABLE_NPAGE page numbers in the |
| @@ -42767,13 +42841,33 @@ | |
| 42841 | return (iRet==0xFFFFFFFF); |
| 42842 | } |
| 42843 | |
| 42844 | /* |
| 42845 | ** This function merges two sorted lists into a single sorted list. |
| 42846 | ** |
| 42847 | ** aLeft[] and aRight[] are arrays of indices. The sort key is |
| 42848 | ** aContent[aLeft[]] and aContent[aRight[]]. Upon entry, the following |
| 42849 | ** is guaranteed for all J<K: |
| 42850 | ** |
| 42851 | ** aContent[aLeft[J]] < aContent[aLeft[K]] |
| 42852 | ** aContent[aRight[J]] < aContent[aRight[K]] |
| 42853 | ** |
| 42854 | ** This routine overwrites aRight[] with a new (probably longer) sequence |
| 42855 | ** of indices such that the aRight[] contains every index that appears in |
| 42856 | ** either aLeft[] or the old aRight[] and such that the second condition |
| 42857 | ** above is still met. |
| 42858 | ** |
| 42859 | ** The aContent[aLeft[X]] values will be unique for all X. And the |
| 42860 | ** aContent[aRight[X]] values will be unique too. But there might be |
| 42861 | ** one or more combinations of X and Y such that |
| 42862 | ** |
| 42863 | ** aLeft[X]!=aRight[Y] && aContent[aLeft[X]] == aContent[aRight[Y]] |
| 42864 | ** |
| 42865 | ** When that happens, omit the aLeft[X] and use the aRight[Y] index. |
| 42866 | */ |
| 42867 | static void walMerge( |
| 42868 | const u32 *aContent, /* Pages in wal - keys for the sort */ |
| 42869 | ht_slot *aLeft, /* IN: Left hand input list */ |
| 42870 | int nLeft, /* IN: Elements in array *paLeft */ |
| 42871 | ht_slot **paRight, /* IN/OUT: Right hand input list */ |
| 42872 | int *pnRight, /* IN/OUT: Elements in *paRight */ |
| 42873 | ht_slot *aTmp /* Temporary buffer */ |
| @@ -42809,14 +42903,28 @@ | |
| 42903 | *pnRight = iOut; |
| 42904 | memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut); |
| 42905 | } |
| 42906 | |
| 42907 | /* |
| 42908 | ** Sort the elements in list aList using aContent[] as the sort key. |
| 42909 | ** Remove elements with duplicate keys, preferring to keep the |
| 42910 | ** larger aList[] values. |
| 42911 | ** |
| 42912 | ** The aList[] entries are indices into aContent[]. The values in |
| 42913 | ** aList[] are to be sorted so that for all J<K: |
| 42914 | ** |
| 42915 | ** aContent[aList[J]] < aContent[aList[K]] |
| 42916 | ** |
| 42917 | ** For any X and Y such that |
| 42918 | ** |
| 42919 | ** aContent[aList[X]] == aContent[aList[Y]] |
| 42920 | ** |
| 42921 | ** Keep the larger of the two values aList[X] and aList[Y] and discard |
| 42922 | ** the smaller. |
| 42923 | */ |
| 42924 | static void walMergesort( |
| 42925 | const u32 *aContent, /* Pages in wal */ |
| 42926 | ht_slot *aBuffer, /* Buffer of at least *pnList items to use */ |
| 42927 | ht_slot *aList, /* IN/OUT: List to sort */ |
| 42928 | int *pnList /* IN/OUT: Number of elements in aList[] */ |
| 42929 | ){ |
| 42930 | struct Sublist { |
| @@ -42877,10 +42985,11 @@ | |
| 42985 | } |
| 42986 | |
| 42987 | /* |
| 42988 | ** Construct a WalInterator object that can be used to loop over all |
| 42989 | ** pages in the WAL in ascending order. The caller must hold the checkpoint |
| 42990 | ** lock. |
| 42991 | ** |
| 42992 | ** On success, make *pp point to the newly allocated WalInterator object |
| 42993 | ** return SQLITE_OK. Otherwise, return an error code. If this routine |
| 42994 | ** returns an error, the value of *pp is undefined. |
| 42995 | ** |
| @@ -43011,11 +43120,12 @@ | |
| 43120 | volatile WalCkptInfo *pInfo; /* The checkpoint status information */ |
| 43121 | |
| 43122 | szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16); |
| 43123 | testcase( szPage<=32768 ); |
| 43124 | testcase( szPage>=65536 ); |
| 43125 | pInfo = walCkptInfo(pWal); |
| 43126 | if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK; |
| 43127 | |
| 43128 | /* Allocate the iterator */ |
| 43129 | rc = walIteratorInit(pWal, &pIter); |
| 43130 | if( rc!=SQLITE_OK ){ |
| 43131 | return rc; |
| @@ -43033,11 +43143,10 @@ | |
| 43143 | ** overwrite database pages that are in use by active readers and thus |
| 43144 | ** cannot be backfilled from the WAL. |
| 43145 | */ |
| 43146 | mxSafeFrame = pWal->hdr.mxFrame; |
| 43147 | mxPage = pWal->hdr.nPage; |
| 43148 | for(i=1; i<WAL_NREADER; i++){ |
| 43149 | u32 y = pInfo->aReadMark[i]; |
| 43150 | if( mxSafeFrame>=y ){ |
| 43151 | assert( y<=pWal->hdr.mxFrame ); |
| 43152 | rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| @@ -55556,11 +55665,11 @@ | |
| 55665 | u8 opcode = pOp->opcode; |
| 55666 | |
| 55667 | pOp->opflags = sqlite3OpcodeProperty[opcode]; |
| 55668 | if( opcode==OP_Function || opcode==OP_AggStep ){ |
| 55669 | if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; |
| 55670 | }else if( (opcode==OP_Transaction && pOp->p2!=0) || opcode==OP_Vacuum ){ |
| 55671 | p->readOnly = 0; |
| 55672 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 55673 | }else if( opcode==OP_VUpdate ){ |
| 55674 | if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; |
| 55675 | }else if( opcode==OP_VFilter ){ |
| @@ -80921,13 +81030,13 @@ | |
| 81030 | if( caseSensitive ){ |
| 81031 | pInfo = (struct compareInfo*)&likeInfoAlt; |
| 81032 | }else{ |
| 81033 | pInfo = (struct compareInfo*)&likeInfoNorm; |
| 81034 | } |
| 81035 | sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); |
| 81036 | sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); |
| 81037 | sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, |
| 81038 | (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0); |
| 81039 | setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); |
| 81040 | setLikeOptFlag(db, "like", |
| 81041 | caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE); |
| 81042 | } |
| @@ -97673,14 +97782,13 @@ | |
| 97782 | Parse *pParse, |
| 97783 | Expr *pExpr, |
| 97784 | u8 aff, |
| 97785 | sqlite3_value **pp |
| 97786 | ){ |
| 97787 | if( pExpr->op==TK_VARIABLE |
| 97788 | || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) |
| 97789 | ){ |
| 97790 | int iVar = pExpr->iColumn; |
| 97791 | sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-23257-02778 */ |
| 97792 | *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); |
| 97793 | return SQLITE_OK; |
| 97794 | } |
| @@ -106470,10 +106578,13 @@ | |
| 106578 | | SQLITE_LoadExtension |
| 106579 | #endif |
| 106580 | #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS |
| 106581 | | SQLITE_RecTriggers |
| 106582 | #endif |
| 106583 | #if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS |
| 106584 | | SQLITE_ForeignKeys |
| 106585 | #endif |
| 106586 | ; |
| 106587 | sqlite3HashInit(&db->aCollSeq); |
| 106588 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 106589 | sqlite3HashInit(&db->aModule); |
| 106590 | #endif |
| @@ -111307,13 +111418,20 @@ | |
| 111418 | int iCol /* Column of requested pos-list */ |
| 111419 | ){ |
| 111420 | assert( pExpr->isLoaded ); |
| 111421 | if( pExpr->aDoclist ){ |
| 111422 | char *pEnd = &pExpr->aDoclist[pExpr->nDoclist]; |
| 111423 | char *pCsr; |
| 111424 | |
| 111425 | if( pExpr->pCurrent==0 ){ |
| 111426 | pExpr->pCurrent = pExpr->aDoclist; |
| 111427 | pExpr->iCurrent = 0; |
| 111428 | pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent,&pExpr->iCurrent); |
| 111429 | } |
| 111430 | pCsr = pExpr->pCurrent; |
| 111431 | assert( pCsr ); |
| 111432 | |
| 111433 | while( pCsr<pEnd ){ |
| 111434 | if( pExpr->iCurrent<iDocid ){ |
| 111435 | fts3PoslistCopy(0, &pCsr); |
| 111436 | if( pCsr<pEnd ){ |
| 111437 | fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent); |
| @@ -117513,11 +117631,11 @@ | |
| 117631 | /* |
| 117632 | ** This is an fts3ExprIterate() callback used while loading the doclists |
| 117633 | ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also |
| 117634 | ** fts3ExprLoadDoclists(). |
| 117635 | */ |
| 117636 | static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){ |
| 117637 | int rc = SQLITE_OK; |
| 117638 | LoadDoclistCtx *p = (LoadDoclistCtx *)ctx; |
| 117639 | |
| 117640 | UNUSED_PARAMETER(iPhrase); |
| 117641 | |
| @@ -117533,26 +117651,10 @@ | |
| 117651 | } |
| 117652 | |
| 117653 | return rc; |
| 117654 | } |
| 117655 | |
| 117656 | /* |
| 117657 | ** Load the doclists for each phrase in the query associated with FTS3 cursor |
| 117658 | ** pCsr. |
| 117659 | ** |
| 117660 | ** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable |
| @@ -117567,14 +117669,11 @@ | |
| 117669 | int *pnToken /* OUT: Number of tokens in query */ |
| 117670 | ){ |
| 117671 | int rc; /* Return Code */ |
| 117672 | LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */ |
| 117673 | sCtx.pCsr = pCsr; |
| 117674 | rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx); |
| 117675 | if( pnPhrase ) *pnPhrase = sCtx.nPhrase; |
| 117676 | if( pnToken ) *pnToken = sCtx.nToken; |
| 117677 | return rc; |
| 117678 | } |
| 117679 | |
| 117680 |
+177
-78
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -650,11 +650,11 @@ | ||
| 650 | 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | 652 | */ |
| 653 | 653 | #define SQLITE_VERSION "3.7.4" |
| 654 | 654 | #define SQLITE_VERSION_NUMBER 3007004 |
| 655 | -#define SQLITE_SOURCE_ID "2010-12-06 21:09:59 fabcb6b95e1d4059d1e6c6183f65846f6cbd5749" | |
| 655 | +#define SQLITE_SOURCE_ID "2010-12-21 21:28:38 b0888047bb6d9ac55e29b9224df2ff650728bb78" | |
| 656 | 656 | |
| 657 | 657 | /* |
| 658 | 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | 660 | ** |
| @@ -1256,10 +1256,15 @@ | ||
| 1256 | 1256 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 1257 | 1257 | ** point to an integer (type int) containing the new chunk-size to use |
| 1258 | 1258 | ** for the nominated database. Allocating database file space in large |
| 1259 | 1259 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 1260 | 1260 | ** improve performance on some systems. |
| 1261 | +** | |
| 1262 | +** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer | |
| 1263 | +** to the [sqlite3_file] object associated with a particular database | |
| 1264 | +** connection. See the [sqlite3_file_control()] documentation for | |
| 1265 | +** additional information. | |
| 1261 | 1266 | */ |
| 1262 | 1267 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1263 | 1268 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1264 | 1269 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1265 | 1270 | #define SQLITE_LAST_ERRNO 4 |
| @@ -3191,18 +3196,35 @@ | ||
| 3191 | 3196 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 3192 | 3197 | |
| 3193 | 3198 | /* |
| 3194 | 3199 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 3195 | 3200 | ** |
| 3196 | -** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if | |
| 3197 | -** the [prepared statement] X is [SELECT] statement and false (zero) if | |
| 3198 | -** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], | |
| 3199 | -** [ALTER], or [REINDEX] statement. | |
| 3200 | -** If X is a NULL pointer or any other kind of statement, including but | |
| 3201 | -** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], | |
| 3202 | -** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is | |
| 3203 | -** undefined. | |
| 3201 | +** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if | |
| 3202 | +** and only if the [prepared statement] X is makes no direct changes to | |
| 3203 | +** the content of the database file. | |
| 3204 | +** | |
| 3205 | +** Note that [application-defined SQL functions] or | |
| 3206 | +** [virtual tables] might change the database indirectly as a side effect. | |
| 3207 | +** ^(For example, if an application defines a function "eval()" that | |
| 3208 | +** calls [sqlite3_exec()], then the following SQL statement would | |
| 3209 | +** change the database file through side-effects: | |
| 3210 | +** | |
| 3211 | +** <blockquote><pre> | |
| 3212 | +** SELECT eval('DELETE FROM t1') FROM t2; | |
| 3213 | +** </pre></blockquote> | |
| 3214 | +** | |
| 3215 | +** But because the [SELECT] statement does not change the database file | |
| 3216 | +** directly, sqlite3_stmt_readonly() would still return true.)^ | |
| 3217 | +** | |
| 3218 | +** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], | |
| 3219 | +** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, | |
| 3220 | +** since the statements themselves do not actually modify the database but | |
| 3221 | +** rather they control the timing of when other statements modify the | |
| 3222 | +** database. ^The [ATTACH] and [DETACH] statements also cause | |
| 3223 | +** sqlite3_stmt_readonly() to return true since, while those statements | |
| 3224 | +** change the configuration of a database connection, they do not make | |
| 3225 | +** changes to the content of the database files on disk. | |
| 3204 | 3226 | */ |
| 3205 | 3227 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 3206 | 3228 | |
| 3207 | 3229 | /* |
| 3208 | 3230 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5927,11 +5949,12 @@ | ||
| 5927 | 5949 | ** internal equivalents). Only the value returned in the |
| 5928 | 5950 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5929 | 5951 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5930 | 5952 | ** |
| 5931 | 5953 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5932 | -** <dd>This parameter records the number of separate memory allocations.</dd>)^ | |
| 5954 | +** <dd>This parameter records the number of separate memory allocations | |
| 5955 | +** currently checked out.</dd>)^ | |
| 5933 | 5956 | ** |
| 5934 | 5957 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5935 | 5958 | ** <dd>This parameter returns the number of pages used out of the |
| 5936 | 5959 | ** [pagecache memory allocator] that was configured using |
| 5937 | 5960 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -6032,10 +6055,32 @@ | ||
| 6032 | 6055 | ** |
| 6033 | 6056 | ** <dl> |
| 6034 | 6057 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 6035 | 6058 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 6036 | 6059 | ** checked out.</dd>)^ |
| 6060 | +** | |
| 6061 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> | |
| 6062 | +** <dd>This parameter returns the number malloc attempts that were | |
| 6063 | +** satisfied using lookaside memory. Only the high-water value is meaningful; | |
| 6064 | +** the current value is always zero. | |
| 6065 | +** checked out.</dd>)^ | |
| 6066 | +** | |
| 6067 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> | |
| 6068 | +** <dd>This parameter returns the number malloc attempts that might have | |
| 6069 | +** been satisfied using lookaside memory but failed due to the amount of | |
| 6070 | +** memory requested being larger than the lookaside slot size. | |
| 6071 | +** Only the high-water value is meaningful; | |
| 6072 | +** the current value is always zero. | |
| 6073 | +** checked out.</dd>)^ | |
| 6074 | +** | |
| 6075 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> | |
| 6076 | +** <dd>This parameter returns the number malloc attempts that might have | |
| 6077 | +** been satisfied using lookaside memory but failed due to all lookaside | |
| 6078 | +** memory already being in use. | |
| 6079 | +** Only the high-water value is meaningful; | |
| 6080 | +** the current value is always zero. | |
| 6081 | +** checked out.</dd>)^ | |
| 6037 | 6082 | ** |
| 6038 | 6083 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 6039 | 6084 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6040 | 6085 | ** memory used by all pager caches associated with the database connection.)^ |
| 6041 | 6086 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -6055,15 +6100,18 @@ | ||
| 6055 | 6100 | ** the database connection.)^ |
| 6056 | 6101 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 6057 | 6102 | ** </dd> |
| 6058 | 6103 | ** </dl> |
| 6059 | 6104 | */ |
| 6060 | -#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 | |
| 6061 | -#define SQLITE_DBSTATUS_CACHE_USED 1 | |
| 6062 | -#define SQLITE_DBSTATUS_SCHEMA_USED 2 | |
| 6063 | -#define SQLITE_DBSTATUS_STMT_USED 3 | |
| 6064 | -#define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ | |
| 6105 | +#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 | |
| 6106 | +#define SQLITE_DBSTATUS_CACHE_USED 1 | |
| 6107 | +#define SQLITE_DBSTATUS_SCHEMA_USED 2 | |
| 6108 | +#define SQLITE_DBSTATUS_STMT_USED 3 | |
| 6109 | +#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 | |
| 6110 | +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 | |
| 6111 | +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 | |
| 6112 | +#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ | |
| 6065 | 6113 | |
| 6066 | 6114 | |
| 6067 | 6115 | /* |
| 6068 | 6116 | ** CAPI3REF: Prepared Statement Status |
| 6069 | 6117 | ** |
| @@ -6307,15 +6355,16 @@ | ||
| 6307 | 6355 | ** It is useful either for creating backups of databases or |
| 6308 | 6356 | ** for copying in-memory databases to or from persistent files. |
| 6309 | 6357 | ** |
| 6310 | 6358 | ** See Also: [Using the SQLite Online Backup API] |
| 6311 | 6359 | ** |
| 6312 | -** ^Exclusive access is required to the destination database for the | |
| 6313 | -** duration of the operation. ^However the source database is only | |
| 6314 | -** read-locked while it is actually being read; it is not locked | |
| 6315 | -** continuously for the entire backup operation. ^Thus, the backup may be | |
| 6316 | -** performed on a live source database without preventing other users from | |
| 6360 | +** ^SQLite holds a write transaction open on the destination database file | |
| 6361 | +** for the duration of the backup operation. | |
| 6362 | +** ^The source database is read-locked only while it is being read; | |
| 6363 | +** it is not locked continuously for the entire backup operation. | |
| 6364 | +** ^Thus, the backup may be performed on a live source database without | |
| 6365 | +** preventing other database connections from | |
| 6317 | 6366 | ** reading or writing to the source database while the backup is underway. |
| 6318 | 6367 | ** |
| 6319 | 6368 | ** ^(To perform a backup operation: |
| 6320 | 6369 | ** <ol> |
| 6321 | 6370 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -6338,15 +6387,15 @@ | ||
| 6338 | 6387 | ** an [ATTACH] statement for an attached database. |
| 6339 | 6388 | ** ^The S and M arguments passed to |
| 6340 | 6389 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 6341 | 6390 | ** and database name of the source database, respectively. |
| 6342 | 6391 | ** ^The source and destination [database connections] (parameters S and D) |
| 6343 | -** must be different or else sqlite3_backup_init(D,N,S,M) will file with | |
| 6392 | +** must be different or else sqlite3_backup_init(D,N,S,M) will fail with | |
| 6344 | 6393 | ** an error. |
| 6345 | 6394 | ** |
| 6346 | 6395 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 6347 | -** returned and an error code and error message are store3d in the | |
| 6396 | +** returned and an error code and error message are stored in the | |
| 6348 | 6397 | ** destination [database connection] D. |
| 6349 | 6398 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 6350 | 6399 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 6351 | 6400 | ** [sqlite3_errmsg16()] functions. |
| 6352 | 6401 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -6359,11 +6408,11 @@ | ||
| 6359 | 6408 | ** |
| 6360 | 6409 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 6361 | 6410 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 6362 | 6411 | ** ^If N is negative, all remaining source pages are copied. |
| 6363 | 6412 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 6364 | -** are still more pages to be copied, then the function resturns [SQLITE_OK]. | |
| 6413 | +** are still more pages to be copied, then the function returns [SQLITE_OK]. | |
| 6365 | 6414 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 6366 | 6415 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 6367 | 6416 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 6368 | 6417 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 6369 | 6418 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -6373,11 +6422,11 @@ | ||
| 6373 | 6422 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 6374 | 6423 | ** <ol> |
| 6375 | 6424 | ** <li> the destination database was opened read-only, or |
| 6376 | 6425 | ** <li> the destination database is using write-ahead-log journaling |
| 6377 | 6426 | ** and the destination and source page sizes differ, or |
| 6378 | -** <li> The destination database is an in-memory database and the | |
| 6427 | +** <li> the destination database is an in-memory database and the | |
| 6379 | 6428 | ** destination and source page sizes differ. |
| 6380 | 6429 | ** </ol>)^ |
| 6381 | 6430 | ** |
| 6382 | 6431 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 6383 | 6432 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6704,11 +6753,12 @@ | ||
| 6704 | 6753 | ** |
| 6705 | 6754 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6706 | 6755 | ** from SQL. |
| 6707 | 6756 | ** |
| 6708 | 6757 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6709 | -** enabled with a threshold of 1000 pages. The use of this interface | |
| 6758 | +** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] | |
| 6759 | +** pages. The use of this interface | |
| 6710 | 6760 | ** is only necessary if the default setting is found to be suboptimal |
| 6711 | 6761 | ** for a particular application. |
| 6712 | 6762 | */ |
| 6713 | 6763 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6714 | 6764 | |
| @@ -8875,10 +8925,11 @@ | ||
| 8875 | 8925 | u16 sz; /* Size of each buffer in bytes */ |
| 8876 | 8926 | u8 bEnabled; /* False to disable new lookaside allocations */ |
| 8877 | 8927 | u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ |
| 8878 | 8928 | int nOut; /* Number of buffers currently checked out */ |
| 8879 | 8929 | int mxOut; /* Highwater mark for nOut */ |
| 8930 | + int anStat[3]; /* 0: hits. 1: size misses. 2: full misses */ | |
| 8880 | 8931 | LookasideSlot *pFree; /* List of available buffers */ |
| 8881 | 8932 | void *pStart; /* First byte of available memory space */ |
| 8882 | 8933 | void *pEnd; /* First byte past end of available space */ |
| 8883 | 8934 | }; |
| 8884 | 8935 | struct LookasideSlot { |
| @@ -12506,10 +12557,26 @@ | ||
| 12506 | 12557 | if( resetFlag ){ |
| 12507 | 12558 | db->lookaside.mxOut = db->lookaside.nOut; |
| 12508 | 12559 | } |
| 12509 | 12560 | break; |
| 12510 | 12561 | } |
| 12562 | + | |
| 12563 | + case SQLITE_DBSTATUS_LOOKASIDE_HIT: | |
| 12564 | + case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: | |
| 12565 | + case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: { | |
| 12566 | + testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT ); | |
| 12567 | + testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE ); | |
| 12568 | + testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL ); | |
| 12569 | + assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 ); | |
| 12570 | + assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 ); | |
| 12571 | + *pCurrent = 0; | |
| 12572 | + *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT]; | |
| 12573 | + if( resetFlag ){ | |
| 12574 | + db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0; | |
| 12575 | + } | |
| 12576 | + break; | |
| 12577 | + } | |
| 12511 | 12578 | |
| 12512 | 12579 | /* |
| 12513 | 12580 | ** Return an approximation for the amount of memory currently used |
| 12514 | 12581 | ** by all pagers associated with the given database connection. The |
| 12515 | 12582 | ** highwater mark is meaningless and is returned as zero. |
| @@ -18068,18 +18135,24 @@ | ||
| 18068 | 18135 | if( db ){ |
| 18069 | 18136 | LookasideSlot *pBuf; |
| 18070 | 18137 | if( db->mallocFailed ){ |
| 18071 | 18138 | return 0; |
| 18072 | 18139 | } |
| 18073 | - if( db->lookaside.bEnabled && n<=db->lookaside.sz | |
| 18074 | - && (pBuf = db->lookaside.pFree)!=0 ){ | |
| 18075 | - db->lookaside.pFree = pBuf->pNext; | |
| 18076 | - db->lookaside.nOut++; | |
| 18077 | - if( db->lookaside.nOut>db->lookaside.mxOut ){ | |
| 18078 | - db->lookaside.mxOut = db->lookaside.nOut; | |
| 18079 | - } | |
| 18080 | - return (void*)pBuf; | |
| 18140 | + if( db->lookaside.bEnabled ){ | |
| 18141 | + if( n>db->lookaside.sz ){ | |
| 18142 | + db->lookaside.anStat[1]++; | |
| 18143 | + }else if( (pBuf = db->lookaside.pFree)==0 ){ | |
| 18144 | + db->lookaside.anStat[2]++; | |
| 18145 | + }else{ | |
| 18146 | + db->lookaside.pFree = pBuf->pNext; | |
| 18147 | + db->lookaside.nOut++; | |
| 18148 | + db->lookaside.anStat[0]++; | |
| 18149 | + if( db->lookaside.nOut>db->lookaside.mxOut ){ | |
| 18150 | + db->lookaside.mxOut = db->lookaside.nOut; | |
| 18151 | + } | |
| 18152 | + return (void*)pBuf; | |
| 18153 | + } | |
| 18081 | 18154 | } |
| 18082 | 18155 | } |
| 18083 | 18156 | #else |
| 18084 | 18157 | if( db && db->mallocFailed ){ |
| 18085 | 18158 | return 0; |
| @@ -28391,22 +28464,23 @@ | ||
| 28391 | 28464 | |
| 28392 | 28465 | /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN |
| 28393 | 28466 | ** bytes of writable memory. |
| 28394 | 28467 | */ |
| 28395 | 28468 | static int proxyGetHostID(unsigned char *pHostID, int *pError){ |
| 28396 | - struct timespec timeout = {1, 0}; /* 1 sec timeout */ | |
| 28397 | - | |
| 28398 | 28469 | assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); |
| 28399 | 28470 | memset(pHostID, 0, PROXY_HOSTIDLEN); |
| 28400 | 28471 | #if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\ |
| 28401 | 28472 | && __MAC_OS_X_VERSION_MIN_REQUIRED<1050 |
| 28402 | - if( gethostuuid(pHostID, &timeout) ){ | |
| 28403 | - int err = errno; | |
| 28404 | - if( pError ){ | |
| 28405 | - *pError = err; | |
| 28473 | + { | |
| 28474 | + static const struct timespec timeout = {1, 0}; /* 1 sec timeout */ | |
| 28475 | + if( gethostuuid(pHostID, &timeout) ){ | |
| 28476 | + int err = errno; | |
| 28477 | + if( pError ){ | |
| 28478 | + *pError = err; | |
| 28479 | + } | |
| 28480 | + return SQLITE_IOERR; | |
| 28406 | 28481 | } |
| 28407 | - return SQLITE_IOERR; | |
| 28408 | 28482 | } |
| 28409 | 28483 | #endif |
| 28410 | 28484 | #ifdef SQLITE_TEST |
| 28411 | 28485 | /* simulate multiple hosts by creating unique hostid file paths */ |
| 28412 | 28486 | if( sqlite3_hostid_num != 0){ |
| @@ -41896,18 +41970,18 @@ | ||
| 41896 | 41970 | ** |
| 41897 | 41971 | ** This functionality is used by the checkpoint code (see walCheckpoint()). |
| 41898 | 41972 | */ |
| 41899 | 41973 | struct WalIterator { |
| 41900 | 41974 | int iPrior; /* Last result returned from the iterator */ |
| 41901 | - int nSegment; /* Size of the aSegment[] array */ | |
| 41975 | + int nSegment; /* Number of entries in aSegment[] */ | |
| 41902 | 41976 | struct WalSegment { |
| 41903 | 41977 | int iNext; /* Next slot in aIndex[] not yet returned */ |
| 41904 | 41978 | ht_slot *aIndex; /* i0, i1, i2... such that aPgno[iN] ascend */ |
| 41905 | 41979 | u32 *aPgno; /* Array of page numbers. */ |
| 41906 | - int nEntry; /* Max size of aPgno[] and aIndex[] arrays */ | |
| 41980 | + int nEntry; /* Nr. of entries in aPgno[] and aIndex[] */ | |
| 41907 | 41981 | int iZero; /* Frame number associated with aPgno[0] */ |
| 41908 | - } aSegment[1]; /* One for every 32KB page in the WAL */ | |
| 41982 | + } aSegment[1]; /* One for every 32KB page in the wal-index */ | |
| 41909 | 41983 | }; |
| 41910 | 41984 | |
| 41911 | 41985 | /* |
| 41912 | 41986 | ** Define the parameters of the hash tables in the wal-index file. There |
| 41913 | 41987 | ** is a hash-table following every HASHTABLE_NPAGE page numbers in the |
| @@ -42767,13 +42841,33 @@ | ||
| 42767 | 42841 | return (iRet==0xFFFFFFFF); |
| 42768 | 42842 | } |
| 42769 | 42843 | |
| 42770 | 42844 | /* |
| 42771 | 42845 | ** This function merges two sorted lists into a single sorted list. |
| 42846 | +** | |
| 42847 | +** aLeft[] and aRight[] are arrays of indices. The sort key is | |
| 42848 | +** aContent[aLeft[]] and aContent[aRight[]]. Upon entry, the following | |
| 42849 | +** is guaranteed for all J<K: | |
| 42850 | +** | |
| 42851 | +** aContent[aLeft[J]] < aContent[aLeft[K]] | |
| 42852 | +** aContent[aRight[J]] < aContent[aRight[K]] | |
| 42853 | +** | |
| 42854 | +** This routine overwrites aRight[] with a new (probably longer) sequence | |
| 42855 | +** of indices such that the aRight[] contains every index that appears in | |
| 42856 | +** either aLeft[] or the old aRight[] and such that the second condition | |
| 42857 | +** above is still met. | |
| 42858 | +** | |
| 42859 | +** The aContent[aLeft[X]] values will be unique for all X. And the | |
| 42860 | +** aContent[aRight[X]] values will be unique too. But there might be | |
| 42861 | +** one or more combinations of X and Y such that | |
| 42862 | +** | |
| 42863 | +** aLeft[X]!=aRight[Y] && aContent[aLeft[X]] == aContent[aRight[Y]] | |
| 42864 | +** | |
| 42865 | +** When that happens, omit the aLeft[X] and use the aRight[Y] index. | |
| 42772 | 42866 | */ |
| 42773 | 42867 | static void walMerge( |
| 42774 | - u32 *aContent, /* Pages in wal */ | |
| 42868 | + const u32 *aContent, /* Pages in wal - keys for the sort */ | |
| 42775 | 42869 | ht_slot *aLeft, /* IN: Left hand input list */ |
| 42776 | 42870 | int nLeft, /* IN: Elements in array *paLeft */ |
| 42777 | 42871 | ht_slot **paRight, /* IN/OUT: Right hand input list */ |
| 42778 | 42872 | int *pnRight, /* IN/OUT: Elements in *paRight */ |
| 42779 | 42873 | ht_slot *aTmp /* Temporary buffer */ |
| @@ -42809,14 +42903,28 @@ | ||
| 42809 | 42903 | *pnRight = iOut; |
| 42810 | 42904 | memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut); |
| 42811 | 42905 | } |
| 42812 | 42906 | |
| 42813 | 42907 | /* |
| 42814 | -** Sort the elements in list aList, removing any duplicates. | |
| 42908 | +** Sort the elements in list aList using aContent[] as the sort key. | |
| 42909 | +** Remove elements with duplicate keys, preferring to keep the | |
| 42910 | +** larger aList[] values. | |
| 42911 | +** | |
| 42912 | +** The aList[] entries are indices into aContent[]. The values in | |
| 42913 | +** aList[] are to be sorted so that for all J<K: | |
| 42914 | +** | |
| 42915 | +** aContent[aList[J]] < aContent[aList[K]] | |
| 42916 | +** | |
| 42917 | +** For any X and Y such that | |
| 42918 | +** | |
| 42919 | +** aContent[aList[X]] == aContent[aList[Y]] | |
| 42920 | +** | |
| 42921 | +** Keep the larger of the two values aList[X] and aList[Y] and discard | |
| 42922 | +** the smaller. | |
| 42815 | 42923 | */ |
| 42816 | 42924 | static void walMergesort( |
| 42817 | - u32 *aContent, /* Pages in wal */ | |
| 42925 | + const u32 *aContent, /* Pages in wal */ | |
| 42818 | 42926 | ht_slot *aBuffer, /* Buffer of at least *pnList items to use */ |
| 42819 | 42927 | ht_slot *aList, /* IN/OUT: List to sort */ |
| 42820 | 42928 | int *pnList /* IN/OUT: Number of elements in aList[] */ |
| 42821 | 42929 | ){ |
| 42822 | 42930 | struct Sublist { |
| @@ -42877,10 +42985,11 @@ | ||
| 42877 | 42985 | } |
| 42878 | 42986 | |
| 42879 | 42987 | /* |
| 42880 | 42988 | ** Construct a WalInterator object that can be used to loop over all |
| 42881 | 42989 | ** pages in the WAL in ascending order. The caller must hold the checkpoint |
| 42990 | +** lock. | |
| 42882 | 42991 | ** |
| 42883 | 42992 | ** On success, make *pp point to the newly allocated WalInterator object |
| 42884 | 42993 | ** return SQLITE_OK. Otherwise, return an error code. If this routine |
| 42885 | 42994 | ** returns an error, the value of *pp is undefined. |
| 42886 | 42995 | ** |
| @@ -43011,11 +43120,12 @@ | ||
| 43011 | 43120 | volatile WalCkptInfo *pInfo; /* The checkpoint status information */ |
| 43012 | 43121 | |
| 43013 | 43122 | szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16); |
| 43014 | 43123 | testcase( szPage<=32768 ); |
| 43015 | 43124 | testcase( szPage>=65536 ); |
| 43016 | - if( pWal->hdr.mxFrame==0 ) return SQLITE_OK; | |
| 43125 | + pInfo = walCkptInfo(pWal); | |
| 43126 | + if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK; | |
| 43017 | 43127 | |
| 43018 | 43128 | /* Allocate the iterator */ |
| 43019 | 43129 | rc = walIteratorInit(pWal, &pIter); |
| 43020 | 43130 | if( rc!=SQLITE_OK ){ |
| 43021 | 43131 | return rc; |
| @@ -43033,11 +43143,10 @@ | ||
| 43033 | 43143 | ** overwrite database pages that are in use by active readers and thus |
| 43034 | 43144 | ** cannot be backfilled from the WAL. |
| 43035 | 43145 | */ |
| 43036 | 43146 | mxSafeFrame = pWal->hdr.mxFrame; |
| 43037 | 43147 | mxPage = pWal->hdr.nPage; |
| 43038 | - pInfo = walCkptInfo(pWal); | |
| 43039 | 43148 | for(i=1; i<WAL_NREADER; i++){ |
| 43040 | 43149 | u32 y = pInfo->aReadMark[i]; |
| 43041 | 43150 | if( mxSafeFrame>=y ){ |
| 43042 | 43151 | assert( y<=pWal->hdr.mxFrame ); |
| 43043 | 43152 | rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| @@ -55556,11 +55665,11 @@ | ||
| 55556 | 55665 | u8 opcode = pOp->opcode; |
| 55557 | 55666 | |
| 55558 | 55667 | pOp->opflags = sqlite3OpcodeProperty[opcode]; |
| 55559 | 55668 | if( opcode==OP_Function || opcode==OP_AggStep ){ |
| 55560 | 55669 | if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; |
| 55561 | - }else if( opcode==OP_Transaction && pOp->p2!=0 ){ | |
| 55670 | + }else if( (opcode==OP_Transaction && pOp->p2!=0) || opcode==OP_Vacuum ){ | |
| 55562 | 55671 | p->readOnly = 0; |
| 55563 | 55672 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 55564 | 55673 | }else if( opcode==OP_VUpdate ){ |
| 55565 | 55674 | if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; |
| 55566 | 55675 | }else if( opcode==OP_VFilter ){ |
| @@ -80921,13 +81030,13 @@ | ||
| 80921 | 81030 | if( caseSensitive ){ |
| 80922 | 81031 | pInfo = (struct compareInfo*)&likeInfoAlt; |
| 80923 | 81032 | }else{ |
| 80924 | 81033 | pInfo = (struct compareInfo*)&likeInfoNorm; |
| 80925 | 81034 | } |
| 80926 | - sqlite3CreateFunc(db, "like", 2, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); | |
| 80927 | - sqlite3CreateFunc(db, "like", 3, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); | |
| 80928 | - sqlite3CreateFunc(db, "glob", 2, SQLITE_ANY, | |
| 81035 | + sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); | |
| 81036 | + sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); | |
| 81037 | + sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, | |
| 80929 | 81038 | (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0); |
| 80930 | 81039 | setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); |
| 80931 | 81040 | setLikeOptFlag(db, "like", |
| 80932 | 81041 | caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE); |
| 80933 | 81042 | } |
| @@ -97673,14 +97782,13 @@ | ||
| 97673 | 97782 | Parse *pParse, |
| 97674 | 97783 | Expr *pExpr, |
| 97675 | 97784 | u8 aff, |
| 97676 | 97785 | sqlite3_value **pp |
| 97677 | 97786 | ){ |
| 97678 | - /* The evalConstExpr() function will have already converted any TK_VARIABLE | |
| 97679 | - ** expression involved in an comparison into a TK_REGISTER. */ | |
| 97680 | - assert( pExpr->op!=TK_VARIABLE ); | |
| 97681 | - if( pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE ){ | |
| 97787 | + if( pExpr->op==TK_VARIABLE | |
| 97788 | + || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) | |
| 97789 | + ){ | |
| 97682 | 97790 | int iVar = pExpr->iColumn; |
| 97683 | 97791 | sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-23257-02778 */ |
| 97684 | 97792 | *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); |
| 97685 | 97793 | return SQLITE_OK; |
| 97686 | 97794 | } |
| @@ -106470,10 +106578,13 @@ | ||
| 106470 | 106578 | | SQLITE_LoadExtension |
| 106471 | 106579 | #endif |
| 106472 | 106580 | #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS |
| 106473 | 106581 | | SQLITE_RecTriggers |
| 106474 | 106582 | #endif |
| 106583 | +#if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS | |
| 106584 | + | SQLITE_ForeignKeys | |
| 106585 | +#endif | |
| 106475 | 106586 | ; |
| 106476 | 106587 | sqlite3HashInit(&db->aCollSeq); |
| 106477 | 106588 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 106478 | 106589 | sqlite3HashInit(&db->aModule); |
| 106479 | 106590 | #endif |
| @@ -111307,13 +111418,20 @@ | ||
| 111307 | 111418 | int iCol /* Column of requested pos-list */ |
| 111308 | 111419 | ){ |
| 111309 | 111420 | assert( pExpr->isLoaded ); |
| 111310 | 111421 | if( pExpr->aDoclist ){ |
| 111311 | 111422 | char *pEnd = &pExpr->aDoclist[pExpr->nDoclist]; |
| 111312 | - char *pCsr = pExpr->pCurrent; | |
| 111423 | + char *pCsr; | |
| 111313 | 111424 | |
| 111425 | + if( pExpr->pCurrent==0 ){ | |
| 111426 | + pExpr->pCurrent = pExpr->aDoclist; | |
| 111427 | + pExpr->iCurrent = 0; | |
| 111428 | + pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent,&pExpr->iCurrent); | |
| 111429 | + } | |
| 111430 | + pCsr = pExpr->pCurrent; | |
| 111314 | 111431 | assert( pCsr ); |
| 111432 | + | |
| 111315 | 111433 | while( pCsr<pEnd ){ |
| 111316 | 111434 | if( pExpr->iCurrent<iDocid ){ |
| 111317 | 111435 | fts3PoslistCopy(0, &pCsr); |
| 111318 | 111436 | if( pCsr<pEnd ){ |
| 111319 | 111437 | fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent); |
| @@ -117513,11 +117631,11 @@ | ||
| 117513 | 117631 | /* |
| 117514 | 117632 | ** This is an fts3ExprIterate() callback used while loading the doclists |
| 117515 | 117633 | ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also |
| 117516 | 117634 | ** fts3ExprLoadDoclists(). |
| 117517 | 117635 | */ |
| 117518 | -static int fts3ExprLoadDoclistsCb1(Fts3Expr *pExpr, int iPhrase, void *ctx){ | |
| 117636 | +static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){ | |
| 117519 | 117637 | int rc = SQLITE_OK; |
| 117520 | 117638 | LoadDoclistCtx *p = (LoadDoclistCtx *)ctx; |
| 117521 | 117639 | |
| 117522 | 117640 | UNUSED_PARAMETER(iPhrase); |
| 117523 | 117641 | |
| @@ -117533,26 +117651,10 @@ | ||
| 117533 | 117651 | } |
| 117534 | 117652 | |
| 117535 | 117653 | return rc; |
| 117536 | 117654 | } |
| 117537 | 117655 | |
| 117538 | -/* | |
| 117539 | -** This is an fts3ExprIterate() callback used while loading the doclists | |
| 117540 | -** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also | |
| 117541 | -** fts3ExprLoadDoclists(). | |
| 117542 | -*/ | |
| 117543 | -static int fts3ExprLoadDoclistsCb2(Fts3Expr *pExpr, int iPhrase, void *ctx){ | |
| 117544 | - UNUSED_PARAMETER(iPhrase); | |
| 117545 | - UNUSED_PARAMETER(ctx); | |
| 117546 | - if( pExpr->aDoclist ){ | |
| 117547 | - pExpr->pCurrent = pExpr->aDoclist; | |
| 117548 | - pExpr->iCurrent = 0; | |
| 117549 | - pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent, &pExpr->iCurrent); | |
| 117550 | - } | |
| 117551 | - return SQLITE_OK; | |
| 117552 | -} | |
| 117553 | - | |
| 117554 | 117656 | /* |
| 117555 | 117657 | ** Load the doclists for each phrase in the query associated with FTS3 cursor |
| 117556 | 117658 | ** pCsr. |
| 117557 | 117659 | ** |
| 117558 | 117660 | ** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable |
| @@ -117567,14 +117669,11 @@ | ||
| 117567 | 117669 | int *pnToken /* OUT: Number of tokens in query */ |
| 117568 | 117670 | ){ |
| 117569 | 117671 | int rc; /* Return Code */ |
| 117570 | 117672 | LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */ |
| 117571 | 117673 | sCtx.pCsr = pCsr; |
| 117572 | - rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb1, (void *)&sCtx); | |
| 117573 | - if( rc==SQLITE_OK ){ | |
| 117574 | - (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb2, 0); | |
| 117575 | - } | |
| 117674 | + rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx); | |
| 117576 | 117675 | if( pnPhrase ) *pnPhrase = sCtx.nPhrase; |
| 117577 | 117676 | if( pnToken ) *pnToken = sCtx.nToken; |
| 117578 | 117677 | return rc; |
| 117579 | 117678 | } |
| 117580 | 117679 | |
| 117581 | 117680 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.4" |
| 654 | #define SQLITE_VERSION_NUMBER 3007004 |
| 655 | #define SQLITE_SOURCE_ID "2010-12-06 21:09:59 fabcb6b95e1d4059d1e6c6183f65846f6cbd5749" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -1256,10 +1256,15 @@ | |
| 1256 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 1257 | ** point to an integer (type int) containing the new chunk-size to use |
| 1258 | ** for the nominated database. Allocating database file space in large |
| 1259 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 1260 | ** improve performance on some systems. |
| 1261 | */ |
| 1262 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1263 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1264 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1265 | #define SQLITE_LAST_ERRNO 4 |
| @@ -3191,18 +3196,35 @@ | |
| 3191 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 3192 | |
| 3193 | /* |
| 3194 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 3195 | ** |
| 3196 | ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if |
| 3197 | ** the [prepared statement] X is [SELECT] statement and false (zero) if |
| 3198 | ** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], |
| 3199 | ** [ALTER], or [REINDEX] statement. |
| 3200 | ** If X is a NULL pointer or any other kind of statement, including but |
| 3201 | ** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], |
| 3202 | ** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is |
| 3203 | ** undefined. |
| 3204 | */ |
| 3205 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 3206 | |
| 3207 | /* |
| 3208 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5927,11 +5949,12 @@ | |
| 5927 | ** internal equivalents). Only the value returned in the |
| 5928 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5929 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5930 | ** |
| 5931 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5932 | ** <dd>This parameter records the number of separate memory allocations.</dd>)^ |
| 5933 | ** |
| 5934 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5935 | ** <dd>This parameter returns the number of pages used out of the |
| 5936 | ** [pagecache memory allocator] that was configured using |
| 5937 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -6032,10 +6055,32 @@ | |
| 6032 | ** |
| 6033 | ** <dl> |
| 6034 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 6035 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 6036 | ** checked out.</dd>)^ |
| 6037 | ** |
| 6038 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 6039 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6040 | ** memory used by all pager caches associated with the database connection.)^ |
| 6041 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -6055,15 +6100,18 @@ | |
| 6055 | ** the database connection.)^ |
| 6056 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 6057 | ** </dd> |
| 6058 | ** </dl> |
| 6059 | */ |
| 6060 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 6061 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 6062 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 6063 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 6064 | #define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ |
| 6065 | |
| 6066 | |
| 6067 | /* |
| 6068 | ** CAPI3REF: Prepared Statement Status |
| 6069 | ** |
| @@ -6307,15 +6355,16 @@ | |
| 6307 | ** It is useful either for creating backups of databases or |
| 6308 | ** for copying in-memory databases to or from persistent files. |
| 6309 | ** |
| 6310 | ** See Also: [Using the SQLite Online Backup API] |
| 6311 | ** |
| 6312 | ** ^Exclusive access is required to the destination database for the |
| 6313 | ** duration of the operation. ^However the source database is only |
| 6314 | ** read-locked while it is actually being read; it is not locked |
| 6315 | ** continuously for the entire backup operation. ^Thus, the backup may be |
| 6316 | ** performed on a live source database without preventing other users from |
| 6317 | ** reading or writing to the source database while the backup is underway. |
| 6318 | ** |
| 6319 | ** ^(To perform a backup operation: |
| 6320 | ** <ol> |
| 6321 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -6338,15 +6387,15 @@ | |
| 6338 | ** an [ATTACH] statement for an attached database. |
| 6339 | ** ^The S and M arguments passed to |
| 6340 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 6341 | ** and database name of the source database, respectively. |
| 6342 | ** ^The source and destination [database connections] (parameters S and D) |
| 6343 | ** must be different or else sqlite3_backup_init(D,N,S,M) will file with |
| 6344 | ** an error. |
| 6345 | ** |
| 6346 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 6347 | ** returned and an error code and error message are store3d in the |
| 6348 | ** destination [database connection] D. |
| 6349 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 6350 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 6351 | ** [sqlite3_errmsg16()] functions. |
| 6352 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -6359,11 +6408,11 @@ | |
| 6359 | ** |
| 6360 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 6361 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 6362 | ** ^If N is negative, all remaining source pages are copied. |
| 6363 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 6364 | ** are still more pages to be copied, then the function resturns [SQLITE_OK]. |
| 6365 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 6366 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 6367 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 6368 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 6369 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -6373,11 +6422,11 @@ | |
| 6373 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 6374 | ** <ol> |
| 6375 | ** <li> the destination database was opened read-only, or |
| 6376 | ** <li> the destination database is using write-ahead-log journaling |
| 6377 | ** and the destination and source page sizes differ, or |
| 6378 | ** <li> The destination database is an in-memory database and the |
| 6379 | ** destination and source page sizes differ. |
| 6380 | ** </ol>)^ |
| 6381 | ** |
| 6382 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 6383 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6704,11 +6753,12 @@ | |
| 6704 | ** |
| 6705 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6706 | ** from SQL. |
| 6707 | ** |
| 6708 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6709 | ** enabled with a threshold of 1000 pages. The use of this interface |
| 6710 | ** is only necessary if the default setting is found to be suboptimal |
| 6711 | ** for a particular application. |
| 6712 | */ |
| 6713 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6714 | |
| @@ -8875,10 +8925,11 @@ | |
| 8875 | u16 sz; /* Size of each buffer in bytes */ |
| 8876 | u8 bEnabled; /* False to disable new lookaside allocations */ |
| 8877 | u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ |
| 8878 | int nOut; /* Number of buffers currently checked out */ |
| 8879 | int mxOut; /* Highwater mark for nOut */ |
| 8880 | LookasideSlot *pFree; /* List of available buffers */ |
| 8881 | void *pStart; /* First byte of available memory space */ |
| 8882 | void *pEnd; /* First byte past end of available space */ |
| 8883 | }; |
| 8884 | struct LookasideSlot { |
| @@ -12506,10 +12557,26 @@ | |
| 12506 | if( resetFlag ){ |
| 12507 | db->lookaside.mxOut = db->lookaside.nOut; |
| 12508 | } |
| 12509 | break; |
| 12510 | } |
| 12511 | |
| 12512 | /* |
| 12513 | ** Return an approximation for the amount of memory currently used |
| 12514 | ** by all pagers associated with the given database connection. The |
| 12515 | ** highwater mark is meaningless and is returned as zero. |
| @@ -18068,18 +18135,24 @@ | |
| 18068 | if( db ){ |
| 18069 | LookasideSlot *pBuf; |
| 18070 | if( db->mallocFailed ){ |
| 18071 | return 0; |
| 18072 | } |
| 18073 | if( db->lookaside.bEnabled && n<=db->lookaside.sz |
| 18074 | && (pBuf = db->lookaside.pFree)!=0 ){ |
| 18075 | db->lookaside.pFree = pBuf->pNext; |
| 18076 | db->lookaside.nOut++; |
| 18077 | if( db->lookaside.nOut>db->lookaside.mxOut ){ |
| 18078 | db->lookaside.mxOut = db->lookaside.nOut; |
| 18079 | } |
| 18080 | return (void*)pBuf; |
| 18081 | } |
| 18082 | } |
| 18083 | #else |
| 18084 | if( db && db->mallocFailed ){ |
| 18085 | return 0; |
| @@ -28391,22 +28464,23 @@ | |
| 28391 | |
| 28392 | /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN |
| 28393 | ** bytes of writable memory. |
| 28394 | */ |
| 28395 | static int proxyGetHostID(unsigned char *pHostID, int *pError){ |
| 28396 | struct timespec timeout = {1, 0}; /* 1 sec timeout */ |
| 28397 | |
| 28398 | assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); |
| 28399 | memset(pHostID, 0, PROXY_HOSTIDLEN); |
| 28400 | #if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\ |
| 28401 | && __MAC_OS_X_VERSION_MIN_REQUIRED<1050 |
| 28402 | if( gethostuuid(pHostID, &timeout) ){ |
| 28403 | int err = errno; |
| 28404 | if( pError ){ |
| 28405 | *pError = err; |
| 28406 | } |
| 28407 | return SQLITE_IOERR; |
| 28408 | } |
| 28409 | #endif |
| 28410 | #ifdef SQLITE_TEST |
| 28411 | /* simulate multiple hosts by creating unique hostid file paths */ |
| 28412 | if( sqlite3_hostid_num != 0){ |
| @@ -41896,18 +41970,18 @@ | |
| 41896 | ** |
| 41897 | ** This functionality is used by the checkpoint code (see walCheckpoint()). |
| 41898 | */ |
| 41899 | struct WalIterator { |
| 41900 | int iPrior; /* Last result returned from the iterator */ |
| 41901 | int nSegment; /* Size of the aSegment[] array */ |
| 41902 | struct WalSegment { |
| 41903 | int iNext; /* Next slot in aIndex[] not yet returned */ |
| 41904 | ht_slot *aIndex; /* i0, i1, i2... such that aPgno[iN] ascend */ |
| 41905 | u32 *aPgno; /* Array of page numbers. */ |
| 41906 | int nEntry; /* Max size of aPgno[] and aIndex[] arrays */ |
| 41907 | int iZero; /* Frame number associated with aPgno[0] */ |
| 41908 | } aSegment[1]; /* One for every 32KB page in the WAL */ |
| 41909 | }; |
| 41910 | |
| 41911 | /* |
| 41912 | ** Define the parameters of the hash tables in the wal-index file. There |
| 41913 | ** is a hash-table following every HASHTABLE_NPAGE page numbers in the |
| @@ -42767,13 +42841,33 @@ | |
| 42767 | return (iRet==0xFFFFFFFF); |
| 42768 | } |
| 42769 | |
| 42770 | /* |
| 42771 | ** This function merges two sorted lists into a single sorted list. |
| 42772 | */ |
| 42773 | static void walMerge( |
| 42774 | u32 *aContent, /* Pages in wal */ |
| 42775 | ht_slot *aLeft, /* IN: Left hand input list */ |
| 42776 | int nLeft, /* IN: Elements in array *paLeft */ |
| 42777 | ht_slot **paRight, /* IN/OUT: Right hand input list */ |
| 42778 | int *pnRight, /* IN/OUT: Elements in *paRight */ |
| 42779 | ht_slot *aTmp /* Temporary buffer */ |
| @@ -42809,14 +42903,28 @@ | |
| 42809 | *pnRight = iOut; |
| 42810 | memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut); |
| 42811 | } |
| 42812 | |
| 42813 | /* |
| 42814 | ** Sort the elements in list aList, removing any duplicates. |
| 42815 | */ |
| 42816 | static void walMergesort( |
| 42817 | u32 *aContent, /* Pages in wal */ |
| 42818 | ht_slot *aBuffer, /* Buffer of at least *pnList items to use */ |
| 42819 | ht_slot *aList, /* IN/OUT: List to sort */ |
| 42820 | int *pnList /* IN/OUT: Number of elements in aList[] */ |
| 42821 | ){ |
| 42822 | struct Sublist { |
| @@ -42877,10 +42985,11 @@ | |
| 42877 | } |
| 42878 | |
| 42879 | /* |
| 42880 | ** Construct a WalInterator object that can be used to loop over all |
| 42881 | ** pages in the WAL in ascending order. The caller must hold the checkpoint |
| 42882 | ** |
| 42883 | ** On success, make *pp point to the newly allocated WalInterator object |
| 42884 | ** return SQLITE_OK. Otherwise, return an error code. If this routine |
| 42885 | ** returns an error, the value of *pp is undefined. |
| 42886 | ** |
| @@ -43011,11 +43120,12 @@ | |
| 43011 | volatile WalCkptInfo *pInfo; /* The checkpoint status information */ |
| 43012 | |
| 43013 | szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16); |
| 43014 | testcase( szPage<=32768 ); |
| 43015 | testcase( szPage>=65536 ); |
| 43016 | if( pWal->hdr.mxFrame==0 ) return SQLITE_OK; |
| 43017 | |
| 43018 | /* Allocate the iterator */ |
| 43019 | rc = walIteratorInit(pWal, &pIter); |
| 43020 | if( rc!=SQLITE_OK ){ |
| 43021 | return rc; |
| @@ -43033,11 +43143,10 @@ | |
| 43033 | ** overwrite database pages that are in use by active readers and thus |
| 43034 | ** cannot be backfilled from the WAL. |
| 43035 | */ |
| 43036 | mxSafeFrame = pWal->hdr.mxFrame; |
| 43037 | mxPage = pWal->hdr.nPage; |
| 43038 | pInfo = walCkptInfo(pWal); |
| 43039 | for(i=1; i<WAL_NREADER; i++){ |
| 43040 | u32 y = pInfo->aReadMark[i]; |
| 43041 | if( mxSafeFrame>=y ){ |
| 43042 | assert( y<=pWal->hdr.mxFrame ); |
| 43043 | rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| @@ -55556,11 +55665,11 @@ | |
| 55556 | u8 opcode = pOp->opcode; |
| 55557 | |
| 55558 | pOp->opflags = sqlite3OpcodeProperty[opcode]; |
| 55559 | if( opcode==OP_Function || opcode==OP_AggStep ){ |
| 55560 | if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; |
| 55561 | }else if( opcode==OP_Transaction && pOp->p2!=0 ){ |
| 55562 | p->readOnly = 0; |
| 55563 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 55564 | }else if( opcode==OP_VUpdate ){ |
| 55565 | if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; |
| 55566 | }else if( opcode==OP_VFilter ){ |
| @@ -80921,13 +81030,13 @@ | |
| 80921 | if( caseSensitive ){ |
| 80922 | pInfo = (struct compareInfo*)&likeInfoAlt; |
| 80923 | }else{ |
| 80924 | pInfo = (struct compareInfo*)&likeInfoNorm; |
| 80925 | } |
| 80926 | sqlite3CreateFunc(db, "like", 2, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); |
| 80927 | sqlite3CreateFunc(db, "like", 3, SQLITE_ANY, pInfo, likeFunc, 0, 0, 0); |
| 80928 | sqlite3CreateFunc(db, "glob", 2, SQLITE_ANY, |
| 80929 | (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0); |
| 80930 | setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); |
| 80931 | setLikeOptFlag(db, "like", |
| 80932 | caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE); |
| 80933 | } |
| @@ -97673,14 +97782,13 @@ | |
| 97673 | Parse *pParse, |
| 97674 | Expr *pExpr, |
| 97675 | u8 aff, |
| 97676 | sqlite3_value **pp |
| 97677 | ){ |
| 97678 | /* The evalConstExpr() function will have already converted any TK_VARIABLE |
| 97679 | ** expression involved in an comparison into a TK_REGISTER. */ |
| 97680 | assert( pExpr->op!=TK_VARIABLE ); |
| 97681 | if( pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE ){ |
| 97682 | int iVar = pExpr->iColumn; |
| 97683 | sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-23257-02778 */ |
| 97684 | *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); |
| 97685 | return SQLITE_OK; |
| 97686 | } |
| @@ -106470,10 +106578,13 @@ | |
| 106470 | | SQLITE_LoadExtension |
| 106471 | #endif |
| 106472 | #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS |
| 106473 | | SQLITE_RecTriggers |
| 106474 | #endif |
| 106475 | ; |
| 106476 | sqlite3HashInit(&db->aCollSeq); |
| 106477 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 106478 | sqlite3HashInit(&db->aModule); |
| 106479 | #endif |
| @@ -111307,13 +111418,20 @@ | |
| 111307 | int iCol /* Column of requested pos-list */ |
| 111308 | ){ |
| 111309 | assert( pExpr->isLoaded ); |
| 111310 | if( pExpr->aDoclist ){ |
| 111311 | char *pEnd = &pExpr->aDoclist[pExpr->nDoclist]; |
| 111312 | char *pCsr = pExpr->pCurrent; |
| 111313 | |
| 111314 | assert( pCsr ); |
| 111315 | while( pCsr<pEnd ){ |
| 111316 | if( pExpr->iCurrent<iDocid ){ |
| 111317 | fts3PoslistCopy(0, &pCsr); |
| 111318 | if( pCsr<pEnd ){ |
| 111319 | fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent); |
| @@ -117513,11 +117631,11 @@ | |
| 117513 | /* |
| 117514 | ** This is an fts3ExprIterate() callback used while loading the doclists |
| 117515 | ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also |
| 117516 | ** fts3ExprLoadDoclists(). |
| 117517 | */ |
| 117518 | static int fts3ExprLoadDoclistsCb1(Fts3Expr *pExpr, int iPhrase, void *ctx){ |
| 117519 | int rc = SQLITE_OK; |
| 117520 | LoadDoclistCtx *p = (LoadDoclistCtx *)ctx; |
| 117521 | |
| 117522 | UNUSED_PARAMETER(iPhrase); |
| 117523 | |
| @@ -117533,26 +117651,10 @@ | |
| 117533 | } |
| 117534 | |
| 117535 | return rc; |
| 117536 | } |
| 117537 | |
| 117538 | /* |
| 117539 | ** This is an fts3ExprIterate() callback used while loading the doclists |
| 117540 | ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also |
| 117541 | ** fts3ExprLoadDoclists(). |
| 117542 | */ |
| 117543 | static int fts3ExprLoadDoclistsCb2(Fts3Expr *pExpr, int iPhrase, void *ctx){ |
| 117544 | UNUSED_PARAMETER(iPhrase); |
| 117545 | UNUSED_PARAMETER(ctx); |
| 117546 | if( pExpr->aDoclist ){ |
| 117547 | pExpr->pCurrent = pExpr->aDoclist; |
| 117548 | pExpr->iCurrent = 0; |
| 117549 | pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent, &pExpr->iCurrent); |
| 117550 | } |
| 117551 | return SQLITE_OK; |
| 117552 | } |
| 117553 | |
| 117554 | /* |
| 117555 | ** Load the doclists for each phrase in the query associated with FTS3 cursor |
| 117556 | ** pCsr. |
| 117557 | ** |
| 117558 | ** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable |
| @@ -117567,14 +117669,11 @@ | |
| 117567 | int *pnToken /* OUT: Number of tokens in query */ |
| 117568 | ){ |
| 117569 | int rc; /* Return Code */ |
| 117570 | LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */ |
| 117571 | sCtx.pCsr = pCsr; |
| 117572 | rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb1, (void *)&sCtx); |
| 117573 | if( rc==SQLITE_OK ){ |
| 117574 | (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb2, 0); |
| 117575 | } |
| 117576 | if( pnPhrase ) *pnPhrase = sCtx.nPhrase; |
| 117577 | if( pnToken ) *pnToken = sCtx.nToken; |
| 117578 | return rc; |
| 117579 | } |
| 117580 | |
| 117581 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -650,11 +650,11 @@ | |
| 650 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 651 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 652 | */ |
| 653 | #define SQLITE_VERSION "3.7.4" |
| 654 | #define SQLITE_VERSION_NUMBER 3007004 |
| 655 | #define SQLITE_SOURCE_ID "2010-12-21 21:28:38 b0888047bb6d9ac55e29b9224df2ff650728bb78" |
| 656 | |
| 657 | /* |
| 658 | ** CAPI3REF: Run-Time Library Version Numbers |
| 659 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 660 | ** |
| @@ -1256,10 +1256,15 @@ | |
| 1256 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 1257 | ** point to an integer (type int) containing the new chunk-size to use |
| 1258 | ** for the nominated database. Allocating database file space in large |
| 1259 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 1260 | ** improve performance on some systems. |
| 1261 | ** |
| 1262 | ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer |
| 1263 | ** to the [sqlite3_file] object associated with a particular database |
| 1264 | ** connection. See the [sqlite3_file_control()] documentation for |
| 1265 | ** additional information. |
| 1266 | */ |
| 1267 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1268 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1269 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1270 | #define SQLITE_LAST_ERRNO 4 |
| @@ -3191,18 +3196,35 @@ | |
| 3196 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 3197 | |
| 3198 | /* |
| 3199 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 3200 | ** |
| 3201 | ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if |
| 3202 | ** and only if the [prepared statement] X is makes no direct changes to |
| 3203 | ** the content of the database file. |
| 3204 | ** |
| 3205 | ** Note that [application-defined SQL functions] or |
| 3206 | ** [virtual tables] might change the database indirectly as a side effect. |
| 3207 | ** ^(For example, if an application defines a function "eval()" that |
| 3208 | ** calls [sqlite3_exec()], then the following SQL statement would |
| 3209 | ** change the database file through side-effects: |
| 3210 | ** |
| 3211 | ** <blockquote><pre> |
| 3212 | ** SELECT eval('DELETE FROM t1') FROM t2; |
| 3213 | ** </pre></blockquote> |
| 3214 | ** |
| 3215 | ** But because the [SELECT] statement does not change the database file |
| 3216 | ** directly, sqlite3_stmt_readonly() would still return true.)^ |
| 3217 | ** |
| 3218 | ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], |
| 3219 | ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, |
| 3220 | ** since the statements themselves do not actually modify the database but |
| 3221 | ** rather they control the timing of when other statements modify the |
| 3222 | ** database. ^The [ATTACH] and [DETACH] statements also cause |
| 3223 | ** sqlite3_stmt_readonly() to return true since, while those statements |
| 3224 | ** change the configuration of a database connection, they do not make |
| 3225 | ** changes to the content of the database files on disk. |
| 3226 | */ |
| 3227 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 3228 | |
| 3229 | /* |
| 3230 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5927,11 +5949,12 @@ | |
| 5949 | ** internal equivalents). Only the value returned in the |
| 5950 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5951 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5952 | ** |
| 5953 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5954 | ** <dd>This parameter records the number of separate memory allocations |
| 5955 | ** currently checked out.</dd>)^ |
| 5956 | ** |
| 5957 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5958 | ** <dd>This parameter returns the number of pages used out of the |
| 5959 | ** [pagecache memory allocator] that was configured using |
| 5960 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -6032,10 +6055,32 @@ | |
| 6055 | ** |
| 6056 | ** <dl> |
| 6057 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 6058 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 6059 | ** checked out.</dd>)^ |
| 6060 | ** |
| 6061 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> |
| 6062 | ** <dd>This parameter returns the number malloc attempts that were |
| 6063 | ** satisfied using lookaside memory. Only the high-water value is meaningful; |
| 6064 | ** the current value is always zero. |
| 6065 | ** checked out.</dd>)^ |
| 6066 | ** |
| 6067 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> |
| 6068 | ** <dd>This parameter returns the number malloc attempts that might have |
| 6069 | ** been satisfied using lookaside memory but failed due to the amount of |
| 6070 | ** memory requested being larger than the lookaside slot size. |
| 6071 | ** Only the high-water value is meaningful; |
| 6072 | ** the current value is always zero. |
| 6073 | ** checked out.</dd>)^ |
| 6074 | ** |
| 6075 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> |
| 6076 | ** <dd>This parameter returns the number malloc attempts that might have |
| 6077 | ** been satisfied using lookaside memory but failed due to all lookaside |
| 6078 | ** memory already being in use. |
| 6079 | ** Only the high-water value is meaningful; |
| 6080 | ** the current value is always zero. |
| 6081 | ** checked out.</dd>)^ |
| 6082 | ** |
| 6083 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 6084 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 6085 | ** memory used by all pager caches associated with the database connection.)^ |
| 6086 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -6055,15 +6100,18 @@ | |
| 6100 | ** the database connection.)^ |
| 6101 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 6102 | ** </dd> |
| 6103 | ** </dl> |
| 6104 | */ |
| 6105 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 6106 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 6107 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 6108 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 6109 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 6110 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 6111 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 6112 | #define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ |
| 6113 | |
| 6114 | |
| 6115 | /* |
| 6116 | ** CAPI3REF: Prepared Statement Status |
| 6117 | ** |
| @@ -6307,15 +6355,16 @@ | |
| 6355 | ** It is useful either for creating backups of databases or |
| 6356 | ** for copying in-memory databases to or from persistent files. |
| 6357 | ** |
| 6358 | ** See Also: [Using the SQLite Online Backup API] |
| 6359 | ** |
| 6360 | ** ^SQLite holds a write transaction open on the destination database file |
| 6361 | ** for the duration of the backup operation. |
| 6362 | ** ^The source database is read-locked only while it is being read; |
| 6363 | ** it is not locked continuously for the entire backup operation. |
| 6364 | ** ^Thus, the backup may be performed on a live source database without |
| 6365 | ** preventing other database connections from |
| 6366 | ** reading or writing to the source database while the backup is underway. |
| 6367 | ** |
| 6368 | ** ^(To perform a backup operation: |
| 6369 | ** <ol> |
| 6370 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -6338,15 +6387,15 @@ | |
| 6387 | ** an [ATTACH] statement for an attached database. |
| 6388 | ** ^The S and M arguments passed to |
| 6389 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 6390 | ** and database name of the source database, respectively. |
| 6391 | ** ^The source and destination [database connections] (parameters S and D) |
| 6392 | ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with |
| 6393 | ** an error. |
| 6394 | ** |
| 6395 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 6396 | ** returned and an error code and error message are stored in the |
| 6397 | ** destination [database connection] D. |
| 6398 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 6399 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 6400 | ** [sqlite3_errmsg16()] functions. |
| 6401 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -6359,11 +6408,11 @@ | |
| 6408 | ** |
| 6409 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 6410 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 6411 | ** ^If N is negative, all remaining source pages are copied. |
| 6412 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 6413 | ** are still more pages to be copied, then the function returns [SQLITE_OK]. |
| 6414 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 6415 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 6416 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 6417 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 6418 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -6373,11 +6422,11 @@ | |
| 6422 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 6423 | ** <ol> |
| 6424 | ** <li> the destination database was opened read-only, or |
| 6425 | ** <li> the destination database is using write-ahead-log journaling |
| 6426 | ** and the destination and source page sizes differ, or |
| 6427 | ** <li> the destination database is an in-memory database and the |
| 6428 | ** destination and source page sizes differ. |
| 6429 | ** </ol>)^ |
| 6430 | ** |
| 6431 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 6432 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6704,11 +6753,12 @@ | |
| 6753 | ** |
| 6754 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6755 | ** from SQL. |
| 6756 | ** |
| 6757 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6758 | ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] |
| 6759 | ** pages. The use of this interface |
| 6760 | ** is only necessary if the default setting is found to be suboptimal |
| 6761 | ** for a particular application. |
| 6762 | */ |
| 6763 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6764 | |
| @@ -8875,10 +8925,11 @@ | |
| 8925 | u16 sz; /* Size of each buffer in bytes */ |
| 8926 | u8 bEnabled; /* False to disable new lookaside allocations */ |
| 8927 | u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ |
| 8928 | int nOut; /* Number of buffers currently checked out */ |
| 8929 | int mxOut; /* Highwater mark for nOut */ |
| 8930 | int anStat[3]; /* 0: hits. 1: size misses. 2: full misses */ |
| 8931 | LookasideSlot *pFree; /* List of available buffers */ |
| 8932 | void *pStart; /* First byte of available memory space */ |
| 8933 | void *pEnd; /* First byte past end of available space */ |
| 8934 | }; |
| 8935 | struct LookasideSlot { |
| @@ -12506,10 +12557,26 @@ | |
| 12557 | if( resetFlag ){ |
| 12558 | db->lookaside.mxOut = db->lookaside.nOut; |
| 12559 | } |
| 12560 | break; |
| 12561 | } |
| 12562 | |
| 12563 | case SQLITE_DBSTATUS_LOOKASIDE_HIT: |
| 12564 | case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE: |
| 12565 | case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: { |
| 12566 | testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT ); |
| 12567 | testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE ); |
| 12568 | testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL ); |
| 12569 | assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 ); |
| 12570 | assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 ); |
| 12571 | *pCurrent = 0; |
| 12572 | *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT]; |
| 12573 | if( resetFlag ){ |
| 12574 | db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0; |
| 12575 | } |
| 12576 | break; |
| 12577 | } |
| 12578 | |
| 12579 | /* |
| 12580 | ** Return an approximation for the amount of memory currently used |
| 12581 | ** by all pagers associated with the given database connection. The |
| 12582 | ** highwater mark is meaningless and is returned as zero. |
| @@ -18068,18 +18135,24 @@ | |
| 18135 | if( db ){ |
| 18136 | LookasideSlot *pBuf; |
| 18137 | if( db->mallocFailed ){ |
| 18138 | return 0; |
| 18139 | } |
| 18140 | if( db->lookaside.bEnabled ){ |
| 18141 | if( n>db->lookaside.sz ){ |
| 18142 | db->lookaside.anStat[1]++; |
| 18143 | }else if( (pBuf = db->lookaside.pFree)==0 ){ |
| 18144 | db->lookaside.anStat[2]++; |
| 18145 | }else{ |
| 18146 | db->lookaside.pFree = pBuf->pNext; |
| 18147 | db->lookaside.nOut++; |
| 18148 | db->lookaside.anStat[0]++; |
| 18149 | if( db->lookaside.nOut>db->lookaside.mxOut ){ |
| 18150 | db->lookaside.mxOut = db->lookaside.nOut; |
| 18151 | } |
| 18152 | return (void*)pBuf; |
| 18153 | } |
| 18154 | } |
| 18155 | } |
| 18156 | #else |
| 18157 | if( db && db->mallocFailed ){ |
| 18158 | return 0; |
| @@ -28391,22 +28464,23 @@ | |
| 28464 | |
| 28465 | /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN |
| 28466 | ** bytes of writable memory. |
| 28467 | */ |
| 28468 | static int proxyGetHostID(unsigned char *pHostID, int *pError){ |
| 28469 | assert(PROXY_HOSTIDLEN == sizeof(uuid_t)); |
| 28470 | memset(pHostID, 0, PROXY_HOSTIDLEN); |
| 28471 | #if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\ |
| 28472 | && __MAC_OS_X_VERSION_MIN_REQUIRED<1050 |
| 28473 | { |
| 28474 | static const struct timespec timeout = {1, 0}; /* 1 sec timeout */ |
| 28475 | if( gethostuuid(pHostID, &timeout) ){ |
| 28476 | int err = errno; |
| 28477 | if( pError ){ |
| 28478 | *pError = err; |
| 28479 | } |
| 28480 | return SQLITE_IOERR; |
| 28481 | } |
| 28482 | } |
| 28483 | #endif |
| 28484 | #ifdef SQLITE_TEST |
| 28485 | /* simulate multiple hosts by creating unique hostid file paths */ |
| 28486 | if( sqlite3_hostid_num != 0){ |
| @@ -41896,18 +41970,18 @@ | |
| 41970 | ** |
| 41971 | ** This functionality is used by the checkpoint code (see walCheckpoint()). |
| 41972 | */ |
| 41973 | struct WalIterator { |
| 41974 | int iPrior; /* Last result returned from the iterator */ |
| 41975 | int nSegment; /* Number of entries in aSegment[] */ |
| 41976 | struct WalSegment { |
| 41977 | int iNext; /* Next slot in aIndex[] not yet returned */ |
| 41978 | ht_slot *aIndex; /* i0, i1, i2... such that aPgno[iN] ascend */ |
| 41979 | u32 *aPgno; /* Array of page numbers. */ |
| 41980 | int nEntry; /* Nr. of entries in aPgno[] and aIndex[] */ |
| 41981 | int iZero; /* Frame number associated with aPgno[0] */ |
| 41982 | } aSegment[1]; /* One for every 32KB page in the wal-index */ |
| 41983 | }; |
| 41984 | |
| 41985 | /* |
| 41986 | ** Define the parameters of the hash tables in the wal-index file. There |
| 41987 | ** is a hash-table following every HASHTABLE_NPAGE page numbers in the |
| @@ -42767,13 +42841,33 @@ | |
| 42841 | return (iRet==0xFFFFFFFF); |
| 42842 | } |
| 42843 | |
| 42844 | /* |
| 42845 | ** This function merges two sorted lists into a single sorted list. |
| 42846 | ** |
| 42847 | ** aLeft[] and aRight[] are arrays of indices. The sort key is |
| 42848 | ** aContent[aLeft[]] and aContent[aRight[]]. Upon entry, the following |
| 42849 | ** is guaranteed for all J<K: |
| 42850 | ** |
| 42851 | ** aContent[aLeft[J]] < aContent[aLeft[K]] |
| 42852 | ** aContent[aRight[J]] < aContent[aRight[K]] |
| 42853 | ** |
| 42854 | ** This routine overwrites aRight[] with a new (probably longer) sequence |
| 42855 | ** of indices such that the aRight[] contains every index that appears in |
| 42856 | ** either aLeft[] or the old aRight[] and such that the second condition |
| 42857 | ** above is still met. |
| 42858 | ** |
| 42859 | ** The aContent[aLeft[X]] values will be unique for all X. And the |
| 42860 | ** aContent[aRight[X]] values will be unique too. But there might be |
| 42861 | ** one or more combinations of X and Y such that |
| 42862 | ** |
| 42863 | ** aLeft[X]!=aRight[Y] && aContent[aLeft[X]] == aContent[aRight[Y]] |
| 42864 | ** |
| 42865 | ** When that happens, omit the aLeft[X] and use the aRight[Y] index. |
| 42866 | */ |
| 42867 | static void walMerge( |
| 42868 | const u32 *aContent, /* Pages in wal - keys for the sort */ |
| 42869 | ht_slot *aLeft, /* IN: Left hand input list */ |
| 42870 | int nLeft, /* IN: Elements in array *paLeft */ |
| 42871 | ht_slot **paRight, /* IN/OUT: Right hand input list */ |
| 42872 | int *pnRight, /* IN/OUT: Elements in *paRight */ |
| 42873 | ht_slot *aTmp /* Temporary buffer */ |
| @@ -42809,14 +42903,28 @@ | |
| 42903 | *pnRight = iOut; |
| 42904 | memcpy(aLeft, aTmp, sizeof(aTmp[0])*iOut); |
| 42905 | } |
| 42906 | |
| 42907 | /* |
| 42908 | ** Sort the elements in list aList using aContent[] as the sort key. |
| 42909 | ** Remove elements with duplicate keys, preferring to keep the |
| 42910 | ** larger aList[] values. |
| 42911 | ** |
| 42912 | ** The aList[] entries are indices into aContent[]. The values in |
| 42913 | ** aList[] are to be sorted so that for all J<K: |
| 42914 | ** |
| 42915 | ** aContent[aList[J]] < aContent[aList[K]] |
| 42916 | ** |
| 42917 | ** For any X and Y such that |
| 42918 | ** |
| 42919 | ** aContent[aList[X]] == aContent[aList[Y]] |
| 42920 | ** |
| 42921 | ** Keep the larger of the two values aList[X] and aList[Y] and discard |
| 42922 | ** the smaller. |
| 42923 | */ |
| 42924 | static void walMergesort( |
| 42925 | const u32 *aContent, /* Pages in wal */ |
| 42926 | ht_slot *aBuffer, /* Buffer of at least *pnList items to use */ |
| 42927 | ht_slot *aList, /* IN/OUT: List to sort */ |
| 42928 | int *pnList /* IN/OUT: Number of elements in aList[] */ |
| 42929 | ){ |
| 42930 | struct Sublist { |
| @@ -42877,10 +42985,11 @@ | |
| 42985 | } |
| 42986 | |
| 42987 | /* |
| 42988 | ** Construct a WalInterator object that can be used to loop over all |
| 42989 | ** pages in the WAL in ascending order. The caller must hold the checkpoint |
| 42990 | ** lock. |
| 42991 | ** |
| 42992 | ** On success, make *pp point to the newly allocated WalInterator object |
| 42993 | ** return SQLITE_OK. Otherwise, return an error code. If this routine |
| 42994 | ** returns an error, the value of *pp is undefined. |
| 42995 | ** |
| @@ -43011,11 +43120,12 @@ | |
| 43120 | volatile WalCkptInfo *pInfo; /* The checkpoint status information */ |
| 43121 | |
| 43122 | szPage = (pWal->hdr.szPage&0xfe00) + ((pWal->hdr.szPage&0x0001)<<16); |
| 43123 | testcase( szPage<=32768 ); |
| 43124 | testcase( szPage>=65536 ); |
| 43125 | pInfo = walCkptInfo(pWal); |
| 43126 | if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK; |
| 43127 | |
| 43128 | /* Allocate the iterator */ |
| 43129 | rc = walIteratorInit(pWal, &pIter); |
| 43130 | if( rc!=SQLITE_OK ){ |
| 43131 | return rc; |
| @@ -43033,11 +43143,10 @@ | |
| 43143 | ** overwrite database pages that are in use by active readers and thus |
| 43144 | ** cannot be backfilled from the WAL. |
| 43145 | */ |
| 43146 | mxSafeFrame = pWal->hdr.mxFrame; |
| 43147 | mxPage = pWal->hdr.nPage; |
| 43148 | for(i=1; i<WAL_NREADER; i++){ |
| 43149 | u32 y = pInfo->aReadMark[i]; |
| 43150 | if( mxSafeFrame>=y ){ |
| 43151 | assert( y<=pWal->hdr.mxFrame ); |
| 43152 | rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1); |
| @@ -55556,11 +55665,11 @@ | |
| 55665 | u8 opcode = pOp->opcode; |
| 55666 | |
| 55667 | pOp->opflags = sqlite3OpcodeProperty[opcode]; |
| 55668 | if( opcode==OP_Function || opcode==OP_AggStep ){ |
| 55669 | if( pOp->p5>nMaxArgs ) nMaxArgs = pOp->p5; |
| 55670 | }else if( (opcode==OP_Transaction && pOp->p2!=0) || opcode==OP_Vacuum ){ |
| 55671 | p->readOnly = 0; |
| 55672 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 55673 | }else if( opcode==OP_VUpdate ){ |
| 55674 | if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2; |
| 55675 | }else if( opcode==OP_VFilter ){ |
| @@ -80921,13 +81030,13 @@ | |
| 81030 | if( caseSensitive ){ |
| 81031 | pInfo = (struct compareInfo*)&likeInfoAlt; |
| 81032 | }else{ |
| 81033 | pInfo = (struct compareInfo*)&likeInfoNorm; |
| 81034 | } |
| 81035 | sqlite3CreateFunc(db, "like", 2, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); |
| 81036 | sqlite3CreateFunc(db, "like", 3, SQLITE_UTF8, pInfo, likeFunc, 0, 0, 0); |
| 81037 | sqlite3CreateFunc(db, "glob", 2, SQLITE_UTF8, |
| 81038 | (struct compareInfo*)&globInfo, likeFunc, 0, 0, 0); |
| 81039 | setLikeOptFlag(db, "glob", SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE); |
| 81040 | setLikeOptFlag(db, "like", |
| 81041 | caseSensitive ? (SQLITE_FUNC_LIKE | SQLITE_FUNC_CASE) : SQLITE_FUNC_LIKE); |
| 81042 | } |
| @@ -97673,14 +97782,13 @@ | |
| 97782 | Parse *pParse, |
| 97783 | Expr *pExpr, |
| 97784 | u8 aff, |
| 97785 | sqlite3_value **pp |
| 97786 | ){ |
| 97787 | if( pExpr->op==TK_VARIABLE |
| 97788 | || (pExpr->op==TK_REGISTER && pExpr->op2==TK_VARIABLE) |
| 97789 | ){ |
| 97790 | int iVar = pExpr->iColumn; |
| 97791 | sqlite3VdbeSetVarmask(pParse->pVdbe, iVar); /* IMP: R-23257-02778 */ |
| 97792 | *pp = sqlite3VdbeGetValue(pParse->pReprepare, iVar, aff); |
| 97793 | return SQLITE_OK; |
| 97794 | } |
| @@ -106470,10 +106578,13 @@ | |
| 106578 | | SQLITE_LoadExtension |
| 106579 | #endif |
| 106580 | #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS |
| 106581 | | SQLITE_RecTriggers |
| 106582 | #endif |
| 106583 | #if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS |
| 106584 | | SQLITE_ForeignKeys |
| 106585 | #endif |
| 106586 | ; |
| 106587 | sqlite3HashInit(&db->aCollSeq); |
| 106588 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 106589 | sqlite3HashInit(&db->aModule); |
| 106590 | #endif |
| @@ -111307,13 +111418,20 @@ | |
| 111418 | int iCol /* Column of requested pos-list */ |
| 111419 | ){ |
| 111420 | assert( pExpr->isLoaded ); |
| 111421 | if( pExpr->aDoclist ){ |
| 111422 | char *pEnd = &pExpr->aDoclist[pExpr->nDoclist]; |
| 111423 | char *pCsr; |
| 111424 | |
| 111425 | if( pExpr->pCurrent==0 ){ |
| 111426 | pExpr->pCurrent = pExpr->aDoclist; |
| 111427 | pExpr->iCurrent = 0; |
| 111428 | pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent,&pExpr->iCurrent); |
| 111429 | } |
| 111430 | pCsr = pExpr->pCurrent; |
| 111431 | assert( pCsr ); |
| 111432 | |
| 111433 | while( pCsr<pEnd ){ |
| 111434 | if( pExpr->iCurrent<iDocid ){ |
| 111435 | fts3PoslistCopy(0, &pCsr); |
| 111436 | if( pCsr<pEnd ){ |
| 111437 | fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent); |
| @@ -117513,11 +117631,11 @@ | |
| 117631 | /* |
| 117632 | ** This is an fts3ExprIterate() callback used while loading the doclists |
| 117633 | ** for each phrase into Fts3Expr.aDoclist[]/nDoclist. See also |
| 117634 | ** fts3ExprLoadDoclists(). |
| 117635 | */ |
| 117636 | static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, int iPhrase, void *ctx){ |
| 117637 | int rc = SQLITE_OK; |
| 117638 | LoadDoclistCtx *p = (LoadDoclistCtx *)ctx; |
| 117639 | |
| 117640 | UNUSED_PARAMETER(iPhrase); |
| 117641 | |
| @@ -117533,26 +117651,10 @@ | |
| 117651 | } |
| 117652 | |
| 117653 | return rc; |
| 117654 | } |
| 117655 | |
| 117656 | /* |
| 117657 | ** Load the doclists for each phrase in the query associated with FTS3 cursor |
| 117658 | ** pCsr. |
| 117659 | ** |
| 117660 | ** If pnPhrase is not NULL, then *pnPhrase is set to the number of matchable |
| @@ -117567,14 +117669,11 @@ | |
| 117669 | int *pnToken /* OUT: Number of tokens in query */ |
| 117670 | ){ |
| 117671 | int rc; /* Return Code */ |
| 117672 | LoadDoclistCtx sCtx = {0,0,0}; /* Context for fts3ExprIterate() */ |
| 117673 | sCtx.pCsr = pCsr; |
| 117674 | rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx); |
| 117675 | if( pnPhrase ) *pnPhrase = sCtx.nPhrase; |
| 117676 | if( pnToken ) *pnToken = sCtx.nToken; |
| 117677 | return rc; |
| 117678 | } |
| 117679 | |
| 117680 |
+75
-25
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.4" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007004 |
| 112 | -#define SQLITE_SOURCE_ID "2010-12-06 21:09:59 fabcb6b95e1d4059d1e6c6183f65846f6cbd5749" | |
| 112 | +#define SQLITE_SOURCE_ID "2010-12-21 21:28:38 b0888047bb6d9ac55e29b9224df2ff650728bb78" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| @@ -713,10 +713,15 @@ | ||
| 713 | 713 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 714 | 714 | ** point to an integer (type int) containing the new chunk-size to use |
| 715 | 715 | ** for the nominated database. Allocating database file space in large |
| 716 | 716 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 717 | 717 | ** improve performance on some systems. |
| 718 | +** | |
| 719 | +** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer | |
| 720 | +** to the [sqlite3_file] object associated with a particular database | |
| 721 | +** connection. See the [sqlite3_file_control()] documentation for | |
| 722 | +** additional information. | |
| 718 | 723 | */ |
| 719 | 724 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 720 | 725 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 721 | 726 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 722 | 727 | #define SQLITE_LAST_ERRNO 4 |
| @@ -2648,18 +2653,35 @@ | ||
| 2648 | 2653 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 2649 | 2654 | |
| 2650 | 2655 | /* |
| 2651 | 2656 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 2652 | 2657 | ** |
| 2653 | -** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if | |
| 2654 | -** the [prepared statement] X is [SELECT] statement and false (zero) if | |
| 2655 | -** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], | |
| 2656 | -** [ALTER], or [REINDEX] statement. | |
| 2657 | -** If X is a NULL pointer or any other kind of statement, including but | |
| 2658 | -** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], | |
| 2659 | -** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is | |
| 2660 | -** undefined. | |
| 2658 | +** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if | |
| 2659 | +** and only if the [prepared statement] X is makes no direct changes to | |
| 2660 | +** the content of the database file. | |
| 2661 | +** | |
| 2662 | +** Note that [application-defined SQL functions] or | |
| 2663 | +** [virtual tables] might change the database indirectly as a side effect. | |
| 2664 | +** ^(For example, if an application defines a function "eval()" that | |
| 2665 | +** calls [sqlite3_exec()], then the following SQL statement would | |
| 2666 | +** change the database file through side-effects: | |
| 2667 | +** | |
| 2668 | +** <blockquote><pre> | |
| 2669 | +** SELECT eval('DELETE FROM t1') FROM t2; | |
| 2670 | +** </pre></blockquote> | |
| 2671 | +** | |
| 2672 | +** But because the [SELECT] statement does not change the database file | |
| 2673 | +** directly, sqlite3_stmt_readonly() would still return true.)^ | |
| 2674 | +** | |
| 2675 | +** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], | |
| 2676 | +** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, | |
| 2677 | +** since the statements themselves do not actually modify the database but | |
| 2678 | +** rather they control the timing of when other statements modify the | |
| 2679 | +** database. ^The [ATTACH] and [DETACH] statements also cause | |
| 2680 | +** sqlite3_stmt_readonly() to return true since, while those statements | |
| 2681 | +** change the configuration of a database connection, they do not make | |
| 2682 | +** changes to the content of the database files on disk. | |
| 2661 | 2683 | */ |
| 2662 | 2684 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 2663 | 2685 | |
| 2664 | 2686 | /* |
| 2665 | 2687 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5384,11 +5406,12 @@ | ||
| 5384 | 5406 | ** internal equivalents). Only the value returned in the |
| 5385 | 5407 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5386 | 5408 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5387 | 5409 | ** |
| 5388 | 5410 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5389 | -** <dd>This parameter records the number of separate memory allocations.</dd>)^ | |
| 5411 | +** <dd>This parameter records the number of separate memory allocations | |
| 5412 | +** currently checked out.</dd>)^ | |
| 5390 | 5413 | ** |
| 5391 | 5414 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5392 | 5415 | ** <dd>This parameter returns the number of pages used out of the |
| 5393 | 5416 | ** [pagecache memory allocator] that was configured using |
| 5394 | 5417 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -5489,10 +5512,32 @@ | ||
| 5489 | 5512 | ** |
| 5490 | 5513 | ** <dl> |
| 5491 | 5514 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 5492 | 5515 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 5493 | 5516 | ** checked out.</dd>)^ |
| 5517 | +** | |
| 5518 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> | |
| 5519 | +** <dd>This parameter returns the number malloc attempts that were | |
| 5520 | +** satisfied using lookaside memory. Only the high-water value is meaningful; | |
| 5521 | +** the current value is always zero. | |
| 5522 | +** checked out.</dd>)^ | |
| 5523 | +** | |
| 5524 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> | |
| 5525 | +** <dd>This parameter returns the number malloc attempts that might have | |
| 5526 | +** been satisfied using lookaside memory but failed due to the amount of | |
| 5527 | +** memory requested being larger than the lookaside slot size. | |
| 5528 | +** Only the high-water value is meaningful; | |
| 5529 | +** the current value is always zero. | |
| 5530 | +** checked out.</dd>)^ | |
| 5531 | +** | |
| 5532 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> | |
| 5533 | +** <dd>This parameter returns the number malloc attempts that might have | |
| 5534 | +** been satisfied using lookaside memory but failed due to all lookaside | |
| 5535 | +** memory already being in use. | |
| 5536 | +** Only the high-water value is meaningful; | |
| 5537 | +** the current value is always zero. | |
| 5538 | +** checked out.</dd>)^ | |
| 5494 | 5539 | ** |
| 5495 | 5540 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 5496 | 5541 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 5497 | 5542 | ** memory used by all pager caches associated with the database connection.)^ |
| 5498 | 5543 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -5512,15 +5557,18 @@ | ||
| 5512 | 5557 | ** the database connection.)^ |
| 5513 | 5558 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 5514 | 5559 | ** </dd> |
| 5515 | 5560 | ** </dl> |
| 5516 | 5561 | */ |
| 5517 | -#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 | |
| 5518 | -#define SQLITE_DBSTATUS_CACHE_USED 1 | |
| 5519 | -#define SQLITE_DBSTATUS_SCHEMA_USED 2 | |
| 5520 | -#define SQLITE_DBSTATUS_STMT_USED 3 | |
| 5521 | -#define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ | |
| 5562 | +#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 | |
| 5563 | +#define SQLITE_DBSTATUS_CACHE_USED 1 | |
| 5564 | +#define SQLITE_DBSTATUS_SCHEMA_USED 2 | |
| 5565 | +#define SQLITE_DBSTATUS_STMT_USED 3 | |
| 5566 | +#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 | |
| 5567 | +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 | |
| 5568 | +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 | |
| 5569 | +#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ | |
| 5522 | 5570 | |
| 5523 | 5571 | |
| 5524 | 5572 | /* |
| 5525 | 5573 | ** CAPI3REF: Prepared Statement Status |
| 5526 | 5574 | ** |
| @@ -5764,15 +5812,16 @@ | ||
| 5764 | 5812 | ** It is useful either for creating backups of databases or |
| 5765 | 5813 | ** for copying in-memory databases to or from persistent files. |
| 5766 | 5814 | ** |
| 5767 | 5815 | ** See Also: [Using the SQLite Online Backup API] |
| 5768 | 5816 | ** |
| 5769 | -** ^Exclusive access is required to the destination database for the | |
| 5770 | -** duration of the operation. ^However the source database is only | |
| 5771 | -** read-locked while it is actually being read; it is not locked | |
| 5772 | -** continuously for the entire backup operation. ^Thus, the backup may be | |
| 5773 | -** performed on a live source database without preventing other users from | |
| 5817 | +** ^SQLite holds a write transaction open on the destination database file | |
| 5818 | +** for the duration of the backup operation. | |
| 5819 | +** ^The source database is read-locked only while it is being read; | |
| 5820 | +** it is not locked continuously for the entire backup operation. | |
| 5821 | +** ^Thus, the backup may be performed on a live source database without | |
| 5822 | +** preventing other database connections from | |
| 5774 | 5823 | ** reading or writing to the source database while the backup is underway. |
| 5775 | 5824 | ** |
| 5776 | 5825 | ** ^(To perform a backup operation: |
| 5777 | 5826 | ** <ol> |
| 5778 | 5827 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -5795,15 +5844,15 @@ | ||
| 5795 | 5844 | ** an [ATTACH] statement for an attached database. |
| 5796 | 5845 | ** ^The S and M arguments passed to |
| 5797 | 5846 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 5798 | 5847 | ** and database name of the source database, respectively. |
| 5799 | 5848 | ** ^The source and destination [database connections] (parameters S and D) |
| 5800 | -** must be different or else sqlite3_backup_init(D,N,S,M) will file with | |
| 5849 | +** must be different or else sqlite3_backup_init(D,N,S,M) will fail with | |
| 5801 | 5850 | ** an error. |
| 5802 | 5851 | ** |
| 5803 | 5852 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 5804 | -** returned and an error code and error message are store3d in the | |
| 5853 | +** returned and an error code and error message are stored in the | |
| 5805 | 5854 | ** destination [database connection] D. |
| 5806 | 5855 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 5807 | 5856 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 5808 | 5857 | ** [sqlite3_errmsg16()] functions. |
| 5809 | 5858 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -5816,11 +5865,11 @@ | ||
| 5816 | 5865 | ** |
| 5817 | 5866 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 5818 | 5867 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 5819 | 5868 | ** ^If N is negative, all remaining source pages are copied. |
| 5820 | 5869 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 5821 | -** are still more pages to be copied, then the function resturns [SQLITE_OK]. | |
| 5870 | +** are still more pages to be copied, then the function returns [SQLITE_OK]. | |
| 5822 | 5871 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 5823 | 5872 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 5824 | 5873 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 5825 | 5874 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 5826 | 5875 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -5830,11 +5879,11 @@ | ||
| 5830 | 5879 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 5831 | 5880 | ** <ol> |
| 5832 | 5881 | ** <li> the destination database was opened read-only, or |
| 5833 | 5882 | ** <li> the destination database is using write-ahead-log journaling |
| 5834 | 5883 | ** and the destination and source page sizes differ, or |
| 5835 | -** <li> The destination database is an in-memory database and the | |
| 5884 | +** <li> the destination database is an in-memory database and the | |
| 5836 | 5885 | ** destination and source page sizes differ. |
| 5837 | 5886 | ** </ol>)^ |
| 5838 | 5887 | ** |
| 5839 | 5888 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 5840 | 5889 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6161,11 +6210,12 @@ | ||
| 6161 | 6210 | ** |
| 6162 | 6211 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6163 | 6212 | ** from SQL. |
| 6164 | 6213 | ** |
| 6165 | 6214 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6166 | -** enabled with a threshold of 1000 pages. The use of this interface | |
| 6215 | +** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] | |
| 6216 | +** pages. The use of this interface | |
| 6167 | 6217 | ** is only necessary if the default setting is found to be suboptimal |
| 6168 | 6218 | ** for a particular application. |
| 6169 | 6219 | */ |
| 6170 | 6220 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6171 | 6221 | |
| 6172 | 6222 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.4" |
| 111 | #define SQLITE_VERSION_NUMBER 3007004 |
| 112 | #define SQLITE_SOURCE_ID "2010-12-06 21:09:59 fabcb6b95e1d4059d1e6c6183f65846f6cbd5749" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -713,10 +713,15 @@ | |
| 713 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 714 | ** point to an integer (type int) containing the new chunk-size to use |
| 715 | ** for the nominated database. Allocating database file space in large |
| 716 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 717 | ** improve performance on some systems. |
| 718 | */ |
| 719 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 720 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 721 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 722 | #define SQLITE_LAST_ERRNO 4 |
| @@ -2648,18 +2653,35 @@ | |
| 2648 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 2649 | |
| 2650 | /* |
| 2651 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 2652 | ** |
| 2653 | ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if |
| 2654 | ** the [prepared statement] X is [SELECT] statement and false (zero) if |
| 2655 | ** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], |
| 2656 | ** [ALTER], or [REINDEX] statement. |
| 2657 | ** If X is a NULL pointer or any other kind of statement, including but |
| 2658 | ** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], |
| 2659 | ** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is |
| 2660 | ** undefined. |
| 2661 | */ |
| 2662 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 2663 | |
| 2664 | /* |
| 2665 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5384,11 +5406,12 @@ | |
| 5384 | ** internal equivalents). Only the value returned in the |
| 5385 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5386 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5387 | ** |
| 5388 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5389 | ** <dd>This parameter records the number of separate memory allocations.</dd>)^ |
| 5390 | ** |
| 5391 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5392 | ** <dd>This parameter returns the number of pages used out of the |
| 5393 | ** [pagecache memory allocator] that was configured using |
| 5394 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -5489,10 +5512,32 @@ | |
| 5489 | ** |
| 5490 | ** <dl> |
| 5491 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 5492 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 5493 | ** checked out.</dd>)^ |
| 5494 | ** |
| 5495 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 5496 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 5497 | ** memory used by all pager caches associated with the database connection.)^ |
| 5498 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -5512,15 +5557,18 @@ | |
| 5512 | ** the database connection.)^ |
| 5513 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 5514 | ** </dd> |
| 5515 | ** </dl> |
| 5516 | */ |
| 5517 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 5518 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 5519 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 5520 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 5521 | #define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ |
| 5522 | |
| 5523 | |
| 5524 | /* |
| 5525 | ** CAPI3REF: Prepared Statement Status |
| 5526 | ** |
| @@ -5764,15 +5812,16 @@ | |
| 5764 | ** It is useful either for creating backups of databases or |
| 5765 | ** for copying in-memory databases to or from persistent files. |
| 5766 | ** |
| 5767 | ** See Also: [Using the SQLite Online Backup API] |
| 5768 | ** |
| 5769 | ** ^Exclusive access is required to the destination database for the |
| 5770 | ** duration of the operation. ^However the source database is only |
| 5771 | ** read-locked while it is actually being read; it is not locked |
| 5772 | ** continuously for the entire backup operation. ^Thus, the backup may be |
| 5773 | ** performed on a live source database without preventing other users from |
| 5774 | ** reading or writing to the source database while the backup is underway. |
| 5775 | ** |
| 5776 | ** ^(To perform a backup operation: |
| 5777 | ** <ol> |
| 5778 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -5795,15 +5844,15 @@ | |
| 5795 | ** an [ATTACH] statement for an attached database. |
| 5796 | ** ^The S and M arguments passed to |
| 5797 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 5798 | ** and database name of the source database, respectively. |
| 5799 | ** ^The source and destination [database connections] (parameters S and D) |
| 5800 | ** must be different or else sqlite3_backup_init(D,N,S,M) will file with |
| 5801 | ** an error. |
| 5802 | ** |
| 5803 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 5804 | ** returned and an error code and error message are store3d in the |
| 5805 | ** destination [database connection] D. |
| 5806 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 5807 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 5808 | ** [sqlite3_errmsg16()] functions. |
| 5809 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -5816,11 +5865,11 @@ | |
| 5816 | ** |
| 5817 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 5818 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 5819 | ** ^If N is negative, all remaining source pages are copied. |
| 5820 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 5821 | ** are still more pages to be copied, then the function resturns [SQLITE_OK]. |
| 5822 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 5823 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 5824 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 5825 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 5826 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -5830,11 +5879,11 @@ | |
| 5830 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 5831 | ** <ol> |
| 5832 | ** <li> the destination database was opened read-only, or |
| 5833 | ** <li> the destination database is using write-ahead-log journaling |
| 5834 | ** and the destination and source page sizes differ, or |
| 5835 | ** <li> The destination database is an in-memory database and the |
| 5836 | ** destination and source page sizes differ. |
| 5837 | ** </ol>)^ |
| 5838 | ** |
| 5839 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 5840 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6161,11 +6210,12 @@ | |
| 6161 | ** |
| 6162 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6163 | ** from SQL. |
| 6164 | ** |
| 6165 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6166 | ** enabled with a threshold of 1000 pages. The use of this interface |
| 6167 | ** is only necessary if the default setting is found to be suboptimal |
| 6168 | ** for a particular application. |
| 6169 | */ |
| 6170 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6171 | |
| 6172 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.4" |
| 111 | #define SQLITE_VERSION_NUMBER 3007004 |
| 112 | #define SQLITE_SOURCE_ID "2010-12-21 21:28:38 b0888047bb6d9ac55e29b9224df2ff650728bb78" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -713,10 +713,15 @@ | |
| 713 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 714 | ** point to an integer (type int) containing the new chunk-size to use |
| 715 | ** for the nominated database. Allocating database file space in large |
| 716 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 717 | ** improve performance on some systems. |
| 718 | ** |
| 719 | ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer |
| 720 | ** to the [sqlite3_file] object associated with a particular database |
| 721 | ** connection. See the [sqlite3_file_control()] documentation for |
| 722 | ** additional information. |
| 723 | */ |
| 724 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 725 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 726 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 727 | #define SQLITE_LAST_ERRNO 4 |
| @@ -2648,18 +2653,35 @@ | |
| 2653 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 2654 | |
| 2655 | /* |
| 2656 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 2657 | ** |
| 2658 | ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if |
| 2659 | ** and only if the [prepared statement] X is makes no direct changes to |
| 2660 | ** the content of the database file. |
| 2661 | ** |
| 2662 | ** Note that [application-defined SQL functions] or |
| 2663 | ** [virtual tables] might change the database indirectly as a side effect. |
| 2664 | ** ^(For example, if an application defines a function "eval()" that |
| 2665 | ** calls [sqlite3_exec()], then the following SQL statement would |
| 2666 | ** change the database file through side-effects: |
| 2667 | ** |
| 2668 | ** <blockquote><pre> |
| 2669 | ** SELECT eval('DELETE FROM t1') FROM t2; |
| 2670 | ** </pre></blockquote> |
| 2671 | ** |
| 2672 | ** But because the [SELECT] statement does not change the database file |
| 2673 | ** directly, sqlite3_stmt_readonly() would still return true.)^ |
| 2674 | ** |
| 2675 | ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], |
| 2676 | ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, |
| 2677 | ** since the statements themselves do not actually modify the database but |
| 2678 | ** rather they control the timing of when other statements modify the |
| 2679 | ** database. ^The [ATTACH] and [DETACH] statements also cause |
| 2680 | ** sqlite3_stmt_readonly() to return true since, while those statements |
| 2681 | ** change the configuration of a database connection, they do not make |
| 2682 | ** changes to the content of the database files on disk. |
| 2683 | */ |
| 2684 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 2685 | |
| 2686 | /* |
| 2687 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5384,11 +5406,12 @@ | |
| 5406 | ** internal equivalents). Only the value returned in the |
| 5407 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5408 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5409 | ** |
| 5410 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5411 | ** <dd>This parameter records the number of separate memory allocations |
| 5412 | ** currently checked out.</dd>)^ |
| 5413 | ** |
| 5414 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5415 | ** <dd>This parameter returns the number of pages used out of the |
| 5416 | ** [pagecache memory allocator] that was configured using |
| 5417 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -5489,10 +5512,32 @@ | |
| 5512 | ** |
| 5513 | ** <dl> |
| 5514 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 5515 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 5516 | ** checked out.</dd>)^ |
| 5517 | ** |
| 5518 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> |
| 5519 | ** <dd>This parameter returns the number malloc attempts that were |
| 5520 | ** satisfied using lookaside memory. Only the high-water value is meaningful; |
| 5521 | ** the current value is always zero. |
| 5522 | ** checked out.</dd>)^ |
| 5523 | ** |
| 5524 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> |
| 5525 | ** <dd>This parameter returns the number malloc attempts that might have |
| 5526 | ** been satisfied using lookaside memory but failed due to the amount of |
| 5527 | ** memory requested being larger than the lookaside slot size. |
| 5528 | ** Only the high-water value is meaningful; |
| 5529 | ** the current value is always zero. |
| 5530 | ** checked out.</dd>)^ |
| 5531 | ** |
| 5532 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> |
| 5533 | ** <dd>This parameter returns the number malloc attempts that might have |
| 5534 | ** been satisfied using lookaside memory but failed due to all lookaside |
| 5535 | ** memory already being in use. |
| 5536 | ** Only the high-water value is meaningful; |
| 5537 | ** the current value is always zero. |
| 5538 | ** checked out.</dd>)^ |
| 5539 | ** |
| 5540 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 5541 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 5542 | ** memory used by all pager caches associated with the database connection.)^ |
| 5543 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -5512,15 +5557,18 @@ | |
| 5557 | ** the database connection.)^ |
| 5558 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 5559 | ** </dd> |
| 5560 | ** </dl> |
| 5561 | */ |
| 5562 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 5563 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 5564 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 5565 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 5566 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 5567 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 5568 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 5569 | #define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ |
| 5570 | |
| 5571 | |
| 5572 | /* |
| 5573 | ** CAPI3REF: Prepared Statement Status |
| 5574 | ** |
| @@ -5764,15 +5812,16 @@ | |
| 5812 | ** It is useful either for creating backups of databases or |
| 5813 | ** for copying in-memory databases to or from persistent files. |
| 5814 | ** |
| 5815 | ** See Also: [Using the SQLite Online Backup API] |
| 5816 | ** |
| 5817 | ** ^SQLite holds a write transaction open on the destination database file |
| 5818 | ** for the duration of the backup operation. |
| 5819 | ** ^The source database is read-locked only while it is being read; |
| 5820 | ** it is not locked continuously for the entire backup operation. |
| 5821 | ** ^Thus, the backup may be performed on a live source database without |
| 5822 | ** preventing other database connections from |
| 5823 | ** reading or writing to the source database while the backup is underway. |
| 5824 | ** |
| 5825 | ** ^(To perform a backup operation: |
| 5826 | ** <ol> |
| 5827 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -5795,15 +5844,15 @@ | |
| 5844 | ** an [ATTACH] statement for an attached database. |
| 5845 | ** ^The S and M arguments passed to |
| 5846 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 5847 | ** and database name of the source database, respectively. |
| 5848 | ** ^The source and destination [database connections] (parameters S and D) |
| 5849 | ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with |
| 5850 | ** an error. |
| 5851 | ** |
| 5852 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 5853 | ** returned and an error code and error message are stored in the |
| 5854 | ** destination [database connection] D. |
| 5855 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 5856 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 5857 | ** [sqlite3_errmsg16()] functions. |
| 5858 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -5816,11 +5865,11 @@ | |
| 5865 | ** |
| 5866 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 5867 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 5868 | ** ^If N is negative, all remaining source pages are copied. |
| 5869 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 5870 | ** are still more pages to be copied, then the function returns [SQLITE_OK]. |
| 5871 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 5872 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 5873 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 5874 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 5875 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -5830,11 +5879,11 @@ | |
| 5879 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 5880 | ** <ol> |
| 5881 | ** <li> the destination database was opened read-only, or |
| 5882 | ** <li> the destination database is using write-ahead-log journaling |
| 5883 | ** and the destination and source page sizes differ, or |
| 5884 | ** <li> the destination database is an in-memory database and the |
| 5885 | ** destination and source page sizes differ. |
| 5886 | ** </ol>)^ |
| 5887 | ** |
| 5888 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 5889 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6161,11 +6210,12 @@ | |
| 6210 | ** |
| 6211 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6212 | ** from SQL. |
| 6213 | ** |
| 6214 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6215 | ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] |
| 6216 | ** pages. The use of this interface |
| 6217 | ** is only necessary if the default setting is found to be suboptimal |
| 6218 | ** for a particular application. |
| 6219 | */ |
| 6220 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6221 | |
| 6222 |
+75
-25
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.4" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007004 |
| 112 | -#define SQLITE_SOURCE_ID "2010-12-06 21:09:59 fabcb6b95e1d4059d1e6c6183f65846f6cbd5749" | |
| 112 | +#define SQLITE_SOURCE_ID "2010-12-21 21:28:38 b0888047bb6d9ac55e29b9224df2ff650728bb78" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| @@ -713,10 +713,15 @@ | ||
| 713 | 713 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 714 | 714 | ** point to an integer (type int) containing the new chunk-size to use |
| 715 | 715 | ** for the nominated database. Allocating database file space in large |
| 716 | 716 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 717 | 717 | ** improve performance on some systems. |
| 718 | +** | |
| 719 | +** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer | |
| 720 | +** to the [sqlite3_file] object associated with a particular database | |
| 721 | +** connection. See the [sqlite3_file_control()] documentation for | |
| 722 | +** additional information. | |
| 718 | 723 | */ |
| 719 | 724 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 720 | 725 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 721 | 726 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 722 | 727 | #define SQLITE_LAST_ERRNO 4 |
| @@ -2648,18 +2653,35 @@ | ||
| 2648 | 2653 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 2649 | 2654 | |
| 2650 | 2655 | /* |
| 2651 | 2656 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 2652 | 2657 | ** |
| 2653 | -** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if | |
| 2654 | -** the [prepared statement] X is [SELECT] statement and false (zero) if | |
| 2655 | -** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], | |
| 2656 | -** [ALTER], or [REINDEX] statement. | |
| 2657 | -** If X is a NULL pointer or any other kind of statement, including but | |
| 2658 | -** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], | |
| 2659 | -** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is | |
| 2660 | -** undefined. | |
| 2658 | +** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if | |
| 2659 | +** and only if the [prepared statement] X is makes no direct changes to | |
| 2660 | +** the content of the database file. | |
| 2661 | +** | |
| 2662 | +** Note that [application-defined SQL functions] or | |
| 2663 | +** [virtual tables] might change the database indirectly as a side effect. | |
| 2664 | +** ^(For example, if an application defines a function "eval()" that | |
| 2665 | +** calls [sqlite3_exec()], then the following SQL statement would | |
| 2666 | +** change the database file through side-effects: | |
| 2667 | +** | |
| 2668 | +** <blockquote><pre> | |
| 2669 | +** SELECT eval('DELETE FROM t1') FROM t2; | |
| 2670 | +** </pre></blockquote> | |
| 2671 | +** | |
| 2672 | +** But because the [SELECT] statement does not change the database file | |
| 2673 | +** directly, sqlite3_stmt_readonly() would still return true.)^ | |
| 2674 | +** | |
| 2675 | +** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], | |
| 2676 | +** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, | |
| 2677 | +** since the statements themselves do not actually modify the database but | |
| 2678 | +** rather they control the timing of when other statements modify the | |
| 2679 | +** database. ^The [ATTACH] and [DETACH] statements also cause | |
| 2680 | +** sqlite3_stmt_readonly() to return true since, while those statements | |
| 2681 | +** change the configuration of a database connection, they do not make | |
| 2682 | +** changes to the content of the database files on disk. | |
| 2661 | 2683 | */ |
| 2662 | 2684 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 2663 | 2685 | |
| 2664 | 2686 | /* |
| 2665 | 2687 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5384,11 +5406,12 @@ | ||
| 5384 | 5406 | ** internal equivalents). Only the value returned in the |
| 5385 | 5407 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5386 | 5408 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5387 | 5409 | ** |
| 5388 | 5410 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5389 | -** <dd>This parameter records the number of separate memory allocations.</dd>)^ | |
| 5411 | +** <dd>This parameter records the number of separate memory allocations | |
| 5412 | +** currently checked out.</dd>)^ | |
| 5390 | 5413 | ** |
| 5391 | 5414 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5392 | 5415 | ** <dd>This parameter returns the number of pages used out of the |
| 5393 | 5416 | ** [pagecache memory allocator] that was configured using |
| 5394 | 5417 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -5489,10 +5512,32 @@ | ||
| 5489 | 5512 | ** |
| 5490 | 5513 | ** <dl> |
| 5491 | 5514 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 5492 | 5515 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 5493 | 5516 | ** checked out.</dd>)^ |
| 5517 | +** | |
| 5518 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> | |
| 5519 | +** <dd>This parameter returns the number malloc attempts that were | |
| 5520 | +** satisfied using lookaside memory. Only the high-water value is meaningful; | |
| 5521 | +** the current value is always zero. | |
| 5522 | +** checked out.</dd>)^ | |
| 5523 | +** | |
| 5524 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> | |
| 5525 | +** <dd>This parameter returns the number malloc attempts that might have | |
| 5526 | +** been satisfied using lookaside memory but failed due to the amount of | |
| 5527 | +** memory requested being larger than the lookaside slot size. | |
| 5528 | +** Only the high-water value is meaningful; | |
| 5529 | +** the current value is always zero. | |
| 5530 | +** checked out.</dd>)^ | |
| 5531 | +** | |
| 5532 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> | |
| 5533 | +** <dd>This parameter returns the number malloc attempts that might have | |
| 5534 | +** been satisfied using lookaside memory but failed due to all lookaside | |
| 5535 | +** memory already being in use. | |
| 5536 | +** Only the high-water value is meaningful; | |
| 5537 | +** the current value is always zero. | |
| 5538 | +** checked out.</dd>)^ | |
| 5494 | 5539 | ** |
| 5495 | 5540 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 5496 | 5541 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 5497 | 5542 | ** memory used by all pager caches associated with the database connection.)^ |
| 5498 | 5543 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -5512,15 +5557,18 @@ | ||
| 5512 | 5557 | ** the database connection.)^ |
| 5513 | 5558 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 5514 | 5559 | ** </dd> |
| 5515 | 5560 | ** </dl> |
| 5516 | 5561 | */ |
| 5517 | -#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 | |
| 5518 | -#define SQLITE_DBSTATUS_CACHE_USED 1 | |
| 5519 | -#define SQLITE_DBSTATUS_SCHEMA_USED 2 | |
| 5520 | -#define SQLITE_DBSTATUS_STMT_USED 3 | |
| 5521 | -#define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ | |
| 5562 | +#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 | |
| 5563 | +#define SQLITE_DBSTATUS_CACHE_USED 1 | |
| 5564 | +#define SQLITE_DBSTATUS_SCHEMA_USED 2 | |
| 5565 | +#define SQLITE_DBSTATUS_STMT_USED 3 | |
| 5566 | +#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 | |
| 5567 | +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 | |
| 5568 | +#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 | |
| 5569 | +#define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ | |
| 5522 | 5570 | |
| 5523 | 5571 | |
| 5524 | 5572 | /* |
| 5525 | 5573 | ** CAPI3REF: Prepared Statement Status |
| 5526 | 5574 | ** |
| @@ -5764,15 +5812,16 @@ | ||
| 5764 | 5812 | ** It is useful either for creating backups of databases or |
| 5765 | 5813 | ** for copying in-memory databases to or from persistent files. |
| 5766 | 5814 | ** |
| 5767 | 5815 | ** See Also: [Using the SQLite Online Backup API] |
| 5768 | 5816 | ** |
| 5769 | -** ^Exclusive access is required to the destination database for the | |
| 5770 | -** duration of the operation. ^However the source database is only | |
| 5771 | -** read-locked while it is actually being read; it is not locked | |
| 5772 | -** continuously for the entire backup operation. ^Thus, the backup may be | |
| 5773 | -** performed on a live source database without preventing other users from | |
| 5817 | +** ^SQLite holds a write transaction open on the destination database file | |
| 5818 | +** for the duration of the backup operation. | |
| 5819 | +** ^The source database is read-locked only while it is being read; | |
| 5820 | +** it is not locked continuously for the entire backup operation. | |
| 5821 | +** ^Thus, the backup may be performed on a live source database without | |
| 5822 | +** preventing other database connections from | |
| 5774 | 5823 | ** reading or writing to the source database while the backup is underway. |
| 5775 | 5824 | ** |
| 5776 | 5825 | ** ^(To perform a backup operation: |
| 5777 | 5826 | ** <ol> |
| 5778 | 5827 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -5795,15 +5844,15 @@ | ||
| 5795 | 5844 | ** an [ATTACH] statement for an attached database. |
| 5796 | 5845 | ** ^The S and M arguments passed to |
| 5797 | 5846 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 5798 | 5847 | ** and database name of the source database, respectively. |
| 5799 | 5848 | ** ^The source and destination [database connections] (parameters S and D) |
| 5800 | -** must be different or else sqlite3_backup_init(D,N,S,M) will file with | |
| 5849 | +** must be different or else sqlite3_backup_init(D,N,S,M) will fail with | |
| 5801 | 5850 | ** an error. |
| 5802 | 5851 | ** |
| 5803 | 5852 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 5804 | -** returned and an error code and error message are store3d in the | |
| 5853 | +** returned and an error code and error message are stored in the | |
| 5805 | 5854 | ** destination [database connection] D. |
| 5806 | 5855 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 5807 | 5856 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 5808 | 5857 | ** [sqlite3_errmsg16()] functions. |
| 5809 | 5858 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -5816,11 +5865,11 @@ | ||
| 5816 | 5865 | ** |
| 5817 | 5866 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 5818 | 5867 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 5819 | 5868 | ** ^If N is negative, all remaining source pages are copied. |
| 5820 | 5869 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 5821 | -** are still more pages to be copied, then the function resturns [SQLITE_OK]. | |
| 5870 | +** are still more pages to be copied, then the function returns [SQLITE_OK]. | |
| 5822 | 5871 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 5823 | 5872 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 5824 | 5873 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 5825 | 5874 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 5826 | 5875 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -5830,11 +5879,11 @@ | ||
| 5830 | 5879 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 5831 | 5880 | ** <ol> |
| 5832 | 5881 | ** <li> the destination database was opened read-only, or |
| 5833 | 5882 | ** <li> the destination database is using write-ahead-log journaling |
| 5834 | 5883 | ** and the destination and source page sizes differ, or |
| 5835 | -** <li> The destination database is an in-memory database and the | |
| 5884 | +** <li> the destination database is an in-memory database and the | |
| 5836 | 5885 | ** destination and source page sizes differ. |
| 5837 | 5886 | ** </ol>)^ |
| 5838 | 5887 | ** |
| 5839 | 5888 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 5840 | 5889 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6161,11 +6210,12 @@ | ||
| 6161 | 6210 | ** |
| 6162 | 6211 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6163 | 6212 | ** from SQL. |
| 6164 | 6213 | ** |
| 6165 | 6214 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6166 | -** enabled with a threshold of 1000 pages. The use of this interface | |
| 6215 | +** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] | |
| 6216 | +** pages. The use of this interface | |
| 6167 | 6217 | ** is only necessary if the default setting is found to be suboptimal |
| 6168 | 6218 | ** for a particular application. |
| 6169 | 6219 | */ |
| 6170 | 6220 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6171 | 6221 | |
| 6172 | 6222 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.4" |
| 111 | #define SQLITE_VERSION_NUMBER 3007004 |
| 112 | #define SQLITE_SOURCE_ID "2010-12-06 21:09:59 fabcb6b95e1d4059d1e6c6183f65846f6cbd5749" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -713,10 +713,15 @@ | |
| 713 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 714 | ** point to an integer (type int) containing the new chunk-size to use |
| 715 | ** for the nominated database. Allocating database file space in large |
| 716 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 717 | ** improve performance on some systems. |
| 718 | */ |
| 719 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 720 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 721 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 722 | #define SQLITE_LAST_ERRNO 4 |
| @@ -2648,18 +2653,35 @@ | |
| 2648 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 2649 | |
| 2650 | /* |
| 2651 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 2652 | ** |
| 2653 | ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if |
| 2654 | ** the [prepared statement] X is [SELECT] statement and false (zero) if |
| 2655 | ** X is an [INSERT], [UPDATE], [DELETE], CREATE, DROP, [ANALYZE], |
| 2656 | ** [ALTER], or [REINDEX] statement. |
| 2657 | ** If X is a NULL pointer or any other kind of statement, including but |
| 2658 | ** not limited to [ATTACH], [DETACH], [COMMIT], [ROLLBACK], [RELEASE], |
| 2659 | ** [SAVEPOINT], [PRAGMA], or [VACUUM] the result of sqlite3_stmt_readonly(X) is |
| 2660 | ** undefined. |
| 2661 | */ |
| 2662 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 2663 | |
| 2664 | /* |
| 2665 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5384,11 +5406,12 @@ | |
| 5384 | ** internal equivalents). Only the value returned in the |
| 5385 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5386 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5387 | ** |
| 5388 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5389 | ** <dd>This parameter records the number of separate memory allocations.</dd>)^ |
| 5390 | ** |
| 5391 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5392 | ** <dd>This parameter returns the number of pages used out of the |
| 5393 | ** [pagecache memory allocator] that was configured using |
| 5394 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -5489,10 +5512,32 @@ | |
| 5489 | ** |
| 5490 | ** <dl> |
| 5491 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 5492 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 5493 | ** checked out.</dd>)^ |
| 5494 | ** |
| 5495 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 5496 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 5497 | ** memory used by all pager caches associated with the database connection.)^ |
| 5498 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -5512,15 +5557,18 @@ | |
| 5512 | ** the database connection.)^ |
| 5513 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 5514 | ** </dd> |
| 5515 | ** </dl> |
| 5516 | */ |
| 5517 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 5518 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 5519 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 5520 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 5521 | #define SQLITE_DBSTATUS_MAX 3 /* Largest defined DBSTATUS */ |
| 5522 | |
| 5523 | |
| 5524 | /* |
| 5525 | ** CAPI3REF: Prepared Statement Status |
| 5526 | ** |
| @@ -5764,15 +5812,16 @@ | |
| 5764 | ** It is useful either for creating backups of databases or |
| 5765 | ** for copying in-memory databases to or from persistent files. |
| 5766 | ** |
| 5767 | ** See Also: [Using the SQLite Online Backup API] |
| 5768 | ** |
| 5769 | ** ^Exclusive access is required to the destination database for the |
| 5770 | ** duration of the operation. ^However the source database is only |
| 5771 | ** read-locked while it is actually being read; it is not locked |
| 5772 | ** continuously for the entire backup operation. ^Thus, the backup may be |
| 5773 | ** performed on a live source database without preventing other users from |
| 5774 | ** reading or writing to the source database while the backup is underway. |
| 5775 | ** |
| 5776 | ** ^(To perform a backup operation: |
| 5777 | ** <ol> |
| 5778 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -5795,15 +5844,15 @@ | |
| 5795 | ** an [ATTACH] statement for an attached database. |
| 5796 | ** ^The S and M arguments passed to |
| 5797 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 5798 | ** and database name of the source database, respectively. |
| 5799 | ** ^The source and destination [database connections] (parameters S and D) |
| 5800 | ** must be different or else sqlite3_backup_init(D,N,S,M) will file with |
| 5801 | ** an error. |
| 5802 | ** |
| 5803 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 5804 | ** returned and an error code and error message are store3d in the |
| 5805 | ** destination [database connection] D. |
| 5806 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 5807 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 5808 | ** [sqlite3_errmsg16()] functions. |
| 5809 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -5816,11 +5865,11 @@ | |
| 5816 | ** |
| 5817 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 5818 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 5819 | ** ^If N is negative, all remaining source pages are copied. |
| 5820 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 5821 | ** are still more pages to be copied, then the function resturns [SQLITE_OK]. |
| 5822 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 5823 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 5824 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 5825 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 5826 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -5830,11 +5879,11 @@ | |
| 5830 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 5831 | ** <ol> |
| 5832 | ** <li> the destination database was opened read-only, or |
| 5833 | ** <li> the destination database is using write-ahead-log journaling |
| 5834 | ** and the destination and source page sizes differ, or |
| 5835 | ** <li> The destination database is an in-memory database and the |
| 5836 | ** destination and source page sizes differ. |
| 5837 | ** </ol>)^ |
| 5838 | ** |
| 5839 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 5840 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6161,11 +6210,12 @@ | |
| 6161 | ** |
| 6162 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6163 | ** from SQL. |
| 6164 | ** |
| 6165 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6166 | ** enabled with a threshold of 1000 pages. The use of this interface |
| 6167 | ** is only necessary if the default setting is found to be suboptimal |
| 6168 | ** for a particular application. |
| 6169 | */ |
| 6170 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6171 | |
| 6172 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.4" |
| 111 | #define SQLITE_VERSION_NUMBER 3007004 |
| 112 | #define SQLITE_SOURCE_ID "2010-12-21 21:28:38 b0888047bb6d9ac55e29b9224df2ff650728bb78" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| @@ -713,10 +713,15 @@ | |
| 713 | ** by the user. The fourth argument to [sqlite3_file_control()] should |
| 714 | ** point to an integer (type int) containing the new chunk-size to use |
| 715 | ** for the nominated database. Allocating database file space in large |
| 716 | ** chunks (say 1MB at a time), may reduce file-system fragmentation and |
| 717 | ** improve performance on some systems. |
| 718 | ** |
| 719 | ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer |
| 720 | ** to the [sqlite3_file] object associated with a particular database |
| 721 | ** connection. See the [sqlite3_file_control()] documentation for |
| 722 | ** additional information. |
| 723 | */ |
| 724 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 725 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 726 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 727 | #define SQLITE_LAST_ERRNO 4 |
| @@ -2648,18 +2653,35 @@ | |
| 2653 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 2654 | |
| 2655 | /* |
| 2656 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| 2657 | ** |
| 2658 | ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if |
| 2659 | ** and only if the [prepared statement] X is makes no direct changes to |
| 2660 | ** the content of the database file. |
| 2661 | ** |
| 2662 | ** Note that [application-defined SQL functions] or |
| 2663 | ** [virtual tables] might change the database indirectly as a side effect. |
| 2664 | ** ^(For example, if an application defines a function "eval()" that |
| 2665 | ** calls [sqlite3_exec()], then the following SQL statement would |
| 2666 | ** change the database file through side-effects: |
| 2667 | ** |
| 2668 | ** <blockquote><pre> |
| 2669 | ** SELECT eval('DELETE FROM t1') FROM t2; |
| 2670 | ** </pre></blockquote> |
| 2671 | ** |
| 2672 | ** But because the [SELECT] statement does not change the database file |
| 2673 | ** directly, sqlite3_stmt_readonly() would still return true.)^ |
| 2674 | ** |
| 2675 | ** ^Transaction control statements such as [BEGIN], [COMMIT], [ROLLBACK], |
| 2676 | ** [SAVEPOINT], and [RELEASE] cause sqlite3_stmt_readonly() to return true, |
| 2677 | ** since the statements themselves do not actually modify the database but |
| 2678 | ** rather they control the timing of when other statements modify the |
| 2679 | ** database. ^The [ATTACH] and [DETACH] statements also cause |
| 2680 | ** sqlite3_stmt_readonly() to return true since, while those statements |
| 2681 | ** change the configuration of a database connection, they do not make |
| 2682 | ** changes to the content of the database files on disk. |
| 2683 | */ |
| 2684 | SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt); |
| 2685 | |
| 2686 | /* |
| 2687 | ** CAPI3REF: Dynamically Typed Value Object |
| @@ -5384,11 +5406,12 @@ | |
| 5406 | ** internal equivalents). Only the value returned in the |
| 5407 | ** *pHighwater parameter to [sqlite3_status()] is of interest. |
| 5408 | ** The value written into the *pCurrent parameter is undefined.</dd>)^ |
| 5409 | ** |
| 5410 | ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt> |
| 5411 | ** <dd>This parameter records the number of separate memory allocations |
| 5412 | ** currently checked out.</dd>)^ |
| 5413 | ** |
| 5414 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> |
| 5415 | ** <dd>This parameter returns the number of pages used out of the |
| 5416 | ** [pagecache memory allocator] that was configured using |
| 5417 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| @@ -5489,10 +5512,32 @@ | |
| 5512 | ** |
| 5513 | ** <dl> |
| 5514 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> |
| 5515 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 5516 | ** checked out.</dd>)^ |
| 5517 | ** |
| 5518 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> |
| 5519 | ** <dd>This parameter returns the number malloc attempts that were |
| 5520 | ** satisfied using lookaside memory. Only the high-water value is meaningful; |
| 5521 | ** the current value is always zero. |
| 5522 | ** checked out.</dd>)^ |
| 5523 | ** |
| 5524 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> |
| 5525 | ** <dd>This parameter returns the number malloc attempts that might have |
| 5526 | ** been satisfied using lookaside memory but failed due to the amount of |
| 5527 | ** memory requested being larger than the lookaside slot size. |
| 5528 | ** Only the high-water value is meaningful; |
| 5529 | ** the current value is always zero. |
| 5530 | ** checked out.</dd>)^ |
| 5531 | ** |
| 5532 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> |
| 5533 | ** <dd>This parameter returns the number malloc attempts that might have |
| 5534 | ** been satisfied using lookaside memory but failed due to all lookaside |
| 5535 | ** memory already being in use. |
| 5536 | ** Only the high-water value is meaningful; |
| 5537 | ** the current value is always zero. |
| 5538 | ** checked out.</dd>)^ |
| 5539 | ** |
| 5540 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 5541 | ** <dd>This parameter returns the approximate number of of bytes of heap |
| 5542 | ** memory used by all pager caches associated with the database connection.)^ |
| 5543 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| @@ -5512,15 +5557,18 @@ | |
| 5557 | ** the database connection.)^ |
| 5558 | ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. |
| 5559 | ** </dd> |
| 5560 | ** </dl> |
| 5561 | */ |
| 5562 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 5563 | #define SQLITE_DBSTATUS_CACHE_USED 1 |
| 5564 | #define SQLITE_DBSTATUS_SCHEMA_USED 2 |
| 5565 | #define SQLITE_DBSTATUS_STMT_USED 3 |
| 5566 | #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4 |
| 5567 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 |
| 5568 | #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 |
| 5569 | #define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */ |
| 5570 | |
| 5571 | |
| 5572 | /* |
| 5573 | ** CAPI3REF: Prepared Statement Status |
| 5574 | ** |
| @@ -5764,15 +5812,16 @@ | |
| 5812 | ** It is useful either for creating backups of databases or |
| 5813 | ** for copying in-memory databases to or from persistent files. |
| 5814 | ** |
| 5815 | ** See Also: [Using the SQLite Online Backup API] |
| 5816 | ** |
| 5817 | ** ^SQLite holds a write transaction open on the destination database file |
| 5818 | ** for the duration of the backup operation. |
| 5819 | ** ^The source database is read-locked only while it is being read; |
| 5820 | ** it is not locked continuously for the entire backup operation. |
| 5821 | ** ^Thus, the backup may be performed on a live source database without |
| 5822 | ** preventing other database connections from |
| 5823 | ** reading or writing to the source database while the backup is underway. |
| 5824 | ** |
| 5825 | ** ^(To perform a backup operation: |
| 5826 | ** <ol> |
| 5827 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| @@ -5795,15 +5844,15 @@ | |
| 5844 | ** an [ATTACH] statement for an attached database. |
| 5845 | ** ^The S and M arguments passed to |
| 5846 | ** sqlite3_backup_init(D,N,S,M) identify the [database connection] |
| 5847 | ** and database name of the source database, respectively. |
| 5848 | ** ^The source and destination [database connections] (parameters S and D) |
| 5849 | ** must be different or else sqlite3_backup_init(D,N,S,M) will fail with |
| 5850 | ** an error. |
| 5851 | ** |
| 5852 | ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is |
| 5853 | ** returned and an error code and error message are stored in the |
| 5854 | ** destination [database connection] D. |
| 5855 | ** ^The error code and message for the failed call to sqlite3_backup_init() |
| 5856 | ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or |
| 5857 | ** [sqlite3_errmsg16()] functions. |
| 5858 | ** ^A successful call to sqlite3_backup_init() returns a pointer to an |
| @@ -5816,11 +5865,11 @@ | |
| 5865 | ** |
| 5866 | ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between |
| 5867 | ** the source and destination databases specified by [sqlite3_backup] object B. |
| 5868 | ** ^If N is negative, all remaining source pages are copied. |
| 5869 | ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there |
| 5870 | ** are still more pages to be copied, then the function returns [SQLITE_OK]. |
| 5871 | ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages |
| 5872 | ** from source to destination, then it returns [SQLITE_DONE]. |
| 5873 | ** ^If an error occurs while running sqlite3_backup_step(B,N), |
| 5874 | ** then an [error code] is returned. ^As well as [SQLITE_OK] and |
| 5875 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| @@ -5830,11 +5879,11 @@ | |
| 5879 | ** ^(The sqlite3_backup_step() might return [SQLITE_READONLY] if |
| 5880 | ** <ol> |
| 5881 | ** <li> the destination database was opened read-only, or |
| 5882 | ** <li> the destination database is using write-ahead-log journaling |
| 5883 | ** and the destination and source page sizes differ, or |
| 5884 | ** <li> the destination database is an in-memory database and the |
| 5885 | ** destination and source page sizes differ. |
| 5886 | ** </ol>)^ |
| 5887 | ** |
| 5888 | ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then |
| 5889 | ** the [sqlite3_busy_handler | busy-handler function] |
| @@ -6161,11 +6210,12 @@ | |
| 6210 | ** |
| 6211 | ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface |
| 6212 | ** from SQL. |
| 6213 | ** |
| 6214 | ** ^Every new [database connection] defaults to having the auto-checkpoint |
| 6215 | ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] |
| 6216 | ** pages. The use of this interface |
| 6217 | ** is only necessary if the default setting is found to be suboptimal |
| 6218 | ** for a particular application. |
| 6219 | */ |
| 6220 | SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); |
| 6221 | |
| 6222 |