| | @@ -16,11 +16,11 @@ |
| 16 | 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | 19 | ** |
| 20 | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | | -** 5cbccab499bc3983aac1f57355552db607de with changes in files: |
| 21 | +** 724f2299f206cc9e7f830f984c50a8fc4ac1 with changes in files: |
| 22 | 22 | ** |
| 23 | 23 | ** |
| 24 | 24 | */ |
| 25 | 25 | #ifndef SQLITE_AMALGAMATION |
| 26 | 26 | #define SQLITE_CORE 1 |
| | @@ -467,14 +467,14 @@ |
| 467 | 467 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 468 | 468 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 469 | 469 | */ |
| 470 | 470 | #define SQLITE_VERSION "3.51.0" |
| 471 | 471 | #define SQLITE_VERSION_NUMBER 3051000 |
| 472 | | -#define SQLITE_SOURCE_ID "2025-10-15 10:52:45 5cbccab499bc3983aac1f57355552db607dee6c7ef4eb00d794dbee89c18db70" |
| 472 | +#define SQLITE_SOURCE_ID "2025-10-28 13:24:50 724f2299f206cc9e7f830f984c50a8fc4ac1c17210d71d9affe657b45252b060" |
| 473 | 473 | #define SQLITE_SCM_BRANCH "trunk" |
| 474 | 474 | #define SQLITE_SCM_TAGS "" |
| 475 | | -#define SQLITE_SCM_DATETIME "2025-10-15T10:52:45.276Z" |
| 475 | +#define SQLITE_SCM_DATETIME "2025-10-28T13:24:50.858Z" |
| 476 | 476 | |
| 477 | 477 | /* |
| 478 | 478 | ** CAPI3REF: Run-Time Library Version Numbers |
| 479 | 479 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 480 | 480 | ** |
| | @@ -1251,11 +1251,11 @@ |
| 1251 | 1251 | ** to the [sqlite3_file] object associated with the journal file (either |
| 1252 | 1252 | ** the [rollback journal] or the [write-ahead log]) for a particular database |
| 1253 | 1253 | ** connection. See also [SQLITE_FCNTL_FILE_POINTER]. |
| 1254 | 1254 | ** |
| 1255 | 1255 | ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]] |
| 1256 | | -** No longer in use. |
| 1256 | +** The SQLITE_FCNTL_SYNC_OMITTED file-control is no longer used. |
| 1257 | 1257 | ** |
| 1258 | 1258 | ** <li>[[SQLITE_FCNTL_SYNC]] |
| 1259 | 1259 | ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and |
| 1260 | 1260 | ** sent to the VFS immediately before the xSync method is invoked on a |
| 1261 | 1261 | ** database file descriptor. Or, if the xSync method is not invoked |
| | @@ -1548,10 +1548,19 @@ |
| 1548 | 1548 | ** <li>[[SQLITE_FCNTL_RESET_CACHE]] |
| 1549 | 1549 | ** If there is currently no transaction open on the database, and the |
| 1550 | 1550 | ** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control |
| 1551 | 1551 | ** purges the contents of the in-memory page cache. If there is an open |
| 1552 | 1552 | ** transaction, or if the db is a temp-db, this opcode is a no-op, not an error. |
| 1553 | +** |
| 1554 | +** <li>[[SQLITE_FCNTL_FILESTAT]] |
| 1555 | +** The [SQLITE_FCNTL_FILESTAT] opcode returns low-level diagnostic information |
| 1556 | +** about the [sqlite3_file] objects used access the database and journal files |
| 1557 | +** for the given schema. The fourth parameter to [sqlite3_file_control()] |
| 1558 | +** should be an initialized [sqlite3_str] pointer. JSON text describing |
| 1559 | +** various aspects of the sqlite3_file object is appended to the sqlite3_str. |
| 1560 | +** The SQLITE_FCNTL_FILESTAT opcode is usually a no-op, unless compile-time |
| 1561 | +** options are used to enable it. |
| 1553 | 1562 | ** </ul> |
| 1554 | 1563 | */ |
| 1555 | 1564 | #define SQLITE_FCNTL_LOCKSTATE 1 |
| 1556 | 1565 | #define SQLITE_FCNTL_GET_LOCKPROXYFILE 2 |
| 1557 | 1566 | #define SQLITE_FCNTL_SET_LOCKPROXYFILE 3 |
| | @@ -1593,10 +1602,11 @@ |
| 1593 | 1602 | #define SQLITE_FCNTL_EXTERNAL_READER 40 |
| 1594 | 1603 | #define SQLITE_FCNTL_CKSM_FILE 41 |
| 1595 | 1604 | #define SQLITE_FCNTL_RESET_CACHE 42 |
| 1596 | 1605 | #define SQLITE_FCNTL_NULL_IO 43 |
| 1597 | 1606 | #define SQLITE_FCNTL_BLOCK_ON_CONNECT 44 |
| 1607 | +#define SQLITE_FCNTL_FILESTAT 45 |
| 1598 | 1608 | |
| 1599 | 1609 | /* deprecated names */ |
| 1600 | 1610 | #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE |
| 1601 | 1611 | #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE |
| 1602 | 1612 | #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
| | @@ -5226,13 +5236,15 @@ |
| 5226 | 5236 | ** ^The sqlite3_bind_pointer(S,I,P,T,D) routine causes the I-th parameter in |
| 5227 | 5237 | ** [prepared statement] S to have an SQL value of NULL, but to also be |
| 5228 | 5238 | ** associated with the pointer P of type T. ^D is either a NULL pointer or |
| 5229 | 5239 | ** a pointer to a destructor function for P. ^SQLite will invoke the |
| 5230 | 5240 | ** destructor D with a single argument of P when it is finished using |
| 5231 | | -** P. The T parameter should be a static string, preferably a string |
| 5232 | | -** literal. The sqlite3_bind_pointer() routine is part of the |
| 5233 | | -** [pointer passing interface] added for SQLite 3.20.0. |
| 5241 | +** P, even if the call to sqlite3_bind_pointer() fails. Due to a |
| 5242 | +** historical design quirk, results are undefined if D is |
| 5243 | +** SQLITE_TRANSIENT. The T parameter should be a static string, |
| 5244 | +** preferably a string literal. The sqlite3_bind_pointer() routine is |
| 5245 | +** part of the [pointer passing interface] added for SQLite 3.20.0. |
| 5234 | 5246 | ** |
| 5235 | 5247 | ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer |
| 5236 | 5248 | ** for the [prepared statement] or with a prepared statement for which |
| 5237 | 5249 | ** [sqlite3_step()] has been called more recently than [sqlite3_reset()], |
| 5238 | 5250 | ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() |
| | @@ -11472,23 +11484,25 @@ |
| 11472 | 11484 | ** array to be bound, and N is the number of eements in the array. The |
| 11473 | 11485 | ** F argument is one of constants [SQLITE_CARRAY_INT32], [SQLITE_CARRAY_INT64], |
| 11474 | 11486 | ** [SQLITE_CARRAY_DOUBLE], [SQLITE_CARRAY_TEXT], or [SQLITE_CARRAY_BLOB] to |
| 11475 | 11487 | ** indicate the datatype of the array being bound. The X argument is not a |
| 11476 | 11488 | ** NULL pointer, then SQLite will invoke the function X on the P parameter |
| 11477 | | -** after it has finished using P. |
| 11489 | +** after it has finished using P, even if the call to |
| 11490 | +** sqlite3_carray_bind() fails. The special-case finalizer |
| 11491 | +** SQLITE_TRANSIENT has no effect here. |
| 11478 | 11492 | */ |
| 11479 | | -SQLITE_API SQLITE_API int sqlite3_carray_bind( |
| 11493 | +SQLITE_API int sqlite3_carray_bind( |
| 11480 | 11494 | sqlite3_stmt *pStmt, /* Statement to be bound */ |
| 11481 | 11495 | int i, /* Parameter index */ |
| 11482 | 11496 | void *aData, /* Pointer to array data */ |
| 11483 | 11497 | int nData, /* Number of data elements */ |
| 11484 | 11498 | int mFlags, /* CARRAY flags */ |
| 11485 | 11499 | void (*xDel)(void*) /* Destructor for aData */ |
| 11486 | 11500 | ); |
| 11487 | 11501 | |
| 11488 | 11502 | /* |
| 11489 | | -** CAPI3REF: Datatypes for the CARRAY table-valued funtion |
| 11503 | +** CAPI3REF: Datatypes for the CARRAY table-valued function |
| 11490 | 11504 | ** |
| 11491 | 11505 | ** The fifth argument to the [sqlite3_carray_bind()] interface musts be |
| 11492 | 11506 | ** one of the following constants, to specify the datatype of the array |
| 11493 | 11507 | ** that is being bound into the [carray table-valued function]. |
| 11494 | 11508 | */ |
| | @@ -22014,11 +22028,11 @@ |
| 22014 | 22028 | SQLITE_PRIVATE void sqlite3RootPageMoved(sqlite3*, int, Pgno, Pgno); |
| 22015 | 22029 | SQLITE_PRIVATE void sqlite3Reindex(Parse*, Token*, Token*); |
| 22016 | 22030 | SQLITE_PRIVATE void sqlite3AlterFunctions(void); |
| 22017 | 22031 | SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*); |
| 22018 | 22032 | SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*); |
| 22019 | | -SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *); |
| 22033 | +SQLITE_PRIVATE i64 sqlite3GetToken(const unsigned char *, int *); |
| 22020 | 22034 | SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...); |
| 22021 | 22035 | SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int); |
| 22022 | 22036 | SQLITE_PRIVATE void sqlite3CodeRhsOfIN(Parse*, Expr*, int); |
| 22023 | 22037 | SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr*); |
| 22024 | 22038 | SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*); |
| | @@ -39781,10 +39795,123 @@ |
| 39781 | 39795 | #endif |
| 39782 | 39796 | |
| 39783 | 39797 | }; /* End of the overrideable system calls */ |
| 39784 | 39798 | |
| 39785 | 39799 | |
| 39800 | +#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT) |
| 39801 | +/* |
| 39802 | +** Extract Posix Advisory Locking information about file description fd |
| 39803 | +** from the /proc/PID/fdinfo/FD pseudo-file. Fill the string buffer a[16] |
| 39804 | +** with characters to indicate which SQLite-relevant locks are held. |
| 39805 | +** a[16] will be a 15-character zero-terminated string with the following |
| 39806 | +** schema: |
| 39807 | +** |
| 39808 | +** AAA/B.DDD.DDDDD |
| 39809 | +** |
| 39810 | +** Each of character A-D will be "w" or "r" or "-" to indicate either a |
| 39811 | +** write-lock, a read-lock, or no-lock, respectively. The "." and "/" |
| 39812 | +** characters are delimiters intended to make the string more easily |
| 39813 | +** readable by humans. Here are the meaning of the specific letters: |
| 39814 | +** |
| 39815 | +** AAA -> The main database locks. PENDING_BYTE, RESERVED_BYTE, |
| 39816 | +** and SHARED_FIRST, respectively. |
| 39817 | +** |
| 39818 | +** B -> The deadman switch lock. Offset 128 of the -shm file. |
| 39819 | +** |
| 39820 | +** CCC -> WAL locks: WRITE, CKPT, RECOVER |
| 39821 | +** |
| 39822 | +** DDDDD -> WAL read-locks 0 through 5 |
| 39823 | +** |
| 39824 | +** Note that elements before the "/" apply to the main database file and |
| 39825 | +** elements after the "/" apply to the -shm file in WAL mode. |
| 39826 | +** |
| 39827 | +** Here is another way of thinking about the meaning of the result string: |
| 39828 | +** |
| 39829 | +** AAA/B.CCC.DDDDD |
| 39830 | +** ||| | ||| \___/ |
| 39831 | +** PENDING--'|| | ||| `----- READ 0-5 |
| 39832 | +** RESERVED--'| | ||`---- RECOVER |
| 39833 | +** SHARED ----' | |`----- CKPT |
| 39834 | +** DMS ------' `------ WRITE |
| 39835 | +** |
| 39836 | +** Return SQLITE_OK on success and SQLITE_ERROR_UNABLE if the /proc |
| 39837 | +** pseudo-filesystem is unavailable. |
| 39838 | +*/ |
| 39839 | +static int unixPosixAdvisoryLocks( |
| 39840 | + int fd, /* The file descriptor to analyze */ |
| 39841 | + char a[16] /* Write a text description of PALs here */ |
| 39842 | +){ |
| 39843 | + int in; |
| 39844 | + ssize_t n; |
| 39845 | + char *p, *pNext, *x; |
| 39846 | + char z[2000]; |
| 39847 | + |
| 39848 | + /* 1 */ |
| 39849 | + /* 012 4 678 01234 */ |
| 39850 | + memcpy(a, "---/-.---.-----", 16); |
| 39851 | + sqlite3_snprintf(sizeof(z), z, "/proc/%d/fdinfo/%d", getpid(), fd); |
| 39852 | + in = osOpen(z, O_RDONLY, 0); |
| 39853 | + if( in<0 ){ |
| 39854 | + return SQLITE_ERROR_UNABLE; |
| 39855 | + } |
| 39856 | + n = osRead(in, z, sizeof(z)-1); |
| 39857 | + osClose(in); |
| 39858 | + if( n<=0 ) return SQLITE_ERROR_UNABLE; |
| 39859 | + z[n] = 0; |
| 39860 | + |
| 39861 | + /* We are looking for lines that begin with "lock:\t". Examples: |
| 39862 | + ** |
| 39863 | + ** lock: 1: POSIX ADVISORY READ 494716 08:02:5277597 1073741826 1073742335 |
| 39864 | + ** lock: 1: POSIX ADVISORY WRITE 494716 08:02:5282282 120 120 |
| 39865 | + ** lock: 2: POSIX ADVISORY READ 494716 08:02:5282282 123 123 |
| 39866 | + ** lock: 3: POSIX ADVISORY READ 494716 08:02:5282282 128 128 |
| 39867 | + */ |
| 39868 | + pNext = strstr(z, "lock:\t"); |
| 39869 | + while( pNext ){ |
| 39870 | + char cType = 0; |
| 39871 | + sqlite3_int64 iFirst, iLast; |
| 39872 | + p = pNext+6; |
| 39873 | + pNext = strstr(p, "lock:\t"); |
| 39874 | + if( pNext ) pNext[-1] = 0; |
| 39875 | + if( (x = strstr(p, " READ "))!=0 ){ |
| 39876 | + cType = 'r'; |
| 39877 | + x += 6; |
| 39878 | + }else if( (x = strstr(p, " WRITE "))!=0 ){ |
| 39879 | + cType = 'w'; |
| 39880 | + x += 7; |
| 39881 | + }else{ |
| 39882 | + continue; |
| 39883 | + } |
| 39884 | + x = strrchr(x, ' '); |
| 39885 | + if( x==0 ) continue; |
| 39886 | + iLast = strtoll(x+1, 0, 10); |
| 39887 | + *x = 0; |
| 39888 | + x = strrchr(p, ' '); |
| 39889 | + if( x==0 ) continue; |
| 39890 | + iFirst = strtoll(x+1, 0, 10); |
| 39891 | + if( iLast>=PENDING_BYTE ){ |
| 39892 | + if( iFirst<=PENDING_BYTE && iLast>=PENDING_BYTE ) a[0] = cType; |
| 39893 | + if( iFirst<=PENDING_BYTE+1 && iLast>=PENDING_BYTE+1 ) a[1] = cType; |
| 39894 | + if( iFirst<=PENDING_BYTE+2 && iLast>=PENDING_BYTE+510 ) a[2] = cType; |
| 39895 | + }else if( iLast<=128 ){ |
| 39896 | + if( iFirst<=128 && iLast>=128 ) a[4] = cType; |
| 39897 | + if( iFirst<=120 && iLast>=120 ) a[6] = cType; |
| 39898 | + if( iFirst<=121 && iLast>=121 ) a[7] = cType; |
| 39899 | + if( iFirst<=122 && iLast>=122 ) a[8] = cType; |
| 39900 | + if( iFirst<=123 && iLast>=123 ) a[10] = cType; |
| 39901 | + if( iFirst<=124 && iLast>=124 ) a[11] = cType; |
| 39902 | + if( iFirst<=125 && iLast>=125 ) a[12] = cType; |
| 39903 | + if( iFirst<=126 && iLast>=126 ) a[13] = cType; |
| 39904 | + if( iFirst<=127 && iLast>=127 ) a[14] = cType; |
| 39905 | + } |
| 39906 | + } |
| 39907 | + return SQLITE_OK; |
| 39908 | +} |
| 39909 | +#else |
| 39910 | +# define unixPosixAdvisoryLocks(A,B) SQLITE_ERROR_UNABLE |
| 39911 | +#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */ |
| 39912 | + |
| 39786 | 39913 | /* |
| 39787 | 39914 | ** On some systems, calls to fchown() will trigger a message in a security |
| 39788 | 39915 | ** log if they come from non-root processes. So avoid calling fchown() if |
| 39789 | 39916 | ** we are not running as root. |
| 39790 | 39917 | */ |
| | @@ -40904,10 +41031,13 @@ |
| 40904 | 41031 | rc = osSetPosixAdvisoryLock(pFile->h, pLock, pFile); |
| 40905 | 41032 | } |
| 40906 | 41033 | return rc; |
| 40907 | 41034 | } |
| 40908 | 41035 | |
| 41036 | +/* Forward reference */ |
| 41037 | +static int unixIsSharingShmNode(unixFile*); |
| 41038 | + |
| 40909 | 41039 | /* |
| 40910 | 41040 | ** Lock the file with the lock specified by parameter eFileLock - one |
| 40911 | 41041 | ** of the following: |
| 40912 | 41042 | ** |
| 40913 | 41043 | ** (1) SHARED_LOCK |
| | @@ -41092,11 +41222,13 @@ |
| 41092 | 41222 | }else{ |
| 41093 | 41223 | pFile->eFileLock = SHARED_LOCK; |
| 41094 | 41224 | pInode->nLock++; |
| 41095 | 41225 | pInode->nShared = 1; |
| 41096 | 41226 | } |
| 41097 | | - }else if( eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1 ){ |
| 41227 | + }else if( (eFileLock==EXCLUSIVE_LOCK && pInode->nShared>1) |
| 41228 | + || unixIsSharingShmNode(pFile) |
| 41229 | + ){ |
| 41098 | 41230 | /* We are trying for an exclusive lock but another thread in this |
| 41099 | 41231 | ** same process is still holding a shared lock. */ |
| 41100 | 41232 | rc = SQLITE_BUSY; |
| 41101 | 41233 | }else{ |
| 41102 | 41234 | /* The request was for a RESERVED or EXCLUSIVE lock. It is |
| | @@ -43187,10 +43319,14 @@ |
| 43187 | 43319 | /* Forward declaration */ |
| 43188 | 43320 | static int unixGetTempname(int nBuf, char *zBuf); |
| 43189 | 43321 | #if !defined(SQLITE_WASI) && !defined(SQLITE_OMIT_WAL) |
| 43190 | 43322 | static int unixFcntlExternalReader(unixFile*, int*); |
| 43191 | 43323 | #endif |
| 43324 | +#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT) |
| 43325 | + static void unixDescribeShm(sqlite3_str*,unixShm*); |
| 43326 | +#endif |
| 43327 | + |
| 43192 | 43328 | |
| 43193 | 43329 | /* |
| 43194 | 43330 | ** Information and control of an open file handle. |
| 43195 | 43331 | */ |
| 43196 | 43332 | static int unixFileControl(sqlite3_file *id, int op, void *pArg){ |
| | @@ -43329,10 +43465,70 @@ |
| 43329 | 43465 | #else |
| 43330 | 43466 | *(int*)pArg = 0; |
| 43331 | 43467 | return SQLITE_OK; |
| 43332 | 43468 | #endif |
| 43333 | 43469 | } |
| 43470 | + |
| 43471 | +#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT) |
| 43472 | + case SQLITE_FCNTL_FILESTAT: { |
| 43473 | + sqlite3_str *pStr = (sqlite3_str*)pArg; |
| 43474 | + char aLck[16]; |
| 43475 | + unixInodeInfo *pInode; |
| 43476 | + static const char *azLock[] = { "SHARED", "RESERVED", |
| 43477 | + "PENDING", "EXCLUSIVE" }; |
| 43478 | + sqlite3_str_appendf(pStr, "{\"h\":%d", pFile->h); |
| 43479 | + sqlite3_str_appendf(pStr, ",\"vfs\":\"%s\"", pFile->pVfs->zName); |
| 43480 | + if( pFile->eFileLock ){ |
| 43481 | + sqlite3_str_appendf(pStr, ",\"eFileLock\":\"%s\"", |
| 43482 | + azLock[pFile->eFileLock-1]); |
| 43483 | + if( unixPosixAdvisoryLocks(pFile->h, aLck)==SQLITE_OK ){ |
| 43484 | + sqlite3_str_appendf(pStr, ",\"pal\":\"%s\"", aLck); |
| 43485 | + } |
| 43486 | + } |
| 43487 | + unixEnterMutex(); |
| 43488 | + if( pFile->pShm ){ |
| 43489 | + sqlite3_str_appendall(pStr, ",\"shm\":"); |
| 43490 | + unixDescribeShm(pStr, pFile->pShm); |
| 43491 | + } |
| 43492 | +#if SQLITE_MAX_MMAP_SIZE>0 |
| 43493 | + if( pFile->mmapSize ){ |
| 43494 | + sqlite3_str_appendf(pStr, ",\"mmapSize\":%lld", pFile->mmapSize); |
| 43495 | + sqlite3_str_appendf(pStr, ",\"nFetchOut\":%d", pFile->nFetchOut); |
| 43496 | + } |
| 43497 | +#endif |
| 43498 | + if( (pInode = pFile->pInode)!=0 ){ |
| 43499 | + sqlite3_str_appendf(pStr, ",\"inode\":{\"nRef\":%d",pInode->nRef); |
| 43500 | + sqlite3_mutex_enter(pInode->pLockMutex); |
| 43501 | + sqlite3_str_appendf(pStr, ",\"nShared\":%d", pInode->nShared); |
| 43502 | + if( pInode->eFileLock ){ |
| 43503 | + sqlite3_str_appendf(pStr, ",\"eFileLock\":\"%s\"", |
| 43504 | + azLock[pInode->eFileLock-1]); |
| 43505 | + } |
| 43506 | + if( pInode->pUnused ){ |
| 43507 | + char cSep = '['; |
| 43508 | + UnixUnusedFd *pUFd = pFile->pInode->pUnused; |
| 43509 | + sqlite3_str_appendall(pStr, ",\"unusedFd\":"); |
| 43510 | + while( pUFd ){ |
| 43511 | + sqlite3_str_appendf(pStr, "%c{\"fd\":%d,\"flags\":%d", |
| 43512 | + cSep, pUFd->fd, pUFd->flags); |
| 43513 | + cSep = ','; |
| 43514 | + if( unixPosixAdvisoryLocks(pUFd->fd, aLck)==SQLITE_OK ){ |
| 43515 | + sqlite3_str_appendf(pStr, ",\"pal\":\"%s\"", aLck); |
| 43516 | + } |
| 43517 | + sqlite3_str_append(pStr, "}", 1); |
| 43518 | + pUFd = pUFd->pNext; |
| 43519 | + } |
| 43520 | + sqlite3_str_append(pStr, "]", 1); |
| 43521 | + } |
| 43522 | + sqlite3_mutex_leave(pInode->pLockMutex); |
| 43523 | + sqlite3_str_append(pStr, "}", 1); |
| 43524 | + } |
| 43525 | + unixLeaveMutex(); |
| 43526 | + sqlite3_str_append(pStr, "}", 1); |
| 43527 | + return SQLITE_OK; |
| 43528 | + } |
| 43529 | +#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */ |
| 43334 | 43530 | } |
| 43335 | 43531 | return SQLITE_NOTFOUND; |
| 43336 | 43532 | } |
| 43337 | 43533 | |
| 43338 | 43534 | /* |
| | @@ -43595,10 +43791,30 @@ |
| 43595 | 43791 | ** Constants used for locking |
| 43596 | 43792 | */ |
| 43597 | 43793 | #define UNIX_SHM_BASE ((22+SQLITE_SHM_NLOCK)*4) /* first lock byte */ |
| 43598 | 43794 | #define UNIX_SHM_DMS (UNIX_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */ |
| 43599 | 43795 | |
| 43796 | +#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT) |
| 43797 | +/* |
| 43798 | +** Describe the pShm object using JSON. Used for diagnostics only. |
| 43799 | +*/ |
| 43800 | +static void unixDescribeShm(sqlite3_str *pStr, unixShm *pShm){ |
| 43801 | + unixShmNode *pNode = pShm->pShmNode; |
| 43802 | + char aLck[16]; |
| 43803 | + sqlite3_str_appendf(pStr, "{\"h\":%d", pNode->hShm); |
| 43804 | + assert( unixMutexHeld() ); |
| 43805 | + sqlite3_str_appendf(pStr, ",\"nRef\":%d", pNode->nRef); |
| 43806 | + sqlite3_str_appendf(pStr, ",\"id\":%d", pShm->id); |
| 43807 | + sqlite3_str_appendf(pStr, ",\"sharedMask\":%d", pShm->sharedMask); |
| 43808 | + sqlite3_str_appendf(pStr, ",\"exclMask\":%d", pShm->exclMask); |
| 43809 | + if( unixPosixAdvisoryLocks(pNode->hShm, aLck)==SQLITE_OK ){ |
| 43810 | + sqlite3_str_appendf(pStr, ",\"pal\":\"%s\"", aLck); |
| 43811 | + } |
| 43812 | + sqlite3_str_append(pStr, "}", 1); |
| 43813 | +} |
| 43814 | +#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */ |
| 43815 | + |
| 43600 | 43816 | /* |
| 43601 | 43817 | ** Use F_GETLK to check whether or not there are any readers with open |
| 43602 | 43818 | ** wal-mode transactions in other processes on database file pFile. If |
| 43603 | 43819 | ** no error occurs, return SQLITE_OK and set (*piOut) to 1 if there are |
| 43604 | 43820 | ** such transactions, or 0 otherwise. If an error occurs, return an |
| | @@ -43628,10 +43844,53 @@ |
| 43628 | 43844 | } |
| 43629 | 43845 | |
| 43630 | 43846 | return rc; |
| 43631 | 43847 | } |
| 43632 | 43848 | |
| 43849 | +/* |
| 43850 | +** If pFile has a -shm file open and it is sharing that file with some |
| 43851 | +** other connection, either in the same process or in a separate process, |
| 43852 | +** then return true. Return false if either pFile does not have a -shm |
| 43853 | +** file open or if it is the only connection to that -shm file across the |
| 43854 | +** entire system. |
| 43855 | +** |
| 43856 | +** This routine is not required for correct operation. It can always return |
| 43857 | +** false and SQLite will continue to operate according to spec. However, |
| 43858 | +** when this routine does its job, it adds extra robustness in cases |
| 43859 | +** where database file locks have been erroneously deleted in a WAL-mode |
| 43860 | +** database by doing close(open(DATABASE_PATHNAME)) or similar. |
| 43861 | +** |
| 43862 | +** With false negatives, SQLite still operates to spec, though with less |
| 43863 | +** robustness. With false positives, the last database connection on a |
| 43864 | +** WAL-mode database will fail to unlink the -wal and -shm files, which |
| 43865 | +** is annoying but harmless. False positives will also prevent a database |
| 43866 | +** connection from running "PRAGMA journal_mode=DELETE" in order to take |
| 43867 | +** the database out of WAL mode, which is perhaps more serious, but is |
| 43868 | +** still not a disaster. |
| 43869 | +*/ |
| 43870 | +static int unixIsSharingShmNode(unixFile *pFile){ |
| 43871 | + int rc; |
| 43872 | + unixShmNode *pShmNode; |
| 43873 | + if( pFile->pShm==0 ) return 0; |
| 43874 | + if( pFile->ctrlFlags & UNIXFILE_EXCL ) return 0; |
| 43875 | + pShmNode = pFile->pShm->pShmNode; |
| 43876 | + rc = 1; |
| 43877 | + unixEnterMutex(); |
| 43878 | + if( ALWAYS(pShmNode->nRef==1) ){ |
| 43879 | + struct flock lock; |
| 43880 | + lock.l_whence = SEEK_SET; |
| 43881 | + lock.l_start = UNIX_SHM_DMS; |
| 43882 | + lock.l_len = 1; |
| 43883 | + lock.l_type = F_WRLCK; |
| 43884 | + osFcntl(pShmNode->hShm, F_GETLK, &lock); |
| 43885 | + if( lock.l_type==F_UNLCK ){ |
| 43886 | + rc = 0; |
| 43887 | + } |
| 43888 | + } |
| 43889 | + unixLeaveMutex(); |
| 43890 | + return rc; |
| 43891 | +} |
| 43633 | 43892 | |
| 43634 | 43893 | /* |
| 43635 | 43894 | ** Apply posix advisory locks for all bytes from ofst through ofst+n-1. |
| 43636 | 43895 | ** |
| 43637 | 43896 | ** Locks block if the mask is exactly UNIX_SHM_C and are non-blocking |
| | @@ -43673,11 +43932,12 @@ |
| 43673 | 43932 | /* Shared locks never span more than one byte */ |
| 43674 | 43933 | assert( n==1 || lockType!=F_RDLCK ); |
| 43675 | 43934 | |
| 43676 | 43935 | /* Locks are within range */ |
| 43677 | 43936 | assert( n>=1 && n<=SQLITE_SHM_NLOCK ); |
| 43678 | | - assert( ofst>=UNIX_SHM_BASE && ofst<=(UNIX_SHM_DMS+SQLITE_SHM_NLOCK) ); |
| 43937 | + assert( ofst>=UNIX_SHM_BASE && ofst<=UNIX_SHM_DMS ); |
| 43938 | + assert( ofst+n-1<=UNIX_SHM_DMS ); |
| 43679 | 43939 | |
| 43680 | 43940 | if( pShmNode->hShm>=0 ){ |
| 43681 | 43941 | int res; |
| 43682 | 43942 | /* Initialize the locking parameters */ |
| 43683 | 43943 | f.l_type = lockType; |
| | @@ -51478,10 +51738,32 @@ |
| 51478 | 51738 | int iNew = *(int*)pArg; |
| 51479 | 51739 | pFile->bBlockOnConnect = iNew; |
| 51480 | 51740 | return SQLITE_OK; |
| 51481 | 51741 | } |
| 51482 | 51742 | #endif /* SQLITE_ENABLE_SETLK_TIMEOUT */ |
| 51743 | + |
| 51744 | +#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT) |
| 51745 | + case SQLITE_FCNTL_FILESTAT: { |
| 51746 | + sqlite3_str *pStr = (sqlite3_str*)pArg; |
| 51747 | + sqlite3_str_appendf(pStr, "{\"h\":%llu", (sqlite3_uint64)pFile->h); |
| 51748 | + sqlite3_str_appendf(pStr, ",\"vfs\":\"%s\"", pFile->pVfs->zName); |
| 51749 | + if( pFile->locktype ){ |
| 51750 | + static const char *azLock[] = { "SHARED", "RESERVED", |
| 51751 | + "PENDING", "EXCLUSIVE" }; |
| 51752 | + sqlite3_str_appendf(pStr, ",\"locktype\":\"%s\"", |
| 51753 | + azLock[pFile->locktype-1]); |
| 51754 | + } |
| 51755 | +#if SQLITE_MAX_MMAP_SIZE>0 |
| 51756 | + if( pFile->mmapSize ){ |
| 51757 | + sqlite3_str_appendf(pStr, ",\"mmapSize\":%lld", pFile->mmapSize); |
| 51758 | + sqlite3_str_appendf(pStr, ",\"nFetchOut\":%d", pFile->nFetchOut); |
| 51759 | + } |
| 51760 | +#endif |
| 51761 | + sqlite3_str_append(pStr, "}", 1); |
| 51762 | + return SQLITE_OK; |
| 51763 | + } |
| 51764 | +#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */ |
| 51483 | 51765 | |
| 51484 | 51766 | } |
| 51485 | 51767 | OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h)); |
| 51486 | 51768 | return SQLITE_NOTFOUND; |
| 51487 | 51769 | } |
| | @@ -67063,11 +67345,11 @@ |
| 67063 | 67345 | } aSegment[FLEXARRAY]; /* One for every 32KB page in the wal-index */ |
| 67064 | 67346 | }; |
| 67065 | 67347 | |
| 67066 | 67348 | /* Size (in bytes) of a WalIterator object suitable for N or fewer segments */ |
| 67067 | 67349 | #define SZ_WALITERATOR(N) \ |
| 67068 | | - (offsetof(WalIterator,aSegment)*(N)*sizeof(struct WalSegment)) |
| 67350 | + (offsetof(WalIterator,aSegment)+(N)*sizeof(struct WalSegment)) |
| 67069 | 67351 | |
| 67070 | 67352 | /* |
| 67071 | 67353 | ** Define the parameters of the hash tables in the wal-index file. There |
| 67072 | 67354 | ** is a hash-table following every HASHTABLE_NPAGE page numbers in the |
| 67073 | 67355 | ** wal-index. |
| | @@ -94735,14 +95017,14 @@ |
| 94735 | 95017 | ** zSql is a zero-terminated string of UTF-8 SQL text. Return the number of |
| 94736 | 95018 | ** bytes in this text up to but excluding the first character in |
| 94737 | 95019 | ** a host parameter. If the text contains no host parameters, return |
| 94738 | 95020 | ** the total number of bytes in the text. |
| 94739 | 95021 | */ |
| 94740 | | -static int findNextHostParameter(const char *zSql, int *pnToken){ |
| 95022 | +static i64 findNextHostParameter(const char *zSql, i64 *pnToken){ |
| 94741 | 95023 | int tokenType; |
| 94742 | | - int nTotal = 0; |
| 94743 | | - int n; |
| 95024 | + i64 nTotal = 0; |
| 95025 | + i64 n; |
| 94744 | 95026 | |
| 94745 | 95027 | *pnToken = 0; |
| 94746 | 95028 | while( zSql[0] ){ |
| 94747 | 95029 | n = sqlite3GetToken((u8*)zSql, &tokenType); |
| 94748 | 95030 | assert( n>0 && tokenType!=TK_ILLEGAL ); |
| | @@ -94785,12 +95067,12 @@ |
| 94785 | 95067 | const char *zRawSql /* Raw text of the SQL statement */ |
| 94786 | 95068 | ){ |
| 94787 | 95069 | sqlite3 *db; /* The database connection */ |
| 94788 | 95070 | int idx = 0; /* Index of a host parameter */ |
| 94789 | 95071 | int nextIndex = 1; /* Index of next ? host parameter */ |
| 94790 | | - int n; /* Length of a token prefix */ |
| 94791 | | - int nToken; /* Length of the parameter token */ |
| 95072 | + i64 n; /* Length of a token prefix */ |
| 95073 | + i64 nToken; /* Length of the parameter token */ |
| 94792 | 95074 | int i; /* Loop counter */ |
| 94793 | 95075 | Mem *pVar; /* Value of a host parameter */ |
| 94794 | 95076 | StrAccum out; /* Accumulate the output here */ |
| 94795 | 95077 | #ifndef SQLITE_OMIT_UTF16 |
| 94796 | 95078 | Mem utf8; /* Used to convert UTF16 into UTF8 for display */ |
| | @@ -96816,10 +97098,13 @@ |
| 96816 | 97098 | nByte = pIn1->n; |
| 96817 | 97099 | nByte += pIn2->n; |
| 96818 | 97100 | if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 96819 | 97101 | goto too_big; |
| 96820 | 97102 | } |
| 97103 | +#if SQLITE_MAX_LENGTH>2147483645 |
| 97104 | + if( nByte>2147483645 ){ goto too_big; } |
| 97105 | +#endif |
| 96821 | 97106 | if( sqlite3VdbeMemGrow(pOut, (int)nByte+2, pOut==pIn2) ){ |
| 96822 | 97107 | goto no_mem; |
| 96823 | 97108 | } |
| 96824 | 97109 | MemSetTypeFlag(pOut, MEM_Str); |
| 96825 | 97110 | if( pOut!=pIn2 ){ |
| | @@ -131915,11 +132200,11 @@ |
| 131915 | 132200 | static void *contextMalloc(sqlite3_context *context, i64 nByte){ |
| 131916 | 132201 | char *z; |
| 131917 | 132202 | sqlite3 *db = sqlite3_context_db_handle(context); |
| 131918 | 132203 | assert( nByte>0 ); |
| 131919 | 132204 | testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH] ); |
| 131920 | | - testcase( nByte==db->aLimit[SQLITE_LIMIT_LENGTH]+1 ); |
| 132205 | + testcase( nByte==(i64)db->aLimit[SQLITE_LIMIT_LENGTH]+1 ); |
| 131921 | 132206 | if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 131922 | 132207 | sqlite3_result_error_toobig(context); |
| 131923 | 132208 | z = 0; |
| 131924 | 132209 | }else{ |
| 131925 | 132210 | z = sqlite3Malloc(nByte); |
| | @@ -134180,12 +134465,12 @@ |
| 134180 | 134465 | ** aggregate. Remember all input Y values until the very end. |
| 134181 | 134466 | ** Those values are accumulated in the Percentile.a[] array. |
| 134182 | 134467 | */ |
| 134183 | 134468 | typedef struct Percentile Percentile; |
| 134184 | 134469 | struct Percentile { |
| 134185 | | - unsigned nAlloc; /* Number of slots allocated for a[] */ |
| 134186 | | - unsigned nUsed; /* Number of slots actually used in a[] */ |
| 134470 | + u64 nAlloc; /* Number of slots allocated for a[] */ |
| 134471 | + u64 nUsed; /* Number of slots actually used in a[] */ |
| 134187 | 134472 | char bSorted; /* True if a[] is already in sorted order */ |
| 134188 | 134473 | char bKeepSorted; /* True if advantageous to keep a[] sorted */ |
| 134189 | 134474 | char bPctValid; /* True if rPct is valid */ |
| 134190 | 134475 | double rPct; /* Fraction. 0.0 to 1.0 */ |
| 134191 | 134476 | double *a; /* Array of Y values */ |
| | @@ -134218,15 +134503,15 @@ |
| 134218 | 134503 | ** If bExact is false, return the index at which a new entry with |
| 134219 | 134504 | ** value y should be insert in order to keep the values in sorted |
| 134220 | 134505 | ** order. The smallest return value in this case will be 0, and |
| 134221 | 134506 | ** the largest return value will be p->nUsed. |
| 134222 | 134507 | */ |
| 134223 | | -static int percentBinarySearch(Percentile *p, double y, int bExact){ |
| 134224 | | - int iFirst = 0; /* First element of search range */ |
| 134225 | | - int iLast = p->nUsed - 1; /* Last element of search range */ |
| 134508 | +static i64 percentBinarySearch(Percentile *p, double y, int bExact){ |
| 134509 | + i64 iFirst = 0; /* First element of search range */ |
| 134510 | + i64 iLast = (i64)p->nUsed - 1; /* Last element of search range */ |
| 134226 | 134511 | while( iLast>=iFirst ){ |
| 134227 | | - int iMid = (iFirst+iLast)/2; |
| 134512 | + i64 iMid = (iFirst+iLast)/2; |
| 134228 | 134513 | double x = p->a[iMid]; |
| 134229 | 134514 | if( x<y ){ |
| 134230 | 134515 | iFirst = iMid + 1; |
| 134231 | 134516 | }else if( x>y ){ |
| 134232 | 134517 | iLast = iMid - 1; |
| | @@ -134325,11 +134610,11 @@ |
| 134325 | 134610 | return; |
| 134326 | 134611 | } |
| 134327 | 134612 | |
| 134328 | 134613 | /* Allocate and store the Y */ |
| 134329 | 134614 | if( p->nUsed>=p->nAlloc ){ |
| 134330 | | - unsigned n = p->nAlloc*2 + 250; |
| 134615 | + u64 n = p->nAlloc*2 + 250; |
| 134331 | 134616 | double *a = sqlite3_realloc64(p->a, sizeof(double)*n); |
| 134332 | 134617 | if( a==0 ){ |
| 134333 | 134618 | sqlite3_free(p->a); |
| 134334 | 134619 | memset(p, 0, sizeof(*p)); |
| 134335 | 134620 | sqlite3_result_error_nomem(pCtx); |
| | @@ -134342,11 +134627,11 @@ |
| 134342 | 134627 | p->a[p->nUsed++] = y; |
| 134343 | 134628 | p->bSorted = 1; |
| 134344 | 134629 | }else if( !p->bSorted || y>=p->a[p->nUsed-1] ){ |
| 134345 | 134630 | p->a[p->nUsed++] = y; |
| 134346 | 134631 | }else if( p->bKeepSorted ){ |
| 134347 | | - int i; |
| 134632 | + i64 i; |
| 134348 | 134633 | i = percentBinarySearch(p, y, 0); |
| 134349 | 134634 | if( i<(int)p->nUsed ){ |
| 134350 | 134635 | memmove(&p->a[i+1], &p->a[i], (p->nUsed-i)*sizeof(p->a[0])); |
| 134351 | 134636 | } |
| 134352 | 134637 | p->a[i] = y; |
| | @@ -134427,11 +134712,11 @@ |
| 134427 | 134712 | */ |
| 134428 | 134713 | static void percentInverse(sqlite3_context *pCtx,int argc,sqlite3_value **argv){ |
| 134429 | 134714 | Percentile *p; |
| 134430 | 134715 | int eType; |
| 134431 | 134716 | double y; |
| 134432 | | - int i; |
| 134717 | + i64 i; |
| 134433 | 134718 | assert( argc==2 || argc==1 ); |
| 134434 | 134719 | |
| 134435 | 134720 | /* Allocate the session context. */ |
| 134436 | 134721 | p = (Percentile*)sqlite3_aggregate_context(pCtx, sizeof(*p)); |
| 134437 | 134722 | assert( p!=0 ); |
| | @@ -134513,10 +134798,60 @@ |
| 134513 | 134798 | percentCompute(pCtx, 0); |
| 134514 | 134799 | } |
| 134515 | 134800 | /****** End of percentile family of functions ******/ |
| 134516 | 134801 | #endif /* SQLITE_ENABLE_PERCENTILE */ |
| 134517 | 134802 | |
| 134803 | +#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT) |
| 134804 | +/* |
| 134805 | +** Implementation of sqlite_filestat(SCHEMA). |
| 134806 | +** |
| 134807 | +** Return JSON text that describes low-level debug/diagnostic information |
| 134808 | +** about the sqlite3_file object associated with SCHEMA. |
| 134809 | +*/ |
| 134810 | +static void filestatFunc( |
| 134811 | + sqlite3_context *context, |
| 134812 | + int argc, |
| 134813 | + sqlite3_value **argv |
| 134814 | +){ |
| 134815 | + sqlite3 *db = sqlite3_context_db_handle(context); |
| 134816 | + const char *zDbName; |
| 134817 | + sqlite3_str *pStr; |
| 134818 | + Btree *pBtree; |
| 134819 | + |
| 134820 | + zDbName = (const char*)sqlite3_value_text(argv[0]); |
| 134821 | + pBtree = sqlite3DbNameToBtree(db, zDbName); |
| 134822 | + if( pBtree ){ |
| 134823 | + Pager *pPager; |
| 134824 | + sqlite3_file *fd; |
| 134825 | + int rc; |
| 134826 | + sqlite3BtreeEnter(pBtree); |
| 134827 | + pPager = sqlite3BtreePager(pBtree); |
| 134828 | + assert( pPager!=0 ); |
| 134829 | + fd = sqlite3PagerFile(pPager); |
| 134830 | + pStr = sqlite3_str_new(db); |
| 134831 | + if( pStr==0 ){ |
| 134832 | + sqlite3_result_error_nomem(context); |
| 134833 | + }else{ |
| 134834 | + sqlite3_str_append(pStr, "{\"db\":", 6); |
| 134835 | + rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_FILESTAT, pStr); |
| 134836 | + if( rc ) sqlite3_str_append(pStr, "null", 4); |
| 134837 | + fd = sqlite3PagerJrnlFile(pPager); |
| 134838 | + if( fd && fd->pMethods!=0 ){ |
| 134839 | + sqlite3_str_appendall(pStr, ",\"journal\":"); |
| 134840 | + rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_FILESTAT, pStr); |
| 134841 | + if( rc ) sqlite3_str_append(pStr, "null", 4); |
| 134842 | + } |
| 134843 | + sqlite3_str_append(pStr, "}", 1); |
| 134844 | + sqlite3_result_text(context, sqlite3_str_finish(pStr), -1, |
| 134845 | + sqlite3_free); |
| 134846 | + } |
| 134847 | + sqlite3BtreeLeave(pBtree); |
| 134848 | + }else{ |
| 134849 | + sqlite3_result_text(context, "{}", 2, SQLITE_STATIC); |
| 134850 | + } |
| 134851 | +} |
| 134852 | +#endif /* SQLITE_DEBUG || SQLITE_ENABLE_FILESTAT */ |
| 134518 | 134853 | |
| 134519 | 134854 | #ifdef SQLITE_DEBUG |
| 134520 | 134855 | /* |
| 134521 | 134856 | ** Implementation of fpdecode(x,y,z) function. |
| 134522 | 134857 | ** |
| | @@ -134672,10 +135007,13 @@ |
| 134672 | 135007 | INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY), |
| 134673 | 135008 | INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY), |
| 134674 | 135009 | #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC |
| 134675 | 135010 | INLINE_FUNC(sqlite_offset, 1, INLINEFUNC_sqlite_offset, 0 ), |
| 134676 | 135011 | #endif |
| 135012 | +#if defined(SQLITE_DEBUG) || defined(SQLITE_ENABLE_FILESTAT) |
| 135013 | + FUNCTION(sqlite_filestat, 1, 0, 0, filestatFunc ), |
| 135014 | +#endif |
| 134677 | 135015 | FUNCTION(ltrim, 1, 1, 0, trimFunc ), |
| 134678 | 135016 | FUNCTION(ltrim, 2, 1, 0, trimFunc ), |
| 134679 | 135017 | FUNCTION(rtrim, 1, 2, 0, trimFunc ), |
| 134680 | 135018 | FUNCTION(rtrim, 2, 2, 0, trimFunc ), |
| 134681 | 135019 | FUNCTION(trim, 1, 3, 0, trimFunc ), |
| | @@ -183458,12 +183796,13 @@ |
| 183458 | 183796 | |
| 183459 | 183797 | /* |
| 183460 | 183798 | ** Return the length (in bytes) of the token that begins at z[0]. |
| 183461 | 183799 | ** Store the token type in *tokenType before returning. |
| 183462 | 183800 | */ |
| 183463 | | -SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){ |
| 183464 | | - int i, c; |
| 183801 | +SQLITE_PRIVATE i64 sqlite3GetToken(const unsigned char *z, int *tokenType){ |
| 183802 | + i64 i; |
| 183803 | + int c; |
| 183465 | 183804 | switch( aiClass[*z] ){ /* Switch on the character-class of the first byte |
| 183466 | 183805 | ** of the token. See the comment on the CC_ defines |
| 183467 | 183806 | ** above. */ |
| 183468 | 183807 | case CC_SPACE: { |
| 183469 | 183808 | testcase( z[0]==' ' ); |
| | @@ -183787,11 +184126,11 @@ |
| 183787 | 184126 | ** Run the parser on the given SQL string. |
| 183788 | 184127 | */ |
| 183789 | 184128 | SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){ |
| 183790 | 184129 | int nErr = 0; /* Number of errors encountered */ |
| 183791 | 184130 | void *pEngine; /* The LEMON-generated LALR(1) parser */ |
| 183792 | | - int n = 0; /* Length of the next token token */ |
| 184131 | + i64 n = 0; /* Length of the next token token */ |
| 183793 | 184132 | int tokenType; /* type of the next token */ |
| 183794 | 184133 | int lastTokenParsed = -1; /* type of the previous token */ |
| 183795 | 184134 | sqlite3 *db = pParse->db; /* The database connection */ |
| 183796 | 184135 | int mxSqlLen; /* Max length of an SQL string */ |
| 183797 | 184136 | Parse *pParentParse = 0; /* Outer parse context, if any */ |
| | @@ -183890,17 +184229,17 @@ |
| 183890 | 184229 | zSql += n; |
| 183891 | 184230 | continue; |
| 183892 | 184231 | }else if( tokenType!=TK_QNUMBER ){ |
| 183893 | 184232 | Token x; |
| 183894 | 184233 | x.z = zSql; |
| 183895 | | - x.n = n; |
| 184234 | + x.n = (u32)n; |
| 183896 | 184235 | sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x); |
| 183897 | 184236 | break; |
| 183898 | 184237 | } |
| 183899 | 184238 | } |
| 183900 | 184239 | pParse->sLastToken.z = zSql; |
| 183901 | | - pParse->sLastToken.n = n; |
| 184240 | + pParse->sLastToken.n = (u32)n; |
| 183902 | 184241 | sqlite3Parser(pEngine, tokenType, pParse->sLastToken); |
| 183903 | 184242 | lastTokenParsed = tokenType; |
| 183904 | 184243 | zSql += n; |
| 183905 | 184244 | assert( db->mallocFailed==0 || pParse->rc!=SQLITE_OK || startedWithOom ); |
| 183906 | 184245 | if( pParse->rc!=SQLITE_OK ) break; |
| | @@ -183972,11 +184311,11 @@ |
| 183972 | 184311 | Vdbe *pVdbe, /* VM being reprepared */ |
| 183973 | 184312 | const char *zSql /* The original SQL string */ |
| 183974 | 184313 | ){ |
| 183975 | 184314 | sqlite3 *db; /* The database connection */ |
| 183976 | 184315 | int i; /* Next unread byte of zSql[] */ |
| 183977 | | - int n; /* length of current token */ |
| 184316 | + i64 n; /* length of current token */ |
| 183978 | 184317 | int tokenType; /* type of current token */ |
| 183979 | 184318 | int prevType = 0; /* Previous non-whitespace token */ |
| 183980 | 184319 | int nParen; /* Number of nested levels of parentheses */ |
| 183981 | 184320 | int iStartIN; /* Start of RHS of IN operator in z[] */ |
| 183982 | 184321 | int nParenAtIN; /* Value of nParent at start of RHS of IN operator */ |
| | @@ -215365,11 +215704,11 @@ |
| 215365 | 215704 | /* #include "sqlite3ext.h" */ |
| 215366 | 215705 | SQLITE_EXTENSION_INIT1 |
| 215367 | 215706 | #else |
| 215368 | 215707 | /* #include "sqlite3.h" */ |
| 215369 | 215708 | #endif |
| 215370 | | -SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */ |
| 215709 | +SQLITE_PRIVATE sqlite3_int64 sqlite3GetToken(const unsigned char*,int*); /* In SQLite core */ |
| 215371 | 215710 | |
| 215372 | 215711 | /* #include <stddef.h> */ |
| 215373 | 215712 | |
| 215374 | 215713 | /* |
| 215375 | 215714 | ** If building separately, we will need some setup that is normally |
| | @@ -229904,11 +230243,12 @@ |
| 229904 | 230243 | if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){ |
| 229905 | 230244 | unsigned char *aPage = sqlite3PagerGetData(pDbPage); |
| 229906 | 230245 | memcpy(aPage, pData, szPage); |
| 229907 | 230246 | pTab->pgnoTrunc = 0; |
| 229908 | 230247 | } |
| 229909 | | - }else{ |
| 230248 | + } |
| 230249 | + if( rc!=SQLITE_OK ){ |
| 229910 | 230250 | pTab->pgnoTrunc = 0; |
| 229911 | 230251 | } |
| 229912 | 230252 | sqlite3PagerUnref(pDbPage); |
| 229913 | 230253 | return rc; |
| 229914 | 230254 | |
| | @@ -259926,11 +260266,11 @@ |
| 259926 | 260266 | int nArg, /* Number of args */ |
| 259927 | 260267 | sqlite3_value **apUnused /* Function arguments */ |
| 259928 | 260268 | ){ |
| 259929 | 260269 | assert( nArg==0 ); |
| 259930 | 260270 | UNUSED_PARAM2(nArg, apUnused); |
| 259931 | | - sqlite3_result_text(pCtx, "fts5: 2025-10-15 10:52:45 5cbccab499bc3983aac1f57355552db607dee6c7ef4eb00d794dbee89c18db70", -1, SQLITE_TRANSIENT); |
| 260271 | + sqlite3_result_text(pCtx, "fts5: 2025-10-28 13:24:50 724f2299f206cc9e7f830f984c50a8fc4ac1c17210d71d9affe657b45252b060", -1, SQLITE_TRANSIENT); |
| 259932 | 260272 | } |
| 259933 | 260273 | |
| 259934 | 260274 | /* |
| 259935 | 260275 | ** Implementation of fts5_locale(LOCALE, TEXT) function. |
| 259936 | 260276 | ** |
| 259937 | 260277 | |