| | @@ -1,8 +1,8 @@ |
| 1 | 1 | /****************************************************************************** |
| 2 | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | | -** version 3.8.8. By combining all the individual C code files into this |
| 3 | +** version 3.8.9. By combining all the individual C code files into this |
| 4 | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| | @@ -88,10 +88,48 @@ |
| 88 | 88 | #endif /* _MSVC_H_ */ |
| 89 | 89 | |
| 90 | 90 | /************** End of msvc.h ************************************************/ |
| 91 | 91 | /************** Continuing where we left off in sqliteInt.h ******************/ |
| 92 | 92 | |
| 93 | +/* |
| 94 | +** Special setup for VxWorks |
| 95 | +*/ |
| 96 | +/************** Include vxworks.h in the middle of sqliteInt.h ***************/ |
| 97 | +/************** Begin file vxworks.h *****************************************/ |
| 98 | +/* |
| 99 | +** 2015-03-02 |
| 100 | +** |
| 101 | +** The author disclaims copyright to this source code. In place of |
| 102 | +** a legal notice, here is a blessing: |
| 103 | +** |
| 104 | +** May you do good and not evil. |
| 105 | +** May you find forgiveness for yourself and forgive others. |
| 106 | +** May you share freely, never taking more than you give. |
| 107 | +** |
| 108 | +****************************************************************************** |
| 109 | +** |
| 110 | +** This file contains code that is specific to Wind River's VxWorks |
| 111 | +*/ |
| 112 | +#if defined(__RTP__) || defined(_WRS_KERNEL) |
| 113 | +/* This is VxWorks. Set up things specially for that OS |
| 114 | +*/ |
| 115 | +#include <vxWorks.h> |
| 116 | +#include <pthread.h> /* amalgamator: dontcache */ |
| 117 | +#define OS_VXWORKS 1 |
| 118 | +#define SQLITE_OS_OTHER 0 |
| 119 | +#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1 |
| 120 | +#define SQLITE_OMIT_LOAD_EXTENSION 1 |
| 121 | +#define SQLITE_ENABLE_LOCKING_STYLE 0 |
| 122 | +#define HAVE_UTIME 1 |
| 123 | +#else |
| 124 | +/* This is not VxWorks. */ |
| 125 | +#define OS_VXWORKS 0 |
| 126 | +#endif /* defined(_WRS_KERNEL) */ |
| 127 | + |
| 128 | +/************** End of vxworks.h *********************************************/ |
| 129 | +/************** Continuing where we left off in sqliteInt.h ******************/ |
| 130 | + |
| 93 | 131 | /* |
| 94 | 132 | ** These #defines should enable >2GB file support on POSIX if the |
| 95 | 133 | ** underlying operating system supports it. If the OS lacks |
| 96 | 134 | ** large file support, or if the OS is windows, these should be no-ops. |
| 97 | 135 | ** |
| | @@ -276,13 +314,13 @@ |
| 276 | 314 | ** |
| 277 | 315 | ** See also: [sqlite3_libversion()], |
| 278 | 316 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 279 | 317 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 280 | 318 | */ |
| 281 | | -#define SQLITE_VERSION "3.8.8" |
| 282 | | -#define SQLITE_VERSION_NUMBER 3008008 |
| 283 | | -#define SQLITE_SOURCE_ID "2015-02-25 14:25:31 6d132e7a224ee68b5cefe9222944aac5760ffc20" |
| 319 | +#define SQLITE_VERSION "3.8.9" |
| 320 | +#define SQLITE_VERSION_NUMBER 3008009 |
| 321 | +#define SQLITE_SOURCE_ID "2015-03-09 10:40:48 e5da5e7d5dc5a3438ced23f1ee83e695abc29c45" |
| 284 | 322 | |
| 285 | 323 | /* |
| 286 | 324 | ** CAPI3REF: Run-Time Library Version Numbers |
| 287 | 325 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 288 | 326 | ** |
| | @@ -925,18 +963,20 @@ |
| 925 | 963 | ** |
| 926 | 964 | ** These integer constants are opcodes for the xFileControl method |
| 927 | 965 | ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] |
| 928 | 966 | ** interface. |
| 929 | 967 | ** |
| 968 | +** <ul> |
| 969 | +** <li>[[SQLITE_FCNTL_LOCKSTATE]] |
| 930 | 970 | ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This |
| 931 | 971 | ** opcode causes the xFileControl method to write the current state of |
| 932 | 972 | ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], |
| 933 | 973 | ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) |
| 934 | 974 | ** into an integer that the pArg argument points to. This capability |
| 935 | | -** is used during testing and only needs to be supported when SQLITE_TEST |
| 936 | | -** is defined. |
| 937 | | -** <ul> |
| 975 | +** is used during testing and is only available when the SQLITE_TEST |
| 976 | +** compile-time option is used. |
| 977 | +** |
| 938 | 978 | ** <li>[[SQLITE_FCNTL_SIZE_HINT]] |
| 939 | 979 | ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS |
| 940 | 980 | ** layer a hint of how large the database file will grow to be during the |
| 941 | 981 | ** current transaction. This hint is not guaranteed to be accurate but it |
| 942 | 982 | ** is often close. The underlying VFS might choose to preallocate database |
| | @@ -1057,11 +1097,13 @@ |
| 1057 | 1097 | ** the error message if the pragma fails. ^If the |
| 1058 | 1098 | ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal |
| 1059 | 1099 | ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA] |
| 1060 | 1100 | ** file control returns [SQLITE_OK], then the parser assumes that the |
| 1061 | 1101 | ** VFS has handled the PRAGMA itself and the parser generates a no-op |
| 1062 | | -** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns |
| 1102 | +** prepared statement if result string is NULL, or that returns a copy |
| 1103 | +** of the result string if the string is non-NULL. |
| 1104 | +** ^If the [SQLITE_FCNTL_PRAGMA] file control returns |
| 1063 | 1105 | ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means |
| 1064 | 1106 | ** that the VFS encountered an error while handling the [PRAGMA] and the |
| 1065 | 1107 | ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] |
| 1066 | 1108 | ** file control occurs at the beginning of pragma statement analysis and so |
| 1067 | 1109 | ** it is able to override built-in [PRAGMA] statements. |
| | @@ -1916,11 +1958,10 @@ |
| 1916 | 1958 | ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE |
| 1917 | 1959 | ** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is |
| 1918 | 1960 | ** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro |
| 1919 | 1961 | ** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value |
| 1920 | 1962 | ** that specifies the maximum size of the created heap. |
| 1921 | | -** </dl> |
| 1922 | 1963 | ** |
| 1923 | 1964 | ** [[SQLITE_CONFIG_PCACHE_HDRSZ]] |
| 1924 | 1965 | ** <dt>SQLITE_CONFIG_PCACHE_HDRSZ |
| 1925 | 1966 | ** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which |
| 1926 | 1967 | ** is a pointer to an integer and writes into that integer the number of extra |
| | @@ -3356,20 +3397,18 @@ |
| 3356 | 3397 | ** The second argument, "zSql", is the statement to be compiled, encoded |
| 3357 | 3398 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 3358 | 3399 | ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 3359 | 3400 | ** use UTF-16. |
| 3360 | 3401 | ** |
| 3361 | | -** ^If the nByte argument is less than zero, then zSql is read up to the |
| 3362 | | -** first zero terminator. ^If nByte is non-negative, then it is the maximum |
| 3363 | | -** number of bytes read from zSql. ^When nByte is non-negative, the |
| 3364 | | -** zSql string ends at either the first '\000' or '\u0000' character or |
| 3365 | | -** the nByte-th byte, whichever comes first. If the caller knows |
| 3366 | | -** that the supplied string is nul-terminated, then there is a small |
| 3367 | | -** performance advantage to be gained by passing an nByte parameter that |
| 3368 | | -** is equal to the number of bytes in the input string <i>including</i> |
| 3369 | | -** the nul-terminator bytes as this saves SQLite from having to |
| 3370 | | -** make a copy of the input string. |
| 3402 | +** ^If the nByte argument is negative, then zSql is read up to the |
| 3403 | +** first zero terminator. ^If nByte is positive, then it is the |
| 3404 | +** number of bytes read from zSql. ^If nByte is zero, then no prepared |
| 3405 | +** statement is generated. |
| 3406 | +** If the caller knows that the supplied string is nul-terminated, then |
| 3407 | +** there is a small performance advantage to passing an nByte parameter that |
| 3408 | +** is the number of bytes in the input string <i>including</i> |
| 3409 | +** the nul-terminator. |
| 3371 | 3410 | ** |
| 3372 | 3411 | ** ^If pzTail is not NULL then *pzTail is made to point to the first byte |
| 3373 | 3412 | ** past the end of the first SQL statement in zSql. These routines only |
| 3374 | 3413 | ** compile the first statement in zSql, so *pzTail is left pointing to |
| 3375 | 3414 | ** what remains uncompiled. |
| | @@ -4394,12 +4433,12 @@ |
| 4394 | 4433 | ** DEPRECATED |
| 4395 | 4434 | ** |
| 4396 | 4435 | ** These functions are [deprecated]. In order to maintain |
| 4397 | 4436 | ** backwards compatibility with older code, these functions continue |
| 4398 | 4437 | ** to be supported. However, new applications should avoid |
| 4399 | | -** the use of these functions. To help encourage people to avoid |
| 4400 | | -** using these functions, we are not going to tell you what they do. |
| 4438 | +** the use of these functions. To encourage programmers to avoid |
| 4439 | +** these functions, we will not explain what they do. |
| 4401 | 4440 | */ |
| 4402 | 4441 | #ifndef SQLITE_OMIT_DEPRECATED |
| 4403 | 4442 | SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); |
| 4404 | 4443 | SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); |
| 4405 | 4444 | SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); |
| | @@ -7157,24 +7196,24 @@ |
| 7157 | 7196 | ** |
| 7158 | 7197 | ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() |
| 7159 | 7198 | ** is not a permanent error and does not affect the return value of |
| 7160 | 7199 | ** sqlite3_backup_finish(). |
| 7161 | 7200 | ** |
| 7162 | | -** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]] |
| 7201 | +** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]] |
| 7163 | 7202 | ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b> |
| 7164 | 7203 | ** |
| 7165 | | -** ^Each call to sqlite3_backup_step() sets two values inside |
| 7166 | | -** the [sqlite3_backup] object: the number of pages still to be backed |
| 7167 | | -** up and the total number of pages in the source database file. |
| 7168 | | -** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces |
| 7169 | | -** retrieve these two values, respectively. |
| 7170 | | -** |
| 7171 | | -** ^The values returned by these functions are only updated by |
| 7172 | | -** sqlite3_backup_step(). ^If the source database is modified during a backup |
| 7173 | | -** operation, then the values are not updated to account for any extra |
| 7174 | | -** pages that need to be updated or the size of the source database file |
| 7175 | | -** changing. |
| 7204 | +** ^The sqlite3_backup_remaining() routine returns the number of pages still |
| 7205 | +** to be backed up at the conclusion of the most recent sqlite3_backup_step(). |
| 7206 | +** ^The sqlite3_backup_pagecount() routine returns the total number of pages |
| 7207 | +** in the source database at the conclusion of the most recent |
| 7208 | +** sqlite3_backup_step(). |
| 7209 | +** ^(The values returned by these functions are only updated by |
| 7210 | +** sqlite3_backup_step(). If the source database is modified in a way that |
| 7211 | +** changes the size of the source database or the number of pages remaining, |
| 7212 | +** those changes are not reflected in the output of sqlite3_backup_pagecount() |
| 7213 | +** and sqlite3_backup_remaining() until after the next |
| 7214 | +** sqlite3_backup_step().)^ |
| 7176 | 7215 | ** |
| 7177 | 7216 | ** <b>Concurrent Usage of Database Handles</b> |
| 7178 | 7217 | ** |
| 7179 | 7218 | ** ^The source [database connection] may be used by the application for other |
| 7180 | 7219 | ** purposes while a backup operation is underway or being initialized. |
| | @@ -8018,19 +8057,21 @@ |
| 8018 | 8057 | #ifndef SQLITE_MAX_FUNCTION_ARG |
| 8019 | 8058 | # define SQLITE_MAX_FUNCTION_ARG 127 |
| 8020 | 8059 | #endif |
| 8021 | 8060 | |
| 8022 | 8061 | /* |
| 8023 | | -** The maximum number of in-memory pages to use for the main database |
| 8024 | | -** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE |
| 8062 | +** The suggested maximum number of in-memory pages to use for |
| 8063 | +** the main database table and for temporary tables. |
| 8064 | +** |
| 8065 | +** IMPLEMENTATION-OF: R-31093-59126 The default suggested cache size |
| 8066 | +** is 2000 pages. |
| 8067 | +** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be |
| 8068 | +** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options. |
| 8025 | 8069 | */ |
| 8026 | 8070 | #ifndef SQLITE_DEFAULT_CACHE_SIZE |
| 8027 | 8071 | # define SQLITE_DEFAULT_CACHE_SIZE 2000 |
| 8028 | 8072 | #endif |
| 8029 | | -#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE |
| 8030 | | -# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500 |
| 8031 | | -#endif |
| 8032 | 8073 | |
| 8033 | 8074 | /* |
| 8034 | 8075 | ** The default number of frames to accumulate in the log file before |
| 8035 | 8076 | ** checkpointing the database in WAL mode. |
| 8036 | 8077 | */ |
| | @@ -9733,27 +9774,29 @@ |
| 9733 | 9774 | #define OP_FkCounter 134 /* synopsis: fkctr[P1]+=P2 */ |
| 9734 | 9775 | #define OP_FkIfZero 135 /* synopsis: if fkctr[P1]==0 goto P2 */ |
| 9735 | 9776 | #define OP_MemMax 136 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 9736 | 9777 | #define OP_IfPos 137 /* synopsis: if r[P1]>0 goto P2 */ |
| 9737 | 9778 | #define OP_IfNeg 138 /* synopsis: r[P1]+=P3, if r[P1]<0 goto P2 */ |
| 9738 | | -#define OP_IfZero 139 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2 */ |
| 9739 | | -#define OP_AggFinal 140 /* synopsis: accum=r[P1] N=P2 */ |
| 9740 | | -#define OP_IncrVacuum 141 |
| 9741 | | -#define OP_Expire 142 |
| 9742 | | -#define OP_TableLock 143 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 9743 | | -#define OP_VBegin 144 |
| 9744 | | -#define OP_VCreate 145 |
| 9745 | | -#define OP_VDestroy 146 |
| 9746 | | -#define OP_VOpen 147 |
| 9747 | | -#define OP_VColumn 148 /* synopsis: r[P3]=vcolumn(P2) */ |
| 9748 | | -#define OP_VNext 149 |
| 9749 | | -#define OP_VRename 150 |
| 9750 | | -#define OP_Pagecount 151 |
| 9751 | | -#define OP_MaxPgcnt 152 |
| 9752 | | -#define OP_Init 153 /* synopsis: Start at P2 */ |
| 9753 | | -#define OP_Noop 154 |
| 9754 | | -#define OP_Explain 155 |
| 9779 | +#define OP_IfNotZero 139 /* synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2 */ |
| 9780 | +#define OP_DecrJumpZero 140 /* synopsis: if (--r[P1])==0 goto P2 */ |
| 9781 | +#define OP_JumpZeroIncr 141 /* synopsis: if (r[P1]++)==0 ) goto P2 */ |
| 9782 | +#define OP_AggFinal 142 /* synopsis: accum=r[P1] N=P2 */ |
| 9783 | +#define OP_IncrVacuum 143 |
| 9784 | +#define OP_Expire 144 |
| 9785 | +#define OP_TableLock 145 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 9786 | +#define OP_VBegin 146 |
| 9787 | +#define OP_VCreate 147 |
| 9788 | +#define OP_VDestroy 148 |
| 9789 | +#define OP_VOpen 149 |
| 9790 | +#define OP_VColumn 150 /* synopsis: r[P3]=vcolumn(P2) */ |
| 9791 | +#define OP_VNext 151 |
| 9792 | +#define OP_VRename 152 |
| 9793 | +#define OP_Pagecount 153 |
| 9794 | +#define OP_MaxPgcnt 154 |
| 9795 | +#define OP_Init 155 /* synopsis: Start at P2 */ |
| 9796 | +#define OP_Noop 156 |
| 9797 | +#define OP_Explain 157 |
| 9755 | 9798 | |
| 9756 | 9799 | |
| 9757 | 9800 | /* Properties such as "out2" or "jump" that are specified in |
| 9758 | 9801 | ** comments following the "case" for each opcode in the vdbe.c |
| 9759 | 9802 | ** are encoded into bitvectors as follows: |
| | @@ -9781,13 +9824,13 @@ |
| 9781 | 9824 | /* 96 */ 0x24, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,\ |
| 9782 | 9825 | /* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08, 0x00,\ |
| 9783 | 9826 | /* 112 */ 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00,\ |
| 9784 | 9827 | /* 120 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 9785 | 9828 | /* 128 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x02, 0x00, 0x01,\ |
| 9786 | | -/* 136 */ 0x08, 0x05, 0x05, 0x05, 0x00, 0x01, 0x00, 0x00,\ |
| 9787 | | -/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,\ |
| 9788 | | -/* 152 */ 0x02, 0x01, 0x00, 0x00,} |
| 9829 | +/* 136 */ 0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x01,\ |
| 9830 | +/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\ |
| 9831 | +/* 152 */ 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,} |
| 9789 | 9832 | |
| 9790 | 9833 | /************** End of opcodes.h *********************************************/ |
| 9791 | 9834 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 9792 | 9835 | |
| 9793 | 9836 | /* |
| | @@ -12022,11 +12065,11 @@ |
| 12022 | 12065 | #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ |
| 12023 | 12066 | #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ |
| 12024 | 12067 | #define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */ |
| 12025 | 12068 | #define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */ |
| 12026 | 12069 | #define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */ |
| 12027 | | - /* 0x0080 // not currently used */ |
| 12070 | +#define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */ |
| 12028 | 12071 | #define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */ |
| 12029 | 12072 | #define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */ |
| 12030 | 12073 | #define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */ |
| 12031 | 12074 | #define WHERE_SORTBYGROUP 0x0800 /* Support sqlite3WhereIsSorted() */ |
| 12032 | 12075 | #define WHERE_REOPEN_IDX 0x1000 /* Try to use OP_ReopenIdx */ |
| | @@ -24969,27 +25012,29 @@ |
| 24969 | 25012 | /* 134 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 24970 | 25013 | /* 135 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 24971 | 25014 | /* 136 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 24972 | 25015 | /* 137 */ "IfPos" OpHelp("if r[P1]>0 goto P2"), |
| 24973 | 25016 | /* 138 */ "IfNeg" OpHelp("r[P1]+=P3, if r[P1]<0 goto P2"), |
| 24974 | | - /* 139 */ "IfZero" OpHelp("r[P1]+=P3, if r[P1]==0 goto P2"), |
| 24975 | | - /* 140 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 24976 | | - /* 141 */ "IncrVacuum" OpHelp(""), |
| 24977 | | - /* 142 */ "Expire" OpHelp(""), |
| 24978 | | - /* 143 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 24979 | | - /* 144 */ "VBegin" OpHelp(""), |
| 24980 | | - /* 145 */ "VCreate" OpHelp(""), |
| 24981 | | - /* 146 */ "VDestroy" OpHelp(""), |
| 24982 | | - /* 147 */ "VOpen" OpHelp(""), |
| 24983 | | - /* 148 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 24984 | | - /* 149 */ "VNext" OpHelp(""), |
| 24985 | | - /* 150 */ "VRename" OpHelp(""), |
| 24986 | | - /* 151 */ "Pagecount" OpHelp(""), |
| 24987 | | - /* 152 */ "MaxPgcnt" OpHelp(""), |
| 24988 | | - /* 153 */ "Init" OpHelp("Start at P2"), |
| 24989 | | - /* 154 */ "Noop" OpHelp(""), |
| 24990 | | - /* 155 */ "Explain" OpHelp(""), |
| 25017 | + /* 139 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]+=P3, goto P2"), |
| 25018 | + /* 140 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 25019 | + /* 141 */ "JumpZeroIncr" OpHelp("if (r[P1]++)==0 ) goto P2"), |
| 25020 | + /* 142 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 25021 | + /* 143 */ "IncrVacuum" OpHelp(""), |
| 25022 | + /* 144 */ "Expire" OpHelp(""), |
| 25023 | + /* 145 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 25024 | + /* 146 */ "VBegin" OpHelp(""), |
| 25025 | + /* 147 */ "VCreate" OpHelp(""), |
| 25026 | + /* 148 */ "VDestroy" OpHelp(""), |
| 25027 | + /* 149 */ "VOpen" OpHelp(""), |
| 25028 | + /* 150 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 25029 | + /* 151 */ "VNext" OpHelp(""), |
| 25030 | + /* 152 */ "VRename" OpHelp(""), |
| 25031 | + /* 153 */ "Pagecount" OpHelp(""), |
| 25032 | + /* 154 */ "MaxPgcnt" OpHelp(""), |
| 25033 | + /* 155 */ "Init" OpHelp("Start at P2"), |
| 25034 | + /* 156 */ "Noop" OpHelp(""), |
| 25035 | + /* 157 */ "Explain" OpHelp(""), |
| 24991 | 25036 | }; |
| 24992 | 25037 | return azName[i]; |
| 24993 | 25038 | } |
| 24994 | 25039 | #endif |
| 24995 | 25040 | |
| | @@ -25065,22 +25110,10 @@ |
| 25065 | 25110 | # else |
| 25066 | 25111 | # define SQLITE_ENABLE_LOCKING_STYLE 0 |
| 25067 | 25112 | # endif |
| 25068 | 25113 | #endif |
| 25069 | 25114 | |
| 25070 | | -/* |
| 25071 | | -** Define the OS_VXWORKS pre-processor macro to 1 if building on |
| 25072 | | -** vxworks, or 0 otherwise. |
| 25073 | | -*/ |
| 25074 | | -#ifndef OS_VXWORKS |
| 25075 | | -# if defined(__RTP__) || defined(_WRS_KERNEL) |
| 25076 | | -# define OS_VXWORKS 1 |
| 25077 | | -# else |
| 25078 | | -# define OS_VXWORKS 0 |
| 25079 | | -# endif |
| 25080 | | -#endif |
| 25081 | | - |
| 25082 | 25115 | /* |
| 25083 | 25116 | ** standard include files. |
| 25084 | 25117 | */ |
| 25085 | 25118 | #include <sys/types.h> |
| 25086 | 25119 | #include <sys/stat.h> |
| | @@ -25091,22 +25124,23 @@ |
| 25091 | 25124 | #include <errno.h> |
| 25092 | 25125 | #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 |
| 25093 | 25126 | # include <sys/mman.h> |
| 25094 | 25127 | #endif |
| 25095 | 25128 | |
| 25096 | | -#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS |
| 25129 | +#if SQLITE_ENABLE_LOCKING_STYLE |
| 25097 | 25130 | # include <sys/ioctl.h> |
| 25098 | | -# if OS_VXWORKS |
| 25099 | | -# include <semaphore.h> |
| 25100 | | -# include <limits.h> |
| 25101 | | -# else |
| 25102 | | -# include <sys/file.h> |
| 25103 | | -# include <sys/param.h> |
| 25104 | | -# endif |
| 25131 | +# include <sys/file.h> |
| 25132 | +# include <sys/param.h> |
| 25105 | 25133 | #endif /* SQLITE_ENABLE_LOCKING_STYLE */ |
| 25106 | 25134 | |
| 25107 | | -#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) |
| 25135 | +#if OS_VXWORKS |
| 25136 | +/* # include <sys/ioctl.h> */ |
| 25137 | +# include <semaphore.h> |
| 25138 | +# include <limits.h> |
| 25139 | +#endif /* OS_VXWORKS */ |
| 25140 | + |
| 25141 | +#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE |
| 25108 | 25142 | # include <sys/mount.h> |
| 25109 | 25143 | #endif |
| 25110 | 25144 | |
| 25111 | 25145 | #ifdef HAVE_UTIME |
| 25112 | 25146 | # include <utime.h> |
| | @@ -25142,10 +25176,14 @@ |
| 25142 | 25176 | |
| 25143 | 25177 | /* |
| 25144 | 25178 | ** Maximum supported path-length. |
| 25145 | 25179 | */ |
| 25146 | 25180 | #define MAX_PATHNAME 512 |
| 25181 | + |
| 25182 | +/* Always cast the getpid() return type for compatibility with |
| 25183 | +** kernel modules in VxWorks. */ |
| 25184 | +#define osGetpid(X) (pid_t)getpid() |
| 25147 | 25185 | |
| 25148 | 25186 | /* |
| 25149 | 25187 | ** Only set the lastErrno if the error code is a real error and not |
| 25150 | 25188 | ** a normal expected return code of SQLITE_BUSY or SQLITE_OK |
| 25151 | 25189 | */ |
| | @@ -25231,11 +25269,11 @@ |
| 25231 | 25269 | |
| 25232 | 25270 | /* This variable holds the process id (pid) from when the xRandomness() |
| 25233 | 25271 | ** method was called. If xOpen() is called from a different process id, |
| 25234 | 25272 | ** indicating that a fork() has occurred, the PRNG will be reset. |
| 25235 | 25273 | */ |
| 25236 | | -static int randomnessPid = 0; |
| 25274 | +static pid_t randomnessPid = 0; |
| 25237 | 25275 | |
| 25238 | 25276 | /* |
| 25239 | 25277 | ** Allowed values for the unixFile.ctrlFlags bitmask: |
| 25240 | 25278 | */ |
| 25241 | 25279 | #define UNIXFILE_EXCL 0x01 /* Connections from one process only */ |
| | @@ -25587,11 +25625,11 @@ |
| 25587 | 25625 | #define osFcntl ((int(*)(int,int,...))aSyscall[7].pCurrent) |
| 25588 | 25626 | |
| 25589 | 25627 | { "read", (sqlite3_syscall_ptr)read, 0 }, |
| 25590 | 25628 | #define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent) |
| 25591 | 25629 | |
| 25592 | | -#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) |
| 25630 | +#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE |
| 25593 | 25631 | { "pread", (sqlite3_syscall_ptr)pread, 0 }, |
| 25594 | 25632 | #else |
| 25595 | 25633 | { "pread", (sqlite3_syscall_ptr)0, 0 }, |
| 25596 | 25634 | #endif |
| 25597 | 25635 | #define osPread ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[9].pCurrent) |
| | @@ -25604,11 +25642,11 @@ |
| 25604 | 25642 | #define osPread64 ((ssize_t(*)(int,void*,size_t,off_t))aSyscall[10].pCurrent) |
| 25605 | 25643 | |
| 25606 | 25644 | { "write", (sqlite3_syscall_ptr)write, 0 }, |
| 25607 | 25645 | #define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent) |
| 25608 | 25646 | |
| 25609 | | -#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS) |
| 25647 | +#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE |
| 25610 | 25648 | { "pwrite", (sqlite3_syscall_ptr)pwrite, 0 }, |
| 25611 | 25649 | #else |
| 25612 | 25650 | { "pwrite", (sqlite3_syscall_ptr)0, 0 }, |
| 25613 | 25651 | #endif |
| 25614 | 25652 | #define osPwrite ((ssize_t(*)(int,const void*,size_t,off_t))\ |
| | @@ -26743,11 +26781,12 @@ |
| 26743 | 26781 | int tErrno = 0; |
| 26744 | 26782 | |
| 26745 | 26783 | assert( pFile ); |
| 26746 | 26784 | OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h, |
| 26747 | 26785 | azFileLock(eFileLock), azFileLock(pFile->eFileLock), |
| 26748 | | - azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared , getpid())); |
| 26786 | + azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared, |
| 26787 | + osGetpid())); |
| 26749 | 26788 | |
| 26750 | 26789 | /* If there is already a lock of this type or more restrictive on the |
| 26751 | 26790 | ** unixFile, do nothing. Don't use the end_lock: exit path, as |
| 26752 | 26791 | ** unixEnterMutex() hasn't been called yet. |
| 26753 | 26792 | */ |
| | @@ -26951,11 +26990,11 @@ |
| 26951 | 26990 | int rc = SQLITE_OK; |
| 26952 | 26991 | |
| 26953 | 26992 | assert( pFile ); |
| 26954 | 26993 | OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock, |
| 26955 | 26994 | pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared, |
| 26956 | | - getpid())); |
| 26995 | + osGetpid())); |
| 26957 | 26996 | |
| 26958 | 26997 | assert( eFileLock<=SHARED_LOCK ); |
| 26959 | 26998 | if( pFile->eFileLock<=eFileLock ){ |
| 26960 | 26999 | return SQLITE_OK; |
| 26961 | 27000 | } |
| | @@ -27378,11 +27417,11 @@ |
| 27378 | 27417 | char *zLockFile = (char *)pFile->lockingContext; |
| 27379 | 27418 | int rc; |
| 27380 | 27419 | |
| 27381 | 27420 | assert( pFile ); |
| 27382 | 27421 | OSTRACE(("UNLOCK %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock, |
| 27383 | | - pFile->eFileLock, getpid())); |
| 27422 | + pFile->eFileLock, osGetpid())); |
| 27384 | 27423 | assert( eFileLock<=SHARED_LOCK ); |
| 27385 | 27424 | |
| 27386 | 27425 | /* no-op if possible */ |
| 27387 | 27426 | if( pFile->eFileLock==eFileLock ){ |
| 27388 | 27427 | return SQLITE_OK; |
| | @@ -27441,14 +27480,13 @@ |
| 27441 | 27480 | ** a single exclusive lock. In other words, SHARED, RESERVED, and |
| 27442 | 27481 | ** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite |
| 27443 | 27482 | ** still works when you do this, but concurrency is reduced since |
| 27444 | 27483 | ** only a single process can be reading the database at a time. |
| 27445 | 27484 | ** |
| 27446 | | -** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off or if |
| 27447 | | -** compiling for VXWORKS. |
| 27485 | +** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off |
| 27448 | 27486 | */ |
| 27449 | | -#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS |
| 27487 | +#if SQLITE_ENABLE_LOCKING_STYLE |
| 27450 | 27488 | |
| 27451 | 27489 | /* |
| 27452 | 27490 | ** Retry flock() calls that fail with EINTR |
| 27453 | 27491 | */ |
| 27454 | 27492 | #ifdef EINTR |
| | @@ -27597,11 +27635,11 @@ |
| 27597 | 27635 | static int flockUnlock(sqlite3_file *id, int eFileLock) { |
| 27598 | 27636 | unixFile *pFile = (unixFile*)id; |
| 27599 | 27637 | |
| 27600 | 27638 | assert( pFile ); |
| 27601 | 27639 | OSTRACE(("UNLOCK %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock, |
| 27602 | | - pFile->eFileLock, getpid())); |
| 27640 | + pFile->eFileLock, osGetpid())); |
| 27603 | 27641 | assert( eFileLock<=SHARED_LOCK ); |
| 27604 | 27642 | |
| 27605 | 27643 | /* no-op if possible */ |
| 27606 | 27644 | if( pFile->eFileLock==eFileLock ){ |
| 27607 | 27645 | return SQLITE_OK; |
| | @@ -27658,11 +27696,11 @@ |
| 27658 | 27696 | ** This routine checks if there is a RESERVED lock held on the specified |
| 27659 | 27697 | ** file by this or any other process. If such a lock is held, set *pResOut |
| 27660 | 27698 | ** to a non-zero value otherwise *pResOut is set to zero. The return value |
| 27661 | 27699 | ** is set to SQLITE_OK unless an I/O error occurs during lock checking. |
| 27662 | 27700 | */ |
| 27663 | | -static int semCheckReservedLock(sqlite3_file *id, int *pResOut) { |
| 27701 | +static int semXCheckReservedLock(sqlite3_file *id, int *pResOut) { |
| 27664 | 27702 | int rc = SQLITE_OK; |
| 27665 | 27703 | int reserved = 0; |
| 27666 | 27704 | unixFile *pFile = (unixFile*)id; |
| 27667 | 27705 | |
| 27668 | 27706 | SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; ); |
| | @@ -27725,11 +27763,11 @@ |
| 27725 | 27763 | ** access the file. |
| 27726 | 27764 | ** |
| 27727 | 27765 | ** This routine will only increase a lock. Use the sqlite3OsUnlock() |
| 27728 | 27766 | ** routine to lower a locking level. |
| 27729 | 27767 | */ |
| 27730 | | -static int semLock(sqlite3_file *id, int eFileLock) { |
| 27768 | +static int semXLock(sqlite3_file *id, int eFileLock) { |
| 27731 | 27769 | unixFile *pFile = (unixFile*)id; |
| 27732 | 27770 | sem_t *pSem = pFile->pInode->pSem; |
| 27733 | 27771 | int rc = SQLITE_OK; |
| 27734 | 27772 | |
| 27735 | 27773 | /* if we already have a lock, it is exclusive. |
| | @@ -27758,18 +27796,18 @@ |
| 27758 | 27796 | ** must be either NO_LOCK or SHARED_LOCK. |
| 27759 | 27797 | ** |
| 27760 | 27798 | ** If the locking level of the file descriptor is already at or below |
| 27761 | 27799 | ** the requested locking level, this routine is a no-op. |
| 27762 | 27800 | */ |
| 27763 | | -static int semUnlock(sqlite3_file *id, int eFileLock) { |
| 27801 | +static int semXUnlock(sqlite3_file *id, int eFileLock) { |
| 27764 | 27802 | unixFile *pFile = (unixFile*)id; |
| 27765 | 27803 | sem_t *pSem = pFile->pInode->pSem; |
| 27766 | 27804 | |
| 27767 | 27805 | assert( pFile ); |
| 27768 | 27806 | assert( pSem ); |
| 27769 | 27807 | OSTRACE(("UNLOCK %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock, |
| 27770 | | - pFile->eFileLock, getpid())); |
| 27808 | + pFile->eFileLock, osGetpid())); |
| 27771 | 27809 | assert( eFileLock<=SHARED_LOCK ); |
| 27772 | 27810 | |
| 27773 | 27811 | /* no-op if possible */ |
| 27774 | 27812 | if( pFile->eFileLock==eFileLock ){ |
| 27775 | 27813 | return SQLITE_OK; |
| | @@ -27795,14 +27833,14 @@ |
| 27795 | 27833 | } |
| 27796 | 27834 | |
| 27797 | 27835 | /* |
| 27798 | 27836 | ** Close a file. |
| 27799 | 27837 | */ |
| 27800 | | -static int semClose(sqlite3_file *id) { |
| 27838 | +static int semXClose(sqlite3_file *id) { |
| 27801 | 27839 | if( id ){ |
| 27802 | 27840 | unixFile *pFile = (unixFile*)id; |
| 27803 | | - semUnlock(id, NO_LOCK); |
| 27841 | + semXUnlock(id, NO_LOCK); |
| 27804 | 27842 | assert( pFile ); |
| 27805 | 27843 | unixEnterMutex(); |
| 27806 | 27844 | releaseInodeInfo(pFile); |
| 27807 | 27845 | unixLeaveMutex(); |
| 27808 | 27846 | closeUnixFile(id); |
| | @@ -27979,11 +28017,11 @@ |
| 27979 | 28017 | afpLockingContext *context = (afpLockingContext *) pFile->lockingContext; |
| 27980 | 28018 | |
| 27981 | 28019 | assert( pFile ); |
| 27982 | 28020 | OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h, |
| 27983 | 28021 | azFileLock(eFileLock), azFileLock(pFile->eFileLock), |
| 27984 | | - azFileLock(pInode->eFileLock), pInode->nShared , getpid())); |
| 28022 | + azFileLock(pInode->eFileLock), pInode->nShared , osGetpid())); |
| 27985 | 28023 | |
| 27986 | 28024 | /* If there is already a lock of this type or more restrictive on the |
| 27987 | 28025 | ** unixFile, do nothing. Don't use the afp_end_lock: exit path, as |
| 27988 | 28026 | ** unixEnterMutex() hasn't been called yet. |
| 27989 | 28027 | */ |
| | @@ -28165,11 +28203,11 @@ |
| 28165 | 28203 | #endif |
| 28166 | 28204 | |
| 28167 | 28205 | assert( pFile ); |
| 28168 | 28206 | OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock, |
| 28169 | 28207 | pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared, |
| 28170 | | - getpid())); |
| 28208 | + osGetpid())); |
| 28171 | 28209 | |
| 28172 | 28210 | assert( eFileLock<=SHARED_LOCK ); |
| 28173 | 28211 | if( pFile->eFileLock<=eFileLock ){ |
| 28174 | 28212 | return SQLITE_OK; |
| 28175 | 28213 | } |
| | @@ -29204,11 +29242,13 @@ |
| 29204 | 29242 | ** |
| 29205 | 29243 | ** This function should not be called directly by other code in this file. |
| 29206 | 29244 | ** Instead, it should be called via macro osGetpagesize(). |
| 29207 | 29245 | */ |
| 29208 | 29246 | static int unixGetpagesize(void){ |
| 29209 | | -#if defined(_BSD_SOURCE) |
| 29247 | +#if OS_VXWORKS |
| 29248 | + return 1024; |
| 29249 | +#elif defined(_BSD_SOURCE) |
| 29210 | 29250 | return getpagesize(); |
| 29211 | 29251 | #else |
| 29212 | 29252 | return (int)sysconf(_SC_PAGESIZE); |
| 29213 | 29253 | #endif |
| 29214 | 29254 | } |
| | @@ -29833,11 +29873,11 @@ |
| 29833 | 29873 | } |
| 29834 | 29874 | } |
| 29835 | 29875 | } |
| 29836 | 29876 | sqlite3_mutex_leave(pShmNode->mutex); |
| 29837 | 29877 | OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n", |
| 29838 | | - p->id, getpid(), p->sharedMask, p->exclMask)); |
| 29878 | + p->id, osGetpid(), p->sharedMask, p->exclMask)); |
| 29839 | 29879 | return rc; |
| 29840 | 29880 | } |
| 29841 | 29881 | |
| 29842 | 29882 | /* |
| 29843 | 29883 | ** Implement a memory barrier or memory fence on shared memory. |
| | @@ -30236,11 +30276,11 @@ |
| 30236 | 30276 | dotlockUnlock, /* xUnlock method */ |
| 30237 | 30277 | dotlockCheckReservedLock, /* xCheckReservedLock method */ |
| 30238 | 30278 | 0 /* xShmMap method */ |
| 30239 | 30279 | ) |
| 30240 | 30280 | |
| 30241 | | -#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS |
| 30281 | +#if SQLITE_ENABLE_LOCKING_STYLE |
| 30242 | 30282 | IOMETHODS( |
| 30243 | 30283 | flockIoFinder, /* Finder function name */ |
| 30244 | 30284 | flockIoMethods, /* sqlite3_io_methods object name */ |
| 30245 | 30285 | 1, /* shared memory is disabled */ |
| 30246 | 30286 | flockClose, /* xClose method */ |
| | @@ -30254,14 +30294,14 @@ |
| 30254 | 30294 | #if OS_VXWORKS |
| 30255 | 30295 | IOMETHODS( |
| 30256 | 30296 | semIoFinder, /* Finder function name */ |
| 30257 | 30297 | semIoMethods, /* sqlite3_io_methods object name */ |
| 30258 | 30298 | 1, /* shared memory is disabled */ |
| 30259 | | - semClose, /* xClose method */ |
| 30260 | | - semLock, /* xLock method */ |
| 30261 | | - semUnlock, /* xUnlock method */ |
| 30262 | | - semCheckReservedLock, /* xCheckReservedLock method */ |
| 30299 | + semXClose, /* xClose method */ |
| 30300 | + semXLock, /* xLock method */ |
| 30301 | + semXUnlock, /* xUnlock method */ |
| 30302 | + semXCheckReservedLock, /* xCheckReservedLock method */ |
| 30263 | 30303 | 0 /* xShmMap method */ |
| 30264 | 30304 | ) |
| 30265 | 30305 | #endif |
| 30266 | 30306 | |
| 30267 | 30307 | #if defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE |
| | @@ -30381,19 +30421,17 @@ |
| 30381 | 30421 | static const sqlite3_io_methods |
| 30382 | 30422 | *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl; |
| 30383 | 30423 | |
| 30384 | 30424 | #endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */ |
| 30385 | 30425 | |
| 30386 | | -#if OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE |
| 30387 | | -/* |
| 30388 | | -** This "finder" function attempts to determine the best locking strategy |
| 30389 | | -** for the database file "filePath". It then returns the sqlite3_io_methods |
| 30390 | | -** object that implements that strategy. |
| 30391 | | -** |
| 30392 | | -** This is for VXWorks only. |
| 30426 | +#if OS_VXWORKS |
| 30427 | +/* |
| 30428 | +** This "finder" function for VxWorks checks to see if posix advisory |
| 30429 | +** locking works. If it does, then that is what is used. If it does not |
| 30430 | +** work, then fallback to named semaphore locking. |
| 30393 | 30431 | */ |
| 30394 | | -static const sqlite3_io_methods *autolockIoFinderImpl( |
| 30432 | +static const sqlite3_io_methods *vxworksIoFinderImpl( |
| 30395 | 30433 | const char *filePath, /* name of the database file */ |
| 30396 | 30434 | unixFile *pNew /* the open file object */ |
| 30397 | 30435 | ){ |
| 30398 | 30436 | struct flock lockInfo; |
| 30399 | 30437 | |
| | @@ -30415,13 +30453,13 @@ |
| 30415 | 30453 | }else{ |
| 30416 | 30454 | return &semIoMethods; |
| 30417 | 30455 | } |
| 30418 | 30456 | } |
| 30419 | 30457 | static const sqlite3_io_methods |
| 30420 | | - *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl; |
| 30458 | + *(*const vxworksIoFinder)(const char*,unixFile*) = vxworksIoFinderImpl; |
| 30421 | 30459 | |
| 30422 | | -#endif /* OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE */ |
| 30460 | +#endif /* OS_VXWORKS */ |
| 30423 | 30461 | |
| 30424 | 30462 | /* |
| 30425 | 30463 | ** An abstract type for a pointer to an IO method finder function: |
| 30426 | 30464 | */ |
| 30427 | 30465 | typedef const sqlite3_io_methods *(*finder_type)(const char*,unixFile*); |
| | @@ -30930,12 +30968,12 @@ |
| 30930 | 30968 | /* Detect a pid change and reset the PRNG. There is a race condition |
| 30931 | 30969 | ** here such that two or more threads all trying to open databases at |
| 30932 | 30970 | ** the same instant might all reset the PRNG. But multiple resets |
| 30933 | 30971 | ** are harmless. |
| 30934 | 30972 | */ |
| 30935 | | - if( randomnessPid!=getpid() ){ |
| 30936 | | - randomnessPid = getpid(); |
| 30973 | + if( randomnessPid!=osGetpid() ){ |
| 30974 | + randomnessPid = osGetpid(); |
| 30937 | 30975 | sqlite3_randomness(0,0); |
| 30938 | 30976 | } |
| 30939 | 30977 | |
| 30940 | 30978 | memset(p, 0, sizeof(unixFile)); |
| 30941 | 30979 | |
| | @@ -31322,11 +31360,11 @@ |
| 31322 | 31360 | ** When testing, initializing zBuf[] to zero is all we do. That means |
| 31323 | 31361 | ** that we always use the same random number sequence. This makes the |
| 31324 | 31362 | ** tests repeatable. |
| 31325 | 31363 | */ |
| 31326 | 31364 | memset(zBuf, 0, nBuf); |
| 31327 | | - randomnessPid = getpid(); |
| 31365 | + randomnessPid = osGetpid(); |
| 31328 | 31366 | #if !defined(SQLITE_TEST) |
| 31329 | 31367 | { |
| 31330 | 31368 | int fd, got; |
| 31331 | 31369 | fd = robust_open("/dev/urandom", O_RDONLY, 0); |
| 31332 | 31370 | if( fd<0 ){ |
| | @@ -31643,11 +31681,11 @@ |
| 31643 | 31681 | #else |
| 31644 | 31682 | # ifdef _CS_DARWIN_USER_TEMP_DIR |
| 31645 | 31683 | { |
| 31646 | 31684 | if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){ |
| 31647 | 31685 | OSTRACE(("GETLOCKPATH failed %s errno=%d pid=%d\n", |
| 31648 | | - lPath, errno, getpid())); |
| 31686 | + lPath, errno, osGetpid())); |
| 31649 | 31687 | return SQLITE_IOERR_LOCK; |
| 31650 | 31688 | } |
| 31651 | 31689 | len = strlcat(lPath, "sqliteplocks", maxLen); |
| 31652 | 31690 | } |
| 31653 | 31691 | # else |
| | @@ -31665,11 +31703,11 @@ |
| 31665 | 31703 | char c = dbPath[i]; |
| 31666 | 31704 | lPath[i+len] = (c=='/')?'_':c; |
| 31667 | 31705 | } |
| 31668 | 31706 | lPath[i+len]='\0'; |
| 31669 | 31707 | strlcat(lPath, ":auto:", maxLen); |
| 31670 | | - OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, getpid())); |
| 31708 | + OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid())); |
| 31671 | 31709 | return SQLITE_OK; |
| 31672 | 31710 | } |
| 31673 | 31711 | |
| 31674 | 31712 | /* |
| 31675 | 31713 | ** Creates the lock file and any missing directories in lockPath |
| | @@ -31692,20 +31730,20 @@ |
| 31692 | 31730 | if( osMkdir(buf, SQLITE_DEFAULT_PROXYDIR_PERMISSIONS) ){ |
| 31693 | 31731 | int err=errno; |
| 31694 | 31732 | if( err!=EEXIST ) { |
| 31695 | 31733 | OSTRACE(("CREATELOCKPATH FAILED creating %s, " |
| 31696 | 31734 | "'%s' proxy lock path=%s pid=%d\n", |
| 31697 | | - buf, strerror(err), lockPath, getpid())); |
| 31735 | + buf, strerror(err), lockPath, osGetpid())); |
| 31698 | 31736 | return err; |
| 31699 | 31737 | } |
| 31700 | 31738 | } |
| 31701 | 31739 | } |
| 31702 | 31740 | start=i+1; |
| 31703 | 31741 | } |
| 31704 | 31742 | buf[i] = lockPath[i]; |
| 31705 | 31743 | } |
| 31706 | | - OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, getpid())); |
| 31744 | + OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid())); |
| 31707 | 31745 | return 0; |
| 31708 | 31746 | } |
| 31709 | 31747 | |
| 31710 | 31748 | /* |
| 31711 | 31749 | ** Create a new VFS file descriptor (stored in memory obtained from |
| | @@ -32006,11 +32044,12 @@ |
| 32006 | 32044 | int readLen = 0; |
| 32007 | 32045 | int tryOldLockPath = 0; |
| 32008 | 32046 | int forceNewLockPath = 0; |
| 32009 | 32047 | |
| 32010 | 32048 | OSTRACE(("TAKECONCH %d for %s pid=%d\n", conchFile->h, |
| 32011 | | - (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), getpid())); |
| 32049 | + (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), |
| 32050 | + osGetpid())); |
| 32012 | 32051 | |
| 32013 | 32052 | rc = proxyGetHostID(myHostID, &pError); |
| 32014 | 32053 | if( (rc&0xff)==SQLITE_IOERR ){ |
| 32015 | 32054 | storeLastErrno(pFile, pError); |
| 32016 | 32055 | goto end_takeconch; |
| | @@ -32216,11 +32255,11 @@ |
| 32216 | 32255 | |
| 32217 | 32256 | pCtx = (proxyLockingContext *)pFile->lockingContext; |
| 32218 | 32257 | conchFile = pCtx->conchFile; |
| 32219 | 32258 | OSTRACE(("RELEASECONCH %d for %s pid=%d\n", conchFile->h, |
| 32220 | 32259 | (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), |
| 32221 | | - getpid())); |
| 32260 | + osGetpid())); |
| 32222 | 32261 | if( pCtx->conchHeld>0 ){ |
| 32223 | 32262 | rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK); |
| 32224 | 32263 | } |
| 32225 | 32264 | pCtx->conchHeld = 0; |
| 32226 | 32265 | OSTRACE(("RELEASECONCH %d %s\n", conchFile->h, |
| | @@ -32358,11 +32397,11 @@ |
| 32358 | 32397 | }else{ |
| 32359 | 32398 | lockPath=(char *)path; |
| 32360 | 32399 | } |
| 32361 | 32400 | |
| 32362 | 32401 | OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h, |
| 32363 | | - (lockPath ? lockPath : ":auto:"), getpid())); |
| 32402 | + (lockPath ? lockPath : ":auto:"), osGetpid())); |
| 32364 | 32403 | |
| 32365 | 32404 | pCtx = sqlite3_malloc( sizeof(*pCtx) ); |
| 32366 | 32405 | if( pCtx==0 ){ |
| 32367 | 32406 | return SQLITE_NOMEM; |
| 32368 | 32407 | } |
| | @@ -32699,26 +32738,28 @@ |
| 32699 | 32738 | ** Note that the sqlite3_vfs.pNext field of the VFS object is modified |
| 32700 | 32739 | ** by the SQLite core when the VFS is registered. So the following |
| 32701 | 32740 | ** array cannot be const. |
| 32702 | 32741 | */ |
| 32703 | 32742 | static sqlite3_vfs aVfs[] = { |
| 32704 | | -#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__)) |
| 32743 | +#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) |
| 32705 | 32744 | UNIXVFS("unix", autolockIoFinder ), |
| 32745 | +#elif OS_VXWORKS |
| 32746 | + UNIXVFS("unix", vxworksIoFinder ), |
| 32706 | 32747 | #else |
| 32707 | 32748 | UNIXVFS("unix", posixIoFinder ), |
| 32708 | 32749 | #endif |
| 32709 | 32750 | UNIXVFS("unix-none", nolockIoFinder ), |
| 32710 | 32751 | UNIXVFS("unix-dotfile", dotlockIoFinder ), |
| 32711 | 32752 | UNIXVFS("unix-excl", posixIoFinder ), |
| 32712 | 32753 | #if OS_VXWORKS |
| 32713 | 32754 | UNIXVFS("unix-namedsem", semIoFinder ), |
| 32714 | 32755 | #endif |
| 32715 | | -#if SQLITE_ENABLE_LOCKING_STYLE |
| 32756 | +#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS |
| 32716 | 32757 | UNIXVFS("unix-posix", posixIoFinder ), |
| 32717 | | -#if !OS_VXWORKS |
| 32758 | +#endif |
| 32759 | +#if SQLITE_ENABLE_LOCKING_STYLE |
| 32718 | 32760 | UNIXVFS("unix-flock", flockIoFinder ), |
| 32719 | | -#endif |
| 32720 | 32761 | #endif |
| 32721 | 32762 | #if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) |
| 32722 | 32763 | UNIXVFS("unix-afp", afpIoFinder ), |
| 32723 | 32764 | UNIXVFS("unix-nfs", nfsIoFinder ), |
| 32724 | 32765 | UNIXVFS("unix-proxy", proxyIoFinder ), |
| | @@ -39072,16 +39113,24 @@ |
| 39072 | 39113 | sqlite3GlobalConfig.pcache2.xUnpin(p->pCache->pCache, p->pPage, 0); |
| 39073 | 39114 | } |
| 39074 | 39115 | } |
| 39075 | 39116 | |
| 39076 | 39117 | /* |
| 39077 | | -** Compute the number of pages of cache requested. |
| 39118 | +** Compute the number of pages of cache requested. p->szCache is the |
| 39119 | +** cache size requested by the "PRAGMA cache_size" statement. |
| 39120 | +** |
| 39121 | +** |
| 39078 | 39122 | */ |
| 39079 | 39123 | static int numberOfCachePages(PCache *p){ |
| 39080 | 39124 | if( p->szCache>=0 ){ |
| 39125 | + /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the |
| 39126 | + ** suggested cache size is set to N. */ |
| 39081 | 39127 | return p->szCache; |
| 39082 | 39128 | }else{ |
| 39129 | + /* IMPLEMENTATION-OF: R-61436-13639 If the argument N is negative, then |
| 39130 | + ** the number of cache pages is adjusted to use approximately abs(N*1024) |
| 39131 | + ** bytes of memory. */ |
| 39083 | 39132 | return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra)); |
| 39084 | 39133 | } |
| 39085 | 39134 | } |
| 39086 | 39135 | |
| 39087 | 39136 | /*************************************************** General Interfaces ****** |
| | @@ -68615,10 +68664,14 @@ |
| 68615 | 68664 | } |
| 68616 | 68665 | SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){ |
| 68617 | 68666 | return sqlite3ValueText(pVal, SQLITE_UTF16LE); |
| 68618 | 68667 | } |
| 68619 | 68668 | #endif /* SQLITE_OMIT_UTF16 */ |
| 68669 | +/* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five |
| 68670 | +** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating |
| 68671 | +** point number string BLOB NULL |
| 68672 | +*/ |
| 68620 | 68673 | SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){ |
| 68621 | 68674 | static const u8 aType[] = { |
| 68622 | 68675 | SQLITE_BLOB, /* 0x00 */ |
| 68623 | 68676 | SQLITE_NULL, /* 0x01 */ |
| 68624 | 68677 | SQLITE_TEXT, /* 0x02 */ |
| | @@ -71290,11 +71343,11 @@ |
| 71290 | 71343 | |
| 71291 | 71344 | /* Opcode: String8 * P2 * P4 * |
| 71292 | 71345 | ** Synopsis: r[P2]='P4' |
| 71293 | 71346 | ** |
| 71294 | 71347 | ** P4 points to a nul terminated UTF-8 string. This opcode is transformed |
| 71295 | | -** into a String before it is executed for the first time. During |
| 71348 | +** into a String opcode before it is executed for the first time. During |
| 71296 | 71349 | ** this transformation, the length of string P4 is computed and stored |
| 71297 | 71350 | ** as the P1 parameter. |
| 71298 | 71351 | */ |
| 71299 | 71352 | case OP_String8: { /* same as TK_STRING, out2-prerelease */ |
| 71300 | 71353 | assert( pOp->p4.z!=0 ); |
| | @@ -71322,22 +71375,34 @@ |
| 71322 | 71375 | goto too_big; |
| 71323 | 71376 | } |
| 71324 | 71377 | /* Fall through to the next case, OP_String */ |
| 71325 | 71378 | } |
| 71326 | 71379 | |
| 71327 | | -/* Opcode: String P1 P2 * P4 * |
| 71380 | +/* Opcode: String P1 P2 P3 P4 P5 |
| 71328 | 71381 | ** Synopsis: r[P2]='P4' (len=P1) |
| 71329 | 71382 | ** |
| 71330 | 71383 | ** The string value P4 of length P1 (bytes) is stored in register P2. |
| 71384 | +** |
| 71385 | +** If P5!=0 and the content of register P3 is greater than zero, then |
| 71386 | +** the datatype of the register P2 is converted to BLOB. The content is |
| 71387 | +** the same sequence of bytes, it is merely interpreted as a BLOB instead |
| 71388 | +** of a string, as if it had been CAST. |
| 71331 | 71389 | */ |
| 71332 | 71390 | case OP_String: { /* out2-prerelease */ |
| 71333 | 71391 | assert( pOp->p4.z!=0 ); |
| 71334 | 71392 | pOut->flags = MEM_Str|MEM_Static|MEM_Term; |
| 71335 | 71393 | pOut->z = pOp->p4.z; |
| 71336 | 71394 | pOut->n = pOp->p1; |
| 71337 | 71395 | pOut->enc = encoding; |
| 71338 | 71396 | UPDATE_MAX_BLOBSIZE(pOut); |
| 71397 | + if( pOp->p5 ){ |
| 71398 | + assert( pOp->p3>0 ); |
| 71399 | + assert( pOp->p3<=(p->nMem-p->nCursor) ); |
| 71400 | + pIn3 = &aMem[pOp->p3]; |
| 71401 | + assert( pIn3->flags & MEM_Int ); |
| 71402 | + if( pIn3->u.i ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term; |
| 71403 | + } |
| 71339 | 71404 | break; |
| 71340 | 71405 | } |
| 71341 | 71406 | |
| 71342 | 71407 | /* Opcode: Null P1 P2 P3 * * |
| 71343 | 71408 | ** Synopsis: r[P2..P3]=NULL |
| | @@ -73325,11 +73390,16 @@ |
| 73325 | 73390 | ** the value of this counter needs to be restored too. */ |
| 73326 | 73391 | p->nStmtDefCons = db->nDeferredCons; |
| 73327 | 73392 | p->nStmtDefImmCons = db->nDeferredImmCons; |
| 73328 | 73393 | } |
| 73329 | 73394 | |
| 73330 | | - /* Gather the schema version number for checking */ |
| 73395 | + /* Gather the schema version number for checking: |
| 73396 | + ** IMPLEMENTATION-OF: R-32195-19465 The schema version is used by SQLite |
| 73397 | + ** each time a query is executed to ensure that the internal cache of the |
| 73398 | + ** schema used when compiling the SQL query matches the schema of the |
| 73399 | + ** database against which the compiled query is actually executed. |
| 73400 | + */ |
| 73331 | 73401 | sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta); |
| 73332 | 73402 | iGen = db->aDb[pOp->p1].pSchema->iGeneration; |
| 73333 | 73403 | }else{ |
| 73334 | 73404 | iGen = iMeta = 0; |
| 73335 | 73405 | } |
| | @@ -75843,14 +75913,16 @@ |
| 75843 | 75913 | #endif /* SQLITE_OMIT_AUTOINCREMENT */ |
| 75844 | 75914 | |
| 75845 | 75915 | /* Opcode: IfPos P1 P2 * * * |
| 75846 | 75916 | ** Synopsis: if r[P1]>0 goto P2 |
| 75847 | 75917 | ** |
| 75848 | | -** If the value of register P1 is 1 or greater, jump to P2. |
| 75918 | +** Register P1 must contain an integer. |
| 75919 | +** If the value of register P1 is 1 or greater, jump to P2 and |
| 75920 | +** add the literal value P3 to register P1. |
| 75849 | 75921 | ** |
| 75850 | | -** It is illegal to use this instruction on a register that does |
| 75851 | | -** not contain an integer. An assertion fault will result if you try. |
| 75922 | +** If the initial value of register P1 is less than 1, then the |
| 75923 | +** value is unchanged and control passes through to the next instruction. |
| 75852 | 75924 | */ |
| 75853 | 75925 | case OP_IfPos: { /* jump, in1 */ |
| 75854 | 75926 | pIn1 = &aMem[pOp->p1]; |
| 75855 | 75927 | assert( pIn1->flags&MEM_Int ); |
| 75856 | 75928 | VdbeBranchTaken( pIn1->u.i>0, 2); |
| | @@ -75875,27 +75947,63 @@ |
| 75875 | 75947 | pc = pOp->p2 - 1; |
| 75876 | 75948 | } |
| 75877 | 75949 | break; |
| 75878 | 75950 | } |
| 75879 | 75951 | |
| 75880 | | -/* Opcode: IfZero P1 P2 P3 * * |
| 75881 | | -** Synopsis: r[P1]+=P3, if r[P1]==0 goto P2 |
| 75952 | +/* Opcode: IfNotZero P1 P2 P3 * * |
| 75953 | +** Synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2 |
| 75882 | 75954 | ** |
| 75883 | | -** The register P1 must contain an integer. Add literal P3 to the |
| 75884 | | -** value in register P1. If the result is exactly 0, jump to P2. |
| 75955 | +** Register P1 must contain an integer. If the content of register P1 is |
| 75956 | +** initially nonzero, then add P3 to P1 and jump to P2. If register P1 is |
| 75957 | +** initially zero, leave it unchanged and fall through. |
| 75885 | 75958 | */ |
| 75886 | | -case OP_IfZero: { /* jump, in1 */ |
| 75959 | +case OP_IfNotZero: { /* jump, in1 */ |
| 75960 | + pIn1 = &aMem[pOp->p1]; |
| 75961 | + assert( pIn1->flags&MEM_Int ); |
| 75962 | + VdbeBranchTaken(pIn1->u.i<0, 2); |
| 75963 | + if( pIn1->u.i ){ |
| 75964 | + pIn1->u.i += pOp->p3; |
| 75965 | + pc = pOp->p2 - 1; |
| 75966 | + } |
| 75967 | + break; |
| 75968 | +} |
| 75969 | + |
| 75970 | +/* Opcode: DecrJumpZero P1 P2 * * * |
| 75971 | +** Synopsis: if (--r[P1])==0 goto P2 |
| 75972 | +** |
| 75973 | +** Register P1 must hold an integer. Decrement the value in register P1 |
| 75974 | +** then jump to P2 if the new value is exactly zero. |
| 75975 | +*/ |
| 75976 | +case OP_DecrJumpZero: { /* jump, in1 */ |
| 75887 | 75977 | pIn1 = &aMem[pOp->p1]; |
| 75888 | 75978 | assert( pIn1->flags&MEM_Int ); |
| 75889 | | - pIn1->u.i += pOp->p3; |
| 75979 | + pIn1->u.i--; |
| 75890 | 75980 | VdbeBranchTaken(pIn1->u.i==0, 2); |
| 75891 | 75981 | if( pIn1->u.i==0 ){ |
| 75892 | 75982 | pc = pOp->p2 - 1; |
| 75893 | 75983 | } |
| 75894 | 75984 | break; |
| 75895 | 75985 | } |
| 75896 | 75986 | |
| 75987 | + |
| 75988 | +/* Opcode: JumpZeroIncr P1 P2 * * * |
| 75989 | +** Synopsis: if (r[P1]++)==0 ) goto P2 |
| 75990 | +** |
| 75991 | +** The register P1 must contain an integer. If register P1 is initially |
| 75992 | +** zero, then jump to P2. Increment register P1 regardless of whether or |
| 75993 | +** not the jump is taken. |
| 75994 | +*/ |
| 75995 | +case OP_JumpZeroIncr: { /* jump, in1 */ |
| 75996 | + pIn1 = &aMem[pOp->p1]; |
| 75997 | + assert( pIn1->flags&MEM_Int ); |
| 75998 | + VdbeBranchTaken(pIn1->u.i==0, 2); |
| 75999 | + if( (pIn1->u.i++)==0 ){ |
| 76000 | + pc = pOp->p2 - 1; |
| 76001 | + } |
| 76002 | + break; |
| 76003 | +} |
| 76004 | + |
| 75897 | 76005 | /* Opcode: AggStep * P2 P3 P4 P5 |
| 75898 | 76006 | ** Synopsis: accum=r[P3] step(r[P2@P5]) |
| 75899 | 76007 | ** |
| 75900 | 76008 | ** Execute the step function for an aggregate. The |
| 75901 | 76009 | ** function has P5 arguments. P4 is a pointer to the FuncDef |
| | @@ -97181,10 +97289,15 @@ |
| 97181 | 97289 | ** pExpr points to an expression which implements a function. If |
| 97182 | 97290 | ** it is appropriate to apply the LIKE optimization to that function |
| 97183 | 97291 | ** then set aWc[0] through aWc[2] to the wildcard characters and |
| 97184 | 97292 | ** return TRUE. If the function is not a LIKE-style function then |
| 97185 | 97293 | ** return FALSE. |
| 97294 | +** |
| 97295 | +** *pIsNocase is set to true if uppercase and lowercase are equivalent for |
| 97296 | +** the function (default for LIKE). If the function makes the distinction |
| 97297 | +** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to |
| 97298 | +** false. |
| 97186 | 97299 | */ |
| 97187 | 97300 | SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){ |
| 97188 | 97301 | FuncDef *pDef; |
| 97189 | 97302 | if( pExpr->op!=TK_FUNCTION |
| 97190 | 97303 | || !pExpr->x.pList |
| | @@ -102972,10 +103085,21 @@ |
| 102972 | 103085 | } |
| 102973 | 103086 | |
| 102974 | 103087 | /* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS |
| 102975 | 103088 | ** connection. If it returns SQLITE_OK, then assume that the VFS |
| 102976 | 103089 | ** handled the pragma and generate a no-op prepared statement. |
| 103090 | + ** |
| 103091 | + ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed, |
| 103092 | + ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file |
| 103093 | + ** object corresponding to the database file to which the pragma |
| 103094 | + ** statement refers. |
| 103095 | + ** |
| 103096 | + ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA |
| 103097 | + ** file control is an array of pointers to strings (char**) in which the |
| 103098 | + ** second element of the array is the name of the pragma and the third |
| 103099 | + ** element is the argument to the pragma or NULL if the pragma has no |
| 103100 | + ** argument. |
| 102977 | 103101 | */ |
| 102978 | 103102 | aFcntl[0] = 0; |
| 102979 | 103103 | aFcntl[1] = zLeft; |
| 102980 | 103104 | aFcntl[2] = zRight; |
| 102981 | 103105 | aFcntl[3] = 0; |
| | @@ -103732,34 +103856,46 @@ |
| 103732 | 103856 | Index *pIdx; |
| 103733 | 103857 | Table *pTab; |
| 103734 | 103858 | pIdx = sqlite3FindIndex(db, zRight, zDb); |
| 103735 | 103859 | if( pIdx ){ |
| 103736 | 103860 | int i; |
| 103737 | | - int mx = pPragma->iArg ? pIdx->nColumn : pIdx->nKeyCol; |
| 103861 | + int mx; |
| 103862 | + if( pPragma->iArg ){ |
| 103863 | + /* PRAGMA index_xinfo (newer version with more rows and columns) */ |
| 103864 | + mx = pIdx->nColumn; |
| 103865 | + pParse->nMem = 6; |
| 103866 | + }else{ |
| 103867 | + /* PRAGMA index_info (legacy version) */ |
| 103868 | + mx = pIdx->nKeyCol; |
| 103869 | + pParse->nMem = 3; |
| 103870 | + } |
| 103738 | 103871 | pTab = pIdx->pTable; |
| 103739 | | - sqlite3VdbeSetNumCols(v, 6); |
| 103740 | | - pParse->nMem = 6; |
| 103872 | + sqlite3VdbeSetNumCols(v, pParse->nMem); |
| 103741 | 103873 | sqlite3CodeVerifySchema(pParse, iDb); |
| 103742 | 103874 | sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC); |
| 103743 | 103875 | sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC); |
| 103744 | 103876 | sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC); |
| 103745 | | - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "desc", SQLITE_STATIC); |
| 103746 | | - sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "coll", SQLITE_STATIC); |
| 103747 | | - sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "key", SQLITE_STATIC); |
| 103877 | + if( pPragma->iArg ){ |
| 103878 | + sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "desc", SQLITE_STATIC); |
| 103879 | + sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "coll", SQLITE_STATIC); |
| 103880 | + sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "key", SQLITE_STATIC); |
| 103881 | + } |
| 103748 | 103882 | for(i=0; i<mx; i++){ |
| 103749 | 103883 | i16 cnum = pIdx->aiColumn[i]; |
| 103750 | 103884 | sqlite3VdbeAddOp2(v, OP_Integer, i, 1); |
| 103751 | 103885 | sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2); |
| 103752 | 103886 | if( cnum<0 ){ |
| 103753 | 103887 | sqlite3VdbeAddOp2(v, OP_Null, 0, 3); |
| 103754 | 103888 | }else{ |
| 103755 | 103889 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0); |
| 103756 | 103890 | } |
| 103757 | | - sqlite3VdbeAddOp2(v, OP_Integer, pIdx->aSortOrder[i], 4); |
| 103758 | | - sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pIdx->azColl[i], 0); |
| 103759 | | - sqlite3VdbeAddOp2(v, OP_Integer, i<pIdx->nKeyCol, 6); |
| 103760 | | - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6); |
| 103891 | + if( pPragma->iArg ){ |
| 103892 | + sqlite3VdbeAddOp2(v, OP_Integer, pIdx->aSortOrder[i], 4); |
| 103893 | + sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pIdx->azColl[i], 0); |
| 103894 | + sqlite3VdbeAddOp2(v, OP_Integer, i<pIdx->nKeyCol, 6); |
| 103895 | + } |
| 103896 | + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem); |
| 103761 | 103897 | } |
| 103762 | 103898 | } |
| 103763 | 103899 | } |
| 103764 | 103900 | break; |
| 103765 | 103901 | |
| | @@ -104457,12 +104593,13 @@ |
| 104457 | 104593 | #endif |
| 104458 | 104594 | |
| 104459 | 104595 | /* |
| 104460 | 104596 | ** PRAGMA shrink_memory |
| 104461 | 104597 | ** |
| 104462 | | - ** This pragma attempts to free as much memory as possible from the |
| 104463 | | - ** current database connection. |
| 104598 | + ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database |
| 104599 | + ** connection on which it is invoked to free up as much memory as it |
| 104600 | + ** can, by calling sqlite3_db_release_memory(). |
| 104464 | 104601 | */ |
| 104465 | 104602 | case PragTyp_SHRINK_MEMORY: { |
| 104466 | 104603 | sqlite3_db_release_memory(db); |
| 104467 | 104604 | break; |
| 104468 | 104605 | } |
| | @@ -104487,12 +104624,16 @@ |
| 104487 | 104624 | |
| 104488 | 104625 | /* |
| 104489 | 104626 | ** PRAGMA soft_heap_limit |
| 104490 | 104627 | ** PRAGMA soft_heap_limit = N |
| 104491 | 104628 | ** |
| 104492 | | - ** Call sqlite3_soft_heap_limit64(N). Return the result. If N is omitted, |
| 104493 | | - ** use -1. |
| 104629 | + ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the |
| 104630 | + ** sqlite3_soft_heap_limit64() interface with the argument N, if N is |
| 104631 | + ** specified and is a non-negative integer. |
| 104632 | + ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always |
| 104633 | + ** returns the same integer that would be returned by the |
| 104634 | + ** sqlite3_soft_heap_limit64(-1) C-language function. |
| 104494 | 104635 | */ |
| 104495 | 104636 | case PragTyp_SOFT_HEAP_LIMIT: { |
| 104496 | 104637 | sqlite3_int64 N; |
| 104497 | 104638 | if( zRight && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK ){ |
| 104498 | 104639 | sqlite3_soft_heap_limit64(N); |
| | @@ -106065,24 +106206,21 @@ |
| 106065 | 106206 | }else{ |
| 106066 | 106207 | op = OP_IdxInsert; |
| 106067 | 106208 | } |
| 106068 | 106209 | sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord); |
| 106069 | 106210 | if( pSelect->iLimit ){ |
| 106070 | | - int addr1, addr2; |
| 106211 | + int addr; |
| 106071 | 106212 | int iLimit; |
| 106072 | 106213 | if( pSelect->iOffset ){ |
| 106073 | 106214 | iLimit = pSelect->iOffset+1; |
| 106074 | 106215 | }else{ |
| 106075 | 106216 | iLimit = pSelect->iLimit; |
| 106076 | 106217 | } |
| 106077 | | - addr1 = sqlite3VdbeAddOp1(v, OP_IfZero, iLimit); VdbeCoverage(v); |
| 106078 | | - sqlite3VdbeAddOp2(v, OP_AddImm, iLimit, -1); |
| 106079 | | - addr2 = sqlite3VdbeAddOp0(v, OP_Goto); |
| 106080 | | - sqlite3VdbeJumpHere(v, addr1); |
| 106218 | + addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, -1); VdbeCoverage(v); |
| 106081 | 106219 | sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor); |
| 106082 | 106220 | sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor); |
| 106083 | | - sqlite3VdbeJumpHere(v, addr2); |
| 106221 | + sqlite3VdbeJumpHere(v, addr); |
| 106084 | 106222 | } |
| 106085 | 106223 | } |
| 106086 | 106224 | |
| 106087 | 106225 | /* |
| 106088 | 106226 | ** Add code to implement the OFFSET |
| | @@ -106475,11 +106613,11 @@ |
| 106475 | 106613 | /* Jump to the end of the loop if the LIMIT is reached. Except, if |
| 106476 | 106614 | ** there is a sorter, in which case the sorter has already limited |
| 106477 | 106615 | ** the output for us. |
| 106478 | 106616 | */ |
| 106479 | 106617 | if( pSort==0 && p->iLimit ){ |
| 106480 | | - sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); VdbeCoverage(v); |
| 106618 | + sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v); |
| 106481 | 106619 | } |
| 106482 | 106620 | } |
| 106483 | 106621 | |
| 106484 | 106622 | /* |
| 106485 | 106623 | ** Allocate a KeyInfo object sufficient for an index of N key columns and |
| | @@ -107328,11 +107466,11 @@ |
| 107328 | 107466 | } |
| 107329 | 107467 | }else{ |
| 107330 | 107468 | sqlite3ExprCode(pParse, p->pLimit, iLimit); |
| 107331 | 107469 | sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v); |
| 107332 | 107470 | VdbeComment((v, "LIMIT counter")); |
| 107333 | | - sqlite3VdbeAddOp2(v, OP_IfZero, iLimit, iBreak); VdbeCoverage(v); |
| 107471 | + sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, iBreak); VdbeCoverage(v); |
| 107334 | 107472 | } |
| 107335 | 107473 | if( p->pOffset ){ |
| 107336 | 107474 | p->iOffset = iOffset = ++pParse->nMem; |
| 107337 | 107475 | pParse->nMem++; /* Allocate an extra register for limit+offset */ |
| 107338 | 107476 | sqlite3ExprCode(pParse, p->pOffset, iOffset); |
| | @@ -107547,11 +107685,11 @@ |
| 107547 | 107685 | addrCont = sqlite3VdbeMakeLabel(v); |
| 107548 | 107686 | codeOffset(v, regOffset, addrCont); |
| 107549 | 107687 | selectInnerLoop(pParse, p, p->pEList, iCurrent, |
| 107550 | 107688 | 0, 0, pDest, addrCont, addrBreak); |
| 107551 | 107689 | if( regLimit ){ |
| 107552 | | - sqlite3VdbeAddOp3(v, OP_IfZero, regLimit, addrBreak, -1); |
| 107690 | + sqlite3VdbeAddOp2(v, OP_DecrJumpZero, regLimit, addrBreak); |
| 107553 | 107691 | VdbeCoverage(v); |
| 107554 | 107692 | } |
| 107555 | 107693 | sqlite3VdbeResolveLabel(v, addrCont); |
| 107556 | 107694 | |
| 107557 | 107695 | /* Execute the recursive SELECT taking the single row in Current as |
| | @@ -107772,11 +107910,11 @@ |
| 107772 | 107910 | } |
| 107773 | 107911 | p->pPrior = 0; |
| 107774 | 107912 | p->iLimit = pPrior->iLimit; |
| 107775 | 107913 | p->iOffset = pPrior->iOffset; |
| 107776 | 107914 | if( p->iLimit ){ |
| 107777 | | - addr = sqlite3VdbeAddOp1(v, OP_IfZero, p->iLimit); VdbeCoverage(v); |
| 107915 | + addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v); |
| 107778 | 107916 | VdbeComment((v, "Jump ahead if LIMIT reached")); |
| 107779 | 107917 | } |
| 107780 | 107918 | explainSetInteger(iSub2, pParse->iNextSelectId); |
| 107781 | 107919 | rc = sqlite3Select(pParse, p, &dest); |
| 107782 | 107920 | testcase( rc!=SQLITE_OK ); |
| | @@ -108173,11 +108311,11 @@ |
| 108173 | 108311 | } |
| 108174 | 108312 | |
| 108175 | 108313 | /* Jump to the end of the loop if the LIMIT is reached. |
| 108176 | 108314 | */ |
| 108177 | 108315 | if( p->iLimit ){ |
| 108178 | | - sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); VdbeCoverage(v); |
| 108316 | + sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v); |
| 108179 | 108317 | } |
| 108180 | 108318 | |
| 108181 | 108319 | /* Generate the subroutine return |
| 108182 | 108320 | */ |
| 108183 | 108321 | sqlite3VdbeResolveLabel(v, iContinue); |
| | @@ -114787,10 +114925,12 @@ |
| 114787 | 114925 | int addrNxt; /* Jump here to start the next IN combination */ |
| 114788 | 114926 | int addrSkip; /* Jump here for next iteration of skip-scan */ |
| 114789 | 114927 | int addrCont; /* Jump here to continue with the next loop cycle */ |
| 114790 | 114928 | int addrFirst; /* First instruction of interior of the loop */ |
| 114791 | 114929 | int addrBody; /* Beginning of the body of this loop */ |
| 114930 | + int iLikeRepCntr; /* LIKE range processing counter register */ |
| 114931 | + int addrLikeRep; /* LIKE range processing address */ |
| 114792 | 114932 | u8 iFrom; /* Which entry in the FROM clause */ |
| 114793 | 114933 | u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */ |
| 114794 | 114934 | int p1, p2; /* Operands of the opcode used to ends the loop */ |
| 114795 | 114935 | union { /* Information that depends on pWLoop->wsFlags */ |
| 114796 | 114936 | struct { |
| | @@ -114971,11 +115111,11 @@ |
| 114971 | 115111 | WhereOrInfo *pOrInfo; /* Extra information if (eOperator & WO_OR)!=0 */ |
| 114972 | 115112 | WhereAndInfo *pAndInfo; /* Extra information if (eOperator& WO_AND)!=0 */ |
| 114973 | 115113 | } u; |
| 114974 | 115114 | LogEst truthProb; /* Probability of truth for this expression */ |
| 114975 | 115115 | u16 eOperator; /* A WO_xx value describing <op> */ |
| 114976 | | - u8 wtFlags; /* TERM_xxx bit flags. See below */ |
| 115116 | + u16 wtFlags; /* TERM_xxx bit flags. See below */ |
| 114977 | 115117 | u8 nChild; /* Number of children that must disable us */ |
| 114978 | 115118 | WhereClause *pWC; /* The clause this term is part of */ |
| 114979 | 115119 | Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */ |
| 114980 | 115120 | Bitmask prereqAll; /* Bitmask of tables referenced by pExpr */ |
| 114981 | 115121 | }; |
| | @@ -114993,10 +115133,13 @@ |
| 114993 | 115133 | #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 |
| 114994 | 115134 | # define TERM_VNULL 0x80 /* Manufactured x>NULL or x<=NULL term */ |
| 114995 | 115135 | #else |
| 114996 | 115136 | # define TERM_VNULL 0x00 /* Disabled if not using stat3 */ |
| 114997 | 115137 | #endif |
| 115138 | +#define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */ |
| 115139 | +#define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */ |
| 115140 | +#define TERM_LIKE 0x400 /* The original LIKE operator */ |
| 114998 | 115141 | |
| 114999 | 115142 | /* |
| 115000 | 115143 | ** An instance of the WhereScan object is used as an iterator for locating |
| 115001 | 115144 | ** terms in the WHERE clause that are useful to the query planner. |
| 115002 | 115145 | */ |
| | @@ -115368,11 +115511,11 @@ |
| 115368 | 115511 | ** WARNING: This routine might reallocate the space used to store |
| 115369 | 115512 | ** WhereTerms. All pointers to WhereTerms should be invalidated after |
| 115370 | 115513 | ** calling this routine. Such pointers may be reinitialized by referencing |
| 115371 | 115514 | ** the pWC->a[] array. |
| 115372 | 115515 | */ |
| 115373 | | -static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){ |
| 115516 | +static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){ |
| 115374 | 115517 | WhereTerm *pTerm; |
| 115375 | 115518 | int idx; |
| 115376 | 115519 | testcase( wtFlags & TERM_VIRTUAL ); |
| 115377 | 115520 | if( pWC->nTerm>=pWC->nSlot ){ |
| 115378 | 115521 | WhereTerm *pOld = pWC->a; |
| | @@ -115793,11 +115936,15 @@ |
| 115793 | 115936 | ** Check to see if the given expression is a LIKE or GLOB operator that |
| 115794 | 115937 | ** can be optimized using inequality constraints. Return TRUE if it is |
| 115795 | 115938 | ** so and false if not. |
| 115796 | 115939 | ** |
| 115797 | 115940 | ** In order for the operator to be optimizible, the RHS must be a string |
| 115798 | | -** literal that does not begin with a wildcard. |
| 115941 | +** literal that does not begin with a wildcard. The LHS must be a column |
| 115942 | +** that may only be NULL, a string, or a BLOB, never a number. (This means |
| 115943 | +** that virtual tables cannot participate in the LIKE optimization.) If the |
| 115944 | +** collating sequence for the column on the LHS must be appropriate for |
| 115945 | +** the operator. |
| 115799 | 115946 | */ |
| 115800 | 115947 | static int isLikeOrGlob( |
| 115801 | 115948 | Parse *pParse, /* Parsing and code generating context */ |
| 115802 | 115949 | Expr *pExpr, /* Test this expression */ |
| 115803 | 115950 | Expr **ppPrefix, /* Pointer to TK_STRING expression with pattern prefix */ |
| | @@ -115822,11 +115969,11 @@ |
| 115822 | 115969 | #endif |
| 115823 | 115970 | pList = pExpr->x.pList; |
| 115824 | 115971 | pLeft = pList->a[1].pExpr; |
| 115825 | 115972 | if( pLeft->op!=TK_COLUMN |
| 115826 | 115973 | || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT |
| 115827 | | - || IsVirtual(pLeft->pTab) |
| 115974 | + || IsVirtual(pLeft->pTab) /* Value might be numeric */ |
| 115828 | 115975 | ){ |
| 115829 | 115976 | /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must |
| 115830 | 115977 | ** be the name of an indexed column with TEXT affinity. */ |
| 115831 | 115978 | return 0; |
| 115832 | 115979 | } |
| | @@ -116271,11 +116418,11 @@ |
| 116271 | 116418 | Bitmask prereqLeft; /* Prerequesites of the pExpr->pLeft */ |
| 116272 | 116419 | Bitmask prereqAll; /* Prerequesites of pExpr */ |
| 116273 | 116420 | Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */ |
| 116274 | 116421 | Expr *pStr1 = 0; /* RHS of LIKE/GLOB operator */ |
| 116275 | 116422 | int isComplete = 0; /* RHS of LIKE/GLOB ends with wildcard */ |
| 116276 | | - int noCase = 0; /* LIKE/GLOB distinguishes case */ |
| 116423 | + int noCase = 0; /* uppercase equivalent to lowercase */ |
| 116277 | 116424 | int op; /* Top-level operator. pExpr->op */ |
| 116278 | 116425 | Parse *pParse = pWInfo->pParse; /* Parsing context */ |
| 116279 | 116426 | sqlite3 *db = pParse->db; /* Database connection */ |
| 116280 | 116427 | |
| 116281 | 116428 | if( db->mallocFailed ){ |
| | @@ -116409,16 +116556,19 @@ |
| 116409 | 116556 | |
| 116410 | 116557 | #ifndef SQLITE_OMIT_LIKE_OPTIMIZATION |
| 116411 | 116558 | /* Add constraints to reduce the search space on a LIKE or GLOB |
| 116412 | 116559 | ** operator. |
| 116413 | 116560 | ** |
| 116414 | | - ** A like pattern of the form "x LIKE 'abc%'" is changed into constraints |
| 116561 | + ** A like pattern of the form "x LIKE 'aBc%'" is changed into constraints |
| 116415 | 116562 | ** |
| 116416 | | - ** x>='abc' AND x<'abd' AND x LIKE 'abc%' |
| 116563 | + ** x>='ABC' AND x<'abd' AND x LIKE 'aBc%' |
| 116417 | 116564 | ** |
| 116418 | 116565 | ** The last character of the prefix "abc" is incremented to form the |
| 116419 | | - ** termination condition "abd". |
| 116566 | + ** termination condition "abd". If case is not significant (the default |
| 116567 | + ** for LIKE) then the lower-bound is made all uppercase and the upper- |
| 116568 | + ** bound is made all lowercase so that the bounds also work when comparing |
| 116569 | + ** BLOBs. |
| 116420 | 116570 | */ |
| 116421 | 116571 | if( pWC->op==TK_AND |
| 116422 | 116572 | && isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase) |
| 116423 | 116573 | ){ |
| 116424 | 116574 | Expr *pLeft; /* LHS of LIKE/GLOB operator */ |
| | @@ -116426,13 +116576,29 @@ |
| 116426 | 116576 | Expr *pNewExpr1; |
| 116427 | 116577 | Expr *pNewExpr2; |
| 116428 | 116578 | int idxNew1; |
| 116429 | 116579 | int idxNew2; |
| 116430 | 116580 | Token sCollSeqName; /* Name of collating sequence */ |
| 116581 | + const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC; |
| 116431 | 116582 | |
| 116432 | 116583 | pLeft = pExpr->x.pList->a[1].pExpr; |
| 116433 | 116584 | pStr2 = sqlite3ExprDup(db, pStr1, 0); |
| 116585 | + |
| 116586 | + /* Convert the lower bound to upper-case and the upper bound to |
| 116587 | + ** lower-case (upper-case is less than lower-case in ASCII) so that |
| 116588 | + ** the range constraints also work for BLOBs |
| 116589 | + */ |
| 116590 | + if( noCase && !pParse->db->mallocFailed ){ |
| 116591 | + int i; |
| 116592 | + char c; |
| 116593 | + pTerm->wtFlags |= TERM_LIKE; |
| 116594 | + for(i=0; (c = pStr1->u.zToken[i])!=0; i++){ |
| 116595 | + pStr1->u.zToken[i] = sqlite3Toupper(c); |
| 116596 | + pStr2->u.zToken[i] = sqlite3Tolower(c); |
| 116597 | + } |
| 116598 | + } |
| 116599 | + |
| 116434 | 116600 | if( !db->mallocFailed ){ |
| 116435 | 116601 | u8 c, *pC; /* Last character before the first wildcard */ |
| 116436 | 116602 | pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1]; |
| 116437 | 116603 | c = *pC; |
| 116438 | 116604 | if( noCase ){ |
| | @@ -116448,23 +116614,23 @@ |
| 116448 | 116614 | *pC = c + 1; |
| 116449 | 116615 | } |
| 116450 | 116616 | sCollSeqName.z = noCase ? "NOCASE" : "BINARY"; |
| 116451 | 116617 | sCollSeqName.n = 6; |
| 116452 | 116618 | pNewExpr1 = sqlite3ExprDup(db, pLeft, 0); |
| 116453 | | - pNewExpr1 = sqlite3PExpr(pParse, TK_GE, |
| 116619 | + pNewExpr1 = sqlite3PExpr(pParse, TK_GE, |
| 116454 | 116620 | sqlite3ExprAddCollateToken(pParse,pNewExpr1,&sCollSeqName), |
| 116455 | 116621 | pStr1, 0); |
| 116456 | 116622 | transferJoinMarkings(pNewExpr1, pExpr); |
| 116457 | | - idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL|TERM_DYNAMIC); |
| 116623 | + idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags); |
| 116458 | 116624 | testcase( idxNew1==0 ); |
| 116459 | 116625 | exprAnalyze(pSrc, pWC, idxNew1); |
| 116460 | 116626 | pNewExpr2 = sqlite3ExprDup(db, pLeft, 0); |
| 116461 | 116627 | pNewExpr2 = sqlite3PExpr(pParse, TK_LT, |
| 116462 | 116628 | sqlite3ExprAddCollateToken(pParse,pNewExpr2,&sCollSeqName), |
| 116463 | 116629 | pStr2, 0); |
| 116464 | 116630 | transferJoinMarkings(pNewExpr2, pExpr); |
| 116465 | | - idxNew2 = whereClauseInsert(pWC, pNewExpr2, TERM_VIRTUAL|TERM_DYNAMIC); |
| 116631 | + idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags); |
| 116466 | 116632 | testcase( idxNew2==0 ); |
| 116467 | 116633 | exprAnalyze(pSrc, pWC, idxNew2); |
| 116468 | 116634 | pTerm = &pWC->a[idxTerm]; |
| 116469 | 116635 | if( isComplete ){ |
| 116470 | 116636 | markTermAsChild(pWC, idxNew1, idxTerm); |
| | @@ -117635,24 +117801,47 @@ |
| 117635 | 117801 | ** by indices, we disable them to prevent redundant tests in the inner |
| 117636 | 117802 | ** loop. We would get the correct results if nothing were ever disabled, |
| 117637 | 117803 | ** but joins might run a little slower. The trick is to disable as much |
| 117638 | 117804 | ** as we can without disabling too much. If we disabled in (1), we'd get |
| 117639 | 117805 | ** the wrong answer. See ticket #813. |
| 117806 | +** |
| 117807 | +** If all the children of a term are disabled, then that term is also |
| 117808 | +** automatically disabled. In this way, terms get disabled if derived |
| 117809 | +** virtual terms are tested first. For example: |
| 117810 | +** |
| 117811 | +** x GLOB 'abc*' AND x>='abc' AND x<'acd' |
| 117812 | +** \___________/ \______/ \_____/ |
| 117813 | +** parent child1 child2 |
| 117814 | +** |
| 117815 | +** Only the parent term was in the original WHERE clause. The child1 |
| 117816 | +** and child2 terms were added by the LIKE optimization. If both of |
| 117817 | +** the virtual child terms are valid, then testing of the parent can be |
| 117818 | +** skipped. |
| 117819 | +** |
| 117820 | +** Usually the parent term is marked as TERM_CODED. But if the parent |
| 117821 | +** term was originally TERM_LIKE, then the parent gets TERM_LIKECOND instead. |
| 117822 | +** The TERM_LIKECOND marking indicates that the term should be coded inside |
| 117823 | +** a conditional such that is only evaluated on the second pass of a |
| 117824 | +** LIKE-optimization loop, when scanning BLOBs instead of strings. |
| 117640 | 117825 | */ |
| 117641 | 117826 | static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){ |
| 117642 | | - if( pTerm |
| 117827 | + int nLoop = 0; |
| 117828 | + while( pTerm |
| 117643 | 117829 | && (pTerm->wtFlags & TERM_CODED)==0 |
| 117644 | 117830 | && (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin)) |
| 117645 | 117831 | && (pLevel->notReady & pTerm->prereqAll)==0 |
| 117646 | 117832 | ){ |
| 117647 | | - pTerm->wtFlags |= TERM_CODED; |
| 117648 | | - if( pTerm->iParent>=0 ){ |
| 117649 | | - WhereTerm *pOther = &pTerm->pWC->a[pTerm->iParent]; |
| 117650 | | - if( (--pOther->nChild)==0 ){ |
| 117651 | | - disableTerm(pLevel, pOther); |
| 117652 | | - } |
| 117833 | + if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){ |
| 117834 | + pTerm->wtFlags |= TERM_LIKECOND; |
| 117835 | + }else{ |
| 117836 | + pTerm->wtFlags |= TERM_CODED; |
| 117653 | 117837 | } |
| 117838 | + if( pTerm->iParent<0 ) break; |
| 117839 | + pTerm = &pTerm->pWC->a[pTerm->iParent]; |
| 117840 | + pTerm->nChild--; |
| 117841 | + if( pTerm->nChild!=0 ) break; |
| 117842 | + nLoop++; |
| 117654 | 117843 | } |
| 117655 | 117844 | } |
| 117656 | 117845 | |
| 117657 | 117846 | /* |
| 117658 | 117847 | ** Code an OP_Affinity opcode to apply the column affinity string zAff |
| | @@ -118132,11 +118321,30 @@ |
| 118132 | 118321 | } |
| 118133 | 118322 | #else |
| 118134 | 118323 | # define addScanStatus(a, b, c, d) ((void)d) |
| 118135 | 118324 | #endif |
| 118136 | 118325 | |
| 118137 | | - |
| 118326 | +/* |
| 118327 | +** Look at the last instruction coded. If that instruction is OP_String8 |
| 118328 | +** and if pLoop->iLikeRepCntr is non-zero, then change the P3 to be |
| 118329 | +** pLoop->iLikeRepCntr and set P5. |
| 118330 | +** |
| 118331 | +** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range |
| 118332 | +** expression: "x>='ABC' AND x<'abd'". But this requires that the range |
| 118333 | +** scan loop run twice, once for strings and a second time for BLOBs. |
| 118334 | +** The OP_String opcodes on the second pass convert the upper and lower |
| 118335 | +** bound string contants to blobs. This routine makes the necessary changes |
| 118336 | +** to the OP_String opcodes for that to happen. |
| 118337 | +*/ |
| 118338 | +static void whereLikeOptimizationStringFixup(Vdbe *v, WhereLevel *pLevel){ |
| 118339 | + VdbeOp *pOp; |
| 118340 | + pOp = sqlite3VdbeGetOp(v, -1); |
| 118341 | + if( pLevel->iLikeRepCntr && pOp->opcode==OP_String8 ){ |
| 118342 | + pOp->p3 = pLevel->iLikeRepCntr; |
| 118343 | + pOp->p5 = 1; |
| 118344 | + } |
| 118345 | +} |
| 118138 | 118346 | |
| 118139 | 118347 | /* |
| 118140 | 118348 | ** Generate code for the start of the iLevel-th loop in the WHERE clause |
| 118141 | 118349 | ** implementation described by pWInfo. |
| 118142 | 118350 | */ |
| | @@ -118466,10 +118674,23 @@ |
| 118466 | 118674 | nExtraReg = 1; |
| 118467 | 118675 | } |
| 118468 | 118676 | if( pLoop->wsFlags & WHERE_TOP_LIMIT ){ |
| 118469 | 118677 | pRangeEnd = pLoop->aLTerm[j++]; |
| 118470 | 118678 | nExtraReg = 1; |
| 118679 | + if( pRangeStart |
| 118680 | + && (pRangeStart->wtFlags & TERM_LIKEOPT)!=0 |
| 118681 | + && (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 |
| 118682 | + ){ |
| 118683 | + pLevel->iLikeRepCntr = ++pParse->nMem; |
| 118684 | + testcase( bRev ); |
| 118685 | + testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC ); |
| 118686 | + sqlite3VdbeAddOp2(v, OP_Integer, |
| 118687 | + bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC), |
| 118688 | + pLevel->iLikeRepCntr); |
| 118689 | + VdbeComment((v, "LIKE loop counter")); |
| 118690 | + pLevel->addrLikeRep = sqlite3VdbeCurrentAddr(v); |
| 118691 | + } |
| 118471 | 118692 | if( pRangeStart==0 |
| 118472 | 118693 | && (j = pIdx->aiColumn[nEq])>=0 |
| 118473 | 118694 | && pIdx->pTable->aCol[j].notNull==0 |
| 118474 | 118695 | ){ |
| 118475 | 118696 | bSeekPastNull = 1; |
| | @@ -118508,10 +118729,11 @@ |
| 118508 | 118729 | /* Seek the index cursor to the start of the range. */ |
| 118509 | 118730 | nConstraint = nEq; |
| 118510 | 118731 | if( pRangeStart ){ |
| 118511 | 118732 | Expr *pRight = pRangeStart->pExpr->pRight; |
| 118512 | 118733 | sqlite3ExprCode(pParse, pRight, regBase+nEq); |
| 118734 | + whereLikeOptimizationStringFixup(v, pLevel); |
| 118513 | 118735 | if( (pRangeStart->wtFlags & TERM_VNULL)==0 |
| 118514 | 118736 | && sqlite3ExprCanBeNull(pRight) |
| 118515 | 118737 | ){ |
| 118516 | 118738 | sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt); |
| 118517 | 118739 | VdbeCoverage(v); |
| | @@ -118553,10 +118775,11 @@ |
| 118553 | 118775 | nConstraint = nEq; |
| 118554 | 118776 | if( pRangeEnd ){ |
| 118555 | 118777 | Expr *pRight = pRangeEnd->pExpr->pRight; |
| 118556 | 118778 | sqlite3ExprCacheRemove(pParse, regBase+nEq, 1); |
| 118557 | 118779 | sqlite3ExprCode(pParse, pRight, regBase+nEq); |
| 118780 | + whereLikeOptimizationStringFixup(v, pLevel); |
| 118558 | 118781 | if( (pRangeEnd->wtFlags & TERM_VNULL)==0 |
| 118559 | 118782 | && sqlite3ExprCanBeNull(pRight) |
| 118560 | 118783 | ){ |
| 118561 | 118784 | sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, addrNxt); |
| 118562 | 118785 | VdbeCoverage(v); |
| | @@ -118780,11 +119003,12 @@ |
| 118780 | 119003 | ** eliminating duplicates from other WHERE clauses, the action for each |
| 118781 | 119004 | ** sub-WHERE clause is to to invoke the main loop body as a subroutine. |
| 118782 | 119005 | */ |
| 118783 | 119006 | wctrlFlags = WHERE_OMIT_OPEN_CLOSE |
| 118784 | 119007 | | WHERE_FORCE_TABLE |
| 118785 | | - | WHERE_ONETABLE_ONLY; |
| 119008 | + | WHERE_ONETABLE_ONLY |
| 119009 | + | WHERE_NO_AUTOINDEX; |
| 118786 | 119010 | for(ii=0; ii<pOrWc->nTerm; ii++){ |
| 118787 | 119011 | WhereTerm *pOrTerm = &pOrWc->a[ii]; |
| 118788 | 119012 | if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){ |
| 118789 | 119013 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ |
| 118790 | 119014 | Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */ |
| | @@ -118942,10 +119166,11 @@ |
| 118942 | 119166 | /* Insert code to test every subexpression that can be completely |
| 118943 | 119167 | ** computed using the current set of tables. |
| 118944 | 119168 | */ |
| 118945 | 119169 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 118946 | 119170 | Expr *pE; |
| 119171 | + int skipLikeAddr = 0; |
| 118947 | 119172 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 118948 | 119173 | testcase( pTerm->wtFlags & TERM_CODED ); |
| 118949 | 119174 | if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue; |
| 118950 | 119175 | if( (pTerm->prereqAll & pLevel->notReady)!=0 ){ |
| 118951 | 119176 | testcase( pWInfo->untestedTerms==0 |
| | @@ -118955,12 +119180,18 @@ |
| 118955 | 119180 | } |
| 118956 | 119181 | pE = pTerm->pExpr; |
| 118957 | 119182 | assert( pE!=0 ); |
| 118958 | 119183 | if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){ |
| 118959 | 119184 | continue; |
| 119185 | + } |
| 119186 | + if( pTerm->wtFlags & TERM_LIKECOND ){ |
| 119187 | + assert( pLevel->iLikeRepCntr>0 ); |
| 119188 | + skipLikeAddr = sqlite3VdbeAddOp1(v, OP_IfNot, pLevel->iLikeRepCntr); |
| 119189 | + VdbeCoverage(v); |
| 118960 | 119190 | } |
| 118961 | 119191 | sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL); |
| 119192 | + if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr); |
| 118962 | 119193 | pTerm->wtFlags |= TERM_CODED; |
| 118963 | 119194 | } |
| 118964 | 119195 | |
| 118965 | 119196 | /* Insert code to test for implied constraints based on transitivity |
| 118966 | 119197 | ** of the "==" operator. |
| | @@ -119974,10 +120205,11 @@ |
| 119974 | 120205 | rLogSize = estLog(rSize); |
| 119975 | 120206 | |
| 119976 | 120207 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 119977 | 120208 | /* Automatic indexes */ |
| 119978 | 120209 | if( !pBuilder->pOrSet |
| 120210 | + && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0 |
| 119979 | 120211 | && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0 |
| 119980 | 120212 | && pSrc->pIndex==0 |
| 119981 | 120213 | && !pSrc->viaCoroutine |
| 119982 | 120214 | && !pSrc->notIndexed |
| 119983 | 120215 | && HasRowid(pTab) |
| | @@ -121758,10 +121990,20 @@ |
| 121758 | 121990 | if( pLevel->addrSkip ){ |
| 121759 | 121991 | sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip); |
| 121760 | 121992 | VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName)); |
| 121761 | 121993 | sqlite3VdbeJumpHere(v, pLevel->addrSkip); |
| 121762 | 121994 | sqlite3VdbeJumpHere(v, pLevel->addrSkip-2); |
| 121995 | + } |
| 121996 | + if( pLevel->addrLikeRep ){ |
| 121997 | + int op; |
| 121998 | + if( sqlite3VdbeGetOp(v, pLevel->addrLikeRep-1)->p1 ){ |
| 121999 | + op = OP_DecrJumpZero; |
| 122000 | + }else{ |
| 122001 | + op = OP_JumpZeroIncr; |
| 122002 | + } |
| 122003 | + sqlite3VdbeAddOp2(v, op, pLevel->iLikeRepCntr, pLevel->addrLikeRep); |
| 122004 | + VdbeCoverage(v); |
| 121763 | 122005 | } |
| 121764 | 122006 | if( pLevel->iLeftJoin ){ |
| 121765 | 122007 | addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v); |
| 121766 | 122008 | assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 |
| 121767 | 122009 | || (pLoop->wsFlags & WHERE_INDEXED)!=0 ); |
| | @@ -126982,30 +127224,32 @@ |
| 126982 | 127224 | /* Mutex configuration options are only available in a threadsafe |
| 126983 | 127225 | ** compile. |
| 126984 | 127226 | */ |
| 126985 | 127227 | #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-54466-46756 */ |
| 126986 | 127228 | case SQLITE_CONFIG_SINGLETHREAD: { |
| 126987 | | - /* Disable all mutexing */ |
| 126988 | | - sqlite3GlobalConfig.bCoreMutex = 0; |
| 126989 | | - sqlite3GlobalConfig.bFullMutex = 0; |
| 127229 | + /* EVIDENCE-OF: R-02748-19096 This option sets the threading mode to |
| 127230 | + ** Single-thread. */ |
| 127231 | + sqlite3GlobalConfig.bCoreMutex = 0; /* Disable mutex on core */ |
| 127232 | + sqlite3GlobalConfig.bFullMutex = 0; /* Disable mutex on connections */ |
| 126990 | 127233 | break; |
| 126991 | 127234 | } |
| 126992 | 127235 | #endif |
| 126993 | 127236 | #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-20520-54086 */ |
| 126994 | 127237 | case SQLITE_CONFIG_MULTITHREAD: { |
| 126995 | | - /* Disable mutexing of database connections */ |
| 126996 | | - /* Enable mutexing of core data structures */ |
| 126997 | | - sqlite3GlobalConfig.bCoreMutex = 1; |
| 126998 | | - sqlite3GlobalConfig.bFullMutex = 0; |
| 127238 | + /* EVIDENCE-OF: R-14374-42468 This option sets the threading mode to |
| 127239 | + ** Multi-thread. */ |
| 127240 | + sqlite3GlobalConfig.bCoreMutex = 1; /* Enable mutex on core */ |
| 127241 | + sqlite3GlobalConfig.bFullMutex = 0; /* Disable mutex on connections */ |
| 126999 | 127242 | break; |
| 127000 | 127243 | } |
| 127001 | 127244 | #endif |
| 127002 | 127245 | #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-59593-21810 */ |
| 127003 | 127246 | case SQLITE_CONFIG_SERIALIZED: { |
| 127004 | | - /* Enable all mutexing */ |
| 127005 | | - sqlite3GlobalConfig.bCoreMutex = 1; |
| 127006 | | - sqlite3GlobalConfig.bFullMutex = 1; |
| 127247 | + /* EVIDENCE-OF: R-41220-51800 This option sets the threading mode to |
| 127248 | + ** Serialized. */ |
| 127249 | + sqlite3GlobalConfig.bCoreMutex = 1; /* Enable mutex on core */ |
| 127250 | + sqlite3GlobalConfig.bFullMutex = 1; /* Enable mutex on connections */ |
| 127007 | 127251 | break; |
| 127008 | 127252 | } |
| 127009 | 127253 | #endif |
| 127010 | 127254 | #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-63666-48755 */ |
| 127011 | 127255 | case SQLITE_CONFIG_MUTEX: { |
| | @@ -127113,11 +127357,12 @@ |
| 127113 | 127357 | ** SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. */ |
| 127114 | 127358 | #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5) |
| 127115 | 127359 | case SQLITE_CONFIG_HEAP: { |
| 127116 | 127360 | /* EVIDENCE-OF: R-19854-42126 There are three arguments to |
| 127117 | 127361 | ** SQLITE_CONFIG_HEAP: An 8-byte aligned pointer to the memory, the |
| 127118 | | - ** number of bytes in the memory buffer, and the minimum allocation size. */ |
| 127362 | + ** number of bytes in the memory buffer, and the minimum allocation size. |
| 127363 | + */ |
| 127119 | 127364 | sqlite3GlobalConfig.pHeap = va_arg(ap, void*); |
| 127120 | 127365 | sqlite3GlobalConfig.nHeap = va_arg(ap, int); |
| 127121 | 127366 | sqlite3GlobalConfig.mnReq = va_arg(ap, int); |
| 127122 | 127367 | |
| 127123 | 127368 | if( sqlite3GlobalConfig.mnReq<1 ){ |
| | @@ -127218,11 +127463,13 @@ |
| 127218 | 127463 | ** EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be |
| 127219 | 127464 | ** silently truncated if necessary so that it does not exceed the |
| 127220 | 127465 | ** compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE |
| 127221 | 127466 | ** compile-time option. |
| 127222 | 127467 | */ |
| 127223 | | - if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ) mxMmap = SQLITE_MAX_MMAP_SIZE; |
| 127468 | + if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ){ |
| 127469 | + mxMmap = SQLITE_MAX_MMAP_SIZE; |
| 127470 | + } |
| 127224 | 127471 | if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE; |
| 127225 | 127472 | if( szMmap>mxMmap) szMmap = mxMmap; |
| 127226 | 127473 | sqlite3GlobalConfig.mxMmap = mxMmap; |
| 127227 | 127474 | sqlite3GlobalConfig.szMmap = szMmap; |
| 127228 | 127475 | break; |
| | @@ -129062,11 +129309,23 @@ |
| 129062 | 129309 | for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&'); |
| 129063 | 129310 | zFile = sqlite3_malloc(nByte); |
| 129064 | 129311 | if( !zFile ) return SQLITE_NOMEM; |
| 129065 | 129312 | |
| 129066 | 129313 | iIn = 5; |
| 129067 | | -#ifndef SQLITE_ALLOW_URI_AUTHORITY |
| 129314 | +#ifdef SQLITE_ALLOW_URI_AUTHORITY |
| 129315 | + if( strncmp(zUri+5, "///", 3)==0 ){ |
| 129316 | + iIn = 7; |
| 129317 | + /* The following condition causes URIs with five leading / characters |
| 129318 | + ** like file://///host/path to be converted into UNCs like //host/path. |
| 129319 | + ** The correct URI for that UNC has only two or four leading / characters |
| 129320 | + ** file://host/path or file:////host/path. But 5 leading slashes is a |
| 129321 | + ** common error, we are told, so we handle it as a special case. */ |
| 129322 | + if( strncmp(zUri+7, "///", 3)==0 ){ iIn++; } |
| 129323 | + }else if( strncmp(zUri+5, "//localhost/", 12)==0 ){ |
| 129324 | + iIn = 16; |
| 129325 | + } |
| 129326 | +#else |
| 129068 | 129327 | /* Discard the scheme and authority segments of the URI. */ |
| 129069 | 129328 | if( zUri[5]=='/' && zUri[6]=='/' ){ |
| 129070 | 129329 | iIn = 7; |
| 129071 | 129330 | while( zUri[iIn] && zUri[iIn]!='/' ) iIn++; |
| 129072 | 129331 | if( iIn!=7 && (iIn!=16 || memcmp("localhost", &zUri[7], 9)) ){ |
| | @@ -129505,11 +129764,12 @@ |
| 129505 | 129764 | sqlite3_wal_autocheckpoint(db, SQLITE_DEFAULT_WAL_AUTOCHECKPOINT); |
| 129506 | 129765 | |
| 129507 | 129766 | opendb_out: |
| 129508 | 129767 | sqlite3_free(zOpen); |
| 129509 | 129768 | if( db ){ |
| 129510 | | - assert( db->mutex!=0 || isThreadsafe==0 || sqlite3GlobalConfig.bFullMutex==0 ); |
| 129769 | + assert( db->mutex!=0 || isThreadsafe==0 |
| 129770 | + || sqlite3GlobalConfig.bFullMutex==0 ); |
| 129511 | 129771 | sqlite3_mutex_leave(db->mutex); |
| 129512 | 129772 | } |
| 129513 | 129773 | rc = sqlite3_errcode(db); |
| 129514 | 129774 | assert( db!=0 || rc==SQLITE_NOMEM ); |
| 129515 | 129775 | if( rc==SQLITE_NOMEM ){ |
| | @@ -130250,21 +130510,21 @@ |
| 130250 | 130510 | case SQLITE_TESTCTRL_ISINIT: { |
| 130251 | 130511 | if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR; |
| 130252 | 130512 | break; |
| 130253 | 130513 | } |
| 130254 | 130514 | |
| 130255 | | - /* sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum); |
| 130515 | + /* sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum); |
| 130256 | 130516 | ** |
| 130257 | 130517 | ** This test control is used to create imposter tables. "db" is a pointer |
| 130258 | 130518 | ** to the database connection. dbName is the database name (ex: "main" or |
| 130259 | 130519 | ** "temp") which will receive the imposter. "onOff" turns imposter mode on |
| 130260 | 130520 | ** or off. "tnum" is the root page of the b-tree to which the imposter |
| 130261 | 130521 | ** table should connect. |
| 130262 | 130522 | ** |
| 130263 | 130523 | ** Enable imposter mode only when the schema has already been parsed. Then |
| 130264 | | - ** run a single CREATE TABLE statement to construct the imposter table in the |
| 130265 | | - ** parsed schema. Then turn imposter mode back off again. |
| 130524 | + ** run a single CREATE TABLE statement to construct the imposter table in |
| 130525 | + ** the parsed schema. Then turn imposter mode back off again. |
| 130266 | 130526 | ** |
| 130267 | 130527 | ** If onOff==0 and tnum>0 then reset the schema for all databases, causing |
| 130268 | 130528 | ** the schema to be reparsed the next time it is needed. This has the |
| 130269 | 130529 | ** effect of erasing all imposter tables. |
| 130270 | 130530 | */ |
| 130271 | 130531 | |