| | @@ -1150,11 +1150,11 @@ |
| 1150 | 1150 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1151 | 1151 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1152 | 1152 | */ |
| 1153 | 1153 | #define SQLITE_VERSION "3.25.0" |
| 1154 | 1154 | #define SQLITE_VERSION_NUMBER 3025000 |
| 1155 | | -#define SQLITE_SOURCE_ID "2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb36212426b1" |
| 1155 | +#define SQLITE_SOURCE_ID "2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60ad069f" |
| 1156 | 1156 | |
| 1157 | 1157 | /* |
| 1158 | 1158 | ** CAPI3REF: Run-Time Library Version Numbers |
| 1159 | 1159 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 1160 | 1160 | ** |
| | @@ -2098,10 +2098,29 @@ |
| 2098 | 2098 | ** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]] |
| 2099 | 2099 | ** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode causes attempts to obtain |
| 2100 | 2100 | ** a file lock using the xLock or xShmLock methods of the VFS to wait |
| 2101 | 2101 | ** for up to M milliseconds before failing, where M is the single |
| 2102 | 2102 | ** unsigned integer parameter. |
| 2103 | +** |
| 2104 | +** <li>[[SQLITE_FCNTL_DATA_VERSION]] |
| 2105 | +** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to |
| 2106 | +** a database file. The argument is a pointer to a 32-bit unsigned integer. |
| 2107 | +** The "data version" for the pager is written into the pointer. The |
| 2108 | +** "data version" changes whenever any change occurs to the corresponding |
| 2109 | +** database file, either through SQL statements on the same database |
| 2110 | +** connection, or through transactions committed by separate database |
| 2111 | +** connections possibly in other processes. The [sqlite3_total_changes()] |
| 2112 | +** interface can be used to find if any database on the connection has changed, |
| 2113 | +** but that interface response to changes on TEMP as well as MAIN and does |
| 2114 | +** not provide a mechanism to detect changes to MAIN only. Also, the |
| 2115 | +** [sqlite3_total_changes()] interface response to internal changes only and |
| 2116 | +** omits changes made by other database connections. The |
| 2117 | +** [PRAGMA data_version] command provide a mechanism to detect changes to |
| 2118 | +** a single attached database that occur due to other database connections, |
| 2119 | +** but omits changes implemented by the database connection for which it is |
| 2120 | +** called. This file control is the only mechanism to detect changes that |
| 2121 | +** happen either internally or externally on a single database. |
| 2103 | 2122 | ** </ul> |
| 2104 | 2123 | */ |
| 2105 | 2124 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 2106 | 2125 | #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 |
| 2107 | 2126 | #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 |
| | @@ -2133,10 +2152,11 @@ |
| 2133 | 2152 | #define SQLITE_FCNTL_PDB 30 |
| 2134 | 2153 | #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 |
| 2135 | 2154 | #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 |
| 2136 | 2155 | #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 |
| 2137 | 2156 | #define SQLITE_FCNTL_LOCK_TIMEOUT 34 |
| 2157 | +#define SQLITE_FCNTL_DATA_VERSION 35 |
| 2138 | 2158 | |
| 2139 | 2159 | /* deprecated names */ |
| 2140 | 2160 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE |
| 2141 | 2161 | #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE |
| 2142 | 2162 | #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
| | @@ -3301,16 +3321,21 @@ |
| 3301 | 3321 | ** returns the value as set when the calling statement began executing. |
| 3302 | 3322 | ** ^If it is used by the second or subsequent such statement within a trigger |
| 3303 | 3323 | ** program, the value returned reflects the number of rows modified by the |
| 3304 | 3324 | ** previous INSERT, UPDATE or DELETE statement within the same trigger. |
| 3305 | 3325 | ** |
| 3306 | | -** See also the [sqlite3_total_changes()] interface, the |
| 3307 | | -** [count_changes pragma], and the [changes() SQL function]. |
| 3308 | | -** |
| 3309 | 3326 | ** If a separate thread makes changes on the same database connection |
| 3310 | 3327 | ** while [sqlite3_changes()] is running then the value returned |
| 3311 | 3328 | ** is unpredictable and not meaningful. |
| 3329 | +** |
| 3330 | +** See also: |
| 3331 | +** <ul> |
| 3332 | +** <li> the [sqlite3_total_changes()] interface |
| 3333 | +** <li> the [count_changes pragma] |
| 3334 | +** <li> the [changes() SQL function] |
| 3335 | +** <li> the [data_version pragma] |
| 3336 | +** </ul> |
| 3312 | 3337 | */ |
| 3313 | 3338 | SQLITE_API int sqlite3_changes(sqlite3*); |
| 3314 | 3339 | |
| 3315 | 3340 | /* |
| 3316 | 3341 | ** CAPI3REF: Total Number Of Rows Modified |
| | @@ -3324,17 +3349,30 @@ |
| 3324 | 3349 | ** |
| 3325 | 3350 | ** ^Changes made as part of [foreign key actions] are included in the |
| 3326 | 3351 | ** count, but those made as part of REPLACE constraint resolution are |
| 3327 | 3352 | ** not. ^Changes to a view that are intercepted by INSTEAD OF triggers |
| 3328 | 3353 | ** are not counted. |
| 3354 | +** |
| 3355 | +** This the [sqlite3_total_changes(D)] interface only reports the number |
| 3356 | +** of rows that changed due to SQL statement run against database |
| 3357 | +** connection D. Any changes by other database connections are ignored. |
| 3358 | +** To detect changes against a database file from other database |
| 3359 | +** connections use the [PRAGMA data_version] command or the |
| 3360 | +** [SQLITE_FCNTL_DATA_VERSION] [file control]. |
| 3329 | 3361 | ** |
| 3330 | | -** See also the [sqlite3_changes()] interface, the |
| 3331 | | -** [count_changes pragma], and the [total_changes() SQL function]. |
| 3332 | | -** |
| 3333 | 3362 | ** If a separate thread makes changes on the same database connection |
| 3334 | 3363 | ** while [sqlite3_total_changes()] is running then the value |
| 3335 | 3364 | ** returned is unpredictable and not meaningful. |
| 3365 | +** |
| 3366 | +** See also: |
| 3367 | +** <ul> |
| 3368 | +** <li> the [sqlite3_changes()] interface |
| 3369 | +** <li> the [count_changes pragma] |
| 3370 | +** <li> the [changes() SQL function] |
| 3371 | +** <li> the [data_version pragma] |
| 3372 | +** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control] |
| 3373 | +** </ul> |
| 3336 | 3374 | */ |
| 3337 | 3375 | SQLITE_API int sqlite3_total_changes(sqlite3*); |
| 3338 | 3376 | |
| 3339 | 3377 | /* |
| 3340 | 3378 | ** CAPI3REF: Interrupt A Long-Running Query |
| | @@ -8102,10 +8140,11 @@ |
| 8102 | 8140 | SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); |
| 8103 | 8141 | |
| 8104 | 8142 | /* |
| 8105 | 8143 | ** CAPI3REF: Low-Level Control Of Database Files |
| 8106 | 8144 | ** METHOD: sqlite3 |
| 8145 | +** KEYWORDS: {file control} |
| 8107 | 8146 | ** |
| 8108 | 8147 | ** ^The [sqlite3_file_control()] interface makes a direct call to the |
| 8109 | 8148 | ** xFileControl method for the [sqlite3_io_methods] object associated |
| 8110 | 8149 | ** with a particular database identified by the second argument. ^The |
| 8111 | 8150 | ** name of the database is "main" for the main database or "temp" for the |
| | @@ -8116,15 +8155,22 @@ |
| 8116 | 8155 | ** ^The third and fourth parameters to this routine |
| 8117 | 8156 | ** are passed directly through to the second and third parameters of |
| 8118 | 8157 | ** the xFileControl method. ^The return value of the xFileControl |
| 8119 | 8158 | ** method becomes the return value of this routine. |
| 8120 | 8159 | ** |
| 8160 | +** A few opcodes for [sqlite3_file_control()] are handled directly |
| 8161 | +** by the SQLite core and never invoke the |
| 8162 | +** sqlite3_io_methods.xFileControl method. |
| 8121 | 8163 | ** ^The [SQLITE_FCNTL_FILE_POINTER] value for the op parameter causes |
| 8122 | 8164 | ** a pointer to the underlying [sqlite3_file] object to be written into |
| 8123 | | -** the space pointed to by the 4th parameter. ^The [SQLITE_FCNTL_FILE_POINTER] |
| 8124 | | -** case is a short-circuit path which does not actually invoke the |
| 8125 | | -** underlying sqlite3_io_methods.xFileControl method. |
| 8165 | +** the space pointed to by the 4th parameter. The |
| 8166 | +** [SQLITE_FCNTL_JOURNAL_POINTER] works similarly except that it returns |
| 8167 | +** the [sqlite3_file] object associated with the journal file instead of |
| 8168 | +** the main database. The [SQLITE_FCNTL_VFS_POINTER] opcode returns |
| 8169 | +** a pointer to the underlying [sqlite3_vfs] object for the file. |
| 8170 | +** The [SQLITE_FCNTL_DATA_VERSION] returns the data version counter |
| 8171 | +** from the pager. |
| 8126 | 8172 | ** |
| 8127 | 8173 | ** ^If the second parameter (zDbName) does not match the name of any |
| 8128 | 8174 | ** open database file, then SQLITE_ERROR is returned. ^This error |
| 8129 | 8175 | ** code is not remembered and will not be recalled by [sqlite3_errcode()] |
| 8130 | 8176 | ** or [sqlite3_errmsg()]. The underlying xFileControl method might |
| | @@ -51664,11 +51710,10 @@ |
| 51664 | 51710 | |
| 51665 | 51711 | /* |
| 51666 | 51712 | ** Return the pPager->iDataVersion value |
| 51667 | 51713 | */ |
| 51668 | 51714 | SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager *pPager){ |
| 51669 | | - assert( pPager->eState>PAGER_OPEN ); |
| 51670 | 51715 | return pPager->iDataVersion; |
| 51671 | 51716 | } |
| 51672 | 51717 | |
| 51673 | 51718 | /* |
| 51674 | 51719 | ** Free all structures in the Pager.aSavepoint[] array and set both |
| | @@ -56282,13 +56327,14 @@ |
| 56282 | 56327 | /* If this is an in-memory db, or no pages have been written to, or this |
| 56283 | 56328 | ** function has already been called, it is mostly a no-op. However, any |
| 56284 | 56329 | ** backup in progress needs to be restarted. */ |
| 56285 | 56330 | sqlite3BackupRestart(pPager->pBackup); |
| 56286 | 56331 | }else{ |
| 56332 | + PgHdr *pList; |
| 56287 | 56333 | if( pagerUseWal(pPager) ){ |
| 56288 | | - PgHdr *pList = sqlite3PcacheDirtyList(pPager->pPCache); |
| 56289 | 56334 | PgHdr *pPageOne = 0; |
| 56335 | + pList = sqlite3PcacheDirtyList(pPager->pPCache); |
| 56290 | 56336 | if( pList==0 ){ |
| 56291 | 56337 | /* Must have at least one page for the WAL commit flag. |
| 56292 | 56338 | ** Ticket [2d1a5c67dfc2363e44f29d9bbd57f] 2011-05-18 */ |
| 56293 | 56339 | rc = sqlite3PagerGet(pPager, 1, &pPageOne, 0); |
| 56294 | 56340 | pList = pPageOne; |
| | @@ -56305,18 +56351,18 @@ |
| 56305 | 56351 | }else{ |
| 56306 | 56352 | /* The bBatch boolean is true if the batch-atomic-write commit method |
| 56307 | 56353 | ** should be used. No rollback journal is created if batch-atomic-write |
| 56308 | 56354 | ** is enabled. |
| 56309 | 56355 | */ |
| 56310 | | - sqlite3_file *fd = pPager->fd; |
| 56311 | 56356 | #ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE |
| 56312 | | - const int bBatch = zMaster==0 /* An SQLITE_IOCAP_BATCH_ATOMIC commit */ |
| 56357 | + sqlite3_file *fd = pPager->fd; |
| 56358 | + int bBatch = zMaster==0 /* An SQLITE_IOCAP_BATCH_ATOMIC commit */ |
| 56313 | 56359 | && (sqlite3OsDeviceCharacteristics(fd) & SQLITE_IOCAP_BATCH_ATOMIC) |
| 56314 | 56360 | && !pPager->noSync |
| 56315 | 56361 | && sqlite3JournalIsInMemory(pPager->jfd); |
| 56316 | 56362 | #else |
| 56317 | | -# define bBatch 0 |
| 56363 | +# define bBatch 0 |
| 56318 | 56364 | #endif |
| 56319 | 56365 | |
| 56320 | 56366 | #ifdef SQLITE_ENABLE_ATOMIC_WRITE |
| 56321 | 56367 | /* The following block updates the change-counter. Exactly how it |
| 56322 | 56368 | ** does this depends on whether or not the atomic-update optimization |
| | @@ -56364,19 +56410,20 @@ |
| 56364 | 56410 | if( rc==SQLITE_OK ){ |
| 56365 | 56411 | rc = pager_incr_changecounter(pPager, 0); |
| 56366 | 56412 | } |
| 56367 | 56413 | } |
| 56368 | 56414 | } |
| 56369 | | -#else |
| 56415 | +#else /* SQLITE_ENABLE_ATOMIC_WRITE */ |
| 56370 | 56416 | #ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE |
| 56371 | 56417 | if( zMaster ){ |
| 56372 | 56418 | rc = sqlite3JournalCreate(pPager->jfd); |
| 56373 | 56419 | if( rc!=SQLITE_OK ) goto commit_phase_one_exit; |
| 56420 | + assert( bBatch==0 ); |
| 56374 | 56421 | } |
| 56375 | 56422 | #endif |
| 56376 | 56423 | rc = pager_incr_changecounter(pPager, 0); |
| 56377 | | -#endif |
| 56424 | +#endif /* !SQLITE_ENABLE_ATOMIC_WRITE */ |
| 56378 | 56425 | if( rc!=SQLITE_OK ) goto commit_phase_one_exit; |
| 56379 | 56426 | |
| 56380 | 56427 | /* Write the master journal name into the journal file. If a master |
| 56381 | 56428 | ** journal file name has already been written to the journal file, |
| 56382 | 56429 | ** or if zMaster is NULL (no master journal), then this call is a no-op. |
| | @@ -56396,27 +56443,39 @@ |
| 56396 | 56443 | ** xSync() call will be changed to a no-op by the OS anyhow. |
| 56397 | 56444 | */ |
| 56398 | 56445 | rc = syncJournal(pPager, 0); |
| 56399 | 56446 | if( rc!=SQLITE_OK ) goto commit_phase_one_exit; |
| 56400 | 56447 | |
| 56448 | + pList = sqlite3PcacheDirtyList(pPager->pPCache); |
| 56449 | +#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE |
| 56401 | 56450 | if( bBatch ){ |
| 56402 | | - /* The pager is now in DBMOD state. But regardless of what happens |
| 56403 | | - ** next, attempting to play the journal back into the database would |
| 56404 | | - ** be unsafe. Close it now to make sure that does not happen. */ |
| 56405 | | - sqlite3OsClose(pPager->jfd); |
| 56406 | 56451 | rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0); |
| 56407 | | - if( rc!=SQLITE_OK ) goto commit_phase_one_exit; |
| 56408 | | - } |
| 56409 | | - rc = pager_write_pagelist(pPager,sqlite3PcacheDirtyList(pPager->pPCache)); |
| 56410 | | - if( bBatch ){ |
| 56411 | 56452 | if( rc==SQLITE_OK ){ |
| 56412 | | - rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0); |
| 56453 | + rc = pager_write_pagelist(pPager, pList); |
| 56454 | + if( rc==SQLITE_OK ){ |
| 56455 | + rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0); |
| 56456 | + } |
| 56457 | + if( rc!=SQLITE_OK ){ |
| 56458 | + sqlite3OsFileControlHint(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0); |
| 56459 | + } |
| 56413 | 56460 | } |
| 56414 | | - if( rc!=SQLITE_OK ){ |
| 56415 | | - sqlite3OsFileControlHint(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0); |
| 56461 | + |
| 56462 | + if( (rc&0xFF)==SQLITE_IOERR && rc!=SQLITE_IOERR_NOMEM ){ |
| 56463 | + rc = sqlite3JournalCreate(pPager->jfd); |
| 56464 | + if( rc!=SQLITE_OK ){ |
| 56465 | + sqlite3OsClose(pPager->jfd); |
| 56466 | + } |
| 56467 | + bBatch = 0; |
| 56468 | + }else{ |
| 56469 | + sqlite3OsClose(pPager->jfd); |
| 56416 | 56470 | } |
| 56417 | 56471 | } |
| 56472 | +#endif /* SQLITE_ENABLE_BATCH_ATOMIC_WRITE */ |
| 56473 | + |
| 56474 | + if( bBatch==0 && rc==SQLITE_OK ){ |
| 56475 | + rc = pager_write_pagelist(pPager, pList); |
| 56476 | + } |
| 56418 | 56477 | |
| 56419 | 56478 | if( rc!=SQLITE_OK ){ |
| 56420 | 56479 | assert( rc!=SQLITE_IOERR_BLOCKED ); |
| 56421 | 56480 | goto commit_phase_one_exit; |
| 56422 | 56481 | } |
| | @@ -151804,11 +151863,11 @@ |
| 151804 | 151863 | } |
| 151805 | 151864 | } |
| 151806 | 151865 | sqlite3VtabRollback(db); |
| 151807 | 151866 | sqlite3EndBenignMalloc(); |
| 151808 | 151867 | |
| 151809 | | - if( (db->mDbFlags&DBFLAG_SchemaChange)!=0 && db->init.busy==0 ){ |
| 151868 | + if( schemaChange ){ |
| 151810 | 151869 | sqlite3ExpirePreparedStatements(db); |
| 151811 | 151870 | sqlite3ResetAllSchemasOfConnection(db); |
| 151812 | 151871 | } |
| 151813 | 151872 | sqlite3BtreeLeaveAll(db); |
| 151814 | 151873 | |
| | @@ -154224,10 +154283,13 @@ |
| 154224 | 154283 | *(sqlite3_vfs**)pArg = sqlite3PagerVfs(pPager); |
| 154225 | 154284 | rc = SQLITE_OK; |
| 154226 | 154285 | }else if( op==SQLITE_FCNTL_JOURNAL_POINTER ){ |
| 154227 | 154286 | *(sqlite3_file**)pArg = sqlite3PagerJrnlFile(pPager); |
| 154228 | 154287 | rc = SQLITE_OK; |
| 154288 | + }else if( op==SQLITE_FCNTL_DATA_VERSION ){ |
| 154289 | + *(unsigned int*)pArg = sqlite3PagerDataVersion(pPager); |
| 154290 | + rc = SQLITE_OK; |
| 154229 | 154291 | }else{ |
| 154230 | 154292 | rc = sqlite3OsFileControl(fd, op, pArg); |
| 154231 | 154293 | } |
| 154232 | 154294 | sqlite3BtreeLeave(pBtree); |
| 154233 | 154295 | } |
| | @@ -211451,11 +211513,11 @@ |
| 211451 | 211513 | int nArg, /* Number of args */ |
| 211452 | 211514 | sqlite3_value **apUnused /* Function arguments */ |
| 211453 | 211515 | ){ |
| 211454 | 211516 | assert( nArg==0 ); |
| 211455 | 211517 | UNUSED_PARAM2(nArg, apUnused); |
| 211456 | | - sqlite3_result_text(pCtx, "fts5: 2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb36212426b1", -1, SQLITE_TRANSIENT); |
| 211518 | + sqlite3_result_text(pCtx, "fts5: 2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60ad069f", -1, SQLITE_TRANSIENT); |
| 211457 | 211519 | } |
| 211458 | 211520 | |
| 211459 | 211521 | static int fts5Init(sqlite3 *db){ |
| 211460 | 211522 | static const sqlite3_module fts5Mod = { |
| 211461 | 211523 | /* iVersion */ 2, |
| | @@ -216161,12 +216223,12 @@ |
| 216161 | 216223 | } |
| 216162 | 216224 | #endif /* SQLITE_CORE */ |
| 216163 | 216225 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 216164 | 216226 | |
| 216165 | 216227 | /************** End of stmt.c ************************************************/ |
| 216166 | | -#if __LINE__!=216166 |
| 216228 | +#if __LINE__!=216228 |
| 216167 | 216229 | #undef SQLITE_SOURCE_ID |
| 216168 | | -#define SQLITE_SOURCE_ID "2018-07-13 20:28:54 148d9b61471a874a16a9ec9c9603da03cadb3a40662fb550af51cb362124alt2" |
| 216230 | +#define SQLITE_SOURCE_ID "2018-07-18 19:09:07 a5087c5c87ad65f92e3bc96bbc84afb43faf10ab6b9ed3ba16304b5c60adalt2" |
| 216169 | 216231 | #endif |
| 216170 | 216232 | /* Return the source-id for this library */ |
| 216171 | 216233 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 216172 | 216234 | /************************** End of sqlite3.c ******************************/ |
| 216173 | 216235 | |