diff options
Diffstat (limited to 'c/sqlite3.c')
| -rw-r--r-- | c/sqlite3.c | 14703 |
1 files changed, 8317 insertions, 6386 deletions
diff --git a/c/sqlite3.c b/c/sqlite3.c index 89faea5..fba450a 100644 --- a/c/sqlite3.c +++ b/c/sqlite3.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /****************************************************************************** | 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.36.0. By combining all the individual C code files into this | 3 | ** version 3.37.1. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements | 6 | ** possible if the files were compiled separately. Performance improvements |
| @@ -22,793 +22,6 @@ | |||
| 22 | #ifndef SQLITE_PRIVATE | 22 | #ifndef SQLITE_PRIVATE |
| 23 | # define SQLITE_PRIVATE static | 23 | # define SQLITE_PRIVATE static |
| 24 | #endif | 24 | #endif |
| 25 | /************** Begin file ctime.c *******************************************/ | ||
| 26 | /* | ||
| 27 | ** 2010 February 23 | ||
| 28 | ** | ||
| 29 | ** The author disclaims copyright to this source code. In place of | ||
| 30 | ** a legal notice, here is a blessing: | ||
| 31 | ** | ||
| 32 | ** May you do good and not evil. | ||
| 33 | ** May you find forgiveness for yourself and forgive others. | ||
| 34 | ** May you share freely, never taking more than you give. | ||
| 35 | ** | ||
| 36 | ************************************************************************* | ||
| 37 | ** | ||
| 38 | ** This file implements routines used to report what compile-time options | ||
| 39 | ** SQLite was built with. | ||
| 40 | */ | ||
| 41 | |||
| 42 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */ | ||
| 43 | |||
| 44 | /* | ||
| 45 | ** Include the configuration header output by 'configure' if we're using the | ||
| 46 | ** autoconf-based build | ||
| 47 | */ | ||
| 48 | #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H) | ||
| 49 | #include "config.h" | ||
| 50 | #define SQLITECONFIG_H 1 | ||
| 51 | #endif | ||
| 52 | |||
| 53 | /* These macros are provided to "stringify" the value of the define | ||
| 54 | ** for those options in which the value is meaningful. */ | ||
| 55 | #define CTIMEOPT_VAL_(opt) #opt | ||
| 56 | #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt) | ||
| 57 | |||
| 58 | /* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This | ||
| 59 | ** option requires a separate macro because legal values contain a single | ||
| 60 | ** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */ | ||
| 61 | #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2 | ||
| 62 | #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt) | ||
| 63 | |||
| 64 | /* | ||
| 65 | ** An array of names of all compile-time options. This array should | ||
| 66 | ** be sorted A-Z. | ||
| 67 | ** | ||
| 68 | ** This array looks large, but in a typical installation actually uses | ||
| 69 | ** only a handful of compile-time options, so most times this array is usually | ||
| 70 | ** rather short and uses little memory space. | ||
| 71 | */ | ||
| 72 | static const char * const sqlite3azCompileOpt[] = { | ||
| 73 | |||
| 74 | /* | ||
| 75 | ** BEGIN CODE GENERATED BY tool/mkctime.tcl | ||
| 76 | */ | ||
| 77 | #if SQLITE_32BIT_ROWID | ||
| 78 | "32BIT_ROWID", | ||
| 79 | #endif | ||
| 80 | #if SQLITE_4_BYTE_ALIGNED_MALLOC | ||
| 81 | "4_BYTE_ALIGNED_MALLOC", | ||
| 82 | #endif | ||
| 83 | #if SQLITE_64BIT_STATS | ||
| 84 | "64BIT_STATS", | ||
| 85 | #endif | ||
| 86 | #ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN | ||
| 87 | # if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1 | ||
| 88 | "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN), | ||
| 89 | # endif | ||
| 90 | #endif | ||
| 91 | #if SQLITE_ALLOW_URI_AUTHORITY | ||
| 92 | "ALLOW_URI_AUTHORITY", | ||
| 93 | #endif | ||
| 94 | #ifdef SQLITE_BITMASK_TYPE | ||
| 95 | "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE), | ||
| 96 | #endif | ||
| 97 | #if SQLITE_BUG_COMPATIBLE_20160819 | ||
| 98 | "BUG_COMPATIBLE_20160819", | ||
| 99 | #endif | ||
| 100 | #if SQLITE_CASE_SENSITIVE_LIKE | ||
| 101 | "CASE_SENSITIVE_LIKE", | ||
| 102 | #endif | ||
| 103 | #if SQLITE_CHECK_PAGES | ||
| 104 | "CHECK_PAGES", | ||
| 105 | #endif | ||
| 106 | #if defined(__clang__) && defined(__clang_major__) | ||
| 107 | "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "." | ||
| 108 | CTIMEOPT_VAL(__clang_minor__) "." | ||
| 109 | CTIMEOPT_VAL(__clang_patchlevel__), | ||
| 110 | #elif defined(_MSC_VER) | ||
| 111 | "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), | ||
| 112 | #elif defined(__GNUC__) && defined(__VERSION__) | ||
| 113 | "COMPILER=gcc-" __VERSION__, | ||
| 114 | #endif | ||
| 115 | #if SQLITE_COVERAGE_TEST | ||
| 116 | "COVERAGE_TEST", | ||
| 117 | #endif | ||
| 118 | #if SQLITE_DEBUG | ||
| 119 | "DEBUG", | ||
| 120 | #endif | ||
| 121 | #if SQLITE_DEFAULT_AUTOMATIC_INDEX | ||
| 122 | "DEFAULT_AUTOMATIC_INDEX", | ||
| 123 | #endif | ||
| 124 | #if SQLITE_DEFAULT_AUTOVACUUM | ||
| 125 | "DEFAULT_AUTOVACUUM", | ||
| 126 | #endif | ||
| 127 | #ifdef SQLITE_DEFAULT_CACHE_SIZE | ||
| 128 | "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE), | ||
| 129 | #endif | ||
| 130 | #if SQLITE_DEFAULT_CKPTFULLFSYNC | ||
| 131 | "DEFAULT_CKPTFULLFSYNC", | ||
| 132 | #endif | ||
| 133 | #ifdef SQLITE_DEFAULT_FILE_FORMAT | ||
| 134 | "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT), | ||
| 135 | #endif | ||
| 136 | #ifdef SQLITE_DEFAULT_FILE_PERMISSIONS | ||
| 137 | "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS), | ||
| 138 | #endif | ||
| 139 | #if SQLITE_DEFAULT_FOREIGN_KEYS | ||
| 140 | "DEFAULT_FOREIGN_KEYS", | ||
| 141 | #endif | ||
| 142 | #ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT | ||
| 143 | "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT), | ||
| 144 | #endif | ||
| 145 | #ifdef SQLITE_DEFAULT_LOCKING_MODE | ||
| 146 | "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE), | ||
| 147 | #endif | ||
| 148 | #ifdef SQLITE_DEFAULT_LOOKASIDE | ||
| 149 | "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE), | ||
| 150 | #endif | ||
| 151 | #ifdef SQLITE_DEFAULT_MEMSTATUS | ||
| 152 | # if SQLITE_DEFAULT_MEMSTATUS != 1 | ||
| 153 | "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS), | ||
| 154 | # endif | ||
| 155 | #endif | ||
| 156 | #ifdef SQLITE_DEFAULT_MMAP_SIZE | ||
| 157 | "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE), | ||
| 158 | #endif | ||
| 159 | #ifdef SQLITE_DEFAULT_PAGE_SIZE | ||
| 160 | "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE), | ||
| 161 | #endif | ||
| 162 | #ifdef SQLITE_DEFAULT_PCACHE_INITSZ | ||
| 163 | "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ), | ||
| 164 | #endif | ||
| 165 | #ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS | ||
| 166 | "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS), | ||
| 167 | #endif | ||
| 168 | #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS | ||
| 169 | "DEFAULT_RECURSIVE_TRIGGERS", | ||
| 170 | #endif | ||
| 171 | #ifdef SQLITE_DEFAULT_ROWEST | ||
| 172 | "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST), | ||
| 173 | #endif | ||
| 174 | #ifdef SQLITE_DEFAULT_SECTOR_SIZE | ||
| 175 | "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE), | ||
| 176 | #endif | ||
| 177 | #ifdef SQLITE_DEFAULT_SYNCHRONOUS | ||
| 178 | "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS), | ||
| 179 | #endif | ||
| 180 | #ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT | ||
| 181 | "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT), | ||
| 182 | #endif | ||
| 183 | #ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS | ||
| 184 | "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS), | ||
| 185 | #endif | ||
| 186 | #ifdef SQLITE_DEFAULT_WORKER_THREADS | ||
| 187 | "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS), | ||
| 188 | #endif | ||
| 189 | #if SQLITE_DIRECT_OVERFLOW_READ | ||
| 190 | "DIRECT_OVERFLOW_READ", | ||
| 191 | #endif | ||
| 192 | #if SQLITE_DISABLE_DIRSYNC | ||
| 193 | "DISABLE_DIRSYNC", | ||
| 194 | #endif | ||
| 195 | #if SQLITE_DISABLE_FTS3_UNICODE | ||
| 196 | "DISABLE_FTS3_UNICODE", | ||
| 197 | #endif | ||
| 198 | #if SQLITE_DISABLE_FTS4_DEFERRED | ||
| 199 | "DISABLE_FTS4_DEFERRED", | ||
| 200 | #endif | ||
| 201 | #if SQLITE_DISABLE_INTRINSIC | ||
| 202 | "DISABLE_INTRINSIC", | ||
| 203 | #endif | ||
| 204 | #if SQLITE_DISABLE_LFS | ||
| 205 | "DISABLE_LFS", | ||
| 206 | #endif | ||
| 207 | #if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS | ||
| 208 | "DISABLE_PAGECACHE_OVERFLOW_STATS", | ||
| 209 | #endif | ||
| 210 | #if SQLITE_DISABLE_SKIPAHEAD_DISTINCT | ||
| 211 | "DISABLE_SKIPAHEAD_DISTINCT", | ||
| 212 | #endif | ||
| 213 | #ifdef SQLITE_ENABLE_8_3_NAMES | ||
| 214 | "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES), | ||
| 215 | #endif | ||
| 216 | #if SQLITE_ENABLE_API_ARMOR | ||
| 217 | "ENABLE_API_ARMOR", | ||
| 218 | #endif | ||
| 219 | #if SQLITE_ENABLE_ATOMIC_WRITE | ||
| 220 | "ENABLE_ATOMIC_WRITE", | ||
| 221 | #endif | ||
| 222 | #if SQLITE_ENABLE_BATCH_ATOMIC_WRITE | ||
| 223 | "ENABLE_BATCH_ATOMIC_WRITE", | ||
| 224 | #endif | ||
| 225 | #if SQLITE_ENABLE_BYTECODE_VTAB | ||
| 226 | "ENABLE_BYTECODE_VTAB", | ||
| 227 | #endif | ||
| 228 | #ifdef SQLITE_ENABLE_CEROD | ||
| 229 | "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD), | ||
| 230 | #endif | ||
| 231 | #if SQLITE_ENABLE_COLUMN_METADATA | ||
| 232 | "ENABLE_COLUMN_METADATA", | ||
| 233 | #endif | ||
| 234 | #if SQLITE_ENABLE_COLUMN_USED_MASK | ||
| 235 | "ENABLE_COLUMN_USED_MASK", | ||
| 236 | #endif | ||
| 237 | #if SQLITE_ENABLE_COSTMULT | ||
| 238 | "ENABLE_COSTMULT", | ||
| 239 | #endif | ||
| 240 | #if SQLITE_ENABLE_CURSOR_HINTS | ||
| 241 | "ENABLE_CURSOR_HINTS", | ||
| 242 | #endif | ||
| 243 | #if SQLITE_ENABLE_DBPAGE_VTAB | ||
| 244 | "ENABLE_DBPAGE_VTAB", | ||
| 245 | #endif | ||
| 246 | #if SQLITE_ENABLE_DBSTAT_VTAB | ||
| 247 | "ENABLE_DBSTAT_VTAB", | ||
| 248 | #endif | ||
| 249 | #if SQLITE_ENABLE_EXPENSIVE_ASSERT | ||
| 250 | "ENABLE_EXPENSIVE_ASSERT", | ||
| 251 | #endif | ||
| 252 | #if SQLITE_ENABLE_EXPLAIN_COMMENTS | ||
| 253 | "ENABLE_EXPLAIN_COMMENTS", | ||
| 254 | #endif | ||
| 255 | #if SQLITE_ENABLE_FTS3 | ||
| 256 | "ENABLE_FTS3", | ||
| 257 | #endif | ||
| 258 | #if SQLITE_ENABLE_FTS3_PARENTHESIS | ||
| 259 | "ENABLE_FTS3_PARENTHESIS", | ||
| 260 | #endif | ||
| 261 | #if SQLITE_ENABLE_FTS3_TOKENIZER | ||
| 262 | "ENABLE_FTS3_TOKENIZER", | ||
| 263 | #endif | ||
| 264 | #if SQLITE_ENABLE_FTS4 | ||
| 265 | "ENABLE_FTS4", | ||
| 266 | #endif | ||
| 267 | #if SQLITE_ENABLE_FTS5 | ||
| 268 | "ENABLE_FTS5", | ||
| 269 | #endif | ||
| 270 | #if SQLITE_ENABLE_GEOPOLY | ||
| 271 | "ENABLE_GEOPOLY", | ||
| 272 | #endif | ||
| 273 | #if SQLITE_ENABLE_HIDDEN_COLUMNS | ||
| 274 | "ENABLE_HIDDEN_COLUMNS", | ||
| 275 | #endif | ||
| 276 | #if SQLITE_ENABLE_ICU | ||
| 277 | "ENABLE_ICU", | ||
| 278 | #endif | ||
| 279 | #if SQLITE_ENABLE_IOTRACE | ||
| 280 | "ENABLE_IOTRACE", | ||
| 281 | #endif | ||
| 282 | #if SQLITE_ENABLE_JSON1 | ||
| 283 | "ENABLE_JSON1", | ||
| 284 | #endif | ||
| 285 | #if SQLITE_ENABLE_LOAD_EXTENSION | ||
| 286 | "ENABLE_LOAD_EXTENSION", | ||
| 287 | #endif | ||
| 288 | #ifdef SQLITE_ENABLE_LOCKING_STYLE | ||
| 289 | "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE), | ||
| 290 | #endif | ||
| 291 | #if SQLITE_ENABLE_MATH_FUNCTIONS | ||
| 292 | "ENABLE_MATH_FUNCTIONS", | ||
| 293 | #endif | ||
| 294 | #if SQLITE_ENABLE_MEMORY_MANAGEMENT | ||
| 295 | "ENABLE_MEMORY_MANAGEMENT", | ||
| 296 | #endif | ||
| 297 | #if SQLITE_ENABLE_MEMSYS3 | ||
| 298 | "ENABLE_MEMSYS3", | ||
| 299 | #endif | ||
| 300 | #if SQLITE_ENABLE_MEMSYS5 | ||
| 301 | "ENABLE_MEMSYS5", | ||
| 302 | #endif | ||
| 303 | #if SQLITE_ENABLE_MULTIPLEX | ||
| 304 | "ENABLE_MULTIPLEX", | ||
| 305 | #endif | ||
| 306 | #if SQLITE_ENABLE_NORMALIZE | ||
| 307 | "ENABLE_NORMALIZE", | ||
| 308 | #endif | ||
| 309 | #if SQLITE_ENABLE_NULL_TRIM | ||
| 310 | "ENABLE_NULL_TRIM", | ||
| 311 | #endif | ||
| 312 | #if SQLITE_ENABLE_OFFSET_SQL_FUNC | ||
| 313 | "ENABLE_OFFSET_SQL_FUNC", | ||
| 314 | #endif | ||
| 315 | #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK | ||
| 316 | "ENABLE_OVERSIZE_CELL_CHECK", | ||
| 317 | #endif | ||
| 318 | #if SQLITE_ENABLE_PREUPDATE_HOOK | ||
| 319 | "ENABLE_PREUPDATE_HOOK", | ||
| 320 | #endif | ||
| 321 | #if SQLITE_ENABLE_QPSG | ||
| 322 | "ENABLE_QPSG", | ||
| 323 | #endif | ||
| 324 | #if SQLITE_ENABLE_RBU | ||
| 325 | "ENABLE_RBU", | ||
| 326 | #endif | ||
| 327 | #if SQLITE_ENABLE_RTREE | ||
| 328 | "ENABLE_RTREE", | ||
| 329 | #endif | ||
| 330 | #if SQLITE_ENABLE_SELECTTRACE | ||
| 331 | "ENABLE_SELECTTRACE", | ||
| 332 | #endif | ||
| 333 | #if SQLITE_ENABLE_SESSION | ||
| 334 | "ENABLE_SESSION", | ||
| 335 | #endif | ||
| 336 | #if SQLITE_ENABLE_SNAPSHOT | ||
| 337 | "ENABLE_SNAPSHOT", | ||
| 338 | #endif | ||
| 339 | #if SQLITE_ENABLE_SORTER_REFERENCES | ||
| 340 | "ENABLE_SORTER_REFERENCES", | ||
| 341 | #endif | ||
| 342 | #if SQLITE_ENABLE_SQLLOG | ||
| 343 | "ENABLE_SQLLOG", | ||
| 344 | #endif | ||
| 345 | #if SQLITE_ENABLE_STAT4 | ||
| 346 | "ENABLE_STAT4", | ||
| 347 | #endif | ||
| 348 | #if SQLITE_ENABLE_STMTVTAB | ||
| 349 | "ENABLE_STMTVTAB", | ||
| 350 | #endif | ||
| 351 | #if SQLITE_ENABLE_STMT_SCANSTATUS | ||
| 352 | "ENABLE_STMT_SCANSTATUS", | ||
| 353 | #endif | ||
| 354 | #if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION | ||
| 355 | "ENABLE_UNKNOWN_SQL_FUNCTION", | ||
| 356 | #endif | ||
| 357 | #if SQLITE_ENABLE_UNLOCK_NOTIFY | ||
| 358 | "ENABLE_UNLOCK_NOTIFY", | ||
| 359 | #endif | ||
| 360 | #if SQLITE_ENABLE_UPDATE_DELETE_LIMIT | ||
| 361 | "ENABLE_UPDATE_DELETE_LIMIT", | ||
| 362 | #endif | ||
| 363 | #if SQLITE_ENABLE_URI_00_ERROR | ||
| 364 | "ENABLE_URI_00_ERROR", | ||
| 365 | #endif | ||
| 366 | #if SQLITE_ENABLE_VFSTRACE | ||
| 367 | "ENABLE_VFSTRACE", | ||
| 368 | #endif | ||
| 369 | #if SQLITE_ENABLE_WHERETRACE | ||
| 370 | "ENABLE_WHERETRACE", | ||
| 371 | #endif | ||
| 372 | #if SQLITE_ENABLE_ZIPVFS | ||
| 373 | "ENABLE_ZIPVFS", | ||
| 374 | #endif | ||
| 375 | #if SQLITE_EXPLAIN_ESTIMATED_ROWS | ||
| 376 | "EXPLAIN_ESTIMATED_ROWS", | ||
| 377 | #endif | ||
| 378 | #if SQLITE_EXTRA_IFNULLROW | ||
| 379 | "EXTRA_IFNULLROW", | ||
| 380 | #endif | ||
| 381 | #ifdef SQLITE_EXTRA_INIT | ||
| 382 | "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT), | ||
| 383 | #endif | ||
| 384 | #ifdef SQLITE_EXTRA_SHUTDOWN | ||
| 385 | "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN), | ||
| 386 | #endif | ||
| 387 | #ifdef SQLITE_FTS3_MAX_EXPR_DEPTH | ||
| 388 | "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH), | ||
| 389 | #endif | ||
| 390 | #if SQLITE_FTS5_ENABLE_TEST_MI | ||
| 391 | "FTS5_ENABLE_TEST_MI", | ||
| 392 | #endif | ||
| 393 | #if SQLITE_FTS5_NO_WITHOUT_ROWID | ||
| 394 | "FTS5_NO_WITHOUT_ROWID", | ||
| 395 | #endif | ||
| 396 | #if HAVE_ISNAN || SQLITE_HAVE_ISNAN | ||
| 397 | "HAVE_ISNAN", | ||
| 398 | #endif | ||
| 399 | #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX | ||
| 400 | # if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1 | ||
| 401 | "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX), | ||
| 402 | # endif | ||
| 403 | #endif | ||
| 404 | #if SQLITE_IGNORE_AFP_LOCK_ERRORS | ||
| 405 | "IGNORE_AFP_LOCK_ERRORS", | ||
| 406 | #endif | ||
| 407 | #if SQLITE_IGNORE_FLOCK_LOCK_ERRORS | ||
| 408 | "IGNORE_FLOCK_LOCK_ERRORS", | ||
| 409 | #endif | ||
| 410 | #if SQLITE_INLINE_MEMCPY | ||
| 411 | "INLINE_MEMCPY", | ||
| 412 | #endif | ||
| 413 | #if SQLITE_INT64_TYPE | ||
| 414 | "INT64_TYPE", | ||
| 415 | #endif | ||
| 416 | #ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX | ||
| 417 | "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX), | ||
| 418 | #endif | ||
| 419 | #if SQLITE_LIKE_DOESNT_MATCH_BLOBS | ||
| 420 | "LIKE_DOESNT_MATCH_BLOBS", | ||
| 421 | #endif | ||
| 422 | #if SQLITE_LOCK_TRACE | ||
| 423 | "LOCK_TRACE", | ||
| 424 | #endif | ||
| 425 | #if SQLITE_LOG_CACHE_SPILL | ||
| 426 | "LOG_CACHE_SPILL", | ||
| 427 | #endif | ||
| 428 | #ifdef SQLITE_MALLOC_SOFT_LIMIT | ||
| 429 | "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT), | ||
| 430 | #endif | ||
| 431 | #ifdef SQLITE_MAX_ATTACHED | ||
| 432 | "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED), | ||
| 433 | #endif | ||
| 434 | #ifdef SQLITE_MAX_COLUMN | ||
| 435 | "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN), | ||
| 436 | #endif | ||
| 437 | #ifdef SQLITE_MAX_COMPOUND_SELECT | ||
| 438 | "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT), | ||
| 439 | #endif | ||
| 440 | #ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE | ||
| 441 | "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE), | ||
| 442 | #endif | ||
| 443 | #ifdef SQLITE_MAX_EXPR_DEPTH | ||
| 444 | "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH), | ||
| 445 | #endif | ||
| 446 | #ifdef SQLITE_MAX_FUNCTION_ARG | ||
| 447 | "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG), | ||
| 448 | #endif | ||
| 449 | #ifdef SQLITE_MAX_LENGTH | ||
| 450 | "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH), | ||
| 451 | #endif | ||
| 452 | #ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH | ||
| 453 | "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH), | ||
| 454 | #endif | ||
| 455 | #ifdef SQLITE_MAX_MEMORY | ||
| 456 | "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY), | ||
| 457 | #endif | ||
| 458 | #ifdef SQLITE_MAX_MMAP_SIZE | ||
| 459 | "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE), | ||
| 460 | #endif | ||
| 461 | #ifdef SQLITE_MAX_MMAP_SIZE_ | ||
| 462 | "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_), | ||
| 463 | #endif | ||
| 464 | #ifdef SQLITE_MAX_PAGE_COUNT | ||
| 465 | "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT), | ||
| 466 | #endif | ||
| 467 | #ifdef SQLITE_MAX_PAGE_SIZE | ||
| 468 | "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE), | ||
| 469 | #endif | ||
| 470 | #ifdef SQLITE_MAX_SCHEMA_RETRY | ||
| 471 | "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY), | ||
| 472 | #endif | ||
| 473 | #ifdef SQLITE_MAX_SQL_LENGTH | ||
| 474 | "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH), | ||
| 475 | #endif | ||
| 476 | #ifdef SQLITE_MAX_TRIGGER_DEPTH | ||
| 477 | "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH), | ||
| 478 | #endif | ||
| 479 | #ifdef SQLITE_MAX_VARIABLE_NUMBER | ||
| 480 | "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER), | ||
| 481 | #endif | ||
| 482 | #ifdef SQLITE_MAX_VDBE_OP | ||
| 483 | "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP), | ||
| 484 | #endif | ||
| 485 | #ifdef SQLITE_MAX_WORKER_THREADS | ||
| 486 | "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS), | ||
| 487 | #endif | ||
| 488 | #if SQLITE_MEMDEBUG | ||
| 489 | "MEMDEBUG", | ||
| 490 | #endif | ||
| 491 | #if SQLITE_MIXED_ENDIAN_64BIT_FLOAT | ||
| 492 | "MIXED_ENDIAN_64BIT_FLOAT", | ||
| 493 | #endif | ||
| 494 | #if SQLITE_MMAP_READWRITE | ||
| 495 | "MMAP_READWRITE", | ||
| 496 | #endif | ||
| 497 | #if SQLITE_MUTEX_NOOP | ||
| 498 | "MUTEX_NOOP", | ||
| 499 | #endif | ||
| 500 | #if SQLITE_MUTEX_OMIT | ||
| 501 | "MUTEX_OMIT", | ||
| 502 | #endif | ||
| 503 | #if SQLITE_MUTEX_PTHREADS | ||
| 504 | "MUTEX_PTHREADS", | ||
| 505 | #endif | ||
| 506 | #if SQLITE_MUTEX_W32 | ||
| 507 | "MUTEX_W32", | ||
| 508 | #endif | ||
| 509 | #if SQLITE_NEED_ERR_NAME | ||
| 510 | "NEED_ERR_NAME", | ||
| 511 | #endif | ||
| 512 | #if SQLITE_NOINLINE | ||
| 513 | "NOINLINE", | ||
| 514 | #endif | ||
| 515 | #if SQLITE_NO_SYNC | ||
| 516 | "NO_SYNC", | ||
| 517 | #endif | ||
| 518 | #if SQLITE_OMIT_ALTERTABLE | ||
| 519 | "OMIT_ALTERTABLE", | ||
| 520 | #endif | ||
| 521 | #if SQLITE_OMIT_ANALYZE | ||
| 522 | "OMIT_ANALYZE", | ||
| 523 | #endif | ||
| 524 | #if SQLITE_OMIT_ATTACH | ||
| 525 | "OMIT_ATTACH", | ||
| 526 | #endif | ||
| 527 | #if SQLITE_OMIT_AUTHORIZATION | ||
| 528 | "OMIT_AUTHORIZATION", | ||
| 529 | #endif | ||
| 530 | #if SQLITE_OMIT_AUTOINCREMENT | ||
| 531 | "OMIT_AUTOINCREMENT", | ||
| 532 | #endif | ||
| 533 | #if SQLITE_OMIT_AUTOINIT | ||
| 534 | "OMIT_AUTOINIT", | ||
| 535 | #endif | ||
| 536 | #if SQLITE_OMIT_AUTOMATIC_INDEX | ||
| 537 | "OMIT_AUTOMATIC_INDEX", | ||
| 538 | #endif | ||
| 539 | #if SQLITE_OMIT_AUTORESET | ||
| 540 | "OMIT_AUTORESET", | ||
| 541 | #endif | ||
| 542 | #if SQLITE_OMIT_AUTOVACUUM | ||
| 543 | "OMIT_AUTOVACUUM", | ||
| 544 | #endif | ||
| 545 | #if SQLITE_OMIT_BETWEEN_OPTIMIZATION | ||
| 546 | "OMIT_BETWEEN_OPTIMIZATION", | ||
| 547 | #endif | ||
| 548 | #if SQLITE_OMIT_BLOB_LITERAL | ||
| 549 | "OMIT_BLOB_LITERAL", | ||
| 550 | #endif | ||
| 551 | #if SQLITE_OMIT_CAST | ||
| 552 | "OMIT_CAST", | ||
| 553 | #endif | ||
| 554 | #if SQLITE_OMIT_CHECK | ||
| 555 | "OMIT_CHECK", | ||
| 556 | #endif | ||
| 557 | #if SQLITE_OMIT_COMPLETE | ||
| 558 | "OMIT_COMPLETE", | ||
| 559 | #endif | ||
| 560 | #if SQLITE_OMIT_COMPOUND_SELECT | ||
| 561 | "OMIT_COMPOUND_SELECT", | ||
| 562 | #endif | ||
| 563 | #if SQLITE_OMIT_CONFLICT_CLAUSE | ||
| 564 | "OMIT_CONFLICT_CLAUSE", | ||
| 565 | #endif | ||
| 566 | #if SQLITE_OMIT_CTE | ||
| 567 | "OMIT_CTE", | ||
| 568 | #endif | ||
| 569 | #if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT) | ||
| 570 | "OMIT_DATETIME_FUNCS", | ||
| 571 | #endif | ||
| 572 | #if SQLITE_OMIT_DECLTYPE | ||
| 573 | "OMIT_DECLTYPE", | ||
| 574 | #endif | ||
| 575 | #if SQLITE_OMIT_DEPRECATED | ||
| 576 | "OMIT_DEPRECATED", | ||
| 577 | #endif | ||
| 578 | #if SQLITE_OMIT_DESERIALIZE | ||
| 579 | "OMIT_DESERIALIZE", | ||
| 580 | #endif | ||
| 581 | #if SQLITE_OMIT_DISKIO | ||
| 582 | "OMIT_DISKIO", | ||
| 583 | #endif | ||
| 584 | #if SQLITE_OMIT_EXPLAIN | ||
| 585 | "OMIT_EXPLAIN", | ||
| 586 | #endif | ||
| 587 | #if SQLITE_OMIT_FLAG_PRAGMAS | ||
| 588 | "OMIT_FLAG_PRAGMAS", | ||
| 589 | #endif | ||
| 590 | #if SQLITE_OMIT_FLOATING_POINT | ||
| 591 | "OMIT_FLOATING_POINT", | ||
| 592 | #endif | ||
| 593 | #if SQLITE_OMIT_FOREIGN_KEY | ||
| 594 | "OMIT_FOREIGN_KEY", | ||
| 595 | #endif | ||
| 596 | #if SQLITE_OMIT_GET_TABLE | ||
| 597 | "OMIT_GET_TABLE", | ||
| 598 | #endif | ||
| 599 | #if SQLITE_OMIT_HEX_INTEGER | ||
| 600 | "OMIT_HEX_INTEGER", | ||
| 601 | #endif | ||
| 602 | #if SQLITE_OMIT_INCRBLOB | ||
| 603 | "OMIT_INCRBLOB", | ||
| 604 | #endif | ||
| 605 | #if SQLITE_OMIT_INTEGRITY_CHECK | ||
| 606 | "OMIT_INTEGRITY_CHECK", | ||
| 607 | #endif | ||
| 608 | #if SQLITE_OMIT_INTROSPECTION_PRAGMAS | ||
| 609 | "OMIT_INTROSPECTION_PRAGMAS", | ||
| 610 | #endif | ||
| 611 | #if SQLITE_OMIT_LIKE_OPTIMIZATION | ||
| 612 | "OMIT_LIKE_OPTIMIZATION", | ||
| 613 | #endif | ||
| 614 | #if SQLITE_OMIT_LOAD_EXTENSION | ||
| 615 | "OMIT_LOAD_EXTENSION", | ||
| 616 | #endif | ||
| 617 | #if SQLITE_OMIT_LOCALTIME | ||
| 618 | "OMIT_LOCALTIME", | ||
| 619 | #endif | ||
| 620 | #if SQLITE_OMIT_LOOKASIDE | ||
| 621 | "OMIT_LOOKASIDE", | ||
| 622 | #endif | ||
| 623 | #if SQLITE_OMIT_MEMORYDB | ||
| 624 | "OMIT_MEMORYDB", | ||
| 625 | #endif | ||
| 626 | #if SQLITE_OMIT_OR_OPTIMIZATION | ||
| 627 | "OMIT_OR_OPTIMIZATION", | ||
| 628 | #endif | ||
| 629 | #if SQLITE_OMIT_PAGER_PRAGMAS | ||
| 630 | "OMIT_PAGER_PRAGMAS", | ||
| 631 | #endif | ||
| 632 | #if SQLITE_OMIT_PARSER_TRACE | ||
| 633 | "OMIT_PARSER_TRACE", | ||
| 634 | #endif | ||
| 635 | #if SQLITE_OMIT_POPEN | ||
| 636 | "OMIT_POPEN", | ||
| 637 | #endif | ||
| 638 | #if SQLITE_OMIT_PRAGMA | ||
| 639 | "OMIT_PRAGMA", | ||
| 640 | #endif | ||
| 641 | #if SQLITE_OMIT_PROGRESS_CALLBACK | ||
| 642 | "OMIT_PROGRESS_CALLBACK", | ||
| 643 | #endif | ||
| 644 | #if SQLITE_OMIT_QUICKBALANCE | ||
| 645 | "OMIT_QUICKBALANCE", | ||
| 646 | #endif | ||
| 647 | #if SQLITE_OMIT_REINDEX | ||
| 648 | "OMIT_REINDEX", | ||
| 649 | #endif | ||
| 650 | #if SQLITE_OMIT_SCHEMA_PRAGMAS | ||
| 651 | "OMIT_SCHEMA_PRAGMAS", | ||
| 652 | #endif | ||
| 653 | #if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS | ||
| 654 | "OMIT_SCHEMA_VERSION_PRAGMAS", | ||
| 655 | #endif | ||
| 656 | #if SQLITE_OMIT_SHARED_CACHE | ||
| 657 | "OMIT_SHARED_CACHE", | ||
| 658 | #endif | ||
| 659 | #if SQLITE_OMIT_SHUTDOWN_DIRECTORIES | ||
| 660 | "OMIT_SHUTDOWN_DIRECTORIES", | ||
| 661 | #endif | ||
| 662 | #if SQLITE_OMIT_SUBQUERY | ||
| 663 | "OMIT_SUBQUERY", | ||
| 664 | #endif | ||
| 665 | #if SQLITE_OMIT_TCL_VARIABLE | ||
| 666 | "OMIT_TCL_VARIABLE", | ||
| 667 | #endif | ||
| 668 | #if SQLITE_OMIT_TEMPDB | ||
| 669 | "OMIT_TEMPDB", | ||
| 670 | #endif | ||
| 671 | #if SQLITE_OMIT_TEST_CONTROL | ||
| 672 | "OMIT_TEST_CONTROL", | ||
| 673 | #endif | ||
| 674 | #ifdef SQLITE_OMIT_TRACE | ||
| 675 | # if SQLITE_OMIT_TRACE != 1 | ||
| 676 | "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE), | ||
| 677 | # endif | ||
| 678 | #endif | ||
| 679 | #if SQLITE_OMIT_TRIGGER | ||
| 680 | "OMIT_TRIGGER", | ||
| 681 | #endif | ||
| 682 | #if SQLITE_OMIT_TRUNCATE_OPTIMIZATION | ||
| 683 | "OMIT_TRUNCATE_OPTIMIZATION", | ||
| 684 | #endif | ||
| 685 | #if SQLITE_OMIT_UTF16 | ||
| 686 | "OMIT_UTF16", | ||
| 687 | #endif | ||
| 688 | #if SQLITE_OMIT_VACUUM | ||
| 689 | "OMIT_VACUUM", | ||
| 690 | #endif | ||
| 691 | #if SQLITE_OMIT_VIEW | ||
| 692 | "OMIT_VIEW", | ||
| 693 | #endif | ||
| 694 | #if SQLITE_OMIT_VIRTUALTABLE | ||
| 695 | "OMIT_VIRTUALTABLE", | ||
| 696 | #endif | ||
| 697 | #if SQLITE_OMIT_WAL | ||
| 698 | "OMIT_WAL", | ||
| 699 | #endif | ||
| 700 | #if SQLITE_OMIT_WSD | ||
| 701 | "OMIT_WSD", | ||
| 702 | #endif | ||
| 703 | #if SQLITE_OMIT_XFER_OPT | ||
| 704 | "OMIT_XFER_OPT", | ||
| 705 | #endif | ||
| 706 | #if SQLITE_PCACHE_SEPARATE_HEADER | ||
| 707 | "PCACHE_SEPARATE_HEADER", | ||
| 708 | #endif | ||
| 709 | #if SQLITE_PERFORMANCE_TRACE | ||
| 710 | "PERFORMANCE_TRACE", | ||
| 711 | #endif | ||
| 712 | #ifdef SQLITE_POWERSAFE_OVERWRITE | ||
| 713 | # if SQLITE_POWERSAFE_OVERWRITE != 1 | ||
| 714 | "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE), | ||
| 715 | # endif | ||
| 716 | #endif | ||
| 717 | #if SQLITE_PREFER_PROXY_LOCKING | ||
| 718 | "PREFER_PROXY_LOCKING", | ||
| 719 | #endif | ||
| 720 | #if SQLITE_PROXY_DEBUG | ||
| 721 | "PROXY_DEBUG", | ||
| 722 | #endif | ||
| 723 | #if SQLITE_REVERSE_UNORDERED_SELECTS | ||
| 724 | "REVERSE_UNORDERED_SELECTS", | ||
| 725 | #endif | ||
| 726 | #if SQLITE_RTREE_INT_ONLY | ||
| 727 | "RTREE_INT_ONLY", | ||
| 728 | #endif | ||
| 729 | #if SQLITE_SECURE_DELETE | ||
| 730 | "SECURE_DELETE", | ||
| 731 | #endif | ||
| 732 | #if SQLITE_SMALL_STACK | ||
| 733 | "SMALL_STACK", | ||
| 734 | #endif | ||
| 735 | #ifdef SQLITE_SORTER_PMASZ | ||
| 736 | "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ), | ||
| 737 | #endif | ||
| 738 | #if SQLITE_SOUNDEX | ||
| 739 | "SOUNDEX", | ||
| 740 | #endif | ||
| 741 | #ifdef SQLITE_STAT4_SAMPLES | ||
| 742 | "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES), | ||
| 743 | #endif | ||
| 744 | #ifdef SQLITE_STMTJRNL_SPILL | ||
| 745 | "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL), | ||
| 746 | #endif | ||
| 747 | #if SQLITE_SUBSTR_COMPATIBILITY | ||
| 748 | "SUBSTR_COMPATIBILITY", | ||
| 749 | #endif | ||
| 750 | #if (!defined(SQLITE_WIN32_MALLOC) \ | ||
| 751 | && !defined(SQLITE_ZERO_MALLOC) \ | ||
| 752 | && !defined(SQLITE_MEMDEBUG) \ | ||
| 753 | ) || defined(SQLITE_SYSTEM_MALLOC) | ||
| 754 | "SYSTEM_MALLOC", | ||
| 755 | #endif | ||
| 756 | #if SQLITE_TCL | ||
| 757 | "TCL", | ||
| 758 | #endif | ||
| 759 | #ifdef SQLITE_TEMP_STORE | ||
| 760 | "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE), | ||
| 761 | #endif | ||
| 762 | #if SQLITE_TEST | ||
| 763 | "TEST", | ||
| 764 | #endif | ||
| 765 | #if defined(SQLITE_THREADSAFE) | ||
| 766 | "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE), | ||
| 767 | #elif defined(THREADSAFE) | ||
| 768 | "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE), | ||
| 769 | #else | ||
| 770 | "THREADSAFE=1", | ||
| 771 | #endif | ||
| 772 | #if SQLITE_UNLINK_AFTER_CLOSE | ||
| 773 | "UNLINK_AFTER_CLOSE", | ||
| 774 | #endif | ||
| 775 | #if SQLITE_UNTESTABLE | ||
| 776 | "UNTESTABLE", | ||
| 777 | #endif | ||
| 778 | #if SQLITE_USER_AUTHENTICATION | ||
| 779 | "USER_AUTHENTICATION", | ||
| 780 | #endif | ||
| 781 | #if SQLITE_USE_ALLOCA | ||
| 782 | "USE_ALLOCA", | ||
| 783 | #endif | ||
| 784 | #if SQLITE_USE_FCNTL_TRACE | ||
| 785 | "USE_FCNTL_TRACE", | ||
| 786 | #endif | ||
| 787 | #if SQLITE_USE_URI | ||
| 788 | "USE_URI", | ||
| 789 | #endif | ||
| 790 | #if SQLITE_VDBE_COVERAGE | ||
| 791 | "VDBE_COVERAGE", | ||
| 792 | #endif | ||
| 793 | #if SQLITE_WIN32_MALLOC | ||
| 794 | "WIN32_MALLOC", | ||
| 795 | #endif | ||
| 796 | #if SQLITE_ZERO_MALLOC | ||
| 797 | "ZERO_MALLOC", | ||
| 798 | #endif | ||
| 799 | /* | ||
| 800 | ** END CODE GENERATED BY tool/mkctime.tcl | ||
| 801 | */ | ||
| 802 | }; | ||
| 803 | |||
| 804 | SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){ | ||
| 805 | *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]); | ||
| 806 | return (const char**)sqlite3azCompileOpt; | ||
| 807 | } | ||
| 808 | |||
| 809 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ | ||
| 810 | |||
| 811 | /************** End of ctime.c ***********************************************/ | ||
| 812 | /************** Begin file sqliteInt.h ***************************************/ | 25 | /************** Begin file sqliteInt.h ***************************************/ |
| 813 | /* | 26 | /* |
| 814 | ** 2001 September 15 | 27 | ** 2001 September 15 |
| @@ -1074,6 +287,17 @@ SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){ | |||
| 1074 | # define _USE_32BIT_TIME_T | 287 | # define _USE_32BIT_TIME_T |
| 1075 | #endif | 288 | #endif |
| 1076 | 289 | ||
| 290 | /* Optionally #include a user-defined header, whereby compilation options | ||
| 291 | ** may be set prior to where they take effect, but after platform setup. | ||
| 292 | ** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include | ||
| 293 | ** file. | ||
| 294 | */ | ||
| 295 | #ifdef SQLITE_CUSTOM_INCLUDE | ||
| 296 | # define INC_STRINGIFY_(f) #f | ||
| 297 | # define INC_STRINGIFY(f) INC_STRINGIFY_(f) | ||
| 298 | # include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE) | ||
| 299 | #endif | ||
| 300 | |||
| 1077 | /* The public SQLite interface. The _FILE_OFFSET_BITS macro must appear | 301 | /* The public SQLite interface. The _FILE_OFFSET_BITS macro must appear |
| 1078 | ** first in QNX. Also, the _USE_32BIT_TIME_T macro must appear first for | 302 | ** first in QNX. Also, the _USE_32BIT_TIME_T macro must appear first for |
| 1079 | ** MinGW. | 303 | ** MinGW. |
| @@ -1125,7 +349,30 @@ extern "C" { | |||
| 1125 | 349 | ||
| 1126 | 350 | ||
| 1127 | /* | 351 | /* |
| 1128 | ** Provide the ability to override linkage features of the interface. | 352 | ** Facilitate override of interface linkage and calling conventions. |
| 353 | ** Be aware that these macros may not be used within this particular | ||
| 354 | ** translation of the amalgamation and its associated header file. | ||
| 355 | ** | ||
| 356 | ** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the | ||
| 357 | ** compiler that the target identifier should have external linkage. | ||
| 358 | ** | ||
| 359 | ** The SQLITE_CDECL macro is used to set the calling convention for | ||
| 360 | ** public functions that accept a variable number of arguments. | ||
| 361 | ** | ||
| 362 | ** The SQLITE_APICALL macro is used to set the calling convention for | ||
| 363 | ** public functions that accept a fixed number of arguments. | ||
| 364 | ** | ||
| 365 | ** The SQLITE_STDCALL macro is no longer used and is now deprecated. | ||
| 366 | ** | ||
| 367 | ** The SQLITE_CALLBACK macro is used to set the calling convention for | ||
| 368 | ** function pointers. | ||
| 369 | ** | ||
| 370 | ** The SQLITE_SYSAPI macro is used to set the calling convention for | ||
| 371 | ** functions provided by the operating system. | ||
| 372 | ** | ||
| 373 | ** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and | ||
| 374 | ** SQLITE_SYSAPI macros are used only when building for environments | ||
| 375 | ** that require non-default calling conventions. | ||
| 1129 | */ | 376 | */ |
| 1130 | #ifndef SQLITE_EXTERN | 377 | #ifndef SQLITE_EXTERN |
| 1131 | # define SQLITE_EXTERN extern | 378 | # define SQLITE_EXTERN extern |
| @@ -1205,9 +452,9 @@ extern "C" { | |||
| 1205 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 452 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 1206 | ** [sqlite_version()] and [sqlite_source_id()]. | 453 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 1207 | */ | 454 | */ |
| 1208 | #define SQLITE_VERSION "3.36.0" | 455 | #define SQLITE_VERSION "3.37.1" |
| 1209 | #define SQLITE_VERSION_NUMBER 3036000 | 456 | #define SQLITE_VERSION_NUMBER 3037001 |
| 1210 | #define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5" | 457 | #define SQLITE_SOURCE_ID "2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62" |
| 1211 | 458 | ||
| 1212 | /* | 459 | /* |
| 1213 | ** CAPI3REF: Run-Time Library Version Numbers | 460 | ** CAPI3REF: Run-Time Library Version Numbers |
| @@ -1619,6 +866,7 @@ SQLITE_API int sqlite3_exec( | |||
| 1619 | #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) | 866 | #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) |
| 1620 | #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) | 867 | #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) |
| 1621 | #define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8)) | 868 | #define SQLITE_CONSTRAINT_PINNED (SQLITE_CONSTRAINT |(11<<8)) |
| 869 | #define SQLITE_CONSTRAINT_DATATYPE (SQLITE_CONSTRAINT |(12<<8)) | ||
| 1622 | #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) | 870 | #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) |
| 1623 | #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) | 871 | #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) |
| 1624 | #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) | 872 | #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) |
| @@ -1632,6 +880,19 @@ SQLITE_API int sqlite3_exec( | |||
| 1632 | ** These bit values are intended for use in the | 880 | ** These bit values are intended for use in the |
| 1633 | ** 3rd parameter to the [sqlite3_open_v2()] interface and | 881 | ** 3rd parameter to the [sqlite3_open_v2()] interface and |
| 1634 | ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. | 882 | ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. |
| 883 | ** | ||
| 884 | ** Only those flags marked as "Ok for sqlite3_open_v2()" may be | ||
| 885 | ** used as the third argument to the [sqlite3_open_v2()] interface. | ||
| 886 | ** The other flags have historically been ignored by sqlite3_open_v2(), | ||
| 887 | ** though future versions of SQLite might change so that an error is | ||
| 888 | ** raised if any of the disallowed bits are passed into sqlite3_open_v2(). | ||
| 889 | ** Applications should not depend on the historical behavior. | ||
| 890 | ** | ||
| 891 | ** Note in particular that passing the SQLITE_OPEN_EXCLUSIVE flag into | ||
| 892 | ** [sqlite3_open_v2()] does *not* cause the underlying database file | ||
| 893 | ** to be opened using O_EXCL. Passing SQLITE_OPEN_EXCLUSIVE into | ||
| 894 | ** [sqlite3_open_v2()] has historically be a no-op and might become an | ||
| 895 | ** error in future versions of SQLite. | ||
| 1635 | */ | 896 | */ |
| 1636 | #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ | 897 | #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ |
| 1637 | #define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ | 898 | #define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ |
| @@ -1654,6 +915,7 @@ SQLITE_API int sqlite3_exec( | |||
| 1654 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ | 915 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 1655 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ | 916 | #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */ |
| 1656 | #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ | 917 | #define SQLITE_OPEN_NOFOLLOW 0x01000000 /* Ok for sqlite3_open_v2() */ |
| 918 | #define SQLITE_OPEN_EXRESCODE 0x02000000 /* Extended result codes */ | ||
| 1657 | 919 | ||
| 1658 | /* Reserved: 0x00F00000 */ | 920 | /* Reserved: 0x00F00000 */ |
| 1659 | /* Legacy compatibility: */ | 921 | /* Legacy compatibility: */ |
| @@ -3546,11 +2808,14 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64); | |||
| 3546 | ** CAPI3REF: Count The Number Of Rows Modified | 2808 | ** CAPI3REF: Count The Number Of Rows Modified |
| 3547 | ** METHOD: sqlite3 | 2809 | ** METHOD: sqlite3 |
| 3548 | ** | 2810 | ** |
| 3549 | ** ^This function returns the number of rows modified, inserted or | 2811 | ** ^These functions return the number of rows modified, inserted or |
| 3550 | ** deleted by the most recently completed INSERT, UPDATE or DELETE | 2812 | ** deleted by the most recently completed INSERT, UPDATE or DELETE |
| 3551 | ** statement on the database connection specified by the only parameter. | 2813 | ** statement on the database connection specified by the only parameter. |
| 3552 | ** ^Executing any other type of SQL statement does not modify the value | 2814 | ** The two functions are identical except for the type of the return value |
| 3553 | ** returned by this function. | 2815 | ** and that if the number of rows modified by the most recent INSERT, UPDATE |
| 2816 | ** or DELETE is greater than the maximum value supported by type "int", then | ||
| 2817 | ** the return value of sqlite3_changes() is undefined. ^Executing any other | ||
| 2818 | ** type of SQL statement does not modify the value returned by these functions. | ||
| 3554 | ** | 2819 | ** |
| 3555 | ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are | 2820 | ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are |
| 3556 | ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], | 2821 | ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers], |
| @@ -3599,16 +2864,21 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3*,sqlite3_int64); | |||
| 3599 | ** </ul> | 2864 | ** </ul> |
| 3600 | */ | 2865 | */ |
| 3601 | SQLITE_API int sqlite3_changes(sqlite3*); | 2866 | SQLITE_API int sqlite3_changes(sqlite3*); |
| 2867 | SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*); | ||
| 3602 | 2868 | ||
| 3603 | /* | 2869 | /* |
| 3604 | ** CAPI3REF: Total Number Of Rows Modified | 2870 | ** CAPI3REF: Total Number Of Rows Modified |
| 3605 | ** METHOD: sqlite3 | 2871 | ** METHOD: sqlite3 |
| 3606 | ** | 2872 | ** |
| 3607 | ** ^This function returns the total number of rows inserted, modified or | 2873 | ** ^These functions return the total number of rows inserted, modified or |
| 3608 | ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed | 2874 | ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed |
| 3609 | ** since the database connection was opened, including those executed as | 2875 | ** since the database connection was opened, including those executed as |
| 3610 | ** part of trigger programs. ^Executing any other type of SQL statement | 2876 | ** part of trigger programs. The two functions are identical except for the |
| 3611 | ** does not affect the value returned by sqlite3_total_changes(). | 2877 | ** type of the return value and that if the number of rows modified by the |
| 2878 | ** connection exceeds the maximum value supported by type "int", then | ||
| 2879 | ** the return value of sqlite3_total_changes() is undefined. ^Executing | ||
| 2880 | ** any other type of SQL statement does not affect the value returned by | ||
| 2881 | ** sqlite3_total_changes(). | ||
| 3612 | ** | 2882 | ** |
| 3613 | ** ^Changes made as part of [foreign key actions] are included in the | 2883 | ** ^Changes made as part of [foreign key actions] are included in the |
| 3614 | ** count, but those made as part of REPLACE constraint resolution are | 2884 | ** count, but those made as part of REPLACE constraint resolution are |
| @@ -3636,6 +2906,7 @@ SQLITE_API int sqlite3_changes(sqlite3*); | |||
| 3636 | ** </ul> | 2906 | ** </ul> |
| 3637 | */ | 2907 | */ |
| 3638 | SQLITE_API int sqlite3_total_changes(sqlite3*); | 2908 | SQLITE_API int sqlite3_total_changes(sqlite3*); |
| 2909 | SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*); | ||
| 3639 | 2910 | ||
| 3640 | /* | 2911 | /* |
| 3641 | ** CAPI3REF: Interrupt A Long-Running Query | 2912 | ** CAPI3REF: Interrupt A Long-Running Query |
| @@ -4465,6 +3736,14 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); | |||
| 4465 | ** the default shared cache setting provided by | 3736 | ** the default shared cache setting provided by |
| 4466 | ** [sqlite3_enable_shared_cache()].)^ | 3737 | ** [sqlite3_enable_shared_cache()].)^ |
| 4467 | ** | 3738 | ** |
| 3739 | ** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> | ||
| 3740 | ** <dd>The database connection comes up in "extended result code mode". | ||
| 3741 | ** In other words, the database behaves has if | ||
| 3742 | ** [sqlite3_extended_result_codes(db,1)] where called on the database | ||
| 3743 | ** connection as soon as the connection is created. In addition to setting | ||
| 3744 | ** the extended result code mode, this flag also causes [sqlite3_open_v2()] | ||
| 3745 | ** to return an extended result code.</dd> | ||
| 3746 | ** | ||
| 4468 | ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> | 3747 | ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt> |
| 4469 | ** <dd>The database filename is not allowed to be a symbolic link</dd> | 3748 | ** <dd>The database filename is not allowed to be a symbolic link</dd> |
| 4470 | ** </dl>)^ | 3749 | ** </dl>)^ |
| @@ -4472,7 +3751,15 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); | |||
| 4472 | ** If the 3rd parameter to sqlite3_open_v2() is not one of the | 3751 | ** If the 3rd parameter to sqlite3_open_v2() is not one of the |
| 4473 | ** required combinations shown above optionally combined with other | 3752 | ** required combinations shown above optionally combined with other |
| 4474 | ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] | 3753 | ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits] |
| 4475 | ** then the behavior is undefined. | 3754 | ** then the behavior is undefined. Historic versions of SQLite |
| 3755 | ** have silently ignored surplus bits in the flags parameter to | ||
| 3756 | ** sqlite3_open_v2(), however that behavior might not be carried through | ||
| 3757 | ** into future versions of SQLite and so applications should not rely | ||
| 3758 | ** upon it. Note in particular that the SQLITE_OPEN_EXCLUSIVE flag is a no-op | ||
| 3759 | ** for sqlite3_open_v2(). The SQLITE_OPEN_EXCLUSIVE does *not* cause | ||
| 3760 | ** the open to fail if the database already exists. The SQLITE_OPEN_EXCLUSIVE | ||
| 3761 | ** flag is intended for use by the [sqlite3_vfs|VFS interface] only, and not | ||
| 3762 | ** by sqlite3_open_v2(). | ||
| 4476 | ** | 3763 | ** |
| 4477 | ** ^The fourth parameter to sqlite3_open_v2() is the name of the | 3764 | ** ^The fourth parameter to sqlite3_open_v2() is the name of the |
| 4478 | ** [sqlite3_vfs] object that defines the operating system interface that | 3765 | ** [sqlite3_vfs] object that defines the operating system interface that |
| @@ -5240,12 +4527,17 @@ SQLITE_API int sqlite3_prepare16_v3( | |||
| 5240 | ** are managed by SQLite and are automatically freed when the prepared | 4527 | ** are managed by SQLite and are automatically freed when the prepared |
| 5241 | ** statement is finalized. | 4528 | ** statement is finalized. |
| 5242 | ** ^The string returned by sqlite3_expanded_sql(P), on the other hand, | 4529 | ** ^The string returned by sqlite3_expanded_sql(P), on the other hand, |
| 5243 | ** is obtained from [sqlite3_malloc()] and must be free by the application | 4530 | ** is obtained from [sqlite3_malloc()] and must be freed by the application |
| 5244 | ** by passing it to [sqlite3_free()]. | 4531 | ** by passing it to [sqlite3_free()]. |
| 4532 | ** | ||
| 4533 | ** ^The sqlite3_normalized_sql() interface is only available if | ||
| 4534 | ** the [SQLITE_ENABLE_NORMALIZE] compile-time option is defined. | ||
| 5245 | */ | 4535 | */ |
| 5246 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); | 4536 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 5247 | SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt); | 4537 | SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt); |
| 4538 | #ifdef SQLITE_ENABLE_NORMALIZE | ||
| 5248 | SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt); | 4539 | SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt); |
| 4540 | #endif | ||
| 5249 | 4541 | ||
| 5250 | /* | 4542 | /* |
| 5251 | ** CAPI3REF: Determine If An SQL Statement Writes The Database | 4543 | ** CAPI3REF: Determine If An SQL Statement Writes The Database |
| @@ -7430,6 +6722,72 @@ SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); | |||
| 7430 | SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); | 6722 | SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); |
| 7431 | 6723 | ||
| 7432 | /* | 6724 | /* |
| 6725 | ** CAPI3REF: Autovacuum Compaction Amount Callback | ||
| 6726 | ** METHOD: sqlite3 | ||
| 6727 | ** | ||
| 6728 | ** ^The sqlite3_autovacuum_pages(D,C,P,X) interface registers a callback | ||
| 6729 | ** function C that is invoked prior to each autovacuum of the database | ||
| 6730 | ** file. ^The callback is passed a copy of the generic data pointer (P), | ||
| 6731 | ** the schema-name of the attached database that is being autovacuumed, | ||
| 6732 | ** the the size of the database file in pages, the number of free pages, | ||
| 6733 | ** and the number of bytes per page, respectively. The callback should | ||
| 6734 | ** return the number of free pages that should be removed by the | ||
| 6735 | ** autovacuum. ^If the callback returns zero, then no autovacuum happens. | ||
| 6736 | ** ^If the value returned is greater than or equal to the number of | ||
| 6737 | ** free pages, then a complete autovacuum happens. | ||
| 6738 | ** | ||
| 6739 | ** <p>^If there are multiple ATTACH-ed database files that are being | ||
| 6740 | ** modified as part of a transaction commit, then the autovacuum pages | ||
| 6741 | ** callback is invoked separately for each file. | ||
| 6742 | ** | ||
| 6743 | ** <p><b>The callback is not reentrant.</b> The callback function should | ||
| 6744 | ** not attempt to invoke any other SQLite interface. If it does, bad | ||
| 6745 | ** things may happen, including segmentation faults and corrupt database | ||
| 6746 | ** files. The callback function should be a simple function that | ||
| 6747 | ** does some arithmetic on its input parameters and returns a result. | ||
| 6748 | ** | ||
| 6749 | ** ^The X parameter to sqlite3_autovacuum_pages(D,C,P,X) is an optional | ||
| 6750 | ** destructor for the P parameter. ^If X is not NULL, then X(P) is | ||
| 6751 | ** invoked whenever the database connection closes or when the callback | ||
| 6752 | ** is overwritten by another invocation of sqlite3_autovacuum_pages(). | ||
| 6753 | ** | ||
| 6754 | ** <p>^There is only one autovacuum pages callback per database connection. | ||
| 6755 | ** ^Each call to the sqlite3_autovacuum_pages() interface overrides all | ||
| 6756 | ** previous invocations for that database connection. ^If the callback | ||
| 6757 | ** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer, | ||
| 6758 | ** then the autovacuum steps callback is cancelled. The return value | ||
| 6759 | ** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might | ||
| 6760 | ** be some other error code if something goes wrong. The current | ||
| 6761 | ** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other | ||
| 6762 | ** return codes might be added in future releases. | ||
| 6763 | ** | ||
| 6764 | ** <p>If no autovacuum pages callback is specified (the usual case) or | ||
| 6765 | ** a NULL pointer is provided for the callback, | ||
| 6766 | ** then the default behavior is to vacuum all free pages. So, in other | ||
| 6767 | ** words, the default behavior is the same as if the callback function | ||
| 6768 | ** were something like this: | ||
| 6769 | ** | ||
| 6770 | ** <blockquote><pre> | ||
| 6771 | ** unsigned int demonstration_autovac_pages_callback( | ||
| 6772 | ** void *pClientData, | ||
| 6773 | ** const char *zSchema, | ||
| 6774 | ** unsigned int nDbPage, | ||
| 6775 | ** unsigned int nFreePage, | ||
| 6776 | ** unsigned int nBytePerPage | ||
| 6777 | ** ){ | ||
| 6778 | ** return nFreePage; | ||
| 6779 | ** } | ||
| 6780 | ** </pre></blockquote> | ||
| 6781 | */ | ||
| 6782 | SQLITE_API int sqlite3_autovacuum_pages( | ||
| 6783 | sqlite3 *db, | ||
| 6784 | unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int), | ||
| 6785 | void*, | ||
| 6786 | void(*)(void*) | ||
| 6787 | ); | ||
| 6788 | |||
| 6789 | |||
| 6790 | /* | ||
| 7433 | ** CAPI3REF: Data Change Notification Callbacks | 6791 | ** CAPI3REF: Data Change Notification Callbacks |
| 7434 | ** METHOD: sqlite3 | 6792 | ** METHOD: sqlite3 |
| 7435 | ** | 6793 | ** |
| @@ -10092,8 +9450,9 @@ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...); | |||
| 10092 | ** | 9450 | ** |
| 10093 | ** A single database handle may have at most a single write-ahead log callback | 9451 | ** A single database handle may have at most a single write-ahead log callback |
| 10094 | ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any | 9452 | ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any |
| 10095 | ** previously registered write-ahead log callback. ^Note that the | 9453 | ** previously registered write-ahead log callback. ^The return value is |
| 10096 | ** [sqlite3_wal_autocheckpoint()] interface and the | 9454 | ** a copy of the third parameter from the previous call, if any, or 0. |
| 9455 | ** ^Note that the [sqlite3_wal_autocheckpoint()] interface and the | ||
| 10097 | ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will | 9456 | ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will |
| 10098 | ** overwrite any prior [sqlite3_wal_hook()] settings. | 9457 | ** overwrite any prior [sqlite3_wal_hook()] settings. |
| 10099 | */ | 9458 | */ |
| @@ -10960,6 +10319,10 @@ SQLITE_API unsigned char *sqlite3_serialize( | |||
| 10960 | ** database is currently in a read transaction or is involved in a backup | 10319 | ** database is currently in a read transaction or is involved in a backup |
| 10961 | ** operation. | 10320 | ** operation. |
| 10962 | ** | 10321 | ** |
| 10322 | ** It is not possible to deserialized into the TEMP database. If the | ||
| 10323 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the | ||
| 10324 | ** function returns SQLITE_ERROR. | ||
| 10325 | ** | ||
| 10963 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the | 10326 | ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the |
| 10964 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then | 10327 | ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then |
| 10965 | ** [sqlite3_free()] is invoked on argument P prior to returning. | 10328 | ** [sqlite3_free()] is invoked on argument P prior to returning. |
| @@ -13442,7 +12805,7 @@ struct fts5_api { | |||
| 13442 | ** autoconf-based build | 12805 | ** autoconf-based build |
| 13443 | */ | 12806 | */ |
| 13444 | #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H) | 12807 | #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H) |
| 13445 | /* #include "config.h" */ | 12808 | #include "config.h" |
| 13446 | #define SQLITECONFIG_H 1 | 12809 | #define SQLITECONFIG_H 1 |
| 13447 | #endif | 12810 | #endif |
| 13448 | 12811 | ||
| @@ -13678,11 +13041,12 @@ struct fts5_api { | |||
| 13678 | #ifndef __has_extension | 13041 | #ifndef __has_extension |
| 13679 | # define __has_extension(x) 0 /* compatibility with non-clang compilers */ | 13042 | # define __has_extension(x) 0 /* compatibility with non-clang compilers */ |
| 13680 | #endif | 13043 | #endif |
| 13681 | #if GCC_VERSION>=4007000 || \ | 13044 | #if GCC_VERSION>=4007000 || __has_extension(c_atomic) |
| 13682 | (__has_extension(c_atomic) && __has_extension(c_atomic_store_n)) | 13045 | # define SQLITE_ATOMIC_INTRINSICS 1 |
| 13683 | # define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED) | 13046 | # define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED) |
| 13684 | # define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED) | 13047 | # define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED) |
| 13685 | #else | 13048 | #else |
| 13049 | # define SQLITE_ATOMIC_INTRINSICS 0 | ||
| 13686 | # define AtomicLoad(PTR) (*(PTR)) | 13050 | # define AtomicLoad(PTR) (*(PTR)) |
| 13687 | # define AtomicStore(PTR,VAL) (*(PTR) = (VAL)) | 13051 | # define AtomicStore(PTR,VAL) (*(PTR) = (VAL)) |
| 13688 | #endif | 13052 | #endif |
| @@ -13887,11 +13251,12 @@ struct fts5_api { | |||
| 13887 | ** is significant and used at least once. On switch statements | 13251 | ** is significant and used at least once. On switch statements |
| 13888 | ** where multiple cases go to the same block of code, testcase() | 13252 | ** where multiple cases go to the same block of code, testcase() |
| 13889 | ** can insure that all cases are evaluated. | 13253 | ** can insure that all cases are evaluated. |
| 13890 | ** | ||
| 13891 | */ | 13254 | */ |
| 13892 | #ifdef SQLITE_COVERAGE_TEST | 13255 | #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG) |
| 13893 | SQLITE_PRIVATE void sqlite3Coverage(int); | 13256 | # ifndef SQLITE_AMALGAMATION |
| 13894 | # define testcase(X) if( X ){ sqlite3Coverage(__LINE__); } | 13257 | extern unsigned int sqlite3CoverageCounter; |
| 13258 | # endif | ||
| 13259 | # define testcase(X) if( X ){ sqlite3CoverageCounter += (unsigned)__LINE__; } | ||
| 13895 | #else | 13260 | #else |
| 13896 | # define testcase(X) | 13261 | # define testcase(X) |
| 13897 | #endif | 13262 | #endif |
| @@ -13922,6 +13287,14 @@ SQLITE_PRIVATE void sqlite3Coverage(int); | |||
| 13922 | #endif | 13287 | #endif |
| 13923 | 13288 | ||
| 13924 | /* | 13289 | /* |
| 13290 | ** Disable ALWAYS() and NEVER() (make them pass-throughs) for coverage | ||
| 13291 | ** and mutation testing | ||
| 13292 | */ | ||
| 13293 | #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST) | ||
| 13294 | # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1 | ||
| 13295 | #endif | ||
| 13296 | |||
| 13297 | /* | ||
| 13925 | ** The ALWAYS and NEVER macros surround boolean expressions which | 13298 | ** The ALWAYS and NEVER macros surround boolean expressions which |
| 13926 | ** are intended to always be true or false, respectively. Such | 13299 | ** are intended to always be true or false, respectively. Such |
| 13927 | ** expressions could be omitted from the code completely. But they | 13300 | ** expressions could be omitted from the code completely. But they |
| @@ -13936,7 +13309,7 @@ SQLITE_PRIVATE void sqlite3Coverage(int); | |||
| 13936 | ** be true and false so that the unreachable code they specify will | 13309 | ** be true and false so that the unreachable code they specify will |
| 13937 | ** not be counted as untested code. | 13310 | ** not be counted as untested code. |
| 13938 | */ | 13311 | */ |
| 13939 | #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST) | 13312 | #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS) |
| 13940 | # define ALWAYS(X) (1) | 13313 | # define ALWAYS(X) (1) |
| 13941 | # define NEVER(X) (0) | 13314 | # define NEVER(X) (0) |
| 13942 | #elif !defined(NDEBUG) | 13315 | #elif !defined(NDEBUG) |
| @@ -13948,26 +13321,6 @@ SQLITE_PRIVATE void sqlite3Coverage(int); | |||
| 13948 | #endif | 13321 | #endif |
| 13949 | 13322 | ||
| 13950 | /* | 13323 | /* |
| 13951 | ** The harmless(X) macro indicates that expression X is usually false | ||
| 13952 | ** but can be true without causing any problems, but we don't know of | ||
| 13953 | ** any way to cause X to be true. | ||
| 13954 | ** | ||
| 13955 | ** In debugging and testing builds, this macro will abort if X is ever | ||
| 13956 | ** true. In this way, developers are alerted to a possible test case | ||
| 13957 | ** that causes X to be true. If a harmless macro ever fails, that is | ||
| 13958 | ** an opportunity to change the macro into a testcase() and add a new | ||
| 13959 | ** test case to the test suite. | ||
| 13960 | ** | ||
| 13961 | ** For normal production builds, harmless(X) is a no-op, since it does | ||
| 13962 | ** not matter whether expression X is true or false. | ||
| 13963 | */ | ||
| 13964 | #ifdef SQLITE_DEBUG | ||
| 13965 | # define harmless(X) assert(!(X)); | ||
| 13966 | #else | ||
| 13967 | # define harmless(X) | ||
| 13968 | #endif | ||
| 13969 | |||
| 13970 | /* | ||
| 13971 | ** Some conditionals are optimizations only. In other words, if the | 13324 | ** Some conditionals are optimizations only. In other words, if the |
| 13972 | ** conditionals are replaced with a constant 1 (true) or 0 (false) then | 13325 | ** conditionals are replaced with a constant 1 (true) or 0 (false) then |
| 13973 | ** the correct answer is still obtained, though perhaps not as quickly. | 13326 | ** the correct answer is still obtained, though perhaps not as quickly. |
| @@ -14031,6 +13384,13 @@ SQLITE_PRIVATE void sqlite3Coverage(int); | |||
| 14031 | #endif | 13384 | #endif |
| 14032 | 13385 | ||
| 14033 | /* | 13386 | /* |
| 13387 | ** SQLITE_OMIT_VIRTUALTABLE implies SQLITE_OMIT_ALTERTABLE | ||
| 13388 | */ | ||
| 13389 | #if defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_ALTERTABLE) | ||
| 13390 | # define SQLITE_OMIT_ALTERTABLE | ||
| 13391 | #endif | ||
| 13392 | |||
| 13393 | /* | ||
| 14034 | ** Return true (non-zero) if the input is an integer that is too large | 13394 | ** Return true (non-zero) if the input is an integer that is too large |
| 14035 | ** to fit in 32-bits. This macro is used inside of various testcase() | 13395 | ** to fit in 32-bits. This macro is used inside of various testcase() |
| 14036 | ** macros to verify that we have tested SQLite for large-file support. | 13396 | ** macros to verify that we have tested SQLite for large-file support. |
| @@ -14142,7 +13502,7 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*); | |||
| 14142 | /* | 13502 | /* |
| 14143 | ** Number of entries in a hash table | 13503 | ** Number of entries in a hash table |
| 14144 | */ | 13504 | */ |
| 14145 | /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ | 13505 | #define sqliteHashCount(H) ((H)->count) |
| 14146 | 13506 | ||
| 14147 | #endif /* SQLITE_HASH_H */ | 13507 | #endif /* SQLITE_HASH_H */ |
| 14148 | 13508 | ||
| @@ -14174,8 +13534,8 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*); | |||
| 14174 | #define TK_LP 22 | 13534 | #define TK_LP 22 |
| 14175 | #define TK_RP 23 | 13535 | #define TK_RP 23 |
| 14176 | #define TK_AS 24 | 13536 | #define TK_AS 24 |
| 14177 | #define TK_WITHOUT 25 | 13537 | #define TK_COMMA 25 |
| 14178 | #define TK_COMMA 26 | 13538 | #define TK_WITHOUT 26 |
| 14179 | #define TK_ABORT 27 | 13539 | #define TK_ABORT 27 |
| 14180 | #define TK_ACTION 28 | 13540 | #define TK_ACTION 28 |
| 14181 | #define TK_AFTER 29 | 13541 | #define TK_AFTER 29 |
| @@ -14438,7 +13798,7 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*); | |||
| 14438 | ** number of pages. A negative number N translations means that a buffer | 13798 | ** number of pages. A negative number N translations means that a buffer |
| 14439 | ** of -1024*N bytes is allocated and used for as many pages as it will hold. | 13799 | ** of -1024*N bytes is allocated and used for as many pages as it will hold. |
| 14440 | ** | 13800 | ** |
| 14441 | ** The default value of "20" was choosen to minimize the run-time of the | 13801 | ** The default value of "20" was chosen to minimize the run-time of the |
| 14442 | ** speedtest1 test program with options: --shrink-memory --reprepare | 13802 | ** speedtest1 test program with options: --shrink-memory --reprepare |
| 14443 | */ | 13803 | */ |
| 14444 | #ifndef SQLITE_DEFAULT_PCACHE_INITSZ | 13804 | #ifndef SQLITE_DEFAULT_PCACHE_INITSZ |
| @@ -14600,6 +13960,7 @@ typedef INT16_TYPE LogEst; | |||
| 14600 | # define SQLITE_PTRSIZE __SIZEOF_POINTER__ | 13960 | # define SQLITE_PTRSIZE __SIZEOF_POINTER__ |
| 14601 | # elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ | 13961 | # elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \ |
| 14602 | defined(_M_ARM) || defined(__arm__) || defined(__x86) || \ | 13962 | defined(_M_ARM) || defined(__arm__) || defined(__x86) || \ |
| 13963 | (defined(__APPLE__) && defined(__POWERPC__)) || \ | ||
| 14603 | (defined(__TOS_AIX__) && !defined(__64BIT__)) | 13964 | (defined(__TOS_AIX__) && !defined(__64BIT__)) |
| 14604 | # define SQLITE_PTRSIZE 4 | 13965 | # define SQLITE_PTRSIZE 4 |
| 14605 | # else | 13966 | # else |
| @@ -14794,11 +14155,25 @@ struct BusyHandler { | |||
| 14794 | 14155 | ||
| 14795 | /* | 14156 | /* |
| 14796 | ** Name of table that holds the database schema. | 14157 | ** Name of table that holds the database schema. |
| 14158 | ** | ||
| 14159 | ** The PREFERRED names are used whereever possible. But LEGACY is also | ||
| 14160 | ** used for backwards compatibility. | ||
| 14161 | ** | ||
| 14162 | ** 1. Queries can use either the PREFERRED or the LEGACY names | ||
| 14163 | ** 2. The sqlite3_set_authorizer() callback uses the LEGACY name | ||
| 14164 | ** 3. The PRAGMA table_list statement uses the PREFERRED name | ||
| 14165 | ** | ||
| 14166 | ** The LEGACY names are stored in the internal symbol hash table | ||
| 14167 | ** in support of (2). Names are translated using sqlite3PreferredTableName() | ||
| 14168 | ** for (3). The sqlite3FindTable() function takes care of translating | ||
| 14169 | ** names for (1). | ||
| 14170 | ** | ||
| 14171 | ** Note that "sqlite_temp_schema" can also be called "temp.sqlite_schema". | ||
| 14797 | */ | 14172 | */ |
| 14798 | #define DFLT_SCHEMA_TABLE "sqlite_master" | 14173 | #define LEGACY_SCHEMA_TABLE "sqlite_master" |
| 14799 | #define DFLT_TEMP_SCHEMA_TABLE "sqlite_temp_master" | 14174 | #define LEGACY_TEMP_SCHEMA_TABLE "sqlite_temp_master" |
| 14800 | #define ALT_SCHEMA_TABLE "sqlite_schema" | 14175 | #define PREFERRED_SCHEMA_TABLE "sqlite_schema" |
| 14801 | #define ALT_TEMP_SCHEMA_TABLE "sqlite_temp_schema" | 14176 | #define PREFERRED_TEMP_SCHEMA_TABLE "sqlite_temp_schema" |
| 14802 | 14177 | ||
| 14803 | 14178 | ||
| 14804 | /* | 14179 | /* |
| @@ -14810,7 +14185,7 @@ struct BusyHandler { | |||
| 14810 | ** The name of the schema table. The name is different for TEMP. | 14185 | ** The name of the schema table. The name is different for TEMP. |
| 14811 | */ | 14186 | */ |
| 14812 | #define SCHEMA_TABLE(x) \ | 14187 | #define SCHEMA_TABLE(x) \ |
| 14813 | ((!OMIT_TEMPDB)&&(x==1)?DFLT_TEMP_SCHEMA_TABLE:DFLT_SCHEMA_TABLE) | 14188 | ((!OMIT_TEMPDB)&&(x==1)?LEGACY_TEMP_SCHEMA_TABLE:LEGACY_SCHEMA_TABLE) |
| 14814 | 14189 | ||
| 14815 | /* | 14190 | /* |
| 14816 | ** A convenience macro that returns the number of elements in | 14191 | ** A convenience macro that returns the number of elements in |
| @@ -15351,7 +14726,7 @@ SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *); | |||
| 15351 | #define BTREE_BLOBKEY 2 /* Table has keys only - no data */ | 14726 | #define BTREE_BLOBKEY 2 /* Table has keys only - no data */ |
| 15352 | 14727 | ||
| 15353 | SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*); | 14728 | SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*); |
| 15354 | SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*); | 14729 | SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, i64*); |
| 15355 | SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*); | 14730 | SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*); |
| 15356 | SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int); | 14731 | SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int); |
| 15357 | 14732 | ||
| @@ -15475,13 +14850,17 @@ SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...); | |||
| 15475 | #endif | 14850 | #endif |
| 15476 | 14851 | ||
| 15477 | SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*); | 14852 | SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*); |
| 15478 | SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( | 14853 | SQLITE_PRIVATE int sqlite3BtreeTableMoveto( |
| 15479 | BtCursor*, | 14854 | BtCursor*, |
| 15480 | UnpackedRecord *pUnKey, | ||
| 15481 | i64 intKey, | 14855 | i64 intKey, |
| 15482 | int bias, | 14856 | int bias, |
| 15483 | int *pRes | 14857 | int *pRes |
| 15484 | ); | 14858 | ); |
| 14859 | SQLITE_PRIVATE int sqlite3BtreeIndexMoveto( | ||
| 14860 | BtCursor*, | ||
| 14861 | UnpackedRecord *pUnKey, | ||
| 14862 | int *pRes | ||
| 14863 | ); | ||
| 15485 | SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*); | 14864 | SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*); |
| 15486 | SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*); | 14865 | SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*); |
| 15487 | SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags); | 14866 | SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags); |
| @@ -15832,35 +15211,35 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 15832 | #define OP_If 18 /* jump */ | 15211 | #define OP_If 18 /* jump */ |
| 15833 | #define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */ | 15212 | #define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */ |
| 15834 | #define OP_IfNot 20 /* jump */ | 15213 | #define OP_IfNot 20 /* jump */ |
| 15835 | #define OP_IfNullRow 21 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */ | 15214 | #define OP_IsNullOrType 21 /* jump, synopsis: if typeof(r[P1]) IN (P3,5) goto P2 */ |
| 15836 | #define OP_SeekLT 22 /* jump, synopsis: key=r[P3@P4] */ | 15215 | #define OP_IfNullRow 22 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */ |
| 15837 | #define OP_SeekLE 23 /* jump, synopsis: key=r[P3@P4] */ | 15216 | #define OP_SeekLT 23 /* jump, synopsis: key=r[P3@P4] */ |
| 15838 | #define OP_SeekGE 24 /* jump, synopsis: key=r[P3@P4] */ | 15217 | #define OP_SeekLE 24 /* jump, synopsis: key=r[P3@P4] */ |
| 15839 | #define OP_SeekGT 25 /* jump, synopsis: key=r[P3@P4] */ | 15218 | #define OP_SeekGE 25 /* jump, synopsis: key=r[P3@P4] */ |
| 15840 | #define OP_IfNotOpen 26 /* jump, synopsis: if( !csr[P1] ) goto P2 */ | 15219 | #define OP_SeekGT 26 /* jump, synopsis: key=r[P3@P4] */ |
| 15841 | #define OP_IfNoHope 27 /* jump, synopsis: key=r[P3@P4] */ | 15220 | #define OP_IfNotOpen 27 /* jump, synopsis: if( !csr[P1] ) goto P2 */ |
| 15842 | #define OP_NoConflict 28 /* jump, synopsis: key=r[P3@P4] */ | 15221 | #define OP_IfNoHope 28 /* jump, synopsis: key=r[P3@P4] */ |
| 15843 | #define OP_NotFound 29 /* jump, synopsis: key=r[P3@P4] */ | 15222 | #define OP_NoConflict 29 /* jump, synopsis: key=r[P3@P4] */ |
| 15844 | #define OP_Found 30 /* jump, synopsis: key=r[P3@P4] */ | 15223 | #define OP_NotFound 30 /* jump, synopsis: key=r[P3@P4] */ |
| 15845 | #define OP_SeekRowid 31 /* jump, synopsis: intkey=r[P3] */ | 15224 | #define OP_Found 31 /* jump, synopsis: key=r[P3@P4] */ |
| 15846 | #define OP_NotExists 32 /* jump, synopsis: intkey=r[P3] */ | 15225 | #define OP_SeekRowid 32 /* jump, synopsis: intkey=r[P3] */ |
| 15847 | #define OP_Last 33 /* jump */ | 15226 | #define OP_NotExists 33 /* jump, synopsis: intkey=r[P3] */ |
| 15848 | #define OP_IfSmaller 34 /* jump */ | 15227 | #define OP_Last 34 /* jump */ |
| 15849 | #define OP_SorterSort 35 /* jump */ | 15228 | #define OP_IfSmaller 35 /* jump */ |
| 15850 | #define OP_Sort 36 /* jump */ | 15229 | #define OP_SorterSort 36 /* jump */ |
| 15851 | #define OP_Rewind 37 /* jump */ | 15230 | #define OP_Sort 37 /* jump */ |
| 15852 | #define OP_IdxLE 38 /* jump, synopsis: key=r[P3@P4] */ | 15231 | #define OP_Rewind 38 /* jump */ |
| 15853 | #define OP_IdxGT 39 /* jump, synopsis: key=r[P3@P4] */ | 15232 | #define OP_IdxLE 39 /* jump, synopsis: key=r[P3@P4] */ |
| 15854 | #define OP_IdxLT 40 /* jump, synopsis: key=r[P3@P4] */ | 15233 | #define OP_IdxGT 40 /* jump, synopsis: key=r[P3@P4] */ |
| 15855 | #define OP_IdxGE 41 /* jump, synopsis: key=r[P3@P4] */ | 15234 | #define OP_IdxLT 41 /* jump, synopsis: key=r[P3@P4] */ |
| 15856 | #define OP_RowSetRead 42 /* jump, synopsis: r[P3]=rowset(P1) */ | 15235 | #define OP_IdxGE 42 /* jump, synopsis: key=r[P3@P4] */ |
| 15857 | #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ | 15236 | #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 15858 | #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ | 15237 | #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 15859 | #define OP_RowSetTest 45 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ | 15238 | #define OP_RowSetRead 45 /* jump, synopsis: r[P3]=rowset(P1) */ |
| 15860 | #define OP_Program 46 /* jump */ | 15239 | #define OP_RowSetTest 46 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ |
| 15861 | #define OP_FkIfZero 47 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ | 15240 | #define OP_Program 47 /* jump */ |
| 15862 | #define OP_IfPos 48 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ | 15241 | #define OP_FkIfZero 48 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ |
| 15863 | #define OP_IfNotZero 49 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ | 15242 | #define OP_IfPos 49 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ |
| 15864 | #define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ | 15243 | #define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 15865 | #define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ | 15244 | #define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 15866 | #define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */ | 15245 | #define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| @@ -15870,49 +15249,49 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 15870 | #define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ | 15249 | #define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 15871 | #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ | 15250 | #define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 15872 | #define OP_ElseEq 58 /* jump, same as TK_ESCAPE */ | 15251 | #define OP_ElseEq 58 /* jump, same as TK_ESCAPE */ |
| 15873 | #define OP_DecrJumpZero 59 /* jump, synopsis: if (--r[P1])==0 goto P2 */ | 15252 | #define OP_IfNotZero 59 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ |
| 15874 | #define OP_IncrVacuum 60 /* jump */ | 15253 | #define OP_DecrJumpZero 60 /* jump, synopsis: if (--r[P1])==0 goto P2 */ |
| 15875 | #define OP_VNext 61 /* jump */ | 15254 | #define OP_IncrVacuum 61 /* jump */ |
| 15876 | #define OP_Init 62 /* jump, synopsis: Start at P2 */ | 15255 | #define OP_VNext 62 /* jump */ |
| 15877 | #define OP_PureFunc 63 /* synopsis: r[P3]=func(r[P2@NP]) */ | 15256 | #define OP_Init 63 /* jump, synopsis: Start at P2 */ |
| 15878 | #define OP_Function 64 /* synopsis: r[P3]=func(r[P2@NP]) */ | 15257 | #define OP_PureFunc 64 /* synopsis: r[P3]=func(r[P2@NP]) */ |
| 15879 | #define OP_Return 65 | 15258 | #define OP_Function 65 /* synopsis: r[P3]=func(r[P2@NP]) */ |
| 15880 | #define OP_EndCoroutine 66 | 15259 | #define OP_Return 66 |
| 15881 | #define OP_HaltIfNull 67 /* synopsis: if r[P3]=null halt */ | 15260 | #define OP_EndCoroutine 67 |
| 15882 | #define OP_Halt 68 | 15261 | #define OP_HaltIfNull 68 /* synopsis: if r[P3]=null halt */ |
| 15883 | #define OP_Integer 69 /* synopsis: r[P2]=P1 */ | 15262 | #define OP_Halt 69 |
| 15884 | #define OP_Int64 70 /* synopsis: r[P2]=P4 */ | 15263 | #define OP_Integer 70 /* synopsis: r[P2]=P1 */ |
| 15885 | #define OP_String 71 /* synopsis: r[P2]='P4' (len=P1) */ | 15264 | #define OP_Int64 71 /* synopsis: r[P2]=P4 */ |
| 15886 | #define OP_Null 72 /* synopsis: r[P2..P3]=NULL */ | 15265 | #define OP_String 72 /* synopsis: r[P2]='P4' (len=P1) */ |
| 15887 | #define OP_SoftNull 73 /* synopsis: r[P1]=NULL */ | 15266 | #define OP_Null 73 /* synopsis: r[P2..P3]=NULL */ |
| 15888 | #define OP_Blob 74 /* synopsis: r[P2]=P4 (len=P1) */ | 15267 | #define OP_SoftNull 74 /* synopsis: r[P1]=NULL */ |
| 15889 | #define OP_Variable 75 /* synopsis: r[P2]=parameter(P1,P4) */ | 15268 | #define OP_Blob 75 /* synopsis: r[P2]=P4 (len=P1) */ |
| 15890 | #define OP_Move 76 /* synopsis: r[P2@P3]=r[P1@P3] */ | 15269 | #define OP_Variable 76 /* synopsis: r[P2]=parameter(P1,P4) */ |
| 15891 | #define OP_Copy 77 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ | 15270 | #define OP_Move 77 /* synopsis: r[P2@P3]=r[P1@P3] */ |
| 15892 | #define OP_SCopy 78 /* synopsis: r[P2]=r[P1] */ | 15271 | #define OP_Copy 78 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ |
| 15893 | #define OP_IntCopy 79 /* synopsis: r[P2]=r[P1] */ | 15272 | #define OP_SCopy 79 /* synopsis: r[P2]=r[P1] */ |
| 15894 | #define OP_ChngCntRow 80 /* synopsis: output=r[P1] */ | 15273 | #define OP_IntCopy 80 /* synopsis: r[P2]=r[P1] */ |
| 15895 | #define OP_ResultRow 81 /* synopsis: output=r[P1@P2] */ | 15274 | #define OP_ChngCntRow 81 /* synopsis: output=r[P1] */ |
| 15896 | #define OP_CollSeq 82 | 15275 | #define OP_ResultRow 82 /* synopsis: output=r[P1@P2] */ |
| 15897 | #define OP_AddImm 83 /* synopsis: r[P1]=r[P1]+P2 */ | 15276 | #define OP_CollSeq 83 |
| 15898 | #define OP_RealAffinity 84 | 15277 | #define OP_AddImm 84 /* synopsis: r[P1]=r[P1]+P2 */ |
| 15899 | #define OP_Cast 85 /* synopsis: affinity(r[P1]) */ | 15278 | #define OP_RealAffinity 85 |
| 15900 | #define OP_Permutation 86 | 15279 | #define OP_Cast 86 /* synopsis: affinity(r[P1]) */ |
| 15901 | #define OP_Compare 87 /* synopsis: r[P1@P3] <-> r[P2@P3] */ | 15280 | #define OP_Permutation 87 |
| 15902 | #define OP_IsTrue 88 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ | 15281 | #define OP_Compare 88 /* synopsis: r[P1@P3] <-> r[P2@P3] */ |
| 15903 | #define OP_ZeroOrNull 89 /* synopsis: r[P2] = 0 OR NULL */ | 15282 | #define OP_IsTrue 89 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ |
| 15904 | #define OP_Offset 90 /* synopsis: r[P3] = sqlite_offset(P1) */ | 15283 | #define OP_ZeroOrNull 90 /* synopsis: r[P2] = 0 OR NULL */ |
| 15905 | #define OP_Column 91 /* synopsis: r[P3]=PX */ | 15284 | #define OP_Offset 91 /* synopsis: r[P3] = sqlite_offset(P1) */ |
| 15906 | #define OP_Affinity 92 /* synopsis: affinity(r[P1@P2]) */ | 15285 | #define OP_Column 92 /* synopsis: r[P3]=PX */ |
| 15907 | #define OP_MakeRecord 93 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ | 15286 | #define OP_TypeCheck 93 /* synopsis: typecheck(r[P1@P2]) */ |
| 15908 | #define OP_Count 94 /* synopsis: r[P2]=count() */ | 15287 | #define OP_Affinity 94 /* synopsis: affinity(r[P1@P2]) */ |
| 15909 | #define OP_ReadCookie 95 | 15288 | #define OP_MakeRecord 95 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ |
| 15910 | #define OP_SetCookie 96 | 15289 | #define OP_Count 96 /* synopsis: r[P2]=count() */ |
| 15911 | #define OP_ReopenIdx 97 /* synopsis: root=P2 iDb=P3 */ | 15290 | #define OP_ReadCookie 97 |
| 15912 | #define OP_OpenRead 98 /* synopsis: root=P2 iDb=P3 */ | 15291 | #define OP_SetCookie 98 |
| 15913 | #define OP_OpenWrite 99 /* synopsis: root=P2 iDb=P3 */ | 15292 | #define OP_ReopenIdx 99 /* synopsis: root=P2 iDb=P3 */ |
| 15914 | #define OP_OpenDup 100 | 15293 | #define OP_OpenRead 100 /* synopsis: root=P2 iDb=P3 */ |
| 15915 | #define OP_OpenAutoindex 101 /* synopsis: nColumn=P2 */ | 15294 | #define OP_OpenWrite 101 /* synopsis: root=P2 iDb=P3 */ |
| 15916 | #define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ | 15295 | #define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 15917 | #define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ | 15296 | #define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 15918 | #define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ | 15297 | #define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| @@ -15923,74 +15302,76 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 15923 | #define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ | 15302 | #define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 15924 | #define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ | 15303 | #define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 15925 | #define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ | 15304 | #define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 15926 | #define OP_OpenEphemeral 112 /* synopsis: nColumn=P2 */ | 15305 | #define OP_OpenDup 112 |
| 15927 | #define OP_BitNot 113 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ | 15306 | #define OP_BitNot 113 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ |
| 15928 | #define OP_SorterOpen 114 | 15307 | #define OP_OpenAutoindex 114 /* synopsis: nColumn=P2 */ |
| 15929 | #define OP_SequenceTest 115 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ | 15308 | #define OP_OpenEphemeral 115 /* synopsis: nColumn=P2 */ |
| 15930 | #define OP_String8 116 /* same as TK_STRING, synopsis: r[P2]='P4' */ | 15309 | #define OP_String8 116 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 15931 | #define OP_OpenPseudo 117 /* synopsis: P3 columns in r[P2] */ | 15310 | #define OP_SorterOpen 117 |
| 15932 | #define OP_Close 118 | 15311 | #define OP_SequenceTest 118 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ |
| 15933 | #define OP_ColumnsUsed 119 | 15312 | #define OP_OpenPseudo 119 /* synopsis: P3 columns in r[P2] */ |
| 15934 | #define OP_SeekScan 120 /* synopsis: Scan-ahead up to P1 rows */ | 15313 | #define OP_Close 120 |
| 15935 | #define OP_SeekHit 121 /* synopsis: set P2<=seekHit<=P3 */ | 15314 | #define OP_ColumnsUsed 121 |
| 15936 | #define OP_Sequence 122 /* synopsis: r[P2]=cursor[P1].ctr++ */ | 15315 | #define OP_SeekScan 122 /* synopsis: Scan-ahead up to P1 rows */ |
| 15937 | #define OP_NewRowid 123 /* synopsis: r[P2]=rowid */ | 15316 | #define OP_SeekHit 123 /* synopsis: set P2<=seekHit<=P3 */ |
| 15938 | #define OP_Insert 124 /* synopsis: intkey=r[P3] data=r[P2] */ | 15317 | #define OP_Sequence 124 /* synopsis: r[P2]=cursor[P1].ctr++ */ |
| 15939 | #define OP_RowCell 125 | 15318 | #define OP_NewRowid 125 /* synopsis: r[P2]=rowid */ |
| 15940 | #define OP_Delete 126 | 15319 | #define OP_Insert 126 /* synopsis: intkey=r[P3] data=r[P2] */ |
| 15941 | #define OP_ResetCount 127 | 15320 | #define OP_RowCell 127 |
| 15942 | #define OP_SorterCompare 128 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ | 15321 | #define OP_Delete 128 |
| 15943 | #define OP_SorterData 129 /* synopsis: r[P2]=data */ | 15322 | #define OP_ResetCount 129 |
| 15944 | #define OP_RowData 130 /* synopsis: r[P2]=data */ | 15323 | #define OP_SorterCompare 130 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ |
| 15945 | #define OP_Rowid 131 /* synopsis: r[P2]=rowid */ | 15324 | #define OP_SorterData 131 /* synopsis: r[P2]=data */ |
| 15946 | #define OP_NullRow 132 | 15325 | #define OP_RowData 132 /* synopsis: r[P2]=data */ |
| 15947 | #define OP_SeekEnd 133 | 15326 | #define OP_Rowid 133 /* synopsis: r[P2]=rowid */ |
| 15948 | #define OP_IdxInsert 134 /* synopsis: key=r[P2] */ | 15327 | #define OP_NullRow 134 |
| 15949 | #define OP_SorterInsert 135 /* synopsis: key=r[P2] */ | 15328 | #define OP_SeekEnd 135 |
| 15950 | #define OP_IdxDelete 136 /* synopsis: key=r[P2@P3] */ | 15329 | #define OP_IdxInsert 136 /* synopsis: key=r[P2] */ |
| 15951 | #define OP_DeferredSeek 137 /* synopsis: Move P3 to P1.rowid if needed */ | 15330 | #define OP_SorterInsert 137 /* synopsis: key=r[P2] */ |
| 15952 | #define OP_IdxRowid 138 /* synopsis: r[P2]=rowid */ | 15331 | #define OP_IdxDelete 138 /* synopsis: key=r[P2@P3] */ |
| 15953 | #define OP_FinishSeek 139 | 15332 | #define OP_DeferredSeek 139 /* synopsis: Move P3 to P1.rowid if needed */ |
| 15954 | #define OP_Destroy 140 | 15333 | #define OP_IdxRowid 140 /* synopsis: r[P2]=rowid */ |
| 15955 | #define OP_Clear 141 | 15334 | #define OP_FinishSeek 141 |
| 15956 | #define OP_ResetSorter 142 | 15335 | #define OP_Destroy 142 |
| 15957 | #define OP_CreateBtree 143 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ | 15336 | #define OP_Clear 143 |
| 15958 | #define OP_SqlExec 144 | 15337 | #define OP_ResetSorter 144 |
| 15959 | #define OP_ParseSchema 145 | 15338 | #define OP_CreateBtree 145 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ |
| 15960 | #define OP_LoadAnalysis 146 | 15339 | #define OP_SqlExec 146 |
| 15961 | #define OP_DropTable 147 | 15340 | #define OP_ParseSchema 147 |
| 15962 | #define OP_DropIndex 148 | 15341 | #define OP_LoadAnalysis 148 |
| 15963 | #define OP_DropTrigger 149 | 15342 | #define OP_DropTable 149 |
| 15964 | #define OP_IntegrityCk 150 | 15343 | #define OP_DropIndex 150 |
| 15965 | #define OP_RowSetAdd 151 /* synopsis: rowset(P1)=r[P2] */ | 15344 | #define OP_DropTrigger 151 |
| 15966 | #define OP_Real 152 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ | 15345 | #define OP_Real 152 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 15967 | #define OP_Param 153 | 15346 | #define OP_IntegrityCk 153 |
| 15968 | #define OP_FkCounter 154 /* synopsis: fkctr[P1]+=P2 */ | 15347 | #define OP_RowSetAdd 154 /* synopsis: rowset(P1)=r[P2] */ |
| 15969 | #define OP_MemMax 155 /* synopsis: r[P1]=max(r[P1],r[P2]) */ | 15348 | #define OP_Param 155 |
| 15970 | #define OP_OffsetLimit 156 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ | 15349 | #define OP_FkCounter 156 /* synopsis: fkctr[P1]+=P2 */ |
| 15971 | #define OP_AggInverse 157 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ | 15350 | #define OP_MemMax 157 /* synopsis: r[P1]=max(r[P1],r[P2]) */ |
| 15972 | #define OP_AggStep 158 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | 15351 | #define OP_OffsetLimit 158 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ |
| 15973 | #define OP_AggStep1 159 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | 15352 | #define OP_AggInverse 159 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ |
| 15974 | #define OP_AggValue 160 /* synopsis: r[P3]=value N=P2 */ | 15353 | #define OP_AggStep 160 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 15975 | #define OP_AggFinal 161 /* synopsis: accum=r[P1] N=P2 */ | 15354 | #define OP_AggStep1 161 /* synopsis: accum=r[P3] step(r[P2@P5]) */ |
| 15976 | #define OP_Expire 162 | 15355 | #define OP_AggValue 162 /* synopsis: r[P3]=value N=P2 */ |
| 15977 | #define OP_CursorLock 163 | 15356 | #define OP_AggFinal 163 /* synopsis: accum=r[P1] N=P2 */ |
| 15978 | #define OP_CursorUnlock 164 | 15357 | #define OP_Expire 164 |
| 15979 | #define OP_TableLock 165 /* synopsis: iDb=P1 root=P2 write=P3 */ | 15358 | #define OP_CursorLock 165 |
| 15980 | #define OP_VBegin 166 | 15359 | #define OP_CursorUnlock 166 |
| 15981 | #define OP_VCreate 167 | 15360 | #define OP_TableLock 167 /* synopsis: iDb=P1 root=P2 write=P3 */ |
| 15982 | #define OP_VDestroy 168 | 15361 | #define OP_VBegin 168 |
| 15983 | #define OP_VOpen 169 | 15362 | #define OP_VCreate 169 |
| 15984 | #define OP_VColumn 170 /* synopsis: r[P3]=vcolumn(P2) */ | 15363 | #define OP_VDestroy 170 |
| 15985 | #define OP_VRename 171 | 15364 | #define OP_VOpen 171 |
| 15986 | #define OP_Pagecount 172 | 15365 | #define OP_VColumn 172 /* synopsis: r[P3]=vcolumn(P2) */ |
| 15987 | #define OP_MaxPgcnt 173 | 15366 | #define OP_VRename 173 |
| 15988 | #define OP_Trace 174 | 15367 | #define OP_Pagecount 174 |
| 15989 | #define OP_CursorHint 175 | 15368 | #define OP_MaxPgcnt 175 |
| 15990 | #define OP_ReleaseReg 176 /* synopsis: release r[P1@P2] mask P3 */ | 15369 | #define OP_Trace 176 |
| 15991 | #define OP_Noop 177 | 15370 | #define OP_CursorHint 177 |
| 15992 | #define OP_Explain 178 | 15371 | #define OP_ReleaseReg 178 /* synopsis: release r[P1@P2] mask P3 */ |
| 15993 | #define OP_Abortable 179 | 15372 | #define OP_Noop 179 |
| 15373 | #define OP_Explain 180 | ||
| 15374 | #define OP_Abortable 181 | ||
| 15994 | 15375 | ||
| 15995 | /* Properties such as "out2" or "jump" that are specified in | 15376 | /* Properties such as "out2" or "jump" that are specified in |
| 15996 | ** comments following the "case" for each opcode in the vdbe.c | 15377 | ** comments following the "case" for each opcode in the vdbe.c |
| @@ -16005,27 +15386,27 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 16005 | #define OPFLG_INITIALIZER {\ | 15386 | #define OPFLG_INITIALIZER {\ |
| 16006 | /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\ | 15387 | /* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\ |
| 16007 | /* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\ | 15388 | /* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\ |
| 16008 | /* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\ | 15389 | /* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x03, 0x01, 0x09,\ |
| 16009 | /* 24 */ 0x09, 0x09, 0x01, 0x09, 0x09, 0x09, 0x09, 0x09,\ | 15390 | /* 24 */ 0x09, 0x09, 0x09, 0x01, 0x09, 0x09, 0x09, 0x09,\ |
| 16010 | /* 32 */ 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ | 15391 | /* 32 */ 0x09, 0x09, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\ |
| 16011 | /* 40 */ 0x01, 0x01, 0x23, 0x26, 0x26, 0x0b, 0x01, 0x01,\ | 15392 | /* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\ |
| 16012 | /* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ | 15393 | /* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\ |
| 16013 | /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00,\ | 15394 | /* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\ |
| 16014 | /* 64 */ 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10, 0x10,\ | 15395 | /* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\ |
| 16015 | /* 72 */ 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10,\ | 15396 | /* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\ |
| 16016 | /* 80 */ 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00,\ | 15397 | /* 80 */ 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00,\ |
| 16017 | /* 88 */ 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00, 0x10, 0x10,\ | 15398 | /* 88 */ 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00, 0x00,\ |
| 16018 | /* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26,\ | 15399 | /* 96 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26,\ |
| 16019 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ | 15400 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 16020 | /* 112 */ 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\ | 15401 | /* 112 */ 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\ |
| 16021 | /* 120 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00,\ | 15402 | /* 120 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ |
| 16022 | /* 128 */ 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x04, 0x04,\ | 15403 | /* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\ |
| 16023 | /* 136 */ 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10,\ | 15404 | /* 136 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00,\ |
| 16024 | /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06,\ | 15405 | /* 144 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 16025 | /* 152 */ 0x10, 0x10, 0x00, 0x04, 0x1a, 0x00, 0x00, 0x00,\ | 15406 | /* 152 */ 0x10, 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00,\ |
| 16026 | /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ | 15407 | /* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ |
| 16027 | /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\ | 15408 | /* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\ |
| 16028 | /* 176 */ 0x00, 0x00, 0x00, 0x00,} | 15409 | /* 176 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,} |
| 16029 | 15410 | ||
| 16030 | /* The resolve3P2Values() routine is able to run faster if it knows | 15411 | /* The resolve3P2Values() routine is able to run faster if it knows |
| 16031 | ** the value of the largest JUMP opcode. The smaller the maximum | 15412 | ** the value of the largest JUMP opcode. The smaller the maximum |
| @@ -16033,7 +15414,7 @@ typedef struct VdbeOpList VdbeOpList; | |||
| 16033 | ** generated this include file strives to group all JUMP opcodes | 15414 | ** generated this include file strives to group all JUMP opcodes |
| 16034 | ** together near the beginning of the list. | 15415 | ** together near the beginning of the list. |
| 16035 | */ | 15416 | */ |
| 16036 | #define SQLITE_MX_JUMP_OPCODE 62 /* Maximum JUMP opcode */ | 15417 | #define SQLITE_MX_JUMP_OPCODE 63 /* Maximum JUMP opcode */ |
| 16037 | 15418 | ||
| 16038 | /************** End of opcodes.h *********************************************/ | 15419 | /************** End of opcodes.h *********************************************/ |
| 16039 | /************** Continuing where we left off in vdbe.h ***********************/ | 15420 | /************** Continuing where we left off in vdbe.h ***********************/ |
| @@ -17110,10 +16491,10 @@ struct sqlite3 { | |||
| 17110 | u8 mTrace; /* zero or more SQLITE_TRACE flags */ | 16491 | u8 mTrace; /* zero or more SQLITE_TRACE flags */ |
| 17111 | u8 noSharedCache; /* True if no shared-cache backends */ | 16492 | u8 noSharedCache; /* True if no shared-cache backends */ |
| 17112 | u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */ | 16493 | u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */ |
| 16494 | u8 eOpenState; /* Current condition of the connection */ | ||
| 17113 | int nextPagesize; /* Pagesize after VACUUM if >0 */ | 16495 | int nextPagesize; /* Pagesize after VACUUM if >0 */ |
| 17114 | u32 magic; /* Magic number for detect library misuse */ | 16496 | i64 nChange; /* Value returned by sqlite3_changes() */ |
| 17115 | int nChange; /* Value returned by sqlite3_changes() */ | 16497 | i64 nTotalChange; /* Value returned by sqlite3_total_changes() */ |
| 17116 | int nTotalChange; /* Value returned by sqlite3_total_changes() */ | ||
| 17117 | int aLimit[SQLITE_N_LIMIT]; /* Limits */ | 16498 | int aLimit[SQLITE_N_LIMIT]; /* Limits */ |
| 17118 | int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */ | 16499 | int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */ |
| 17119 | struct sqlite3InitInfo { /* Information used during initialization */ | 16500 | struct sqlite3InitInfo { /* Information used during initialization */ |
| @@ -17123,7 +16504,7 @@ struct sqlite3 { | |||
| 17123 | unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */ | 16504 | unsigned orphanTrigger : 1; /* Last statement is orphaned TEMP trigger */ |
| 17124 | unsigned imposterTable : 1; /* Building an imposter table */ | 16505 | unsigned imposterTable : 1; /* Building an imposter table */ |
| 17125 | unsigned reopenMemdb : 1; /* ATTACH is really a reopen using MemDB */ | 16506 | unsigned reopenMemdb : 1; /* ATTACH is really a reopen using MemDB */ |
| 17126 | char **azInit; /* "type", "name", and "tbl_name" columns */ | 16507 | const char **azInit; /* "type", "name", and "tbl_name" columns */ |
| 17127 | } init; | 16508 | } init; |
| 17128 | int nVdbeActive; /* Number of VDBEs currently running */ | 16509 | int nVdbeActive; /* Number of VDBEs currently running */ |
| 17129 | int nVdbeRead; /* Number of active VDBEs that read or write */ | 16510 | int nVdbeRead; /* Number of active VDBEs that read or write */ |
| @@ -17133,10 +16514,10 @@ struct sqlite3 { | |||
| 17133 | int nExtension; /* Number of loaded extensions */ | 16514 | int nExtension; /* Number of loaded extensions */ |
| 17134 | void **aExtension; /* Array of shared library handles */ | 16515 | void **aExtension; /* Array of shared library handles */ |
| 17135 | union { | 16516 | union { |
| 17136 | void (*xLegacy)(void*,const char*); /* Legacy trace function */ | 16517 | void (*xLegacy)(void*,const char*); /* mTrace==SQLITE_TRACE_LEGACY */ |
| 17137 | int (*xV2)(u32,void*,void*,void*); /* V2 Trace function */ | 16518 | int (*xV2)(u32,void*,void*,void*); /* All other mTrace values */ |
| 17138 | } trace; | 16519 | } trace; |
| 17139 | void *pTraceArg; /* Argument to the trace function */ | 16520 | void *pTraceArg; /* Argument to the trace function */ |
| 17140 | #ifndef SQLITE_OMIT_DEPRECATED | 16521 | #ifndef SQLITE_OMIT_DEPRECATED |
| 17141 | void (*xProfile)(void*,const char*,u64); /* Profiling function */ | 16522 | void (*xProfile)(void*,const char*,u64); /* Profiling function */ |
| 17142 | void *pProfileArg; /* Argument to profile function */ | 16523 | void *pProfileArg; /* Argument to profile function */ |
| @@ -17147,6 +16528,9 @@ struct sqlite3 { | |||
| 17147 | void (*xRollbackCallback)(void*); /* Invoked at every commit. */ | 16528 | void (*xRollbackCallback)(void*); /* Invoked at every commit. */ |
| 17148 | void *pUpdateArg; | 16529 | void *pUpdateArg; |
| 17149 | void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64); | 16530 | void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64); |
| 16531 | void *pAutovacPagesArg; /* Client argument to autovac_pages */ | ||
| 16532 | void (*xAutovacDestr)(void*); /* Destructor for pAutovacPAgesArg */ | ||
| 16533 | unsigned int (*xAutovacPages)(void*,const char*,u32,u32,u32); | ||
| 17150 | Parse *pParse; /* Current parse */ | 16534 | Parse *pParse; /* Current parse */ |
| 17151 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | 16535 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 17152 | void *pPreUpdateArg; /* First argument to xPreUpdateCallback */ | 16536 | void *pPreUpdateArg; /* First argument to xPreUpdateCallback */ |
| @@ -17276,6 +16660,7 @@ struct sqlite3 { | |||
| 17276 | #define SQLITE_CountRows HI(0x00001) /* Count rows changed by INSERT, */ | 16660 | #define SQLITE_CountRows HI(0x00001) /* Count rows changed by INSERT, */ |
| 17277 | /* DELETE, or UPDATE and return */ | 16661 | /* DELETE, or UPDATE and return */ |
| 17278 | /* the count using a callback. */ | 16662 | /* the count using a callback. */ |
| 16663 | #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */ | ||
| 17279 | 16664 | ||
| 17280 | /* Flags used only if debugging */ | 16665 | /* Flags used only if debugging */ |
| 17281 | #ifdef SQLITE_DEBUG | 16666 | #ifdef SQLITE_DEBUG |
| @@ -17322,6 +16707,8 @@ struct sqlite3 { | |||
| 17322 | #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ | 16707 | #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */ |
| 17323 | #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */ | 16708 | #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */ |
| 17324 | #define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */ | 16709 | #define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */ |
| 16710 | #define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */ | ||
| 16711 | /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */ | ||
| 17325 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ | 16712 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ |
| 17326 | 16713 | ||
| 17327 | /* | 16714 | /* |
| @@ -17336,17 +16723,16 @@ struct sqlite3 { | |||
| 17336 | */ | 16723 | */ |
| 17337 | #define ConstFactorOk(P) ((P)->okConstFactor) | 16724 | #define ConstFactorOk(P) ((P)->okConstFactor) |
| 17338 | 16725 | ||
| 17339 | /* | 16726 | /* Possible values for the sqlite3.eOpenState field. |
| 17340 | ** Possible values for the sqlite.magic field. | 16727 | ** The numbers are randomly selected such that a minimum of three bits must |
| 17341 | ** The numbers are obtained at random and have no special meaning, other | 16728 | ** change to convert any number to another or to zero |
| 17342 | ** than being distinct from one another. | ||
| 17343 | */ | 16729 | */ |
| 17344 | #define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ | 16730 | #define SQLITE_STATE_OPEN 0x76 /* Database is open */ |
| 17345 | #define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ | 16731 | #define SQLITE_STATE_CLOSED 0xce /* Database is closed */ |
| 17346 | #define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ | 16732 | #define SQLITE_STATE_SICK 0xba /* Error and awaiting close */ |
| 17347 | #define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ | 16733 | #define SQLITE_STATE_BUSY 0x6d /* Database currently in use */ |
| 17348 | #define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ | 16734 | #define SQLITE_STATE_ERROR 0xd5 /* An SQLITE_MISUSE error occurred */ |
| 17349 | #define SQLITE_MAGIC_ZOMBIE 0x64cffc7f /* Close with last statement close */ | 16735 | #define SQLITE_STATE_ZOMBIE 0xa7 /* Close with last statement close */ |
| 17350 | 16736 | ||
| 17351 | /* | 16737 | /* |
| 17352 | ** Each SQL function is defined by an instance of the following | 16738 | ** Each SQL function is defined by an instance of the following |
| @@ -17371,7 +16757,7 @@ struct FuncDef { | |||
| 17371 | union { | 16757 | union { |
| 17372 | FuncDef *pHash; /* Next with a different name but the same hash */ | 16758 | FuncDef *pHash; /* Next with a different name but the same hash */ |
| 17373 | FuncDestructor *pDestructor; /* Reference counted destructor function */ | 16759 | FuncDestructor *pDestructor; /* Reference counted destructor function */ |
| 17374 | } u; | 16760 | } u; /* pHash if SQLITE_FUNC_BUILTIN, pDestructor otherwise */ |
| 17375 | }; | 16761 | }; |
| 17376 | 16762 | ||
| 17377 | /* | 16763 | /* |
| @@ -17401,12 +16787,13 @@ struct FuncDestructor { | |||
| 17401 | ** are assert() statements in the code to verify this. | 16787 | ** are assert() statements in the code to verify this. |
| 17402 | ** | 16788 | ** |
| 17403 | ** Value constraints (enforced via assert()): | 16789 | ** Value constraints (enforced via assert()): |
| 17404 | ** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg | 16790 | ** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg |
| 17405 | ** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG | 16791 | ** SQLITE_FUNC_ANYORDER == NC_OrderAgg == SF_OrderByReqd |
| 17406 | ** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG | 16792 | ** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG |
| 17407 | ** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API | 16793 | ** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG |
| 17408 | ** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API | 16794 | ** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API |
| 17409 | ** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS | 16795 | ** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API |
| 16796 | ** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS | ||
| 17410 | ** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API | 16797 | ** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API |
| 17411 | */ | 16798 | */ |
| 17412 | #define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */ | 16799 | #define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */ |
| @@ -17431,6 +16818,8 @@ struct FuncDestructor { | |||
| 17431 | #define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */ | 16818 | #define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */ |
| 17432 | #define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */ | 16819 | #define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */ |
| 17433 | #define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */ | 16820 | #define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */ |
| 16821 | #define SQLITE_FUNC_BUILTIN 0x00800000 /* This is a built-in function */ | ||
| 16822 | #define SQLITE_FUNC_ANYORDER 0x08000000 /* count/min/max aggregate */ | ||
| 17434 | 16823 | ||
| 17435 | /* Identifier numbers for each in-line function */ | 16824 | /* Identifier numbers for each in-line function */ |
| 17436 | #define INLINEFUNC_coalesce 0 | 16825 | #define INLINEFUNC_coalesce 0 |
| @@ -17508,44 +16897,51 @@ struct FuncDestructor { | |||
| 17508 | ** parameter. | 16897 | ** parameter. |
| 17509 | */ | 16898 | */ |
| 17510 | #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ | 16899 | #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 17511 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ | 16900 | {nArg, SQLITE_FUNC_BUILTIN|\ |
| 16901 | SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ | ||
| 17512 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } | 16902 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17513 | #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \ | 16903 | #define VFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 17514 | {nArg, SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ | 16904 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 17515 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } | 16905 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17516 | #define SFUNCTION(zName, nArg, iArg, bNC, xFunc) \ | 16906 | #define SFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 17517 | {nArg, SQLITE_UTF8|SQLITE_DIRECTONLY|SQLITE_FUNC_UNSAFE, \ | 16907 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_DIRECTONLY|SQLITE_FUNC_UNSAFE, \ |
| 17518 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } | 16908 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17519 | #define MFUNCTION(zName, nArg, xPtr, xFunc) \ | 16909 | #define MFUNCTION(zName, nArg, xPtr, xFunc) \ |
| 17520 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \ | 16910 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \ |
| 17521 | xPtr, 0, xFunc, 0, 0, 0, #zName, {0} } | 16911 | xPtr, 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17522 | #define INLINE_FUNC(zName, nArg, iArg, mFlags) \ | 16912 | #define INLINE_FUNC(zName, nArg, iArg, mFlags) \ |
| 17523 | {nArg, SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ | 16913 | {nArg, SQLITE_FUNC_BUILTIN|\ |
| 16914 | SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ | ||
| 17524 | SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } | 16915 | SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } |
| 17525 | #define TEST_FUNC(zName, nArg, iArg, mFlags) \ | 16916 | #define TEST_FUNC(zName, nArg, iArg, mFlags) \ |
| 17526 | {nArg, SQLITE_UTF8|SQLITE_FUNC_INTERNAL|SQLITE_FUNC_TEST| \ | 16917 | {nArg, SQLITE_FUNC_BUILTIN|\ |
| 16918 | SQLITE_UTF8|SQLITE_FUNC_INTERNAL|SQLITE_FUNC_TEST| \ | ||
| 17527 | SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ | 16919 | SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \ |
| 17528 | SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } | 16920 | SQLITE_INT_TO_PTR(iArg), 0, noopFunc, 0, 0, 0, #zName, {0} } |
| 17529 | #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ | 16921 | #define DFUNCTION(zName, nArg, iArg, bNC, xFunc) \ |
| 17530 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \ | 16922 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_SLOCHNG|SQLITE_UTF8, \ |
| 17531 | 0, 0, xFunc, 0, 0, 0, #zName, {0} } | 16923 | 0, 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17532 | #define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \ | 16924 | #define PURE_DATE(zName, nArg, iArg, bNC, xFunc) \ |
| 17533 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ | 16925 | {nArg, SQLITE_FUNC_BUILTIN|\ |
| 16926 | SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ | ||
| 17534 | (void*)&sqlite3Config, 0, xFunc, 0, 0, 0, #zName, {0} } | 16927 | (void*)&sqlite3Config, 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17535 | #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ | 16928 | #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \ |
| 17536 | {nArg,SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ | 16929 | {nArg, SQLITE_FUNC_BUILTIN|\ |
| 16930 | SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ | ||
| 17537 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } | 16931 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17538 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ | 16932 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
| 17539 | {nArg, SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ | 16933 | {nArg, SQLITE_FUNC_BUILTIN|\ |
| 16934 | SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ | ||
| 17540 | pArg, 0, xFunc, 0, 0, 0, #zName, } | 16935 | pArg, 0, xFunc, 0, 0, 0, #zName, } |
| 17541 | #define LIKEFUNC(zName, nArg, arg, flags) \ | 16936 | #define LIKEFUNC(zName, nArg, arg, flags) \ |
| 17542 | {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ | 16937 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ |
| 17543 | (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} } | 16938 | (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} } |
| 17544 | #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \ | 16939 | #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \ |
| 17545 | {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \ | 16940 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \ |
| 17546 | SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}} | 16941 | SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}} |
| 17547 | #define INTERNAL_FUNCTION(zName, nArg, xFunc) \ | 16942 | #define INTERNAL_FUNCTION(zName, nArg, xFunc) \ |
| 17548 | {nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ | 16943 | {nArg, SQLITE_FUNC_BUILTIN|\ |
| 16944 | SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \ | ||
| 17549 | 0, 0, xFunc, 0, 0, 0, #zName, {0} } | 16945 | 0, 0, xFunc, 0, 0, 0, #zName, {0} } |
| 17550 | 16946 | ||
| 17551 | 16947 | ||
| @@ -17601,18 +16997,42 @@ struct Module { | |||
| 17601 | ** or equal to the table column index. It is | 16997 | ** or equal to the table column index. It is |
| 17602 | ** equal if and only if there are no VIRTUAL | 16998 | ** equal if and only if there are no VIRTUAL |
| 17603 | ** columns to the left. | 16999 | ** columns to the left. |
| 17000 | ** | ||
| 17001 | ** Notes on zCnName: | ||
| 17002 | ** The zCnName field stores the name of the column, the datatype of the | ||
| 17003 | ** column, and the collating sequence for the column, in that order, all in | ||
| 17004 | ** a single allocation. Each string is 0x00 terminated. The datatype | ||
| 17005 | ** is only included if the COLFLAG_HASTYPE bit of colFlags is set and the | ||
| 17006 | ** collating sequence name is only included if the COLFLAG_HASCOLL bit is | ||
| 17007 | ** set. | ||
| 17604 | */ | 17008 | */ |
| 17605 | struct Column { | 17009 | struct Column { |
| 17606 | char *zName; /* Name of this column, \000, then the type */ | 17010 | char *zCnName; /* Name of this column */ |
| 17607 | Expr *pDflt; /* Default value or GENERATED ALWAYS AS value */ | 17011 | unsigned notNull :4; /* An OE_ code for handling a NOT NULL constraint */ |
| 17608 | char *zColl; /* Collating sequence. If NULL, use the default */ | 17012 | unsigned eCType :4; /* One of the standard types */ |
| 17609 | u8 notNull; /* An OE_ code for handling a NOT NULL constraint */ | 17013 | char affinity; /* One of the SQLITE_AFF_... values */ |
| 17610 | char affinity; /* One of the SQLITE_AFF_... values */ | 17014 | u8 szEst; /* Est size of value in this column. sizeof(INT)==1 */ |
| 17611 | u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */ | 17015 | u8 hName; /* Column name hash for faster lookup */ |
| 17612 | u8 hName; /* Column name hash for faster lookup */ | 17016 | u16 iDflt; /* 1-based index of DEFAULT. 0 means "none" */ |
| 17613 | u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */ | 17017 | u16 colFlags; /* Boolean properties. See COLFLAG_ defines below */ |
| 17614 | }; | 17018 | }; |
| 17615 | 17019 | ||
| 17020 | /* Allowed values for Column.eCType. | ||
| 17021 | ** | ||
| 17022 | ** Values must match entries in the global constant arrays | ||
| 17023 | ** sqlite3StdTypeLen[] and sqlite3StdType[]. Each value is one more | ||
| 17024 | ** than the offset into these arrays for the corresponding name. | ||
| 17025 | ** Adjust the SQLITE_N_STDTYPE value if adding or removing entries. | ||
| 17026 | */ | ||
| 17027 | #define COLTYPE_CUSTOM 0 /* Type appended to zName */ | ||
| 17028 | #define COLTYPE_ANY 1 | ||
| 17029 | #define COLTYPE_BLOB 2 | ||
| 17030 | #define COLTYPE_INT 3 | ||
| 17031 | #define COLTYPE_INTEGER 4 | ||
| 17032 | #define COLTYPE_REAL 5 | ||
| 17033 | #define COLTYPE_TEXT 6 | ||
| 17034 | #define SQLITE_N_STDTYPE 6 /* Number of standard types */ | ||
| 17035 | |||
| 17616 | /* Allowed values for Column.colFlags. | 17036 | /* Allowed values for Column.colFlags. |
| 17617 | ** | 17037 | ** |
| 17618 | ** Constraints: | 17038 | ** Constraints: |
| @@ -17629,6 +17049,7 @@ struct Column { | |||
| 17629 | #define COLFLAG_STORED 0x0040 /* GENERATED ALWAYS AS ... STORED */ | 17049 | #define COLFLAG_STORED 0x0040 /* GENERATED ALWAYS AS ... STORED */ |
| 17630 | #define COLFLAG_NOTAVAIL 0x0080 /* STORED column not yet calculated */ | 17050 | #define COLFLAG_NOTAVAIL 0x0080 /* STORED column not yet calculated */ |
| 17631 | #define COLFLAG_BUSY 0x0100 /* Blocks recursion on GENERATED columns */ | 17051 | #define COLFLAG_BUSY 0x0100 /* Blocks recursion on GENERATED columns */ |
| 17052 | #define COLFLAG_HASCOLL 0x0200 /* Has collating sequence name in zCnName */ | ||
| 17632 | #define COLFLAG_GENERATED 0x0060 /* Combo: _STORED, _VIRTUAL */ | 17053 | #define COLFLAG_GENERATED 0x0060 /* Combo: _STORED, _VIRTUAL */ |
| 17633 | #define COLFLAG_NOINSERT 0x0062 /* Combo: _HIDDEN, _STORED, _VIRTUAL */ | 17054 | #define COLFLAG_NOINSERT 0x0062 /* Combo: _HIDDEN, _STORED, _VIRTUAL */ |
| 17634 | 17055 | ||
| @@ -17758,15 +17179,13 @@ struct VTable { | |||
| 17758 | #define SQLITE_VTABRISK_High 2 | 17179 | #define SQLITE_VTABRISK_High 2 |
| 17759 | 17180 | ||
| 17760 | /* | 17181 | /* |
| 17761 | ** The schema for each SQL table and view is represented in memory | 17182 | ** The schema for each SQL table, virtual table, and view is represented |
| 17762 | ** by an instance of the following structure. | 17183 | ** in memory by an instance of the following structure. |
| 17763 | */ | 17184 | */ |
| 17764 | struct Table { | 17185 | struct Table { |
| 17765 | char *zName; /* Name of the table or view */ | 17186 | char *zName; /* Name of the table or view */ |
| 17766 | Column *aCol; /* Information about each column */ | 17187 | Column *aCol; /* Information about each column */ |
| 17767 | Index *pIndex; /* List of SQL indexes on this table. */ | 17188 | Index *pIndex; /* List of SQL indexes on this table. */ |
| 17768 | Select *pSelect; /* NULL for tables. Points to definition if a view. */ | ||
| 17769 | FKey *pFKey; /* Linked list of all foreign keys in this table */ | ||
| 17770 | char *zColAff; /* String defining the affinity of each column */ | 17189 | char *zColAff; /* String defining the affinity of each column */ |
| 17771 | ExprList *pCheck; /* All CHECK constraints */ | 17190 | ExprList *pCheck; /* All CHECK constraints */ |
| 17772 | /* ... also used as column name list in a VIEW */ | 17191 | /* ... also used as column name list in a VIEW */ |
| @@ -17782,15 +17201,24 @@ struct Table { | |||
| 17782 | LogEst costMult; /* Cost multiplier for using this table */ | 17201 | LogEst costMult; /* Cost multiplier for using this table */ |
| 17783 | #endif | 17202 | #endif |
| 17784 | u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ | 17203 | u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ |
| 17785 | #ifndef SQLITE_OMIT_ALTERTABLE | 17204 | u8 eTabType; /* 0: normal, 1: virtual, 2: view */ |
| 17786 | int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ | 17205 | union { |
| 17787 | #endif | 17206 | struct { /* Used by ordinary tables: */ |
| 17788 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 17207 | int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ |
| 17789 | int nModuleArg; /* Number of arguments to the module */ | 17208 | FKey *pFKey; /* Linked list of all foreign keys in this table */ |
| 17790 | char **azModuleArg; /* 0: module 1: schema 2: vtab name 3...: args */ | 17209 | ExprList *pDfltList; /* DEFAULT clauses on various columns. |
| 17791 | VTable *pVTable; /* List of VTable objects. */ | 17210 | ** Or the AS clause for generated columns. */ |
| 17792 | #endif | 17211 | } tab; |
| 17793 | Trigger *pTrigger; /* List of triggers stored in pSchema */ | 17212 | struct { /* Used by views: */ |
| 17213 | Select *pSelect; /* View definition */ | ||
| 17214 | } view; | ||
| 17215 | struct { /* Used by virtual tables only: */ | ||
| 17216 | int nArg; /* Number of arguments to the module */ | ||
| 17217 | char **azArg; /* 0: module 1: schema 2: vtab name 3...: args */ | ||
| 17218 | VTable *p; /* List of VTable objects. */ | ||
| 17219 | } vtab; | ||
| 17220 | } u; | ||
| 17221 | Trigger *pTrigger; /* List of triggers on this object */ | ||
| 17794 | Schema *pSchema; /* Schema that contains this table */ | 17222 | Schema *pSchema; /* Schema that contains this table */ |
| 17795 | }; | 17223 | }; |
| 17796 | 17224 | ||
| @@ -17809,24 +17237,35 @@ struct Table { | |||
| 17809 | ** TF_HasStored == COLFLAG_STORED | 17237 | ** TF_HasStored == COLFLAG_STORED |
| 17810 | ** TF_HasHidden == COLFLAG_HIDDEN | 17238 | ** TF_HasHidden == COLFLAG_HIDDEN |
| 17811 | */ | 17239 | */ |
| 17812 | #define TF_Readonly 0x0001 /* Read-only system table */ | 17240 | #define TF_Readonly 0x00000001 /* Read-only system table */ |
| 17813 | #define TF_HasHidden 0x0002 /* Has one or more hidden columns */ | 17241 | #define TF_HasHidden 0x00000002 /* Has one or more hidden columns */ |
| 17814 | #define TF_HasPrimaryKey 0x0004 /* Table has a primary key */ | 17242 | #define TF_HasPrimaryKey 0x00000004 /* Table has a primary key */ |
| 17815 | #define TF_Autoincrement 0x0008 /* Integer primary key is autoincrement */ | 17243 | #define TF_Autoincrement 0x00000008 /* Integer primary key is autoincrement */ |
| 17816 | #define TF_HasStat1 0x0010 /* nRowLogEst set from sqlite_stat1 */ | 17244 | #define TF_HasStat1 0x00000010 /* nRowLogEst set from sqlite_stat1 */ |
| 17817 | #define TF_HasVirtual 0x0020 /* Has one or more VIRTUAL columns */ | 17245 | #define TF_HasVirtual 0x00000020 /* Has one or more VIRTUAL columns */ |
| 17818 | #define TF_HasStored 0x0040 /* Has one or more STORED columns */ | 17246 | #define TF_HasStored 0x00000040 /* Has one or more STORED columns */ |
| 17819 | #define TF_HasGenerated 0x0060 /* Combo: HasVirtual + HasStored */ | 17247 | #define TF_HasGenerated 0x00000060 /* Combo: HasVirtual + HasStored */ |
| 17820 | #define TF_WithoutRowid 0x0080 /* No rowid. PRIMARY KEY is the key */ | 17248 | #define TF_WithoutRowid 0x00000080 /* No rowid. PRIMARY KEY is the key */ |
| 17821 | #define TF_StatsUsed 0x0100 /* Query planner decisions affected by | 17249 | #define TF_StatsUsed 0x00000100 /* Query planner decisions affected by |
| 17822 | ** Index.aiRowLogEst[] values */ | 17250 | ** Index.aiRowLogEst[] values */ |
| 17823 | #define TF_NoVisibleRowid 0x0200 /* No user-visible "rowid" column */ | 17251 | #define TF_NoVisibleRowid 0x00000200 /* No user-visible "rowid" column */ |
| 17824 | #define TF_OOOHidden 0x0400 /* Out-of-Order hidden columns */ | 17252 | #define TF_OOOHidden 0x00000400 /* Out-of-Order hidden columns */ |
| 17825 | #define TF_HasNotNull 0x0800 /* Contains NOT NULL constraints */ | 17253 | #define TF_HasNotNull 0x00000800 /* Contains NOT NULL constraints */ |
| 17826 | #define TF_Shadow 0x1000 /* True for a shadow table */ | 17254 | #define TF_Shadow 0x00001000 /* True for a shadow table */ |
| 17827 | #define TF_HasStat4 0x2000 /* STAT4 info available for this table */ | 17255 | #define TF_HasStat4 0x00002000 /* STAT4 info available for this table */ |
| 17828 | #define TF_Ephemeral 0x4000 /* An ephemeral table */ | 17256 | #define TF_Ephemeral 0x00004000 /* An ephemeral table */ |
| 17829 | #define TF_Eponymous 0x8000 /* An eponymous virtual table */ | 17257 | #define TF_Eponymous 0x00008000 /* An eponymous virtual table */ |
| 17258 | #define TF_Strict 0x00010000 /* STRICT mode */ | ||
| 17259 | |||
| 17260 | /* | ||
| 17261 | ** Allowed values for Table.eTabType | ||
| 17262 | */ | ||
| 17263 | #define TABTYP_NORM 0 /* Ordinary table */ | ||
| 17264 | #define TABTYP_VTAB 1 /* Virtual table */ | ||
| 17265 | #define TABTYP_VIEW 2 /* A view */ | ||
| 17266 | |||
| 17267 | #define IsView(X) ((X)->eTabType==TABTYP_VIEW) | ||
| 17268 | #define IsOrdinaryTable(X) ((X)->eTabType==TABTYP_NORM) | ||
| 17830 | 17269 | ||
| 17831 | /* | 17270 | /* |
| 17832 | ** Test to see whether or not a table is a virtual table. This is | 17271 | ** Test to see whether or not a table is a virtual table. This is |
| @@ -17834,9 +17273,9 @@ struct Table { | |||
| 17834 | ** table support is omitted from the build. | 17273 | ** table support is omitted from the build. |
| 17835 | */ | 17274 | */ |
| 17836 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 17275 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 17837 | # define IsVirtual(X) ((X)->nModuleArg) | 17276 | # define IsVirtual(X) ((X)->eTabType==TABTYP_VTAB) |
| 17838 | # define ExprIsVtab(X) \ | 17277 | # define ExprIsVtab(X) \ |
| 17839 | ((X)->op==TK_COLUMN && (X)->y.pTab!=0 && (X)->y.pTab->nModuleArg) | 17278 | ((X)->op==TK_COLUMN && (X)->y.pTab!=0 && (X)->y.pTab->eTabType==TABTYP_VTAB) |
| 17840 | #else | 17279 | #else |
| 17841 | # define IsVirtual(X) 0 | 17280 | # define IsVirtual(X) 0 |
| 17842 | # define ExprIsVtab(X) 0 | 17281 | # define ExprIsVtab(X) 0 |
| @@ -18225,10 +17664,10 @@ typedef int ynVar; | |||
| 18225 | ** tree. | 17664 | ** tree. |
| 18226 | ** | 17665 | ** |
| 18227 | ** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, | 17666 | ** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, |
| 18228 | ** or TK_STRING), then Expr.token contains the text of the SQL literal. If | 17667 | ** or TK_STRING), then Expr.u.zToken contains the text of the SQL literal. If |
| 18229 | ** the expression is a variable (TK_VARIABLE), then Expr.token contains the | 17668 | ** the expression is a variable (TK_VARIABLE), then Expr.u.zToken contains the |
| 18230 | ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION), | 17669 | ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION), |
| 18231 | ** then Expr.token contains the name of the function. | 17670 | ** then Expr.u.zToken contains the name of the function. |
| 18232 | ** | 17671 | ** |
| 18233 | ** Expr.pRight and Expr.pLeft are the left and right subexpressions of a | 17672 | ** Expr.pRight and Expr.pLeft are the left and right subexpressions of a |
| 18234 | ** binary operator. Either or both may be NULL. | 17673 | ** binary operator. Either or both may be NULL. |
| @@ -18268,7 +17707,7 @@ typedef int ynVar; | |||
| 18268 | ** help reduce memory requirements, sometimes an Expr object will be | 17707 | ** help reduce memory requirements, sometimes an Expr object will be |
| 18269 | ** truncated. And to reduce the number of memory allocations, sometimes | 17708 | ** truncated. And to reduce the number of memory allocations, sometimes |
| 18270 | ** two or more Expr objects will be stored in a single memory allocation, | 17709 | ** two or more Expr objects will be stored in a single memory allocation, |
| 18271 | ** together with Expr.zToken strings. | 17710 | ** together with Expr.u.zToken strings. |
| 18272 | ** | 17711 | ** |
| 18273 | ** If the EP_Reduced and EP_TokenOnly flags are set when | 17712 | ** If the EP_Reduced and EP_TokenOnly flags are set when |
| 18274 | ** an Expr object is truncated. When EP_Reduced is set, then all | 17713 | ** an Expr object is truncated. When EP_Reduced is set, then all |
| @@ -18337,8 +17776,7 @@ struct Expr { | |||
| 18337 | } y; | 17776 | } y; |
| 18338 | }; | 17777 | }; |
| 18339 | 17778 | ||
| 18340 | /* | 17779 | /* The following are the meanings of bits in the Expr.flags field. |
| 18341 | ** The following are the meanings of bits in the Expr.flags field. | ||
| 18342 | ** Value restrictions: | 17780 | ** Value restrictions: |
| 18343 | ** | 17781 | ** |
| 18344 | ** EP_Agg == NC_HasAgg == SF_HasAgg | 17782 | ** EP_Agg == NC_HasAgg == SF_HasAgg |
| @@ -18377,14 +17815,12 @@ struct Expr { | |||
| 18377 | #define EP_FromDDL 0x40000000 /* Originates from sqlite_schema */ | 17815 | #define EP_FromDDL 0x40000000 /* Originates from sqlite_schema */ |
| 18378 | /* 0x80000000 // Available */ | 17816 | /* 0x80000000 // Available */ |
| 18379 | 17817 | ||
| 18380 | /* | 17818 | /* The EP_Propagate mask is a set of properties that automatically propagate |
| 18381 | ** The EP_Propagate mask is a set of properties that automatically propagate | ||
| 18382 | ** upwards into parent nodes. | 17819 | ** upwards into parent nodes. |
| 18383 | */ | 17820 | */ |
| 18384 | #define EP_Propagate (EP_Collate|EP_Subquery|EP_HasFunc) | 17821 | #define EP_Propagate (EP_Collate|EP_Subquery|EP_HasFunc) |
| 18385 | 17822 | ||
| 18386 | /* | 17823 | /* Macros can be used to test, set, or clear bits in the |
| 18387 | ** These macros can be used to test, set, or clear bits in the | ||
| 18388 | ** Expr.flags field. | 17824 | ** Expr.flags field. |
| 18389 | */ | 17825 | */ |
| 18390 | #define ExprHasProperty(E,P) (((E)->flags&(P))!=0) | 17826 | #define ExprHasProperty(E,P) (((E)->flags&(P))!=0) |
| @@ -18394,6 +17830,16 @@ struct Expr { | |||
| 18394 | #define ExprAlwaysTrue(E) (((E)->flags&(EP_FromJoin|EP_IsTrue))==EP_IsTrue) | 17830 | #define ExprAlwaysTrue(E) (((E)->flags&(EP_FromJoin|EP_IsTrue))==EP_IsTrue) |
| 18395 | #define ExprAlwaysFalse(E) (((E)->flags&(EP_FromJoin|EP_IsFalse))==EP_IsFalse) | 17831 | #define ExprAlwaysFalse(E) (((E)->flags&(EP_FromJoin|EP_IsFalse))==EP_IsFalse) |
| 18396 | 17832 | ||
| 17833 | /* Macros used to ensure that the correct members of unions are accessed | ||
| 17834 | ** in Expr. | ||
| 17835 | */ | ||
| 17836 | #define ExprUseUToken(E) (((E)->flags&EP_IntValue)==0) | ||
| 17837 | #define ExprUseUValue(E) (((E)->flags&EP_IntValue)!=0) | ||
| 17838 | #define ExprUseXList(E) (((E)->flags&EP_xIsSelect)==0) | ||
| 17839 | #define ExprUseXSelect(E) (((E)->flags&EP_xIsSelect)!=0) | ||
| 17840 | #define ExprUseYTab(E) (((E)->flags&(EP_WinFunc|EP_Subrtn))==0) | ||
| 17841 | #define ExprUseYWin(E) (((E)->flags&EP_WinFunc)!=0) | ||
| 17842 | #define ExprUseYSub(E) (((E)->flags&EP_Subrtn)!=0) | ||
| 18397 | 17843 | ||
| 18398 | /* Flags for use with Expr.vvaFlags | 17844 | /* Flags for use with Expr.vvaFlags |
| 18399 | */ | 17845 | */ |
| @@ -18476,11 +17922,12 @@ struct ExprList { | |||
| 18476 | unsigned bSorterRef :1; /* Defer evaluation until after sorting */ | 17922 | unsigned bSorterRef :1; /* Defer evaluation until after sorting */ |
| 18477 | unsigned bNulls: 1; /* True if explicit "NULLS FIRST/LAST" */ | 17923 | unsigned bNulls: 1; /* True if explicit "NULLS FIRST/LAST" */ |
| 18478 | union { | 17924 | union { |
| 18479 | struct { | 17925 | struct { /* Used by any ExprList other than Parse.pConsExpr */ |
| 18480 | u16 iOrderByCol; /* For ORDER BY, column number in result set */ | 17926 | u16 iOrderByCol; /* For ORDER BY, column number in result set */ |
| 18481 | u16 iAlias; /* Index into Parse.aAlias[] for zName */ | 17927 | u16 iAlias; /* Index into Parse.aAlias[] for zName */ |
| 18482 | } x; | 17928 | } x; |
| 18483 | int iConstExprReg; /* Register in which Expr value is cached */ | 17929 | int iConstExprReg; /* Register in which Expr value is cached. Used only |
| 17930 | ** by Parse.pConstExpr */ | ||
| 18484 | } u; | 17931 | } u; |
| 18485 | } a[1]; /* One slot for each expression in the list */ | 17932 | } a[1]; /* One slot for each expression in the list */ |
| 18486 | }; | 17933 | }; |
| @@ -18518,6 +17965,13 @@ struct IdList { | |||
| 18518 | /* | 17965 | /* |
| 18519 | ** The SrcItem object represents a single term in the FROM clause of a query. | 17966 | ** The SrcItem object represents a single term in the FROM clause of a query. |
| 18520 | ** The SrcList object is mostly an array of SrcItems. | 17967 | ** The SrcList object is mostly an array of SrcItems. |
| 17968 | ** | ||
| 17969 | ** Union member validity: | ||
| 17970 | ** | ||
| 17971 | ** u1.zIndexedBy fg.isIndexedBy && !fg.isTabFunc | ||
| 17972 | ** u1.pFuncArg fg.isTabFunc && !fg.isIndexedBy | ||
| 17973 | ** u2.pIBIndex fg.isIndexedBy && !fg.isCte | ||
| 17974 | ** u2.pCteUse fg.isCte && !fg.isIndexedBy | ||
| 18521 | */ | 17975 | */ |
| 18522 | struct SrcItem { | 17976 | struct SrcItem { |
| 18523 | Schema *pSchema; /* Schema to which this item is fixed */ | 17977 | Schema *pSchema; /* Schema to which this item is fixed */ |
| @@ -18666,31 +18120,33 @@ struct NameContext { | |||
| 18666 | ** Allowed values for the NameContext, ncFlags field. | 18120 | ** Allowed values for the NameContext, ncFlags field. |
| 18667 | ** | 18121 | ** |
| 18668 | ** Value constraints (all checked via assert()): | 18122 | ** Value constraints (all checked via assert()): |
| 18669 | ** NC_HasAgg == SF_HasAgg == EP_Agg | 18123 | ** NC_HasAgg == SF_HasAgg == EP_Agg |
| 18670 | ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX | 18124 | ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX |
| 18125 | ** NC_OrderAgg == SF_OrderByReqd == SQLITE_FUNC_ANYORDER | ||
| 18671 | ** NC_HasWin == EP_Win | 18126 | ** NC_HasWin == EP_Win |
| 18672 | ** | 18127 | ** |
| 18673 | */ | 18128 | */ |
| 18674 | #define NC_AllowAgg 0x00001 /* Aggregate functions are allowed here */ | 18129 | #define NC_AllowAgg 0x000001 /* Aggregate functions are allowed here */ |
| 18675 | #define NC_PartIdx 0x00002 /* True if resolving a partial index WHERE */ | 18130 | #define NC_PartIdx 0x000002 /* True if resolving a partial index WHERE */ |
| 18676 | #define NC_IsCheck 0x00004 /* True if resolving a CHECK constraint */ | 18131 | #define NC_IsCheck 0x000004 /* True if resolving a CHECK constraint */ |
| 18677 | #define NC_GenCol 0x00008 /* True for a GENERATED ALWAYS AS clause */ | 18132 | #define NC_GenCol 0x000008 /* True for a GENERATED ALWAYS AS clause */ |
| 18678 | #define NC_HasAgg 0x00010 /* One or more aggregate functions seen */ | 18133 | #define NC_HasAgg 0x000010 /* One or more aggregate functions seen */ |
| 18679 | #define NC_IdxExpr 0x00020 /* True if resolving columns of CREATE INDEX */ | 18134 | #define NC_IdxExpr 0x000020 /* True if resolving columns of CREATE INDEX */ |
| 18680 | #define NC_SelfRef 0x0002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */ | 18135 | #define NC_SelfRef 0x00002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */ |
| 18681 | #define NC_VarSelect 0x00040 /* A correlated subquery has been seen */ | 18136 | #define NC_VarSelect 0x000040 /* A correlated subquery has been seen */ |
| 18682 | #define NC_UEList 0x00080 /* True if uNC.pEList is used */ | 18137 | #define NC_UEList 0x000080 /* True if uNC.pEList is used */ |
| 18683 | #define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */ | 18138 | #define NC_UAggInfo 0x000100 /* True if uNC.pAggInfo is used */ |
| 18684 | #define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */ | 18139 | #define NC_UUpsert 0x000200 /* True if uNC.pUpsert is used */ |
| 18685 | #define NC_UBaseReg 0x00400 /* True if uNC.iBaseReg is used */ | 18140 | #define NC_UBaseReg 0x000400 /* True if uNC.iBaseReg is used */ |
| 18686 | #define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */ | 18141 | #define NC_MinMaxAgg 0x001000 /* min/max aggregates seen. See note above */ |
| 18687 | #define NC_Complex 0x02000 /* True if a function or subquery seen */ | 18142 | #define NC_Complex 0x002000 /* True if a function or subquery seen */ |
| 18688 | #define NC_AllowWin 0x04000 /* Window functions are allowed here */ | 18143 | #define NC_AllowWin 0x004000 /* Window functions are allowed here */ |
| 18689 | #define NC_HasWin 0x08000 /* One or more window functions seen */ | 18144 | #define NC_HasWin 0x008000 /* One or more window functions seen */ |
| 18690 | #define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */ | 18145 | #define NC_IsDDL 0x010000 /* Resolving names in a CREATE statement */ |
| 18691 | #define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */ | 18146 | #define NC_InAggFunc 0x020000 /* True if analyzing arguments to an agg func */ |
| 18692 | #define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */ | 18147 | #define NC_FromDDL 0x040000 /* SQL text comes from sqlite_schema */ |
| 18693 | #define NC_NoSelect 0x80000 /* Do not descend into sub-selects */ | 18148 | #define NC_NoSelect 0x080000 /* Do not descend into sub-selects */ |
| 18149 | #define NC_OrderAgg 0x8000000 /* Has an aggregate other than count/min/max */ | ||
| 18694 | 18150 | ||
| 18695 | /* | 18151 | /* |
| 18696 | ** An instance of the following object describes a single ON CONFLICT | 18152 | ** An instance of the following object describes a single ON CONFLICT |
| @@ -18773,9 +18229,10 @@ struct Select { | |||
| 18773 | ** "Select Flag". | 18229 | ** "Select Flag". |
| 18774 | ** | 18230 | ** |
| 18775 | ** Value constraints (all checked via assert()) | 18231 | ** Value constraints (all checked via assert()) |
| 18776 | ** SF_HasAgg == NC_HasAgg | 18232 | ** SF_HasAgg == NC_HasAgg |
| 18777 | ** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX | 18233 | ** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX |
| 18778 | ** SF_FixedLimit == WHERE_USE_LIMIT | 18234 | ** SF_OrderByReqd == NC_OrderAgg == SQLITE_FUNC_ANYORDER |
| 18235 | ** SF_FixedLimit == WHERE_USE_LIMIT | ||
| 18779 | */ | 18236 | */ |
| 18780 | #define SF_Distinct 0x0000001 /* Output should be DISTINCT */ | 18237 | #define SF_Distinct 0x0000001 /* Output should be DISTINCT */ |
| 18781 | #define SF_All 0x0000002 /* Includes the ALL keyword */ | 18238 | #define SF_All 0x0000002 /* Includes the ALL keyword */ |
| @@ -18800,10 +18257,11 @@ struct Select { | |||
| 18800 | #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */ | 18257 | #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */ |
| 18801 | #define SF_View 0x0200000 /* SELECT statement is a view */ | 18258 | #define SF_View 0x0200000 /* SELECT statement is a view */ |
| 18802 | #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */ | 18259 | #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */ |
| 18803 | #define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */ | 18260 | #define SF_UFSrcCheck 0x0800000 /* Check pSrc as required by UPDATE...FROM */ |
| 18804 | #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */ | 18261 | #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */ |
| 18805 | #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */ | 18262 | #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */ |
| 18806 | #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */ | 18263 | #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */ |
| 18264 | #define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */ | ||
| 18807 | 18265 | ||
| 18808 | /* | 18266 | /* |
| 18809 | ** The results of a SELECT can be distributed in several ways, as defined | 18267 | ** The results of a SELECT can be distributed in several ways, as defined |
| @@ -19045,7 +18503,6 @@ struct Parse { | |||
| 19045 | AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ | 18503 | AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */ |
| 19046 | Parse *pToplevel; /* Parse structure for main program (or NULL) */ | 18504 | Parse *pToplevel; /* Parse structure for main program (or NULL) */ |
| 19047 | Table *pTriggerTab; /* Table triggers are being coded for */ | 18505 | Table *pTriggerTab; /* Table triggers are being coded for */ |
| 19048 | Parse *pParentParse; /* Parent parser if this parser is nested */ | ||
| 19049 | union { | 18506 | union { |
| 19050 | int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */ | 18507 | int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */ |
| 19051 | Returning *pReturning; /* The RETURNING clause */ | 18508 | Returning *pReturning; /* The RETURNING clause */ |
| @@ -19108,6 +18565,8 @@ struct Parse { | |||
| 19108 | #endif | 18565 | #endif |
| 19109 | }; | 18566 | }; |
| 19110 | 18567 | ||
| 18568 | /* Allowed values for Parse.eParseMode | ||
| 18569 | */ | ||
| 19111 | #define PARSE_MODE_NORMAL 0 | 18570 | #define PARSE_MODE_NORMAL 0 |
| 19112 | #define PARSE_MODE_DECLARE_VTAB 1 | 18571 | #define PARSE_MODE_DECLARE_VTAB 1 |
| 19113 | #define PARSE_MODE_RENAME 2 | 18572 | #define PARSE_MODE_RENAME 2 |
| @@ -19329,8 +18788,10 @@ typedef struct { | |||
| 19329 | /* | 18788 | /* |
| 19330 | ** Allowed values for mInitFlags | 18789 | ** Allowed values for mInitFlags |
| 19331 | */ | 18790 | */ |
| 18791 | #define INITFLAG_AlterMask 0x0003 /* Types of ALTER */ | ||
| 19332 | #define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */ | 18792 | #define INITFLAG_AlterRename 0x0001 /* Reparse after a RENAME */ |
| 19333 | #define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */ | 18793 | #define INITFLAG_AlterDrop 0x0002 /* Reparse after a DROP COLUMN */ |
| 18794 | #define INITFLAG_AlterAdd 0x0003 /* Reparse after an ADD COLUMN */ | ||
| 19334 | 18795 | ||
| 19335 | /* Tuning parameters are set using SQLITE_TESTCTRL_TUNE and are controlled | 18796 | /* Tuning parameters are set using SQLITE_TESTCTRL_TUNE and are controlled |
| 19336 | ** on debug-builds of the CLI using ".testctrl tune ID VALUE". Tuning | 18797 | ** on debug-builds of the CLI using ".testctrl tune ID VALUE". Tuning |
| @@ -19451,8 +18912,8 @@ struct Walker { | |||
| 19451 | int n; /* A counter */ | 18912 | int n; /* A counter */ |
| 19452 | int iCur; /* A cursor number */ | 18913 | int iCur; /* A cursor number */ |
| 19453 | SrcList *pSrcList; /* FROM clause */ | 18914 | SrcList *pSrcList; /* FROM clause */ |
| 19454 | struct SrcCount *pSrcCount; /* Counting column references */ | ||
| 19455 | struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ | 18915 | struct CCurHint *pCCurHint; /* Used by codeCursorHint() */ |
| 18916 | struct RefSrcList *pRefSrcList; /* sqlite3ReferencesSrcList() */ | ||
| 19456 | int *aiCol; /* array of column indexes */ | 18917 | int *aiCol; /* array of column indexes */ |
| 19457 | struct IdxCover *pIdxCover; /* Check for index coverage */ | 18918 | struct IdxCover *pIdxCover; /* Check for index coverage */ |
| 19458 | struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */ | 18919 | struct IdxExprTrans *pIdxTrans; /* Convert idxed expr to column */ |
| @@ -19637,7 +19098,7 @@ SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p); | |||
| 19637 | SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8); | 19098 | SQLITE_PRIVATE Window *sqlite3WindowAlloc(Parse*, int, int, Expr*, int , Expr*, u8); |
| 19638 | SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*); | 19099 | SQLITE_PRIVATE void sqlite3WindowAttach(Parse*, Expr*, Window*); |
| 19639 | SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin); | 19100 | SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin); |
| 19640 | SQLITE_PRIVATE int sqlite3WindowCompare(Parse*, Window*, Window*, int); | 19101 | SQLITE_PRIVATE int sqlite3WindowCompare(const Parse*, const Window*, const Window*, int); |
| 19641 | SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Select*); | 19102 | SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse*, Select*); |
| 19642 | SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int); | 19103 | SQLITE_PRIVATE void sqlite3WindowCodeStep(Parse*, Select*, WhereInfo*, int, int); |
| 19643 | SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*); | 19104 | SQLITE_PRIVATE int sqlite3WindowRewrite(Parse*, Select*); |
| @@ -19769,8 +19230,8 @@ SQLITE_PRIVATE void *sqlite3DbReallocOrFree(sqlite3 *, void *, u64); | |||
| 19769 | SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, u64); | 19230 | SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *, void *, u64); |
| 19770 | SQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*); | 19231 | SQLITE_PRIVATE void sqlite3DbFree(sqlite3*, void*); |
| 19771 | SQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3*, void*); | 19232 | SQLITE_PRIVATE void sqlite3DbFreeNN(sqlite3*, void*); |
| 19772 | SQLITE_PRIVATE int sqlite3MallocSize(void*); | 19233 | SQLITE_PRIVATE int sqlite3MallocSize(const void*); |
| 19773 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, void*); | 19234 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3*, const void*); |
| 19774 | SQLITE_PRIVATE void *sqlite3PageMalloc(int); | 19235 | SQLITE_PRIVATE void *sqlite3PageMalloc(int); |
| 19775 | SQLITE_PRIVATE void sqlite3PageFree(void*); | 19236 | SQLITE_PRIVATE void sqlite3PageFree(void*); |
| 19776 | SQLITE_PRIVATE void sqlite3MemSetDefault(void); | 19237 | SQLITE_PRIVATE void sqlite3MemSetDefault(void); |
| @@ -19886,6 +19347,7 @@ SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...); | |||
| 19886 | SQLITE_PRIVATE int sqlite3ErrorToParser(sqlite3*,int); | 19347 | SQLITE_PRIVATE int sqlite3ErrorToParser(sqlite3*,int); |
| 19887 | SQLITE_PRIVATE void sqlite3Dequote(char*); | 19348 | SQLITE_PRIVATE void sqlite3Dequote(char*); |
| 19888 | SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*); | 19349 | SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*); |
| 19350 | SQLITE_PRIVATE void sqlite3DequoteToken(Token*); | ||
| 19889 | SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*); | 19351 | SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*); |
| 19890 | SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int); | 19352 | SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int); |
| 19891 | SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **); | 19353 | SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **); |
| @@ -19905,16 +19367,17 @@ SQLITE_PRIVATE Expr *sqlite3PExpr(Parse*, int, Expr*, Expr*); | |||
| 19905 | SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); | 19367 | SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse*, Expr*, Select*); |
| 19906 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); | 19368 | SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse*,Expr*, Expr*); |
| 19907 | SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); | 19369 | SQLITE_PRIVATE Expr *sqlite3ExprSimplifiedAndOr(Expr*); |
| 19908 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, Token*, int); | 19370 | SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse*,ExprList*, const Token*, int); |
| 19909 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,Expr*,FuncDef*); | 19371 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*); |
| 19910 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); | 19372 | SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32); |
| 19911 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); | 19373 | SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*); |
| 19912 | SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*); | 19374 | SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*); |
| 19913 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); | 19375 | SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*); |
| 19914 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); | 19376 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*); |
| 19915 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); | 19377 | SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*); |
| 19378 | SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse*, int, ExprList*); | ||
| 19916 | SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int); | 19379 | SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int); |
| 19917 | SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int); | 19380 | SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,const Token*,int); |
| 19918 | SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*); | 19381 | SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*); |
| 19919 | SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*); | 19382 | SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*); |
| 19920 | SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*); | 19383 | SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*); |
| @@ -19930,6 +19393,10 @@ SQLITE_PRIVATE void sqlite3ResetAllSchemasOfConnection(sqlite3*); | |||
| 19930 | SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int); | 19393 | SQLITE_PRIVATE void sqlite3ResetOneSchema(sqlite3*,int); |
| 19931 | SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*); | 19394 | SQLITE_PRIVATE void sqlite3CollapseDatabaseArray(sqlite3*); |
| 19932 | SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*); | 19395 | SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3*); |
| 19396 | SQLITE_PRIVATE void sqlite3ColumnSetExpr(Parse*,Table*,Column*,Expr*); | ||
| 19397 | SQLITE_PRIVATE Expr *sqlite3ColumnExpr(Table*,Column*); | ||
| 19398 | SQLITE_PRIVATE void sqlite3ColumnSetColl(sqlite3*,Column*,const char*zColl); | ||
| 19399 | SQLITE_PRIVATE const char *sqlite3ColumnColl(Column*); | ||
| 19933 | SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*); | 19400 | SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3*,Table*); |
| 19934 | SQLITE_PRIVATE void sqlite3GenerateColumnNames(Parse *pParse, Select *pSelect); | 19401 | SQLITE_PRIVATE void sqlite3GenerateColumnNames(Parse *pParse, Select *pSelect); |
| 19935 | SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); | 19402 | SQLITE_PRIVATE int sqlite3ColumnsFromExprList(Parse*,ExprList*,i16*,Column**); |
| @@ -19951,14 +19418,14 @@ SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*); | |||
| 19951 | #else | 19418 | #else |
| 19952 | # define sqlite3ColumnPropertiesFromName(T,C) /* no-op */ | 19419 | # define sqlite3ColumnPropertiesFromName(T,C) /* no-op */ |
| 19953 | #endif | 19420 | #endif |
| 19954 | SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*,Token*); | 19421 | SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token,Token); |
| 19955 | SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int); | 19422 | SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int); |
| 19956 | SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); | 19423 | SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int); |
| 19957 | SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*, const char*, const char*); | 19424 | SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*, const char*, const char*); |
| 19958 | SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*); | 19425 | SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*); |
| 19959 | SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*); | 19426 | SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*); |
| 19960 | SQLITE_PRIVATE void sqlite3AddGenerated(Parse*,Expr*,Token*); | 19427 | SQLITE_PRIVATE void sqlite3AddGenerated(Parse*,Expr*,Token*); |
| 19961 | SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*); | 19428 | SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u32,Select*); |
| 19962 | SQLITE_PRIVATE void sqlite3AddReturning(Parse*,ExprList*); | 19429 | SQLITE_PRIVATE void sqlite3AddReturning(Parse*,ExprList*); |
| 19963 | SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*, | 19430 | SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*, |
| 19964 | sqlite3_vfs**,char**,char **); | 19431 | sqlite3_vfs**,char**,char **); |
| @@ -20068,7 +19535,7 @@ SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int | |||
| 20068 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int); | 19535 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int); |
| 20069 | SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int); | 19536 | SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int); |
| 20070 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS | 19537 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 20071 | SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Column*, int); | 19538 | SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int); |
| 20072 | #endif | 19539 | #endif |
| 20073 | SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int); | 19540 | SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int); |
| 20074 | SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int); | 19541 | SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int); |
| @@ -20087,23 +19554,24 @@ SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3*,const char*, const char*); | |||
| 20087 | #define LOCATE_VIEW 0x01 | 19554 | #define LOCATE_VIEW 0x01 |
| 20088 | #define LOCATE_NOERR 0x02 | 19555 | #define LOCATE_NOERR 0x02 |
| 20089 | SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*); | 19556 | SQLITE_PRIVATE Table *sqlite3LocateTable(Parse*,u32 flags,const char*, const char*); |
| 19557 | SQLITE_PRIVATE const char *sqlite3PreferredTableName(const char*); | ||
| 20090 | SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,SrcItem *); | 19558 | SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,SrcItem *); |
| 20091 | SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*); | 19559 | SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*); |
| 20092 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); | 19560 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*); |
| 20093 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); | 19561 | SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*); |
| 20094 | SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*,Expr*); | 19562 | SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*,Expr*); |
| 20095 | SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int, sqlite3_value*); | 19563 | SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int, sqlite3_value*); |
| 20096 | SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*); | 19564 | SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, const Token*); |
| 20097 | SQLITE_PRIVATE int sqlite3ExprCompare(Parse*,Expr*, Expr*, int); | 19565 | SQLITE_PRIVATE int sqlite3ExprCompare(const Parse*,const Expr*,const Expr*, int); |
| 20098 | SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int); | 19566 | SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*,Expr*,int); |
| 20099 | SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList*, ExprList*, int); | 19567 | SQLITE_PRIVATE int sqlite3ExprListCompare(const ExprList*,const ExprList*, int); |
| 20100 | SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse*,Expr*, Expr*, int); | 19568 | SQLITE_PRIVATE int sqlite3ExprImpliesExpr(const Parse*,const Expr*,const Expr*, int); |
| 20101 | SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr*,int); | 19569 | SQLITE_PRIVATE int sqlite3ExprImpliesNonNullRow(Expr*,int); |
| 20102 | SQLITE_PRIVATE void sqlite3AggInfoPersistWalkerInit(Walker*,Parse*); | 19570 | SQLITE_PRIVATE void sqlite3AggInfoPersistWalkerInit(Walker*,Parse*); |
| 20103 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); | 19571 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*); |
| 20104 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); | 19572 | SQLITE_PRIVATE void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*); |
| 20105 | SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); | 19573 | SQLITE_PRIVATE int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx); |
| 20106 | SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr*, SrcList*); | 19574 | SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse*, Expr*, SrcList*); |
| 20107 | SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); | 19575 | SQLITE_PRIVATE Vdbe *sqlite3GetVdbe(Parse*); |
| 20108 | #ifndef SQLITE_UNTESTABLE | 19576 | #ifndef SQLITE_UNTESTABLE |
| 20109 | SQLITE_PRIVATE void sqlite3PrngSaveState(void); | 19577 | SQLITE_PRIVATE void sqlite3PrngSaveState(void); |
| @@ -20128,7 +19596,7 @@ SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int); | |||
| 20128 | #ifdef SQLITE_ENABLE_CURSOR_HINTS | 19596 | #ifdef SQLITE_ENABLE_CURSOR_HINTS |
| 20129 | SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*); | 19597 | SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr*); |
| 20130 | #endif | 19598 | #endif |
| 20131 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*); | 19599 | SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr*, int*); |
| 20132 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); | 19600 | SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*); |
| 20133 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); | 19601 | SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char); |
| 20134 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); | 19602 | SQLITE_PRIVATE int sqlite3IsRowid(const char*); |
| @@ -20153,11 +19621,11 @@ SQLITE_PRIVATE void sqlite3MayAbort(Parse*); | |||
| 20153 | SQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8); | 19621 | SQLITE_PRIVATE void sqlite3HaltConstraint(Parse*, int, int, char*, i8, u8); |
| 20154 | SQLITE_PRIVATE void sqlite3UniqueConstraint(Parse*, int, Index*); | 19622 | SQLITE_PRIVATE void sqlite3UniqueConstraint(Parse*, int, Index*); |
| 20155 | SQLITE_PRIVATE void sqlite3RowidConstraint(Parse*, int, Table*); | 19623 | SQLITE_PRIVATE void sqlite3RowidConstraint(Parse*, int, Table*); |
| 20156 | SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,Expr*,int); | 19624 | SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3*,const Expr*,int); |
| 20157 | SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int); | 19625 | SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,const ExprList*,int); |
| 20158 | SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int); | 19626 | SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,const SrcList*,int); |
| 20159 | SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*); | 19627 | SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,const IdList*); |
| 20160 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int); | 19628 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,const Select*,int); |
| 20161 | SQLITE_PRIVATE FuncDef *sqlite3FunctionSearch(int,const char*); | 19629 | SQLITE_PRIVATE FuncDef *sqlite3FunctionSearch(int,const char*); |
| 20162 | SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int); | 19630 | SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int); |
| 20163 | SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8); | 19631 | SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8); |
| @@ -20295,7 +19763,7 @@ SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3*, Index*); | |||
| 20295 | SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int); | 19763 | SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe*, Table*, int); |
| 20296 | SQLITE_PRIVATE char sqlite3CompareAffinity(const Expr *pExpr, char aff2); | 19764 | SQLITE_PRIVATE char sqlite3CompareAffinity(const Expr *pExpr, char aff2); |
| 20297 | SQLITE_PRIVATE int sqlite3IndexAffinityOk(const Expr *pExpr, char idx_affinity); | 19765 | SQLITE_PRIVATE int sqlite3IndexAffinityOk(const Expr *pExpr, char idx_affinity); |
| 20298 | SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table*,int); | 19766 | SQLITE_PRIVATE char sqlite3TableColumnAffinity(const Table*,int); |
| 20299 | SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr); | 19767 | SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr); |
| 20300 | SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8); | 19768 | SQLITE_PRIVATE int sqlite3Atoi64(const char*, i64*, int, u8); |
| 20301 | SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*); | 19769 | SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*); |
| @@ -20324,14 +19792,14 @@ SQLITE_PRIVATE void sqlite3SetTextEncoding(sqlite3 *db, u8); | |||
| 20324 | SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr); | 19792 | SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr); |
| 20325 | SQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, const Expr *pExpr); | 19793 | SQLITE_PRIVATE CollSeq *sqlite3ExprNNCollSeq(Parse *pParse, const Expr *pExpr); |
| 20326 | SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,const Expr*,const Expr*); | 19794 | SQLITE_PRIVATE int sqlite3ExprCollSeqMatch(Parse*,const Expr*,const Expr*); |
| 20327 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int); | 19795 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(const Parse *pParse, Expr*, const Token*, int); |
| 20328 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*); | 19796 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(const Parse*,Expr*,const char*); |
| 20329 | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*); | 19797 | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*); |
| 20330 | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr*); | 19798 | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr*); |
| 20331 | SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *); | 19799 | SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *); |
| 20332 | SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*); | 19800 | SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*); |
| 20333 | SQLITE_PRIVATE int sqlite3CheckObjectName(Parse*, const char*,const char*,const char*); | 19801 | SQLITE_PRIVATE int sqlite3CheckObjectName(Parse*, const char*,const char*,const char*); |
| 20334 | SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int); | 19802 | SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, i64); |
| 20335 | SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64); | 19803 | SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64); |
| 20336 | SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64); | 19804 | SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64); |
| 20337 | SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64); | 19805 | SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64); |
| @@ -20356,11 +19824,15 @@ SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *); | |||
| 20356 | #ifndef SQLITE_OMIT_UTF16 | 19824 | #ifndef SQLITE_OMIT_UTF16 |
| 20357 | SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); | 19825 | SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8); |
| 20358 | #endif | 19826 | #endif |
| 20359 | SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **); | 19827 | SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, const Expr *, u8, u8, sqlite3_value **); |
| 20360 | SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); | 19828 | SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8); |
| 20361 | #ifndef SQLITE_AMALGAMATION | 19829 | #ifndef SQLITE_AMALGAMATION |
| 20362 | SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[]; | 19830 | SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[]; |
| 20363 | SQLITE_PRIVATE const char sqlite3StrBINARY[]; | 19831 | SQLITE_PRIVATE const char sqlite3StrBINARY[]; |
| 19832 | SQLITE_PRIVATE const unsigned char sqlite3StdTypeLen[]; | ||
| 19833 | SQLITE_PRIVATE const char sqlite3StdTypeAffinity[]; | ||
| 19834 | SQLITE_PRIVATE const char sqlite3StdTypeMap[]; | ||
| 19835 | SQLITE_PRIVATE const char *sqlite3StdType[]; | ||
| 20364 | SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[]; | 19836 | SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[]; |
| 20365 | SQLITE_PRIVATE const unsigned char *sqlite3aLTb; | 19837 | SQLITE_PRIVATE const unsigned char *sqlite3aLTb; |
| 20366 | SQLITE_PRIVATE const unsigned char *sqlite3aEQb; | 19838 | SQLITE_PRIVATE const unsigned char *sqlite3aEQb; |
| @@ -20404,9 +19876,9 @@ SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const | |||
| 20404 | SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int); | 19876 | SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int); |
| 20405 | SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *); | 19877 | SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *); |
| 20406 | SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *); | 19878 | SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *, SrcList *); |
| 20407 | SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse*, SrcList*, Token*); | 19879 | SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse*, SrcList*, const Token*); |
| 20408 | SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse*, void*, Token*); | 19880 | SQLITE_PRIVATE const void *sqlite3RenameTokenMap(Parse*, const void*, const Token*); |
| 20409 | SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse*, void *pTo, void *pFrom); | 19881 | SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse*, const void *pTo, const void *pFrom); |
| 20410 | SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse*, Expr*); | 19882 | SQLITE_PRIVATE void sqlite3RenameExprUnmap(Parse*, Expr*); |
| 20411 | SQLITE_PRIVATE void sqlite3RenameExprlistUnmap(Parse*, ExprList*); | 19883 | SQLITE_PRIVATE void sqlite3RenameExprlistUnmap(Parse*, ExprList*); |
| 20412 | SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*); | 19884 | SQLITE_PRIVATE CollSeq *sqlite3GetCollSeq(Parse*, u8, CollSeq *, const char*); |
| @@ -20450,6 +19922,8 @@ SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *); | |||
| 20450 | 19922 | ||
| 20451 | SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int); | 19923 | SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int); |
| 20452 | SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*); | 19924 | SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*); |
| 19925 | SQLITE_PRIVATE void sqlite3StrAccumSetError(StrAccum*, u8); | ||
| 19926 | SQLITE_PRIVATE void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*); | ||
| 20453 | SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int); | 19927 | SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int); |
| 20454 | SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int); | 19928 | SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int); |
| 20455 | 19929 | ||
| @@ -20502,7 +19976,7 @@ SQLITE_PRIVATE int sqlite3Utf8To8(unsigned char*); | |||
| 20502 | #endif | 19976 | #endif |
| 20503 | 19977 | ||
| 20504 | #ifdef SQLITE_OMIT_VIRTUALTABLE | 19978 | #ifdef SQLITE_OMIT_VIRTUALTABLE |
| 20505 | # define sqlite3VtabClear(Y) | 19979 | # define sqlite3VtabClear(D,T) |
| 20506 | # define sqlite3VtabSync(X,Y) SQLITE_OK | 19980 | # define sqlite3VtabSync(X,Y) SQLITE_OK |
| 20507 | # define sqlite3VtabRollback(X) | 19981 | # define sqlite3VtabRollback(X) |
| 20508 | # define sqlite3VtabCommit(X) | 19982 | # define sqlite3VtabCommit(X) |
| @@ -20539,9 +20013,11 @@ SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db); | |||
| 20539 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 20013 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 20540 | SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName); | 20014 | SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName); |
| 20541 | SQLITE_PRIVATE int sqlite3IsShadowTableOf(sqlite3*,Table*,const char*); | 20015 | SQLITE_PRIVATE int sqlite3IsShadowTableOf(sqlite3*,Table*,const char*); |
| 20016 | SQLITE_PRIVATE void sqlite3MarkAllShadowTablesOf(sqlite3*, Table*); | ||
| 20542 | #else | 20017 | #else |
| 20543 | # define sqlite3ShadowTableName(A,B) 0 | 20018 | # define sqlite3ShadowTableName(A,B) 0 |
| 20544 | # define sqlite3IsShadowTableOf(A,B,C) 0 | 20019 | # define sqlite3IsShadowTableOf(A,B,C) 0 |
| 20020 | # define sqlite3MarkAllShadowTablesOf(A,B) | ||
| 20545 | #endif | 20021 | #endif |
| 20546 | SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*); | 20022 | SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*); |
| 20547 | SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*); | 20023 | SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*); |
| @@ -20584,7 +20060,7 @@ SQLITE_PRIVATE With *sqlite3WithPush(Parse*, With*, u8); | |||
| 20584 | # define sqlite3CteDelete(D,C) | 20060 | # define sqlite3CteDelete(D,C) |
| 20585 | # define sqlite3CteWithAdd(P,W,C) ((void*)0) | 20061 | # define sqlite3CteWithAdd(P,W,C) ((void*)0) |
| 20586 | # define sqlite3WithDelete(x,y) | 20062 | # define sqlite3WithDelete(x,y) |
| 20587 | # define sqlite3WithPush(x,y,z) | 20063 | # define sqlite3WithPush(x,y,z) ((void*)0) |
| 20588 | #endif | 20064 | #endif |
| 20589 | #ifndef SQLITE_OMIT_UPSERT | 20065 | #ifndef SQLITE_OMIT_UPSERT |
| 20590 | SQLITE_PRIVATE Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*); | 20066 | SQLITE_PRIVATE Upsert *sqlite3UpsertNew(sqlite3*,ExprList*,Expr*,ExprList*,Expr*,Upsert*); |
| @@ -20681,7 +20157,7 @@ SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *); | |||
| 20681 | 20157 | ||
| 20682 | SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p); | 20158 | SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p); |
| 20683 | #if SQLITE_MAX_EXPR_DEPTH>0 | 20159 | #if SQLITE_MAX_EXPR_DEPTH>0 |
| 20684 | SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *); | 20160 | SQLITE_PRIVATE int sqlite3SelectExprHeight(const Select *); |
| 20685 | SQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse*, int); | 20161 | SQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse*, int); |
| 20686 | #else | 20162 | #else |
| 20687 | #define sqlite3SelectExprHeight(x) 0 | 20163 | #define sqlite3SelectExprHeight(x) 0 |
| @@ -20752,8 +20228,8 @@ SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...); | |||
| 20752 | */ | 20228 | */ |
| 20753 | #ifdef SQLITE_MEMDEBUG | 20229 | #ifdef SQLITE_MEMDEBUG |
| 20754 | SQLITE_PRIVATE void sqlite3MemdebugSetType(void*,u8); | 20230 | SQLITE_PRIVATE void sqlite3MemdebugSetType(void*,u8); |
| 20755 | SQLITE_PRIVATE int sqlite3MemdebugHasType(void*,u8); | 20231 | SQLITE_PRIVATE int sqlite3MemdebugHasType(const void*,u8); |
| 20756 | SQLITE_PRIVATE int sqlite3MemdebugNoType(void*,u8); | 20232 | SQLITE_PRIVATE int sqlite3MemdebugNoType(const void*,u8); |
| 20757 | #else | 20233 | #else |
| 20758 | # define sqlite3MemdebugSetType(X,Y) /* no-op */ | 20234 | # define sqlite3MemdebugSetType(X,Y) /* no-op */ |
| 20759 | # define sqlite3MemdebugHasType(X,Y) 1 | 20235 | # define sqlite3MemdebugHasType(X,Y) 1 |
| @@ -20778,10 +20254,10 @@ SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3*); | |||
| 20778 | SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*); | 20254 | SQLITE_PRIVATE int sqlite3DbstatRegister(sqlite3*); |
| 20779 | #endif | 20255 | #endif |
| 20780 | 20256 | ||
| 20781 | SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr); | 20257 | SQLITE_PRIVATE int sqlite3ExprVectorSize(const Expr *pExpr); |
| 20782 | SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr); | 20258 | SQLITE_PRIVATE int sqlite3ExprIsVector(const Expr *pExpr); |
| 20783 | SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int); | 20259 | SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int); |
| 20784 | SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int); | 20260 | SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int,int); |
| 20785 | SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*); | 20261 | SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*); |
| 20786 | 20262 | ||
| 20787 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS | 20263 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS |
| @@ -20791,6 +20267,990 @@ SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt); | |||
| 20791 | #endif /* SQLITEINT_H */ | 20267 | #endif /* SQLITEINT_H */ |
| 20792 | 20268 | ||
| 20793 | /************** End of sqliteInt.h *******************************************/ | 20269 | /************** End of sqliteInt.h *******************************************/ |
| 20270 | /************** Begin file os_common.h ***************************************/ | ||
| 20271 | /* | ||
| 20272 | ** 2004 May 22 | ||
| 20273 | ** | ||
| 20274 | ** The author disclaims copyright to this source code. In place of | ||
| 20275 | ** a legal notice, here is a blessing: | ||
| 20276 | ** | ||
| 20277 | ** May you do good and not evil. | ||
| 20278 | ** May you find forgiveness for yourself and forgive others. | ||
| 20279 | ** May you share freely, never taking more than you give. | ||
| 20280 | ** | ||
| 20281 | ****************************************************************************** | ||
| 20282 | ** | ||
| 20283 | ** This file contains macros and a little bit of code that is common to | ||
| 20284 | ** all of the platform-specific files (os_*.c) and is #included into those | ||
| 20285 | ** files. | ||
| 20286 | ** | ||
| 20287 | ** This file should be #included by the os_*.c files only. It is not a | ||
| 20288 | ** general purpose header file. | ||
| 20289 | */ | ||
| 20290 | #ifndef _OS_COMMON_H_ | ||
| 20291 | #define _OS_COMMON_H_ | ||
| 20292 | |||
| 20293 | /* | ||
| 20294 | ** At least two bugs have slipped in because we changed the MEMORY_DEBUG | ||
| 20295 | ** macro to SQLITE_DEBUG and some older makefiles have not yet made the | ||
| 20296 | ** switch. The following code should catch this problem at compile-time. | ||
| 20297 | */ | ||
| 20298 | #ifdef MEMORY_DEBUG | ||
| 20299 | # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." | ||
| 20300 | #endif | ||
| 20301 | |||
| 20302 | /* | ||
| 20303 | ** Macros for performance tracing. Normally turned off. Only works | ||
| 20304 | ** on i486 hardware. | ||
| 20305 | */ | ||
| 20306 | #ifdef SQLITE_PERFORMANCE_TRACE | ||
| 20307 | |||
| 20308 | /* | ||
| 20309 | ** hwtime.h contains inline assembler code for implementing | ||
| 20310 | ** high-performance timing routines. | ||
| 20311 | */ | ||
| 20312 | /************** Include hwtime.h in the middle of os_common.h ****************/ | ||
| 20313 | /************** Begin file hwtime.h ******************************************/ | ||
| 20314 | /* | ||
| 20315 | ** 2008 May 27 | ||
| 20316 | ** | ||
| 20317 | ** The author disclaims copyright to this source code. In place of | ||
| 20318 | ** a legal notice, here is a blessing: | ||
| 20319 | ** | ||
| 20320 | ** May you do good and not evil. | ||
| 20321 | ** May you find forgiveness for yourself and forgive others. | ||
| 20322 | ** May you share freely, never taking more than you give. | ||
| 20323 | ** | ||
| 20324 | ****************************************************************************** | ||
| 20325 | ** | ||
| 20326 | ** This file contains inline asm code for retrieving "high-performance" | ||
| 20327 | ** counters for x86 and x86_64 class CPUs. | ||
| 20328 | */ | ||
| 20329 | #ifndef SQLITE_HWTIME_H | ||
| 20330 | #define SQLITE_HWTIME_H | ||
| 20331 | |||
| 20332 | /* | ||
| 20333 | ** The following routine only works on pentium-class (or newer) processors. | ||
| 20334 | ** It uses the RDTSC opcode to read the cycle count value out of the | ||
| 20335 | ** processor and returns that value. This can be used for high-res | ||
| 20336 | ** profiling. | ||
| 20337 | */ | ||
| 20338 | #if !defined(__STRICT_ANSI__) && \ | ||
| 20339 | (defined(__GNUC__) || defined(_MSC_VER)) && \ | ||
| 20340 | (defined(i386) || defined(__i386__) || defined(_M_IX86)) | ||
| 20341 | |||
| 20342 | #if defined(__GNUC__) | ||
| 20343 | |||
| 20344 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 20345 | unsigned int lo, hi; | ||
| 20346 | __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); | ||
| 20347 | return (sqlite_uint64)hi << 32 | lo; | ||
| 20348 | } | ||
| 20349 | |||
| 20350 | #elif defined(_MSC_VER) | ||
| 20351 | |||
| 20352 | __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){ | ||
| 20353 | __asm { | ||
| 20354 | rdtsc | ||
| 20355 | ret ; return value at EDX:EAX | ||
| 20356 | } | ||
| 20357 | } | ||
| 20358 | |||
| 20359 | #endif | ||
| 20360 | |||
| 20361 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) | ||
| 20362 | |||
| 20363 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 20364 | unsigned long val; | ||
| 20365 | __asm__ __volatile__ ("rdtsc" : "=A" (val)); | ||
| 20366 | return val; | ||
| 20367 | } | ||
| 20368 | |||
| 20369 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) | ||
| 20370 | |||
| 20371 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 20372 | unsigned long long retval; | ||
| 20373 | unsigned long junk; | ||
| 20374 | __asm__ __volatile__ ("\n\ | ||
| 20375 | 1: mftbu %1\n\ | ||
| 20376 | mftb %L0\n\ | ||
| 20377 | mftbu %0\n\ | ||
| 20378 | cmpw %0,%1\n\ | ||
| 20379 | bne 1b" | ||
| 20380 | : "=r" (retval), "=r" (junk)); | ||
| 20381 | return retval; | ||
| 20382 | } | ||
| 20383 | |||
| 20384 | #else | ||
| 20385 | |||
| 20386 | /* | ||
| 20387 | ** asm() is needed for hardware timing support. Without asm(), | ||
| 20388 | ** disable the sqlite3Hwtime() routine. | ||
| 20389 | ** | ||
| 20390 | ** sqlite3Hwtime() is only used for some obscure debugging | ||
| 20391 | ** and analysis configurations, not in any deliverable, so this | ||
| 20392 | ** should not be a great loss. | ||
| 20393 | */ | ||
| 20394 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } | ||
| 20395 | |||
| 20396 | #endif | ||
| 20397 | |||
| 20398 | #endif /* !defined(SQLITE_HWTIME_H) */ | ||
| 20399 | |||
| 20400 | /************** End of hwtime.h **********************************************/ | ||
| 20401 | /************** Continuing where we left off in os_common.h ******************/ | ||
| 20402 | |||
| 20403 | static sqlite_uint64 g_start; | ||
| 20404 | static sqlite_uint64 g_elapsed; | ||
| 20405 | #define TIMER_START g_start=sqlite3Hwtime() | ||
| 20406 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start | ||
| 20407 | #define TIMER_ELAPSED g_elapsed | ||
| 20408 | #else | ||
| 20409 | #define TIMER_START | ||
| 20410 | #define TIMER_END | ||
| 20411 | #define TIMER_ELAPSED ((sqlite_uint64)0) | ||
| 20412 | #endif | ||
| 20413 | |||
| 20414 | /* | ||
| 20415 | ** If we compile with the SQLITE_TEST macro set, then the following block | ||
| 20416 | ** of code will give us the ability to simulate a disk I/O error. This | ||
| 20417 | ** is used for testing the I/O recovery logic. | ||
| 20418 | */ | ||
| 20419 | #if defined(SQLITE_TEST) | ||
| 20420 | SQLITE_API extern int sqlite3_io_error_hit; | ||
| 20421 | SQLITE_API extern int sqlite3_io_error_hardhit; | ||
| 20422 | SQLITE_API extern int sqlite3_io_error_pending; | ||
| 20423 | SQLITE_API extern int sqlite3_io_error_persist; | ||
| 20424 | SQLITE_API extern int sqlite3_io_error_benign; | ||
| 20425 | SQLITE_API extern int sqlite3_diskfull_pending; | ||
| 20426 | SQLITE_API extern int sqlite3_diskfull; | ||
| 20427 | #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X) | ||
| 20428 | #define SimulateIOError(CODE) \ | ||
| 20429 | if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \ | ||
| 20430 | || sqlite3_io_error_pending-- == 1 ) \ | ||
| 20431 | { local_ioerr(); CODE; } | ||
| 20432 | static void local_ioerr(){ | ||
| 20433 | IOTRACE(("IOERR\n")); | ||
| 20434 | sqlite3_io_error_hit++; | ||
| 20435 | if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++; | ||
| 20436 | } | ||
| 20437 | #define SimulateDiskfullError(CODE) \ | ||
| 20438 | if( sqlite3_diskfull_pending ){ \ | ||
| 20439 | if( sqlite3_diskfull_pending == 1 ){ \ | ||
| 20440 | local_ioerr(); \ | ||
| 20441 | sqlite3_diskfull = 1; \ | ||
| 20442 | sqlite3_io_error_hit = 1; \ | ||
| 20443 | CODE; \ | ||
| 20444 | }else{ \ | ||
| 20445 | sqlite3_diskfull_pending--; \ | ||
| 20446 | } \ | ||
| 20447 | } | ||
| 20448 | #else | ||
| 20449 | #define SimulateIOErrorBenign(X) | ||
| 20450 | #define SimulateIOError(A) | ||
| 20451 | #define SimulateDiskfullError(A) | ||
| 20452 | #endif /* defined(SQLITE_TEST) */ | ||
| 20453 | |||
| 20454 | /* | ||
| 20455 | ** When testing, keep a count of the number of open files. | ||
| 20456 | */ | ||
| 20457 | #if defined(SQLITE_TEST) | ||
| 20458 | SQLITE_API extern int sqlite3_open_file_count; | ||
| 20459 | #define OpenCounter(X) sqlite3_open_file_count+=(X) | ||
| 20460 | #else | ||
| 20461 | #define OpenCounter(X) | ||
| 20462 | #endif /* defined(SQLITE_TEST) */ | ||
| 20463 | |||
| 20464 | #endif /* !defined(_OS_COMMON_H_) */ | ||
| 20465 | |||
| 20466 | /************** End of os_common.h *******************************************/ | ||
| 20467 | /************** Begin file ctime.c *******************************************/ | ||
| 20468 | /* | ||
| 20469 | ** 2010 February 23 | ||
| 20470 | ** | ||
| 20471 | ** The author disclaims copyright to this source code. In place of | ||
| 20472 | ** a legal notice, here is a blessing: | ||
| 20473 | ** | ||
| 20474 | ** May you do good and not evil. | ||
| 20475 | ** May you find forgiveness for yourself and forgive others. | ||
| 20476 | ** May you share freely, never taking more than you give. | ||
| 20477 | ** | ||
| 20478 | ************************************************************************* | ||
| 20479 | ** | ||
| 20480 | ** This file implements routines used to report what compile-time options | ||
| 20481 | ** SQLite was built with. | ||
| 20482 | */ | ||
| 20483 | #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */ | ||
| 20484 | |||
| 20485 | /* | ||
| 20486 | ** Include the configuration header output by 'configure' if we're using the | ||
| 20487 | ** autoconf-based build | ||
| 20488 | */ | ||
| 20489 | #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H) | ||
| 20490 | /* #include "config.h" */ | ||
| 20491 | #define SQLITECONFIG_H 1 | ||
| 20492 | #endif | ||
| 20493 | |||
| 20494 | /* These macros are provided to "stringify" the value of the define | ||
| 20495 | ** for those options in which the value is meaningful. */ | ||
| 20496 | #define CTIMEOPT_VAL_(opt) #opt | ||
| 20497 | #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt) | ||
| 20498 | |||
| 20499 | /* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This | ||
| 20500 | ** option requires a separate macro because legal values contain a single | ||
| 20501 | ** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */ | ||
| 20502 | #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2 | ||
| 20503 | #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt) | ||
| 20504 | /* #include "sqliteInt.h" */ | ||
| 20505 | |||
| 20506 | /* | ||
| 20507 | ** An array of names of all compile-time options. This array should | ||
| 20508 | ** be sorted A-Z. | ||
| 20509 | ** | ||
| 20510 | ** This array looks large, but in a typical installation actually uses | ||
| 20511 | ** only a handful of compile-time options, so most times this array is usually | ||
| 20512 | ** rather short and uses little memory space. | ||
| 20513 | */ | ||
| 20514 | static const char * const sqlite3azCompileOpt[] = { | ||
| 20515 | |||
| 20516 | /* | ||
| 20517 | ** BEGIN CODE GENERATED BY tool/mkctime.tcl | ||
| 20518 | */ | ||
| 20519 | #ifdef SQLITE_32BIT_ROWID | ||
| 20520 | "32BIT_ROWID", | ||
| 20521 | #endif | ||
| 20522 | #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC | ||
| 20523 | "4_BYTE_ALIGNED_MALLOC", | ||
| 20524 | #endif | ||
| 20525 | #ifdef SQLITE_64BIT_STATS | ||
| 20526 | "64BIT_STATS", | ||
| 20527 | #endif | ||
| 20528 | #ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN | ||
| 20529 | # if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1 | ||
| 20530 | "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN), | ||
| 20531 | # endif | ||
| 20532 | #endif | ||
| 20533 | #ifdef SQLITE_ALLOW_URI_AUTHORITY | ||
| 20534 | "ALLOW_URI_AUTHORITY", | ||
| 20535 | #endif | ||
| 20536 | #ifdef SQLITE_ATOMIC_INTRINSICS | ||
| 20537 | "ATOMIC_INTRINSICS=" CTIMEOPT_VAL(SQLITE_ATOMIC_INTRINSICS), | ||
| 20538 | #endif | ||
| 20539 | #ifdef SQLITE_BITMASK_TYPE | ||
| 20540 | "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE), | ||
| 20541 | #endif | ||
| 20542 | #ifdef SQLITE_BUG_COMPATIBLE_20160819 | ||
| 20543 | "BUG_COMPATIBLE_20160819", | ||
| 20544 | #endif | ||
| 20545 | #ifdef SQLITE_CASE_SENSITIVE_LIKE | ||
| 20546 | "CASE_SENSITIVE_LIKE", | ||
| 20547 | #endif | ||
| 20548 | #ifdef SQLITE_CHECK_PAGES | ||
| 20549 | "CHECK_PAGES", | ||
| 20550 | #endif | ||
| 20551 | #if defined(__clang__) && defined(__clang_major__) | ||
| 20552 | "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "." | ||
| 20553 | CTIMEOPT_VAL(__clang_minor__) "." | ||
| 20554 | CTIMEOPT_VAL(__clang_patchlevel__), | ||
| 20555 | #elif defined(_MSC_VER) | ||
| 20556 | "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER), | ||
| 20557 | #elif defined(__GNUC__) && defined(__VERSION__) | ||
| 20558 | "COMPILER=gcc-" __VERSION__, | ||
| 20559 | #endif | ||
| 20560 | #ifdef SQLITE_COVERAGE_TEST | ||
| 20561 | "COVERAGE_TEST", | ||
| 20562 | #endif | ||
| 20563 | #ifdef SQLITE_DEBUG | ||
| 20564 | "DEBUG", | ||
| 20565 | #endif | ||
| 20566 | #ifdef SQLITE_DEFAULT_AUTOMATIC_INDEX | ||
| 20567 | "DEFAULT_AUTOMATIC_INDEX", | ||
| 20568 | #endif | ||
| 20569 | #ifdef SQLITE_DEFAULT_AUTOVACUUM | ||
| 20570 | "DEFAULT_AUTOVACUUM", | ||
| 20571 | #endif | ||
| 20572 | #ifdef SQLITE_DEFAULT_CACHE_SIZE | ||
| 20573 | "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE), | ||
| 20574 | #endif | ||
| 20575 | #ifdef SQLITE_DEFAULT_CKPTFULLFSYNC | ||
| 20576 | "DEFAULT_CKPTFULLFSYNC", | ||
| 20577 | #endif | ||
| 20578 | #ifdef SQLITE_DEFAULT_FILE_FORMAT | ||
| 20579 | "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT), | ||
| 20580 | #endif | ||
| 20581 | #ifdef SQLITE_DEFAULT_FILE_PERMISSIONS | ||
| 20582 | "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS), | ||
| 20583 | #endif | ||
| 20584 | #ifdef SQLITE_DEFAULT_FOREIGN_KEYS | ||
| 20585 | "DEFAULT_FOREIGN_KEYS", | ||
| 20586 | #endif | ||
| 20587 | #ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT | ||
| 20588 | "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT), | ||
| 20589 | #endif | ||
| 20590 | #ifdef SQLITE_DEFAULT_LOCKING_MODE | ||
| 20591 | "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE), | ||
| 20592 | #endif | ||
| 20593 | #ifdef SQLITE_DEFAULT_LOOKASIDE | ||
| 20594 | "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE), | ||
| 20595 | #endif | ||
| 20596 | #ifdef SQLITE_DEFAULT_MEMSTATUS | ||
| 20597 | # if SQLITE_DEFAULT_MEMSTATUS != 1 | ||
| 20598 | "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS), | ||
| 20599 | # endif | ||
| 20600 | #endif | ||
| 20601 | #ifdef SQLITE_DEFAULT_MMAP_SIZE | ||
| 20602 | "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE), | ||
| 20603 | #endif | ||
| 20604 | #ifdef SQLITE_DEFAULT_PAGE_SIZE | ||
| 20605 | "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE), | ||
| 20606 | #endif | ||
| 20607 | #ifdef SQLITE_DEFAULT_PCACHE_INITSZ | ||
| 20608 | "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ), | ||
| 20609 | #endif | ||
| 20610 | #ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS | ||
| 20611 | "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS), | ||
| 20612 | #endif | ||
| 20613 | #ifdef SQLITE_DEFAULT_RECURSIVE_TRIGGERS | ||
| 20614 | "DEFAULT_RECURSIVE_TRIGGERS", | ||
| 20615 | #endif | ||
| 20616 | #ifdef SQLITE_DEFAULT_ROWEST | ||
| 20617 | "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST), | ||
| 20618 | #endif | ||
| 20619 | #ifdef SQLITE_DEFAULT_SECTOR_SIZE | ||
| 20620 | "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE), | ||
| 20621 | #endif | ||
| 20622 | #ifdef SQLITE_DEFAULT_SYNCHRONOUS | ||
| 20623 | "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS), | ||
| 20624 | #endif | ||
| 20625 | #ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT | ||
| 20626 | "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT), | ||
| 20627 | #endif | ||
| 20628 | #ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS | ||
| 20629 | "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS), | ||
| 20630 | #endif | ||
| 20631 | #ifdef SQLITE_DEFAULT_WORKER_THREADS | ||
| 20632 | "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS), | ||
| 20633 | #endif | ||
| 20634 | #ifdef SQLITE_DIRECT_OVERFLOW_READ | ||
| 20635 | "DIRECT_OVERFLOW_READ", | ||
| 20636 | #endif | ||
| 20637 | #ifdef SQLITE_DISABLE_DIRSYNC | ||
| 20638 | "DISABLE_DIRSYNC", | ||
| 20639 | #endif | ||
| 20640 | #ifdef SQLITE_DISABLE_FTS3_UNICODE | ||
| 20641 | "DISABLE_FTS3_UNICODE", | ||
| 20642 | #endif | ||
| 20643 | #ifdef SQLITE_DISABLE_FTS4_DEFERRED | ||
| 20644 | "DISABLE_FTS4_DEFERRED", | ||
| 20645 | #endif | ||
| 20646 | #ifdef SQLITE_DISABLE_INTRINSIC | ||
| 20647 | "DISABLE_INTRINSIC", | ||
| 20648 | #endif | ||
| 20649 | #ifdef SQLITE_DISABLE_LFS | ||
| 20650 | "DISABLE_LFS", | ||
| 20651 | #endif | ||
| 20652 | #ifdef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS | ||
| 20653 | "DISABLE_PAGECACHE_OVERFLOW_STATS", | ||
| 20654 | #endif | ||
| 20655 | #ifdef SQLITE_DISABLE_SKIPAHEAD_DISTINCT | ||
| 20656 | "DISABLE_SKIPAHEAD_DISTINCT", | ||
| 20657 | #endif | ||
| 20658 | #ifdef SQLITE_ENABLE_8_3_NAMES | ||
| 20659 | "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES), | ||
| 20660 | #endif | ||
| 20661 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 20662 | "ENABLE_API_ARMOR", | ||
| 20663 | #endif | ||
| 20664 | #ifdef SQLITE_ENABLE_ATOMIC_WRITE | ||
| 20665 | "ENABLE_ATOMIC_WRITE", | ||
| 20666 | #endif | ||
| 20667 | #ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE | ||
| 20668 | "ENABLE_BATCH_ATOMIC_WRITE", | ||
| 20669 | #endif | ||
| 20670 | #ifdef SQLITE_ENABLE_BYTECODE_VTAB | ||
| 20671 | "ENABLE_BYTECODE_VTAB", | ||
| 20672 | #endif | ||
| 20673 | #ifdef SQLITE_ENABLE_CEROD | ||
| 20674 | "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD), | ||
| 20675 | #endif | ||
| 20676 | #ifdef SQLITE_ENABLE_COLUMN_METADATA | ||
| 20677 | "ENABLE_COLUMN_METADATA", | ||
| 20678 | #endif | ||
| 20679 | #ifdef SQLITE_ENABLE_COLUMN_USED_MASK | ||
| 20680 | "ENABLE_COLUMN_USED_MASK", | ||
| 20681 | #endif | ||
| 20682 | #ifdef SQLITE_ENABLE_COSTMULT | ||
| 20683 | "ENABLE_COSTMULT", | ||
| 20684 | #endif | ||
| 20685 | #ifdef SQLITE_ENABLE_CURSOR_HINTS | ||
| 20686 | "ENABLE_CURSOR_HINTS", | ||
| 20687 | #endif | ||
| 20688 | #ifdef SQLITE_ENABLE_DBPAGE_VTAB | ||
| 20689 | "ENABLE_DBPAGE_VTAB", | ||
| 20690 | #endif | ||
| 20691 | #ifdef SQLITE_ENABLE_DBSTAT_VTAB | ||
| 20692 | "ENABLE_DBSTAT_VTAB", | ||
| 20693 | #endif | ||
| 20694 | #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT | ||
| 20695 | "ENABLE_EXPENSIVE_ASSERT", | ||
| 20696 | #endif | ||
| 20697 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS | ||
| 20698 | "ENABLE_EXPLAIN_COMMENTS", | ||
| 20699 | #endif | ||
| 20700 | #ifdef SQLITE_ENABLE_FTS3 | ||
| 20701 | "ENABLE_FTS3", | ||
| 20702 | #endif | ||
| 20703 | #ifdef SQLITE_ENABLE_FTS3_PARENTHESIS | ||
| 20704 | "ENABLE_FTS3_PARENTHESIS", | ||
| 20705 | #endif | ||
| 20706 | #ifdef SQLITE_ENABLE_FTS3_TOKENIZER | ||
| 20707 | "ENABLE_FTS3_TOKENIZER", | ||
| 20708 | #endif | ||
| 20709 | #ifdef SQLITE_ENABLE_FTS4 | ||
| 20710 | "ENABLE_FTS4", | ||
| 20711 | #endif | ||
| 20712 | #ifdef SQLITE_ENABLE_FTS5 | ||
| 20713 | "ENABLE_FTS5", | ||
| 20714 | #endif | ||
| 20715 | #ifdef SQLITE_ENABLE_GEOPOLY | ||
| 20716 | "ENABLE_GEOPOLY", | ||
| 20717 | #endif | ||
| 20718 | #ifdef SQLITE_ENABLE_HIDDEN_COLUMNS | ||
| 20719 | "ENABLE_HIDDEN_COLUMNS", | ||
| 20720 | #endif | ||
| 20721 | #ifdef SQLITE_ENABLE_ICU | ||
| 20722 | "ENABLE_ICU", | ||
| 20723 | #endif | ||
| 20724 | #ifdef SQLITE_ENABLE_IOTRACE | ||
| 20725 | "ENABLE_IOTRACE", | ||
| 20726 | #endif | ||
| 20727 | #ifdef SQLITE_ENABLE_JSON1 | ||
| 20728 | "ENABLE_JSON1", | ||
| 20729 | #endif | ||
| 20730 | #ifdef SQLITE_ENABLE_LOAD_EXTENSION | ||
| 20731 | "ENABLE_LOAD_EXTENSION", | ||
| 20732 | #endif | ||
| 20733 | #ifdef SQLITE_ENABLE_LOCKING_STYLE | ||
| 20734 | "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE), | ||
| 20735 | #endif | ||
| 20736 | #ifdef SQLITE_ENABLE_MATH_FUNCTIONS | ||
| 20737 | "ENABLE_MATH_FUNCTIONS", | ||
| 20738 | #endif | ||
| 20739 | #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT | ||
| 20740 | "ENABLE_MEMORY_MANAGEMENT", | ||
| 20741 | #endif | ||
| 20742 | #ifdef SQLITE_ENABLE_MEMSYS3 | ||
| 20743 | "ENABLE_MEMSYS3", | ||
| 20744 | #endif | ||
| 20745 | #ifdef SQLITE_ENABLE_MEMSYS5 | ||
| 20746 | "ENABLE_MEMSYS5", | ||
| 20747 | #endif | ||
| 20748 | #ifdef SQLITE_ENABLE_MULTIPLEX | ||
| 20749 | "ENABLE_MULTIPLEX", | ||
| 20750 | #endif | ||
| 20751 | #ifdef SQLITE_ENABLE_NORMALIZE | ||
| 20752 | "ENABLE_NORMALIZE", | ||
| 20753 | #endif | ||
| 20754 | #ifdef SQLITE_ENABLE_NULL_TRIM | ||
| 20755 | "ENABLE_NULL_TRIM", | ||
| 20756 | #endif | ||
| 20757 | #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC | ||
| 20758 | "ENABLE_OFFSET_SQL_FUNC", | ||
| 20759 | #endif | ||
| 20760 | #ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK | ||
| 20761 | "ENABLE_OVERSIZE_CELL_CHECK", | ||
| 20762 | #endif | ||
| 20763 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | ||
| 20764 | "ENABLE_PREUPDATE_HOOK", | ||
| 20765 | #endif | ||
| 20766 | #ifdef SQLITE_ENABLE_QPSG | ||
| 20767 | "ENABLE_QPSG", | ||
| 20768 | #endif | ||
| 20769 | #ifdef SQLITE_ENABLE_RBU | ||
| 20770 | "ENABLE_RBU", | ||
| 20771 | #endif | ||
| 20772 | #ifdef SQLITE_ENABLE_RTREE | ||
| 20773 | "ENABLE_RTREE", | ||
| 20774 | #endif | ||
| 20775 | #ifdef SQLITE_ENABLE_SELECTTRACE | ||
| 20776 | "ENABLE_SELECTTRACE", | ||
| 20777 | #endif | ||
| 20778 | #ifdef SQLITE_ENABLE_SESSION | ||
| 20779 | "ENABLE_SESSION", | ||
| 20780 | #endif | ||
| 20781 | #ifdef SQLITE_ENABLE_SNAPSHOT | ||
| 20782 | "ENABLE_SNAPSHOT", | ||
| 20783 | #endif | ||
| 20784 | #ifdef SQLITE_ENABLE_SORTER_REFERENCES | ||
| 20785 | "ENABLE_SORTER_REFERENCES", | ||
| 20786 | #endif | ||
| 20787 | #ifdef SQLITE_ENABLE_SQLLOG | ||
| 20788 | "ENABLE_SQLLOG", | ||
| 20789 | #endif | ||
| 20790 | #ifdef SQLITE_ENABLE_STAT4 | ||
| 20791 | "ENABLE_STAT4", | ||
| 20792 | #endif | ||
| 20793 | #ifdef SQLITE_ENABLE_STMTVTAB | ||
| 20794 | "ENABLE_STMTVTAB", | ||
| 20795 | #endif | ||
| 20796 | #ifdef SQLITE_ENABLE_STMT_SCANSTATUS | ||
| 20797 | "ENABLE_STMT_SCANSTATUS", | ||
| 20798 | #endif | ||
| 20799 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION | ||
| 20800 | "ENABLE_UNKNOWN_SQL_FUNCTION", | ||
| 20801 | #endif | ||
| 20802 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY | ||
| 20803 | "ENABLE_UNLOCK_NOTIFY", | ||
| 20804 | #endif | ||
| 20805 | #ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT | ||
| 20806 | "ENABLE_UPDATE_DELETE_LIMIT", | ||
| 20807 | #endif | ||
| 20808 | #ifdef SQLITE_ENABLE_URI_00_ERROR | ||
| 20809 | "ENABLE_URI_00_ERROR", | ||
| 20810 | #endif | ||
| 20811 | #ifdef SQLITE_ENABLE_VFSTRACE | ||
| 20812 | "ENABLE_VFSTRACE", | ||
| 20813 | #endif | ||
| 20814 | #ifdef SQLITE_ENABLE_WHERETRACE | ||
| 20815 | "ENABLE_WHERETRACE", | ||
| 20816 | #endif | ||
| 20817 | #ifdef SQLITE_ENABLE_ZIPVFS | ||
| 20818 | "ENABLE_ZIPVFS", | ||
| 20819 | #endif | ||
| 20820 | #ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS | ||
| 20821 | "EXPLAIN_ESTIMATED_ROWS", | ||
| 20822 | #endif | ||
| 20823 | #ifdef SQLITE_EXTRA_IFNULLROW | ||
| 20824 | "EXTRA_IFNULLROW", | ||
| 20825 | #endif | ||
| 20826 | #ifdef SQLITE_EXTRA_INIT | ||
| 20827 | "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT), | ||
| 20828 | #endif | ||
| 20829 | #ifdef SQLITE_EXTRA_SHUTDOWN | ||
| 20830 | "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN), | ||
| 20831 | #endif | ||
| 20832 | #ifdef SQLITE_FTS3_MAX_EXPR_DEPTH | ||
| 20833 | "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH), | ||
| 20834 | #endif | ||
| 20835 | #ifdef SQLITE_FTS5_ENABLE_TEST_MI | ||
| 20836 | "FTS5_ENABLE_TEST_MI", | ||
| 20837 | #endif | ||
| 20838 | #ifdef SQLITE_FTS5_NO_WITHOUT_ROWID | ||
| 20839 | "FTS5_NO_WITHOUT_ROWID", | ||
| 20840 | #endif | ||
| 20841 | #if HAVE_ISNAN || SQLITE_HAVE_ISNAN | ||
| 20842 | "HAVE_ISNAN", | ||
| 20843 | #endif | ||
| 20844 | #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX | ||
| 20845 | # if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1 | ||
| 20846 | "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX), | ||
| 20847 | # endif | ||
| 20848 | #endif | ||
| 20849 | #ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS | ||
| 20850 | "IGNORE_AFP_LOCK_ERRORS", | ||
| 20851 | #endif | ||
| 20852 | #ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS | ||
| 20853 | "IGNORE_FLOCK_LOCK_ERRORS", | ||
| 20854 | #endif | ||
| 20855 | #ifdef SQLITE_INLINE_MEMCPY | ||
| 20856 | "INLINE_MEMCPY", | ||
| 20857 | #endif | ||
| 20858 | #ifdef SQLITE_INT64_TYPE | ||
| 20859 | "INT64_TYPE", | ||
| 20860 | #endif | ||
| 20861 | #ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX | ||
| 20862 | "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX), | ||
| 20863 | #endif | ||
| 20864 | #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS | ||
| 20865 | "LIKE_DOESNT_MATCH_BLOBS", | ||
| 20866 | #endif | ||
| 20867 | #ifdef SQLITE_LOCK_TRACE | ||
| 20868 | "LOCK_TRACE", | ||
| 20869 | #endif | ||
| 20870 | #ifdef SQLITE_LOG_CACHE_SPILL | ||
| 20871 | "LOG_CACHE_SPILL", | ||
| 20872 | #endif | ||
| 20873 | #ifdef SQLITE_MALLOC_SOFT_LIMIT | ||
| 20874 | "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT), | ||
| 20875 | #endif | ||
| 20876 | #ifdef SQLITE_MAX_ATTACHED | ||
| 20877 | "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED), | ||
| 20878 | #endif | ||
| 20879 | #ifdef SQLITE_MAX_COLUMN | ||
| 20880 | "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN), | ||
| 20881 | #endif | ||
| 20882 | #ifdef SQLITE_MAX_COMPOUND_SELECT | ||
| 20883 | "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT), | ||
| 20884 | #endif | ||
| 20885 | #ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE | ||
| 20886 | "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE), | ||
| 20887 | #endif | ||
| 20888 | #ifdef SQLITE_MAX_EXPR_DEPTH | ||
| 20889 | "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH), | ||
| 20890 | #endif | ||
| 20891 | #ifdef SQLITE_MAX_FUNCTION_ARG | ||
| 20892 | "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG), | ||
| 20893 | #endif | ||
| 20894 | #ifdef SQLITE_MAX_LENGTH | ||
| 20895 | "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH), | ||
| 20896 | #endif | ||
| 20897 | #ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH | ||
| 20898 | "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH), | ||
| 20899 | #endif | ||
| 20900 | #ifdef SQLITE_MAX_MEMORY | ||
| 20901 | "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY), | ||
| 20902 | #endif | ||
| 20903 | #ifdef SQLITE_MAX_MMAP_SIZE | ||
| 20904 | "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE), | ||
| 20905 | #endif | ||
| 20906 | #ifdef SQLITE_MAX_MMAP_SIZE_ | ||
| 20907 | "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_), | ||
| 20908 | #endif | ||
| 20909 | #ifdef SQLITE_MAX_PAGE_COUNT | ||
| 20910 | "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT), | ||
| 20911 | #endif | ||
| 20912 | #ifdef SQLITE_MAX_PAGE_SIZE | ||
| 20913 | "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE), | ||
| 20914 | #endif | ||
| 20915 | #ifdef SQLITE_MAX_SCHEMA_RETRY | ||
| 20916 | "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY), | ||
| 20917 | #endif | ||
| 20918 | #ifdef SQLITE_MAX_SQL_LENGTH | ||
| 20919 | "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH), | ||
| 20920 | #endif | ||
| 20921 | #ifdef SQLITE_MAX_TRIGGER_DEPTH | ||
| 20922 | "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH), | ||
| 20923 | #endif | ||
| 20924 | #ifdef SQLITE_MAX_VARIABLE_NUMBER | ||
| 20925 | "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER), | ||
| 20926 | #endif | ||
| 20927 | #ifdef SQLITE_MAX_VDBE_OP | ||
| 20928 | "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP), | ||
| 20929 | #endif | ||
| 20930 | #ifdef SQLITE_MAX_WORKER_THREADS | ||
| 20931 | "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS), | ||
| 20932 | #endif | ||
| 20933 | #ifdef SQLITE_MEMDEBUG | ||
| 20934 | "MEMDEBUG", | ||
| 20935 | #endif | ||
| 20936 | #ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT | ||
| 20937 | "MIXED_ENDIAN_64BIT_FLOAT", | ||
| 20938 | #endif | ||
| 20939 | #ifdef SQLITE_MMAP_READWRITE | ||
| 20940 | "MMAP_READWRITE", | ||
| 20941 | #endif | ||
| 20942 | #ifdef SQLITE_MUTEX_NOOP | ||
| 20943 | "MUTEX_NOOP", | ||
| 20944 | #endif | ||
| 20945 | #ifdef SQLITE_MUTEX_OMIT | ||
| 20946 | "MUTEX_OMIT", | ||
| 20947 | #endif | ||
| 20948 | #ifdef SQLITE_MUTEX_PTHREADS | ||
| 20949 | "MUTEX_PTHREADS", | ||
| 20950 | #endif | ||
| 20951 | #ifdef SQLITE_MUTEX_W32 | ||
| 20952 | "MUTEX_W32", | ||
| 20953 | #endif | ||
| 20954 | #ifdef SQLITE_NEED_ERR_NAME | ||
| 20955 | "NEED_ERR_NAME", | ||
| 20956 | #endif | ||
| 20957 | #ifdef SQLITE_NO_SYNC | ||
| 20958 | "NO_SYNC", | ||
| 20959 | #endif | ||
| 20960 | #ifdef SQLITE_OMIT_ALTERTABLE | ||
| 20961 | "OMIT_ALTERTABLE", | ||
| 20962 | #endif | ||
| 20963 | #ifdef SQLITE_OMIT_ANALYZE | ||
| 20964 | "OMIT_ANALYZE", | ||
| 20965 | #endif | ||
| 20966 | #ifdef SQLITE_OMIT_ATTACH | ||
| 20967 | "OMIT_ATTACH", | ||
| 20968 | #endif | ||
| 20969 | #ifdef SQLITE_OMIT_AUTHORIZATION | ||
| 20970 | "OMIT_AUTHORIZATION", | ||
| 20971 | #endif | ||
| 20972 | #ifdef SQLITE_OMIT_AUTOINCREMENT | ||
| 20973 | "OMIT_AUTOINCREMENT", | ||
| 20974 | #endif | ||
| 20975 | #ifdef SQLITE_OMIT_AUTOINIT | ||
| 20976 | "OMIT_AUTOINIT", | ||
| 20977 | #endif | ||
| 20978 | #ifdef SQLITE_OMIT_AUTOMATIC_INDEX | ||
| 20979 | "OMIT_AUTOMATIC_INDEX", | ||
| 20980 | #endif | ||
| 20981 | #ifdef SQLITE_OMIT_AUTORESET | ||
| 20982 | "OMIT_AUTORESET", | ||
| 20983 | #endif | ||
| 20984 | #ifdef SQLITE_OMIT_AUTOVACUUM | ||
| 20985 | "OMIT_AUTOVACUUM", | ||
| 20986 | #endif | ||
| 20987 | #ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION | ||
| 20988 | "OMIT_BETWEEN_OPTIMIZATION", | ||
| 20989 | #endif | ||
| 20990 | #ifdef SQLITE_OMIT_BLOB_LITERAL | ||
| 20991 | "OMIT_BLOB_LITERAL", | ||
| 20992 | #endif | ||
| 20993 | #ifdef SQLITE_OMIT_CAST | ||
| 20994 | "OMIT_CAST", | ||
| 20995 | #endif | ||
| 20996 | #ifdef SQLITE_OMIT_CHECK | ||
| 20997 | "OMIT_CHECK", | ||
| 20998 | #endif | ||
| 20999 | #ifdef SQLITE_OMIT_COMPLETE | ||
| 21000 | "OMIT_COMPLETE", | ||
| 21001 | #endif | ||
| 21002 | #ifdef SQLITE_OMIT_COMPOUND_SELECT | ||
| 21003 | "OMIT_COMPOUND_SELECT", | ||
| 21004 | #endif | ||
| 21005 | #ifdef SQLITE_OMIT_CONFLICT_CLAUSE | ||
| 21006 | "OMIT_CONFLICT_CLAUSE", | ||
| 21007 | #endif | ||
| 21008 | #ifdef SQLITE_OMIT_CTE | ||
| 21009 | "OMIT_CTE", | ||
| 21010 | #endif | ||
| 21011 | #if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT) | ||
| 21012 | "OMIT_DATETIME_FUNCS", | ||
| 21013 | #endif | ||
| 21014 | #ifdef SQLITE_OMIT_DECLTYPE | ||
| 21015 | "OMIT_DECLTYPE", | ||
| 21016 | #endif | ||
| 21017 | #ifdef SQLITE_OMIT_DEPRECATED | ||
| 21018 | "OMIT_DEPRECATED", | ||
| 21019 | #endif | ||
| 21020 | #ifdef SQLITE_OMIT_DESERIALIZE | ||
| 21021 | "OMIT_DESERIALIZE", | ||
| 21022 | #endif | ||
| 21023 | #ifdef SQLITE_OMIT_DISKIO | ||
| 21024 | "OMIT_DISKIO", | ||
| 21025 | #endif | ||
| 21026 | #ifdef SQLITE_OMIT_EXPLAIN | ||
| 21027 | "OMIT_EXPLAIN", | ||
| 21028 | #endif | ||
| 21029 | #ifdef SQLITE_OMIT_FLAG_PRAGMAS | ||
| 21030 | "OMIT_FLAG_PRAGMAS", | ||
| 21031 | #endif | ||
| 21032 | #ifdef SQLITE_OMIT_FLOATING_POINT | ||
| 21033 | "OMIT_FLOATING_POINT", | ||
| 21034 | #endif | ||
| 21035 | #ifdef SQLITE_OMIT_FOREIGN_KEY | ||
| 21036 | "OMIT_FOREIGN_KEY", | ||
| 21037 | #endif | ||
| 21038 | #ifdef SQLITE_OMIT_GET_TABLE | ||
| 21039 | "OMIT_GET_TABLE", | ||
| 21040 | #endif | ||
| 21041 | #ifdef SQLITE_OMIT_HEX_INTEGER | ||
| 21042 | "OMIT_HEX_INTEGER", | ||
| 21043 | #endif | ||
| 21044 | #ifdef SQLITE_OMIT_INCRBLOB | ||
| 21045 | "OMIT_INCRBLOB", | ||
| 21046 | #endif | ||
| 21047 | #ifdef SQLITE_OMIT_INTEGRITY_CHECK | ||
| 21048 | "OMIT_INTEGRITY_CHECK", | ||
| 21049 | #endif | ||
| 21050 | #ifdef SQLITE_OMIT_INTROSPECTION_PRAGMAS | ||
| 21051 | "OMIT_INTROSPECTION_PRAGMAS", | ||
| 21052 | #endif | ||
| 21053 | #ifdef SQLITE_OMIT_LIKE_OPTIMIZATION | ||
| 21054 | "OMIT_LIKE_OPTIMIZATION", | ||
| 21055 | #endif | ||
| 21056 | #ifdef SQLITE_OMIT_LOAD_EXTENSION | ||
| 21057 | "OMIT_LOAD_EXTENSION", | ||
| 21058 | #endif | ||
| 21059 | #ifdef SQLITE_OMIT_LOCALTIME | ||
| 21060 | "OMIT_LOCALTIME", | ||
| 21061 | #endif | ||
| 21062 | #ifdef SQLITE_OMIT_LOOKASIDE | ||
| 21063 | "OMIT_LOOKASIDE", | ||
| 21064 | #endif | ||
| 21065 | #ifdef SQLITE_OMIT_MEMORYDB | ||
| 21066 | "OMIT_MEMORYDB", | ||
| 21067 | #endif | ||
| 21068 | #ifdef SQLITE_OMIT_OR_OPTIMIZATION | ||
| 21069 | "OMIT_OR_OPTIMIZATION", | ||
| 21070 | #endif | ||
| 21071 | #ifdef SQLITE_OMIT_PAGER_PRAGMAS | ||
| 21072 | "OMIT_PAGER_PRAGMAS", | ||
| 21073 | #endif | ||
| 21074 | #ifdef SQLITE_OMIT_PARSER_TRACE | ||
| 21075 | "OMIT_PARSER_TRACE", | ||
| 21076 | #endif | ||
| 21077 | #ifdef SQLITE_OMIT_POPEN | ||
| 21078 | "OMIT_POPEN", | ||
| 21079 | #endif | ||
| 21080 | #ifdef SQLITE_OMIT_PRAGMA | ||
| 21081 | "OMIT_PRAGMA", | ||
| 21082 | #endif | ||
| 21083 | #ifdef SQLITE_OMIT_PROGRESS_CALLBACK | ||
| 21084 | "OMIT_PROGRESS_CALLBACK", | ||
| 21085 | #endif | ||
| 21086 | #ifdef SQLITE_OMIT_QUICKBALANCE | ||
| 21087 | "OMIT_QUICKBALANCE", | ||
| 21088 | #endif | ||
| 21089 | #ifdef SQLITE_OMIT_REINDEX | ||
| 21090 | "OMIT_REINDEX", | ||
| 21091 | #endif | ||
| 21092 | #ifdef SQLITE_OMIT_SCHEMA_PRAGMAS | ||
| 21093 | "OMIT_SCHEMA_PRAGMAS", | ||
| 21094 | #endif | ||
| 21095 | #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS | ||
| 21096 | "OMIT_SCHEMA_VERSION_PRAGMAS", | ||
| 21097 | #endif | ||
| 21098 | #ifdef SQLITE_OMIT_SHARED_CACHE | ||
| 21099 | "OMIT_SHARED_CACHE", | ||
| 21100 | #endif | ||
| 21101 | #ifdef SQLITE_OMIT_SHUTDOWN_DIRECTORIES | ||
| 21102 | "OMIT_SHUTDOWN_DIRECTORIES", | ||
| 21103 | #endif | ||
| 21104 | #ifdef SQLITE_OMIT_SUBQUERY | ||
| 21105 | "OMIT_SUBQUERY", | ||
| 21106 | #endif | ||
| 21107 | #ifdef SQLITE_OMIT_TCL_VARIABLE | ||
| 21108 | "OMIT_TCL_VARIABLE", | ||
| 21109 | #endif | ||
| 21110 | #ifdef SQLITE_OMIT_TEMPDB | ||
| 21111 | "OMIT_TEMPDB", | ||
| 21112 | #endif | ||
| 21113 | #ifdef SQLITE_OMIT_TEST_CONTROL | ||
| 21114 | "OMIT_TEST_CONTROL", | ||
| 21115 | #endif | ||
| 21116 | #ifdef SQLITE_OMIT_TRACE | ||
| 21117 | # if SQLITE_OMIT_TRACE != 1 | ||
| 21118 | "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE), | ||
| 21119 | # endif | ||
| 21120 | #endif | ||
| 21121 | #ifdef SQLITE_OMIT_TRIGGER | ||
| 21122 | "OMIT_TRIGGER", | ||
| 21123 | #endif | ||
| 21124 | #ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION | ||
| 21125 | "OMIT_TRUNCATE_OPTIMIZATION", | ||
| 21126 | #endif | ||
| 21127 | #ifdef SQLITE_OMIT_UTF16 | ||
| 21128 | "OMIT_UTF16", | ||
| 21129 | #endif | ||
| 21130 | #ifdef SQLITE_OMIT_VACUUM | ||
| 21131 | "OMIT_VACUUM", | ||
| 21132 | #endif | ||
| 21133 | #ifdef SQLITE_OMIT_VIEW | ||
| 21134 | "OMIT_VIEW", | ||
| 21135 | #endif | ||
| 21136 | #ifdef SQLITE_OMIT_VIRTUALTABLE | ||
| 21137 | "OMIT_VIRTUALTABLE", | ||
| 21138 | #endif | ||
| 21139 | #ifdef SQLITE_OMIT_WAL | ||
| 21140 | "OMIT_WAL", | ||
| 21141 | #endif | ||
| 21142 | #ifdef SQLITE_OMIT_WSD | ||
| 21143 | "OMIT_WSD", | ||
| 21144 | #endif | ||
| 21145 | #ifdef SQLITE_OMIT_XFER_OPT | ||
| 21146 | "OMIT_XFER_OPT", | ||
| 21147 | #endif | ||
| 21148 | #ifdef SQLITE_PCACHE_SEPARATE_HEADER | ||
| 21149 | "PCACHE_SEPARATE_HEADER", | ||
| 21150 | #endif | ||
| 21151 | #ifdef SQLITE_PERFORMANCE_TRACE | ||
| 21152 | "PERFORMANCE_TRACE", | ||
| 21153 | #endif | ||
| 21154 | #ifdef SQLITE_POWERSAFE_OVERWRITE | ||
| 21155 | # if SQLITE_POWERSAFE_OVERWRITE != 1 | ||
| 21156 | "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE), | ||
| 21157 | # endif | ||
| 21158 | #endif | ||
| 21159 | #ifdef SQLITE_PREFER_PROXY_LOCKING | ||
| 21160 | "PREFER_PROXY_LOCKING", | ||
| 21161 | #endif | ||
| 21162 | #ifdef SQLITE_PROXY_DEBUG | ||
| 21163 | "PROXY_DEBUG", | ||
| 21164 | #endif | ||
| 21165 | #ifdef SQLITE_REVERSE_UNORDERED_SELECTS | ||
| 21166 | "REVERSE_UNORDERED_SELECTS", | ||
| 21167 | #endif | ||
| 21168 | #ifdef SQLITE_RTREE_INT_ONLY | ||
| 21169 | "RTREE_INT_ONLY", | ||
| 21170 | #endif | ||
| 21171 | #ifdef SQLITE_SECURE_DELETE | ||
| 21172 | "SECURE_DELETE", | ||
| 21173 | #endif | ||
| 21174 | #ifdef SQLITE_SMALL_STACK | ||
| 21175 | "SMALL_STACK", | ||
| 21176 | #endif | ||
| 21177 | #ifdef SQLITE_SORTER_PMASZ | ||
| 21178 | "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ), | ||
| 21179 | #endif | ||
| 21180 | #ifdef SQLITE_SOUNDEX | ||
| 21181 | "SOUNDEX", | ||
| 21182 | #endif | ||
| 21183 | #ifdef SQLITE_STAT4_SAMPLES | ||
| 21184 | "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES), | ||
| 21185 | #endif | ||
| 21186 | #ifdef SQLITE_STMTJRNL_SPILL | ||
| 21187 | "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL), | ||
| 21188 | #endif | ||
| 21189 | #ifdef SQLITE_SUBSTR_COMPATIBILITY | ||
| 21190 | "SUBSTR_COMPATIBILITY", | ||
| 21191 | #endif | ||
| 21192 | #if (!defined(SQLITE_WIN32_MALLOC) \ | ||
| 21193 | && !defined(SQLITE_ZERO_MALLOC) \ | ||
| 21194 | && !defined(SQLITE_MEMDEBUG) \ | ||
| 21195 | ) || defined(SQLITE_SYSTEM_MALLOC) | ||
| 21196 | "SYSTEM_MALLOC", | ||
| 21197 | #endif | ||
| 21198 | #ifdef SQLITE_TCL | ||
| 21199 | "TCL", | ||
| 21200 | #endif | ||
| 21201 | #ifdef SQLITE_TEMP_STORE | ||
| 21202 | "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE), | ||
| 21203 | #endif | ||
| 21204 | #ifdef SQLITE_TEST | ||
| 21205 | "TEST", | ||
| 21206 | #endif | ||
| 21207 | #if defined(SQLITE_THREADSAFE) | ||
| 21208 | "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE), | ||
| 21209 | #elif defined(THREADSAFE) | ||
| 21210 | "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE), | ||
| 21211 | #else | ||
| 21212 | "THREADSAFE=1", | ||
| 21213 | #endif | ||
| 21214 | #ifdef SQLITE_UNLINK_AFTER_CLOSE | ||
| 21215 | "UNLINK_AFTER_CLOSE", | ||
| 21216 | #endif | ||
| 21217 | #ifdef SQLITE_UNTESTABLE | ||
| 21218 | "UNTESTABLE", | ||
| 21219 | #endif | ||
| 21220 | #ifdef SQLITE_USER_AUTHENTICATION | ||
| 21221 | "USER_AUTHENTICATION", | ||
| 21222 | #endif | ||
| 21223 | #ifdef SQLITE_USE_ALLOCA | ||
| 21224 | "USE_ALLOCA", | ||
| 21225 | #endif | ||
| 21226 | #ifdef SQLITE_USE_FCNTL_TRACE | ||
| 21227 | "USE_FCNTL_TRACE", | ||
| 21228 | #endif | ||
| 21229 | #ifdef SQLITE_USE_URI | ||
| 21230 | "USE_URI", | ||
| 21231 | #endif | ||
| 21232 | #ifdef SQLITE_VDBE_COVERAGE | ||
| 21233 | "VDBE_COVERAGE", | ||
| 21234 | #endif | ||
| 21235 | #ifdef SQLITE_WIN32_MALLOC | ||
| 21236 | "WIN32_MALLOC", | ||
| 21237 | #endif | ||
| 21238 | #ifdef SQLITE_ZERO_MALLOC | ||
| 21239 | "ZERO_MALLOC", | ||
| 21240 | #endif | ||
| 21241 | /* | ||
| 21242 | ** END CODE GENERATED BY tool/mkctime.tcl | ||
| 21243 | */ | ||
| 21244 | }; | ||
| 21245 | |||
| 21246 | SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){ | ||
| 21247 | *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]); | ||
| 21248 | return (const char**)sqlite3azCompileOpt; | ||
| 21249 | } | ||
| 21250 | |||
| 21251 | #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ | ||
| 21252 | |||
| 21253 | /************** End of ctime.c ***********************************************/ | ||
| 20794 | /************** Begin file global.c ******************************************/ | 21254 | /************** Begin file global.c ******************************************/ |
| 20795 | /* | 21255 | /* |
| 20796 | ** 2008 June 13 | 21256 | ** 2008 June 13 |
| @@ -21092,6 +21552,18 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = { | |||
| 21092 | */ | 21552 | */ |
| 21093 | SQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions; | 21553 | SQLITE_PRIVATE FuncDefHash sqlite3BuiltinFunctions; |
| 21094 | 21554 | ||
| 21555 | #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG) | ||
| 21556 | /* | ||
| 21557 | ** Counter used for coverage testing. Does not come into play for | ||
| 21558 | ** release builds. | ||
| 21559 | ** | ||
| 21560 | ** Access to this global variable is not mutex protected. This might | ||
| 21561 | ** result in TSAN warnings. But as the variable does not exist in | ||
| 21562 | ** release builds, that should not be a concern. | ||
| 21563 | */ | ||
| 21564 | SQLITE_PRIVATE unsigned int sqlite3CoverageCounter; | ||
| 21565 | #endif /* SQLITE_COVERAGE_TEST || SQLITE_DEBUG */ | ||
| 21566 | |||
| 21095 | #ifdef VDBE_PROFILE | 21567 | #ifdef VDBE_PROFILE |
| 21096 | /* | 21568 | /* |
| 21097 | ** The following performance counter can be used in place of | 21569 | ** The following performance counter can be used in place of |
| @@ -21142,6 +21614,48 @@ SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER; | |||
| 21142 | */ | 21614 | */ |
| 21143 | SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY"; | 21615 | SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY"; |
| 21144 | 21616 | ||
| 21617 | /* | ||
| 21618 | ** Standard typenames. These names must match the COLTYPE_* definitions. | ||
| 21619 | ** Adjust the SQLITE_N_STDTYPE value if adding or removing entries. | ||
| 21620 | ** | ||
| 21621 | ** sqlite3StdType[] The actual names of the datatypes. | ||
| 21622 | ** | ||
| 21623 | ** sqlite3StdTypeLen[] The length (in bytes) of each entry | ||
| 21624 | ** in sqlite3StdType[]. | ||
| 21625 | ** | ||
| 21626 | ** sqlite3StdTypeAffinity[] The affinity associated with each entry | ||
| 21627 | ** in sqlite3StdType[]. | ||
| 21628 | ** | ||
| 21629 | ** sqlite3StdTypeMap[] The type value (as returned from | ||
| 21630 | ** sqlite3_column_type() or sqlite3_value_type()) | ||
| 21631 | ** for each entry in sqlite3StdType[]. | ||
| 21632 | */ | ||
| 21633 | SQLITE_PRIVATE const unsigned char sqlite3StdTypeLen[] = { 3, 4, 3, 7, 4, 4 }; | ||
| 21634 | SQLITE_PRIVATE const char sqlite3StdTypeAffinity[] = { | ||
| 21635 | SQLITE_AFF_NUMERIC, | ||
| 21636 | SQLITE_AFF_BLOB, | ||
| 21637 | SQLITE_AFF_INTEGER, | ||
| 21638 | SQLITE_AFF_INTEGER, | ||
| 21639 | SQLITE_AFF_REAL, | ||
| 21640 | SQLITE_AFF_TEXT | ||
| 21641 | }; | ||
| 21642 | SQLITE_PRIVATE const char sqlite3StdTypeMap[] = { | ||
| 21643 | 0, | ||
| 21644 | SQLITE_BLOB, | ||
| 21645 | SQLITE_INTEGER, | ||
| 21646 | SQLITE_INTEGER, | ||
| 21647 | SQLITE_FLOAT, | ||
| 21648 | SQLITE_TEXT | ||
| 21649 | }; | ||
| 21650 | SQLITE_PRIVATE const char *sqlite3StdType[] = { | ||
| 21651 | "ANY", | ||
| 21652 | "BLOB", | ||
| 21653 | "INT", | ||
| 21654 | "INTEGER", | ||
| 21655 | "REAL", | ||
| 21656 | "TEXT" | ||
| 21657 | }; | ||
| 21658 | |||
| 21145 | /************** End of global.c **********************************************/ | 21659 | /************** End of global.c **********************************************/ |
| 21146 | /************** Begin file status.c ******************************************/ | 21660 | /************** Begin file status.c ******************************************/ |
| 21147 | /* | 21661 | /* |
| @@ -21344,8 +21858,8 @@ struct VdbeFrame { | |||
| 21344 | int nMem; /* Number of entries in aMem */ | 21858 | int nMem; /* Number of entries in aMem */ |
| 21345 | int nChildMem; /* Number of memory cells for child frame */ | 21859 | int nChildMem; /* Number of memory cells for child frame */ |
| 21346 | int nChildCsr; /* Number of cursors for child frame */ | 21860 | int nChildCsr; /* Number of cursors for child frame */ |
| 21347 | int nChange; /* Statement changes (Vdbe.nChange) */ | 21861 | i64 nChange; /* Statement changes (Vdbe.nChange) */ |
| 21348 | int nDbChange; /* Value of db->nChange */ | 21862 | i64 nDbChange; /* Value of db->nChange */ |
| 21349 | }; | 21863 | }; |
| 21350 | 21864 | ||
| 21351 | /* Magic number for sanity checking on VdbeFrame objects */ | 21865 | /* Magic number for sanity checking on VdbeFrame objects */ |
| @@ -21552,7 +22066,7 @@ struct Vdbe { | |||
| 21552 | u32 cacheCtr; /* VdbeCursor row cache generation counter */ | 22066 | u32 cacheCtr; /* VdbeCursor row cache generation counter */ |
| 21553 | int pc; /* The program counter */ | 22067 | int pc; /* The program counter */ |
| 21554 | int rc; /* Value to return */ | 22068 | int rc; /* Value to return */ |
| 21555 | int nChange; /* Number of db changes made since last reset */ | 22069 | i64 nChange; /* Number of db changes made since last reset */ |
| 21556 | int iStatement; /* Statement number (or 0 if has no opened stmt) */ | 22070 | int iStatement; /* Statement number (or 0 if has no opened stmt) */ |
| 21557 | i64 iCurrentTime; /* Value of julianday('now') for this statement */ | 22071 | i64 iCurrentTime; /* Value of julianday('now') for this statement */ |
| 21558 | i64 nFkConstraint; /* Number of imm. FK constraints this VM */ | 22072 | i64 nFkConstraint; /* Number of imm. FK constraints this VM */ |
| @@ -21690,13 +22204,18 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetDouble(Mem*, double); | |||
| 21690 | SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*)); | 22204 | SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(Mem*, void*, const char*, void(*)(void*)); |
| 21691 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); | 22205 | SQLITE_PRIVATE void sqlite3VdbeMemInit(Mem*,sqlite3*,u16); |
| 21692 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); | 22206 | SQLITE_PRIVATE void sqlite3VdbeMemSetNull(Mem*); |
| 22207 | #ifndef SQLITE_OMIT_INCRBLOB | ||
| 21693 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); | 22208 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem*,int); |
| 22209 | #else | ||
| 22210 | SQLITE_PRIVATE int sqlite3VdbeMemSetZeroBlob(Mem*,int); | ||
| 22211 | #endif | ||
| 21694 | #ifdef SQLITE_DEBUG | 22212 | #ifdef SQLITE_DEBUG |
| 21695 | SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*); | 22213 | SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*); |
| 21696 | #endif | 22214 | #endif |
| 21697 | SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*); | 22215 | SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*); |
| 21698 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); | 22216 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*); |
| 21699 | SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8); | 22217 | SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8); |
| 22218 | SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double); | ||
| 21700 | SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*); | 22219 | SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*); |
| 21701 | SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*); | 22220 | SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*); |
| 21702 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*); | 22221 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*); |
| @@ -23181,131 +23700,100 @@ static void strftimeFunc( | |||
| 23181 | sqlite3_value **argv | 23700 | sqlite3_value **argv |
| 23182 | ){ | 23701 | ){ |
| 23183 | DateTime x; | 23702 | DateTime x; |
| 23184 | u64 n; | ||
| 23185 | size_t i,j; | 23703 | size_t i,j; |
| 23186 | char *z; | ||
| 23187 | sqlite3 *db; | 23704 | sqlite3 *db; |
| 23188 | const char *zFmt; | 23705 | const char *zFmt; |
| 23189 | char zBuf[100]; | 23706 | sqlite3_str sRes; |
| 23707 | |||
| 23708 | |||
| 23190 | if( argc==0 ) return; | 23709 | if( argc==0 ) return; |
| 23191 | zFmt = (const char*)sqlite3_value_text(argv[0]); | 23710 | zFmt = (const char*)sqlite3_value_text(argv[0]); |
| 23192 | if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return; | 23711 | if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return; |
| 23193 | db = sqlite3_context_db_handle(context); | 23712 | db = sqlite3_context_db_handle(context); |
| 23194 | for(i=0, n=1; zFmt[i]; i++, n++){ | 23713 | sqlite3StrAccumInit(&sRes, 0, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]); |
| 23195 | if( zFmt[i]=='%' ){ | 23714 | |
| 23196 | switch( zFmt[i+1] ){ | ||
| 23197 | case 'd': | ||
| 23198 | case 'H': | ||
| 23199 | case 'm': | ||
| 23200 | case 'M': | ||
| 23201 | case 'S': | ||
| 23202 | case 'W': | ||
| 23203 | n++; | ||
| 23204 | /* fall thru */ | ||
| 23205 | case 'w': | ||
| 23206 | case '%': | ||
| 23207 | break; | ||
| 23208 | case 'f': | ||
| 23209 | n += 8; | ||
| 23210 | break; | ||
| 23211 | case 'j': | ||
| 23212 | n += 3; | ||
| 23213 | break; | ||
| 23214 | case 'Y': | ||
| 23215 | n += 8; | ||
| 23216 | break; | ||
| 23217 | case 's': | ||
| 23218 | case 'J': | ||
| 23219 | n += 50; | ||
| 23220 | break; | ||
| 23221 | default: | ||
| 23222 | return; /* ERROR. return a NULL */ | ||
| 23223 | } | ||
| 23224 | i++; | ||
| 23225 | } | ||
| 23226 | } | ||
| 23227 | testcase( n==sizeof(zBuf)-1 ); | ||
| 23228 | testcase( n==sizeof(zBuf) ); | ||
| 23229 | testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH]+1 ); | ||
| 23230 | testcase( n==(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ); | ||
| 23231 | if( n<sizeof(zBuf) ){ | ||
| 23232 | z = zBuf; | ||
| 23233 | }else if( n>(u64)db->aLimit[SQLITE_LIMIT_LENGTH] ){ | ||
| 23234 | sqlite3_result_error_toobig(context); | ||
| 23235 | return; | ||
| 23236 | }else{ | ||
| 23237 | z = sqlite3DbMallocRawNN(db, (int)n); | ||
| 23238 | if( z==0 ){ | ||
| 23239 | sqlite3_result_error_nomem(context); | ||
| 23240 | return; | ||
| 23241 | } | ||
| 23242 | } | ||
| 23243 | computeJD(&x); | 23715 | computeJD(&x); |
| 23244 | computeYMD_HMS(&x); | 23716 | computeYMD_HMS(&x); |
| 23245 | for(i=j=0; zFmt[i]; i++){ | 23717 | for(i=j=0; zFmt[i]; i++){ |
| 23246 | if( zFmt[i]!='%' ){ | 23718 | if( zFmt[i]!='%' ) continue; |
| 23247 | z[j++] = zFmt[i]; | 23719 | if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j)); |
| 23248 | }else{ | 23720 | i++; |
| 23249 | i++; | 23721 | j = i + 1; |
| 23250 | switch( zFmt[i] ){ | 23722 | switch( zFmt[i] ){ |
| 23251 | case 'd': sqlite3_snprintf(3, &z[j],"%02d",x.D); j+=2; break; | 23723 | case 'd': { |
| 23252 | case 'f': { | 23724 | sqlite3_str_appendf(&sRes, "%02d", x.D); |
| 23253 | double s = x.s; | 23725 | break; |
| 23254 | if( s>59.999 ) s = 59.999; | 23726 | } |
| 23255 | sqlite3_snprintf(7, &z[j],"%06.3f", s); | 23727 | case 'f': { |
| 23256 | j += sqlite3Strlen30(&z[j]); | 23728 | double s = x.s; |
| 23257 | break; | 23729 | if( s>59.999 ) s = 59.999; |
| 23258 | } | 23730 | sqlite3_str_appendf(&sRes, "%06.3f", s); |
| 23259 | case 'H': sqlite3_snprintf(3, &z[j],"%02d",x.h); j+=2; break; | 23731 | break; |
| 23260 | case 'W': /* Fall thru */ | 23732 | } |
| 23261 | case 'j': { | 23733 | case 'H': { |
| 23262 | int nDay; /* Number of days since 1st day of year */ | 23734 | sqlite3_str_appendf(&sRes, "%02d", x.h); |
| 23263 | DateTime y = x; | 23735 | break; |
| 23264 | y.validJD = 0; | 23736 | } |
| 23265 | y.M = 1; | 23737 | case 'W': /* Fall thru */ |
| 23266 | y.D = 1; | 23738 | case 'j': { |
| 23267 | computeJD(&y); | 23739 | int nDay; /* Number of days since 1st day of year */ |
| 23268 | nDay = (int)((x.iJD-y.iJD+43200000)/86400000); | 23740 | DateTime y = x; |
| 23269 | if( zFmt[i]=='W' ){ | 23741 | y.validJD = 0; |
| 23270 | int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ | 23742 | y.M = 1; |
| 23271 | wd = (int)(((x.iJD+43200000)/86400000)%7); | 23743 | y.D = 1; |
| 23272 | sqlite3_snprintf(3, &z[j],"%02d",(nDay+7-wd)/7); | 23744 | computeJD(&y); |
| 23273 | j += 2; | 23745 | nDay = (int)((x.iJD-y.iJD+43200000)/86400000); |
| 23274 | }else{ | 23746 | if( zFmt[i]=='W' ){ |
| 23275 | sqlite3_snprintf(4, &z[j],"%03d",nDay+1); | 23747 | int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */ |
| 23276 | j += 3; | 23748 | wd = (int)(((x.iJD+43200000)/86400000)%7); |
| 23277 | } | 23749 | sqlite3_str_appendf(&sRes,"%02d",(nDay+7-wd)/7); |
| 23278 | break; | 23750 | }else{ |
| 23279 | } | 23751 | sqlite3_str_appendf(&sRes,"%03d",nDay+1); |
| 23280 | case 'J': { | ||
| 23281 | sqlite3_snprintf(20, &z[j],"%.16g",x.iJD/86400000.0); | ||
| 23282 | j+=sqlite3Strlen30(&z[j]); | ||
| 23283 | break; | ||
| 23284 | } | ||
| 23285 | case 'm': sqlite3_snprintf(3, &z[j],"%02d",x.M); j+=2; break; | ||
| 23286 | case 'M': sqlite3_snprintf(3, &z[j],"%02d",x.m); j+=2; break; | ||
| 23287 | case 's': { | ||
| 23288 | i64 iS = (i64)(x.iJD/1000 - 21086676*(i64)10000); | ||
| 23289 | sqlite3Int64ToText(iS, &z[j]); | ||
| 23290 | j += sqlite3Strlen30(&z[j]); | ||
| 23291 | break; | ||
| 23292 | } | ||
| 23293 | case 'S': sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break; | ||
| 23294 | case 'w': { | ||
| 23295 | z[j++] = (char)(((x.iJD+129600000)/86400000) % 7) + '0'; | ||
| 23296 | break; | ||
| 23297 | } | ||
| 23298 | case 'Y': { | ||
| 23299 | sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=sqlite3Strlen30(&z[j]); | ||
| 23300 | break; | ||
| 23301 | } | 23752 | } |
| 23302 | default: z[j++] = '%'; break; | 23753 | break; |
| 23754 | } | ||
| 23755 | case 'J': { | ||
| 23756 | sqlite3_str_appendf(&sRes,"%.16g",x.iJD/86400000.0); | ||
| 23757 | break; | ||
| 23758 | } | ||
| 23759 | case 'm': { | ||
| 23760 | sqlite3_str_appendf(&sRes,"%02d",x.M); | ||
| 23761 | break; | ||
| 23762 | } | ||
| 23763 | case 'M': { | ||
| 23764 | sqlite3_str_appendf(&sRes,"%02d",x.m); | ||
| 23765 | break; | ||
| 23766 | } | ||
| 23767 | case 's': { | ||
| 23768 | i64 iS = (i64)(x.iJD/1000 - 21086676*(i64)10000); | ||
| 23769 | sqlite3_str_appendf(&sRes,"%lld",iS); | ||
| 23770 | break; | ||
| 23771 | } | ||
| 23772 | case 'S': { | ||
| 23773 | sqlite3_str_appendf(&sRes,"%02d",(int)x.s); | ||
| 23774 | break; | ||
| 23775 | } | ||
| 23776 | case 'w': { | ||
| 23777 | sqlite3_str_appendchar(&sRes, 1, | ||
| 23778 | (char)(((x.iJD+129600000)/86400000) % 7) + '0'); | ||
| 23779 | break; | ||
| 23780 | } | ||
| 23781 | case 'Y': { | ||
| 23782 | sqlite3_str_appendf(&sRes,"%04d",x.Y); | ||
| 23783 | break; | ||
| 23784 | } | ||
| 23785 | case '%': { | ||
| 23786 | sqlite3_str_appendchar(&sRes, 1, '%'); | ||
| 23787 | break; | ||
| 23788 | } | ||
| 23789 | default: { | ||
| 23790 | sqlite3_str_reset(&sRes); | ||
| 23791 | return; | ||
| 23303 | } | 23792 | } |
| 23304 | } | 23793 | } |
| 23305 | } | 23794 | } |
| 23306 | z[j] = 0; | 23795 | if( j<i ) sqlite3_str_append(&sRes, zFmt+j, (int)(i-j)); |
| 23307 | sqlite3_result_text(context, z, -1, | 23796 | sqlite3ResultStrAccum(context, &sRes); |
| 23308 | z==zBuf ? SQLITE_TRANSIENT : SQLITE_DYNAMIC); | ||
| 23309 | } | 23797 | } |
| 23310 | 23798 | ||
| 23311 | /* | 23799 | /* |
| @@ -23586,6 +24074,7 @@ SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id){ | |||
| 23586 | return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE); | 24074 | return (xSectorSize ? xSectorSize(id) : SQLITE_DEFAULT_SECTOR_SIZE); |
| 23587 | } | 24075 | } |
| 23588 | SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){ | 24076 | SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id){ |
| 24077 | if( NEVER(id->pMethods==0) ) return 0; | ||
| 23589 | return id->pMethods->xDeviceCharacteristics(id); | 24078 | return id->pMethods->xDeviceCharacteristics(id); |
| 23590 | } | 24079 | } |
| 23591 | #ifndef SQLITE_OMIT_WAL | 24080 | #ifndef SQLITE_OMIT_WAL |
| @@ -23740,12 +24229,15 @@ SQLITE_PRIVATE int sqlite3OsOpenMalloc( | |||
| 23740 | rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, pOutFlags); | 24229 | rc = sqlite3OsOpen(pVfs, zFile, pFile, flags, pOutFlags); |
| 23741 | if( rc!=SQLITE_OK ){ | 24230 | if( rc!=SQLITE_OK ){ |
| 23742 | sqlite3_free(pFile); | 24231 | sqlite3_free(pFile); |
| 24232 | *ppFile = 0; | ||
| 23743 | }else{ | 24233 | }else{ |
| 23744 | *ppFile = pFile; | 24234 | *ppFile = pFile; |
| 23745 | } | 24235 | } |
| 23746 | }else{ | 24236 | }else{ |
| 24237 | *ppFile = 0; | ||
| 23747 | rc = SQLITE_NOMEM_BKPT; | 24238 | rc = SQLITE_NOMEM_BKPT; |
| 23748 | } | 24239 | } |
| 24240 | assert( *ppFile!=0 || rc!=SQLITE_OK ); | ||
| 23749 | return rc; | 24241 | return rc; |
| 23750 | } | 24242 | } |
| 23751 | SQLITE_PRIVATE void sqlite3OsCloseFree(sqlite3_file *pFile){ | 24243 | SQLITE_PRIVATE void sqlite3OsCloseFree(sqlite3_file *pFile){ |
| @@ -24463,7 +24955,7 @@ static void adjustStats(int iSize, int increment){ | |||
| 24463 | ** This routine checks the guards at either end of the allocation and | 24955 | ** This routine checks the guards at either end of the allocation and |
| 24464 | ** if they are incorrect it asserts. | 24956 | ** if they are incorrect it asserts. |
| 24465 | */ | 24957 | */ |
| 24466 | static struct MemBlockHdr *sqlite3MemsysGetHeader(void *pAllocation){ | 24958 | static struct MemBlockHdr *sqlite3MemsysGetHeader(const void *pAllocation){ |
| 24467 | struct MemBlockHdr *p; | 24959 | struct MemBlockHdr *p; |
| 24468 | int *pInt; | 24960 | int *pInt; |
| 24469 | u8 *pU8; | 24961 | u8 *pU8; |
| @@ -24710,7 +25202,7 @@ SQLITE_PRIVATE void sqlite3MemdebugSetType(void *p, u8 eType){ | |||
| 24710 | ** | 25202 | ** |
| 24711 | ** assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); | 25203 | ** assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 24712 | */ | 25204 | */ |
| 24713 | SQLITE_PRIVATE int sqlite3MemdebugHasType(void *p, u8 eType){ | 25205 | SQLITE_PRIVATE int sqlite3MemdebugHasType(const void *p, u8 eType){ |
| 24714 | int rc = 1; | 25206 | int rc = 1; |
| 24715 | if( p && sqlite3GlobalConfig.m.xFree==sqlite3MemFree ){ | 25207 | if( p && sqlite3GlobalConfig.m.xFree==sqlite3MemFree ){ |
| 24716 | struct MemBlockHdr *pHdr; | 25208 | struct MemBlockHdr *pHdr; |
| @@ -24732,7 +25224,7 @@ SQLITE_PRIVATE int sqlite3MemdebugHasType(void *p, u8 eType){ | |||
| 24732 | ** | 25224 | ** |
| 24733 | ** assert( sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) ); | 25225 | ** assert( sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) ); |
| 24734 | */ | 25226 | */ |
| 24735 | SQLITE_PRIVATE int sqlite3MemdebugNoType(void *p, u8 eType){ | 25227 | SQLITE_PRIVATE int sqlite3MemdebugNoType(const void *p, u8 eType){ |
| 24736 | int rc = 1; | 25228 | int rc = 1; |
| 24737 | if( p && sqlite3GlobalConfig.m.xFree==sqlite3MemFree ){ | 25229 | if( p && sqlite3GlobalConfig.m.xFree==sqlite3MemFree ){ |
| 24738 | struct MemBlockHdr *pHdr; | 25230 | struct MemBlockHdr *pHdr; |
| @@ -27110,205 +27602,7 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ | |||
| 27110 | /* | 27602 | /* |
| 27111 | ** Include code that is common to all os_*.c files | 27603 | ** Include code that is common to all os_*.c files |
| 27112 | */ | 27604 | */ |
| 27113 | /************** Include os_common.h in the middle of mutex_w32.c *************/ | 27605 | /* #include "os_common.h" */ |
| 27114 | /************** Begin file os_common.h ***************************************/ | ||
| 27115 | /* | ||
| 27116 | ** 2004 May 22 | ||
| 27117 | ** | ||
| 27118 | ** The author disclaims copyright to this source code. In place of | ||
| 27119 | ** a legal notice, here is a blessing: | ||
| 27120 | ** | ||
| 27121 | ** May you do good and not evil. | ||
| 27122 | ** May you find forgiveness for yourself and forgive others. | ||
| 27123 | ** May you share freely, never taking more than you give. | ||
| 27124 | ** | ||
| 27125 | ****************************************************************************** | ||
| 27126 | ** | ||
| 27127 | ** This file contains macros and a little bit of code that is common to | ||
| 27128 | ** all of the platform-specific files (os_*.c) and is #included into those | ||
| 27129 | ** files. | ||
| 27130 | ** | ||
| 27131 | ** This file should be #included by the os_*.c files only. It is not a | ||
| 27132 | ** general purpose header file. | ||
| 27133 | */ | ||
| 27134 | #ifndef _OS_COMMON_H_ | ||
| 27135 | #define _OS_COMMON_H_ | ||
| 27136 | |||
| 27137 | /* | ||
| 27138 | ** At least two bugs have slipped in because we changed the MEMORY_DEBUG | ||
| 27139 | ** macro to SQLITE_DEBUG and some older makefiles have not yet made the | ||
| 27140 | ** switch. The following code should catch this problem at compile-time. | ||
| 27141 | */ | ||
| 27142 | #ifdef MEMORY_DEBUG | ||
| 27143 | # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." | ||
| 27144 | #endif | ||
| 27145 | |||
| 27146 | /* | ||
| 27147 | ** Macros for performance tracing. Normally turned off. Only works | ||
| 27148 | ** on i486 hardware. | ||
| 27149 | */ | ||
| 27150 | #ifdef SQLITE_PERFORMANCE_TRACE | ||
| 27151 | |||
| 27152 | /* | ||
| 27153 | ** hwtime.h contains inline assembler code for implementing | ||
| 27154 | ** high-performance timing routines. | ||
| 27155 | */ | ||
| 27156 | /************** Include hwtime.h in the middle of os_common.h ****************/ | ||
| 27157 | /************** Begin file hwtime.h ******************************************/ | ||
| 27158 | /* | ||
| 27159 | ** 2008 May 27 | ||
| 27160 | ** | ||
| 27161 | ** The author disclaims copyright to this source code. In place of | ||
| 27162 | ** a legal notice, here is a blessing: | ||
| 27163 | ** | ||
| 27164 | ** May you do good and not evil. | ||
| 27165 | ** May you find forgiveness for yourself and forgive others. | ||
| 27166 | ** May you share freely, never taking more than you give. | ||
| 27167 | ** | ||
| 27168 | ****************************************************************************** | ||
| 27169 | ** | ||
| 27170 | ** This file contains inline asm code for retrieving "high-performance" | ||
| 27171 | ** counters for x86 and x86_64 class CPUs. | ||
| 27172 | */ | ||
| 27173 | #ifndef SQLITE_HWTIME_H | ||
| 27174 | #define SQLITE_HWTIME_H | ||
| 27175 | |||
| 27176 | /* | ||
| 27177 | ** The following routine only works on pentium-class (or newer) processors. | ||
| 27178 | ** It uses the RDTSC opcode to read the cycle count value out of the | ||
| 27179 | ** processor and returns that value. This can be used for high-res | ||
| 27180 | ** profiling. | ||
| 27181 | */ | ||
| 27182 | #if !defined(__STRICT_ANSI__) && \ | ||
| 27183 | (defined(__GNUC__) || defined(_MSC_VER)) && \ | ||
| 27184 | (defined(i386) || defined(__i386__) || defined(_M_IX86)) | ||
| 27185 | |||
| 27186 | #if defined(__GNUC__) | ||
| 27187 | |||
| 27188 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 27189 | unsigned int lo, hi; | ||
| 27190 | __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); | ||
| 27191 | return (sqlite_uint64)hi << 32 | lo; | ||
| 27192 | } | ||
| 27193 | |||
| 27194 | #elif defined(_MSC_VER) | ||
| 27195 | |||
| 27196 | __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){ | ||
| 27197 | __asm { | ||
| 27198 | rdtsc | ||
| 27199 | ret ; return value at EDX:EAX | ||
| 27200 | } | ||
| 27201 | } | ||
| 27202 | |||
| 27203 | #endif | ||
| 27204 | |||
| 27205 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) | ||
| 27206 | |||
| 27207 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 27208 | unsigned long val; | ||
| 27209 | __asm__ __volatile__ ("rdtsc" : "=A" (val)); | ||
| 27210 | return val; | ||
| 27211 | } | ||
| 27212 | |||
| 27213 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) | ||
| 27214 | |||
| 27215 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 27216 | unsigned long long retval; | ||
| 27217 | unsigned long junk; | ||
| 27218 | __asm__ __volatile__ ("\n\ | ||
| 27219 | 1: mftbu %1\n\ | ||
| 27220 | mftb %L0\n\ | ||
| 27221 | mftbu %0\n\ | ||
| 27222 | cmpw %0,%1\n\ | ||
| 27223 | bne 1b" | ||
| 27224 | : "=r" (retval), "=r" (junk)); | ||
| 27225 | return retval; | ||
| 27226 | } | ||
| 27227 | |||
| 27228 | #else | ||
| 27229 | |||
| 27230 | /* | ||
| 27231 | ** asm() is needed for hardware timing support. Without asm(), | ||
| 27232 | ** disable the sqlite3Hwtime() routine. | ||
| 27233 | ** | ||
| 27234 | ** sqlite3Hwtime() is only used for some obscure debugging | ||
| 27235 | ** and analysis configurations, not in any deliverable, so this | ||
| 27236 | ** should not be a great loss. | ||
| 27237 | */ | ||
| 27238 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } | ||
| 27239 | |||
| 27240 | #endif | ||
| 27241 | |||
| 27242 | #endif /* !defined(SQLITE_HWTIME_H) */ | ||
| 27243 | |||
| 27244 | /************** End of hwtime.h **********************************************/ | ||
| 27245 | /************** Continuing where we left off in os_common.h ******************/ | ||
| 27246 | |||
| 27247 | static sqlite_uint64 g_start; | ||
| 27248 | static sqlite_uint64 g_elapsed; | ||
| 27249 | #define TIMER_START g_start=sqlite3Hwtime() | ||
| 27250 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start | ||
| 27251 | #define TIMER_ELAPSED g_elapsed | ||
| 27252 | #else | ||
| 27253 | #define TIMER_START | ||
| 27254 | #define TIMER_END | ||
| 27255 | #define TIMER_ELAPSED ((sqlite_uint64)0) | ||
| 27256 | #endif | ||
| 27257 | |||
| 27258 | /* | ||
| 27259 | ** If we compile with the SQLITE_TEST macro set, then the following block | ||
| 27260 | ** of code will give us the ability to simulate a disk I/O error. This | ||
| 27261 | ** is used for testing the I/O recovery logic. | ||
| 27262 | */ | ||
| 27263 | #if defined(SQLITE_TEST) | ||
| 27264 | SQLITE_API extern int sqlite3_io_error_hit; | ||
| 27265 | SQLITE_API extern int sqlite3_io_error_hardhit; | ||
| 27266 | SQLITE_API extern int sqlite3_io_error_pending; | ||
| 27267 | SQLITE_API extern int sqlite3_io_error_persist; | ||
| 27268 | SQLITE_API extern int sqlite3_io_error_benign; | ||
| 27269 | SQLITE_API extern int sqlite3_diskfull_pending; | ||
| 27270 | SQLITE_API extern int sqlite3_diskfull; | ||
| 27271 | #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X) | ||
| 27272 | #define SimulateIOError(CODE) \ | ||
| 27273 | if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \ | ||
| 27274 | || sqlite3_io_error_pending-- == 1 ) \ | ||
| 27275 | { local_ioerr(); CODE; } | ||
| 27276 | static void local_ioerr(){ | ||
| 27277 | IOTRACE(("IOERR\n")); | ||
| 27278 | sqlite3_io_error_hit++; | ||
| 27279 | if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++; | ||
| 27280 | } | ||
| 27281 | #define SimulateDiskfullError(CODE) \ | ||
| 27282 | if( sqlite3_diskfull_pending ){ \ | ||
| 27283 | if( sqlite3_diskfull_pending == 1 ){ \ | ||
| 27284 | local_ioerr(); \ | ||
| 27285 | sqlite3_diskfull = 1; \ | ||
| 27286 | sqlite3_io_error_hit = 1; \ | ||
| 27287 | CODE; \ | ||
| 27288 | }else{ \ | ||
| 27289 | sqlite3_diskfull_pending--; \ | ||
| 27290 | } \ | ||
| 27291 | } | ||
| 27292 | #else | ||
| 27293 | #define SimulateIOErrorBenign(X) | ||
| 27294 | #define SimulateIOError(A) | ||
| 27295 | #define SimulateDiskfullError(A) | ||
| 27296 | #endif /* defined(SQLITE_TEST) */ | ||
| 27297 | |||
| 27298 | /* | ||
| 27299 | ** When testing, keep a count of the number of open files. | ||
| 27300 | */ | ||
| 27301 | #if defined(SQLITE_TEST) | ||
| 27302 | SQLITE_API extern int sqlite3_open_file_count; | ||
| 27303 | #define OpenCounter(X) sqlite3_open_file_count+=(X) | ||
| 27304 | #else | ||
| 27305 | #define OpenCounter(X) | ||
| 27306 | #endif /* defined(SQLITE_TEST) */ | ||
| 27307 | |||
| 27308 | #endif /* !defined(_OS_COMMON_H_) */ | ||
| 27309 | |||
| 27310 | /************** End of os_common.h *******************************************/ | ||
| 27311 | /************** Continuing where we left off in mutex_w32.c ******************/ | ||
| 27312 | 27606 | ||
| 27313 | /* | 27607 | /* |
| 27314 | ** Include the header file for the Windows VFS. | 27608 | ** Include the header file for the Windows VFS. |
| @@ -28101,7 +28395,7 @@ SQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){ | |||
| 28101 | ** TRUE if p is a lookaside memory allocation from db | 28395 | ** TRUE if p is a lookaside memory allocation from db |
| 28102 | */ | 28396 | */ |
| 28103 | #ifndef SQLITE_OMIT_LOOKASIDE | 28397 | #ifndef SQLITE_OMIT_LOOKASIDE |
| 28104 | static int isLookaside(sqlite3 *db, void *p){ | 28398 | static int isLookaside(sqlite3 *db, const void *p){ |
| 28105 | return SQLITE_WITHIN(p, db->lookaside.pStart, db->lookaside.pEnd); | 28399 | return SQLITE_WITHIN(p, db->lookaside.pStart, db->lookaside.pEnd); |
| 28106 | } | 28400 | } |
| 28107 | #else | 28401 | #else |
| @@ -28112,18 +28406,18 @@ static int isLookaside(sqlite3 *db, void *p){ | |||
| 28112 | ** Return the size of a memory allocation previously obtained from | 28406 | ** Return the size of a memory allocation previously obtained from |
| 28113 | ** sqlite3Malloc() or sqlite3_malloc(). | 28407 | ** sqlite3Malloc() or sqlite3_malloc(). |
| 28114 | */ | 28408 | */ |
| 28115 | SQLITE_PRIVATE int sqlite3MallocSize(void *p){ | 28409 | SQLITE_PRIVATE int sqlite3MallocSize(const void *p){ |
| 28116 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); | 28410 | assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); |
| 28117 | return sqlite3GlobalConfig.m.xSize(p); | 28411 | return sqlite3GlobalConfig.m.xSize((void*)p); |
| 28118 | } | 28412 | } |
| 28119 | static int lookasideMallocSize(sqlite3 *db, void *p){ | 28413 | static int lookasideMallocSize(sqlite3 *db, const void *p){ |
| 28120 | #ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE | 28414 | #ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE |
| 28121 | return p<db->lookaside.pMiddle ? db->lookaside.szTrue : LOOKASIDE_SMALL; | 28415 | return p<db->lookaside.pMiddle ? db->lookaside.szTrue : LOOKASIDE_SMALL; |
| 28122 | #else | 28416 | #else |
| 28123 | return db->lookaside.szTrue; | 28417 | return db->lookaside.szTrue; |
| 28124 | #endif | 28418 | #endif |
| 28125 | } | 28419 | } |
| 28126 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){ | 28420 | SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, const void *p){ |
| 28127 | assert( p!=0 ); | 28421 | assert( p!=0 ); |
| 28128 | #ifdef SQLITE_DEBUG | 28422 | #ifdef SQLITE_DEBUG |
| 28129 | if( db==0 || !isLookaside(db,p) ){ | 28423 | if( db==0 || !isLookaside(db,p) ){ |
| @@ -28150,7 +28444,7 @@ SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){ | |||
| 28150 | } | 28444 | } |
| 28151 | } | 28445 | } |
| 28152 | } | 28446 | } |
| 28153 | return sqlite3GlobalConfig.m.xSize(p); | 28447 | return sqlite3GlobalConfig.m.xSize((void*)p); |
| 28154 | } | 28448 | } |
| 28155 | SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){ | 28449 | SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){ |
| 28156 | assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); | 28450 | assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) ); |
| @@ -28760,7 +29054,7 @@ static char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){ | |||
| 28760 | /* | 29054 | /* |
| 28761 | ** Set the StrAccum object to an error mode. | 29055 | ** Set the StrAccum object to an error mode. |
| 28762 | */ | 29056 | */ |
| 28763 | static void setStrAccumError(StrAccum *p, u8 eError){ | 29057 | SQLITE_PRIVATE void sqlite3StrAccumSetError(StrAccum *p, u8 eError){ |
| 28764 | assert( eError==SQLITE_NOMEM || eError==SQLITE_TOOBIG ); | 29058 | assert( eError==SQLITE_NOMEM || eError==SQLITE_TOOBIG ); |
| 28765 | p->accError = eError; | 29059 | p->accError = eError; |
| 28766 | if( p->mxAlloc ) sqlite3_str_reset(p); | 29060 | if( p->mxAlloc ) sqlite3_str_reset(p); |
| @@ -28796,12 +29090,12 @@ static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){ | |||
| 28796 | char *z; | 29090 | char *z; |
| 28797 | if( pAccum->accError ) return 0; | 29091 | if( pAccum->accError ) return 0; |
| 28798 | if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){ | 29092 | if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){ |
| 28799 | setStrAccumError(pAccum, SQLITE_TOOBIG); | 29093 | sqlite3StrAccumSetError(pAccum, SQLITE_TOOBIG); |
| 28800 | return 0; | 29094 | return 0; |
| 28801 | } | 29095 | } |
| 28802 | z = sqlite3DbMallocRaw(pAccum->db, n); | 29096 | z = sqlite3DbMallocRaw(pAccum->db, n); |
| 28803 | if( z==0 ){ | 29097 | if( z==0 ){ |
| 28804 | setStrAccumError(pAccum, SQLITE_NOMEM); | 29098 | sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM); |
| 28805 | } | 29099 | } |
| 28806 | return z; | 29100 | return z; |
| 28807 | } | 29101 | } |
| @@ -29540,7 +29834,7 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ | |||
| 29540 | return 0; | 29834 | return 0; |
| 29541 | } | 29835 | } |
| 29542 | if( p->mxAlloc==0 ){ | 29836 | if( p->mxAlloc==0 ){ |
| 29543 | setStrAccumError(p, SQLITE_TOOBIG); | 29837 | sqlite3StrAccumSetError(p, SQLITE_TOOBIG); |
| 29544 | return p->nAlloc - p->nChar - 1; | 29838 | return p->nAlloc - p->nChar - 1; |
| 29545 | }else{ | 29839 | }else{ |
| 29546 | char *zOld = isMalloced(p) ? p->zText : 0; | 29840 | char *zOld = isMalloced(p) ? p->zText : 0; |
| @@ -29553,7 +29847,7 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ | |||
| 29553 | } | 29847 | } |
| 29554 | if( szNew > p->mxAlloc ){ | 29848 | if( szNew > p->mxAlloc ){ |
| 29555 | sqlite3_str_reset(p); | 29849 | sqlite3_str_reset(p); |
| 29556 | setStrAccumError(p, SQLITE_TOOBIG); | 29850 | sqlite3StrAccumSetError(p, SQLITE_TOOBIG); |
| 29557 | return 0; | 29851 | return 0; |
| 29558 | }else{ | 29852 | }else{ |
| 29559 | p->nAlloc = (int)szNew; | 29853 | p->nAlloc = (int)szNew; |
| @@ -29571,7 +29865,7 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){ | |||
| 29571 | p->printfFlags |= SQLITE_PRINTF_MALLOCED; | 29865 | p->printfFlags |= SQLITE_PRINTF_MALLOCED; |
| 29572 | }else{ | 29866 | }else{ |
| 29573 | sqlite3_str_reset(p); | 29867 | sqlite3_str_reset(p); |
| 29574 | setStrAccumError(p, SQLITE_NOMEM); | 29868 | sqlite3StrAccumSetError(p, SQLITE_NOMEM); |
| 29575 | return 0; | 29869 | return 0; |
| 29576 | } | 29870 | } |
| 29577 | } | 29871 | } |
| @@ -29644,7 +29938,7 @@ static SQLITE_NOINLINE char *strAccumFinishRealloc(StrAccum *p){ | |||
| 29644 | memcpy(zText, p->zText, p->nChar+1); | 29938 | memcpy(zText, p->zText, p->nChar+1); |
| 29645 | p->printfFlags |= SQLITE_PRINTF_MALLOCED; | 29939 | p->printfFlags |= SQLITE_PRINTF_MALLOCED; |
| 29646 | }else{ | 29940 | }else{ |
| 29647 | setStrAccumError(p, SQLITE_NOMEM); | 29941 | sqlite3StrAccumSetError(p, SQLITE_NOMEM); |
| 29648 | } | 29942 | } |
| 29649 | p->zText = zText; | 29943 | p->zText = zText; |
| 29650 | return zText; | 29944 | return zText; |
| @@ -29660,6 +29954,22 @@ SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){ | |||
| 29660 | } | 29954 | } |
| 29661 | 29955 | ||
| 29662 | /* | 29956 | /* |
| 29957 | ** Use the content of the StrAccum passed as the second argument | ||
| 29958 | ** as the result of an SQL function. | ||
| 29959 | */ | ||
| 29960 | SQLITE_PRIVATE void sqlite3ResultStrAccum(sqlite3_context *pCtx, StrAccum *p){ | ||
| 29961 | if( p->accError ){ | ||
| 29962 | sqlite3_result_error_code(pCtx, p->accError); | ||
| 29963 | sqlite3_str_reset(p); | ||
| 29964 | }else if( isMalloced(p) ){ | ||
| 29965 | sqlite3_result_text(pCtx, p->zText, p->nChar, SQLITE_DYNAMIC); | ||
| 29966 | }else{ | ||
| 29967 | sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC); | ||
| 29968 | sqlite3_str_reset(p); | ||
| 29969 | } | ||
| 29970 | } | ||
| 29971 | |||
| 29972 | /* | ||
| 29663 | ** This singleton is an sqlite3_str object that is returned if | 29973 | ** This singleton is an sqlite3_str object that is returned if |
| 29664 | ** sqlite3_malloc() fails to provide space for a real one. This | 29974 | ** sqlite3_malloc() fails to provide space for a real one. This |
| 29665 | ** sqlite3_str object accepts no new text and always returns | 29975 | ** sqlite3_str object accepts no new text and always returns |
| @@ -30079,6 +30389,8 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc) | |||
| 30079 | } | 30389 | } |
| 30080 | if( pItem->fg.jointype & JT_LEFT ){ | 30390 | if( pItem->fg.jointype & JT_LEFT ){ |
| 30081 | sqlite3_str_appendf(&x, " LEFT-JOIN"); | 30391 | sqlite3_str_appendf(&x, " LEFT-JOIN"); |
| 30392 | }else if( pItem->fg.jointype & JT_CROSS ){ | ||
| 30393 | sqlite3_str_appendf(&x, " CROSS-JOIN"); | ||
| 30082 | } | 30394 | } |
| 30083 | if( pItem->fg.fromDDL ){ | 30395 | if( pItem->fg.fromDDL ){ |
| 30084 | sqlite3_str_appendf(&x, " DDL"); | 30396 | sqlite3_str_appendf(&x, " DDL"); |
| @@ -30377,6 +30689,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30377 | sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s", | 30689 | sqlite3TreeViewLine(pView, "COLUMN(%d)%s%s", |
| 30378 | pExpr->iColumn, zFlgs, zOp2); | 30690 | pExpr->iColumn, zFlgs, zOp2); |
| 30379 | }else{ | 30691 | }else{ |
| 30692 | assert( ExprUseYTab(pExpr) ); | ||
| 30380 | sqlite3TreeViewLine(pView, "{%d:%d} pTab=%p%s", | 30693 | sqlite3TreeViewLine(pView, "{%d:%d} pTab=%p%s", |
| 30381 | pExpr->iTable, pExpr->iColumn, | 30694 | pExpr->iTable, pExpr->iColumn, |
| 30382 | pExpr->y.pTab, zFlgs); | 30695 | pExpr->y.pTab, zFlgs); |
| @@ -30396,11 +30709,13 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30396 | } | 30709 | } |
| 30397 | #ifndef SQLITE_OMIT_FLOATING_POINT | 30710 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 30398 | case TK_FLOAT: { | 30711 | case TK_FLOAT: { |
| 30712 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30399 | sqlite3TreeViewLine(pView,"%s", pExpr->u.zToken); | 30713 | sqlite3TreeViewLine(pView,"%s", pExpr->u.zToken); |
| 30400 | break; | 30714 | break; |
| 30401 | } | 30715 | } |
| 30402 | #endif | 30716 | #endif |
| 30403 | case TK_STRING: { | 30717 | case TK_STRING: { |
| 30718 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30404 | sqlite3TreeViewLine(pView,"%Q", pExpr->u.zToken); | 30719 | sqlite3TreeViewLine(pView,"%Q", pExpr->u.zToken); |
| 30405 | break; | 30720 | break; |
| 30406 | } | 30721 | } |
| @@ -30409,17 +30724,19 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30409 | break; | 30724 | break; |
| 30410 | } | 30725 | } |
| 30411 | case TK_TRUEFALSE: { | 30726 | case TK_TRUEFALSE: { |
| 30412 | sqlite3TreeViewLine(pView, | 30727 | sqlite3TreeViewLine(pView,"%s%s", |
| 30413 | sqlite3ExprTruthValue(pExpr) ? "TRUE" : "FALSE"); | 30728 | sqlite3ExprTruthValue(pExpr) ? "TRUE" : "FALSE", zFlgs); |
| 30414 | break; | 30729 | break; |
| 30415 | } | 30730 | } |
| 30416 | #ifndef SQLITE_OMIT_BLOB_LITERAL | 30731 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 30417 | case TK_BLOB: { | 30732 | case TK_BLOB: { |
| 30733 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30418 | sqlite3TreeViewLine(pView,"%s", pExpr->u.zToken); | 30734 | sqlite3TreeViewLine(pView,"%s", pExpr->u.zToken); |
| 30419 | break; | 30735 | break; |
| 30420 | } | 30736 | } |
| 30421 | #endif | 30737 | #endif |
| 30422 | case TK_VARIABLE: { | 30738 | case TK_VARIABLE: { |
| 30739 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30423 | sqlite3TreeViewLine(pView,"VARIABLE(%s,%d)", | 30740 | sqlite3TreeViewLine(pView,"VARIABLE(%s,%d)", |
| 30424 | pExpr->u.zToken, pExpr->iColumn); | 30741 | pExpr->u.zToken, pExpr->iColumn); |
| 30425 | break; | 30742 | break; |
| @@ -30429,12 +30746,14 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30429 | break; | 30746 | break; |
| 30430 | } | 30747 | } |
| 30431 | case TK_ID: { | 30748 | case TK_ID: { |
| 30749 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30432 | sqlite3TreeViewLine(pView,"ID \"%w\"", pExpr->u.zToken); | 30750 | sqlite3TreeViewLine(pView,"ID \"%w\"", pExpr->u.zToken); |
| 30433 | break; | 30751 | break; |
| 30434 | } | 30752 | } |
| 30435 | #ifndef SQLITE_OMIT_CAST | 30753 | #ifndef SQLITE_OMIT_CAST |
| 30436 | case TK_CAST: { | 30754 | case TK_CAST: { |
| 30437 | /* Expressions of the form: CAST(pLeft AS token) */ | 30755 | /* Expressions of the form: CAST(pLeft AS token) */ |
| 30756 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30438 | sqlite3TreeViewLine(pView,"CAST %Q", pExpr->u.zToken); | 30757 | sqlite3TreeViewLine(pView,"CAST %Q", pExpr->u.zToken); |
| 30439 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); | 30758 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 30440 | break; | 30759 | break; |
| @@ -30484,6 +30803,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30484 | } | 30803 | } |
| 30485 | 30804 | ||
| 30486 | case TK_SPAN: { | 30805 | case TK_SPAN: { |
| 30806 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30487 | sqlite3TreeViewLine(pView, "SPAN %Q", pExpr->u.zToken); | 30807 | sqlite3TreeViewLine(pView, "SPAN %Q", pExpr->u.zToken); |
| 30488 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); | 30808 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 0); |
| 30489 | break; | 30809 | break; |
| @@ -30495,6 +30815,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30495 | ** up in the treeview output as "SOFT-COLLATE". Explicit COLLATE | 30815 | ** up in the treeview output as "SOFT-COLLATE". Explicit COLLATE |
| 30496 | ** operators that appear in the original SQL always have the | 30816 | ** operators that appear in the original SQL always have the |
| 30497 | ** EP_Collate bit set and appear in treeview output as just "COLLATE" */ | 30817 | ** EP_Collate bit set and appear in treeview output as just "COLLATE" */ |
| 30818 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30498 | sqlite3TreeViewLine(pView, "%sCOLLATE %Q%s", | 30819 | sqlite3TreeViewLine(pView, "%sCOLLATE %Q%s", |
| 30499 | !ExprHasProperty(pExpr, EP_Collate) ? "SOFT-" : "", | 30820 | !ExprHasProperty(pExpr, EP_Collate) ? "SOFT-" : "", |
| 30500 | pExpr->u.zToken, zFlgs); | 30821 | pExpr->u.zToken, zFlgs); |
| @@ -30510,6 +30831,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30510 | pFarg = 0; | 30831 | pFarg = 0; |
| 30511 | pWin = 0; | 30832 | pWin = 0; |
| 30512 | }else{ | 30833 | }else{ |
| 30834 | assert( ExprUseXList(pExpr) ); | ||
| 30513 | pFarg = pExpr->x.pList; | 30835 | pFarg = pExpr->x.pList; |
| 30514 | #ifndef SQLITE_OMIT_WINDOWFUNC | 30836 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 30515 | pWin = ExprHasProperty(pExpr, EP_WinFunc) ? pExpr->y.pWin : 0; | 30837 | pWin = ExprHasProperty(pExpr, EP_WinFunc) ? pExpr->y.pWin : 0; |
| @@ -30517,6 +30839,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30517 | pWin = 0; | 30839 | pWin = 0; |
| 30518 | #endif | 30840 | #endif |
| 30519 | } | 30841 | } |
| 30842 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30520 | if( pExpr->op==TK_AGG_FUNCTION ){ | 30843 | if( pExpr->op==TK_AGG_FUNCTION ){ |
| 30521 | sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s agg=%d[%d]/%p", | 30844 | sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s agg=%d[%d]/%p", |
| 30522 | pExpr->op2, pExpr->u.zToken, zFlgs, | 30845 | pExpr->op2, pExpr->u.zToken, zFlgs, |
| @@ -30548,11 +30871,13 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30548 | } | 30871 | } |
| 30549 | #ifndef SQLITE_OMIT_SUBQUERY | 30872 | #ifndef SQLITE_OMIT_SUBQUERY |
| 30550 | case TK_EXISTS: { | 30873 | case TK_EXISTS: { |
| 30874 | assert( ExprUseXSelect(pExpr) ); | ||
| 30551 | sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags); | 30875 | sqlite3TreeViewLine(pView, "EXISTS-expr flags=0x%x", pExpr->flags); |
| 30552 | sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0); | 30876 | sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0); |
| 30553 | break; | 30877 | break; |
| 30554 | } | 30878 | } |
| 30555 | case TK_SELECT: { | 30879 | case TK_SELECT: { |
| 30880 | assert( ExprUseXSelect(pExpr) ); | ||
| 30556 | sqlite3TreeViewLine(pView, "subquery-expr flags=0x%x", pExpr->flags); | 30881 | sqlite3TreeViewLine(pView, "subquery-expr flags=0x%x", pExpr->flags); |
| 30557 | sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0); | 30882 | sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0); |
| 30558 | break; | 30883 | break; |
| @@ -30560,7 +30885,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30560 | case TK_IN: { | 30885 | case TK_IN: { |
| 30561 | sqlite3TreeViewLine(pView, "IN flags=0x%x", pExpr->flags); | 30886 | sqlite3TreeViewLine(pView, "IN flags=0x%x", pExpr->flags); |
| 30562 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 1); | 30887 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 1); |
| 30563 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 30888 | if( ExprUseXSelect(pExpr) ){ |
| 30564 | sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0); | 30889 | sqlite3TreeViewSelect(pView, pExpr->x.pSelect, 0); |
| 30565 | }else{ | 30890 | }else{ |
| 30566 | sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0); | 30891 | sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0); |
| @@ -30581,9 +30906,12 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30581 | ** Z is stored in pExpr->pList->a[1].pExpr. | 30906 | ** Z is stored in pExpr->pList->a[1].pExpr. |
| 30582 | */ | 30907 | */ |
| 30583 | case TK_BETWEEN: { | 30908 | case TK_BETWEEN: { |
| 30584 | Expr *pX = pExpr->pLeft; | 30909 | const Expr *pX, *pY, *pZ; |
| 30585 | Expr *pY = pExpr->x.pList->a[0].pExpr; | 30910 | pX = pExpr->pLeft; |
| 30586 | Expr *pZ = pExpr->x.pList->a[1].pExpr; | 30911 | assert( ExprUseXList(pExpr) ); |
| 30912 | assert( pExpr->x.pList->nExpr==2 ); | ||
| 30913 | pY = pExpr->x.pList->a[0].pExpr; | ||
| 30914 | pZ = pExpr->x.pList->a[1].pExpr; | ||
| 30587 | sqlite3TreeViewLine(pView, "BETWEEN"); | 30915 | sqlite3TreeViewLine(pView, "BETWEEN"); |
| 30588 | sqlite3TreeViewExpr(pView, pX, 1); | 30916 | sqlite3TreeViewExpr(pView, pX, 1); |
| 30589 | sqlite3TreeViewExpr(pView, pY, 1); | 30917 | sqlite3TreeViewExpr(pView, pY, 1); |
| @@ -30605,6 +30933,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30605 | case TK_CASE: { | 30933 | case TK_CASE: { |
| 30606 | sqlite3TreeViewLine(pView, "CASE"); | 30934 | sqlite3TreeViewLine(pView, "CASE"); |
| 30607 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 1); | 30935 | sqlite3TreeViewExpr(pView, pExpr->pLeft, 1); |
| 30936 | assert( ExprUseXList(pExpr) ); | ||
| 30608 | sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0); | 30937 | sqlite3TreeViewExprList(pView, pExpr->x.pList, 0, 0); |
| 30609 | break; | 30938 | break; |
| 30610 | } | 30939 | } |
| @@ -30617,6 +30946,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30617 | case OE_Fail: zType = "fail"; break; | 30946 | case OE_Fail: zType = "fail"; break; |
| 30618 | case OE_Ignore: zType = "ignore"; break; | 30947 | case OE_Ignore: zType = "ignore"; break; |
| 30619 | } | 30948 | } |
| 30949 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 30620 | sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken); | 30950 | sqlite3TreeViewLine(pView, "RAISE %s(%Q)", zType, pExpr->u.zToken); |
| 30621 | break; | 30951 | break; |
| 30622 | } | 30952 | } |
| @@ -30629,12 +30959,16 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30629 | } | 30959 | } |
| 30630 | case TK_VECTOR: { | 30960 | case TK_VECTOR: { |
| 30631 | char *z = sqlite3_mprintf("VECTOR%s",zFlgs); | 30961 | char *z = sqlite3_mprintf("VECTOR%s",zFlgs); |
| 30962 | assert( ExprUseXList(pExpr) ); | ||
| 30632 | sqlite3TreeViewBareExprList(pView, pExpr->x.pList, z); | 30963 | sqlite3TreeViewBareExprList(pView, pExpr->x.pList, z); |
| 30633 | sqlite3_free(z); | 30964 | sqlite3_free(z); |
| 30634 | break; | 30965 | break; |
| 30635 | } | 30966 | } |
| 30636 | case TK_SELECT_COLUMN: { | 30967 | case TK_SELECT_COLUMN: { |
| 30637 | sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn); | 30968 | sqlite3TreeViewLine(pView, "SELECT-COLUMN %d of [0..%d]%s", |
| 30969 | pExpr->iColumn, pExpr->iTable-1, | ||
| 30970 | pExpr->pRight==pExpr->pLeft ? " (SELECT-owner)" : ""); | ||
| 30971 | assert( ExprUseXSelect(pExpr->pLeft) ); | ||
| 30638 | sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0); | 30972 | sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0); |
| 30639 | break; | 30973 | break; |
| 30640 | } | 30974 | } |
| @@ -30651,6 +30985,15 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m | |||
| 30651 | sqlite3TreeViewExpr(pView, &tmp, 0); | 30985 | sqlite3TreeViewExpr(pView, &tmp, 0); |
| 30652 | break; | 30986 | break; |
| 30653 | } | 30987 | } |
| 30988 | case TK_ROW: { | ||
| 30989 | if( pExpr->iColumn<=0 ){ | ||
| 30990 | sqlite3TreeViewLine(pView, "First FROM table rowid"); | ||
| 30991 | }else{ | ||
| 30992 | sqlite3TreeViewLine(pView, "First FROM table column %d", | ||
| 30993 | pExpr->iColumn-1); | ||
| 30994 | } | ||
| 30995 | break; | ||
| 30996 | } | ||
| 30654 | default: { | 30997 | default: { |
| 30655 | sqlite3TreeViewLine(pView, "op=%d", pExpr->op); | 30998 | sqlite3TreeViewLine(pView, "op=%d", pExpr->op); |
| 30656 | break; | 30999 | break; |
| @@ -31703,16 +32046,6 @@ SQLITE_PRIVATE void sqlite3UtfSelfTest(void){ | |||
| 31703 | #endif | 32046 | #endif |
| 31704 | 32047 | ||
| 31705 | /* | 32048 | /* |
| 31706 | ** Routine needed to support the testcase() macro. | ||
| 31707 | */ | ||
| 31708 | #ifdef SQLITE_COVERAGE_TEST | ||
| 31709 | SQLITE_PRIVATE void sqlite3Coverage(int x){ | ||
| 31710 | static unsigned dummy = 0; | ||
| 31711 | dummy += (unsigned)x; | ||
| 31712 | } | ||
| 31713 | #endif | ||
| 31714 | |||
| 31715 | /* | ||
| 31716 | ** Calls to sqlite3FaultSim() are used to simulate a failure during testing, | 32049 | ** Calls to sqlite3FaultSim() are used to simulate a failure during testing, |
| 31717 | ** or to bypass normal error detection during testing in order to let | 32050 | ** or to bypass normal error detection during testing in order to let |
| 31718 | ** execute proceed futher downstream. | 32051 | ** execute proceed futher downstream. |
| @@ -31741,11 +32074,21 @@ SQLITE_PRIVATE int sqlite3FaultSim(int iTest){ | |||
| 31741 | #ifndef SQLITE_OMIT_FLOATING_POINT | 32074 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| 31742 | /* | 32075 | /* |
| 31743 | ** Return true if the floating point value is Not a Number (NaN). | 32076 | ** Return true if the floating point value is Not a Number (NaN). |
| 32077 | ** | ||
| 32078 | ** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN. | ||
| 32079 | ** Otherwise, we have our own implementation that works on most systems. | ||
| 31744 | */ | 32080 | */ |
| 31745 | SQLITE_PRIVATE int sqlite3IsNaN(double x){ | 32081 | SQLITE_PRIVATE int sqlite3IsNaN(double x){ |
| 32082 | int rc; /* The value return */ | ||
| 32083 | #if !SQLITE_HAVE_ISNAN && !HAVE_ISNAN | ||
| 31746 | u64 y; | 32084 | u64 y; |
| 31747 | memcpy(&y,&x,sizeof(y)); | 32085 | memcpy(&y,&x,sizeof(y)); |
| 31748 | return IsNaN(y); | 32086 | rc = IsNaN(y); |
| 32087 | #else | ||
| 32088 | rc = isnan(x); | ||
| 32089 | #endif /* HAVE_ISNAN */ | ||
| 32090 | testcase( rc ); | ||
| 32091 | return rc; | ||
| 31749 | } | 32092 | } |
| 31750 | #endif /* SQLITE_OMIT_FLOATING_POINT */ | 32093 | #endif /* SQLITE_OMIT_FLOATING_POINT */ |
| 31751 | 32094 | ||
| @@ -31770,8 +32113,14 @@ SQLITE_PRIVATE int sqlite3Strlen30(const char *z){ | |||
| 31770 | ** the column name if and only if the COLFLAG_HASTYPE flag is set. | 32113 | ** the column name if and only if the COLFLAG_HASTYPE flag is set. |
| 31771 | */ | 32114 | */ |
| 31772 | SQLITE_PRIVATE char *sqlite3ColumnType(Column *pCol, char *zDflt){ | 32115 | SQLITE_PRIVATE char *sqlite3ColumnType(Column *pCol, char *zDflt){ |
| 31773 | if( (pCol->colFlags & COLFLAG_HASTYPE)==0 ) return zDflt; | 32116 | if( pCol->colFlags & COLFLAG_HASTYPE ){ |
| 31774 | return pCol->zName + strlen(pCol->zName) + 1; | 32117 | return pCol->zCnName + strlen(pCol->zCnName) + 1; |
| 32118 | }else if( pCol->eCType ){ | ||
| 32119 | assert( pCol->eCType<=SQLITE_N_STDTYPE ); | ||
| 32120 | return (char*)sqlite3StdType[pCol->eCType-1]; | ||
| 32121 | }else{ | ||
| 32122 | return zDflt; | ||
| 32123 | } | ||
| 31775 | } | 32124 | } |
| 31776 | 32125 | ||
| 31777 | /* | 32126 | /* |
| @@ -31942,12 +32291,35 @@ SQLITE_PRIVATE void sqlite3Dequote(char *z){ | |||
| 31942 | z[j] = 0; | 32291 | z[j] = 0; |
| 31943 | } | 32292 | } |
| 31944 | SQLITE_PRIVATE void sqlite3DequoteExpr(Expr *p){ | 32293 | SQLITE_PRIVATE void sqlite3DequoteExpr(Expr *p){ |
| 32294 | assert( !ExprHasProperty(p, EP_IntValue) ); | ||
| 31945 | assert( sqlite3Isquote(p->u.zToken[0]) ); | 32295 | assert( sqlite3Isquote(p->u.zToken[0]) ); |
| 31946 | p->flags |= p->u.zToken[0]=='"' ? EP_Quoted|EP_DblQuoted : EP_Quoted; | 32296 | p->flags |= p->u.zToken[0]=='"' ? EP_Quoted|EP_DblQuoted : EP_Quoted; |
| 31947 | sqlite3Dequote(p->u.zToken); | 32297 | sqlite3Dequote(p->u.zToken); |
| 31948 | } | 32298 | } |
| 31949 | 32299 | ||
| 31950 | /* | 32300 | /* |
| 32301 | ** If the input token p is quoted, try to adjust the token to remove | ||
| 32302 | ** the quotes. This is not always possible: | ||
| 32303 | ** | ||
| 32304 | ** "abc" -> abc | ||
| 32305 | ** "ab""cd" -> (not possible because of the interior "") | ||
| 32306 | ** | ||
| 32307 | ** Remove the quotes if possible. This is a optimization. The overall | ||
| 32308 | ** system should still return the correct answer even if this routine | ||
| 32309 | ** is always a no-op. | ||
| 32310 | */ | ||
| 32311 | SQLITE_PRIVATE void sqlite3DequoteToken(Token *p){ | ||
| 32312 | unsigned int i; | ||
| 32313 | if( p->n<2 ) return; | ||
| 32314 | if( !sqlite3Isquote(p->z[0]) ) return; | ||
| 32315 | for(i=1; i<p->n-1; i++){ | ||
| 32316 | if( sqlite3Isquote(p->z[i]) ) return; | ||
| 32317 | } | ||
| 32318 | p->n -= 2; | ||
| 32319 | p->z++; | ||
| 32320 | } | ||
| 32321 | |||
| 32322 | /* | ||
| 31951 | ** Generate a Token object from a string | 32323 | ** Generate a Token object from a string |
| 31952 | */ | 32324 | */ |
| 31953 | SQLITE_PRIVATE void sqlite3TokenInit(Token *p, char *z){ | 32325 | SQLITE_PRIVATE void sqlite3TokenInit(Token *p, char *z){ |
| @@ -33052,13 +33424,13 @@ static void logBadConnection(const char *zType){ | |||
| 33052 | ** used as an argument to sqlite3_errmsg() or sqlite3_close(). | 33424 | ** used as an argument to sqlite3_errmsg() or sqlite3_close(). |
| 33053 | */ | 33425 | */ |
| 33054 | SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3 *db){ | 33426 | SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3 *db){ |
| 33055 | u32 magic; | 33427 | u8 eOpenState; |
| 33056 | if( db==0 ){ | 33428 | if( db==0 ){ |
| 33057 | logBadConnection("NULL"); | 33429 | logBadConnection("NULL"); |
| 33058 | return 0; | 33430 | return 0; |
| 33059 | } | 33431 | } |
| 33060 | magic = db->magic; | 33432 | eOpenState = db->eOpenState; |
| 33061 | if( magic!=SQLITE_MAGIC_OPEN ){ | 33433 | if( eOpenState!=SQLITE_STATE_OPEN ){ |
| 33062 | if( sqlite3SafetyCheckSickOrOk(db) ){ | 33434 | if( sqlite3SafetyCheckSickOrOk(db) ){ |
| 33063 | testcase( sqlite3GlobalConfig.xLog!=0 ); | 33435 | testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 33064 | logBadConnection("unopened"); | 33436 | logBadConnection("unopened"); |
| @@ -33069,11 +33441,11 @@ SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3 *db){ | |||
| 33069 | } | 33441 | } |
| 33070 | } | 33442 | } |
| 33071 | SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3 *db){ | 33443 | SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3 *db){ |
| 33072 | u32 magic; | 33444 | u8 eOpenState; |
| 33073 | magic = db->magic; | 33445 | eOpenState = db->eOpenState; |
| 33074 | if( magic!=SQLITE_MAGIC_SICK && | 33446 | if( eOpenState!=SQLITE_STATE_SICK && |
| 33075 | magic!=SQLITE_MAGIC_OPEN && | 33447 | eOpenState!=SQLITE_STATE_OPEN && |
| 33076 | magic!=SQLITE_MAGIC_BUSY ){ | 33448 | eOpenState!=SQLITE_STATE_BUSY ){ |
| 33077 | testcase( sqlite3GlobalConfig.xLog!=0 ); | 33449 | testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 33078 | logBadConnection("invalid"); | 33450 | logBadConnection("invalid"); |
| 33079 | return 0; | 33451 | return 0; |
| @@ -33692,35 +34064,35 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ | |||
| 33692 | /* 18 */ "If" OpHelp(""), | 34064 | /* 18 */ "If" OpHelp(""), |
| 33693 | /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"), | 34065 | /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"), |
| 33694 | /* 20 */ "IfNot" OpHelp(""), | 34066 | /* 20 */ "IfNot" OpHelp(""), |
| 33695 | /* 21 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"), | 34067 | /* 21 */ "IsNullOrType" OpHelp("if typeof(r[P1]) IN (P3,5) goto P2"), |
| 33696 | /* 22 */ "SeekLT" OpHelp("key=r[P3@P4]"), | 34068 | /* 22 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"), |
| 33697 | /* 23 */ "SeekLE" OpHelp("key=r[P3@P4]"), | 34069 | /* 23 */ "SeekLT" OpHelp("key=r[P3@P4]"), |
| 33698 | /* 24 */ "SeekGE" OpHelp("key=r[P3@P4]"), | 34070 | /* 24 */ "SeekLE" OpHelp("key=r[P3@P4]"), |
| 33699 | /* 25 */ "SeekGT" OpHelp("key=r[P3@P4]"), | 34071 | /* 25 */ "SeekGE" OpHelp("key=r[P3@P4]"), |
| 33700 | /* 26 */ "IfNotOpen" OpHelp("if( !csr[P1] ) goto P2"), | 34072 | /* 26 */ "SeekGT" OpHelp("key=r[P3@P4]"), |
| 33701 | /* 27 */ "IfNoHope" OpHelp("key=r[P3@P4]"), | 34073 | /* 27 */ "IfNotOpen" OpHelp("if( !csr[P1] ) goto P2"), |
| 33702 | /* 28 */ "NoConflict" OpHelp("key=r[P3@P4]"), | 34074 | /* 28 */ "IfNoHope" OpHelp("key=r[P3@P4]"), |
| 33703 | /* 29 */ "NotFound" OpHelp("key=r[P3@P4]"), | 34075 | /* 29 */ "NoConflict" OpHelp("key=r[P3@P4]"), |
| 33704 | /* 30 */ "Found" OpHelp("key=r[P3@P4]"), | 34076 | /* 30 */ "NotFound" OpHelp("key=r[P3@P4]"), |
| 33705 | /* 31 */ "SeekRowid" OpHelp("intkey=r[P3]"), | 34077 | /* 31 */ "Found" OpHelp("key=r[P3@P4]"), |
| 33706 | /* 32 */ "NotExists" OpHelp("intkey=r[P3]"), | 34078 | /* 32 */ "SeekRowid" OpHelp("intkey=r[P3]"), |
| 33707 | /* 33 */ "Last" OpHelp(""), | 34079 | /* 33 */ "NotExists" OpHelp("intkey=r[P3]"), |
| 33708 | /* 34 */ "IfSmaller" OpHelp(""), | 34080 | /* 34 */ "Last" OpHelp(""), |
| 33709 | /* 35 */ "SorterSort" OpHelp(""), | 34081 | /* 35 */ "IfSmaller" OpHelp(""), |
| 33710 | /* 36 */ "Sort" OpHelp(""), | 34082 | /* 36 */ "SorterSort" OpHelp(""), |
| 33711 | /* 37 */ "Rewind" OpHelp(""), | 34083 | /* 37 */ "Sort" OpHelp(""), |
| 33712 | /* 38 */ "IdxLE" OpHelp("key=r[P3@P4]"), | 34084 | /* 38 */ "Rewind" OpHelp(""), |
| 33713 | /* 39 */ "IdxGT" OpHelp("key=r[P3@P4]"), | 34085 | /* 39 */ "IdxLE" OpHelp("key=r[P3@P4]"), |
| 33714 | /* 40 */ "IdxLT" OpHelp("key=r[P3@P4]"), | 34086 | /* 40 */ "IdxGT" OpHelp("key=r[P3@P4]"), |
| 33715 | /* 41 */ "IdxGE" OpHelp("key=r[P3@P4]"), | 34087 | /* 41 */ "IdxLT" OpHelp("key=r[P3@P4]"), |
| 33716 | /* 42 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), | 34088 | /* 42 */ "IdxGE" OpHelp("key=r[P3@P4]"), |
| 33717 | /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), | 34089 | /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 33718 | /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), | 34090 | /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 33719 | /* 45 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), | 34091 | /* 45 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), |
| 33720 | /* 46 */ "Program" OpHelp(""), | 34092 | /* 46 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), |
| 33721 | /* 47 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), | 34093 | /* 47 */ "Program" OpHelp(""), |
| 33722 | /* 48 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), | 34094 | /* 48 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), |
| 33723 | /* 49 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), | 34095 | /* 49 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), |
| 33724 | /* 50 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), | 34096 | /* 50 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 33725 | /* 51 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), | 34097 | /* 51 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 33726 | /* 52 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), | 34098 | /* 52 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| @@ -33730,49 +34102,49 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ | |||
| 33730 | /* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"), | 34102 | /* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 33731 | /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), | 34103 | /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 33732 | /* 58 */ "ElseEq" OpHelp(""), | 34104 | /* 58 */ "ElseEq" OpHelp(""), |
| 33733 | /* 59 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), | 34105 | /* 59 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), |
| 33734 | /* 60 */ "IncrVacuum" OpHelp(""), | 34106 | /* 60 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), |
| 33735 | /* 61 */ "VNext" OpHelp(""), | 34107 | /* 61 */ "IncrVacuum" OpHelp(""), |
| 33736 | /* 62 */ "Init" OpHelp("Start at P2"), | 34108 | /* 62 */ "VNext" OpHelp(""), |
| 33737 | /* 63 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"), | 34109 | /* 63 */ "Init" OpHelp("Start at P2"), |
| 33738 | /* 64 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"), | 34110 | /* 64 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"), |
| 33739 | /* 65 */ "Return" OpHelp(""), | 34111 | /* 65 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"), |
| 33740 | /* 66 */ "EndCoroutine" OpHelp(""), | 34112 | /* 66 */ "Return" OpHelp(""), |
| 33741 | /* 67 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), | 34113 | /* 67 */ "EndCoroutine" OpHelp(""), |
| 33742 | /* 68 */ "Halt" OpHelp(""), | 34114 | /* 68 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), |
| 33743 | /* 69 */ "Integer" OpHelp("r[P2]=P1"), | 34115 | /* 69 */ "Halt" OpHelp(""), |
| 33744 | /* 70 */ "Int64" OpHelp("r[P2]=P4"), | 34116 | /* 70 */ "Integer" OpHelp("r[P2]=P1"), |
| 33745 | /* 71 */ "String" OpHelp("r[P2]='P4' (len=P1)"), | 34117 | /* 71 */ "Int64" OpHelp("r[P2]=P4"), |
| 33746 | /* 72 */ "Null" OpHelp("r[P2..P3]=NULL"), | 34118 | /* 72 */ "String" OpHelp("r[P2]='P4' (len=P1)"), |
| 33747 | /* 73 */ "SoftNull" OpHelp("r[P1]=NULL"), | 34119 | /* 73 */ "Null" OpHelp("r[P2..P3]=NULL"), |
| 33748 | /* 74 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), | 34120 | /* 74 */ "SoftNull" OpHelp("r[P1]=NULL"), |
| 33749 | /* 75 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), | 34121 | /* 75 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), |
| 33750 | /* 76 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), | 34122 | /* 76 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"), |
| 33751 | /* 77 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), | 34123 | /* 77 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), |
| 33752 | /* 78 */ "SCopy" OpHelp("r[P2]=r[P1]"), | 34124 | /* 78 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), |
| 33753 | /* 79 */ "IntCopy" OpHelp("r[P2]=r[P1]"), | 34125 | /* 79 */ "SCopy" OpHelp("r[P2]=r[P1]"), |
| 33754 | /* 80 */ "ChngCntRow" OpHelp("output=r[P1]"), | 34126 | /* 80 */ "IntCopy" OpHelp("r[P2]=r[P1]"), |
| 33755 | /* 81 */ "ResultRow" OpHelp("output=r[P1@P2]"), | 34127 | /* 81 */ "ChngCntRow" OpHelp("output=r[P1]"), |
| 33756 | /* 82 */ "CollSeq" OpHelp(""), | 34128 | /* 82 */ "ResultRow" OpHelp("output=r[P1@P2]"), |
| 33757 | /* 83 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), | 34129 | /* 83 */ "CollSeq" OpHelp(""), |
| 33758 | /* 84 */ "RealAffinity" OpHelp(""), | 34130 | /* 84 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), |
| 33759 | /* 85 */ "Cast" OpHelp("affinity(r[P1])"), | 34131 | /* 85 */ "RealAffinity" OpHelp(""), |
| 33760 | /* 86 */ "Permutation" OpHelp(""), | 34132 | /* 86 */ "Cast" OpHelp("affinity(r[P1])"), |
| 33761 | /* 87 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), | 34133 | /* 87 */ "Permutation" OpHelp(""), |
| 33762 | /* 88 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), | 34134 | /* 88 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), |
| 33763 | /* 89 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"), | 34135 | /* 89 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), |
| 33764 | /* 90 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), | 34136 | /* 90 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"), |
| 33765 | /* 91 */ "Column" OpHelp("r[P3]=PX"), | 34137 | /* 91 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), |
| 33766 | /* 92 */ "Affinity" OpHelp("affinity(r[P1@P2])"), | 34138 | /* 92 */ "Column" OpHelp("r[P3]=PX"), |
| 33767 | /* 93 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), | 34139 | /* 93 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"), |
| 33768 | /* 94 */ "Count" OpHelp("r[P2]=count()"), | 34140 | /* 94 */ "Affinity" OpHelp("affinity(r[P1@P2])"), |
| 33769 | /* 95 */ "ReadCookie" OpHelp(""), | 34141 | /* 95 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), |
| 33770 | /* 96 */ "SetCookie" OpHelp(""), | 34142 | /* 96 */ "Count" OpHelp("r[P2]=count()"), |
| 33771 | /* 97 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), | 34143 | /* 97 */ "ReadCookie" OpHelp(""), |
| 33772 | /* 98 */ "OpenRead" OpHelp("root=P2 iDb=P3"), | 34144 | /* 98 */ "SetCookie" OpHelp(""), |
| 33773 | /* 99 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), | 34145 | /* 99 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), |
| 33774 | /* 100 */ "OpenDup" OpHelp(""), | 34146 | /* 100 */ "OpenRead" OpHelp("root=P2 iDb=P3"), |
| 33775 | /* 101 */ "OpenAutoindex" OpHelp("nColumn=P2"), | 34147 | /* 101 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), |
| 33776 | /* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), | 34148 | /* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 33777 | /* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), | 34149 | /* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 33778 | /* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), | 34150 | /* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| @@ -33783,74 +34155,76 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){ | |||
| 33783 | /* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), | 34155 | /* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 33784 | /* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), | 34156 | /* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 33785 | /* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), | 34157 | /* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 33786 | /* 112 */ "OpenEphemeral" OpHelp("nColumn=P2"), | 34158 | /* 112 */ "OpenDup" OpHelp(""), |
| 33787 | /* 113 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), | 34159 | /* 113 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), |
| 33788 | /* 114 */ "SorterOpen" OpHelp(""), | 34160 | /* 114 */ "OpenAutoindex" OpHelp("nColumn=P2"), |
| 33789 | /* 115 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), | 34161 | /* 115 */ "OpenEphemeral" OpHelp("nColumn=P2"), |
| 33790 | /* 116 */ "String8" OpHelp("r[P2]='P4'"), | 34162 | /* 116 */ "String8" OpHelp("r[P2]='P4'"), |
| 33791 | /* 117 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), | 34163 | /* 117 */ "SorterOpen" OpHelp(""), |
| 33792 | /* 118 */ "Close" OpHelp(""), | 34164 | /* 118 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), |
| 33793 | /* 119 */ "ColumnsUsed" OpHelp(""), | 34165 | /* 119 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), |
| 33794 | /* 120 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), | 34166 | /* 120 */ "Close" OpHelp(""), |
| 33795 | /* 121 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), | 34167 | /* 121 */ "ColumnsUsed" OpHelp(""), |
| 33796 | /* 122 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), | 34168 | /* 122 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), |
| 33797 | /* 123 */ "NewRowid" OpHelp("r[P2]=rowid"), | 34169 | /* 123 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), |
| 33798 | /* 124 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), | 34170 | /* 124 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), |
| 33799 | /* 125 */ "RowCell" OpHelp(""), | 34171 | /* 125 */ "NewRowid" OpHelp("r[P2]=rowid"), |
| 33800 | /* 126 */ "Delete" OpHelp(""), | 34172 | /* 126 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), |
| 33801 | /* 127 */ "ResetCount" OpHelp(""), | 34173 | /* 127 */ "RowCell" OpHelp(""), |
| 33802 | /* 128 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), | 34174 | /* 128 */ "Delete" OpHelp(""), |
| 33803 | /* 129 */ "SorterData" OpHelp("r[P2]=data"), | 34175 | /* 129 */ "ResetCount" OpHelp(""), |
| 33804 | /* 130 */ "RowData" OpHelp("r[P2]=data"), | 34176 | /* 130 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), |
| 33805 | /* 131 */ "Rowid" OpHelp("r[P2]=rowid"), | 34177 | /* 131 */ "SorterData" OpHelp("r[P2]=data"), |
| 33806 | /* 132 */ "NullRow" OpHelp(""), | 34178 | /* 132 */ "RowData" OpHelp("r[P2]=data"), |
| 33807 | /* 133 */ "SeekEnd" OpHelp(""), | 34179 | /* 133 */ "Rowid" OpHelp("r[P2]=rowid"), |
| 33808 | /* 134 */ "IdxInsert" OpHelp("key=r[P2]"), | 34180 | /* 134 */ "NullRow" OpHelp(""), |
| 33809 | /* 135 */ "SorterInsert" OpHelp("key=r[P2]"), | 34181 | /* 135 */ "SeekEnd" OpHelp(""), |
| 33810 | /* 136 */ "IdxDelete" OpHelp("key=r[P2@P3]"), | 34182 | /* 136 */ "IdxInsert" OpHelp("key=r[P2]"), |
| 33811 | /* 137 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), | 34183 | /* 137 */ "SorterInsert" OpHelp("key=r[P2]"), |
| 33812 | /* 138 */ "IdxRowid" OpHelp("r[P2]=rowid"), | 34184 | /* 138 */ "IdxDelete" OpHelp("key=r[P2@P3]"), |
| 33813 | /* 139 */ "FinishSeek" OpHelp(""), | 34185 | /* 139 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), |
| 33814 | /* 140 */ "Destroy" OpHelp(""), | 34186 | /* 140 */ "IdxRowid" OpHelp("r[P2]=rowid"), |
| 33815 | /* 141 */ "Clear" OpHelp(""), | 34187 | /* 141 */ "FinishSeek" OpHelp(""), |
| 33816 | /* 142 */ "ResetSorter" OpHelp(""), | 34188 | /* 142 */ "Destroy" OpHelp(""), |
| 33817 | /* 143 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), | 34189 | /* 143 */ "Clear" OpHelp(""), |
| 33818 | /* 144 */ "SqlExec" OpHelp(""), | 34190 | /* 144 */ "ResetSorter" OpHelp(""), |
| 33819 | /* 145 */ "ParseSchema" OpHelp(""), | 34191 | /* 145 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), |
| 33820 | /* 146 */ "LoadAnalysis" OpHelp(""), | 34192 | /* 146 */ "SqlExec" OpHelp(""), |
| 33821 | /* 147 */ "DropTable" OpHelp(""), | 34193 | /* 147 */ "ParseSchema" OpHelp(""), |
| 33822 | /* 148 */ "DropIndex" OpHelp(""), | 34194 | /* 148 */ "LoadAnalysis" OpHelp(""), |
| 33823 | /* 149 */ "DropTrigger" OpHelp(""), | 34195 | /* 149 */ "DropTable" OpHelp(""), |
| 33824 | /* 150 */ "IntegrityCk" OpHelp(""), | 34196 | /* 150 */ "DropIndex" OpHelp(""), |
| 33825 | /* 151 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), | 34197 | /* 151 */ "DropTrigger" OpHelp(""), |
| 33826 | /* 152 */ "Real" OpHelp("r[P2]=P4"), | 34198 | /* 152 */ "Real" OpHelp("r[P2]=P4"), |
| 33827 | /* 153 */ "Param" OpHelp(""), | 34199 | /* 153 */ "IntegrityCk" OpHelp(""), |
| 33828 | /* 154 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), | 34200 | /* 154 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), |
| 33829 | /* 155 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), | 34201 | /* 155 */ "Param" OpHelp(""), |
| 33830 | /* 156 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), | 34202 | /* 156 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), |
| 33831 | /* 157 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), | 34203 | /* 157 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), |
| 33832 | /* 158 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), | 34204 | /* 158 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), |
| 33833 | /* 159 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), | 34205 | /* 159 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), |
| 33834 | /* 160 */ "AggValue" OpHelp("r[P3]=value N=P2"), | 34206 | /* 160 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 33835 | /* 161 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), | 34207 | /* 161 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), |
| 33836 | /* 162 */ "Expire" OpHelp(""), | 34208 | /* 162 */ "AggValue" OpHelp("r[P3]=value N=P2"), |
| 33837 | /* 163 */ "CursorLock" OpHelp(""), | 34209 | /* 163 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), |
| 33838 | /* 164 */ "CursorUnlock" OpHelp(""), | 34210 | /* 164 */ "Expire" OpHelp(""), |
| 33839 | /* 165 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), | 34211 | /* 165 */ "CursorLock" OpHelp(""), |
| 33840 | /* 166 */ "VBegin" OpHelp(""), | 34212 | /* 166 */ "CursorUnlock" OpHelp(""), |
| 33841 | /* 167 */ "VCreate" OpHelp(""), | 34213 | /* 167 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), |
| 33842 | /* 168 */ "VDestroy" OpHelp(""), | 34214 | /* 168 */ "VBegin" OpHelp(""), |
| 33843 | /* 169 */ "VOpen" OpHelp(""), | 34215 | /* 169 */ "VCreate" OpHelp(""), |
| 33844 | /* 170 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), | 34216 | /* 170 */ "VDestroy" OpHelp(""), |
| 33845 | /* 171 */ "VRename" OpHelp(""), | 34217 | /* 171 */ "VOpen" OpHelp(""), |
| 33846 | /* 172 */ "Pagecount" OpHelp(""), | 34218 | /* 172 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), |
| 33847 | /* 173 */ "MaxPgcnt" OpHelp(""), | 34219 | /* 173 */ "VRename" OpHelp(""), |
| 33848 | /* 174 */ "Trace" OpHelp(""), | 34220 | /* 174 */ "Pagecount" OpHelp(""), |
| 33849 | /* 175 */ "CursorHint" OpHelp(""), | 34221 | /* 175 */ "MaxPgcnt" OpHelp(""), |
| 33850 | /* 176 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), | 34222 | /* 176 */ "Trace" OpHelp(""), |
| 33851 | /* 177 */ "Noop" OpHelp(""), | 34223 | /* 177 */ "CursorHint" OpHelp(""), |
| 33852 | /* 178 */ "Explain" OpHelp(""), | 34224 | /* 178 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), |
| 33853 | /* 179 */ "Abortable" OpHelp(""), | 34225 | /* 179 */ "Noop" OpHelp(""), |
| 34226 | /* 180 */ "Explain" OpHelp(""), | ||
| 34227 | /* 181 */ "Abortable" OpHelp(""), | ||
| 33854 | }; | 34228 | }; |
| 33855 | return azName[i]; | 34229 | return azName[i]; |
| 33856 | } | 34230 | } |
| @@ -34157,205 +34531,7 @@ static pid_t randomnessPid = 0; | |||
| 34157 | /* | 34531 | /* |
| 34158 | ** Include code that is common to all os_*.c files | 34532 | ** Include code that is common to all os_*.c files |
| 34159 | */ | 34533 | */ |
| 34160 | /************** Include os_common.h in the middle of os_unix.c ***************/ | 34534 | /* #include "os_common.h" */ |
| 34161 | /************** Begin file os_common.h ***************************************/ | ||
| 34162 | /* | ||
| 34163 | ** 2004 May 22 | ||
| 34164 | ** | ||
| 34165 | ** The author disclaims copyright to this source code. In place of | ||
| 34166 | ** a legal notice, here is a blessing: | ||
| 34167 | ** | ||
| 34168 | ** May you do good and not evil. | ||
| 34169 | ** May you find forgiveness for yourself and forgive others. | ||
| 34170 | ** May you share freely, never taking more than you give. | ||
| 34171 | ** | ||
| 34172 | ****************************************************************************** | ||
| 34173 | ** | ||
| 34174 | ** This file contains macros and a little bit of code that is common to | ||
| 34175 | ** all of the platform-specific files (os_*.c) and is #included into those | ||
| 34176 | ** files. | ||
| 34177 | ** | ||
| 34178 | ** This file should be #included by the os_*.c files only. It is not a | ||
| 34179 | ** general purpose header file. | ||
| 34180 | */ | ||
| 34181 | #ifndef _OS_COMMON_H_ | ||
| 34182 | #define _OS_COMMON_H_ | ||
| 34183 | |||
| 34184 | /* | ||
| 34185 | ** At least two bugs have slipped in because we changed the MEMORY_DEBUG | ||
| 34186 | ** macro to SQLITE_DEBUG and some older makefiles have not yet made the | ||
| 34187 | ** switch. The following code should catch this problem at compile-time. | ||
| 34188 | */ | ||
| 34189 | #ifdef MEMORY_DEBUG | ||
| 34190 | # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." | ||
| 34191 | #endif | ||
| 34192 | |||
| 34193 | /* | ||
| 34194 | ** Macros for performance tracing. Normally turned off. Only works | ||
| 34195 | ** on i486 hardware. | ||
| 34196 | */ | ||
| 34197 | #ifdef SQLITE_PERFORMANCE_TRACE | ||
| 34198 | |||
| 34199 | /* | ||
| 34200 | ** hwtime.h contains inline assembler code for implementing | ||
| 34201 | ** high-performance timing routines. | ||
| 34202 | */ | ||
| 34203 | /************** Include hwtime.h in the middle of os_common.h ****************/ | ||
| 34204 | /************** Begin file hwtime.h ******************************************/ | ||
| 34205 | /* | ||
| 34206 | ** 2008 May 27 | ||
| 34207 | ** | ||
| 34208 | ** The author disclaims copyright to this source code. In place of | ||
| 34209 | ** a legal notice, here is a blessing: | ||
| 34210 | ** | ||
| 34211 | ** May you do good and not evil. | ||
| 34212 | ** May you find forgiveness for yourself and forgive others. | ||
| 34213 | ** May you share freely, never taking more than you give. | ||
| 34214 | ** | ||
| 34215 | ****************************************************************************** | ||
| 34216 | ** | ||
| 34217 | ** This file contains inline asm code for retrieving "high-performance" | ||
| 34218 | ** counters for x86 and x86_64 class CPUs. | ||
| 34219 | */ | ||
| 34220 | #ifndef SQLITE_HWTIME_H | ||
| 34221 | #define SQLITE_HWTIME_H | ||
| 34222 | |||
| 34223 | /* | ||
| 34224 | ** The following routine only works on pentium-class (or newer) processors. | ||
| 34225 | ** It uses the RDTSC opcode to read the cycle count value out of the | ||
| 34226 | ** processor and returns that value. This can be used for high-res | ||
| 34227 | ** profiling. | ||
| 34228 | */ | ||
| 34229 | #if !defined(__STRICT_ANSI__) && \ | ||
| 34230 | (defined(__GNUC__) || defined(_MSC_VER)) && \ | ||
| 34231 | (defined(i386) || defined(__i386__) || defined(_M_IX86)) | ||
| 34232 | |||
| 34233 | #if defined(__GNUC__) | ||
| 34234 | |||
| 34235 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 34236 | unsigned int lo, hi; | ||
| 34237 | __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); | ||
| 34238 | return (sqlite_uint64)hi << 32 | lo; | ||
| 34239 | } | ||
| 34240 | |||
| 34241 | #elif defined(_MSC_VER) | ||
| 34242 | |||
| 34243 | __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){ | ||
| 34244 | __asm { | ||
| 34245 | rdtsc | ||
| 34246 | ret ; return value at EDX:EAX | ||
| 34247 | } | ||
| 34248 | } | ||
| 34249 | |||
| 34250 | #endif | ||
| 34251 | |||
| 34252 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) | ||
| 34253 | |||
| 34254 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 34255 | unsigned long val; | ||
| 34256 | __asm__ __volatile__ ("rdtsc" : "=A" (val)); | ||
| 34257 | return val; | ||
| 34258 | } | ||
| 34259 | |||
| 34260 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) | ||
| 34261 | |||
| 34262 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 34263 | unsigned long long retval; | ||
| 34264 | unsigned long junk; | ||
| 34265 | __asm__ __volatile__ ("\n\ | ||
| 34266 | 1: mftbu %1\n\ | ||
| 34267 | mftb %L0\n\ | ||
| 34268 | mftbu %0\n\ | ||
| 34269 | cmpw %0,%1\n\ | ||
| 34270 | bne 1b" | ||
| 34271 | : "=r" (retval), "=r" (junk)); | ||
| 34272 | return retval; | ||
| 34273 | } | ||
| 34274 | |||
| 34275 | #else | ||
| 34276 | |||
| 34277 | /* | ||
| 34278 | ** asm() is needed for hardware timing support. Without asm(), | ||
| 34279 | ** disable the sqlite3Hwtime() routine. | ||
| 34280 | ** | ||
| 34281 | ** sqlite3Hwtime() is only used for some obscure debugging | ||
| 34282 | ** and analysis configurations, not in any deliverable, so this | ||
| 34283 | ** should not be a great loss. | ||
| 34284 | */ | ||
| 34285 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } | ||
| 34286 | |||
| 34287 | #endif | ||
| 34288 | |||
| 34289 | #endif /* !defined(SQLITE_HWTIME_H) */ | ||
| 34290 | |||
| 34291 | /************** End of hwtime.h **********************************************/ | ||
| 34292 | /************** Continuing where we left off in os_common.h ******************/ | ||
| 34293 | |||
| 34294 | static sqlite_uint64 g_start; | ||
| 34295 | static sqlite_uint64 g_elapsed; | ||
| 34296 | #define TIMER_START g_start=sqlite3Hwtime() | ||
| 34297 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start | ||
| 34298 | #define TIMER_ELAPSED g_elapsed | ||
| 34299 | #else | ||
| 34300 | #define TIMER_START | ||
| 34301 | #define TIMER_END | ||
| 34302 | #define TIMER_ELAPSED ((sqlite_uint64)0) | ||
| 34303 | #endif | ||
| 34304 | |||
| 34305 | /* | ||
| 34306 | ** If we compile with the SQLITE_TEST macro set, then the following block | ||
| 34307 | ** of code will give us the ability to simulate a disk I/O error. This | ||
| 34308 | ** is used for testing the I/O recovery logic. | ||
| 34309 | */ | ||
| 34310 | #if defined(SQLITE_TEST) | ||
| 34311 | SQLITE_API extern int sqlite3_io_error_hit; | ||
| 34312 | SQLITE_API extern int sqlite3_io_error_hardhit; | ||
| 34313 | SQLITE_API extern int sqlite3_io_error_pending; | ||
| 34314 | SQLITE_API extern int sqlite3_io_error_persist; | ||
| 34315 | SQLITE_API extern int sqlite3_io_error_benign; | ||
| 34316 | SQLITE_API extern int sqlite3_diskfull_pending; | ||
| 34317 | SQLITE_API extern int sqlite3_diskfull; | ||
| 34318 | #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X) | ||
| 34319 | #define SimulateIOError(CODE) \ | ||
| 34320 | if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \ | ||
| 34321 | || sqlite3_io_error_pending-- == 1 ) \ | ||
| 34322 | { local_ioerr(); CODE; } | ||
| 34323 | static void local_ioerr(){ | ||
| 34324 | IOTRACE(("IOERR\n")); | ||
| 34325 | sqlite3_io_error_hit++; | ||
| 34326 | if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++; | ||
| 34327 | } | ||
| 34328 | #define SimulateDiskfullError(CODE) \ | ||
| 34329 | if( sqlite3_diskfull_pending ){ \ | ||
| 34330 | if( sqlite3_diskfull_pending == 1 ){ \ | ||
| 34331 | local_ioerr(); \ | ||
| 34332 | sqlite3_diskfull = 1; \ | ||
| 34333 | sqlite3_io_error_hit = 1; \ | ||
| 34334 | CODE; \ | ||
| 34335 | }else{ \ | ||
| 34336 | sqlite3_diskfull_pending--; \ | ||
| 34337 | } \ | ||
| 34338 | } | ||
| 34339 | #else | ||
| 34340 | #define SimulateIOErrorBenign(X) | ||
| 34341 | #define SimulateIOError(A) | ||
| 34342 | #define SimulateDiskfullError(A) | ||
| 34343 | #endif /* defined(SQLITE_TEST) */ | ||
| 34344 | |||
| 34345 | /* | ||
| 34346 | ** When testing, keep a count of the number of open files. | ||
| 34347 | */ | ||
| 34348 | #if defined(SQLITE_TEST) | ||
| 34349 | SQLITE_API extern int sqlite3_open_file_count; | ||
| 34350 | #define OpenCounter(X) sqlite3_open_file_count+=(X) | ||
| 34351 | #else | ||
| 34352 | #define OpenCounter(X) | ||
| 34353 | #endif /* defined(SQLITE_TEST) */ | ||
| 34354 | |||
| 34355 | #endif /* !defined(_OS_COMMON_H_) */ | ||
| 34356 | |||
| 34357 | /************** End of os_common.h *******************************************/ | ||
| 34358 | /************** Continuing where we left off in os_unix.c ********************/ | ||
| 34359 | 34535 | ||
| 34360 | /* | 34536 | /* |
| 34361 | ** Define various macros that are missing from some systems. | 34537 | ** Define various macros that are missing from some systems. |
| @@ -38009,7 +38185,9 @@ static void unixModeBit(unixFile *pFile, unsigned char mask, int *pArg){ | |||
| 38009 | 38185 | ||
| 38010 | /* Forward declaration */ | 38186 | /* Forward declaration */ |
| 38011 | static int unixGetTempname(int nBuf, char *zBuf); | 38187 | static int unixGetTempname(int nBuf, char *zBuf); |
| 38012 | static int unixFcntlExternalReader(unixFile*, int*); | 38188 | #ifndef SQLITE_OMIT_WAL |
| 38189 | static int unixFcntlExternalReader(unixFile*, int*); | ||
| 38190 | #endif | ||
| 38013 | 38191 | ||
| 38014 | /* | 38192 | /* |
| 38015 | ** Information and control of an open file handle. | 38193 | ** Information and control of an open file handle. |
| @@ -38128,7 +38306,12 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ | |||
| 38128 | #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ | 38306 | #endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */ |
| 38129 | 38307 | ||
| 38130 | case SQLITE_FCNTL_EXTERNAL_READER: { | 38308 | case SQLITE_FCNTL_EXTERNAL_READER: { |
| 38309 | #ifndef SQLITE_OMIT_WAL | ||
| 38131 | return unixFcntlExternalReader((unixFile*)id, (int*)pArg); | 38310 | return unixFcntlExternalReader((unixFile*)id, (int*)pArg); |
| 38311 | #else | ||
| 38312 | *(int*)pArg = 0; | ||
| 38313 | return SQLITE_OK; | ||
| 38314 | #endif | ||
| 38132 | } | 38315 | } |
| 38133 | } | 38316 | } |
| 38134 | return SQLITE_NOTFOUND; | 38317 | return SQLITE_NOTFOUND; |
| @@ -39850,24 +40033,34 @@ static int fillInUnixFile( | |||
| 39850 | } | 40033 | } |
| 39851 | 40034 | ||
| 39852 | /* | 40035 | /* |
| 40036 | ** Directories to consider for temp files. | ||
| 40037 | */ | ||
| 40038 | static const char *azTempDirs[] = { | ||
| 40039 | 0, | ||
| 40040 | 0, | ||
| 40041 | "/var/tmp", | ||
| 40042 | "/usr/tmp", | ||
| 40043 | "/tmp", | ||
| 40044 | "." | ||
| 40045 | }; | ||
| 40046 | |||
| 40047 | /* | ||
| 40048 | ** Initialize first two members of azTempDirs[] array. | ||
| 40049 | */ | ||
| 40050 | static void unixTempFileInit(void){ | ||
| 40051 | azTempDirs[0] = getenv("SQLITE_TMPDIR"); | ||
| 40052 | azTempDirs[1] = getenv("TMPDIR"); | ||
| 40053 | } | ||
| 40054 | |||
| 40055 | /* | ||
| 39853 | ** Return the name of a directory in which to put temporary files. | 40056 | ** Return the name of a directory in which to put temporary files. |
| 39854 | ** If no suitable temporary file directory can be found, return NULL. | 40057 | ** If no suitable temporary file directory can be found, return NULL. |
| 39855 | */ | 40058 | */ |
| 39856 | static const char *unixTempFileDir(void){ | 40059 | static const char *unixTempFileDir(void){ |
| 39857 | static const char *azDirs[] = { | ||
| 39858 | 0, | ||
| 39859 | 0, | ||
| 39860 | "/var/tmp", | ||
| 39861 | "/usr/tmp", | ||
| 39862 | "/tmp", | ||
| 39863 | "." | ||
| 39864 | }; | ||
| 39865 | unsigned int i = 0; | 40060 | unsigned int i = 0; |
| 39866 | struct stat buf; | 40061 | struct stat buf; |
| 39867 | const char *zDir = sqlite3_temp_directory; | 40062 | const char *zDir = sqlite3_temp_directory; |
| 39868 | 40063 | ||
| 39869 | if( !azDirs[0] ) azDirs[0] = getenv("SQLITE_TMPDIR"); | ||
| 39870 | if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR"); | ||
| 39871 | while(1){ | 40064 | while(1){ |
| 39872 | if( zDir!=0 | 40065 | if( zDir!=0 |
| 39873 | && osStat(zDir, &buf)==0 | 40066 | && osStat(zDir, &buf)==0 |
| @@ -39876,8 +40069,8 @@ static const char *unixTempFileDir(void){ | |||
| 39876 | ){ | 40069 | ){ |
| 39877 | return zDir; | 40070 | return zDir; |
| 39878 | } | 40071 | } |
| 39879 | if( i>=sizeof(azDirs)/sizeof(azDirs[0]) ) break; | 40072 | if( i>=sizeof(azTempDirs)/sizeof(azTempDirs[0]) ) break; |
| 39880 | zDir = azDirs[i++]; | 40073 | zDir = azTempDirs[i++]; |
| 39881 | } | 40074 | } |
| 39882 | return 0; | 40075 | return 0; |
| 39883 | } | 40076 | } |
| @@ -40183,6 +40376,11 @@ static int unixOpen( | |||
| 40183 | } | 40376 | } |
| 40184 | memset(p, 0, sizeof(unixFile)); | 40377 | memset(p, 0, sizeof(unixFile)); |
| 40185 | 40378 | ||
| 40379 | #ifdef SQLITE_ASSERT_NO_FILES | ||
| 40380 | /* Applications that never read or write a persistent disk files */ | ||
| 40381 | assert( zName==0 ); | ||
| 40382 | #endif | ||
| 40383 | |||
| 40186 | if( eType==SQLITE_OPEN_MAIN_DB ){ | 40384 | if( eType==SQLITE_OPEN_MAIN_DB ){ |
| 40187 | UnixUnusedFd *pUnused; | 40385 | UnixUnusedFd *pUnused; |
| 40188 | pUnused = findReusableFd(zName, flags); | 40386 | pUnused = findReusableFd(zName, flags); |
| @@ -42144,6 +42342,9 @@ SQLITE_API int sqlite3_os_init(void){ | |||
| 42144 | assert( UNIX_SHM_DMS==128 ); /* Byte offset of the deadman-switch */ | 42342 | assert( UNIX_SHM_DMS==128 ); /* Byte offset of the deadman-switch */ |
| 42145 | #endif | 42343 | #endif |
| 42146 | 42344 | ||
| 42345 | /* Initialize temp file dir array. */ | ||
| 42346 | unixTempFileInit(); | ||
| 42347 | |||
| 42147 | return SQLITE_OK; | 42348 | return SQLITE_OK; |
| 42148 | } | 42349 | } |
| 42149 | 42350 | ||
| @@ -42183,205 +42384,7 @@ SQLITE_API int sqlite3_os_end(void){ | |||
| 42183 | /* | 42384 | /* |
| 42184 | ** Include code that is common to all os_*.c files | 42385 | ** Include code that is common to all os_*.c files |
| 42185 | */ | 42386 | */ |
| 42186 | /************** Include os_common.h in the middle of os_win.c ****************/ | 42387 | /* #include "os_common.h" */ |
| 42187 | /************** Begin file os_common.h ***************************************/ | ||
| 42188 | /* | ||
| 42189 | ** 2004 May 22 | ||
| 42190 | ** | ||
| 42191 | ** The author disclaims copyright to this source code. In place of | ||
| 42192 | ** a legal notice, here is a blessing: | ||
| 42193 | ** | ||
| 42194 | ** May you do good and not evil. | ||
| 42195 | ** May you find forgiveness for yourself and forgive others. | ||
| 42196 | ** May you share freely, never taking more than you give. | ||
| 42197 | ** | ||
| 42198 | ****************************************************************************** | ||
| 42199 | ** | ||
| 42200 | ** This file contains macros and a little bit of code that is common to | ||
| 42201 | ** all of the platform-specific files (os_*.c) and is #included into those | ||
| 42202 | ** files. | ||
| 42203 | ** | ||
| 42204 | ** This file should be #included by the os_*.c files only. It is not a | ||
| 42205 | ** general purpose header file. | ||
| 42206 | */ | ||
| 42207 | #ifndef _OS_COMMON_H_ | ||
| 42208 | #define _OS_COMMON_H_ | ||
| 42209 | |||
| 42210 | /* | ||
| 42211 | ** At least two bugs have slipped in because we changed the MEMORY_DEBUG | ||
| 42212 | ** macro to SQLITE_DEBUG and some older makefiles have not yet made the | ||
| 42213 | ** switch. The following code should catch this problem at compile-time. | ||
| 42214 | */ | ||
| 42215 | #ifdef MEMORY_DEBUG | ||
| 42216 | # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead." | ||
| 42217 | #endif | ||
| 42218 | |||
| 42219 | /* | ||
| 42220 | ** Macros for performance tracing. Normally turned off. Only works | ||
| 42221 | ** on i486 hardware. | ||
| 42222 | */ | ||
| 42223 | #ifdef SQLITE_PERFORMANCE_TRACE | ||
| 42224 | |||
| 42225 | /* | ||
| 42226 | ** hwtime.h contains inline assembler code for implementing | ||
| 42227 | ** high-performance timing routines. | ||
| 42228 | */ | ||
| 42229 | /************** Include hwtime.h in the middle of os_common.h ****************/ | ||
| 42230 | /************** Begin file hwtime.h ******************************************/ | ||
| 42231 | /* | ||
| 42232 | ** 2008 May 27 | ||
| 42233 | ** | ||
| 42234 | ** The author disclaims copyright to this source code. In place of | ||
| 42235 | ** a legal notice, here is a blessing: | ||
| 42236 | ** | ||
| 42237 | ** May you do good and not evil. | ||
| 42238 | ** May you find forgiveness for yourself and forgive others. | ||
| 42239 | ** May you share freely, never taking more than you give. | ||
| 42240 | ** | ||
| 42241 | ****************************************************************************** | ||
| 42242 | ** | ||
| 42243 | ** This file contains inline asm code for retrieving "high-performance" | ||
| 42244 | ** counters for x86 and x86_64 class CPUs. | ||
| 42245 | */ | ||
| 42246 | #ifndef SQLITE_HWTIME_H | ||
| 42247 | #define SQLITE_HWTIME_H | ||
| 42248 | |||
| 42249 | /* | ||
| 42250 | ** The following routine only works on pentium-class (or newer) processors. | ||
| 42251 | ** It uses the RDTSC opcode to read the cycle count value out of the | ||
| 42252 | ** processor and returns that value. This can be used for high-res | ||
| 42253 | ** profiling. | ||
| 42254 | */ | ||
| 42255 | #if !defined(__STRICT_ANSI__) && \ | ||
| 42256 | (defined(__GNUC__) || defined(_MSC_VER)) && \ | ||
| 42257 | (defined(i386) || defined(__i386__) || defined(_M_IX86)) | ||
| 42258 | |||
| 42259 | #if defined(__GNUC__) | ||
| 42260 | |||
| 42261 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 42262 | unsigned int lo, hi; | ||
| 42263 | __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); | ||
| 42264 | return (sqlite_uint64)hi << 32 | lo; | ||
| 42265 | } | ||
| 42266 | |||
| 42267 | #elif defined(_MSC_VER) | ||
| 42268 | |||
| 42269 | __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){ | ||
| 42270 | __asm { | ||
| 42271 | rdtsc | ||
| 42272 | ret ; return value at EDX:EAX | ||
| 42273 | } | ||
| 42274 | } | ||
| 42275 | |||
| 42276 | #endif | ||
| 42277 | |||
| 42278 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) | ||
| 42279 | |||
| 42280 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 42281 | unsigned long val; | ||
| 42282 | __asm__ __volatile__ ("rdtsc" : "=A" (val)); | ||
| 42283 | return val; | ||
| 42284 | } | ||
| 42285 | |||
| 42286 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) | ||
| 42287 | |||
| 42288 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 42289 | unsigned long long retval; | ||
| 42290 | unsigned long junk; | ||
| 42291 | __asm__ __volatile__ ("\n\ | ||
| 42292 | 1: mftbu %1\n\ | ||
| 42293 | mftb %L0\n\ | ||
| 42294 | mftbu %0\n\ | ||
| 42295 | cmpw %0,%1\n\ | ||
| 42296 | bne 1b" | ||
| 42297 | : "=r" (retval), "=r" (junk)); | ||
| 42298 | return retval; | ||
| 42299 | } | ||
| 42300 | |||
| 42301 | #else | ||
| 42302 | |||
| 42303 | /* | ||
| 42304 | ** asm() is needed for hardware timing support. Without asm(), | ||
| 42305 | ** disable the sqlite3Hwtime() routine. | ||
| 42306 | ** | ||
| 42307 | ** sqlite3Hwtime() is only used for some obscure debugging | ||
| 42308 | ** and analysis configurations, not in any deliverable, so this | ||
| 42309 | ** should not be a great loss. | ||
| 42310 | */ | ||
| 42311 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } | ||
| 42312 | |||
| 42313 | #endif | ||
| 42314 | |||
| 42315 | #endif /* !defined(SQLITE_HWTIME_H) */ | ||
| 42316 | |||
| 42317 | /************** End of hwtime.h **********************************************/ | ||
| 42318 | /************** Continuing where we left off in os_common.h ******************/ | ||
| 42319 | |||
| 42320 | static sqlite_uint64 g_start; | ||
| 42321 | static sqlite_uint64 g_elapsed; | ||
| 42322 | #define TIMER_START g_start=sqlite3Hwtime() | ||
| 42323 | #define TIMER_END g_elapsed=sqlite3Hwtime()-g_start | ||
| 42324 | #define TIMER_ELAPSED g_elapsed | ||
| 42325 | #else | ||
| 42326 | #define TIMER_START | ||
| 42327 | #define TIMER_END | ||
| 42328 | #define TIMER_ELAPSED ((sqlite_uint64)0) | ||
| 42329 | #endif | ||
| 42330 | |||
| 42331 | /* | ||
| 42332 | ** If we compile with the SQLITE_TEST macro set, then the following block | ||
| 42333 | ** of code will give us the ability to simulate a disk I/O error. This | ||
| 42334 | ** is used for testing the I/O recovery logic. | ||
| 42335 | */ | ||
| 42336 | #if defined(SQLITE_TEST) | ||
| 42337 | SQLITE_API extern int sqlite3_io_error_hit; | ||
| 42338 | SQLITE_API extern int sqlite3_io_error_hardhit; | ||
| 42339 | SQLITE_API extern int sqlite3_io_error_pending; | ||
| 42340 | SQLITE_API extern int sqlite3_io_error_persist; | ||
| 42341 | SQLITE_API extern int sqlite3_io_error_benign; | ||
| 42342 | SQLITE_API extern int sqlite3_diskfull_pending; | ||
| 42343 | SQLITE_API extern int sqlite3_diskfull; | ||
| 42344 | #define SimulateIOErrorBenign(X) sqlite3_io_error_benign=(X) | ||
| 42345 | #define SimulateIOError(CODE) \ | ||
| 42346 | if( (sqlite3_io_error_persist && sqlite3_io_error_hit) \ | ||
| 42347 | || sqlite3_io_error_pending-- == 1 ) \ | ||
| 42348 | { local_ioerr(); CODE; } | ||
| 42349 | static void local_ioerr(){ | ||
| 42350 | IOTRACE(("IOERR\n")); | ||
| 42351 | sqlite3_io_error_hit++; | ||
| 42352 | if( !sqlite3_io_error_benign ) sqlite3_io_error_hardhit++; | ||
| 42353 | } | ||
| 42354 | #define SimulateDiskfullError(CODE) \ | ||
| 42355 | if( sqlite3_diskfull_pending ){ \ | ||
| 42356 | if( sqlite3_diskfull_pending == 1 ){ \ | ||
| 42357 | local_ioerr(); \ | ||
| 42358 | sqlite3_diskfull = 1; \ | ||
| 42359 | sqlite3_io_error_hit = 1; \ | ||
| 42360 | CODE; \ | ||
| 42361 | }else{ \ | ||
| 42362 | sqlite3_diskfull_pending--; \ | ||
| 42363 | } \ | ||
| 42364 | } | ||
| 42365 | #else | ||
| 42366 | #define SimulateIOErrorBenign(X) | ||
| 42367 | #define SimulateIOError(A) | ||
| 42368 | #define SimulateDiskfullError(A) | ||
| 42369 | #endif /* defined(SQLITE_TEST) */ | ||
| 42370 | |||
| 42371 | /* | ||
| 42372 | ** When testing, keep a count of the number of open files. | ||
| 42373 | */ | ||
| 42374 | #if defined(SQLITE_TEST) | ||
| 42375 | SQLITE_API extern int sqlite3_open_file_count; | ||
| 42376 | #define OpenCounter(X) sqlite3_open_file_count+=(X) | ||
| 42377 | #else | ||
| 42378 | #define OpenCounter(X) | ||
| 42379 | #endif /* defined(SQLITE_TEST) */ | ||
| 42380 | |||
| 42381 | #endif /* !defined(_OS_COMMON_H_) */ | ||
| 42382 | |||
| 42383 | /************** End of os_common.h *******************************************/ | ||
| 42384 | /************** Continuing where we left off in os_win.c *********************/ | ||
| 42385 | 42388 | ||
| 42386 | /* | 42389 | /* |
| 42387 | ** Include the header file for the Windows VFS. | 42390 | ** Include the header file for the Windows VFS. |
| @@ -48792,7 +48795,7 @@ static int memdbRead( | |||
| 48792 | */ | 48795 | */ |
| 48793 | static int memdbEnlarge(MemStore *p, sqlite3_int64 newSz){ | 48796 | static int memdbEnlarge(MemStore *p, sqlite3_int64 newSz){ |
| 48794 | unsigned char *pNew; | 48797 | unsigned char *pNew; |
| 48795 | if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){ | 48798 | if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || NEVER(p->nMmap>0) ){ |
| 48796 | return SQLITE_FULL; | 48799 | return SQLITE_FULL; |
| 48797 | } | 48800 | } |
| 48798 | if( newSz>p->szMax ){ | 48801 | if( newSz>p->szMax ){ |
| @@ -48851,8 +48854,9 @@ static int memdbTruncate(sqlite3_file *pFile, sqlite_int64 size){ | |||
| 48851 | MemStore *p = ((MemFile*)pFile)->pStore; | 48854 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48852 | int rc = SQLITE_OK; | 48855 | int rc = SQLITE_OK; |
| 48853 | memdbEnter(p); | 48856 | memdbEnter(p); |
| 48854 | if( NEVER(size>p->sz) ){ | 48857 | if( size>p->sz ){ |
| 48855 | rc = SQLITE_FULL; | 48858 | /* This can only happen with a corrupt wal mode db */ |
| 48859 | rc = SQLITE_CORRUPT; | ||
| 48856 | }else{ | 48860 | }else{ |
| 48857 | p->sz = size; | 48861 | p->sz = size; |
| 48858 | } | 48862 | } |
| @@ -48991,7 +48995,7 @@ static int memdbFetch( | |||
| 48991 | ){ | 48995 | ){ |
| 48992 | MemStore *p = ((MemFile*)pFile)->pStore; | 48996 | MemStore *p = ((MemFile*)pFile)->pStore; |
| 48993 | memdbEnter(p); | 48997 | memdbEnter(p); |
| 48994 | if( iOfst+iAmt>p->sz ){ | 48998 | if( iOfst+iAmt>p->sz || (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)!=0 ){ |
| 48995 | *pp = 0; | 48999 | *pp = 0; |
| 48996 | }else{ | 49000 | }else{ |
| 48997 | p->nMmap++; | 49001 | p->nMmap++; |
| @@ -49025,10 +49029,9 @@ static int memdbOpen( | |||
| 49025 | MemFile *pFile = (MemFile*)pFd; | 49029 | MemFile *pFile = (MemFile*)pFd; |
| 49026 | MemStore *p = 0; | 49030 | MemStore *p = 0; |
| 49027 | int szName; | 49031 | int szName; |
| 49028 | if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){ | 49032 | UNUSED_PARAMETER(pVfs); |
| 49029 | return ORIGVFS(pVfs)->xOpen(ORIGVFS(pVfs), zName, pFd, flags, pOutFlags); | 49033 | |
| 49030 | } | 49034 | memset(pFile, 0, sizeof(*pFile)); |
| 49031 | memset(pFile, 0, sizeof(*p)); | ||
| 49032 | szName = sqlite3Strlen30(zName); | 49035 | szName = sqlite3Strlen30(zName); |
| 49033 | if( szName>1 && zName[0]=='/' ){ | 49036 | if( szName>1 && zName[0]=='/' ){ |
| 49034 | int i; | 49037 | int i; |
| @@ -49087,8 +49090,9 @@ static int memdbOpen( | |||
| 49087 | p->szMax = sqlite3GlobalConfig.mxMemdbSize; | 49090 | p->szMax = sqlite3GlobalConfig.mxMemdbSize; |
| 49088 | } | 49091 | } |
| 49089 | pFile->pStore = p; | 49092 | pFile->pStore = p; |
| 49090 | assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */ | 49093 | if( pOutFlags!=0 ){ |
| 49091 | *pOutFlags = flags | SQLITE_OPEN_MEMORY; | 49094 | *pOutFlags = flags | SQLITE_OPEN_MEMORY; |
| 49095 | } | ||
| 49092 | pFd->pMethods = &memdb_io_methods; | 49096 | pFd->pMethods = &memdb_io_methods; |
| 49093 | memdbLeave(p); | 49097 | memdbLeave(p); |
| 49094 | return SQLITE_OK; | 49098 | return SQLITE_OK; |
| @@ -49329,7 +49333,8 @@ SQLITE_API int sqlite3_deserialize( | |||
| 49329 | sqlite3_mutex_enter(db->mutex); | 49333 | sqlite3_mutex_enter(db->mutex); |
| 49330 | if( zSchema==0 ) zSchema = db->aDb[0].zDbSName; | 49334 | if( zSchema==0 ) zSchema = db->aDb[0].zDbSName; |
| 49331 | iDb = sqlite3FindDbName(db, zSchema); | 49335 | iDb = sqlite3FindDbName(db, zSchema); |
| 49332 | if( iDb<0 ){ | 49336 | testcase( iDb==1 ); |
| 49337 | if( iDb<2 && iDb!=0 ){ | ||
| 49333 | rc = SQLITE_ERROR; | 49338 | rc = SQLITE_ERROR; |
| 49334 | goto end_deserialize; | 49339 | goto end_deserialize; |
| 49335 | } | 49340 | } |
| @@ -49752,7 +49757,7 @@ SQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int sz, int *aOp){ | |||
| 49752 | sqlite3BitvecClear(0, 1, pTmpSpace); | 49757 | sqlite3BitvecClear(0, 1, pTmpSpace); |
| 49753 | 49758 | ||
| 49754 | /* Run the program */ | 49759 | /* Run the program */ |
| 49755 | pc = 0; | 49760 | pc = i = 0; |
| 49756 | while( (op = aOp[pc])!=0 ){ | 49761 | while( (op = aOp[pc])!=0 ){ |
| 49757 | switch( op ){ | 49762 | switch( op ){ |
| 49758 | case 1: | 49763 | case 1: |
| @@ -50056,11 +50061,14 @@ static int numberOfCachePages(PCache *p){ | |||
| 50056 | ** suggested cache size is set to N. */ | 50061 | ** suggested cache size is set to N. */ |
| 50057 | return p->szCache; | 50062 | return p->szCache; |
| 50058 | }else{ | 50063 | }else{ |
| 50064 | i64 n; | ||
| 50059 | /* IMPLEMANTATION-OF: R-59858-46238 If the argument N is negative, then the | 50065 | /* IMPLEMANTATION-OF: R-59858-46238 If the argument N is negative, then the |
| 50060 | ** number of cache pages is adjusted to be a number of pages that would | 50066 | ** number of cache pages is adjusted to be a number of pages that would |
| 50061 | ** use approximately abs(N*1024) bytes of memory based on the current | 50067 | ** use approximately abs(N*1024) bytes of memory based on the current |
| 50062 | ** page size. */ | 50068 | ** page size. */ |
| 50063 | return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra)); | 50069 | n = ((-1024*(i64)p->szCache)/(p->szPage+p->szExtra)); |
| 50070 | if( n>1000000000 ) n = 1000000000; | ||
| 50071 | return (int)n; | ||
| 50064 | } | 50072 | } |
| 50065 | } | 50073 | } |
| 50066 | 50074 | ||
| @@ -51515,12 +51523,18 @@ static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){ | |||
| 51515 | */ | 51523 | */ |
| 51516 | static void pcache1Cachesize(sqlite3_pcache *p, int nMax){ | 51524 | static void pcache1Cachesize(sqlite3_pcache *p, int nMax){ |
| 51517 | PCache1 *pCache = (PCache1 *)p; | 51525 | PCache1 *pCache = (PCache1 *)p; |
| 51526 | u32 n; | ||
| 51527 | assert( nMax>=0 ); | ||
| 51518 | if( pCache->bPurgeable ){ | 51528 | if( pCache->bPurgeable ){ |
| 51519 | PGroup *pGroup = pCache->pGroup; | 51529 | PGroup *pGroup = pCache->pGroup; |
| 51520 | pcache1EnterMutex(pGroup); | 51530 | pcache1EnterMutex(pGroup); |
| 51521 | pGroup->nMaxPage += (nMax - pCache->nMax); | 51531 | n = (u32)nMax; |
| 51532 | if( n > 0x7fff0000 - pGroup->nMaxPage + pCache->nMax ){ | ||
| 51533 | n = 0x7fff0000 - pGroup->nMaxPage + pCache->nMax; | ||
| 51534 | } | ||
| 51535 | pGroup->nMaxPage += (n - pCache->nMax); | ||
| 51522 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; | 51536 | pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage; |
| 51523 | pCache->nMax = nMax; | 51537 | pCache->nMax = n; |
| 51524 | pCache->n90pct = pCache->nMax*9/10; | 51538 | pCache->n90pct = pCache->nMax*9/10; |
| 51525 | pcache1EnforceMaxPage(pCache); | 51539 | pcache1EnforceMaxPage(pCache); |
| 51526 | pcache1LeaveMutex(pGroup); | 51540 | pcache1LeaveMutex(pGroup); |
| @@ -51536,7 +51550,7 @@ static void pcache1Shrink(sqlite3_pcache *p){ | |||
| 51536 | PCache1 *pCache = (PCache1*)p; | 51550 | PCache1 *pCache = (PCache1*)p; |
| 51537 | if( pCache->bPurgeable ){ | 51551 | if( pCache->bPurgeable ){ |
| 51538 | PGroup *pGroup = pCache->pGroup; | 51552 | PGroup *pGroup = pCache->pGroup; |
| 51539 | int savedMaxPage; | 51553 | unsigned int savedMaxPage; |
| 51540 | pcache1EnterMutex(pGroup); | 51554 | pcache1EnterMutex(pGroup); |
| 51541 | savedMaxPage = pGroup->nMaxPage; | 51555 | savedMaxPage = pGroup->nMaxPage; |
| 51542 | pGroup->nMaxPage = 0; | 51556 | pGroup->nMaxPage = 0; |
| @@ -53273,6 +53287,7 @@ struct Pager { | |||
| 53273 | u8 noLock; /* Do not lock (except in WAL mode) */ | 53287 | u8 noLock; /* Do not lock (except in WAL mode) */ |
| 53274 | u8 readOnly; /* True for a read-only database */ | 53288 | u8 readOnly; /* True for a read-only database */ |
| 53275 | u8 memDb; /* True to inhibit all file I/O */ | 53289 | u8 memDb; /* True to inhibit all file I/O */ |
| 53290 | u8 memVfs; /* VFS-implemented memory database */ | ||
| 53276 | 53291 | ||
| 53277 | /************************************************************************** | 53292 | /************************************************************************** |
| 53278 | ** The following block contains those class members that change during | 53293 | ** The following block contains those class members that change during |
| @@ -53322,8 +53337,8 @@ struct Pager { | |||
| 53322 | i16 nReserve; /* Number of unused bytes at end of each page */ | 53337 | i16 nReserve; /* Number of unused bytes at end of each page */ |
| 53323 | u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */ | 53338 | u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */ |
| 53324 | u32 sectorSize; /* Assumed sector size during rollback */ | 53339 | u32 sectorSize; /* Assumed sector size during rollback */ |
| 53325 | int pageSize; /* Number of bytes in a page */ | ||
| 53326 | Pgno mxPgno; /* Maximum allowed size of the database */ | 53340 | Pgno mxPgno; /* Maximum allowed size of the database */ |
| 53341 | i64 pageSize; /* Number of bytes in a page */ | ||
| 53327 | i64 journalSizeLimit; /* Size limit for persistent journal files */ | 53342 | i64 journalSizeLimit; /* Size limit for persistent journal files */ |
| 53328 | char *zFilename; /* Name of the database file */ | 53343 | char *zFilename; /* Name of the database file */ |
| 53329 | char *zJournal; /* Name of the journal file */ | 53344 | char *zJournal; /* Name of the journal file */ |
| @@ -55667,6 +55682,7 @@ static int readDbPage(PgHdr *pPg){ | |||
| 55667 | */ | 55682 | */ |
| 55668 | static void pager_write_changecounter(PgHdr *pPg){ | 55683 | static void pager_write_changecounter(PgHdr *pPg){ |
| 55669 | u32 change_counter; | 55684 | u32 change_counter; |
| 55685 | if( NEVER(pPg==0) ) return; | ||
| 55670 | 55686 | ||
| 55671 | /* Increment the value just read and write it back to byte 24. */ | 55687 | /* Increment the value just read and write it back to byte 24. */ |
| 55672 | change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1; | 55688 | change_counter = sqlite3Get4byte((u8*)pPg->pPager->dbFileVers)+1; |
| @@ -57501,6 +57517,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen( | |||
| 57501 | pPager->zWal = 0; | 57517 | pPager->zWal = 0; |
| 57502 | } | 57518 | } |
| 57503 | #endif | 57519 | #endif |
| 57520 | (void)pPtr; /* Suppress warning about unused pPtr value */ | ||
| 57504 | 57521 | ||
| 57505 | if( nPathname ) sqlite3DbFree(0, zPathname); | 57522 | if( nPathname ) sqlite3DbFree(0, zPathname); |
| 57506 | pPager->pVfs = pVfs; | 57523 | pPager->pVfs = pVfs; |
| @@ -57513,7 +57530,7 @@ SQLITE_PRIVATE int sqlite3PagerOpen( | |||
| 57513 | rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout); | 57530 | rc = sqlite3OsOpen(pVfs, pPager->zFilename, pPager->fd, vfsFlags, &fout); |
| 57514 | assert( !memDb ); | 57531 | assert( !memDb ); |
| 57515 | #ifndef SQLITE_OMIT_DESERIALIZE | 57532 | #ifndef SQLITE_OMIT_DESERIALIZE |
| 57516 | memJM = (fout&SQLITE_OPEN_MEMORY)!=0; | 57533 | pPager->memVfs = memJM = (fout&SQLITE_OPEN_MEMORY)!=0; |
| 57517 | #endif | 57534 | #endif |
| 57518 | readOnly = (fout&SQLITE_OPEN_READONLY)!=0; | 57535 | readOnly = (fout&SQLITE_OPEN_READONLY)!=0; |
| 57519 | 57536 | ||
| @@ -59380,8 +59397,8 @@ SQLITE_PRIVATE int sqlite3PagerRefcount(Pager *pPager){ | |||
| 59380 | ** used by the pager and its associated cache. | 59397 | ** used by the pager and its associated cache. |
| 59381 | */ | 59398 | */ |
| 59382 | SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager *pPager){ | 59399 | SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager *pPager){ |
| 59383 | int perPageSize = pPager->pageSize + pPager->nExtra + sizeof(PgHdr) | 59400 | int perPageSize = pPager->pageSize + pPager->nExtra |
| 59384 | + 5*sizeof(void*); | 59401 | + (int)(sizeof(PgHdr) + 5*sizeof(void*)); |
| 59385 | return perPageSize*sqlite3PcachePagecount(pPager->pPCache) | 59402 | return perPageSize*sqlite3PcachePagecount(pPager->pPCache) |
| 59386 | + sqlite3MallocSize(pPager) | 59403 | + sqlite3MallocSize(pPager) |
| 59387 | + pPager->pageSize; | 59404 | + pPager->pageSize; |
| @@ -59450,7 +59467,7 @@ SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, i | |||
| 59450 | ** Return true if this is an in-memory or temp-file backed pager. | 59467 | ** Return true if this is an in-memory or temp-file backed pager. |
| 59451 | */ | 59468 | */ |
| 59452 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){ | 59469 | SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager *pPager){ |
| 59453 | return pPager->tempFile; | 59470 | return pPager->tempFile || pPager->memVfs; |
| 59454 | } | 59471 | } |
| 59455 | 59472 | ||
| 59456 | /* | 59473 | /* |
| @@ -59575,14 +59592,14 @@ SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){ | |||
| 59575 | } | 59592 | } |
| 59576 | pPager->nSavepoint = nNew; | 59593 | pPager->nSavepoint = nNew; |
| 59577 | 59594 | ||
| 59578 | /* If this is a release of the outermost savepoint, truncate | 59595 | /* Truncate the sub-journal so that it only includes the parts |
| 59579 | ** the sub-journal to zero bytes in size. */ | 59596 | ** that are still in use. */ |
| 59580 | if( op==SAVEPOINT_RELEASE ){ | 59597 | if( op==SAVEPOINT_RELEASE ){ |
| 59581 | PagerSavepoint *pRel = &pPager->aSavepoint[nNew]; | 59598 | PagerSavepoint *pRel = &pPager->aSavepoint[nNew]; |
| 59582 | if( pRel->bTruncateOnRelease && isOpen(pPager->sjfd) ){ | 59599 | if( pRel->bTruncateOnRelease && isOpen(pPager->sjfd) ){ |
| 59583 | /* Only truncate if it is an in-memory sub-journal. */ | 59600 | /* Only truncate if it is an in-memory sub-journal. */ |
| 59584 | if( sqlite3JournalIsInMemory(pPager->sjfd) ){ | 59601 | if( sqlite3JournalIsInMemory(pPager->sjfd) ){ |
| 59585 | i64 sz = (pPager->pageSize+4)*pRel->iSubRec; | 59602 | i64 sz = (pPager->pageSize+4)*(i64)pRel->iSubRec; |
| 59586 | rc = sqlite3OsTruncate(pPager->sjfd, sz); | 59603 | rc = sqlite3OsTruncate(pPager->sjfd, sz); |
| 59587 | assert( rc==SQLITE_OK ); | 59604 | assert( rc==SQLITE_OK ); |
| 59588 | } | 59605 | } |
| @@ -59770,7 +59787,7 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i | |||
| 59770 | pPgOld = sqlite3PagerLookup(pPager, pgno); | 59787 | pPgOld = sqlite3PagerLookup(pPager, pgno); |
| 59771 | assert( !pPgOld || pPgOld->nRef==1 || CORRUPT_DB ); | 59788 | assert( !pPgOld || pPgOld->nRef==1 || CORRUPT_DB ); |
| 59772 | if( pPgOld ){ | 59789 | if( pPgOld ){ |
| 59773 | if( pPgOld->nRef>1 ){ | 59790 | if( NEVER(pPgOld->nRef>1) ){ |
| 59774 | sqlite3PagerUnrefNotNull(pPgOld); | 59791 | sqlite3PagerUnrefNotNull(pPgOld); |
| 59775 | return SQLITE_CORRUPT_BKPT; | 59792 | return SQLITE_CORRUPT_BKPT; |
| 59776 | } | 59793 | } |
| @@ -60516,7 +60533,10 @@ SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){ | |||
| 60516 | ** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and | 60533 | ** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and |
| 60517 | ** HASHTABLE_NPAGE are selected so that together the wal-index header and | 60534 | ** HASHTABLE_NPAGE are selected so that together the wal-index header and |
| 60518 | ** first index block are the same size as all other index blocks in the | 60535 | ** first index block are the same size as all other index blocks in the |
| 60519 | ** wal-index. | 60536 | ** wal-index. The values are: |
| 60537 | ** | ||
| 60538 | ** HASHTABLE_NPAGE 4096 | ||
| 60539 | ** HASHTABLE_NPAGE_ONE 4062 | ||
| 60520 | ** | 60540 | ** |
| 60521 | ** Each index block contains two sections, a page-mapping that contains the | 60541 | ** Each index block contains two sections, a page-mapping that contains the |
| 60522 | ** database page number associated with each wal frame, and a hash-table | 60542 | ** database page number associated with each wal frame, and a hash-table |
| @@ -60752,6 +60772,70 @@ struct WalCkptInfo { | |||
| 60752 | }; | 60772 | }; |
| 60753 | #define READMARK_NOT_USED 0xffffffff | 60773 | #define READMARK_NOT_USED 0xffffffff |
| 60754 | 60774 | ||
| 60775 | /* | ||
| 60776 | ** This is a schematic view of the complete 136-byte header of the | ||
| 60777 | ** wal-index file (also known as the -shm file): | ||
| 60778 | ** | ||
| 60779 | ** +-----------------------------+ | ||
| 60780 | ** 0: | iVersion | \ | ||
| 60781 | ** +-----------------------------+ | | ||
| 60782 | ** 4: | (unused padding) | | | ||
| 60783 | ** +-----------------------------+ | | ||
| 60784 | ** 8: | iChange | | | ||
| 60785 | ** +-------+-------+-------------+ | | ||
| 60786 | ** 12: | bInit | bBig | szPage | | | ||
| 60787 | ** +-------+-------+-------------+ | | ||
| 60788 | ** 16: | mxFrame | | First copy of the | ||
| 60789 | ** +-----------------------------+ | WalIndexHdr object | ||
| 60790 | ** 20: | nPage | | | ||
| 60791 | ** +-----------------------------+ | | ||
| 60792 | ** 24: | aFrameCksum | | | ||
| 60793 | ** | | | | ||
| 60794 | ** +-----------------------------+ | | ||
| 60795 | ** 32: | aSalt | | | ||
| 60796 | ** | | | | ||
| 60797 | ** +-----------------------------+ | | ||
| 60798 | ** 40: | aCksum | | | ||
| 60799 | ** | | / | ||
| 60800 | ** +-----------------------------+ | ||
| 60801 | ** 48: | iVersion | \ | ||
| 60802 | ** +-----------------------------+ | | ||
| 60803 | ** 52: | (unused padding) | | | ||
| 60804 | ** +-----------------------------+ | | ||
| 60805 | ** 56: | iChange | | | ||
| 60806 | ** +-------+-------+-------------+ | | ||
| 60807 | ** 60: | bInit | bBig | szPage | | | ||
| 60808 | ** +-------+-------+-------------+ | Second copy of the | ||
| 60809 | ** 64: | mxFrame | | WalIndexHdr | ||
| 60810 | ** +-----------------------------+ | | ||
| 60811 | ** 68: | nPage | | | ||
| 60812 | ** +-----------------------------+ | | ||
| 60813 | ** 72: | aFrameCksum | | | ||
| 60814 | ** | | | | ||
| 60815 | ** +-----------------------------+ | | ||
| 60816 | ** 80: | aSalt | | | ||
| 60817 | ** | | | | ||
| 60818 | ** +-----------------------------+ | | ||
| 60819 | ** 88: | aCksum | | | ||
| 60820 | ** | | / | ||
| 60821 | ** +-----------------------------+ | ||
| 60822 | ** 96: | nBackfill | | ||
| 60823 | ** +-----------------------------+ | ||
| 60824 | ** 100: | 5 read marks | | ||
| 60825 | ** | | | ||
| 60826 | ** | | | ||
| 60827 | ** | | | ||
| 60828 | ** | | | ||
| 60829 | ** +-------+-------+------+------+ | ||
| 60830 | ** 120: | Write | Ckpt | Rcvr | Rd0 | \ | ||
| 60831 | ** +-------+-------+------+------+ ) 8 lock bytes | ||
| 60832 | ** | Read1 | Read2 | Rd3 | Rd4 | / | ||
| 60833 | ** +-------+-------+------+------+ | ||
| 60834 | ** 128: | nBackfillAttempted | | ||
| 60835 | ** +-----------------------------+ | ||
| 60836 | ** 132: | (unused padding) | | ||
| 60837 | ** +-----------------------------+ | ||
| 60838 | */ | ||
| 60755 | 60839 | ||
| 60756 | /* A block of WALINDEX_LOCK_RESERVED bytes beginning at | 60840 | /* A block of WALINDEX_LOCK_RESERVED bytes beginning at |
| 60757 | ** WALINDEX_LOCK_OFFSET is reserved for locks. Since some systems | 60841 | ** WALINDEX_LOCK_OFFSET is reserved for locks. Since some systems |
| @@ -60908,9 +60992,13 @@ struct WalIterator { | |||
| 60908 | ** so. It is safe to enlarge the wal-index if pWal->writeLock is true | 60992 | ** so. It is safe to enlarge the wal-index if pWal->writeLock is true |
| 60909 | ** or pWal->exclusiveMode==WAL_HEAPMEMORY_MODE. | 60993 | ** or pWal->exclusiveMode==WAL_HEAPMEMORY_MODE. |
| 60910 | ** | 60994 | ** |
| 60911 | ** If this call is successful, *ppPage is set to point to the wal-index | 60995 | ** Three possible result scenarios: |
| 60912 | ** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs, | 60996 | ** |
| 60913 | ** then an SQLite error code is returned and *ppPage is set to 0. | 60997 | ** (1) rc==SQLITE_OK and *ppPage==Requested-Wal-Index-Page |
| 60998 | ** (2) rc>=SQLITE_ERROR and *ppPage==NULL | ||
| 60999 | ** (3) rc==SQLITE_OK and *ppPage==NULL // only if iPage==0 | ||
| 61000 | ** | ||
| 61001 | ** Scenario (3) can only occur when pWal->writeLock is false and iPage==0 | ||
| 60914 | */ | 61002 | */ |
| 60915 | static SQLITE_NOINLINE int walIndexPageRealloc( | 61003 | static SQLITE_NOINLINE int walIndexPageRealloc( |
| 60916 | Wal *pWal, /* The WAL context */ | 61004 | Wal *pWal, /* The WAL context */ |
| @@ -60943,7 +61031,9 @@ static SQLITE_NOINLINE int walIndexPageRealloc( | |||
| 60943 | rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ, | 61031 | rc = sqlite3OsShmMap(pWal->pDbFd, iPage, WALINDEX_PGSZ, |
| 60944 | pWal->writeLock, (void volatile **)&pWal->apWiData[iPage] | 61032 | pWal->writeLock, (void volatile **)&pWal->apWiData[iPage] |
| 60945 | ); | 61033 | ); |
| 60946 | assert( pWal->apWiData[iPage]!=0 || rc!=SQLITE_OK || pWal->writeLock==0 ); | 61034 | assert( pWal->apWiData[iPage]!=0 |
| 61035 | || rc!=SQLITE_OK | ||
| 61036 | || (pWal->writeLock==0 && iPage==0) ); | ||
| 60947 | testcase( pWal->apWiData[iPage]==0 && rc==SQLITE_OK ); | 61037 | testcase( pWal->apWiData[iPage]==0 && rc==SQLITE_OK ); |
| 60948 | if( rc==SQLITE_OK ){ | 61038 | if( rc==SQLITE_OK ){ |
| 60949 | if( iPage>0 && sqlite3FaultSim(600) ) rc = SQLITE_NOMEM; | 61039 | if( iPage>0 && sqlite3FaultSim(600) ) rc = SQLITE_NOMEM; |
| @@ -61282,8 +61372,8 @@ struct WalHashLoc { | |||
| 61282 | ** slot in the hash table is set to N, it refers to frame number | 61372 | ** slot in the hash table is set to N, it refers to frame number |
| 61283 | ** (pLoc->iZero+N) in the log. | 61373 | ** (pLoc->iZero+N) in the log. |
| 61284 | ** | 61374 | ** |
| 61285 | ** Finally, set pLoc->aPgno so that pLoc->aPgno[1] is the page number of the | 61375 | ** Finally, set pLoc->aPgno so that pLoc->aPgno[0] is the page number of the |
| 61286 | ** first frame indexed by the hash table, frame (pLoc->iZero+1). | 61376 | ** first frame indexed by the hash table, frame (pLoc->iZero). |
| 61287 | */ | 61377 | */ |
| 61288 | static int walHashGet( | 61378 | static int walHashGet( |
| 61289 | Wal *pWal, /* WAL handle */ | 61379 | Wal *pWal, /* WAL handle */ |
| @@ -61295,7 +61385,7 @@ static int walHashGet( | |||
| 61295 | rc = walIndexPage(pWal, iHash, &pLoc->aPgno); | 61385 | rc = walIndexPage(pWal, iHash, &pLoc->aPgno); |
| 61296 | assert( rc==SQLITE_OK || iHash>0 ); | 61386 | assert( rc==SQLITE_OK || iHash>0 ); |
| 61297 | 61387 | ||
| 61298 | if( rc==SQLITE_OK ){ | 61388 | if( pLoc->aPgno ){ |
| 61299 | pLoc->aHash = (volatile ht_slot *)&pLoc->aPgno[HASHTABLE_NPAGE]; | 61389 | pLoc->aHash = (volatile ht_slot *)&pLoc->aPgno[HASHTABLE_NPAGE]; |
| 61300 | if( iHash==0 ){ | 61390 | if( iHash==0 ){ |
| 61301 | pLoc->aPgno = &pLoc->aPgno[WALINDEX_HDR_SIZE/sizeof(u32)]; | 61391 | pLoc->aPgno = &pLoc->aPgno[WALINDEX_HDR_SIZE/sizeof(u32)]; |
| @@ -61303,7 +61393,8 @@ static int walHashGet( | |||
| 61303 | }else{ | 61393 | }else{ |
| 61304 | pLoc->iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE; | 61394 | pLoc->iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE; |
| 61305 | } | 61395 | } |
| 61306 | pLoc->aPgno = &pLoc->aPgno[-1]; | 61396 | }else if( NEVER(rc==SQLITE_OK) ){ |
| 61397 | rc = SQLITE_ERROR; | ||
| 61307 | } | 61398 | } |
| 61308 | return rc; | 61399 | return rc; |
| 61309 | } | 61400 | } |
| @@ -61385,8 +61476,9 @@ static void walCleanupHash(Wal *pWal){ | |||
| 61385 | /* Zero the entries in the aPgno array that correspond to frames with | 61476 | /* Zero the entries in the aPgno array that correspond to frames with |
| 61386 | ** frame numbers greater than pWal->hdr.mxFrame. | 61477 | ** frame numbers greater than pWal->hdr.mxFrame. |
| 61387 | */ | 61478 | */ |
| 61388 | nByte = (int)((char *)sLoc.aHash - (char *)&sLoc.aPgno[iLimit+1]); | 61479 | nByte = (int)((char *)sLoc.aHash - (char *)&sLoc.aPgno[iLimit]); |
| 61389 | memset((void *)&sLoc.aPgno[iLimit+1], 0, nByte); | 61480 | assert( nByte>=0 ); |
| 61481 | memset((void *)&sLoc.aPgno[iLimit], 0, nByte); | ||
| 61390 | 61482 | ||
| 61391 | #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT | 61483 | #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT |
| 61392 | /* Verify that the every entry in the mapping region is still reachable | 61484 | /* Verify that the every entry in the mapping region is still reachable |
| @@ -61395,11 +61487,11 @@ static void walCleanupHash(Wal *pWal){ | |||
| 61395 | if( iLimit ){ | 61487 | if( iLimit ){ |
| 61396 | int j; /* Loop counter */ | 61488 | int j; /* Loop counter */ |
| 61397 | int iKey; /* Hash key */ | 61489 | int iKey; /* Hash key */ |
| 61398 | for(j=1; j<=iLimit; j++){ | 61490 | for(j=0; j<iLimit; j++){ |
| 61399 | for(iKey=walHash(sLoc.aPgno[j]);sLoc.aHash[iKey];iKey=walNextHash(iKey)){ | 61491 | for(iKey=walHash(sLoc.aPgno[j]);sLoc.aHash[iKey];iKey=walNextHash(iKey)){ |
| 61400 | if( sLoc.aHash[iKey]==j ) break; | 61492 | if( sLoc.aHash[iKey]==j+1 ) break; |
| 61401 | } | 61493 | } |
| 61402 | assert( sLoc.aHash[iKey]==j ); | 61494 | assert( sLoc.aHash[iKey]==j+1 ); |
| 61403 | } | 61495 | } |
| 61404 | } | 61496 | } |
| 61405 | #endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */ | 61497 | #endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */ |
| @@ -61431,9 +61523,9 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){ | |||
| 61431 | ** entire hash table and aPgno[] array before proceeding. | 61523 | ** entire hash table and aPgno[] array before proceeding. |
| 61432 | */ | 61524 | */ |
| 61433 | if( idx==1 ){ | 61525 | if( idx==1 ){ |
| 61434 | int nByte = (int)((u8 *)&sLoc.aHash[HASHTABLE_NSLOT] | 61526 | int nByte = (int)((u8*)&sLoc.aHash[HASHTABLE_NSLOT] - (u8*)sLoc.aPgno); |
| 61435 | - (u8 *)&sLoc.aPgno[1]); | 61527 | assert( nByte>=0 ); |
| 61436 | memset((void*)&sLoc.aPgno[1], 0, nByte); | 61528 | memset((void*)sLoc.aPgno, 0, nByte); |
| 61437 | } | 61529 | } |
| 61438 | 61530 | ||
| 61439 | /* If the entry in aPgno[] is already set, then the previous writer | 61531 | /* If the entry in aPgno[] is already set, then the previous writer |
| @@ -61442,9 +61534,9 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){ | |||
| 61442 | ** Remove the remnants of that writers uncommitted transaction from | 61534 | ** Remove the remnants of that writers uncommitted transaction from |
| 61443 | ** the hash-table before writing any new entries. | 61535 | ** the hash-table before writing any new entries. |
| 61444 | */ | 61536 | */ |
| 61445 | if( sLoc.aPgno[idx] ){ | 61537 | if( sLoc.aPgno[idx-1] ){ |
| 61446 | walCleanupHash(pWal); | 61538 | walCleanupHash(pWal); |
| 61447 | assert( !sLoc.aPgno[idx] ); | 61539 | assert( !sLoc.aPgno[idx-1] ); |
| 61448 | } | 61540 | } |
| 61449 | 61541 | ||
| 61450 | /* Write the aPgno[] array entry and the hash-table slot. */ | 61542 | /* Write the aPgno[] array entry and the hash-table slot. */ |
| @@ -61452,7 +61544,7 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){ | |||
| 61452 | for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){ | 61544 | for(iKey=walHash(iPage); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){ |
| 61453 | if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT; | 61545 | if( (nCollide--)==0 ) return SQLITE_CORRUPT_BKPT; |
| 61454 | } | 61546 | } |
| 61455 | sLoc.aPgno[idx] = iPage; | 61547 | sLoc.aPgno[idx-1] = iPage; |
| 61456 | AtomicStore(&sLoc.aHash[iKey], (ht_slot)idx); | 61548 | AtomicStore(&sLoc.aHash[iKey], (ht_slot)idx); |
| 61457 | 61549 | ||
| 61458 | #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT | 61550 | #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT |
| @@ -61473,19 +61565,18 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){ | |||
| 61473 | */ | 61565 | */ |
| 61474 | if( (idx&0x3ff)==0 ){ | 61566 | if( (idx&0x3ff)==0 ){ |
| 61475 | int i; /* Loop counter */ | 61567 | int i; /* Loop counter */ |
| 61476 | for(i=1; i<=idx; i++){ | 61568 | for(i=0; i<idx; i++){ |
| 61477 | for(iKey=walHash(sLoc.aPgno[i]); | 61569 | for(iKey=walHash(sLoc.aPgno[i]); |
| 61478 | sLoc.aHash[iKey]; | 61570 | sLoc.aHash[iKey]; |
| 61479 | iKey=walNextHash(iKey)){ | 61571 | iKey=walNextHash(iKey)){ |
| 61480 | if( sLoc.aHash[iKey]==i ) break; | 61572 | if( sLoc.aHash[iKey]==i+1 ) break; |
| 61481 | } | 61573 | } |
| 61482 | assert( sLoc.aHash[iKey]==i ); | 61574 | assert( sLoc.aHash[iKey]==i+1 ); |
| 61483 | } | 61575 | } |
| 61484 | } | 61576 | } |
| 61485 | #endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */ | 61577 | #endif /* SQLITE_ENABLE_EXPENSIVE_ASSERT */ |
| 61486 | } | 61578 | } |
| 61487 | 61579 | ||
| 61488 | |||
| 61489 | return rc; | 61580 | return rc; |
| 61490 | } | 61581 | } |
| 61491 | 61582 | ||
| @@ -61606,7 +61697,8 @@ static int walIndexRecover(Wal *pWal){ | |||
| 61606 | u32 iFirst = 1 + (iPg==0?0:HASHTABLE_NPAGE_ONE+(iPg-1)*HASHTABLE_NPAGE); | 61697 | u32 iFirst = 1 + (iPg==0?0:HASHTABLE_NPAGE_ONE+(iPg-1)*HASHTABLE_NPAGE); |
| 61607 | u32 nHdr, nHdr32; | 61698 | u32 nHdr, nHdr32; |
| 61608 | rc = walIndexPage(pWal, iPg, (volatile u32**)&aShare); | 61699 | rc = walIndexPage(pWal, iPg, (volatile u32**)&aShare); |
| 61609 | if( rc ) break; | 61700 | assert( aShare!=0 || rc!=SQLITE_OK ); |
| 61701 | if( aShare==0 ) break; | ||
| 61610 | pWal->apWiData[iPg] = aPrivate; | 61702 | pWal->apWiData[iPg] = aPrivate; |
| 61611 | 61703 | ||
| 61612 | for(iFrame=iFirst; iFrame<=iLast; iFrame++){ | 61704 | for(iFrame=iFirst; iFrame<=iLast; iFrame++){ |
| @@ -61765,14 +61857,43 @@ SQLITE_PRIVATE int sqlite3WalOpen( | |||
| 61765 | assert( zWalName && zWalName[0] ); | 61857 | assert( zWalName && zWalName[0] ); |
| 61766 | assert( pDbFd ); | 61858 | assert( pDbFd ); |
| 61767 | 61859 | ||
| 61860 | /* Verify the values of various constants. Any changes to the values | ||
| 61861 | ** of these constants would result in an incompatible on-disk format | ||
| 61862 | ** for the -shm file. Any change that causes one of these asserts to | ||
| 61863 | ** fail is a backward compatibility problem, even if the change otherwise | ||
| 61864 | ** works. | ||
| 61865 | ** | ||
| 61866 | ** This table also serves as a helpful cross-reference when trying to | ||
| 61867 | ** interpret hex dumps of the -shm file. | ||
| 61868 | */ | ||
| 61869 | assert( 48 == sizeof(WalIndexHdr) ); | ||
| 61870 | assert( 40 == sizeof(WalCkptInfo) ); | ||
| 61871 | assert( 120 == WALINDEX_LOCK_OFFSET ); | ||
| 61872 | assert( 136 == WALINDEX_HDR_SIZE ); | ||
| 61873 | assert( 4096 == HASHTABLE_NPAGE ); | ||
| 61874 | assert( 4062 == HASHTABLE_NPAGE_ONE ); | ||
| 61875 | assert( 8192 == HASHTABLE_NSLOT ); | ||
| 61876 | assert( 383 == HASHTABLE_HASH_1 ); | ||
| 61877 | assert( 32768 == WALINDEX_PGSZ ); | ||
| 61878 | assert( 8 == SQLITE_SHM_NLOCK ); | ||
| 61879 | assert( 5 == WAL_NREADER ); | ||
| 61880 | assert( 24 == WAL_FRAME_HDRSIZE ); | ||
| 61881 | assert( 32 == WAL_HDRSIZE ); | ||
| 61882 | assert( 120 == WALINDEX_LOCK_OFFSET + WAL_WRITE_LOCK ); | ||
| 61883 | assert( 121 == WALINDEX_LOCK_OFFSET + WAL_CKPT_LOCK ); | ||
| 61884 | assert( 122 == WALINDEX_LOCK_OFFSET + WAL_RECOVER_LOCK ); | ||
| 61885 | assert( 123 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(0) ); | ||
| 61886 | assert( 124 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(1) ); | ||
| 61887 | assert( 125 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(2) ); | ||
| 61888 | assert( 126 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(3) ); | ||
| 61889 | assert( 127 == WALINDEX_LOCK_OFFSET + WAL_READ_LOCK(4) ); | ||
| 61890 | |||
| 61768 | /* In the amalgamation, the os_unix.c and os_win.c source files come before | 61891 | /* In the amalgamation, the os_unix.c and os_win.c source files come before |
| 61769 | ** this source file. Verify that the #defines of the locking byte offsets | 61892 | ** this source file. Verify that the #defines of the locking byte offsets |
| 61770 | ** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value. | 61893 | ** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value. |
| 61771 | ** For that matter, if the lock offset ever changes from its initial design | 61894 | ** For that matter, if the lock offset ever changes from its initial design |
| 61772 | ** value of 120, we need to know that so there is an assert() to check it. | 61895 | ** value of 120, we need to know that so there is an assert() to check it. |
| 61773 | */ | 61896 | */ |
| 61774 | assert( 120==WALINDEX_LOCK_OFFSET ); | ||
| 61775 | assert( 136==WALINDEX_HDR_SIZE ); | ||
| 61776 | #ifdef WIN_SHM_BASE | 61897 | #ifdef WIN_SHM_BASE |
| 61777 | assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET ); | 61898 | assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET ); |
| 61778 | #endif | 61899 | #endif |
| @@ -62074,7 +62195,6 @@ static int walIteratorInit(Wal *pWal, u32 nBackfill, WalIterator **pp){ | |||
| 62074 | int nEntry; /* Number of entries in this segment */ | 62195 | int nEntry; /* Number of entries in this segment */ |
| 62075 | ht_slot *aIndex; /* Sorted index for this segment */ | 62196 | ht_slot *aIndex; /* Sorted index for this segment */ |
| 62076 | 62197 | ||
| 62077 | sLoc.aPgno++; | ||
| 62078 | if( (i+1)==nSegment ){ | 62198 | if( (i+1)==nSegment ){ |
| 62079 | nEntry = (int)(iLast - sLoc.iZero); | 62199 | nEntry = (int)(iLast - sLoc.iZero); |
| 62080 | }else{ | 62200 | }else{ |
| @@ -63213,7 +63333,8 @@ SQLITE_PRIVATE int sqlite3WalSnapshotRecover(Wal *pWal){ | |||
| 63213 | 63333 | ||
| 63214 | rc = walHashGet(pWal, walFramePage(i), &sLoc); | 63334 | rc = walHashGet(pWal, walFramePage(i), &sLoc); |
| 63215 | if( rc!=SQLITE_OK ) break; | 63335 | if( rc!=SQLITE_OK ) break; |
| 63216 | pgno = sLoc.aPgno[i-sLoc.iZero]; | 63336 | assert( i - sLoc.iZero - 1 >=0 ); |
| 63337 | pgno = sLoc.aPgno[i-sLoc.iZero-1]; | ||
| 63217 | iDbOff = (i64)(pgno-1) * szPage; | 63338 | iDbOff = (i64)(pgno-1) * szPage; |
| 63218 | 63339 | ||
| 63219 | if( iDbOff+szPage<=szDb ){ | 63340 | if( iDbOff+szPage<=szDb ){ |
| @@ -63446,7 +63567,7 @@ SQLITE_PRIVATE int sqlite3WalFindFrame( | |||
| 63446 | iKey = walHash(pgno); | 63567 | iKey = walHash(pgno); |
| 63447 | while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){ | 63568 | while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){ |
| 63448 | u32 iFrame = iH + sLoc.iZero; | 63569 | u32 iFrame = iH + sLoc.iZero; |
| 63449 | if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH]==pgno ){ | 63570 | if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH-1]==pgno ){ |
| 63450 | assert( iFrame>iRead || CORRUPT_DB ); | 63571 | assert( iFrame>iRead || CORRUPT_DB ); |
| 63451 | iRead = iFrame; | 63572 | iRead = iFrame; |
| 63452 | } | 63573 | } |
| @@ -64698,7 +64819,6 @@ typedef struct CellInfo CellInfo; | |||
| 64698 | */ | 64819 | */ |
| 64699 | struct MemPage { | 64820 | struct MemPage { |
| 64700 | u8 isInit; /* True if previously initialized. MUST BE FIRST! */ | 64821 | u8 isInit; /* True if previously initialized. MUST BE FIRST! */ |
| 64701 | u8 bBusy; /* Prevent endless loops on corrupt database files */ | ||
| 64702 | u8 intKey; /* True if table b-trees. False for index b-trees */ | 64822 | u8 intKey; /* True if table b-trees. False for index b-trees */ |
| 64703 | u8 intKeyLeaf; /* True if the leaf of an intKey table */ | 64823 | u8 intKeyLeaf; /* True if the leaf of an intKey table */ |
| 64704 | Pgno pgno; /* Page number for this page */ | 64824 | Pgno pgno; /* Page number for this page */ |
| @@ -66279,15 +66399,13 @@ static int btreeMoveto( | |||
| 66279 | sqlite3VdbeRecordUnpack(pKeyInfo, (int)nKey, pKey, pIdxKey); | 66399 | sqlite3VdbeRecordUnpack(pKeyInfo, (int)nKey, pKey, pIdxKey); |
| 66280 | if( pIdxKey->nField==0 || pIdxKey->nField>pKeyInfo->nAllField ){ | 66400 | if( pIdxKey->nField==0 || pIdxKey->nField>pKeyInfo->nAllField ){ |
| 66281 | rc = SQLITE_CORRUPT_BKPT; | 66401 | rc = SQLITE_CORRUPT_BKPT; |
| 66282 | goto moveto_done; | 66402 | }else{ |
| 66403 | rc = sqlite3BtreeIndexMoveto(pCur, pIdxKey, pRes); | ||
| 66283 | } | 66404 | } |
| 66405 | sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey); | ||
| 66284 | }else{ | 66406 | }else{ |
| 66285 | pIdxKey = 0; | 66407 | pIdxKey = 0; |
| 66286 | } | 66408 | rc = sqlite3BtreeTableMoveto(pCur, nKey, bias, pRes); |
| 66287 | rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes); | ||
| 66288 | moveto_done: | ||
| 66289 | if( pIdxKey ){ | ||
| 66290 | sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey); | ||
| 66291 | } | 66409 | } |
| 66292 | return rc; | 66410 | return rc; |
| 66293 | } | 66411 | } |
| @@ -66942,7 +67060,7 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){ | |||
| 66942 | if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); | 67060 | if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage); |
| 66943 | memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); | 67061 | memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz)); |
| 66944 | sz += sz2; | 67062 | sz += sz2; |
| 66945 | }else if( iFree+sz>usableSize ){ | 67063 | }else if( NEVER(iFree+sz>usableSize) ){ |
| 66946 | return SQLITE_CORRUPT_PAGE(pPage); | 67064 | return SQLITE_CORRUPT_PAGE(pPage); |
| 66947 | } | 67065 | } |
| 66948 | 67066 | ||
| @@ -67136,7 +67254,7 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){ | |||
| 67136 | int g2; | 67254 | int g2; |
| 67137 | assert( pSpace+nByte<=data+pPage->pBt->usableSize ); | 67255 | assert( pSpace+nByte<=data+pPage->pBt->usableSize ); |
| 67138 | *pIdx = g2 = (int)(pSpace-data); | 67256 | *pIdx = g2 = (int)(pSpace-data); |
| 67139 | if( NEVER(g2<=gap) ){ | 67257 | if( g2<=gap ){ |
| 67140 | return SQLITE_CORRUPT_PAGE(pPage); | 67258 | return SQLITE_CORRUPT_PAGE(pPage); |
| 67141 | }else{ | 67259 | }else{ |
| 67142 | return SQLITE_OK; | 67260 | return SQLITE_OK; |
| @@ -68549,7 +68667,6 @@ static int lockBtree(BtShared *pBt){ | |||
| 68549 | MemPage *pPage1; /* Page 1 of the database file */ | 68667 | MemPage *pPage1; /* Page 1 of the database file */ |
| 68550 | u32 nPage; /* Number of pages in the database */ | 68668 | u32 nPage; /* Number of pages in the database */ |
| 68551 | u32 nPageFile = 0; /* Number of pages in the database file */ | 68669 | u32 nPageFile = 0; /* Number of pages in the database file */ |
| 68552 | u32 nPageHeader; /* Number of pages in the database according to hdr */ | ||
| 68553 | 68670 | ||
| 68554 | assert( sqlite3_mutex_held(pBt->mutex) ); | 68671 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 68555 | assert( pBt->pPage1==0 ); | 68672 | assert( pBt->pPage1==0 ); |
| @@ -68561,7 +68678,7 @@ static int lockBtree(BtShared *pBt){ | |||
| 68561 | /* Do some checking to help insure the file we opened really is | 68678 | /* Do some checking to help insure the file we opened really is |
| 68562 | ** a valid database file. | 68679 | ** a valid database file. |
| 68563 | */ | 68680 | */ |
| 68564 | nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData); | 68681 | nPage = get4byte(28+(u8*)pPage1->aData); |
| 68565 | sqlite3PagerPagecount(pBt->pPager, (int*)&nPageFile); | 68682 | sqlite3PagerPagecount(pBt->pPager, (int*)&nPageFile); |
| 68566 | if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){ | 68683 | if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){ |
| 68567 | nPage = nPageFile; | 68684 | nPage = nPageFile; |
| @@ -68596,7 +68713,7 @@ static int lockBtree(BtShared *pBt){ | |||
| 68596 | goto page1_init_failed; | 68713 | goto page1_init_failed; |
| 68597 | } | 68714 | } |
| 68598 | 68715 | ||
| 68599 | /* If the write version is set to 2, this database should be accessed | 68716 | /* If the read version is set to 2, this database should be accessed |
| 68600 | ** in WAL mode. If the log is not already open, open it now. Then | 68717 | ** in WAL mode. If the log is not already open, open it now. Then |
| 68601 | ** return SQLITE_OK and return without populating BtShared.pPage1. | 68718 | ** return SQLITE_OK and return without populating BtShared.pPage1. |
| 68602 | ** The caller detects this and calls this function again. This is | 68719 | ** The caller detects this and calls this function again. This is |
| @@ -69394,16 +69511,18 @@ SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){ | |||
| 69394 | /* | 69511 | /* |
| 69395 | ** This routine is called prior to sqlite3PagerCommit when a transaction | 69512 | ** This routine is called prior to sqlite3PagerCommit when a transaction |
| 69396 | ** is committed for an auto-vacuum database. | 69513 | ** is committed for an auto-vacuum database. |
| 69397 | ** | ||
| 69398 | ** If SQLITE_OK is returned, then *pnTrunc is set to the number of pages | ||
| 69399 | ** the database file should be truncated to during the commit process. | ||
| 69400 | ** i.e. the database has been reorganized so that only the first *pnTrunc | ||
| 69401 | ** pages are in use. | ||
| 69402 | */ | 69514 | */ |
| 69403 | static int autoVacuumCommit(BtShared *pBt){ | 69515 | static int autoVacuumCommit(Btree *p){ |
| 69404 | int rc = SQLITE_OK; | 69516 | int rc = SQLITE_OK; |
| 69405 | Pager *pPager = pBt->pPager; | 69517 | Pager *pPager; |
| 69406 | VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager); ) | 69518 | BtShared *pBt; |
| 69519 | sqlite3 *db; | ||
| 69520 | VVA_ONLY( int nRef ); | ||
| 69521 | |||
| 69522 | assert( p!=0 ); | ||
| 69523 | pBt = p->pBt; | ||
| 69524 | pPager = pBt->pPager; | ||
| 69525 | VVA_ONLY( nRef = sqlite3PagerRefcount(pPager); ) | ||
| 69407 | 69526 | ||
| 69408 | assert( sqlite3_mutex_held(pBt->mutex) ); | 69527 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 69409 | invalidateAllOverflowCache(pBt); | 69528 | invalidateAllOverflowCache(pBt); |
| @@ -69411,6 +69530,7 @@ static int autoVacuumCommit(BtShared *pBt){ | |||
| 69411 | if( !pBt->incrVacuum ){ | 69530 | if( !pBt->incrVacuum ){ |
| 69412 | Pgno nFin; /* Number of pages in database after autovacuuming */ | 69531 | Pgno nFin; /* Number of pages in database after autovacuuming */ |
| 69413 | Pgno nFree; /* Number of pages on the freelist initially */ | 69532 | Pgno nFree; /* Number of pages on the freelist initially */ |
| 69533 | Pgno nVac; /* Number of pages to vacuum */ | ||
| 69414 | Pgno iFree; /* The next page to be freed */ | 69534 | Pgno iFree; /* The next page to be freed */ |
| 69415 | Pgno nOrig; /* Database size before freeing */ | 69535 | Pgno nOrig; /* Database size before freeing */ |
| 69416 | 69536 | ||
| @@ -69424,18 +69544,42 @@ static int autoVacuumCommit(BtShared *pBt){ | |||
| 69424 | } | 69544 | } |
| 69425 | 69545 | ||
| 69426 | nFree = get4byte(&pBt->pPage1->aData[36]); | 69546 | nFree = get4byte(&pBt->pPage1->aData[36]); |
| 69427 | nFin = finalDbSize(pBt, nOrig, nFree); | 69547 | db = p->db; |
| 69548 | if( db->xAutovacPages ){ | ||
| 69549 | int iDb; | ||
| 69550 | for(iDb=0; ALWAYS(iDb<db->nDb); iDb++){ | ||
| 69551 | if( db->aDb[iDb].pBt==p ) break; | ||
| 69552 | } | ||
| 69553 | nVac = db->xAutovacPages( | ||
| 69554 | db->pAutovacPagesArg, | ||
| 69555 | db->aDb[iDb].zDbSName, | ||
| 69556 | nOrig, | ||
| 69557 | nFree, | ||
| 69558 | pBt->pageSize | ||
| 69559 | ); | ||
| 69560 | if( nVac>nFree ){ | ||
| 69561 | nVac = nFree; | ||
| 69562 | } | ||
| 69563 | if( nVac==0 ){ | ||
| 69564 | return SQLITE_OK; | ||
| 69565 | } | ||
| 69566 | }else{ | ||
| 69567 | nVac = nFree; | ||
| 69568 | } | ||
| 69569 | nFin = finalDbSize(pBt, nOrig, nVac); | ||
| 69428 | if( nFin>nOrig ) return SQLITE_CORRUPT_BKPT; | 69570 | if( nFin>nOrig ) return SQLITE_CORRUPT_BKPT; |
| 69429 | if( nFin<nOrig ){ | 69571 | if( nFin<nOrig ){ |
| 69430 | rc = saveAllCursors(pBt, 0, 0); | 69572 | rc = saveAllCursors(pBt, 0, 0); |
| 69431 | } | 69573 | } |
| 69432 | for(iFree=nOrig; iFree>nFin && rc==SQLITE_OK; iFree--){ | 69574 | for(iFree=nOrig; iFree>nFin && rc==SQLITE_OK; iFree--){ |
| 69433 | rc = incrVacuumStep(pBt, nFin, iFree, 1); | 69575 | rc = incrVacuumStep(pBt, nFin, iFree, nVac==nFree); |
| 69434 | } | 69576 | } |
| 69435 | if( (rc==SQLITE_DONE || rc==SQLITE_OK) && nFree>0 ){ | 69577 | if( (rc==SQLITE_DONE || rc==SQLITE_OK) && nFree>0 ){ |
| 69436 | rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); | 69578 | rc = sqlite3PagerWrite(pBt->pPage1->pDbPage); |
| 69437 | put4byte(&pBt->pPage1->aData[32], 0); | 69579 | if( nVac==nFree ){ |
| 69438 | put4byte(&pBt->pPage1->aData[36], 0); | 69580 | put4byte(&pBt->pPage1->aData[32], 0); |
| 69581 | put4byte(&pBt->pPage1->aData[36], 0); | ||
| 69582 | } | ||
| 69439 | put4byte(&pBt->pPage1->aData[28], nFin); | 69583 | put4byte(&pBt->pPage1->aData[28], nFin); |
| 69440 | pBt->bDoTruncate = 1; | 69584 | pBt->bDoTruncate = 1; |
| 69441 | pBt->nPage = nFin; | 69585 | pBt->nPage = nFin; |
| @@ -69486,7 +69630,7 @@ SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree *p, const char *zSuperJrnl){ | |||
| 69486 | sqlite3BtreeEnter(p); | 69630 | sqlite3BtreeEnter(p); |
| 69487 | #ifndef SQLITE_OMIT_AUTOVACUUM | 69631 | #ifndef SQLITE_OMIT_AUTOVACUUM |
| 69488 | if( pBt->autoVacuum ){ | 69632 | if( pBt->autoVacuum ){ |
| 69489 | rc = autoVacuumCommit(pBt); | 69633 | rc = autoVacuumCommit(p); |
| 69490 | if( rc!=SQLITE_OK ){ | 69634 | if( rc!=SQLITE_OK ){ |
| 69491 | sqlite3BtreeLeave(p); | 69635 | sqlite3BtreeLeave(p); |
| 69492 | return rc; | 69636 | return rc; |
| @@ -70291,7 +70435,9 @@ static int accessPayload( | |||
| 70291 | assert( pPage ); | 70435 | assert( pPage ); |
| 70292 | assert( eOp==0 || eOp==1 ); | 70436 | assert( eOp==0 || eOp==1 ); |
| 70293 | assert( pCur->eState==CURSOR_VALID ); | 70437 | assert( pCur->eState==CURSOR_VALID ); |
| 70294 | assert( pCur->ix<pPage->nCell ); | 70438 | if( pCur->ix>=pPage->nCell ){ |
| 70439 | return SQLITE_CORRUPT_PAGE(pPage); | ||
| 70440 | } | ||
| 70295 | assert( cursorHoldsMutex(pCur) ); | 70441 | assert( cursorHoldsMutex(pCur) ); |
| 70296 | 70442 | ||
| 70297 | getCellInfo(pCur); | 70443 | getCellInfo(pCur); |
| @@ -70478,7 +70624,6 @@ SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor *pCur, u32 offset, u32 amt, void | |||
| 70478 | assert( cursorHoldsMutex(pCur) ); | 70624 | assert( cursorHoldsMutex(pCur) ); |
| 70479 | assert( pCur->eState==CURSOR_VALID ); | 70625 | assert( pCur->eState==CURSOR_VALID ); |
| 70480 | assert( pCur->iPage>=0 && pCur->pPage ); | 70626 | assert( pCur->iPage>=0 && pCur->pPage ); |
| 70481 | assert( pCur->ix<pCur->pPage->nCell ); | ||
| 70482 | return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0); | 70627 | return accessPayload(pCur, offset, amt, (unsigned char*)pBuf, 0); |
| 70483 | } | 70628 | } |
| 70484 | 70629 | ||
| @@ -70540,7 +70685,7 @@ static const void *fetchPayload( | |||
| 70540 | assert( pCur->eState==CURSOR_VALID ); | 70685 | assert( pCur->eState==CURSOR_VALID ); |
| 70541 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); | 70686 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); |
| 70542 | assert( cursorOwnsBtShared(pCur) ); | 70687 | assert( cursorOwnsBtShared(pCur) ); |
| 70543 | assert( pCur->ix<pCur->pPage->nCell ); | 70688 | assert( pCur->ix<pCur->pPage->nCell || CORRUPT_DB ); |
| 70544 | assert( pCur->info.nSize>0 ); | 70689 | assert( pCur->info.nSize>0 ); |
| 70545 | assert( pCur->info.pPayload>pCur->pPage->aData || CORRUPT_DB ); | 70690 | assert( pCur->info.pPayload>pCur->pPage->aData || CORRUPT_DB ); |
| 70546 | assert( pCur->info.pPayload<pCur->pPage->aDataEnd ||CORRUPT_DB); | 70691 | assert( pCur->info.pPayload<pCur->pPage->aDataEnd ||CORRUPT_DB); |
| @@ -70873,12 +71018,8 @@ SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){ | |||
| 70873 | return rc; | 71018 | return rc; |
| 70874 | } | 71019 | } |
| 70875 | 71020 | ||
| 70876 | /* Move the cursor so that it points to an entry near the key | 71021 | /* Move the cursor so that it points to an entry in a table (a.k.a INTKEY) |
| 70877 | ** specified by pIdxKey or intKey. Return a success code. | 71022 | ** table near the key intKey. Return a success code. |
| 70878 | ** | ||
| 70879 | ** For INTKEY tables, the intKey parameter is used. pIdxKey | ||
| 70880 | ** must be NULL. For index tables, pIdxKey is used and intKey | ||
| 70881 | ** is ignored. | ||
| 70882 | ** | 71023 | ** |
| 70883 | ** If an exact match is not found, then the cursor is always | 71024 | ** If an exact match is not found, then the cursor is always |
| 70884 | ** left pointing at a leaf page which would hold the entry if it | 71025 | ** left pointing at a leaf page which would hold the entry if it |
| @@ -70891,39 +71032,32 @@ SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor *pCur, int *pRes){ | |||
| 70891 | ** *pRes is as follows: | 71032 | ** *pRes is as follows: |
| 70892 | ** | 71033 | ** |
| 70893 | ** *pRes<0 The cursor is left pointing at an entry that | 71034 | ** *pRes<0 The cursor is left pointing at an entry that |
| 70894 | ** is smaller than intKey/pIdxKey or if the table is empty | 71035 | ** is smaller than intKey or if the table is empty |
| 70895 | ** and the cursor is therefore left point to nothing. | 71036 | ** and the cursor is therefore left point to nothing. |
| 70896 | ** | 71037 | ** |
| 70897 | ** *pRes==0 The cursor is left pointing at an entry that | 71038 | ** *pRes==0 The cursor is left pointing at an entry that |
| 70898 | ** exactly matches intKey/pIdxKey. | 71039 | ** exactly matches intKey. |
| 70899 | ** | 71040 | ** |
| 70900 | ** *pRes>0 The cursor is left pointing at an entry that | 71041 | ** *pRes>0 The cursor is left pointing at an entry that |
| 70901 | ** is larger than intKey/pIdxKey. | 71042 | ** is larger than intKey. |
| 70902 | ** | ||
| 70903 | ** For index tables, the pIdxKey->eqSeen field is set to 1 if there | ||
| 70904 | ** exists an entry in the table that exactly matches pIdxKey. | ||
| 70905 | */ | 71043 | */ |
| 70906 | SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( | 71044 | SQLITE_PRIVATE int sqlite3BtreeTableMoveto( |
| 70907 | BtCursor *pCur, /* The cursor to be moved */ | 71045 | BtCursor *pCur, /* The cursor to be moved */ |
| 70908 | UnpackedRecord *pIdxKey, /* Unpacked index key */ | ||
| 70909 | i64 intKey, /* The table key */ | 71046 | i64 intKey, /* The table key */ |
| 70910 | int biasRight, /* If true, bias the search to the high end */ | 71047 | int biasRight, /* If true, bias the search to the high end */ |
| 70911 | int *pRes /* Write search results here */ | 71048 | int *pRes /* Write search results here */ |
| 70912 | ){ | 71049 | ){ |
| 70913 | int rc; | 71050 | int rc; |
| 70914 | RecordCompare xRecordCompare; | ||
| 70915 | 71051 | ||
| 70916 | assert( cursorOwnsBtShared(pCur) ); | 71052 | assert( cursorOwnsBtShared(pCur) ); |
| 70917 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); | 71053 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); |
| 70918 | assert( pRes ); | 71054 | assert( pRes ); |
| 70919 | assert( (pIdxKey==0)==(pCur->pKeyInfo==0) ); | 71055 | assert( pCur->pKeyInfo==0 ); |
| 70920 | assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) ); | 71056 | assert( pCur->eState!=CURSOR_VALID || pCur->curIntKey!=0 ); |
| 70921 | 71057 | ||
| 70922 | /* If the cursor is already positioned at the point we are trying | 71058 | /* If the cursor is already positioned at the point we are trying |
| 70923 | ** to move to, then just return without doing any work */ | 71059 | ** to move to, then just return without doing any work */ |
| 70924 | if( pIdxKey==0 | 71060 | if( pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0 ){ |
| 70925 | && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0 | ||
| 70926 | ){ | ||
| 70927 | if( pCur->info.nKey==intKey ){ | 71061 | if( pCur->info.nKey==intKey ){ |
| 70928 | *pRes = 0; | 71062 | *pRes = 0; |
| 70929 | return SQLITE_OK; | 71063 | return SQLITE_OK; |
| @@ -70945,9 +71079,7 @@ SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( | |||
| 70945 | if( pCur->info.nKey==intKey ){ | 71079 | if( pCur->info.nKey==intKey ){ |
| 70946 | return SQLITE_OK; | 71080 | return SQLITE_OK; |
| 70947 | } | 71081 | } |
| 70948 | }else if( rc==SQLITE_DONE ){ | 71082 | }else if( rc!=SQLITE_DONE ){ |
| 70949 | rc = SQLITE_OK; | ||
| 70950 | }else{ | ||
| 70951 | return rc; | 71083 | return rc; |
| 70952 | } | 71084 | } |
| 70953 | } | 71085 | } |
| @@ -70958,17 +71090,6 @@ SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( | |||
| 70958 | pCur->pBtree->nSeek++; /* Performance measurement during testing */ | 71090 | pCur->pBtree->nSeek++; /* Performance measurement during testing */ |
| 70959 | #endif | 71091 | #endif |
| 70960 | 71092 | ||
| 70961 | if( pIdxKey ){ | ||
| 70962 | xRecordCompare = sqlite3VdbeFindCompare(pIdxKey); | ||
| 70963 | pIdxKey->errCode = 0; | ||
| 70964 | assert( pIdxKey->default_rc==1 | ||
| 70965 | || pIdxKey->default_rc==0 | ||
| 70966 | || pIdxKey->default_rc==-1 | ||
| 70967 | ); | ||
| 70968 | }else{ | ||
| 70969 | xRecordCompare = 0; /* All keys are integers */ | ||
| 70970 | } | ||
| 70971 | |||
| 70972 | rc = moveToRoot(pCur); | 71093 | rc = moveToRoot(pCur); |
| 70973 | if( rc ){ | 71094 | if( rc ){ |
| 70974 | if( rc==SQLITE_EMPTY ){ | 71095 | if( rc==SQLITE_EMPTY ){ |
| @@ -70983,7 +71104,8 @@ SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( | |||
| 70983 | assert( pCur->eState==CURSOR_VALID ); | 71104 | assert( pCur->eState==CURSOR_VALID ); |
| 70984 | assert( pCur->pPage->nCell > 0 ); | 71105 | assert( pCur->pPage->nCell > 0 ); |
| 70985 | assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey ); | 71106 | assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey ); |
| 70986 | assert( pCur->curIntKey || pIdxKey ); | 71107 | assert( pCur->curIntKey ); |
| 71108 | |||
| 70987 | for(;;){ | 71109 | for(;;){ |
| 70988 | int lwr, upr, idx, c; | 71110 | int lwr, upr, idx, c; |
| 70989 | Pgno chldPg; | 71111 | Pgno chldPg; |
| @@ -70997,133 +71119,238 @@ SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( | |||
| 70997 | ** be the right kind (index or table) of b-tree page. Otherwise | 71119 | ** be the right kind (index or table) of b-tree page. Otherwise |
| 70998 | ** a moveToChild() or moveToRoot() call would have detected corruption. */ | 71120 | ** a moveToChild() or moveToRoot() call would have detected corruption. */ |
| 70999 | assert( pPage->nCell>0 ); | 71121 | assert( pPage->nCell>0 ); |
| 71000 | assert( pPage->intKey==(pIdxKey==0) ); | 71122 | assert( pPage->intKey ); |
| 71001 | lwr = 0; | 71123 | lwr = 0; |
| 71002 | upr = pPage->nCell-1; | 71124 | upr = pPage->nCell-1; |
| 71003 | assert( biasRight==0 || biasRight==1 ); | 71125 | assert( biasRight==0 || biasRight==1 ); |
| 71004 | idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */ | 71126 | idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */ |
| 71005 | pCur->ix = (u16)idx; | 71127 | pCur->ix = (u16)idx; |
| 71006 | if( xRecordCompare==0 ){ | 71128 | for(;;){ |
| 71007 | for(;;){ | 71129 | i64 nCellKey; |
| 71008 | i64 nCellKey; | 71130 | pCell = findCellPastPtr(pPage, idx); |
| 71009 | pCell = findCellPastPtr(pPage, idx); | 71131 | if( pPage->intKeyLeaf ){ |
| 71010 | if( pPage->intKeyLeaf ){ | 71132 | while( 0x80 <= *(pCell++) ){ |
| 71011 | while( 0x80 <= *(pCell++) ){ | 71133 | if( pCell>=pPage->aDataEnd ){ |
| 71012 | if( pCell>=pPage->aDataEnd ){ | 71134 | return SQLITE_CORRUPT_PAGE(pPage); |
| 71013 | return SQLITE_CORRUPT_PAGE(pPage); | ||
| 71014 | } | ||
| 71015 | } | 71135 | } |
| 71016 | } | 71136 | } |
| 71017 | getVarint(pCell, (u64*)&nCellKey); | 71137 | } |
| 71018 | if( nCellKey<intKey ){ | 71138 | getVarint(pCell, (u64*)&nCellKey); |
| 71019 | lwr = idx+1; | 71139 | if( nCellKey<intKey ){ |
| 71020 | if( lwr>upr ){ c = -1; break; } | 71140 | lwr = idx+1; |
| 71021 | }else if( nCellKey>intKey ){ | 71141 | if( lwr>upr ){ c = -1; break; } |
| 71022 | upr = idx-1; | 71142 | }else if( nCellKey>intKey ){ |
| 71023 | if( lwr>upr ){ c = +1; break; } | 71143 | upr = idx-1; |
| 71144 | if( lwr>upr ){ c = +1; break; } | ||
| 71145 | }else{ | ||
| 71146 | assert( nCellKey==intKey ); | ||
| 71147 | pCur->ix = (u16)idx; | ||
| 71148 | if( !pPage->leaf ){ | ||
| 71149 | lwr = idx; | ||
| 71150 | goto moveto_table_next_layer; | ||
| 71024 | }else{ | 71151 | }else{ |
| 71025 | assert( nCellKey==intKey ); | 71152 | pCur->curFlags |= BTCF_ValidNKey; |
| 71026 | pCur->ix = (u16)idx; | 71153 | pCur->info.nKey = nCellKey; |
| 71027 | if( !pPage->leaf ){ | 71154 | pCur->info.nSize = 0; |
| 71028 | lwr = idx; | 71155 | *pRes = 0; |
| 71029 | goto moveto_next_layer; | 71156 | return SQLITE_OK; |
| 71030 | }else{ | ||
| 71031 | pCur->curFlags |= BTCF_ValidNKey; | ||
| 71032 | pCur->info.nKey = nCellKey; | ||
| 71033 | pCur->info.nSize = 0; | ||
| 71034 | *pRes = 0; | ||
| 71035 | return SQLITE_OK; | ||
| 71036 | } | ||
| 71037 | } | 71157 | } |
| 71038 | assert( lwr+upr>=0 ); | ||
| 71039 | idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2; */ | ||
| 71040 | } | 71158 | } |
| 71159 | assert( lwr+upr>=0 ); | ||
| 71160 | idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2; */ | ||
| 71161 | } | ||
| 71162 | assert( lwr==upr+1 || !pPage->leaf ); | ||
| 71163 | assert( pPage->isInit ); | ||
| 71164 | if( pPage->leaf ){ | ||
| 71165 | assert( pCur->ix<pCur->pPage->nCell ); | ||
| 71166 | pCur->ix = (u16)idx; | ||
| 71167 | *pRes = c; | ||
| 71168 | rc = SQLITE_OK; | ||
| 71169 | goto moveto_table_finish; | ||
| 71170 | } | ||
| 71171 | moveto_table_next_layer: | ||
| 71172 | if( lwr>=pPage->nCell ){ | ||
| 71173 | chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); | ||
| 71041 | }else{ | 71174 | }else{ |
| 71042 | for(;;){ | 71175 | chldPg = get4byte(findCell(pPage, lwr)); |
| 71043 | int nCell; /* Size of the pCell cell in bytes */ | 71176 | } |
| 71044 | pCell = findCellPastPtr(pPage, idx); | 71177 | pCur->ix = (u16)lwr; |
| 71045 | 71178 | rc = moveToChild(pCur, chldPg); | |
| 71046 | /* The maximum supported page-size is 65536 bytes. This means that | 71179 | if( rc ) break; |
| 71047 | ** the maximum number of record bytes stored on an index B-Tree | 71180 | } |
| 71048 | ** page is less than 16384 bytes and may be stored as a 2-byte | 71181 | moveto_table_finish: |
| 71049 | ** varint. This information is used to attempt to avoid parsing | 71182 | pCur->info.nSize = 0; |
| 71050 | ** the entire cell by checking for the cases where the record is | 71183 | assert( (pCur->curFlags & BTCF_ValidOvfl)==0 ); |
| 71051 | ** stored entirely within the b-tree page by inspecting the first | 71184 | return rc; |
| 71052 | ** 2 bytes of the cell. | 71185 | } |
| 71053 | */ | 71186 | |
| 71054 | nCell = pCell[0]; | 71187 | /* Move the cursor so that it points to an entry in an index table |
| 71055 | if( nCell<=pPage->max1bytePayload ){ | 71188 | ** near the key pIdxKey. Return a success code. |
| 71056 | /* This branch runs if the record-size field of the cell is a | 71189 | ** |
| 71057 | ** single byte varint and the record fits entirely on the main | 71190 | ** If an exact match is not found, then the cursor is always |
| 71058 | ** b-tree page. */ | 71191 | ** left pointing at a leaf page which would hold the entry if it |
| 71059 | testcase( pCell+nCell+1==pPage->aDataEnd ); | 71192 | ** were present. The cursor might point to an entry that comes |
| 71060 | c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey); | 71193 | ** before or after the key. |
| 71061 | }else if( !(pCell[1] & 0x80) | 71194 | ** |
| 71062 | && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal | 71195 | ** An integer is written into *pRes which is the result of |
| 71063 | ){ | 71196 | ** comparing the key with the entry to which the cursor is |
| 71064 | /* The record-size field is a 2 byte varint and the record | 71197 | ** pointing. The meaning of the integer written into |
| 71065 | ** fits entirely on the main b-tree page. */ | 71198 | ** *pRes is as follows: |
| 71066 | testcase( pCell+nCell+2==pPage->aDataEnd ); | 71199 | ** |
| 71067 | c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey); | 71200 | ** *pRes<0 The cursor is left pointing at an entry that |
| 71068 | }else{ | 71201 | ** is smaller than pIdxKey or if the table is empty |
| 71069 | /* The record flows over onto one or more overflow pages. In | 71202 | ** and the cursor is therefore left point to nothing. |
| 71070 | ** this case the whole cell needs to be parsed, a buffer allocated | 71203 | ** |
| 71071 | ** and accessPayload() used to retrieve the record into the | 71204 | ** *pRes==0 The cursor is left pointing at an entry that |
| 71072 | ** buffer before VdbeRecordCompare() can be called. | 71205 | ** exactly matches pIdxKey. |
| 71073 | ** | 71206 | ** |
| 71074 | ** If the record is corrupt, the xRecordCompare routine may read | 71207 | ** *pRes>0 The cursor is left pointing at an entry that |
| 71075 | ** up to two varints past the end of the buffer. An extra 18 | 71208 | ** is larger than pIdxKey. |
| 71076 | ** bytes of padding is allocated at the end of the buffer in | 71209 | ** |
| 71077 | ** case this happens. */ | 71210 | ** The pIdxKey->eqSeen field is set to 1 if there |
| 71078 | void *pCellKey; | 71211 | ** exists an entry in the table that exactly matches pIdxKey. |
| 71079 | u8 * const pCellBody = pCell - pPage->childPtrSize; | 71212 | */ |
| 71080 | const int nOverrun = 18; /* Size of the overrun padding */ | 71213 | SQLITE_PRIVATE int sqlite3BtreeIndexMoveto( |
| 71081 | pPage->xParseCell(pPage, pCellBody, &pCur->info); | 71214 | BtCursor *pCur, /* The cursor to be moved */ |
| 71082 | nCell = (int)pCur->info.nKey; | 71215 | UnpackedRecord *pIdxKey, /* Unpacked index key */ |
| 71083 | testcase( nCell<0 ); /* True if key size is 2^32 or more */ | 71216 | int *pRes /* Write search results here */ |
| 71084 | testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */ | 71217 | ){ |
| 71085 | testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */ | 71218 | int rc; |
| 71086 | testcase( nCell==2 ); /* Minimum legal index key size */ | 71219 | RecordCompare xRecordCompare; |
| 71087 | if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){ | 71220 | |
| 71088 | rc = SQLITE_CORRUPT_PAGE(pPage); | 71221 | assert( cursorOwnsBtShared(pCur) ); |
| 71089 | goto moveto_finish; | 71222 | assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); |
| 71090 | } | 71223 | assert( pRes ); |
| 71091 | pCellKey = sqlite3Malloc( nCell+nOverrun ); | 71224 | assert( pCur->pKeyInfo!=0 ); |
| 71092 | if( pCellKey==0 ){ | 71225 | |
| 71093 | rc = SQLITE_NOMEM_BKPT; | 71226 | #ifdef SQLITE_DEBUG |
| 71094 | goto moveto_finish; | 71227 | pCur->pBtree->nSeek++; /* Performance measurement during testing */ |
| 71095 | } | 71228 | #endif |
| 71096 | pCur->ix = (u16)idx; | 71229 | |
| 71097 | rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0); | 71230 | xRecordCompare = sqlite3VdbeFindCompare(pIdxKey); |
| 71098 | memset(((u8*)pCellKey)+nCell,0,nOverrun); /* Fix uninit warnings */ | 71231 | pIdxKey->errCode = 0; |
| 71099 | pCur->curFlags &= ~BTCF_ValidOvfl; | 71232 | assert( pIdxKey->default_rc==1 |
| 71100 | if( rc ){ | 71233 | || pIdxKey->default_rc==0 |
| 71101 | sqlite3_free(pCellKey); | 71234 | || pIdxKey->default_rc==-1 |
| 71102 | goto moveto_finish; | 71235 | ); |
| 71103 | } | 71236 | |
| 71104 | c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey); | 71237 | rc = moveToRoot(pCur); |
| 71105 | sqlite3_free(pCellKey); | 71238 | if( rc ){ |
| 71239 | if( rc==SQLITE_EMPTY ){ | ||
| 71240 | assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 ); | ||
| 71241 | *pRes = -1; | ||
| 71242 | return SQLITE_OK; | ||
| 71243 | } | ||
| 71244 | return rc; | ||
| 71245 | } | ||
| 71246 | assert( pCur->pPage ); | ||
| 71247 | assert( pCur->pPage->isInit ); | ||
| 71248 | assert( pCur->eState==CURSOR_VALID ); | ||
| 71249 | assert( pCur->pPage->nCell > 0 ); | ||
| 71250 | assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey ); | ||
| 71251 | assert( pCur->curIntKey || pIdxKey ); | ||
| 71252 | for(;;){ | ||
| 71253 | int lwr, upr, idx, c; | ||
| 71254 | Pgno chldPg; | ||
| 71255 | MemPage *pPage = pCur->pPage; | ||
| 71256 | u8 *pCell; /* Pointer to current cell in pPage */ | ||
| 71257 | |||
| 71258 | /* pPage->nCell must be greater than zero. If this is the root-page | ||
| 71259 | ** the cursor would have been INVALID above and this for(;;) loop | ||
| 71260 | ** not run. If this is not the root-page, then the moveToChild() routine | ||
| 71261 | ** would have already detected db corruption. Similarly, pPage must | ||
| 71262 | ** be the right kind (index or table) of b-tree page. Otherwise | ||
| 71263 | ** a moveToChild() or moveToRoot() call would have detected corruption. */ | ||
| 71264 | assert( pPage->nCell>0 ); | ||
| 71265 | assert( pPage->intKey==(pIdxKey==0) ); | ||
| 71266 | lwr = 0; | ||
| 71267 | upr = pPage->nCell-1; | ||
| 71268 | idx = upr>>1; /* idx = (lwr+upr)/2; */ | ||
| 71269 | pCur->ix = (u16)idx; | ||
| 71270 | for(;;){ | ||
| 71271 | int nCell; /* Size of the pCell cell in bytes */ | ||
| 71272 | pCell = findCellPastPtr(pPage, idx); | ||
| 71273 | |||
| 71274 | /* The maximum supported page-size is 65536 bytes. This means that | ||
| 71275 | ** the maximum number of record bytes stored on an index B-Tree | ||
| 71276 | ** page is less than 16384 bytes and may be stored as a 2-byte | ||
| 71277 | ** varint. This information is used to attempt to avoid parsing | ||
| 71278 | ** the entire cell by checking for the cases where the record is | ||
| 71279 | ** stored entirely within the b-tree page by inspecting the first | ||
| 71280 | ** 2 bytes of the cell. | ||
| 71281 | */ | ||
| 71282 | nCell = pCell[0]; | ||
| 71283 | if( nCell<=pPage->max1bytePayload ){ | ||
| 71284 | /* This branch runs if the record-size field of the cell is a | ||
| 71285 | ** single byte varint and the record fits entirely on the main | ||
| 71286 | ** b-tree page. */ | ||
| 71287 | testcase( pCell+nCell+1==pPage->aDataEnd ); | ||
| 71288 | c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey); | ||
| 71289 | }else if( !(pCell[1] & 0x80) | ||
| 71290 | && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal | ||
| 71291 | ){ | ||
| 71292 | /* The record-size field is a 2 byte varint and the record | ||
| 71293 | ** fits entirely on the main b-tree page. */ | ||
| 71294 | testcase( pCell+nCell+2==pPage->aDataEnd ); | ||
| 71295 | c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey); | ||
| 71296 | }else{ | ||
| 71297 | /* The record flows over onto one or more overflow pages. In | ||
| 71298 | ** this case the whole cell needs to be parsed, a buffer allocated | ||
| 71299 | ** and accessPayload() used to retrieve the record into the | ||
| 71300 | ** buffer before VdbeRecordCompare() can be called. | ||
| 71301 | ** | ||
| 71302 | ** If the record is corrupt, the xRecordCompare routine may read | ||
| 71303 | ** up to two varints past the end of the buffer. An extra 18 | ||
| 71304 | ** bytes of padding is allocated at the end of the buffer in | ||
| 71305 | ** case this happens. */ | ||
| 71306 | void *pCellKey; | ||
| 71307 | u8 * const pCellBody = pCell - pPage->childPtrSize; | ||
| 71308 | const int nOverrun = 18; /* Size of the overrun padding */ | ||
| 71309 | pPage->xParseCell(pPage, pCellBody, &pCur->info); | ||
| 71310 | nCell = (int)pCur->info.nKey; | ||
| 71311 | testcase( nCell<0 ); /* True if key size is 2^32 or more */ | ||
| 71312 | testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */ | ||
| 71313 | testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */ | ||
| 71314 | testcase( nCell==2 ); /* Minimum legal index key size */ | ||
| 71315 | if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){ | ||
| 71316 | rc = SQLITE_CORRUPT_PAGE(pPage); | ||
| 71317 | goto moveto_index_finish; | ||
| 71318 | } | ||
| 71319 | pCellKey = sqlite3Malloc( nCell+nOverrun ); | ||
| 71320 | if( pCellKey==0 ){ | ||
| 71321 | rc = SQLITE_NOMEM_BKPT; | ||
| 71322 | goto moveto_index_finish; | ||
| 71106 | } | 71323 | } |
| 71107 | assert( | 71324 | pCur->ix = (u16)idx; |
| 71108 | (pIdxKey->errCode!=SQLITE_CORRUPT || c==0) | 71325 | rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0); |
| 71109 | && (pIdxKey->errCode!=SQLITE_NOMEM || pCur->pBtree->db->mallocFailed) | 71326 | memset(((u8*)pCellKey)+nCell,0,nOverrun); /* Fix uninit warnings */ |
| 71110 | ); | 71327 | pCur->curFlags &= ~BTCF_ValidOvfl; |
| 71111 | if( c<0 ){ | 71328 | if( rc ){ |
| 71112 | lwr = idx+1; | 71329 | sqlite3_free(pCellKey); |
| 71113 | }else if( c>0 ){ | 71330 | goto moveto_index_finish; |
| 71114 | upr = idx-1; | ||
| 71115 | }else{ | ||
| 71116 | assert( c==0 ); | ||
| 71117 | *pRes = 0; | ||
| 71118 | rc = SQLITE_OK; | ||
| 71119 | pCur->ix = (u16)idx; | ||
| 71120 | if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT; | ||
| 71121 | goto moveto_finish; | ||
| 71122 | } | 71331 | } |
| 71123 | if( lwr>upr ) break; | 71332 | c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey); |
| 71124 | assert( lwr+upr>=0 ); | 71333 | sqlite3_free(pCellKey); |
| 71125 | idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2 */ | 71334 | } |
| 71335 | assert( | ||
| 71336 | (pIdxKey->errCode!=SQLITE_CORRUPT || c==0) | ||
| 71337 | && (pIdxKey->errCode!=SQLITE_NOMEM || pCur->pBtree->db->mallocFailed) | ||
| 71338 | ); | ||
| 71339 | if( c<0 ){ | ||
| 71340 | lwr = idx+1; | ||
| 71341 | }else if( c>0 ){ | ||
| 71342 | upr = idx-1; | ||
| 71343 | }else{ | ||
| 71344 | assert( c==0 ); | ||
| 71345 | *pRes = 0; | ||
| 71346 | rc = SQLITE_OK; | ||
| 71347 | pCur->ix = (u16)idx; | ||
| 71348 | if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT; | ||
| 71349 | goto moveto_index_finish; | ||
| 71126 | } | 71350 | } |
| 71351 | if( lwr>upr ) break; | ||
| 71352 | assert( lwr+upr>=0 ); | ||
| 71353 | idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2 */ | ||
| 71127 | } | 71354 | } |
| 71128 | assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) ); | 71355 | assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) ); |
| 71129 | assert( pPage->isInit ); | 71356 | assert( pPage->isInit ); |
| @@ -71132,9 +71359,8 @@ SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( | |||
| 71132 | pCur->ix = (u16)idx; | 71359 | pCur->ix = (u16)idx; |
| 71133 | *pRes = c; | 71360 | *pRes = c; |
| 71134 | rc = SQLITE_OK; | 71361 | rc = SQLITE_OK; |
| 71135 | goto moveto_finish; | 71362 | goto moveto_index_finish; |
| 71136 | } | 71363 | } |
| 71137 | moveto_next_layer: | ||
| 71138 | if( lwr>=pPage->nCell ){ | 71364 | if( lwr>=pPage->nCell ){ |
| 71139 | chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); | 71365 | chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]); |
| 71140 | }else{ | 71366 | }else{ |
| @@ -71144,7 +71370,7 @@ moveto_next_layer: | |||
| 71144 | rc = moveToChild(pCur, chldPg); | 71370 | rc = moveToChild(pCur, chldPg); |
| 71145 | if( rc ) break; | 71371 | if( rc ) break; |
| 71146 | } | 71372 | } |
| 71147 | moveto_finish: | 71373 | moveto_index_finish: |
| 71148 | pCur->info.nSize = 0; | 71374 | pCur->info.nSize = 0; |
| 71149 | assert( (pCur->curFlags & BTCF_ValidOvfl)==0 ); | 71375 | assert( (pCur->curFlags & BTCF_ValidOvfl)==0 ); |
| 71150 | return rc; | 71376 | return rc; |
| @@ -71245,16 +71471,6 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){ | |||
| 71245 | return SQLITE_CORRUPT_BKPT; | 71471 | return SQLITE_CORRUPT_BKPT; |
| 71246 | } | 71472 | } |
| 71247 | 71473 | ||
| 71248 | /* If the database file is corrupt, it is possible for the value of idx | ||
| 71249 | ** to be invalid here. This can only occur if a second cursor modifies | ||
| 71250 | ** the page while cursor pCur is holding a reference to it. Which can | ||
| 71251 | ** only happen if the database is corrupt in such a way as to link the | ||
| 71252 | ** page into more than one b-tree structure. | ||
| 71253 | ** | ||
| 71254 | ** Update 2019-12-23: appears to long longer be possible after the | ||
| 71255 | ** addition of anotherValidCursor() condition on balance_deeper(). */ | ||
| 71256 | harmless( idx>pPage->nCell ); | ||
| 71257 | |||
| 71258 | if( idx>=pPage->nCell ){ | 71474 | if( idx>=pPage->nCell ){ |
| 71259 | if( !pPage->leaf ){ | 71475 | if( !pPage->leaf ){ |
| 71260 | rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8])); | 71476 | rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8])); |
| @@ -71742,7 +71958,7 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){ | |||
| 71742 | assert( CORRUPT_DB || iPage>1 ); | 71958 | assert( CORRUPT_DB || iPage>1 ); |
| 71743 | assert( !pMemPage || pMemPage->pgno==iPage ); | 71959 | assert( !pMemPage || pMemPage->pgno==iPage ); |
| 71744 | 71960 | ||
| 71745 | if( iPage<2 || iPage>pBt->nPage ){ | 71961 | if( NEVER(iPage<2) || iPage>pBt->nPage ){ |
| 71746 | return SQLITE_CORRUPT_BKPT; | 71962 | return SQLITE_CORRUPT_BKPT; |
| 71747 | } | 71963 | } |
| 71748 | if( pMemPage ){ | 71964 | if( pMemPage ){ |
| @@ -72698,6 +72914,7 @@ static int editPage( | |||
| 72698 | 72914 | ||
| 72699 | pData = &aData[get2byteNotZero(&aData[hdr+5])]; | 72915 | pData = &aData[get2byteNotZero(&aData[hdr+5])]; |
| 72700 | if( pData<pBegin ) goto editpage_fail; | 72916 | if( pData<pBegin ) goto editpage_fail; |
| 72917 | if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail; | ||
| 72701 | 72918 | ||
| 72702 | /* Add cells to the start of the page */ | 72919 | /* Add cells to the start of the page */ |
| 72703 | if( iNew<iOld ){ | 72920 | if( iNew<iOld ){ |
| @@ -73059,11 +73276,10 @@ static int balance_nonroot( | |||
| 73059 | Pgno aPgno[NB+2]; /* Page numbers of new pages before shuffling */ | 73276 | Pgno aPgno[NB+2]; /* Page numbers of new pages before shuffling */ |
| 73060 | Pgno aPgOrder[NB+2]; /* Copy of aPgno[] used for sorting pages */ | 73277 | Pgno aPgOrder[NB+2]; /* Copy of aPgno[] used for sorting pages */ |
| 73061 | u16 aPgFlags[NB+2]; /* flags field of new pages before shuffling */ | 73278 | u16 aPgFlags[NB+2]; /* flags field of new pages before shuffling */ |
| 73062 | CellArray b; /* Parsed information on cells being balanced */ | 73279 | CellArray b; /* Parsed information on cells being balanced */ |
| 73063 | 73280 | ||
| 73064 | memset(abDone, 0, sizeof(abDone)); | 73281 | memset(abDone, 0, sizeof(abDone)); |
| 73065 | b.nCell = 0; | 73282 | memset(&b, 0, sizeof(b)); |
| 73066 | b.apCell = 0; | ||
| 73067 | pBt = pParent->pBt; | 73283 | pBt = pParent->pBt; |
| 73068 | assert( sqlite3_mutex_held(pBt->mutex) ); | 73284 | assert( sqlite3_mutex_held(pBt->mutex) ); |
| 73069 | assert( sqlite3PagerIswriteable(pParent->pDbPage) ); | 73285 | assert( sqlite3PagerIswriteable(pParent->pDbPage) ); |
| @@ -73128,6 +73344,7 @@ static int balance_nonroot( | |||
| 73128 | goto balance_cleanup; | 73344 | goto balance_cleanup; |
| 73129 | } | 73345 | } |
| 73130 | } | 73346 | } |
| 73347 | nMaxCells += apOld[i]->nCell + ArraySize(pParent->apOvfl); | ||
| 73131 | if( (i--)==0 ) break; | 73348 | if( (i--)==0 ) break; |
| 73132 | 73349 | ||
| 73133 | if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){ | 73350 | if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){ |
| @@ -73169,7 +73386,6 @@ static int balance_nonroot( | |||
| 73169 | 73386 | ||
| 73170 | /* Make nMaxCells a multiple of 4 in order to preserve 8-byte | 73387 | /* Make nMaxCells a multiple of 4 in order to preserve 8-byte |
| 73171 | ** alignment */ | 73388 | ** alignment */ |
| 73172 | nMaxCells = nOld*(MX_CELL(pBt) + ArraySize(pParent->apOvfl)); | ||
| 73173 | nMaxCells = (nMaxCells + 3)&~3; | 73389 | nMaxCells = (nMaxCells + 3)&~3; |
| 73174 | 73390 | ||
| 73175 | /* | 73391 | /* |
| @@ -73452,7 +73668,9 @@ static int balance_nonroot( | |||
| 73452 | apOld[i] = 0; | 73668 | apOld[i] = 0; |
| 73453 | rc = sqlite3PagerWrite(pNew->pDbPage); | 73669 | rc = sqlite3PagerWrite(pNew->pDbPage); |
| 73454 | nNew++; | 73670 | nNew++; |
| 73455 | if( sqlite3PagerPageRefcount(pNew->pDbPage)!=1+(i==(iParentIdx-nxDiv)) ){ | 73671 | if( sqlite3PagerPageRefcount(pNew->pDbPage)!=1+(i==(iParentIdx-nxDiv)) |
| 73672 | && rc==SQLITE_OK | ||
| 73673 | ){ | ||
| 73456 | rc = SQLITE_CORRUPT_BKPT; | 73674 | rc = SQLITE_CORRUPT_BKPT; |
| 73457 | } | 73675 | } |
| 73458 | if( rc ) goto balance_cleanup; | 73676 | if( rc ) goto balance_cleanup; |
| @@ -73872,7 +74090,7 @@ static int balance_deeper(MemPage *pRoot, MemPage **ppChild){ | |||
| 73872 | ** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid | 74090 | ** Return SQLITE_CORRUPT if any cursor other than pCur is currently valid |
| 73873 | ** on the same B-tree as pCur. | 74091 | ** on the same B-tree as pCur. |
| 73874 | ** | 74092 | ** |
| 73875 | ** This can if a database is corrupt with two or more SQL tables | 74093 | ** This can occur if a database is corrupt with two or more SQL tables |
| 73876 | ** pointing to the same b-tree. If an insert occurs on one SQL table | 74094 | ** pointing to the same b-tree. If an insert occurs on one SQL table |
| 73877 | ** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL | 74095 | ** and causes a BEFORE TRIGGER to do a secondary insert on the other SQL |
| 73878 | ** table linked to the same b-tree. If the secondary insert causes a | 74096 | ** table linked to the same b-tree. If the secondary insert causes a |
| @@ -74101,7 +74319,7 @@ static int btreeOverwriteCell(BtCursor *pCur, const BtreePayload *pX){ | |||
| 74101 | do{ | 74319 | do{ |
| 74102 | rc = btreeGetPage(pBt, ovflPgno, &pPage, 0); | 74320 | rc = btreeGetPage(pBt, ovflPgno, &pPage, 0); |
| 74103 | if( rc ) return rc; | 74321 | if( rc ) return rc; |
| 74104 | if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){ | 74322 | if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 || pPage->isInit ){ |
| 74105 | rc = SQLITE_CORRUPT_BKPT; | 74323 | rc = SQLITE_CORRUPT_BKPT; |
| 74106 | }else{ | 74324 | }else{ |
| 74107 | if( iOffset+ovflPageSize<(u32)nTotal ){ | 74325 | if( iOffset+ovflPageSize<(u32)nTotal ){ |
| @@ -74250,7 +74468,8 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 74250 | ** to an adjacent cell. Move the cursor so that it is pointing either | 74468 | ** to an adjacent cell. Move the cursor so that it is pointing either |
| 74251 | ** to the cell to be overwritten or an adjacent cell. | 74469 | ** to the cell to be overwritten or an adjacent cell. |
| 74252 | */ | 74470 | */ |
| 74253 | rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc); | 74471 | rc = sqlite3BtreeTableMoveto(pCur, pX->nKey, |
| 74472 | (flags & BTREE_APPEND)!=0, &loc); | ||
| 74254 | if( rc ) return rc; | 74473 | if( rc ) return rc; |
| 74255 | } | 74474 | } |
| 74256 | }else{ | 74475 | }else{ |
| @@ -74273,13 +74492,11 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 74273 | r.aMem = pX->aMem; | 74492 | r.aMem = pX->aMem; |
| 74274 | r.nField = pX->nMem; | 74493 | r.nField = pX->nMem; |
| 74275 | r.default_rc = 0; | 74494 | r.default_rc = 0; |
| 74276 | r.errCode = 0; | ||
| 74277 | r.r1 = 0; | ||
| 74278 | r.r2 = 0; | ||
| 74279 | r.eqSeen = 0; | 74495 | r.eqSeen = 0; |
| 74280 | rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc); | 74496 | rc = sqlite3BtreeIndexMoveto(pCur, &r, &loc); |
| 74281 | }else{ | 74497 | }else{ |
| 74282 | rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc); | 74498 | rc = btreeMoveto(pCur, pX->pKey, pX->nKey, |
| 74499 | (flags & BTREE_APPEND)!=0, &loc); | ||
| 74283 | } | 74500 | } |
| 74284 | if( rc ) return rc; | 74501 | if( rc ) return rc; |
| 74285 | } | 74502 | } |
| @@ -74342,7 +74559,10 @@ SQLITE_PRIVATE int sqlite3BtreeInsert( | |||
| 74342 | idx = pCur->ix; | 74559 | idx = pCur->ix; |
| 74343 | if( loc==0 ){ | 74560 | if( loc==0 ){ |
| 74344 | CellInfo info; | 74561 | CellInfo info; |
| 74345 | assert( idx<pPage->nCell ); | 74562 | assert( idx>=0 ); |
| 74563 | if( idx>=pPage->nCell ){ | ||
| 74564 | return SQLITE_CORRUPT_BKPT; | ||
| 74565 | } | ||
| 74346 | rc = sqlite3PagerWrite(pPage->pDbPage); | 74566 | rc = sqlite3PagerWrite(pPage->pDbPage); |
| 74347 | if( rc ){ | 74567 | if( rc ){ |
| 74348 | goto end_insert; | 74568 | goto end_insert; |
| @@ -74524,7 +74744,7 @@ SQLITE_PRIVATE int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64 | |||
| 74524 | } | 74744 | } |
| 74525 | }while( rc==SQLITE_OK && nOut>0 ); | 74745 | }while( rc==SQLITE_OK && nOut>0 ); |
| 74526 | 74746 | ||
| 74527 | if( rc==SQLITE_OK && nRem>0 ){ | 74747 | if( rc==SQLITE_OK && nRem>0 && ALWAYS(pPgnoOut) ){ |
| 74528 | Pgno pgnoNew; | 74748 | Pgno pgnoNew; |
| 74529 | MemPage *pNew = 0; | 74749 | MemPage *pNew = 0; |
| 74530 | rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0); | 74750 | rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0); |
| @@ -74913,7 +75133,7 @@ static int clearDatabasePage( | |||
| 74913 | BtShared *pBt, /* The BTree that contains the table */ | 75133 | BtShared *pBt, /* The BTree that contains the table */ |
| 74914 | Pgno pgno, /* Page number to clear */ | 75134 | Pgno pgno, /* Page number to clear */ |
| 74915 | int freePageFlag, /* Deallocate page if true */ | 75135 | int freePageFlag, /* Deallocate page if true */ |
| 74916 | int *pnChange /* Add number of Cells freed to this counter */ | 75136 | i64 *pnChange /* Add number of Cells freed to this counter */ |
| 74917 | ){ | 75137 | ){ |
| 74918 | MemPage *pPage; | 75138 | MemPage *pPage; |
| 74919 | int rc; | 75139 | int rc; |
| @@ -74928,11 +75148,12 @@ static int clearDatabasePage( | |||
| 74928 | } | 75148 | } |
| 74929 | rc = getAndInitPage(pBt, pgno, &pPage, 0, 0); | 75149 | rc = getAndInitPage(pBt, pgno, &pPage, 0, 0); |
| 74930 | if( rc ) return rc; | 75150 | if( rc ) return rc; |
| 74931 | if( pPage->bBusy ){ | 75151 | if( (pBt->openFlags & BTREE_SINGLE)==0 |
| 75152 | && sqlite3PagerPageRefcount(pPage->pDbPage)!=1 | ||
| 75153 | ){ | ||
| 74932 | rc = SQLITE_CORRUPT_BKPT; | 75154 | rc = SQLITE_CORRUPT_BKPT; |
| 74933 | goto cleardatabasepage_out; | 75155 | goto cleardatabasepage_out; |
| 74934 | } | 75156 | } |
| 74935 | pPage->bBusy = 1; | ||
| 74936 | hdr = pPage->hdrOffset; | 75157 | hdr = pPage->hdrOffset; |
| 74937 | for(i=0; i<pPage->nCell; i++){ | 75158 | for(i=0; i<pPage->nCell; i++){ |
| 74938 | pCell = findCell(pPage, i); | 75159 | pCell = findCell(pPage, i); |
| @@ -74946,6 +75167,7 @@ static int clearDatabasePage( | |||
| 74946 | if( !pPage->leaf ){ | 75167 | if( !pPage->leaf ){ |
| 74947 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); | 75168 | rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange); |
| 74948 | if( rc ) goto cleardatabasepage_out; | 75169 | if( rc ) goto cleardatabasepage_out; |
| 75170 | if( pPage->intKey ) pnChange = 0; | ||
| 74949 | } | 75171 | } |
| 74950 | if( pnChange ){ | 75172 | if( pnChange ){ |
| 74951 | testcase( !pPage->intKey ); | 75173 | testcase( !pPage->intKey ); |
| @@ -74958,7 +75180,6 @@ static int clearDatabasePage( | |||
| 74958 | } | 75180 | } |
| 74959 | 75181 | ||
| 74960 | cleardatabasepage_out: | 75182 | cleardatabasepage_out: |
| 74961 | pPage->bBusy = 0; | ||
| 74962 | releasePage(pPage); | 75183 | releasePage(pPage); |
| 74963 | return rc; | 75184 | return rc; |
| 74964 | } | 75185 | } |
| @@ -74975,7 +75196,7 @@ cleardatabasepage_out: | |||
| 74975 | ** If pnChange is not NULL, then the integer value pointed to by pnChange | 75196 | ** If pnChange is not NULL, then the integer value pointed to by pnChange |
| 74976 | ** is incremented by the number of entries in the table. | 75197 | ** is incremented by the number of entries in the table. |
| 74977 | */ | 75198 | */ |
| 74978 | SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){ | 75199 | SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, i64 *pnChange){ |
| 74979 | int rc; | 75200 | int rc; |
| 74980 | BtShared *pBt = p->pBt; | 75201 | BtShared *pBt = p->pBt; |
| 74981 | sqlite3BtreeEnter(p); | 75202 | sqlite3BtreeEnter(p); |
| @@ -75037,10 +75258,10 @@ static int btreeDropTable(Btree *p, Pgno iTable, int *piMoved){ | |||
| 75037 | return SQLITE_CORRUPT_BKPT; | 75258 | return SQLITE_CORRUPT_BKPT; |
| 75038 | } | 75259 | } |
| 75039 | 75260 | ||
| 75040 | rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0); | ||
| 75041 | if( rc ) return rc; | ||
| 75042 | rc = sqlite3BtreeClearTable(p, iTable, 0); | 75261 | rc = sqlite3BtreeClearTable(p, iTable, 0); |
| 75043 | if( rc ){ | 75262 | if( rc ) return rc; |
| 75263 | rc = btreeGetPage(pBt, (Pgno)iTable, &pPage, 0); | ||
| 75264 | if( NEVER(rc) ){ | ||
| 75044 | releasePage(pPage); | 75265 | releasePage(pPage); |
| 75045 | return rc; | 75266 | return rc; |
| 75046 | } | 75267 | } |
| @@ -77197,6 +77418,7 @@ SQLITE_PRIVATE int sqlite3VdbeChangeEncoding(Mem *pMem, int desiredEnc){ | |||
| 77197 | #ifndef SQLITE_OMIT_UTF16 | 77418 | #ifndef SQLITE_OMIT_UTF16 |
| 77198 | int rc; | 77419 | int rc; |
| 77199 | #endif | 77420 | #endif |
| 77421 | assert( pMem!=0 ); | ||
| 77200 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); | 77422 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); |
| 77201 | assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE | 77423 | assert( desiredEnc==SQLITE_UTF8 || desiredEnc==SQLITE_UTF16LE |
| 77202 | || desiredEnc==SQLITE_UTF16BE ); | 77424 | || desiredEnc==SQLITE_UTF16BE ); |
| @@ -77329,6 +77551,7 @@ static SQLITE_NOINLINE int vdbeMemAddTerminator(Mem *pMem){ | |||
| 77329 | ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. | 77551 | ** Return SQLITE_OK on success or SQLITE_NOMEM if malloc fails. |
| 77330 | */ | 77552 | */ |
| 77331 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){ | 77553 | SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){ |
| 77554 | assert( pMem!=0 ); | ||
| 77332 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 77555 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 77333 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); | 77556 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); |
| 77334 | if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){ | 77557 | if( (pMem->flags & (MEM_Str|MEM_Blob))!=0 ){ |
| @@ -77353,6 +77576,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem *pMem){ | |||
| 77353 | #ifndef SQLITE_OMIT_INCRBLOB | 77576 | #ifndef SQLITE_OMIT_INCRBLOB |
| 77354 | SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){ | 77577 | SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){ |
| 77355 | int nByte; | 77578 | int nByte; |
| 77579 | assert( pMem!=0 ); | ||
| 77356 | assert( pMem->flags & MEM_Zero ); | 77580 | assert( pMem->flags & MEM_Zero ); |
| 77357 | assert( (pMem->flags&MEM_Blob)!=0 || MemNullNochng(pMem) ); | 77581 | assert( (pMem->flags&MEM_Blob)!=0 || MemNullNochng(pMem) ); |
| 77358 | testcase( sqlite3_value_nochange(pMem) ); | 77582 | testcase( sqlite3_value_nochange(pMem) ); |
| @@ -77368,6 +77592,8 @@ SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){ | |||
| 77368 | if( sqlite3VdbeMemGrow(pMem, nByte, 1) ){ | 77592 | if( sqlite3VdbeMemGrow(pMem, nByte, 1) ){ |
| 77369 | return SQLITE_NOMEM_BKPT; | 77593 | return SQLITE_NOMEM_BKPT; |
| 77370 | } | 77594 | } |
| 77595 | assert( pMem->z!=0 ); | ||
| 77596 | assert( sqlite3DbMallocSize(pMem->db,pMem->z) >= nByte ); | ||
| 77371 | 77597 | ||
| 77372 | memset(&pMem->z[pMem->n], 0, pMem->u.nZero); | 77598 | memset(&pMem->z[pMem->n], 0, pMem->u.nZero); |
| 77373 | pMem->n += pMem->u.nZero; | 77599 | pMem->n += pMem->u.nZero; |
| @@ -77380,6 +77606,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *pMem){ | |||
| 77380 | ** Make sure the given Mem is \u0000 terminated. | 77606 | ** Make sure the given Mem is \u0000 terminated. |
| 77381 | */ | 77607 | */ |
| 77382 | SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){ | 77608 | SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){ |
| 77609 | assert( pMem!=0 ); | ||
| 77383 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 77610 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 77384 | testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) ); | 77611 | testcase( (pMem->flags & (MEM_Term|MEM_Str))==(MEM_Term|MEM_Str) ); |
| 77385 | testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 ); | 77612 | testcase( (pMem->flags & (MEM_Term|MEM_Str))==0 ); |
| @@ -77407,6 +77634,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemNulTerminate(Mem *pMem){ | |||
| 77407 | SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){ | 77634 | SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem *pMem, u8 enc, u8 bForce){ |
| 77408 | const int nByte = 32; | 77635 | const int nByte = 32; |
| 77409 | 77636 | ||
| 77637 | assert( pMem!=0 ); | ||
| 77410 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 77638 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 77411 | assert( !(pMem->flags&MEM_Zero) ); | 77639 | assert( !(pMem->flags&MEM_Zero) ); |
| 77412 | assert( !(pMem->flags&(MEM_Str|MEM_Blob)) ); | 77640 | assert( !(pMem->flags&(MEM_Str|MEM_Blob)) ); |
| @@ -77442,6 +77670,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){ | |||
| 77442 | sqlite3_context ctx; | 77670 | sqlite3_context ctx; |
| 77443 | Mem t; | 77671 | Mem t; |
| 77444 | assert( pFunc!=0 ); | 77672 | assert( pFunc!=0 ); |
| 77673 | assert( pMem!=0 ); | ||
| 77445 | assert( pFunc->xFinalize!=0 ); | 77674 | assert( pFunc->xFinalize!=0 ); |
| 77446 | assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef ); | 77675 | assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->u.pDef ); |
| 77447 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 77676 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| @@ -77592,6 +77821,7 @@ static SQLITE_NOINLINE i64 memIntValue(Mem *pMem){ | |||
| 77592 | } | 77821 | } |
| 77593 | SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){ | 77822 | SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){ |
| 77594 | int flags; | 77823 | int flags; |
| 77824 | assert( pMem!=0 ); | ||
| 77595 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 77825 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 77596 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | 77826 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 77597 | flags = pMem->flags; | 77827 | flags = pMem->flags; |
| @@ -77620,6 +77850,7 @@ static SQLITE_NOINLINE double memRealValue(Mem *pMem){ | |||
| 77620 | return val; | 77850 | return val; |
| 77621 | } | 77851 | } |
| 77622 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){ | 77852 | SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem *pMem){ |
| 77853 | assert( pMem!=0 ); | ||
| 77623 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 77854 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 77624 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | 77855 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 77625 | if( pMem->flags & MEM_Real ){ | 77856 | if( pMem->flags & MEM_Real ){ |
| @@ -77652,6 +77883,7 @@ SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem *pMem, int ifNull){ | |||
| 77652 | */ | 77883 | */ |
| 77653 | SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){ | 77884 | SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){ |
| 77654 | i64 ix; | 77885 | i64 ix; |
| 77886 | assert( pMem!=0 ); | ||
| 77655 | assert( pMem->flags & MEM_Real ); | 77887 | assert( pMem->flags & MEM_Real ); |
| 77656 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); | 77888 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); |
| 77657 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 77889 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| @@ -77679,6 +77911,7 @@ SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem *pMem){ | |||
| 77679 | ** Convert pMem to type integer. Invalidate any prior representations. | 77911 | ** Convert pMem to type integer. Invalidate any prior representations. |
| 77680 | */ | 77912 | */ |
| 77681 | SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){ | 77913 | SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){ |
| 77914 | assert( pMem!=0 ); | ||
| 77682 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 77915 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 77683 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); | 77916 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); |
| 77684 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | 77917 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| @@ -77693,6 +77926,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem *pMem){ | |||
| 77693 | ** Invalidate any prior representations. | 77926 | ** Invalidate any prior representations. |
| 77694 | */ | 77927 | */ |
| 77695 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){ | 77928 | SQLITE_PRIVATE int sqlite3VdbeMemRealify(Mem *pMem){ |
| 77929 | assert( pMem!=0 ); | ||
| 77696 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 77930 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 77697 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); | 77931 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 77698 | 77932 | ||
| @@ -77726,6 +77960,7 @@ SQLITE_PRIVATE int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){ | |||
| 77726 | ** as much of the string as we can and ignore the rest. | 77960 | ** as much of the string as we can and ignore the rest. |
| 77727 | */ | 77961 | */ |
| 77728 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){ | 77962 | SQLITE_PRIVATE int sqlite3VdbeMemNumerify(Mem *pMem){ |
| 77963 | assert( pMem!=0 ); | ||
| 77729 | testcase( pMem->flags & MEM_Int ); | 77964 | testcase( pMem->flags & MEM_Int ); |
| 77730 | testcase( pMem->flags & MEM_Real ); | 77965 | testcase( pMem->flags & MEM_Real ); |
| 77731 | testcase( pMem->flags & MEM_IntReal ); | 77966 | testcase( pMem->flags & MEM_IntReal ); |
| @@ -77835,6 +78070,7 @@ SQLITE_PRIVATE void sqlite3ValueSetNull(sqlite3_value *p){ | |||
| 77835 | ** Delete any previous value and set the value to be a BLOB of length | 78070 | ** Delete any previous value and set the value to be a BLOB of length |
| 77836 | ** n containing all zeros. | 78071 | ** n containing all zeros. |
| 77837 | */ | 78072 | */ |
| 78073 | #ifndef SQLITE_OMIT_INCRBLOB | ||
| 77838 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ | 78074 | SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ |
| 77839 | sqlite3VdbeMemRelease(pMem); | 78075 | sqlite3VdbeMemRelease(pMem); |
| 77840 | pMem->flags = MEM_Blob|MEM_Zero; | 78076 | pMem->flags = MEM_Blob|MEM_Zero; |
| @@ -77844,6 +78080,21 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ | |||
| 77844 | pMem->enc = SQLITE_UTF8; | 78080 | pMem->enc = SQLITE_UTF8; |
| 77845 | pMem->z = 0; | 78081 | pMem->z = 0; |
| 77846 | } | 78082 | } |
| 78083 | #else | ||
| 78084 | SQLITE_PRIVATE int sqlite3VdbeMemSetZeroBlob(Mem *pMem, int n){ | ||
| 78085 | int nByte = n>0?n:1; | ||
| 78086 | if( sqlite3VdbeMemGrow(pMem, nByte, 0) ){ | ||
| 78087 | return SQLITE_NOMEM_BKPT; | ||
| 78088 | } | ||
| 78089 | assert( pMem->z!=0 ); | ||
| 78090 | assert( sqlite3DbMallocSize(pMem->db, pMem->z)>=nByte ); | ||
| 78091 | memset(pMem->z, 0, nByte); | ||
| 78092 | pMem->n = n>0?n:0; | ||
| 78093 | pMem->flags = MEM_Blob; | ||
| 78094 | pMem->enc = SQLITE_UTF8; | ||
| 78095 | return SQLITE_OK; | ||
| 78096 | } | ||
| 78097 | #endif | ||
| 77847 | 78098 | ||
| 77848 | /* | 78099 | /* |
| 77849 | ** The pMem is known to contain content that needs to be destroyed prior | 78100 | ** The pMem is known to contain content that needs to be destroyed prior |
| @@ -78077,6 +78328,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemSetStr( | |||
| 78077 | int iLimit; /* Maximum allowed string or blob size */ | 78328 | int iLimit; /* Maximum allowed string or blob size */ |
| 78078 | u16 flags = 0; /* New value for pMem->flags */ | 78329 | u16 flags = 0; /* New value for pMem->flags */ |
| 78079 | 78330 | ||
| 78331 | assert( pMem!=0 ); | ||
| 78080 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); | 78332 | assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) ); |
| 78081 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); | 78333 | assert( !sqlite3VdbeMemIsRowSet(pMem) ); |
| 78082 | 78334 | ||
| @@ -78385,7 +78637,7 @@ static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){ | |||
| 78385 | #ifdef SQLITE_ENABLE_STAT4 | 78637 | #ifdef SQLITE_ENABLE_STAT4 |
| 78386 | static int valueFromFunction( | 78638 | static int valueFromFunction( |
| 78387 | sqlite3 *db, /* The database connection */ | 78639 | sqlite3 *db, /* The database connection */ |
| 78388 | Expr *p, /* The expression to evaluate */ | 78640 | const Expr *p, /* The expression to evaluate */ |
| 78389 | u8 enc, /* Encoding to use */ | 78641 | u8 enc, /* Encoding to use */ |
| 78390 | u8 aff, /* Affinity to use */ | 78642 | u8 aff, /* Affinity to use */ |
| 78391 | sqlite3_value **ppVal, /* Write the new value here */ | 78643 | sqlite3_value **ppVal, /* Write the new value here */ |
| @@ -78402,8 +78654,10 @@ static int valueFromFunction( | |||
| 78402 | 78654 | ||
| 78403 | assert( pCtx!=0 ); | 78655 | assert( pCtx!=0 ); |
| 78404 | assert( (p->flags & EP_TokenOnly)==0 ); | 78656 | assert( (p->flags & EP_TokenOnly)==0 ); |
| 78657 | assert( ExprUseXList(p) ); | ||
| 78405 | pList = p->x.pList; | 78658 | pList = p->x.pList; |
| 78406 | if( pList ) nVal = pList->nExpr; | 78659 | if( pList ) nVal = pList->nExpr; |
| 78660 | assert( !ExprHasProperty(p, EP_IntValue) ); | ||
| 78407 | pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0); | 78661 | pFunc = sqlite3FindFunction(db, p->u.zToken, nVal, enc, 0); |
| 78408 | assert( pFunc ); | 78662 | assert( pFunc ); |
| 78409 | if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 | 78663 | if( (pFunc->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG))==0 |
| @@ -78479,7 +78733,7 @@ static int valueFromFunction( | |||
| 78479 | */ | 78733 | */ |
| 78480 | static int valueFromExpr( | 78734 | static int valueFromExpr( |
| 78481 | sqlite3 *db, /* The database connection */ | 78735 | sqlite3 *db, /* The database connection */ |
| 78482 | Expr *pExpr, /* The expression to evaluate */ | 78736 | const Expr *pExpr, /* The expression to evaluate */ |
| 78483 | u8 enc, /* Encoding to use */ | 78737 | u8 enc, /* Encoding to use */ |
| 78484 | u8 affinity, /* Affinity to use */ | 78738 | u8 affinity, /* Affinity to use */ |
| 78485 | sqlite3_value **ppVal, /* Write the new value here */ | 78739 | sqlite3_value **ppVal, /* Write the new value here */ |
| @@ -78507,7 +78761,9 @@ static int valueFromExpr( | |||
| 78507 | assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 ); | 78761 | assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 ); |
| 78508 | 78762 | ||
| 78509 | if( op==TK_CAST ){ | 78763 | if( op==TK_CAST ){ |
| 78510 | u8 aff = sqlite3AffinityType(pExpr->u.zToken,0); | 78764 | u8 aff; |
| 78765 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 78766 | aff = sqlite3AffinityType(pExpr->u.zToken,0); | ||
| 78511 | rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx); | 78767 | rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx); |
| 78512 | testcase( rc!=SQLITE_OK ); | 78768 | testcase( rc!=SQLITE_OK ); |
| 78513 | if( *ppVal ){ | 78769 | if( *ppVal ){ |
| @@ -78580,6 +78836,7 @@ static int valueFromExpr( | |||
| 78580 | #ifndef SQLITE_OMIT_BLOB_LITERAL | 78836 | #ifndef SQLITE_OMIT_BLOB_LITERAL |
| 78581 | else if( op==TK_BLOB ){ | 78837 | else if( op==TK_BLOB ){ |
| 78582 | int nVal; | 78838 | int nVal; |
| 78839 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 78583 | assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' ); | 78840 | assert( pExpr->u.zToken[0]=='x' || pExpr->u.zToken[0]=='X' ); |
| 78584 | assert( pExpr->u.zToken[1]=='\'' ); | 78841 | assert( pExpr->u.zToken[1]=='\'' ); |
| 78585 | pVal = valueNew(db, pCtx); | 78842 | pVal = valueNew(db, pCtx); |
| @@ -78597,6 +78854,7 @@ static int valueFromExpr( | |||
| 78597 | } | 78854 | } |
| 78598 | #endif | 78855 | #endif |
| 78599 | else if( op==TK_TRUEFALSE ){ | 78856 | else if( op==TK_TRUEFALSE ){ |
| 78857 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 78600 | pVal = valueNew(db, pCtx); | 78858 | pVal = valueNew(db, pCtx); |
| 78601 | if( pVal ){ | 78859 | if( pVal ){ |
| 78602 | pVal->flags = MEM_Int; | 78860 | pVal->flags = MEM_Int; |
| @@ -78634,7 +78892,7 @@ no_mem: | |||
| 78634 | */ | 78892 | */ |
| 78635 | SQLITE_PRIVATE int sqlite3ValueFromExpr( | 78893 | SQLITE_PRIVATE int sqlite3ValueFromExpr( |
| 78636 | sqlite3 *db, /* The database connection */ | 78894 | sqlite3 *db, /* The database connection */ |
| 78637 | Expr *pExpr, /* The expression to evaluate */ | 78895 | const Expr *pExpr, /* The expression to evaluate */ |
| 78638 | u8 enc, /* Encoding to use */ | 78896 | u8 enc, /* Encoding to use */ |
| 78639 | u8 affinity, /* Affinity to use */ | 78897 | u8 affinity, /* Affinity to use */ |
| 78640 | sqlite3_value **ppVal /* Write the new value here */ | 78898 | sqlite3_value **ppVal /* Write the new value here */ |
| @@ -79150,8 +79408,10 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){ | |||
| 79150 | if( p->nOpAlloc<=i ){ | 79408 | if( p->nOpAlloc<=i ){ |
| 79151 | return growOp3(p, op, p1, p2, p3); | 79409 | return growOp3(p, op, p1, p2, p3); |
| 79152 | } | 79410 | } |
| 79411 | assert( p->aOp!=0 ); | ||
| 79153 | p->nOp++; | 79412 | p->nOp++; |
| 79154 | pOp = &p->aOp[i]; | 79413 | pOp = &p->aOp[i]; |
| 79414 | assert( pOp!=0 ); | ||
| 79155 | pOp->opcode = (u8)op; | 79415 | pOp->opcode = (u8)op; |
| 79156 | pOp->p5 = 0; | 79416 | pOp->p5 = 0; |
| 79157 | pOp->p1 = p1; | 79417 | pOp->p1 = p1; |
| @@ -80394,7 +80654,7 @@ SQLITE_PRIVATE char *sqlite3VdbeDisplayComment( | |||
| 80394 | if( zOpName[nOpName+1] ){ | 80654 | if( zOpName[nOpName+1] ){ |
| 80395 | int seenCom = 0; | 80655 | int seenCom = 0; |
| 80396 | char c; | 80656 | char c; |
| 80397 | zSynopsis = zOpName += nOpName + 1; | 80657 | zSynopsis = zOpName + nOpName + 1; |
| 80398 | if( strncmp(zSynopsis,"IF ",3)==0 ){ | 80658 | if( strncmp(zSynopsis,"IF ",3)==0 ){ |
| 80399 | sqlite3_snprintf(sizeof(zAlt), zAlt, "if %s goto P2", zSynopsis+3); | 80659 | sqlite3_snprintf(sizeof(zAlt), zAlt, "if %s goto P2", zSynopsis+3); |
| 80400 | zSynopsis = zAlt; | 80660 | zSynopsis = zAlt; |
| @@ -80467,6 +80727,7 @@ static void displayP4Expr(StrAccum *p, Expr *pExpr){ | |||
| 80467 | const char *zOp = 0; | 80727 | const char *zOp = 0; |
| 80468 | switch( pExpr->op ){ | 80728 | switch( pExpr->op ){ |
| 80469 | case TK_STRING: | 80729 | case TK_STRING: |
| 80730 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 80470 | sqlite3_str_appendf(p, "%Q", pExpr->u.zToken); | 80731 | sqlite3_str_appendf(p, "%Q", pExpr->u.zToken); |
| 80471 | break; | 80732 | break; |
| 80472 | case TK_INTEGER: | 80733 | case TK_INTEGER: |
| @@ -80569,7 +80830,7 @@ SQLITE_PRIVATE char *sqlite3VdbeDisplayP4(sqlite3 *db, Op *pOp){ | |||
| 80569 | case P4_COLLSEQ: { | 80830 | case P4_COLLSEQ: { |
| 80570 | static const char *const encnames[] = {"?", "8", "16LE", "16BE"}; | 80831 | static const char *const encnames[] = {"?", "8", "16LE", "16BE"}; |
| 80571 | CollSeq *pColl = pOp->p4.pColl; | 80832 | CollSeq *pColl = pOp->p4.pColl; |
| 80572 | assert( pColl->enc>=0 && pColl->enc<4 ); | 80833 | assert( pColl->enc<4 ); |
| 80573 | sqlite3_str_appendf(&x, "%.18s-%s", pColl->zName, | 80834 | sqlite3_str_appendf(&x, "%.18s-%s", pColl->zName, |
| 80574 | encnames[pColl->enc]); | 80835 | encnames[pColl->enc]); |
| 80575 | break; | 80836 | break; |
| @@ -80813,8 +81074,8 @@ static void releaseMemArray(Mem *p, int N){ | |||
| 80813 | */ | 81074 | */ |
| 80814 | testcase( p->flags & MEM_Agg ); | 81075 | testcase( p->flags & MEM_Agg ); |
| 80815 | testcase( p->flags & MEM_Dyn ); | 81076 | testcase( p->flags & MEM_Dyn ); |
| 80816 | testcase( p->xDel==sqlite3VdbeFrameMemDel ); | ||
| 80817 | if( p->flags&(MEM_Agg|MEM_Dyn) ){ | 81077 | if( p->flags&(MEM_Agg|MEM_Dyn) ){ |
| 81078 | testcase( (p->flags & MEM_Dyn)!=0 && p->xDel==sqlite3VdbeFrameMemDel ); | ||
| 80818 | sqlite3VdbeMemRelease(p); | 81079 | sqlite3VdbeMemRelease(p); |
| 80819 | }else if( p->szMalloc ){ | 81080 | }else if( p->szMalloc ){ |
| 80820 | sqlite3DbFreeNN(db, p->zMalloc); | 81081 | sqlite3DbFreeNN(db, p->zMalloc); |
| @@ -81914,9 +82175,9 @@ SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *p, int deferred){ | |||
| 81914 | ** has made changes and is in autocommit mode, then commit those | 82175 | ** has made changes and is in autocommit mode, then commit those |
| 81915 | ** changes. If a rollback is needed, then do the rollback. | 82176 | ** changes. If a rollback is needed, then do the rollback. |
| 81916 | ** | 82177 | ** |
| 81917 | ** This routine is the only way to move the state of a VM from | 82178 | ** This routine is the only way to move the sqlite3eOpenState of a VM from |
| 81918 | ** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT. It is harmless to | 82179 | ** SQLITE_STATE_RUN to SQLITE_STATE_HALT. It is harmless to |
| 81919 | ** call this on a VM that is in the SQLITE_MAGIC_HALT state. | 82180 | ** call this on a VM that is in the SQLITE_STATE_HALT state. |
| 81920 | ** | 82181 | ** |
| 81921 | ** Return an error code. If the commit could not complete because of | 82182 | ** Return an error code. If the commit could not complete because of |
| 81922 | ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it | 82183 | ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it |
| @@ -81962,9 +82223,15 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){ | |||
| 81962 | sqlite3VdbeEnter(p); | 82223 | sqlite3VdbeEnter(p); |
| 81963 | 82224 | ||
| 81964 | /* Check for one of the special errors */ | 82225 | /* Check for one of the special errors */ |
| 81965 | mrc = p->rc & 0xff; | 82226 | if( p->rc ){ |
| 81966 | isSpecialError = mrc==SQLITE_NOMEM || mrc==SQLITE_IOERR | 82227 | mrc = p->rc & 0xff; |
| 81967 | || mrc==SQLITE_INTERRUPT || mrc==SQLITE_FULL; | 82228 | isSpecialError = mrc==SQLITE_NOMEM |
| 82229 | || mrc==SQLITE_IOERR | ||
| 82230 | || mrc==SQLITE_INTERRUPT | ||
| 82231 | || mrc==SQLITE_FULL; | ||
| 82232 | }else{ | ||
| 82233 | mrc = isSpecialError = 0; | ||
| 82234 | } | ||
| 81968 | if( isSpecialError ){ | 82235 | if( isSpecialError ){ |
| 81969 | /* If the query was read-only and the error code is SQLITE_INTERRUPT, | 82236 | /* If the query was read-only and the error code is SQLITE_INTERRUPT, |
| 81970 | ** no rollback is necessary. Otherwise, at least a savepoint | 82237 | ** no rollback is necessary. Otherwise, at least a savepoint |
| @@ -82016,6 +82283,9 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){ | |||
| 82016 | return SQLITE_ERROR; | 82283 | return SQLITE_ERROR; |
| 82017 | } | 82284 | } |
| 82018 | rc = SQLITE_CONSTRAINT_FOREIGNKEY; | 82285 | rc = SQLITE_CONSTRAINT_FOREIGNKEY; |
| 82286 | }else if( db->flags & SQLITE_CorruptRdOnly ){ | ||
| 82287 | rc = SQLITE_CORRUPT; | ||
| 82288 | db->flags &= ~SQLITE_CorruptRdOnly; | ||
| 82019 | }else{ | 82289 | }else{ |
| 82020 | /* The auto-commit flag is true, the vdbe program was successful | 82290 | /* The auto-commit flag is true, the vdbe program was successful |
| 82021 | ** or hit an 'OR FAIL' constraint and there are no deferred foreign | 82291 | ** or hit an 'OR FAIL' constraint and there are no deferred foreign |
| @@ -82410,7 +82680,7 @@ SQLITE_PRIVATE int SQLITE_NOINLINE sqlite3VdbeFinishMoveto(VdbeCursor *p){ | |||
| 82410 | assert( p->deferredMoveto ); | 82680 | assert( p->deferredMoveto ); |
| 82411 | assert( p->isTable ); | 82681 | assert( p->isTable ); |
| 82412 | assert( p->eCurType==CURTYPE_BTREE ); | 82682 | assert( p->eCurType==CURTYPE_BTREE ); |
| 82413 | rc = sqlite3BtreeMovetoUnpacked(p->uc.pCursor, 0, p->movetoTarget, 0, &res); | 82683 | rc = sqlite3BtreeTableMoveto(p->uc.pCursor, p->movetoTarget, 0, &res); |
| 82414 | if( rc ) return rc; | 82684 | if( rc ) return rc; |
| 82415 | if( res!=0 ) return SQLITE_CORRUPT_BKPT; | 82685 | if( res!=0 ) return SQLITE_CORRUPT_BKPT; |
| 82416 | #ifdef SQLITE_TEST | 82686 | #ifdef SQLITE_TEST |
| @@ -83194,7 +83464,7 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3BlobCompare(const Mem *pB1, const Mem | |||
| 83194 | ** number. Return negative, zero, or positive if the first (i64) is less than, | 83464 | ** number. Return negative, zero, or positive if the first (i64) is less than, |
| 83195 | ** equal to, or greater than the second (double). | 83465 | ** equal to, or greater than the second (double). |
| 83196 | */ | 83466 | */ |
| 83197 | static int sqlite3IntFloatCompare(i64 i, double r){ | 83467 | SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){ |
| 83198 | if( sizeof(LONGDOUBLE_TYPE)>8 ){ | 83468 | if( sizeof(LONGDOUBLE_TYPE)>8 ){ |
| 83199 | LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; | 83469 | LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i; |
| 83200 | testcase( x<r ); | 83470 | testcase( x<r ); |
| @@ -83918,7 +84188,7 @@ SQLITE_PRIVATE int sqlite3VdbeIdxKeyCompare( | |||
| 83918 | ** This routine sets the value to be returned by subsequent calls to | 84188 | ** This routine sets the value to be returned by subsequent calls to |
| 83919 | ** sqlite3_changes() on the database handle 'db'. | 84189 | ** sqlite3_changes() on the database handle 'db'. |
| 83920 | */ | 84190 | */ |
| 83921 | SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, int nChange){ | 84191 | SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, i64 nChange){ |
| 83922 | assert( sqlite3_mutex_held(db->mutex) ); | 84192 | assert( sqlite3_mutex_held(db->mutex) ); |
| 83923 | db->nChange = nChange; | 84193 | db->nChange = nChange; |
| 83924 | db->nTotalChange += nChange; | 84194 | db->nTotalChange += nChange; |
| @@ -84120,6 +84390,8 @@ SQLITE_PRIVATE void sqlite3VdbePreUpdateHook( | |||
| 84120 | } | 84390 | } |
| 84121 | } | 84391 | } |
| 84122 | 84392 | ||
| 84393 | assert( pCsr!=0 ); | ||
| 84394 | assert( pCsr->eCurType==CURTYPE_BTREE ); | ||
| 84123 | assert( pCsr->nField==pTab->nCol | 84395 | assert( pCsr->nField==pTab->nCol |
| 84124 | || (pCsr->nField==pTab->nCol+1 && op==SQLITE_DELETE && iReg==-1) | 84396 | || (pCsr->nField==pTab->nCol+1 && op==SQLITE_DELETE && iReg==-1) |
| 84125 | ); | 84397 | ); |
| @@ -84519,8 +84791,8 @@ SQLITE_API void sqlite3_value_free(sqlite3_value *pOld){ | |||
| 84519 | ** the function result. | 84791 | ** the function result. |
| 84520 | ** | 84792 | ** |
| 84521 | ** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the | 84793 | ** The setStrOrError() function calls sqlite3VdbeMemSetStr() to store the |
| 84522 | ** result as a string or blob but if the string or blob is too large, it | 84794 | ** result as a string or blob. Appropriate errors are set if the string/blob |
| 84523 | ** then sets the error code to SQLITE_TOOBIG | 84795 | ** is too big or if an OOM occurs. |
| 84524 | ** | 84796 | ** |
| 84525 | ** The invokeValueDestructor(P,X) routine invokes destructor function X() | 84797 | ** The invokeValueDestructor(P,X) routine invokes destructor function X() |
| 84526 | ** on value P is not going to be used and need to be destroyed. | 84798 | ** on value P is not going to be used and need to be destroyed. |
| @@ -84532,8 +84804,16 @@ static void setResultStrOrError( | |||
| 84532 | u8 enc, /* Encoding of z. 0 for BLOBs */ | 84804 | u8 enc, /* Encoding of z. 0 for BLOBs */ |
| 84533 | void (*xDel)(void*) /* Destructor function */ | 84805 | void (*xDel)(void*) /* Destructor function */ |
| 84534 | ){ | 84806 | ){ |
| 84535 | if( sqlite3VdbeMemSetStr(pCtx->pOut, z, n, enc, xDel)==SQLITE_TOOBIG ){ | 84807 | int rc = sqlite3VdbeMemSetStr(pCtx->pOut, z, n, enc, xDel); |
| 84536 | sqlite3_result_error_toobig(pCtx); | 84808 | if( rc ){ |
| 84809 | if( rc==SQLITE_TOOBIG ){ | ||
| 84810 | sqlite3_result_error_toobig(pCtx); | ||
| 84811 | }else{ | ||
| 84812 | /* The only errors possible from sqlite3VdbeMemSetStr are | ||
| 84813 | ** SQLITE_TOOBIG and SQLITE_NOMEM */ | ||
| 84814 | assert( rc==SQLITE_NOMEM ); | ||
| 84815 | sqlite3_result_error_nomem(pCtx); | ||
| 84816 | } | ||
| 84537 | } | 84817 | } |
| 84538 | } | 84818 | } |
| 84539 | static int invokeValueDestructor( | 84819 | static int invokeValueDestructor( |
| @@ -84690,8 +84970,12 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *pCtx, u64 n){ | |||
| 84690 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ | 84970 | if( n>(u64)pOut->db->aLimit[SQLITE_LIMIT_LENGTH] ){ |
| 84691 | return SQLITE_TOOBIG; | 84971 | return SQLITE_TOOBIG; |
| 84692 | } | 84972 | } |
| 84973 | #ifndef SQLITE_OMIT_INCRBLOB | ||
| 84693 | sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); | 84974 | sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); |
| 84694 | return SQLITE_OK; | 84975 | return SQLITE_OK; |
| 84976 | #else | ||
| 84977 | return sqlite3VdbeMemSetZeroBlob(pCtx->pOut, (int)n); | ||
| 84978 | #endif | ||
| 84695 | } | 84979 | } |
| 84696 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ | 84980 | SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ |
| 84697 | pCtx->isError = errCode ? errCode : -1; | 84981 | pCtx->isError = errCode ? errCode : -1; |
| @@ -85703,7 +85987,11 @@ SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){ | |||
| 85703 | Vdbe *p = (Vdbe *)pStmt; | 85987 | Vdbe *p = (Vdbe *)pStmt; |
| 85704 | rc = vdbeUnbind(p, i); | 85988 | rc = vdbeUnbind(p, i); |
| 85705 | if( rc==SQLITE_OK ){ | 85989 | if( rc==SQLITE_OK ){ |
| 85990 | #ifndef SQLITE_OMIT_INCRBLOB | ||
| 85706 | sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n); | 85991 | sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n); |
| 85992 | #else | ||
| 85993 | rc = sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n); | ||
| 85994 | #endif | ||
| 85707 | sqlite3_mutex_leave(p->db->mutex); | 85995 | sqlite3_mutex_leave(p->db->mutex); |
| 85708 | } | 85996 | } |
| 85709 | return rc; | 85997 | return rc; |
| @@ -85991,6 +86279,7 @@ SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppVa | |||
| 85991 | u32 nRec; | 86279 | u32 nRec; |
| 85992 | u8 *aRec; | 86280 | u8 *aRec; |
| 85993 | 86281 | ||
| 86282 | assert( p->pCsr->eCurType==CURTYPE_BTREE ); | ||
| 85994 | nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor); | 86283 | nRec = sqlite3BtreePayloadSize(p->pCsr->uc.pCursor); |
| 85995 | aRec = sqlite3DbMallocRaw(db, nRec); | 86284 | aRec = sqlite3DbMallocRaw(db, nRec); |
| 85996 | if( !aRec ) goto preupdate_old_out; | 86285 | if( !aRec ) goto preupdate_old_out; |
| @@ -86298,11 +86587,9 @@ SQLITE_PRIVATE char *sqlite3VdbeExpandSql( | |||
| 86298 | #ifndef SQLITE_OMIT_UTF16 | 86587 | #ifndef SQLITE_OMIT_UTF16 |
| 86299 | Mem utf8; /* Used to convert UTF16 into UTF8 for display */ | 86588 | Mem utf8; /* Used to convert UTF16 into UTF8 for display */ |
| 86300 | #endif | 86589 | #endif |
| 86301 | char zBase[100]; /* Initial working space */ | ||
| 86302 | 86590 | ||
| 86303 | db = p->db; | 86591 | db = p->db; |
| 86304 | sqlite3StrAccumInit(&out, 0, zBase, sizeof(zBase), | 86592 | sqlite3StrAccumInit(&out, 0, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]); |
| 86305 | db->aLimit[SQLITE_LIMIT_LENGTH]); | ||
| 86306 | if( db->nVdbeExec>1 ){ | 86593 | if( db->nVdbeExec>1 ){ |
| 86307 | while( *zRawSql ){ | 86594 | while( *zRawSql ){ |
| 86308 | const char *zStart = zRawSql; | 86595 | const char *zStart = zRawSql; |
| @@ -87035,96 +87322,7 @@ SQLITE_PRIVATE void sqlite3VdbeRegisterDump(Vdbe *v){ | |||
| 87035 | ** hwtime.h contains inline assembler code for implementing | 87322 | ** hwtime.h contains inline assembler code for implementing |
| 87036 | ** high-performance timing routines. | 87323 | ** high-performance timing routines. |
| 87037 | */ | 87324 | */ |
| 87038 | /************** Include hwtime.h in the middle of vdbe.c *********************/ | 87325 | /* #include "hwtime.h" */ |
| 87039 | /************** Begin file hwtime.h ******************************************/ | ||
| 87040 | /* | ||
| 87041 | ** 2008 May 27 | ||
| 87042 | ** | ||
| 87043 | ** The author disclaims copyright to this source code. In place of | ||
| 87044 | ** a legal notice, here is a blessing: | ||
| 87045 | ** | ||
| 87046 | ** May you do good and not evil. | ||
| 87047 | ** May you find forgiveness for yourself and forgive others. | ||
| 87048 | ** May you share freely, never taking more than you give. | ||
| 87049 | ** | ||
| 87050 | ****************************************************************************** | ||
| 87051 | ** | ||
| 87052 | ** This file contains inline asm code for retrieving "high-performance" | ||
| 87053 | ** counters for x86 and x86_64 class CPUs. | ||
| 87054 | */ | ||
| 87055 | #ifndef SQLITE_HWTIME_H | ||
| 87056 | #define SQLITE_HWTIME_H | ||
| 87057 | |||
| 87058 | /* | ||
| 87059 | ** The following routine only works on pentium-class (or newer) processors. | ||
| 87060 | ** It uses the RDTSC opcode to read the cycle count value out of the | ||
| 87061 | ** processor and returns that value. This can be used for high-res | ||
| 87062 | ** profiling. | ||
| 87063 | */ | ||
| 87064 | #if !defined(__STRICT_ANSI__) && \ | ||
| 87065 | (defined(__GNUC__) || defined(_MSC_VER)) && \ | ||
| 87066 | (defined(i386) || defined(__i386__) || defined(_M_IX86)) | ||
| 87067 | |||
| 87068 | #if defined(__GNUC__) | ||
| 87069 | |||
| 87070 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 87071 | unsigned int lo, hi; | ||
| 87072 | __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); | ||
| 87073 | return (sqlite_uint64)hi << 32 | lo; | ||
| 87074 | } | ||
| 87075 | |||
| 87076 | #elif defined(_MSC_VER) | ||
| 87077 | |||
| 87078 | __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){ | ||
| 87079 | __asm { | ||
| 87080 | rdtsc | ||
| 87081 | ret ; return value at EDX:EAX | ||
| 87082 | } | ||
| 87083 | } | ||
| 87084 | |||
| 87085 | #endif | ||
| 87086 | |||
| 87087 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) | ||
| 87088 | |||
| 87089 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 87090 | unsigned long val; | ||
| 87091 | __asm__ __volatile__ ("rdtsc" : "=A" (val)); | ||
| 87092 | return val; | ||
| 87093 | } | ||
| 87094 | |||
| 87095 | #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) | ||
| 87096 | |||
| 87097 | __inline__ sqlite_uint64 sqlite3Hwtime(void){ | ||
| 87098 | unsigned long long retval; | ||
| 87099 | unsigned long junk; | ||
| 87100 | __asm__ __volatile__ ("\n\ | ||
| 87101 | 1: mftbu %1\n\ | ||
| 87102 | mftb %L0\n\ | ||
| 87103 | mftbu %0\n\ | ||
| 87104 | cmpw %0,%1\n\ | ||
| 87105 | bne 1b" | ||
| 87106 | : "=r" (retval), "=r" (junk)); | ||
| 87107 | return retval; | ||
| 87108 | } | ||
| 87109 | |||
| 87110 | #else | ||
| 87111 | |||
| 87112 | /* | ||
| 87113 | ** asm() is needed for hardware timing support. Without asm(), | ||
| 87114 | ** disable the sqlite3Hwtime() routine. | ||
| 87115 | ** | ||
| 87116 | ** sqlite3Hwtime() is only used for some obscure debugging | ||
| 87117 | ** and analysis configurations, not in any deliverable, so this | ||
| 87118 | ** should not be a great loss. | ||
| 87119 | */ | ||
| 87120 | SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } | ||
| 87121 | |||
| 87122 | #endif | ||
| 87123 | |||
| 87124 | #endif /* !defined(SQLITE_HWTIME_H) */ | ||
| 87125 | |||
| 87126 | /************** End of hwtime.h **********************************************/ | ||
| 87127 | /************** Continuing where we left off in vdbe.c ***********************/ | ||
| 87128 | 87326 | ||
| 87129 | #endif | 87327 | #endif |
| 87130 | 87328 | ||
| @@ -87171,6 +87369,19 @@ static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){ | |||
| 87171 | } | 87369 | } |
| 87172 | } | 87370 | } |
| 87173 | 87371 | ||
| 87372 | /* | ||
| 87373 | ** Return the symbolic name for the data type of a pMem | ||
| 87374 | */ | ||
| 87375 | static const char *vdbeMemTypeName(Mem *pMem){ | ||
| 87376 | static const char *azTypes[] = { | ||
| 87377 | /* SQLITE_INTEGER */ "INT", | ||
| 87378 | /* SQLITE_FLOAT */ "REAL", | ||
| 87379 | /* SQLITE_TEXT */ "TEXT", | ||
| 87380 | /* SQLITE_BLOB */ "BLOB", | ||
| 87381 | /* SQLITE_NULL */ "NULL" | ||
| 87382 | }; | ||
| 87383 | return azTypes[sqlite3_value_type(pMem)-1]; | ||
| 87384 | } | ||
| 87174 | 87385 | ||
| 87175 | /* | 87386 | /* |
| 87176 | ** Execute as much of a VDBE program as we can. | 87387 | ** Execute as much of a VDBE program as we can. |
| @@ -89002,6 +89213,22 @@ case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */ | |||
| 89002 | break; | 89213 | break; |
| 89003 | } | 89214 | } |
| 89004 | 89215 | ||
| 89216 | /* Opcode: IsNullOrType P1 P2 P3 * * | ||
| 89217 | ** Synopsis: if typeof(r[P1]) IN (P3,5) goto P2 | ||
| 89218 | ** | ||
| 89219 | ** Jump to P2 if the value in register P1 is NULL or has a datatype P3. | ||
| 89220 | ** P3 is an integer which should be one of SQLITE_INTEGER, SQLITE_FLOAT, | ||
| 89221 | ** SQLITE_BLOB, SQLITE_NULL, or SQLITE_TEXT. | ||
| 89222 | */ | ||
| 89223 | case OP_IsNullOrType: { /* jump, in1 */ | ||
| 89224 | int doTheJump; | ||
| 89225 | pIn1 = &aMem[pOp->p1]; | ||
| 89226 | doTheJump = (pIn1->flags & MEM_Null)!=0 || sqlite3_value_type(pIn1)==pOp->p3; | ||
| 89227 | VdbeBranchTaken( doTheJump, 2); | ||
| 89228 | if( doTheJump ) goto jump_to_p2; | ||
| 89229 | break; | ||
| 89230 | } | ||
| 89231 | |||
| 89005 | /* Opcode: ZeroOrNull P1 P2 P3 * * | 89232 | /* Opcode: ZeroOrNull P1 P2 P3 * * |
| 89006 | ** Synopsis: r[P2] = 0 OR NULL | 89233 | ** Synopsis: r[P2] = 0 OR NULL |
| 89007 | ** | 89234 | ** |
| @@ -89370,6 +89597,108 @@ op_column_corrupt: | |||
| 89370 | } | 89597 | } |
| 89371 | } | 89598 | } |
| 89372 | 89599 | ||
| 89600 | /* Opcode: TypeCheck P1 P2 P3 P4 * | ||
| 89601 | ** Synopsis: typecheck(r[P1@P2]) | ||
| 89602 | ** | ||
| 89603 | ** Apply affinities to the range of P2 registers beginning with P1. | ||
| 89604 | ** Take the affinities from the Table object in P4. If any value | ||
| 89605 | ** cannot be coerced into the correct type, then raise an error. | ||
| 89606 | ** | ||
| 89607 | ** This opcode is similar to OP_Affinity except that this opcode | ||
| 89608 | ** forces the register type to the Table column type. This is used | ||
| 89609 | ** to implement "strict affinity". | ||
| 89610 | ** | ||
| 89611 | ** GENERATED ALWAYS AS ... STATIC columns are only checked if P3 | ||
| 89612 | ** is zero. When P3 is non-zero, no type checking occurs for | ||
| 89613 | ** static generated columns. Virtual columns are computed at query time | ||
| 89614 | ** and so they are never checked. | ||
| 89615 | ** | ||
| 89616 | ** Preconditions: | ||
| 89617 | ** | ||
| 89618 | ** <ul> | ||
| 89619 | ** <li> P2 should be the number of non-virtual columns in the | ||
| 89620 | ** table of P4. | ||
| 89621 | ** <li> Table P4 should be a STRICT table. | ||
| 89622 | ** </ul> | ||
| 89623 | ** | ||
| 89624 | ** If any precondition is false, an assertion fault occurs. | ||
| 89625 | */ | ||
| 89626 | case OP_TypeCheck: { | ||
| 89627 | Table *pTab; | ||
| 89628 | Column *aCol; | ||
| 89629 | int i; | ||
| 89630 | |||
| 89631 | assert( pOp->p4type==P4_TABLE ); | ||
| 89632 | pTab = pOp->p4.pTab; | ||
| 89633 | assert( pTab->tabFlags & TF_Strict ); | ||
| 89634 | assert( pTab->nNVCol==pOp->p2 ); | ||
| 89635 | aCol = pTab->aCol; | ||
| 89636 | pIn1 = &aMem[pOp->p1]; | ||
| 89637 | for(i=0; i<pTab->nCol; i++){ | ||
| 89638 | if( aCol[i].colFlags & COLFLAG_GENERATED ){ | ||
| 89639 | if( aCol[i].colFlags & COLFLAG_VIRTUAL ) continue; | ||
| 89640 | if( pOp->p3 ){ pIn1++; continue; } | ||
| 89641 | } | ||
| 89642 | assert( pIn1 < &aMem[pOp->p1+pOp->p2] ); | ||
| 89643 | applyAffinity(pIn1, aCol[i].affinity, encoding); | ||
| 89644 | if( (pIn1->flags & MEM_Null)==0 ){ | ||
| 89645 | switch( aCol[i].eCType ){ | ||
| 89646 | case COLTYPE_BLOB: { | ||
| 89647 | if( (pIn1->flags & MEM_Blob)==0 ) goto vdbe_type_error; | ||
| 89648 | break; | ||
| 89649 | } | ||
| 89650 | case COLTYPE_INTEGER: | ||
| 89651 | case COLTYPE_INT: { | ||
| 89652 | if( (pIn1->flags & MEM_Int)==0 ) goto vdbe_type_error; | ||
| 89653 | break; | ||
| 89654 | } | ||
| 89655 | case COLTYPE_TEXT: { | ||
| 89656 | if( (pIn1->flags & MEM_Str)==0 ) goto vdbe_type_error; | ||
| 89657 | break; | ||
| 89658 | } | ||
| 89659 | case COLTYPE_REAL: { | ||
| 89660 | if( pIn1->flags & MEM_Int ){ | ||
| 89661 | /* When applying REAL affinity, if the result is still an MEM_Int | ||
| 89662 | ** that will fit in 6 bytes, then change the type to MEM_IntReal | ||
| 89663 | ** so that we keep the high-resolution integer value but know that | ||
| 89664 | ** the type really wants to be REAL. */ | ||
| 89665 | testcase( pIn1->u.i==140737488355328LL ); | ||
| 89666 | testcase( pIn1->u.i==140737488355327LL ); | ||
| 89667 | testcase( pIn1->u.i==-140737488355328LL ); | ||
| 89668 | testcase( pIn1->u.i==-140737488355329LL ); | ||
| 89669 | if( pIn1->u.i<=140737488355327LL && pIn1->u.i>=-140737488355328LL){ | ||
| 89670 | pIn1->flags |= MEM_IntReal; | ||
| 89671 | pIn1->flags &= ~MEM_Int; | ||
| 89672 | }else{ | ||
| 89673 | pIn1->u.r = (double)pIn1->u.i; | ||
| 89674 | pIn1->flags |= MEM_Real; | ||
| 89675 | pIn1->flags &= ~MEM_Int; | ||
| 89676 | } | ||
| 89677 | }else if( (pIn1->flags & MEM_Real)==0 ){ | ||
| 89678 | goto vdbe_type_error; | ||
| 89679 | } | ||
| 89680 | break; | ||
| 89681 | } | ||
| 89682 | default: { | ||
| 89683 | /* COLTYPE_ANY. Accept anything. */ | ||
| 89684 | break; | ||
| 89685 | } | ||
| 89686 | } | ||
| 89687 | } | ||
| 89688 | REGISTER_TRACE((int)(pIn1-aMem), pIn1); | ||
| 89689 | pIn1++; | ||
| 89690 | } | ||
| 89691 | assert( pIn1 == &aMem[pOp->p1+pOp->p2] ); | ||
| 89692 | break; | ||
| 89693 | |||
| 89694 | vdbe_type_error: | ||
| 89695 | sqlite3VdbeError(p, "cannot store %s value in %s column %s.%s", | ||
| 89696 | vdbeMemTypeName(pIn1), sqlite3StdType[aCol[i].eCType-1], | ||
| 89697 | pTab->zName, aCol[i].zCnName); | ||
| 89698 | rc = SQLITE_CONSTRAINT_DATATYPE; | ||
| 89699 | goto abort_due_to_error; | ||
| 89700 | } | ||
| 89701 | |||
| 89373 | /* Opcode: Affinity P1 P2 * P4 * | 89702 | /* Opcode: Affinity P1 P2 * P4 * |
| 89374 | ** Synopsis: affinity(r[P1@P2]) | 89703 | ** Synopsis: affinity(r[P1@P2]) |
| 89375 | ** | 89704 | ** |
| @@ -90033,8 +90362,16 @@ case OP_Transaction: { | |||
| 90033 | assert( pOp->p2>=0 && pOp->p2<=2 ); | 90362 | assert( pOp->p2>=0 && pOp->p2<=2 ); |
| 90034 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); | 90363 | assert( pOp->p1>=0 && pOp->p1<db->nDb ); |
| 90035 | assert( DbMaskTest(p->btreeMask, pOp->p1) ); | 90364 | assert( DbMaskTest(p->btreeMask, pOp->p1) ); |
| 90036 | if( pOp->p2 && (db->flags & SQLITE_QueryOnly)!=0 ){ | 90365 | assert( rc==SQLITE_OK ); |
| 90037 | rc = SQLITE_READONLY; | 90366 | if( pOp->p2 && (db->flags & (SQLITE_QueryOnly|SQLITE_CorruptRdOnly))!=0 ){ |
| 90367 | if( db->flags & SQLITE_QueryOnly ){ | ||
| 90368 | /* Writes prohibited by the "PRAGMA query_only=TRUE" statement */ | ||
| 90369 | rc = SQLITE_READONLY; | ||
| 90370 | }else{ | ||
| 90371 | /* Writes prohibited due to a prior SQLITE_CORRUPT in the current | ||
| 90372 | ** transaction */ | ||
| 90373 | rc = SQLITE_CORRUPT; | ||
| 90374 | } | ||
| 90038 | goto abort_due_to_error; | 90375 | goto abort_due_to_error; |
| 90039 | } | 90376 | } |
| 90040 | pBt = db->aDb[pOp->p1].pBt; | 90377 | pBt = db->aDb[pOp->p1].pBt; |
| @@ -90076,7 +90413,8 @@ case OP_Transaction: { | |||
| 90076 | } | 90413 | } |
| 90077 | } | 90414 | } |
| 90078 | assert( pOp->p5==0 || pOp->p4type==P4_INT32 ); | 90415 | assert( pOp->p5==0 || pOp->p4type==P4_INT32 ); |
| 90079 | if( pOp->p5 | 90416 | if( rc==SQLITE_OK |
| 90417 | && pOp->p5 | ||
| 90080 | && (iMeta!=pOp->p3 | 90418 | && (iMeta!=pOp->p3 |
| 90081 | || db->aDb[pOp->p1].pSchema->iGeneration!=pOp->p4.i) | 90419 | || db->aDb[pOp->p1].pSchema->iGeneration!=pOp->p4.i) |
| 90082 | ){ | 90420 | ){ |
| @@ -90286,6 +90624,8 @@ case OP_ReopenIdx: { | |||
| 90286 | pCur = p->apCsr[pOp->p1]; | 90624 | pCur = p->apCsr[pOp->p1]; |
| 90287 | if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){ | 90625 | if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){ |
| 90288 | assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */ | 90626 | assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */ |
| 90627 | assert( pCur->eCurType==CURTYPE_BTREE ); | ||
| 90628 | sqlite3BtreeClearCursor(pCur->uc.pCursor); | ||
| 90289 | goto open_cursor_set_hints; | 90629 | goto open_cursor_set_hints; |
| 90290 | } | 90630 | } |
| 90291 | /* If the cursor is not currently open or is open on a different | 90631 | /* If the cursor is not currently open or is open on a different |
| @@ -90468,7 +90808,7 @@ case OP_OpenEphemeral: { | |||
| 90468 | aMem[pOp->p3].z = ""; | 90808 | aMem[pOp->p3].z = ""; |
| 90469 | } | 90809 | } |
| 90470 | pCx = p->apCsr[pOp->p1]; | 90810 | pCx = p->apCsr[pOp->p1]; |
| 90471 | if( pCx && !pCx->hasBeenDuped ){ | 90811 | if( pCx && !pCx->hasBeenDuped && ALWAYS(pOp->p2<=pCx->nField) ){ |
| 90472 | /* If the ephermeral table is already open and has no duplicates from | 90812 | /* If the ephermeral table is already open and has no duplicates from |
| 90473 | ** OP_OpenDup, then erase all existing content so that the table is | 90813 | ** OP_OpenDup, then erase all existing content so that the table is |
| 90474 | ** empty again, rather than creating a new table. */ | 90814 | ** empty again, rather than creating a new table. */ |
| @@ -90773,6 +91113,7 @@ case OP_SeekGT: { /* jump, in3, group */ | |||
| 90773 | /* If the P3 value could not be converted into an integer without | 91113 | /* If the P3 value could not be converted into an integer without |
| 90774 | ** loss of information, then special processing is required... */ | 91114 | ** loss of information, then special processing is required... */ |
| 90775 | if( (newType & (MEM_Int|MEM_IntReal))==0 ){ | 91115 | if( (newType & (MEM_Int|MEM_IntReal))==0 ){ |
| 91116 | int c; | ||
| 90776 | if( (newType & MEM_Real)==0 ){ | 91117 | if( (newType & MEM_Real)==0 ){ |
| 90777 | if( (newType & MEM_Null) || oc>=OP_SeekGE ){ | 91118 | if( (newType & MEM_Null) || oc>=OP_SeekGE ){ |
| 90778 | VdbeBranchTaken(1,2); | 91119 | VdbeBranchTaken(1,2); |
| @@ -90782,7 +91123,8 @@ case OP_SeekGT: { /* jump, in3, group */ | |||
| 90782 | if( rc!=SQLITE_OK ) goto abort_due_to_error; | 91123 | if( rc!=SQLITE_OK ) goto abort_due_to_error; |
| 90783 | goto seek_not_found; | 91124 | goto seek_not_found; |
| 90784 | } | 91125 | } |
| 90785 | }else | 91126 | } |
| 91127 | c = sqlite3IntFloatCompare(iKey, pIn3->u.r); | ||
| 90786 | 91128 | ||
| 90787 | /* If the approximation iKey is larger than the actual real search | 91129 | /* If the approximation iKey is larger than the actual real search |
| 90788 | ** term, substitute >= for > and < for <=. e.g. if the search term | 91130 | ** term, substitute >= for > and < for <=. e.g. if the search term |
| @@ -90791,7 +91133,7 @@ case OP_SeekGT: { /* jump, in3, group */ | |||
| 90791 | ** (x > 4.9) -> (x >= 5) | 91133 | ** (x > 4.9) -> (x >= 5) |
| 90792 | ** (x <= 4.9) -> (x < 5) | 91134 | ** (x <= 4.9) -> (x < 5) |
| 90793 | */ | 91135 | */ |
| 90794 | if( pIn3->u.r<(double)iKey ){ | 91136 | if( c>0 ){ |
| 90795 | assert( OP_SeekGE==(OP_SeekGT-1) ); | 91137 | assert( OP_SeekGE==(OP_SeekGT-1) ); |
| 90796 | assert( OP_SeekLT==(OP_SeekLE-1) ); | 91138 | assert( OP_SeekLT==(OP_SeekLE-1) ); |
| 90797 | assert( (OP_SeekLE & 0x0001)==(OP_SeekGT & 0x0001) ); | 91139 | assert( (OP_SeekLE & 0x0001)==(OP_SeekGT & 0x0001) ); |
| @@ -90800,14 +91142,14 @@ case OP_SeekGT: { /* jump, in3, group */ | |||
| 90800 | 91142 | ||
| 90801 | /* If the approximation iKey is smaller than the actual real search | 91143 | /* If the approximation iKey is smaller than the actual real search |
| 90802 | ** term, substitute <= for < and > for >=. */ | 91144 | ** term, substitute <= for < and > for >=. */ |
| 90803 | else if( pIn3->u.r>(double)iKey ){ | 91145 | else if( c<0 ){ |
| 90804 | assert( OP_SeekLE==(OP_SeekLT+1) ); | 91146 | assert( OP_SeekLE==(OP_SeekLT+1) ); |
| 90805 | assert( OP_SeekGT==(OP_SeekGE+1) ); | 91147 | assert( OP_SeekGT==(OP_SeekGE+1) ); |
| 90806 | assert( (OP_SeekLT & 0x0001)==(OP_SeekGE & 0x0001) ); | 91148 | assert( (OP_SeekLT & 0x0001)==(OP_SeekGE & 0x0001) ); |
| 90807 | if( (oc & 0x0001)==(OP_SeekLT & 0x0001) ) oc++; | 91149 | if( (oc & 0x0001)==(OP_SeekLT & 0x0001) ) oc++; |
| 90808 | } | 91150 | } |
| 90809 | } | 91151 | } |
| 90810 | rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)iKey, 0, &res); | 91152 | rc = sqlite3BtreeTableMoveto(pC->uc.pCursor, (u64)iKey, 0, &res); |
| 90811 | pC->movetoTarget = iKey; /* Used by OP_Delete */ | 91153 | pC->movetoTarget = iKey; /* Used by OP_Delete */ |
| 90812 | if( rc!=SQLITE_OK ){ | 91154 | if( rc!=SQLITE_OK ){ |
| 90813 | goto abort_due_to_error; | 91155 | goto abort_due_to_error; |
| @@ -90854,7 +91196,7 @@ case OP_SeekGT: { /* jump, in3, group */ | |||
| 90854 | { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); } | 91196 | { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); } |
| 90855 | #endif | 91197 | #endif |
| 90856 | r.eqSeen = 0; | 91198 | r.eqSeen = 0; |
| 90857 | rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, &r, 0, 0, &res); | 91199 | rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, &r, &res); |
| 90858 | if( rc!=SQLITE_OK ){ | 91200 | if( rc!=SQLITE_OK ){ |
| 90859 | goto abort_due_to_error; | 91201 | goto abort_due_to_error; |
| 90860 | } | 91202 | } |
| @@ -91273,7 +91615,7 @@ case OP_Found: { /* jump, in3 */ | |||
| 91273 | } | 91615 | } |
| 91274 | } | 91616 | } |
| 91275 | } | 91617 | } |
| 91276 | rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res); | 91618 | rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, pIdxKey, &res); |
| 91277 | if( pFree ) sqlite3DbFreeNN(db, pFree); | 91619 | if( pFree ) sqlite3DbFreeNN(db, pFree); |
| 91278 | if( rc!=SQLITE_OK ){ | 91620 | if( rc!=SQLITE_OK ){ |
| 91279 | goto abort_due_to_error; | 91621 | goto abort_due_to_error; |
| @@ -91382,7 +91724,7 @@ notExistsWithKey: | |||
| 91382 | pCrsr = pC->uc.pCursor; | 91724 | pCrsr = pC->uc.pCursor; |
| 91383 | assert( pCrsr!=0 ); | 91725 | assert( pCrsr!=0 ); |
| 91384 | res = 0; | 91726 | res = 0; |
| 91385 | rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res); | 91727 | rc = sqlite3BtreeTableMoveto(pCrsr, iKey, 0, &res); |
| 91386 | assert( rc==SQLITE_OK || res==0 ); | 91728 | assert( rc==SQLITE_OK || res==0 ); |
| 91387 | pC->movetoTarget = iKey; /* Used by OP_Delete */ | 91729 | pC->movetoTarget = iKey; /* Used by OP_Delete */ |
| 91388 | pC->nullRow = 0; | 91730 | pC->nullRow = 0; |
| @@ -91539,7 +91881,7 @@ case OP_NewRowid: { /* out2 */ | |||
| 91539 | do{ | 91881 | do{ |
| 91540 | sqlite3_randomness(sizeof(v), &v); | 91882 | sqlite3_randomness(sizeof(v), &v); |
| 91541 | v &= (MAX_ROWID>>1); v++; /* Ensure that v is greater than zero */ | 91883 | v &= (MAX_ROWID>>1); v++; /* Ensure that v is greater than zero */ |
| 91542 | }while( ((rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)v, | 91884 | }while( ((rc = sqlite3BtreeTableMoveto(pC->uc.pCursor, (u64)v, |
| 91543 | 0, &res))==SQLITE_OK) | 91885 | 0, &res))==SQLITE_OK) |
| 91544 | && (res==0) | 91886 | && (res==0) |
| 91545 | && (++cnt<100)); | 91887 | && (++cnt<100)); |
| @@ -91629,7 +91971,7 @@ case OP_Insert: { | |||
| 91629 | assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) ); | 91971 | assert( (pOp->p5 & OPFLAG_ISNOOP) || HasRowid(pTab) ); |
| 91630 | }else{ | 91972 | }else{ |
| 91631 | pTab = 0; | 91973 | pTab = 0; |
| 91632 | zDb = 0; /* Not needed. Silence a compiler warning. */ | 91974 | zDb = 0; |
| 91633 | } | 91975 | } |
| 91634 | 91976 | ||
| 91635 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | 91977 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| @@ -91782,13 +92124,14 @@ case OP_Delete: { | |||
| 91782 | pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor); | 92124 | pC->movetoTarget = sqlite3BtreeIntegerKey(pC->uc.pCursor); |
| 91783 | } | 92125 | } |
| 91784 | }else{ | 92126 | }else{ |
| 91785 | zDb = 0; /* Not needed. Silence a compiler warning. */ | 92127 | zDb = 0; |
| 91786 | pTab = 0; /* Not needed. Silence a compiler warning. */ | 92128 | pTab = 0; |
| 91787 | } | 92129 | } |
| 91788 | 92130 | ||
| 91789 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK | 92131 | #ifdef SQLITE_ENABLE_PREUPDATE_HOOK |
| 91790 | /* Invoke the pre-update-hook if required. */ | 92132 | /* Invoke the pre-update-hook if required. */ |
| 91791 | if( db->xPreUpdateCallback && pOp->p4.pTab ){ | 92133 | assert( db->xPreUpdateCallback==0 || pTab==pOp->p4.pTab ); |
| 92134 | if( db->xPreUpdateCallback && pTab ){ | ||
| 91792 | assert( !(opflags & OPFLAG_ISUPDATE) | 92135 | assert( !(opflags & OPFLAG_ISUPDATE) |
| 91793 | || HasRowid(pTab)==0 | 92136 | || HasRowid(pTab)==0 |
| 91794 | || (aMem[pOp->p3].flags & MEM_Int) | 92137 | || (aMem[pOp->p3].flags & MEM_Int) |
| @@ -91829,7 +92172,7 @@ case OP_Delete: { | |||
| 91829 | /* Invoke the update-hook if required. */ | 92172 | /* Invoke the update-hook if required. */ |
| 91830 | if( opflags & OPFLAG_NCHANGE ){ | 92173 | if( opflags & OPFLAG_NCHANGE ){ |
| 91831 | p->nChange++; | 92174 | p->nChange++; |
| 91832 | if( db->xUpdateCallback && HasRowid(pTab) ){ | 92175 | if( db->xUpdateCallback && ALWAYS(pTab!=0) && HasRowid(pTab) ){ |
| 91833 | db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName, | 92176 | db->xUpdateCallback(db->pUpdateArg, SQLITE_DELETE, zDb, pTab->zName, |
| 91834 | pC->movetoTarget); | 92177 | pC->movetoTarget); |
| 91835 | assert( pC->iDb>=0 ); | 92178 | assert( pC->iDb>=0 ); |
| @@ -92416,7 +92759,8 @@ case OP_SorterInsert: { /* in2 */ | |||
| 92416 | ** an UPDATE or DELETE statement and the index entry to be updated | 92759 | ** an UPDATE or DELETE statement and the index entry to be updated |
| 92417 | ** or deleted is not found. For some uses of IdxDelete | 92760 | ** or deleted is not found. For some uses of IdxDelete |
| 92418 | ** (example: the EXCEPT operator) it does not matter that no matching | 92761 | ** (example: the EXCEPT operator) it does not matter that no matching |
| 92419 | ** entry is found. For those cases, P5 is zero. | 92762 | ** entry is found. For those cases, P5 is zero. Also, do not raise |
| 92763 | ** this (self-correcting and non-critical) error if in writable_schema mode. | ||
| 92420 | */ | 92764 | */ |
| 92421 | case OP_IdxDelete: { | 92765 | case OP_IdxDelete: { |
| 92422 | VdbeCursor *pC; | 92766 | VdbeCursor *pC; |
| @@ -92437,12 +92781,12 @@ case OP_IdxDelete: { | |||
| 92437 | r.nField = (u16)pOp->p3; | 92781 | r.nField = (u16)pOp->p3; |
| 92438 | r.default_rc = 0; | 92782 | r.default_rc = 0; |
| 92439 | r.aMem = &aMem[pOp->p2]; | 92783 | r.aMem = &aMem[pOp->p2]; |
| 92440 | rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res); | 92784 | rc = sqlite3BtreeIndexMoveto(pCrsr, &r, &res); |
| 92441 | if( rc ) goto abort_due_to_error; | 92785 | if( rc ) goto abort_due_to_error; |
| 92442 | if( res==0 ){ | 92786 | if( res==0 ){ |
| 92443 | rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE); | 92787 | rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE); |
| 92444 | if( rc ) goto abort_due_to_error; | 92788 | if( rc ) goto abort_due_to_error; |
| 92445 | }else if( pOp->p5 ){ | 92789 | }else if( pOp->p5 && !sqlite3WritableSchema(db) ){ |
| 92446 | rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption"); | 92790 | rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption"); |
| 92447 | goto abort_due_to_error; | 92791 | goto abort_due_to_error; |
| 92448 | } | 92792 | } |
| @@ -92750,7 +93094,7 @@ case OP_Destroy: { /* out2 */ | |||
| 92750 | ** See also: Destroy | 93094 | ** See also: Destroy |
| 92751 | */ | 93095 | */ |
| 92752 | case OP_Clear: { | 93096 | case OP_Clear: { |
| 92753 | int nChange; | 93097 | i64 nChange; |
| 92754 | 93098 | ||
| 92755 | sqlite3VdbeIncrWriteCounter(p, 0); | 93099 | sqlite3VdbeIncrWriteCounter(p, 0); |
| 92756 | nChange = 0; | 93100 | nChange = 0; |
| @@ -92876,7 +93220,7 @@ case OP_ParseSchema: { | |||
| 92876 | }else | 93220 | }else |
| 92877 | #endif | 93221 | #endif |
| 92878 | { | 93222 | { |
| 92879 | zSchema = DFLT_SCHEMA_TABLE; | 93223 | zSchema = LEGACY_SCHEMA_TABLE; |
| 92880 | initData.db = db; | 93224 | initData.db = db; |
| 92881 | initData.iDb = iDb; | 93225 | initData.iDb = iDb; |
| 92882 | initData.pzErrMsg = &p->zErrMsg; | 93226 | initData.pzErrMsg = &p->zErrMsg; |
| @@ -94096,6 +94440,7 @@ case OP_VFilter: { /* jump */ | |||
| 94096 | pCur = p->apCsr[pOp->p1]; | 94440 | pCur = p->apCsr[pOp->p1]; |
| 94097 | assert( memIsValid(pQuery) ); | 94441 | assert( memIsValid(pQuery) ); |
| 94098 | REGISTER_TRACE(pOp->p3, pQuery); | 94442 | REGISTER_TRACE(pOp->p3, pQuery); |
| 94443 | assert( pCur!=0 ); | ||
| 94099 | assert( pCur->eCurType==CURTYPE_VTAB ); | 94444 | assert( pCur->eCurType==CURTYPE_VTAB ); |
| 94100 | pVCur = pCur->uc.pVCur; | 94445 | pVCur = pCur->uc.pVCur; |
| 94101 | pVtab = pVCur->pVtab; | 94446 | pVtab = pVCur->pVtab; |
| @@ -94107,7 +94452,6 @@ case OP_VFilter: { /* jump */ | |||
| 94107 | iQuery = (int)pQuery->u.i; | 94452 | iQuery = (int)pQuery->u.i; |
| 94108 | 94453 | ||
| 94109 | /* Invoke the xFilter method */ | 94454 | /* Invoke the xFilter method */ |
| 94110 | res = 0; | ||
| 94111 | apArg = p->apArg; | 94455 | apArg = p->apArg; |
| 94112 | for(i = 0; i<nArg; i++){ | 94456 | for(i = 0; i<nArg; i++){ |
| 94113 | apArg[i] = &pArgc[i+1]; | 94457 | apArg[i] = &pArgc[i+1]; |
| @@ -94145,6 +94489,7 @@ case OP_VColumn: { | |||
| 94145 | sqlite3_context sContext; | 94489 | sqlite3_context sContext; |
| 94146 | 94490 | ||
| 94147 | VdbeCursor *pCur = p->apCsr[pOp->p1]; | 94491 | VdbeCursor *pCur = p->apCsr[pOp->p1]; |
| 94492 | assert( pCur!=0 ); | ||
| 94148 | assert( pCur->eCurType==CURTYPE_VTAB ); | 94493 | assert( pCur->eCurType==CURTYPE_VTAB ); |
| 94149 | assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); | 94494 | assert( pOp->p3>0 && pOp->p3<=(p->nMem+1 - p->nCursor) ); |
| 94150 | pDest = &aMem[pOp->p3]; | 94495 | pDest = &aMem[pOp->p3]; |
| @@ -94197,8 +94542,8 @@ case OP_VNext: { /* jump */ | |||
| 94197 | int res; | 94542 | int res; |
| 94198 | VdbeCursor *pCur; | 94543 | VdbeCursor *pCur; |
| 94199 | 94544 | ||
| 94200 | res = 0; | ||
| 94201 | pCur = p->apCsr[pOp->p1]; | 94545 | pCur = p->apCsr[pOp->p1]; |
| 94546 | assert( pCur!=0 ); | ||
| 94202 | assert( pCur->eCurType==CURTYPE_VTAB ); | 94547 | assert( pCur->eCurType==CURTYPE_VTAB ); |
| 94203 | if( pCur->nullRow ){ | 94548 | if( pCur->nullRow ){ |
| 94204 | break; | 94549 | break; |
| @@ -94294,7 +94639,7 @@ case OP_VUpdate: { | |||
| 94294 | const sqlite3_module *pModule; | 94639 | const sqlite3_module *pModule; |
| 94295 | int nArg; | 94640 | int nArg; |
| 94296 | int i; | 94641 | int i; |
| 94297 | sqlite_int64 rowid; | 94642 | sqlite_int64 rowid = 0; |
| 94298 | Mem **apArg; | 94643 | Mem **apArg; |
| 94299 | Mem *pX; | 94644 | Mem *pX; |
| 94300 | 94645 | ||
| @@ -94739,6 +95084,18 @@ abort_due_to_error: | |||
| 94739 | rc = SQLITE_CORRUPT_BKPT; | 95084 | rc = SQLITE_CORRUPT_BKPT; |
| 94740 | } | 95085 | } |
| 94741 | assert( rc ); | 95086 | assert( rc ); |
| 95087 | #ifdef SQLITE_DEBUG | ||
| 95088 | if( db->flags & SQLITE_VdbeTrace ){ | ||
| 95089 | const char *zTrace = p->zSql; | ||
| 95090 | if( zTrace==0 ){ | ||
| 95091 | if( aOp[0].opcode==OP_Trace ){ | ||
| 95092 | zTrace = aOp[0].p4.z; | ||
| 95093 | } | ||
| 95094 | if( zTrace==0 ) zTrace = "???"; | ||
| 95095 | } | ||
| 95096 | printf("ABORT-due-to-error (rc=%d): %s\n", rc, zTrace); | ||
| 95097 | } | ||
| 95098 | #endif | ||
| 94742 | if( p->zErrMsg==0 && rc!=SQLITE_IOERR_NOMEM ){ | 95099 | if( p->zErrMsg==0 && rc!=SQLITE_IOERR_NOMEM ){ |
| 94743 | sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc)); | 95100 | sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc)); |
| 94744 | } | 95101 | } |
| @@ -94749,6 +95106,9 @@ abort_due_to_error: | |||
| 94749 | (int)(pOp - aOp), p->zSql, p->zErrMsg); | 95106 | (int)(pOp - aOp), p->zSql, p->zErrMsg); |
| 94750 | sqlite3VdbeHalt(p); | 95107 | sqlite3VdbeHalt(p); |
| 94751 | if( rc==SQLITE_IOERR_NOMEM ) sqlite3OomFault(db); | 95108 | if( rc==SQLITE_IOERR_NOMEM ) sqlite3OomFault(db); |
| 95109 | if( rc==SQLITE_CORRUPT && db->autoCommit==0 ){ | ||
| 95110 | db->flags |= SQLITE_CorruptRdOnly; | ||
| 95111 | } | ||
| 94752 | rc = SQLITE_ERROR; | 95112 | rc = SQLITE_ERROR; |
| 94753 | if( resetSchemaOnFault>0 ){ | 95113 | if( resetSchemaOnFault>0 ){ |
| 94754 | sqlite3ResetOneSchema(db, resetSchemaOnFault-1); | 95114 | sqlite3ResetOneSchema(db, resetSchemaOnFault-1); |
| @@ -94880,7 +95240,10 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){ | |||
| 94880 | } | 95240 | } |
| 94881 | if( rc==SQLITE_ROW ){ | 95241 | if( rc==SQLITE_ROW ){ |
| 94882 | VdbeCursor *pC = v->apCsr[0]; | 95242 | VdbeCursor *pC = v->apCsr[0]; |
| 94883 | u32 type = pC->nHdrParsed>p->iCol ? pC->aType[p->iCol] : 0; | 95243 | u32 type; |
| 95244 | assert( pC!=0 ); | ||
| 95245 | assert( pC->eCurType==CURTYPE_BTREE ); | ||
| 95246 | type = pC->nHdrParsed>p->iCol ? pC->aType[p->iCol] : 0; | ||
| 94884 | testcase( pC->nHdrParsed==p->iCol ); | 95247 | testcase( pC->nHdrParsed==p->iCol ); |
| 94885 | testcase( pC->nHdrParsed==p->iCol+1 ); | 95248 | testcase( pC->nHdrParsed==p->iCol+1 ); |
| 94886 | if( type<12 ){ | 95249 | if( type<12 ){ |
| @@ -94972,7 +95335,7 @@ SQLITE_API int sqlite3_blob_open( | |||
| 94972 | sqlite3ErrorMsg(&sParse, "cannot open table without rowid: %s", zTable); | 95335 | sqlite3ErrorMsg(&sParse, "cannot open table without rowid: %s", zTable); |
| 94973 | } | 95336 | } |
| 94974 | #ifndef SQLITE_OMIT_VIEW | 95337 | #ifndef SQLITE_OMIT_VIEW |
| 94975 | if( pTab && pTab->pSelect ){ | 95338 | if( pTab && IsView(pTab) ){ |
| 94976 | pTab = 0; | 95339 | pTab = 0; |
| 94977 | sqlite3ErrorMsg(&sParse, "cannot open view: %s", zTable); | 95340 | sqlite3ErrorMsg(&sParse, "cannot open view: %s", zTable); |
| 94978 | } | 95341 | } |
| @@ -94992,7 +95355,7 @@ SQLITE_API int sqlite3_blob_open( | |||
| 94992 | 95355 | ||
| 94993 | /* Now search pTab for the exact column. */ | 95356 | /* Now search pTab for the exact column. */ |
| 94994 | for(iCol=0; iCol<pTab->nCol; iCol++) { | 95357 | for(iCol=0; iCol<pTab->nCol; iCol++) { |
| 94995 | if( sqlite3StrICmp(pTab->aCol[iCol].zName, zColumn)==0 ){ | 95358 | if( sqlite3StrICmp(pTab->aCol[iCol].zCnName, zColumn)==0 ){ |
| 94996 | break; | 95359 | break; |
| 94997 | } | 95360 | } |
| 94998 | } | 95361 | } |
| @@ -95017,7 +95380,8 @@ SQLITE_API int sqlite3_blob_open( | |||
| 95017 | ** key columns must be indexed. The check below will pick up this | 95380 | ** key columns must be indexed. The check below will pick up this |
| 95018 | ** case. */ | 95381 | ** case. */ |
| 95019 | FKey *pFKey; | 95382 | FKey *pFKey; |
| 95020 | for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){ | 95383 | assert( IsOrdinaryTable(pTab) ); |
| 95384 | for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){ | ||
| 95021 | int j; | 95385 | int j; |
| 95022 | for(j=0; j<pFKey->nCol; j++){ | 95386 | for(j=0; j<pFKey->nCol; j++){ |
| 95023 | if( pFKey->aCol[j].iFrom==iCol ){ | 95387 | if( pFKey->aCol[j].iFrom==iCol ){ |
| @@ -95224,6 +95588,8 @@ static int blobReadWrite( | |||
| 95224 | */ | 95588 | */ |
| 95225 | sqlite3_int64 iKey; | 95589 | sqlite3_int64 iKey; |
| 95226 | iKey = sqlite3BtreeIntegerKey(p->pCsr); | 95590 | iKey = sqlite3BtreeIntegerKey(p->pCsr); |
| 95591 | assert( v->apCsr[0]!=0 ); | ||
| 95592 | assert( v->apCsr[0]->eCurType==CURTYPE_BTREE ); | ||
| 95227 | sqlite3VdbePreUpdateHook( | 95593 | sqlite3VdbePreUpdateHook( |
| 95228 | v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1, p->iCol | 95594 | v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1, p->iCol |
| 95229 | ); | 95595 | ); |
| @@ -96606,7 +96972,7 @@ static void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nByte){ | |||
| 96606 | sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_CHUNK_SIZE, &chunksize); | 96972 | sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_CHUNK_SIZE, &chunksize); |
| 96607 | sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_SIZE_HINT, &nByte); | 96973 | sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_SIZE_HINT, &nByte); |
| 96608 | sqlite3OsFetch(pFd, 0, (int)nByte, &p); | 96974 | sqlite3OsFetch(pFd, 0, (int)nByte, &p); |
| 96609 | sqlite3OsUnfetch(pFd, 0, p); | 96975 | if( p ) sqlite3OsUnfetch(pFd, 0, p); |
| 96610 | } | 96976 | } |
| 96611 | } | 96977 | } |
| 96612 | #else | 96978 | #else |
| @@ -97324,6 +97690,7 @@ static int vdbeIncrMergerNew( | |||
| 97324 | vdbeMergeEngineFree(pMerger); | 97690 | vdbeMergeEngineFree(pMerger); |
| 97325 | rc = SQLITE_NOMEM_BKPT; | 97691 | rc = SQLITE_NOMEM_BKPT; |
| 97326 | } | 97692 | } |
| 97693 | assert( *ppOut!=0 || rc!=SQLITE_OK ); | ||
| 97327 | return rc; | 97694 | return rc; |
| 97328 | } | 97695 | } |
| 97329 | 97696 | ||
| @@ -99025,7 +99392,7 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){ | |||
| 99025 | assert( !ExprHasProperty(pExpr, EP_WinFunc) ); | 99392 | assert( !ExprHasProperty(pExpr, EP_WinFunc) ); |
| 99026 | pExpr = pExpr->pRight; | 99393 | pExpr = pExpr->pRight; |
| 99027 | continue; | 99394 | continue; |
| 99028 | }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 99395 | }else if( ExprUseXSelect(pExpr) ){ |
| 99029 | assert( !ExprHasProperty(pExpr, EP_WinFunc) ); | 99396 | assert( !ExprHasProperty(pExpr, EP_WinFunc) ); |
| 99030 | if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; | 99397 | if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort; |
| 99031 | }else{ | 99398 | }else{ |
| @@ -99297,6 +99664,7 @@ static void resolveAlias( | |||
| 99297 | }else{ | 99664 | }else{ |
| 99298 | incrAggFunctionDepth(pDup, nSubquery); | 99665 | incrAggFunctionDepth(pDup, nSubquery); |
| 99299 | if( pExpr->op==TK_COLLATE ){ | 99666 | if( pExpr->op==TK_COLLATE ){ |
| 99667 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 99300 | pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); | 99668 | pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken); |
| 99301 | } | 99669 | } |
| 99302 | 99670 | ||
| @@ -99400,6 +99768,7 @@ SQLITE_PRIVATE Bitmask sqlite3ExprColUsed(Expr *pExpr){ | |||
| 99400 | Table *pExTab; | 99768 | Table *pExTab; |
| 99401 | 99769 | ||
| 99402 | n = pExpr->iColumn; | 99770 | n = pExpr->iColumn; |
| 99771 | assert( ExprUseYTab(pExpr) ); | ||
| 99403 | pExTab = pExpr->y.pTab; | 99772 | pExTab = pExpr->y.pTab; |
| 99404 | assert( pExTab!=0 ); | 99773 | assert( pExTab!=0 ); |
| 99405 | if( (pExTab->tabFlags & TF_HasGenerated)!=0 | 99774 | if( (pExTab->tabFlags & TF_HasGenerated)!=0 |
| @@ -99513,7 +99882,7 @@ static int lookupName( | |||
| 99513 | u8 hCol; | 99882 | u8 hCol; |
| 99514 | pTab = pItem->pTab; | 99883 | pTab = pItem->pTab; |
| 99515 | assert( pTab!=0 && pTab->zName!=0 ); | 99884 | assert( pTab!=0 && pTab->zName!=0 ); |
| 99516 | assert( pTab->nCol>0 ); | 99885 | assert( pTab->nCol>0 || pParse->nErr ); |
| 99517 | if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){ | 99886 | if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){ |
| 99518 | int hit = 0; | 99887 | int hit = 0; |
| 99519 | pEList = pItem->pSelect->pEList; | 99888 | pEList = pItem->pSelect->pEList; |
| @@ -99537,16 +99906,16 @@ static int lookupName( | |||
| 99537 | if( sqlite3StrICmp(zTabName, zTab)!=0 ){ | 99906 | if( sqlite3StrICmp(zTabName, zTab)!=0 ){ |
| 99538 | continue; | 99907 | continue; |
| 99539 | } | 99908 | } |
| 99909 | assert( ExprUseYTab(pExpr) ); | ||
| 99540 | if( IN_RENAME_OBJECT && pItem->zAlias ){ | 99910 | if( IN_RENAME_OBJECT && pItem->zAlias ){ |
| 99541 | sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab); | 99911 | sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab); |
| 99542 | } | 99912 | } |
| 99543 | } | 99913 | } |
| 99544 | if( 0==(cntTab++) ){ | ||
| 99545 | pMatch = pItem; | ||
| 99546 | } | ||
| 99547 | hCol = sqlite3StrIHash(zCol); | 99914 | hCol = sqlite3StrIHash(zCol); |
| 99548 | for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){ | 99915 | for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){ |
| 99549 | if( pCol->hName==hCol && sqlite3StrICmp(pCol->zName, zCol)==0 ){ | 99916 | if( pCol->hName==hCol |
| 99917 | && sqlite3StrICmp(pCol->zCnName, zCol)==0 | ||
| 99918 | ){ | ||
| 99550 | /* If there has been exactly one prior match and this match | 99919 | /* If there has been exactly one prior match and this match |
| 99551 | ** is for the right-hand table of a NATURAL JOIN or is in a | 99920 | ** is for the right-hand table of a NATURAL JOIN or is in a |
| 99552 | ** USING clause, then skip this match. | 99921 | ** USING clause, then skip this match. |
| @@ -99562,9 +99931,14 @@ static int lookupName( | |||
| 99562 | break; | 99931 | break; |
| 99563 | } | 99932 | } |
| 99564 | } | 99933 | } |
| 99934 | if( 0==cnt && VisibleRowid(pTab) ){ | ||
| 99935 | cntTab++; | ||
| 99936 | pMatch = pItem; | ||
| 99937 | } | ||
| 99565 | } | 99938 | } |
| 99566 | if( pMatch ){ | 99939 | if( pMatch ){ |
| 99567 | pExpr->iTable = pMatch->iCursor; | 99940 | pExpr->iTable = pMatch->iCursor; |
| 99941 | assert( ExprUseYTab(pExpr) ); | ||
| 99568 | pExpr->y.pTab = pMatch->pTab; | 99942 | pExpr->y.pTab = pMatch->pTab; |
| 99569 | /* RIGHT JOIN not (yet) supported */ | 99943 | /* RIGHT JOIN not (yet) supported */ |
| 99570 | assert( (pMatch->fg.jointype & JT_RIGHT)==0 ); | 99944 | assert( (pMatch->fg.jointype & JT_RIGHT)==0 ); |
| @@ -99619,7 +99993,9 @@ static int lookupName( | |||
| 99619 | pSchema = pTab->pSchema; | 99993 | pSchema = pTab->pSchema; |
| 99620 | cntTab++; | 99994 | cntTab++; |
| 99621 | for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){ | 99995 | for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){ |
| 99622 | if( pCol->hName==hCol && sqlite3StrICmp(pCol->zName, zCol)==0 ){ | 99996 | if( pCol->hName==hCol |
| 99997 | && sqlite3StrICmp(pCol->zCnName, zCol)==0 | ||
| 99998 | ){ | ||
| 99623 | if( iCol==pTab->iPKey ){ | 99999 | if( iCol==pTab->iPKey ){ |
| 99624 | iCol = -1; | 100000 | iCol = -1; |
| 99625 | } | 100001 | } |
| @@ -99636,6 +100012,7 @@ static int lookupName( | |||
| 99636 | #ifndef SQLITE_OMIT_UPSERT | 100012 | #ifndef SQLITE_OMIT_UPSERT |
| 99637 | if( pExpr->iTable==EXCLUDED_TABLE_NUMBER ){ | 100013 | if( pExpr->iTable==EXCLUDED_TABLE_NUMBER ){ |
| 99638 | testcase( iCol==(-1) ); | 100014 | testcase( iCol==(-1) ); |
| 100015 | assert( ExprUseYTab(pExpr) ); | ||
| 99639 | if( IN_RENAME_OBJECT ){ | 100016 | if( IN_RENAME_OBJECT ){ |
| 99640 | pExpr->iColumn = iCol; | 100017 | pExpr->iColumn = iCol; |
| 99641 | pExpr->y.pTab = pTab; | 100018 | pExpr->y.pTab = pTab; |
| @@ -99648,6 +100025,7 @@ static int lookupName( | |||
| 99648 | }else | 100025 | }else |
| 99649 | #endif /* SQLITE_OMIT_UPSERT */ | 100026 | #endif /* SQLITE_OMIT_UPSERT */ |
| 99650 | { | 100027 | { |
| 100028 | assert( ExprUseYTab(pExpr) ); | ||
| 99651 | pExpr->y.pTab = pTab; | 100029 | pExpr->y.pTab = pTab; |
| 99652 | if( pParse->bReturning ){ | 100030 | if( pParse->bReturning ){ |
| 99653 | eNewExprOp = TK_REGISTER; | 100031 | eNewExprOp = TK_REGISTER; |
| @@ -99684,7 +100062,7 @@ static int lookupName( | |||
| 99684 | && pMatch | 100062 | && pMatch |
| 99685 | && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 | 100063 | && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0 |
| 99686 | && sqlite3IsRowid(zCol) | 100064 | && sqlite3IsRowid(zCol) |
| 99687 | && VisibleRowid(pMatch->pTab) | 100065 | && ALWAYS(VisibleRowid(pMatch->pTab)) |
| 99688 | ){ | 100066 | ){ |
| 99689 | cnt = 1; | 100067 | cnt = 1; |
| 99690 | pExpr->iColumn = -1; | 100068 | pExpr->iColumn = -1; |
| @@ -99722,8 +100100,8 @@ static int lookupName( | |||
| 99722 | ){ | 100100 | ){ |
| 99723 | Expr *pOrig; | 100101 | Expr *pOrig; |
| 99724 | assert( pExpr->pLeft==0 && pExpr->pRight==0 ); | 100102 | assert( pExpr->pLeft==0 && pExpr->pRight==0 ); |
| 99725 | assert( pExpr->x.pList==0 ); | 100103 | assert( ExprUseXList(pExpr)==0 || pExpr->x.pList==0 ); |
| 99726 | assert( pExpr->x.pSelect==0 ); | 100104 | assert( ExprUseXSelect(pExpr)==0 || pExpr->x.pSelect==0 ); |
| 99727 | pOrig = pEList->a[j].pExpr; | 100105 | pOrig = pEList->a[j].pExpr; |
| 99728 | if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){ | 100106 | if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){ |
| 99729 | sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); | 100107 | sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); |
| @@ -99795,7 +100173,7 @@ static int lookupName( | |||
| 99795 | sqlite3VdbeAddDblquoteStr(db, pParse->pVdbe, zCol); | 100173 | sqlite3VdbeAddDblquoteStr(db, pParse->pVdbe, zCol); |
| 99796 | #endif | 100174 | #endif |
| 99797 | pExpr->op = TK_STRING; | 100175 | pExpr->op = TK_STRING; |
| 99798 | pExpr->y.pTab = 0; | 100176 | memset(&pExpr->y, 0, sizeof(pExpr->y)); |
| 99799 | return WRC_Prune; | 100177 | return WRC_Prune; |
| 99800 | } | 100178 | } |
| 99801 | if( sqlite3ExprIdToTrueFalse(pExpr) ){ | 100179 | if( sqlite3ExprIdToTrueFalse(pExpr) ){ |
| @@ -99881,7 +100259,9 @@ SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *db, SrcList *pSrc, int iSr | |||
| 99881 | Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0); | 100259 | Expr *p = sqlite3ExprAlloc(db, TK_COLUMN, 0, 0); |
| 99882 | if( p ){ | 100260 | if( p ){ |
| 99883 | SrcItem *pItem = &pSrc->a[iSrc]; | 100261 | SrcItem *pItem = &pSrc->a[iSrc]; |
| 99884 | Table *pTab = p->y.pTab = pItem->pTab; | 100262 | Table *pTab; |
| 100263 | assert( ExprUseYTab(p) ); | ||
| 100264 | pTab = p->y.pTab = pItem->pTab; | ||
| 99885 | p->iTable = pItem->iCursor; | 100265 | p->iTable = pItem->iCursor; |
| 99886 | if( p->y.pTab->iPKey==iCol ){ | 100266 | if( p->y.pTab->iPKey==iCol ){ |
| 99887 | p->iColumn = -1; | 100267 | p->iColumn = -1; |
| @@ -99948,6 +100328,7 @@ static void notValidImpl( | |||
| 99948 | static int exprProbability(Expr *p){ | 100328 | static int exprProbability(Expr *p){ |
| 99949 | double r = -1.0; | 100329 | double r = -1.0; |
| 99950 | if( p->op!=TK_FLOAT ) return -1; | 100330 | if( p->op!=TK_FLOAT ) return -1; |
| 100331 | assert( !ExprHasProperty(p, EP_IntValue) ); | ||
| 99951 | sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8); | 100332 | sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8); |
| 99952 | assert( r>=0.0 ); | 100333 | assert( r>=0.0 ); |
| 99953 | if( r>1.0 ) return -1; | 100334 | if( r>1.0 ) return -1; |
| @@ -99996,6 +100377,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 99996 | assert( pSrcList && pSrcList->nSrc>=1 ); | 100377 | assert( pSrcList && pSrcList->nSrc>=1 ); |
| 99997 | pItem = pSrcList->a; | 100378 | pItem = pSrcList->a; |
| 99998 | pExpr->op = TK_COLUMN; | 100379 | pExpr->op = TK_COLUMN; |
| 100380 | assert( ExprUseYTab(pExpr) ); | ||
| 99999 | pExpr->y.pTab = pItem->pTab; | 100381 | pExpr->y.pTab = pItem->pTab; |
| 100000 | pExpr->iTable = pItem->iCursor; | 100382 | pExpr->iTable = pItem->iCursor; |
| 100001 | pExpr->iColumn--; | 100383 | pExpr->iColumn--; |
| @@ -100027,6 +100409,8 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 100027 | } | 100409 | } |
| 100028 | sqlite3WalkExpr(pWalker, pExpr->pLeft); | 100410 | sqlite3WalkExpr(pWalker, pExpr->pLeft); |
| 100029 | if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){ | 100411 | if( 0==sqlite3ExprCanBeNull(pExpr->pLeft) && !IN_RENAME_OBJECT ){ |
| 100412 | testcase( ExprHasProperty(pExpr, EP_FromJoin) ); | ||
| 100413 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 100030 | if( pExpr->op==TK_NOTNULL ){ | 100414 | if( pExpr->op==TK_NOTNULL ){ |
| 100031 | pExpr->u.zToken = "true"; | 100415 | pExpr->u.zToken = "true"; |
| 100032 | ExprSetProperty(pExpr, EP_IsTrue); | 100416 | ExprSetProperty(pExpr, EP_IsTrue); |
| @@ -100062,6 +100446,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 100062 | if( pExpr->op==TK_ID ){ | 100446 | if( pExpr->op==TK_ID ){ |
| 100063 | zDb = 0; | 100447 | zDb = 0; |
| 100064 | zTable = 0; | 100448 | zTable = 0; |
| 100449 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 100065 | zColumn = pExpr->u.zToken; | 100450 | zColumn = pExpr->u.zToken; |
| 100066 | }else{ | 100451 | }else{ |
| 100067 | Expr *pLeft = pExpr->pLeft; | 100452 | Expr *pLeft = pExpr->pLeft; |
| @@ -100074,12 +100459,15 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 100074 | zDb = 0; | 100459 | zDb = 0; |
| 100075 | }else{ | 100460 | }else{ |
| 100076 | assert( pRight->op==TK_DOT ); | 100461 | assert( pRight->op==TK_DOT ); |
| 100462 | assert( !ExprHasProperty(pRight, EP_IntValue) ); | ||
| 100077 | zDb = pLeft->u.zToken; | 100463 | zDb = pLeft->u.zToken; |
| 100078 | pLeft = pRight->pLeft; | 100464 | pLeft = pRight->pLeft; |
| 100079 | pRight = pRight->pRight; | 100465 | pRight = pRight->pRight; |
| 100080 | } | 100466 | } |
| 100467 | assert( ExprUseUToken(pLeft) && ExprUseUToken(pRight) ); | ||
| 100081 | zTable = pLeft->u.zToken; | 100468 | zTable = pLeft->u.zToken; |
| 100082 | zColumn = pRight->u.zToken; | 100469 | zColumn = pRight->u.zToken; |
| 100470 | assert( ExprUseYTab(pExpr) ); | ||
| 100083 | if( IN_RENAME_OBJECT ){ | 100471 | if( IN_RENAME_OBJECT ){ |
| 100084 | sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight); | 100472 | sqlite3RenameTokenRemap(pParse, (void*)pExpr, (void*)pRight); |
| 100085 | sqlite3RenameTokenRemap(pParse, (void*)&pExpr->y.pTab, (void*)pLeft); | 100473 | sqlite3RenameTokenRemap(pParse, (void*)&pExpr->y.pTab, (void*)pLeft); |
| @@ -100104,7 +100492,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 100104 | #ifndef SQLITE_OMIT_WINDOWFUNC | 100492 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 100105 | Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0); | 100493 | Window *pWin = (IsWindowFunc(pExpr) ? pExpr->y.pWin : 0); |
| 100106 | #endif | 100494 | #endif |
| 100107 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | 100495 | assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) ); |
| 100108 | zId = pExpr->u.zToken; | 100496 | zId = pExpr->u.zToken; |
| 100109 | nId = sqlite3Strlen30(zId); | 100497 | nId = sqlite3Strlen30(zId); |
| 100110 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); | 100498 | pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); |
| @@ -100268,7 +100656,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 100268 | #ifndef SQLITE_OMIT_WINDOWFUNC | 100656 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 100269 | if( pWin ){ | 100657 | if( pWin ){ |
| 100270 | Select *pSel = pNC->pWinSelect; | 100658 | Select *pSel = pNC->pWinSelect; |
| 100271 | assert( pWin==pExpr->y.pWin ); | 100659 | assert( pWin==0 || (ExprUseYWin(pExpr) && pWin==pExpr->y.pWin) ); |
| 100272 | if( IN_RENAME_OBJECT==0 ){ | 100660 | if( IN_RENAME_OBJECT==0 ){ |
| 100273 | sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef); | 100661 | sqlite3WindowUpdate(pParse, pSel ? pSel->pWinDefn : 0, pWin, pDef); |
| 100274 | if( pParse->db->mallocFailed ) break; | 100662 | if( pParse->db->mallocFailed ) break; |
| @@ -100281,7 +100669,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 100281 | }else | 100669 | }else |
| 100282 | #endif /* SQLITE_OMIT_WINDOWFUNC */ | 100670 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 100283 | { | 100671 | { |
| 100284 | NameContext *pNC2 = pNC; | 100672 | NameContext *pNC2; /* For looping up thru outer contexts */ |
| 100285 | pExpr->op = TK_AGG_FUNCTION; | 100673 | pExpr->op = TK_AGG_FUNCTION; |
| 100286 | pExpr->op2 = 0; | 100674 | pExpr->op2 = 0; |
| 100287 | #ifndef SQLITE_OMIT_WINDOWFUNC | 100675 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| @@ -100289,16 +100677,22 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 100289 | sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter); | 100677 | sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter); |
| 100290 | } | 100678 | } |
| 100291 | #endif | 100679 | #endif |
| 100292 | while( pNC2 && !sqlite3FunctionUsesThisSrc(pExpr, pNC2->pSrcList) ){ | 100680 | pNC2 = pNC; |
| 100681 | while( pNC2 | ||
| 100682 | && sqlite3ReferencesSrcList(pParse, pExpr, pNC2->pSrcList)==0 | ||
| 100683 | ){ | ||
| 100293 | pExpr->op2++; | 100684 | pExpr->op2++; |
| 100294 | pNC2 = pNC2->pNext; | 100685 | pNC2 = pNC2->pNext; |
| 100295 | } | 100686 | } |
| 100296 | assert( pDef!=0 || IN_RENAME_OBJECT ); | 100687 | assert( pDef!=0 || IN_RENAME_OBJECT ); |
| 100297 | if( pNC2 && pDef ){ | 100688 | if( pNC2 && pDef ){ |
| 100298 | assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg ); | 100689 | assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg ); |
| 100690 | assert( SQLITE_FUNC_ANYORDER==NC_OrderAgg ); | ||
| 100299 | testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 ); | 100691 | testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 ); |
| 100300 | pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX); | 100692 | testcase( (pDef->funcFlags & SQLITE_FUNC_ANYORDER)!=0 ); |
| 100301 | 100693 | pNC2->ncFlags |= NC_HasAgg | |
| 100694 | | ((pDef->funcFlags^SQLITE_FUNC_ANYORDER) | ||
| 100695 | & (SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER)); | ||
| 100302 | } | 100696 | } |
| 100303 | } | 100697 | } |
| 100304 | pNC->ncFlags |= savedAllowFlags; | 100698 | pNC->ncFlags |= savedAllowFlags; |
| @@ -100314,15 +100708,17 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 100314 | #endif | 100708 | #endif |
| 100315 | case TK_IN: { | 100709 | case TK_IN: { |
| 100316 | testcase( pExpr->op==TK_IN ); | 100710 | testcase( pExpr->op==TK_IN ); |
| 100317 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 100711 | if( ExprUseXSelect(pExpr) ){ |
| 100318 | int nRef = pNC->nRef; | 100712 | int nRef = pNC->nRef; |
| 100319 | testcase( pNC->ncFlags & NC_IsCheck ); | 100713 | testcase( pNC->ncFlags & NC_IsCheck ); |
| 100320 | testcase( pNC->ncFlags & NC_PartIdx ); | 100714 | testcase( pNC->ncFlags & NC_PartIdx ); |
| 100321 | testcase( pNC->ncFlags & NC_IdxExpr ); | 100715 | testcase( pNC->ncFlags & NC_IdxExpr ); |
| 100322 | testcase( pNC->ncFlags & NC_GenCol ); | 100716 | testcase( pNC->ncFlags & NC_GenCol ); |
| 100323 | sqlite3ResolveNotValid(pParse, pNC, "subqueries", | 100717 | if( pNC->ncFlags & NC_SelfRef ){ |
| 100324 | NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr); | 100718 | notValidImpl(pParse, pNC, "subqueries", pExpr); |
| 100325 | sqlite3WalkSelect(pWalker, pExpr->x.pSelect); | 100719 | }else{ |
| 100720 | sqlite3WalkSelect(pWalker, pExpr->x.pSelect); | ||
| 100721 | } | ||
| 100326 | assert( pNC->nRef>=nRef ); | 100722 | assert( pNC->nRef>=nRef ); |
| 100327 | if( nRef!=pNC->nRef ){ | 100723 | if( nRef!=pNC->nRef ){ |
| 100328 | ExprSetProperty(pExpr, EP_VarSelect); | 100724 | ExprSetProperty(pExpr, EP_VarSelect); |
| @@ -100369,6 +100765,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ | |||
| 100369 | assert( pExpr->pLeft!=0 ); | 100765 | assert( pExpr->pLeft!=0 ); |
| 100370 | nLeft = sqlite3ExprVectorSize(pExpr->pLeft); | 100766 | nLeft = sqlite3ExprVectorSize(pExpr->pLeft); |
| 100371 | if( pExpr->op==TK_BETWEEN ){ | 100767 | if( pExpr->op==TK_BETWEEN ){ |
| 100768 | assert( ExprUseXList(pExpr) ); | ||
| 100372 | nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[0].pExpr); | 100769 | nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[0].pExpr); |
| 100373 | if( nRight==nLeft ){ | 100770 | if( nRight==nLeft ){ |
| 100374 | nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[1].pExpr); | 100771 | nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[1].pExpr); |
| @@ -100417,7 +100814,9 @@ static int resolveAsName( | |||
| 100417 | UNUSED_PARAMETER(pParse); | 100814 | UNUSED_PARAMETER(pParse); |
| 100418 | 100815 | ||
| 100419 | if( pE->op==TK_ID ){ | 100816 | if( pE->op==TK_ID ){ |
| 100420 | char *zCol = pE->u.zToken; | 100817 | const char *zCol; |
| 100818 | assert( !ExprHasProperty(pE, EP_IntValue) ); | ||
| 100819 | zCol = pE->u.zToken; | ||
| 100421 | for(i=0; i<pEList->nExpr; i++){ | 100820 | for(i=0; i<pEList->nExpr; i++){ |
| 100422 | if( pEList->a[i].eEName==ENAME_NAME | 100821 | if( pEList->a[i].eEName==ENAME_NAME |
| 100423 | && sqlite3_stricmp(pEList->a[i].zEName, zCol)==0 | 100822 | && sqlite3_stricmp(pEList->a[i].zEName, zCol)==0 |
| @@ -100841,7 +101240,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 100841 | p->pOrderBy = 0; | 101240 | p->pOrderBy = 0; |
| 100842 | } | 101241 | } |
| 100843 | 101242 | ||
| 100844 | /* Recursively resolve names in all subqueries | 101243 | /* Recursively resolve names in all subqueries in the FROM clause |
| 100845 | */ | 101244 | */ |
| 100846 | for(i=0; i<p->pSrc->nSrc; i++){ | 101245 | for(i=0; i<p->pSrc->nSrc; i++){ |
| 100847 | SrcItem *pItem = &p->pSrc->a[i]; | 101246 | SrcItem *pItem = &p->pSrc->a[i]; |
| @@ -100885,7 +101284,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){ | |||
| 100885 | pGroupBy = p->pGroupBy; | 101284 | pGroupBy = p->pGroupBy; |
| 100886 | if( pGroupBy || (sNC.ncFlags & NC_HasAgg)!=0 ){ | 101285 | if( pGroupBy || (sNC.ncFlags & NC_HasAgg)!=0 ){ |
| 100887 | assert( NC_MinMaxAgg==SF_MinMaxAgg ); | 101286 | assert( NC_MinMaxAgg==SF_MinMaxAgg ); |
| 100888 | p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg); | 101287 | assert( NC_OrderAgg==SF_OrderByReqd ); |
| 101288 | p->selFlags |= SF_Aggregate | (sNC.ncFlags&(NC_MinMaxAgg|NC_OrderAgg)); | ||
| 100889 | }else{ | 101289 | }else{ |
| 100890 | sNC.ncFlags &= ~NC_AllowAgg; | 101290 | sNC.ncFlags &= ~NC_AllowAgg; |
| 100891 | } | 101291 | } |
| @@ -101068,8 +101468,8 @@ SQLITE_PRIVATE int sqlite3ResolveExprNames( | |||
| 101068 | Walker w; | 101468 | Walker w; |
| 101069 | 101469 | ||
| 101070 | if( pExpr==0 ) return SQLITE_OK; | 101470 | if( pExpr==0 ) return SQLITE_OK; |
| 101071 | savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin); | 101471 | savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg); |
| 101072 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); | 101472 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg); |
| 101073 | w.pParse = pNC->pParse; | 101473 | w.pParse = pNC->pParse; |
| 101074 | w.xExprCallback = resolveExprStep; | 101474 | w.xExprCallback = resolveExprStep; |
| 101075 | w.xSelectCallback = (pNC->ncFlags & NC_NoSelect) ? 0 : resolveSelectStep; | 101475 | w.xSelectCallback = (pNC->ncFlags & NC_NoSelect) ? 0 : resolveSelectStep; |
| @@ -101112,8 +101512,8 @@ SQLITE_PRIVATE int sqlite3ResolveExprListNames( | |||
| 101112 | w.xSelectCallback = resolveSelectStep; | 101512 | w.xSelectCallback = resolveSelectStep; |
| 101113 | w.xSelectCallback2 = 0; | 101513 | w.xSelectCallback2 = 0; |
| 101114 | w.u.pNC = pNC; | 101514 | w.u.pNC = pNC; |
| 101115 | savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin); | 101515 | savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg); |
| 101116 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); | 101516 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg); |
| 101117 | for(i=0; i<pList->nExpr; i++){ | 101517 | for(i=0; i<pList->nExpr; i++){ |
| 101118 | Expr *pExpr = pList->a[i].pExpr; | 101518 | Expr *pExpr = pList->a[i].pExpr; |
| 101119 | if( pExpr==0 ) continue; | 101519 | if( pExpr==0 ) continue; |
| @@ -101131,10 +101531,11 @@ SQLITE_PRIVATE int sqlite3ResolveExprListNames( | |||
| 101131 | assert( EP_Win==NC_HasWin ); | 101531 | assert( EP_Win==NC_HasWin ); |
| 101132 | testcase( pNC->ncFlags & NC_HasAgg ); | 101532 | testcase( pNC->ncFlags & NC_HasAgg ); |
| 101133 | testcase( pNC->ncFlags & NC_HasWin ); | 101533 | testcase( pNC->ncFlags & NC_HasWin ); |
| 101134 | if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin) ){ | 101534 | if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg) ){ |
| 101135 | ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) ); | 101535 | ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) ); |
| 101136 | savedHasAgg |= pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin); | 101536 | savedHasAgg |= pNC->ncFlags & |
| 101137 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin); | 101537 | (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg); |
| 101538 | pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg); | ||
| 101138 | } | 101539 | } |
| 101139 | if( w.pParse->nErr>0 ) return WRC_Abort; | 101540 | if( w.pParse->nErr>0 ) return WRC_Abort; |
| 101140 | } | 101541 | } |
| @@ -101248,9 +101649,9 @@ static int exprCodeVector(Parse *pParse, Expr *p, int *piToFree); | |||
| 101248 | /* | 101649 | /* |
| 101249 | ** Return the affinity character for a single column of a table. | 101650 | ** Return the affinity character for a single column of a table. |
| 101250 | */ | 101651 | */ |
| 101251 | SQLITE_PRIVATE char sqlite3TableColumnAffinity(Table *pTab, int iCol){ | 101652 | SQLITE_PRIVATE char sqlite3TableColumnAffinity(const Table *pTab, int iCol){ |
| 101252 | assert( iCol<pTab->nCol ); | 101653 | if( iCol<0 || NEVER(iCol>=pTab->nCol) ) return SQLITE_AFF_INTEGER; |
| 101253 | return iCol>=0 ? pTab->aCol[iCol].affinity : SQLITE_AFF_INTEGER; | 101654 | return pTab->aCol[iCol].affinity; |
| 101254 | } | 101655 | } |
| 101255 | 101656 | ||
| 101256 | /* | 101657 | /* |
| @@ -101280,11 +101681,14 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr){ | |||
| 101280 | } | 101681 | } |
| 101281 | op = pExpr->op; | 101682 | op = pExpr->op; |
| 101282 | if( op==TK_REGISTER ) op = pExpr->op2; | 101683 | if( op==TK_REGISTER ) op = pExpr->op2; |
| 101283 | if( (op==TK_COLUMN || op==TK_AGG_COLUMN) && pExpr->y.pTab ){ | 101684 | if( op==TK_COLUMN || op==TK_AGG_COLUMN ){ |
| 101284 | return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); | 101685 | assert( ExprUseYTab(pExpr) ); |
| 101686 | if( pExpr->y.pTab ){ | ||
| 101687 | return sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); | ||
| 101688 | } | ||
| 101285 | } | 101689 | } |
| 101286 | if( op==TK_SELECT ){ | 101690 | if( op==TK_SELECT ){ |
| 101287 | assert( pExpr->flags&EP_xIsSelect ); | 101691 | assert( ExprUseXSelect(pExpr) ); |
| 101288 | assert( pExpr->x.pSelect!=0 ); | 101692 | assert( pExpr->x.pSelect!=0 ); |
| 101289 | assert( pExpr->x.pSelect->pEList!=0 ); | 101693 | assert( pExpr->x.pSelect->pEList!=0 ); |
| 101290 | assert( pExpr->x.pSelect->pEList->a[0].pExpr!=0 ); | 101694 | assert( pExpr->x.pSelect->pEList->a[0].pExpr!=0 ); |
| @@ -101297,12 +101701,15 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr){ | |||
| 101297 | } | 101701 | } |
| 101298 | #endif | 101702 | #endif |
| 101299 | if( op==TK_SELECT_COLUMN ){ | 101703 | if( op==TK_SELECT_COLUMN ){ |
| 101300 | assert( pExpr->pLeft->flags&EP_xIsSelect ); | 101704 | assert( pExpr->pLeft!=0 && ExprUseXSelect(pExpr->pLeft) ); |
| 101705 | assert( pExpr->iColumn < pExpr->iTable ); | ||
| 101706 | assert( pExpr->iTable==pExpr->pLeft->x.pSelect->pEList->nExpr ); | ||
| 101301 | return sqlite3ExprAffinity( | 101707 | return sqlite3ExprAffinity( |
| 101302 | pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr | 101708 | pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr |
| 101303 | ); | 101709 | ); |
| 101304 | } | 101710 | } |
| 101305 | if( op==TK_VECTOR ){ | 101711 | if( op==TK_VECTOR ){ |
| 101712 | assert( ExprUseXList(pExpr) ); | ||
| 101306 | return sqlite3ExprAffinity(pExpr->x.pList->a[0].pExpr); | 101713 | return sqlite3ExprAffinity(pExpr->x.pList->a[0].pExpr); |
| 101307 | } | 101714 | } |
| 101308 | return pExpr->affExpr; | 101715 | return pExpr->affExpr; |
| @@ -101317,7 +101724,7 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(const Expr *pExpr){ | |||
| 101317 | ** and the pExpr parameter is returned unchanged. | 101724 | ** and the pExpr parameter is returned unchanged. |
| 101318 | */ | 101725 | */ |
| 101319 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken( | 101726 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken( |
| 101320 | Parse *pParse, /* Parsing context */ | 101727 | const Parse *pParse, /* Parsing context */ |
| 101321 | Expr *pExpr, /* Add the "COLLATE" clause to this expression */ | 101728 | Expr *pExpr, /* Add the "COLLATE" clause to this expression */ |
| 101322 | const Token *pCollName, /* Name of collating sequence */ | 101729 | const Token *pCollName, /* Name of collating sequence */ |
| 101323 | int dequote /* True to dequote pCollName */ | 101730 | int dequote /* True to dequote pCollName */ |
| @@ -101332,7 +101739,11 @@ SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken( | |||
| 101332 | } | 101739 | } |
| 101333 | return pExpr; | 101740 | return pExpr; |
| 101334 | } | 101741 | } |
| 101335 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, const char *zC){ | 101742 | SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString( |
| 101743 | const Parse *pParse, /* Parsing context */ | ||
| 101744 | Expr *pExpr, /* Add the "COLLATE" clause to this expression */ | ||
| 101745 | const char *zC /* The collating sequence name */ | ||
| 101746 | ){ | ||
| 101336 | Token s; | 101747 | Token s; |
| 101337 | assert( zC!=0 ); | 101748 | assert( zC!=0 ); |
| 101338 | sqlite3TokenInit(&s, (char*)zC); | 101749 | sqlite3TokenInit(&s, (char*)zC); |
| @@ -101358,7 +101769,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr *pExpr){ | |||
| 101358 | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr *pExpr){ | 101769 | SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr *pExpr){ |
| 101359 | while( pExpr && ExprHasProperty(pExpr, EP_Skip|EP_Unlikely) ){ | 101770 | while( pExpr && ExprHasProperty(pExpr, EP_Skip|EP_Unlikely) ){ |
| 101360 | if( ExprHasProperty(pExpr, EP_Unlikely) ){ | 101771 | if( ExprHasProperty(pExpr, EP_Unlikely) ){ |
| 101361 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | 101772 | assert( ExprUseXList(pExpr) ); |
| 101362 | assert( pExpr->x.pList->nExpr>0 ); | 101773 | assert( pExpr->x.pList->nExpr>0 ); |
| 101363 | assert( pExpr->op==TK_FUNCTION ); | 101774 | assert( pExpr->op==TK_FUNCTION ); |
| 101364 | pExpr = pExpr->x.pList->a[0].pExpr; | 101775 | pExpr = pExpr->x.pList->a[0].pExpr; |
| @@ -101391,27 +101802,30 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr){ | |||
| 101391 | while( p ){ | 101802 | while( p ){ |
| 101392 | int op = p->op; | 101803 | int op = p->op; |
| 101393 | if( op==TK_REGISTER ) op = p->op2; | 101804 | if( op==TK_REGISTER ) op = p->op2; |
| 101394 | if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_TRIGGER) | 101805 | if( op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_TRIGGER ){ |
| 101395 | && p->y.pTab!=0 | 101806 | assert( ExprUseYTab(p) ); |
| 101396 | ){ | 101807 | if( p->y.pTab!=0 ){ |
| 101397 | /* op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally | 101808 | /* op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally |
| 101398 | ** a TK_COLUMN but was previously evaluated and cached in a register */ | 101809 | ** a TK_COLUMN but was previously evaluated and cached in a register */ |
| 101399 | int j = p->iColumn; | 101810 | int j = p->iColumn; |
| 101400 | if( j>=0 ){ | 101811 | if( j>=0 ){ |
| 101401 | const char *zColl = p->y.pTab->aCol[j].zColl; | 101812 | const char *zColl = sqlite3ColumnColl(&p->y.pTab->aCol[j]); |
| 101402 | pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0); | 101813 | pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0); |
| 101814 | } | ||
| 101815 | break; | ||
| 101403 | } | 101816 | } |
| 101404 | break; | ||
| 101405 | } | 101817 | } |
| 101406 | if( op==TK_CAST || op==TK_UPLUS ){ | 101818 | if( op==TK_CAST || op==TK_UPLUS ){ |
| 101407 | p = p->pLeft; | 101819 | p = p->pLeft; |
| 101408 | continue; | 101820 | continue; |
| 101409 | } | 101821 | } |
| 101410 | if( op==TK_VECTOR ){ | 101822 | if( op==TK_VECTOR ){ |
| 101823 | assert( ExprUseXList(p) ); | ||
| 101411 | p = p->x.pList->a[0].pExpr; | 101824 | p = p->x.pList->a[0].pExpr; |
| 101412 | continue; | 101825 | continue; |
| 101413 | } | 101826 | } |
| 101414 | if( op==TK_COLLATE ){ | 101827 | if( op==TK_COLLATE ){ |
| 101828 | assert( !ExprHasProperty(p, EP_IntValue) ); | ||
| 101415 | pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken); | 101829 | pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken); |
| 101416 | break; | 101830 | break; |
| 101417 | } | 101831 | } |
| @@ -101421,11 +101835,9 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, const Expr *pExpr){ | |||
| 101421 | }else{ | 101835 | }else{ |
| 101422 | Expr *pNext = p->pRight; | 101836 | Expr *pNext = p->pRight; |
| 101423 | /* The Expr.x union is never used at the same time as Expr.pRight */ | 101837 | /* The Expr.x union is never used at the same time as Expr.pRight */ |
| 101838 | assert( ExprUseXList(p) ); | ||
| 101424 | assert( p->x.pList==0 || p->pRight==0 ); | 101839 | assert( p->x.pList==0 || p->pRight==0 ); |
| 101425 | if( p->x.pList!=0 | 101840 | if( p->x.pList!=0 && !db->mallocFailed ){ |
| 101426 | && !db->mallocFailed | ||
| 101427 | && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) | ||
| 101428 | ){ | ||
| 101429 | int i; | 101841 | int i; |
| 101430 | for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){ | 101842 | for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){ |
| 101431 | if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){ | 101843 | if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){ |
| @@ -101508,7 +101920,7 @@ static char comparisonAffinity(const Expr *pExpr){ | |||
| 101508 | aff = sqlite3ExprAffinity(pExpr->pLeft); | 101920 | aff = sqlite3ExprAffinity(pExpr->pLeft); |
| 101509 | if( pExpr->pRight ){ | 101921 | if( pExpr->pRight ){ |
| 101510 | aff = sqlite3CompareAffinity(pExpr->pRight, aff); | 101922 | aff = sqlite3CompareAffinity(pExpr->pRight, aff); |
| 101511 | }else if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 101923 | }else if( ExprUseXSelect(pExpr) ){ |
| 101512 | aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff); | 101924 | aff = sqlite3CompareAffinity(pExpr->x.pSelect->pEList->a[0].pExpr, aff); |
| 101513 | }else if( aff==0 ){ | 101925 | }else if( aff==0 ){ |
| 101514 | aff = SQLITE_AFF_BLOB; | 101926 | aff = SQLITE_AFF_BLOB; |
| @@ -101634,7 +102046,7 @@ static int codeCompare( | |||
| 101634 | ** But a TK_SELECT might be either a vector or a scalar. It is only | 102046 | ** But a TK_SELECT might be either a vector or a scalar. It is only |
| 101635 | ** considered a vector if it has two or more result columns. | 102047 | ** considered a vector if it has two or more result columns. |
| 101636 | */ | 102048 | */ |
| 101637 | SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr){ | 102049 | SQLITE_PRIVATE int sqlite3ExprIsVector(const Expr *pExpr){ |
| 101638 | return sqlite3ExprVectorSize(pExpr)>1; | 102050 | return sqlite3ExprVectorSize(pExpr)>1; |
| 101639 | } | 102051 | } |
| 101640 | 102052 | ||
| @@ -101644,12 +102056,14 @@ SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr){ | |||
| 101644 | ** is a sub-select, return the number of columns in the sub-select. For | 102056 | ** is a sub-select, return the number of columns in the sub-select. For |
| 101645 | ** any other type of expression, return 1. | 102057 | ** any other type of expression, return 1. |
| 101646 | */ | 102058 | */ |
| 101647 | SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr){ | 102059 | SQLITE_PRIVATE int sqlite3ExprVectorSize(const Expr *pExpr){ |
| 101648 | u8 op = pExpr->op; | 102060 | u8 op = pExpr->op; |
| 101649 | if( op==TK_REGISTER ) op = pExpr->op2; | 102061 | if( op==TK_REGISTER ) op = pExpr->op2; |
| 101650 | if( op==TK_VECTOR ){ | 102062 | if( op==TK_VECTOR ){ |
| 102063 | assert( ExprUseXList(pExpr) ); | ||
| 101651 | return pExpr->x.pList->nExpr; | 102064 | return pExpr->x.pList->nExpr; |
| 101652 | }else if( op==TK_SELECT ){ | 102065 | }else if( op==TK_SELECT ){ |
| 102066 | assert( ExprUseXSelect(pExpr) ); | ||
| 101653 | return pExpr->x.pSelect->pEList->nExpr; | 102067 | return pExpr->x.pSelect->pEList->nExpr; |
| 101654 | }else{ | 102068 | }else{ |
| 101655 | return 1; | 102069 | return 1; |
| @@ -101676,8 +102090,10 @@ SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){ | |||
| 101676 | if( sqlite3ExprIsVector(pVector) ){ | 102090 | if( sqlite3ExprIsVector(pVector) ){ |
| 101677 | assert( pVector->op2==0 || pVector->op==TK_REGISTER ); | 102091 | assert( pVector->op2==0 || pVector->op==TK_REGISTER ); |
| 101678 | if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){ | 102092 | if( pVector->op==TK_SELECT || pVector->op2==TK_SELECT ){ |
| 102093 | assert( ExprUseXSelect(pVector) ); | ||
| 101679 | return pVector->x.pSelect->pEList->a[i].pExpr; | 102094 | return pVector->x.pSelect->pEList->a[i].pExpr; |
| 101680 | }else{ | 102095 | }else{ |
| 102096 | assert( ExprUseXList(pVector) ); | ||
| 101681 | return pVector->x.pList->a[i].pExpr; | 102097 | return pVector->x.pList->a[i].pExpr; |
| 101682 | } | 102098 | } |
| 101683 | } | 102099 | } |
| @@ -101708,11 +102124,12 @@ SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr *pVector, int i){ | |||
| 101708 | SQLITE_PRIVATE Expr *sqlite3ExprForVectorField( | 102124 | SQLITE_PRIVATE Expr *sqlite3ExprForVectorField( |
| 101709 | Parse *pParse, /* Parsing context */ | 102125 | Parse *pParse, /* Parsing context */ |
| 101710 | Expr *pVector, /* The vector. List of expressions or a sub-SELECT */ | 102126 | Expr *pVector, /* The vector. List of expressions or a sub-SELECT */ |
| 101711 | int iField /* Which column of the vector to return */ | 102127 | int iField, /* Which column of the vector to return */ |
| 102128 | int nField /* Total number of columns in the vector */ | ||
| 101712 | ){ | 102129 | ){ |
| 101713 | Expr *pRet; | 102130 | Expr *pRet; |
| 101714 | if( pVector->op==TK_SELECT ){ | 102131 | if( pVector->op==TK_SELECT ){ |
| 101715 | assert( pVector->flags & EP_xIsSelect ); | 102132 | assert( ExprUseXSelect(pVector) ); |
| 101716 | /* The TK_SELECT_COLUMN Expr node: | 102133 | /* The TK_SELECT_COLUMN Expr node: |
| 101717 | ** | 102134 | ** |
| 101718 | ** pLeft: pVector containing TK_SELECT. Not deleted. | 102135 | ** pLeft: pVector containing TK_SELECT. Not deleted. |
| @@ -101731,14 +102148,23 @@ SQLITE_PRIVATE Expr *sqlite3ExprForVectorField( | |||
| 101731 | */ | 102148 | */ |
| 101732 | pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0); | 102149 | pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0); |
| 101733 | if( pRet ){ | 102150 | if( pRet ){ |
| 102151 | pRet->iTable = nField; | ||
| 101734 | pRet->iColumn = iField; | 102152 | pRet->iColumn = iField; |
| 101735 | pRet->pLeft = pVector; | 102153 | pRet->pLeft = pVector; |
| 101736 | } | 102154 | } |
| 101737 | assert( pRet==0 || pRet->iTable==0 ); | ||
| 101738 | }else{ | 102155 | }else{ |
| 101739 | if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr; | 102156 | if( pVector->op==TK_VECTOR ){ |
| 102157 | Expr **ppVector; | ||
| 102158 | assert( ExprUseXList(pVector) ); | ||
| 102159 | ppVector = &pVector->x.pList->a[iField].pExpr; | ||
| 102160 | pVector = *ppVector; | ||
| 102161 | if( IN_RENAME_OBJECT ){ | ||
| 102162 | /* This must be a vector UPDATE inside a trigger */ | ||
| 102163 | *ppVector = 0; | ||
| 102164 | return pVector; | ||
| 102165 | } | ||
| 102166 | } | ||
| 101740 | pRet = sqlite3ExprDup(pParse->db, pVector, 0); | 102167 | pRet = sqlite3ExprDup(pParse->db, pVector, 0); |
| 101741 | sqlite3RenameTokenRemap(pParse, pRet, pVector); | ||
| 101742 | } | 102168 | } |
| 101743 | return pRet; | 102169 | return pRet; |
| 101744 | } | 102170 | } |
| @@ -101794,10 +102220,12 @@ static int exprVectorRegister( | |||
| 101794 | return pVector->iTable+iField; | 102220 | return pVector->iTable+iField; |
| 101795 | } | 102221 | } |
| 101796 | if( op==TK_SELECT ){ | 102222 | if( op==TK_SELECT ){ |
| 102223 | assert( ExprUseXSelect(pVector) ); | ||
| 101797 | *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr; | 102224 | *ppExpr = pVector->x.pSelect->pEList->a[iField].pExpr; |
| 101798 | return regSelect+iField; | 102225 | return regSelect+iField; |
| 101799 | } | 102226 | } |
| 101800 | if( op==TK_VECTOR ){ | 102227 | if( op==TK_VECTOR ){ |
| 102228 | assert( ExprUseXList(pVector) ); | ||
| 101801 | *ppExpr = pVector->x.pList->a[iField].pExpr; | 102229 | *ppExpr = pVector->x.pList->a[iField].pExpr; |
| 101802 | return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree); | 102230 | return sqlite3ExprCodeTemp(pParse, *ppExpr, pRegFree); |
| 101803 | } | 102231 | } |
| @@ -101931,14 +102359,14 @@ SQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse *pParse, int nHeight){ | |||
| 101931 | ** to by pnHeight, the second parameter, then set *pnHeight to that | 102359 | ** to by pnHeight, the second parameter, then set *pnHeight to that |
| 101932 | ** value. | 102360 | ** value. |
| 101933 | */ | 102361 | */ |
| 101934 | static void heightOfExpr(Expr *p, int *pnHeight){ | 102362 | static void heightOfExpr(const Expr *p, int *pnHeight){ |
| 101935 | if( p ){ | 102363 | if( p ){ |
| 101936 | if( p->nHeight>*pnHeight ){ | 102364 | if( p->nHeight>*pnHeight ){ |
| 101937 | *pnHeight = p->nHeight; | 102365 | *pnHeight = p->nHeight; |
| 101938 | } | 102366 | } |
| 101939 | } | 102367 | } |
| 101940 | } | 102368 | } |
| 101941 | static void heightOfExprList(ExprList *p, int *pnHeight){ | 102369 | static void heightOfExprList(const ExprList *p, int *pnHeight){ |
| 101942 | if( p ){ | 102370 | if( p ){ |
| 101943 | int i; | 102371 | int i; |
| 101944 | for(i=0; i<p->nExpr; i++){ | 102372 | for(i=0; i<p->nExpr; i++){ |
| @@ -101946,8 +102374,8 @@ static void heightOfExprList(ExprList *p, int *pnHeight){ | |||
| 101946 | } | 102374 | } |
| 101947 | } | 102375 | } |
| 101948 | } | 102376 | } |
| 101949 | static void heightOfSelect(Select *pSelect, int *pnHeight){ | 102377 | static void heightOfSelect(const Select *pSelect, int *pnHeight){ |
| 101950 | Select *p; | 102378 | const Select *p; |
| 101951 | for(p=pSelect; p; p=p->pPrior){ | 102379 | for(p=pSelect; p; p=p->pPrior){ |
| 101952 | heightOfExpr(p->pWhere, pnHeight); | 102380 | heightOfExpr(p->pWhere, pnHeight); |
| 101953 | heightOfExpr(p->pHaving, pnHeight); | 102381 | heightOfExpr(p->pHaving, pnHeight); |
| @@ -101972,7 +102400,7 @@ static void exprSetHeight(Expr *p){ | |||
| 101972 | int nHeight = 0; | 102400 | int nHeight = 0; |
| 101973 | heightOfExpr(p->pLeft, &nHeight); | 102401 | heightOfExpr(p->pLeft, &nHeight); |
| 101974 | heightOfExpr(p->pRight, &nHeight); | 102402 | heightOfExpr(p->pRight, &nHeight); |
| 101975 | if( ExprHasProperty(p, EP_xIsSelect) ){ | 102403 | if( ExprUseXSelect(p) ){ |
| 101976 | heightOfSelect(p->x.pSelect, &nHeight); | 102404 | heightOfSelect(p->x.pSelect, &nHeight); |
| 101977 | }else if( p->x.pList ){ | 102405 | }else if( p->x.pList ){ |
| 101978 | heightOfExprList(p->x.pList, &nHeight); | 102406 | heightOfExprList(p->x.pList, &nHeight); |
| @@ -101999,7 +102427,7 @@ SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){ | |||
| 101999 | ** Return the maximum height of any expression tree referenced | 102427 | ** Return the maximum height of any expression tree referenced |
| 102000 | ** by the select statement passed as an argument. | 102428 | ** by the select statement passed as an argument. |
| 102001 | */ | 102429 | */ |
| 102002 | SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *p){ | 102430 | SQLITE_PRIVATE int sqlite3SelectExprHeight(const Select *p){ |
| 102003 | int nHeight = 0; | 102431 | int nHeight = 0; |
| 102004 | heightOfSelect(p, &nHeight); | 102432 | heightOfSelect(p, &nHeight); |
| 102005 | return nHeight; | 102433 | return nHeight; |
| @@ -102011,7 +102439,7 @@ SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *p){ | |||
| 102011 | */ | 102439 | */ |
| 102012 | SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){ | 102440 | SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){ |
| 102013 | if( pParse->nErr ) return; | 102441 | if( pParse->nErr ) return; |
| 102014 | if( p && p->x.pList && !ExprHasProperty(p, EP_xIsSelect) ){ | 102442 | if( p && ExprUseXList(p) && p->x.pList ){ |
| 102015 | p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList); | 102443 | p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList); |
| 102016 | } | 102444 | } |
| 102017 | } | 102445 | } |
| @@ -102169,6 +102597,63 @@ SQLITE_PRIVATE void sqlite3PExprAddSelect(Parse *pParse, Expr *pExpr, Select *pS | |||
| 102169 | } | 102597 | } |
| 102170 | } | 102598 | } |
| 102171 | 102599 | ||
| 102600 | /* | ||
| 102601 | ** Expression list pEList is a list of vector values. This function | ||
| 102602 | ** converts the contents of pEList to a VALUES(...) Select statement | ||
| 102603 | ** returning 1 row for each element of the list. For example, the | ||
| 102604 | ** expression list: | ||
| 102605 | ** | ||
| 102606 | ** ( (1,2), (3,4) (5,6) ) | ||
| 102607 | ** | ||
| 102608 | ** is translated to the equivalent of: | ||
| 102609 | ** | ||
| 102610 | ** VALUES(1,2), (3,4), (5,6) | ||
| 102611 | ** | ||
| 102612 | ** Each of the vector values in pEList must contain exactly nElem terms. | ||
| 102613 | ** If a list element that is not a vector or does not contain nElem terms, | ||
| 102614 | ** an error message is left in pParse. | ||
| 102615 | ** | ||
| 102616 | ** This is used as part of processing IN(...) expressions with a list | ||
| 102617 | ** of vectors on the RHS. e.g. "... IN ((1,2), (3,4), (5,6))". | ||
| 102618 | */ | ||
| 102619 | SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse *pParse, int nElem, ExprList *pEList){ | ||
| 102620 | int ii; | ||
| 102621 | Select *pRet = 0; | ||
| 102622 | assert( nElem>1 ); | ||
| 102623 | for(ii=0; ii<pEList->nExpr; ii++){ | ||
| 102624 | Select *pSel; | ||
| 102625 | Expr *pExpr = pEList->a[ii].pExpr; | ||
| 102626 | int nExprElem; | ||
| 102627 | if( pExpr->op==TK_VECTOR ){ | ||
| 102628 | assert( ExprUseXList(pExpr) ); | ||
| 102629 | nExprElem = pExpr->x.pList->nExpr; | ||
| 102630 | }else{ | ||
| 102631 | nExprElem = 1; | ||
| 102632 | } | ||
| 102633 | if( nExprElem!=nElem ){ | ||
| 102634 | sqlite3ErrorMsg(pParse, "IN(...) element has %d term%s - expected %d", | ||
| 102635 | nExprElem, nExprElem>1?"s":"", nElem | ||
| 102636 | ); | ||
| 102637 | break; | ||
| 102638 | } | ||
| 102639 | assert( ExprUseXList(pExpr) ); | ||
| 102640 | pSel = sqlite3SelectNew(pParse, pExpr->x.pList, 0, 0, 0, 0, 0, SF_Values,0); | ||
| 102641 | pExpr->x.pList = 0; | ||
| 102642 | if( pSel ){ | ||
| 102643 | if( pRet ){ | ||
| 102644 | pSel->op = TK_ALL; | ||
| 102645 | pSel->pPrior = pRet; | ||
| 102646 | } | ||
| 102647 | pRet = pSel; | ||
| 102648 | } | ||
| 102649 | } | ||
| 102650 | |||
| 102651 | if( pRet && pRet->pPrior ){ | ||
| 102652 | pRet->selFlags |= SF_MultiValue; | ||
| 102653 | } | ||
| 102654 | sqlite3ExprListDelete(pParse->db, pEList); | ||
| 102655 | return pRet; | ||
| 102656 | } | ||
| 102172 | 102657 | ||
| 102173 | /* | 102658 | /* |
| 102174 | ** Join two expressions using an AND operator. If either expression is | 102659 | ** Join two expressions using an AND operator. If either expression is |
| @@ -102202,7 +102687,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprAnd(Parse *pParse, Expr *pLeft, Expr *pRight){ | |||
| 102202 | SQLITE_PRIVATE Expr *sqlite3ExprFunction( | 102687 | SQLITE_PRIVATE Expr *sqlite3ExprFunction( |
| 102203 | Parse *pParse, /* Parsing context */ | 102688 | Parse *pParse, /* Parsing context */ |
| 102204 | ExprList *pList, /* Argument list */ | 102689 | ExprList *pList, /* Argument list */ |
| 102205 | Token *pToken, /* Name of the function */ | 102690 | const Token *pToken, /* Name of the function */ |
| 102206 | int eDistinct /* SF_Distinct or SF_ALL or 0 */ | 102691 | int eDistinct /* SF_Distinct or SF_ALL or 0 */ |
| 102207 | ){ | 102692 | ){ |
| 102208 | Expr *pNew; | 102693 | Expr *pNew; |
| @@ -102213,12 +102698,15 @@ SQLITE_PRIVATE Expr *sqlite3ExprFunction( | |||
| 102213 | sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */ | 102698 | sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */ |
| 102214 | return 0; | 102699 | return 0; |
| 102215 | } | 102700 | } |
| 102216 | if( pList && pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ | 102701 | if( pList |
| 102702 | && pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] | ||
| 102703 | && !pParse->nested | ||
| 102704 | ){ | ||
| 102217 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", pToken); | 102705 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", pToken); |
| 102218 | } | 102706 | } |
| 102219 | pNew->x.pList = pList; | 102707 | pNew->x.pList = pList; |
| 102220 | ExprSetProperty(pNew, EP_HasFunc); | 102708 | ExprSetProperty(pNew, EP_HasFunc); |
| 102221 | assert( !ExprHasProperty(pNew, EP_xIsSelect) ); | 102709 | assert( ExprUseXList(pNew) ); |
| 102222 | sqlite3ExprSetHeightAndFlags(pParse, pNew); | 102710 | sqlite3ExprSetHeightAndFlags(pParse, pNew); |
| 102223 | if( eDistinct==SF_Distinct ) ExprSetProperty(pNew, EP_Distinct); | 102711 | if( eDistinct==SF_Distinct ) ExprSetProperty(pNew, EP_Distinct); |
| 102224 | return pNew; | 102712 | return pNew; |
| @@ -102237,8 +102725,8 @@ SQLITE_PRIVATE Expr *sqlite3ExprFunction( | |||
| 102237 | */ | 102725 | */ |
| 102238 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable( | 102726 | SQLITE_PRIVATE void sqlite3ExprFunctionUsable( |
| 102239 | Parse *pParse, /* Parsing and code generating context */ | 102727 | Parse *pParse, /* Parsing and code generating context */ |
| 102240 | Expr *pExpr, /* The function invocation */ | 102728 | const Expr *pExpr, /* The function invocation */ |
| 102241 | FuncDef *pDef /* The function being invoked */ | 102729 | const FuncDef *pDef /* The function being invoked */ |
| 102242 | ){ | 102730 | ){ |
| 102243 | assert( !IN_RENAME_OBJECT ); | 102731 | assert( !IN_RENAME_OBJECT ); |
| 102244 | assert( (pDef->funcFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE))!=0 ); | 102732 | assert( (pDef->funcFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE))!=0 ); |
| @@ -102344,27 +102832,26 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n | |||
| 102344 | */ | 102832 | */ |
| 102345 | static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){ | 102833 | static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){ |
| 102346 | assert( p!=0 ); | 102834 | assert( p!=0 ); |
| 102347 | /* Sanity check: Assert that the IntValue is non-negative if it exists */ | 102835 | assert( !ExprUseUValue(p) || p->u.iValue>=0 ); |
| 102348 | assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 ); | 102836 | assert( !ExprUseYWin(p) || !ExprUseYSub(p) ); |
| 102349 | 102837 | assert( !ExprUseYWin(p) || p->y.pWin!=0 || db->mallocFailed ); | |
| 102350 | assert( !ExprHasProperty(p, EP_WinFunc) || p->y.pWin!=0 || db->mallocFailed ); | 102838 | assert( p->op!=TK_FUNCTION || !ExprUseYSub(p) ); |
| 102351 | assert( p->op!=TK_FUNCTION || ExprHasProperty(p, EP_TokenOnly|EP_Reduced) | ||
| 102352 | || p->y.pWin==0 || ExprHasProperty(p, EP_WinFunc) ); | ||
| 102353 | #ifdef SQLITE_DEBUG | 102839 | #ifdef SQLITE_DEBUG |
| 102354 | if( ExprHasProperty(p, EP_Leaf) && !ExprHasProperty(p, EP_TokenOnly) ){ | 102840 | if( ExprHasProperty(p, EP_Leaf) && !ExprHasProperty(p, EP_TokenOnly) ){ |
| 102355 | assert( p->pLeft==0 ); | 102841 | assert( p->pLeft==0 ); |
| 102356 | assert( p->pRight==0 ); | 102842 | assert( p->pRight==0 ); |
| 102357 | assert( p->x.pSelect==0 ); | 102843 | assert( !ExprUseXSelect(p) || p->x.pSelect==0 ); |
| 102844 | assert( !ExprUseXList(p) || p->x.pList==0 ); | ||
| 102358 | } | 102845 | } |
| 102359 | #endif | 102846 | #endif |
| 102360 | if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){ | 102847 | if( !ExprHasProperty(p, (EP_TokenOnly|EP_Leaf)) ){ |
| 102361 | /* The Expr.x union is never used at the same time as Expr.pRight */ | 102848 | /* The Expr.x union is never used at the same time as Expr.pRight */ |
| 102362 | assert( p->x.pList==0 || p->pRight==0 ); | 102849 | assert( (ExprUseXList(p) && p->x.pList==0) || p->pRight==0 ); |
| 102363 | if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft); | 102850 | if( p->pLeft && p->op!=TK_SELECT_COLUMN ) sqlite3ExprDeleteNN(db, p->pLeft); |
| 102364 | if( p->pRight ){ | 102851 | if( p->pRight ){ |
| 102365 | assert( !ExprHasProperty(p, EP_WinFunc) ); | 102852 | assert( !ExprHasProperty(p, EP_WinFunc) ); |
| 102366 | sqlite3ExprDeleteNN(db, p->pRight); | 102853 | sqlite3ExprDeleteNN(db, p->pRight); |
| 102367 | }else if( ExprHasProperty(p, EP_xIsSelect) ){ | 102854 | }else if( ExprUseXSelect(p) ){ |
| 102368 | assert( !ExprHasProperty(p, EP_WinFunc) ); | 102855 | assert( !ExprHasProperty(p, EP_WinFunc) ); |
| 102369 | sqlite3SelectDelete(db, p->x.pSelect); | 102856 | sqlite3SelectDelete(db, p->x.pSelect); |
| 102370 | }else{ | 102857 | }else{ |
| @@ -102376,7 +102863,10 @@ static SQLITE_NOINLINE void sqlite3ExprDeleteNN(sqlite3 *db, Expr *p){ | |||
| 102376 | #endif | 102863 | #endif |
| 102377 | } | 102864 | } |
| 102378 | } | 102865 | } |
| 102379 | if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken); | 102866 | if( ExprHasProperty(p, EP_MemToken) ){ |
| 102867 | assert( !ExprHasProperty(p, EP_IntValue) ); | ||
| 102868 | sqlite3DbFree(db, p->u.zToken); | ||
| 102869 | } | ||
| 102380 | if( !ExprHasProperty(p, EP_Static) ){ | 102870 | if( !ExprHasProperty(p, EP_Static) ){ |
| 102381 | sqlite3DbFreeNN(db, p); | 102871 | sqlite3DbFreeNN(db, p); |
| 102382 | } | 102872 | } |
| @@ -102418,7 +102908,7 @@ SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse *pParse, Expr *p){ | |||
| 102418 | ** passed as the first argument. This is always one of EXPR_FULLSIZE, | 102908 | ** passed as the first argument. This is always one of EXPR_FULLSIZE, |
| 102419 | ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. | 102909 | ** EXPR_REDUCEDSIZE or EXPR_TOKENONLYSIZE. |
| 102420 | */ | 102910 | */ |
| 102421 | static int exprStructSize(Expr *p){ | 102911 | static int exprStructSize(const Expr *p){ |
| 102422 | if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE; | 102912 | if( ExprHasProperty(p, EP_TokenOnly) ) return EXPR_TOKENONLYSIZE; |
| 102423 | if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE; | 102913 | if( ExprHasProperty(p, EP_Reduced) ) return EXPR_REDUCEDSIZE; |
| 102424 | return EXPR_FULLSIZE; | 102914 | return EXPR_FULLSIZE; |
| @@ -102458,7 +102948,7 @@ static int exprStructSize(Expr *p){ | |||
| 102458 | ** of dupedExprStructSize() contain multiple assert() statements that attempt | 102948 | ** of dupedExprStructSize() contain multiple assert() statements that attempt |
| 102459 | ** to enforce this constraint. | 102949 | ** to enforce this constraint. |
| 102460 | */ | 102950 | */ |
| 102461 | static int dupedExprStructSize(Expr *p, int flags){ | 102951 | static int dupedExprStructSize(const Expr *p, int flags){ |
| 102462 | int nSize; | 102952 | int nSize; |
| 102463 | assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ | 102953 | assert( flags==EXPRDUP_REDUCE || flags==0 ); /* Only one flag value allowed */ |
| 102464 | assert( EXPR_FULLSIZE<=0xfff ); | 102954 | assert( EXPR_FULLSIZE<=0xfff ); |
| @@ -102489,7 +102979,7 @@ static int dupedExprStructSize(Expr *p, int flags){ | |||
| 102489 | ** of the Expr structure and a copy of the Expr.u.zToken string (if that | 102979 | ** of the Expr structure and a copy of the Expr.u.zToken string (if that |
| 102490 | ** string is defined.) | 102980 | ** string is defined.) |
| 102491 | */ | 102981 | */ |
| 102492 | static int dupedExprNodeSize(Expr *p, int flags){ | 102982 | static int dupedExprNodeSize(const Expr *p, int flags){ |
| 102493 | int nByte = dupedExprStructSize(p, flags) & 0xfff; | 102983 | int nByte = dupedExprStructSize(p, flags) & 0xfff; |
| 102494 | if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ | 102984 | if( !ExprHasProperty(p, EP_IntValue) && p->u.zToken ){ |
| 102495 | nByte += sqlite3Strlen30NN(p->u.zToken)+1; | 102985 | nByte += sqlite3Strlen30NN(p->u.zToken)+1; |
| @@ -102510,7 +103000,7 @@ static int dupedExprNodeSize(Expr *p, int flags){ | |||
| 102510 | ** and Expr.pRight variables (but not for any structures pointed to or | 103000 | ** and Expr.pRight variables (but not for any structures pointed to or |
| 102511 | ** descended from the Expr.x.pList or Expr.x.pSelect variables). | 103001 | ** descended from the Expr.x.pList or Expr.x.pSelect variables). |
| 102512 | */ | 103002 | */ |
| 102513 | static int dupedExprSize(Expr *p, int flags){ | 103003 | static int dupedExprSize(const Expr *p, int flags){ |
| 102514 | int nByte = 0; | 103004 | int nByte = 0; |
| 102515 | if( p ){ | 103005 | if( p ){ |
| 102516 | nByte = dupedExprNodeSize(p, flags); | 103006 | nByte = dupedExprNodeSize(p, flags); |
| @@ -102529,7 +103019,7 @@ static int dupedExprSize(Expr *p, int flags){ | |||
| 102529 | ** if any. Before returning, *pzBuffer is set to the first byte past the | 103019 | ** if any. Before returning, *pzBuffer is set to the first byte past the |
| 102530 | ** portion of the buffer copied into by this function. | 103020 | ** portion of the buffer copied into by this function. |
| 102531 | */ | 103021 | */ |
| 102532 | static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){ | 103022 | static Expr *exprDup(sqlite3 *db, const Expr *p, int dupFlags, u8 **pzBuffer){ |
| 102533 | Expr *pNew; /* Value to return */ | 103023 | Expr *pNew; /* Value to return */ |
| 102534 | u8 *zAlloc; /* Memory space from which to build Expr object */ | 103024 | u8 *zAlloc; /* Memory space from which to build Expr object */ |
| 102535 | u32 staticFlag; /* EP_Static if space not obtained from malloc */ | 103025 | u32 staticFlag; /* EP_Static if space not obtained from malloc */ |
| @@ -102592,7 +103082,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){ | |||
| 102592 | 103082 | ||
| 102593 | if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){ | 103083 | if( 0==((p->flags|pNew->flags) & (EP_TokenOnly|EP_Leaf)) ){ |
| 102594 | /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ | 103084 | /* Fill in the pNew->x.pSelect or pNew->x.pList member. */ |
| 102595 | if( ExprHasProperty(p, EP_xIsSelect) ){ | 103085 | if( ExprUseXSelect(p) ){ |
| 102596 | pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags); | 103086 | pNew->x.pSelect = sqlite3SelectDup(db, p->x.pSelect, dupFlags); |
| 102597 | }else{ | 103087 | }else{ |
| 102598 | pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags); | 103088 | pNew->x.pList = sqlite3ExprListDup(db, p->x.pList, dupFlags); |
| @@ -102621,7 +103111,6 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int dupFlags, u8 **pzBuffer){ | |||
| 102621 | if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){ | 103111 | if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){ |
| 102622 | if( pNew->op==TK_SELECT_COLUMN ){ | 103112 | if( pNew->op==TK_SELECT_COLUMN ){ |
| 102623 | pNew->pLeft = p->pLeft; | 103113 | pNew->pLeft = p->pLeft; |
| 102624 | assert( p->iColumn==0 || p->pRight==0 ); | ||
| 102625 | assert( p->pRight==0 || p->pRight==p->pLeft | 103114 | assert( p->pRight==0 || p->pRight==p->pLeft |
| 102626 | || ExprHasProperty(p->pLeft, EP_Subquery) ); | 103115 | || ExprHasProperty(p->pLeft, EP_Subquery) ); |
| 102627 | }else{ | 103116 | }else{ |
| @@ -102711,15 +103200,17 @@ static void gatherSelectWindows(Select *p){ | |||
| 102711 | ** truncated version of the usual Expr structure that will be stored as | 103200 | ** truncated version of the usual Expr structure that will be stored as |
| 102712 | ** part of the in-memory representation of the database schema. | 103201 | ** part of the in-memory representation of the database schema. |
| 102713 | */ | 103202 | */ |
| 102714 | SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3 *db, Expr *p, int flags){ | 103203 | SQLITE_PRIVATE Expr *sqlite3ExprDup(sqlite3 *db, const Expr *p, int flags){ |
| 102715 | assert( flags==0 || flags==EXPRDUP_REDUCE ); | 103204 | assert( flags==0 || flags==EXPRDUP_REDUCE ); |
| 102716 | return p ? exprDup(db, p, flags, 0) : 0; | 103205 | return p ? exprDup(db, p, flags, 0) : 0; |
| 102717 | } | 103206 | } |
| 102718 | SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){ | 103207 | SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, const ExprList *p, int flags){ |
| 102719 | ExprList *pNew; | 103208 | ExprList *pNew; |
| 102720 | struct ExprList_item *pItem, *pOldItem; | 103209 | struct ExprList_item *pItem; |
| 103210 | const struct ExprList_item *pOldItem; | ||
| 102721 | int i; | 103211 | int i; |
| 102722 | Expr *pPriorSelectCol = 0; | 103212 | Expr *pPriorSelectColOld = 0; |
| 103213 | Expr *pPriorSelectColNew = 0; | ||
| 102723 | assert( db!=0 ); | 103214 | assert( db!=0 ); |
| 102724 | if( p==0 ) return 0; | 103215 | if( p==0 ) return 0; |
| 102725 | pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p)); | 103216 | pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p)); |
| @@ -102736,17 +103227,17 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags) | |||
| 102736 | && pOldExpr->op==TK_SELECT_COLUMN | 103227 | && pOldExpr->op==TK_SELECT_COLUMN |
| 102737 | && (pNewExpr = pItem->pExpr)!=0 | 103228 | && (pNewExpr = pItem->pExpr)!=0 |
| 102738 | ){ | 103229 | ){ |
| 102739 | assert( pNewExpr->iColumn==0 || i>0 ); | 103230 | if( pNewExpr->pRight ){ |
| 102740 | if( pNewExpr->iColumn==0 ){ | 103231 | pPriorSelectColOld = pOldExpr->pRight; |
| 102741 | assert( pOldExpr->pLeft==pOldExpr->pRight | 103232 | pPriorSelectColNew = pNewExpr->pRight; |
| 102742 | || ExprHasProperty(pOldExpr->pLeft, EP_Subquery) ); | 103233 | pNewExpr->pLeft = pNewExpr->pRight; |
| 102743 | pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight; | ||
| 102744 | }else{ | 103234 | }else{ |
| 102745 | assert( i>0 ); | 103235 | if( pOldExpr->pLeft!=pPriorSelectColOld ){ |
| 102746 | assert( pItem[-1].pExpr!=0 ); | 103236 | pPriorSelectColOld = pOldExpr->pLeft; |
| 102747 | assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 ); | 103237 | pPriorSelectColNew = sqlite3ExprDup(db, pPriorSelectColOld, flags); |
| 102748 | assert( pPriorSelectCol==pItem[-1].pExpr->pLeft ); | 103238 | pNewExpr->pRight = pPriorSelectColNew; |
| 102749 | pNewExpr->pLeft = pPriorSelectCol; | 103239 | } |
| 103240 | pNewExpr->pLeft = pPriorSelectColNew; | ||
| 102750 | } | 103241 | } |
| 102751 | } | 103242 | } |
| 102752 | pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName); | 103243 | pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName); |
| @@ -102768,7 +103259,7 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags) | |||
| 102768 | */ | 103259 | */ |
| 102769 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) \ | 103260 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_TRIGGER) \ |
| 102770 | || !defined(SQLITE_OMIT_SUBQUERY) | 103261 | || !defined(SQLITE_OMIT_SUBQUERY) |
| 102771 | SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){ | 103262 | SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, const SrcList *p, int flags){ |
| 102772 | SrcList *pNew; | 103263 | SrcList *pNew; |
| 102773 | int i; | 103264 | int i; |
| 102774 | int nByte; | 103265 | int nByte; |
| @@ -102780,7 +103271,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){ | |||
| 102780 | pNew->nSrc = pNew->nAlloc = p->nSrc; | 103271 | pNew->nSrc = pNew->nAlloc = p->nSrc; |
| 102781 | for(i=0; i<p->nSrc; i++){ | 103272 | for(i=0; i<p->nSrc; i++){ |
| 102782 | SrcItem *pNewItem = &pNew->a[i]; | 103273 | SrcItem *pNewItem = &pNew->a[i]; |
| 102783 | SrcItem *pOldItem = &p->a[i]; | 103274 | const SrcItem *pOldItem = &p->a[i]; |
| 102784 | Table *pTab; | 103275 | Table *pTab; |
| 102785 | pNewItem->pSchema = pOldItem->pSchema; | 103276 | pNewItem->pSchema = pOldItem->pSchema; |
| 102786 | pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase); | 103277 | pNewItem->zDatabase = sqlite3DbStrDup(db, pOldItem->zDatabase); |
| @@ -102812,7 +103303,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3 *db, SrcList *p, int flags){ | |||
| 102812 | } | 103303 | } |
| 102813 | return pNew; | 103304 | return pNew; |
| 102814 | } | 103305 | } |
| 102815 | SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, IdList *p){ | 103306 | SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, const IdList *p){ |
| 102816 | IdList *pNew; | 103307 | IdList *pNew; |
| 102817 | int i; | 103308 | int i; |
| 102818 | assert( db!=0 ); | 103309 | assert( db!=0 ); |
| @@ -102836,11 +103327,11 @@ SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, IdList *p){ | |||
| 102836 | } | 103327 | } |
| 102837 | return pNew; | 103328 | return pNew; |
| 102838 | } | 103329 | } |
| 102839 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){ | 103330 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, const Select *pDup, int flags){ |
| 102840 | Select *pRet = 0; | 103331 | Select *pRet = 0; |
| 102841 | Select *pNext = 0; | 103332 | Select *pNext = 0; |
| 102842 | Select **pp = &pRet; | 103333 | Select **pp = &pRet; |
| 102843 | Select *p; | 103334 | const Select *p; |
| 102844 | 103335 | ||
| 102845 | assert( db!=0 ); | 103336 | assert( db!=0 ); |
| 102846 | for(p=pDup; p; p=p->pPrior){ | 103337 | for(p=pDup; p; p=p->pPrior){ |
| @@ -102885,7 +103376,7 @@ SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){ | |||
| 102885 | return pRet; | 103376 | return pRet; |
| 102886 | } | 103377 | } |
| 102887 | #else | 103378 | #else |
| 102888 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){ | 103379 | SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, const Select *p, int flags){ |
| 102889 | assert( p==0 ); | 103380 | assert( p==0 ); |
| 102890 | return 0; | 103381 | return 0; |
| 102891 | } | 103382 | } |
| @@ -103005,11 +103496,9 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector( | |||
| 103005 | } | 103496 | } |
| 103006 | 103497 | ||
| 103007 | for(i=0; i<pColumns->nId; i++){ | 103498 | for(i=0; i<pColumns->nId; i++){ |
| 103008 | Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i); | 103499 | Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i, pColumns->nId); |
| 103009 | assert( pSubExpr!=0 || db->mallocFailed ); | 103500 | assert( pSubExpr!=0 || db->mallocFailed ); |
| 103010 | assert( pSubExpr==0 || pSubExpr->iTable==0 ); | ||
| 103011 | if( pSubExpr==0 ) continue; | 103501 | if( pSubExpr==0 ) continue; |
| 103012 | pSubExpr->iTable = pColumns->nId; | ||
| 103013 | pList = sqlite3ExprListAppend(pParse, pList, pSubExpr); | 103502 | pList = sqlite3ExprListAppend(pParse, pList, pSubExpr); |
| 103014 | if( pList ){ | 103503 | if( pList ){ |
| 103015 | assert( pList->nExpr==iFirst+i+1 ); | 103504 | assert( pList->nExpr==iFirst+i+1 ); |
| @@ -103083,7 +103572,7 @@ SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList *p, int iSortOrder, int | |||
| 103083 | SQLITE_PRIVATE void sqlite3ExprListSetName( | 103572 | SQLITE_PRIVATE void sqlite3ExprListSetName( |
| 103084 | Parse *pParse, /* Parsing context */ | 103573 | Parse *pParse, /* Parsing context */ |
| 103085 | ExprList *pList, /* List to which to add the span. */ | 103574 | ExprList *pList, /* List to which to add the span. */ |
| 103086 | Token *pName, /* Name to be added */ | 103575 | const Token *pName, /* Name to be added */ |
| 103087 | int dequote /* True to cause the name to be dequoted */ | 103576 | int dequote /* True to cause the name to be dequoted */ |
| 103088 | ){ | 103577 | ){ |
| 103089 | assert( pList!=0 || pParse->db->mallocFailed!=0 ); | 103578 | assert( pList!=0 || pParse->db->mallocFailed!=0 ); |
| @@ -103101,7 +103590,7 @@ SQLITE_PRIVATE void sqlite3ExprListSetName( | |||
| 103101 | ** to the token-map. */ | 103590 | ** to the token-map. */ |
| 103102 | sqlite3Dequote(pItem->zEName); | 103591 | sqlite3Dequote(pItem->zEName); |
| 103103 | if( IN_RENAME_OBJECT ){ | 103592 | if( IN_RENAME_OBJECT ){ |
| 103104 | sqlite3RenameTokenMap(pParse, (void*)pItem->zEName, pName); | 103593 | sqlite3RenameTokenMap(pParse, (const void*)pItem->zEName, pName); |
| 103105 | } | 103594 | } |
| 103106 | } | 103595 | } |
| 103107 | } | 103596 | } |
| @@ -103220,7 +103709,7 @@ SQLITE_PRIVATE u32 sqlite3IsTrueOrFalse(const char *zIn){ | |||
| 103220 | SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr *pExpr){ | 103709 | SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr *pExpr){ |
| 103221 | u32 v; | 103710 | u32 v; |
| 103222 | assert( pExpr->op==TK_ID || pExpr->op==TK_STRING ); | 103711 | assert( pExpr->op==TK_ID || pExpr->op==TK_STRING ); |
| 103223 | if( !ExprHasProperty(pExpr, EP_Quoted) | 103712 | if( !ExprHasProperty(pExpr, EP_Quoted|EP_IntValue) |
| 103224 | && (v = sqlite3IsTrueOrFalse(pExpr->u.zToken))!=0 | 103713 | && (v = sqlite3IsTrueOrFalse(pExpr->u.zToken))!=0 |
| 103225 | ){ | 103714 | ){ |
| 103226 | pExpr->op = TK_TRUEFALSE; | 103715 | pExpr->op = TK_TRUEFALSE; |
| @@ -103237,6 +103726,7 @@ SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr *pExpr){ | |||
| 103237 | SQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr *pExpr){ | 103726 | SQLITE_PRIVATE int sqlite3ExprTruthValue(const Expr *pExpr){ |
| 103238 | pExpr = sqlite3ExprSkipCollate((Expr*)pExpr); | 103727 | pExpr = sqlite3ExprSkipCollate((Expr*)pExpr); |
| 103239 | assert( pExpr->op==TK_TRUEFALSE ); | 103728 | assert( pExpr->op==TK_TRUEFALSE ); |
| 103729 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 103240 | assert( sqlite3StrICmp(pExpr->u.zToken,"true")==0 | 103730 | assert( sqlite3StrICmp(pExpr->u.zToken,"true")==0 |
| 103241 | || sqlite3StrICmp(pExpr->u.zToken,"false")==0 ); | 103731 | || sqlite3StrICmp(pExpr->u.zToken,"false")==0 ); |
| 103242 | return pExpr->u.zToken[4]==0; | 103732 | return pExpr->u.zToken[4]==0; |
| @@ -103441,7 +103931,7 @@ static int exprNodeIsConstantOrGroupBy(Walker *pWalker, Expr *pExpr){ | |||
| 103441 | } | 103931 | } |
| 103442 | 103932 | ||
| 103443 | /* Check if pExpr is a sub-select. If so, consider it variable. */ | 103933 | /* Check if pExpr is a sub-select. If so, consider it variable. */ |
| 103444 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 103934 | if( ExprUseXSelect(pExpr) ){ |
| 103445 | pWalker->eCode = 0; | 103935 | pWalker->eCode = 0; |
| 103446 | return WRC_Abort; | 103936 | return WRC_Abort; |
| 103447 | } | 103937 | } |
| @@ -103529,7 +104019,7 @@ SQLITE_PRIVATE int sqlite3ExprContainsSubquery(Expr *p){ | |||
| 103529 | ** in *pValue. If the expression is not an integer or if it is too big | 104019 | ** in *pValue. If the expression is not an integer or if it is too big |
| 103530 | ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. | 104020 | ** to fit in a signed 32-bit integer, return 0 and leave *pValue unchanged. |
| 103531 | */ | 104021 | */ |
| 103532 | SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){ | 104022 | SQLITE_PRIVATE int sqlite3ExprIsInteger(const Expr *p, int *pValue){ |
| 103533 | int rc = 0; | 104023 | int rc = 0; |
| 103534 | if( NEVER(p==0) ) return 0; /* Used to only happen following on OOM */ | 104024 | if( NEVER(p==0) ) return 0; /* Used to only happen following on OOM */ |
| 103535 | 104025 | ||
| @@ -103548,9 +104038,9 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){ | |||
| 103548 | break; | 104038 | break; |
| 103549 | } | 104039 | } |
| 103550 | case TK_UMINUS: { | 104040 | case TK_UMINUS: { |
| 103551 | int v; | 104041 | int v = 0; |
| 103552 | if( sqlite3ExprIsInteger(p->pLeft, &v) ){ | 104042 | if( sqlite3ExprIsInteger(p->pLeft, &v) ){ |
| 103553 | assert( v!=(-2147483647-1) ); | 104043 | assert( ((unsigned int)v)!=0x80000000 ); |
| 103554 | *pValue = -v; | 104044 | *pValue = -v; |
| 103555 | rc = 1; | 104045 | rc = 1; |
| 103556 | } | 104046 | } |
| @@ -103591,10 +104081,11 @@ SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){ | |||
| 103591 | case TK_BLOB: | 104081 | case TK_BLOB: |
| 103592 | return 0; | 104082 | return 0; |
| 103593 | case TK_COLUMN: | 104083 | case TK_COLUMN: |
| 104084 | assert( ExprUseYTab(p) ); | ||
| 103594 | return ExprHasProperty(p, EP_CanBeNull) || | 104085 | return ExprHasProperty(p, EP_CanBeNull) || |
| 103595 | p->y.pTab==0 || /* Reference to column of index on expression */ | 104086 | p->y.pTab==0 || /* Reference to column of index on expression */ |
| 103596 | (p->iColumn>=0 | 104087 | (p->iColumn>=0 |
| 103597 | && ALWAYS(p->y.pTab->aCol!=0) /* Defense against OOM problems */ | 104088 | && p->y.pTab->aCol!=0 /* Possible due to prior error */ |
| 103598 | && p->y.pTab->aCol[p->iColumn].notNull==0); | 104089 | && p->y.pTab->aCol[p->iColumn].notNull==0); |
| 103599 | default: | 104090 | default: |
| 103600 | return 1; | 104091 | return 1; |
| @@ -103662,13 +104153,13 @@ SQLITE_PRIVATE int sqlite3IsRowid(const char *z){ | |||
| 103662 | ** table, then return NULL. | 104153 | ** table, then return NULL. |
| 103663 | */ | 104154 | */ |
| 103664 | #ifndef SQLITE_OMIT_SUBQUERY | 104155 | #ifndef SQLITE_OMIT_SUBQUERY |
| 103665 | static Select *isCandidateForInOpt(Expr *pX){ | 104156 | static Select *isCandidateForInOpt(const Expr *pX){ |
| 103666 | Select *p; | 104157 | Select *p; |
| 103667 | SrcList *pSrc; | 104158 | SrcList *pSrc; |
| 103668 | ExprList *pEList; | 104159 | ExprList *pEList; |
| 103669 | Table *pTab; | 104160 | Table *pTab; |
| 103670 | int i; | 104161 | int i; |
| 103671 | if( !ExprHasProperty(pX, EP_xIsSelect) ) return 0; /* Not a subquery */ | 104162 | if( !ExprUseXSelect(pX) ) return 0; /* Not a subquery */ |
| 103672 | if( ExprHasProperty(pX, EP_VarSelect) ) return 0; /* Correlated subq */ | 104163 | if( ExprHasProperty(pX, EP_VarSelect) ) return 0; /* Correlated subq */ |
| 103673 | p = pX->x.pSelect; | 104164 | p = pX->x.pSelect; |
| 103674 | if( p->pPrior ) return 0; /* Not a compound SELECT */ | 104165 | if( p->pPrior ) return 0; /* Not a compound SELECT */ |
| @@ -103686,7 +104177,7 @@ static Select *isCandidateForInOpt(Expr *pX){ | |||
| 103686 | if( pSrc->a[0].pSelect ) return 0; /* FROM is not a subquery or view */ | 104177 | if( pSrc->a[0].pSelect ) return 0; /* FROM is not a subquery or view */ |
| 103687 | pTab = pSrc->a[0].pTab; | 104178 | pTab = pSrc->a[0].pTab; |
| 103688 | assert( pTab!=0 ); | 104179 | assert( pTab!=0 ); |
| 103689 | assert( pTab->pSelect==0 ); /* FROM clause is not a view */ | 104180 | assert( !IsView(pTab) ); /* FROM clause is not a view */ |
| 103690 | if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */ | 104181 | if( IsVirtual(pTab) ) return 0; /* FROM clause not a virtual table */ |
| 103691 | pEList = p->pEList; | 104182 | pEList = p->pEList; |
| 103692 | assert( pEList!=0 ); | 104183 | assert( pEList!=0 ); |
| @@ -103839,7 +104330,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex( | |||
| 103839 | ** or not NULL is actually possible (it may not be, for example, due | 104330 | ** or not NULL is actually possible (it may not be, for example, due |
| 103840 | ** to NOT NULL constraints in the schema). If no NULL values are possible, | 104331 | ** to NOT NULL constraints in the schema). If no NULL values are possible, |
| 103841 | ** set prRhsHasNull to 0 before continuing. */ | 104332 | ** set prRhsHasNull to 0 before continuing. */ |
| 103842 | if( prRhsHasNull && (pX->flags & EP_xIsSelect) ){ | 104333 | if( prRhsHasNull && ExprUseXSelect(pX) ){ |
| 103843 | int i; | 104334 | int i; |
| 103844 | ExprList *pEList = pX->x.pSelect->pEList; | 104335 | ExprList *pEList = pX->x.pSelect->pEList; |
| 103845 | for(i=0; i<pEList->nExpr; i++){ | 104336 | for(i=0; i<pEList->nExpr; i++){ |
| @@ -103940,7 +104431,8 @@ SQLITE_PRIVATE int sqlite3FindInIndex( | |||
| 103940 | CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs); | 104431 | CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs); |
| 103941 | int j; | 104432 | int j; |
| 103942 | 104433 | ||
| 103943 | assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr ); | 104434 | assert( pReq!=0 || pRhs->iColumn==XN_ROWID |
| 104435 | || pParse->nErr || db->mallocFailed ); | ||
| 103944 | for(j=0; j<nExpr; j++){ | 104436 | for(j=0; j<nExpr; j++){ |
| 103945 | if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue; | 104437 | if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue; |
| 103946 | assert( pIdx->azColl[j] ); | 104438 | assert( pIdx->azColl[j] ); |
| @@ -103995,7 +104487,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex( | |||
| 103995 | */ | 104487 | */ |
| 103996 | if( eType==0 | 104488 | if( eType==0 |
| 103997 | && (inFlags & IN_INDEX_NOOP_OK) | 104489 | && (inFlags & IN_INDEX_NOOP_OK) |
| 103998 | && !ExprHasProperty(pX, EP_xIsSelect) | 104490 | && ExprUseXList(pX) |
| 103999 | && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2) | 104491 | && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2) |
| 104000 | ){ | 104492 | ){ |
| 104001 | eType = IN_INDEX_NOOP; | 104493 | eType = IN_INDEX_NOOP; |
| @@ -104040,10 +104532,10 @@ SQLITE_PRIVATE int sqlite3FindInIndex( | |||
| 104040 | ** It is the responsibility of the caller to ensure that the returned | 104532 | ** It is the responsibility of the caller to ensure that the returned |
| 104041 | ** string is eventually freed using sqlite3DbFree(). | 104533 | ** string is eventually freed using sqlite3DbFree(). |
| 104042 | */ | 104534 | */ |
| 104043 | static char *exprINAffinity(Parse *pParse, Expr *pExpr){ | 104535 | static char *exprINAffinity(Parse *pParse, const Expr *pExpr){ |
| 104044 | Expr *pLeft = pExpr->pLeft; | 104536 | Expr *pLeft = pExpr->pLeft; |
| 104045 | int nVal = sqlite3ExprVectorSize(pLeft); | 104537 | int nVal = sqlite3ExprVectorSize(pLeft); |
| 104046 | Select *pSelect = (pExpr->flags & EP_xIsSelect) ? pExpr->x.pSelect : 0; | 104538 | Select *pSelect = ExprUseXSelect(pExpr) ? pExpr->x.pSelect : 0; |
| 104047 | char *zRet; | 104539 | char *zRet; |
| 104048 | 104540 | ||
| 104049 | assert( pExpr->op==TK_IN ); | 104541 | assert( pExpr->op==TK_IN ); |
| @@ -104093,7 +104585,7 @@ SQLITE_PRIVATE void sqlite3SubselectError(Parse *pParse, int nActual, int nExpec | |||
| 104093 | */ | 104585 | */ |
| 104094 | SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){ | 104586 | SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){ |
| 104095 | #ifndef SQLITE_OMIT_SUBQUERY | 104587 | #ifndef SQLITE_OMIT_SUBQUERY |
| 104096 | if( pExpr->flags & EP_xIsSelect ){ | 104588 | if( ExprUseXSelect(pExpr) ){ |
| 104097 | sqlite3SubselectError(pParse, pExpr->x.pSelect->pEList->nExpr, 1); | 104589 | sqlite3SubselectError(pParse, pExpr->x.pSelect->pEList->nExpr, 1); |
| 104098 | }else | 104590 | }else |
| 104099 | #endif | 104591 | #endif |
| @@ -104157,10 +104649,11 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN( | |||
| 104157 | */ | 104649 | */ |
| 104158 | if( ExprHasProperty(pExpr, EP_Subrtn) ){ | 104650 | if( ExprHasProperty(pExpr, EP_Subrtn) ){ |
| 104159 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); | 104651 | addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v); |
| 104160 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 104652 | if( ExprUseXSelect(pExpr) ){ |
| 104161 | ExplainQueryPlan((pParse, 0, "REUSE LIST SUBQUERY %d", | 104653 | ExplainQueryPlan((pParse, 0, "REUSE LIST SUBQUERY %d", |
| 104162 | pExpr->x.pSelect->selId)); | 104654 | pExpr->x.pSelect->selId)); |
| 104163 | } | 104655 | } |
| 104656 | assert( ExprUseYSub(pExpr) ); | ||
| 104164 | sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, | 104657 | sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, |
| 104165 | pExpr->y.sub.iAddr); | 104658 | pExpr->y.sub.iAddr); |
| 104166 | sqlite3VdbeAddOp2(v, OP_OpenDup, iTab, pExpr->iTable); | 104659 | sqlite3VdbeAddOp2(v, OP_OpenDup, iTab, pExpr->iTable); |
| @@ -104169,6 +104662,7 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN( | |||
| 104169 | } | 104662 | } |
| 104170 | 104663 | ||
| 104171 | /* Begin coding the subroutine */ | 104664 | /* Begin coding the subroutine */ |
| 104665 | assert( !ExprUseYWin(pExpr) ); | ||
| 104172 | ExprSetProperty(pExpr, EP_Subrtn); | 104666 | ExprSetProperty(pExpr, EP_Subrtn); |
| 104173 | assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); | 104667 | assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); |
| 104174 | pExpr->y.sub.regReturn = ++pParse->nMem; | 104668 | pExpr->y.sub.regReturn = ++pParse->nMem; |
| @@ -104189,7 +104683,7 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN( | |||
| 104189 | pExpr->iTable = iTab; | 104683 | pExpr->iTable = iTab; |
| 104190 | addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, nVal); | 104684 | addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pExpr->iTable, nVal); |
| 104191 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS | 104685 | #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS |
| 104192 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 104686 | if( ExprUseXSelect(pExpr) ){ |
| 104193 | VdbeComment((v, "Result of SELECT %u", pExpr->x.pSelect->selId)); | 104687 | VdbeComment((v, "Result of SELECT %u", pExpr->x.pSelect->selId)); |
| 104194 | }else{ | 104688 | }else{ |
| 104195 | VdbeComment((v, "RHS of IN operator")); | 104689 | VdbeComment((v, "RHS of IN operator")); |
| @@ -104197,7 +104691,7 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN( | |||
| 104197 | #endif | 104691 | #endif |
| 104198 | pKeyInfo = sqlite3KeyInfoAlloc(pParse->db, nVal, 1); | 104692 | pKeyInfo = sqlite3KeyInfoAlloc(pParse->db, nVal, 1); |
| 104199 | 104693 | ||
| 104200 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 104694 | if( ExprUseXSelect(pExpr) ){ |
| 104201 | /* Case 1: expr IN (SELECT ...) | 104695 | /* Case 1: expr IN (SELECT ...) |
| 104202 | ** | 104696 | ** |
| 104203 | ** Generate code to write the results of the select into the temporary | 104697 | ** Generate code to write the results of the select into the temporary |
| @@ -104295,6 +104789,7 @@ SQLITE_PRIVATE void sqlite3CodeRhsOfIN( | |||
| 104295 | if( addrOnce ){ | 104789 | if( addrOnce ){ |
| 104296 | sqlite3VdbeJumpHere(v, addrOnce); | 104790 | sqlite3VdbeJumpHere(v, addrOnce); |
| 104297 | /* Subroutine return */ | 104791 | /* Subroutine return */ |
| 104792 | assert( ExprUseYSub(pExpr) ); | ||
| 104298 | sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn); | 104793 | sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn); |
| 104299 | sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); | 104794 | sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); |
| 104300 | sqlite3ClearTempRegCache(pParse); | 104795 | sqlite3ClearTempRegCache(pParse); |
| @@ -104331,19 +104826,22 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){ | |||
| 104331 | testcase( pExpr->op==TK_EXISTS ); | 104826 | testcase( pExpr->op==TK_EXISTS ); |
| 104332 | testcase( pExpr->op==TK_SELECT ); | 104827 | testcase( pExpr->op==TK_SELECT ); |
| 104333 | assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT ); | 104828 | assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT ); |
| 104334 | assert( ExprHasProperty(pExpr, EP_xIsSelect) ); | 104829 | assert( ExprUseXSelect(pExpr) ); |
| 104335 | pSel = pExpr->x.pSelect; | 104830 | pSel = pExpr->x.pSelect; |
| 104336 | 104831 | ||
| 104337 | /* If this routine has already been coded, then invoke it as a | 104832 | /* If this routine has already been coded, then invoke it as a |
| 104338 | ** subroutine. */ | 104833 | ** subroutine. */ |
| 104339 | if( ExprHasProperty(pExpr, EP_Subrtn) ){ | 104834 | if( ExprHasProperty(pExpr, EP_Subrtn) ){ |
| 104340 | ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId)); | 104835 | ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId)); |
| 104836 | assert( ExprUseYSub(pExpr) ); | ||
| 104341 | sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, | 104837 | sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn, |
| 104342 | pExpr->y.sub.iAddr); | 104838 | pExpr->y.sub.iAddr); |
| 104343 | return pExpr->iTable; | 104839 | return pExpr->iTable; |
| 104344 | } | 104840 | } |
| 104345 | 104841 | ||
| 104346 | /* Begin coding the subroutine */ | 104842 | /* Begin coding the subroutine */ |
| 104843 | assert( !ExprUseYWin(pExpr) ); | ||
| 104844 | assert( !ExprHasProperty(pExpr, EP_Reduced|EP_TokenOnly) ); | ||
| 104347 | ExprSetProperty(pExpr, EP_Subrtn); | 104845 | ExprSetProperty(pExpr, EP_Subrtn); |
| 104348 | pExpr->y.sub.regReturn = ++pParse->nMem; | 104846 | pExpr->y.sub.regReturn = ++pParse->nMem; |
| 104349 | pExpr->y.sub.iAddr = | 104847 | pExpr->y.sub.iAddr = |
| @@ -104423,6 +104921,7 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){ | |||
| 104423 | } | 104921 | } |
| 104424 | 104922 | ||
| 104425 | /* Subroutine return */ | 104923 | /* Subroutine return */ |
| 104924 | assert( ExprUseYSub(pExpr) ); | ||
| 104426 | sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn); | 104925 | sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn); |
| 104427 | sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); | 104926 | sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1); |
| 104428 | sqlite3ClearTempRegCache(pParse); | 104927 | sqlite3ClearTempRegCache(pParse); |
| @@ -104439,7 +104938,7 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){ | |||
| 104439 | */ | 104938 | */ |
| 104440 | SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){ | 104939 | SQLITE_PRIVATE int sqlite3ExprCheckIN(Parse *pParse, Expr *pIn){ |
| 104441 | int nVector = sqlite3ExprVectorSize(pIn->pLeft); | 104940 | int nVector = sqlite3ExprVectorSize(pIn->pLeft); |
| 104442 | if( (pIn->flags & EP_xIsSelect)!=0 && !pParse->db->mallocFailed ){ | 104941 | if( ExprUseXSelect(pIn) && !pParse->db->mallocFailed ){ |
| 104443 | if( nVector!=pIn->x.pSelect->pEList->nExpr ){ | 104942 | if( nVector!=pIn->x.pSelect->pEList->nExpr ){ |
| 104444 | sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector); | 104943 | sqlite3SubselectError(pParse, pIn->x.pSelect->pEList->nExpr, nVector); |
| 104445 | return 1; | 104944 | return 1; |
| @@ -104573,13 +105072,15 @@ static void sqlite3ExprCodeIN( | |||
| 104573 | ** This is step (1) in the in-operator.md optimized algorithm. | 105072 | ** This is step (1) in the in-operator.md optimized algorithm. |
| 104574 | */ | 105073 | */ |
| 104575 | if( eType==IN_INDEX_NOOP ){ | 105074 | if( eType==IN_INDEX_NOOP ){ |
| 104576 | ExprList *pList = pExpr->x.pList; | 105075 | ExprList *pList; |
| 104577 | CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft); | 105076 | CollSeq *pColl; |
| 104578 | int labelOk = sqlite3VdbeMakeLabel(pParse); | 105077 | int labelOk = sqlite3VdbeMakeLabel(pParse); |
| 104579 | int r2, regToFree; | 105078 | int r2, regToFree; |
| 104580 | int regCkNull = 0; | 105079 | int regCkNull = 0; |
| 104581 | int ii; | 105080 | int ii; |
| 104582 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | 105081 | assert( ExprUseXList(pExpr) ); |
| 105082 | pList = pExpr->x.pList; | ||
| 105083 | pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft); | ||
| 104583 | if( destIfNull!=destIfFalse ){ | 105084 | if( destIfNull!=destIfFalse ){ |
| 104584 | regCkNull = sqlite3GetTempReg(pParse); | 105085 | regCkNull = sqlite3GetTempReg(pParse); |
| 104585 | sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull); | 105086 | sqlite3VdbeAddOp3(v, OP_BitAnd, rLhs, rLhs, regCkNull); |
| @@ -104816,9 +105317,10 @@ SQLITE_PRIVATE void sqlite3ExprCodeLoadIndexColumn( | |||
| 104816 | ** and store the result in register regOut | 105317 | ** and store the result in register regOut |
| 104817 | */ | 105318 | */ |
| 104818 | SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn( | 105319 | SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn( |
| 104819 | Parse *pParse, | 105320 | Parse *pParse, /* Parsing context */ |
| 104820 | Column *pCol, | 105321 | Table *pTab, /* Table containing the generated column */ |
| 104821 | int regOut | 105322 | Column *pCol, /* The generated column */ |
| 105323 | int regOut /* Put the result in this register */ | ||
| 104822 | ){ | 105324 | ){ |
| 104823 | int iAddr; | 105325 | int iAddr; |
| 104824 | Vdbe *v = pParse->pVdbe; | 105326 | Vdbe *v = pParse->pVdbe; |
| @@ -104829,7 +105331,7 @@ SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn( | |||
| 104829 | }else{ | 105331 | }else{ |
| 104830 | iAddr = 0; | 105332 | iAddr = 0; |
| 104831 | } | 105333 | } |
| 104832 | sqlite3ExprCodeCopy(pParse, pCol->pDflt, regOut); | 105334 | sqlite3ExprCodeCopy(pParse, sqlite3ColumnExpr(pTab,pCol), regOut); |
| 104833 | if( pCol->affinity>=SQLITE_AFF_TEXT ){ | 105335 | if( pCol->affinity>=SQLITE_AFF_TEXT ){ |
| 104834 | sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1); | 105336 | sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1); |
| 104835 | } | 105337 | } |
| @@ -104865,12 +105367,13 @@ SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable( | |||
| 104865 | }else if( (pCol = &pTab->aCol[iCol])->colFlags & COLFLAG_VIRTUAL ){ | 105367 | }else if( (pCol = &pTab->aCol[iCol])->colFlags & COLFLAG_VIRTUAL ){ |
| 104866 | Parse *pParse = sqlite3VdbeParser(v); | 105368 | Parse *pParse = sqlite3VdbeParser(v); |
| 104867 | if( pCol->colFlags & COLFLAG_BUSY ){ | 105369 | if( pCol->colFlags & COLFLAG_BUSY ){ |
| 104868 | sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pCol->zName); | 105370 | sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", |
| 105371 | pCol->zCnName); | ||
| 104869 | }else{ | 105372 | }else{ |
| 104870 | int savedSelfTab = pParse->iSelfTab; | 105373 | int savedSelfTab = pParse->iSelfTab; |
| 104871 | pCol->colFlags |= COLFLAG_BUSY; | 105374 | pCol->colFlags |= COLFLAG_BUSY; |
| 104872 | pParse->iSelfTab = iTabCur+1; | 105375 | pParse->iSelfTab = iTabCur+1; |
| 104873 | sqlite3ExprCodeGeneratedColumn(pParse, pCol, regOut); | 105376 | sqlite3ExprCodeGeneratedColumn(pParse, pTab, pCol, regOut); |
| 104874 | pParse->iSelfTab = savedSelfTab; | 105377 | pParse->iSelfTab = savedSelfTab; |
| 104875 | pCol->colFlags &= ~COLFLAG_BUSY; | 105378 | pCol->colFlags &= ~COLFLAG_BUSY; |
| 104876 | } | 105379 | } |
| @@ -104963,6 +105466,7 @@ static int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){ | |||
| 104963 | int i; | 105466 | int i; |
| 104964 | iResult = pParse->nMem+1; | 105467 | iResult = pParse->nMem+1; |
| 104965 | pParse->nMem += nResult; | 105468 | pParse->nMem += nResult; |
| 105469 | assert( ExprUseXList(p) ); | ||
| 104966 | for(i=0; i<nResult; i++){ | 105470 | for(i=0; i<nResult; i++){ |
| 104967 | sqlite3ExprCodeFactorable(pParse, p->x.pList->a[i].pExpr, i+iResult); | 105471 | sqlite3ExprCodeFactorable(pParse, p->x.pList->a[i].pExpr, i+iResult); |
| 104968 | } | 105472 | } |
| @@ -105037,6 +105541,7 @@ static int exprCodeInlineFunction( | |||
| 105037 | ** Test-only SQL functions that are only usable if enabled | 105541 | ** Test-only SQL functions that are only usable if enabled |
| 105038 | ** via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS | 105542 | ** via SQLITE_TESTCTRL_INTERNAL_FUNCTIONS |
| 105039 | */ | 105543 | */ |
| 105544 | #if !defined(SQLITE_UNTESTABLE) | ||
| 105040 | case INLINEFUNC_expr_compare: { | 105545 | case INLINEFUNC_expr_compare: { |
| 105041 | /* Compare two expressions using sqlite3ExprCompare() */ | 105546 | /* Compare two expressions using sqlite3ExprCompare() */ |
| 105042 | assert( nFarg==2 ); | 105547 | assert( nFarg==2 ); |
| @@ -105070,7 +105575,6 @@ static int exprCodeInlineFunction( | |||
| 105070 | break; | 105575 | break; |
| 105071 | } | 105576 | } |
| 105072 | 105577 | ||
| 105073 | #ifdef SQLITE_DEBUG | ||
| 105074 | case INLINEFUNC_affinity: { | 105578 | case INLINEFUNC_affinity: { |
| 105075 | /* The AFFINITY() function evaluates to a string that describes | 105579 | /* The AFFINITY() function evaluates to a string that describes |
| 105076 | ** the type affinity of the argument. This is used for testing of | 105580 | ** the type affinity of the argument. This is used for testing of |
| @@ -105084,7 +105588,7 @@ static int exprCodeInlineFunction( | |||
| 105084 | (aff<=SQLITE_AFF_NONE) ? "none" : azAff[aff-SQLITE_AFF_BLOB]); | 105588 | (aff<=SQLITE_AFF_NONE) ? "none" : azAff[aff-SQLITE_AFF_BLOB]); |
| 105085 | break; | 105589 | break; |
| 105086 | } | 105590 | } |
| 105087 | #endif | 105591 | #endif /* !defined(SQLITE_UNTESTABLE) */ |
| 105088 | } | 105592 | } |
| 105089 | return target; | 105593 | return target; |
| 105090 | } | 105594 | } |
| @@ -105138,7 +105642,8 @@ expr_code_doover: | |||
| 105138 | if( pCol->iColumn<0 ){ | 105642 | if( pCol->iColumn<0 ){ |
| 105139 | VdbeComment((v,"%s.rowid",pTab->zName)); | 105643 | VdbeComment((v,"%s.rowid",pTab->zName)); |
| 105140 | }else{ | 105644 | }else{ |
| 105141 | VdbeComment((v,"%s.%s",pTab->zName,pTab->aCol[pCol->iColumn].zName)); | 105645 | VdbeComment((v,"%s.%s", |
| 105646 | pTab->zName, pTab->aCol[pCol->iColumn].zCnName)); | ||
| 105142 | if( pTab->aCol[pCol->iColumn].affinity==SQLITE_AFF_REAL ){ | 105647 | if( pTab->aCol[pCol->iColumn].affinity==SQLITE_AFF_REAL ){ |
| 105143 | sqlite3VdbeAddOp1(v, OP_RealAffinity, target); | 105648 | sqlite3VdbeAddOp1(v, OP_RealAffinity, target); |
| 105144 | } | 105649 | } |
| @@ -105160,6 +105665,7 @@ expr_code_doover: | |||
| 105160 | */ | 105665 | */ |
| 105161 | int aff; | 105666 | int aff; |
| 105162 | iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); | 105667 | iReg = sqlite3ExprCodeTarget(pParse, pExpr->pLeft,target); |
| 105668 | assert( ExprUseYTab(pExpr) ); | ||
| 105163 | if( pExpr->y.pTab ){ | 105669 | if( pExpr->y.pTab ){ |
| 105164 | aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); | 105670 | aff = sqlite3TableColumnAffinity(pExpr->y.pTab, pExpr->iColumn); |
| 105165 | }else{ | 105671 | }else{ |
| @@ -105183,9 +105689,11 @@ expr_code_doover: | |||
| 105183 | ** immediately prior to the first column. | 105689 | ** immediately prior to the first column. |
| 105184 | */ | 105690 | */ |
| 105185 | Column *pCol; | 105691 | Column *pCol; |
| 105186 | Table *pTab = pExpr->y.pTab; | 105692 | Table *pTab; |
| 105187 | int iSrc; | 105693 | int iSrc; |
| 105188 | int iCol = pExpr->iColumn; | 105694 | int iCol = pExpr->iColumn; |
| 105695 | assert( ExprUseYTab(pExpr) ); | ||
| 105696 | pTab = pExpr->y.pTab; | ||
| 105189 | assert( pTab!=0 ); | 105697 | assert( pTab!=0 ); |
| 105190 | assert( iCol>=XN_ROWID ); | 105698 | assert( iCol>=XN_ROWID ); |
| 105191 | assert( iCol<pTab->nCol ); | 105699 | assert( iCol<pTab->nCol ); |
| @@ -105199,12 +105707,12 @@ expr_code_doover: | |||
| 105199 | if( pCol->colFlags & COLFLAG_GENERATED ){ | 105707 | if( pCol->colFlags & COLFLAG_GENERATED ){ |
| 105200 | if( pCol->colFlags & COLFLAG_BUSY ){ | 105708 | if( pCol->colFlags & COLFLAG_BUSY ){ |
| 105201 | sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", | 105709 | sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", |
| 105202 | pCol->zName); | 105710 | pCol->zCnName); |
| 105203 | return 0; | 105711 | return 0; |
| 105204 | } | 105712 | } |
| 105205 | pCol->colFlags |= COLFLAG_BUSY; | 105713 | pCol->colFlags |= COLFLAG_BUSY; |
| 105206 | if( pCol->colFlags & COLFLAG_NOTAVAIL ){ | 105714 | if( pCol->colFlags & COLFLAG_NOTAVAIL ){ |
| 105207 | sqlite3ExprCodeGeneratedColumn(pParse, pCol, iSrc); | 105715 | sqlite3ExprCodeGeneratedColumn(pParse, pTab, pCol, iSrc); |
| 105208 | } | 105716 | } |
| 105209 | pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL); | 105717 | pCol->colFlags &= ~(COLFLAG_BUSY|COLFLAG_NOTAVAIL); |
| 105210 | return iSrc; | 105718 | return iSrc; |
| @@ -105223,6 +105731,7 @@ expr_code_doover: | |||
| 105223 | iTab = pParse->iSelfTab - 1; | 105731 | iTab = pParse->iSelfTab - 1; |
| 105224 | } | 105732 | } |
| 105225 | } | 105733 | } |
| 105734 | assert( ExprUseYTab(pExpr) ); | ||
| 105226 | iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, | 105735 | iReg = sqlite3ExprCodeGetColumn(pParse, pExpr->y.pTab, |
| 105227 | pExpr->iColumn, iTab, target, | 105736 | pExpr->iColumn, iTab, target, |
| 105228 | pExpr->op2); | 105737 | pExpr->op2); |
| @@ -105300,6 +105809,7 @@ expr_code_doover: | |||
| 105300 | sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target); | 105809 | sqlite3VdbeAddOp2(v, OP_SCopy, inReg, target); |
| 105301 | inReg = target; | 105810 | inReg = target; |
| 105302 | } | 105811 | } |
| 105812 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 105303 | sqlite3VdbeAddOp2(v, OP_Cast, target, | 105813 | sqlite3VdbeAddOp2(v, OP_Cast, target, |
| 105304 | sqlite3AffinityType(pExpr->u.zToken, 0)); | 105814 | sqlite3AffinityType(pExpr->u.zToken, 0)); |
| 105305 | return inReg; | 105815 | return inReg; |
| @@ -105467,8 +105977,8 @@ expr_code_doover: | |||
| 105467 | ** multiple times if we know they always give the same result */ | 105977 | ** multiple times if we know they always give the same result */ |
| 105468 | return sqlite3ExprCodeRunJustOnce(pParse, pExpr, -1); | 105978 | return sqlite3ExprCodeRunJustOnce(pParse, pExpr, -1); |
| 105469 | } | 105979 | } |
| 105470 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | ||
| 105471 | assert( !ExprHasProperty(pExpr, EP_TokenOnly) ); | 105980 | assert( !ExprHasProperty(pExpr, EP_TokenOnly) ); |
| 105981 | assert( ExprUseXList(pExpr) ); | ||
| 105472 | pFarg = pExpr->x.pList; | 105982 | pFarg = pExpr->x.pList; |
| 105473 | nFarg = pFarg ? pFarg->nExpr : 0; | 105983 | nFarg = pFarg ? pFarg->nExpr : 0; |
| 105474 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | 105984 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| @@ -105557,7 +106067,7 @@ expr_code_doover: | |||
| 105557 | sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ); | 106067 | sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ); |
| 105558 | } | 106068 | } |
| 105559 | #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC | 106069 | #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC |
| 105560 | if( pDef->funcFlags & SQLITE_FUNC_OFFSET ){ | 106070 | if( (pDef->funcFlags & SQLITE_FUNC_OFFSET)!=0 && ALWAYS(pFarg!=0) ){ |
| 105561 | Expr *pArg = pFarg->a[0].pExpr; | 106071 | Expr *pArg = pFarg->a[0].pExpr; |
| 105562 | if( pArg->op==TK_COLUMN ){ | 106072 | if( pArg->op==TK_COLUMN ){ |
| 105563 | sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target); | 106073 | sqlite3VdbeAddOp3(v, OP_Offset, pArg->iTable, pArg->iColumn, target); |
| @@ -105587,7 +106097,10 @@ expr_code_doover: | |||
| 105587 | testcase( op==TK_SELECT ); | 106097 | testcase( op==TK_SELECT ); |
| 105588 | if( pParse->db->mallocFailed ){ | 106098 | if( pParse->db->mallocFailed ){ |
| 105589 | return 0; | 106099 | return 0; |
| 105590 | }else if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){ | 106100 | }else if( op==TK_SELECT |
| 106101 | && ALWAYS( ExprUseXSelect(pExpr) ) | ||
| 106102 | && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 | ||
| 106103 | ){ | ||
| 105591 | sqlite3SubselectError(pParse, nCol, 1); | 106104 | sqlite3SubselectError(pParse, nCol, 1); |
| 105592 | }else{ | 106105 | }else{ |
| 105593 | return sqlite3CodeSubselect(pParse, pExpr); | 106106 | return sqlite3CodeSubselect(pParse, pExpr); |
| @@ -105599,11 +106112,9 @@ expr_code_doover: | |||
| 105599 | if( pExpr->pLeft->iTable==0 ){ | 106112 | if( pExpr->pLeft->iTable==0 ){ |
| 105600 | pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft); | 106113 | pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft); |
| 105601 | } | 106114 | } |
| 105602 | assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT | 106115 | assert( pExpr->pLeft->op==TK_SELECT || pExpr->pLeft->op==TK_ERROR ); |
| 105603 | || pExpr->pLeft->op==TK_ERROR ); | 106116 | n = sqlite3ExprVectorSize(pExpr->pLeft); |
| 105604 | if( pExpr->iTable!=0 | 106117 | if( pExpr->iTable!=n ){ |
| 105605 | && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft)) | ||
| 105606 | ){ | ||
| 105607 | sqlite3ErrorMsg(pParse, "%d columns assigned %d values", | 106118 | sqlite3ErrorMsg(pParse, "%d columns assigned %d values", |
| 105608 | pExpr->iTable, n); | 106119 | pExpr->iTable, n); |
| 105609 | } | 106120 | } |
| @@ -105671,9 +106182,14 @@ expr_code_doover: | |||
| 105671 | ** p1==1 -> old.a p1==4 -> new.a | 106182 | ** p1==1 -> old.a p1==4 -> new.a |
| 105672 | ** p1==2 -> old.b p1==5 -> new.b | 106183 | ** p1==2 -> old.b p1==5 -> new.b |
| 105673 | */ | 106184 | */ |
| 105674 | Table *pTab = pExpr->y.pTab; | 106185 | Table *pTab; |
| 105675 | int iCol = pExpr->iColumn; | 106186 | int iCol; |
| 105676 | int p1 = pExpr->iTable * (pTab->nCol+1) + 1 | 106187 | int p1; |
| 106188 | |||
| 106189 | assert( ExprUseYTab(pExpr) ); | ||
| 106190 | pTab = pExpr->y.pTab; | ||
| 106191 | iCol = pExpr->iColumn; | ||
| 106192 | p1 = pExpr->iTable * (pTab->nCol+1) + 1 | ||
| 105677 | + sqlite3TableColumnToStorage(pTab, iCol); | 106193 | + sqlite3TableColumnToStorage(pTab, iCol); |
| 105678 | 106194 | ||
| 105679 | assert( pExpr->iTable==0 || pExpr->iTable==1 ); | 106195 | assert( pExpr->iTable==0 || pExpr->iTable==1 ); |
| @@ -105684,7 +106200,7 @@ expr_code_doover: | |||
| 105684 | sqlite3VdbeAddOp2(v, OP_Param, p1, target); | 106200 | sqlite3VdbeAddOp2(v, OP_Param, p1, target); |
| 105685 | VdbeComment((v, "r[%d]=%s.%s", target, | 106201 | VdbeComment((v, "r[%d]=%s.%s", target, |
| 105686 | (pExpr->iTable ? "new" : "old"), | 106202 | (pExpr->iTable ? "new" : "old"), |
| 105687 | (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[iCol].zName) | 106203 | (pExpr->iColumn<0 ? "rowid" : pExpr->y.pTab->aCol[iCol].zCnName) |
| 105688 | )); | 106204 | )); |
| 105689 | 106205 | ||
| 105690 | #ifndef SQLITE_OMIT_FLOATING_POINT | 106206 | #ifndef SQLITE_OMIT_FLOATING_POINT |
| @@ -105761,7 +106277,7 @@ expr_code_doover: | |||
| 105761 | Expr *pDel = 0; | 106277 | Expr *pDel = 0; |
| 105762 | sqlite3 *db = pParse->db; | 106278 | sqlite3 *db = pParse->db; |
| 105763 | 106279 | ||
| 105764 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList ); | 106280 | assert( ExprUseXList(pExpr) && pExpr->x.pList!=0 ); |
| 105765 | assert(pExpr->x.pList->nExpr > 0); | 106281 | assert(pExpr->x.pList->nExpr > 0); |
| 105766 | pEList = pExpr->x.pList; | 106282 | pEList = pExpr->x.pList; |
| 105767 | aListelem = pEList->a; | 106283 | aListelem = pEList->a; |
| @@ -105958,7 +106474,7 @@ SQLITE_PRIVATE void sqlite3ExprCode(Parse *pParse, Expr *pExpr, int target){ | |||
| 105958 | inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); | 106474 | inReg = sqlite3ExprCodeTarget(pParse, pExpr, target); |
| 105959 | if( inReg!=target ){ | 106475 | if( inReg!=target ){ |
| 105960 | u8 op; | 106476 | u8 op; |
| 105961 | if( ExprHasProperty(pExpr,EP_Subquery) ){ | 106477 | if( ALWAYS(pExpr) && ExprHasProperty(pExpr,EP_Subquery) ){ |
| 105962 | op = OP_Copy; | 106478 | op = OP_Copy; |
| 105963 | }else{ | 106479 | }else{ |
| 105964 | op = OP_SCopy; | 106480 | op = OP_SCopy; |
| @@ -106106,7 +106622,7 @@ static void exprCodeBetween( | |||
| 106106 | memset(&compRight, 0, sizeof(Expr)); | 106622 | memset(&compRight, 0, sizeof(Expr)); |
| 106107 | memset(&exprAnd, 0, sizeof(Expr)); | 106623 | memset(&exprAnd, 0, sizeof(Expr)); |
| 106108 | 106624 | ||
| 106109 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | 106625 | assert( ExprUseXList(pExpr) ); |
| 106110 | pDel = sqlite3ExprDup(db, pExpr->pLeft, 0); | 106626 | pDel = sqlite3ExprDup(db, pExpr->pLeft, 0); |
| 106111 | if( db->mallocFailed==0 ){ | 106627 | if( db->mallocFailed==0 ){ |
| 106112 | exprAnd.op = TK_AND; | 106628 | exprAnd.op = TK_AND; |
| @@ -106496,7 +107012,11 @@ SQLITE_PRIVATE void sqlite3ExprIfFalseDup(Parse *pParse, Expr *pExpr, int dest,i | |||
| 106496 | ** Otherwise, if the values are not the same or if pExpr is not a simple | 107012 | ** Otherwise, if the values are not the same or if pExpr is not a simple |
| 106497 | ** SQL value, zero is returned. | 107013 | ** SQL value, zero is returned. |
| 106498 | */ | 107014 | */ |
| 106499 | static int exprCompareVariable(Parse *pParse, Expr *pVar, Expr *pExpr){ | 107015 | static int exprCompareVariable( |
| 107016 | const Parse *pParse, | ||
| 107017 | const Expr *pVar, | ||
| 107018 | const Expr *pExpr | ||
| 107019 | ){ | ||
| 106500 | int res = 0; | 107020 | int res = 0; |
| 106501 | int iVar; | 107021 | int iVar; |
| 106502 | sqlite3_value *pL, *pR = 0; | 107022 | sqlite3_value *pL, *pR = 0; |
| @@ -106548,7 +107068,12 @@ static int exprCompareVariable(Parse *pParse, Expr *pVar, Expr *pExpr){ | |||
| 106548 | ** Argument pParse should normally be NULL. If it is not NULL and pA or | 107068 | ** Argument pParse should normally be NULL. If it is not NULL and pA or |
| 106549 | ** pB causes a return value of 2. | 107069 | ** pB causes a return value of 2. |
| 106550 | */ | 107070 | */ |
| 106551 | SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){ | 107071 | SQLITE_PRIVATE int sqlite3ExprCompare( |
| 107072 | const Parse *pParse, | ||
| 107073 | const Expr *pA, | ||
| 107074 | const Expr *pB, | ||
| 107075 | int iTab | ||
| 107076 | ){ | ||
| 106552 | u32 combinedFlags; | 107077 | u32 combinedFlags; |
| 106553 | if( pA==0 || pB==0 ){ | 107078 | if( pA==0 || pB==0 ){ |
| 106554 | return pB==pA ? 0 : 2; | 107079 | return pB==pA ? 0 : 2; |
| @@ -106572,7 +107097,9 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTa | |||
| 106572 | } | 107097 | } |
| 106573 | return 2; | 107098 | return 2; |
| 106574 | } | 107099 | } |
| 106575 | if( pA->op!=TK_COLUMN && pA->op!=TK_AGG_COLUMN && pA->u.zToken ){ | 107100 | assert( !ExprHasProperty(pA, EP_IntValue) ); |
| 107101 | assert( !ExprHasProperty(pB, EP_IntValue) ); | ||
| 107102 | if( pA->u.zToken ){ | ||
| 106576 | if( pA->op==TK_FUNCTION || pA->op==TK_AGG_FUNCTION ){ | 107103 | if( pA->op==TK_FUNCTION || pA->op==TK_AGG_FUNCTION ){ |
| 106577 | if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; | 107104 | if( sqlite3StrICmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; |
| 106578 | #ifndef SQLITE_OMIT_WINDOWFUNC | 107105 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| @@ -106590,7 +107117,12 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTa | |||
| 106590 | return 0; | 107117 | return 0; |
| 106591 | }else if( pA->op==TK_COLLATE ){ | 107118 | }else if( pA->op==TK_COLLATE ){ |
| 106592 | if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; | 107119 | if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2; |
| 106593 | }else if( ALWAYS(pB->u.zToken!=0) && strcmp(pA->u.zToken,pB->u.zToken)!=0 ){ | 107120 | }else |
| 107121 | if( pB->u.zToken!=0 | ||
| 107122 | && pA->op!=TK_COLUMN | ||
| 107123 | && pA->op!=TK_AGG_COLUMN | ||
| 107124 | && strcmp(pA->u.zToken,pB->u.zToken)!=0 | ||
| 107125 | ){ | ||
| 106594 | return 2; | 107126 | return 2; |
| 106595 | } | 107127 | } |
| 106596 | } | 107128 | } |
| @@ -106632,7 +107164,7 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTa | |||
| 106632 | ** Two NULL pointers are considered to be the same. But a NULL pointer | 107164 | ** Two NULL pointers are considered to be the same. But a NULL pointer |
| 106633 | ** always differs from a non-NULL pointer. | 107165 | ** always differs from a non-NULL pointer. |
| 106634 | */ | 107166 | */ |
| 106635 | SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){ | 107167 | SQLITE_PRIVATE int sqlite3ExprListCompare(const ExprList *pA, const ExprList *pB, int iTab){ |
| 106636 | int i; | 107168 | int i; |
| 106637 | if( pA==0 && pB==0 ) return 0; | 107169 | if( pA==0 && pB==0 ) return 0; |
| 106638 | if( pA==0 || pB==0 ) return 1; | 107170 | if( pA==0 || pB==0 ) return 1; |
| @@ -106651,7 +107183,7 @@ SQLITE_PRIVATE int sqlite3ExprListCompare(ExprList *pA, ExprList *pB, int iTab){ | |||
| 106651 | ** Like sqlite3ExprCompare() except COLLATE operators at the top-level | 107183 | ** Like sqlite3ExprCompare() except COLLATE operators at the top-level |
| 106652 | ** are ignored. | 107184 | ** are ignored. |
| 106653 | */ | 107185 | */ |
| 106654 | SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){ | 107186 | SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA,Expr *pB, int iTab){ |
| 106655 | return sqlite3ExprCompare(0, | 107187 | return sqlite3ExprCompare(0, |
| 106656 | sqlite3ExprSkipCollateAndLikely(pA), | 107188 | sqlite3ExprSkipCollateAndLikely(pA), |
| 106657 | sqlite3ExprSkipCollateAndLikely(pB), | 107189 | sqlite3ExprSkipCollateAndLikely(pB), |
| @@ -106665,9 +107197,9 @@ SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr *pA, Expr *pB, int iTab){ | |||
| 106665 | ** non-NULL if pNN is not NULL | 107197 | ** non-NULL if pNN is not NULL |
| 106666 | */ | 107198 | */ |
| 106667 | static int exprImpliesNotNull( | 107199 | static int exprImpliesNotNull( |
| 106668 | Parse *pParse, /* Parsing context */ | 107200 | const Parse *pParse,/* Parsing context */ |
| 106669 | Expr *p, /* The expression to be checked */ | 107201 | const Expr *p, /* The expression to be checked */ |
| 106670 | Expr *pNN, /* The expression that is NOT NULL */ | 107202 | const Expr *pNN, /* The expression that is NOT NULL */ |
| 106671 | int iTab, /* Table being evaluated */ | 107203 | int iTab, /* Table being evaluated */ |
| 106672 | int seenNot /* Return true only if p can be any non-NULL value */ | 107204 | int seenNot /* Return true only if p can be any non-NULL value */ |
| 106673 | ){ | 107205 | ){ |
| @@ -106679,12 +107211,13 @@ static int exprImpliesNotNull( | |||
| 106679 | switch( p->op ){ | 107211 | switch( p->op ){ |
| 106680 | case TK_IN: { | 107212 | case TK_IN: { |
| 106681 | if( seenNot && ExprHasProperty(p, EP_xIsSelect) ) return 0; | 107213 | if( seenNot && ExprHasProperty(p, EP_xIsSelect) ) return 0; |
| 106682 | assert( ExprHasProperty(p,EP_xIsSelect) | 107214 | assert( ExprUseXSelect(p) || (p->x.pList!=0 && p->x.pList->nExpr>0) ); |
| 106683 | || (p->x.pList!=0 && p->x.pList->nExpr>0) ); | ||
| 106684 | return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1); | 107215 | return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1); |
| 106685 | } | 107216 | } |
| 106686 | case TK_BETWEEN: { | 107217 | case TK_BETWEEN: { |
| 106687 | ExprList *pList = p->x.pList; | 107218 | ExprList *pList; |
| 107219 | assert( ExprUseXList(p) ); | ||
| 107220 | pList = p->x.pList; | ||
| 106688 | assert( pList!=0 ); | 107221 | assert( pList!=0 ); |
| 106689 | assert( pList->nExpr==2 ); | 107222 | assert( pList->nExpr==2 ); |
| 106690 | if( seenNot ) return 0; | 107223 | if( seenNot ) return 0; |
| @@ -106760,7 +107293,12 @@ static int exprImpliesNotNull( | |||
| 106760 | ** improvement. Returning false might cause a performance reduction, but | 107293 | ** improvement. Returning false might cause a performance reduction, but |
| 106761 | ** it will always give the correct answer and is hence always safe. | 107294 | ** it will always give the correct answer and is hence always safe. |
| 106762 | */ | 107295 | */ |
| 106763 | SQLITE_PRIVATE int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){ | 107296 | SQLITE_PRIVATE int sqlite3ExprImpliesExpr( |
| 107297 | const Parse *pParse, | ||
| 107298 | const Expr *pE1, | ||
| 107299 | const Expr *pE2, | ||
| 107300 | int iTab | ||
| 107301 | ){ | ||
| 106764 | if( sqlite3ExprCompare(pParse, pE1, pE2, iTab)==0 ){ | 107302 | if( sqlite3ExprCompare(pParse, pE1, pE2, iTab)==0 ){ |
| 106765 | return 1; | 107303 | return 1; |
| 106766 | } | 107304 | } |
| @@ -106856,10 +107394,14 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){ | |||
| 106856 | testcase( pExpr->op==TK_GE ); | 107394 | testcase( pExpr->op==TK_GE ); |
| 106857 | /* The y.pTab=0 assignment in wherecode.c always happens after the | 107395 | /* The y.pTab=0 assignment in wherecode.c always happens after the |
| 106858 | ** impliesNotNullRow() test */ | 107396 | ** impliesNotNullRow() test */ |
| 106859 | if( (pLeft->op==TK_COLUMN && ALWAYS(pLeft->y.pTab!=0) | 107397 | assert( pLeft->op!=TK_COLUMN || ExprUseYTab(pLeft) ); |
| 106860 | && IsVirtual(pLeft->y.pTab)) | 107398 | assert( pRight->op!=TK_COLUMN || ExprUseYTab(pRight) ); |
| 106861 | || (pRight->op==TK_COLUMN && ALWAYS(pRight->y.pTab!=0) | 107399 | if( (pLeft->op==TK_COLUMN |
| 106862 | && IsVirtual(pRight->y.pTab)) | 107400 | && pLeft->y.pTab!=0 |
| 107401 | && IsVirtual(pLeft->y.pTab)) | ||
| 107402 | || (pRight->op==TK_COLUMN | ||
| 107403 | && pRight->y.pTab!=0 | ||
| 107404 | && IsVirtual(pRight->y.pTab)) | ||
| 106863 | ){ | 107405 | ){ |
| 106864 | return WRC_Prune; | 107406 | return WRC_Prune; |
| 106865 | } | 107407 | } |
| @@ -106968,88 +107510,125 @@ SQLITE_PRIVATE int sqlite3ExprCoveredByIndex( | |||
| 106968 | } | 107510 | } |
| 106969 | 107511 | ||
| 106970 | 107512 | ||
| 106971 | /* | 107513 | /* Structure used to pass information throught the Walker in order to |
| 106972 | ** An instance of the following structure is used by the tree walker | 107514 | ** implement sqlite3ReferencesSrcList(). |
| 106973 | ** to count references to table columns in the arguments of an | 107515 | */ |
| 106974 | ** aggregate function, in order to implement the | 107516 | struct RefSrcList { |
| 106975 | ** sqlite3FunctionThisSrc() routine. | 107517 | sqlite3 *db; /* Database connection used for sqlite3DbRealloc() */ |
| 106976 | */ | 107518 | SrcList *pRef; /* Looking for references to these tables */ |
| 106977 | struct SrcCount { | 107519 | i64 nExclude; /* Number of tables to exclude from the search */ |
| 106978 | SrcList *pSrc; /* One particular FROM clause in a nested query */ | 107520 | int *aiExclude; /* Cursor IDs for tables to exclude from the search */ |
| 106979 | int iSrcInner; /* Smallest cursor number in this context */ | ||
| 106980 | int nThis; /* Number of references to columns in pSrcList */ | ||
| 106981 | int nOther; /* Number of references to columns in other FROM clauses */ | ||
| 106982 | }; | 107521 | }; |
| 106983 | 107522 | ||
| 106984 | /* | 107523 | /* |
| 106985 | ** xSelect callback for sqlite3FunctionUsesThisSrc(). If this is the first | 107524 | ** Walker SELECT callbacks for sqlite3ReferencesSrcList(). |
| 106986 | ** SELECT with a FROM clause encountered during this iteration, set | 107525 | ** |
| 106987 | ** SrcCount.iSrcInner to the cursor number of the leftmost object in | 107526 | ** When entering a new subquery on the pExpr argument, add all FROM clause |
| 106988 | ** the FROM cause. | 107527 | ** entries for that subquery to the exclude list. |
| 107528 | ** | ||
| 107529 | ** When leaving the subquery, remove those entries from the exclude list. | ||
| 106989 | */ | 107530 | */ |
| 106990 | static int selectSrcCount(Walker *pWalker, Select *pSel){ | 107531 | static int selectRefEnter(Walker *pWalker, Select *pSelect){ |
| 106991 | struct SrcCount *p = pWalker->u.pSrcCount; | 107532 | struct RefSrcList *p = pWalker->u.pRefSrcList; |
| 106992 | if( p->iSrcInner==0x7FFFFFFF && ALWAYS(pSel->pSrc) && pSel->pSrc->nSrc ){ | 107533 | SrcList *pSrc = pSelect->pSrc; |
| 106993 | pWalker->u.pSrcCount->iSrcInner = pSel->pSrc->a[0].iCursor; | 107534 | i64 i, j; |
| 107535 | int *piNew; | ||
| 107536 | if( pSrc->nSrc==0 ) return WRC_Continue; | ||
| 107537 | j = p->nExclude; | ||
| 107538 | p->nExclude += pSrc->nSrc; | ||
| 107539 | piNew = sqlite3DbRealloc(p->db, p->aiExclude, p->nExclude*sizeof(int)); | ||
| 107540 | if( piNew==0 ){ | ||
| 107541 | p->nExclude = 0; | ||
| 107542 | return WRC_Abort; | ||
| 107543 | }else{ | ||
| 107544 | p->aiExclude = piNew; | ||
| 107545 | } | ||
| 107546 | for(i=0; i<pSrc->nSrc; i++, j++){ | ||
| 107547 | p->aiExclude[j] = pSrc->a[i].iCursor; | ||
| 106994 | } | 107548 | } |
| 106995 | return WRC_Continue; | 107549 | return WRC_Continue; |
| 106996 | } | 107550 | } |
| 107551 | static void selectRefLeave(Walker *pWalker, Select *pSelect){ | ||
| 107552 | struct RefSrcList *p = pWalker->u.pRefSrcList; | ||
| 107553 | SrcList *pSrc = pSelect->pSrc; | ||
| 107554 | if( p->nExclude ){ | ||
| 107555 | assert( p->nExclude>=pSrc->nSrc ); | ||
| 107556 | p->nExclude -= pSrc->nSrc; | ||
| 107557 | } | ||
| 107558 | } | ||
| 106997 | 107559 | ||
| 106998 | /* | 107560 | /* This is the Walker EXPR callback for sqlite3ReferencesSrcList(). |
| 106999 | ** Count the number of references to columns. | 107561 | ** |
| 107562 | ** Set the 0x01 bit of pWalker->eCode if there is a reference to any | ||
| 107563 | ** of the tables shown in RefSrcList.pRef. | ||
| 107564 | ** | ||
| 107565 | ** Set the 0x02 bit of pWalker->eCode if there is a reference to a | ||
| 107566 | ** table is in neither RefSrcList.pRef nor RefSrcList.aiExclude. | ||
| 107000 | */ | 107567 | */ |
| 107001 | static int exprSrcCount(Walker *pWalker, Expr *pExpr){ | 107568 | static int exprRefToSrcList(Walker *pWalker, Expr *pExpr){ |
| 107002 | /* There was once a NEVER() on the second term on the grounds that | 107569 | if( pExpr->op==TK_COLUMN |
| 107003 | ** sqlite3FunctionUsesThisSrc() was always called before | 107570 | || pExpr->op==TK_AGG_COLUMN |
| 107004 | ** sqlite3ExprAnalyzeAggregates() and so the TK_COLUMNs have not yet | 107571 | ){ |
| 107005 | ** been converted into TK_AGG_COLUMN. But this is no longer true due | ||
| 107006 | ** to window functions - sqlite3WindowRewrite() may now indirectly call | ||
| 107007 | ** FunctionUsesThisSrc() when creating a new sub-select. */ | ||
| 107008 | if( pExpr->op==TK_COLUMN || pExpr->op==TK_AGG_COLUMN ){ | ||
| 107009 | int i; | 107572 | int i; |
| 107010 | struct SrcCount *p = pWalker->u.pSrcCount; | 107573 | struct RefSrcList *p = pWalker->u.pRefSrcList; |
| 107011 | SrcList *pSrc = p->pSrc; | 107574 | SrcList *pSrc = p->pRef; |
| 107012 | int nSrc = pSrc ? pSrc->nSrc : 0; | 107575 | int nSrc = pSrc ? pSrc->nSrc : 0; |
| 107013 | for(i=0; i<nSrc; i++){ | 107576 | for(i=0; i<nSrc; i++){ |
| 107014 | if( pExpr->iTable==pSrc->a[i].iCursor ) break; | 107577 | if( pExpr->iTable==pSrc->a[i].iCursor ){ |
| 107578 | pWalker->eCode |= 1; | ||
| 107579 | return WRC_Continue; | ||
| 107580 | } | ||
| 107015 | } | 107581 | } |
| 107016 | if( i<nSrc ){ | 107582 | for(i=0; i<p->nExclude && p->aiExclude[i]!=pExpr->iTable; i++){} |
| 107017 | p->nThis++; | 107583 | if( i>=p->nExclude ){ |
| 107018 | }else if( pExpr->iTable<p->iSrcInner ){ | 107584 | pWalker->eCode |= 2; |
| 107019 | /* In a well-formed parse tree (no name resolution errors), | ||
| 107020 | ** TK_COLUMN nodes with smaller Expr.iTable values are in an | ||
| 107021 | ** outer context. Those are the only ones to count as "other" */ | ||
| 107022 | p->nOther++; | ||
| 107023 | } | 107585 | } |
| 107024 | } | 107586 | } |
| 107025 | return WRC_Continue; | 107587 | return WRC_Continue; |
| 107026 | } | 107588 | } |
| 107027 | 107589 | ||
| 107028 | /* | 107590 | /* |
| 107029 | ** Determine if any of the arguments to the pExpr Function reference | 107591 | ** Check to see if pExpr references any tables in pSrcList. |
| 107030 | ** pSrcList. Return true if they do. Also return true if the function | 107592 | ** Possible return values: |
| 107031 | ** has no arguments or has only constant arguments. Return false if pExpr | 107593 | ** |
| 107032 | ** references columns but not columns of tables found in pSrcList. | 107594 | ** 1 pExpr does references a table in pSrcList. |
| 107595 | ** | ||
| 107596 | ** 0 pExpr references some table that is not defined in either | ||
| 107597 | ** pSrcList or in subqueries of pExpr itself. | ||
| 107598 | ** | ||
| 107599 | ** -1 pExpr only references no tables at all, or it only | ||
| 107600 | ** references tables defined in subqueries of pExpr itself. | ||
| 107601 | ** | ||
| 107602 | ** As currently used, pExpr is always an aggregate function call. That | ||
| 107603 | ** fact is exploited for efficiency. | ||
| 107033 | */ | 107604 | */ |
| 107034 | SQLITE_PRIVATE int sqlite3FunctionUsesThisSrc(Expr *pExpr, SrcList *pSrcList){ | 107605 | SQLITE_PRIVATE int sqlite3ReferencesSrcList(Parse *pParse, Expr *pExpr, SrcList *pSrcList){ |
| 107035 | Walker w; | 107606 | Walker w; |
| 107036 | struct SrcCount cnt; | 107607 | struct RefSrcList x; |
| 107037 | assert( pExpr->op==TK_AGG_FUNCTION ); | ||
| 107038 | memset(&w, 0, sizeof(w)); | 107608 | memset(&w, 0, sizeof(w)); |
| 107039 | w.xExprCallback = exprSrcCount; | 107609 | memset(&x, 0, sizeof(x)); |
| 107040 | w.xSelectCallback = selectSrcCount; | 107610 | w.xExprCallback = exprRefToSrcList; |
| 107041 | w.u.pSrcCount = &cnt; | 107611 | w.xSelectCallback = selectRefEnter; |
| 107042 | cnt.pSrc = pSrcList; | 107612 | w.xSelectCallback2 = selectRefLeave; |
| 107043 | cnt.iSrcInner = (pSrcList&&pSrcList->nSrc)?pSrcList->a[0].iCursor:0x7FFFFFFF; | 107613 | w.u.pRefSrcList = &x; |
| 107044 | cnt.nThis = 0; | 107614 | x.db = pParse->db; |
| 107045 | cnt.nOther = 0; | 107615 | x.pRef = pSrcList; |
| 107616 | assert( pExpr->op==TK_AGG_FUNCTION ); | ||
| 107617 | assert( ExprUseXList(pExpr) ); | ||
| 107046 | sqlite3WalkExprList(&w, pExpr->x.pList); | 107618 | sqlite3WalkExprList(&w, pExpr->x.pList); |
| 107047 | #ifndef SQLITE_OMIT_WINDOWFUNC | 107619 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 107048 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ | 107620 | if( ExprHasProperty(pExpr, EP_WinFunc) ){ |
| 107049 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); | 107621 | sqlite3WalkExpr(&w, pExpr->y.pWin->pFilter); |
| 107050 | } | 107622 | } |
| 107051 | #endif | 107623 | #endif |
| 107052 | return cnt.nThis>0 || cnt.nOther==0; | 107624 | sqlite3DbFree(pParse->db, x.aiExclude); |
| 107625 | if( w.eCode & 0x01 ){ | ||
| 107626 | return 1; | ||
| 107627 | }else if( w.eCode ){ | ||
| 107628 | return 0; | ||
| 107629 | }else{ | ||
| 107630 | return -1; | ||
| 107631 | } | ||
| 107053 | } | 107632 | } |
| 107054 | 107633 | ||
| 107055 | /* | 107634 | /* |
| @@ -107184,6 +107763,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ | |||
| 107184 | && (k = addAggInfoColumn(pParse->db, pAggInfo))>=0 | 107763 | && (k = addAggInfoColumn(pParse->db, pAggInfo))>=0 |
| 107185 | ){ | 107764 | ){ |
| 107186 | pCol = &pAggInfo->aCol[k]; | 107765 | pCol = &pAggInfo->aCol[k]; |
| 107766 | assert( ExprUseYTab(pExpr) ); | ||
| 107187 | pCol->pTab = pExpr->y.pTab; | 107767 | pCol->pTab = pExpr->y.pTab; |
| 107188 | pCol->iTable = pExpr->iTable; | 107768 | pCol->iTable = pExpr->iTable; |
| 107189 | pCol->iColumn = pExpr->iColumn; | 107769 | pCol->iColumn = pExpr->iColumn; |
| @@ -107247,7 +107827,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ | |||
| 107247 | pItem = &pAggInfo->aFunc[i]; | 107827 | pItem = &pAggInfo->aFunc[i]; |
| 107248 | pItem->pFExpr = pExpr; | 107828 | pItem->pFExpr = pExpr; |
| 107249 | pItem->iMem = ++pParse->nMem; | 107829 | pItem->iMem = ++pParse->nMem; |
| 107250 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | 107830 | assert( ExprUseUToken(pExpr) ); |
| 107251 | pItem->pFunc = sqlite3FindFunction(pParse->db, | 107831 | pItem->pFunc = sqlite3FindFunction(pParse->db, |
| 107252 | pExpr->u.zToken, | 107832 | pExpr->u.zToken, |
| 107253 | pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0); | 107833 | pExpr->x.pList ? pExpr->x.pList->nExpr : 0, enc, 0); |
| @@ -107462,7 +108042,7 @@ static void renameTestSchema( | |||
| 107462 | pParse->colNamesSet = 1; | 108042 | pParse->colNamesSet = 1; |
| 107463 | sqlite3NestedParse(pParse, | 108043 | sqlite3NestedParse(pParse, |
| 107464 | "SELECT 1 " | 108044 | "SELECT 1 " |
| 107465 | "FROM \"%w\"." DFLT_SCHEMA_TABLE " " | 108045 | "FROM \"%w\"." LEGACY_SCHEMA_TABLE " " |
| 107466 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | 108046 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" |
| 107467 | " AND sql NOT LIKE 'create virtual%%'" | 108047 | " AND sql NOT LIKE 'create virtual%%'" |
| 107468 | " AND sqlite_rename_test(%Q, sql, type, name, %d, %Q, %d)=NULL ", | 108048 | " AND sqlite_rename_test(%Q, sql, type, name, %d, %Q, %d)=NULL ", |
| @@ -107473,7 +108053,7 @@ static void renameTestSchema( | |||
| 107473 | if( bTemp==0 ){ | 108053 | if( bTemp==0 ){ |
| 107474 | sqlite3NestedParse(pParse, | 108054 | sqlite3NestedParse(pParse, |
| 107475 | "SELECT 1 " | 108055 | "SELECT 1 " |
| 107476 | "FROM temp." DFLT_SCHEMA_TABLE " " | 108056 | "FROM temp." LEGACY_SCHEMA_TABLE " " |
| 107477 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | 108057 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" |
| 107478 | " AND sql NOT LIKE 'create virtual%%'" | 108058 | " AND sql NOT LIKE 'create virtual%%'" |
| 107479 | " AND sqlite_rename_test(%Q, sql, type, name, 1, %Q, %d)=NULL ", | 108059 | " AND sqlite_rename_test(%Q, sql, type, name, 1, %Q, %d)=NULL ", |
| @@ -107491,14 +108071,14 @@ static void renameTestSchema( | |||
| 107491 | */ | 108071 | */ |
| 107492 | static void renameFixQuotes(Parse *pParse, const char *zDb, int bTemp){ | 108072 | static void renameFixQuotes(Parse *pParse, const char *zDb, int bTemp){ |
| 107493 | sqlite3NestedParse(pParse, | 108073 | sqlite3NestedParse(pParse, |
| 107494 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE | 108074 | "UPDATE \"%w\"." LEGACY_SCHEMA_TABLE |
| 107495 | " SET sql = sqlite_rename_quotefix(%Q, sql)" | 108075 | " SET sql = sqlite_rename_quotefix(%Q, sql)" |
| 107496 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | 108076 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" |
| 107497 | " AND sql NOT LIKE 'create virtual%%'" , zDb, zDb | 108077 | " AND sql NOT LIKE 'create virtual%%'" , zDb, zDb |
| 107498 | ); | 108078 | ); |
| 107499 | if( bTemp==0 ){ | 108079 | if( bTemp==0 ){ |
| 107500 | sqlite3NestedParse(pParse, | 108080 | sqlite3NestedParse(pParse, |
| 107501 | "UPDATE temp." DFLT_SCHEMA_TABLE | 108081 | "UPDATE temp." LEGACY_SCHEMA_TABLE |
| 107502 | " SET sql = sqlite_rename_quotefix('temp', sql)" | 108082 | " SET sql = sqlite_rename_quotefix('temp', sql)" |
| 107503 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | 108083 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" |
| 107504 | " AND sql NOT LIKE 'create virtual%%'" | 108084 | " AND sql NOT LIKE 'create virtual%%'" |
| @@ -107537,9 +108117,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable( | |||
| 107537 | const char *zTabName; /* Original name of the table */ | 108117 | const char *zTabName; /* Original name of the table */ |
| 107538 | Vdbe *v; | 108118 | Vdbe *v; |
| 107539 | VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */ | 108119 | VTable *pVTab = 0; /* Non-zero if this is a v-tab with an xRename() */ |
| 107540 | u32 savedDbFlags; /* Saved value of db->mDbFlags */ | ||
| 107541 | 108120 | ||
| 107542 | savedDbFlags = db->mDbFlags; | ||
| 107543 | if( NEVER(db->mallocFailed) ) goto exit_rename_table; | 108121 | if( NEVER(db->mallocFailed) ) goto exit_rename_table; |
| 107544 | assert( pSrc->nSrc==1 ); | 108122 | assert( pSrc->nSrc==1 ); |
| 107545 | assert( sqlite3BtreeHoldsAllMutexes(pParse->db) ); | 108123 | assert( sqlite3BtreeHoldsAllMutexes(pParse->db) ); |
| @@ -107548,7 +108126,6 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable( | |||
| 107548 | if( !pTab ) goto exit_rename_table; | 108126 | if( !pTab ) goto exit_rename_table; |
| 107549 | iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); | 108127 | iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); |
| 107550 | zDb = db->aDb[iDb].zDbSName; | 108128 | zDb = db->aDb[iDb].zDbSName; |
| 107551 | db->mDbFlags |= DBFLAG_PreferBuiltin; | ||
| 107552 | 108129 | ||
| 107553 | /* Get a NULL terminated version of the new table name. */ | 108130 | /* Get a NULL terminated version of the new table name. */ |
| 107554 | zName = sqlite3NameFromToken(db, pName); | 108131 | zName = sqlite3NameFromToken(db, pName); |
| @@ -107577,7 +108154,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable( | |||
| 107577 | } | 108154 | } |
| 107578 | 108155 | ||
| 107579 | #ifndef SQLITE_OMIT_VIEW | 108156 | #ifndef SQLITE_OMIT_VIEW |
| 107580 | if( pTab->pSelect ){ | 108157 | if( IsView(pTab) ){ |
| 107581 | sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName); | 108158 | sqlite3ErrorMsg(pParse, "view %s may not be altered", pTab->zName); |
| 107582 | goto exit_rename_table; | 108159 | goto exit_rename_table; |
| 107583 | } | 108160 | } |
| @@ -107619,7 +108196,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable( | |||
| 107619 | /* Rewrite all CREATE TABLE, INDEX, TRIGGER or VIEW statements in | 108196 | /* Rewrite all CREATE TABLE, INDEX, TRIGGER or VIEW statements in |
| 107620 | ** the schema to use the new table name. */ | 108197 | ** the schema to use the new table name. */ |
| 107621 | sqlite3NestedParse(pParse, | 108198 | sqlite3NestedParse(pParse, |
| 107622 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " | 108199 | "UPDATE \"%w\"." LEGACY_SCHEMA_TABLE " SET " |
| 107623 | "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, %d) " | 108200 | "sql = sqlite_rename_table(%Q, type, name, sql, %Q, %Q, %d) " |
| 107624 | "WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)" | 108201 | "WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)" |
| 107625 | "AND name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" | 108202 | "AND name NOT LIKE 'sqliteX_%%' ESCAPE 'X'" |
| @@ -107629,7 +108206,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable( | |||
| 107629 | /* Update the tbl_name and name columns of the sqlite_schema table | 108206 | /* Update the tbl_name and name columns of the sqlite_schema table |
| 107630 | ** as required. */ | 108207 | ** as required. */ |
| 107631 | sqlite3NestedParse(pParse, | 108208 | sqlite3NestedParse(pParse, |
| 107632 | "UPDATE %Q." DFLT_SCHEMA_TABLE " SET " | 108209 | "UPDATE %Q." LEGACY_SCHEMA_TABLE " SET " |
| 107633 | "tbl_name = %Q, " | 108210 | "tbl_name = %Q, " |
| 107634 | "name = CASE " | 108211 | "name = CASE " |
| 107635 | "WHEN type='table' THEN %Q " | 108212 | "WHEN type='table' THEN %Q " |
| @@ -107689,7 +108266,6 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable( | |||
| 107689 | exit_rename_table: | 108266 | exit_rename_table: |
| 107690 | sqlite3SrcListDelete(db, pSrc); | 108267 | sqlite3SrcListDelete(db, pSrc); |
| 107691 | sqlite3DbFree(db, zName); | 108268 | sqlite3DbFree(db, zName); |
| 107692 | db->mDbFlags = savedDbFlags; | ||
| 107693 | } | 108269 | } |
| 107694 | 108270 | ||
| 107695 | /* | 108271 | /* |
| @@ -107739,7 +108315,7 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ | |||
| 107739 | zDb = db->aDb[iDb].zDbSName; | 108315 | zDb = db->aDb[iDb].zDbSName; |
| 107740 | zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */ | 108316 | zTab = &pNew->zName[16]; /* Skip the "sqlite_altertab_" prefix on the name */ |
| 107741 | pCol = &pNew->aCol[pNew->nCol-1]; | 108317 | pCol = &pNew->aCol[pNew->nCol-1]; |
| 107742 | pDflt = pCol->pDflt; | 108318 | pDflt = sqlite3ColumnExpr(pNew, pCol); |
| 107743 | pTab = sqlite3FindTable(db, zTab, zDb); | 108319 | pTab = sqlite3FindTable(db, zTab, zDb); |
| 107744 | assert( pTab ); | 108320 | assert( pTab ); |
| 107745 | 108321 | ||
| @@ -107773,7 +108349,8 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ | |||
| 107773 | if( pDflt && pDflt->pLeft->op==TK_NULL ){ | 108349 | if( pDflt && pDflt->pLeft->op==TK_NULL ){ |
| 107774 | pDflt = 0; | 108350 | pDflt = 0; |
| 107775 | } | 108351 | } |
| 107776 | if( (db->flags&SQLITE_ForeignKeys) && pNew->pFKey && pDflt ){ | 108352 | assert( IsOrdinaryTable(pNew) ); |
| 108353 | if( (db->flags&SQLITE_ForeignKeys) && pNew->u.tab.pFKey && pDflt ){ | ||
| 107777 | sqlite3ErrorIfNotEmpty(pParse, zDb, zTab, | 108354 | sqlite3ErrorIfNotEmpty(pParse, zDb, zTab, |
| 107778 | "Cannot add a REFERENCES column with non-NULL default value"); | 108355 | "Cannot add a REFERENCES column with non-NULL default value"); |
| 107779 | } | 108356 | } |
| @@ -107810,31 +108387,30 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ | |||
| 107810 | zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n); | 108387 | zCol = sqlite3DbStrNDup(db, (char*)pColDef->z, pColDef->n); |
| 107811 | if( zCol ){ | 108388 | if( zCol ){ |
| 107812 | char *zEnd = &zCol[pColDef->n-1]; | 108389 | char *zEnd = &zCol[pColDef->n-1]; |
| 107813 | u32 savedDbFlags = db->mDbFlags; | ||
| 107814 | while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){ | 108390 | while( zEnd>zCol && (*zEnd==';' || sqlite3Isspace(*zEnd)) ){ |
| 107815 | *zEnd-- = '\0'; | 108391 | *zEnd-- = '\0'; |
| 107816 | } | 108392 | } |
| 107817 | db->mDbFlags |= DBFLAG_PreferBuiltin; | ||
| 107818 | /* substr() operations on characters, but addColOffset is in bytes. So we | 108393 | /* substr() operations on characters, but addColOffset is in bytes. So we |
| 107819 | ** have to use printf() to translate between these units: */ | 108394 | ** have to use printf() to translate between these units: */ |
| 108395 | assert( IsOrdinaryTable(pTab) ); | ||
| 108396 | assert( IsOrdinaryTable(pNew) ); | ||
| 107820 | sqlite3NestedParse(pParse, | 108397 | sqlite3NestedParse(pParse, |
| 107821 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " | 108398 | "UPDATE \"%w\"." LEGACY_SCHEMA_TABLE " SET " |
| 107822 | "sql = printf('%%.%ds, ',sql) || %Q" | 108399 | "sql = printf('%%.%ds, ',sql) || %Q" |
| 107823 | " || substr(sql,1+length(printf('%%.%ds',sql))) " | 108400 | " || substr(sql,1+length(printf('%%.%ds',sql))) " |
| 107824 | "WHERE type = 'table' AND name = %Q", | 108401 | "WHERE type = 'table' AND name = %Q", |
| 107825 | zDb, pNew->addColOffset, zCol, pNew->addColOffset, | 108402 | zDb, pNew->u.tab.addColOffset, zCol, pNew->u.tab.addColOffset, |
| 107826 | zTab | 108403 | zTab |
| 107827 | ); | 108404 | ); |
| 107828 | sqlite3DbFree(db, zCol); | 108405 | sqlite3DbFree(db, zCol); |
| 107829 | db->mDbFlags = savedDbFlags; | ||
| 107830 | } | 108406 | } |
| 107831 | 108407 | ||
| 107832 | /* Make sure the schema version is at least 3. But do not upgrade | ||
| 107833 | ** from less than 3 to 4, as that will corrupt any preexisting DESC | ||
| 107834 | ** index. | ||
| 107835 | */ | ||
| 107836 | v = sqlite3GetVdbe(pParse); | 108408 | v = sqlite3GetVdbe(pParse); |
| 107837 | if( v ){ | 108409 | if( v ){ |
| 108410 | /* Make sure the schema version is at least 3. But do not upgrade | ||
| 108411 | ** from less than 3 to 4, as that will corrupt any preexisting DESC | ||
| 108412 | ** index. | ||
| 108413 | */ | ||
| 107838 | r1 = sqlite3GetTempReg(pParse); | 108414 | r1 = sqlite3GetTempReg(pParse); |
| 107839 | sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT); | 108415 | sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT); |
| 107840 | sqlite3VdbeUsesBtree(v, iDb); | 108416 | sqlite3VdbeUsesBtree(v, iDb); |
| @@ -107843,10 +108419,25 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){ | |||
| 107843 | VdbeCoverage(v); | 108419 | VdbeCoverage(v); |
| 107844 | sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3); | 108420 | sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3); |
| 107845 | sqlite3ReleaseTempReg(pParse, r1); | 108421 | sqlite3ReleaseTempReg(pParse, r1); |
| 107846 | } | ||
| 107847 | 108422 | ||
| 107848 | /* Reload the table definition */ | 108423 | /* Reload the table definition */ |
| 107849 | renameReloadSchema(pParse, iDb, INITFLAG_AlterRename); | 108424 | renameReloadSchema(pParse, iDb, INITFLAG_AlterAdd); |
| 108425 | |||
| 108426 | /* Verify that constraints are still satisfied */ | ||
| 108427 | if( pNew->pCheck!=0 | ||
| 108428 | || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0) | ||
| 108429 | ){ | ||
| 108430 | sqlite3NestedParse(pParse, | ||
| 108431 | "SELECT CASE WHEN quick_check GLOB 'CHECK*'" | ||
| 108432 | " THEN raise(ABORT,'CHECK constraint failed')" | ||
| 108433 | " ELSE raise(ABORT,'NOT NULL constraint failed')" | ||
| 108434 | " END" | ||
| 108435 | " FROM pragma_quick_check(\"%w\",\"%w\")" | ||
| 108436 | " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'", | ||
| 108437 | zTab, zDb | ||
| 108438 | ); | ||
| 108439 | } | ||
| 108440 | } | ||
| 107850 | } | 108441 | } |
| 107851 | 108442 | ||
| 107852 | /* | 108443 | /* |
| @@ -107887,7 +108478,7 @@ SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){ | |||
| 107887 | #endif | 108478 | #endif |
| 107888 | 108479 | ||
| 107889 | /* Make sure this is not an attempt to ALTER a view. */ | 108480 | /* Make sure this is not an attempt to ALTER a view. */ |
| 107890 | if( pTab->pSelect ){ | 108481 | if( IsView(pTab) ){ |
| 107891 | sqlite3ErrorMsg(pParse, "Cannot add a column to a view"); | 108482 | sqlite3ErrorMsg(pParse, "Cannot add a column to a view"); |
| 107892 | goto exit_begin_add_column; | 108483 | goto exit_begin_add_column; |
| 107893 | } | 108484 | } |
| @@ -107896,7 +108487,8 @@ SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){ | |||
| 107896 | } | 108487 | } |
| 107897 | 108488 | ||
| 107898 | sqlite3MayAbort(pParse); | 108489 | sqlite3MayAbort(pParse); |
| 107899 | assert( pTab->addColOffset>0 ); | 108490 | assert( IsOrdinaryTable(pTab) ); |
| 108491 | assert( pTab->u.tab.addColOffset>0 ); | ||
| 107900 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | 108492 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 107901 | 108493 | ||
| 107902 | /* Put a copy of the Table struct in Parse.pNewTable for the | 108494 | /* Put a copy of the Table struct in Parse.pNewTable for the |
| @@ -107923,13 +108515,13 @@ SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){ | |||
| 107923 | memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol); | 108515 | memcpy(pNew->aCol, pTab->aCol, sizeof(Column)*pNew->nCol); |
| 107924 | for(i=0; i<pNew->nCol; i++){ | 108516 | for(i=0; i<pNew->nCol; i++){ |
| 107925 | Column *pCol = &pNew->aCol[i]; | 108517 | Column *pCol = &pNew->aCol[i]; |
| 107926 | pCol->zName = sqlite3DbStrDup(db, pCol->zName); | 108518 | pCol->zCnName = sqlite3DbStrDup(db, pCol->zCnName); |
| 107927 | pCol->hName = sqlite3StrIHash(pCol->zName); | 108519 | pCol->hName = sqlite3StrIHash(pCol->zCnName); |
| 107928 | pCol->zColl = 0; | ||
| 107929 | pCol->pDflt = 0; | ||
| 107930 | } | 108520 | } |
| 108521 | assert( IsOrdinaryTable(pNew) ); | ||
| 108522 | pNew->u.tab.pDfltList = sqlite3ExprListDup(db, pTab->u.tab.pDfltList, 0); | ||
| 107931 | pNew->pSchema = db->aDb[iDb].pSchema; | 108523 | pNew->pSchema = db->aDb[iDb].pSchema; |
| 107932 | pNew->addColOffset = pTab->addColOffset; | 108524 | pNew->u.tab.addColOffset = pTab->u.tab.addColOffset; |
| 107933 | pNew->nTabRef = 1; | 108525 | pNew->nTabRef = 1; |
| 107934 | 108526 | ||
| 107935 | exit_begin_add_column: | 108527 | exit_begin_add_column: |
| @@ -107949,7 +108541,7 @@ exit_begin_add_column: | |||
| 107949 | static int isRealTable(Parse *pParse, Table *pTab, int bDrop){ | 108541 | static int isRealTable(Parse *pParse, Table *pTab, int bDrop){ |
| 107950 | const char *zType = 0; | 108542 | const char *zType = 0; |
| 107951 | #ifndef SQLITE_OMIT_VIEW | 108543 | #ifndef SQLITE_OMIT_VIEW |
| 107952 | if( pTab->pSelect ){ | 108544 | if( IsView(pTab) ){ |
| 107953 | zType = "view"; | 108545 | zType = "view"; |
| 107954 | } | 108546 | } |
| 107955 | #endif | 108547 | #endif |
| @@ -108016,7 +108608,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn( | |||
| 108016 | zOld = sqlite3NameFromToken(db, pOld); | 108608 | zOld = sqlite3NameFromToken(db, pOld); |
| 108017 | if( !zOld ) goto exit_rename_column; | 108609 | if( !zOld ) goto exit_rename_column; |
| 108018 | for(iCol=0; iCol<pTab->nCol; iCol++){ | 108610 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 108019 | if( 0==sqlite3StrICmp(pTab->aCol[iCol].zName, zOld) ) break; | 108611 | if( 0==sqlite3StrICmp(pTab->aCol[iCol].zCnName, zOld) ) break; |
| 108020 | } | 108612 | } |
| 108021 | if( iCol==pTab->nCol ){ | 108613 | if( iCol==pTab->nCol ){ |
| 108022 | sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zOld); | 108614 | sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zOld); |
| @@ -108037,18 +108629,17 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn( | |||
| 108037 | assert( pNew->n>0 ); | 108629 | assert( pNew->n>0 ); |
| 108038 | bQuote = sqlite3Isquote(pNew->z[0]); | 108630 | bQuote = sqlite3Isquote(pNew->z[0]); |
| 108039 | sqlite3NestedParse(pParse, | 108631 | sqlite3NestedParse(pParse, |
| 108040 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " | 108632 | "UPDATE \"%w\"." LEGACY_SCHEMA_TABLE " SET " |
| 108041 | "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, %d) " | 108633 | "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, %d) " |
| 108042 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' " | 108634 | "WHERE name NOT LIKE 'sqliteX_%%' ESCAPE 'X' " |
| 108043 | " AND (type != 'index' OR tbl_name = %Q)" | 108635 | " AND (type != 'index' OR tbl_name = %Q)", |
| 108044 | " AND sql NOT LIKE 'create virtual%%'", | ||
| 108045 | zDb, | 108636 | zDb, |
| 108046 | zDb, pTab->zName, iCol, zNew, bQuote, iSchema==1, | 108637 | zDb, pTab->zName, iCol, zNew, bQuote, iSchema==1, |
| 108047 | pTab->zName | 108638 | pTab->zName |
| 108048 | ); | 108639 | ); |
| 108049 | 108640 | ||
| 108050 | sqlite3NestedParse(pParse, | 108641 | sqlite3NestedParse(pParse, |
| 108051 | "UPDATE temp." DFLT_SCHEMA_TABLE " SET " | 108642 | "UPDATE temp." LEGACY_SCHEMA_TABLE " SET " |
| 108052 | "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, 1) " | 108643 | "sql = sqlite_rename_column(sql, type, name, %Q, %Q, %d, %Q, %d, 1) " |
| 108053 | "WHERE type IN ('trigger', 'view')", | 108644 | "WHERE type IN ('trigger', 'view')", |
| 108054 | zDb, pTab->zName, iCol, zNew, bQuote | 108645 | zDb, pTab->zName, iCol, zNew, bQuote |
| @@ -108083,7 +108674,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn( | |||
| 108083 | ** the parse tree. | 108674 | ** the parse tree. |
| 108084 | */ | 108675 | */ |
| 108085 | struct RenameToken { | 108676 | struct RenameToken { |
| 108086 | void *p; /* Parse tree element created by token t */ | 108677 | const void *p; /* Parse tree element created by token t */ |
| 108087 | Token t; /* The token that created parse tree element p */ | 108678 | Token t; /* The token that created parse tree element p */ |
| 108088 | RenameToken *pNext; /* Next is a list of all RenameToken objects */ | 108679 | RenameToken *pNext; /* Next is a list of all RenameToken objects */ |
| 108089 | }; | 108680 | }; |
| @@ -108125,9 +108716,9 @@ struct RenameCtx { | |||
| 108125 | ** Technically, as x no longer points into a valid object or to the byte | 108716 | ** Technically, as x no longer points into a valid object or to the byte |
| 108126 | ** following a valid object, it may not be used in comparison operations. | 108717 | ** following a valid object, it may not be used in comparison operations. |
| 108127 | */ | 108718 | */ |
| 108128 | static void renameTokenCheckAll(Parse *pParse, void *pPtr){ | 108719 | static void renameTokenCheckAll(Parse *pParse, const void *pPtr){ |
| 108129 | if( pParse->nErr==0 && pParse->db->mallocFailed==0 ){ | 108720 | if( pParse->nErr==0 && pParse->db->mallocFailed==0 ){ |
| 108130 | RenameToken *p; | 108721 | const RenameToken *p; |
| 108131 | u8 i = 0; | 108722 | u8 i = 0; |
| 108132 | for(p=pParse->pRename; p; p=p->pNext){ | 108723 | for(p=pParse->pRename; p; p=p->pNext){ |
| 108133 | if( p->p ){ | 108724 | if( p->p ){ |
| @@ -108153,7 +108744,11 @@ static void renameTokenCheckAll(Parse *pParse, void *pPtr){ | |||
| 108153 | ** with tail recursion in tokenExpr() routine, for a small performance | 108744 | ** with tail recursion in tokenExpr() routine, for a small performance |
| 108154 | ** improvement. | 108745 | ** improvement. |
| 108155 | */ | 108746 | */ |
| 108156 | SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){ | 108747 | SQLITE_PRIVATE const void *sqlite3RenameTokenMap( |
| 108748 | Parse *pParse, | ||
| 108749 | const void *pPtr, | ||
| 108750 | const Token *pToken | ||
| 108751 | ){ | ||
| 108157 | RenameToken *pNew; | 108752 | RenameToken *pNew; |
| 108158 | assert( pPtr || pParse->db->mallocFailed ); | 108753 | assert( pPtr || pParse->db->mallocFailed ); |
| 108159 | renameTokenCheckAll(pParse, pPtr); | 108754 | renameTokenCheckAll(pParse, pPtr); |
| @@ -108175,7 +108770,7 @@ SQLITE_PRIVATE void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pTo | |||
| 108175 | ** with parse tree element pFrom. This function remaps the associated token | 108770 | ** with parse tree element pFrom. This function remaps the associated token |
| 108176 | ** to parse tree element pTo. | 108771 | ** to parse tree element pTo. |
| 108177 | */ | 108772 | */ |
| 108178 | SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse *pParse, void *pTo, void *pFrom){ | 108773 | SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse *pParse, const void *pTo, const void *pFrom){ |
| 108179 | RenameToken *p; | 108774 | RenameToken *p; |
| 108180 | renameTokenCheckAll(pParse, pTo); | 108775 | renameTokenCheckAll(pParse, pTo); |
| 108181 | for(p=pParse->pRename; p; p=p->pNext){ | 108776 | for(p=pParse->pRename; p; p=p->pNext){ |
| @@ -108191,7 +108786,10 @@ SQLITE_PRIVATE void sqlite3RenameTokenRemap(Parse *pParse, void *pTo, void *pFro | |||
| 108191 | */ | 108786 | */ |
| 108192 | static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ | 108787 | static int renameUnmapExprCb(Walker *pWalker, Expr *pExpr){ |
| 108193 | Parse *pParse = pWalker->pParse; | 108788 | Parse *pParse = pWalker->pParse; |
| 108194 | sqlite3RenameTokenRemap(pParse, 0, (void*)pExpr); | 108789 | sqlite3RenameTokenRemap(pParse, 0, (const void*)pExpr); |
| 108790 | if( ExprUseYTab(pExpr) ){ | ||
| 108791 | sqlite3RenameTokenRemap(pParse, 0, (const void*)&pExpr->y.pTab); | ||
| 108792 | } | ||
| 108195 | return WRC_Continue; | 108793 | return WRC_Continue; |
| 108196 | } | 108794 | } |
| 108197 | 108795 | ||
| @@ -108221,6 +108819,7 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){ | |||
| 108221 | memset(&sNC, 0, sizeof(sNC)); | 108819 | memset(&sNC, 0, sizeof(sNC)); |
| 108222 | sNC.pParse = pParse; | 108820 | sNC.pParse = pParse; |
| 108223 | if( pCopy ) sqlite3SelectPrep(sNC.pParse, p, &sNC); | 108821 | if( pCopy ) sqlite3SelectPrep(sNC.pParse, p, &sNC); |
| 108822 | if( sNC.pParse->db->mallocFailed ) return; | ||
| 108224 | sqlite3WalkSelect(pWalker, p); | 108823 | sqlite3WalkSelect(pWalker, p); |
| 108225 | sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols); | 108824 | sqlite3RenameExprlistUnmap(pParse, pWith->a[i].pCols); |
| 108226 | } | 108825 | } |
| @@ -108235,12 +108834,12 @@ static void renameWalkWith(Walker *pWalker, Select *pSelect){ | |||
| 108235 | */ | 108834 | */ |
| 108236 | static void unmapColumnIdlistNames( | 108835 | static void unmapColumnIdlistNames( |
| 108237 | Parse *pParse, | 108836 | Parse *pParse, |
| 108238 | IdList *pIdList | 108837 | const IdList *pIdList |
| 108239 | ){ | 108838 | ){ |
| 108240 | if( pIdList ){ | 108839 | if( pIdList ){ |
| 108241 | int ii; | 108840 | int ii; |
| 108242 | for(ii=0; ii<pIdList->nId; ii++){ | 108841 | for(ii=0; ii<pIdList->nId; ii++){ |
| 108243 | sqlite3RenameTokenRemap(pParse, 0, (void*)pIdList->a[ii].zName); | 108842 | sqlite3RenameTokenRemap(pParse, 0, (const void*)pIdList->a[ii].zName); |
| 108244 | } | 108843 | } |
| 108245 | } | 108844 | } |
| 108246 | } | 108845 | } |
| @@ -108252,9 +108851,9 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ | |||
| 108252 | Parse *pParse = pWalker->pParse; | 108851 | Parse *pParse = pWalker->pParse; |
| 108253 | int i; | 108852 | int i; |
| 108254 | if( pParse->nErr ) return WRC_Abort; | 108853 | if( pParse->nErr ) return WRC_Abort; |
| 108854 | testcase( p->selFlags & SF_View ); | ||
| 108855 | testcase( p->selFlags & SF_CopyCte ); | ||
| 108255 | if( p->selFlags & (SF_View|SF_CopyCte) ){ | 108856 | if( p->selFlags & (SF_View|SF_CopyCte) ){ |
| 108256 | testcase( p->selFlags & SF_View ); | ||
| 108257 | testcase( p->selFlags & SF_CopyCte ); | ||
| 108258 | return WRC_Prune; | 108857 | return WRC_Prune; |
| 108259 | } | 108858 | } |
| 108260 | if( ALWAYS(p->pEList) ){ | 108859 | if( ALWAYS(p->pEList) ){ |
| @@ -108269,7 +108868,7 @@ static int renameUnmapSelectCb(Walker *pWalker, Select *p){ | |||
| 108269 | SrcList *pSrc = p->pSrc; | 108868 | SrcList *pSrc = p->pSrc; |
| 108270 | for(i=0; i<pSrc->nSrc; i++){ | 108869 | for(i=0; i<pSrc->nSrc; i++){ |
| 108271 | sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName); | 108870 | sqlite3RenameTokenRemap(pParse, 0, (void*)pSrc->a[i].zName); |
| 108272 | if( sqlite3WalkExpr(pWalker, pSrc->a[i].pOn) ) return WRC_Abort; | 108871 | sqlite3WalkExpr(pWalker, pSrc->a[i].pOn); |
| 108273 | unmapColumnIdlistNames(pParse, pSrc->a[i].pUsing); | 108872 | unmapColumnIdlistNames(pParse, pSrc->a[i].pUsing); |
| 108274 | } | 108873 | } |
| 108275 | } | 108874 | } |
| @@ -108337,7 +108936,7 @@ static void renameTokenFree(sqlite3 *db, RenameToken *pToken){ | |||
| 108337 | static RenameToken *renameTokenFind( | 108936 | static RenameToken *renameTokenFind( |
| 108338 | Parse *pParse, | 108937 | Parse *pParse, |
| 108339 | struct RenameCtx *pCtx, | 108938 | struct RenameCtx *pCtx, |
| 108340 | void *pPtr | 108939 | const void *pPtr |
| 108341 | ){ | 108940 | ){ |
| 108342 | RenameToken **pp; | 108941 | RenameToken **pp; |
| 108343 | if( NEVER(pPtr==0) ){ | 108942 | if( NEVER(pPtr==0) ){ |
| @@ -108391,6 +108990,7 @@ static int renameColumnExprCb(Walker *pWalker, Expr *pExpr){ | |||
| 108391 | renameTokenFind(pWalker->pParse, p, (void*)pExpr); | 108990 | renameTokenFind(pWalker->pParse, p, (void*)pExpr); |
| 108392 | }else if( pExpr->op==TK_COLUMN | 108991 | }else if( pExpr->op==TK_COLUMN |
| 108393 | && pExpr->iColumn==p->iCol | 108992 | && pExpr->iColumn==p->iCol |
| 108993 | && ALWAYS(ExprUseYTab(pExpr)) | ||
| 108394 | && p->pTab==pExpr->y.pTab | 108994 | && p->pTab==pExpr->y.pTab |
| 108395 | ){ | 108995 | ){ |
| 108396 | renameTokenFind(pWalker->pParse, p, (void*)pExpr); | 108996 | renameTokenFind(pWalker->pParse, p, (void*)pExpr); |
| @@ -108456,18 +109056,18 @@ static void renameColumnParseError( | |||
| 108456 | static void renameColumnElistNames( | 109056 | static void renameColumnElistNames( |
| 108457 | Parse *pParse, | 109057 | Parse *pParse, |
| 108458 | RenameCtx *pCtx, | 109058 | RenameCtx *pCtx, |
| 108459 | ExprList *pEList, | 109059 | const ExprList *pEList, |
| 108460 | const char *zOld | 109060 | const char *zOld |
| 108461 | ){ | 109061 | ){ |
| 108462 | if( pEList ){ | 109062 | if( pEList ){ |
| 108463 | int i; | 109063 | int i; |
| 108464 | for(i=0; i<pEList->nExpr; i++){ | 109064 | for(i=0; i<pEList->nExpr; i++){ |
| 108465 | char *zName = pEList->a[i].zEName; | 109065 | const char *zName = pEList->a[i].zEName; |
| 108466 | if( ALWAYS(pEList->a[i].eEName==ENAME_NAME) | 109066 | if( ALWAYS(pEList->a[i].eEName==ENAME_NAME) |
| 108467 | && ALWAYS(zName!=0) | 109067 | && ALWAYS(zName!=0) |
| 108468 | && 0==sqlite3_stricmp(zName, zOld) | 109068 | && 0==sqlite3_stricmp(zName, zOld) |
| 108469 | ){ | 109069 | ){ |
| 108470 | renameTokenFind(pParse, pCtx, (void*)zName); | 109070 | renameTokenFind(pParse, pCtx, (const void*)zName); |
| 108471 | } | 109071 | } |
| 108472 | } | 109072 | } |
| 108473 | } | 109073 | } |
| @@ -108481,15 +109081,15 @@ static void renameColumnElistNames( | |||
| 108481 | static void renameColumnIdlistNames( | 109081 | static void renameColumnIdlistNames( |
| 108482 | Parse *pParse, | 109082 | Parse *pParse, |
| 108483 | RenameCtx *pCtx, | 109083 | RenameCtx *pCtx, |
| 108484 | IdList *pIdList, | 109084 | const IdList *pIdList, |
| 108485 | const char *zOld | 109085 | const char *zOld |
| 108486 | ){ | 109086 | ){ |
| 108487 | if( pIdList ){ | 109087 | if( pIdList ){ |
| 108488 | int i; | 109088 | int i; |
| 108489 | for(i=0; i<pIdList->nId; i++){ | 109089 | for(i=0; i<pIdList->nId; i++){ |
| 108490 | char *zName = pIdList->a[i].zName; | 109090 | const char *zName = pIdList->a[i].zName; |
| 108491 | if( 0==sqlite3_stricmp(zName, zOld) ){ | 109091 | if( 0==sqlite3_stricmp(zName, zOld) ){ |
| 108492 | renameTokenFind(pParse, pCtx, (void*)zName); | 109092 | renameTokenFind(pParse, pCtx, (const void*)zName); |
| 108493 | } | 109093 | } |
| 108494 | } | 109094 | } |
| 108495 | } | 109095 | } |
| @@ -108715,6 +109315,9 @@ static int renameResolveTrigger(Parse *pParse){ | |||
| 108715 | } | 109315 | } |
| 108716 | } | 109316 | } |
| 108717 | } | 109317 | } |
| 109318 | if( rc==SQLITE_OK && db->mallocFailed ){ | ||
| 109319 | rc = SQLITE_NOMEM; | ||
| 109320 | } | ||
| 108718 | sNC.pSrcList = pSrc; | 109321 | sNC.pSrcList = pSrc; |
| 108719 | if( rc==SQLITE_OK && pStep->pWhere ){ | 109322 | if( rc==SQLITE_OK && pStep->pWhere ){ |
| 108720 | rc = sqlite3ResolveExprNames(&sNC, pStep->pWhere); | 109323 | rc = sqlite3ResolveExprNames(&sNC, pStep->pWhere); |
| @@ -108862,7 +109465,7 @@ static void renameColumnFunc( | |||
| 108862 | sqlite3BtreeLeaveAll(db); | 109465 | sqlite3BtreeLeaveAll(db); |
| 108863 | return; | 109466 | return; |
| 108864 | } | 109467 | } |
| 108865 | zOld = pTab->aCol[iCol].zName; | 109468 | zOld = pTab->aCol[iCol].zCnName; |
| 108866 | memset(&sCtx, 0, sizeof(sCtx)); | 109469 | memset(&sCtx, 0, sizeof(sCtx)); |
| 108867 | sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol); | 109470 | sCtx.iCol = ((iCol==pTab->iPKey) ? -1 : iCol); |
| 108868 | 109471 | ||
| @@ -108881,8 +109484,8 @@ static void renameColumnFunc( | |||
| 108881 | sCtx.pTab = pTab; | 109484 | sCtx.pTab = pTab; |
| 108882 | if( rc!=SQLITE_OK ) goto renameColumnFunc_done; | 109485 | if( rc!=SQLITE_OK ) goto renameColumnFunc_done; |
| 108883 | if( sParse.pNewTable ){ | 109486 | if( sParse.pNewTable ){ |
| 108884 | Select *pSelect = sParse.pNewTable->pSelect; | 109487 | if( IsView(sParse.pNewTable) ){ |
| 108885 | if( pSelect ){ | 109488 | Select *pSelect = sParse.pNewTable->u.view.pSelect; |
| 108886 | pSelect->selFlags &= ~SF_View; | 109489 | pSelect->selFlags &= ~SF_View; |
| 108887 | sParse.rc = SQLITE_OK; | 109490 | sParse.rc = SQLITE_OK; |
| 108888 | sqlite3SelectPrep(&sParse, pSelect, 0); | 109491 | sqlite3SelectPrep(&sParse, pSelect, 0); |
| @@ -108891,16 +109494,15 @@ static void renameColumnFunc( | |||
| 108891 | sqlite3WalkSelect(&sWalker, pSelect); | 109494 | sqlite3WalkSelect(&sWalker, pSelect); |
| 108892 | } | 109495 | } |
| 108893 | if( rc!=SQLITE_OK ) goto renameColumnFunc_done; | 109496 | if( rc!=SQLITE_OK ) goto renameColumnFunc_done; |
| 108894 | }else{ | 109497 | }else if( IsOrdinaryTable(sParse.pNewTable) ){ |
| 108895 | /* A regular table */ | 109498 | /* A regular table */ |
| 108896 | int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName); | 109499 | int bFKOnly = sqlite3_stricmp(zTable, sParse.pNewTable->zName); |
| 108897 | FKey *pFKey; | 109500 | FKey *pFKey; |
| 108898 | assert( sParse.pNewTable->pSelect==0 ); | ||
| 108899 | sCtx.pTab = sParse.pNewTable; | 109501 | sCtx.pTab = sParse.pNewTable; |
| 108900 | if( bFKOnly==0 ){ | 109502 | if( bFKOnly==0 ){ |
| 108901 | if( iCol<sParse.pNewTable->nCol ){ | 109503 | if( iCol<sParse.pNewTable->nCol ){ |
| 108902 | renameTokenFind( | 109504 | renameTokenFind( |
| 108903 | &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zName | 109505 | &sParse, &sCtx, (void*)sParse.pNewTable->aCol[iCol].zCnName |
| 108904 | ); | 109506 | ); |
| 108905 | } | 109507 | } |
| 108906 | if( sCtx.iCol<0 ){ | 109508 | if( sCtx.iCol<0 ){ |
| @@ -108915,12 +109517,15 @@ static void renameColumnFunc( | |||
| 108915 | } | 109517 | } |
| 108916 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS | 109518 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 108917 | for(i=0; i<sParse.pNewTable->nCol; i++){ | 109519 | for(i=0; i<sParse.pNewTable->nCol; i++){ |
| 108918 | sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt); | 109520 | Expr *pExpr = sqlite3ColumnExpr(sParse.pNewTable, |
| 109521 | &sParse.pNewTable->aCol[i]); | ||
| 109522 | sqlite3WalkExpr(&sWalker, pExpr); | ||
| 108919 | } | 109523 | } |
| 108920 | #endif | 109524 | #endif |
| 108921 | } | 109525 | } |
| 108922 | 109526 | ||
| 108923 | for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){ | 109527 | assert( IsOrdinaryTable(sParse.pNewTable) ); |
| 109528 | for(pFKey=sParse.pNewTable->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){ | ||
| 108924 | for(i=0; i<pFKey->nCol; i++){ | 109529 | for(i=0; i<pFKey->nCol; i++){ |
| 108925 | if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){ | 109530 | if( bFKOnly==0 && pFKey->aCol[i].iFrom==iCol ){ |
| 108926 | renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]); | 109531 | renameTokenFind(&sParse, &sCtx, (void*)&pFKey->aCol[i]); |
| @@ -108991,7 +109596,10 @@ renameColumnFunc_done: | |||
| 108991 | */ | 109596 | */ |
| 108992 | static int renameTableExprCb(Walker *pWalker, Expr *pExpr){ | 109597 | static int renameTableExprCb(Walker *pWalker, Expr *pExpr){ |
| 108993 | RenameCtx *p = pWalker->u.pRename; | 109598 | RenameCtx *p = pWalker->u.pRename; |
| 108994 | if( pExpr->op==TK_COLUMN && p->pTab==pExpr->y.pTab ){ | 109599 | if( pExpr->op==TK_COLUMN |
| 109600 | && ALWAYS(ExprUseYTab(pExpr)) | ||
| 109601 | && p->pTab==pExpr->y.pTab | ||
| 109602 | ){ | ||
| 108995 | renameTokenFind(pWalker->pParse, p, (void*)&pExpr->y.pTab); | 109603 | renameTokenFind(pWalker->pParse, p, (void*)&pExpr->y.pTab); |
| 108996 | } | 109604 | } |
| 108997 | return WRC_Continue; | 109605 | return WRC_Continue; |
| @@ -109086,28 +109694,31 @@ static void renameTableFunc( | |||
| 109086 | if( sParse.pNewTable ){ | 109694 | if( sParse.pNewTable ){ |
| 109087 | Table *pTab = sParse.pNewTable; | 109695 | Table *pTab = sParse.pNewTable; |
| 109088 | 109696 | ||
| 109089 | if( pTab->pSelect ){ | 109697 | if( IsView(pTab) ){ |
| 109090 | if( isLegacy==0 ){ | 109698 | if( isLegacy==0 ){ |
| 109091 | Select *pSelect = pTab->pSelect; | 109699 | Select *pSelect = pTab->u.view.pSelect; |
| 109092 | NameContext sNC; | 109700 | NameContext sNC; |
| 109093 | memset(&sNC, 0, sizeof(sNC)); | 109701 | memset(&sNC, 0, sizeof(sNC)); |
| 109094 | sNC.pParse = &sParse; | 109702 | sNC.pParse = &sParse; |
| 109095 | 109703 | ||
| 109096 | assert( pSelect->selFlags & SF_View ); | 109704 | assert( pSelect->selFlags & SF_View ); |
| 109097 | pSelect->selFlags &= ~SF_View; | 109705 | pSelect->selFlags &= ~SF_View; |
| 109098 | sqlite3SelectPrep(&sParse, pTab->pSelect, &sNC); | 109706 | sqlite3SelectPrep(&sParse, pTab->u.view.pSelect, &sNC); |
| 109099 | if( sParse.nErr ){ | 109707 | if( sParse.nErr ){ |
| 109100 | rc = sParse.rc; | 109708 | rc = sParse.rc; |
| 109101 | }else{ | 109709 | }else{ |
| 109102 | sqlite3WalkSelect(&sWalker, pTab->pSelect); | 109710 | sqlite3WalkSelect(&sWalker, pTab->u.view.pSelect); |
| 109103 | } | 109711 | } |
| 109104 | } | 109712 | } |
| 109105 | }else{ | 109713 | }else{ |
| 109106 | /* Modify any FK definitions to point to the new table. */ | 109714 | /* Modify any FK definitions to point to the new table. */ |
| 109107 | #ifndef SQLITE_OMIT_FOREIGN_KEY | 109715 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 109108 | if( isLegacy==0 || (db->flags & SQLITE_ForeignKeys) ){ | 109716 | if( (isLegacy==0 || (db->flags & SQLITE_ForeignKeys)) |
| 109717 | && !IsVirtual(pTab) | ||
| 109718 | ){ | ||
| 109109 | FKey *pFKey; | 109719 | FKey *pFKey; |
| 109110 | for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){ | 109720 | assert( IsOrdinaryTable(pTab) ); |
| 109721 | for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){ | ||
| 109111 | if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){ | 109722 | if( sqlite3_stricmp(pFKey->zTo, zOld)==0 ){ |
| 109112 | renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo); | 109723 | renameTokenFind(&sParse, &sCtx, (void*)pFKey->zTo); |
| 109113 | } | 109724 | } |
| @@ -109184,7 +109795,7 @@ static void renameTableFunc( | |||
| 109184 | 109795 | ||
| 109185 | static int renameQuotefixExprCb(Walker *pWalker, Expr *pExpr){ | 109796 | static int renameQuotefixExprCb(Walker *pWalker, Expr *pExpr){ |
| 109186 | if( pExpr->op==TK_STRING && (pExpr->flags & EP_DblQuoted) ){ | 109797 | if( pExpr->op==TK_STRING && (pExpr->flags & EP_DblQuoted) ){ |
| 109187 | renameTokenFind(pWalker->pParse, pWalker->u.pRename, (void*)pExpr); | 109798 | renameTokenFind(pWalker->pParse, pWalker->u.pRename, (const void*)pExpr); |
| 109188 | } | 109799 | } |
| 109189 | return WRC_Continue; | 109800 | return WRC_Continue; |
| 109190 | } | 109801 | } |
| @@ -109247,8 +109858,8 @@ static void renameQuotefixFunc( | |||
| 109247 | sWalker.u.pRename = &sCtx; | 109858 | sWalker.u.pRename = &sCtx; |
| 109248 | 109859 | ||
| 109249 | if( sParse.pNewTable ){ | 109860 | if( sParse.pNewTable ){ |
| 109250 | Select *pSelect = sParse.pNewTable->pSelect; | 109861 | if( IsView(sParse.pNewTable) ){ |
| 109251 | if( pSelect ){ | 109862 | Select *pSelect = sParse.pNewTable->u.view.pSelect; |
| 109252 | pSelect->selFlags &= ~SF_View; | 109863 | pSelect->selFlags &= ~SF_View; |
| 109253 | sParse.rc = SQLITE_OK; | 109864 | sParse.rc = SQLITE_OK; |
| 109254 | sqlite3SelectPrep(&sParse, pSelect, 0); | 109865 | sqlite3SelectPrep(&sParse, pSelect, 0); |
| @@ -109261,7 +109872,9 @@ static void renameQuotefixFunc( | |||
| 109261 | sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck); | 109872 | sqlite3WalkExprList(&sWalker, sParse.pNewTable->pCheck); |
| 109262 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS | 109873 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 109263 | for(i=0; i<sParse.pNewTable->nCol; i++){ | 109874 | for(i=0; i<sParse.pNewTable->nCol; i++){ |
| 109264 | sqlite3WalkExpr(&sWalker, sParse.pNewTable->aCol[i].pDflt); | 109875 | sqlite3WalkExpr(&sWalker, |
| 109876 | sqlite3ColumnExpr(sParse.pNewTable, | ||
| 109877 | &sParse.pNewTable->aCol[i])); | ||
| 109265 | } | 109878 | } |
| 109266 | #endif /* SQLITE_OMIT_GENERATED_COLUMNS */ | 109879 | #endif /* SQLITE_OMIT_GENERATED_COLUMNS */ |
| 109267 | } | 109880 | } |
| @@ -109344,11 +109957,11 @@ static void renameTableTest( | |||
| 109344 | rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); | 109957 | rc = renameParseSql(&sParse, zDb, db, zInput, bTemp); |
| 109345 | db->flags |= (flags & (SQLITE_DqsDML|SQLITE_DqsDDL)); | 109958 | db->flags |= (flags & (SQLITE_DqsDML|SQLITE_DqsDDL)); |
| 109346 | if( rc==SQLITE_OK ){ | 109959 | if( rc==SQLITE_OK ){ |
| 109347 | if( isLegacy==0 && sParse.pNewTable && sParse.pNewTable->pSelect ){ | 109960 | if( isLegacy==0 && sParse.pNewTable && IsView(sParse.pNewTable) ){ |
| 109348 | NameContext sNC; | 109961 | NameContext sNC; |
| 109349 | memset(&sNC, 0, sizeof(sNC)); | 109962 | memset(&sNC, 0, sizeof(sNC)); |
| 109350 | sNC.pParse = &sParse; | 109963 | sNC.pParse = &sParse; |
| 109351 | sqlite3SelectPrep(&sParse, sParse.pNewTable->pSelect, &sNC); | 109964 | sqlite3SelectPrep(&sParse, sParse.pNewTable->u.view.pSelect, &sNC); |
| 109352 | if( sParse.nErr ) rc = sParse.rc; | 109965 | if( sParse.nErr ) rc = sParse.rc; |
| 109353 | } | 109966 | } |
| 109354 | 109967 | ||
| @@ -109419,13 +110032,14 @@ static void dropColumnFunc( | |||
| 109419 | goto drop_column_done; | 110032 | goto drop_column_done; |
| 109420 | } | 110033 | } |
| 109421 | 110034 | ||
| 109422 | pCol = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol].zName); | 110035 | pCol = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol].zCnName); |
| 109423 | if( iCol<pTab->nCol-1 ){ | 110036 | if( iCol<pTab->nCol-1 ){ |
| 109424 | RenameToken *pEnd; | 110037 | RenameToken *pEnd; |
| 109425 | pEnd = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol+1].zName); | 110038 | pEnd = renameTokenFind(&sParse, 0, (void*)pTab->aCol[iCol+1].zCnName); |
| 109426 | zEnd = (const char*)pEnd->t.z; | 110039 | zEnd = (const char*)pEnd->t.z; |
| 109427 | }else{ | 110040 | }else{ |
| 109428 | zEnd = (const char*)&zSql[pTab->addColOffset]; | 110041 | assert( IsOrdinaryTable(pTab) ); |
| 110042 | zEnd = (const char*)&zSql[pTab->u.tab.addColOffset]; | ||
| 109429 | while( ALWAYS(pCol->t.z[0]!=0) && pCol->t.z[0]!=',' ) pCol->t.z--; | 110043 | while( ALWAYS(pCol->t.z[0]!=0) && pCol->t.z[0]!=',' ) pCol->t.z--; |
| 109430 | } | 110044 | } |
| 109431 | 110045 | ||
| @@ -109451,7 +110065,7 @@ drop_column_done: | |||
| 109451 | ** statement. Argument pSrc contains the possibly qualified name of the | 110065 | ** statement. Argument pSrc contains the possibly qualified name of the |
| 109452 | ** table being edited, and token pName the name of the column to drop. | 110066 | ** table being edited, and token pName the name of the column to drop. |
| 109453 | */ | 110067 | */ |
| 109454 | SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token *pName){ | 110068 | SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, const Token *pName){ |
| 109455 | sqlite3 *db = pParse->db; /* Database handle */ | 110069 | sqlite3 *db = pParse->db; /* Database handle */ |
| 109456 | Table *pTab; /* Table to modify */ | 110070 | Table *pTab; /* Table to modify */ |
| 109457 | int iDb; /* Index of db containing pTab in aDb[] */ | 110071 | int iDb; /* Index of db containing pTab in aDb[] */ |
| @@ -109506,7 +110120,7 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token * | |||
| 109506 | renameTestSchema(pParse, zDb, iDb==1, "", 0); | 110120 | renameTestSchema(pParse, zDb, iDb==1, "", 0); |
| 109507 | renameFixQuotes(pParse, zDb, iDb==1); | 110121 | renameFixQuotes(pParse, zDb, iDb==1); |
| 109508 | sqlite3NestedParse(pParse, | 110122 | sqlite3NestedParse(pParse, |
| 109509 | "UPDATE \"%w\"." DFLT_SCHEMA_TABLE " SET " | 110123 | "UPDATE \"%w\"." LEGACY_SCHEMA_TABLE " SET " |
| 109510 | "sql = sqlite_drop_column(%d, sql, %d) " | 110124 | "sql = sqlite_drop_column(%d, sql, %d) " |
| 109511 | "WHERE (type=='table' AND tbl_name=%Q COLLATE nocase)" | 110125 | "WHERE (type=='table' AND tbl_name=%Q COLLATE nocase)" |
| 109512 | , zDb, iDb, iCol, pTab->zName | 110126 | , zDb, iDb, iCol, pTab->zName |
| @@ -109561,6 +110175,12 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, Token * | |||
| 109561 | nField++; | 110175 | nField++; |
| 109562 | } | 110176 | } |
| 109563 | } | 110177 | } |
| 110178 | if( nField==0 ){ | ||
| 110179 | /* dbsqlfuzz 5f09e7bcc78b4954d06bf9f2400d7715f48d1fef */ | ||
| 110180 | pParse->nMem++; | ||
| 110181 | sqlite3VdbeAddOp2(v, OP_Null, 0, reg+1); | ||
| 110182 | nField = 1; | ||
| 110183 | } | ||
| 109564 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg+1, nField, regRec); | 110184 | sqlite3VdbeAddOp3(v, OP_MakeRecord, reg+1, nField, regRec); |
| 109565 | if( pPk ){ | 110185 | if( pPk ){ |
| 109566 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iCur, regRec, reg+1, pPk->nKeyCol); | 110186 | sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iCur, regRec, reg+1, pPk->nKeyCol); |
| @@ -110030,7 +110650,6 @@ static void statInit( | |||
| 110030 | + sizeof(tRowcnt)*3*nColUp*(nCol+mxSample); | 110650 | + sizeof(tRowcnt)*3*nColUp*(nCol+mxSample); |
| 110031 | } | 110651 | } |
| 110032 | #endif | 110652 | #endif |
| 110033 | db = sqlite3_context_db_handle(context); | ||
| 110034 | p = sqlite3DbMallocZero(db, n); | 110653 | p = sqlite3DbMallocZero(db, n); |
| 110035 | if( p==0 ){ | 110654 | if( p==0 ){ |
| 110036 | sqlite3_result_error_nomem(context); | 110655 | sqlite3_result_error_nomem(context); |
| @@ -110449,28 +111068,19 @@ static void statGet( | |||
| 110449 | ** | 111068 | ** |
| 110450 | ** I = (K+D-1)/D | 111069 | ** I = (K+D-1)/D |
| 110451 | */ | 111070 | */ |
| 110452 | char *z; | 111071 | sqlite3_str sStat; /* Text of the constructed "stat" line */ |
| 110453 | int i; | 111072 | int i; /* Loop counter */ |
| 110454 | |||
| 110455 | char *zRet = sqlite3MallocZero( (p->nKeyCol+1)*25 ); | ||
| 110456 | if( zRet==0 ){ | ||
| 110457 | sqlite3_result_error_nomem(context); | ||
| 110458 | return; | ||
| 110459 | } | ||
| 110460 | 111073 | ||
| 110461 | sqlite3_snprintf(24, zRet, "%llu", | 111074 | sqlite3StrAccumInit(&sStat, 0, 0, 0, (p->nKeyCol+1)*100); |
| 111075 | sqlite3_str_appendf(&sStat, "%llu", | ||
| 110462 | p->nSkipAhead ? (u64)p->nEst : (u64)p->nRow); | 111076 | p->nSkipAhead ? (u64)p->nEst : (u64)p->nRow); |
| 110463 | z = zRet + sqlite3Strlen30(zRet); | ||
| 110464 | for(i=0; i<p->nKeyCol; i++){ | 111077 | for(i=0; i<p->nKeyCol; i++){ |
| 110465 | u64 nDistinct = p->current.anDLt[i] + 1; | 111078 | u64 nDistinct = p->current.anDLt[i] + 1; |
| 110466 | u64 iVal = (p->nRow + nDistinct - 1) / nDistinct; | 111079 | u64 iVal = (p->nRow + nDistinct - 1) / nDistinct; |
| 110467 | sqlite3_snprintf(24, z, " %llu", iVal); | 111080 | sqlite3_str_appendf(&sStat, " %llu", iVal); |
| 110468 | z += sqlite3Strlen30(z); | ||
| 110469 | assert( p->current.anEq[i] ); | 111081 | assert( p->current.anEq[i] ); |
| 110470 | } | 111082 | } |
| 110471 | assert( z[0]=='\0' && z>zRet ); | 111083 | sqlite3ResultStrAccum(context, &sStat); |
| 110472 | |||
| 110473 | sqlite3_result_text(context, zRet, -1, sqlite3_free); | ||
| 110474 | } | 111084 | } |
| 110475 | #ifdef SQLITE_ENABLE_STAT4 | 111085 | #ifdef SQLITE_ENABLE_STAT4 |
| 110476 | else if( eCall==STAT_GET_ROWID ){ | 111086 | else if( eCall==STAT_GET_ROWID ){ |
| @@ -110489,6 +111099,8 @@ static void statGet( | |||
| 110489 | } | 111099 | } |
| 110490 | }else{ | 111100 | }else{ |
| 110491 | tRowcnt *aCnt = 0; | 111101 | tRowcnt *aCnt = 0; |
| 111102 | sqlite3_str sStat; | ||
| 111103 | int i; | ||
| 110492 | 111104 | ||
| 110493 | assert( p->iGet<p->nSample ); | 111105 | assert( p->iGet<p->nSample ); |
| 110494 | switch( eCall ){ | 111106 | switch( eCall ){ |
| @@ -110500,23 +111112,12 @@ static void statGet( | |||
| 110500 | break; | 111112 | break; |
| 110501 | } | 111113 | } |
| 110502 | } | 111114 | } |
| 110503 | 111115 | sqlite3StrAccumInit(&sStat, 0, 0, 0, p->nCol*100); | |
| 110504 | { | 111116 | for(i=0; i<p->nCol; i++){ |
| 110505 | char *zRet = sqlite3MallocZero(p->nCol * 25); | 111117 | sqlite3_str_appendf(&sStat, "%llu ", (u64)aCnt[i]); |
| 110506 | if( zRet==0 ){ | ||
| 110507 | sqlite3_result_error_nomem(context); | ||
| 110508 | }else{ | ||
| 110509 | int i; | ||
| 110510 | char *z = zRet; | ||
| 110511 | for(i=0; i<p->nCol; i++){ | ||
| 110512 | sqlite3_snprintf(24, z, "%llu ", (u64)aCnt[i]); | ||
| 110513 | z += sqlite3Strlen30(z); | ||
| 110514 | } | ||
| 110515 | assert( z[0]=='\0' && z>zRet ); | ||
| 110516 | z[-1] = '\0'; | ||
| 110517 | sqlite3_result_text(context, zRet, -1, sqlite3_free); | ||
| 110518 | } | ||
| 110519 | } | 111118 | } |
| 111119 | if( sStat.nChar ) sStat.nChar--; | ||
| 111120 | sqlite3ResultStrAccum(context, &sStat); | ||
| 110520 | } | 111121 | } |
| 110521 | #endif /* SQLITE_ENABLE_STAT4 */ | 111122 | #endif /* SQLITE_ENABLE_STAT4 */ |
| 110522 | #ifndef SQLITE_DEBUG | 111123 | #ifndef SQLITE_DEBUG |
| @@ -110565,7 +111166,7 @@ static void analyzeVdbeCommentIndexWithColumnName( | |||
| 110565 | }else if( i==XN_EXPR ){ | 111166 | }else if( i==XN_EXPR ){ |
| 110566 | VdbeComment((v,"%s.expr(%d)",pIdx->zName, k)); | 111167 | VdbeComment((v,"%s.expr(%d)",pIdx->zName, k)); |
| 110567 | }else{ | 111168 | }else{ |
| 110568 | VdbeComment((v,"%s.%s", pIdx->zName, pIdx->pTable->aCol[i].zName)); | 111169 | VdbeComment((v,"%s.%s", pIdx->zName, pIdx->pTable->aCol[i].zCnName)); |
| 110569 | } | 111170 | } |
| 110570 | } | 111171 | } |
| 110571 | #else | 111172 | #else |
| @@ -110612,7 +111213,7 @@ static void analyzeOneTable( | |||
| 110612 | if( v==0 || NEVER(pTab==0) ){ | 111213 | if( v==0 || NEVER(pTab==0) ){ |
| 110613 | return; | 111214 | return; |
| 110614 | } | 111215 | } |
| 110615 | if( pTab->tnum==0 ){ | 111216 | if( !IsOrdinaryTable(pTab) ){ |
| 110616 | /* Do not gather statistics on views or virtual tables */ | 111217 | /* Do not gather statistics on views or virtual tables */ |
| 110617 | return; | 111218 | return; |
| 110618 | } | 111219 | } |
| @@ -111437,9 +112038,12 @@ static int loadStatTbl( | |||
| 111437 | */ | 112038 | */ |
| 111438 | static int loadStat4(sqlite3 *db, const char *zDb){ | 112039 | static int loadStat4(sqlite3 *db, const char *zDb){ |
| 111439 | int rc = SQLITE_OK; /* Result codes from subroutines */ | 112040 | int rc = SQLITE_OK; /* Result codes from subroutines */ |
| 112041 | const Table *pStat4; | ||
| 111440 | 112042 | ||
| 111441 | assert( db->lookaside.bDisable ); | 112043 | assert( db->lookaside.bDisable ); |
| 111442 | if( sqlite3FindTable(db, "sqlite_stat4", zDb) ){ | 112044 | if( (pStat4 = sqlite3FindTable(db, "sqlite_stat4", zDb))!=0 |
| 112045 | && IsOrdinaryTable(pStat4) | ||
| 112046 | ){ | ||
| 111443 | rc = loadStatTbl(db, | 112047 | rc = loadStatTbl(db, |
| 111444 | "SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx", | 112048 | "SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx", |
| 111445 | "SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4", | 112049 | "SELECT idx,neq,nlt,ndlt,sample FROM %Q.sqlite_stat4", |
| @@ -111476,6 +112080,7 @@ SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ | |||
| 111476 | char *zSql; | 112080 | char *zSql; |
| 111477 | int rc = SQLITE_OK; | 112081 | int rc = SQLITE_OK; |
| 111478 | Schema *pSchema = db->aDb[iDb].pSchema; | 112082 | Schema *pSchema = db->aDb[iDb].pSchema; |
| 112083 | const Table *pStat1; | ||
| 111479 | 112084 | ||
| 111480 | assert( iDb>=0 && iDb<db->nDb ); | 112085 | assert( iDb>=0 && iDb<db->nDb ); |
| 111481 | assert( db->aDb[iDb].pBt!=0 ); | 112086 | assert( db->aDb[iDb].pBt!=0 ); |
| @@ -111498,7 +112103,9 @@ SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){ | |||
| 111498 | /* Load new statistics out of the sqlite_stat1 table */ | 112103 | /* Load new statistics out of the sqlite_stat1 table */ |
| 111499 | sInfo.db = db; | 112104 | sInfo.db = db; |
| 111500 | sInfo.zDatabase = db->aDb[iDb].zDbSName; | 112105 | sInfo.zDatabase = db->aDb[iDb].zDbSName; |
| 111501 | if( sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)!=0 ){ | 112106 | if( (pStat1 = sqlite3FindTable(db, "sqlite_stat1", sInfo.zDatabase)) |
| 112107 | && IsOrdinaryTable(pStat1) | ||
| 112108 | ){ | ||
| 111502 | zSql = sqlite3MPrintf(db, | 112109 | zSql = sqlite3MPrintf(db, |
| 111503 | "SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase); | 112110 | "SELECT tbl,idx,stat FROM %Q.sqlite_stat1", sInfo.zDatabase); |
| 111504 | if( zSql==0 ){ | 112111 | if( zSql==0 ){ |
| @@ -111889,9 +112496,9 @@ static void codeAttach( | |||
| 111889 | sName.pParse = pParse; | 112496 | sName.pParse = pParse; |
| 111890 | 112497 | ||
| 111891 | if( | 112498 | if( |
| 111892 | SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) || | 112499 | SQLITE_OK!=resolveAttachExpr(&sName, pFilename) || |
| 111893 | SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) || | 112500 | SQLITE_OK!=resolveAttachExpr(&sName, pDbname) || |
| 111894 | SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey)) | 112501 | SQLITE_OK!=resolveAttachExpr(&sName, pKey) |
| 111895 | ){ | 112502 | ){ |
| 111896 | goto attach_end; | 112503 | goto attach_end; |
| 111897 | } | 112504 | } |
| @@ -111900,6 +112507,7 @@ static void codeAttach( | |||
| 111900 | if( pAuthArg ){ | 112507 | if( pAuthArg ){ |
| 111901 | char *zAuthArg; | 112508 | char *zAuthArg; |
| 111902 | if( pAuthArg->op==TK_STRING ){ | 112509 | if( pAuthArg->op==TK_STRING ){ |
| 112510 | assert( !ExprHasProperty(pAuthArg, EP_IntValue) ); | ||
| 111903 | zAuthArg = pAuthArg->u.zToken; | 112511 | zAuthArg = pAuthArg->u.zToken; |
| 111904 | }else{ | 112512 | }else{ |
| 111905 | zAuthArg = 0; | 112513 | zAuthArg = 0; |
| @@ -112318,10 +112926,10 @@ SQLITE_PRIVATE void sqlite3AuthRead( | |||
| 112318 | 112926 | ||
| 112319 | if( iCol>=0 ){ | 112927 | if( iCol>=0 ){ |
| 112320 | assert( iCol<pTab->nCol ); | 112928 | assert( iCol<pTab->nCol ); |
| 112321 | zCol = pTab->aCol[iCol].zName; | 112929 | zCol = pTab->aCol[iCol].zCnName; |
| 112322 | }else if( pTab->iPKey>=0 ){ | 112930 | }else if( pTab->iPKey>=0 ){ |
| 112323 | assert( pTab->iPKey<pTab->nCol ); | 112931 | assert( pTab->iPKey<pTab->nCol ); |
| 112324 | zCol = pTab->aCol[pTab->iPKey].zName; | 112932 | zCol = pTab->aCol[pTab->iPKey].zCnName; |
| 112325 | }else{ | 112933 | }else{ |
| 112326 | zCol = "ROWID"; | 112934 | zCol = "ROWID"; |
| 112327 | } | 112935 | } |
| @@ -112584,17 +113192,21 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){ | |||
| 112584 | int i; | 113192 | int i; |
| 112585 | int reg; | 113193 | int reg; |
| 112586 | 113194 | ||
| 112587 | addrRewind = | 113195 | if( pReturning->nRetCol==0 ){ |
| 112588 | sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur); | 113196 | assert( CORRUPT_DB ); |
| 112589 | VdbeCoverage(v); | 113197 | }else{ |
| 112590 | reg = pReturning->iRetReg; | 113198 | addrRewind = |
| 112591 | for(i=0; i<pReturning->nRetCol; i++){ | 113199 | sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur); |
| 112592 | sqlite3VdbeAddOp3(v, OP_Column, pReturning->iRetCur, i, reg+i); | 113200 | VdbeCoverage(v); |
| 113201 | reg = pReturning->iRetReg; | ||
| 113202 | for(i=0; i<pReturning->nRetCol; i++){ | ||
| 113203 | sqlite3VdbeAddOp3(v, OP_Column, pReturning->iRetCur, i, reg+i); | ||
| 113204 | } | ||
| 113205 | sqlite3VdbeAddOp2(v, OP_ResultRow, reg, i); | ||
| 113206 | sqlite3VdbeAddOp2(v, OP_Next, pReturning->iRetCur, addrRewind+1); | ||
| 113207 | VdbeCoverage(v); | ||
| 113208 | sqlite3VdbeJumpHere(v, addrRewind); | ||
| 112593 | } | 113209 | } |
| 112594 | sqlite3VdbeAddOp2(v, OP_ResultRow, reg, i); | ||
| 112595 | sqlite3VdbeAddOp2(v, OP_Next, pReturning->iRetCur, addrRewind+1); | ||
| 112596 | VdbeCoverage(v); | ||
| 112597 | sqlite3VdbeJumpHere(v, addrRewind); | ||
| 112598 | } | 113210 | } |
| 112599 | sqlite3VdbeAddOp0(v, OP_Halt); | 113211 | sqlite3VdbeAddOp0(v, OP_Halt); |
| 112600 | 113212 | ||
| @@ -112675,7 +113287,11 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){ | |||
| 112675 | 113287 | ||
| 112676 | if( pParse->bReturning ){ | 113288 | if( pParse->bReturning ){ |
| 112677 | Returning *pRet = pParse->u1.pReturning; | 113289 | Returning *pRet = pParse->u1.pReturning; |
| 112678 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol); | 113290 | if( pRet->nRetCol==0 ){ |
| 113291 | assert( CORRUPT_DB ); | ||
| 113292 | }else{ | ||
| 113293 | sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol); | ||
| 113294 | } | ||
| 112679 | } | 113295 | } |
| 112680 | 113296 | ||
| 112681 | /* Finally, jump back to the beginning of the executable code. */ | 113297 | /* Finally, jump back to the beginning of the executable code. */ |
| @@ -112699,20 +113315,22 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){ | |||
| 112699 | /* | 113315 | /* |
| 112700 | ** Run the parser and code generator recursively in order to generate | 113316 | ** Run the parser and code generator recursively in order to generate |
| 112701 | ** code for the SQL statement given onto the end of the pParse context | 113317 | ** code for the SQL statement given onto the end of the pParse context |
| 112702 | ** currently under construction. When the parser is run recursively | 113318 | ** currently under construction. Notes: |
| 112703 | ** this way, the final OP_Halt is not appended and other initialization | ||
| 112704 | ** and finalization steps are omitted because those are handling by the | ||
| 112705 | ** outermost parser. | ||
| 112706 | ** | 113319 | ** |
| 112707 | ** Not everything is nestable. This facility is designed to permit | 113320 | ** * The final OP_Halt is not appended and other initialization |
| 112708 | ** INSERT, UPDATE, and DELETE operations against the schema table. Use | 113321 | ** and finalization steps are omitted because those are handling by the |
| 112709 | ** care if you decide to try to use this routine for some other purposes. | 113322 | ** outermost parser. |
| 113323 | ** | ||
| 113324 | ** * Built-in SQL functions always take precedence over application-defined | ||
| 113325 | ** SQL functions. In other words, it is not possible to override a | ||
| 113326 | ** built-in function. | ||
| 112710 | */ | 113327 | */ |
| 112711 | SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){ | 113328 | SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){ |
| 112712 | va_list ap; | 113329 | va_list ap; |
| 112713 | char *zSql; | 113330 | char *zSql; |
| 112714 | char *zErrMsg = 0; | 113331 | char *zErrMsg = 0; |
| 112715 | sqlite3 *db = pParse->db; | 113332 | sqlite3 *db = pParse->db; |
| 113333 | u32 savedDbFlags = db->mDbFlags; | ||
| 112716 | char saveBuf[PARSE_TAIL_SZ]; | 113334 | char saveBuf[PARSE_TAIL_SZ]; |
| 112717 | 113335 | ||
| 112718 | if( pParse->nErr ) return; | 113336 | if( pParse->nErr ) return; |
| @@ -112731,7 +113349,9 @@ SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){ | |||
| 112731 | pParse->nested++; | 113349 | pParse->nested++; |
| 112732 | memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ); | 113350 | memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ); |
| 112733 | memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); | 113351 | memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ); |
| 113352 | db->mDbFlags |= DBFLAG_PreferBuiltin; | ||
| 112734 | sqlite3RunParser(pParse, zSql, &zErrMsg); | 113353 | sqlite3RunParser(pParse, zSql, &zErrMsg); |
| 113354 | db->mDbFlags = savedDbFlags; | ||
| 112735 | sqlite3DbFree(db, zErrMsg); | 113355 | sqlite3DbFree(db, zErrMsg); |
| 112736 | sqlite3DbFree(db, zSql); | 113356 | sqlite3DbFree(db, zSql); |
| 112737 | memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ); | 113357 | memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ); |
| @@ -112789,17 +113409,17 @@ SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const cha | |||
| 112789 | p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, zName); | 113409 | p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, zName); |
| 112790 | if( p==0 && sqlite3StrNICmp(zName, "sqlite_", 7)==0 ){ | 113410 | if( p==0 && sqlite3StrNICmp(zName, "sqlite_", 7)==0 ){ |
| 112791 | if( i==1 ){ | 113411 | if( i==1 ){ |
| 112792 | if( sqlite3StrICmp(zName+7, &ALT_TEMP_SCHEMA_TABLE[7])==0 | 113412 | if( sqlite3StrICmp(zName+7, &PREFERRED_TEMP_SCHEMA_TABLE[7])==0 |
| 112793 | || sqlite3StrICmp(zName+7, &ALT_SCHEMA_TABLE[7])==0 | 113413 | || sqlite3StrICmp(zName+7, &PREFERRED_SCHEMA_TABLE[7])==0 |
| 112794 | || sqlite3StrICmp(zName+7, &DFLT_SCHEMA_TABLE[7])==0 | 113414 | || sqlite3StrICmp(zName+7, &LEGACY_SCHEMA_TABLE[7])==0 |
| 112795 | ){ | 113415 | ){ |
| 112796 | p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash, | 113416 | p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash, |
| 112797 | DFLT_TEMP_SCHEMA_TABLE); | 113417 | LEGACY_TEMP_SCHEMA_TABLE); |
| 112798 | } | 113418 | } |
| 112799 | }else{ | 113419 | }else{ |
| 112800 | if( sqlite3StrICmp(zName+7, &ALT_SCHEMA_TABLE[7])==0 ){ | 113420 | if( sqlite3StrICmp(zName+7, &PREFERRED_SCHEMA_TABLE[7])==0 ){ |
| 112801 | p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, | 113421 | p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, |
| 112802 | DFLT_SCHEMA_TABLE); | 113422 | LEGACY_SCHEMA_TABLE); |
| 112803 | } | 113423 | } |
| 112804 | } | 113424 | } |
| 112805 | } | 113425 | } |
| @@ -112817,11 +113437,11 @@ SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const cha | |||
| 112817 | if( p ) break; | 113437 | if( p ) break; |
| 112818 | } | 113438 | } |
| 112819 | if( p==0 && sqlite3StrNICmp(zName, "sqlite_", 7)==0 ){ | 113439 | if( p==0 && sqlite3StrNICmp(zName, "sqlite_", 7)==0 ){ |
| 112820 | if( sqlite3StrICmp(zName+7, &ALT_SCHEMA_TABLE[7])==0 ){ | 113440 | if( sqlite3StrICmp(zName+7, &PREFERRED_SCHEMA_TABLE[7])==0 ){ |
| 112821 | p = sqlite3HashFind(&db->aDb[0].pSchema->tblHash, DFLT_SCHEMA_TABLE); | 113441 | p = sqlite3HashFind(&db->aDb[0].pSchema->tblHash, LEGACY_SCHEMA_TABLE); |
| 112822 | }else if( sqlite3StrICmp(zName+7, &ALT_TEMP_SCHEMA_TABLE[7])==0 ){ | 113442 | }else if( sqlite3StrICmp(zName+7, &PREFERRED_TEMP_SCHEMA_TABLE[7])==0 ){ |
| 112823 | p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash, | 113443 | p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash, |
| 112824 | DFLT_TEMP_SCHEMA_TABLE); | 113444 | LEGACY_TEMP_SCHEMA_TABLE); |
| 112825 | } | 113445 | } |
| 112826 | } | 113446 | } |
| 112827 | } | 113447 | } |
| @@ -112867,6 +113487,7 @@ SQLITE_PRIVATE Table *sqlite3LocateTable( | |||
| 112867 | pMod = sqlite3PragmaVtabRegister(db, zName); | 113487 | pMod = sqlite3PragmaVtabRegister(db, zName); |
| 112868 | } | 113488 | } |
| 112869 | if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){ | 113489 | if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){ |
| 113490 | testcase( pMod->pEpoTab==0 ); | ||
| 112870 | return pMod->pEpoTab; | 113491 | return pMod->pEpoTab; |
| 112871 | } | 113492 | } |
| 112872 | } | 113493 | } |
| @@ -112917,6 +113538,22 @@ SQLITE_PRIVATE Table *sqlite3LocateTableItem( | |||
| 112917 | } | 113538 | } |
| 112918 | 113539 | ||
| 112919 | /* | 113540 | /* |
| 113541 | ** Return the preferred table name for system tables. Translate legacy | ||
| 113542 | ** names into the new preferred names, as appropriate. | ||
| 113543 | */ | ||
| 113544 | SQLITE_PRIVATE const char *sqlite3PreferredTableName(const char *zName){ | ||
| 113545 | if( sqlite3StrNICmp(zName, "sqlite_", 7)==0 ){ | ||
| 113546 | if( sqlite3StrICmp(zName+7, &LEGACY_SCHEMA_TABLE[7])==0 ){ | ||
| 113547 | return PREFERRED_SCHEMA_TABLE; | ||
| 113548 | } | ||
| 113549 | if( sqlite3StrICmp(zName+7, &LEGACY_TEMP_SCHEMA_TABLE[7])==0 ){ | ||
| 113550 | return PREFERRED_TEMP_SCHEMA_TABLE; | ||
| 113551 | } | ||
| 113552 | } | ||
| 113553 | return zName; | ||
| 113554 | } | ||
| 113555 | |||
| 113556 | /* | ||
| 112920 | ** Locate the in-memory structure that describes | 113557 | ** Locate the in-memory structure that describes |
| 112921 | ** a particular index given the name of that index | 113558 | ** a particular index given the name of that index |
| 112922 | ** and the name of the database that contains the index. | 113559 | ** and the name of the database that contains the index. |
| @@ -113081,6 +113718,84 @@ SQLITE_PRIVATE void sqlite3CommitInternalChanges(sqlite3 *db){ | |||
| 113081 | } | 113718 | } |
| 113082 | 113719 | ||
| 113083 | /* | 113720 | /* |
| 113721 | ** Set the expression associated with a column. This is usually | ||
| 113722 | ** the DEFAULT value, but might also be the expression that computes | ||
| 113723 | ** the value for a generated column. | ||
| 113724 | */ | ||
| 113725 | SQLITE_PRIVATE void sqlite3ColumnSetExpr( | ||
| 113726 | Parse *pParse, /* Parsing context */ | ||
| 113727 | Table *pTab, /* The table containing the column */ | ||
| 113728 | Column *pCol, /* The column to receive the new DEFAULT expression */ | ||
| 113729 | Expr *pExpr /* The new default expression */ | ||
| 113730 | ){ | ||
| 113731 | ExprList *pList; | ||
| 113732 | assert( IsOrdinaryTable(pTab) ); | ||
| 113733 | pList = pTab->u.tab.pDfltList; | ||
| 113734 | if( pCol->iDflt==0 | ||
| 113735 | || NEVER(pList==0) | ||
| 113736 | || NEVER(pList->nExpr<pCol->iDflt) | ||
| 113737 | ){ | ||
| 113738 | pCol->iDflt = pList==0 ? 1 : pList->nExpr+1; | ||
| 113739 | pTab->u.tab.pDfltList = sqlite3ExprListAppend(pParse, pList, pExpr); | ||
| 113740 | }else{ | ||
| 113741 | sqlite3ExprDelete(pParse->db, pList->a[pCol->iDflt-1].pExpr); | ||
| 113742 | pList->a[pCol->iDflt-1].pExpr = pExpr; | ||
| 113743 | } | ||
| 113744 | } | ||
| 113745 | |||
| 113746 | /* | ||
| 113747 | ** Return the expression associated with a column. The expression might be | ||
| 113748 | ** the DEFAULT clause or the AS clause of a generated column. | ||
| 113749 | ** Return NULL if the column has no associated expression. | ||
| 113750 | */ | ||
| 113751 | SQLITE_PRIVATE Expr *sqlite3ColumnExpr(Table *pTab, Column *pCol){ | ||
| 113752 | if( pCol->iDflt==0 ) return 0; | ||
| 113753 | if( NEVER(!IsOrdinaryTable(pTab)) ) return 0; | ||
| 113754 | if( NEVER(pTab->u.tab.pDfltList==0) ) return 0; | ||
| 113755 | if( NEVER(pTab->u.tab.pDfltList->nExpr<pCol->iDflt) ) return 0; | ||
| 113756 | return pTab->u.tab.pDfltList->a[pCol->iDflt-1].pExpr; | ||
| 113757 | } | ||
| 113758 | |||
| 113759 | /* | ||
| 113760 | ** Set the collating sequence name for a column. | ||
| 113761 | */ | ||
| 113762 | SQLITE_PRIVATE void sqlite3ColumnSetColl( | ||
| 113763 | sqlite3 *db, | ||
| 113764 | Column *pCol, | ||
| 113765 | const char *zColl | ||
| 113766 | ){ | ||
| 113767 | i64 nColl; | ||
| 113768 | i64 n; | ||
| 113769 | char *zNew; | ||
| 113770 | assert( zColl!=0 ); | ||
| 113771 | n = sqlite3Strlen30(pCol->zCnName) + 1; | ||
| 113772 | if( pCol->colFlags & COLFLAG_HASTYPE ){ | ||
| 113773 | n += sqlite3Strlen30(pCol->zCnName+n) + 1; | ||
| 113774 | } | ||
| 113775 | nColl = sqlite3Strlen30(zColl) + 1; | ||
| 113776 | zNew = sqlite3DbRealloc(db, pCol->zCnName, nColl+n); | ||
| 113777 | if( zNew ){ | ||
| 113778 | pCol->zCnName = zNew; | ||
| 113779 | memcpy(pCol->zCnName + n, zColl, nColl); | ||
| 113780 | pCol->colFlags |= COLFLAG_HASCOLL; | ||
| 113781 | } | ||
| 113782 | } | ||
| 113783 | |||
| 113784 | /* | ||
| 113785 | ** Return the collating squence name for a column | ||
| 113786 | */ | ||
| 113787 | SQLITE_PRIVATE const char *sqlite3ColumnColl(Column *pCol){ | ||
| 113788 | const char *z; | ||
| 113789 | if( (pCol->colFlags & COLFLAG_HASCOLL)==0 ) return 0; | ||
| 113790 | z = pCol->zCnName; | ||
| 113791 | while( *z ){ z++; } | ||
| 113792 | if( pCol->colFlags & COLFLAG_HASTYPE ){ | ||
| 113793 | do{ z++; }while( *z ); | ||
| 113794 | } | ||
| 113795 | return z+1; | ||
| 113796 | } | ||
| 113797 | |||
| 113798 | /* | ||
| 113084 | ** Delete memory allocated for the column names of a table or view (the | 113799 | ** Delete memory allocated for the column names of a table or view (the |
| 113085 | ** Table.aCol[] array). | 113800 | ** Table.aCol[] array). |
| 113086 | */ | 113801 | */ |
| @@ -113090,12 +113805,20 @@ SQLITE_PRIVATE void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){ | |||
| 113090 | assert( pTable!=0 ); | 113805 | assert( pTable!=0 ); |
| 113091 | if( (pCol = pTable->aCol)!=0 ){ | 113806 | if( (pCol = pTable->aCol)!=0 ){ |
| 113092 | for(i=0; i<pTable->nCol; i++, pCol++){ | 113807 | for(i=0; i<pTable->nCol; i++, pCol++){ |
| 113093 | assert( pCol->zName==0 || pCol->hName==sqlite3StrIHash(pCol->zName) ); | 113808 | assert( pCol->zCnName==0 || pCol->hName==sqlite3StrIHash(pCol->zCnName) ); |
| 113094 | sqlite3DbFree(db, pCol->zName); | 113809 | sqlite3DbFree(db, pCol->zCnName); |
| 113095 | sqlite3ExprDelete(db, pCol->pDflt); | ||
| 113096 | sqlite3DbFree(db, pCol->zColl); | ||
| 113097 | } | 113810 | } |
| 113098 | sqlite3DbFree(db, pTable->aCol); | 113811 | sqlite3DbFree(db, pTable->aCol); |
| 113812 | if( IsOrdinaryTable(pTable) ){ | ||
| 113813 | sqlite3ExprListDelete(db, pTable->u.tab.pDfltList); | ||
| 113814 | } | ||
| 113815 | if( db==0 || db->pnBytesFreed==0 ){ | ||
| 113816 | pTable->aCol = 0; | ||
| 113817 | pTable->nCol = 0; | ||
| 113818 | if( IsOrdinaryTable(pTable) ){ | ||
| 113819 | pTable->u.tab.pDfltList = 0; | ||
| 113820 | } | ||
| 113821 | } | ||
| 113099 | } | 113822 | } |
| 113100 | } | 113823 | } |
| 113101 | 113824 | ||
| @@ -113147,19 +113870,25 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){ | |||
| 113147 | sqlite3FreeIndex(db, pIndex); | 113870 | sqlite3FreeIndex(db, pIndex); |
| 113148 | } | 113871 | } |
| 113149 | 113872 | ||
| 113150 | /* Delete any foreign keys attached to this table. */ | 113873 | if( IsOrdinaryTable(pTable) ){ |
| 113151 | sqlite3FkDelete(db, pTable); | 113874 | sqlite3FkDelete(db, pTable); |
| 113875 | } | ||
| 113876 | #ifndef SQLITE_OMIT_VIRTUAL_TABLE | ||
| 113877 | else if( IsVirtual(pTable) ){ | ||
| 113878 | sqlite3VtabClear(db, pTable); | ||
| 113879 | } | ||
| 113880 | #endif | ||
| 113881 | else{ | ||
| 113882 | assert( IsView(pTable) ); | ||
| 113883 | sqlite3SelectDelete(db, pTable->u.view.pSelect); | ||
| 113884 | } | ||
| 113152 | 113885 | ||
| 113153 | /* Delete the Table structure itself. | 113886 | /* Delete the Table structure itself. |
| 113154 | */ | 113887 | */ |
| 113155 | sqlite3DeleteColumnNames(db, pTable); | 113888 | sqlite3DeleteColumnNames(db, pTable); |
| 113156 | sqlite3DbFree(db, pTable->zName); | 113889 | sqlite3DbFree(db, pTable->zName); |
| 113157 | sqlite3DbFree(db, pTable->zColAff); | 113890 | sqlite3DbFree(db, pTable->zColAff); |
| 113158 | sqlite3SelectDelete(db, pTable->pSelect); | ||
| 113159 | sqlite3ExprListDelete(db, pTable->pCheck); | 113891 | sqlite3ExprListDelete(db, pTable->pCheck); |
| 113160 | #ifndef SQLITE_OMIT_VIRTUALTABLE | ||
| 113161 | sqlite3VtabClear(db, pTable); | ||
| 113162 | #endif | ||
| 113163 | sqlite3DbFree(db, pTable); | 113892 | sqlite3DbFree(db, pTable); |
| 113164 | 113893 | ||
| 113165 | /* Verify that no lookaside memory was used by schema tables */ | 113894 | /* Verify that no lookaside memory was used by schema tables */ |
| @@ -113205,10 +113934,10 @@ SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char | |||
| 113205 | ** are not \000 terminated and are not persistent. The returned string | 113934 | ** are not \000 terminated and are not persistent. The returned string |
| 113206 | ** is \000 terminated and is persistent. | 113935 | ** is \000 terminated and is persistent. |
| 113207 | */ | 113936 | */ |
| 113208 | SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3 *db, Token *pName){ | 113937 | SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3 *db, const Token *pName){ |
| 113209 | char *zName; | 113938 | char *zName; |
| 113210 | if( pName ){ | 113939 | if( pName ){ |
| 113211 | zName = sqlite3DbStrNDup(db, (char*)pName->z, pName->n); | 113940 | zName = sqlite3DbStrNDup(db, (const char*)pName->z, pName->n); |
| 113212 | sqlite3Dequote(zName); | 113941 | sqlite3Dequote(zName); |
| 113213 | }else{ | 113942 | }else{ |
| 113214 | zName = 0; | 113943 | zName = 0; |
| @@ -113222,7 +113951,7 @@ SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3 *db, Token *pName){ | |||
| 113222 | */ | 113951 | */ |
| 113223 | SQLITE_PRIVATE void sqlite3OpenSchemaTable(Parse *p, int iDb){ | 113952 | SQLITE_PRIVATE void sqlite3OpenSchemaTable(Parse *p, int iDb){ |
| 113224 | Vdbe *v = sqlite3GetVdbe(p); | 113953 | Vdbe *v = sqlite3GetVdbe(p); |
| 113225 | sqlite3TableLock(p, iDb, SCHEMA_ROOT, 1, DFLT_SCHEMA_TABLE); | 113954 | sqlite3TableLock(p, iDb, SCHEMA_ROOT, 1, LEGACY_SCHEMA_TABLE); |
| 113226 | sqlite3VdbeAddOp4Int(v, OP_OpenWrite, 0, SCHEMA_ROOT, iDb, 5); | 113955 | sqlite3VdbeAddOp4Int(v, OP_OpenWrite, 0, SCHEMA_ROOT, iDb, 5); |
| 113227 | if( p->nTab==0 ){ | 113956 | if( p->nTab==0 ){ |
| 113228 | p->nTab = 1; | 113957 | p->nTab = 1; |
| @@ -113685,6 +114414,7 @@ SQLITE_PRIVATE void sqlite3StartTable( | |||
| 113685 | 114414 | ||
| 113686 | /* If an error occurs, we jump here */ | 114415 | /* If an error occurs, we jump here */ |
| 113687 | begin_table_error: | 114416 | begin_table_error: |
| 114417 | pParse->checkSchema = 1; | ||
| 113688 | sqlite3DbFree(db, zName); | 114418 | sqlite3DbFree(db, zName); |
| 113689 | return; | 114419 | return; |
| 113690 | } | 114420 | } |
| @@ -113694,7 +114424,7 @@ begin_table_error: | |||
| 113694 | */ | 114424 | */ |
| 113695 | #if SQLITE_ENABLE_HIDDEN_COLUMNS | 114425 | #if SQLITE_ENABLE_HIDDEN_COLUMNS |
| 113696 | SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ | 114426 | SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){ |
| 113697 | if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){ | 114427 | if( sqlite3_strnicmp(pCol->zCnName, "__hidden__", 10)==0 ){ |
| 113698 | pCol->colFlags |= COLFLAG_HIDDEN; | 114428 | pCol->colFlags |= COLFLAG_HIDDEN; |
| 113699 | if( pTab ) pTab->tabFlags |= TF_HasHidden; | 114429 | if( pTab ) pTab->tabFlags |= TF_HasHidden; |
| 113700 | }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){ | 114430 | }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){ |
| @@ -113785,7 +114515,7 @@ SQLITE_PRIVATE void sqlite3AddReturning(Parse *pParse, ExprList *pList){ | |||
| 113785 | ** first to get things going. Then this routine is called for each | 114515 | ** first to get things going. Then this routine is called for each |
| 113786 | ** column. | 114516 | ** column. |
| 113787 | */ | 114517 | */ |
| 113788 | SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){ | 114518 | SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token sName, Token sType){ |
| 113789 | Table *p; | 114519 | Table *p; |
| 113790 | int i; | 114520 | int i; |
| 113791 | char *z; | 114521 | char *z; |
| @@ -113793,55 +114523,96 @@ SQLITE_PRIVATE void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){ | |||
| 113793 | Column *pCol; | 114523 | Column *pCol; |
| 113794 | sqlite3 *db = pParse->db; | 114524 | sqlite3 *db = pParse->db; |
| 113795 | u8 hName; | 114525 | u8 hName; |
| 114526 | Column *aNew; | ||
| 114527 | u8 eType = COLTYPE_CUSTOM; | ||
| 114528 | u8 szEst = 1; | ||
| 114529 | char affinity = SQLITE_AFF_BLOB; | ||
| 113796 | 114530 | ||
| 113797 | if( (p = pParse->pNewTable)==0 ) return; | 114531 | if( (p = pParse->pNewTable)==0 ) return; |
| 113798 | if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){ | 114532 | if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){ |
| 113799 | sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName); | 114533 | sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName); |
| 113800 | return; | 114534 | return; |
| 113801 | } | 114535 | } |
| 113802 | z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2); | 114536 | if( !IN_RENAME_OBJECT ) sqlite3DequoteToken(&sName); |
| 114537 | |||
| 114538 | /* Because keywords GENERATE ALWAYS can be converted into indentifiers | ||
| 114539 | ** by the parser, we can sometimes end up with a typename that ends | ||
| 114540 | ** with "generated always". Check for this case and omit the surplus | ||
| 114541 | ** text. */ | ||
| 114542 | if( sType.n>=16 | ||
| 114543 | && sqlite3_strnicmp(sType.z+(sType.n-6),"always",6)==0 | ||
| 114544 | ){ | ||
| 114545 | sType.n -= 6; | ||
| 114546 | while( ALWAYS(sType.n>0) && sqlite3Isspace(sType.z[sType.n-1]) ) sType.n--; | ||
| 114547 | if( sType.n>=9 | ||
| 114548 | && sqlite3_strnicmp(sType.z+(sType.n-9),"generated",9)==0 | ||
| 114549 | ){ | ||
| 114550 | sType.n -= 9; | ||
| 114551 | while( sType.n>0 && sqlite3Isspace(sType.z[sType.n-1]) ) sType.n--; | ||
| 114552 | } | ||
| 114553 | } | ||
| 114554 | |||
| 114555 | /* Check for standard typenames. For standard typenames we will | ||
| 114556 | ** set the Column.eType field rather than storing the typename after | ||
| 114557 | ** the column name, in order to save space. */ | ||
| 114558 | if( sType.n>=3 ){ | ||
| 114559 | sqlite3DequoteToken(&sType); | ||
| 114560 | for(i=0; i<SQLITE_N_STDTYPE; i++){ | ||
| 114561 | if( sType.n==sqlite3StdTypeLen[i] | ||
| 114562 | && sqlite3_strnicmp(sType.z, sqlite3StdType[i], sType.n)==0 | ||
| 114563 | ){ | ||
| 114564 | sType.n = 0; | ||
| 114565 | eType = i+1; | ||
| 114566 | affinity = sqlite3StdTypeAffinity[i]; | ||
| 114567 | if( affinity<=SQLITE_AFF_TEXT ) szEst = 5; | ||
| 114568 | break; | ||
| 114569 | } | ||
| 114570 | } | ||
| 114571 | } | ||
| 114572 | |||
| 114573 | z = sqlite3DbMallocRaw(db, (i64)sName.n + 1 + (i64)sType.n + (sType.n>0) ); | ||
| 113803 | if( z==0 ) return; | 114574 | if( z==0 ) return; |
| 113804 | if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, pName); | 114575 | if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, &sName); |
| 113805 | memcpy(z, pName->z, pName->n); | 114576 | memcpy(z, sName.z, sName.n); |
| 113806 | z[pName->n] = 0; | 114577 | z[sName.n] = 0; |
| 113807 | sqlite3Dequote(z); | 114578 | sqlite3Dequote(z); |
| 113808 | hName = sqlite3StrIHash(z); | 114579 | hName = sqlite3StrIHash(z); |
| 113809 | for(i=0; i<p->nCol; i++){ | 114580 | for(i=0; i<p->nCol; i++){ |
| 113810 | if( p->aCol[i].hName==hName && sqlite3StrICmp(z, p->aCol[i].zName)==0 ){ | 114581 | if( p->aCol[i].hName==hName && sqlite3StrICmp(z, p->aCol[i].zCnName)==0 ){ |
| 113811 | sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); | 114582 | sqlite3ErrorMsg(pParse, "duplicate column name: %s", z); |
| 113812 | sqlite3DbFree(db, z); | 114583 | sqlite3DbFree(db, z); |
| 113813 | return; | 114584 | return; |
| 113814 | } | 114585 | } |
| 113815 | } | 114586 | } |
| 113816 | if( (p->nCol & 0x7)==0 ){ | 114587 | aNew = sqlite3DbRealloc(db,p->aCol,((i64)p->nCol+1)*sizeof(p->aCol[0])); |
| 113817 | Column *aNew; | 114588 | if( aNew==0 ){ |
| 113818 | aNew = sqlite3DbRealloc(db,p->aCol,(p->nCol+8)*sizeof(p->aCol[0])); | 114589 | sqlite3DbFree(db, z); |
| 113819 | if( aNew==0 ){ | 114590 | return; |
| 113820 | sqlite3DbFree(db, z); | ||
| 113821 | return; | ||
| 113822 | } | ||
| 113823 | p->aCol = aNew; | ||
| 113824 | } | 114591 | } |
| 114592 | p->aCol = aNew; | ||
| 113825 | pCol = &p->aCol[p->nCol]; | 114593 | pCol = &p->aCol[p->nCol]; |
| 113826 | memset(pCol, 0, sizeof(p->aCol[0])); | 114594 | memset(pCol, 0, sizeof(p->aCol[0])); |
| 113827 | pCol->zName = z; | 114595 | pCol->zCnName = z; |
| 113828 | pCol->hName = hName; | 114596 | pCol->hName = hName; |
| 113829 | sqlite3ColumnPropertiesFromName(p, pCol); | 114597 | sqlite3ColumnPropertiesFromName(p, pCol); |
| 113830 | 114598 | ||
| 113831 | if( pType->n==0 ){ | 114599 | if( sType.n==0 ){ |
| 113832 | /* If there is no type specified, columns have the default affinity | 114600 | /* If there is no type specified, columns have the default affinity |
| 113833 | ** 'BLOB' with a default size of 4 bytes. */ | 114601 | ** 'BLOB' with a default size of 4 bytes. */ |
| 113834 | pCol->affinity = SQLITE_AFF_BLOB; | 114602 | pCol->affinity = affinity; |
| 113835 | pCol->szEst = 1; | 114603 | pCol->eCType = eType; |
| 114604 | pCol->szEst = szEst; | ||
| 113836 | #ifdef SQLITE_ENABLE_SORTER_REFERENCES | 114605 | #ifdef SQLITE_ENABLE_SORTER_REFERENCES |
| 113837 | if( 4>=sqlite3GlobalConfig.szSorterRef ){ | 114606 | if( affinity==SQLITE_AFF_BLOB ){ |
| 113838 | pCol->colFlags |= COLFLAG_SORTERREF; | 114607 | if( 4>=sqlite3GlobalConfig.szSorterRef ){ |
| 114608 | pCol->colFlags |= COLFLAG_SORTERREF; | ||
| 114609 | } | ||
| 113839 | } | 114610 | } |
| 113840 | #endif | 114611 | #endif |
| 113841 | }else{ | 114612 | }else{ |
| 113842 | zType = z + sqlite3Strlen30(z) + 1; | 114613 | zType = z + sqlite3Strlen30(z) + 1; |
| 113843 | memcpy(zType, pType->z, pType->n); | 114614 | memcpy(zType, sType.z, sType.n); |
| 113844 | zType[pType->n] = 0; | 114615 | zType[sType.n] = 0; |
| 113845 | sqlite3Dequote(zType); | 114616 | sqlite3Dequote(zType); |
| 113846 | pCol->affinity = sqlite3AffinityType(zType, pCol); | 114617 | pCol->affinity = sqlite3AffinityType(zType, pCol); |
| 113847 | pCol->colFlags |= COLFLAG_HASTYPE; | 114618 | pCol->colFlags |= COLFLAG_HASTYPE; |
| @@ -113996,7 +114767,7 @@ SQLITE_PRIVATE void sqlite3AddDefaultValue( | |||
| 113996 | pCol = &(p->aCol[p->nCol-1]); | 114767 | pCol = &(p->aCol[p->nCol-1]); |
| 113997 | if( !sqlite3ExprIsConstantOrFunction(pExpr, isInit) ){ | 114768 | if( !sqlite3ExprIsConstantOrFunction(pExpr, isInit) ){ |
| 113998 | sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant", | 114769 | sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant", |
| 113999 | pCol->zName); | 114770 | pCol->zCnName); |
| 114000 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS | 114771 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 114001 | }else if( pCol->colFlags & COLFLAG_GENERATED ){ | 114772 | }else if( pCol->colFlags & COLFLAG_GENERATED ){ |
| 114002 | testcase( pCol->colFlags & COLFLAG_VIRTUAL ); | 114773 | testcase( pCol->colFlags & COLFLAG_VIRTUAL ); |
| @@ -114007,15 +114778,15 @@ SQLITE_PRIVATE void sqlite3AddDefaultValue( | |||
| 114007 | /* A copy of pExpr is used instead of the original, as pExpr contains | 114778 | /* A copy of pExpr is used instead of the original, as pExpr contains |
| 114008 | ** tokens that point to volatile memory. | 114779 | ** tokens that point to volatile memory. |
| 114009 | */ | 114780 | */ |
| 114010 | Expr x; | 114781 | Expr x, *pDfltExpr; |
| 114011 | sqlite3ExprDelete(db, pCol->pDflt); | ||
| 114012 | memset(&x, 0, sizeof(x)); | 114782 | memset(&x, 0, sizeof(x)); |
| 114013 | x.op = TK_SPAN; | 114783 | x.op = TK_SPAN; |
| 114014 | x.u.zToken = sqlite3DbSpanDup(db, zStart, zEnd); | 114784 | x.u.zToken = sqlite3DbSpanDup(db, zStart, zEnd); |
| 114015 | x.pLeft = pExpr; | 114785 | x.pLeft = pExpr; |
| 114016 | x.flags = EP_Skip; | 114786 | x.flags = EP_Skip; |
| 114017 | pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE); | 114787 | pDfltExpr = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE); |
| 114018 | sqlite3DbFree(db, x.u.zToken); | 114788 | sqlite3DbFree(db, x.u.zToken); |
| 114789 | sqlite3ColumnSetExpr(pParse, p, pCol, pDfltExpr); | ||
| 114019 | } | 114790 | } |
| 114020 | } | 114791 | } |
| 114021 | if( IN_RENAME_OBJECT ){ | 114792 | if( IN_RENAME_OBJECT ){ |
| @@ -114111,9 +114882,11 @@ SQLITE_PRIVATE void sqlite3AddPrimaryKey( | |||
| 114111 | assert( pCExpr!=0 ); | 114882 | assert( pCExpr!=0 ); |
| 114112 | sqlite3StringToId(pCExpr); | 114883 | sqlite3StringToId(pCExpr); |
| 114113 | if( pCExpr->op==TK_ID ){ | 114884 | if( pCExpr->op==TK_ID ){ |
| 114114 | const char *zCName = pCExpr->u.zToken; | 114885 | const char *zCName; |
| 114886 | assert( !ExprHasProperty(pCExpr, EP_IntValue) ); | ||
| 114887 | zCName = pCExpr->u.zToken; | ||
| 114115 | for(iCol=0; iCol<pTab->nCol; iCol++){ | 114888 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 114116 | if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){ | 114889 | if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zCnName)==0 ){ |
| 114117 | pCol = &pTab->aCol[iCol]; | 114890 | pCol = &pTab->aCol[iCol]; |
| 114118 | makeColumnPartOfPrimaryKey(pParse, pCol); | 114891 | makeColumnPartOfPrimaryKey(pParse, pCol); |
| 114119 | break; | 114892 | break; |
| @@ -114124,7 +114897,7 @@ SQLITE_PRIVATE void sqlite3AddPrimaryKey( | |||
| 114124 | } | 114897 | } |
| 114125 | if( nTerm==1 | 114898 | if( nTerm==1 |
| 114126 | && pCol | 114899 | && pCol |
| 114127 | && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0 | 114900 | && pCol->eCType==COLTYPE_INTEGER |
| 114128 | && sortOrder!=SQLITE_SO_DESC | 114901 | && sortOrder!=SQLITE_SO_DESC |
| 114129 | ){ | 114902 | ){ |
| 114130 | if( IN_RENAME_OBJECT && pList ){ | 114903 | if( IN_RENAME_OBJECT && pList ){ |
| @@ -114204,8 +114977,7 @@ SQLITE_PRIVATE void sqlite3AddCollateType(Parse *pParse, Token *pToken){ | |||
| 114204 | 114977 | ||
| 114205 | if( sqlite3LocateCollSeq(pParse, zColl) ){ | 114978 | if( sqlite3LocateCollSeq(pParse, zColl) ){ |
| 114206 | Index *pIdx; | 114979 | Index *pIdx; |
| 114207 | sqlite3DbFree(db, p->aCol[i].zColl); | 114980 | sqlite3ColumnSetColl(db, &p->aCol[i], zColl); |
| 114208 | p->aCol[i].zColl = zColl; | ||
| 114209 | 114981 | ||
| 114210 | /* If the column is declared as "<name> PRIMARY KEY COLLATE <type>", | 114982 | /* If the column is declared as "<name> PRIMARY KEY COLLATE <type>", |
| 114211 | ** then an index may have been created on this column before the | 114983 | ** then an index may have been created on this column before the |
| @@ -114214,12 +114986,11 @@ SQLITE_PRIVATE void sqlite3AddCollateType(Parse *pParse, Token *pToken){ | |||
| 114214 | for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){ | 114986 | for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){ |
| 114215 | assert( pIdx->nKeyCol==1 ); | 114987 | assert( pIdx->nKeyCol==1 ); |
| 114216 | if( pIdx->aiColumn[0]==i ){ | 114988 | if( pIdx->aiColumn[0]==i ){ |
| 114217 | pIdx->azColl[0] = p->aCol[i].zColl; | 114989 | pIdx->azColl[0] = sqlite3ColumnColl(&p->aCol[i]); |
| 114218 | } | 114990 | } |
| 114219 | } | 114991 | } |
| 114220 | }else{ | ||
| 114221 | sqlite3DbFree(db, zColl); | ||
| 114222 | } | 114992 | } |
| 114993 | sqlite3DbFree(db, zColl); | ||
| 114223 | } | 114994 | } |
| 114224 | 114995 | ||
| 114225 | /* Change the most recently parsed column to be a GENERATED ALWAYS AS | 114996 | /* Change the most recently parsed column to be a GENERATED ALWAYS AS |
| @@ -114239,7 +115010,7 @@ SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType | |||
| 114239 | sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns"); | 115010 | sqlite3ErrorMsg(pParse, "virtual tables cannot use computed columns"); |
| 114240 | goto generated_done; | 115011 | goto generated_done; |
| 114241 | } | 115012 | } |
| 114242 | if( pCol->pDflt ) goto generated_error; | 115013 | if( pCol->iDflt>0 ) goto generated_error; |
| 114243 | if( pType ){ | 115014 | if( pType ){ |
| 114244 | if( pType->n==7 && sqlite3StrNICmp("virtual",pType->z,7)==0 ){ | 115015 | if( pType->n==7 && sqlite3StrNICmp("virtual",pType->z,7)==0 ){ |
| 114245 | /* no-op */ | 115016 | /* no-op */ |
| @@ -114257,13 +115028,13 @@ SQLITE_PRIVATE void sqlite3AddGenerated(Parse *pParse, Expr *pExpr, Token *pType | |||
| 114257 | if( pCol->colFlags & COLFLAG_PRIMKEY ){ | 115028 | if( pCol->colFlags & COLFLAG_PRIMKEY ){ |
| 114258 | makeColumnPartOfPrimaryKey(pParse, pCol); /* For the error message */ | 115029 | makeColumnPartOfPrimaryKey(pParse, pCol); /* For the error message */ |
| 114259 | } | 115030 | } |
| 114260 | pCol->pDflt = pExpr; | 115031 | sqlite3ColumnSetExpr(pParse, pTab, pCol, pExpr); |
| 114261 | pExpr = 0; | 115032 | pExpr = 0; |
| 114262 | goto generated_done; | 115033 | goto generated_done; |
| 114263 | 115034 | ||
| 114264 | generated_error: | 115035 | generated_error: |
| 114265 | sqlite3ErrorMsg(pParse, "error in generated column \"%s\"", | 115036 | sqlite3ErrorMsg(pParse, "error in generated column \"%s\"", |
| 114266 | pCol->zName); | 115037 | pCol->zCnName); |
| 114267 | generated_done: | 115038 | generated_done: |
| 114268 | sqlite3ExprDelete(pParse->db, pExpr); | 115039 | sqlite3ExprDelete(pParse->db, pExpr); |
| 114269 | #else | 115040 | #else |
| @@ -114365,7 +115136,7 @@ static char *createTableStmt(sqlite3 *db, Table *p){ | |||
| 114365 | Column *pCol; | 115136 | Column *pCol; |
| 114366 | n = 0; | 115137 | n = 0; |
| 114367 | for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){ | 115138 | for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){ |
| 114368 | n += identLength(pCol->zName) + 5; | 115139 | n += identLength(pCol->zCnName) + 5; |
| 114369 | } | 115140 | } |
| 114370 | n += identLength(p->zName); | 115141 | n += identLength(p->zName); |
| 114371 | if( n<50 ){ | 115142 | if( n<50 ){ |
| @@ -114401,7 +115172,7 @@ static char *createTableStmt(sqlite3 *db, Table *p){ | |||
| 114401 | sqlite3_snprintf(n-k, &zStmt[k], zSep); | 115172 | sqlite3_snprintf(n-k, &zStmt[k], zSep); |
| 114402 | k += sqlite3Strlen30(&zStmt[k]); | 115173 | k += sqlite3Strlen30(&zStmt[k]); |
| 114403 | zSep = zSep2; | 115174 | zSep = zSep2; |
| 114404 | identPut(zStmt, &k, pCol->zName); | 115175 | identPut(zStmt, &k, pCol->zCnName); |
| 114405 | assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 ); | 115176 | assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 ); |
| 114406 | assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) ); | 115177 | assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) ); |
| 114407 | testcase( pCol->affinity==SQLITE_AFF_BLOB ); | 115178 | testcase( pCol->affinity==SQLITE_AFF_BLOB ); |
| @@ -114485,7 +115256,6 @@ static void estimateIndexWidth(Index *pIdx){ | |||
| 114485 | */ | 115256 | */ |
| 114486 | static int hasColumn(const i16 *aiCol, int nCol, int x){ | 115257 | static int hasColumn(const i16 *aiCol, int nCol, int x){ |
| 114487 | while( nCol-- > 0 ){ | 115258 | while( nCol-- > 0 ){ |
| 114488 | assert( aiCol[0]>=0 ); | ||
| 114489 | if( x==*(aiCol++) ){ | 115259 | if( x==*(aiCol++) ){ |
| 114490 | return 1; | 115260 | return 1; |
| 114491 | } | 115261 | } |
| @@ -114598,7 +115368,9 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ | |||
| 114598 | */ | 115368 | */ |
| 114599 | if( !db->init.imposterTable ){ | 115369 | if( !db->init.imposterTable ){ |
| 114600 | for(i=0; i<pTab->nCol; i++){ | 115370 | for(i=0; i<pTab->nCol; i++){ |
| 114601 | if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){ | 115371 | if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 |
| 115372 | && (pTab->aCol[i].notNull==OE_None) | ||
| 115373 | ){ | ||
| 114602 | pTab->aCol[i].notNull = OE_Abort; | 115374 | pTab->aCol[i].notNull = OE_Abort; |
| 114603 | } | 115375 | } |
| 114604 | } | 115376 | } |
| @@ -114620,7 +115392,7 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){ | |||
| 114620 | if( pTab->iPKey>=0 ){ | 115392 | if( pTab->iPKey>=0 ){ |
| 114621 | ExprList *pList; | 115393 | ExprList *pList; |
| 114622 | Token ipkToken; | 115394 | Token ipkToken; |
| 114623 | sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName); | 115395 | sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zCnName); |
| 114624 | pList = sqlite3ExprListAppend(pParse, 0, | 115396 | pList = sqlite3ExprListAppend(pParse, 0, |
| 114625 | sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0)); | 115397 | sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0)); |
| 114626 | if( pList==0 ){ | 115398 | if( pList==0 ){ |
| @@ -114750,7 +115522,7 @@ SQLITE_PRIVATE int sqlite3IsShadowTableOf(sqlite3 *db, Table *pTab, const char * | |||
| 114750 | nName = sqlite3Strlen30(pTab->zName); | 115522 | nName = sqlite3Strlen30(pTab->zName); |
| 114751 | if( sqlite3_strnicmp(zName, pTab->zName, nName)!=0 ) return 0; | 115523 | if( sqlite3_strnicmp(zName, pTab->zName, nName)!=0 ) return 0; |
| 114752 | if( zName[nName]!='_' ) return 0; | 115524 | if( zName[nName]!='_' ) return 0; |
| 114753 | pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]); | 115525 | pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->u.vtab.azArg[0]); |
| 114754 | if( pMod==0 ) return 0; | 115526 | if( pMod==0 ) return 0; |
| 114755 | if( pMod->pModule->iVersion<3 ) return 0; | 115527 | if( pMod->pModule->iVersion<3 ) return 0; |
| 114756 | if( pMod->pModule->xShadowName==0 ) return 0; | 115528 | if( pMod->pModule->xShadowName==0 ) return 0; |
| @@ -114760,6 +115532,41 @@ SQLITE_PRIVATE int sqlite3IsShadowTableOf(sqlite3 *db, Table *pTab, const char * | |||
| 114760 | 115532 | ||
| 114761 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 115533 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 114762 | /* | 115534 | /* |
| 115535 | ** Table pTab is a virtual table. If it the virtual table implementation | ||
| 115536 | ** exists and has an xShadowName method, then loop over all other ordinary | ||
| 115537 | ** tables within the same schema looking for shadow tables of pTab, and mark | ||
| 115538 | ** any shadow tables seen using the TF_Shadow flag. | ||
| 115539 | */ | ||
| 115540 | SQLITE_PRIVATE void sqlite3MarkAllShadowTablesOf(sqlite3 *db, Table *pTab){ | ||
| 115541 | int nName; /* Length of pTab->zName */ | ||
| 115542 | Module *pMod; /* Module for the virtual table */ | ||
| 115543 | HashElem *k; /* For looping through the symbol table */ | ||
| 115544 | |||
| 115545 | assert( IsVirtual(pTab) ); | ||
| 115546 | pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->u.vtab.azArg[0]); | ||
| 115547 | if( pMod==0 ) return; | ||
| 115548 | if( NEVER(pMod->pModule==0) ) return; | ||
| 115549 | if( pMod->pModule->iVersion<3 ) return; | ||
| 115550 | if( pMod->pModule->xShadowName==0 ) return; | ||
| 115551 | assert( pTab->zName!=0 ); | ||
| 115552 | nName = sqlite3Strlen30(pTab->zName); | ||
| 115553 | for(k=sqliteHashFirst(&pTab->pSchema->tblHash); k; k=sqliteHashNext(k)){ | ||
| 115554 | Table *pOther = sqliteHashData(k); | ||
| 115555 | assert( pOther->zName!=0 ); | ||
| 115556 | if( !IsOrdinaryTable(pOther) ) continue; | ||
| 115557 | if( pOther->tabFlags & TF_Shadow ) continue; | ||
| 115558 | if( sqlite3StrNICmp(pOther->zName, pTab->zName, nName)==0 | ||
| 115559 | && pOther->zName[nName]=='_' | ||
| 115560 | && pMod->pModule->xShadowName(pOther->zName+nName+1) | ||
| 115561 | ){ | ||
| 115562 | pOther->tabFlags |= TF_Shadow; | ||
| 115563 | } | ||
| 115564 | } | ||
| 115565 | } | ||
| 115566 | #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ | ||
| 115567 | |||
| 115568 | #ifndef SQLITE_OMIT_VIRTUALTABLE | ||
| 115569 | /* | ||
| 114763 | ** Return true if zName is a shadow table name in the current database | 115570 | ** Return true if zName is a shadow table name in the current database |
| 114764 | ** connection. | 115571 | ** connection. |
| 114765 | ** | 115572 | ** |
| @@ -114831,7 +115638,7 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 114831 | Parse *pParse, /* Parse context */ | 115638 | Parse *pParse, /* Parse context */ |
| 114832 | Token *pCons, /* The ',' token after the last column defn. */ | 115639 | Token *pCons, /* The ',' token after the last column defn. */ |
| 114833 | Token *pEnd, /* The ')' before options in the CREATE TABLE */ | 115640 | Token *pEnd, /* The ')' before options in the CREATE TABLE */ |
| 114834 | u8 tabOpts, /* Extra table options. Usually 0. */ | 115641 | u32 tabOpts, /* Extra table options. Usually 0. */ |
| 114835 | Select *pSelect /* Select from a "CREATE ... AS SELECT" */ | 115642 | Select *pSelect /* Select from a "CREATE ... AS SELECT" */ |
| 114836 | ){ | 115643 | ){ |
| 114837 | Table *p; /* The new table */ | 115644 | Table *p; /* The new table */ |
| @@ -114859,7 +115666,7 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 114859 | ** table itself. So mark it read-only. | 115666 | ** table itself. So mark it read-only. |
| 114860 | */ | 115667 | */ |
| 114861 | if( db->init.busy ){ | 115668 | if( db->init.busy ){ |
| 114862 | if( pSelect ){ | 115669 | if( pSelect || (!IsOrdinaryTable(p) && db->init.newTnum) ){ |
| 114863 | sqlite3ErrorMsg(pParse, ""); | 115670 | sqlite3ErrorMsg(pParse, ""); |
| 114864 | return; | 115671 | return; |
| 114865 | } | 115672 | } |
| @@ -114867,6 +115674,44 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 114867 | if( p->tnum==1 ) p->tabFlags |= TF_Readonly; | 115674 | if( p->tnum==1 ) p->tabFlags |= TF_Readonly; |
| 114868 | } | 115675 | } |
| 114869 | 115676 | ||
| 115677 | /* Special processing for tables that include the STRICT keyword: | ||
| 115678 | ** | ||
| 115679 | ** * Do not allow custom column datatypes. Every column must have | ||
| 115680 | ** a datatype that is one of INT, INTEGER, REAL, TEXT, or BLOB. | ||
| 115681 | ** | ||
| 115682 | ** * If a PRIMARY KEY is defined, other than the INTEGER PRIMARY KEY, | ||
| 115683 | ** then all columns of the PRIMARY KEY must have a NOT NULL | ||
| 115684 | ** constraint. | ||
| 115685 | */ | ||
| 115686 | if( tabOpts & TF_Strict ){ | ||
| 115687 | int ii; | ||
| 115688 | p->tabFlags |= TF_Strict; | ||
| 115689 | for(ii=0; ii<p->nCol; ii++){ | ||
| 115690 | Column *pCol = &p->aCol[ii]; | ||
| 115691 | if( pCol->eCType==COLTYPE_CUSTOM ){ | ||
| 115692 | if( pCol->colFlags & COLFLAG_HASTYPE ){ | ||
| 115693 | sqlite3ErrorMsg(pParse, | ||
| 115694 | "unknown datatype for %s.%s: \"%s\"", | ||
| 115695 | p->zName, pCol->zCnName, sqlite3ColumnType(pCol, "") | ||
| 115696 | ); | ||
| 115697 | }else{ | ||
| 115698 | sqlite3ErrorMsg(pParse, "missing datatype for %s.%s", | ||
| 115699 | p->zName, pCol->zCnName); | ||
| 115700 | } | ||
| 115701 | return; | ||
| 115702 | }else if( pCol->eCType==COLTYPE_ANY ){ | ||
| 115703 | pCol->affinity = SQLITE_AFF_BLOB; | ||
| 115704 | } | ||
| 115705 | if( (pCol->colFlags & COLFLAG_PRIMKEY)!=0 | ||
| 115706 | && p->iPKey!=ii | ||
| 115707 | && pCol->notNull == OE_None | ||
| 115708 | ){ | ||
| 115709 | pCol->notNull = OE_Abort; | ||
| 115710 | p->tabFlags |= TF_HasNotNull; | ||
| 115711 | } | ||
| 115712 | } | ||
| 115713 | } | ||
| 115714 | |||
| 114870 | assert( (p->tabFlags & TF_HasPrimaryKey)==0 | 115715 | assert( (p->tabFlags & TF_HasPrimaryKey)==0 |
| 114871 | || p->iPKey>=0 || sqlite3PrimaryKeyIndex(p)!=0 ); | 115716 | || p->iPKey>=0 || sqlite3PrimaryKeyIndex(p)!=0 ); |
| 114872 | assert( (p->tabFlags & TF_HasPrimaryKey)!=0 | 115717 | assert( (p->tabFlags & TF_HasPrimaryKey)!=0 |
| @@ -114911,7 +115756,7 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 114911 | for(ii=0; ii<p->nCol; ii++){ | 115756 | for(ii=0; ii<p->nCol; ii++){ |
| 114912 | u32 colFlags = p->aCol[ii].colFlags; | 115757 | u32 colFlags = p->aCol[ii].colFlags; |
| 114913 | if( (colFlags & COLFLAG_GENERATED)!=0 ){ | 115758 | if( (colFlags & COLFLAG_GENERATED)!=0 ){ |
| 114914 | Expr *pX = p->aCol[ii].pDflt; | 115759 | Expr *pX = sqlite3ColumnExpr(p, &p->aCol[ii]); |
| 114915 | testcase( colFlags & COLFLAG_VIRTUAL ); | 115760 | testcase( colFlags & COLFLAG_VIRTUAL ); |
| 114916 | testcase( colFlags & COLFLAG_STORED ); | 115761 | testcase( colFlags & COLFLAG_STORED ); |
| 114917 | if( sqlite3ResolveSelfReference(pParse, p, NC_GenCol, pX, 0) ){ | 115762 | if( sqlite3ResolveSelfReference(pParse, p, NC_GenCol, pX, 0) ){ |
| @@ -114921,8 +115766,8 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 114921 | ** tree that have been allocated from lookaside memory, which is | 115766 | ** tree that have been allocated from lookaside memory, which is |
| 114922 | ** illegal in a schema and will lead to errors or heap corruption | 115767 | ** illegal in a schema and will lead to errors or heap corruption |
| 114923 | ** when the database connection closes. */ | 115768 | ** when the database connection closes. */ |
| 114924 | sqlite3ExprDelete(db, pX); | 115769 | sqlite3ColumnSetExpr(pParse, p, &p->aCol[ii], |
| 114925 | p->aCol[ii].pDflt = sqlite3ExprAlloc(db, TK_NULL, 0, 0); | 115770 | sqlite3ExprAlloc(db, TK_NULL, 0, 0)); |
| 114926 | } | 115771 | } |
| 114927 | }else{ | 115772 | }else{ |
| 114928 | nNG++; | 115773 | nNG++; |
| @@ -114962,7 +115807,7 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 114962 | /* | 115807 | /* |
| 114963 | ** Initialize zType for the new view or table. | 115808 | ** Initialize zType for the new view or table. |
| 114964 | */ | 115809 | */ |
| 114965 | if( p->pSelect==0 ){ | 115810 | if( IsOrdinaryTable(p) ){ |
| 114966 | /* A regular table */ | 115811 | /* A regular table */ |
| 114967 | zType = "table"; | 115812 | zType = "table"; |
| 114968 | zType2 = "TABLE"; | 115813 | zType2 = "TABLE"; |
| @@ -115048,7 +115893,7 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 115048 | ** the information we've collected. | 115893 | ** the information we've collected. |
| 115049 | */ | 115894 | */ |
| 115050 | sqlite3NestedParse(pParse, | 115895 | sqlite3NestedParse(pParse, |
| 115051 | "UPDATE %Q." DFLT_SCHEMA_TABLE | 115896 | "UPDATE %Q." LEGACY_SCHEMA_TABLE |
| 115052 | " SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q" | 115897 | " SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q" |
| 115053 | " WHERE rowid=#%d", | 115898 | " WHERE rowid=#%d", |
| 115054 | db->aDb[iDb].zDbSName, | 115899 | db->aDb[iDb].zDbSName, |
| @@ -115112,12 +115957,12 @@ SQLITE_PRIVATE void sqlite3EndTable( | |||
| 115112 | } | 115957 | } |
| 115113 | 115958 | ||
| 115114 | #ifndef SQLITE_OMIT_ALTERTABLE | 115959 | #ifndef SQLITE_OMIT_ALTERTABLE |
| 115115 | if( !pSelect && !p->pSelect ){ | 115960 | if( !pSelect && IsOrdinaryTable(p) ){ |
| 115116 | assert( pCons && pEnd ); | 115961 | assert( pCons && pEnd ); |
| 115117 | if( pCons->z==0 ){ | 115962 | if( pCons->z==0 ){ |
| 115118 | pCons = pEnd; | 115963 | pCons = pEnd; |
| 115119 | } | 115964 | } |
| 115120 | p->addColOffset = 13 + (int)(pCons->z - pParse->sNameToken.z); | 115965 | p->u.tab.addColOffset = 13 + (int)(pCons->z - pParse->sNameToken.z); |
| 115121 | } | 115966 | } |
| 115122 | #endif | 115967 | #endif |
| 115123 | } | 115968 | } |
| @@ -115174,12 +116019,13 @@ SQLITE_PRIVATE void sqlite3CreateView( | |||
| 115174 | */ | 116019 | */ |
| 115175 | pSelect->selFlags |= SF_View; | 116020 | pSelect->selFlags |= SF_View; |
| 115176 | if( IN_RENAME_OBJECT ){ | 116021 | if( IN_RENAME_OBJECT ){ |
| 115177 | p->pSelect = pSelect; | 116022 | p->u.view.pSelect = pSelect; |
| 115178 | pSelect = 0; | 116023 | pSelect = 0; |
| 115179 | }else{ | 116024 | }else{ |
| 115180 | p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); | 116025 | p->u.view.pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE); |
| 115181 | } | 116026 | } |
| 115182 | p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE); | 116027 | p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE); |
| 116028 | p->eTabType = TABTYP_VIEW; | ||
| 115183 | if( db->mallocFailed ) goto create_view_fail; | 116029 | if( db->mallocFailed ) goto create_view_fail; |
| 115184 | 116030 | ||
| 115185 | /* Locate the end of the CREATE VIEW statement. Make sEnd point to | 116031 | /* Locate the end of the CREATE VIEW statement. Make sEnd point to |
| @@ -115233,13 +116079,12 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ | |||
| 115233 | assert( pTable ); | 116079 | assert( pTable ); |
| 115234 | 116080 | ||
| 115235 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 116081 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 115236 | db->nSchemaLock++; | 116082 | if( IsVirtual(pTable) ){ |
| 115237 | rc = sqlite3VtabCallConnect(pParse, pTable); | 116083 | db->nSchemaLock++; |
| 115238 | db->nSchemaLock--; | 116084 | rc = sqlite3VtabCallConnect(pParse, pTable); |
| 115239 | if( rc ){ | 116085 | db->nSchemaLock--; |
| 115240 | return 1; | 116086 | return rc; |
| 115241 | } | 116087 | } |
| 115242 | if( IsVirtual(pTable) ) return 0; | ||
| 115243 | #endif | 116088 | #endif |
| 115244 | 116089 | ||
| 115245 | #ifndef SQLITE_OMIT_VIEW | 116090 | #ifndef SQLITE_OMIT_VIEW |
| @@ -115276,8 +116121,8 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ | |||
| 115276 | ** to be permanent. So the computation is done on a copy of the SELECT | 116121 | ** to be permanent. So the computation is done on a copy of the SELECT |
| 115277 | ** statement that defines the view. | 116122 | ** statement that defines the view. |
| 115278 | */ | 116123 | */ |
| 115279 | assert( pTable->pSelect ); | 116124 | assert( IsView(pTable) ); |
| 115280 | pSel = sqlite3SelectDup(db, pTable->pSelect, 0); | 116125 | pSel = sqlite3SelectDup(db, pTable->u.view.pSelect, 0); |
| 115281 | if( pSel ){ | 116126 | if( pSel ){ |
| 115282 | u8 eParseMode = pParse->eParseMode; | 116127 | u8 eParseMode = pParse->eParseMode; |
| 115283 | pParse->eParseMode = PARSE_MODE_NORMAL; | 116128 | pParse->eParseMode = PARSE_MODE_NORMAL; |
| @@ -115336,8 +116181,6 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){ | |||
| 115336 | pTable->pSchema->schemaFlags |= DB_UnresetViews; | 116181 | pTable->pSchema->schemaFlags |= DB_UnresetViews; |
| 115337 | if( db->mallocFailed ){ | 116182 | if( db->mallocFailed ){ |
| 115338 | sqlite3DeleteColumnNames(db, pTable); | 116183 | sqlite3DeleteColumnNames(db, pTable); |
| 115339 | pTable->aCol = 0; | ||
| 115340 | pTable->nCol = 0; | ||
| 115341 | } | 116184 | } |
| 115342 | #endif /* SQLITE_OMIT_VIEW */ | 116185 | #endif /* SQLITE_OMIT_VIEW */ |
| 115343 | return nErr; | 116186 | return nErr; |
| @@ -115354,10 +116197,8 @@ static void sqliteViewResetAll(sqlite3 *db, int idx){ | |||
| 115354 | if( !DbHasProperty(db, idx, DB_UnresetViews) ) return; | 116197 | if( !DbHasProperty(db, idx, DB_UnresetViews) ) return; |
| 115355 | for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){ | 116198 | for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){ |
| 115356 | Table *pTab = sqliteHashData(i); | 116199 | Table *pTab = sqliteHashData(i); |
| 115357 | if( pTab->pSelect ){ | 116200 | if( IsView(pTab) ){ |
| 115358 | sqlite3DeleteColumnNames(db, pTab); | 116201 | sqlite3DeleteColumnNames(db, pTab); |
| 115359 | pTab->aCol = 0; | ||
| 115360 | pTab->nCol = 0; | ||
| 115361 | } | 116202 | } |
| 115362 | } | 116203 | } |
| 115363 | DbClearProperty(db, idx, DB_UnresetViews); | 116204 | DbClearProperty(db, idx, DB_UnresetViews); |
| @@ -115431,7 +116272,7 @@ static void destroyRootPage(Parse *pParse, int iTable, int iDb){ | |||
| 115431 | ** token for additional information. | 116272 | ** token for additional information. |
| 115432 | */ | 116273 | */ |
| 115433 | sqlite3NestedParse(pParse, | 116274 | sqlite3NestedParse(pParse, |
| 115434 | "UPDATE %Q." DFLT_SCHEMA_TABLE | 116275 | "UPDATE %Q." LEGACY_SCHEMA_TABLE |
| 115435 | " SET rootpage=%d WHERE #%d AND rootpage=#%d", | 116276 | " SET rootpage=%d WHERE #%d AND rootpage=#%d", |
| 115436 | pParse->db->aDb[iDb].zDbSName, iTable, r1, r1); | 116277 | pParse->db->aDb[iDb].zDbSName, iTable, r1, r1); |
| 115437 | #endif | 116278 | #endif |
| @@ -115566,7 +116407,7 @@ SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, in | |||
| 115566 | ** database. | 116407 | ** database. |
| 115567 | */ | 116408 | */ |
| 115568 | sqlite3NestedParse(pParse, | 116409 | sqlite3NestedParse(pParse, |
| 115569 | "DELETE FROM %Q." DFLT_SCHEMA_TABLE | 116410 | "DELETE FROM %Q." LEGACY_SCHEMA_TABLE |
| 115570 | " WHERE tbl_name=%Q and type!='trigger'", | 116411 | " WHERE tbl_name=%Q and type!='trigger'", |
| 115571 | pDb->zDbSName, pTab->zName); | 116412 | pDb->zDbSName, pTab->zName); |
| 115572 | if( !isView && !IsVirtual(pTab) ){ | 116413 | if( !isView && !IsVirtual(pTab) ){ |
| @@ -115594,6 +116435,7 @@ SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db){ | |||
| 115594 | if( (db->flags & SQLITE_Defensive)!=0 | 116435 | if( (db->flags & SQLITE_Defensive)!=0 |
| 115595 | && db->pVtabCtx==0 | 116436 | && db->pVtabCtx==0 |
| 115596 | && db->nVdbeExec==0 | 116437 | && db->nVdbeExec==0 |
| 116438 | && !sqlite3VtabInSync(db) | ||
| 115597 | ){ | 116439 | ){ |
| 115598 | return 1; | 116440 | return 1; |
| 115599 | } | 116441 | } |
| @@ -115613,6 +116455,9 @@ static int tableMayNotBeDropped(sqlite3 *db, Table *pTab){ | |||
| 115613 | if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ | 116455 | if( (pTab->tabFlags & TF_Shadow)!=0 && sqlite3ReadOnlyShadowTables(db) ){ |
| 115614 | return 1; | 116456 | return 1; |
| 115615 | } | 116457 | } |
| 116458 | if( pTab->tabFlags & TF_Eponymous ){ | ||
| 116459 | return 1; | ||
| 116460 | } | ||
| 115616 | return 0; | 116461 | return 0; |
| 115617 | } | 116462 | } |
| 115618 | 116463 | ||
| @@ -115697,11 +116542,11 @@ SQLITE_PRIVATE void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, | |||
| 115697 | /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used | 116542 | /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used |
| 115698 | ** on a table. | 116543 | ** on a table. |
| 115699 | */ | 116544 | */ |
| 115700 | if( isView && pTab->pSelect==0 ){ | 116545 | if( isView && !IsView(pTab) ){ |
| 115701 | sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab->zName); | 116546 | sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab->zName); |
| 115702 | goto exit_drop_table; | 116547 | goto exit_drop_table; |
| 115703 | } | 116548 | } |
| 115704 | if( !isView && pTab->pSelect ){ | 116549 | if( !isView && IsView(pTab) ){ |
| 115705 | sqlite3ErrorMsg(pParse, "use DROP VIEW to delete view %s", pTab->zName); | 116550 | sqlite3ErrorMsg(pParse, "use DROP VIEW to delete view %s", pTab->zName); |
| 115706 | goto exit_drop_table; | 116551 | goto exit_drop_table; |
| 115707 | } | 116552 | } |
| @@ -115752,7 +116597,7 @@ SQLITE_PRIVATE void sqlite3CreateForeignKey( | |||
| 115752 | FKey *pFKey = 0; | 116597 | FKey *pFKey = 0; |
| 115753 | FKey *pNextTo; | 116598 | FKey *pNextTo; |
| 115754 | Table *p = pParse->pNewTable; | 116599 | Table *p = pParse->pNewTable; |
| 115755 | int nByte; | 116600 | i64 nByte; |
| 115756 | int i; | 116601 | int i; |
| 115757 | int nCol; | 116602 | int nCol; |
| 115758 | char *z; | 116603 | char *z; |
| @@ -115765,7 +116610,7 @@ SQLITE_PRIVATE void sqlite3CreateForeignKey( | |||
| 115765 | if( pToCol && pToCol->nExpr!=1 ){ | 116610 | if( pToCol && pToCol->nExpr!=1 ){ |
| 115766 | sqlite3ErrorMsg(pParse, "foreign key on %s" | 116611 | sqlite3ErrorMsg(pParse, "foreign key on %s" |
| 115767 | " should reference only one column of table %T", | 116612 | " should reference only one column of table %T", |
| 115768 | p->aCol[iCol].zName, pTo); | 116613 | p->aCol[iCol].zCnName, pTo); |
| 115769 | goto fk_end; | 116614 | goto fk_end; |
| 115770 | } | 116615 | } |
| 115771 | nCol = 1; | 116616 | nCol = 1; |
| @@ -115788,7 +116633,8 @@ SQLITE_PRIVATE void sqlite3CreateForeignKey( | |||
| 115788 | goto fk_end; | 116633 | goto fk_end; |
| 115789 | } | 116634 | } |
| 115790 | pFKey->pFrom = p; | 116635 | pFKey->pFrom = p; |
| 115791 | pFKey->pNextFrom = p->pFKey; | 116636 | assert( IsOrdinaryTable(p) ); |
| 116637 | pFKey->pNextFrom = p->u.tab.pFKey; | ||
| 115792 | z = (char*)&pFKey->aCol[nCol]; | 116638 | z = (char*)&pFKey->aCol[nCol]; |
| 115793 | pFKey->zTo = z; | 116639 | pFKey->zTo = z; |
| 115794 | if( IN_RENAME_OBJECT ){ | 116640 | if( IN_RENAME_OBJECT ){ |
| @@ -115805,7 +116651,7 @@ SQLITE_PRIVATE void sqlite3CreateForeignKey( | |||
| 115805 | for(i=0; i<nCol; i++){ | 116651 | for(i=0; i<nCol; i++){ |
| 115806 | int j; | 116652 | int j; |
| 115807 | for(j=0; j<p->nCol; j++){ | 116653 | for(j=0; j<p->nCol; j++){ |
| 115808 | if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zEName)==0 ){ | 116654 | if( sqlite3StrICmp(p->aCol[j].zCnName, pFromCol->a[i].zEName)==0 ){ |
| 115809 | pFKey->aCol[i].iFrom = j; | 116655 | pFKey->aCol[i].iFrom = j; |
| 115810 | break; | 116656 | break; |
| 115811 | } | 116657 | } |
| @@ -115853,7 +116699,8 @@ SQLITE_PRIVATE void sqlite3CreateForeignKey( | |||
| 115853 | 116699 | ||
| 115854 | /* Link the foreign key to the table as the last step. | 116700 | /* Link the foreign key to the table as the last step. |
| 115855 | */ | 116701 | */ |
| 115856 | p->pFKey = pFKey; | 116702 | assert( IsOrdinaryTable(p) ); |
| 116703 | p->u.tab.pFKey = pFKey; | ||
| 115857 | pFKey = 0; | 116704 | pFKey = 0; |
| 115858 | 116705 | ||
| 115859 | fk_end: | 116706 | fk_end: |
| @@ -115874,7 +116721,9 @@ SQLITE_PRIVATE void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){ | |||
| 115874 | #ifndef SQLITE_OMIT_FOREIGN_KEY | 116721 | #ifndef SQLITE_OMIT_FOREIGN_KEY |
| 115875 | Table *pTab; | 116722 | Table *pTab; |
| 115876 | FKey *pFKey; | 116723 | FKey *pFKey; |
| 115877 | if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return; | 116724 | if( (pTab = pParse->pNewTable)==0 ) return; |
| 116725 | if( NEVER(!IsOrdinaryTable(pTab)) ) return; | ||
| 116726 | if( (pFKey = pTab->u.tab.pFKey)==0 ) return; | ||
| 115878 | assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */ | 116727 | assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */ |
| 115879 | pFKey->isDeferred = (u8)isDeferred; | 116728 | pFKey->isDeferred = (u8)isDeferred; |
| 115880 | #endif | 116729 | #endif |
| @@ -116166,7 +117015,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex( | |||
| 116166 | goto exit_create_index; | 117015 | goto exit_create_index; |
| 116167 | } | 117016 | } |
| 116168 | #ifndef SQLITE_OMIT_VIEW | 117017 | #ifndef SQLITE_OMIT_VIEW |
| 116169 | if( pTab->pSelect ){ | 117018 | if( IsView(pTab) ){ |
| 116170 | sqlite3ErrorMsg(pParse, "views may not be indexed"); | 117019 | sqlite3ErrorMsg(pParse, "views may not be indexed"); |
| 116171 | goto exit_create_index; | 117020 | goto exit_create_index; |
| 116172 | } | 117021 | } |
| @@ -116257,7 +117106,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex( | |||
| 116257 | Token prevCol; | 117106 | Token prevCol; |
| 116258 | Column *pCol = &pTab->aCol[pTab->nCol-1]; | 117107 | Column *pCol = &pTab->aCol[pTab->nCol-1]; |
| 116259 | pCol->colFlags |= COLFLAG_UNIQUE; | 117108 | pCol->colFlags |= COLFLAG_UNIQUE; |
| 116260 | sqlite3TokenInit(&prevCol, pCol->zName); | 117109 | sqlite3TokenInit(&prevCol, pCol->zCnName); |
| 116261 | pList = sqlite3ExprListAppend(pParse, 0, | 117110 | pList = sqlite3ExprListAppend(pParse, 0, |
| 116262 | sqlite3ExprAlloc(db, TK_ID, &prevCol, 0)); | 117111 | sqlite3ExprAlloc(db, TK_ID, &prevCol, 0)); |
| 116263 | if( pList==0 ) goto exit_create_index; | 117112 | if( pList==0 ) goto exit_create_index; |
| @@ -116275,6 +117124,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex( | |||
| 116275 | Expr *pExpr = pList->a[i].pExpr; | 117124 | Expr *pExpr = pList->a[i].pExpr; |
| 116276 | assert( pExpr!=0 ); | 117125 | assert( pExpr!=0 ); |
| 116277 | if( pExpr->op==TK_COLLATE ){ | 117126 | if( pExpr->op==TK_COLLATE ){ |
| 117127 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 116278 | nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken)); | 117128 | nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken)); |
| 116279 | } | 117129 | } |
| 116280 | } | 117130 | } |
| @@ -116370,6 +117220,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex( | |||
| 116370 | zColl = 0; | 117220 | zColl = 0; |
| 116371 | if( pListItem->pExpr->op==TK_COLLATE ){ | 117221 | if( pListItem->pExpr->op==TK_COLLATE ){ |
| 116372 | int nColl; | 117222 | int nColl; |
| 117223 | assert( !ExprHasProperty(pListItem->pExpr, EP_IntValue) ); | ||
| 116373 | zColl = pListItem->pExpr->u.zToken; | 117224 | zColl = pListItem->pExpr->u.zToken; |
| 116374 | nColl = sqlite3Strlen30(zColl) + 1; | 117225 | nColl = sqlite3Strlen30(zColl) + 1; |
| 116375 | assert( nExtra>=nColl ); | 117226 | assert( nExtra>=nColl ); |
| @@ -116378,7 +117229,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex( | |||
| 116378 | zExtra += nColl; | 117229 | zExtra += nColl; |
| 116379 | nExtra -= nColl; | 117230 | nExtra -= nColl; |
| 116380 | }else if( j>=0 ){ | 117231 | }else if( j>=0 ){ |
| 116381 | zColl = pTab->aCol[j].zColl; | 117232 | zColl = sqlite3ColumnColl(&pTab->aCol[j]); |
| 116382 | } | 117233 | } |
| 116383 | if( !zColl ) zColl = sqlite3StrBINARY; | 117234 | if( !zColl ) zColl = sqlite3StrBINARY; |
| 116384 | if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){ | 117235 | if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){ |
| @@ -116576,7 +117427,7 @@ SQLITE_PRIVATE void sqlite3CreateIndex( | |||
| 116576 | /* Add an entry in sqlite_schema for this index | 117427 | /* Add an entry in sqlite_schema for this index |
| 116577 | */ | 117428 | */ |
| 116578 | sqlite3NestedParse(pParse, | 117429 | sqlite3NestedParse(pParse, |
| 116579 | "INSERT INTO %Q." DFLT_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);", | 117430 | "INSERT INTO %Q." LEGACY_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);", |
| 116580 | db->aDb[iDb].zDbSName, | 117431 | db->aDb[iDb].zDbSName, |
| 116581 | pIndex->zName, | 117432 | pIndex->zName, |
| 116582 | pTab->zName, | 117433 | pTab->zName, |
| @@ -116618,7 +117469,7 @@ exit_create_index: | |||
| 116618 | ** The list was already ordered when this routine was entered, so at this | 117469 | ** The list was already ordered when this routine was entered, so at this |
| 116619 | ** point at most a single index (the newly added index) will be out of | 117470 | ** point at most a single index (the newly added index) will be out of |
| 116620 | ** order. So we have to reorder at most one index. */ | 117471 | ** order. So we have to reorder at most one index. */ |
| 116621 | Index **ppFrom = &pTab->pIndex; | 117472 | Index **ppFrom; |
| 116622 | Index *pThis; | 117473 | Index *pThis; |
| 116623 | for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){ | 117474 | for(ppFrom=&pTab->pIndex; (pThis = *ppFrom)!=0; ppFrom=&pThis->pNext){ |
| 116624 | Index *pNext; | 117475 | Index *pNext; |
| @@ -116762,7 +117613,7 @@ SQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists | |||
| 116762 | if( v ){ | 117613 | if( v ){ |
| 116763 | sqlite3BeginWriteOperation(pParse, 1, iDb); | 117614 | sqlite3BeginWriteOperation(pParse, 1, iDb); |
| 116764 | sqlite3NestedParse(pParse, | 117615 | sqlite3NestedParse(pParse, |
| 116765 | "DELETE FROM %Q." DFLT_SCHEMA_TABLE " WHERE name=%Q AND type='index'", | 117616 | "DELETE FROM %Q." LEGACY_SCHEMA_TABLE " WHERE name=%Q AND type='index'", |
| 116766 | db->aDb[iDb].zDbSName, pIndex->zName | 117617 | db->aDb[iDb].zDbSName, pIndex->zName |
| 116767 | ); | 117618 | ); |
| 116768 | sqlite3ClearStatTables(pParse, iDb, "idx", pIndex->zName); | 117619 | sqlite3ClearStatTables(pParse, iDb, "idx", pIndex->zName); |
| @@ -117158,6 +118009,7 @@ SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pI | |||
| 117158 | }else{ | 118009 | }else{ |
| 117159 | pItem->u1.zIndexedBy = sqlite3NameFromToken(pParse->db, pIndexedBy); | 118010 | pItem->u1.zIndexedBy = sqlite3NameFromToken(pParse->db, pIndexedBy); |
| 117160 | pItem->fg.isIndexedBy = 1; | 118011 | pItem->fg.isIndexedBy = 1; |
| 118012 | assert( pItem->fg.isCte==0 ); /* No collision on union u2 */ | ||
| 117161 | } | 118013 | } |
| 117162 | } | 118014 | } |
| 117163 | } | 118015 | } |
| @@ -117470,7 +118322,7 @@ SQLITE_PRIVATE void sqlite3UniqueConstraint( | |||
| 117470 | for(j=0; j<pIdx->nKeyCol; j++){ | 118322 | for(j=0; j<pIdx->nKeyCol; j++){ |
| 117471 | char *zCol; | 118323 | char *zCol; |
| 117472 | assert( pIdx->aiColumn[j]>=0 ); | 118324 | assert( pIdx->aiColumn[j]>=0 ); |
| 117473 | zCol = pTab->aCol[pIdx->aiColumn[j]].zName; | 118325 | zCol = pTab->aCol[pIdx->aiColumn[j]].zCnName; |
| 117474 | if( j ) sqlite3_str_append(&errMsg, ", ", 2); | 118326 | if( j ) sqlite3_str_append(&errMsg, ", ", 2); |
| 117475 | sqlite3_str_appendall(&errMsg, pTab->zName); | 118327 | sqlite3_str_appendall(&errMsg, pTab->zName); |
| 117476 | sqlite3_str_append(&errMsg, ".", 1); | 118328 | sqlite3_str_append(&errMsg, ".", 1); |
| @@ -117497,7 +118349,7 @@ SQLITE_PRIVATE void sqlite3RowidConstraint( | |||
| 117497 | int rc; | 118349 | int rc; |
| 117498 | if( pTab->iPKey>=0 ){ | 118350 | if( pTab->iPKey>=0 ){ |
| 117499 | zMsg = sqlite3MPrintf(pParse->db, "%s.%s", pTab->zName, | 118351 | zMsg = sqlite3MPrintf(pParse->db, "%s.%s", pTab->zName, |
| 117500 | pTab->aCol[pTab->iPKey].zName); | 118352 | pTab->aCol[pTab->iPKey].zCnName); |
| 117501 | rc = SQLITE_CONSTRAINT_PRIMARYKEY; | 118353 | rc = SQLITE_CONSTRAINT_PRIMARYKEY; |
| 117502 | }else{ | 118354 | }else{ |
| 117503 | zMsg = sqlite3MPrintf(pParse->db, "%s.rowid", pTab->zName); | 118355 | zMsg = sqlite3MPrintf(pParse->db, "%s.rowid", pTab->zName); |
| @@ -118138,6 +118990,7 @@ SQLITE_PRIVATE FuncDef *sqlite3FunctionSearch( | |||
| 118138 | ){ | 118990 | ){ |
| 118139 | FuncDef *p; | 118991 | FuncDef *p; |
| 118140 | for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){ | 118992 | for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){ |
| 118993 | assert( p->funcFlags & SQLITE_FUNC_BUILTIN ); | ||
| 118141 | if( sqlite3StrICmp(p->zName, zFunc)==0 ){ | 118994 | if( sqlite3StrICmp(p->zName, zFunc)==0 ){ |
| 118142 | return p; | 118995 | return p; |
| 118143 | } | 118996 | } |
| @@ -118159,6 +119012,7 @@ SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs( | |||
| 118159 | int nName = sqlite3Strlen30(zName); | 119012 | int nName = sqlite3Strlen30(zName); |
| 118160 | int h = SQLITE_FUNC_HASH(zName[0], nName); | 119013 | int h = SQLITE_FUNC_HASH(zName[0], nName); |
| 118161 | assert( zName[0]>='a' && zName[0]<='z' ); | 119014 | assert( zName[0]>='a' && zName[0]<='z' ); |
| 119015 | assert( aDef[i].funcFlags & SQLITE_FUNC_BUILTIN ); | ||
| 118162 | pOther = sqlite3FunctionSearch(h, zName); | 119016 | pOther = sqlite3FunctionSearch(h, zName); |
| 118163 | if( pOther ){ | 119017 | if( pOther ){ |
| 118164 | assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] ); | 119018 | assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] ); |
| @@ -118424,7 +119278,7 @@ SQLITE_PRIVATE int sqlite3IsReadOnly(Parse *pParse, Table *pTab, int viewOk){ | |||
| 118424 | return 1; | 119278 | return 1; |
| 118425 | } | 119279 | } |
| 118426 | #ifndef SQLITE_OMIT_VIEW | 119280 | #ifndef SQLITE_OMIT_VIEW |
| 118427 | if( !viewOk && pTab->pSelect ){ | 119281 | if( !viewOk && IsView(pTab) ){ |
| 118428 | sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName); | 119282 | sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName); |
| 118429 | return 1; | 119283 | return 1; |
| 118430 | } | 119284 | } |
| @@ -118528,13 +119382,13 @@ SQLITE_PRIVATE Expr *sqlite3LimitWhere( | |||
| 118528 | }else{ | 119382 | }else{ |
| 118529 | Index *pPk = sqlite3PrimaryKeyIndex(pTab); | 119383 | Index *pPk = sqlite3PrimaryKeyIndex(pTab); |
| 118530 | if( pPk->nKeyCol==1 ){ | 119384 | if( pPk->nKeyCol==1 ){ |
| 118531 | const char *zName = pTab->aCol[pPk->aiColumn[0]].zName; | 119385 | const char *zName = pTab->aCol[pPk->aiColumn[0]].zCnName; |
| 118532 | pLhs = sqlite3Expr(db, TK_ID, zName); | 119386 | pLhs = sqlite3Expr(db, TK_ID, zName); |
| 118533 | pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, zName)); | 119387 | pEList = sqlite3ExprListAppend(pParse, 0, sqlite3Expr(db, TK_ID, zName)); |
| 118534 | }else{ | 119388 | }else{ |
| 118535 | int i; | 119389 | int i; |
| 118536 | for(i=0; i<pPk->nKeyCol; i++){ | 119390 | for(i=0; i<pPk->nKeyCol; i++){ |
| 118537 | Expr *p = sqlite3Expr(db, TK_ID, pTab->aCol[pPk->aiColumn[i]].zName); | 119391 | Expr *p = sqlite3Expr(db, TK_ID, pTab->aCol[pPk->aiColumn[i]].zCnName); |
| 118538 | pEList = sqlite3ExprListAppend(pParse, pEList, p); | 119392 | pEList = sqlite3ExprListAppend(pParse, pEList, p); |
| 118539 | } | 119393 | } |
| 118540 | pLhs = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); | 119394 | pLhs = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| @@ -118550,6 +119404,7 @@ SQLITE_PRIVATE Expr *sqlite3LimitWhere( | |||
| 118550 | pSelectSrc = sqlite3SrcListDup(db, pSrc, 0); | 119404 | pSelectSrc = sqlite3SrcListDup(db, pSrc, 0); |
| 118551 | pSrc->a[0].pTab = pTab; | 119405 | pSrc->a[0].pTab = pTab; |
| 118552 | if( pSrc->a[0].fg.isIndexedBy ){ | 119406 | if( pSrc->a[0].fg.isIndexedBy ){ |
| 119407 | assert( pSrc->a[0].fg.isCte==0 ); | ||
| 118553 | pSrc->a[0].u2.pIBIndex = 0; | 119408 | pSrc->a[0].u2.pIBIndex = 0; |
| 118554 | pSrc->a[0].fg.isIndexedBy = 0; | 119409 | pSrc->a[0].fg.isIndexedBy = 0; |
| 118555 | sqlite3DbFree(db, pSrc->a[0].u1.zIndexedBy); | 119410 | sqlite3DbFree(db, pSrc->a[0].u1.zIndexedBy); |
| @@ -118641,7 +119496,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom( | |||
| 118641 | */ | 119496 | */ |
| 118642 | #ifndef SQLITE_OMIT_TRIGGER | 119497 | #ifndef SQLITE_OMIT_TRIGGER |
| 118643 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); | 119498 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0); |
| 118644 | isView = pTab->pSelect!=0; | 119499 | isView = IsView(pTab); |
| 118645 | #else | 119500 | #else |
| 118646 | # define pTrigger 0 | 119501 | # define pTrigger 0 |
| 118647 | # define isView 0 | 119502 | # define isView 0 |
| @@ -118891,7 +119746,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom( | |||
| 118891 | if( eOnePass!=ONEPASS_OFF ){ | 119746 | if( eOnePass!=ONEPASS_OFF ){ |
| 118892 | assert( nKey==nPk ); /* OP_Found will use an unpacked key */ | 119747 | assert( nKey==nPk ); /* OP_Found will use an unpacked key */ |
| 118893 | if( !IsVirtual(pTab) && aToOpen[iDataCur-iTabCur] ){ | 119748 | if( !IsVirtual(pTab) && aToOpen[iDataCur-iTabCur] ){ |
| 118894 | assert( pPk!=0 || pTab->pSelect!=0 ); | 119749 | assert( pPk!=0 || IsView(pTab) ); |
| 118895 | sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, addrBypass, iKey, nKey); | 119750 | sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, addrBypass, iKey, nKey); |
| 118896 | VdbeCoverage(v); | 119751 | VdbeCoverage(v); |
| 118897 | } | 119752 | } |
| @@ -119125,7 +119980,7 @@ SQLITE_PRIVATE void sqlite3GenerateRowDelete( | |||
| 119125 | ** the update-hook is not invoked for rows removed by REPLACE, but the | 119980 | ** the update-hook is not invoked for rows removed by REPLACE, but the |
| 119126 | ** pre-update-hook is. | 119981 | ** pre-update-hook is. |
| 119127 | */ | 119982 | */ |
| 119128 | if( pTab->pSelect==0 ){ | 119983 | if( !IsView(pTab) ){ |
| 119129 | u8 p5 = 0; | 119984 | u8 p5 = 0; |
| 119130 | sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek); | 119985 | sqlite3GenerateRowIndexDelete(pParse, pTab, iDataCur, iIdxCur,0,iIdxNoSeek); |
| 119131 | sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0)); | 119986 | sqlite3VdbeAddOp2(v, OP_Delete, iDataCur, (count?OPFLAG_NCHANGE:0)); |
| @@ -119885,9 +120740,9 @@ static void last_insert_rowid( | |||
| 119885 | /* | 120740 | /* |
| 119886 | ** Implementation of the changes() SQL function. | 120741 | ** Implementation of the changes() SQL function. |
| 119887 | ** | 120742 | ** |
| 119888 | ** IMP: R-62073-11209 The changes() SQL function is a wrapper | 120743 | ** IMP: R-32760-32347 The changes() SQL function is a wrapper |
| 119889 | ** around the sqlite3_changes() C/C++ function and hence follows the same | 120744 | ** around the sqlite3_changes64() C/C++ function and hence follows the |
| 119890 | ** rules for counting changes. | 120745 | ** same rules for counting changes. |
| 119891 | */ | 120746 | */ |
| 119892 | static void changes( | 120747 | static void changes( |
| 119893 | sqlite3_context *context, | 120748 | sqlite3_context *context, |
| @@ -119896,12 +120751,12 @@ static void changes( | |||
| 119896 | ){ | 120751 | ){ |
| 119897 | sqlite3 *db = sqlite3_context_db_handle(context); | 120752 | sqlite3 *db = sqlite3_context_db_handle(context); |
| 119898 | UNUSED_PARAMETER2(NotUsed, NotUsed2); | 120753 | UNUSED_PARAMETER2(NotUsed, NotUsed2); |
| 119899 | sqlite3_result_int(context, sqlite3_changes(db)); | 120754 | sqlite3_result_int64(context, sqlite3_changes64(db)); |
| 119900 | } | 120755 | } |
| 119901 | 120756 | ||
| 119902 | /* | 120757 | /* |
| 119903 | ** Implementation of the total_changes() SQL function. The return value is | 120758 | ** Implementation of the total_changes() SQL function. The return value is |
| 119904 | ** the same as the sqlite3_total_changes() API function. | 120759 | ** the same as the sqlite3_total_changes64() API function. |
| 119905 | */ | 120760 | */ |
| 119906 | static void total_changes( | 120761 | static void total_changes( |
| 119907 | sqlite3_context *context, | 120762 | sqlite3_context *context, |
| @@ -119910,9 +120765,9 @@ static void total_changes( | |||
| 119910 | ){ | 120765 | ){ |
| 119911 | sqlite3 *db = sqlite3_context_db_handle(context); | 120766 | sqlite3 *db = sqlite3_context_db_handle(context); |
| 119912 | UNUSED_PARAMETER2(NotUsed, NotUsed2); | 120767 | UNUSED_PARAMETER2(NotUsed, NotUsed2); |
| 119913 | /* IMP: R-52756-41993 This function is a wrapper around the | 120768 | /* IMP: R-11217-42568 This function is a wrapper around the |
| 119914 | ** sqlite3_total_changes() C/C++ interface. */ | 120769 | ** sqlite3_total_changes64() C/C++ interface. */ |
| 119915 | sqlite3_result_int(context, sqlite3_total_changes(db)); | 120770 | sqlite3_result_int64(context, sqlite3_total_changes64(db)); |
| 119916 | } | 120771 | } |
| 119917 | 120772 | ||
| 119918 | /* | 120773 | /* |
| @@ -121029,97 +121884,167 @@ static void minMaxFinalize(sqlite3_context *context){ | |||
| 121029 | 121884 | ||
| 121030 | /* | 121885 | /* |
| 121031 | ** group_concat(EXPR, ?SEPARATOR?) | 121886 | ** group_concat(EXPR, ?SEPARATOR?) |
| 121887 | ** | ||
| 121888 | ** The SEPARATOR goes before the EXPR string. This is tragic. The | ||
| 121889 | ** groupConcatInverse() implementation would have been easier if the | ||
| 121890 | ** SEPARATOR were appended after EXPR. And the order is undocumented, | ||
| 121891 | ** so we could change it, in theory. But the old behavior has been | ||
| 121892 | ** around for so long that we dare not, for fear of breaking something. | ||
| 121032 | */ | 121893 | */ |
| 121894 | typedef struct { | ||
| 121895 | StrAccum str; /* The accumulated concatenation */ | ||
| 121896 | #ifndef SQLITE_OMIT_WINDOWFUNC | ||
| 121897 | int nAccum; /* Number of strings presently concatenated */ | ||
| 121898 | int nFirstSepLength; /* Used to detect separator length change */ | ||
| 121899 | /* If pnSepLengths!=0, refs an array of inter-string separator lengths, | ||
| 121900 | ** stored as actually incorporated into presently accumulated result. | ||
| 121901 | ** (Hence, its slots in use number nAccum-1 between method calls.) | ||
| 121902 | ** If pnSepLengths==0, nFirstSepLength is the length used throughout. | ||
| 121903 | */ | ||
| 121904 | int *pnSepLengths; | ||
| 121905 | #endif | ||
| 121906 | } GroupConcatCtx; | ||
| 121907 | |||
| 121033 | static void groupConcatStep( | 121908 | static void groupConcatStep( |
| 121034 | sqlite3_context *context, | 121909 | sqlite3_context *context, |
| 121035 | int argc, | 121910 | int argc, |
| 121036 | sqlite3_value **argv | 121911 | sqlite3_value **argv |
| 121037 | ){ | 121912 | ){ |
| 121038 | const char *zVal; | 121913 | const char *zVal; |
| 121039 | StrAccum *pAccum; | 121914 | GroupConcatCtx *pGCC; |
| 121040 | const char *zSep; | 121915 | const char *zSep; |
| 121041 | int nVal, nSep; | 121916 | int nVal, nSep; |
| 121042 | assert( argc==1 || argc==2 ); | 121917 | assert( argc==1 || argc==2 ); |
| 121043 | if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; | 121918 | if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; |
| 121044 | pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum)); | 121919 | pGCC = (GroupConcatCtx*)sqlite3_aggregate_context(context, sizeof(*pGCC)); |
| 121045 | 121920 | if( pGCC ){ | |
| 121046 | if( pAccum ){ | ||
| 121047 | sqlite3 *db = sqlite3_context_db_handle(context); | 121921 | sqlite3 *db = sqlite3_context_db_handle(context); |
| 121048 | int firstTerm = pAccum->mxAlloc==0; | 121922 | int firstTerm = pGCC->str.mxAlloc==0; |
| 121049 | pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH]; | 121923 | pGCC->str.mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH]; |
| 121050 | if( !firstTerm ){ | 121924 | if( argc==1 ){ |
| 121051 | if( argc==2 ){ | 121925 | if( !firstTerm ){ |
| 121052 | zSep = (char*)sqlite3_value_text(argv[1]); | 121926 | sqlite3_str_appendchar(&pGCC->str, 1, ','); |
| 121053 | nSep = sqlite3_value_bytes(argv[1]); | 121927 | } |
| 121054 | }else{ | 121928 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 121055 | zSep = ","; | 121929 | else{ |
| 121056 | nSep = 1; | 121930 | pGCC->nFirstSepLength = 1; |
| 121931 | } | ||
| 121932 | #endif | ||
| 121933 | }else if( !firstTerm ){ | ||
| 121934 | zSep = (char*)sqlite3_value_text(argv[1]); | ||
| 121935 | nSep = sqlite3_value_bytes(argv[1]); | ||
| 121936 | if( zSep ){ | ||
| 121937 | sqlite3_str_append(&pGCC->str, zSep, nSep); | ||
| 121938 | } | ||
| 121939 | #ifndef SQLITE_OMIT_WINDOWFUNC | ||
| 121940 | else{ | ||
| 121941 | nSep = 0; | ||
| 121942 | } | ||
| 121943 | if( nSep != pGCC->nFirstSepLength || pGCC->pnSepLengths != 0 ){ | ||
| 121944 | int *pnsl = pGCC->pnSepLengths; | ||
| 121945 | if( pnsl == 0 ){ | ||
| 121946 | /* First separator length variation seen, start tracking them. */ | ||
| 121947 | pnsl = (int*)sqlite3_malloc64((pGCC->nAccum+1) * sizeof(int)); | ||
| 121948 | if( pnsl!=0 ){ | ||
| 121949 | int i = 0, nA = pGCC->nAccum-1; | ||
| 121950 | while( i<nA ) pnsl[i++] = pGCC->nFirstSepLength; | ||
| 121951 | } | ||
| 121952 | }else{ | ||
| 121953 | pnsl = (int*)sqlite3_realloc64(pnsl, pGCC->nAccum * sizeof(int)); | ||
| 121954 | } | ||
| 121955 | if( pnsl!=0 ){ | ||
| 121956 | if( ALWAYS(pGCC->nAccum>0) ){ | ||
| 121957 | pnsl[pGCC->nAccum-1] = nSep; | ||
| 121958 | } | ||
| 121959 | pGCC->pnSepLengths = pnsl; | ||
| 121960 | }else{ | ||
| 121961 | sqlite3StrAccumSetError(&pGCC->str, SQLITE_NOMEM); | ||
| 121962 | } | ||
| 121057 | } | 121963 | } |
| 121058 | if( zSep ) sqlite3_str_append(pAccum, zSep, nSep); | 121964 | #endif |
| 121965 | } | ||
| 121966 | #ifndef SQLITE_OMIT_WINDOWFUNC | ||
| 121967 | else{ | ||
| 121968 | pGCC->nFirstSepLength = sqlite3_value_bytes(argv[1]); | ||
| 121059 | } | 121969 | } |
| 121970 | pGCC->nAccum += 1; | ||
| 121971 | #endif | ||
| 121060 | zVal = (char*)sqlite3_value_text(argv[0]); | 121972 | zVal = (char*)sqlite3_value_text(argv[0]); |
| 121061 | nVal = sqlite3_value_bytes(argv[0]); | 121973 | nVal = sqlite3_value_bytes(argv[0]); |
| 121062 | if( zVal ) sqlite3_str_append(pAccum, zVal, nVal); | 121974 | if( zVal ) sqlite3_str_append(&pGCC->str, zVal, nVal); |
| 121063 | } | 121975 | } |
| 121064 | } | 121976 | } |
| 121977 | |||
| 121065 | #ifndef SQLITE_OMIT_WINDOWFUNC | 121978 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 121066 | static void groupConcatInverse( | 121979 | static void groupConcatInverse( |
| 121067 | sqlite3_context *context, | 121980 | sqlite3_context *context, |
| 121068 | int argc, | 121981 | int argc, |
| 121069 | sqlite3_value **argv | 121982 | sqlite3_value **argv |
| 121070 | ){ | 121983 | ){ |
| 121071 | int n; | 121984 | GroupConcatCtx *pGCC; |
| 121072 | StrAccum *pAccum; | ||
| 121073 | assert( argc==1 || argc==2 ); | 121985 | assert( argc==1 || argc==2 ); |
| 121986 | (void)argc; /* Suppress unused parameter warning */ | ||
| 121074 | if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; | 121987 | if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; |
| 121075 | pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum)); | 121988 | pGCC = (GroupConcatCtx*)sqlite3_aggregate_context(context, sizeof(*pGCC)); |
| 121076 | /* pAccum is always non-NULL since groupConcatStep() will have always | 121989 | /* pGCC is always non-NULL since groupConcatStep() will have always |
| 121077 | ** run frist to initialize it */ | 121990 | ** run frist to initialize it */ |
| 121078 | if( ALWAYS(pAccum) ){ | 121991 | if( ALWAYS(pGCC) ){ |
| 121079 | n = sqlite3_value_bytes(argv[0]); | 121992 | int nVS; |
| 121080 | if( argc==2 ){ | 121993 | /* Must call sqlite3_value_text() to convert the argument into text prior |
| 121081 | n += sqlite3_value_bytes(argv[1]); | 121994 | ** to invoking sqlite3_value_bytes(), in case the text encoding is UTF16 */ |
| 121995 | (void)sqlite3_value_text(argv[0]); | ||
| 121996 | nVS = sqlite3_value_bytes(argv[0]); | ||
| 121997 | pGCC->nAccum -= 1; | ||
| 121998 | if( pGCC->pnSepLengths!=0 ){ | ||
| 121999 | assert(pGCC->nAccum >= 0); | ||
| 122000 | if( pGCC->nAccum>0 ){ | ||
| 122001 | nVS += *pGCC->pnSepLengths; | ||
| 122002 | memmove(pGCC->pnSepLengths, pGCC->pnSepLengths+1, | ||
| 122003 | (pGCC->nAccum-1)*sizeof(int)); | ||
| 122004 | } | ||
| 121082 | }else{ | 122005 | }else{ |
| 121083 | n++; | 122006 | /* If removing single accumulated string, harmlessly over-do. */ |
| 122007 | nVS += pGCC->nFirstSepLength; | ||
| 121084 | } | 122008 | } |
| 121085 | if( n>=(int)pAccum->nChar ){ | 122009 | if( nVS>=(int)pGCC->str.nChar ){ |
| 121086 | pAccum->nChar = 0; | 122010 | pGCC->str.nChar = 0; |
| 121087 | }else{ | 122011 | }else{ |
| 121088 | pAccum->nChar -= n; | 122012 | pGCC->str.nChar -= nVS; |
| 121089 | memmove(pAccum->zText, &pAccum->zText[n], pAccum->nChar); | 122013 | memmove(pGCC->str.zText, &pGCC->str.zText[nVS], pGCC->str.nChar); |
| 122014 | } | ||
| 122015 | if( pGCC->str.nChar==0 ){ | ||
| 122016 | pGCC->str.mxAlloc = 0; | ||
| 122017 | sqlite3_free(pGCC->pnSepLengths); | ||
| 122018 | pGCC->pnSepLengths = 0; | ||
| 121090 | } | 122019 | } |
| 121091 | if( pAccum->nChar==0 ) pAccum->mxAlloc = 0; | ||
| 121092 | } | 122020 | } |
| 121093 | } | 122021 | } |
| 121094 | #else | 122022 | #else |
| 121095 | # define groupConcatInverse 0 | 122023 | # define groupConcatInverse 0 |
| 121096 | #endif /* SQLITE_OMIT_WINDOWFUNC */ | 122024 | #endif /* SQLITE_OMIT_WINDOWFUNC */ |
| 121097 | static void groupConcatFinalize(sqlite3_context *context){ | 122025 | static void groupConcatFinalize(sqlite3_context *context){ |
| 121098 | StrAccum *pAccum; | 122026 | GroupConcatCtx *pGCC |
| 121099 | pAccum = sqlite3_aggregate_context(context, 0); | 122027 | = (GroupConcatCtx*)sqlite3_aggregate_context(context, 0); |
| 121100 | if( pAccum ){ | 122028 | if( pGCC ){ |
| 121101 | if( pAccum->accError==SQLITE_TOOBIG ){ | 122029 | sqlite3ResultStrAccum(context, &pGCC->str); |
| 121102 | sqlite3_result_error_toobig(context); | 122030 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 121103 | }else if( pAccum->accError==SQLITE_NOMEM ){ | 122031 | sqlite3_free(pGCC->pnSepLengths); |
| 121104 | sqlite3_result_error_nomem(context); | 122032 | #endif |
| 121105 | }else{ | ||
| 121106 | sqlite3_result_text(context, sqlite3StrAccumFinish(pAccum), -1, | ||
| 121107 | sqlite3_free); | ||
| 121108 | } | ||
| 121109 | } | 122033 | } |
| 121110 | } | 122034 | } |
| 121111 | #ifndef SQLITE_OMIT_WINDOWFUNC | 122035 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 121112 | static void groupConcatValue(sqlite3_context *context){ | 122036 | static void groupConcatValue(sqlite3_context *context){ |
| 121113 | sqlite3_str *pAccum; | 122037 | GroupConcatCtx *pGCC |
| 121114 | pAccum = (sqlite3_str*)sqlite3_aggregate_context(context, 0); | 122038 | = (GroupConcatCtx*)sqlite3_aggregate_context(context, 0); |
| 121115 | if( pAccum ){ | 122039 | if( pGCC ){ |
| 122040 | StrAccum *pAccum = &pGCC->str; | ||
| 121116 | if( pAccum->accError==SQLITE_TOOBIG ){ | 122041 | if( pAccum->accError==SQLITE_TOOBIG ){ |
| 121117 | sqlite3_result_error_toobig(context); | 122042 | sqlite3_result_error_toobig(context); |
| 121118 | }else if( pAccum->accError==SQLITE_NOMEM ){ | 122043 | }else if( pAccum->accError==SQLITE_NOMEM ){ |
| 121119 | sqlite3_result_error_nomem(context); | 122044 | sqlite3_result_error_nomem(context); |
| 121120 | }else{ | 122045 | }else{ |
| 121121 | const char *zText = sqlite3_str_value(pAccum); | 122046 | const char *zText = sqlite3_str_value(pAccum); |
| 121122 | sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT); | 122047 | sqlite3_result_text(context, zText, pAccum->nChar, SQLITE_TRANSIENT); |
| 121123 | } | 122048 | } |
| 121124 | } | 122049 | } |
| 121125 | } | 122050 | } |
| @@ -121183,11 +122108,12 @@ SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocas | |||
| 121183 | int nExpr; | 122108 | int nExpr; |
| 121184 | assert( pExpr!=0 ); | 122109 | assert( pExpr!=0 ); |
| 121185 | assert( pExpr->op==TK_FUNCTION ); | 122110 | assert( pExpr->op==TK_FUNCTION ); |
| 122111 | assert( ExprUseXList(pExpr) ); | ||
| 121186 | if( !pExpr->x.pList ){ | 122112 | if( !pExpr->x.pList ){ |
| 121187 | return 0; | 122113 | return 0; |
| 121188 | } | 122114 | } |
| 121189 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | ||
| 121190 | nExpr = pExpr->x.pList->nExpr; | 122115 | nExpr = pExpr->x.pList->nExpr; |
| 122116 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 121191 | pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0); | 122117 | pDef = sqlite3FindFunction(db, pExpr->u.zToken, nExpr, SQLITE_UTF8, 0); |
| 121192 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION | 122118 | #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 121193 | if( pDef==0 ) return 0; | 122119 | if( pDef==0 ) return 0; |
| @@ -121211,6 +122137,7 @@ SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocas | |||
| 121211 | Expr *pEscape = pExpr->x.pList->a[2].pExpr; | 122137 | Expr *pEscape = pExpr->x.pList->a[2].pExpr; |
| 121212 | char *zEscape; | 122138 | char *zEscape; |
| 121213 | if( pEscape->op!=TK_STRING ) return 0; | 122139 | if( pEscape->op!=TK_STRING ) return 0; |
| 122140 | assert( !ExprHasProperty(pEscape, EP_IntValue) ); | ||
| 121214 | zEscape = pEscape->u.zToken; | 122141 | zEscape = pEscape->u.zToken; |
| 121215 | if( zEscape[0]==0 || zEscape[1]!=0 ) return 0; | 122142 | if( zEscape[0]==0 || zEscape[1]!=0 ) return 0; |
| 121216 | if( zEscape[0]==aWc[0] ) return 0; | 122143 | if( zEscape[0]==aWc[0] ) return 0; |
| @@ -121437,12 +122364,12 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ | |||
| 121437 | */ | 122364 | */ |
| 121438 | static FuncDef aBuiltinFunc[] = { | 122365 | static FuncDef aBuiltinFunc[] = { |
| 121439 | /***** Functions only available with SQLITE_TESTCTRL_INTERNAL_FUNCTIONS *****/ | 122366 | /***** Functions only available with SQLITE_TESTCTRL_INTERNAL_FUNCTIONS *****/ |
| 122367 | #if !defined(SQLITE_UNTESTABLE) | ||
| 121440 | TEST_FUNC(implies_nonnull_row, 2, INLINEFUNC_implies_nonnull_row, 0), | 122368 | TEST_FUNC(implies_nonnull_row, 2, INLINEFUNC_implies_nonnull_row, 0), |
| 121441 | TEST_FUNC(expr_compare, 2, INLINEFUNC_expr_compare, 0), | 122369 | TEST_FUNC(expr_compare, 2, INLINEFUNC_expr_compare, 0), |
| 121442 | TEST_FUNC(expr_implies_expr, 2, INLINEFUNC_expr_implies_expr, 0), | 122370 | TEST_FUNC(expr_implies_expr, 2, INLINEFUNC_expr_implies_expr, 0), |
| 121443 | #ifdef SQLITE_DEBUG | 122371 | TEST_FUNC(affinity, 1, INLINEFUNC_affinity, 0), |
| 121444 | TEST_FUNC(affinity, 1, INLINEFUNC_affinity, 0), | 122372 | #endif /* !defined(SQLITE_UNTESTABLE) */ |
| 121445 | #endif | ||
| 121446 | /***** Regular functions *****/ | 122373 | /***** Regular functions *****/ |
| 121447 | #ifdef SQLITE_SOUNDEX | 122374 | #ifdef SQLITE_SOUNDEX |
| 121448 | FUNCTION(soundex, 1, 0, 0, soundexFunc ), | 122375 | FUNCTION(soundex, 1, 0, 0, soundexFunc ), |
| @@ -121474,11 +122401,11 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ | |||
| 121474 | FUNCTION(min, -1, 0, 1, minmaxFunc ), | 122401 | FUNCTION(min, -1, 0, 1, minmaxFunc ), |
| 121475 | FUNCTION(min, 0, 0, 1, 0 ), | 122402 | FUNCTION(min, 0, 0, 1, 0 ), |
| 121476 | WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, | 122403 | WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, |
| 121477 | SQLITE_FUNC_MINMAX ), | 122404 | SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ), |
| 121478 | FUNCTION(max, -1, 1, 1, minmaxFunc ), | 122405 | FUNCTION(max, -1, 1, 1, minmaxFunc ), |
| 121479 | FUNCTION(max, 0, 1, 1, 0 ), | 122406 | FUNCTION(max, 0, 1, 1, 0 ), |
| 121480 | WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, | 122407 | WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0, |
| 121481 | SQLITE_FUNC_MINMAX ), | 122408 | SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ), |
| 121482 | FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF), | 122409 | FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF), |
| 121483 | FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH), | 122410 | FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH), |
| 121484 | FUNCTION(instr, 2, 0, 0, instrFunc ), | 122411 | FUNCTION(instr, 2, 0, 0, instrFunc ), |
| @@ -121514,9 +122441,10 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ | |||
| 121514 | WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0), | 122441 | WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0), |
| 121515 | WAGGREGATE(avg, 1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0), | 122442 | WAGGREGATE(avg, 1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0), |
| 121516 | WAGGREGATE(count, 0,0,0, countStep, | 122443 | WAGGREGATE(count, 0,0,0, countStep, |
| 121517 | countFinalize, countFinalize, countInverse, SQLITE_FUNC_COUNT ), | 122444 | countFinalize, countFinalize, countInverse, |
| 122445 | SQLITE_FUNC_COUNT|SQLITE_FUNC_ANYORDER ), | ||
| 121518 | WAGGREGATE(count, 1,0,0, countStep, | 122446 | WAGGREGATE(count, 1,0,0, countStep, |
| 121519 | countFinalize, countFinalize, countInverse, 0 ), | 122447 | countFinalize, countFinalize, countInverse, SQLITE_FUNC_ANYORDER ), |
| 121520 | WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep, | 122448 | WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep, |
| 121521 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), | 122449 | groupConcatFinalize, groupConcatValue, groupConcatInverse, 0), |
| 121522 | WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, | 122450 | WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep, |
| @@ -121591,6 +122519,7 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){ | |||
| 121591 | for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash){ | 122519 | for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash){ |
| 121592 | int n = sqlite3Strlen30(p->zName); | 122520 | int n = sqlite3Strlen30(p->zName); |
| 121593 | int h = p->zName[0] + n; | 122521 | int h = p->zName[0] + n; |
| 122522 | assert( p->funcFlags & SQLITE_FUNC_BUILTIN ); | ||
| 121594 | printf(" %s(%d)", p->zName, h); | 122523 | printf(" %s(%d)", p->zName, h); |
| 121595 | } | 122524 | } |
| 121596 | printf("\n"); | 122525 | printf("\n"); |
| @@ -121818,7 +122747,9 @@ SQLITE_PRIVATE int sqlite3FkLocateIndex( | |||
| 121818 | */ | 122747 | */ |
| 121819 | if( pParent->iPKey>=0 ){ | 122748 | if( pParent->iPKey>=0 ){ |
| 121820 | if( !zKey ) return 0; | 122749 | if( !zKey ) return 0; |
| 121821 | if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zName, zKey) ) return 0; | 122750 | if( !sqlite3StrICmp(pParent->aCol[pParent->iPKey].zCnName, zKey) ){ |
| 122751 | return 0; | ||
| 122752 | } | ||
| 121822 | } | 122753 | } |
| 121823 | }else if( paiCol ){ | 122754 | }else if( paiCol ){ |
| 121824 | assert( nCol>1 ); | 122755 | assert( nCol>1 ); |
| @@ -121860,11 +122791,11 @@ SQLITE_PRIVATE int sqlite3FkLocateIndex( | |||
| 121860 | /* If the index uses a collation sequence that is different from | 122791 | /* If the index uses a collation sequence that is different from |
| 121861 | ** the default collation sequence for the column, this index is | 122792 | ** the default collation sequence for the column, this index is |
| 121862 | ** unusable. Bail out early in this case. */ | 122793 | ** unusable. Bail out early in this case. */ |
| 121863 | zDfltColl = pParent->aCol[iCol].zColl; | 122794 | zDfltColl = sqlite3ColumnColl(&pParent->aCol[iCol]); |
| 121864 | if( !zDfltColl ) zDfltColl = sqlite3StrBINARY; | 122795 | if( !zDfltColl ) zDfltColl = sqlite3StrBINARY; |
| 121865 | if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break; | 122796 | if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break; |
| 121866 | 122797 | ||
| 121867 | zIdxCol = pParent->aCol[iCol].zName; | 122798 | zIdxCol = pParent->aCol[iCol].zCnName; |
| 121868 | for(j=0; j<nCol; j++){ | 122799 | for(j=0; j<nCol; j++){ |
| 121869 | if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){ | 122800 | if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){ |
| 121870 | if( aiCol ) aiCol[i] = pFKey->aCol[j].iFrom; | 122801 | if( aiCol ) aiCol[i] = pFKey->aCol[j].iFrom; |
| @@ -122088,7 +123019,7 @@ static Expr *exprTableRegister( | |||
| 122088 | pCol = &pTab->aCol[iCol]; | 123019 | pCol = &pTab->aCol[iCol]; |
| 122089 | pExpr->iTable = regBase + sqlite3TableColumnToStorage(pTab,iCol) + 1; | 123020 | pExpr->iTable = regBase + sqlite3TableColumnToStorage(pTab,iCol) + 1; |
| 122090 | pExpr->affExpr = pCol->affinity; | 123021 | pExpr->affExpr = pCol->affinity; |
| 122091 | zColl = pCol->zColl; | 123022 | zColl = sqlite3ColumnColl(pCol); |
| 122092 | if( zColl==0 ) zColl = db->pDfltColl->zName; | 123023 | if( zColl==0 ) zColl = db->pDfltColl->zName; |
| 122093 | pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl); | 123024 | pExpr = sqlite3ExprAddCollateString(pParse, pExpr, zColl); |
| 122094 | }else{ | 123025 | }else{ |
| @@ -122111,6 +123042,7 @@ static Expr *exprTableColumn( | |||
| 122111 | ){ | 123042 | ){ |
| 122112 | Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0); | 123043 | Expr *pExpr = sqlite3Expr(db, TK_COLUMN, 0); |
| 122113 | if( pExpr ){ | 123044 | if( pExpr ){ |
| 123045 | assert( ExprUseYTab(pExpr) ); | ||
| 122114 | pExpr->y.pTab = pTab; | 123046 | pExpr->y.pTab = pTab; |
| 122115 | pExpr->iTable = iCursor; | 123047 | pExpr->iTable = iCursor; |
| 122116 | pExpr->iColumn = iCol; | 123048 | pExpr->iColumn = iCol; |
| @@ -122197,7 +123129,7 @@ static void fkScanChildren( | |||
| 122197 | pLeft = exprTableRegister(pParse, pTab, regData, iCol); | 123129 | pLeft = exprTableRegister(pParse, pTab, regData, iCol); |
| 122198 | iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom; | 123130 | iCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom; |
| 122199 | assert( iCol>=0 ); | 123131 | assert( iCol>=0 ); |
| 122200 | zCol = pFKey->pFrom->aCol[iCol].zName; | 123132 | zCol = pFKey->pFrom->aCol[iCol].zCnName; |
| 122201 | pRight = sqlite3Expr(db, TK_ID, zCol); | 123133 | pRight = sqlite3Expr(db, TK_ID, zCol); |
| 122202 | pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight); | 123134 | pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight); |
| 122203 | pWhere = sqlite3ExprAnd(pParse, pWhere, pEq); | 123135 | pWhere = sqlite3ExprAnd(pParse, pWhere, pEq); |
| @@ -122232,7 +123164,7 @@ static void fkScanChildren( | |||
| 122232 | i16 iCol = pIdx->aiColumn[i]; | 123164 | i16 iCol = pIdx->aiColumn[i]; |
| 122233 | assert( iCol>=0 ); | 123165 | assert( iCol>=0 ); |
| 122234 | pLeft = exprTableRegister(pParse, pTab, regData, iCol); | 123166 | pLeft = exprTableRegister(pParse, pTab, regData, iCol); |
| 122235 | pRight = sqlite3Expr(db, TK_ID, pTab->aCol[iCol].zName); | 123167 | pRight = sqlite3Expr(db, TK_ID, pTab->aCol[iCol].zCnName); |
| 122236 | pEq = sqlite3PExpr(pParse, TK_IS, pLeft, pRight); | 123168 | pEq = sqlite3PExpr(pParse, TK_IS, pLeft, pRight); |
| 122237 | pAll = sqlite3ExprAnd(pParse, pAll, pEq); | 123169 | pAll = sqlite3ExprAnd(pParse, pAll, pEq); |
| 122238 | } | 123170 | } |
| @@ -122321,12 +123253,12 @@ static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){ | |||
| 122321 | */ | 123253 | */ |
| 122322 | SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){ | 123254 | SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){ |
| 122323 | sqlite3 *db = pParse->db; | 123255 | sqlite3 *db = pParse->db; |
| 122324 | if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) ){ | 123256 | if( (db->flags&SQLITE_ForeignKeys) && IsOrdinaryTable(pTab) ){ |
| 122325 | int iSkip = 0; | 123257 | int iSkip = 0; |
| 122326 | Vdbe *v = sqlite3GetVdbe(pParse); | 123258 | Vdbe *v = sqlite3GetVdbe(pParse); |
| 122327 | 123259 | ||
| 122328 | assert( v ); /* VDBE has already been allocated */ | 123260 | assert( v ); /* VDBE has already been allocated */ |
| 122329 | assert( pTab->pSelect==0 ); /* Not a view */ | 123261 | assert( IsOrdinaryTable(pTab) ); |
| 122330 | if( sqlite3FkReferences(pTab)==0 ){ | 123262 | if( sqlite3FkReferences(pTab)==0 ){ |
| 122331 | /* Search for a deferred foreign key constraint for which this table | 123263 | /* Search for a deferred foreign key constraint for which this table |
| 122332 | ** is the child table. If one cannot be found, return without | 123264 | ** is the child table. If one cannot be found, return without |
| @@ -122334,7 +123266,7 @@ SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTa | |||
| 122334 | ** the entire DELETE if there are no outstanding deferred constraints | 123266 | ** the entire DELETE if there are no outstanding deferred constraints |
| 122335 | ** when this statement is run. */ | 123267 | ** when this statement is run. */ |
| 122336 | FKey *p; | 123268 | FKey *p; |
| 122337 | for(p=pTab->pFKey; p; p=p->pNextFrom){ | 123269 | for(p=pTab->u.tab.pFKey; p; p=p->pNextFrom){ |
| 122338 | if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break; | 123270 | if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break; |
| 122339 | } | 123271 | } |
| 122340 | if( !p ) return; | 123272 | if( !p ) return; |
| @@ -122423,7 +123355,7 @@ static int fkParentIsModified( | |||
| 122423 | if( aChange[iKey]>=0 || (iKey==pTab->iPKey && bChngRowid) ){ | 123355 | if( aChange[iKey]>=0 || (iKey==pTab->iPKey && bChngRowid) ){ |
| 122424 | Column *pCol = &pTab->aCol[iKey]; | 123356 | Column *pCol = &pTab->aCol[iKey]; |
| 122425 | if( zKey ){ | 123357 | if( zKey ){ |
| 122426 | if( 0==sqlite3StrICmp(pCol->zName, zKey) ) return 1; | 123358 | if( 0==sqlite3StrICmp(pCol->zCnName, zKey) ) return 1; |
| 122427 | }else if( pCol->colFlags & COLFLAG_PRIMKEY ){ | 123359 | }else if( pCol->colFlags & COLFLAG_PRIMKEY ){ |
| 122428 | return 1; | 123360 | return 1; |
| 122429 | } | 123361 | } |
| @@ -122490,13 +123422,14 @@ SQLITE_PRIVATE void sqlite3FkCheck( | |||
| 122490 | 123422 | ||
| 122491 | /* If foreign-keys are disabled, this function is a no-op. */ | 123423 | /* If foreign-keys are disabled, this function is a no-op. */ |
| 122492 | if( (db->flags&SQLITE_ForeignKeys)==0 ) return; | 123424 | if( (db->flags&SQLITE_ForeignKeys)==0 ) return; |
| 123425 | if( !IsOrdinaryTable(pTab) ) return; | ||
| 122493 | 123426 | ||
| 122494 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | 123427 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 122495 | zDb = db->aDb[iDb].zDbSName; | 123428 | zDb = db->aDb[iDb].zDbSName; |
| 122496 | 123429 | ||
| 122497 | /* Loop through all the foreign key constraints for which pTab is the | 123430 | /* Loop through all the foreign key constraints for which pTab is the |
| 122498 | ** child table (the table that the foreign key definition is part of). */ | 123431 | ** child table (the table that the foreign key definition is part of). */ |
| 122499 | for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){ | 123432 | for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){ |
| 122500 | Table *pTo; /* Parent table of foreign key pFKey */ | 123433 | Table *pTo; /* Parent table of foreign key pFKey */ |
| 122501 | Index *pIdx = 0; /* Index on key columns in pTo */ | 123434 | Index *pIdx = 0; /* Index on key columns in pTo */ |
| 122502 | int *aiFree = 0; | 123435 | int *aiFree = 0; |
| @@ -122563,7 +123496,7 @@ SQLITE_PRIVATE void sqlite3FkCheck( | |||
| 122563 | ** values read from the parent table are NULL. */ | 123496 | ** values read from the parent table are NULL. */ |
| 122564 | if( db->xAuth ){ | 123497 | if( db->xAuth ){ |
| 122565 | int rcauth; | 123498 | int rcauth; |
| 122566 | char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName; | 123499 | char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zCnName; |
| 122567 | rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb); | 123500 | rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb); |
| 122568 | bIgnore = (rcauth==SQLITE_IGNORE); | 123501 | bIgnore = (rcauth==SQLITE_IGNORE); |
| 122569 | } | 123502 | } |
| @@ -122678,10 +123611,10 @@ SQLITE_PRIVATE u32 sqlite3FkOldmask( | |||
| 122678 | Table *pTab /* Table being modified */ | 123611 | Table *pTab /* Table being modified */ |
| 122679 | ){ | 123612 | ){ |
| 122680 | u32 mask = 0; | 123613 | u32 mask = 0; |
| 122681 | if( pParse->db->flags&SQLITE_ForeignKeys ){ | 123614 | if( pParse->db->flags&SQLITE_ForeignKeys && IsOrdinaryTable(pTab) ){ |
| 122682 | FKey *p; | 123615 | FKey *p; |
| 122683 | int i; | 123616 | int i; |
| 122684 | for(p=pTab->pFKey; p; p=p->pNextFrom){ | 123617 | for(p=pTab->u.tab.pFKey; p; p=p->pNextFrom){ |
| 122685 | for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom); | 123618 | for(i=0; i<p->nCol; i++) mask |= COLUMN_MASK(p->aCol[i].iFrom); |
| 122686 | } | 123619 | } |
| 122687 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ | 123620 | for(p=sqlite3FkReferences(pTab); p; p=p->pNextTo){ |
| @@ -122731,19 +123664,19 @@ SQLITE_PRIVATE int sqlite3FkRequired( | |||
| 122731 | ){ | 123664 | ){ |
| 122732 | int eRet = 1; /* Value to return if bHaveFK is true */ | 123665 | int eRet = 1; /* Value to return if bHaveFK is true */ |
| 122733 | int bHaveFK = 0; /* If FK processing is required */ | 123666 | int bHaveFK = 0; /* If FK processing is required */ |
| 122734 | if( pParse->db->flags&SQLITE_ForeignKeys ){ | 123667 | if( pParse->db->flags&SQLITE_ForeignKeys && IsOrdinaryTable(pTab) ){ |
| 122735 | if( !aChange ){ | 123668 | if( !aChange ){ |
| 122736 | /* A DELETE operation. Foreign key processing is required if the | 123669 | /* A DELETE operation. Foreign key processing is required if the |
| 122737 | ** table in question is either the child or parent table for any | 123670 | ** table in question is either the child or parent table for any |
| 122738 | ** foreign key constraint. */ | 123671 | ** foreign key constraint. */ |
| 122739 | bHaveFK = (sqlite3FkReferences(pTab) || pTab->pFKey); | 123672 | bHaveFK = (sqlite3FkReferences(pTab) || pTab->u.tab.pFKey); |
| 122740 | }else{ | 123673 | }else{ |
| 122741 | /* This is an UPDATE. Foreign key processing is only required if the | 123674 | /* This is an UPDATE. Foreign key processing is only required if the |
| 122742 | ** operation modifies one or more child or parent key columns. */ | 123675 | ** operation modifies one or more child or parent key columns. */ |
| 122743 | FKey *p; | 123676 | FKey *p; |
| 122744 | 123677 | ||
| 122745 | /* Check if any child key columns are being modified. */ | 123678 | /* Check if any child key columns are being modified. */ |
| 122746 | for(p=pTab->pFKey; p; p=p->pNextFrom){ | 123679 | for(p=pTab->u.tab.pFKey; p; p=p->pNextFrom){ |
| 122747 | if( fkChildIsModified(pTab, p, aChange, chngRowid) ){ | 123680 | if( fkChildIsModified(pTab, p, aChange, chngRowid) ){ |
| 122748 | if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) eRet = 2; | 123681 | if( 0==sqlite3_stricmp(pTab->zName, p->zTo) ) eRet = 2; |
| 122749 | bHaveFK = 1; | 123682 | bHaveFK = 1; |
| @@ -122836,8 +123769,8 @@ static Trigger *fkActionTrigger( | |||
| 122836 | assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) ); | 123769 | assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) ); |
| 122837 | assert( pIdx==0 || pIdx->aiColumn[i]>=0 ); | 123770 | assert( pIdx==0 || pIdx->aiColumn[i]>=0 ); |
| 122838 | sqlite3TokenInit(&tToCol, | 123771 | sqlite3TokenInit(&tToCol, |
| 122839 | pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zName); | 123772 | pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zCnName); |
| 122840 | sqlite3TokenInit(&tFromCol, pFKey->pFrom->aCol[iFromCol].zName); | 123773 | sqlite3TokenInit(&tFromCol, pFKey->pFrom->aCol[iFromCol].zCnName); |
| 122841 | 123774 | ||
| 122842 | /* Create the expression "OLD.zToCol = zFromCol". It is important | 123775 | /* Create the expression "OLD.zToCol = zFromCol". It is important |
| 122843 | ** that the "OLD.zToCol" term is on the LHS of the = operator, so | 123776 | ** that the "OLD.zToCol" term is on the LHS of the = operator, so |
| @@ -122882,7 +123815,7 @@ static Trigger *fkActionTrigger( | |||
| 122882 | testcase( pCol->colFlags & COLFLAG_STORED ); | 123815 | testcase( pCol->colFlags & COLFLAG_STORED ); |
| 122883 | pDflt = 0; | 123816 | pDflt = 0; |
| 122884 | }else{ | 123817 | }else{ |
| 122885 | pDflt = pCol->pDflt; | 123818 | pDflt = sqlite3ColumnExpr(pFKey->pFrom, pCol); |
| 122886 | } | 123819 | } |
| 122887 | if( pDflt ){ | 123820 | if( pDflt ){ |
| 122888 | pNew = sqlite3ExprDup(db, pDflt, 0); | 123821 | pNew = sqlite3ExprDup(db, pDflt, 0); |
| @@ -123019,9 +123952,9 @@ SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *db, Table *pTab){ | |||
| 123019 | FKey *pFKey; /* Iterator variable */ | 123952 | FKey *pFKey; /* Iterator variable */ |
| 123020 | FKey *pNext; /* Copy of pFKey->pNextFrom */ | 123953 | FKey *pNext; /* Copy of pFKey->pNextFrom */ |
| 123021 | 123954 | ||
| 123022 | assert( db==0 || IsVirtual(pTab) | 123955 | assert( IsOrdinaryTable(pTab) ); |
| 123023 | || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) ); | 123956 | for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pNext){ |
| 123024 | for(pFKey=pTab->pFKey; pFKey; pFKey=pNext){ | 123957 | assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pTab->pSchema) ); |
| 123025 | 123958 | ||
| 123026 | /* Remove the FK from the fkeyHash hash table. */ | 123959 | /* Remove the FK from the fkeyHash hash table. */ |
| 123027 | if( !db || db->pnBytesFreed==0 ){ | 123960 | if( !db || db->pnBytesFreed==0 ){ |
| @@ -123168,28 +124101,68 @@ SQLITE_PRIVATE const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){ | |||
| 123168 | } | 124101 | } |
| 123169 | 124102 | ||
| 123170 | /* | 124103 | /* |
| 124104 | ** Make changes to the evolving bytecode to do affinity transformations | ||
| 124105 | ** of values that are about to be gathered into a row for table pTab. | ||
| 124106 | ** | ||
| 124107 | ** For ordinary (legacy, non-strict) tables: | ||
| 124108 | ** ----------------------------------------- | ||
| 124109 | ** | ||
| 123171 | ** Compute the affinity string for table pTab, if it has not already been | 124110 | ** Compute the affinity string for table pTab, if it has not already been |
| 123172 | ** computed. As an optimization, omit trailing SQLITE_AFF_BLOB affinities. | 124111 | ** computed. As an optimization, omit trailing SQLITE_AFF_BLOB affinities. |
| 123173 | ** | 124112 | ** |
| 123174 | ** If the affinity exists (if it is no entirely SQLITE_AFF_BLOB values) and | 124113 | ** If the affinity string is empty (because it was all SQLITE_AFF_BLOB entries |
| 123175 | ** if iReg>0 then code an OP_Affinity opcode that will set the affinities | 124114 | ** which were then optimized out) then this routine becomes a no-op. |
| 123176 | ** for register iReg and following. Or if affinities exists and iReg==0, | 124115 | ** |
| 124116 | ** Otherwise if iReg>0 then code an OP_Affinity opcode that will set the | ||
| 124117 | ** affinities for register iReg and following. Or if iReg==0, | ||
| 123177 | ** then just set the P4 operand of the previous opcode (which should be | 124118 | ** then just set the P4 operand of the previous opcode (which should be |
| 123178 | ** an OP_MakeRecord) to the affinity string. | 124119 | ** an OP_MakeRecord) to the affinity string. |
| 123179 | ** | 124120 | ** |
| 123180 | ** A column affinity string has one character per column: | 124121 | ** A column affinity string has one character per column: |
| 123181 | ** | 124122 | ** |
| 123182 | ** Character Column affinity | 124123 | ** Character Column affinity |
| 123183 | ** ------------------------------ | 124124 | ** --------- --------------- |
| 123184 | ** 'A' BLOB | 124125 | ** 'A' BLOB |
| 123185 | ** 'B' TEXT | 124126 | ** 'B' TEXT |
| 123186 | ** 'C' NUMERIC | 124127 | ** 'C' NUMERIC |
| 123187 | ** 'D' INTEGER | 124128 | ** 'D' INTEGER |
| 123188 | ** 'E' REAL | 124129 | ** 'E' REAL |
| 124130 | ** | ||
| 124131 | ** For STRICT tables: | ||
| 124132 | ** ------------------ | ||
| 124133 | ** | ||
| 124134 | ** Generate an appropropriate OP_TypeCheck opcode that will verify the | ||
| 124135 | ** datatypes against the column definitions in pTab. If iReg==0, that | ||
| 124136 | ** means an OP_MakeRecord opcode has already been generated and should be | ||
| 124137 | ** the last opcode generated. The new OP_TypeCheck needs to be inserted | ||
| 124138 | ** before the OP_MakeRecord. The new OP_TypeCheck should use the same | ||
| 124139 | ** register set as the OP_MakeRecord. If iReg>0 then register iReg is | ||
| 124140 | ** the first of a series of registers that will form the new record. | ||
| 124141 | ** Apply the type checking to that array of registers. | ||
| 123189 | */ | 124142 | */ |
| 123190 | SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){ | 124143 | SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){ |
| 123191 | int i, j; | 124144 | int i, j; |
| 123192 | char *zColAff = pTab->zColAff; | 124145 | char *zColAff; |
| 124146 | if( pTab->tabFlags & TF_Strict ){ | ||
| 124147 | if( iReg==0 ){ | ||
| 124148 | /* Move the previous opcode (which should be OP_MakeRecord) forward | ||
| 124149 | ** by one slot and insert a new OP_TypeCheck where the current | ||
| 124150 | ** OP_MakeRecord is found */ | ||
| 124151 | VdbeOp *pPrev; | ||
| 124152 | sqlite3VdbeAppendP4(v, pTab, P4_TABLE); | ||
| 124153 | pPrev = sqlite3VdbeGetOp(v, -1); | ||
| 124154 | assert( pPrev!=0 ); | ||
| 124155 | assert( pPrev->opcode==OP_MakeRecord || sqlite3VdbeDb(v)->mallocFailed ); | ||
| 124156 | pPrev->opcode = OP_TypeCheck; | ||
| 124157 | sqlite3VdbeAddOp3(v, OP_MakeRecord, pPrev->p1, pPrev->p2, pPrev->p3); | ||
| 124158 | }else{ | ||
| 124159 | /* Insert an isolated OP_Typecheck */ | ||
| 124160 | sqlite3VdbeAddOp2(v, OP_TypeCheck, iReg, pTab->nNVCol); | ||
| 124161 | sqlite3VdbeAppendP4(v, pTab, P4_TABLE); | ||
| 124162 | } | ||
| 124163 | return; | ||
| 124164 | } | ||
| 124165 | zColAff = pTab->zColAff; | ||
| 123193 | if( zColAff==0 ){ | 124166 | if( zColAff==0 ){ |
| 123194 | sqlite3 *db = sqlite3VdbeDb(v); | 124167 | sqlite3 *db = sqlite3VdbeDb(v); |
| 123195 | zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1); | 124168 | zColAff = (char *)sqlite3DbMallocRaw(0, pTab->nCol+1); |
| @@ -123215,6 +124188,8 @@ SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){ | |||
| 123215 | if( iReg ){ | 124188 | if( iReg ){ |
| 123216 | sqlite3VdbeAddOp4(v, OP_Affinity, iReg, i, 0, zColAff, i); | 124189 | sqlite3VdbeAddOp4(v, OP_Affinity, iReg, i, 0, zColAff, i); |
| 123217 | }else{ | 124190 | }else{ |
| 124191 | assert( sqlite3VdbeGetOp(v, -1)->opcode==OP_MakeRecord | ||
| 124192 | || sqlite3VdbeDb(v)->mallocFailed ); | ||
| 123218 | sqlite3VdbeChangeP4(v, -1, zColAff, i); | 124193 | sqlite3VdbeChangeP4(v, -1, zColAff, i); |
| 123219 | } | 124194 | } |
| 123220 | } | 124195 | } |
| @@ -123298,24 +124273,30 @@ SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns( | |||
| 123298 | ** that appropriate affinity has been applied to the regular columns | 124273 | ** that appropriate affinity has been applied to the regular columns |
| 123299 | */ | 124274 | */ |
| 123300 | sqlite3TableAffinity(pParse->pVdbe, pTab, iRegStore); | 124275 | sqlite3TableAffinity(pParse->pVdbe, pTab, iRegStore); |
| 123301 | if( (pTab->tabFlags & TF_HasStored)!=0 | 124276 | if( (pTab->tabFlags & TF_HasStored)!=0 ){ |
| 123302 | && (pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1))->opcode==OP_Affinity | 124277 | pOp = sqlite3VdbeGetOp(pParse->pVdbe,-1); |
| 123303 | ){ | 124278 | if( pOp->opcode==OP_Affinity ){ |
| 123304 | /* Change the OP_Affinity argument to '@' (NONE) for all stored | 124279 | /* Change the OP_Affinity argument to '@' (NONE) for all stored |
| 123305 | ** columns. '@' is the no-op affinity and those columns have not | 124280 | ** columns. '@' is the no-op affinity and those columns have not |
| 123306 | ** yet been computed. */ | 124281 | ** yet been computed. */ |
| 123307 | int ii, jj; | 124282 | int ii, jj; |
| 123308 | char *zP4 = pOp->p4.z; | 124283 | char *zP4 = pOp->p4.z; |
| 123309 | assert( zP4!=0 ); | 124284 | assert( zP4!=0 ); |
| 123310 | assert( pOp->p4type==P4_DYNAMIC ); | 124285 | assert( pOp->p4type==P4_DYNAMIC ); |
| 123311 | for(ii=jj=0; zP4[jj]; ii++){ | 124286 | for(ii=jj=0; zP4[jj]; ii++){ |
| 123312 | if( pTab->aCol[ii].colFlags & COLFLAG_VIRTUAL ){ | 124287 | if( pTab->aCol[ii].colFlags & COLFLAG_VIRTUAL ){ |
| 123313 | continue; | 124288 | continue; |
| 123314 | } | 124289 | } |
| 123315 | if( pTab->aCol[ii].colFlags & COLFLAG_STORED ){ | 124290 | if( pTab->aCol[ii].colFlags & COLFLAG_STORED ){ |
| 123316 | zP4[jj] = SQLITE_AFF_NONE; | 124291 | zP4[jj] = SQLITE_AFF_NONE; |
| 124292 | } | ||
| 124293 | jj++; | ||
| 123317 | } | 124294 | } |
| 123318 | jj++; | 124295 | }else if( pOp->opcode==OP_TypeCheck ){ |
| 124296 | /* If an OP_TypeCheck was generated because the table is STRICT, | ||
| 124297 | ** then set the P3 operand to indicate that generated columns should | ||
| 124298 | ** not be checked */ | ||
| 124299 | pOp->p3 = 1; | ||
| 123319 | } | 124300 | } |
| 123320 | } | 124301 | } |
| 123321 | 124302 | ||
| @@ -123351,7 +124332,7 @@ SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns( | |||
| 123351 | int x; | 124332 | int x; |
| 123352 | pCol->colFlags |= COLFLAG_BUSY; | 124333 | pCol->colFlags |= COLFLAG_BUSY; |
| 123353 | w.eCode = 0; | 124334 | w.eCode = 0; |
| 123354 | sqlite3WalkExpr(&w, pCol->pDflt); | 124335 | sqlite3WalkExpr(&w, sqlite3ColumnExpr(pTab, pCol)); |
| 123355 | pCol->colFlags &= ~COLFLAG_BUSY; | 124336 | pCol->colFlags &= ~COLFLAG_BUSY; |
| 123356 | if( w.eCode & COLFLAG_NOTAVAIL ){ | 124337 | if( w.eCode & COLFLAG_NOTAVAIL ){ |
| 123357 | pRedo = pCol; | 124338 | pRedo = pCol; |
| @@ -123360,13 +124341,13 @@ SQLITE_PRIVATE void sqlite3ComputeGeneratedColumns( | |||
| 123360 | eProgress = 1; | 124341 | eProgress = 1; |
| 123361 | assert( pCol->colFlags & COLFLAG_GENERATED ); | 124342 | assert( pCol->colFlags & COLFLAG_GENERATED ); |
| 123362 | x = sqlite3TableColumnToStorage(pTab, i) + iRegStore; | 124343 | x = sqlite3TableColumnToStorage(pTab, i) + iRegStore; |
| 123363 | sqlite3ExprCodeGeneratedColumn(pParse, pCol, x); | 124344 | sqlite3ExprCodeGeneratedColumn(pParse, pTab, pCol, x); |
| 123364 | pCol->colFlags &= ~COLFLAG_NOTAVAIL; | 124345 | pCol->colFlags &= ~COLFLAG_NOTAVAIL; |
| 123365 | } | 124346 | } |
| 123366 | } | 124347 | } |
| 123367 | }while( pRedo && eProgress ); | 124348 | }while( pRedo && eProgress ); |
| 123368 | if( pRedo ){ | 124349 | if( pRedo ){ |
| 123369 | sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pRedo->zName); | 124350 | sqlite3ErrorMsg(pParse, "generated column loop on \"%s\"", pRedo->zCnName); |
| 123370 | } | 124351 | } |
| 123371 | pParse->iSelfTab = 0; | 124352 | pParse->iSelfTab = 0; |
| 123372 | } | 124353 | } |
| @@ -123761,7 +124742,7 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 123761 | */ | 124742 | */ |
| 123762 | #ifndef SQLITE_OMIT_TRIGGER | 124743 | #ifndef SQLITE_OMIT_TRIGGER |
| 123763 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, 0, &tmask); | 124744 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_INSERT, 0, &tmask); |
| 123764 | isView = pTab->pSelect!=0; | 124745 | isView = IsView(pTab); |
| 123765 | #else | 124746 | #else |
| 123766 | # define pTrigger 0 | 124747 | # define pTrigger 0 |
| 123767 | # define tmask 0 | 124748 | # define tmask 0 |
| @@ -123852,7 +124833,7 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 123852 | } | 124833 | } |
| 123853 | for(i=0; i<pColumn->nId; i++){ | 124834 | for(i=0; i<pColumn->nId; i++){ |
| 123854 | for(j=0; j<pTab->nCol; j++){ | 124835 | for(j=0; j<pTab->nCol; j++){ |
| 123855 | if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zName)==0 ){ | 124836 | if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zCnName)==0 ){ |
| 123856 | pColumn->a[i].idx = j; | 124837 | pColumn->a[i].idx = j; |
| 123857 | if( i!=j ) bIdListInOrder = 0; | 124838 | if( i!=j ) bIdListInOrder = 0; |
| 123858 | if( j==pTab->iPKey ){ | 124839 | if( j==pTab->iPKey ){ |
| @@ -123862,7 +124843,7 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 123862 | if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){ | 124843 | if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){ |
| 123863 | sqlite3ErrorMsg(pParse, | 124844 | sqlite3ErrorMsg(pParse, |
| 123864 | "cannot INSERT into generated column \"%s\"", | 124845 | "cannot INSERT into generated column \"%s\"", |
| 123865 | pTab->aCol[j].zName); | 124846 | pTab->aCol[j].zCnName); |
| 123866 | goto insert_cleanup; | 124847 | goto insert_cleanup; |
| 123867 | } | 124848 | } |
| 123868 | #endif | 124849 | #endif |
| @@ -124047,7 +125028,7 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 124047 | pTab->zName); | 125028 | pTab->zName); |
| 124048 | goto insert_cleanup; | 125029 | goto insert_cleanup; |
| 124049 | } | 125030 | } |
| 124050 | if( pTab->pSelect ){ | 125031 | if( IsView(pTab) ){ |
| 124051 | sqlite3ErrorMsg(pParse, "cannot UPSERT a view"); | 125032 | sqlite3ErrorMsg(pParse, "cannot UPSERT a view"); |
| 124052 | goto insert_cleanup; | 125033 | goto insert_cleanup; |
| 124053 | } | 125034 | } |
| @@ -124146,7 +125127,9 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 124146 | }else if( pColumn==0 ){ | 125127 | }else if( pColumn==0 ){ |
| 124147 | /* Hidden columns that are not explicitly named in the INSERT | 125128 | /* Hidden columns that are not explicitly named in the INSERT |
| 124148 | ** get there default value */ | 125129 | ** get there default value */ |
| 124149 | sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore); | 125130 | sqlite3ExprCodeFactorable(pParse, |
| 125131 | sqlite3ColumnExpr(pTab, &pTab->aCol[i]), | ||
| 125132 | iRegStore); | ||
| 124150 | continue; | 125133 | continue; |
| 124151 | } | 125134 | } |
| 124152 | } | 125135 | } |
| @@ -124155,13 +125138,17 @@ SQLITE_PRIVATE void sqlite3Insert( | |||
| 124155 | if( j>=pColumn->nId ){ | 125138 | if( j>=pColumn->nId ){ |
| 124156 | /* A column not named in the insert column list gets its | 125139 | /* A column not named in the insert column list gets its |
| 124157 | ** default value */ | 125140 | ** default value */ |
| 124158 | sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore); | 125141 | sqlite3ExprCodeFactorable(pParse, |
| 125142 | sqlite3ColumnExpr(pTab, &pTab->aCol[i]), | ||
| 125143 | iRegStore); | ||
| 124159 | continue; | 125144 | continue; |
| 124160 | } | 125145 | } |
| 124161 | k = j; | 125146 | k = j; |
| 124162 | }else if( nColumn==0 ){ | 125147 | }else if( nColumn==0 ){ |
| 124163 | /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */ | 125148 | /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */ |
| 124164 | sqlite3ExprCodeFactorable(pParse, pTab->aCol[i].pDflt, iRegStore); | 125149 | sqlite3ExprCodeFactorable(pParse, |
| 125150 | sqlite3ColumnExpr(pTab, &pTab->aCol[i]), | ||
| 125151 | iRegStore); | ||
| 124165 | continue; | 125152 | continue; |
| 124166 | }else{ | 125153 | }else{ |
| 124167 | k = i - nHidden; | 125154 | k = i - nHidden; |
| @@ -124676,7 +125663,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 124676 | db = pParse->db; | 125663 | db = pParse->db; |
| 124677 | v = pParse->pVdbe; | 125664 | v = pParse->pVdbe; |
| 124678 | assert( v!=0 ); | 125665 | assert( v!=0 ); |
| 124679 | assert( pTab->pSelect==0 ); /* This table is not a VIEW */ | 125666 | assert( !IsView(pTab) ); /* This table is not a VIEW */ |
| 124680 | nCol = pTab->nCol; | 125667 | nCol = pTab->nCol; |
| 124681 | 125668 | ||
| 124682 | /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for | 125669 | /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for |
| @@ -124727,7 +125714,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 124727 | } | 125714 | } |
| 124728 | if( onError==OE_Replace ){ | 125715 | if( onError==OE_Replace ){ |
| 124729 | if( b2ndPass /* REPLACE becomes ABORT on the 2nd pass */ | 125716 | if( b2ndPass /* REPLACE becomes ABORT on the 2nd pass */ |
| 124730 | || pCol->pDflt==0 /* REPLACE is ABORT if no DEFAULT value */ | 125717 | || pCol->iDflt==0 /* REPLACE is ABORT if no DEFAULT value */ |
| 124731 | ){ | 125718 | ){ |
| 124732 | testcase( pCol->colFlags & COLFLAG_VIRTUAL ); | 125719 | testcase( pCol->colFlags & COLFLAG_VIRTUAL ); |
| 124733 | testcase( pCol->colFlags & COLFLAG_STORED ); | 125720 | testcase( pCol->colFlags & COLFLAG_STORED ); |
| @@ -124749,7 +125736,8 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 124749 | VdbeCoverage(v); | 125736 | VdbeCoverage(v); |
| 124750 | assert( (pCol->colFlags & COLFLAG_GENERATED)==0 ); | 125737 | assert( (pCol->colFlags & COLFLAG_GENERATED)==0 ); |
| 124751 | nSeenReplace++; | 125738 | nSeenReplace++; |
| 124752 | sqlite3ExprCodeCopy(pParse, pCol->pDflt, iReg); | 125739 | sqlite3ExprCodeCopy(pParse, |
| 125740 | sqlite3ColumnExpr(pTab, pCol), iReg); | ||
| 124753 | sqlite3VdbeJumpHere(v, addr1); | 125741 | sqlite3VdbeJumpHere(v, addr1); |
| 124754 | break; | 125742 | break; |
| 124755 | } | 125743 | } |
| @@ -124759,7 +125747,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 124759 | case OE_Rollback: | 125747 | case OE_Rollback: |
| 124760 | case OE_Fail: { | 125748 | case OE_Fail: { |
| 124761 | char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName, | 125749 | char *zMsg = sqlite3MPrintf(db, "%s.%s", pTab->zName, |
| 124762 | pCol->zName); | 125750 | pCol->zCnName); |
| 124763 | sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, | 125751 | sqlite3VdbeAddOp3(v, OP_HaltIfNull, SQLITE_CONSTRAINT_NOTNULL, |
| 124764 | onError, iReg); | 125752 | onError, iReg); |
| 124765 | sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC); | 125753 | sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC); |
| @@ -125012,6 +126000,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 125012 | if( onError==OE_Replace /* IPK rule is REPLACE */ | 126000 | if( onError==OE_Replace /* IPK rule is REPLACE */ |
| 125013 | && onError!=overrideError /* Rules for other constraints are different */ | 126001 | && onError!=overrideError /* Rules for other constraints are different */ |
| 125014 | && pTab->pIndex /* There exist other constraints */ | 126002 | && pTab->pIndex /* There exist other constraints */ |
| 126003 | && !upsertIpkDelay /* IPK check already deferred by UPSERT */ | ||
| 125015 | ){ | 126004 | ){ |
| 125016 | ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1; | 126005 | ipkTop = sqlite3VdbeAddOp0(v, OP_Goto)+1; |
| 125017 | VdbeComment((v, "defer IPK REPLACE until last")); | 126006 | VdbeComment((v, "defer IPK REPLACE until last")); |
| @@ -125177,7 +126166,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 125177 | testcase( sqlite3TableColumnToStorage(pTab, iField)!=iField ); | 126166 | testcase( sqlite3TableColumnToStorage(pTab, iField)!=iField ); |
| 125178 | x = sqlite3TableColumnToStorage(pTab, iField) + regNewData + 1; | 126167 | x = sqlite3TableColumnToStorage(pTab, iField) + regNewData + 1; |
| 125179 | sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i); | 126168 | sqlite3VdbeAddOp2(v, OP_SCopy, x, regIdx+i); |
| 125180 | VdbeComment((v, "%s", pTab->aCol[iField].zName)); | 126169 | VdbeComment((v, "%s", pTab->aCol[iField].zCnName)); |
| 125181 | } | 126170 | } |
| 125182 | } | 126171 | } |
| 125183 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]); | 126172 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regIdx, pIdx->nColumn, aRegIdx[ix]); |
| @@ -125229,6 +126218,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 125229 | ** This is not possible for ENABLE_PREUPDATE_HOOK builds, as the row | 126218 | ** This is not possible for ENABLE_PREUPDATE_HOOK builds, as the row |
| 125230 | ** must be explicitly deleted in order to ensure any pre-update hook | 126219 | ** must be explicitly deleted in order to ensure any pre-update hook |
| 125231 | ** is invoked. */ | 126220 | ** is invoked. */ |
| 126221 | assert( IsOrdinaryTable(pTab) ); | ||
| 125232 | #ifndef SQLITE_ENABLE_PREUPDATE_HOOK | 126222 | #ifndef SQLITE_ENABLE_PREUPDATE_HOOK |
| 125233 | if( (ix==0 && pIdx->pNext==0) /* Condition 3 */ | 126223 | if( (ix==0 && pIdx->pNext==0) /* Condition 3 */ |
| 125234 | && pPk==pIdx /* Condition 2 */ | 126224 | && pPk==pIdx /* Condition 2 */ |
| @@ -125236,7 +126226,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 125236 | && ( 0==(db->flags&SQLITE_RecTriggers) || /* Condition 4 */ | 126226 | && ( 0==(db->flags&SQLITE_RecTriggers) || /* Condition 4 */ |
| 125237 | 0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0)) | 126227 | 0==sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0)) |
| 125238 | && ( 0==(db->flags&SQLITE_ForeignKeys) || /* Condition 5 */ | 126228 | && ( 0==(db->flags&SQLITE_ForeignKeys) || /* Condition 5 */ |
| 125239 | (0==pTab->pFKey && 0==sqlite3FkReferences(pTab))) | 126229 | (0==pTab->u.tab.pFKey && 0==sqlite3FkReferences(pTab))) |
| 125240 | ){ | 126230 | ){ |
| 125241 | sqlite3VdbeResolveLabel(v, addrUniqueOk); | 126231 | sqlite3VdbeResolveLabel(v, addrUniqueOk); |
| 125242 | continue; | 126232 | continue; |
| @@ -125271,7 +126261,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 125271 | x = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]); | 126261 | x = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]); |
| 125272 | sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i); | 126262 | sqlite3VdbeAddOp3(v, OP_Column, iThisCur, x, regR+i); |
| 125273 | VdbeComment((v, "%s.%s", pTab->zName, | 126263 | VdbeComment((v, "%s.%s", pTab->zName, |
| 125274 | pTab->aCol[pPk->aiColumn[i]].zName)); | 126264 | pTab->aCol[pPk->aiColumn[i]].zCnName)); |
| 125275 | } | 126265 | } |
| 125276 | } | 126266 | } |
| 125277 | if( isUpdate ){ | 126267 | if( isUpdate ){ |
| @@ -125335,7 +126325,8 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 125335 | 126325 | ||
| 125336 | assert( onError==OE_Replace ); | 126326 | assert( onError==OE_Replace ); |
| 125337 | nConflictCk = sqlite3VdbeCurrentAddr(v) - addrConflictCk; | 126327 | nConflictCk = sqlite3VdbeCurrentAddr(v) - addrConflictCk; |
| 125338 | assert( nConflictCk>0 ); | 126328 | assert( nConflictCk>0 || db->mallocFailed ); |
| 126329 | testcase( nConflictCk<=0 ); | ||
| 125339 | testcase( nConflictCk>1 ); | 126330 | testcase( nConflictCk>1 ); |
| 125340 | if( regTrigCnt ){ | 126331 | if( regTrigCnt ){ |
| 125341 | sqlite3MultiWrite(pParse); | 126332 | sqlite3MultiWrite(pParse); |
| @@ -125418,6 +126409,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks( | |||
| 125418 | if( ipkTop ){ | 126409 | if( ipkTop ){ |
| 125419 | sqlite3VdbeGoto(v, ipkTop); | 126410 | sqlite3VdbeGoto(v, ipkTop); |
| 125420 | VdbeComment((v, "Do IPK REPLACE")); | 126411 | VdbeComment((v, "Do IPK REPLACE")); |
| 126412 | assert( ipkBottom>0 ); | ||
| 125421 | sqlite3VdbeJumpHere(v, ipkBottom); | 126413 | sqlite3VdbeJumpHere(v, ipkBottom); |
| 125422 | } | 126414 | } |
| 125423 | 126415 | ||
| @@ -125470,7 +126462,7 @@ SQLITE_PRIVATE void sqlite3SetMakeRecordP5(Vdbe *v, Table *pTab){ | |||
| 125470 | if( pTab->pSchema->file_format<2 ) return; | 126462 | if( pTab->pSchema->file_format<2 ) return; |
| 125471 | 126463 | ||
| 125472 | for(i=pTab->nCol-1; i>0; i--){ | 126464 | for(i=pTab->nCol-1; i>0; i--){ |
| 125473 | if( pTab->aCol[i].pDflt!=0 ) break; | 126465 | if( pTab->aCol[i].iDflt!=0 ) break; |
| 125474 | if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break; | 126466 | if( pTab->aCol[i].colFlags & COLFLAG_PRIMKEY ) break; |
| 125475 | } | 126467 | } |
| 125476 | sqlite3VdbeChangeP5(v, i+1); | 126468 | sqlite3VdbeChangeP5(v, i+1); |
| @@ -125535,7 +126527,7 @@ SQLITE_PRIVATE void sqlite3CompleteInsertion( | |||
| 125535 | 126527 | ||
| 125536 | v = pParse->pVdbe; | 126528 | v = pParse->pVdbe; |
| 125537 | assert( v!=0 ); | 126529 | assert( v!=0 ); |
| 125538 | assert( pTab->pSelect==0 ); /* This table is not a VIEW */ | 126530 | assert( !IsView(pTab) ); /* This table is not a VIEW */ |
| 125539 | for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ | 126531 | for(i=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, i++){ |
| 125540 | /* All REPLACE indexes are at the end of the list */ | 126532 | /* All REPLACE indexes are at the end of the list */ |
| 125541 | assert( pIdx->onError!=OE_Replace | 126533 | assert( pIdx->onError!=OE_Replace |
| @@ -125621,8 +126613,9 @@ SQLITE_PRIVATE int sqlite3OpenTableAndIndices( | |||
| 125621 | assert( op==OP_OpenWrite || p5==0 ); | 126613 | assert( op==OP_OpenWrite || p5==0 ); |
| 125622 | if( IsVirtual(pTab) ){ | 126614 | if( IsVirtual(pTab) ){ |
| 125623 | /* This routine is a no-op for virtual tables. Leave the output | 126615 | /* This routine is a no-op for virtual tables. Leave the output |
| 125624 | ** variables *piDataCur and *piIdxCur uninitialized so that valgrind | 126616 | ** variables *piDataCur and *piIdxCur set to illegal cursor numbers |
| 125625 | ** can detect if they are used by mistake in the caller. */ | 126617 | ** for improved error detection. */ |
| 126618 | *piDataCur = *piIdxCur = -999; | ||
| 125626 | return 0; | 126619 | return 0; |
| 125627 | } | 126620 | } |
| 125628 | iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); | 126621 | iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema); |
| @@ -125837,13 +126830,8 @@ static int xferOptimization( | |||
| 125837 | if( HasRowid(pDest)!=HasRowid(pSrc) ){ | 126830 | if( HasRowid(pDest)!=HasRowid(pSrc) ){ |
| 125838 | return 0; /* source and destination must both be WITHOUT ROWID or not */ | 126831 | return 0; /* source and destination must both be WITHOUT ROWID or not */ |
| 125839 | } | 126832 | } |
| 125840 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 126833 | if( !IsOrdinaryTable(pSrc) ){ |
| 125841 | if( IsVirtual(pSrc) ){ | 126834 | return 0; /* tab2 may not be a view or virtual table */ |
| 125842 | return 0; /* tab2 must not be a virtual table */ | ||
| 125843 | } | ||
| 125844 | #endif | ||
| 125845 | if( pSrc->pSelect ){ | ||
| 125846 | return 0; /* tab2 may not be a view */ | ||
| 125847 | } | 126835 | } |
| 125848 | if( pDest->nCol!=pSrc->nCol ){ | 126836 | if( pDest->nCol!=pSrc->nCol ){ |
| 125849 | return 0; /* Number of columns must be the same in tab1 and tab2 */ | 126837 | return 0; /* Number of columns must be the same in tab1 and tab2 */ |
| @@ -125851,6 +126839,9 @@ static int xferOptimization( | |||
| 125851 | if( pDest->iPKey!=pSrc->iPKey ){ | 126839 | if( pDest->iPKey!=pSrc->iPKey ){ |
| 125852 | return 0; /* Both tables must have the same INTEGER PRIMARY KEY */ | 126840 | return 0; /* Both tables must have the same INTEGER PRIMARY KEY */ |
| 125853 | } | 126841 | } |
| 126842 | if( (pDest->tabFlags & TF_Strict)!=0 && (pSrc->tabFlags & TF_Strict)==0 ){ | ||
| 126843 | return 0; /* Cannot feed from a non-strict into a strict table */ | ||
| 126844 | } | ||
| 125854 | for(i=0; i<pDest->nCol; i++){ | 126845 | for(i=0; i<pDest->nCol; i++){ |
| 125855 | Column *pDestCol = &pDest->aCol[i]; | 126846 | Column *pDestCol = &pDest->aCol[i]; |
| 125856 | Column *pSrcCol = &pSrc->aCol[i]; | 126847 | Column *pSrcCol = &pSrc->aCol[i]; |
| @@ -125887,7 +126878,9 @@ static int xferOptimization( | |||
| 125887 | ** This requirement could be relaxed for VIRTUAL columns, I suppose. | 126878 | ** This requirement could be relaxed for VIRTUAL columns, I suppose. |
| 125888 | */ | 126879 | */ |
| 125889 | if( (pDestCol->colFlags & COLFLAG_GENERATED)!=0 ){ | 126880 | if( (pDestCol->colFlags & COLFLAG_GENERATED)!=0 ){ |
| 125890 | if( sqlite3ExprCompare(0, pSrcCol->pDflt, pDestCol->pDflt, -1)!=0 ){ | 126881 | if( sqlite3ExprCompare(0, |
| 126882 | sqlite3ColumnExpr(pSrc, pSrcCol), | ||
| 126883 | sqlite3ColumnExpr(pDest, pDestCol), -1)!=0 ){ | ||
| 125891 | testcase( pDestCol->colFlags & COLFLAG_VIRTUAL ); | 126884 | testcase( pDestCol->colFlags & COLFLAG_VIRTUAL ); |
| 125892 | testcase( pDestCol->colFlags & COLFLAG_STORED ); | 126885 | testcase( pDestCol->colFlags & COLFLAG_STORED ); |
| 125893 | return 0; /* Different generator expressions */ | 126886 | return 0; /* Different generator expressions */ |
| @@ -125897,7 +126890,8 @@ static int xferOptimization( | |||
| 125897 | if( pDestCol->affinity!=pSrcCol->affinity ){ | 126890 | if( pDestCol->affinity!=pSrcCol->affinity ){ |
| 125898 | return 0; /* Affinity must be the same on all columns */ | 126891 | return 0; /* Affinity must be the same on all columns */ |
| 125899 | } | 126892 | } |
| 125900 | if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){ | 126893 | if( sqlite3_stricmp(sqlite3ColumnColl(pDestCol), |
| 126894 | sqlite3ColumnColl(pSrcCol))!=0 ){ | ||
| 125901 | return 0; /* Collating sequence must be the same on all columns */ | 126895 | return 0; /* Collating sequence must be the same on all columns */ |
| 125902 | } | 126896 | } |
| 125903 | if( pDestCol->notNull && !pSrcCol->notNull ){ | 126897 | if( pDestCol->notNull && !pSrcCol->notNull ){ |
| @@ -125905,11 +126899,15 @@ static int xferOptimization( | |||
| 125905 | } | 126899 | } |
| 125906 | /* Default values for second and subsequent columns need to match. */ | 126900 | /* Default values for second and subsequent columns need to match. */ |
| 125907 | if( (pDestCol->colFlags & COLFLAG_GENERATED)==0 && i>0 ){ | 126901 | if( (pDestCol->colFlags & COLFLAG_GENERATED)==0 && i>0 ){ |
| 125908 | assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN ); | 126902 | Expr *pDestExpr = sqlite3ColumnExpr(pDest, pDestCol); |
| 125909 | assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN ); | 126903 | Expr *pSrcExpr = sqlite3ColumnExpr(pSrc, pSrcCol); |
| 125910 | if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0) | 126904 | assert( pDestExpr==0 || pDestExpr->op==TK_SPAN ); |
| 125911 | || (pDestCol->pDflt && strcmp(pDestCol->pDflt->u.zToken, | 126905 | assert( pDestExpr==0 || !ExprHasProperty(pDestExpr, EP_IntValue) ); |
| 125912 | pSrcCol->pDflt->u.zToken)!=0) | 126906 | assert( pSrcExpr==0 || pSrcExpr->op==TK_SPAN ); |
| 126907 | assert( pSrcExpr==0 || !ExprHasProperty(pSrcExpr, EP_IntValue) ); | ||
| 126908 | if( (pDestExpr==0)!=(pSrcExpr==0) | ||
| 126909 | || (pDestExpr!=0 && strcmp(pDestExpr->u.zToken, | ||
| 126910 | pSrcExpr->u.zToken)!=0) | ||
| 125913 | ){ | 126911 | ){ |
| 125914 | return 0; /* Default values must be the same for all columns */ | 126912 | return 0; /* Default values must be the same for all columns */ |
| 125915 | } | 126913 | } |
| @@ -125946,7 +126944,8 @@ static int xferOptimization( | |||
| 125946 | ** the extra complication to make this rule less restrictive is probably | 126944 | ** the extra complication to make this rule less restrictive is probably |
| 125947 | ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] | 126945 | ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e] |
| 125948 | */ | 126946 | */ |
| 125949 | if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){ | 126947 | assert( IsOrdinaryTable(pDest) ); |
| 126948 | if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->u.tab.pFKey!=0 ){ | ||
| 125950 | return 0; | 126949 | return 0; |
| 125951 | } | 126950 | } |
| 125952 | #endif | 126951 | #endif |
| @@ -126624,6 +127623,13 @@ struct sqlite3_api_routines { | |||
| 126624 | sqlite3_file *(*database_file_object)(const char*); | 127623 | sqlite3_file *(*database_file_object)(const char*); |
| 126625 | /* Version 3.34.0 and later */ | 127624 | /* Version 3.34.0 and later */ |
| 126626 | int (*txn_state)(sqlite3*,const char*); | 127625 | int (*txn_state)(sqlite3*,const char*); |
| 127626 | /* Version 3.36.1 and later */ | ||
| 127627 | sqlite3_int64 (*changes64)(sqlite3*); | ||
| 127628 | sqlite3_int64 (*total_changes64)(sqlite3*); | ||
| 127629 | /* Version 3.37.0 and later */ | ||
| 127630 | int (*autovacuum_pages)(sqlite3*, | ||
| 127631 | unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int), | ||
| 127632 | void*, void(*)(void*)); | ||
| 126627 | }; | 127633 | }; |
| 126628 | 127634 | ||
| 126629 | /* | 127635 | /* |
| @@ -126930,6 +127936,11 @@ typedef int (*sqlite3_loadext_entry)( | |||
| 126930 | #define sqlite3_database_file_object sqlite3_api->database_file_object | 127936 | #define sqlite3_database_file_object sqlite3_api->database_file_object |
| 126931 | /* Version 3.34.0 and later */ | 127937 | /* Version 3.34.0 and later */ |
| 126932 | #define sqlite3_txn_state sqlite3_api->txn_state | 127938 | #define sqlite3_txn_state sqlite3_api->txn_state |
| 127939 | /* Version 3.36.1 and later */ | ||
| 127940 | #define sqlite3_changes64 sqlite3_api->changes64 | ||
| 127941 | #define sqlite3_total_changes64 sqlite3_api->total_changes64 | ||
| 127942 | /* Version 3.37.0 and later */ | ||
| 127943 | #define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages | ||
| 126933 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ | 127944 | #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ |
| 126934 | 127945 | ||
| 126935 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) | 127946 | #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) |
| @@ -127414,6 +128425,11 @@ static const sqlite3_api_routines sqlite3Apis = { | |||
| 127414 | sqlite3_database_file_object, | 128425 | sqlite3_database_file_object, |
| 127415 | /* Version 3.34.0 and later */ | 128426 | /* Version 3.34.0 and later */ |
| 127416 | sqlite3_txn_state, | 128427 | sqlite3_txn_state, |
| 128428 | /* Version 3.36.1 and later */ | ||
| 128429 | sqlite3_changes64, | ||
| 128430 | sqlite3_total_changes64, | ||
| 128431 | /* Version 3.37.0 and later */ | ||
| 128432 | sqlite3_autovacuum_pages, | ||
| 127417 | }; | 128433 | }; |
| 127418 | 128434 | ||
| 127419 | /* True if x is the directory separator character | 128435 | /* True if x is the directory separator character |
| @@ -127876,13 +128892,14 @@ SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){ | |||
| 127876 | #define PragTyp_SOFT_HEAP_LIMIT 35 | 128892 | #define PragTyp_SOFT_HEAP_LIMIT 35 |
| 127877 | #define PragTyp_SYNCHRONOUS 36 | 128893 | #define PragTyp_SYNCHRONOUS 36 |
| 127878 | #define PragTyp_TABLE_INFO 37 | 128894 | #define PragTyp_TABLE_INFO 37 |
| 127879 | #define PragTyp_TEMP_STORE 38 | 128895 | #define PragTyp_TABLE_LIST 38 |
| 127880 | #define PragTyp_TEMP_STORE_DIRECTORY 39 | 128896 | #define PragTyp_TEMP_STORE 39 |
| 127881 | #define PragTyp_THREADS 40 | 128897 | #define PragTyp_TEMP_STORE_DIRECTORY 40 |
| 127882 | #define PragTyp_WAL_AUTOCHECKPOINT 41 | 128898 | #define PragTyp_THREADS 41 |
| 127883 | #define PragTyp_WAL_CHECKPOINT 42 | 128899 | #define PragTyp_WAL_AUTOCHECKPOINT 42 |
| 127884 | #define PragTyp_LOCK_STATUS 43 | 128900 | #define PragTyp_WAL_CHECKPOINT 43 |
| 127885 | #define PragTyp_STATS 44 | 128901 | #define PragTyp_LOCK_STATUS 44 |
| 128902 | #define PragTyp_STATS 45 | ||
| 127886 | 128903 | ||
| 127887 | /* Property flags associated with various pragma. */ | 128904 | /* Property flags associated with various pragma. */ |
| 127888 | #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ | 128905 | #define PragFlg_NeedSchema 0x01 /* Force schema load before running */ |
| @@ -127915,45 +128932,51 @@ static const char *const pragCName[] = { | |||
| 127915 | /* 13 */ "pk", | 128932 | /* 13 */ "pk", |
| 127916 | /* 14 */ "hidden", | 128933 | /* 14 */ "hidden", |
| 127917 | /* table_info reuses 8 */ | 128934 | /* table_info reuses 8 */ |
| 127918 | /* 15 */ "seqno", /* Used by: index_xinfo */ | 128935 | /* 15 */ "schema", /* Used by: table_list */ |
| 127919 | /* 16 */ "cid", | 128936 | /* 16 */ "name", |
| 127920 | /* 17 */ "name", | 128937 | /* 17 */ "type", |
| 127921 | /* 18 */ "desc", | 128938 | /* 18 */ "ncol", |
| 127922 | /* 19 */ "coll", | 128939 | /* 19 */ "wr", |
| 127923 | /* 20 */ "key", | 128940 | /* 20 */ "strict", |
| 127924 | /* 21 */ "name", /* Used by: function_list */ | 128941 | /* 21 */ "seqno", /* Used by: index_xinfo */ |
| 127925 | /* 22 */ "builtin", | 128942 | /* 22 */ "cid", |
| 127926 | /* 23 */ "type", | 128943 | /* 23 */ "name", |
| 127927 | /* 24 */ "enc", | 128944 | /* 24 */ "desc", |
| 127928 | /* 25 */ "narg", | 128945 | /* 25 */ "coll", |
| 127929 | /* 26 */ "flags", | 128946 | /* 26 */ "key", |
| 127930 | /* 27 */ "tbl", /* Used by: stats */ | 128947 | /* 27 */ "name", /* Used by: function_list */ |
| 127931 | /* 28 */ "idx", | 128948 | /* 28 */ "builtin", |
| 127932 | /* 29 */ "wdth", | 128949 | /* 29 */ "type", |
| 127933 | /* 30 */ "hght", | 128950 | /* 30 */ "enc", |
| 127934 | /* 31 */ "flgs", | 128951 | /* 31 */ "narg", |
| 127935 | /* 32 */ "seq", /* Used by: index_list */ | 128952 | /* 32 */ "flags", |
| 127936 | /* 33 */ "name", | 128953 | /* 33 */ "tbl", /* Used by: stats */ |
| 127937 | /* 34 */ "unique", | 128954 | /* 34 */ "idx", |
| 127938 | /* 35 */ "origin", | 128955 | /* 35 */ "wdth", |
| 127939 | /* 36 */ "partial", | 128956 | /* 36 */ "hght", |
| 127940 | /* 37 */ "table", /* Used by: foreign_key_check */ | 128957 | /* 37 */ "flgs", |
| 127941 | /* 38 */ "rowid", | 128958 | /* 38 */ "seq", /* Used by: index_list */ |
| 127942 | /* 39 */ "parent", | 128959 | /* 39 */ "name", |
| 127943 | /* 40 */ "fkid", | 128960 | /* 40 */ "unique", |
| 127944 | /* index_info reuses 15 */ | 128961 | /* 41 */ "origin", |
| 127945 | /* 41 */ "seq", /* Used by: database_list */ | 128962 | /* 42 */ "partial", |
| 127946 | /* 42 */ "name", | 128963 | /* 43 */ "table", /* Used by: foreign_key_check */ |
| 127947 | /* 43 */ "file", | 128964 | /* 44 */ "rowid", |
| 127948 | /* 44 */ "busy", /* Used by: wal_checkpoint */ | 128965 | /* 45 */ "parent", |
| 127949 | /* 45 */ "log", | 128966 | /* 46 */ "fkid", |
| 127950 | /* 46 */ "checkpointed", | 128967 | /* index_info reuses 21 */ |
| 127951 | /* collation_list reuses 32 */ | 128968 | /* 47 */ "seq", /* Used by: database_list */ |
| 127952 | /* 47 */ "database", /* Used by: lock_status */ | 128969 | /* 48 */ "name", |
| 127953 | /* 48 */ "status", | 128970 | /* 49 */ "file", |
| 127954 | /* 49 */ "cache_size", /* Used by: default_cache_size */ | 128971 | /* 50 */ "busy", /* Used by: wal_checkpoint */ |
| 128972 | /* 51 */ "log", | ||
| 128973 | /* 52 */ "checkpointed", | ||
| 128974 | /* collation_list reuses 38 */ | ||
| 128975 | /* 53 */ "database", /* Used by: lock_status */ | ||
| 128976 | /* 54 */ "status", | ||
| 128977 | /* 55 */ "cache_size", /* Used by: default_cache_size */ | ||
| 127955 | /* module_list pragma_list reuses 9 */ | 128978 | /* module_list pragma_list reuses 9 */ |
| 127956 | /* 50 */ "timeout", /* Used by: busy_timeout */ | 128979 | /* 56 */ "timeout", /* Used by: busy_timeout */ |
| 127957 | }; | 128980 | }; |
| 127958 | 128981 | ||
| 127959 | /* Definitions of all built-in pragmas */ | 128982 | /* Definitions of all built-in pragmas */ |
| @@ -128004,7 +129027,7 @@ static const PragmaName aPragmaName[] = { | |||
| 128004 | {/* zName: */ "busy_timeout", | 129027 | {/* zName: */ "busy_timeout", |
| 128005 | /* ePragTyp: */ PragTyp_BUSY_TIMEOUT, | 129028 | /* ePragTyp: */ PragTyp_BUSY_TIMEOUT, |
| 128006 | /* ePragFlg: */ PragFlg_Result0, | 129029 | /* ePragFlg: */ PragFlg_Result0, |
| 128007 | /* ColNames: */ 50, 1, | 129030 | /* ColNames: */ 56, 1, |
| 128008 | /* iArg: */ 0 }, | 129031 | /* iArg: */ 0 }, |
| 128009 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 129032 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| 128010 | {/* zName: */ "cache_size", | 129033 | {/* zName: */ "cache_size", |
| @@ -128043,7 +129066,7 @@ static const PragmaName aPragmaName[] = { | |||
| 128043 | {/* zName: */ "collation_list", | 129066 | {/* zName: */ "collation_list", |
| 128044 | /* ePragTyp: */ PragTyp_COLLATION_LIST, | 129067 | /* ePragTyp: */ PragTyp_COLLATION_LIST, |
| 128045 | /* ePragFlg: */ PragFlg_Result0, | 129068 | /* ePragFlg: */ PragFlg_Result0, |
| 128046 | /* ColNames: */ 32, 2, | 129069 | /* ColNames: */ 38, 2, |
| 128047 | /* iArg: */ 0 }, | 129070 | /* iArg: */ 0 }, |
| 128048 | #endif | 129071 | #endif |
| 128049 | #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) | 129072 | #if !defined(SQLITE_OMIT_COMPILEOPTION_DIAGS) |
| @@ -128078,14 +129101,14 @@ static const PragmaName aPragmaName[] = { | |||
| 128078 | {/* zName: */ "database_list", | 129101 | {/* zName: */ "database_list", |
| 128079 | /* ePragTyp: */ PragTyp_DATABASE_LIST, | 129102 | /* ePragTyp: */ PragTyp_DATABASE_LIST, |
| 128080 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0, | 129103 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0, |
| 128081 | /* ColNames: */ 41, 3, | 129104 | /* ColNames: */ 47, 3, |
| 128082 | /* iArg: */ 0 }, | 129105 | /* iArg: */ 0 }, |
| 128083 | #endif | 129106 | #endif |
| 128084 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) | 129107 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED) |
| 128085 | {/* zName: */ "default_cache_size", | 129108 | {/* zName: */ "default_cache_size", |
| 128086 | /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE, | 129109 | /* ePragTyp: */ PragTyp_DEFAULT_CACHE_SIZE, |
| 128087 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1, | 129110 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1, |
| 128088 | /* ColNames: */ 49, 1, | 129111 | /* ColNames: */ 55, 1, |
| 128089 | /* iArg: */ 0 }, | 129112 | /* iArg: */ 0 }, |
| 128090 | #endif | 129113 | #endif |
| 128091 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) | 129114 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| @@ -128115,7 +129138,7 @@ static const PragmaName aPragmaName[] = { | |||
| 128115 | {/* zName: */ "foreign_key_check", | 129138 | {/* zName: */ "foreign_key_check", |
| 128116 | /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK, | 129139 | /* ePragTyp: */ PragTyp_FOREIGN_KEY_CHECK, |
| 128117 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt, | 129140 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128118 | /* ColNames: */ 37, 4, | 129141 | /* ColNames: */ 43, 4, |
| 128119 | /* iArg: */ 0 }, | 129142 | /* iArg: */ 0 }, |
| 128120 | #endif | 129143 | #endif |
| 128121 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) | 129144 | #if !defined(SQLITE_OMIT_FOREIGN_KEY) |
| @@ -128158,7 +129181,7 @@ static const PragmaName aPragmaName[] = { | |||
| 128158 | {/* zName: */ "function_list", | 129181 | {/* zName: */ "function_list", |
| 128159 | /* ePragTyp: */ PragTyp_FUNCTION_LIST, | 129182 | /* ePragTyp: */ PragTyp_FUNCTION_LIST, |
| 128160 | /* ePragFlg: */ PragFlg_Result0, | 129183 | /* ePragFlg: */ PragFlg_Result0, |
| 128161 | /* ColNames: */ 21, 6, | 129184 | /* ColNames: */ 27, 6, |
| 128162 | /* iArg: */ 0 }, | 129185 | /* iArg: */ 0 }, |
| 128163 | #endif | 129186 | #endif |
| 128164 | #endif | 129187 | #endif |
| @@ -128187,23 +129210,23 @@ static const PragmaName aPragmaName[] = { | |||
| 128187 | {/* zName: */ "index_info", | 129210 | {/* zName: */ "index_info", |
| 128188 | /* ePragTyp: */ PragTyp_INDEX_INFO, | 129211 | /* ePragTyp: */ PragTyp_INDEX_INFO, |
| 128189 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, | 129212 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128190 | /* ColNames: */ 15, 3, | 129213 | /* ColNames: */ 21, 3, |
| 128191 | /* iArg: */ 0 }, | 129214 | /* iArg: */ 0 }, |
| 128192 | {/* zName: */ "index_list", | 129215 | {/* zName: */ "index_list", |
| 128193 | /* ePragTyp: */ PragTyp_INDEX_LIST, | 129216 | /* ePragTyp: */ PragTyp_INDEX_LIST, |
| 128194 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, | 129217 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128195 | /* ColNames: */ 32, 5, | 129218 | /* ColNames: */ 38, 5, |
| 128196 | /* iArg: */ 0 }, | 129219 | /* iArg: */ 0 }, |
| 128197 | {/* zName: */ "index_xinfo", | 129220 | {/* zName: */ "index_xinfo", |
| 128198 | /* ePragTyp: */ PragTyp_INDEX_INFO, | 129221 | /* ePragTyp: */ PragTyp_INDEX_INFO, |
| 128199 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, | 129222 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128200 | /* ColNames: */ 15, 6, | 129223 | /* ColNames: */ 21, 6, |
| 128201 | /* iArg: */ 1 }, | 129224 | /* iArg: */ 1 }, |
| 128202 | #endif | 129225 | #endif |
| 128203 | #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) | 129226 | #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) |
| 128204 | {/* zName: */ "integrity_check", | 129227 | {/* zName: */ "integrity_check", |
| 128205 | /* ePragTyp: */ PragTyp_INTEGRITY_CHECK, | 129228 | /* ePragTyp: */ PragTyp_INTEGRITY_CHECK, |
| 128206 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1, | 129229 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128207 | /* ColNames: */ 0, 0, | 129230 | /* ColNames: */ 0, 0, |
| 128208 | /* iArg: */ 0 }, | 129231 | /* iArg: */ 0 }, |
| 128209 | #endif | 129232 | #endif |
| @@ -128237,7 +129260,7 @@ static const PragmaName aPragmaName[] = { | |||
| 128237 | {/* zName: */ "lock_status", | 129260 | {/* zName: */ "lock_status", |
| 128238 | /* ePragTyp: */ PragTyp_LOCK_STATUS, | 129261 | /* ePragTyp: */ PragTyp_LOCK_STATUS, |
| 128239 | /* ePragFlg: */ PragFlg_Result0, | 129262 | /* ePragFlg: */ PragFlg_Result0, |
| 128240 | /* ColNames: */ 47, 2, | 129263 | /* ColNames: */ 53, 2, |
| 128241 | /* iArg: */ 0 }, | 129264 | /* iArg: */ 0 }, |
| 128242 | #endif | 129265 | #endif |
| 128243 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 129266 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| @@ -128311,7 +129334,7 @@ static const PragmaName aPragmaName[] = { | |||
| 128311 | #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) | 129334 | #if !defined(SQLITE_OMIT_INTEGRITY_CHECK) |
| 128312 | {/* zName: */ "quick_check", | 129335 | {/* zName: */ "quick_check", |
| 128313 | /* ePragTyp: */ PragTyp_INTEGRITY_CHECK, | 129336 | /* ePragTyp: */ PragTyp_INTEGRITY_CHECK, |
| 128314 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1, | 129337 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128315 | /* ColNames: */ 0, 0, | 129338 | /* ColNames: */ 0, 0, |
| 128316 | /* iArg: */ 0 }, | 129339 | /* iArg: */ 0 }, |
| 128317 | #endif | 129340 | #endif |
| @@ -128376,7 +129399,7 @@ static const PragmaName aPragmaName[] = { | |||
| 128376 | {/* zName: */ "stats", | 129399 | {/* zName: */ "stats", |
| 128377 | /* ePragTyp: */ PragTyp_STATS, | 129400 | /* ePragTyp: */ PragTyp_STATS, |
| 128378 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq, | 129401 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq, |
| 128379 | /* ColNames: */ 27, 5, | 129402 | /* ColNames: */ 33, 5, |
| 128380 | /* iArg: */ 0 }, | 129403 | /* iArg: */ 0 }, |
| 128381 | #endif | 129404 | #endif |
| 128382 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) | 129405 | #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) |
| @@ -128392,6 +129415,11 @@ static const PragmaName aPragmaName[] = { | |||
| 128392 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, | 129415 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| 128393 | /* ColNames: */ 8, 6, | 129416 | /* ColNames: */ 8, 6, |
| 128394 | /* iArg: */ 0 }, | 129417 | /* iArg: */ 0 }, |
| 129418 | {/* zName: */ "table_list", | ||
| 129419 | /* ePragTyp: */ PragTyp_TABLE_LIST, | ||
| 129420 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1, | ||
| 129421 | /* ColNames: */ 15, 6, | ||
| 129422 | /* iArg: */ 0 }, | ||
| 128395 | {/* zName: */ "table_xinfo", | 129423 | {/* zName: */ "table_xinfo", |
| 128396 | /* ePragTyp: */ PragTyp_TABLE_INFO, | 129424 | /* ePragTyp: */ PragTyp_TABLE_INFO, |
| 128397 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, | 129425 | /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result1|PragFlg_SchemaOpt, |
| @@ -128467,7 +129495,7 @@ static const PragmaName aPragmaName[] = { | |||
| 128467 | {/* zName: */ "wal_checkpoint", | 129495 | {/* zName: */ "wal_checkpoint", |
| 128468 | /* ePragTyp: */ PragTyp_WAL_CHECKPOINT, | 129496 | /* ePragTyp: */ PragTyp_WAL_CHECKPOINT, |
| 128469 | /* ePragFlg: */ PragFlg_NeedSchema, | 129497 | /* ePragFlg: */ PragFlg_NeedSchema, |
| 128470 | /* ColNames: */ 44, 3, | 129498 | /* ColNames: */ 50, 3, |
| 128471 | /* iArg: */ 0 }, | 129499 | /* iArg: */ 0 }, |
| 128472 | #endif | 129500 | #endif |
| 128473 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) | 129501 | #if !defined(SQLITE_OMIT_FLAG_PRAGMAS) |
| @@ -128478,7 +129506,7 @@ static const PragmaName aPragmaName[] = { | |||
| 128478 | /* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError }, | 129506 | /* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError }, |
| 128479 | #endif | 129507 | #endif |
| 128480 | }; | 129508 | }; |
| 128481 | /* Number of pragmas: 67 on by default, 77 total. */ | 129509 | /* Number of pragmas: 68 on by default, 78 total. */ |
| 128482 | 129510 | ||
| 128483 | /************** End of pragma.h **********************************************/ | 129511 | /************** End of pragma.h **********************************************/ |
| 128484 | /************** Continuing where we left off in pragma.c *********************/ | 129512 | /************** Continuing where we left off in pragma.c *********************/ |
| @@ -128920,7 +129948,11 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 128920 | 129948 | ||
| 128921 | /* Locate the pragma in the lookup table */ | 129949 | /* Locate the pragma in the lookup table */ |
| 128922 | pPragma = pragmaLocate(zLeft); | 129950 | pPragma = pragmaLocate(zLeft); |
| 128923 | if( pPragma==0 ) goto pragma_out; | 129951 | if( pPragma==0 ){ |
| 129952 | /* IMP: R-43042-22504 No error messages are generated if an | ||
| 129953 | ** unknown pragma is issued. */ | ||
| 129954 | goto pragma_out; | ||
| 129955 | } | ||
| 128924 | 129956 | ||
| 128925 | /* Make sure the database schema is loaded if the pragma requires that */ | 129957 | /* Make sure the database schema is loaded if the pragma requires that */ |
| 128926 | if( (pPragma->mPragFlg & PragFlg_NeedSchema)!=0 ){ | 129958 | if( (pPragma->mPragFlg & PragFlg_NeedSchema)!=0 ){ |
| @@ -129570,6 +130602,14 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129570 | }else{ | 130602 | }else{ |
| 129571 | db->flags &= ~mask; | 130603 | db->flags &= ~mask; |
| 129572 | if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0; | 130604 | if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0; |
| 130605 | if( (mask & SQLITE_WriteSchema)!=0 | ||
| 130606 | && sqlite3_stricmp(zRight, "reset")==0 | ||
| 130607 | ){ | ||
| 130608 | /* IMP: R-60817-01178 If the argument is "RESET" then schema | ||
| 130609 | ** writing is disabled (as with "PRAGMA writable_schema=OFF") and, | ||
| 130610 | ** in addition, the schema is reloaded. */ | ||
| 130611 | sqlite3ResetAllSchemasOfConnection(db); | ||
| 130612 | } | ||
| 129573 | } | 130613 | } |
| 129574 | 130614 | ||
| 129575 | /* Many of the flag-pragmas modify the code generated by the SQL | 130615 | /* Many of the flag-pragmas modify the code generated by the SQL |
| @@ -129610,6 +130650,7 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129610 | sqlite3ViewGetColumnNames(pParse, pTab); | 130650 | sqlite3ViewGetColumnNames(pParse, pTab); |
| 129611 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ | 130651 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ |
| 129612 | int isHidden = 0; | 130652 | int isHidden = 0; |
| 130653 | const Expr *pColExpr; | ||
| 129613 | if( pCol->colFlags & COLFLAG_NOINSERT ){ | 130654 | if( pCol->colFlags & COLFLAG_NOINSERT ){ |
| 129614 | if( pPragma->iArg==0 ){ | 130655 | if( pPragma->iArg==0 ){ |
| 129615 | nHidden++; | 130656 | nHidden++; |
| @@ -129630,13 +130671,16 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129630 | }else{ | 130671 | }else{ |
| 129631 | for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){} | 130672 | for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){} |
| 129632 | } | 130673 | } |
| 129633 | assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN || isHidden>=2 ); | 130674 | pColExpr = sqlite3ColumnExpr(pTab,pCol); |
| 130675 | assert( pColExpr==0 || pColExpr->op==TK_SPAN || isHidden>=2 ); | ||
| 130676 | assert( pColExpr==0 || !ExprHasProperty(pColExpr, EP_IntValue) | ||
| 130677 | || isHidden>=2 ); | ||
| 129634 | sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi", | 130678 | sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi", |
| 129635 | i-nHidden, | 130679 | i-nHidden, |
| 129636 | pCol->zName, | 130680 | pCol->zCnName, |
| 129637 | sqlite3ColumnType(pCol,""), | 130681 | sqlite3ColumnType(pCol,""), |
| 129638 | pCol->notNull ? 1 : 0, | 130682 | pCol->notNull ? 1 : 0, |
| 129639 | pCol->pDflt && isHidden<2 ? pCol->pDflt->u.zToken : 0, | 130683 | (isHidden>=2 || pColExpr==0) ? 0 : pColExpr->u.zToken, |
| 129640 | k, | 130684 | k, |
| 129641 | isHidden); | 130685 | isHidden); |
| 129642 | } | 130686 | } |
| @@ -129644,6 +130688,81 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129644 | } | 130688 | } |
| 129645 | break; | 130689 | break; |
| 129646 | 130690 | ||
| 130691 | /* | ||
| 130692 | ** PRAGMA table_list | ||
| 130693 | ** | ||
| 130694 | ** Return a single row for each table, virtual table, or view in the | ||
| 130695 | ** entire schema. | ||
| 130696 | ** | ||
| 130697 | ** schema: Name of attached database hold this table | ||
| 130698 | ** name: Name of the table itself | ||
| 130699 | ** type: "table", "view", "virtual", "shadow" | ||
| 130700 | ** ncol: Number of columns | ||
| 130701 | ** wr: True for a WITHOUT ROWID table | ||
| 130702 | ** strict: True for a STRICT table | ||
| 130703 | */ | ||
| 130704 | case PragTyp_TABLE_LIST: { | ||
| 130705 | int ii; | ||
| 130706 | pParse->nMem = 6; | ||
| 130707 | sqlite3CodeVerifyNamedSchema(pParse, zDb); | ||
| 130708 | for(ii=0; ii<db->nDb; ii++){ | ||
| 130709 | HashElem *k; | ||
| 130710 | Hash *pHash; | ||
| 130711 | int initNCol; | ||
| 130712 | if( zDb && sqlite3_stricmp(zDb, db->aDb[ii].zDbSName)!=0 ) continue; | ||
| 130713 | |||
| 130714 | /* Ensure that the Table.nCol field is initialized for all views | ||
| 130715 | ** and virtual tables. Each time we initialize a Table.nCol value | ||
| 130716 | ** for a table, that can potentially disrupt the hash table, so restart | ||
| 130717 | ** the initialization scan. | ||
| 130718 | */ | ||
| 130719 | pHash = &db->aDb[ii].pSchema->tblHash; | ||
| 130720 | initNCol = sqliteHashCount(pHash); | ||
| 130721 | while( initNCol-- ){ | ||
| 130722 | for(k=sqliteHashFirst(pHash); 1; k=sqliteHashNext(k) ){ | ||
| 130723 | Table *pTab; | ||
| 130724 | if( k==0 ){ initNCol = 0; break; } | ||
| 130725 | pTab = sqliteHashData(k); | ||
| 130726 | if( pTab->nCol==0 ){ | ||
| 130727 | char *zSql = sqlite3MPrintf(db, "SELECT*FROM\"%w\"", pTab->zName); | ||
| 130728 | if( zSql ){ | ||
| 130729 | sqlite3_stmt *pDummy = 0; | ||
| 130730 | (void)sqlite3_prepare(db, zSql, -1, &pDummy, 0); | ||
| 130731 | (void)sqlite3_finalize(pDummy); | ||
| 130732 | sqlite3DbFree(db, zSql); | ||
| 130733 | } | ||
| 130734 | pHash = &db->aDb[ii].pSchema->tblHash; | ||
| 130735 | break; | ||
| 130736 | } | ||
| 130737 | } | ||
| 130738 | } | ||
| 130739 | |||
| 130740 | for(k=sqliteHashFirst(pHash); k; k=sqliteHashNext(k) ){ | ||
| 130741 | Table *pTab = sqliteHashData(k); | ||
| 130742 | const char *zType; | ||
| 130743 | if( zRight && sqlite3_stricmp(zRight, pTab->zName)!=0 ) continue; | ||
| 130744 | if( IsView(pTab) ){ | ||
| 130745 | zType = "view"; | ||
| 130746 | }else if( IsVirtual(pTab) ){ | ||
| 130747 | zType = "virtual"; | ||
| 130748 | }else if( pTab->tabFlags & TF_Shadow ){ | ||
| 130749 | zType = "shadow"; | ||
| 130750 | }else{ | ||
| 130751 | zType = "table"; | ||
| 130752 | } | ||
| 130753 | sqlite3VdbeMultiLoad(v, 1, "sssiii", | ||
| 130754 | db->aDb[ii].zDbSName, | ||
| 130755 | sqlite3PreferredTableName(pTab->zName), | ||
| 130756 | zType, | ||
| 130757 | pTab->nCol, | ||
| 130758 | (pTab->tabFlags & TF_WithoutRowid)!=0, | ||
| 130759 | (pTab->tabFlags & TF_Strict)!=0 | ||
| 130760 | ); | ||
| 130761 | } | ||
| 130762 | } | ||
| 130763 | } | ||
| 130764 | break; | ||
| 130765 | |||
| 129647 | #ifdef SQLITE_DEBUG | 130766 | #ifdef SQLITE_DEBUG |
| 129648 | case PragTyp_STATS: { | 130767 | case PragTyp_STATS: { |
| 129649 | Index *pIdx; | 130768 | Index *pIdx; |
| @@ -129653,7 +130772,7 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129653 | for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){ | 130772 | for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){ |
| 129654 | Table *pTab = sqliteHashData(i); | 130773 | Table *pTab = sqliteHashData(i); |
| 129655 | sqlite3VdbeMultiLoad(v, 1, "ssiii", | 130774 | sqlite3VdbeMultiLoad(v, 1, "ssiii", |
| 129656 | pTab->zName, | 130775 | sqlite3PreferredTableName(pTab->zName), |
| 129657 | 0, | 130776 | 0, |
| 129658 | pTab->szTabRow, | 130777 | pTab->szTabRow, |
| 129659 | pTab->nRowLogEst, | 130778 | pTab->nRowLogEst, |
| @@ -129703,7 +130822,7 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129703 | for(i=0; i<mx; i++){ | 130822 | for(i=0; i<mx; i++){ |
| 129704 | i16 cnum = pIdx->aiColumn[i]; | 130823 | i16 cnum = pIdx->aiColumn[i]; |
| 129705 | sqlite3VdbeMultiLoad(v, 1, "iisX", i, cnum, | 130824 | sqlite3VdbeMultiLoad(v, 1, "iisX", i, cnum, |
| 129706 | cnum<0 ? 0 : pTab->aCol[cnum].zName); | 130825 | cnum<0 ? 0 : pTab->aCol[cnum].zCnName); |
| 129707 | if( pPragma->iArg ){ | 130826 | if( pPragma->iArg ){ |
| 129708 | sqlite3VdbeMultiLoad(v, 4, "isiX", | 130827 | sqlite3VdbeMultiLoad(v, 4, "isiX", |
| 129709 | pIdx->aSortOrder[i], | 130828 | pIdx->aSortOrder[i], |
| @@ -129772,11 +130891,13 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129772 | pParse->nMem = 6; | 130891 | pParse->nMem = 6; |
| 129773 | for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){ | 130892 | for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){ |
| 129774 | for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){ | 130893 | for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){ |
| 130894 | assert( p->funcFlags & SQLITE_FUNC_BUILTIN ); | ||
| 129775 | pragmaFunclistLine(v, p, 1, showInternFunc); | 130895 | pragmaFunclistLine(v, p, 1, showInternFunc); |
| 129776 | } | 130896 | } |
| 129777 | } | 130897 | } |
| 129778 | for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){ | 130898 | for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){ |
| 129779 | p = (FuncDef*)sqliteHashData(j); | 130899 | p = (FuncDef*)sqliteHashData(j); |
| 130900 | assert( (p->funcFlags & SQLITE_FUNC_BUILTIN)==0 ); | ||
| 129780 | pragmaFunclistLine(v, p, 0, showInternFunc); | 130901 | pragmaFunclistLine(v, p, 0, showInternFunc); |
| 129781 | } | 130902 | } |
| 129782 | } | 130903 | } |
| @@ -129810,8 +130931,8 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129810 | FKey *pFK; | 130931 | FKey *pFK; |
| 129811 | Table *pTab; | 130932 | Table *pTab; |
| 129812 | pTab = sqlite3FindTable(db, zRight, zDb); | 130933 | pTab = sqlite3FindTable(db, zRight, zDb); |
| 129813 | if( pTab ){ | 130934 | if( pTab && IsOrdinaryTable(pTab) ){ |
| 129814 | pFK = pTab->pFKey; | 130935 | pFK = pTab->u.tab.pFKey; |
| 129815 | if( pFK ){ | 130936 | if( pFK ){ |
| 129816 | int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema); | 130937 | int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 129817 | int i = 0; | 130938 | int i = 0; |
| @@ -129824,7 +130945,7 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129824 | i, | 130945 | i, |
| 129825 | j, | 130946 | j, |
| 129826 | pFK->zTo, | 130947 | pFK->zTo, |
| 129827 | pTab->aCol[pFK->aCol[j].iFrom].zName, | 130948 | pTab->aCol[pFK->aCol[j].iFrom].zCnName, |
| 129828 | pFK->aCol[j].zCol, | 130949 | pFK->aCol[j].zCol, |
| 129829 | actionName(pFK->aAction[1]), /* ON UPDATE */ | 130950 | actionName(pFK->aAction[1]), /* ON UPDATE */ |
| 129830 | actionName(pFK->aAction[0]), /* ON DELETE */ | 130951 | actionName(pFK->aAction[0]), /* ON DELETE */ |
| @@ -129870,7 +130991,7 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129870 | pTab = (Table*)sqliteHashData(k); | 130991 | pTab = (Table*)sqliteHashData(k); |
| 129871 | k = sqliteHashNext(k); | 130992 | k = sqliteHashNext(k); |
| 129872 | } | 130993 | } |
| 129873 | if( pTab==0 || pTab->pFKey==0 ) continue; | 130994 | if( pTab==0 || !IsOrdinaryTable(pTab) || pTab->u.tab.pFKey==0 ) continue; |
| 129874 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | 130995 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 129875 | zDb = db->aDb[iDb].zDbSName; | 130996 | zDb = db->aDb[iDb].zDbSName; |
| 129876 | sqlite3CodeVerifySchema(pParse, iDb); | 130997 | sqlite3CodeVerifySchema(pParse, iDb); |
| @@ -129878,7 +130999,8 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129878 | if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow; | 130999 | if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow; |
| 129879 | sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead); | 131000 | sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead); |
| 129880 | sqlite3VdbeLoadString(v, regResult, pTab->zName); | 131001 | sqlite3VdbeLoadString(v, regResult, pTab->zName); |
| 129881 | for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ | 131002 | assert( IsOrdinaryTable(pTab) ); |
| 131003 | for(i=1, pFK=pTab->u.tab.pFKey; pFK; i++, pFK=pFK->pNextFrom){ | ||
| 129882 | pParent = sqlite3FindTable(db, pFK->zTo, zDb); | 131004 | pParent = sqlite3FindTable(db, pFK->zTo, zDb); |
| 129883 | if( pParent==0 ) continue; | 131005 | if( pParent==0 ) continue; |
| 129884 | pIdx = 0; | 131006 | pIdx = 0; |
| @@ -129900,7 +131022,8 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129900 | if( pFK ) break; | 131022 | if( pFK ) break; |
| 129901 | if( pParse->nTab<i ) pParse->nTab = i; | 131023 | if( pParse->nTab<i ) pParse->nTab = i; |
| 129902 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); VdbeCoverage(v); | 131024 | addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); VdbeCoverage(v); |
| 129903 | for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ | 131025 | assert( IsOrdinaryTable(pTab) ); |
| 131026 | for(i=1, pFK=pTab->u.tab.pFKey; pFK; i++, pFK=pFK->pNextFrom){ | ||
| 129904 | pParent = sqlite3FindTable(db, pFK->zTo, zDb); | 131027 | pParent = sqlite3FindTable(db, pFK->zTo, zDb); |
| 129905 | pIdx = 0; | 131028 | pIdx = 0; |
| 129906 | aiCols = 0; | 131029 | aiCols = 0; |
| @@ -129914,6 +131037,7 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 129914 | ** regRow..regRow+n. If any of the child key values are NULL, this | 131037 | ** regRow..regRow+n. If any of the child key values are NULL, this |
| 129915 | ** row cannot cause an FK violation. Jump directly to addrOk in | 131038 | ** row cannot cause an FK violation. Jump directly to addrOk in |
| 129916 | ** this case. */ | 131039 | ** this case. */ |
| 131040 | if( regRow+pFK->nCol>pParse->nMem ) pParse->nMem = regRow+pFK->nCol; | ||
| 129917 | for(j=0; j<pFK->nCol; j++){ | 131041 | for(j=0; j<pFK->nCol; j++){ |
| 129918 | int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom; | 131042 | int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom; |
| 129919 | sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j); | 131043 | sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j); |
| @@ -130100,8 +131224,9 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 130100 | int loopTop; | 131224 | int loopTop; |
| 130101 | int iDataCur, iIdxCur; | 131225 | int iDataCur, iIdxCur; |
| 130102 | int r1 = -1; | 131226 | int r1 = -1; |
| 131227 | int bStrict; | ||
| 130103 | 131228 | ||
| 130104 | if( pTab->tnum<1 ) continue; /* Skip VIEWs or VIRTUAL TABLEs */ | 131229 | if( !IsOrdinaryTable(pTab) ) continue; |
| 130105 | if( pObjTab && pObjTab!=pTab ) continue; | 131230 | if( pObjTab && pObjTab!=pTab ) continue; |
| 130106 | pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab); | 131231 | pPk = HasRowid(pTab) ? 0 : sqlite3PrimaryKeyIndex(pTab); |
| 130107 | sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0, | 131232 | sqlite3OpenTableAndIndices(pParse, pTab, OP_OpenRead, 0, |
| @@ -130121,23 +131246,48 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 130121 | /* Sanity check on record header decoding */ | 131246 | /* Sanity check on record header decoding */ |
| 130122 | sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nNVCol-1,3); | 131247 | sqlite3VdbeAddOp3(v, OP_Column, iDataCur, pTab->nNVCol-1,3); |
| 130123 | sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); | 131248 | sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); |
| 131249 | VdbeComment((v, "(right-most column)")); | ||
| 130124 | } | 131250 | } |
| 130125 | /* Verify that all NOT NULL columns really are NOT NULL */ | 131251 | /* Verify that all NOT NULL columns really are NOT NULL. At the |
| 131252 | ** same time verify the type of the content of STRICT tables */ | ||
| 131253 | bStrict = (pTab->tabFlags & TF_Strict)!=0; | ||
| 130126 | for(j=0; j<pTab->nCol; j++){ | 131254 | for(j=0; j<pTab->nCol; j++){ |
| 130127 | char *zErr; | 131255 | char *zErr; |
| 130128 | int jmp2; | 131256 | Column *pCol = pTab->aCol + j; |
| 131257 | int doError, jmp2; | ||
| 130129 | if( j==pTab->iPKey ) continue; | 131258 | if( j==pTab->iPKey ) continue; |
| 130130 | if( pTab->aCol[j].notNull==0 ) continue; | 131259 | if( pCol->notNull==0 && !bStrict ) continue; |
| 131260 | doError = bStrict ? sqlite3VdbeMakeLabel(pParse) : 0; | ||
| 130131 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); | 131261 | sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, j, 3); |
| 130132 | if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){ | 131262 | if( sqlite3VdbeGetOp(v,-1)->opcode==OP_Column ){ |
| 130133 | sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); | 131263 | sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG); |
| 130134 | } | 131264 | } |
| 130135 | jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); | 131265 | if( pCol->notNull ){ |
| 130136 | zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, | 131266 | jmp2 = sqlite3VdbeAddOp1(v, OP_NotNull, 3); VdbeCoverage(v); |
| 130137 | pTab->aCol[j].zName); | 131267 | zErr = sqlite3MPrintf(db, "NULL value in %s.%s", pTab->zName, |
| 130138 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); | 131268 | pCol->zCnName); |
| 130139 | integrityCheckResultRow(v); | 131269 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); |
| 130140 | sqlite3VdbeJumpHere(v, jmp2); | 131270 | if( bStrict && pCol->eCType!=COLTYPE_ANY ){ |
| 131271 | sqlite3VdbeGoto(v, doError); | ||
| 131272 | }else{ | ||
| 131273 | integrityCheckResultRow(v); | ||
| 131274 | } | ||
| 131275 | sqlite3VdbeJumpHere(v, jmp2); | ||
| 131276 | } | ||
| 131277 | if( (pTab->tabFlags & TF_Strict)!=0 | ||
| 131278 | && pCol->eCType!=COLTYPE_ANY | ||
| 131279 | ){ | ||
| 131280 | jmp2 = sqlite3VdbeAddOp3(v, OP_IsNullOrType, 3, 0, | ||
| 131281 | sqlite3StdTypeMap[pCol->eCType-1]); | ||
| 131282 | VdbeCoverage(v); | ||
| 131283 | zErr = sqlite3MPrintf(db, "non-%s value in %s.%s", | ||
| 131284 | sqlite3StdType[pCol->eCType-1], | ||
| 131285 | pTab->zName, pTab->aCol[j].zCnName); | ||
| 131286 | sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, zErr, P4_DYNAMIC); | ||
| 131287 | sqlite3VdbeResolveLabel(v, doError); | ||
| 131288 | integrityCheckResultRow(v); | ||
| 131289 | sqlite3VdbeJumpHere(v, jmp2); | ||
| 131290 | } | ||
| 130141 | } | 131291 | } |
| 130142 | /* Verify CHECK constraints */ | 131292 | /* Verify CHECK constraints */ |
| 130143 | if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ | 131293 | if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){ |
| @@ -130671,12 +131821,12 @@ SQLITE_PRIVATE void sqlite3Pragma( | |||
| 130671 | case PragTyp_ANALYSIS_LIMIT: { | 131821 | case PragTyp_ANALYSIS_LIMIT: { |
| 130672 | sqlite3_int64 N; | 131822 | sqlite3_int64 N; |
| 130673 | if( zRight | 131823 | if( zRight |
| 130674 | && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK | 131824 | && sqlite3DecOrHexToI64(zRight, &N)==SQLITE_OK /* IMP: R-40975-20399 */ |
| 130675 | && N>=0 | 131825 | && N>=0 |
| 130676 | ){ | 131826 | ){ |
| 130677 | db->nAnalysisLimit = (int)(N&0x7fffffff); | 131827 | db->nAnalysisLimit = (int)(N&0x7fffffff); |
| 130678 | } | 131828 | } |
| 130679 | returnSingleInt(v, db->nAnalysisLimit); | 131829 | returnSingleInt(v, db->nAnalysisLimit); /* IMP: R-57594-65522 */ |
| 130680 | break; | 131830 | break; |
| 130681 | } | 131831 | } |
| 130682 | 131832 | ||
| @@ -131078,10 +132228,15 @@ static void corruptSchema( | |||
| 131078 | pData->rc = SQLITE_NOMEM_BKPT; | 132228 | pData->rc = SQLITE_NOMEM_BKPT; |
| 131079 | }else if( pData->pzErrMsg[0]!=0 ){ | 132229 | }else if( pData->pzErrMsg[0]!=0 ){ |
| 131080 | /* A error message has already been generated. Do not overwrite it */ | 132230 | /* A error message has already been generated. Do not overwrite it */ |
| 131081 | }else if( pData->mInitFlags & (INITFLAG_AlterRename|INITFLAG_AlterDrop) ){ | 132231 | }else if( pData->mInitFlags & (INITFLAG_AlterMask) ){ |
| 132232 | static const char *azAlterType[] = { | ||
| 132233 | "rename", | ||
| 132234 | "drop column", | ||
| 132235 | "add column" | ||
| 132236 | }; | ||
| 131082 | *pData->pzErrMsg = sqlite3MPrintf(db, | 132237 | *pData->pzErrMsg = sqlite3MPrintf(db, |
| 131083 | "error in %s %s after %s: %s", azObj[0], azObj[1], | 132238 | "error in %s %s after %s: %s", azObj[0], azObj[1], |
| 131084 | (pData->mInitFlags & INITFLAG_AlterRename) ? "rename" : "drop column", | 132239 | azAlterType[(pData->mInitFlags&INITFLAG_AlterMask)-1], |
| 131085 | zExtra | 132240 | zExtra |
| 131086 | ); | 132241 | ); |
| 131087 | pData->rc = SQLITE_ERROR; | 132242 | pData->rc = SQLITE_ERROR; |
| @@ -131183,7 +132338,7 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char | |||
| 131183 | } | 132338 | } |
| 131184 | } | 132339 | } |
| 131185 | db->init.orphanTrigger = 0; | 132340 | db->init.orphanTrigger = 0; |
| 131186 | db->init.azInit = argv; | 132341 | db->init.azInit = (const char**)argv; |
| 131187 | pStmt = 0; | 132342 | pStmt = 0; |
| 131188 | TESTONLY(rcp = ) sqlite3Prepare(db, argv[4], -1, 0, 0, &pStmt, 0); | 132343 | TESTONLY(rcp = ) sqlite3Prepare(db, argv[4], -1, 0, 0, &pStmt, 0); |
| 131189 | rc = db->errCode; | 132344 | rc = db->errCode; |
| @@ -131202,6 +132357,7 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char | |||
| 131202 | } | 132357 | } |
| 131203 | } | 132358 | } |
| 131204 | } | 132359 | } |
| 132360 | db->init.azInit = sqlite3StdType; /* Any array of string ptrs will do */ | ||
| 131205 | sqlite3_finalize(pStmt); | 132361 | sqlite3_finalize(pStmt); |
| 131206 | }else if( argv[1]==0 || (argv[4]!=0 && argv[4][0]!=0) ){ | 132362 | }else if( argv[1]==0 || (argv[4]!=0 && argv[4][0]!=0) ){ |
| 131207 | corruptSchema(pData, argv, 0); | 132363 | corruptSchema(pData, argv, 0); |
| @@ -131851,6 +133007,7 @@ static int sqlite3LockAndPrepare( | |||
| 131851 | ** reset is considered a permanent error. */ | 133007 | ** reset is considered a permanent error. */ |
| 131852 | rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail); | 133008 | rc = sqlite3Prepare(db, zSql, nBytes, prepFlags, pOld, ppStmt, pzTail); |
| 131853 | assert( rc==SQLITE_OK || *ppStmt==0 ); | 133009 | assert( rc==SQLITE_OK || *ppStmt==0 ); |
| 133010 | if( rc==SQLITE_OK || db->mallocFailed ) break; | ||
| 131854 | }while( rc==SQLITE_ERROR_RETRY | 133011 | }while( rc==SQLITE_ERROR_RETRY |
| 131855 | || (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) ); | 133012 | || (rc==SQLITE_SCHEMA && (sqlite3ResetOneSchema(db,-1), cnt++)==0) ); |
| 131856 | sqlite3BtreeLeaveAll(db); | 133013 | sqlite3BtreeLeaveAll(db); |
| @@ -132342,7 +133499,7 @@ SQLITE_PRIVATE int sqlite3ColumnIndex(Table *pTab, const char *zCol){ | |||
| 132342 | u8 h = sqlite3StrIHash(zCol); | 133499 | u8 h = sqlite3StrIHash(zCol); |
| 132343 | Column *pCol; | 133500 | Column *pCol; |
| 132344 | for(pCol=pTab->aCol, i=0; i<pTab->nCol; pCol++, i++){ | 133501 | for(pCol=pTab->aCol, i=0; i<pTab->nCol; pCol++, i++){ |
| 132345 | if( pCol->hName==h && sqlite3StrICmp(pCol->zName, zCol)==0 ) return i; | 133502 | if( pCol->hName==h && sqlite3StrICmp(pCol->zCnName, zCol)==0 ) return i; |
| 132346 | } | 133503 | } |
| 132347 | return -1; | 133504 | return -1; |
| 132348 | } | 133505 | } |
| @@ -132418,6 +133575,9 @@ static void addWhereTerm( | |||
| 132418 | pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight); | 133575 | pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight); |
| 132419 | 133576 | ||
| 132420 | pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2); | 133577 | pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2); |
| 133578 | assert( pE2!=0 || pEq==0 ); /* Due to db->mallocFailed test | ||
| 133579 | ** in sqlite3DbMallocRawNN() called from | ||
| 133580 | ** sqlite3PExpr(). */ | ||
| 132421 | if( pEq && isOuterJoin ){ | 133581 | if( pEq && isOuterJoin ){ |
| 132422 | ExprSetProperty(pEq, EP_FromJoin); | 133582 | ExprSetProperty(pEq, EP_FromJoin); |
| 132423 | assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) ); | 133583 | assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) ); |
| @@ -132459,10 +133619,13 @@ SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){ | |||
| 132459 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); | 133619 | assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); |
| 132460 | ExprSetVVAProperty(p, EP_NoReduce); | 133620 | ExprSetVVAProperty(p, EP_NoReduce); |
| 132461 | p->iRightJoinTable = iTable; | 133621 | p->iRightJoinTable = iTable; |
| 132462 | if( p->op==TK_FUNCTION && p->x.pList ){ | 133622 | if( p->op==TK_FUNCTION ){ |
| 132463 | int i; | 133623 | assert( ExprUseXList(p) ); |
| 132464 | for(i=0; i<p->x.pList->nExpr; i++){ | 133624 | if( p->x.pList ){ |
| 132465 | sqlite3SetJoinExpr(p->x.pList->a[i].pExpr, iTable); | 133625 | int i; |
| 133626 | for(i=0; i<p->x.pList->nExpr; i++){ | ||
| 133627 | sqlite3SetJoinExpr(p->x.pList->a[i].pExpr, iTable); | ||
| 133628 | } | ||
| 132466 | } | 133629 | } |
| 132467 | } | 133630 | } |
| 132468 | sqlite3SetJoinExpr(p->pLeft, iTable); | 133631 | sqlite3SetJoinExpr(p->pLeft, iTable); |
| @@ -132485,10 +133648,13 @@ static void unsetJoinExpr(Expr *p, int iTable){ | |||
| 132485 | if( p->op==TK_COLUMN && p->iTable==iTable ){ | 133648 | if( p->op==TK_COLUMN && p->iTable==iTable ){ |
| 132486 | ExprClearProperty(p, EP_CanBeNull); | 133649 | ExprClearProperty(p, EP_CanBeNull); |
| 132487 | } | 133650 | } |
| 132488 | if( p->op==TK_FUNCTION && p->x.pList ){ | 133651 | if( p->op==TK_FUNCTION ){ |
| 132489 | int i; | 133652 | assert( ExprUseXList(p) ); |
| 132490 | for(i=0; i<p->x.pList->nExpr; i++){ | 133653 | if( p->x.pList ){ |
| 132491 | unsetJoinExpr(p->x.pList->a[i].pExpr, iTable); | 133654 | int i; |
| 133655 | for(i=0; i<p->x.pList->nExpr; i++){ | ||
| 133656 | unsetJoinExpr(p->x.pList->a[i].pExpr, iTable); | ||
| 133657 | } | ||
| 132492 | } | 133658 | } |
| 132493 | } | 133659 | } |
| 132494 | unsetJoinExpr(p->pLeft, iTable); | 133660 | unsetJoinExpr(p->pLeft, iTable); |
| @@ -132541,7 +133707,7 @@ static int sqliteProcessJoin(Parse *pParse, Select *p){ | |||
| 132541 | int iLeftCol; /* Matching column in the left table */ | 133707 | int iLeftCol; /* Matching column in the left table */ |
| 132542 | 133708 | ||
| 132543 | if( IsHiddenColumn(&pRightTab->aCol[j]) ) continue; | 133709 | if( IsHiddenColumn(&pRightTab->aCol[j]) ) continue; |
| 132544 | zName = pRightTab->aCol[j].zName; | 133710 | zName = pRightTab->aCol[j].zCnName; |
| 132545 | if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol, 1) ){ | 133711 | if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol, 1) ){ |
| 132546 | addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j, | 133712 | addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j, |
| 132547 | isOuter, &p->pWhere); | 133713 | isOuter, &p->pWhere); |
| @@ -132944,7 +134110,9 @@ static void fixDistinctOpenEph( | |||
| 132944 | int iVal, /* Value returned by codeDistinct() */ | 134110 | int iVal, /* Value returned by codeDistinct() */ |
| 132945 | int iOpenEphAddr /* Address of OP_OpenEphemeral instruction for iTab */ | 134111 | int iOpenEphAddr /* Address of OP_OpenEphemeral instruction for iTab */ |
| 132946 | ){ | 134112 | ){ |
| 132947 | if( eTnctType==WHERE_DISTINCT_UNIQUE || eTnctType==WHERE_DISTINCT_ORDERED ){ | 134113 | if( pParse->nErr==0 |
| 134114 | && (eTnctType==WHERE_DISTINCT_UNIQUE || eTnctType==WHERE_DISTINCT_ORDERED) | ||
| 134115 | ){ | ||
| 132948 | Vdbe *v = pParse->pVdbe; | 134116 | Vdbe *v = pParse->pVdbe; |
| 132949 | sqlite3VdbeChangeToNoop(v, iOpenEphAddr); | 134117 | sqlite3VdbeChangeToNoop(v, iOpenEphAddr); |
| 132950 | if( sqlite3VdbeGetOp(v, iOpenEphAddr+1)->opcode==OP_Explain ){ | 134118 | if( sqlite3VdbeGetOp(v, iOpenEphAddr+1)->opcode==OP_Explain ){ |
| @@ -133001,9 +134169,13 @@ static void selectExprDefer( | |||
| 133001 | struct ExprList_item *pItem = &pEList->a[i]; | 134169 | struct ExprList_item *pItem = &pEList->a[i]; |
| 133002 | if( pItem->u.x.iOrderByCol==0 ){ | 134170 | if( pItem->u.x.iOrderByCol==0 ){ |
| 133003 | Expr *pExpr = pItem->pExpr; | 134171 | Expr *pExpr = pItem->pExpr; |
| 133004 | Table *pTab = pExpr->y.pTab; | 134172 | Table *pTab; |
| 133005 | if( pExpr->op==TK_COLUMN && pExpr->iColumn>=0 && pTab && !IsVirtual(pTab) | 134173 | if( pExpr->op==TK_COLUMN |
| 133006 | && (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF) | 134174 | && pExpr->iColumn>=0 |
| 134175 | && ALWAYS( ExprUseYTab(pExpr) ) | ||
| 134176 | && (pTab = pExpr->y.pTab)!=0 | ||
| 134177 | && IsOrdinaryTable(pTab) | ||
| 134178 | && (pTab->aCol[pExpr->iColumn].colFlags & COLFLAG_SORTERREF)!=0 | ||
| 133007 | ){ | 134179 | ){ |
| 133008 | int j; | 134180 | int j; |
| 133009 | for(j=0; j<nDefer; j++){ | 134181 | for(j=0; j<nDefer; j++){ |
| @@ -133024,6 +134196,7 @@ static void selectExprDefer( | |||
| 133024 | Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0); | 134196 | Expr *pNew = sqlite3PExpr(pParse, TK_COLUMN, 0, 0); |
| 133025 | if( pNew ){ | 134197 | if( pNew ){ |
| 133026 | pNew->iTable = pExpr->iTable; | 134198 | pNew->iTable = pExpr->iTable; |
| 134199 | assert( ExprUseYTab(pNew) ); | ||
| 133027 | pNew->y.pTab = pExpr->y.pTab; | 134200 | pNew->y.pTab = pExpr->y.pTab; |
| 133028 | pNew->iColumn = pPk ? pPk->aiColumn[k] : -1; | 134201 | pNew->iColumn = pPk ? pPk->aiColumn[k] : -1; |
| 133029 | pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew); | 134202 | pExtra = sqlite3ExprListAppend(pParse, pExtra, pNew); |
| @@ -133872,7 +135045,7 @@ static const char *columnTypeImpl( | |||
| 133872 | break; | 135045 | break; |
| 133873 | } | 135046 | } |
| 133874 | 135047 | ||
| 133875 | assert( pTab && pExpr->y.pTab==pTab ); | 135048 | assert( pTab && ExprUseYTab(pExpr) && pExpr->y.pTab==pTab ); |
| 133876 | if( pS ){ | 135049 | if( pS ){ |
| 133877 | /* The "table" is actually a sub-select or a view in the FROM clause | 135050 | /* The "table" is actually a sub-select or a view in the FROM clause |
| 133878 | ** of the SELECT statement. Return the declaration type and origin | 135051 | ** of the SELECT statement. Return the declaration type and origin |
| @@ -133906,7 +135079,7 @@ static const char *columnTypeImpl( | |||
| 133906 | zType = "INTEGER"; | 135079 | zType = "INTEGER"; |
| 133907 | zOrigCol = "rowid"; | 135080 | zOrigCol = "rowid"; |
| 133908 | }else{ | 135081 | }else{ |
| 133909 | zOrigCol = pTab->aCol[iCol].zName; | 135082 | zOrigCol = pTab->aCol[iCol].zCnName; |
| 133910 | zType = sqlite3ColumnType(&pTab->aCol[iCol],0); | 135083 | zType = sqlite3ColumnType(&pTab->aCol[iCol],0); |
| 133911 | } | 135084 | } |
| 133912 | zOrigTab = pTab->zName; | 135085 | zOrigTab = pTab->zName; |
| @@ -133932,9 +135105,11 @@ static const char *columnTypeImpl( | |||
| 133932 | ** statement. | 135105 | ** statement. |
| 133933 | */ | 135106 | */ |
| 133934 | NameContext sNC; | 135107 | NameContext sNC; |
| 133935 | Select *pS = pExpr->x.pSelect; | 135108 | Select *pS; |
| 133936 | Expr *p = pS->pEList->a[0].pExpr; | 135109 | Expr *p; |
| 133937 | assert( ExprHasProperty(pExpr, EP_xIsSelect) ); | 135110 | assert( ExprUseXSelect(pExpr) ); |
| 135111 | pS = pExpr->x.pSelect; | ||
| 135112 | p = pS->pEList->a[0].pExpr; | ||
| 133938 | sNC.pSrcList = pS->pSrc; | 135113 | sNC.pSrcList = pS->pSrc; |
| 133939 | sNC.pNext = pNC; | 135114 | sNC.pNext = pNC; |
| 133940 | sNC.pParse = pNC->pParse; | 135115 | sNC.pParse = pNC->pParse; |
| @@ -134063,7 +135238,8 @@ SQLITE_PRIVATE void sqlite3GenerateColumnNames( | |||
| 134063 | 135238 | ||
| 134064 | assert( p!=0 ); | 135239 | assert( p!=0 ); |
| 134065 | assert( p->op!=TK_AGG_COLUMN ); /* Agg processing has not run yet */ | 135240 | assert( p->op!=TK_AGG_COLUMN ); /* Agg processing has not run yet */ |
| 134066 | assert( p->op!=TK_COLUMN || p->y.pTab!=0 ); /* Covering idx not yet coded */ | 135241 | assert( p->op!=TK_COLUMN |
| 135242 | || (ExprUseYTab(p) && p->y.pTab!=0) ); /* Covering idx not yet coded */ | ||
| 134067 | if( pEList->a[i].zEName && pEList->a[i].eEName==ENAME_NAME ){ | 135243 | if( pEList->a[i].zEName && pEList->a[i].eEName==ENAME_NAME ){ |
| 134068 | /* An AS clause always takes first priority */ | 135244 | /* An AS clause always takes first priority */ |
| 134069 | char *zName = pEList->a[i].zEName; | 135245 | char *zName = pEList->a[i].zEName; |
| @@ -134078,7 +135254,7 @@ SQLITE_PRIVATE void sqlite3GenerateColumnNames( | |||
| 134078 | if( iCol<0 ){ | 135254 | if( iCol<0 ){ |
| 134079 | zCol = "rowid"; | 135255 | zCol = "rowid"; |
| 134080 | }else{ | 135256 | }else{ |
| 134081 | zCol = pTab->aCol[iCol].zName; | 135257 | zCol = pTab->aCol[iCol].zCnName; |
| 134082 | } | 135258 | } |
| 134083 | if( fullName ){ | 135259 | if( fullName ){ |
| 134084 | char *zName = 0; | 135260 | char *zName = 0; |
| @@ -134159,11 +135335,14 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExprList( | |||
| 134159 | pColExpr = pColExpr->pRight; | 135335 | pColExpr = pColExpr->pRight; |
| 134160 | assert( pColExpr!=0 ); | 135336 | assert( pColExpr!=0 ); |
| 134161 | } | 135337 | } |
| 134162 | if( pColExpr->op==TK_COLUMN && (pTab = pColExpr->y.pTab)!=0 ){ | 135338 | if( pColExpr->op==TK_COLUMN |
| 135339 | && ALWAYS( ExprUseYTab(pColExpr) ) | ||
| 135340 | && (pTab = pColExpr->y.pTab)!=0 | ||
| 135341 | ){ | ||
| 134163 | /* For columns use the column name name */ | 135342 | /* For columns use the column name name */ |
| 134164 | int iCol = pColExpr->iColumn; | 135343 | int iCol = pColExpr->iColumn; |
| 134165 | if( iCol<0 ) iCol = pTab->iPKey; | 135344 | if( iCol<0 ) iCol = pTab->iPKey; |
| 134166 | zName = iCol>=0 ? pTab->aCol[iCol].zName : "rowid"; | 135345 | zName = iCol>=0 ? pTab->aCol[iCol].zCnName : "rowid"; |
| 134167 | }else if( pColExpr->op==TK_ID ){ | 135346 | }else if( pColExpr->op==TK_ID ){ |
| 134168 | assert( !ExprHasProperty(pColExpr, EP_IntValue) ); | 135347 | assert( !ExprHasProperty(pColExpr, EP_IntValue) ); |
| 134169 | zName = pColExpr->u.zToken; | 135348 | zName = pColExpr->u.zToken; |
| @@ -134191,7 +135370,7 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExprList( | |||
| 134191 | zName = sqlite3MPrintf(db, "%.*z:%u", nName, zName, ++cnt); | 135370 | zName = sqlite3MPrintf(db, "%.*z:%u", nName, zName, ++cnt); |
| 134192 | if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt); | 135371 | if( cnt>3 ) sqlite3_randomness(sizeof(cnt), &cnt); |
| 134193 | } | 135372 | } |
| 134194 | pCol->zName = zName; | 135373 | pCol->zCnName = zName; |
| 134195 | pCol->hName = sqlite3StrIHash(zName); | 135374 | pCol->hName = sqlite3StrIHash(zName); |
| 134196 | sqlite3ColumnPropertiesFromName(0, pCol); | 135375 | sqlite3ColumnPropertiesFromName(0, pCol); |
| 134197 | if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){ | 135376 | if( zName && sqlite3HashInsert(&ht, zName, pCol)==pCol ){ |
| @@ -134201,7 +135380,7 @@ SQLITE_PRIVATE int sqlite3ColumnsFromExprList( | |||
| 134201 | sqlite3HashClear(&ht); | 135380 | sqlite3HashClear(&ht); |
| 134202 | if( db->mallocFailed ){ | 135381 | if( db->mallocFailed ){ |
| 134203 | for(j=0; j<i; j++){ | 135382 | for(j=0; j<i; j++){ |
| 134204 | sqlite3DbFree(db, aCol[j].zName); | 135383 | sqlite3DbFree(db, aCol[j].zCnName); |
| 134205 | } | 135384 | } |
| 134206 | sqlite3DbFree(db, aCol); | 135385 | sqlite3DbFree(db, aCol); |
| 134207 | *paCol = 0; | 135386 | *paCol = 0; |
| @@ -134245,7 +135424,7 @@ SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation( | |||
| 134245 | a = pSelect->pEList->a; | 135424 | a = pSelect->pEList->a; |
| 134246 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ | 135425 | for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){ |
| 134247 | const char *zType; | 135426 | const char *zType; |
| 134248 | int n, m; | 135427 | i64 n, m; |
| 134249 | pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT); | 135428 | pTab->tabFlags |= (pCol->colFlags & COLFLAG_NOINSERT); |
| 134250 | p = a[i].pExpr; | 135429 | p = a[i].pExpr; |
| 134251 | zType = columnType(&sNC, p, 0, 0, 0); | 135430 | zType = columnType(&sNC, p, 0, 0, 0); |
| @@ -134253,17 +135432,21 @@ SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation( | |||
| 134253 | pCol->affinity = sqlite3ExprAffinity(p); | 135432 | pCol->affinity = sqlite3ExprAffinity(p); |
| 134254 | if( zType ){ | 135433 | if( zType ){ |
| 134255 | m = sqlite3Strlen30(zType); | 135434 | m = sqlite3Strlen30(zType); |
| 134256 | n = sqlite3Strlen30(pCol->zName); | 135435 | n = sqlite3Strlen30(pCol->zCnName); |
| 134257 | pCol->zName = sqlite3DbReallocOrFree(db, pCol->zName, n+m+2); | 135436 | pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2); |
| 134258 | if( pCol->zName ){ | 135437 | if( pCol->zCnName ){ |
| 134259 | memcpy(&pCol->zName[n+1], zType, m+1); | 135438 | memcpy(&pCol->zCnName[n+1], zType, m+1); |
| 134260 | pCol->colFlags |= COLFLAG_HASTYPE; | 135439 | pCol->colFlags |= COLFLAG_HASTYPE; |
| 135440 | }else{ | ||
| 135441 | testcase( pCol->colFlags & COLFLAG_HASTYPE ); | ||
| 135442 | pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL); | ||
| 134261 | } | 135443 | } |
| 134262 | } | 135444 | } |
| 134263 | if( pCol->affinity<=SQLITE_AFF_NONE ) pCol->affinity = aff; | 135445 | if( pCol->affinity<=SQLITE_AFF_NONE ) pCol->affinity = aff; |
| 134264 | pColl = sqlite3ExprCollSeq(pParse, p); | 135446 | pColl = sqlite3ExprCollSeq(pParse, p); |
| 134265 | if( pColl && pCol->zColl==0 ){ | 135447 | if( pColl ){ |
| 134266 | pCol->zColl = sqlite3DbStrDup(db, pColl->zName); | 135448 | assert( pTab->pIndex==0 ); |
| 135449 | sqlite3ColumnSetColl(db, pCol, pColl->zName); | ||
| 134267 | } | 135450 | } |
| 134268 | } | 135451 | } |
| 134269 | pTab->szTabRow = 1; /* Any non-zero value works */ | 135452 | pTab->szTabRow = 1; /* Any non-zero value works */ |
| @@ -134427,7 +135610,7 @@ static CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){ | |||
| 134427 | */ | 135610 | */ |
| 134428 | static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){ | 135611 | static KeyInfo *multiSelectOrderByKeyInfo(Parse *pParse, Select *p, int nExtra){ |
| 134429 | ExprList *pOrderBy = p->pOrderBy; | 135612 | ExprList *pOrderBy = p->pOrderBy; |
| 134430 | int nOrderBy = p->pOrderBy->nExpr; | 135613 | int nOrderBy = ALWAYS(pOrderBy!=0) ? pOrderBy->nExpr : 0; |
| 134431 | sqlite3 *db = pParse->db; | 135614 | sqlite3 *db = pParse->db; |
| 134432 | KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1); | 135615 | KeyInfo *pRet = sqlite3KeyInfoAlloc(db, nOrderBy+nExtra, 1); |
| 134433 | if( pRet ){ | 135616 | if( pRet ){ |
| @@ -134499,7 +135682,7 @@ static void generateWithRecursiveQuery( | |||
| 134499 | SrcList *pSrc = p->pSrc; /* The FROM clause of the recursive query */ | 135682 | SrcList *pSrc = p->pSrc; /* The FROM clause of the recursive query */ |
| 134500 | int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */ | 135683 | int nCol = p->pEList->nExpr; /* Number of columns in the recursive table */ |
| 134501 | Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */ | 135684 | Vdbe *v = pParse->pVdbe; /* The prepared statement under construction */ |
| 134502 | Select *pSetup = p->pPrior; /* The setup query */ | 135685 | Select *pSetup; /* The setup query */ |
| 134503 | Select *pFirstRec; /* Left-most recursive term */ | 135686 | Select *pFirstRec; /* Left-most recursive term */ |
| 134504 | int addrTop; /* Top of the loop */ | 135687 | int addrTop; /* Top of the loop */ |
| 134505 | int addrCont, addrBreak; /* CONTINUE and BREAK addresses */ | 135688 | int addrCont, addrBreak; /* CONTINUE and BREAK addresses */ |
| @@ -134583,7 +135766,6 @@ static void generateWithRecursiveQuery( | |||
| 134583 | ** iDistinct table. pFirstRec is left pointing to the left-most | 135766 | ** iDistinct table. pFirstRec is left pointing to the left-most |
| 134584 | ** recursive term of the CTE. | 135767 | ** recursive term of the CTE. |
| 134585 | */ | 135768 | */ |
| 134586 | pFirstRec = p; | ||
| 134587 | for(pFirstRec=p; ALWAYS(pFirstRec!=0); pFirstRec=pFirstRec->pPrior){ | 135769 | for(pFirstRec=p; ALWAYS(pFirstRec!=0); pFirstRec=pFirstRec->pPrior){ |
| 134588 | if( pFirstRec->selFlags & SF_Aggregate ){ | 135770 | if( pFirstRec->selFlags & SF_Aggregate ){ |
| 134589 | sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported"); | 135771 | sqlite3ErrorMsg(pParse, "recursive aggregate queries not supported"); |
| @@ -135049,6 +136231,7 @@ static int multiSelect( | |||
| 135049 | int nCol; /* Number of columns in result set */ | 136231 | int nCol; /* Number of columns in result set */ |
| 135050 | 136232 | ||
| 135051 | assert( p->pNext==0 ); | 136233 | assert( p->pNext==0 ); |
| 136234 | assert( p->pEList!=0 ); | ||
| 135052 | nCol = p->pEList->nExpr; | 136235 | nCol = p->pEList->nExpr; |
| 135053 | pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1); | 136236 | pKeyInfo = sqlite3KeyInfoAlloc(db, nCol, 1); |
| 135054 | if( !pKeyInfo ){ | 136237 | if( !pKeyInfo ){ |
| @@ -135083,7 +136266,11 @@ static int multiSelect( | |||
| 135083 | multi_select_end: | 136266 | multi_select_end: |
| 135084 | pDest->iSdst = dest.iSdst; | 136267 | pDest->iSdst = dest.iSdst; |
| 135085 | pDest->nSdst = dest.nSdst; | 136268 | pDest->nSdst = dest.nSdst; |
| 135086 | sqlite3SelectDelete(db, pDelete); | 136269 | if( pDelete ){ |
| 136270 | sqlite3ParserAddCleanup(pParse, | ||
| 136271 | (void(*)(sqlite3*,void*))sqlite3SelectDelete, | ||
| 136272 | pDelete); | ||
| 136273 | } | ||
| 135087 | return rc; | 136274 | return rc; |
| 135088 | } | 136275 | } |
| 135089 | #endif /* SQLITE_OMIT_COMPOUND_SELECT */ | 136276 | #endif /* SQLITE_OMIT_COMPOUND_SELECT */ |
| @@ -135396,6 +136583,7 @@ static int multiSelectOrderBy( | |||
| 135396 | for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){ | 136583 | for(i=1; db->mallocFailed==0 && i<=p->pEList->nExpr; i++){ |
| 135397 | struct ExprList_item *pItem; | 136584 | struct ExprList_item *pItem; |
| 135398 | for(j=0, pItem=pOrderBy->a; j<nOrderBy; j++, pItem++){ | 136585 | for(j=0, pItem=pOrderBy->a; j<nOrderBy; j++, pItem++){ |
| 136586 | assert( pItem!=0 ); | ||
| 135399 | assert( pItem->u.x.iOrderByCol>0 ); | 136587 | assert( pItem->u.x.iOrderByCol>0 ); |
| 135400 | if( pItem->u.x.iOrderByCol==i ) break; | 136588 | if( pItem->u.x.iOrderByCol==i ) break; |
| 135401 | } | 136589 | } |
| @@ -135422,6 +136610,7 @@ static int multiSelectOrderBy( | |||
| 135422 | struct ExprList_item *pItem; | 136610 | struct ExprList_item *pItem; |
| 135423 | aPermute[0] = nOrderBy; | 136611 | aPermute[0] = nOrderBy; |
| 135424 | for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){ | 136612 | for(i=1, pItem=pOrderBy->a; i<=nOrderBy; i++, pItem++){ |
| 136613 | assert( pItem!=0 ); | ||
| 135425 | assert( pItem->u.x.iOrderByCol>0 ); | 136614 | assert( pItem->u.x.iOrderByCol>0 ); |
| 135426 | assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr ); | 136615 | assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr ); |
| 135427 | aPermute[i] = pItem->u.x.iOrderByCol - 1; | 136616 | aPermute[i] = pItem->u.x.iOrderByCol - 1; |
| @@ -135734,7 +136923,7 @@ static Expr *substExpr( | |||
| 135734 | } | 136923 | } |
| 135735 | pExpr->pLeft = substExpr(pSubst, pExpr->pLeft); | 136924 | pExpr->pLeft = substExpr(pSubst, pExpr->pLeft); |
| 135736 | pExpr->pRight = substExpr(pSubst, pExpr->pRight); | 136925 | pExpr->pRight = substExpr(pSubst, pExpr->pRight); |
| 135737 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 136926 | if( ExprUseXSelect(pExpr) ){ |
| 135738 | substSelect(pSubst, pExpr->x.pSelect, 1); | 136927 | substSelect(pSubst, pExpr->x.pSelect, 1); |
| 135739 | }else{ | 136928 | }else{ |
| 135740 | substExprList(pSubst, pExpr->x.pList); | 136929 | substExprList(pSubst, pExpr->x.pList); |
| @@ -135825,10 +137014,10 @@ static void recomputeColumnsUsed( | |||
| 135825 | ** new cursor number assigned, set an entry in the aCsrMap[] array | 137014 | ** new cursor number assigned, set an entry in the aCsrMap[] array |
| 135826 | ** to map the old cursor number to the new: | 137015 | ** to map the old cursor number to the new: |
| 135827 | ** | 137016 | ** |
| 135828 | ** aCsrMap[iOld] = iNew; | 137017 | ** aCsrMap[iOld+1] = iNew; |
| 135829 | ** | 137018 | ** |
| 135830 | ** The array is guaranteed by the caller to be large enough for all | 137019 | ** The array is guaranteed by the caller to be large enough for all |
| 135831 | ** existing cursor numbers in pSrc. | 137020 | ** existing cursor numbers in pSrc. aCsrMap[0] is the array size. |
| 135832 | ** | 137021 | ** |
| 135833 | ** If pSrc contains any sub-selects, call this routine recursively | 137022 | ** If pSrc contains any sub-selects, call this routine recursively |
| 135834 | ** on the FROM clause of each such sub-select, with iExcept set to -1. | 137023 | ** on the FROM clause of each such sub-select, with iExcept set to -1. |
| @@ -135844,10 +137033,11 @@ static void srclistRenumberCursors( | |||
| 135844 | for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){ | 137033 | for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){ |
| 135845 | if( i!=iExcept ){ | 137034 | if( i!=iExcept ){ |
| 135846 | Select *p; | 137035 | Select *p; |
| 135847 | if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor]==0 ){ | 137036 | assert( pItem->iCursor < aCsrMap[0] ); |
| 135848 | aCsrMap[pItem->iCursor] = pParse->nTab++; | 137037 | if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor+1]==0 ){ |
| 137038 | aCsrMap[pItem->iCursor+1] = pParse->nTab++; | ||
| 135849 | } | 137039 | } |
| 135850 | pItem->iCursor = aCsrMap[pItem->iCursor]; | 137040 | pItem->iCursor = aCsrMap[pItem->iCursor+1]; |
| 135851 | for(p=pItem->pSelect; p; p=p->pPrior){ | 137041 | for(p=pItem->pSelect; p; p=p->pPrior){ |
| 135852 | srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1); | 137042 | srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1); |
| 135853 | } | 137043 | } |
| @@ -135856,17 +137046,27 @@ static void srclistRenumberCursors( | |||
| 135856 | } | 137046 | } |
| 135857 | 137047 | ||
| 135858 | /* | 137048 | /* |
| 137049 | ** *piCursor is a cursor number. Change it if it needs to be mapped. | ||
| 137050 | */ | ||
| 137051 | static void renumberCursorDoMapping(Walker *pWalker, int *piCursor){ | ||
| 137052 | int *aCsrMap = pWalker->u.aiCol; | ||
| 137053 | int iCsr = *piCursor; | ||
| 137054 | if( iCsr < aCsrMap[0] && aCsrMap[iCsr+1]>0 ){ | ||
| 137055 | *piCursor = aCsrMap[iCsr+1]; | ||
| 137056 | } | ||
| 137057 | } | ||
| 137058 | |||
| 137059 | /* | ||
| 135859 | ** Expression walker callback used by renumberCursors() to update | 137060 | ** Expression walker callback used by renumberCursors() to update |
| 135860 | ** Expr objects to match newly assigned cursor numbers. | 137061 | ** Expr objects to match newly assigned cursor numbers. |
| 135861 | */ | 137062 | */ |
| 135862 | static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){ | 137063 | static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){ |
| 135863 | int *aCsrMap = pWalker->u.aiCol; | ||
| 135864 | int op = pExpr->op; | 137064 | int op = pExpr->op; |
| 135865 | if( (op==TK_COLUMN || op==TK_IF_NULL_ROW) && aCsrMap[pExpr->iTable] ){ | 137065 | if( op==TK_COLUMN || op==TK_IF_NULL_ROW ){ |
| 135866 | pExpr->iTable = aCsrMap[pExpr->iTable]; | 137066 | renumberCursorDoMapping(pWalker, &pExpr->iTable); |
| 135867 | } | 137067 | } |
| 135868 | if( ExprHasProperty(pExpr, EP_FromJoin) && aCsrMap[pExpr->iRightJoinTable] ){ | 137068 | if( ExprHasProperty(pExpr, EP_FromJoin) ){ |
| 135869 | pExpr->iRightJoinTable = aCsrMap[pExpr->iRightJoinTable]; | 137069 | renumberCursorDoMapping(pWalker, &pExpr->iRightJoinTable); |
| 135870 | } | 137070 | } |
| 135871 | return WRC_Continue; | 137071 | return WRC_Continue; |
| 135872 | } | 137072 | } |
| @@ -136210,7 +137410,8 @@ static int flattenSubquery( | |||
| 136210 | 137410 | ||
| 136211 | if( pSrc->nSrc>1 ){ | 137411 | if( pSrc->nSrc>1 ){ |
| 136212 | if( pParse->nSelect>500 ) return 0; | 137412 | if( pParse->nSelect>500 ) return 0; |
| 136213 | aCsrMap = sqlite3DbMallocZero(db, pParse->nTab*sizeof(int)); | 137413 | aCsrMap = sqlite3DbMallocZero(db, ((i64)pParse->nTab+1)*sizeof(int)); |
| 137414 | if( aCsrMap ) aCsrMap[0] = pParse->nTab; | ||
| 136214 | } | 137415 | } |
| 136215 | } | 137416 | } |
| 136216 | 137417 | ||
| @@ -136933,7 +138134,7 @@ static int pushDownWhereTerms( | |||
| 136933 | */ | 138134 | */ |
| 136934 | static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){ | 138135 | static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){ |
| 136935 | int eRet = WHERE_ORDERBY_NORMAL; /* Return value */ | 138136 | int eRet = WHERE_ORDERBY_NORMAL; /* Return value */ |
| 136936 | ExprList *pEList = pFunc->x.pList; /* Arguments to agg function */ | 138137 | ExprList *pEList; /* Arguments to agg function */ |
| 136937 | const char *zFunc; /* Name of aggregate function pFunc */ | 138138 | const char *zFunc; /* Name of aggregate function pFunc */ |
| 136938 | ExprList *pOrderBy; | 138139 | ExprList *pOrderBy; |
| 136939 | u8 sortFlags = 0; | 138140 | u8 sortFlags = 0; |
| @@ -136941,6 +138142,8 @@ static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){ | |||
| 136941 | assert( *ppMinMax==0 ); | 138142 | assert( *ppMinMax==0 ); |
| 136942 | assert( pFunc->op==TK_AGG_FUNCTION ); | 138143 | assert( pFunc->op==TK_AGG_FUNCTION ); |
| 136943 | assert( !IsWindowFunc(pFunc) ); | 138144 | assert( !IsWindowFunc(pFunc) ); |
| 138145 | assert( ExprUseXList(pFunc) ); | ||
| 138146 | pEList = pFunc->x.pList; | ||
| 136944 | if( pEList==0 | 138147 | if( pEList==0 |
| 136945 | || pEList->nExpr!=1 | 138148 | || pEList->nExpr!=1 |
| 136946 | || ExprHasProperty(pFunc, EP_WinFunc) | 138149 | || ExprHasProperty(pFunc, EP_WinFunc) |
| @@ -136948,6 +138151,7 @@ static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){ | |||
| 136948 | ){ | 138151 | ){ |
| 136949 | return eRet; | 138152 | return eRet; |
| 136950 | } | 138153 | } |
| 138154 | assert( !ExprHasProperty(pFunc, EP_IntValue) ); | ||
| 136951 | zFunc = pFunc->u.zToken; | 138155 | zFunc = pFunc->u.zToken; |
| 136952 | if( sqlite3StrICmp(zFunc, "min")==0 ){ | 138156 | if( sqlite3StrICmp(zFunc, "min")==0 ){ |
| 136953 | eRet = WHERE_ORDERBY_MIN; | 138157 | eRet = WHERE_ORDERBY_MIN; |
| @@ -136975,7 +138179,13 @@ static u8 minMaxQuery(sqlite3 *db, Expr *pFunc, ExprList **ppMinMax){ | |||
| 136975 | ** | 138179 | ** |
| 136976 | ** where table is a database table, not a sub-select or view. If the query | 138180 | ** where table is a database table, not a sub-select or view. If the query |
| 136977 | ** does match this pattern, then a pointer to the Table object representing | 138181 | ** does match this pattern, then a pointer to the Table object representing |
| 136978 | ** <tbl> is returned. Otherwise, 0 is returned. | 138182 | ** <tbl> is returned. Otherwise, NULL is returned. |
| 138183 | ** | ||
| 138184 | ** This routine checks to see if it is safe to use the count optimization. | ||
| 138185 | ** A correct answer is still obtained (though perhaps more slowly) if | ||
| 138186 | ** this routine returns NULL when it could have returned a table pointer. | ||
| 138187 | ** But returning the pointer when NULL should have been returned can | ||
| 138188 | ** result in incorrect answers and/or crashes. So, when in doubt, return NULL. | ||
| 136979 | */ | 138189 | */ |
| 136980 | static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ | 138190 | static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ |
| 136981 | Table *pTab; | 138191 | Table *pTab; |
| @@ -136983,19 +138193,26 @@ static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){ | |||
| 136983 | 138193 | ||
| 136984 | assert( !p->pGroupBy ); | 138194 | assert( !p->pGroupBy ); |
| 136985 | 138195 | ||
| 136986 | if( p->pWhere || p->pEList->nExpr!=1 | 138196 | if( p->pWhere |
| 136987 | || p->pSrc->nSrc!=1 || p->pSrc->a[0].pSelect | 138197 | || p->pEList->nExpr!=1 |
| 138198 | || p->pSrc->nSrc!=1 | ||
| 138199 | || p->pSrc->a[0].pSelect | ||
| 138200 | || pAggInfo->nFunc!=1 | ||
| 136988 | ){ | 138201 | ){ |
| 136989 | return 0; | 138202 | return 0; |
| 136990 | } | 138203 | } |
| 136991 | pTab = p->pSrc->a[0].pTab; | 138204 | pTab = p->pSrc->a[0].pTab; |
| 138205 | assert( pTab!=0 ); | ||
| 138206 | assert( !IsView(pTab) ); | ||
| 138207 | if( !IsOrdinaryTable(pTab) ) return 0; | ||
| 136992 | pExpr = p->pEList->a[0].pExpr; | 138208 | pExpr = p->pEList->a[0].pExpr; |
| 136993 | assert( pTab && !pTab->pSelect && pExpr ); | 138209 | assert( pExpr!=0 ); |
| 136994 | |||
| 136995 | if( IsVirtual(pTab) ) return 0; | ||
| 136996 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; | 138210 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; |
| 136997 | if( NEVER(pAggInfo->nFunc==0) ) return 0; | 138211 | if( pExpr->pAggInfo!=pAggInfo ) return 0; |
| 136998 | if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0; | 138212 | if( (pAggInfo->aFunc[0].pFunc->funcFlags&SQLITE_FUNC_COUNT)==0 ) return 0; |
| 138213 | assert( pAggInfo->aFunc[0].pFExpr==pExpr ); | ||
| 138214 | testcase( ExprHasProperty(pExpr, EP_Distinct) ); | ||
| 138215 | testcase( ExprHasProperty(pExpr, EP_WinFunc) ); | ||
| 136999 | if( ExprHasProperty(pExpr, EP_Distinct|EP_WinFunc) ) return 0; | 138216 | if( ExprHasProperty(pExpr, EP_Distinct|EP_WinFunc) ) return 0; |
| 137000 | 138217 | ||
| 137001 | return pTab; | 138218 | return pTab; |
| @@ -137024,6 +138241,7 @@ SQLITE_PRIVATE int sqlite3IndexedByLookup(Parse *pParse, SrcItem *pFrom){ | |||
| 137024 | pParse->checkSchema = 1; | 138241 | pParse->checkSchema = 1; |
| 137025 | return SQLITE_ERROR; | 138242 | return SQLITE_ERROR; |
| 137026 | } | 138243 | } |
| 138244 | assert( pFrom->fg.isCte==0 ); | ||
| 137027 | pFrom->u2.pIBIndex = pIdx; | 138245 | pFrom->u2.pIBIndex = pIdx; |
| 137028 | return SQLITE_OK; | 138246 | return SQLITE_OK; |
| 137029 | } | 138247 | } |
| @@ -137281,6 +138499,10 @@ static int resolveFromTermToCte( | |||
| 137281 | if( db->mallocFailed ) return 2; | 138499 | if( db->mallocFailed ) return 2; |
| 137282 | pFrom->pSelect->selFlags |= SF_CopyCte; | 138500 | pFrom->pSelect->selFlags |= SF_CopyCte; |
| 137283 | assert( pFrom->pSelect ); | 138501 | assert( pFrom->pSelect ); |
| 138502 | if( pFrom->fg.isIndexedBy ){ | ||
| 138503 | sqlite3ErrorMsg(pParse, "no such index: \"%s\"", pFrom->u1.zIndexedBy); | ||
| 138504 | return 2; | ||
| 138505 | } | ||
| 137284 | pFrom->fg.isCte = 1; | 138506 | pFrom->fg.isCte = 1; |
| 137285 | pFrom->u2.pCteUse = pCteUse; | 138507 | pFrom->u2.pCteUse = pCteUse; |
| 137286 | pCteUse->nUse++; | 138508 | pCteUse->nUse++; |
| @@ -137535,30 +138757,31 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 137535 | return WRC_Abort; | 138757 | return WRC_Abort; |
| 137536 | } | 138758 | } |
| 137537 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) | 138759 | #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 137538 | if( IsVirtual(pTab) || pTab->pSelect ){ | 138760 | if( !IsOrdinaryTable(pTab) ){ |
| 137539 | i16 nCol; | 138761 | i16 nCol; |
| 137540 | u8 eCodeOrig = pWalker->eCode; | 138762 | u8 eCodeOrig = pWalker->eCode; |
| 137541 | if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort; | 138763 | if( sqlite3ViewGetColumnNames(pParse, pTab) ) return WRC_Abort; |
| 137542 | assert( pFrom->pSelect==0 ); | 138764 | assert( pFrom->pSelect==0 ); |
| 137543 | if( pTab->pSelect | 138765 | if( IsView(pTab) ){ |
| 137544 | && (db->flags & SQLITE_EnableView)==0 | 138766 | if( (db->flags & SQLITE_EnableView)==0 |
| 137545 | && pTab->pSchema!=db->aDb[1].pSchema | 138767 | && pTab->pSchema!=db->aDb[1].pSchema |
| 137546 | ){ | 138768 | ){ |
| 137547 | sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", | 138769 | sqlite3ErrorMsg(pParse, "access to view \"%s\" prohibited", |
| 137548 | pTab->zName); | 138770 | pTab->zName); |
| 138771 | } | ||
| 138772 | pFrom->pSelect = sqlite3SelectDup(db, pTab->u.view.pSelect, 0); | ||
| 137549 | } | 138773 | } |
| 137550 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 138774 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| 137551 | assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 ); | 138775 | else if( ALWAYS(IsVirtual(pTab)) |
| 137552 | if( IsVirtual(pTab) | ||
| 137553 | && pFrom->fg.fromDDL | 138776 | && pFrom->fg.fromDDL |
| 137554 | && ALWAYS(pTab->pVTable!=0) | 138777 | && ALWAYS(pTab->u.vtab.p!=0) |
| 137555 | && pTab->pVTable->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0) | 138778 | && pTab->u.vtab.p->eVtabRisk > ((db->flags & SQLITE_TrustedSchema)!=0) |
| 137556 | ){ | 138779 | ){ |
| 137557 | sqlite3ErrorMsg(pParse, "unsafe use of virtual table \"%s\"", | 138780 | sqlite3ErrorMsg(pParse, "unsafe use of virtual table \"%s\"", |
| 137558 | pTab->zName); | 138781 | pTab->zName); |
| 137559 | } | 138782 | } |
| 138783 | assert( SQLITE_VTABRISK_Normal==1 && SQLITE_VTABRISK_High==2 ); | ||
| 137560 | #endif | 138784 | #endif |
| 137561 | pFrom->pSelect = sqlite3SelectDup(db, pTab->pSelect, 0); | ||
| 137562 | nCol = pTab->nCol; | 138785 | nCol = pTab->nCol; |
| 137563 | pTab->nCol = -1; | 138786 | pTab->nCol = -1; |
| 137564 | pWalker->eCode = 1; /* Turn on Select.selId renumbering */ | 138787 | pWalker->eCode = 1; /* Turn on Select.selId renumbering */ |
| @@ -137658,7 +138881,7 @@ static int selectExpander(Walker *pWalker, Select *p){ | |||
| 137658 | zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : "*"; | 138881 | zSchemaName = iDb>=0 ? db->aDb[iDb].zDbSName : "*"; |
| 137659 | } | 138882 | } |
| 137660 | for(j=0; j<pTab->nCol; j++){ | 138883 | for(j=0; j<pTab->nCol; j++){ |
| 137661 | char *zName = pTab->aCol[j].zName; | 138884 | char *zName = pTab->aCol[j].zCnName; |
| 137662 | char *zColname; /* The computed column name */ | 138885 | char *zColname; /* The computed column name */ |
| 137663 | char *zToFree; /* Malloced string that needs to be freed */ | 138886 | char *zToFree; /* Malloced string that needs to be freed */ |
| 137664 | Token sColname; /* Computed column name as a token */ | 138887 | Token sColname; /* Computed column name as a token */ |
| @@ -137915,7 +139138,7 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){ | |||
| 137915 | for(pFunc=pAggInfo->aFunc, i=0; i<pAggInfo->nFunc; i++, pFunc++){ | 139138 | for(pFunc=pAggInfo->aFunc, i=0; i<pAggInfo->nFunc; i++, pFunc++){ |
| 137916 | if( pFunc->iDistinct>=0 ){ | 139139 | if( pFunc->iDistinct>=0 ){ |
| 137917 | Expr *pE = pFunc->pFExpr; | 139140 | Expr *pE = pFunc->pFExpr; |
| 137918 | assert( !ExprHasProperty(pE, EP_xIsSelect) ); | 139141 | assert( ExprUseXList(pE) ); |
| 137919 | if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){ | 139142 | if( pE->x.pList==0 || pE->x.pList->nExpr!=1 ){ |
| 137920 | sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one " | 139143 | sqlite3ErrorMsg(pParse, "DISTINCT aggregates must have exactly one " |
| 137921 | "argument"); | 139144 | "argument"); |
| @@ -137940,8 +139163,9 @@ static void finalizeAggFunctions(Parse *pParse, AggInfo *pAggInfo){ | |||
| 137940 | int i; | 139163 | int i; |
| 137941 | struct AggInfo_func *pF; | 139164 | struct AggInfo_func *pF; |
| 137942 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){ | 139165 | for(i=0, pF=pAggInfo->aFunc; i<pAggInfo->nFunc; i++, pF++){ |
| 137943 | ExprList *pList = pF->pFExpr->x.pList; | 139166 | ExprList *pList; |
| 137944 | assert( !ExprHasProperty(pF->pFExpr, EP_xIsSelect) ); | 139167 | assert( ExprUseXList(pF->pFExpr) ); |
| 139168 | pList = pF->pFExpr->x.pList; | ||
| 137945 | sqlite3VdbeAddOp2(v, OP_AggFinal, pF->iMem, pList ? pList->nExpr : 0); | 139169 | sqlite3VdbeAddOp2(v, OP_AggFinal, pF->iMem, pList ? pList->nExpr : 0); |
| 137946 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); | 139170 | sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
| 137947 | } | 139171 | } |
| @@ -137975,9 +139199,10 @@ static void updateAccumulator( | |||
| 137975 | int nArg; | 139199 | int nArg; |
| 137976 | int addrNext = 0; | 139200 | int addrNext = 0; |
| 137977 | int regAgg; | 139201 | int regAgg; |
| 137978 | ExprList *pList = pF->pFExpr->x.pList; | 139202 | ExprList *pList; |
| 137979 | assert( !ExprHasProperty(pF->pFExpr, EP_xIsSelect) ); | 139203 | assert( ExprUseXList(pF->pFExpr) ); |
| 137980 | assert( !IsWindowFunc(pF->pFExpr) ); | 139204 | assert( !IsWindowFunc(pF->pFExpr) ); |
| 139205 | pList = pF->pFExpr->x.pList; | ||
| 137981 | if( ExprHasProperty(pF->pFExpr, EP_WinFunc) ){ | 139206 | if( ExprHasProperty(pF->pFExpr, EP_WinFunc) ){ |
| 137982 | Expr *pFilter = pF->pFExpr->y.pWin->pFilter; | 139207 | Expr *pFilter = pF->pFExpr->y.pWin->pFilter; |
| 137983 | if( pAggInfo->nAccumulator | 139208 | if( pAggInfo->nAccumulator |
| @@ -138090,8 +139315,16 @@ static void explainSimpleCount( | |||
| 138090 | static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){ | 139315 | static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){ |
| 138091 | if( pExpr->op!=TK_AND ){ | 139316 | if( pExpr->op!=TK_AND ){ |
| 138092 | Select *pS = pWalker->u.pSelect; | 139317 | Select *pS = pWalker->u.pSelect; |
| 139318 | /* This routine is called before the HAVING clause of the current | ||
| 139319 | ** SELECT is analyzed for aggregates. So if pExpr->pAggInfo is set | ||
| 139320 | ** here, it indicates that the expression is a correlated reference to a | ||
| 139321 | ** column from an outer aggregate query, or an aggregate function that | ||
| 139322 | ** belongs to an outer query. Do not move the expression to the WHERE | ||
| 139323 | ** clause in this obscure case, as doing so may corrupt the outer Select | ||
| 139324 | ** statements AggInfo structure. */ | ||
| 138093 | if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy) | 139325 | if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy) |
| 138094 | && ExprAlwaysFalse(pExpr)==0 | 139326 | && ExprAlwaysFalse(pExpr)==0 |
| 139327 | && pExpr->pAggInfo==0 | ||
| 138095 | ){ | 139328 | ){ |
| 138096 | sqlite3 *db = pWalker->pParse->db; | 139329 | sqlite3 *db = pWalker->pParse->db; |
| 138097 | Expr *pNew = sqlite3Expr(db, TK_INTEGER, "1"); | 139330 | Expr *pNew = sqlite3Expr(db, TK_INTEGER, "1"); |
| @@ -138215,7 +139448,9 @@ static int countOfViewOptimization(Parse *pParse, Select *p){ | |||
| 138215 | if( p->pGroupBy ) return 0; | 139448 | if( p->pGroupBy ) return 0; |
| 138216 | pExpr = p->pEList->a[0].pExpr; | 139449 | pExpr = p->pEList->a[0].pExpr; |
| 138217 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */ | 139450 | if( pExpr->op!=TK_AGG_FUNCTION ) return 0; /* Result is an aggregate */ |
| 139451 | assert( ExprUseUToken(pExpr) ); | ||
| 138218 | if( sqlite3_stricmp(pExpr->u.zToken,"count") ) return 0; /* Is count() */ | 139452 | if( sqlite3_stricmp(pExpr->u.zToken,"count") ) return 0; /* Is count() */ |
| 139453 | assert( ExprUseXList(pExpr) ); | ||
| 138219 | if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */ | 139454 | if( pExpr->x.pList!=0 ) return 0; /* Must be count(*) */ |
| 138220 | if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */ | 139455 | if( p->pSrc->nSrc!=1 ) return 0; /* One table in FROM */ |
| 138221 | pSub = p->pSrc->a[0].pSelect; | 139456 | pSub = p->pSrc->a[0].pSelect; |
| @@ -138357,11 +139592,16 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138357 | } | 139592 | } |
| 138358 | #endif | 139593 | #endif |
| 138359 | 139594 | ||
| 138360 | /* If the SF_UpdateFrom flag is set, then this function is being called | 139595 | /* If the SF_UFSrcCheck flag is set, then this function is being called |
| 138361 | ** as part of populating the temp table for an UPDATE...FROM statement. | 139596 | ** as part of populating the temp table for an UPDATE...FROM statement. |
| 138362 | ** In this case, it is an error if the target object (pSrc->a[0]) name | 139597 | ** In this case, it is an error if the target object (pSrc->a[0]) name |
| 138363 | ** or alias is duplicated within FROM clause (pSrc->a[1..n]). */ | 139598 | ** or alias is duplicated within FROM clause (pSrc->a[1..n]). |
| 138364 | if( p->selFlags & SF_UpdateFrom ){ | 139599 | ** |
| 139600 | ** Postgres disallows this case too. The reason is that some other | ||
| 139601 | ** systems handle this case differently, and not all the same way, | ||
| 139602 | ** which is just confusing. To avoid this, we follow PG's lead and | ||
| 139603 | ** disallow it altogether. */ | ||
| 139604 | if( p->selFlags & SF_UFSrcCheck ){ | ||
| 138365 | SrcItem *p0 = &p->pSrc->a[0]; | 139605 | SrcItem *p0 = &p->pSrc->a[0]; |
| 138366 | for(i=1; i<p->pSrc->nSrc; i++){ | 139606 | for(i=1; i<p->pSrc->nSrc; i++){ |
| 138367 | SrcItem *p1 = &p->pSrc->a[i]; | 139607 | SrcItem *p1 = &p->pSrc->a[i]; |
| @@ -138373,6 +139613,12 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138373 | goto select_end; | 139613 | goto select_end; |
| 138374 | } | 139614 | } |
| 138375 | } | 139615 | } |
| 139616 | |||
| 139617 | /* Clear the SF_UFSrcCheck flag. The check has already been performed, | ||
| 139618 | ** and leaving this flag set can cause errors if a compound sub-query | ||
| 139619 | ** in p->pSrc is flattened into this query and this function called | ||
| 139620 | ** again as part of compound SELECT processing. */ | ||
| 139621 | p->selFlags &= ~SF_UFSrcCheck; | ||
| 138376 | } | 139622 | } |
| 138377 | 139623 | ||
| 138378 | if( pDest->eDest==SRT_Output ){ | 139624 | if( pDest->eDest==SRT_Output ){ |
| @@ -138444,6 +139690,39 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138444 | if( (pSub->selFlags & SF_Aggregate)!=0 ) continue; | 139690 | if( (pSub->selFlags & SF_Aggregate)!=0 ) continue; |
| 138445 | assert( pSub->pGroupBy==0 ); | 139691 | assert( pSub->pGroupBy==0 ); |
| 138446 | 139692 | ||
| 139693 | /* If a FROM-clause subquery has an ORDER BY clause that is not | ||
| 139694 | ** really doing anything, then delete it now so that it does not | ||
| 139695 | ** interfere with query flattening. See the discussion at | ||
| 139696 | ** https://sqlite.org/forum/forumpost/2d76f2bcf65d256a | ||
| 139697 | ** | ||
| 139698 | ** Beware of these cases where the ORDER BY clause may not be safely | ||
| 139699 | ** omitted: | ||
| 139700 | ** | ||
| 139701 | ** (1) There is also a LIMIT clause | ||
| 139702 | ** (2) The subquery was added to help with window-function | ||
| 139703 | ** processing | ||
| 139704 | ** (3) The subquery is in the FROM clause of an UPDATE | ||
| 139705 | ** (4) The outer query uses an aggregate function other than | ||
| 139706 | ** the built-in count(), min(), or max(). | ||
| 139707 | ** (5) The ORDER BY isn't going to accomplish anything because | ||
| 139708 | ** one of: | ||
| 139709 | ** (a) The outer query has a different ORDER BY clause | ||
| 139710 | ** (b) The subquery is part of a join | ||
| 139711 | ** See forum post 062d576715d277c8 | ||
| 139712 | */ | ||
| 139713 | if( pSub->pOrderBy!=0 | ||
| 139714 | && (p->pOrderBy!=0 || pTabList->nSrc>1) /* Condition (5) */ | ||
| 139715 | && pSub->pLimit==0 /* Condition (1) */ | ||
| 139716 | && (pSub->selFlags & SF_OrderByReqd)==0 /* Condition (2) */ | ||
| 139717 | && (p->selFlags & SF_OrderByReqd)==0 /* Condition (3) and (4) */ | ||
| 139718 | && OptimizationEnabled(db, SQLITE_OmitOrderBy) | ||
| 139719 | ){ | ||
| 139720 | SELECTTRACE(0x100,pParse,p, | ||
| 139721 | ("omit superfluous ORDER BY on %r FROM-clause subquery\n",i+1)); | ||
| 139722 | sqlite3ExprListDelete(db, pSub->pOrderBy); | ||
| 139723 | pSub->pOrderBy = 0; | ||
| 139724 | } | ||
| 139725 | |||
| 138447 | /* If the outer query contains a "complex" result set (that is, | 139726 | /* If the outer query contains a "complex" result set (that is, |
| 138448 | ** if the result set of the outer query uses functions or subqueries) | 139727 | ** if the result set of the outer query uses functions or subqueries) |
| 138449 | ** and if the subquery contains an ORDER BY clause and if | 139728 | ** and if the subquery contains an ORDER BY clause and if |
| @@ -138586,7 +139865,8 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138586 | ** inside the subquery. This can help the subquery to run more efficiently. | 139865 | ** inside the subquery. This can help the subquery to run more efficiently. |
| 138587 | */ | 139866 | */ |
| 138588 | if( OptimizationEnabled(db, SQLITE_PushDown) | 139867 | if( OptimizationEnabled(db, SQLITE_PushDown) |
| 138589 | && (pItem->fg.isCte==0 || pItem->u2.pCteUse->eM10d!=M10d_Yes) | 139868 | && (pItem->fg.isCte==0 |
| 139869 | || (pItem->u2.pCteUse->eM10d!=M10d_Yes && pItem->u2.pCteUse->nUse<2)) | ||
| 138590 | && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor, | 139870 | && pushDownWhereTerms(pParse, pSub, p->pWhere, pItem->iCursor, |
| 138591 | (pItem->fg.jointype & JT_OUTER)!=0) | 139871 | (pItem->fg.jointype & JT_OUTER)!=0) |
| 138592 | ){ | 139872 | ){ |
| @@ -138647,6 +139927,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138647 | sqlite3VdbeAddOp2(v, OP_Gosub, pCteUse->regRtn, pCteUse->addrM9e); | 139927 | sqlite3VdbeAddOp2(v, OP_Gosub, pCteUse->regRtn, pCteUse->addrM9e); |
| 138648 | if( pItem->iCursor!=pCteUse->iCur ){ | 139928 | if( pItem->iCursor!=pCteUse->iCur ){ |
| 138649 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pCteUse->iCur); | 139929 | sqlite3VdbeAddOp2(v, OP_OpenDup, pItem->iCursor, pCteUse->iCur); |
| 139930 | VdbeComment((v, "%!S", pItem)); | ||
| 138650 | } | 139931 | } |
| 138651 | pSub->nSelectRow = pCteUse->nRowEst; | 139932 | pSub->nSelectRow = pCteUse->nRowEst; |
| 138652 | }else if( (pPrior = isSelfJoinView(pTabList, pItem))!=0 ){ | 139933 | }else if( (pPrior = isSelfJoinView(pTabList, pItem))!=0 ){ |
| @@ -138984,7 +140265,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 138984 | } | 140265 | } |
| 138985 | for(i=0; i<pAggInfo->nFunc; i++){ | 140266 | for(i=0; i<pAggInfo->nFunc; i++){ |
| 138986 | Expr *pExpr = pAggInfo->aFunc[i].pFExpr; | 140267 | Expr *pExpr = pAggInfo->aFunc[i].pFExpr; |
| 138987 | assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | 140268 | assert( ExprUseXList(pExpr) ); |
| 138988 | sNC.ncFlags |= NC_InAggFunc; | 140269 | sNC.ncFlags |= NC_InAggFunc; |
| 138989 | sqlite3ExprAnalyzeAggList(&sNC, pExpr->x.pList); | 140270 | sqlite3ExprAnalyzeAggList(&sNC, pExpr->x.pList); |
| 138990 | #ifndef SQLITE_OMIT_WINDOWFUNC | 140271 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| @@ -139039,7 +140320,9 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 139039 | 140320 | ||
| 139040 | if( pAggInfo->nFunc==1 | 140321 | if( pAggInfo->nFunc==1 |
| 139041 | && pAggInfo->aFunc[0].iDistinct>=0 | 140322 | && pAggInfo->aFunc[0].iDistinct>=0 |
| 139042 | && pAggInfo->aFunc[0].pFExpr->x.pList | 140323 | && ALWAYS(pAggInfo->aFunc[0].pFExpr!=0) |
| 140324 | && ALWAYS(ExprUseXList(pAggInfo->aFunc[0].pFExpr)) | ||
| 140325 | && pAggInfo->aFunc[0].pFExpr->x.pList!=0 | ||
| 139043 | ){ | 140326 | ){ |
| 139044 | Expr *pExpr = pAggInfo->aFunc[0].pFExpr->x.pList->a[0].pExpr; | 140327 | Expr *pExpr = pAggInfo->aFunc[0].pFExpr->x.pList->a[0].pExpr; |
| 139045 | pExpr = sqlite3ExprDup(db, pExpr, 0); | 140328 | pExpr = sqlite3ExprDup(db, pExpr, 0); |
| @@ -139360,6 +140643,7 @@ SQLITE_PRIVATE int sqlite3Select( | |||
| 139360 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regAcc); | 140643 | sqlite3VdbeAddOp2(v, OP_Integer, 0, regAcc); |
| 139361 | } | 140644 | } |
| 139362 | }else if( pAggInfo->nFunc==1 && pAggInfo->aFunc[0].iDistinct>=0 ){ | 140645 | }else if( pAggInfo->nFunc==1 && pAggInfo->aFunc[0].iDistinct>=0 ){ |
| 140646 | assert( ExprUseXList(pAggInfo->aFunc[0].pFExpr) ); | ||
| 139363 | pDistinct = pAggInfo->aFunc[0].pFExpr->x.pList; | 140647 | pDistinct = pAggInfo->aFunc[0].pFExpr->x.pList; |
| 139364 | distFlag = pDistinct ? (WHERE_WANT_DISTINCT|WHERE_AGG_DISTINCT) : 0; | 140648 | distFlag = pDistinct ? (WHERE_WANT_DISTINCT|WHERE_AGG_DISTINCT) : 0; |
| 139365 | } | 140649 | } |
| @@ -139891,12 +141175,12 @@ SQLITE_PRIVATE void sqlite3BeginTrigger( | |||
| 139891 | /* INSTEAD of triggers are only for views and views only support INSTEAD | 141175 | /* INSTEAD of triggers are only for views and views only support INSTEAD |
| 139892 | ** of triggers. | 141176 | ** of triggers. |
| 139893 | */ | 141177 | */ |
| 139894 | if( pTab->pSelect && tr_tm!=TK_INSTEAD ){ | 141178 | if( IsView(pTab) && tr_tm!=TK_INSTEAD ){ |
| 139895 | sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S", | 141179 | sqlite3ErrorMsg(pParse, "cannot create %s trigger on view: %S", |
| 139896 | (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName->a); | 141180 | (tr_tm == TK_BEFORE)?"BEFORE":"AFTER", pTableName->a); |
| 139897 | goto trigger_orphan_error; | 141181 | goto trigger_orphan_error; |
| 139898 | } | 141182 | } |
| 139899 | if( !pTab->pSelect && tr_tm==TK_INSTEAD ){ | 141183 | if( !IsView(pTab) && tr_tm==TK_INSTEAD ){ |
| 139900 | sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF" | 141184 | sqlite3ErrorMsg(pParse, "cannot create INSTEAD OF" |
| 139901 | " trigger on table: %S", pTableName->a); | 141185 | " trigger on table: %S", pTableName->a); |
| 139902 | goto trigger_orphan_error; | 141186 | goto trigger_orphan_error; |
| @@ -140033,7 +141317,7 @@ SQLITE_PRIVATE void sqlite3FinishTrigger( | |||
| 140033 | z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n); | 141317 | z = sqlite3DbStrNDup(db, (char*)pAll->z, pAll->n); |
| 140034 | testcase( z==0 ); | 141318 | testcase( z==0 ); |
| 140035 | sqlite3NestedParse(pParse, | 141319 | sqlite3NestedParse(pParse, |
| 140036 | "INSERT INTO %Q." DFLT_SCHEMA_TABLE | 141320 | "INSERT INTO %Q." LEGACY_SCHEMA_TABLE |
| 140037 | " VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')", | 141321 | " VALUES('trigger',%Q,%Q,0,'CREATE TRIGGER %q')", |
| 140038 | db->aDb[iDb].zDbSName, zName, | 141322 | db->aDb[iDb].zDbSName, zName, |
| 140039 | pTrig->table, z); | 141323 | pTrig->table, z); |
| @@ -140347,7 +141631,7 @@ SQLITE_PRIVATE void sqlite3DropTriggerPtr(Parse *pParse, Trigger *pTrigger){ | |||
| 140347 | */ | 141631 | */ |
| 140348 | if( (v = sqlite3GetVdbe(pParse))!=0 ){ | 141632 | if( (v = sqlite3GetVdbe(pParse))!=0 ){ |
| 140349 | sqlite3NestedParse(pParse, | 141633 | sqlite3NestedParse(pParse, |
| 140350 | "DELETE FROM %Q." DFLT_SCHEMA_TABLE " WHERE name=%Q AND type='trigger'", | 141634 | "DELETE FROM %Q." LEGACY_SCHEMA_TABLE " WHERE name=%Q AND type='trigger'", |
| 140351 | db->aDb[iDb].zDbSName, pTrigger->zName | 141635 | db->aDb[iDb].zDbSName, pTrigger->zName |
| 140352 | ); | 141636 | ); |
| 140353 | sqlite3ChangeCookie(pParse, iDb); | 141637 | sqlite3ChangeCookie(pParse, iDb); |
| @@ -140549,11 +141833,11 @@ static ExprList *sqlite3ExpandReturning( | |||
| 140549 | for(jj=0; jj<pTab->nCol; jj++){ | 141833 | for(jj=0; jj<pTab->nCol; jj++){ |
| 140550 | Expr *pNewExpr; | 141834 | Expr *pNewExpr; |
| 140551 | if( IsHiddenColumn(pTab->aCol+jj) ) continue; | 141835 | if( IsHiddenColumn(pTab->aCol+jj) ) continue; |
| 140552 | pNewExpr = sqlite3Expr(db, TK_ID, pTab->aCol[jj].zName); | 141836 | pNewExpr = sqlite3Expr(db, TK_ID, pTab->aCol[jj].zCnName); |
| 140553 | pNew = sqlite3ExprListAppend(pParse, pNew, pNewExpr); | 141837 | pNew = sqlite3ExprListAppend(pParse, pNew, pNewExpr); |
| 140554 | if( !db->mallocFailed ){ | 141838 | if( !db->mallocFailed ){ |
| 140555 | struct ExprList_item *pItem = &pNew->a[pNew->nExpr-1]; | 141839 | struct ExprList_item *pItem = &pNew->a[pNew->nExpr-1]; |
| 140556 | pItem->zEName = sqlite3DbStrDup(db, pTab->aCol[jj].zName); | 141840 | pItem->zEName = sqlite3DbStrDup(db, pTab->aCol[jj].zCnName); |
| 140557 | pItem->eEName = ENAME_NAME; | 141841 | pItem->eEName = ENAME_NAME; |
| 140558 | } | 141842 | } |
| 140559 | } | 141843 | } |
| @@ -140598,6 +141882,7 @@ static void codeReturningTrigger( | |||
| 140598 | sSelect.pSrc = &sFrom; | 141882 | sSelect.pSrc = &sFrom; |
| 140599 | sFrom.nSrc = 1; | 141883 | sFrom.nSrc = 1; |
| 140600 | sFrom.a[0].pTab = pTab; | 141884 | sFrom.a[0].pTab = pTab; |
| 141885 | sFrom.a[0].iCursor = -1; | ||
| 140601 | sqlite3SelectPrep(pParse, &sSelect, 0); | 141886 | sqlite3SelectPrep(pParse, &sSelect, 0); |
| 140602 | if( db->mallocFailed==0 && pParse->nErr==0 ){ | 141887 | if( db->mallocFailed==0 && pParse->nErr==0 ){ |
| 140603 | sqlite3GenerateColumnNames(pParse, &sSelect); | 141888 | sqlite3GenerateColumnNames(pParse, &sSelect); |
| @@ -141153,13 +142438,14 @@ static void updateVirtualTable( | |||
| 141153 | */ | 142438 | */ |
| 141154 | SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){ | 142439 | SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){ |
| 141155 | assert( pTab!=0 ); | 142440 | assert( pTab!=0 ); |
| 141156 | if( !pTab->pSelect ){ | 142441 | if( !IsView(pTab) ){ |
| 141157 | sqlite3_value *pValue = 0; | 142442 | sqlite3_value *pValue = 0; |
| 141158 | u8 enc = ENC(sqlite3VdbeDb(v)); | 142443 | u8 enc = ENC(sqlite3VdbeDb(v)); |
| 141159 | Column *pCol = &pTab->aCol[i]; | 142444 | Column *pCol = &pTab->aCol[i]; |
| 141160 | VdbeComment((v, "%s.%s", pTab->zName, pCol->zName)); | 142445 | VdbeComment((v, "%s.%s", pTab->zName, pCol->zCnName)); |
| 141161 | assert( i<pTab->nCol ); | 142446 | assert( i<pTab->nCol ); |
| 141162 | sqlite3ValueFromExpr(sqlite3VdbeDb(v), pCol->pDflt, enc, | 142447 | sqlite3ValueFromExpr(sqlite3VdbeDb(v), |
| 142448 | sqlite3ColumnExpr(pTab,pCol), enc, | ||
| 141163 | pCol->affinity, &pValue); | 142449 | pCol->affinity, &pValue); |
| 141164 | if( pValue ){ | 142450 | if( pValue ){ |
| 141165 | sqlite3VdbeAppendP4(v, pValue, P4_MEM); | 142451 | sqlite3VdbeAppendP4(v, pValue, P4_MEM); |
| @@ -141329,7 +142615,7 @@ static void updateFromSelect( | |||
| 141329 | pList = sqlite3ExprListAppend(pParse, pList, pNew); | 142615 | pList = sqlite3ExprListAppend(pParse, pList, pNew); |
| 141330 | } | 142616 | } |
| 141331 | eDest = IsVirtual(pTab) ? SRT_Table : SRT_Upfrom; | 142617 | eDest = IsVirtual(pTab) ? SRT_Table : SRT_Upfrom; |
| 141332 | }else if( pTab->pSelect ){ | 142618 | }else if( IsView(pTab) ){ |
| 141333 | for(i=0; i<pTab->nCol; i++){ | 142619 | for(i=0; i<pTab->nCol; i++){ |
| 141334 | pList = sqlite3ExprListAppend(pParse, pList, exprRowColumn(pParse, i)); | 142620 | pList = sqlite3ExprListAppend(pParse, pList, exprRowColumn(pParse, i)); |
| 141335 | } | 142621 | } |
| @@ -141352,8 +142638,9 @@ static void updateFromSelect( | |||
| 141352 | } | 142638 | } |
| 141353 | } | 142639 | } |
| 141354 | pSelect = sqlite3SelectNew(pParse, pList, | 142640 | pSelect = sqlite3SelectNew(pParse, pList, |
| 141355 | pSrc, pWhere2, pGrp, 0, pOrderBy2, SF_UpdateFrom|SF_IncludeHidden, pLimit2 | 142641 | pSrc, pWhere2, pGrp, 0, pOrderBy2, SF_UFSrcCheck|SF_IncludeHidden, pLimit2 |
| 141356 | ); | 142642 | ); |
| 142643 | if( pSelect ) pSelect->selFlags |= SF_OrderByReqd; | ||
| 141357 | sqlite3SelectDestInit(&dest, eDest, iEph); | 142644 | sqlite3SelectDestInit(&dest, eDest, iEph); |
| 141358 | dest.iSDParm2 = (pPk ? pPk->nKeyCol : -1); | 142645 | dest.iSDParm2 = (pPk ? pPk->nKeyCol : -1); |
| 141359 | sqlite3Select(pParse, pSelect, &dest); | 142646 | sqlite3Select(pParse, pSelect, &dest); |
| @@ -141453,7 +142740,7 @@ SQLITE_PRIVATE void sqlite3Update( | |||
| 141453 | */ | 142740 | */ |
| 141454 | #ifndef SQLITE_OMIT_TRIGGER | 142741 | #ifndef SQLITE_OMIT_TRIGGER |
| 141455 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, &tmask); | 142742 | pTrigger = sqlite3TriggersExist(pParse, pTab, TK_UPDATE, pChanges, &tmask); |
| 141456 | isView = pTab->pSelect!=0; | 142743 | isView = IsView(pTab); |
| 141457 | assert( pTrigger || tmask==0 ); | 142744 | assert( pTrigger || tmask==0 ); |
| 141458 | #else | 142745 | #else |
| 141459 | # define pTrigger 0 | 142746 | # define pTrigger 0 |
| @@ -141542,13 +142829,16 @@ SQLITE_PRIVATE void sqlite3Update( | |||
| 141542 | */ | 142829 | */ |
| 141543 | chngRowid = chngPk = 0; | 142830 | chngRowid = chngPk = 0; |
| 141544 | for(i=0; i<pChanges->nExpr; i++){ | 142831 | for(i=0; i<pChanges->nExpr; i++){ |
| 142832 | u8 hCol = sqlite3StrIHash(pChanges->a[i].zEName); | ||
| 141545 | /* If this is an UPDATE with a FROM clause, do not resolve expressions | 142833 | /* If this is an UPDATE with a FROM clause, do not resolve expressions |
| 141546 | ** here. The call to sqlite3Select() below will do that. */ | 142834 | ** here. The call to sqlite3Select() below will do that. */ |
| 141547 | if( nChangeFrom==0 && sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){ | 142835 | if( nChangeFrom==0 && sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){ |
| 141548 | goto update_cleanup; | 142836 | goto update_cleanup; |
| 141549 | } | 142837 | } |
| 141550 | for(j=0; j<pTab->nCol; j++){ | 142838 | for(j=0; j<pTab->nCol; j++){ |
| 141551 | if( sqlite3StrICmp(pTab->aCol[j].zName, pChanges->a[i].zEName)==0 ){ | 142839 | if( pTab->aCol[j].hName==hCol |
| 142840 | && sqlite3StrICmp(pTab->aCol[j].zCnName, pChanges->a[i].zEName)==0 | ||
| 142841 | ){ | ||
| 141552 | if( j==pTab->iPKey ){ | 142842 | if( j==pTab->iPKey ){ |
| 141553 | chngRowid = 1; | 142843 | chngRowid = 1; |
| 141554 | pRowidExpr = pChanges->a[i].pExpr; | 142844 | pRowidExpr = pChanges->a[i].pExpr; |
| @@ -141562,7 +142852,7 @@ SQLITE_PRIVATE void sqlite3Update( | |||
| 141562 | testcase( pTab->aCol[j].colFlags & COLFLAG_STORED ); | 142852 | testcase( pTab->aCol[j].colFlags & COLFLAG_STORED ); |
| 141563 | sqlite3ErrorMsg(pParse, | 142853 | sqlite3ErrorMsg(pParse, |
| 141564 | "cannot UPDATE generated column \"%s\"", | 142854 | "cannot UPDATE generated column \"%s\"", |
| 141565 | pTab->aCol[j].zName); | 142855 | pTab->aCol[j].zCnName); |
| 141566 | goto update_cleanup; | 142856 | goto update_cleanup; |
| 141567 | } | 142857 | } |
| 141568 | #endif | 142858 | #endif |
| @@ -141586,7 +142876,7 @@ SQLITE_PRIVATE void sqlite3Update( | |||
| 141586 | { | 142876 | { |
| 141587 | int rc; | 142877 | int rc; |
| 141588 | rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName, | 142878 | rc = sqlite3AuthCheck(pParse, SQLITE_UPDATE, pTab->zName, |
| 141589 | j<0 ? "ROWID" : pTab->aCol[j].zName, | 142879 | j<0 ? "ROWID" : pTab->aCol[j].zCnName, |
| 141590 | db->aDb[iDb].zDbSName); | 142880 | db->aDb[iDb].zDbSName); |
| 141591 | if( rc==SQLITE_DENY ){ | 142881 | if( rc==SQLITE_DENY ){ |
| 141592 | goto update_cleanup; | 142882 | goto update_cleanup; |
| @@ -141618,8 +142908,10 @@ SQLITE_PRIVATE void sqlite3Update( | |||
| 141618 | for(i=0; i<pTab->nCol; i++){ | 142908 | for(i=0; i<pTab->nCol; i++){ |
| 141619 | if( aXRef[i]>=0 ) continue; | 142909 | if( aXRef[i]>=0 ) continue; |
| 141620 | if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 ) continue; | 142910 | if( (pTab->aCol[i].colFlags & COLFLAG_GENERATED)==0 ) continue; |
| 141621 | if( sqlite3ExprReferencesUpdatedColumn(pTab->aCol[i].pDflt, | 142911 | if( sqlite3ExprReferencesUpdatedColumn( |
| 141622 | aXRef, chngRowid) ){ | 142912 | sqlite3ColumnExpr(pTab, &pTab->aCol[i]), |
| 142913 | aXRef, chngRowid) | ||
| 142914 | ){ | ||
| 141623 | aXRef[i] = 99999; | 142915 | aXRef[i] = 99999; |
| 141624 | bProgress = 1; | 142916 | bProgress = 1; |
| 141625 | } | 142917 | } |
| @@ -142711,7 +144003,7 @@ SQLITE_PRIVATE void sqlite3UpsertDoUpdate( | |||
| 142711 | k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]); | 144003 | k = sqlite3TableColumnToIndex(pIdx, pPk->aiColumn[i]); |
| 142712 | sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i); | 144004 | sqlite3VdbeAddOp3(v, OP_Column, iCur, k, iPk+i); |
| 142713 | VdbeComment((v, "%s.%s", pIdx->zName, | 144005 | VdbeComment((v, "%s.%s", pIdx->zName, |
| 142714 | pTab->aCol[pPk->aiColumn[i]].zName)); | 144006 | pTab->aCol[pPk->aiColumn[i]].zCnName)); |
| 142715 | } | 144007 | } |
| 142716 | sqlite3VdbeVerifyAbortable(v, OE_Abort); | 144008 | sqlite3VdbeVerifyAbortable(v, OE_Abort); |
| 142717 | i = sqlite3VdbeAddOp4Int(v, OP_Found, iDataCur, 0, iPk, nPk); | 144009 | i = sqlite3VdbeAddOp4Int(v, OP_Found, iDataCur, 0, iPk, nPk); |
| @@ -142893,8 +144185,8 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3RunVacuum( | |||
| 142893 | Btree *pTemp; /* The temporary database we vacuum into */ | 144185 | Btree *pTemp; /* The temporary database we vacuum into */ |
| 142894 | u32 saved_mDbFlags; /* Saved value of db->mDbFlags */ | 144186 | u32 saved_mDbFlags; /* Saved value of db->mDbFlags */ |
| 142895 | u64 saved_flags; /* Saved value of db->flags */ | 144187 | u64 saved_flags; /* Saved value of db->flags */ |
| 142896 | int saved_nChange; /* Saved value of db->nChange */ | 144188 | i64 saved_nChange; /* Saved value of db->nChange */ |
| 142897 | int saved_nTotalChange; /* Saved value of db->nTotalChange */ | 144189 | i64 saved_nTotalChange; /* Saved value of db->nTotalChange */ |
| 142898 | u32 saved_openFlags; /* Saved value of db->openFlags */ | 144190 | u32 saved_openFlags; /* Saved value of db->openFlags */ |
| 142899 | u8 saved_mTrace; /* Saved trace settings */ | 144191 | u8 saved_mTrace; /* Saved trace settings */ |
| 142900 | Db *pDb = 0; /* Database to detach at end of vacuum */ | 144192 | Db *pDb = 0; /* Database to detach at end of vacuum */ |
| @@ -142992,7 +144284,9 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3RunVacuum( | |||
| 142992 | 144284 | ||
| 142993 | /* Do not attempt to change the page size for a WAL database */ | 144285 | /* Do not attempt to change the page size for a WAL database */ |
| 142994 | if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain)) | 144286 | if( sqlite3PagerGetJournalMode(sqlite3BtreePager(pMain)) |
| 142995 | ==PAGER_JOURNALMODE_WAL ){ | 144287 | ==PAGER_JOURNALMODE_WAL |
| 144288 | && pOut==0 | ||
| 144289 | ){ | ||
| 142996 | db->nextPagesize = 0; | 144290 | db->nextPagesize = 0; |
| 142997 | } | 144291 | } |
| 142998 | 144292 | ||
| @@ -143341,7 +144635,7 @@ SQLITE_PRIVATE void sqlite3VtabLock(VTable *pVTab){ | |||
| 143341 | SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){ | 144635 | SQLITE_PRIVATE VTable *sqlite3GetVTable(sqlite3 *db, Table *pTab){ |
| 143342 | VTable *pVtab; | 144636 | VTable *pVtab; |
| 143343 | assert( IsVirtual(pTab) ); | 144637 | assert( IsVirtual(pTab) ); |
| 143344 | for(pVtab=pTab->pVTable; pVtab && pVtab->db!=db; pVtab=pVtab->pNext); | 144638 | for(pVtab=pTab->u.vtab.p; pVtab && pVtab->db!=db; pVtab=pVtab->pNext); |
| 143345 | return pVtab; | 144639 | return pVtab; |
| 143346 | } | 144640 | } |
| 143347 | 144641 | ||
| @@ -143354,7 +144648,8 @@ SQLITE_PRIVATE void sqlite3VtabUnlock(VTable *pVTab){ | |||
| 143354 | 144648 | ||
| 143355 | assert( db ); | 144649 | assert( db ); |
| 143356 | assert( pVTab->nRef>0 ); | 144650 | assert( pVTab->nRef>0 ); |
| 143357 | assert( db->magic==SQLITE_MAGIC_OPEN || db->magic==SQLITE_MAGIC_ZOMBIE ); | 144651 | assert( db->eOpenState==SQLITE_STATE_OPEN |
| 144652 | || db->eOpenState==SQLITE_STATE_ZOMBIE ); | ||
| 143358 | 144653 | ||
| 143359 | pVTab->nRef--; | 144654 | pVTab->nRef--; |
| 143360 | if( pVTab->nRef==0 ){ | 144655 | if( pVTab->nRef==0 ){ |
| @@ -143369,21 +144664,24 @@ SQLITE_PRIVATE void sqlite3VtabUnlock(VTable *pVTab){ | |||
| 143369 | 144664 | ||
| 143370 | /* | 144665 | /* |
| 143371 | ** Table p is a virtual table. This function moves all elements in the | 144666 | ** Table p is a virtual table. This function moves all elements in the |
| 143372 | ** p->pVTable list to the sqlite3.pDisconnect lists of their associated | 144667 | ** p->u.vtab.p list to the sqlite3.pDisconnect lists of their associated |
| 143373 | ** database connections to be disconnected at the next opportunity. | 144668 | ** database connections to be disconnected at the next opportunity. |
| 143374 | ** Except, if argument db is not NULL, then the entry associated with | 144669 | ** Except, if argument db is not NULL, then the entry associated with |
| 143375 | ** connection db is left in the p->pVTable list. | 144670 | ** connection db is left in the p->u.vtab.p list. |
| 143376 | */ | 144671 | */ |
| 143377 | static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){ | 144672 | static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){ |
| 143378 | VTable *pRet = 0; | 144673 | VTable *pRet = 0; |
| 143379 | VTable *pVTable = p->pVTable; | 144674 | VTable *pVTable; |
| 143380 | p->pVTable = 0; | 144675 | |
| 144676 | assert( IsVirtual(p) ); | ||
| 144677 | pVTable = p->u.vtab.p; | ||
| 144678 | p->u.vtab.p = 0; | ||
| 143381 | 144679 | ||
| 143382 | /* Assert that the mutex (if any) associated with the BtShared database | 144680 | /* Assert that the mutex (if any) associated with the BtShared database |
| 143383 | ** that contains table p is held by the caller. See header comments | 144681 | ** that contains table p is held by the caller. See header comments |
| 143384 | ** above function sqlite3VtabUnlockList() for an explanation of why | 144682 | ** above function sqlite3VtabUnlockList() for an explanation of why |
| 143385 | ** this makes it safe to access the sqlite3.pDisconnect list of any | 144683 | ** this makes it safe to access the sqlite3.pDisconnect list of any |
| 143386 | ** database connection that may have an entry in the p->pVTable list. | 144684 | ** database connection that may have an entry in the p->u.vtab.p list. |
| 143387 | */ | 144685 | */ |
| 143388 | assert( db==0 || sqlite3SchemaMutexHeld(db, 0, p->pSchema) ); | 144686 | assert( db==0 || sqlite3SchemaMutexHeld(db, 0, p->pSchema) ); |
| 143389 | 144687 | ||
| @@ -143393,7 +144691,7 @@ static VTable *vtabDisconnectAll(sqlite3 *db, Table *p){ | |||
| 143393 | assert( db2 ); | 144691 | assert( db2 ); |
| 143394 | if( db2==db ){ | 144692 | if( db2==db ){ |
| 143395 | pRet = pVTable; | 144693 | pRet = pVTable; |
| 143396 | p->pVTable = pRet; | 144694 | p->u.vtab.p = pRet; |
| 143397 | pRet->pNext = 0; | 144695 | pRet->pNext = 0; |
| 143398 | }else{ | 144696 | }else{ |
| 143399 | pVTable->pNext = db2->pDisconnect; | 144697 | pVTable->pNext = db2->pDisconnect; |
| @@ -143421,7 +144719,7 @@ SQLITE_PRIVATE void sqlite3VtabDisconnect(sqlite3 *db, Table *p){ | |||
| 143421 | assert( sqlite3BtreeHoldsAllMutexes(db) ); | 144719 | assert( sqlite3BtreeHoldsAllMutexes(db) ); |
| 143422 | assert( sqlite3_mutex_held(db->mutex) ); | 144720 | assert( sqlite3_mutex_held(db->mutex) ); |
| 143423 | 144721 | ||
| 143424 | for(ppVTab=&p->pVTable; *ppVTab; ppVTab=&(*ppVTab)->pNext){ | 144722 | for(ppVTab=&p->u.vtab.p; *ppVTab; ppVTab=&(*ppVTab)->pNext){ |
| 143425 | if( (*ppVTab)->db==db ){ | 144723 | if( (*ppVTab)->db==db ){ |
| 143426 | VTable *pVTab = *ppVTab; | 144724 | VTable *pVTab = *ppVTab; |
| 143427 | *ppVTab = pVTab->pNext; | 144725 | *ppVTab = pVTab->pNext; |
| @@ -143484,37 +144782,41 @@ SQLITE_PRIVATE void sqlite3VtabUnlockList(sqlite3 *db){ | |||
| 143484 | ** database connection. | 144782 | ** database connection. |
| 143485 | */ | 144783 | */ |
| 143486 | SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){ | 144784 | SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){ |
| 144785 | assert( IsVirtual(p) ); | ||
| 143487 | if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p); | 144786 | if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p); |
| 143488 | if( p->azModuleArg ){ | 144787 | if( p->u.vtab.azArg ){ |
| 143489 | int i; | 144788 | int i; |
| 143490 | for(i=0; i<p->nModuleArg; i++){ | 144789 | for(i=0; i<p->u.vtab.nArg; i++){ |
| 143491 | if( i!=1 ) sqlite3DbFree(db, p->azModuleArg[i]); | 144790 | if( i!=1 ) sqlite3DbFree(db, p->u.vtab.azArg[i]); |
| 143492 | } | 144791 | } |
| 143493 | sqlite3DbFree(db, p->azModuleArg); | 144792 | sqlite3DbFree(db, p->u.vtab.azArg); |
| 143494 | } | 144793 | } |
| 143495 | } | 144794 | } |
| 143496 | 144795 | ||
| 143497 | /* | 144796 | /* |
| 143498 | ** Add a new module argument to pTable->azModuleArg[]. | 144797 | ** Add a new module argument to pTable->u.vtab.azArg[]. |
| 143499 | ** The string is not copied - the pointer is stored. The | 144798 | ** The string is not copied - the pointer is stored. The |
| 143500 | ** string will be freed automatically when the table is | 144799 | ** string will be freed automatically when the table is |
| 143501 | ** deleted. | 144800 | ** deleted. |
| 143502 | */ | 144801 | */ |
| 143503 | static void addModuleArgument(Parse *pParse, Table *pTable, char *zArg){ | 144802 | static void addModuleArgument(Parse *pParse, Table *pTable, char *zArg){ |
| 143504 | sqlite3_int64 nBytes = sizeof(char *)*(2+pTable->nModuleArg); | 144803 | sqlite3_int64 nBytes; |
| 143505 | char **azModuleArg; | 144804 | char **azModuleArg; |
| 143506 | sqlite3 *db = pParse->db; | 144805 | sqlite3 *db = pParse->db; |
| 143507 | if( pTable->nModuleArg+3>=db->aLimit[SQLITE_LIMIT_COLUMN] ){ | 144806 | |
| 144807 | assert( IsVirtual(pTable) ); | ||
| 144808 | nBytes = sizeof(char *)*(2+pTable->u.vtab.nArg); | ||
| 144809 | if( pTable->u.vtab.nArg+3>=db->aLimit[SQLITE_LIMIT_COLUMN] ){ | ||
| 143508 | sqlite3ErrorMsg(pParse, "too many columns on %s", pTable->zName); | 144810 | sqlite3ErrorMsg(pParse, "too many columns on %s", pTable->zName); |
| 143509 | } | 144811 | } |
| 143510 | azModuleArg = sqlite3DbRealloc(db, pTable->azModuleArg, nBytes); | 144812 | azModuleArg = sqlite3DbRealloc(db, pTable->u.vtab.azArg, nBytes); |
| 143511 | if( azModuleArg==0 ){ | 144813 | if( azModuleArg==0 ){ |
| 143512 | sqlite3DbFree(db, zArg); | 144814 | sqlite3DbFree(db, zArg); |
| 143513 | }else{ | 144815 | }else{ |
| 143514 | int i = pTable->nModuleArg++; | 144816 | int i = pTable->u.vtab.nArg++; |
| 143515 | azModuleArg[i] = zArg; | 144817 | azModuleArg[i] = zArg; |
| 143516 | azModuleArg[i+1] = 0; | 144818 | azModuleArg[i+1] = 0; |
| 143517 | pTable->azModuleArg = azModuleArg; | 144819 | pTable->u.vtab.azArg = azModuleArg; |
| 143518 | } | 144820 | } |
| 143519 | } | 144821 | } |
| 143520 | 144822 | ||
| @@ -143537,10 +144839,11 @@ SQLITE_PRIVATE void sqlite3VtabBeginParse( | |||
| 143537 | pTable = pParse->pNewTable; | 144839 | pTable = pParse->pNewTable; |
| 143538 | if( pTable==0 ) return; | 144840 | if( pTable==0 ) return; |
| 143539 | assert( 0==pTable->pIndex ); | 144841 | assert( 0==pTable->pIndex ); |
| 144842 | pTable->eTabType = TABTYP_VTAB; | ||
| 143540 | 144843 | ||
| 143541 | db = pParse->db; | 144844 | db = pParse->db; |
| 143542 | 144845 | ||
| 143543 | assert( pTable->nModuleArg==0 ); | 144846 | assert( pTable->u.vtab.nArg==0 ); |
| 143544 | addModuleArgument(pParse, pTable, sqlite3NameFromToken(db, pModuleName)); | 144847 | addModuleArgument(pParse, pTable, sqlite3NameFromToken(db, pModuleName)); |
| 143545 | addModuleArgument(pParse, pTable, 0); | 144848 | addModuleArgument(pParse, pTable, 0); |
| 143546 | addModuleArgument(pParse, pTable, sqlite3DbStrDup(db, pTable->zName)); | 144849 | addModuleArgument(pParse, pTable, sqlite3DbStrDup(db, pTable->zName)); |
| @@ -143557,11 +144860,11 @@ SQLITE_PRIVATE void sqlite3VtabBeginParse( | |||
| 143557 | ** sqlite_schema table, has already been made by sqlite3StartTable(). | 144860 | ** sqlite_schema table, has already been made by sqlite3StartTable(). |
| 143558 | ** The second call, to obtain permission to create the table, is made now. | 144861 | ** The second call, to obtain permission to create the table, is made now. |
| 143559 | */ | 144862 | */ |
| 143560 | if( pTable->azModuleArg ){ | 144863 | if( pTable->u.vtab.azArg ){ |
| 143561 | int iDb = sqlite3SchemaToIndex(db, pTable->pSchema); | 144864 | int iDb = sqlite3SchemaToIndex(db, pTable->pSchema); |
| 143562 | assert( iDb>=0 ); /* The database the table is being created in */ | 144865 | assert( iDb>=0 ); /* The database the table is being created in */ |
| 143563 | sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName, | 144866 | sqlite3AuthCheck(pParse, SQLITE_CREATE_VTABLE, pTable->zName, |
| 143564 | pTable->azModuleArg[0], pParse->db->aDb[iDb].zDbSName); | 144867 | pTable->u.vtab.azArg[0], pParse->db->aDb[iDb].zDbSName); |
| 143565 | } | 144868 | } |
| 143566 | #endif | 144869 | #endif |
| 143567 | } | 144870 | } |
| @@ -143589,9 +144892,10 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ | |||
| 143589 | sqlite3 *db = pParse->db; /* The database connection */ | 144892 | sqlite3 *db = pParse->db; /* The database connection */ |
| 143590 | 144893 | ||
| 143591 | if( pTab==0 ) return; | 144894 | if( pTab==0 ) return; |
| 144895 | assert( IsVirtual(pTab) ); | ||
| 143592 | addArgumentToVtab(pParse); | 144896 | addArgumentToVtab(pParse); |
| 143593 | pParse->sArg.z = 0; | 144897 | pParse->sArg.z = 0; |
| 143594 | if( pTab->nModuleArg<1 ) return; | 144898 | if( pTab->u.vtab.nArg<1 ) return; |
| 143595 | 144899 | ||
| 143596 | /* If the CREATE VIRTUAL TABLE statement is being entered for the | 144900 | /* If the CREATE VIRTUAL TABLE statement is being entered for the |
| 143597 | ** first time (in other words if the virtual table is actually being | 144901 | ** first time (in other words if the virtual table is actually being |
| @@ -143624,7 +144928,7 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ | |||
| 143624 | */ | 144928 | */ |
| 143625 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | 144929 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 143626 | sqlite3NestedParse(pParse, | 144930 | sqlite3NestedParse(pParse, |
| 143627 | "UPDATE %Q." DFLT_SCHEMA_TABLE " " | 144931 | "UPDATE %Q." LEGACY_SCHEMA_TABLE " " |
| 143628 | "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q " | 144932 | "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q " |
| 143629 | "WHERE rowid=#%d", | 144933 | "WHERE rowid=#%d", |
| 143630 | db->aDb[iDb].zDbSName, | 144934 | db->aDb[iDb].zDbSName, |
| @@ -143644,18 +144948,14 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){ | |||
| 143644 | iReg = ++pParse->nMem; | 144948 | iReg = ++pParse->nMem; |
| 143645 | sqlite3VdbeLoadString(v, iReg, pTab->zName); | 144949 | sqlite3VdbeLoadString(v, iReg, pTab->zName); |
| 143646 | sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg); | 144950 | sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg); |
| 143647 | } | 144951 | }else{ |
| 143648 | 144952 | /* If we are rereading the sqlite_schema table create the in-memory | |
| 143649 | /* If we are rereading the sqlite_schema table create the in-memory | 144953 | ** record of the table. */ |
| 143650 | ** record of the table. The xConnect() method is not called until | ||
| 143651 | ** the first time the virtual table is used in an SQL statement. This | ||
| 143652 | ** allows a schema that contains virtual tables to be loaded before | ||
| 143653 | ** the required virtual table implementations are registered. */ | ||
| 143654 | else { | ||
| 143655 | Table *pOld; | 144954 | Table *pOld; |
| 143656 | Schema *pSchema = pTab->pSchema; | 144955 | Schema *pSchema = pTab->pSchema; |
| 143657 | const char *zName = pTab->zName; | 144956 | const char *zName = pTab->zName; |
| 143658 | assert( sqlite3SchemaMutexHeld(db, 0, pSchema) ); | 144957 | assert( zName!=0 ); |
| 144958 | sqlite3MarkAllShadowTablesOf(db, pTab); | ||
| 143659 | pOld = sqlite3HashInsert(&pSchema->tblHash, zName, pTab); | 144959 | pOld = sqlite3HashInsert(&pSchema->tblHash, zName, pTab); |
| 143660 | if( pOld ){ | 144960 | if( pOld ){ |
| 143661 | sqlite3OomFault(db); | 144961 | sqlite3OomFault(db); |
| @@ -143706,13 +145006,16 @@ static int vtabCallConstructor( | |||
| 143706 | VtabCtx sCtx; | 145006 | VtabCtx sCtx; |
| 143707 | VTable *pVTable; | 145007 | VTable *pVTable; |
| 143708 | int rc; | 145008 | int rc; |
| 143709 | const char *const*azArg = (const char *const*)pTab->azModuleArg; | 145009 | const char *const*azArg; |
| 143710 | int nArg = pTab->nModuleArg; | 145010 | int nArg = pTab->u.vtab.nArg; |
| 143711 | char *zErr = 0; | 145011 | char *zErr = 0; |
| 143712 | char *zModuleName; | 145012 | char *zModuleName; |
| 143713 | int iDb; | 145013 | int iDb; |
| 143714 | VtabCtx *pCtx; | 145014 | VtabCtx *pCtx; |
| 143715 | 145015 | ||
| 145016 | assert( IsVirtual(pTab) ); | ||
| 145017 | azArg = (const char *const*)pTab->u.vtab.azArg; | ||
| 145018 | |||
| 143716 | /* Check that the virtual-table is not already being initialized */ | 145019 | /* Check that the virtual-table is not already being initialized */ |
| 143717 | for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){ | 145020 | for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){ |
| 143718 | if( pCtx->pTab==pTab ){ | 145021 | if( pCtx->pTab==pTab ){ |
| @@ -143739,7 +145042,7 @@ static int vtabCallConstructor( | |||
| 143739 | pVTable->eVtabRisk = SQLITE_VTABRISK_Normal; | 145042 | pVTable->eVtabRisk = SQLITE_VTABRISK_Normal; |
| 143740 | 145043 | ||
| 143741 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | 145044 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 143742 | pTab->azModuleArg[1] = db->aDb[iDb].zDbSName; | 145045 | pTab->u.vtab.azArg[1] = db->aDb[iDb].zDbSName; |
| 143743 | 145046 | ||
| 143744 | /* Invoke the virtual table constructor */ | 145047 | /* Invoke the virtual table constructor */ |
| 143745 | assert( &db->pVtabCtx ); | 145048 | assert( &db->pVtabCtx ); |
| @@ -143778,12 +145081,12 @@ static int vtabCallConstructor( | |||
| 143778 | int iCol; | 145081 | int iCol; |
| 143779 | u16 oooHidden = 0; | 145082 | u16 oooHidden = 0; |
| 143780 | /* If everything went according to plan, link the new VTable structure | 145083 | /* If everything went according to plan, link the new VTable structure |
| 143781 | ** into the linked list headed by pTab->pVTable. Then loop through the | 145084 | ** into the linked list headed by pTab->u.vtab.p. Then loop through the |
| 143782 | ** columns of the table to see if any of them contain the token "hidden". | 145085 | ** columns of the table to see if any of them contain the token "hidden". |
| 143783 | ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from | 145086 | ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from |
| 143784 | ** the type string. */ | 145087 | ** the type string. */ |
| 143785 | pVTable->pNext = pTab->pVTable; | 145088 | pVTable->pNext = pTab->u.vtab.p; |
| 143786 | pTab->pVTable = pVTable; | 145089 | pTab->u.vtab.p = pVTable; |
| 143787 | 145090 | ||
| 143788 | for(iCol=0; iCol<pTab->nCol; iCol++){ | 145091 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 143789 | char *zType = sqlite3ColumnType(&pTab->aCol[iCol], ""); | 145092 | char *zType = sqlite3ColumnType(&pTab->aCol[iCol], ""); |
| @@ -143836,16 +145139,17 @@ SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse *pParse, Table *pTab){ | |||
| 143836 | int rc; | 145139 | int rc; |
| 143837 | 145140 | ||
| 143838 | assert( pTab ); | 145141 | assert( pTab ); |
| 143839 | if( !IsVirtual(pTab) || sqlite3GetVTable(db, pTab) ){ | 145142 | assert( IsVirtual(pTab) ); |
| 145143 | if( sqlite3GetVTable(db, pTab) ){ | ||
| 143840 | return SQLITE_OK; | 145144 | return SQLITE_OK; |
| 143841 | } | 145145 | } |
| 143842 | 145146 | ||
| 143843 | /* Locate the required virtual table module */ | 145147 | /* Locate the required virtual table module */ |
| 143844 | zMod = pTab->azModuleArg[0]; | 145148 | zMod = pTab->u.vtab.azArg[0]; |
| 143845 | pMod = (Module*)sqlite3HashFind(&db->aModule, zMod); | 145149 | pMod = (Module*)sqlite3HashFind(&db->aModule, zMod); |
| 143846 | 145150 | ||
| 143847 | if( !pMod ){ | 145151 | if( !pMod ){ |
| 143848 | const char *zModule = pTab->azModuleArg[0]; | 145152 | const char *zModule = pTab->u.vtab.azArg[0]; |
| 143849 | sqlite3ErrorMsg(pParse, "no such module: %s", zModule); | 145153 | sqlite3ErrorMsg(pParse, "no such module: %s", zModule); |
| 143850 | rc = SQLITE_ERROR; | 145154 | rc = SQLITE_ERROR; |
| 143851 | }else{ | 145155 | }else{ |
| @@ -143908,10 +145212,10 @@ SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab, | |||
| 143908 | const char *zMod; | 145212 | const char *zMod; |
| 143909 | 145213 | ||
| 143910 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName); | 145214 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName); |
| 143911 | assert( pTab && IsVirtual(pTab) && !pTab->pVTable ); | 145215 | assert( pTab && IsVirtual(pTab) && !pTab->u.vtab.p ); |
| 143912 | 145216 | ||
| 143913 | /* Locate the required virtual table module */ | 145217 | /* Locate the required virtual table module */ |
| 143914 | zMod = pTab->azModuleArg[0]; | 145218 | zMod = pTab->u.vtab.azArg[0]; |
| 143915 | pMod = (Module*)sqlite3HashFind(&db->aModule, zMod); | 145219 | pMod = (Module*)sqlite3HashFind(&db->aModule, zMod); |
| 143916 | 145220 | ||
| 143917 | /* If the module has been registered and includes a Create method, | 145221 | /* If the module has been registered and includes a Create method, |
| @@ -143948,6 +145252,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ | |||
| 143948 | Table *pTab; | 145252 | Table *pTab; |
| 143949 | char *zErr = 0; | 145253 | char *zErr = 0; |
| 143950 | Parse sParse; | 145254 | Parse sParse; |
| 145255 | int initBusy; | ||
| 143951 | 145256 | ||
| 143952 | #ifdef SQLITE_ENABLE_API_ARMOR | 145257 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 143953 | if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){ | 145258 | if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){ |
| @@ -143967,17 +145272,23 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ | |||
| 143967 | memset(&sParse, 0, sizeof(sParse)); | 145272 | memset(&sParse, 0, sizeof(sParse)); |
| 143968 | sParse.eParseMode = PARSE_MODE_DECLARE_VTAB; | 145273 | sParse.eParseMode = PARSE_MODE_DECLARE_VTAB; |
| 143969 | sParse.db = db; | 145274 | sParse.db = db; |
| 145275 | /* We should never be able to reach this point while loading the | ||
| 145276 | ** schema. Nevertheless, defend against that (turn off db->init.busy) | ||
| 145277 | ** in case a bug arises. */ | ||
| 145278 | assert( db->init.busy==0 ); | ||
| 145279 | initBusy = db->init.busy; | ||
| 145280 | db->init.busy = 0; | ||
| 143970 | sParse.nQueryLoop = 1; | 145281 | sParse.nQueryLoop = 1; |
| 143971 | if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr) | 145282 | if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr) |
| 143972 | && sParse.pNewTable | 145283 | && sParse.pNewTable |
| 143973 | && !db->mallocFailed | 145284 | && !db->mallocFailed |
| 143974 | && !sParse.pNewTable->pSelect | 145285 | && IsOrdinaryTable(sParse.pNewTable) |
| 143975 | && !IsVirtual(sParse.pNewTable) | ||
| 143976 | ){ | 145286 | ){ |
| 143977 | if( !pTab->aCol ){ | 145287 | if( !pTab->aCol ){ |
| 143978 | Table *pNew = sParse.pNewTable; | 145288 | Table *pNew = sParse.pNewTable; |
| 143979 | Index *pIdx; | 145289 | Index *pIdx; |
| 143980 | pTab->aCol = pNew->aCol; | 145290 | pTab->aCol = pNew->aCol; |
| 145291 | sqlite3ExprListDelete(db, pNew->u.tab.pDfltList); | ||
| 143981 | pTab->nNVCol = pTab->nCol = pNew->nCol; | 145292 | pTab->nNVCol = pTab->nCol = pNew->nCol; |
| 143982 | pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid); | 145293 | pTab->tabFlags |= pNew->tabFlags & (TF_WithoutRowid|TF_NoVisibleRowid); |
| 143983 | pNew->nCol = 0; | 145294 | pNew->nCol = 0; |
| @@ -144013,6 +145324,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){ | |||
| 144013 | } | 145324 | } |
| 144014 | sqlite3DeleteTable(db, sParse.pNewTable); | 145325 | sqlite3DeleteTable(db, sParse.pNewTable); |
| 144015 | sqlite3ParserReset(&sParse); | 145326 | sqlite3ParserReset(&sParse); |
| 145327 | db->init.busy = initBusy; | ||
| 144016 | 145328 | ||
| 144017 | assert( (rc&0xff)==rc ); | 145329 | assert( (rc&0xff)==rc ); |
| 144018 | rc = sqlite3ApiExit(db, rc); | 145330 | rc = sqlite3ApiExit(db, rc); |
| @@ -144032,10 +145344,13 @@ SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab | |||
| 144032 | Table *pTab; | 145344 | Table *pTab; |
| 144033 | 145345 | ||
| 144034 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName); | 145346 | pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zDbSName); |
| 144035 | if( pTab!=0 && ALWAYS(pTab->pVTable!=0) ){ | 145347 | if( ALWAYS(pTab!=0) |
| 145348 | && ALWAYS(IsVirtual(pTab)) | ||
| 145349 | && ALWAYS(pTab->u.vtab.p!=0) | ||
| 145350 | ){ | ||
| 144036 | VTable *p; | 145351 | VTable *p; |
| 144037 | int (*xDestroy)(sqlite3_vtab *); | 145352 | int (*xDestroy)(sqlite3_vtab *); |
| 144038 | for(p=pTab->pVTable; p; p=p->pNext){ | 145353 | for(p=pTab->u.vtab.p; p; p=p->pNext){ |
| 144039 | assert( p->pVtab ); | 145354 | assert( p->pVtab ); |
| 144040 | if( p->pVtab->nRef>0 ){ | 145355 | if( p->pVtab->nRef>0 ){ |
| 144041 | return SQLITE_LOCKED; | 145356 | return SQLITE_LOCKED; |
| @@ -144049,9 +145364,9 @@ SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab | |||
| 144049 | rc = xDestroy(p->pVtab); | 145364 | rc = xDestroy(p->pVtab); |
| 144050 | /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ | 145365 | /* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */ |
| 144051 | if( rc==SQLITE_OK ){ | 145366 | if( rc==SQLITE_OK ){ |
| 144052 | assert( pTab->pVTable==p && p->pNext==0 ); | 145367 | assert( pTab->u.vtab.p==p && p->pNext==0 ); |
| 144053 | p->pVtab = 0; | 145368 | p->pVtab = 0; |
| 144054 | pTab->pVTable = 0; | 145369 | pTab->u.vtab.p = 0; |
| 144055 | sqlite3VtabUnlock(p); | 145370 | sqlite3VtabUnlock(p); |
| 144056 | } | 145371 | } |
| 144057 | sqlite3DeleteTable(db, pTab); | 145372 | sqlite3DeleteTable(db, pTab); |
| @@ -144265,6 +145580,7 @@ SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction( | |||
| 144265 | /* Check to see the left operand is a column in a virtual table */ | 145580 | /* Check to see the left operand is a column in a virtual table */ |
| 144266 | if( NEVER(pExpr==0) ) return pDef; | 145581 | if( NEVER(pExpr==0) ) return pDef; |
| 144267 | if( pExpr->op!=TK_COLUMN ) return pDef; | 145582 | if( pExpr->op!=TK_COLUMN ) return pDef; |
| 145583 | assert( ExprUseYTab(pExpr) ); | ||
| 144268 | pTab = pExpr->y.pTab; | 145584 | pTab = pExpr->y.pTab; |
| 144269 | if( pTab==0 ) return pDef; | 145585 | if( pTab==0 ) return pDef; |
| 144270 | if( !IsVirtual(pTab) ) return pDef; | 145586 | if( !IsVirtual(pTab) ) return pDef; |
| @@ -144339,8 +145655,9 @@ SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){ | |||
| 144339 | /* | 145655 | /* |
| 144340 | ** Check to see if virtual table module pMod can be have an eponymous | 145656 | ** Check to see if virtual table module pMod can be have an eponymous |
| 144341 | ** virtual table instance. If it can, create one if one does not already | 145657 | ** virtual table instance. If it can, create one if one does not already |
| 144342 | ** exist. Return non-zero if the eponymous virtual table instance exists | 145658 | ** exist. Return non-zero if either the eponymous virtual table instance |
| 144343 | ** when this routine returns, and return zero if it does not exist. | 145659 | ** exists when this routine returns or if an attempt to create it failed |
| 145660 | ** and an error message was left in pParse. | ||
| 144344 | ** | 145661 | ** |
| 144345 | ** An eponymous virtual table instance is one that is named after its | 145662 | ** An eponymous virtual table instance is one that is named after its |
| 144346 | ** module, and more importantly, does not require a CREATE VIRTUAL TABLE | 145663 | ** module, and more importantly, does not require a CREATE VIRTUAL TABLE |
| @@ -144367,8 +145684,9 @@ SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){ | |||
| 144367 | } | 145684 | } |
| 144368 | pMod->pEpoTab = pTab; | 145685 | pMod->pEpoTab = pTab; |
| 144369 | pTab->nTabRef = 1; | 145686 | pTab->nTabRef = 1; |
| 145687 | pTab->eTabType = TABTYP_VTAB; | ||
| 144370 | pTab->pSchema = db->aDb[0].pSchema; | 145688 | pTab->pSchema = db->aDb[0].pSchema; |
| 144371 | assert( pTab->nModuleArg==0 ); | 145689 | assert( pTab->u.vtab.nArg==0 ); |
| 144372 | pTab->iPKey = -1; | 145690 | pTab->iPKey = -1; |
| 144373 | pTab->tabFlags |= TF_Eponymous; | 145691 | pTab->tabFlags |= TF_Eponymous; |
| 144374 | addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); | 145692 | addModuleArgument(pParse, pTab, sqlite3DbStrDup(db, pTab->zName)); |
| @@ -144379,7 +145697,6 @@ SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse *pParse, Module *pMod){ | |||
| 144379 | sqlite3ErrorMsg(pParse, "%s", zErr); | 145697 | sqlite3ErrorMsg(pParse, "%s", zErr); |
| 144380 | sqlite3DbFree(db, zErr); | 145698 | sqlite3DbFree(db, zErr); |
| 144381 | sqlite3VtabEponymousTableClear(db, pMod); | 145699 | sqlite3VtabEponymousTableClear(db, pMod); |
| 144382 | return 0; | ||
| 144383 | } | 145700 | } |
| 144384 | return 1; | 145701 | return 1; |
| 144385 | } | 145702 | } |
| @@ -144572,7 +145889,7 @@ struct WhereLevel { | |||
| 144572 | u8 eEndLoopOp; /* IN Loop terminator. OP_Next or OP_Prev */ | 145889 | u8 eEndLoopOp; /* IN Loop terminator. OP_Next or OP_Prev */ |
| 144573 | } *aInLoop; /* Information about each nested IN operator */ | 145890 | } *aInLoop; /* Information about each nested IN operator */ |
| 144574 | } in; /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */ | 145891 | } in; /* Used when pWLoop->wsFlags&WHERE_IN_ABLE */ |
| 144575 | Index *pCovidx; /* Possible covering index for WHERE_MULTI_OR */ | 145892 | Index *pCoveringIdx; /* Possible covering index for WHERE_MULTI_OR */ |
| 144576 | } u; | 145893 | } u; |
| 144577 | struct WhereLoop *pWLoop; /* The selected WhereLoop object */ | 145894 | struct WhereLoop *pWLoop; /* The selected WhereLoop object */ |
| 144578 | Bitmask notReady; /* FROM entries not usable at this level */ | 145895 | Bitmask notReady; /* FROM entries not usable at this level */ |
| @@ -145113,7 +146430,7 @@ static const char *explainIndexColumnName(Index *pIdx, int i){ | |||
| 145113 | i = pIdx->aiColumn[i]; | 146430 | i = pIdx->aiColumn[i]; |
| 145114 | if( i==XN_EXPR ) return "<expr>"; | 146431 | if( i==XN_EXPR ) return "<expr>"; |
| 145115 | if( i==XN_ROWID ) return "rowid"; | 146432 | if( i==XN_ROWID ) return "rowid"; |
| 145116 | return pIdx->pTable->aCol[i].zName; | 146433 | return pIdx->pTable->aCol[i].zCnName; |
| 145117 | } | 146434 | } |
| 145118 | 146435 | ||
| 145119 | /* | 146436 | /* |
| @@ -145500,16 +146817,23 @@ static Expr *removeUnindexableInClauseTerms( | |||
| 145500 | Expr *pNew; | 146817 | Expr *pNew; |
| 145501 | pNew = sqlite3ExprDup(db, pX, 0); | 146818 | pNew = sqlite3ExprDup(db, pX, 0); |
| 145502 | if( db->mallocFailed==0 ){ | 146819 | if( db->mallocFailed==0 ){ |
| 145503 | ExprList *pOrigRhs = pNew->x.pSelect->pEList; /* Original unmodified RHS */ | 146820 | ExprList *pOrigRhs; /* Original unmodified RHS */ |
| 145504 | ExprList *pOrigLhs = pNew->pLeft->x.pList; /* Original unmodified LHS */ | 146821 | ExprList *pOrigLhs; /* Original unmodified LHS */ |
| 145505 | ExprList *pRhs = 0; /* New RHS after modifications */ | 146822 | ExprList *pRhs = 0; /* New RHS after modifications */ |
| 145506 | ExprList *pLhs = 0; /* New LHS after mods */ | 146823 | ExprList *pLhs = 0; /* New LHS after mods */ |
| 145507 | int i; /* Loop counter */ | 146824 | int i; /* Loop counter */ |
| 145508 | Select *pSelect; /* Pointer to the SELECT on the RHS */ | 146825 | Select *pSelect; /* Pointer to the SELECT on the RHS */ |
| 145509 | 146826 | ||
| 146827 | assert( ExprUseXSelect(pNew) ); | ||
| 146828 | pOrigRhs = pNew->x.pSelect->pEList; | ||
| 146829 | assert( pNew->pLeft!=0 ); | ||
| 146830 | assert( ExprUseXList(pNew->pLeft) ); | ||
| 146831 | pOrigLhs = pNew->pLeft->x.pList; | ||
| 145510 | for(i=iEq; i<pLoop->nLTerm; i++){ | 146832 | for(i=iEq; i<pLoop->nLTerm; i++){ |
| 145511 | if( pLoop->aLTerm[i]->pExpr==pX ){ | 146833 | if( pLoop->aLTerm[i]->pExpr==pX ){ |
| 145512 | int iField = pLoop->aLTerm[i]->u.x.iField - 1; | 146834 | int iField; |
| 146835 | assert( (pLoop->aLTerm[i]->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 146836 | iField = pLoop->aLTerm[i]->u.x.iField - 1; | ||
| 145513 | if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */ | 146837 | if( pOrigRhs->a[iField].pExpr==0 ) continue; /* Duplicate PK column */ |
| 145514 | pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr); | 146838 | pRhs = sqlite3ExprListAppend(pParse, pRhs, pOrigRhs->a[iField].pExpr); |
| 145515 | pOrigRhs->a[iField].pExpr = 0; | 146839 | pOrigRhs->a[iField].pExpr = 0; |
| @@ -145624,7 +146948,7 @@ static int codeEqualityTerm( | |||
| 145624 | } | 146948 | } |
| 145625 | 146949 | ||
| 145626 | iTab = 0; | 146950 | iTab = 0; |
| 145627 | if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){ | 146951 | if( !ExprUseXSelect(pX) || pX->x.pSelect->pEList->nExpr==1 ){ |
| 145628 | eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab); | 146952 | eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab); |
| 145629 | }else{ | 146953 | }else{ |
| 145630 | sqlite3 *db = pParse->db; | 146954 | sqlite3 *db = pParse->db; |
| @@ -145646,8 +146970,8 @@ static int codeEqualityTerm( | |||
| 145646 | sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0); | 146970 | sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0); |
| 145647 | VdbeCoverageIf(v, bRev); | 146971 | VdbeCoverageIf(v, bRev); |
| 145648 | VdbeCoverageIf(v, !bRev); | 146972 | VdbeCoverageIf(v, !bRev); |
| 145649 | assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 ); | ||
| 145650 | 146973 | ||
| 146974 | assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 ); | ||
| 145651 | pLoop->wsFlags |= WHERE_IN_ABLE; | 146975 | pLoop->wsFlags |= WHERE_IN_ABLE; |
| 145652 | if( pLevel->u.in.nIn==0 ){ | 146976 | if( pLevel->u.in.nIn==0 ){ |
| 145653 | pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse); | 146977 | pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse); |
| @@ -146189,7 +147513,7 @@ static void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){ | |||
| 146189 | assert( nReg>0 ); | 147513 | assert( nReg>0 ); |
| 146190 | if( p && sqlite3ExprIsVector(p) ){ | 147514 | if( p && sqlite3ExprIsVector(p) ){ |
| 146191 | #ifndef SQLITE_OMIT_SUBQUERY | 147515 | #ifndef SQLITE_OMIT_SUBQUERY |
| 146192 | if( (p->flags & EP_xIsSelect) ){ | 147516 | if( ExprUseXSelect(p) ){ |
| 146193 | Vdbe *v = pParse->pVdbe; | 147517 | Vdbe *v = pParse->pVdbe; |
| 146194 | int iSelect; | 147518 | int iSelect; |
| 146195 | assert( p->op==TK_SELECT ); | 147519 | assert( p->op==TK_SELECT ); |
| @@ -146199,7 +147523,9 @@ static void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){ | |||
| 146199 | #endif | 147523 | #endif |
| 146200 | { | 147524 | { |
| 146201 | int i; | 147525 | int i; |
| 146202 | ExprList *pList = p->x.pList; | 147526 | const ExprList *pList; |
| 147527 | assert( ExprUseXList(p) ); | ||
| 147528 | pList = p->x.pList; | ||
| 146203 | assert( nReg<=pList->nExpr ); | 147529 | assert( nReg<=pList->nExpr ); |
| 146204 | for(i=0; i<nReg; i++){ | 147530 | for(i=0; i<nReg; i++){ |
| 146205 | sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i); | 147531 | sqlite3ExprCode(pParse, pList->a[i].pExpr, iReg+i); |
| @@ -146252,10 +147578,10 @@ static int whereIndexExprTransNode(Walker *p, Expr *pExpr){ | |||
| 146252 | pExpr->op = TK_COLUMN; | 147578 | pExpr->op = TK_COLUMN; |
| 146253 | pExpr->iTable = pX->iIdxCur; | 147579 | pExpr->iTable = pX->iIdxCur; |
| 146254 | pExpr->iColumn = pX->iIdxCol; | 147580 | pExpr->iColumn = pX->iIdxCol; |
| 146255 | pExpr->y.pTab = 0; | ||
| 146256 | testcase( ExprHasProperty(pExpr, EP_Skip) ); | 147581 | testcase( ExprHasProperty(pExpr, EP_Skip) ); |
| 146257 | testcase( ExprHasProperty(pExpr, EP_Unlikely) ); | 147582 | testcase( ExprHasProperty(pExpr, EP_Unlikely) ); |
| 146258 | ExprClearProperty(pExpr, EP_Skip|EP_Unlikely); | 147583 | ExprClearProperty(pExpr, EP_Skip|EP_Unlikely|EP_WinFunc|EP_Subrtn); |
| 147584 | pExpr->y.pTab = 0; | ||
| 146259 | return WRC_Prune; | 147585 | return WRC_Prune; |
| 146260 | }else{ | 147586 | }else{ |
| 146261 | return WRC_Continue; | 147587 | return WRC_Continue; |
| @@ -146270,7 +147596,7 @@ static int whereIndexExprTransColumn(Walker *p, Expr *pExpr){ | |||
| 146270 | if( pExpr->op==TK_COLUMN ){ | 147596 | if( pExpr->op==TK_COLUMN ){ |
| 146271 | IdxExprTrans *pX = p->u.pIdxTrans; | 147597 | IdxExprTrans *pX = p->u.pIdxTrans; |
| 146272 | if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){ | 147598 | if( pExpr->iTable==pX->iTabCur && pExpr->iColumn==pX->iTabCol ){ |
| 146273 | assert( pExpr->y.pTab!=0 ); | 147599 | assert( ExprUseYTab(pExpr) && pExpr->y.pTab!=0 ); |
| 146274 | preserveExpr(pX, pExpr); | 147600 | preserveExpr(pX, pExpr); |
| 146275 | pExpr->affExpr = sqlite3TableColumnAffinity(pExpr->y.pTab,pExpr->iColumn); | 147601 | pExpr->affExpr = sqlite3TableColumnAffinity(pExpr->y.pTab,pExpr->iColumn); |
| 146276 | pExpr->iTable = pX->iIdxCur; | 147602 | pExpr->iTable = pX->iIdxCur; |
| @@ -146318,15 +147644,16 @@ static void whereIndexExprTrans( | |||
| 146318 | for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){ | 147644 | for(iIdxCol=0; iIdxCol<pIdx->nColumn; iIdxCol++){ |
| 146319 | i16 iRef = pIdx->aiColumn[iIdxCol]; | 147645 | i16 iRef = pIdx->aiColumn[iIdxCol]; |
| 146320 | if( iRef==XN_EXPR ){ | 147646 | if( iRef==XN_EXPR ){ |
| 146321 | assert( aColExpr->a[iIdxCol].pExpr!=0 ); | 147647 | assert( aColExpr!=0 && aColExpr->a[iIdxCol].pExpr!=0 ); |
| 146322 | x.pIdxExpr = aColExpr->a[iIdxCol].pExpr; | 147648 | x.pIdxExpr = aColExpr->a[iIdxCol].pExpr; |
| 146323 | if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue; | 147649 | if( sqlite3ExprIsConstant(x.pIdxExpr) ) continue; |
| 146324 | w.xExprCallback = whereIndexExprTransNode; | 147650 | w.xExprCallback = whereIndexExprTransNode; |
| 146325 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS | 147651 | #ifndef SQLITE_OMIT_GENERATED_COLUMNS |
| 146326 | }else if( iRef>=0 | 147652 | }else if( iRef>=0 |
| 146327 | && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 | 147653 | && (pTab->aCol[iRef].colFlags & COLFLAG_VIRTUAL)!=0 |
| 146328 | && (pTab->aCol[iRef].zColl==0 | 147654 | && ((pTab->aCol[iRef].colFlags & COLFLAG_HASCOLL)==0 |
| 146329 | || sqlite3StrICmp(pTab->aCol[iRef].zColl, sqlite3StrBINARY)==0) | 147655 | || sqlite3StrICmp(sqlite3ColumnColl(&pTab->aCol[iRef]), |
| 147656 | sqlite3StrBINARY)==0) | ||
| 146330 | ){ | 147657 | ){ |
| 146331 | /* Check to see if there are direct references to generated columns | 147658 | /* Check to see if there are direct references to generated columns |
| 146332 | ** that are contained in the index. Pulling the generated column | 147659 | ** that are contained in the index. Pulling the generated column |
| @@ -146506,7 +147833,12 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 146506 | pLevel->p1 = iCur; | 147833 | pLevel->p1 = iCur; |
| 146507 | pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext; | 147834 | pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext; |
| 146508 | pLevel->p2 = sqlite3VdbeCurrentAddr(v); | 147835 | pLevel->p2 = sqlite3VdbeCurrentAddr(v); |
| 146509 | iIn = pLevel->u.in.nIn; | 147836 | assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 ); |
| 147837 | if( pLoop->wsFlags & WHERE_IN_ABLE ){ | ||
| 147838 | iIn = pLevel->u.in.nIn; | ||
| 147839 | }else{ | ||
| 147840 | iIn = 0; | ||
| 147841 | } | ||
| 146510 | for(j=nConstraint-1; j>=0; j--){ | 147842 | for(j=nConstraint-1; j>=0; j--){ |
| 146511 | pTerm = pLoop->aLTerm[j]; | 147843 | pTerm = pLoop->aLTerm[j]; |
| 146512 | if( (pTerm->eOperator & WO_IN)!=0 ) iIn--; | 147844 | if( (pTerm->eOperator & WO_IN)!=0 ) iIn--; |
| @@ -146583,9 +147915,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 146583 | sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg); | 147915 | sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg); |
| 146584 | VdbeCoverage(v); | 147916 | VdbeCoverage(v); |
| 146585 | pLevel->op = OP_Noop; | 147917 | pLevel->op = OP_Noop; |
| 146586 | if( (pTerm->prereqAll & pLevel->notReady)==0 ){ | ||
| 146587 | pTerm->wtFlags |= TERM_CODED; | ||
| 146588 | } | ||
| 146589 | }else if( (pLoop->wsFlags & WHERE_IPK)!=0 | 147918 | }else if( (pLoop->wsFlags & WHERE_IPK)!=0 |
| 146590 | && (pLoop->wsFlags & WHERE_COLUMN_RANGE)!=0 | 147919 | && (pLoop->wsFlags & WHERE_COLUMN_RANGE)!=0 |
| 146591 | ){ | 147920 | ){ |
| @@ -146956,8 +148285,19 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 146956 | ** range (if any). | 148285 | ** range (if any). |
| 146957 | */ | 148286 | */ |
| 146958 | nConstraint = nEq; | 148287 | nConstraint = nEq; |
| 148288 | assert( pLevel->p2==0 ); | ||
| 146959 | if( pRangeEnd ){ | 148289 | if( pRangeEnd ){ |
| 146960 | Expr *pRight = pRangeEnd->pExpr->pRight; | 148290 | Expr *pRight = pRangeEnd->pExpr->pRight; |
| 148291 | if( addrSeekScan ){ | ||
| 148292 | /* For a seek-scan that has a range on the lowest term of the index, | ||
| 148293 | ** we have to make the top of the loop be code that sets the end | ||
| 148294 | ** condition of the range. Otherwise, the OP_SeekScan might jump | ||
| 148295 | ** over that initialization, leaving the range-end value set to the | ||
| 148296 | ** range-start value, resulting in a wrong answer. | ||
| 148297 | ** See ticket 5981a8c041a3c2f3 (2021-11-02). | ||
| 148298 | */ | ||
| 148299 | pLevel->p2 = sqlite3VdbeCurrentAddr(v); | ||
| 148300 | } | ||
| 146961 | codeExprOrVector(pParse, pRight, regBase+nEq, nTop); | 148301 | codeExprOrVector(pParse, pRight, regBase+nEq, nTop); |
| 146962 | whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd); | 148302 | whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd); |
| 146963 | if( (pRangeEnd->wtFlags & TERM_VNULL)==0 | 148303 | if( (pRangeEnd->wtFlags & TERM_VNULL)==0 |
| @@ -146991,7 +148331,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 146991 | sqlite3DbFree(db, zEndAff); | 148331 | sqlite3DbFree(db, zEndAff); |
| 146992 | 148332 | ||
| 146993 | /* Top of the loop body */ | 148333 | /* Top of the loop body */ |
| 146994 | pLevel->p2 = sqlite3VdbeCurrentAddr(v); | 148334 | if( pLevel->p2==0 ) pLevel->p2 = sqlite3VdbeCurrentAddr(v); |
| 146995 | 148335 | ||
| 146996 | /* Check if the index cursor is past the end of the range. */ | 148336 | /* Check if the index cursor is past the end of the range. */ |
| 146997 | if( nConstraint ){ | 148337 | if( nConstraint ){ |
| @@ -147398,7 +148738,10 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 147398 | } | 148738 | } |
| 147399 | } | 148739 | } |
| 147400 | ExplainQueryPlanPop(pParse); | 148740 | ExplainQueryPlanPop(pParse); |
| 147401 | pLevel->u.pCovidx = pCov; | 148741 | assert( pLevel->pWLoop==pLoop ); |
| 148742 | assert( (pLoop->wsFlags & WHERE_MULTI_OR)!=0 ); | ||
| 148743 | assert( (pLoop->wsFlags & WHERE_IN_ABLE)==0 ); | ||
| 148744 | pLevel->u.pCoveringIdx = pCov; | ||
| 147402 | if( pCov ) pLevel->iIdxCur = iCovCur; | 148745 | if( pCov ) pLevel->iIdxCur = iCovCur; |
| 147403 | if( pAndExpr ){ | 148746 | if( pAndExpr ){ |
| 147404 | pAndExpr->pLeft = 0; | 148747 | pAndExpr->pLeft = 0; |
| @@ -147542,12 +148885,13 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart( | |||
| 147542 | #endif | 148885 | #endif |
| 147543 | assert( !ExprHasProperty(pE, EP_FromJoin) ); | 148886 | assert( !ExprHasProperty(pE, EP_FromJoin) ); |
| 147544 | assert( (pTerm->prereqRight & pLevel->notReady)!=0 ); | 148887 | assert( (pTerm->prereqRight & pLevel->notReady)!=0 ); |
| 148888 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 147545 | pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.x.leftColumn, notReady, | 148889 | pAlt = sqlite3WhereFindTerm(pWC, iCur, pTerm->u.x.leftColumn, notReady, |
| 147546 | WO_EQ|WO_IN|WO_IS, 0); | 148890 | WO_EQ|WO_IN|WO_IS, 0); |
| 147547 | if( pAlt==0 ) continue; | 148891 | if( pAlt==0 ) continue; |
| 147548 | if( pAlt->wtFlags & (TERM_CODED) ) continue; | 148892 | if( pAlt->wtFlags & (TERM_CODED) ) continue; |
| 147549 | if( (pAlt->eOperator & WO_IN) | 148893 | if( (pAlt->eOperator & WO_IN) |
| 147550 | && (pAlt->pExpr->flags & EP_xIsSelect) | 148894 | && ExprUseXSelect(pAlt->pExpr) |
| 147551 | && (pAlt->pExpr->x.pSelect->pEList->nExpr>1) | 148895 | && (pAlt->pExpr->x.pSelect->pEList->nExpr>1) |
| 147552 | ){ | 148896 | ){ |
| 147553 | continue; | 148897 | continue; |
| @@ -147796,6 +149140,7 @@ static int isLikeOrGlob( | |||
| 147796 | #ifdef SQLITE_EBCDIC | 149140 | #ifdef SQLITE_EBCDIC |
| 147797 | if( *pnoCase ) return 0; | 149141 | if( *pnoCase ) return 0; |
| 147798 | #endif | 149142 | #endif |
| 149143 | assert( ExprUseXList(pExpr) ); | ||
| 147799 | pList = pExpr->x.pList; | 149144 | pList = pExpr->x.pList; |
| 147800 | pLeft = pList->a[1].pExpr; | 149145 | pLeft = pList->a[1].pExpr; |
| 147801 | 149146 | ||
| @@ -147811,7 +149156,8 @@ static int isLikeOrGlob( | |||
| 147811 | sqlite3VdbeSetVarmask(pParse->pVdbe, iCol); | 149156 | sqlite3VdbeSetVarmask(pParse->pVdbe, iCol); |
| 147812 | assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER ); | 149157 | assert( pRight->op==TK_VARIABLE || pRight->op==TK_REGISTER ); |
| 147813 | }else if( op==TK_STRING ){ | 149158 | }else if( op==TK_STRING ){ |
| 147814 | z = (u8*)pRight->u.zToken; | 149159 | assert( !ExprHasProperty(pRight, EP_IntValue) ); |
| 149160 | z = (u8*)pRight->u.zToken; | ||
| 147815 | } | 149161 | } |
| 147816 | if( z ){ | 149162 | if( z ){ |
| 147817 | 149163 | ||
| @@ -147840,7 +149186,9 @@ static int isLikeOrGlob( | |||
| 147840 | pPrefix = sqlite3Expr(db, TK_STRING, (char*)z); | 149186 | pPrefix = sqlite3Expr(db, TK_STRING, (char*)z); |
| 147841 | if( pPrefix ){ | 149187 | if( pPrefix ){ |
| 147842 | int iFrom, iTo; | 149188 | int iFrom, iTo; |
| 147843 | char *zNew = pPrefix->u.zToken; | 149189 | char *zNew; |
| 149190 | assert( !ExprHasProperty(pPrefix, EP_IntValue) ); | ||
| 149191 | zNew = pPrefix->u.zToken; | ||
| 147844 | zNew[cnt] = 0; | 149192 | zNew[cnt] = 0; |
| 147845 | for(iFrom=iTo=0; iFrom<cnt; iFrom++){ | 149193 | for(iFrom=iTo=0; iFrom<cnt; iFrom++){ |
| 147846 | if( zNew[iFrom]==wc[3] ) iFrom++; | 149194 | if( zNew[iFrom]==wc[3] ) iFrom++; |
| @@ -147864,7 +149212,9 @@ static int isLikeOrGlob( | |||
| 147864 | */ | 149212 | */ |
| 147865 | if( pLeft->op!=TK_COLUMN | 149213 | if( pLeft->op!=TK_COLUMN |
| 147866 | || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT | 149214 | || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT |
| 147867 | || IsVirtual(pLeft->y.pTab) /* Value might be numeric */ | 149215 | || (ALWAYS( ExprUseYTab(pLeft) ) |
| 149216 | && pLeft->y.pTab | ||
| 149217 | && IsVirtual(pLeft->y.pTab)) /* Might be numeric */ | ||
| 147868 | ){ | 149218 | ){ |
| 147869 | int isNum; | 149219 | int isNum; |
| 147870 | double rDummy; | 149220 | double rDummy; |
| @@ -147892,6 +149242,7 @@ static int isLikeOrGlob( | |||
| 147892 | if( op==TK_VARIABLE ){ | 149242 | if( op==TK_VARIABLE ){ |
| 147893 | Vdbe *v = pParse->pVdbe; | 149243 | Vdbe *v = pParse->pVdbe; |
| 147894 | sqlite3VdbeSetVarmask(v, pRight->iColumn); | 149244 | sqlite3VdbeSetVarmask(v, pRight->iColumn); |
| 149245 | assert( !ExprHasProperty(pRight, EP_IntValue) ); | ||
| 147895 | if( *pisComplete && pRight->u.zToken[1] ){ | 149246 | if( *pisComplete && pRight->u.zToken[1] ){ |
| 147896 | /* If the rhs of the LIKE expression is a variable, and the current | 149247 | /* If the rhs of the LIKE expression is a variable, and the current |
| 147897 | ** value of the variable means there is no need to invoke the LIKE | 149248 | ** value of the variable means there is no need to invoke the LIKE |
| @@ -147965,6 +149316,7 @@ static int isAuxiliaryVtabOperator( | |||
| 147965 | Expr *pCol; /* Column reference */ | 149316 | Expr *pCol; /* Column reference */ |
| 147966 | int i; | 149317 | int i; |
| 147967 | 149318 | ||
| 149319 | assert( ExprUseXList(pExpr) ); | ||
| 147968 | pList = pExpr->x.pList; | 149320 | pList = pExpr->x.pList; |
| 147969 | if( pList==0 || pList->nExpr!=2 ){ | 149321 | if( pList==0 || pList->nExpr!=2 ){ |
| 147970 | return 0; | 149322 | return 0; |
| @@ -147978,9 +149330,11 @@ static int isAuxiliaryVtabOperator( | |||
| 147978 | ** MATCH(expression,vtab_column) | 149330 | ** MATCH(expression,vtab_column) |
| 147979 | */ | 149331 | */ |
| 147980 | pCol = pList->a[1].pExpr; | 149332 | pCol = pList->a[1].pExpr; |
| 149333 | assert( pCol->op!=TK_COLUMN || ExprUseYTab(pCol) ); | ||
| 147981 | testcase( pCol->op==TK_COLUMN && pCol->y.pTab==0 ); | 149334 | testcase( pCol->op==TK_COLUMN && pCol->y.pTab==0 ); |
| 147982 | if( ExprIsVtab(pCol) ){ | 149335 | if( ExprIsVtab(pCol) ){ |
| 147983 | for(i=0; i<ArraySize(aOp); i++){ | 149336 | for(i=0; i<ArraySize(aOp); i++){ |
| 149337 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 147984 | if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){ | 149338 | if( sqlite3StrICmp(pExpr->u.zToken, aOp[i].zOp)==0 ){ |
| 147985 | *peOp2 = aOp[i].eOp2; | 149339 | *peOp2 = aOp[i].eOp2; |
| 147986 | *ppRight = pList->a[0].pExpr; | 149340 | *ppRight = pList->a[0].pExpr; |
| @@ -148001,6 +149355,7 @@ static int isAuxiliaryVtabOperator( | |||
| 148001 | ** with function names in an arbitrary case. | 149355 | ** with function names in an arbitrary case. |
| 148002 | */ | 149356 | */ |
| 148003 | pCol = pList->a[0].pExpr; | 149357 | pCol = pList->a[0].pExpr; |
| 149358 | assert( pCol->op!=TK_COLUMN || ExprUseYTab(pCol) ); | ||
| 148004 | testcase( pCol->op==TK_COLUMN && pCol->y.pTab==0 ); | 149359 | testcase( pCol->op==TK_COLUMN && pCol->y.pTab==0 ); |
| 148005 | if( ExprIsVtab(pCol) ){ | 149360 | if( ExprIsVtab(pCol) ){ |
| 148006 | sqlite3_vtab *pVtab; | 149361 | sqlite3_vtab *pVtab; |
| @@ -148010,7 +149365,8 @@ static int isAuxiliaryVtabOperator( | |||
| 148010 | pVtab = sqlite3GetVTable(db, pCol->y.pTab)->pVtab; | 149365 | pVtab = sqlite3GetVTable(db, pCol->y.pTab)->pVtab; |
| 148011 | assert( pVtab!=0 ); | 149366 | assert( pVtab!=0 ); |
| 148012 | assert( pVtab->pModule!=0 ); | 149367 | assert( pVtab->pModule!=0 ); |
| 148013 | pMod = (sqlite3_module *)pVtab->pModule; | 149368 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 149369 | pMod = (sqlite3_module *)pVtab->pModule; | ||
| 148014 | if( pMod->xFindFunction!=0 ){ | 149370 | if( pMod->xFindFunction!=0 ){ |
| 148015 | i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed); | 149371 | i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed); |
| 148016 | if( i>=SQLITE_INDEX_CONSTRAINT_FUNCTION ){ | 149372 | if( i>=SQLITE_INDEX_CONSTRAINT_FUNCTION ){ |
| @@ -148025,10 +149381,12 @@ static int isAuxiliaryVtabOperator( | |||
| 148025 | int res = 0; | 149381 | int res = 0; |
| 148026 | Expr *pLeft = pExpr->pLeft; | 149382 | Expr *pLeft = pExpr->pLeft; |
| 148027 | Expr *pRight = pExpr->pRight; | 149383 | Expr *pRight = pExpr->pRight; |
| 149384 | assert( pLeft->op!=TK_COLUMN || ExprUseYTab(pLeft) ); | ||
| 148028 | testcase( pLeft->op==TK_COLUMN && pLeft->y.pTab==0 ); | 149385 | testcase( pLeft->op==TK_COLUMN && pLeft->y.pTab==0 ); |
| 148029 | if( ExprIsVtab(pLeft) ){ | 149386 | if( ExprIsVtab(pLeft) ){ |
| 148030 | res++; | 149387 | res++; |
| 148031 | } | 149388 | } |
| 149389 | assert( pRight==0 || pRight->op!=TK_COLUMN || ExprUseYTab(pRight) ); | ||
| 148032 | testcase( pRight && pRight->op==TK_COLUMN && pRight->y.pTab==0 ); | 149390 | testcase( pRight && pRight->op==TK_COLUMN && pRight->y.pTab==0 ); |
| 148033 | if( pRight && ExprIsVtab(pRight) ){ | 149391 | if( pRight && ExprIsVtab(pRight) ){ |
| 148034 | res++; | 149392 | res++; |
| @@ -148281,6 +149639,7 @@ static void exprAnalyzeOrTerm( | |||
| 148281 | pOrTerm->u.pAndInfo = pAndInfo; | 149639 | pOrTerm->u.pAndInfo = pAndInfo; |
| 148282 | pOrTerm->wtFlags |= TERM_ANDINFO; | 149640 | pOrTerm->wtFlags |= TERM_ANDINFO; |
| 148283 | pOrTerm->eOperator = WO_AND; | 149641 | pOrTerm->eOperator = WO_AND; |
| 149642 | pOrTerm->leftCursor = -1; | ||
| 148284 | pAndWC = &pAndInfo->wc; | 149643 | pAndWC = &pAndInfo->wc; |
| 148285 | memset(pAndWC->aStatic, 0, sizeof(pAndWC->aStatic)); | 149644 | memset(pAndWC->aStatic, 0, sizeof(pAndWC->aStatic)); |
| 148286 | sqlite3WhereClauseInit(pAndWC, pWC->pWInfo); | 149645 | sqlite3WhereClauseInit(pAndWC, pWC->pWInfo); |
| @@ -148323,11 +149682,10 @@ static void exprAnalyzeOrTerm( | |||
| 148323 | ** empty. | 149682 | ** empty. |
| 148324 | */ | 149683 | */ |
| 148325 | pOrInfo->indexable = indexable; | 149684 | pOrInfo->indexable = indexable; |
| 149685 | pTerm->eOperator = WO_OR; | ||
| 149686 | pTerm->leftCursor = -1; | ||
| 148326 | if( indexable ){ | 149687 | if( indexable ){ |
| 148327 | pTerm->eOperator = WO_OR; | ||
| 148328 | pWC->hasOr = 1; | 149688 | pWC->hasOr = 1; |
| 148329 | }else{ | ||
| 148330 | pTerm->eOperator = WO_OR; | ||
| 148331 | } | 149689 | } |
| 148332 | 149690 | ||
| 148333 | /* For a two-way OR, attempt to implementation case 2. | 149691 | /* For a two-way OR, attempt to implementation case 2. |
| @@ -148400,6 +149758,7 @@ static void exprAnalyzeOrTerm( | |||
| 148400 | assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) ); | 149758 | assert( pOrTerm->wtFlags & (TERM_COPIED|TERM_VIRTUAL) ); |
| 148401 | continue; | 149759 | continue; |
| 148402 | } | 149760 | } |
| 149761 | assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 148403 | iColumn = pOrTerm->u.x.leftColumn; | 149762 | iColumn = pOrTerm->u.x.leftColumn; |
| 148404 | iCursor = pOrTerm->leftCursor; | 149763 | iCursor = pOrTerm->leftCursor; |
| 148405 | pLeft = pOrTerm->pExpr->pLeft; | 149764 | pLeft = pOrTerm->pExpr->pLeft; |
| @@ -148420,6 +149779,7 @@ static void exprAnalyzeOrTerm( | |||
| 148420 | okToChngToIN = 1; | 149779 | okToChngToIN = 1; |
| 148421 | for(; i>=0 && okToChngToIN; i--, pOrTerm++){ | 149780 | for(; i>=0 && okToChngToIN; i--, pOrTerm++){ |
| 148422 | assert( pOrTerm->eOperator & WO_EQ ); | 149781 | assert( pOrTerm->eOperator & WO_EQ ); |
| 149782 | assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 148423 | if( pOrTerm->leftCursor!=iCursor ){ | 149783 | if( pOrTerm->leftCursor!=iCursor ){ |
| 148424 | pOrTerm->wtFlags &= ~TERM_OR_OK; | 149784 | pOrTerm->wtFlags &= ~TERM_OR_OK; |
| 148425 | }else if( pOrTerm->u.x.leftColumn!=iColumn || (iColumn==XN_EXPR | 149785 | }else if( pOrTerm->u.x.leftColumn!=iColumn || (iColumn==XN_EXPR |
| @@ -148456,6 +149816,7 @@ static void exprAnalyzeOrTerm( | |||
| 148456 | for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){ | 149816 | for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){ |
| 148457 | if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue; | 149817 | if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue; |
| 148458 | assert( pOrTerm->eOperator & WO_EQ ); | 149818 | assert( pOrTerm->eOperator & WO_EQ ); |
| 149819 | assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 148459 | assert( pOrTerm->leftCursor==iCursor ); | 149820 | assert( pOrTerm->leftCursor==iCursor ); |
| 148460 | assert( pOrTerm->u.x.leftColumn==iColumn ); | 149821 | assert( pOrTerm->u.x.leftColumn==iColumn ); |
| 148461 | pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0); | 149822 | pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0); |
| @@ -148468,7 +149829,7 @@ static void exprAnalyzeOrTerm( | |||
| 148468 | if( pNew ){ | 149829 | if( pNew ){ |
| 148469 | int idxNew; | 149830 | int idxNew; |
| 148470 | transferJoinMarkings(pNew, pExpr); | 149831 | transferJoinMarkings(pNew, pExpr); |
| 148471 | assert( !ExprHasProperty(pNew, EP_xIsSelect) ); | 149832 | assert( ExprUseXList(pNew) ); |
| 148472 | pNew->x.pList = pList; | 149833 | pNew->x.pList = pList; |
| 148473 | idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC); | 149834 | idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC); |
| 148474 | testcase( idxNew==0 ); | 149835 | testcase( idxNew==0 ); |
| @@ -148596,6 +149957,7 @@ static int exprMightBeIndexed( | |||
| 148596 | assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE ); | 149957 | assert( TK_IS<TK_GE && TK_ISNULL<TK_GE && TK_IN<TK_GE ); |
| 148597 | assert( op<=TK_GE ); | 149958 | assert( op<=TK_GE ); |
| 148598 | if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){ | 149959 | if( pExpr->op==TK_VECTOR && (op>=TK_GT && ALWAYS(op<=TK_GE)) ){ |
| 149960 | assert( ExprUseXList(pExpr) ); | ||
| 148599 | pExpr = pExpr->x.pList->a[0].pExpr; | 149961 | pExpr = pExpr->x.pList->a[0].pExpr; |
| 148600 | 149962 | ||
| 148601 | } | 149963 | } |
| @@ -148662,7 +150024,7 @@ static void exprAnalyze( | |||
| 148662 | if( op==TK_IN ){ | 150024 | if( op==TK_IN ){ |
| 148663 | assert( pExpr->pRight==0 ); | 150025 | assert( pExpr->pRight==0 ); |
| 148664 | if( sqlite3ExprCheckIN(pParse, pExpr) ) return; | 150026 | if( sqlite3ExprCheckIN(pParse, pExpr) ) return; |
| 148665 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 150027 | if( ExprUseXSelect(pExpr) ){ |
| 148666 | pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect); | 150028 | pTerm->prereqRight = exprSelectUsage(pMaskSet, pExpr->x.pSelect); |
| 148667 | }else{ | 150029 | }else{ |
| 148668 | pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList); | 150030 | pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList); |
| @@ -148698,11 +150060,13 @@ static void exprAnalyze( | |||
| 148698 | if( pTerm->u.x.iField>0 ){ | 150060 | if( pTerm->u.x.iField>0 ){ |
| 148699 | assert( op==TK_IN ); | 150061 | assert( op==TK_IN ); |
| 148700 | assert( pLeft->op==TK_VECTOR ); | 150062 | assert( pLeft->op==TK_VECTOR ); |
| 150063 | assert( ExprUseXList(pLeft) ); | ||
| 148701 | pLeft = pLeft->x.pList->a[pTerm->u.x.iField-1].pExpr; | 150064 | pLeft = pLeft->x.pList->a[pTerm->u.x.iField-1].pExpr; |
| 148702 | } | 150065 | } |
| 148703 | 150066 | ||
| 148704 | if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){ | 150067 | if( exprMightBeIndexed(pSrc, prereqLeft, aiCurCol, pLeft, op) ){ |
| 148705 | pTerm->leftCursor = aiCurCol[0]; | 150068 | pTerm->leftCursor = aiCurCol[0]; |
| 150069 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 148706 | pTerm->u.x.leftColumn = aiCurCol[1]; | 150070 | pTerm->u.x.leftColumn = aiCurCol[1]; |
| 148707 | pTerm->eOperator = operatorMask(op) & opMask; | 150071 | pTerm->eOperator = operatorMask(op) & opMask; |
| 148708 | } | 150072 | } |
| @@ -148740,12 +150104,18 @@ static void exprAnalyze( | |||
| 148740 | } | 150104 | } |
| 148741 | pNew->wtFlags |= exprCommute(pParse, pDup); | 150105 | pNew->wtFlags |= exprCommute(pParse, pDup); |
| 148742 | pNew->leftCursor = aiCurCol[0]; | 150106 | pNew->leftCursor = aiCurCol[0]; |
| 150107 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 148743 | pNew->u.x.leftColumn = aiCurCol[1]; | 150108 | pNew->u.x.leftColumn = aiCurCol[1]; |
| 148744 | testcase( (prereqLeft | extraRight) != prereqLeft ); | 150109 | testcase( (prereqLeft | extraRight) != prereqLeft ); |
| 148745 | pNew->prereqRight = prereqLeft | extraRight; | 150110 | pNew->prereqRight = prereqLeft | extraRight; |
| 148746 | pNew->prereqAll = prereqAll; | 150111 | pNew->prereqAll = prereqAll; |
| 148747 | pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask; | 150112 | pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask; |
| 148748 | }else if( op==TK_ISNULL && 0==sqlite3ExprCanBeNull(pLeft) ){ | 150113 | }else |
| 150114 | if( op==TK_ISNULL | ||
| 150115 | && !ExprHasProperty(pExpr,EP_FromJoin) | ||
| 150116 | && 0==sqlite3ExprCanBeNull(pLeft) | ||
| 150117 | ){ | ||
| 150118 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); | ||
| 148749 | pExpr->op = TK_TRUEFALSE; | 150119 | pExpr->op = TK_TRUEFALSE; |
| 148750 | pExpr->u.zToken = "false"; | 150120 | pExpr->u.zToken = "false"; |
| 148751 | ExprSetProperty(pExpr, EP_IsFalse); | 150121 | ExprSetProperty(pExpr, EP_IsFalse); |
| @@ -148771,9 +150141,11 @@ static void exprAnalyze( | |||
| 148771 | ** BETWEEN term is skipped. | 150141 | ** BETWEEN term is skipped. |
| 148772 | */ | 150142 | */ |
| 148773 | else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){ | 150143 | else if( pExpr->op==TK_BETWEEN && pWC->op==TK_AND ){ |
| 148774 | ExprList *pList = pExpr->x.pList; | 150144 | ExprList *pList; |
| 148775 | int i; | 150145 | int i; |
| 148776 | static const u8 ops[] = {TK_GE, TK_LE}; | 150146 | static const u8 ops[] = {TK_GE, TK_LE}; |
| 150147 | assert( ExprUseXList(pExpr) ); | ||
| 150148 | pList = pExpr->x.pList; | ||
| 148777 | assert( pList!=0 ); | 150149 | assert( pList!=0 ); |
| 148778 | assert( pList->nExpr==2 ); | 150150 | assert( pList->nExpr==2 ); |
| 148779 | for(i=0; i<2; i++){ | 150151 | for(i=0; i<2; i++){ |
| @@ -148866,8 +150238,12 @@ static void exprAnalyze( | |||
| 148866 | const char *zCollSeqName; /* Name of collating sequence */ | 150238 | const char *zCollSeqName; /* Name of collating sequence */ |
| 148867 | const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC; | 150239 | const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC; |
| 148868 | 150240 | ||
| 150241 | assert( ExprUseXList(pExpr) ); | ||
| 148869 | pLeft = pExpr->x.pList->a[1].pExpr; | 150242 | pLeft = pExpr->x.pList->a[1].pExpr; |
| 148870 | pStr2 = sqlite3ExprDup(db, pStr1, 0); | 150243 | pStr2 = sqlite3ExprDup(db, pStr1, 0); |
| 150244 | assert( pStr1==0 || !ExprHasProperty(pStr1, EP_IntValue) ); | ||
| 150245 | assert( pStr2==0 || !ExprHasProperty(pStr2, EP_IntValue) ); | ||
| 150246 | |||
| 148871 | 150247 | ||
| 148872 | /* Convert the lower bound to upper-case and the upper bound to | 150248 | /* Convert the lower bound to upper-case and the upper bound to |
| 148873 | ** lower-case (upper-case is less than lower-case in ASCII) so that | 150249 | ** lower-case (upper-case is less than lower-case in ASCII) so that |
| @@ -148942,8 +150318,8 @@ static void exprAnalyze( | |||
| 148942 | for(i=0; i<nLeft; i++){ | 150318 | for(i=0; i<nLeft; i++){ |
| 148943 | int idxNew; | 150319 | int idxNew; |
| 148944 | Expr *pNew; | 150320 | Expr *pNew; |
| 148945 | Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i); | 150321 | Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i, nLeft); |
| 148946 | Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i); | 150322 | Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i, nLeft); |
| 148947 | 150323 | ||
| 148948 | pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight); | 150324 | pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight); |
| 148949 | transferJoinMarkings(pNew, pExpr); | 150325 | transferJoinMarkings(pNew, pExpr); |
| @@ -148967,6 +150343,7 @@ static void exprAnalyze( | |||
| 148967 | else if( pExpr->op==TK_IN | 150343 | else if( pExpr->op==TK_IN |
| 148968 | && pTerm->u.x.iField==0 | 150344 | && pTerm->u.x.iField==0 |
| 148969 | && pExpr->pLeft->op==TK_VECTOR | 150345 | && pExpr->pLeft->op==TK_VECTOR |
| 150346 | && ALWAYS( ExprUseXSelect(pExpr) ) | ||
| 148970 | && pExpr->x.pSelect->pPrior==0 | 150347 | && pExpr->x.pSelect->pPrior==0 |
| 148971 | #ifndef SQLITE_OMIT_WINDOWFUNC | 150348 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 148972 | && pExpr->x.pSelect->pWin==0 | 150349 | && pExpr->x.pSelect->pWin==0 |
| @@ -149130,14 +150507,15 @@ SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){ | |||
| 149130 | if( p->pRight ){ | 150507 | if( p->pRight ){ |
| 149131 | mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pRight); | 150508 | mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pRight); |
| 149132 | assert( p->x.pList==0 ); | 150509 | assert( p->x.pList==0 ); |
| 149133 | }else if( ExprHasProperty(p, EP_xIsSelect) ){ | 150510 | }else if( ExprUseXSelect(p) ){ |
| 149134 | if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1; | 150511 | if( ExprHasProperty(p, EP_VarSelect) ) pMaskSet->bVarSelect = 1; |
| 149135 | mask |= exprSelectUsage(pMaskSet, p->x.pSelect); | 150512 | mask |= exprSelectUsage(pMaskSet, p->x.pSelect); |
| 149136 | }else if( p->x.pList ){ | 150513 | }else if( p->x.pList ){ |
| 149137 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList); | 150514 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->x.pList); |
| 149138 | } | 150515 | } |
| 149139 | #ifndef SQLITE_OMIT_WINDOWFUNC | 150516 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 149140 | if( (p->op==TK_FUNCTION || p->op==TK_AGG_FUNCTION) && p->y.pWin ){ | 150517 | if( (p->op==TK_FUNCTION || p->op==TK_AGG_FUNCTION) && ExprUseYWin(p) ){ |
| 150518 | assert( p->y.pWin!=0 ); | ||
| 149141 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pPartition); | 150519 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pPartition); |
| 149142 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pOrderBy); | 150520 | mask |= sqlite3WhereExprListUsage(pMaskSet, p->y.pWin->pOrderBy); |
| 149143 | mask |= sqlite3WhereExprUsage(pMaskSet, p->y.pWin->pFilter); | 150521 | mask |= sqlite3WhereExprUsage(pMaskSet, p->y.pWin->pFilter); |
| @@ -149212,6 +150590,7 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs( | |||
| 149212 | if( pColRef==0 ) return; | 150590 | if( pColRef==0 ) return; |
| 149213 | pColRef->iTable = pItem->iCursor; | 150591 | pColRef->iTable = pItem->iCursor; |
| 149214 | pColRef->iColumn = k++; | 150592 | pColRef->iColumn = k++; |
| 150593 | assert( ExprUseYTab(pColRef) ); | ||
| 149215 | pColRef->y.pTab = pTab; | 150594 | pColRef->y.pTab = pTab; |
| 149216 | pRhs = sqlite3PExpr(pParse, TK_UPLUS, | 150595 | pRhs = sqlite3PExpr(pParse, TK_UPLUS, |
| 149217 | sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0); | 150596 | sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0); |
| @@ -149513,8 +150892,10 @@ static WhereTerm *whereScanNext(WhereScan *pScan){ | |||
| 149513 | iColumn = pScan->aiColumn[pScan->iEquiv-1]; | 150892 | iColumn = pScan->aiColumn[pScan->iEquiv-1]; |
| 149514 | iCur = pScan->aiCur[pScan->iEquiv-1]; | 150893 | iCur = pScan->aiCur[pScan->iEquiv-1]; |
| 149515 | assert( pWC!=0 ); | 150894 | assert( pWC!=0 ); |
| 150895 | assert( iCur>=0 ); | ||
| 149516 | do{ | 150896 | do{ |
| 149517 | for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){ | 150897 | for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){ |
| 150898 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 || pTerm->leftCursor<0 ); | ||
| 149518 | if( pTerm->leftCursor==iCur | 150899 | if( pTerm->leftCursor==iCur |
| 149519 | && pTerm->u.x.leftColumn==iColumn | 150900 | && pTerm->u.x.leftColumn==iColumn |
| 149520 | && (iColumn!=XN_EXPR | 150901 | && (iColumn!=XN_EXPR |
| @@ -149556,7 +150937,8 @@ static WhereTerm *whereScanNext(WhereScan *pScan){ | |||
| 149556 | } | 150937 | } |
| 149557 | } | 150938 | } |
| 149558 | if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0 | 150939 | if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0 |
| 149559 | && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN | 150940 | && (pX = pTerm->pExpr->pRight, ALWAYS(pX!=0)) |
| 150941 | && pX->op==TK_COLUMN | ||
| 149560 | && pX->iTable==pScan->aiCur[0] | 150942 | && pX->iTable==pScan->aiCur[0] |
| 149561 | && pX->iColumn==pScan->aiColumn[0] | 150943 | && pX->iColumn==pScan->aiColumn[0] |
| 149562 | ){ | 150944 | ){ |
| @@ -149953,6 +151335,7 @@ static int termCanDriveIndex( | |||
| 149953 | return 0; | 151335 | return 0; |
| 149954 | } | 151336 | } |
| 149955 | if( (pTerm->prereqRight & notReady)!=0 ) return 0; | 151337 | if( (pTerm->prereqRight & notReady)!=0 ) return 0; |
| 151338 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 149956 | if( pTerm->u.x.leftColumn<0 ) return 0; | 151339 | if( pTerm->u.x.leftColumn<0 ) return 0; |
| 149957 | aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity; | 151340 | aff = pSrc->pTab->aCol[pTerm->u.x.leftColumn].affinity; |
| 149958 | if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0; | 151341 | if( !sqlite3IndexAffinityOk(pTerm->pExpr, aff) ) return 0; |
| @@ -150025,14 +151408,17 @@ static void constructAutomaticIndex( | |||
| 150025 | sqlite3ExprDup(pParse->db, pExpr, 0)); | 151408 | sqlite3ExprDup(pParse->db, pExpr, 0)); |
| 150026 | } | 151409 | } |
| 150027 | if( termCanDriveIndex(pTerm, pSrc, notReady) ){ | 151410 | if( termCanDriveIndex(pTerm, pSrc, notReady) ){ |
| 150028 | int iCol = pTerm->u.x.leftColumn; | 151411 | int iCol; |
| 150029 | Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol); | 151412 | Bitmask cMask; |
| 151413 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 151414 | iCol = pTerm->u.x.leftColumn; | ||
| 151415 | cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol); | ||
| 150030 | testcase( iCol==BMS ); | 151416 | testcase( iCol==BMS ); |
| 150031 | testcase( iCol==BMS-1 ); | 151417 | testcase( iCol==BMS-1 ); |
| 150032 | if( !sentWarning ){ | 151418 | if( !sentWarning ){ |
| 150033 | sqlite3_log(SQLITE_WARNING_AUTOINDEX, | 151419 | sqlite3_log(SQLITE_WARNING_AUTOINDEX, |
| 150034 | "automatic index on %s(%s)", pTable->zName, | 151420 | "automatic index on %s(%s)", pTable->zName, |
| 150035 | pTable->aCol[iCol].zName); | 151421 | pTable->aCol[iCol].zCnName); |
| 150036 | sentWarning = 1; | 151422 | sentWarning = 1; |
| 150037 | } | 151423 | } |
| 150038 | if( (idxCols & cMask)==0 ){ | 151424 | if( (idxCols & cMask)==0 ){ |
| @@ -150078,8 +151464,11 @@ static void constructAutomaticIndex( | |||
| 150078 | idxCols = 0; | 151464 | idxCols = 0; |
| 150079 | for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){ | 151465 | for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){ |
| 150080 | if( termCanDriveIndex(pTerm, pSrc, notReady) ){ | 151466 | if( termCanDriveIndex(pTerm, pSrc, notReady) ){ |
| 150081 | int iCol = pTerm->u.x.leftColumn; | 151467 | int iCol; |
| 150082 | Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol); | 151468 | Bitmask cMask; |
| 151469 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 151470 | iCol = pTerm->u.x.leftColumn; | ||
| 151471 | cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol); | ||
| 150083 | testcase( iCol==BMS-1 ); | 151472 | testcase( iCol==BMS-1 ); |
| 150084 | testcase( iCol==BMS ); | 151473 | testcase( iCol==BMS ); |
| 150085 | if( (idxCols & cMask)==0 ){ | 151474 | if( (idxCols & cMask)==0 ){ |
| @@ -150206,6 +151595,7 @@ static sqlite3_index_info *allocateIndexInfo( | |||
| 150206 | testcase( pTerm->eOperator & WO_ALL ); | 151595 | testcase( pTerm->eOperator & WO_ALL ); |
| 150207 | if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; | 151596 | if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue; |
| 150208 | if( pTerm->wtFlags & TERM_VNULL ) continue; | 151597 | if( pTerm->wtFlags & TERM_VNULL ) continue; |
| 151598 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 150209 | assert( pTerm->u.x.leftColumn>=(-1) ); | 151599 | assert( pTerm->u.x.leftColumn>=(-1) ); |
| 150210 | nTerm++; | 151600 | nTerm++; |
| 150211 | } | 151601 | } |
| @@ -150266,6 +151656,7 @@ static sqlite3_index_info *allocateIndexInfo( | |||
| 150266 | ){ | 151656 | ){ |
| 150267 | continue; | 151657 | continue; |
| 150268 | } | 151658 | } |
| 151659 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 150269 | assert( pTerm->u.x.leftColumn>=(-1) ); | 151660 | assert( pTerm->u.x.leftColumn>=(-1) ); |
| 150270 | pIdxCons[j].iColumn = pTerm->u.x.leftColumn; | 151661 | pIdxCons[j].iColumn = pTerm->u.x.leftColumn; |
| 150271 | pIdxCons[j].iTermOffset = i; | 151662 | pIdxCons[j].iTermOffset = i; |
| @@ -151029,6 +152420,7 @@ SQLITE_PRIVATE void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){ | |||
| 151029 | if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L'; | 152420 | if( ExprHasProperty(pTerm->pExpr, EP_FromJoin) ) zType[2] = 'L'; |
| 151030 | if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C'; | 152421 | if( pTerm->wtFlags & TERM_CODED ) zType[3] = 'C'; |
| 151031 | if( pTerm->eOperator & WO_SINGLE ){ | 152422 | if( pTerm->eOperator & WO_SINGLE ){ |
| 152423 | assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 ); | ||
| 151032 | sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}", | 152424 | sqlite3_snprintf(sizeof(zLeft),zLeft,"left={%d:%d}", |
| 151033 | pTerm->leftCursor, pTerm->u.x.leftColumn); | 152425 | pTerm->leftCursor, pTerm->u.x.leftColumn); |
| 151034 | }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){ | 152426 | }else if( (pTerm->eOperator & WO_OR)!=0 && pTerm->u.pOrInfo!=0 ){ |
| @@ -151046,7 +152438,7 @@ SQLITE_PRIVATE void sqlite3WhereTermPrint(WhereTerm *pTerm, int iTerm){ | |||
| 151046 | sqlite3DebugPrintf(" prob=%-3d prereq=%llx,%llx", | 152438 | sqlite3DebugPrintf(" prob=%-3d prereq=%llx,%llx", |
| 151047 | pTerm->truthProb, (u64)pTerm->prereqAll, (u64)pTerm->prereqRight); | 152439 | pTerm->truthProb, (u64)pTerm->prereqAll, (u64)pTerm->prereqRight); |
| 151048 | } | 152440 | } |
| 151049 | if( pTerm->u.x.iField ){ | 152441 | if( (pTerm->eOperator & (WO_OR|WO_AND))==0 && pTerm->u.x.iField ){ |
| 151050 | sqlite3DebugPrintf(" iField=%d", pTerm->u.x.iField); | 152442 | sqlite3DebugPrintf(" iField=%d", pTerm->u.x.iField); |
| 151051 | } | 152443 | } |
| 151052 | if( pTerm->iParent>=0 ){ | 152444 | if( pTerm->iParent>=0 ){ |
| @@ -151210,7 +152602,8 @@ static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){ | |||
| 151210 | assert( pWInfo!=0 ); | 152602 | assert( pWInfo!=0 ); |
| 151211 | for(i=0; i<pWInfo->nLevel; i++){ | 152603 | for(i=0; i<pWInfo->nLevel; i++){ |
| 151212 | WhereLevel *pLevel = &pWInfo->a[i]; | 152604 | WhereLevel *pLevel = &pWInfo->a[i]; |
| 151213 | if( pLevel->pWLoop && (pLevel->pWLoop->wsFlags & WHERE_IN_ABLE) ){ | 152605 | if( pLevel->pWLoop && (pLevel->pWLoop->wsFlags & WHERE_IN_ABLE)!=0 ){ |
| 152606 | assert( (pLevel->pWLoop->wsFlags & WHERE_MULTI_OR)==0 ); | ||
| 151214 | sqlite3DbFree(db, pLevel->u.in.aInLoop); | 152607 | sqlite3DbFree(db, pLevel->u.in.aInLoop); |
| 151215 | } | 152608 | } |
| 151216 | } | 152609 | } |
| @@ -151238,7 +152631,8 @@ static void whereUndoExprMods(WhereInfo *pWInfo){ | |||
| 151238 | /* | 152631 | /* |
| 151239 | ** Return TRUE if all of the following are true: | 152632 | ** Return TRUE if all of the following are true: |
| 151240 | ** | 152633 | ** |
| 151241 | ** (1) X has the same or lower cost that Y | 152634 | ** (1) X has the same or lower cost, or returns the same or fewer rows, |
| 152635 | ** than Y. | ||
| 151242 | ** (2) X uses fewer WHERE clause terms than Y | 152636 | ** (2) X uses fewer WHERE clause terms than Y |
| 151243 | ** (3) Every WHERE clause term used by X is also used by Y | 152637 | ** (3) Every WHERE clause term used by X is also used by Y |
| 151244 | ** (4) X skips at least as many columns as Y | 152638 | ** (4) X skips at least as many columns as Y |
| @@ -151261,11 +152655,8 @@ static int whereLoopCheaperProperSubset( | |||
| 151261 | if( pX->nLTerm-pX->nSkip >= pY->nLTerm-pY->nSkip ){ | 152655 | if( pX->nLTerm-pX->nSkip >= pY->nLTerm-pY->nSkip ){ |
| 151262 | return 0; /* X is not a subset of Y */ | 152656 | return 0; /* X is not a subset of Y */ |
| 151263 | } | 152657 | } |
| 152658 | if( pX->rRun>pY->rRun && pX->nOut>pY->nOut ) return 0; | ||
| 151264 | if( pY->nSkip > pX->nSkip ) return 0; | 152659 | if( pY->nSkip > pX->nSkip ) return 0; |
| 151265 | if( pX->rRun >= pY->rRun ){ | ||
| 151266 | if( pX->rRun > pY->rRun ) return 0; /* X costs more than Y */ | ||
| 151267 | if( pX->nOut > pY->nOut ) return 0; /* X costs more than Y */ | ||
| 151268 | } | ||
| 151269 | for(i=pX->nLTerm-1; i>=0; i--){ | 152660 | for(i=pX->nLTerm-1; i>=0; i--){ |
| 151270 | if( pX->aLTerm[i]==0 ) continue; | 152661 | if( pX->aLTerm[i]==0 ) continue; |
| 151271 | for(j=pY->nLTerm-1; j>=0; j--){ | 152662 | for(j=pY->nLTerm-1; j>=0; j--){ |
| @@ -151281,8 +152672,8 @@ static int whereLoopCheaperProperSubset( | |||
| 151281 | } | 152672 | } |
| 151282 | 152673 | ||
| 151283 | /* | 152674 | /* |
| 151284 | ** Try to adjust the cost of WhereLoop pTemplate upwards or downwards so | 152675 | ** Try to adjust the cost and number of output rows of WhereLoop pTemplate |
| 151285 | ** that: | 152676 | ** upwards or downwards so that: |
| 151286 | ** | 152677 | ** |
| 151287 | ** (1) pTemplate costs less than any other WhereLoops that are a proper | 152678 | ** (1) pTemplate costs less than any other WhereLoops that are a proper |
| 151288 | ** subset of pTemplate | 152679 | ** subset of pTemplate |
| @@ -151303,16 +152694,20 @@ static void whereLoopAdjustCost(const WhereLoop *p, WhereLoop *pTemplate){ | |||
| 151303 | /* Adjust pTemplate cost downward so that it is cheaper than its | 152694 | /* Adjust pTemplate cost downward so that it is cheaper than its |
| 151304 | ** subset p. */ | 152695 | ** subset p. */ |
| 151305 | WHERETRACE(0x80,("subset cost adjustment %d,%d to %d,%d\n", | 152696 | WHERETRACE(0x80,("subset cost adjustment %d,%d to %d,%d\n", |
| 151306 | pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut-1)); | 152697 | pTemplate->rRun, pTemplate->nOut, |
| 151307 | pTemplate->rRun = p->rRun; | 152698 | MIN(p->rRun, pTemplate->rRun), |
| 151308 | pTemplate->nOut = p->nOut - 1; | 152699 | MIN(p->nOut - 1, pTemplate->nOut))); |
| 152700 | pTemplate->rRun = MIN(p->rRun, pTemplate->rRun); | ||
| 152701 | pTemplate->nOut = MIN(p->nOut - 1, pTemplate->nOut); | ||
| 151309 | }else if( whereLoopCheaperProperSubset(pTemplate, p) ){ | 152702 | }else if( whereLoopCheaperProperSubset(pTemplate, p) ){ |
| 151310 | /* Adjust pTemplate cost upward so that it is costlier than p since | 152703 | /* Adjust pTemplate cost upward so that it is costlier than p since |
| 151311 | ** pTemplate is a proper subset of p */ | 152704 | ** pTemplate is a proper subset of p */ |
| 151312 | WHERETRACE(0x80,("subset cost adjustment %d,%d to %d,%d\n", | 152705 | WHERETRACE(0x80,("subset cost adjustment %d,%d to %d,%d\n", |
| 151313 | pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut+1)); | 152706 | pTemplate->rRun, pTemplate->nOut, |
| 151314 | pTemplate->rRun = p->rRun; | 152707 | MAX(p->rRun, pTemplate->rRun), |
| 151315 | pTemplate->nOut = p->nOut + 1; | 152708 | MAX(p->nOut + 1, pTemplate->nOut))); |
| 152709 | pTemplate->rRun = MAX(p->rRun, pTemplate->rRun); | ||
| 152710 | pTemplate->nOut = MAX(p->nOut + 1, pTemplate->nOut); | ||
| 151316 | } | 152711 | } |
| 151317 | } | 152712 | } |
| 151318 | } | 152713 | } |
| @@ -151643,9 +153038,12 @@ static int whereRangeVectorLen( | |||
| 151643 | char aff; /* Comparison affinity */ | 153038 | char aff; /* Comparison affinity */ |
| 151644 | char idxaff = 0; /* Indexed columns affinity */ | 153039 | char idxaff = 0; /* Indexed columns affinity */ |
| 151645 | CollSeq *pColl; /* Comparison collation sequence */ | 153040 | CollSeq *pColl; /* Comparison collation sequence */ |
| 151646 | Expr *pLhs = pTerm->pExpr->pLeft->x.pList->a[i].pExpr; | 153041 | Expr *pLhs, *pRhs; |
| 151647 | Expr *pRhs = pTerm->pExpr->pRight; | 153042 | |
| 151648 | if( pRhs->flags & EP_xIsSelect ){ | 153043 | assert( ExprUseXList(pTerm->pExpr->pLeft) ); |
| 153044 | pLhs = pTerm->pExpr->pLeft->x.pList->a[i].pExpr; | ||
| 153045 | pRhs = pTerm->pExpr->pRight; | ||
| 153046 | if( ExprUseXSelect(pRhs) ){ | ||
| 151649 | pRhs = pRhs->x.pSelect->pEList->a[i].pExpr; | 153047 | pRhs = pRhs->x.pSelect->pEList->a[i].pExpr; |
| 151650 | }else{ | 153048 | }else{ |
| 151651 | pRhs = pRhs->x.pList->a[i].pExpr; | 153049 | pRhs = pRhs->x.pList->a[i].pExpr; |
| @@ -151806,7 +153204,7 @@ static int whereLoopAddBtreeIndex( | |||
| 151806 | 153204 | ||
| 151807 | if( eOp & WO_IN ){ | 153205 | if( eOp & WO_IN ){ |
| 151808 | Expr *pExpr = pTerm->pExpr; | 153206 | Expr *pExpr = pTerm->pExpr; |
| 151809 | if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 153207 | if( ExprUseXSelect(pExpr) ){ |
| 151810 | /* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */ | 153208 | /* "x IN (SELECT ...)": TUNING: the SELECT returns 25 rows */ |
| 151811 | int i; | 153209 | int i; |
| 151812 | nIn = 46; assert( 46==sqlite3LogEst(25) ); | 153210 | nIn = 46; assert( 46==sqlite3LogEst(25) ); |
| @@ -151947,7 +153345,7 @@ static int whereLoopAddBtreeIndex( | |||
| 151947 | if( nInMul==0 | 153345 | if( nInMul==0 |
| 151948 | && pProbe->nSample | 153346 | && pProbe->nSample |
| 151949 | && ALWAYS(pNew->u.btree.nEq<=pProbe->nSampleCol) | 153347 | && ALWAYS(pNew->u.btree.nEq<=pProbe->nSampleCol) |
| 151950 | && ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect)) | 153348 | && ((eOp & WO_IN)==0 || ExprUseXList(pTerm->pExpr)) |
| 151951 | && OptimizationEnabled(db, SQLITE_Stat4) | 153349 | && OptimizationEnabled(db, SQLITE_Stat4) |
| 151952 | ){ | 153350 | ){ |
| 151953 | Expr *pExpr = pTerm->pExpr; | 153351 | Expr *pExpr = pTerm->pExpr; |
| @@ -152211,7 +153609,6 @@ static int whereLoopAddBtree( | |||
| 152211 | int iSortIdx = 1; /* Index number */ | 153609 | int iSortIdx = 1; /* Index number */ |
| 152212 | int b; /* A boolean value */ | 153610 | int b; /* A boolean value */ |
| 152213 | LogEst rSize; /* number of rows in the table */ | 153611 | LogEst rSize; /* number of rows in the table */ |
| 152214 | LogEst rLogSize; /* Logarithm of the number of rows in the table */ | ||
| 152215 | WhereClause *pWC; /* The parsed WHERE clause */ | 153612 | WhereClause *pWC; /* The parsed WHERE clause */ |
| 152216 | Table *pTab; /* Table being queried */ | 153613 | Table *pTab; /* Table being queried */ |
| 152217 | 153614 | ||
| @@ -152224,6 +153621,7 @@ static int whereLoopAddBtree( | |||
| 152224 | assert( !IsVirtual(pSrc->pTab) ); | 153621 | assert( !IsVirtual(pSrc->pTab) ); |
| 152225 | 153622 | ||
| 152226 | if( pSrc->fg.isIndexedBy ){ | 153623 | if( pSrc->fg.isIndexedBy ){ |
| 153624 | assert( pSrc->fg.isCte==0 ); | ||
| 152227 | /* An INDEXED BY clause specifies a particular index to use */ | 153625 | /* An INDEXED BY clause specifies a particular index to use */ |
| 152228 | pProbe = pSrc->u2.pIBIndex; | 153626 | pProbe = pSrc->u2.pIBIndex; |
| 152229 | }else if( !HasRowid(pTab) ){ | 153627 | }else if( !HasRowid(pTab) ){ |
| @@ -152254,7 +153652,6 @@ static int whereLoopAddBtree( | |||
| 152254 | pProbe = &sPk; | 153652 | pProbe = &sPk; |
| 152255 | } | 153653 | } |
| 152256 | rSize = pTab->nRowLogEst; | 153654 | rSize = pTab->nRowLogEst; |
| 152257 | rLogSize = estLog(rSize); | ||
| 152258 | 153655 | ||
| 152259 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX | 153656 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| 152260 | /* Automatic indexes */ | 153657 | /* Automatic indexes */ |
| @@ -152268,8 +153665,10 @@ static int whereLoopAddBtree( | |||
| 152268 | && !pSrc->fg.isRecursive /* Not a recursive common table expression. */ | 153665 | && !pSrc->fg.isRecursive /* Not a recursive common table expression. */ |
| 152269 | ){ | 153666 | ){ |
| 152270 | /* Generate auto-index WhereLoops */ | 153667 | /* Generate auto-index WhereLoops */ |
| 153668 | LogEst rLogSize; /* Logarithm of the number of rows in the table */ | ||
| 152271 | WhereTerm *pTerm; | 153669 | WhereTerm *pTerm; |
| 152272 | WhereTerm *pWCEnd = pWC->a + pWC->nTerm; | 153670 | WhereTerm *pWCEnd = pWC->a + pWC->nTerm; |
| 153671 | rLogSize = estLog(rSize); | ||
| 152273 | for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){ | 153672 | for(pTerm=pWC->a; rc==SQLITE_OK && pTerm<pWCEnd; pTerm++){ |
| 152274 | if( pTerm->prereqRight & pNew->maskSelf ) continue; | 153673 | if( pTerm->prereqRight & pNew->maskSelf ) continue; |
| 152275 | if( termCanDriveIndex(pTerm, pSrc, 0) ){ | 153674 | if( termCanDriveIndex(pTerm, pSrc, 0) ){ |
| @@ -152287,7 +153686,7 @@ static int whereLoopAddBtree( | |||
| 152287 | ** those objects, since there is no opportunity to add schema | 153686 | ** those objects, since there is no opportunity to add schema |
| 152288 | ** indexes on subqueries and views. */ | 153687 | ** indexes on subqueries and views. */ |
| 152289 | pNew->rSetup = rLogSize + rSize; | 153688 | pNew->rSetup = rLogSize + rSize; |
| 152290 | if( pTab->pSelect==0 && (pTab->tabFlags & TF_Ephemeral)==0 ){ | 153689 | if( !IsView(pTab) && (pTab->tabFlags & TF_Ephemeral)==0 ){ |
| 152291 | pNew->rSetup += 28; | 153690 | pNew->rSetup += 28; |
| 152292 | }else{ | 153691 | }else{ |
| 152293 | pNew->rSetup -= 10; | 153692 | pNew->rSetup -= 10; |
| @@ -153309,7 +154708,7 @@ static i8 wherePathSatisfiesOrderBy( | |||
| 153309 | if( obSat==obDone ) return (i8)nOrderBy; | 154708 | if( obSat==obDone ) return (i8)nOrderBy; |
| 153310 | if( !isOrderDistinct ){ | 154709 | if( !isOrderDistinct ){ |
| 153311 | for(i=nOrderBy-1; i>0; i--){ | 154710 | for(i=nOrderBy-1; i>0; i--){ |
| 153312 | Bitmask m = MASKBIT(i) - 1; | 154711 | Bitmask m = ALWAYS(i<BMS) ? MASKBIT(i) - 1 : 0; |
| 153313 | if( (obSat&m)==m ) return i; | 154712 | if( (obSat&m)==m ) return i; |
| 153314 | } | 154713 | } |
| 153315 | return 0; | 154714 | return 0; |
| @@ -153819,6 +155218,7 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ | |||
| 153819 | int j; | 155218 | int j; |
| 153820 | Table *pTab; | 155219 | Table *pTab; |
| 153821 | Index *pIdx; | 155220 | Index *pIdx; |
| 155221 | WhereScan scan; | ||
| 153822 | 155222 | ||
| 153823 | pWInfo = pBuilder->pWInfo; | 155223 | pWInfo = pBuilder->pWInfo; |
| 153824 | if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0; | 155224 | if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0; |
| @@ -153832,7 +155232,8 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ | |||
| 153832 | pLoop = pBuilder->pNew; | 155232 | pLoop = pBuilder->pNew; |
| 153833 | pLoop->wsFlags = 0; | 155233 | pLoop->wsFlags = 0; |
| 153834 | pLoop->nSkip = 0; | 155234 | pLoop->nSkip = 0; |
| 153835 | pTerm = sqlite3WhereFindTerm(pWC, iCur, -1, 0, WO_EQ|WO_IS, 0); | 155235 | pTerm = whereScanInit(&scan, pWC, iCur, -1, WO_EQ|WO_IS, 0); |
| 155236 | while( pTerm && pTerm->prereqRight ) pTerm = whereScanNext(&scan); | ||
| 153836 | if( pTerm ){ | 155237 | if( pTerm ){ |
| 153837 | testcase( pTerm->eOperator & WO_IS ); | 155238 | testcase( pTerm->eOperator & WO_IS ); |
| 153838 | pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW; | 155239 | pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW; |
| @@ -153851,7 +155252,8 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ | |||
| 153851 | ) continue; | 155252 | ) continue; |
| 153852 | opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ; | 155253 | opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ; |
| 153853 | for(j=0; j<pIdx->nKeyCol; j++){ | 155254 | for(j=0; j<pIdx->nKeyCol; j++){ |
| 153854 | pTerm = sqlite3WhereFindTerm(pWC, iCur, j, 0, opMask, pIdx); | 155255 | pTerm = whereScanInit(&scan, pWC, iCur, j, opMask, pIdx); |
| 155256 | while( pTerm && pTerm->prereqRight ) pTerm = whereScanNext(&scan); | ||
| 153855 | if( pTerm==0 ) break; | 155257 | if( pTerm==0 ) break; |
| 153856 | testcase( pTerm->eOperator & WO_IS ); | 155258 | testcase( pTerm->eOperator & WO_IS ); |
| 153857 | pLoop->aLTerm[j] = pTerm; | 155259 | pLoop->aLTerm[j] = pTerm; |
| @@ -153880,9 +155282,15 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){ | |||
| 153880 | if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){ | 155282 | if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){ |
| 153881 | pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE; | 155283 | pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE; |
| 153882 | } | 155284 | } |
| 155285 | if( scan.iEquiv>1 ) pLoop->wsFlags |= WHERE_TRANSCONS; | ||
| 153883 | #ifdef SQLITE_DEBUG | 155286 | #ifdef SQLITE_DEBUG |
| 153884 | pLoop->cId = '0'; | 155287 | pLoop->cId = '0'; |
| 153885 | #endif | 155288 | #endif |
| 155289 | #ifdef WHERETRACE_ENABLED | ||
| 155290 | if( sqlite3WhereTrace ){ | ||
| 155291 | sqlite3DebugPrintf("whereShortCut() used to compute solution\n"); | ||
| 155292 | } | ||
| 155293 | #endif | ||
| 153886 | return 1; | 155294 | return 1; |
| 153887 | } | 155295 | } |
| 153888 | return 0; | 155296 | return 0; |
| @@ -154438,7 +155846,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( | |||
| 154438 | pTab = pTabItem->pTab; | 155846 | pTab = pTabItem->pTab; |
| 154439 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); | 155847 | iDb = sqlite3SchemaToIndex(db, pTab->pSchema); |
| 154440 | pLoop = pLevel->pWLoop; | 155848 | pLoop = pLevel->pWLoop; |
| 154441 | if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ){ | 155849 | if( (pTab->tabFlags & TF_Ephemeral)!=0 || IsView(pTab) ){ |
| 154442 | /* Do nothing */ | 155850 | /* Do nothing */ |
| 154443 | }else | 155851 | }else |
| 154444 | #ifndef SQLITE_OMIT_VIRTUALTABLE | 155852 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| @@ -154563,6 +155971,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin( | |||
| 154563 | for(ii=0; ii<nTabList; ii++){ | 155971 | for(ii=0; ii<nTabList; ii++){ |
| 154564 | int addrExplain; | 155972 | int addrExplain; |
| 154565 | int wsFlags; | 155973 | int wsFlags; |
| 155974 | if( pParse->nErr ) goto whereBeginError; | ||
| 154566 | pLevel = &pWInfo->a[ii]; | 155975 | pLevel = &pWInfo->a[ii]; |
| 154567 | wsFlags = pLevel->pWLoop->wsFlags; | 155976 | wsFlags = pLevel->pWLoop->wsFlags; |
| 154568 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX | 155977 | #ifndef SQLITE_OMIT_AUTOMATIC_INDEX |
| @@ -154684,7 +156093,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 154684 | }else{ | 156093 | }else{ |
| 154685 | sqlite3VdbeResolveLabel(v, pLevel->addrCont); | 156094 | sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 154686 | } | 156095 | } |
| 154687 | if( pLoop->wsFlags & WHERE_IN_ABLE && pLevel->u.in.nIn>0 ){ | 156096 | if( (pLoop->wsFlags & WHERE_IN_ABLE)!=0 && pLevel->u.in.nIn>0 ){ |
| 154688 | struct InLoop *pIn; | 156097 | struct InLoop *pIn; |
| 154689 | int j; | 156098 | int j; |
| 154690 | sqlite3VdbeResolveLabel(v, pLevel->addrNxt); | 156099 | sqlite3VdbeResolveLabel(v, pLevel->addrNxt); |
| @@ -154753,8 +156162,14 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 154753 | sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur); | 156162 | sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur); |
| 154754 | } | 156163 | } |
| 154755 | if( (ws & WHERE_INDEXED) | 156164 | if( (ws & WHERE_INDEXED) |
| 154756 | || ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx) | 156165 | || ((ws & WHERE_MULTI_OR) && pLevel->u.pCoveringIdx) |
| 154757 | ){ | 156166 | ){ |
| 156167 | if( ws & WHERE_MULTI_OR ){ | ||
| 156168 | Index *pIx = pLevel->u.pCoveringIdx; | ||
| 156169 | int iDb = sqlite3SchemaToIndex(db, pIx->pSchema); | ||
| 156170 | sqlite3VdbeAddOp3(v, OP_ReopenIdx, pLevel->iIdxCur, pIx->tnum, iDb); | ||
| 156171 | sqlite3VdbeSetP4KeyInfo(pParse, pIx); | ||
| 156172 | } | ||
| 154758 | sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur); | 156173 | sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur); |
| 154759 | } | 156174 | } |
| 154760 | if( pLevel->op==OP_Return ){ | 156175 | if( pLevel->op==OP_Return ){ |
| @@ -154801,7 +156216,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 154801 | ** created for the ONEPASS optimization. | 156216 | ** created for the ONEPASS optimization. |
| 154802 | */ | 156217 | */ |
| 154803 | if( (pTab->tabFlags & TF_Ephemeral)==0 | 156218 | if( (pTab->tabFlags & TF_Ephemeral)==0 |
| 154804 | && pTab->pSelect==0 | 156219 | && !IsView(pTab) |
| 154805 | && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 | 156220 | && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 |
| 154806 | ){ | 156221 | ){ |
| 154807 | int ws = pLoop->wsFlags; | 156222 | int ws = pLoop->wsFlags; |
| @@ -154831,7 +156246,7 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){ | |||
| 154831 | if( pLoop->wsFlags & (WHERE_INDEXED|WHERE_IDX_ONLY) ){ | 156246 | if( pLoop->wsFlags & (WHERE_INDEXED|WHERE_IDX_ONLY) ){ |
| 154832 | pIdx = pLoop->u.btree.pIndex; | 156247 | pIdx = pLoop->u.btree.pIndex; |
| 154833 | }else if( pLoop->wsFlags & WHERE_MULTI_OR ){ | 156248 | }else if( pLoop->wsFlags & WHERE_MULTI_OR ){ |
| 154834 | pIdx = pLevel->u.pCovidx; | 156249 | pIdx = pLevel->u.pCoveringIdx; |
| 154835 | } | 156250 | } |
| 154836 | if( pIdx | 156251 | if( pIdx |
| 154837 | && !db->mallocFailed | 156252 | && !db->mallocFailed |
| @@ -155492,7 +156907,7 @@ static void noopValueFunc(sqlite3_context *p){ UNUSED_PARAMETER(p); /*no-op*/ } | |||
| 155492 | /* Window functions that use all window interfaces: xStep, xFinal, | 156907 | /* Window functions that use all window interfaces: xStep, xFinal, |
| 155493 | ** xValue, and xInverse */ | 156908 | ** xValue, and xInverse */ |
| 155494 | #define WINDOWFUNCALL(name,nArg,extra) { \ | 156909 | #define WINDOWFUNCALL(name,nArg,extra) { \ |
| 155495 | nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \ | 156910 | nArg, (SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \ |
| 155496 | name ## StepFunc, name ## FinalizeFunc, name ## ValueFunc, \ | 156911 | name ## StepFunc, name ## FinalizeFunc, name ## ValueFunc, \ |
| 155497 | name ## InvFunc, name ## Name, {0} \ | 156912 | name ## InvFunc, name ## Name, {0} \ |
| 155498 | } | 156913 | } |
| @@ -155500,7 +156915,7 @@ static void noopValueFunc(sqlite3_context *p){ UNUSED_PARAMETER(p); /*no-op*/ } | |||
| 155500 | /* Window functions that are implemented using bytecode and thus have | 156915 | /* Window functions that are implemented using bytecode and thus have |
| 155501 | ** no-op routines for their methods */ | 156916 | ** no-op routines for their methods */ |
| 155502 | #define WINDOWFUNCNOOP(name,nArg,extra) { \ | 156917 | #define WINDOWFUNCNOOP(name,nArg,extra) { \ |
| 155503 | nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \ | 156918 | nArg, (SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \ |
| 155504 | noopStepFunc, noopValueFunc, noopValueFunc, \ | 156919 | noopStepFunc, noopValueFunc, noopValueFunc, \ |
| 155505 | noopStepFunc, name ## Name, {0} \ | 156920 | noopStepFunc, name ## Name, {0} \ |
| 155506 | } | 156921 | } |
| @@ -155509,7 +156924,7 @@ static void noopValueFunc(sqlite3_context *p){ UNUSED_PARAMETER(p); /*no-op*/ } | |||
| 155509 | ** same routine for xFinalize and xValue and which never call | 156924 | ** same routine for xFinalize and xValue and which never call |
| 155510 | ** xInverse. */ | 156925 | ** xInverse. */ |
| 155511 | #define WINDOWFUNCX(name,nArg,extra) { \ | 156926 | #define WINDOWFUNCX(name,nArg,extra) { \ |
| 155512 | nArg, (SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \ | 156927 | nArg, (SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_WINDOW|extra), 0, 0, \ |
| 155513 | name ## StepFunc, name ## ValueFunc, name ## ValueFunc, \ | 156928 | name ## StepFunc, name ## ValueFunc, name ## ValueFunc, \ |
| 155514 | noopStepFunc, name ## Name, {0} \ | 156929 | noopStepFunc, name ## Name, {0} \ |
| 155515 | } | 156930 | } |
| @@ -155819,9 +157234,7 @@ static ExprList *exprListAppendList( | |||
| 155819 | if( bIntToNull ){ | 157234 | if( bIntToNull ){ |
| 155820 | int iDummy; | 157235 | int iDummy; |
| 155821 | Expr *pSub; | 157236 | Expr *pSub; |
| 155822 | for(pSub=pDup; ExprHasProperty(pSub, EP_Skip); pSub=pSub->pLeft){ | 157237 | pSub = sqlite3ExprSkipCollateAndLikely(pDup); |
| 155823 | assert( pSub ); | ||
| 155824 | } | ||
| 155825 | if( sqlite3ExprIsInteger(pSub, &iDummy) ){ | 157238 | if( sqlite3ExprIsInteger(pSub, &iDummy) ){ |
| 155826 | pSub->op = TK_NULL; | 157239 | pSub->op = TK_NULL; |
| 155827 | pSub->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse); | 157240 | pSub->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse); |
| @@ -155854,7 +157267,8 @@ static int sqlite3WindowExtraAggFuncDepth(Walker *pWalker, Expr *pExpr){ | |||
| 155854 | 157267 | ||
| 155855 | static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){ | 157268 | static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){ |
| 155856 | if( pExpr->op==TK_AGG_FUNCTION && pExpr->pAggInfo==0 ){ | 157269 | if( pExpr->op==TK_AGG_FUNCTION && pExpr->pAggInfo==0 ){ |
| 155857 | sqlite3ErrorMsg(pWalker->pParse, | 157270 | assert( !ExprHasProperty(pExpr, EP_IntValue) ); |
| 157271 | sqlite3ErrorMsg(pWalker->pParse, | ||
| 155858 | "misuse of aggregate: %s()", pExpr->u.zToken); | 157272 | "misuse of aggregate: %s()", pExpr->u.zToken); |
| 155859 | } | 157273 | } |
| 155860 | return WRC_Continue; | 157274 | return WRC_Continue; |
| @@ -155942,7 +157356,9 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ | |||
| 155942 | ** window function - one for the accumulator, another for interim | 157356 | ** window function - one for the accumulator, another for interim |
| 155943 | ** results. */ | 157357 | ** results. */ |
| 155944 | for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ | 157358 | for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ |
| 155945 | ExprList *pArgs = pWin->pOwner->x.pList; | 157359 | ExprList *pArgs; |
| 157360 | assert( ExprUseXList(pWin->pOwner) ); | ||
| 157361 | pArgs = pWin->pOwner->x.pList; | ||
| 155946 | if( pWin->pFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){ | 157362 | if( pWin->pFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){ |
| 155947 | selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist); | 157363 | selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist); |
| 155948 | pWin->iArgCol = (pSublist ? pSublist->nExpr : 0); | 157364 | pWin->iArgCol = (pSublist ? pSublist->nExpr : 0); |
| @@ -155979,11 +157395,14 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ | |||
| 155979 | ("New window-function subquery in FROM clause of (%u/%p)\n", | 157395 | ("New window-function subquery in FROM clause of (%u/%p)\n", |
| 155980 | p->selId, p)); | 157396 | p->selId, p)); |
| 155981 | p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); | 157397 | p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0); |
| 157398 | assert( pSub!=0 || p->pSrc==0 ); /* Due to db->mallocFailed test inside | ||
| 157399 | ** of sqlite3DbMallocRawNN() called from | ||
| 157400 | ** sqlite3SrcListAppend() */ | ||
| 155982 | if( p->pSrc ){ | 157401 | if( p->pSrc ){ |
| 155983 | Table *pTab2; | 157402 | Table *pTab2; |
| 155984 | p->pSrc->a[0].pSelect = pSub; | 157403 | p->pSrc->a[0].pSelect = pSub; |
| 155985 | sqlite3SrcListAssignCursors(pParse, p->pSrc); | 157404 | sqlite3SrcListAssignCursors(pParse, p->pSrc); |
| 155986 | pSub->selFlags |= SF_Expanded; | 157405 | pSub->selFlags |= SF_Expanded|SF_OrderByReqd; |
| 155987 | pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE); | 157406 | pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE); |
| 155988 | pSub->selFlags |= (selFlags & SF_Aggregate); | 157407 | pSub->selFlags |= (selFlags & SF_Aggregate); |
| 155989 | if( pTab2==0 ){ | 157408 | if( pTab2==0 ){ |
| @@ -156006,7 +157425,11 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){ | |||
| 156006 | sqlite3SelectDelete(db, pSub); | 157425 | sqlite3SelectDelete(db, pSub); |
| 156007 | } | 157426 | } |
| 156008 | if( db->mallocFailed ) rc = SQLITE_NOMEM; | 157427 | if( db->mallocFailed ) rc = SQLITE_NOMEM; |
| 156009 | sqlite3DbFree(db, pTab); | 157428 | |
| 157429 | /* Defer deleting the temporary table pTab because if an error occurred, | ||
| 157430 | ** there could still be references to that table embedded in the | ||
| 157431 | ** result-set or ORDER BY clause of the SELECT statement p. */ | ||
| 157432 | sqlite3ParserAddCleanup(pParse, sqlite3DbFree, pTab); | ||
| 156010 | } | 157433 | } |
| 156011 | 157434 | ||
| 156012 | if( rc ){ | 157435 | if( rc ){ |
| @@ -156255,7 +157678,12 @@ SQLITE_PRIVATE void sqlite3WindowLink(Select *pSel, Window *pWin){ | |||
| 156255 | ** different, or 2 if it cannot be determined if the objects are identical | 157678 | ** different, or 2 if it cannot be determined if the objects are identical |
| 156256 | ** or not. Identical window objects can be processed in a single scan. | 157679 | ** or not. Identical window objects can be processed in a single scan. |
| 156257 | */ | 157680 | */ |
| 156258 | SQLITE_PRIVATE int sqlite3WindowCompare(Parse *pParse, Window *p1, Window *p2, int bFilter){ | 157681 | SQLITE_PRIVATE int sqlite3WindowCompare( |
| 157682 | const Parse *pParse, | ||
| 157683 | const Window *p1, | ||
| 157684 | const Window *p2, | ||
| 157685 | int bFilter | ||
| 157686 | ){ | ||
| 156259 | int res; | 157687 | int res; |
| 156260 | if( NEVER(p1==0) || NEVER(p2==0) ) return 1; | 157688 | if( NEVER(p1==0) || NEVER(p2==0) ) return 1; |
| 156261 | if( p1->eFrmType!=p2->eFrmType ) return 1; | 157689 | if( p1->eFrmType!=p2->eFrmType ) return 1; |
| @@ -156327,8 +157755,11 @@ SQLITE_PRIVATE void sqlite3WindowCodeInit(Parse *pParse, Select *pSelect){ | |||
| 156327 | ** regApp+1: integer value used to ensure keys are unique | 157755 | ** regApp+1: integer value used to ensure keys are unique |
| 156328 | ** regApp+2: output of MakeRecord | 157756 | ** regApp+2: output of MakeRecord |
| 156329 | */ | 157757 | */ |
| 156330 | ExprList *pList = pWin->pOwner->x.pList; | 157758 | ExprList *pList; |
| 156331 | KeyInfo *pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0); | 157759 | KeyInfo *pKeyInfo; |
| 157760 | assert( ExprUseXList(pWin->pOwner) ); | ||
| 157761 | pList = pWin->pOwner->x.pList; | ||
| 157762 | pKeyInfo = sqlite3KeyInfoFromExprList(pParse, pList, 0, 0); | ||
| 156332 | pWin->csrApp = pParse->nTab++; | 157763 | pWin->csrApp = pParse->nTab++; |
| 156333 | pWin->regApp = pParse->nMem+1; | 157764 | pWin->regApp = pParse->nMem+1; |
| 156334 | pParse->nMem += 3; | 157765 | pParse->nMem += 3; |
| @@ -156416,7 +157847,9 @@ static void windowCheckValue(Parse *pParse, int reg, int eCond){ | |||
| 156416 | ** with the object passed as the only argument to this function. | 157847 | ** with the object passed as the only argument to this function. |
| 156417 | */ | 157848 | */ |
| 156418 | static int windowArgCount(Window *pWin){ | 157849 | static int windowArgCount(Window *pWin){ |
| 156419 | ExprList *pList = pWin->pOwner->x.pList; | 157850 | const ExprList *pList; |
| 157851 | assert( ExprUseXList(pWin->pOwner) ); | ||
| 157852 | pList = pWin->pOwner->x.pList; | ||
| 156420 | return (pList ? pList->nExpr : 0); | 157853 | return (pList ? pList->nExpr : 0); |
| 156421 | } | 157854 | } |
| 156422 | 157855 | ||
| @@ -156601,6 +158034,7 @@ static void windowAggStep( | |||
| 156601 | int addrIf = 0; | 158034 | int addrIf = 0; |
| 156602 | if( pWin->pFilter ){ | 158035 | if( pWin->pFilter ){ |
| 156603 | int regTmp; | 158036 | int regTmp; |
| 158037 | assert( ExprUseXList(pWin->pOwner) ); | ||
| 156604 | assert( pWin->bExprArgs || !nArg ||nArg==pWin->pOwner->x.pList->nExpr ); | 158038 | assert( pWin->bExprArgs || !nArg ||nArg==pWin->pOwner->x.pList->nExpr ); |
| 156605 | assert( pWin->bExprArgs || nArg ||pWin->pOwner->x.pList==0 ); | 158039 | assert( pWin->bExprArgs || nArg ||pWin->pOwner->x.pList==0 ); |
| 156606 | regTmp = sqlite3GetTempReg(pParse); | 158040 | regTmp = sqlite3GetTempReg(pParse); |
| @@ -156614,6 +158048,7 @@ static void windowAggStep( | |||
| 156614 | int iOp = sqlite3VdbeCurrentAddr(v); | 158048 | int iOp = sqlite3VdbeCurrentAddr(v); |
| 156615 | int iEnd; | 158049 | int iEnd; |
| 156616 | 158050 | ||
| 158051 | assert( ExprUseXList(pWin->pOwner) ); | ||
| 156617 | nArg = pWin->pOwner->x.pList->nExpr; | 158052 | nArg = pWin->pOwner->x.pList->nExpr; |
| 156618 | regArg = sqlite3GetTempRange(pParse, nArg); | 158053 | regArg = sqlite3GetTempRange(pParse, nArg); |
| 156619 | sqlite3ExprCodeExprList(pParse, pWin->pOwner->x.pList, regArg, 0, 0); | 158054 | sqlite3ExprCodeExprList(pParse, pWin->pOwner->x.pList, regArg, 0, 0); |
| @@ -156628,6 +158063,7 @@ static void windowAggStep( | |||
| 156628 | if( pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ | 158063 | if( pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){ |
| 156629 | CollSeq *pColl; | 158064 | CollSeq *pColl; |
| 156630 | assert( nArg>0 ); | 158065 | assert( nArg>0 ); |
| 158066 | assert( ExprUseXList(pWin->pOwner) ); | ||
| 156631 | pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr); | 158067 | pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr); |
| 156632 | sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ); | 158068 | sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ); |
| 156633 | } | 158069 | } |
| @@ -156813,6 +158249,7 @@ static void windowReturnOneRow(WindowCodeArg *p){ | |||
| 156813 | 158249 | ||
| 156814 | for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ | 158250 | for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ |
| 156815 | FuncDef *pFunc = pWin->pFunc; | 158251 | FuncDef *pFunc = pWin->pFunc; |
| 158252 | assert( ExprUseXList(pWin->pOwner) ); | ||
| 156816 | if( pFunc->zName==nth_valueName | 158253 | if( pFunc->zName==nth_valueName |
| 156817 | || pFunc->zName==first_valueName | 158254 | || pFunc->zName==first_valueName |
| 156818 | ){ | 158255 | ){ |
| @@ -158162,9 +159599,9 @@ static void updateDeleteLimitError( | |||
| 158162 | ExprClearVVAProperties(p); | 159599 | ExprClearVVAProperties(p); |
| 158163 | p->iAgg = -1; | 159600 | p->iAgg = -1; |
| 158164 | p->pLeft = p->pRight = 0; | 159601 | p->pLeft = p->pRight = 0; |
| 158165 | p->x.pList = 0; | ||
| 158166 | p->pAggInfo = 0; | 159602 | p->pAggInfo = 0; |
| 158167 | p->y.pTab = 0; | 159603 | memset(&p->x, 0, sizeof(p->x)); |
| 159604 | memset(&p->y, 0, sizeof(p->y)); | ||
| 158168 | p->op2 = 0; | 159605 | p->op2 = 0; |
| 158169 | p->iTable = 0; | 159606 | p->iTable = 0; |
| 158170 | p->iColumn = 0; | 159607 | p->iColumn = 0; |
| @@ -158250,8 +159687,8 @@ static void updateDeleteLimitError( | |||
| 158250 | #define TK_LP 22 | 159687 | #define TK_LP 22 |
| 158251 | #define TK_RP 23 | 159688 | #define TK_RP 23 |
| 158252 | #define TK_AS 24 | 159689 | #define TK_AS 24 |
| 158253 | #define TK_WITHOUT 25 | 159690 | #define TK_COMMA 25 |
| 158254 | #define TK_COMMA 26 | 159691 | #define TK_WITHOUT 26 |
| 158255 | #define TK_ABORT 27 | 159692 | #define TK_ABORT 27 |
| 158256 | #define TK_ACTION 28 | 159693 | #define TK_ACTION 28 |
| 158257 | #define TK_AFTER 29 | 159694 | #define TK_AFTER 29 |
| @@ -158468,29 +159905,30 @@ static void updateDeleteLimitError( | |||
| 158468 | #endif | 159905 | #endif |
| 158469 | /************* Begin control #defines *****************************************/ | 159906 | /************* Begin control #defines *****************************************/ |
| 158470 | #define YYCODETYPE unsigned short int | 159907 | #define YYCODETYPE unsigned short int |
| 158471 | #define YYNOCODE 317 | 159908 | #define YYNOCODE 318 |
| 158472 | #define YYACTIONTYPE unsigned short int | 159909 | #define YYACTIONTYPE unsigned short int |
| 158473 | #define YYWILDCARD 101 | 159910 | #define YYWILDCARD 101 |
| 158474 | #define sqlite3ParserTOKENTYPE Token | 159911 | #define sqlite3ParserTOKENTYPE Token |
| 158475 | typedef union { | 159912 | typedef union { |
| 158476 | int yyinit; | 159913 | int yyinit; |
| 158477 | sqlite3ParserTOKENTYPE yy0; | 159914 | sqlite3ParserTOKENTYPE yy0; |
| 158478 | Window* yy49; | 159915 | With* yy43; |
| 158479 | ExprList* yy70; | 159916 | u32 yy51; |
| 158480 | Select* yy81; | 159917 | int yy64; |
| 158481 | With* yy103; | 159918 | struct FrameBound yy81; |
| 158482 | struct FrameBound yy117; | 159919 | struct {int value; int mask;} yy83; |
| 158483 | struct {int value; int mask;} yy139; | 159920 | TriggerStep* yy95; |
| 158484 | SrcList* yy153; | 159921 | Upsert* yy138; |
| 158485 | TriggerStep* yy157; | 159922 | IdList* yy240; |
| 158486 | Upsert* yy190; | 159923 | Cte* yy255; |
| 158487 | struct TrigEvent yy262; | 159924 | Select* yy303; |
| 158488 | Cte* yy329; | 159925 | Window* yy375; |
| 158489 | int yy376; | 159926 | u8 yy534; |
| 158490 | Expr* yy404; | 159927 | ExprList* yy562; |
| 158491 | IdList* yy436; | 159928 | struct TrigEvent yy570; |
| 158492 | const char* yy504; | 159929 | const char* yy600; |
| 158493 | u8 yy552; | 159930 | SrcList* yy607; |
| 159931 | Expr* yy626; | ||
| 158494 | } YYMINORTYPE; | 159932 | } YYMINORTYPE; |
| 158495 | #ifndef YYSTACKDEPTH | 159933 | #ifndef YYSTACKDEPTH |
| 158496 | #define YYSTACKDEPTH 100 | 159934 | #define YYSTACKDEPTH 100 |
| @@ -158506,18 +159944,18 @@ typedef union { | |||
| 158506 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; | 159944 | #define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse; |
| 158507 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; | 159945 | #define sqlite3ParserCTX_STORE yypParser->pParse=pParse; |
| 158508 | #define YYFALLBACK 1 | 159946 | #define YYFALLBACK 1 |
| 158509 | #define YYNSTATE 570 | 159947 | #define YYNSTATE 572 |
| 158510 | #define YYNRULE 398 | 159948 | #define YYNRULE 401 |
| 158511 | #define YYNRULE_WITH_ACTION 337 | 159949 | #define YYNRULE_WITH_ACTION 339 |
| 158512 | #define YYNTOKEN 184 | 159950 | #define YYNTOKEN 184 |
| 158513 | #define YY_MAX_SHIFT 569 | 159951 | #define YY_MAX_SHIFT 571 |
| 158514 | #define YY_MIN_SHIFTREDUCE 825 | 159952 | #define YY_MIN_SHIFTREDUCE 829 |
| 158515 | #define YY_MAX_SHIFTREDUCE 1222 | 159953 | #define YY_MAX_SHIFTREDUCE 1229 |
| 158516 | #define YY_ERROR_ACTION 1223 | 159954 | #define YY_ERROR_ACTION 1230 |
| 158517 | #define YY_ACCEPT_ACTION 1224 | 159955 | #define YY_ACCEPT_ACTION 1231 |
| 158518 | #define YY_NO_ACTION 1225 | 159956 | #define YY_NO_ACTION 1232 |
| 158519 | #define YY_MIN_REDUCE 1226 | 159957 | #define YY_MIN_REDUCE 1233 |
| 158520 | #define YY_MAX_REDUCE 1623 | 159958 | #define YY_MAX_REDUCE 1633 |
| 158521 | /************* End control #defines *******************************************/ | 159959 | /************* End control #defines *******************************************/ |
| 158522 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) | 159960 | #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) |
| 158523 | 159961 | ||
| @@ -158584,444 +160022,447 @@ typedef union { | |||
| 158584 | ** yy_default[] Default action for each state. | 160022 | ** yy_default[] Default action for each state. |
| 158585 | ** | 160023 | ** |
| 158586 | *********** Begin parsing tables **********************************************/ | 160024 | *********** Begin parsing tables **********************************************/ |
| 158587 | #define YY_ACTTAB_COUNT (2023) | 160025 | #define YY_ACTTAB_COUNT (2037) |
| 158588 | static const YYACTIONTYPE yy_action[] = { | 160026 | static const YYACTIONTYPE yy_action[] = { |
| 158589 | /* 0 */ 563, 1295, 563, 1274, 168, 1257, 115, 112, 218, 373, | 160027 | /* 0 */ 564, 115, 112, 220, 169, 199, 115, 112, 220, 564, |
| 158590 | /* 10 */ 563, 1295, 374, 563, 488, 563, 115, 112, 218, 406, | 160028 | /* 10 */ 375, 1266, 564, 376, 564, 270, 1309, 1309, 406, 407, |
| 158591 | /* 20 */ 1300, 1300, 41, 41, 41, 41, 514, 1504, 520, 1298, | 160029 | /* 20 */ 1084, 199, 1513, 41, 41, 515, 489, 521, 558, 558, |
| 158592 | /* 30 */ 1298, 959, 41, 41, 1260, 71, 71, 51, 51, 960, | 160030 | /* 30 */ 558, 965, 41, 41, 395, 41, 41, 51, 51, 966, |
| 158593 | /* 40 */ 557, 557, 557, 122, 123, 113, 1200, 1200, 1035, 1038, | 160031 | /* 40 */ 296, 1269, 296, 122, 123, 113, 1207, 1207, 1041, 1044, |
| 158594 | /* 50 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 414, 406, | 160032 | /* 50 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 564, 407, |
| 158595 | /* 60 */ 273, 273, 273, 273, 115, 112, 218, 115, 112, 218, | 160033 | /* 60 */ 275, 275, 275, 275, 1268, 115, 112, 220, 115, 112, |
| 158596 | /* 70 */ 197, 268, 545, 560, 515, 560, 211, 563, 385, 248, | 160034 | /* 70 */ 220, 1512, 846, 561, 516, 561, 115, 112, 220, 250, |
| 158597 | /* 80 */ 215, 521, 399, 122, 123, 113, 1200, 1200, 1035, 1038, | 160035 | /* 80 */ 217, 71, 71, 122, 123, 113, 1207, 1207, 1041, 1044, |
| 158598 | /* 90 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 540, 13, | 160036 | /* 90 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 440, 440, |
| 158599 | /* 100 */ 13, 1259, 119, 119, 119, 119, 118, 118, 117, 117, | 160037 | /* 100 */ 440, 1149, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158600 | /* 110 */ 117, 116, 441, 1176, 419, 197, 446, 320, 512, 1539, | 160038 | /* 110 */ 117, 116, 442, 1183, 1149, 116, 442, 1149, 546, 513, |
| 158601 | /* 120 */ 1545, 372, 1547, 6, 371, 1176, 1148, 394, 1148, 406, | 160039 | /* 120 */ 1548, 1554, 374, 442, 6, 1183, 1154, 522, 1154, 407, |
| 158602 | /* 130 */ 1545, 534, 115, 112, 218, 1415, 99, 30, 121, 121, | 160040 | /* 130 */ 1556, 461, 373, 1554, 535, 99, 463, 332, 121, 121, |
| 158603 | /* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117, | 160041 | /* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158604 | /* 150 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, | 160042 | /* 150 */ 117, 116, 442, 122, 123, 113, 1207, 1207, 1041, 1044, |
| 158605 | /* 160 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 31, 1176, | 160043 | /* 160 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 1257, 1183, |
| 158606 | /* 170 */ 1177, 1178, 241, 357, 1558, 501, 498, 497, 317, 124, | 160044 | /* 170 */ 1184, 1185, 243, 1064, 564, 502, 499, 498, 567, 124, |
| 158607 | /* 180 */ 319, 1176, 1177, 1178, 1176, 496, 119, 119, 119, 119, | 160045 | /* 180 */ 567, 1183, 1184, 1185, 474, 497, 119, 119, 119, 119, |
| 158608 | /* 190 */ 118, 118, 117, 117, 117, 116, 441, 139, 96, 406, | 160046 | /* 190 */ 118, 118, 117, 117, 117, 116, 442, 70, 70, 407, |
| 158609 | /* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 441, | 160047 | /* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 442, |
| 158610 | /* 210 */ 541, 1532, 119, 119, 119, 119, 118, 118, 117, 117, | 160048 | /* 210 */ 1409, 1469, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158611 | /* 220 */ 117, 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, | 160049 | /* 220 */ 117, 116, 442, 122, 123, 113, 1207, 1207, 1041, 1044, |
| 158612 | /* 230 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 406, 441, | 160050 | /* 230 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 407, 1031, |
| 158613 | /* 240 */ 1176, 1177, 1178, 81, 439, 439, 439, 80, 119, 119, | 160051 | /* 240 */ 1031, 1042, 1045, 81, 382, 541, 378, 80, 119, 119, |
| 158614 | /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 488, | 160052 | /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 381, |
| 158615 | /* 260 */ 1176, 318, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, | 160053 | /* 260 */ 463, 332, 122, 123, 113, 1207, 1207, 1041, 1044, 1034, |
| 158616 | /* 270 */ 1028, 120, 120, 121, 121, 121, 121, 493, 1025, 1025, | 160054 | /* 270 */ 1034, 120, 120, 121, 121, 121, 121, 262, 215, 512, |
| 158617 | /* 280 */ 1036, 1039, 119, 119, 119, 119, 118, 118, 117, 117, | 160055 | /* 280 */ 1424, 422, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158618 | /* 290 */ 117, 116, 441, 1584, 995, 1224, 1, 1, 569, 2, | 160056 | /* 290 */ 117, 116, 442, 1231, 1, 1, 571, 2, 1235, 1573, |
| 158619 | /* 300 */ 1228, 1267, 137, 1503, 245, 305, 473, 140, 406, 860, | 160057 | /* 300 */ 571, 2, 1235, 307, 1149, 141, 1600, 307, 407, 141, |
| 158620 | /* 310 */ 561, 1176, 914, 914, 1308, 359, 1176, 1177, 1178, 462, | 160058 | /* 310 */ 1183, 361, 1317, 1035, 866, 531, 1317, 1149, 359, 1567, |
| 158621 | /* 320 */ 330, 119, 119, 119, 119, 118, 118, 117, 117, 117, | 160059 | /* 320 */ 1149, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158622 | /* 330 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, | 160060 | /* 330 */ 116, 442, 122, 123, 113, 1207, 1207, 1041, 1044, 1034, |
| 158623 | /* 340 */ 1028, 120, 120, 121, 121, 121, 121, 328, 273, 273, | 160061 | /* 340 */ 1034, 120, 120, 121, 121, 121, 121, 275, 275, 1001, |
| 158624 | /* 350 */ 1015, 83, 1029, 425, 1564, 569, 2, 1228, 304, 554, | 160062 | /* 350 */ 426, 275, 275, 1128, 1627, 1021, 1627, 137, 542, 1541, |
| 158625 | /* 360 */ 925, 560, 305, 944, 140, 860, 1006, 1176, 1177, 1178, | 160063 | /* 360 */ 561, 272, 950, 950, 561, 1423, 1183, 1184, 1185, 1594, |
| 158626 | /* 370 */ 1005, 1308, 411, 213, 511, 229, 119, 119, 119, 119, | 160064 | /* 370 */ 866, 1012, 530, 315, 231, 1011, 468, 1276, 231, 119, |
| 158627 | /* 380 */ 118, 118, 117, 117, 117, 116, 441, 519, 347, 116, | 160065 | /* 380 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 442, |
| 158628 | /* 390 */ 441, 119, 119, 119, 119, 118, 118, 117, 117, 117, | 160066 | /* 390 */ 1570, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158629 | /* 400 */ 116, 441, 1005, 1005, 1007, 273, 273, 445, 563, 16, | 160067 | /* 400 */ 116, 442, 330, 359, 1567, 564, 446, 1011, 1011, 1013, |
| 158630 | /* 410 */ 16, 1590, 563, 1540, 563, 406, 1176, 6, 560, 344, | 160068 | /* 410 */ 446, 207, 564, 306, 555, 407, 363, 1021, 363, 346, |
| 158631 | /* 420 */ 182, 118, 118, 117, 117, 117, 116, 441, 416, 142, | 160069 | /* 420 */ 184, 118, 118, 117, 117, 117, 116, 442, 71, 71, |
| 158632 | /* 430 */ 71, 71, 229, 563, 71, 71, 55, 55, 203, 122, | 160070 | /* 430 */ 439, 438, 1126, 1012, 472, 71, 71, 1011, 205, 122, |
| 158633 | /* 440 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, | 160071 | /* 440 */ 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120, |
| 158634 | /* 450 */ 121, 121, 121, 121, 217, 13, 13, 1176, 406, 568, | 160072 | /* 450 */ 121, 121, 121, 121, 219, 219, 472, 1183, 407, 570, |
| 158635 | /* 460 */ 1400, 1228, 502, 137, 445, 168, 305, 545, 140, 1180, | 160073 | /* 460 */ 1183, 1235, 503, 1477, 149, 546, 307, 489, 141, 1011, |
| 158636 | /* 470 */ 424, 545, 1176, 1177, 1178, 1308, 544, 438, 437, 944, | 160074 | /* 470 */ 1011, 1013, 546, 140, 545, 1317, 1214, 191, 1214, 950, |
| 158637 | /* 480 */ 513, 452, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, | 160075 | /* 480 */ 950, 514, 122, 123, 113, 1207, 1207, 1041, 1044, 1034, |
| 158638 | /* 490 */ 1028, 120, 120, 121, 121, 121, 121, 315, 119, 119, | 160076 | /* 490 */ 1034, 120, 120, 121, 121, 121, 121, 563, 119, 119, |
| 158639 | /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 273, | 160077 | /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 283, |
| 158640 | /* 510 */ 273, 1143, 416, 1176, 1177, 1178, 543, 563, 1143, 304, | 160078 | /* 510 */ 275, 275, 415, 1183, 1184, 1185, 1183, 1184, 1185, 372, |
| 158641 | /* 520 */ 554, 1561, 560, 1207, 1143, 1207, 1180, 1143, 406, 530, | 160079 | /* 520 */ 1183, 243, 344, 561, 502, 499, 498, 1539, 407, 1540, |
| 158642 | /* 530 */ 421, 1143, 864, 183, 1143, 143, 229, 562, 32, 71, | 160080 | /* 530 */ 1183, 288, 870, 143, 497, 1549, 185, 231, 9, 6, |
| 158643 | /* 540 */ 71, 119, 119, 119, 119, 118, 118, 117, 117, 117, | 160081 | /* 540 */ 253, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158644 | /* 550 */ 116, 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, | 160082 | /* 550 */ 116, 442, 122, 123, 113, 1207, 1207, 1041, 1044, 1034, |
| 158645 | /* 560 */ 1028, 120, 120, 121, 121, 121, 121, 406, 445, 241, | 160083 | /* 560 */ 1034, 120, 120, 121, 121, 121, 121, 407, 137, 446, |
| 158646 | /* 570 */ 1176, 857, 501, 498, 497, 1176, 526, 189, 245, 538, | 160084 | /* 570 */ 447, 863, 169, 1183, 397, 1204, 1183, 1184, 1185, 931, |
| 158647 | /* 580 */ 1539, 282, 496, 370, 6, 563, 529, 477, 5, 279, | 160085 | /* 580 */ 526, 1001, 98, 339, 564, 342, 1183, 1184, 1185, 306, |
| 158648 | /* 590 */ 1015, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, | 160086 | /* 590 */ 555, 122, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, |
| 158649 | /* 600 */ 120, 120, 121, 121, 121, 121, 1006, 13, 13, 1414, | 160087 | /* 600 */ 120, 120, 121, 121, 121, 121, 452, 71, 71, 275, |
| 158650 | /* 610 */ 1005, 119, 119, 119, 119, 118, 118, 117, 117, 117, | 160088 | /* 610 */ 275, 119, 119, 119, 119, 118, 118, 117, 117, 117, |
| 158651 | /* 620 */ 116, 441, 426, 273, 273, 1176, 1176, 1177, 1178, 1619, | 160089 | /* 620 */ 116, 442, 561, 417, 306, 555, 1183, 1307, 1307, 1183, |
| 158652 | /* 630 */ 392, 1176, 1177, 1178, 1176, 342, 560, 406, 525, 361, | 160090 | /* 630 */ 1184, 1185, 1204, 1149, 330, 458, 318, 407, 363, 470, |
| 158653 | /* 640 */ 430, 1161, 1005, 1005, 1007, 348, 411, 357, 1558, 488, | 160091 | /* 640 */ 431, 1167, 32, 541, 527, 350, 1149, 1629, 393, 1149, |
| 158654 | /* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, | 160092 | /* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 158655 | /* 660 */ 441, 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, | 160093 | /* 660 */ 442, 122, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, |
| 158656 | /* 670 */ 120, 120, 121, 121, 121, 121, 406, 830, 831, 832, | 160094 | /* 670 */ 120, 120, 121, 121, 121, 121, 407, 199, 472, 1183, |
| 158657 | /* 680 */ 1016, 1176, 1177, 1178, 396, 285, 148, 1312, 304, 554, | 160095 | /* 680 */ 1022, 472, 1183, 1184, 1185, 386, 151, 539, 1548, 277, |
| 158658 | /* 690 */ 1176, 1177, 1178, 1467, 216, 3, 337, 137, 340, 560, | 160096 | /* 690 */ 400, 137, 6, 317, 5, 564, 562, 3, 920, 920, |
| 158659 | /* 700 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, | 160097 | /* 700 */ 122, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, |
| 158660 | /* 710 */ 120, 121, 121, 121, 121, 563, 504, 946, 273, 273, | 160098 | /* 710 */ 120, 121, 121, 121, 121, 411, 505, 83, 71, 71, |
| 158661 | /* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, | 160099 | /* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 158662 | /* 730 */ 441, 560, 1176, 427, 563, 451, 98, 13, 13, 259, | 160100 | /* 730 */ 442, 1183, 218, 428, 1183, 1183, 1184, 1185, 363, 261, |
| 158663 | /* 740 */ 276, 356, 507, 351, 506, 246, 406, 361, 469, 1530, | 160101 | /* 740 */ 278, 358, 508, 353, 507, 248, 407, 306, 555, 1539, |
| 158664 | /* 750 */ 1000, 347, 293, 304, 554, 1589, 71, 71, 889, 119, | 160102 | /* 750 */ 1006, 349, 363, 291, 489, 302, 293, 1542, 281, 119, |
| 158665 | /* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, | 160103 | /* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 442, |
| 158666 | /* 770 */ 122, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, | 160104 | /* 770 */ 122, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, |
| 158667 | /* 780 */ 120, 121, 121, 121, 121, 406, 1143, 1078, 1176, 1177, | 160105 | /* 780 */ 120, 121, 121, 121, 121, 407, 148, 1183, 1184, 1185, |
| 158668 | /* 790 */ 1178, 416, 1080, 300, 150, 995, 1080, 361, 361, 1143, | 160106 | /* 790 */ 1183, 1184, 1185, 275, 275, 1304, 1257, 1283, 483, 1476, |
| 158669 | /* 800 */ 361, 378, 1143, 477, 563, 244, 243, 242, 1278, 122, | 160107 | /* 800 */ 150, 489, 480, 564, 1187, 1304, 561, 1587, 1255, 122, |
| 158670 | /* 810 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, | 160108 | /* 810 */ 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120, |
| 158671 | /* 820 */ 121, 121, 121, 121, 563, 880, 13, 13, 483, 119, | 160109 | /* 820 */ 121, 121, 121, 121, 564, 886, 13, 13, 520, 119, |
| 158672 | /* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 441, | 160110 | /* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 442, |
| 158673 | /* 840 */ 1176, 191, 540, 563, 147, 149, 13, 13, 328, 457, | 160111 | /* 840 */ 1183, 420, 417, 564, 269, 269, 1316, 13, 13, 1539, |
| 158674 | /* 850 */ 316, 1083, 1083, 485, 1537, 406, 505, 1530, 6, 1514, | 160112 | /* 850 */ 1546, 16, 16, 322, 6, 407, 506, 561, 1089, 1089, |
| 158675 | /* 860 */ 284, 192, 1277, 145, 881, 71, 71, 488, 119, 119, | 160113 | /* 860 */ 486, 1187, 425, 1539, 887, 292, 71, 71, 119, 119, |
| 158676 | /* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 122, | 160114 | /* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 122, |
| 158677 | /* 880 */ 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, | 160115 | /* 880 */ 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120, |
| 158678 | /* 890 */ 121, 121, 121, 121, 563, 471, 1176, 1177, 1178, 406, | 160116 | /* 890 */ 121, 121, 121, 121, 564, 12, 1183, 1184, 1185, 407, |
| 158679 | /* 900 */ 852, 327, 301, 462, 330, 1516, 270, 1530, 1530, 944, | 160117 | /* 900 */ 275, 275, 451, 303, 834, 835, 836, 417, 489, 276, |
| 158680 | /* 910 */ 1531, 1307, 313, 9, 842, 251, 71, 71, 477, 428, | 160118 | /* 910 */ 276, 1547, 284, 561, 319, 6, 321, 71, 71, 429, |
| 158681 | /* 920 */ 146, 488, 38, 945, 101, 113, 1200, 1200, 1035, 1038, | 160119 | /* 920 */ 451, 450, 561, 952, 101, 113, 1207, 1207, 1041, 1044, |
| 158682 | /* 930 */ 1028, 1028, 120, 120, 121, 121, 121, 121, 119, 119, | 160120 | /* 930 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 119, 119, |
| 158683 | /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 441, 563, | 160121 | /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 1105, |
| 158684 | /* 950 */ 1197, 1099, 563, 436, 563, 1533, 563, 852, 1122, 1617, | 160122 | /* 950 */ 1183, 489, 564, 1312, 437, 455, 478, 564, 246, 245, |
| 158685 | /* 960 */ 454, 290, 1617, 546, 251, 1303, 1100, 267, 267, 281, | 160123 | /* 960 */ 244, 1409, 1545, 547, 1106, 405, 6, 1544, 196, 1258, |
| 158686 | /* 970 */ 404, 70, 70, 460, 71, 71, 71, 71, 13, 13, | 160124 | /* 970 */ 413, 6, 105, 462, 103, 71, 71, 286, 564, 1107, |
| 158687 | /* 980 */ 560, 1101, 119, 119, 119, 119, 118, 118, 117, 117, | 160125 | /* 980 */ 13, 13, 119, 119, 119, 119, 118, 118, 117, 117, |
| 158688 | /* 990 */ 117, 116, 441, 542, 104, 273, 273, 273, 273, 1197, | 160126 | /* 990 */ 117, 116, 442, 451, 104, 427, 337, 320, 275, 275, |
| 158689 | /* 1000 */ 217, 1468, 900, 471, 450, 563, 1473, 1197, 560, 447, | 160127 | /* 1000 */ 906, 13, 13, 564, 1482, 1105, 1183, 1184, 1185, 126, |
| 158690 | /* 1010 */ 560, 545, 901, 440, 406, 1058, 292, 274, 274, 198, | 160128 | /* 1010 */ 907, 561, 546, 564, 407, 478, 295, 1321, 253, 200, |
| 158691 | /* 1020 */ 547, 450, 449, 1473, 1475, 944, 455, 56, 56, 410, | 160129 | /* 1020 */ 1106, 548, 1482, 1484, 280, 1409, 55, 55, 1287, 561, |
| 158692 | /* 1030 */ 560, 1122, 1618, 379, 406, 1618, 404, 1120, 122, 123, | 160130 | /* 1030 */ 478, 380, 423, 951, 407, 1107, 71, 71, 122, 123, |
| 158693 | /* 1040 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, | 160131 | /* 1040 */ 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120, 121, |
| 158694 | /* 1050 */ 121, 121, 121, 1460, 406, 12, 1197, 1512, 122, 123, | 160132 | /* 1050 */ 121, 121, 121, 1204, 407, 287, 552, 309, 122, 123, |
| 158695 | /* 1060 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, | 160133 | /* 1060 */ 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120, 121, |
| 158696 | /* 1070 */ 121, 121, 121, 308, 471, 126, 359, 286, 122, 111, | 160134 | /* 1070 */ 121, 121, 121, 441, 1128, 1628, 146, 1628, 122, 111, |
| 158697 | /* 1080 */ 113, 1200, 1200, 1035, 1038, 1028, 1028, 120, 120, 121, | 160135 | /* 1080 */ 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120, 121, |
| 158698 | /* 1090 */ 121, 121, 121, 309, 450, 471, 1473, 119, 119, 119, | 160136 | /* 1090 */ 121, 121, 121, 404, 403, 1482, 424, 119, 119, 119, |
| 158699 | /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 441, 1176, 563, | 160137 | /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 442, 1183, 564, |
| 158700 | /* 1110 */ 1120, 482, 563, 312, 433, 479, 197, 119, 119, 119, | 160138 | /* 1110 */ 1204, 544, 1086, 858, 329, 361, 1086, 119, 119, 119, |
| 158701 | /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 441, 405, 12, | 160139 | /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 442, 564, 294, |
| 158702 | /* 1130 */ 536, 15, 15, 478, 43, 43, 509, 119, 119, 119, | 160140 | /* 1130 */ 144, 523, 56, 56, 224, 564, 510, 119, 119, 119, |
| 158703 | /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 441, 289, 535, | 160141 | /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 442, 484, 1409, |
| 158704 | /* 1150 */ 294, 563, 294, 391, 1220, 438, 437, 406, 1154, 403, | 160142 | /* 1150 */ 537, 15, 15, 1126, 434, 439, 438, 407, 13, 13, |
| 158705 | /* 1160 */ 402, 1400, 920, 1204, 1176, 1177, 1178, 919, 1206, 291, | 160143 | /* 1160 */ 1523, 12, 926, 1211, 1183, 1184, 1185, 925, 1213, 536, |
| 158706 | /* 1170 */ 1306, 1249, 412, 57, 57, 488, 1205, 563, 556, 412, | 160144 | /* 1170 */ 858, 557, 413, 193, 1525, 494, 1212, 448, 1160, 1222, |
| 158707 | /* 1180 */ 1176, 1344, 123, 113, 1200, 1200, 1035, 1038, 1028, 1028, | 160145 | /* 1180 */ 1183, 564, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, |
| 158708 | /* 1190 */ 120, 120, 121, 121, 121, 121, 1400, 1143, 563, 44, | 160146 | /* 1190 */ 120, 120, 121, 121, 121, 121, 1521, 1149, 564, 965, |
| 158709 | /* 1200 */ 44, 1207, 194, 1207, 273, 273, 1400, 461, 537, 1154, | 160147 | /* 1200 */ 564, 1214, 247, 1214, 13, 13, 1409, 966, 538, 564, |
| 158710 | /* 1210 */ 1143, 108, 555, 1143, 4, 391, 1121, 560, 1538, 335, | 160148 | /* 1210 */ 1149, 108, 556, 1149, 4, 310, 392, 1227, 17, 194, |
| 158711 | /* 1220 */ 58, 58, 6, 1246, 1099, 380, 1400, 376, 558, 1536, | 160149 | /* 1220 */ 485, 43, 43, 57, 57, 306, 555, 524, 559, 1160, |
| 158712 | /* 1230 */ 563, 422, 1221, 6, 304, 554, 1176, 1177, 1178, 1100, | 160150 | /* 1230 */ 464, 564, 44, 44, 392, 1127, 1183, 1184, 1185, 479, |
| 158713 | /* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, | 160151 | /* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116, |
| 158714 | /* 1250 */ 441, 442, 59, 59, 1101, 516, 1535, 273, 273, 563, | 160152 | /* 1250 */ 442, 443, 564, 327, 13, 13, 564, 418, 1315, 414, |
| 158715 | /* 1260 */ 6, 563, 110, 552, 563, 528, 423, 413, 169, 548, | 160153 | /* 1260 */ 171, 564, 311, 553, 213, 529, 1253, 564, 517, 543, |
| 158716 | /* 1270 */ 560, 108, 555, 137, 4, 551, 484, 272, 215, 222, | 160154 | /* 1270 */ 412, 108, 556, 137, 4, 58, 58, 435, 314, 59, |
| 158717 | /* 1280 */ 211, 60, 60, 61, 61, 98, 62, 62, 558, 273, | 160155 | /* 1280 */ 59, 274, 217, 549, 60, 60, 349, 476, 559, 1353, |
| 158718 | /* 1290 */ 273, 563, 1015, 467, 1221, 563, 434, 563, 106, 106, | 160156 | /* 1290 */ 61, 61, 1021, 275, 275, 1228, 213, 564, 106, 106, |
| 158719 | /* 1300 */ 8, 920, 560, 273, 273, 107, 919, 442, 565, 564, | 160157 | /* 1300 */ 8, 275, 275, 275, 275, 107, 561, 443, 566, 565, |
| 158720 | /* 1310 */ 563, 442, 1005, 45, 45, 464, 560, 46, 46, 47, | 160158 | /* 1310 */ 564, 443, 1011, 1228, 561, 564, 561, 564, 275, 275, |
| 158721 | /* 1320 */ 47, 84, 202, 552, 1215, 404, 468, 563, 205, 304, | 160159 | /* 1320 */ 62, 62, 1352, 553, 247, 456, 564, 98, 110, 306, |
| 158722 | /* 1330 */ 554, 563, 49, 49, 563, 522, 404, 532, 563, 867, | 160160 | /* 1330 */ 555, 561, 564, 45, 45, 405, 1203, 533, 46, 46, |
| 158723 | /* 1340 */ 563, 105, 531, 103, 1005, 1005, 1007, 1008, 27, 50, | 160161 | /* 1340 */ 47, 47, 532, 465, 1011, 1011, 1013, 1014, 27, 49, |
| 158724 | /* 1350 */ 50, 563, 1015, 63, 63, 475, 64, 64, 106, 106, | 160162 | /* 1350 */ 49, 564, 1021, 405, 469, 50, 50, 564, 106, 106, |
| 158725 | /* 1360 */ 65, 65, 14, 14, 17, 107, 563, 442, 565, 564, | 160163 | /* 1360 */ 305, 564, 84, 204, 405, 107, 564, 443, 566, 565, |
| 158726 | /* 1370 */ 563, 303, 1005, 66, 66, 563, 226, 563, 959, 563, | 160164 | /* 1370 */ 405, 564, 1011, 564, 63, 63, 564, 1599, 564, 895, |
| 158727 | /* 1380 */ 543, 404, 1196, 1343, 871, 278, 960, 456, 128, 128, | 160165 | /* 1380 */ 64, 64, 457, 477, 65, 65, 147, 96, 38, 14, |
| 158728 | /* 1390 */ 563, 1065, 67, 67, 563, 206, 867, 52, 52, 68, | 160166 | /* 1390 */ 14, 1528, 412, 564, 66, 66, 128, 128, 926, 67, |
| 158729 | /* 1400 */ 68, 69, 69, 417, 1005, 1005, 1007, 1008, 27, 1563, | 160167 | /* 1400 */ 67, 52, 52, 925, 1011, 1011, 1013, 1014, 27, 1572, |
| 158730 | /* 1410 */ 1165, 444, 53, 53, 277, 1519, 156, 156, 307, 389, | 160168 | /* 1410 */ 1171, 445, 208, 1123, 279, 394, 68, 68, 228, 390, |
| 158731 | /* 1420 */ 389, 388, 262, 386, 1165, 444, 839, 321, 277, 108, | 160169 | /* 1420 */ 390, 389, 264, 387, 1171, 445, 843, 877, 279, 108, |
| 158732 | /* 1430 */ 555, 523, 4, 389, 389, 388, 262, 386, 563, 223, | 160170 | /* 1430 */ 556, 453, 4, 390, 390, 389, 264, 387, 564, 225, |
| 158733 | /* 1440 */ 839, 311, 326, 1492, 1117, 98, 558, 393, 1065, 310, | 160171 | /* 1440 */ 843, 313, 328, 1003, 98, 252, 559, 544, 471, 312, |
| 158734 | /* 1450 */ 563, 476, 563, 223, 563, 311, 879, 878, 1009, 277, | 160172 | /* 1450 */ 252, 564, 208, 225, 564, 313, 473, 30, 252, 279, |
| 158735 | /* 1460 */ 157, 157, 463, 310, 389, 389, 388, 262, 386, 442, | 160173 | /* 1460 */ 466, 69, 69, 312, 390, 390, 389, 264, 387, 443, |
| 158736 | /* 1470 */ 518, 839, 76, 76, 54, 54, 72, 72, 355, 225, | 160174 | /* 1470 */ 333, 843, 98, 564, 53, 53, 323, 157, 157, 227, |
| 158737 | /* 1480 */ 563, 552, 275, 563, 223, 325, 311, 161, 354, 465, | 160175 | /* 1480 */ 495, 553, 249, 289, 225, 564, 313, 162, 31, 1501, |
| 158738 | /* 1490 */ 135, 563, 228, 225, 310, 532, 563, 206, 886, 887, | 160176 | /* 1490 */ 135, 564, 1500, 227, 312, 533, 158, 158, 885, 884, |
| 158739 | /* 1500 */ 533, 161, 129, 129, 135, 73, 73, 224, 962, 963, | 160177 | /* 1500 */ 534, 162, 873, 301, 135, 564, 481, 226, 76, 76, |
| 158740 | /* 1510 */ 1015, 563, 287, 130, 130, 1009, 106, 106, 131, 131, | 160178 | /* 1510 */ 1021, 347, 1071, 98, 54, 54, 106, 106, 1067, 564, |
| 158741 | /* 1520 */ 563, 224, 563, 107, 225, 442, 565, 564, 997, 1276, | 160179 | /* 1520 */ 249, 226, 519, 107, 227, 443, 566, 565, 72, 72, |
| 158742 | /* 1530 */ 1005, 250, 161, 127, 127, 135, 108, 555, 1077, 4, | 160180 | /* 1530 */ 1011, 334, 162, 564, 230, 135, 108, 556, 959, 4, |
| 158743 | /* 1540 */ 1077, 407, 155, 155, 154, 154, 304, 554, 1126, 563, | 160181 | /* 1540 */ 252, 408, 129, 129, 564, 1349, 306, 555, 564, 923, |
| 158744 | /* 1550 */ 1331, 563, 224, 558, 470, 407, 563, 250, 563, 1491, | 160182 | /* 1550 */ 564, 110, 226, 559, 564, 408, 73, 73, 564, 873, |
| 158745 | /* 1560 */ 304, 554, 1005, 1005, 1007, 1008, 27, 563, 480, 332, | 160183 | /* 1560 */ 306, 555, 1011, 1011, 1013, 1014, 27, 130, 130, 1071, |
| 158746 | /* 1570 */ 448, 136, 136, 134, 134, 1340, 442, 336, 132, 132, | 160184 | /* 1570 */ 449, 131, 131, 127, 127, 357, 443, 156, 156, 892, |
| 158747 | /* 1580 */ 133, 133, 563, 1076, 448, 1076, 407, 563, 552, 75, | 160185 | /* 1580 */ 893, 155, 155, 338, 449, 356, 408, 564, 553, 968, |
| 158748 | /* 1590 */ 75, 304, 554, 339, 341, 343, 108, 555, 563, 4, | 160186 | /* 1590 */ 969, 306, 555, 1015, 341, 564, 108, 556, 564, 4, |
| 158749 | /* 1600 */ 1577, 299, 532, 563, 77, 77, 1291, 531, 472, 74, | 160187 | /* 1600 */ 1132, 1286, 533, 564, 856, 343, 145, 532, 345, 1300, |
| 158750 | /* 1610 */ 74, 250, 1275, 558, 350, 448, 331, 1015, 360, 98, | 160188 | /* 1610 */ 136, 136, 1083, 559, 1083, 449, 564, 1021, 134, 134, |
| 158751 | /* 1620 */ 42, 42, 1352, 106, 106, 48, 48, 1399, 494, 1327, | 160189 | /* 1620 */ 1284, 132, 132, 106, 106, 1285, 133, 133, 564, 352, |
| 158752 | /* 1630 */ 107, 247, 442, 565, 564, 345, 442, 1005, 98, 1061, | 160190 | /* 1630 */ 107, 564, 443, 566, 565, 1340, 443, 1011, 362, 75, |
| 158753 | /* 1640 */ 953, 917, 247, 250, 110, 1552, 550, 850, 552, 918, | 160191 | /* 1640 */ 75, 1082, 564, 1082, 564, 924, 1561, 110, 553, 551, |
| 158754 | /* 1650 */ 144, 1338, 110, 549, 1405, 1256, 1248, 1237, 1236, 1238, | 160192 | /* 1650 */ 1015, 77, 77, 1361, 74, 74, 1408, 1336, 1347, 550, |
| 158755 | /* 1660 */ 1571, 1324, 208, 390, 489, 265, 363, 200, 365, 1005, | 160193 | /* 1660 */ 1414, 1265, 1256, 1244, 1243, 42, 42, 48, 48, 1011, |
| 158756 | /* 1670 */ 1005, 1007, 1008, 27, 11, 280, 221, 1015, 323, 474, | 160194 | /* 1670 */ 1011, 1013, 1014, 27, 1245, 1580, 490, 1021, 267, 202, |
| 158757 | /* 1680 */ 1274, 367, 212, 106, 106, 924, 1386, 324, 288, 1381, | 160195 | /* 1680 */ 1333, 365, 11, 106, 106, 930, 367, 210, 369, 391, |
| 158758 | /* 1690 */ 107, 453, 442, 565, 564, 283, 329, 1005, 1391, 499, | 160196 | /* 1690 */ 107, 1395, 443, 566, 565, 223, 1390, 1011, 500, 454, |
| 158759 | /* 1700 */ 353, 1374, 1464, 108, 555, 1463, 4, 1574, 1390, 397, | 160197 | /* 1700 */ 282, 1400, 285, 108, 556, 214, 4, 325, 1383, 1283, |
| 158760 | /* 1710 */ 1215, 171, 254, 369, 383, 207, 195, 196, 1511, 553, | 160198 | /* 1710 */ 475, 355, 1473, 1583, 1472, 1399, 371, 1222, 326, 398, |
| 158761 | /* 1720 */ 558, 1509, 415, 1212, 100, 555, 83, 4, 204, 1005, | 160199 | /* 1720 */ 559, 290, 331, 197, 100, 556, 209, 4, 198, 1011, |
| 158762 | /* 1730 */ 1005, 1007, 1008, 27, 180, 166, 173, 219, 79, 82, | 160200 | /* 1730 */ 1011, 1013, 1014, 27, 385, 256, 1520, 1518, 554, 1219, |
| 158763 | /* 1740 */ 458, 558, 175, 442, 35, 1387, 176, 459, 177, 178, | 160201 | /* 1740 */ 416, 559, 83, 443, 173, 206, 182, 221, 459, 167, |
| 158764 | /* 1750 */ 492, 231, 96, 1469, 395, 552, 1393, 1392, 36, 466, | 160202 | /* 1750 */ 177, 460, 175, 493, 233, 553, 79, 178, 1396, 179, |
| 158765 | /* 1760 */ 1395, 184, 398, 481, 442, 1458, 235, 89, 1480, 487, | 160203 | /* 1760 */ 35, 180, 96, 1402, 443, 396, 36, 467, 1478, 1401, |
| 158766 | /* 1770 */ 266, 334, 237, 188, 490, 400, 552, 338, 238, 508, | 160204 | /* 1770 */ 482, 237, 1404, 399, 82, 186, 553, 1467, 89, 488, |
| 158767 | /* 1780 */ 1239, 239, 1294, 1293, 1015, 1292, 1285, 429, 91, 871, | 160205 | /* 1780 */ 190, 268, 239, 491, 1021, 340, 240, 401, 1246, 1489, |
| 158768 | /* 1790 */ 106, 106, 1588, 213, 401, 1587, 431, 107, 1264, 442, | 160206 | /* 1790 */ 106, 106, 336, 509, 1294, 241, 1303, 107, 430, 443, |
| 158769 | /* 1800 */ 565, 564, 1263, 352, 1005, 1015, 1262, 1586, 1557, 517, | 160207 | /* 1800 */ 566, 565, 1302, 91, 1011, 1021, 1598, 1301, 1273, 215, |
| 158770 | /* 1810 */ 432, 106, 106, 1284, 297, 298, 358, 524, 107, 1335, | 160208 | /* 1810 */ 1597, 106, 106, 402, 877, 432, 354, 1272, 107, 1271, |
| 158771 | /* 1820 */ 442, 565, 564, 95, 1336, 1005, 252, 253, 435, 125, | 160209 | /* 1820 */ 443, 566, 565, 1596, 1566, 1011, 1293, 433, 518, 299, |
| 158772 | /* 1830 */ 543, 1543, 10, 1444, 377, 1542, 1005, 1005, 1007, 1008, | 160210 | /* 1830 */ 300, 360, 95, 525, 1344, 364, 1011, 1011, 1013, 1014, |
| 158773 | /* 1840 */ 27, 97, 527, 375, 362, 102, 260, 364, 381, 1317, | 160211 | /* 1840 */ 27, 254, 255, 1552, 436, 1551, 125, 544, 10, 379, |
| 158774 | /* 1850 */ 382, 1334, 366, 1245, 1333, 1316, 368, 1005, 1005, 1007, | 160212 | /* 1850 */ 1326, 1453, 102, 97, 1345, 528, 304, 1011, 1011, 1013, |
| 158775 | /* 1860 */ 1008, 27, 1359, 1358, 34, 199, 1171, 566, 261, 263, | 160213 | /* 1860 */ 1014, 27, 366, 377, 1343, 1342, 368, 370, 1325, 384, |
| 158776 | /* 1870 */ 264, 567, 1234, 158, 1229, 141, 295, 159, 1496, 302, | 160214 | /* 1870 */ 201, 383, 34, 1368, 1367, 568, 1177, 266, 263, 265, |
| 158777 | /* 1880 */ 1497, 1495, 1494, 160, 826, 209, 443, 201, 306, 210, | 160215 | /* 1880 */ 1505, 159, 569, 1241, 1236, 1506, 160, 142, 1504, 1503, |
| 158778 | /* 1890 */ 78, 220, 1075, 138, 1073, 314, 162, 172, 1196, 227, | 160216 | /* 1890 */ 297, 211, 830, 161, 212, 78, 444, 203, 308, 222, |
| 158779 | /* 1900 */ 174, 903, 322, 230, 1089, 179, 163, 164, 418, 408, | 160217 | /* 1900 */ 1081, 139, 1079, 316, 174, 163, 1203, 229, 176, 909, |
| 158780 | /* 1910 */ 409, 170, 181, 85, 86, 420, 87, 165, 1092, 88, | 160218 | /* 1910 */ 324, 232, 1095, 181, 409, 410, 172, 164, 165, 419, |
| 158781 | /* 1920 */ 233, 232, 1088, 151, 18, 234, 1081, 250, 333, 1209, | 160219 | /* 1920 */ 183, 85, 86, 421, 166, 87, 88, 1098, 1094, 234, |
| 158782 | /* 1930 */ 185, 486, 236, 186, 37, 841, 491, 354, 240, 346, | 160220 | /* 1930 */ 235, 152, 18, 236, 335, 1087, 1216, 252, 187, 487, |
| 158783 | /* 1940 */ 495, 187, 90, 869, 19, 20, 500, 503, 349, 92, | 160221 | /* 1940 */ 238, 188, 37, 845, 492, 356, 242, 496, 351, 501, |
| 158784 | /* 1950 */ 167, 152, 296, 882, 93, 510, 94, 1159, 153, 1041, | 160222 | /* 1950 */ 189, 90, 19, 504, 348, 20, 875, 92, 298, 168, |
| 158785 | /* 1960 */ 1128, 39, 214, 269, 1127, 271, 249, 952, 190, 947, | 160223 | /* 1960 */ 888, 153, 93, 511, 94, 1165, 154, 1047, 1134, 39, |
| 158786 | /* 1970 */ 110, 1149, 21, 7, 1153, 22, 1145, 23, 1147, 24, | 160224 | /* 1970 */ 216, 1133, 271, 273, 958, 192, 953, 110, 1151, 1155, |
| 158787 | /* 1980 */ 1133, 25, 1152, 33, 539, 193, 26, 1056, 98, 1042, | 160225 | /* 1980 */ 251, 7, 21, 1159, 1139, 22, 1153, 33, 23, 24, |
| 158788 | /* 1990 */ 1040, 1044, 1098, 1045, 1097, 256, 255, 28, 40, 257, | 160226 | /* 1990 */ 25, 540, 1158, 195, 98, 1062, 26, 1048, 1046, 1050, |
| 158789 | /* 2000 */ 1010, 851, 109, 29, 913, 559, 384, 387, 258, 1167, | 160227 | /* 2000 */ 1104, 1051, 1103, 257, 258, 28, 40, 1173, 1016, 857, |
| 158790 | /* 2010 */ 1166, 1225, 1225, 1225, 1579, 1225, 1225, 1225, 1225, 1225, | 160228 | /* 2010 */ 109, 29, 560, 388, 138, 1172, 259, 170, 260, 1232, |
| 158791 | /* 2020 */ 1225, 1225, 1578, | 160229 | /* 2020 */ 1232, 919, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232, |
| 160230 | /* 2030 */ 1232, 1232, 1589, 1232, 1232, 1232, 1588, | ||
| 158792 | }; | 160231 | }; |
| 158793 | static const YYCODETYPE yy_lookahead[] = { | 160232 | static const YYCODETYPE yy_lookahead[] = { |
| 158794 | /* 0 */ 192, 221, 192, 223, 192, 214, 272, 273, 274, 217, | 160233 | /* 0 */ 192, 273, 274, 275, 192, 192, 273, 274, 275, 192, |
| 158795 | /* 10 */ 192, 231, 217, 192, 192, 192, 272, 273, 274, 19, | 160234 | /* 10 */ 218, 215, 192, 218, 192, 212, 234, 235, 205, 19, |
| 158796 | /* 20 */ 233, 234, 214, 215, 214, 215, 203, 293, 203, 233, | 160235 | /* 20 */ 11, 192, 294, 215, 216, 203, 192, 203, 209, 210, |
| 158797 | /* 30 */ 234, 31, 214, 215, 214, 214, 215, 214, 215, 39, | 160236 | /* 30 */ 211, 31, 215, 216, 205, 215, 216, 215, 216, 39, |
| 158798 | /* 40 */ 208, 209, 210, 43, 44, 45, 46, 47, 48, 49, | 160237 | /* 40 */ 227, 215, 229, 43, 44, 45, 46, 47, 48, 49, |
| 158799 | /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 236, 19, | 160238 | /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 19, |
| 158800 | /* 60 */ 237, 238, 237, 238, 272, 273, 274, 272, 273, 274, | 160239 | /* 60 */ 238, 239, 238, 239, 215, 273, 274, 275, 273, 274, |
| 158801 | /* 70 */ 192, 211, 251, 250, 251, 250, 26, 192, 200, 254, | 160240 | /* 70 */ 275, 237, 21, 251, 252, 251, 273, 274, 275, 255, |
| 158802 | /* 80 */ 255, 260, 204, 43, 44, 45, 46, 47, 48, 49, | 160241 | /* 80 */ 256, 215, 216, 43, 44, 45, 46, 47, 48, 49, |
| 158803 | /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 214, | 160242 | /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 209, 210, |
| 158804 | /* 100 */ 215, 214, 102, 103, 104, 105, 106, 107, 108, 109, | 160243 | /* 100 */ 211, 76, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158805 | /* 110 */ 110, 111, 112, 59, 229, 192, 294, 16, 306, 307, | 160244 | /* 110 */ 110, 111, 112, 59, 89, 111, 112, 92, 252, 307, |
| 158806 | /* 120 */ 312, 313, 312, 311, 314, 59, 86, 204, 88, 19, | 160245 | /* 120 */ 308, 313, 314, 112, 312, 59, 86, 261, 88, 19, |
| 158807 | /* 130 */ 312, 313, 272, 273, 274, 271, 26, 22, 54, 55, | 160246 | /* 130 */ 313, 80, 315, 313, 314, 25, 127, 128, 54, 55, |
| 158808 | /* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109, | 160247 | /* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158809 | /* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, | 160248 | /* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, |
| 158810 | /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 53, 115, | 160249 | /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 115, |
| 158811 | /* 170 */ 116, 117, 118, 309, 310, 121, 122, 123, 77, 69, | 160250 | /* 170 */ 116, 117, 118, 122, 192, 121, 122, 123, 202, 69, |
| 158812 | /* 180 */ 79, 115, 116, 117, 59, 131, 102, 103, 104, 105, | 160251 | /* 180 */ 204, 115, 116, 117, 192, 131, 102, 103, 104, 105, |
| 158813 | /* 190 */ 106, 107, 108, 109, 110, 111, 112, 72, 148, 19, | 160252 | /* 190 */ 106, 107, 108, 109, 110, 111, 112, 215, 216, 19, |
| 158814 | /* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112, | 160253 | /* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112, |
| 158815 | /* 210 */ 304, 305, 102, 103, 104, 105, 106, 107, 108, 109, | 160254 | /* 210 */ 192, 160, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158816 | /* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, | 160255 | /* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49, |
| 158817 | /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 112, | 160256 | /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 46, |
| 158818 | /* 240 */ 115, 116, 117, 24, 208, 209, 210, 67, 102, 103, | 160257 | /* 240 */ 47, 48, 49, 24, 248, 192, 250, 67, 102, 103, |
| 158819 | /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192, | 160258 | /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 277, |
| 158820 | /* 260 */ 59, 160, 43, 44, 45, 46, 47, 48, 49, 50, | 160259 | /* 260 */ 127, 128, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158821 | /* 270 */ 51, 52, 53, 54, 55, 56, 57, 19, 46, 47, | 160260 | /* 270 */ 51, 52, 53, 54, 55, 56, 57, 26, 164, 165, |
| 158822 | /* 280 */ 48, 49, 102, 103, 104, 105, 106, 107, 108, 109, | 160261 | /* 280 */ 272, 263, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158823 | /* 290 */ 110, 111, 112, 213, 73, 184, 185, 186, 187, 188, | 160262 | /* 290 */ 110, 111, 112, 184, 185, 186, 187, 188, 189, 186, |
| 158824 | /* 300 */ 189, 221, 81, 236, 46, 194, 192, 196, 19, 59, | 160263 | /* 300 */ 187, 188, 189, 194, 76, 196, 229, 194, 19, 196, |
| 158825 | /* 310 */ 133, 59, 135, 136, 203, 192, 115, 116, 117, 127, | 160264 | /* 310 */ 59, 192, 203, 120, 59, 87, 203, 89, 310, 311, |
| 158826 | /* 320 */ 128, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 160265 | /* 320 */ 92, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158827 | /* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, | 160266 | /* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158828 | /* 340 */ 51, 52, 53, 54, 55, 56, 57, 126, 237, 238, | 160267 | /* 340 */ 51, 52, 53, 54, 55, 56, 57, 238, 239, 73, |
| 158829 | /* 350 */ 100, 150, 120, 230, 186, 187, 188, 189, 137, 138, | 160268 | /* 350 */ 231, 238, 239, 22, 23, 100, 25, 81, 305, 306, |
| 158830 | /* 360 */ 108, 250, 194, 26, 196, 115, 116, 115, 116, 117, | 160269 | /* 360 */ 251, 23, 25, 25, 251, 272, 115, 116, 117, 214, |
| 158831 | /* 370 */ 120, 203, 114, 164, 165, 264, 102, 103, 104, 105, | 160270 | /* 370 */ 115, 116, 144, 192, 265, 120, 114, 222, 265, 102, |
| 158832 | /* 380 */ 106, 107, 108, 109, 110, 111, 112, 192, 130, 111, | 160271 | /* 380 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 158833 | /* 390 */ 112, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 160272 | /* 390 */ 192, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158834 | /* 400 */ 111, 112, 152, 153, 154, 237, 238, 296, 192, 214, | 160273 | /* 400 */ 111, 112, 126, 310, 311, 192, 297, 152, 153, 154, |
| 158835 | /* 410 */ 215, 228, 192, 307, 192, 19, 59, 311, 250, 23, | 160274 | /* 410 */ 297, 149, 192, 137, 138, 19, 192, 100, 192, 23, |
| 158836 | /* 420 */ 22, 106, 107, 108, 109, 110, 111, 112, 192, 72, | 160275 | /* 420 */ 22, 106, 107, 108, 109, 110, 111, 112, 215, 216, |
| 158837 | /* 430 */ 214, 215, 264, 192, 214, 215, 214, 215, 149, 43, | 160276 | /* 430 */ 106, 107, 101, 116, 192, 215, 216, 120, 149, 43, |
| 158838 | /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, | 160277 | /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 158839 | /* 450 */ 54, 55, 56, 57, 117, 214, 215, 59, 19, 187, | 160278 | /* 450 */ 54, 55, 56, 57, 117, 117, 192, 59, 19, 187, |
| 158840 | /* 460 */ 192, 189, 23, 81, 296, 192, 194, 251, 196, 59, | 160279 | /* 460 */ 59, 189, 23, 282, 240, 252, 194, 192, 196, 152, |
| 158841 | /* 470 */ 229, 251, 115, 116, 117, 203, 260, 106, 107, 142, | 160280 | /* 470 */ 153, 154, 252, 72, 261, 203, 152, 25, 154, 142, |
| 158842 | /* 480 */ 260, 267, 43, 44, 45, 46, 47, 48, 49, 50, | 160281 | /* 480 */ 142, 261, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158843 | /* 490 */ 51, 52, 53, 54, 55, 56, 57, 261, 102, 103, | 160282 | /* 490 */ 51, 52, 53, 54, 55, 56, 57, 192, 102, 103, |
| 158844 | /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 237, | 160283 | /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 267, |
| 158845 | /* 510 */ 238, 76, 192, 115, 116, 117, 144, 192, 76, 137, | 160284 | /* 510 */ 238, 239, 237, 115, 116, 117, 115, 116, 117, 192, |
| 158846 | /* 520 */ 138, 192, 250, 152, 89, 154, 116, 92, 19, 87, | 160285 | /* 520 */ 59, 118, 16, 251, 121, 122, 123, 303, 19, 303, |
| 158847 | /* 530 */ 262, 89, 23, 22, 92, 163, 264, 192, 22, 214, | 160286 | /* 530 */ 59, 267, 23, 72, 131, 308, 22, 265, 22, 312, |
| 158848 | /* 540 */ 215, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 160287 | /* 540 */ 24, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158849 | /* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, | 160288 | /* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50, |
| 158850 | /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 296, 118, | 160289 | /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 81, 297, |
| 158851 | /* 570 */ 59, 23, 121, 122, 123, 59, 251, 26, 46, 306, | 160290 | /* 570 */ 295, 23, 192, 59, 203, 59, 115, 116, 117, 108, |
| 158852 | /* 580 */ 307, 261, 131, 192, 311, 192, 144, 192, 22, 203, | 160291 | /* 580 */ 192, 73, 25, 77, 192, 79, 115, 116, 117, 137, |
| 158853 | /* 590 */ 100, 43, 44, 45, 46, 47, 48, 49, 50, 51, | 160292 | /* 590 */ 138, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 158854 | /* 600 */ 52, 53, 54, 55, 56, 57, 116, 214, 215, 271, | 160293 | /* 600 */ 52, 53, 54, 55, 56, 57, 119, 215, 216, 238, |
| 158855 | /* 610 */ 120, 102, 103, 104, 105, 106, 107, 108, 109, 110, | 160294 | /* 610 */ 239, 102, 103, 104, 105, 106, 107, 108, 109, 110, |
| 158856 | /* 620 */ 111, 112, 229, 237, 238, 59, 115, 116, 117, 299, | 160295 | /* 620 */ 111, 112, 251, 192, 137, 138, 59, 234, 235, 115, |
| 158857 | /* 630 */ 300, 115, 116, 117, 59, 16, 250, 19, 192, 192, | 160296 | /* 630 */ 116, 117, 116, 76, 126, 127, 128, 19, 192, 268, |
| 158858 | /* 640 */ 19, 23, 152, 153, 154, 24, 114, 309, 310, 192, | 160297 | /* 640 */ 19, 23, 22, 192, 252, 24, 89, 300, 301, 92, |
| 158859 | /* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, | 160298 | /* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 158860 | /* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51, | 160299 | /* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51, |
| 158861 | /* 670 */ 52, 53, 54, 55, 56, 57, 19, 7, 8, 9, | 160300 | /* 670 */ 52, 53, 54, 55, 56, 57, 19, 192, 192, 59, |
| 158862 | /* 680 */ 23, 115, 116, 117, 203, 290, 239, 238, 137, 138, | 160301 | /* 680 */ 23, 192, 115, 116, 117, 200, 240, 307, 308, 22, |
| 158863 | /* 690 */ 115, 116, 117, 236, 192, 22, 77, 81, 79, 250, | 160302 | /* 690 */ 205, 81, 312, 262, 22, 192, 133, 22, 135, 136, |
| 158864 | /* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, | 160303 | /* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 158865 | /* 710 */ 53, 54, 55, 56, 57, 192, 95, 142, 237, 238, | 160304 | /* 710 */ 53, 54, 55, 56, 57, 197, 95, 150, 215, 216, |
| 158866 | /* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, | 160305 | /* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 158867 | /* 730 */ 112, 250, 59, 112, 192, 119, 26, 214, 215, 118, | 160306 | /* 730 */ 112, 59, 192, 112, 59, 115, 116, 117, 192, 118, |
| 158868 | /* 740 */ 119, 120, 121, 122, 123, 124, 19, 192, 267, 302, | 160307 | /* 740 */ 119, 120, 121, 122, 123, 124, 19, 137, 138, 303, |
| 158869 | /* 750 */ 23, 130, 229, 137, 138, 23, 214, 215, 26, 102, | 160308 | /* 750 */ 23, 130, 192, 267, 192, 252, 267, 306, 203, 102, |
| 158870 | /* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, | 160309 | /* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 158871 | /* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, | 160310 | /* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, |
| 158872 | /* 780 */ 53, 54, 55, 56, 57, 19, 76, 11, 115, 116, | 160311 | /* 780 */ 53, 54, 55, 56, 57, 19, 240, 115, 116, 117, |
| 158873 | /* 790 */ 117, 192, 29, 251, 239, 73, 33, 192, 192, 89, | 160312 | /* 790 */ 115, 116, 117, 238, 239, 222, 192, 224, 280, 237, |
| 158874 | /* 800 */ 192, 192, 92, 192, 192, 126, 127, 128, 224, 43, | 160313 | /* 800 */ 240, 192, 284, 192, 59, 232, 251, 140, 204, 43, |
| 158875 | /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, | 160314 | /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 158876 | /* 820 */ 54, 55, 56, 57, 192, 35, 214, 215, 65, 102, | 160315 | /* 820 */ 54, 55, 56, 57, 192, 35, 215, 216, 192, 102, |
| 158877 | /* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, | 160316 | /* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, |
| 158878 | /* 840 */ 59, 229, 192, 192, 239, 239, 214, 215, 126, 127, | 160317 | /* 840 */ 59, 230, 192, 192, 238, 239, 237, 215, 216, 303, |
| 158879 | /* 850 */ 128, 126, 127, 128, 307, 19, 66, 302, 311, 192, | 160318 | /* 850 */ 308, 215, 216, 16, 312, 19, 66, 251, 126, 127, |
| 158880 | /* 860 */ 261, 229, 224, 22, 74, 214, 215, 192, 102, 103, | 160319 | /* 860 */ 128, 116, 230, 303, 74, 203, 215, 216, 102, 103, |
| 158881 | /* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43, | 160320 | /* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43, |
| 158882 | /* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, | 160321 | /* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, |
| 158883 | /* 890 */ 54, 55, 56, 57, 192, 192, 115, 116, 117, 19, | 160322 | /* 890 */ 54, 55, 56, 57, 192, 212, 115, 116, 117, 19, |
| 158884 | /* 900 */ 59, 290, 251, 127, 128, 192, 23, 302, 302, 26, | 160323 | /* 900 */ 238, 239, 192, 252, 7, 8, 9, 192, 192, 238, |
| 158885 | /* 910 */ 302, 236, 192, 22, 21, 24, 214, 215, 192, 129, | 160324 | /* 910 */ 239, 308, 262, 251, 77, 312, 79, 215, 216, 129, |
| 158886 | /* 920 */ 22, 192, 24, 142, 158, 45, 46, 47, 48, 49, | 160325 | /* 920 */ 210, 211, 251, 142, 158, 45, 46, 47, 48, 49, |
| 158887 | /* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103, | 160326 | /* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103, |
| 158888 | /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 192, | 160327 | /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 12, |
| 158889 | /* 950 */ 59, 12, 192, 251, 192, 305, 192, 116, 22, 23, | 160328 | /* 950 */ 59, 192, 192, 237, 252, 243, 192, 192, 126, 127, |
| 158890 | /* 960 */ 242, 203, 26, 203, 24, 236, 27, 237, 238, 266, | 160329 | /* 960 */ 128, 192, 308, 203, 27, 253, 312, 308, 285, 207, |
| 158891 | /* 970 */ 252, 214, 215, 80, 214, 215, 214, 215, 214, 215, | 160330 | /* 970 */ 208, 312, 157, 290, 159, 215, 216, 262, 192, 42, |
| 158892 | /* 980 */ 250, 42, 102, 103, 104, 105, 106, 107, 108, 109, | 160331 | /* 980 */ 215, 216, 102, 103, 104, 105, 106, 107, 108, 109, |
| 158893 | /* 990 */ 110, 111, 112, 229, 158, 237, 238, 237, 238, 59, | 160332 | /* 990 */ 110, 111, 112, 283, 158, 230, 237, 160, 238, 239, |
| 158894 | /* 1000 */ 117, 281, 63, 192, 192, 192, 192, 116, 250, 192, | 160333 | /* 1000 */ 63, 215, 216, 192, 192, 12, 115, 116, 117, 22, |
| 158895 | /* 1010 */ 250, 251, 73, 251, 19, 122, 290, 237, 238, 24, | 160334 | /* 1010 */ 73, 251, 252, 192, 19, 192, 230, 239, 24, 24, |
| 158896 | /* 1020 */ 260, 209, 210, 209, 210, 142, 242, 214, 215, 197, | 160335 | /* 1020 */ 27, 261, 210, 211, 99, 192, 215, 216, 225, 251, |
| 158897 | /* 1030 */ 250, 22, 23, 276, 19, 26, 252, 101, 43, 44, | 160336 | /* 1030 */ 192, 192, 263, 142, 19, 42, 215, 216, 43, 44, |
| 158898 | /* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, | 160337 | /* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 158899 | /* 1050 */ 55, 56, 57, 160, 19, 211, 116, 192, 43, 44, | 160338 | /* 1050 */ 55, 56, 57, 59, 19, 291, 63, 132, 43, 44, |
| 158900 | /* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, | 160339 | /* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 158901 | /* 1070 */ 55, 56, 57, 192, 192, 22, 192, 266, 43, 44, | 160340 | /* 1070 */ 55, 56, 57, 252, 22, 23, 22, 25, 43, 44, |
| 158902 | /* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, | 160341 | /* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
| 158903 | /* 1090 */ 55, 56, 57, 192, 282, 192, 282, 102, 103, 104, | 160342 | /* 1090 */ 55, 56, 57, 106, 107, 283, 263, 102, 103, 104, |
| 158904 | /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 192, | 160343 | /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 192, |
| 158905 | /* 1110 */ 101, 279, 192, 192, 230, 283, 192, 102, 103, 104, | 160344 | /* 1110 */ 116, 144, 29, 59, 291, 192, 33, 102, 103, 104, |
| 158906 | /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 204, 211, | 160345 | /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 192, 291, |
| 158907 | /* 1130 */ 66, 214, 215, 289, 214, 215, 108, 102, 103, 104, | 160346 | /* 1130 */ 163, 19, 215, 216, 15, 192, 108, 102, 103, 104, |
| 158908 | /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 266, 85, | 160347 | /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 65, 192, |
| 158909 | /* 1150 */ 226, 192, 228, 22, 23, 106, 107, 19, 94, 106, | 160348 | /* 1150 */ 66, 215, 216, 101, 231, 106, 107, 19, 215, 216, |
| 158910 | /* 1160 */ 107, 192, 134, 114, 115, 116, 117, 139, 119, 266, | 160349 | /* 1160 */ 192, 212, 134, 114, 115, 116, 117, 139, 119, 85, |
| 158911 | /* 1170 */ 203, 206, 207, 214, 215, 192, 127, 192, 206, 207, | 160350 | /* 1170 */ 116, 207, 208, 230, 192, 19, 127, 192, 94, 60, |
| 158912 | /* 1180 */ 59, 192, 44, 45, 46, 47, 48, 49, 50, 51, | 160351 | /* 1180 */ 59, 192, 44, 45, 46, 47, 48, 49, 50, 51, |
| 158913 | /* 1190 */ 52, 53, 54, 55, 56, 57, 192, 76, 192, 214, | 160352 | /* 1190 */ 52, 53, 54, 55, 56, 57, 192, 76, 192, 31, |
| 158914 | /* 1200 */ 215, 152, 284, 154, 237, 238, 192, 289, 87, 145, | 160353 | /* 1200 */ 192, 152, 46, 154, 215, 216, 192, 39, 87, 192, |
| 158915 | /* 1210 */ 89, 19, 20, 92, 22, 22, 23, 250, 307, 236, | 160354 | /* 1210 */ 89, 19, 20, 92, 22, 192, 22, 23, 22, 230, |
| 158916 | /* 1220 */ 214, 215, 311, 203, 12, 247, 192, 249, 36, 307, | 160355 | /* 1220 */ 263, 215, 216, 215, 216, 137, 138, 115, 36, 145, |
| 158917 | /* 1230 */ 192, 262, 101, 311, 137, 138, 115, 116, 117, 27, | 160356 | /* 1230 */ 128, 192, 215, 216, 22, 23, 115, 116, 117, 290, |
| 158918 | /* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, | 160357 | /* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, |
| 158919 | /* 1250 */ 112, 59, 214, 215, 42, 203, 307, 237, 238, 192, | 160358 | /* 1250 */ 112, 59, 192, 151, 215, 216, 192, 61, 203, 298, |
| 158920 | /* 1260 */ 311, 192, 26, 71, 192, 144, 262, 297, 298, 203, | 160359 | /* 1260 */ 299, 192, 192, 71, 25, 144, 203, 192, 203, 230, |
| 158921 | /* 1270 */ 250, 19, 20, 81, 22, 63, 262, 254, 255, 15, | 160360 | /* 1270 */ 114, 19, 20, 81, 22, 215, 216, 263, 192, 215, |
| 158922 | /* 1280 */ 26, 214, 215, 214, 215, 26, 214, 215, 36, 237, | 160361 | /* 1280 */ 216, 255, 256, 203, 215, 216, 130, 19, 36, 192, |
| 158923 | /* 1290 */ 238, 192, 100, 114, 101, 192, 262, 192, 106, 107, | 160362 | /* 1290 */ 215, 216, 100, 238, 239, 101, 25, 192, 106, 107, |
| 158924 | /* 1300 */ 48, 134, 250, 237, 238, 113, 139, 115, 116, 117, | 160363 | /* 1300 */ 48, 238, 239, 238, 239, 113, 251, 115, 116, 117, |
| 158925 | /* 1310 */ 192, 59, 120, 214, 215, 242, 250, 214, 215, 214, | 160364 | /* 1310 */ 192, 59, 120, 101, 251, 192, 251, 192, 238, 239, |
| 158926 | /* 1320 */ 215, 148, 149, 71, 60, 252, 242, 192, 149, 137, | 160365 | /* 1320 */ 215, 216, 192, 71, 46, 243, 192, 25, 25, 137, |
| 158927 | /* 1330 */ 138, 192, 214, 215, 192, 19, 252, 85, 192, 59, | 160366 | /* 1330 */ 138, 251, 192, 215, 216, 253, 25, 85, 215, 216, |
| 158928 | /* 1340 */ 192, 157, 90, 159, 152, 153, 154, 155, 156, 214, | 160367 | /* 1340 */ 215, 216, 90, 243, 152, 153, 154, 155, 156, 215, |
| 158929 | /* 1350 */ 215, 192, 100, 214, 215, 19, 214, 215, 106, 107, | 160368 | /* 1350 */ 216, 192, 100, 253, 243, 215, 216, 192, 106, 107, |
| 158930 | /* 1360 */ 214, 215, 214, 215, 22, 113, 192, 115, 116, 117, | 160369 | /* 1360 */ 243, 192, 148, 149, 253, 113, 192, 115, 116, 117, |
| 158931 | /* 1370 */ 192, 242, 120, 214, 215, 192, 24, 192, 31, 192, | 160370 | /* 1370 */ 253, 192, 120, 192, 215, 216, 192, 23, 192, 25, |
| 158932 | /* 1380 */ 144, 252, 26, 192, 125, 99, 39, 192, 214, 215, | 160371 | /* 1380 */ 215, 216, 192, 115, 215, 216, 22, 148, 24, 215, |
| 158933 | /* 1390 */ 192, 59, 214, 215, 192, 141, 116, 214, 215, 214, | 160372 | /* 1390 */ 216, 192, 114, 192, 215, 216, 215, 216, 134, 215, |
| 158934 | /* 1400 */ 215, 214, 215, 61, 152, 153, 154, 155, 156, 0, | 160373 | /* 1400 */ 216, 215, 216, 139, 152, 153, 154, 155, 156, 0, |
| 158935 | /* 1410 */ 1, 2, 214, 215, 5, 192, 214, 215, 132, 10, | 160374 | /* 1410 */ 1, 2, 141, 23, 5, 25, 215, 216, 24, 10, |
| 158936 | /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 192, 5, 19, | 160375 | /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 125, 5, 19, |
| 158937 | /* 1430 */ 20, 115, 22, 10, 11, 12, 13, 14, 192, 30, | 160376 | /* 1430 */ 20, 268, 22, 10, 11, 12, 13, 14, 192, 30, |
| 158938 | /* 1440 */ 17, 32, 23, 192, 23, 26, 36, 26, 116, 40, | 160377 | /* 1440 */ 17, 32, 23, 23, 25, 25, 36, 144, 23, 40, |
| 158939 | /* 1450 */ 192, 115, 192, 30, 192, 32, 119, 120, 59, 5, | 160378 | /* 1450 */ 25, 192, 141, 30, 192, 32, 23, 22, 25, 5, |
| 158940 | /* 1460 */ 214, 215, 128, 40, 10, 11, 12, 13, 14, 59, | 160379 | /* 1460 */ 128, 215, 216, 40, 10, 11, 12, 13, 14, 59, |
| 158941 | /* 1470 */ 19, 17, 214, 215, 214, 215, 214, 215, 120, 70, | 160380 | /* 1470 */ 23, 17, 25, 192, 215, 216, 192, 215, 216, 70, |
| 158942 | /* 1480 */ 192, 71, 22, 192, 30, 151, 32, 78, 130, 128, | 160381 | /* 1480 */ 23, 71, 25, 151, 30, 192, 32, 78, 53, 192, |
| 158943 | /* 1490 */ 81, 192, 140, 70, 40, 85, 192, 141, 7, 8, | 160382 | /* 1490 */ 81, 192, 192, 70, 40, 85, 215, 216, 119, 120, |
| 158944 | /* 1500 */ 90, 78, 214, 215, 81, 214, 215, 98, 83, 84, | 160383 | /* 1500 */ 90, 78, 59, 254, 81, 192, 192, 98, 215, 216, |
| 158945 | /* 1510 */ 100, 192, 151, 214, 215, 116, 106, 107, 214, 215, | 160384 | /* 1510 */ 100, 23, 59, 25, 215, 216, 106, 107, 23, 192, |
| 158946 | /* 1520 */ 192, 98, 192, 113, 70, 115, 116, 117, 23, 224, | 160385 | /* 1520 */ 25, 98, 19, 113, 70, 115, 116, 117, 215, 216, |
| 158947 | /* 1530 */ 120, 26, 78, 214, 215, 81, 19, 20, 152, 22, | 160386 | /* 1530 */ 120, 192, 78, 192, 140, 81, 19, 20, 23, 22, |
| 158948 | /* 1540 */ 154, 132, 214, 215, 214, 215, 137, 138, 97, 192, | 160387 | /* 1540 */ 25, 132, 215, 216, 192, 192, 137, 138, 192, 23, |
| 158949 | /* 1550 */ 256, 192, 98, 36, 23, 132, 192, 26, 192, 192, | 160388 | /* 1550 */ 192, 25, 98, 36, 192, 132, 215, 216, 192, 116, |
| 158950 | /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 192, 192, 192, | 160389 | /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 215, 216, 116, |
| 158951 | /* 1570 */ 161, 214, 215, 214, 215, 192, 59, 192, 214, 215, | 160390 | /* 1570 */ 161, 215, 216, 215, 216, 120, 59, 215, 216, 7, |
| 158952 | /* 1580 */ 214, 215, 192, 152, 161, 154, 132, 192, 71, 214, | 160391 | /* 1580 */ 8, 215, 216, 192, 161, 130, 132, 192, 71, 83, |
| 158953 | /* 1590 */ 215, 137, 138, 192, 192, 192, 19, 20, 192, 22, | 160392 | /* 1590 */ 84, 137, 138, 59, 192, 192, 19, 20, 192, 22, |
| 158954 | /* 1600 */ 140, 253, 85, 192, 214, 215, 192, 90, 23, 214, | 160393 | /* 1600 */ 97, 225, 85, 192, 23, 192, 25, 90, 192, 192, |
| 158955 | /* 1610 */ 215, 26, 192, 36, 192, 161, 23, 100, 192, 26, | 160394 | /* 1610 */ 215, 216, 152, 36, 154, 161, 192, 100, 215, 216, |
| 158956 | /* 1620 */ 214, 215, 192, 106, 107, 214, 215, 192, 23, 192, | 160395 | /* 1620 */ 192, 215, 216, 106, 107, 225, 215, 216, 192, 192, |
| 158957 | /* 1630 */ 113, 26, 115, 116, 117, 23, 59, 120, 26, 23, | 160396 | /* 1630 */ 113, 192, 115, 116, 117, 257, 59, 120, 192, 215, |
| 158958 | /* 1640 */ 23, 23, 26, 26, 26, 316, 234, 23, 71, 23, | 160397 | /* 1640 */ 216, 152, 192, 154, 192, 23, 317, 25, 71, 235, |
| 158959 | /* 1650 */ 26, 192, 26, 192, 192, 192, 192, 192, 192, 192, | 160398 | /* 1650 */ 116, 215, 216, 192, 215, 216, 192, 192, 192, 192, |
| 158960 | /* 1660 */ 192, 253, 212, 190, 286, 285, 253, 240, 253, 152, | 160399 | /* 1660 */ 192, 192, 192, 192, 192, 215, 216, 215, 216, 152, |
| 158961 | /* 1670 */ 153, 154, 155, 156, 241, 243, 295, 100, 291, 291, | 160400 | /* 1670 */ 153, 154, 155, 156, 192, 192, 287, 100, 286, 241, |
| 158962 | /* 1680 */ 223, 253, 227, 106, 107, 108, 269, 244, 244, 265, | 160401 | /* 1680 */ 254, 254, 242, 106, 107, 108, 254, 213, 254, 190, |
| 158963 | /* 1690 */ 113, 257, 115, 116, 117, 257, 243, 120, 269, 218, | 160402 | /* 1690 */ 113, 270, 115, 116, 117, 296, 266, 120, 219, 258, |
| 158964 | /* 1700 */ 217, 265, 217, 19, 20, 217, 22, 195, 269, 269, | 160403 | /* 1700 */ 244, 270, 258, 19, 20, 228, 22, 292, 266, 224, |
| 158965 | /* 1710 */ 60, 295, 140, 257, 243, 241, 247, 247, 199, 278, | 160404 | /* 1710 */ 292, 218, 218, 195, 218, 270, 258, 60, 245, 270, |
| 158966 | /* 1720 */ 36, 199, 199, 38, 19, 20, 150, 22, 149, 152, | 160405 | /* 1720 */ 36, 245, 244, 248, 19, 20, 242, 22, 248, 152, |
| 158967 | /* 1730 */ 153, 154, 155, 156, 22, 43, 232, 295, 292, 292, | 160406 | /* 1730 */ 153, 154, 155, 156, 244, 140, 199, 199, 279, 38, |
| 158968 | /* 1740 */ 18, 36, 235, 59, 268, 270, 235, 199, 235, 235, | 160407 | /* 1740 */ 199, 36, 150, 59, 296, 149, 22, 296, 18, 43, |
| 158969 | /* 1750 */ 18, 198, 148, 281, 244, 71, 270, 270, 268, 244, | 160408 | /* 1750 */ 236, 199, 233, 18, 198, 71, 293, 236, 271, 236, |
| 158970 | /* 1760 */ 232, 232, 244, 199, 59, 244, 198, 157, 288, 62, | 160409 | /* 1760 */ 269, 236, 148, 271, 59, 245, 269, 245, 282, 271, |
| 158971 | /* 1770 */ 199, 287, 198, 22, 219, 219, 71, 199, 198, 114, | 160410 | /* 1770 */ 199, 198, 233, 245, 293, 233, 71, 245, 157, 62, |
| 158972 | /* 1780 */ 199, 198, 216, 216, 100, 216, 225, 64, 22, 125, | 160411 | /* 1780 */ 22, 199, 198, 220, 100, 199, 198, 220, 199, 289, |
| 158973 | /* 1790 */ 106, 107, 222, 164, 219, 222, 24, 113, 216, 115, | 160412 | /* 1790 */ 106, 107, 288, 114, 226, 198, 217, 113, 64, 115, |
| 158974 | /* 1800 */ 116, 117, 218, 216, 120, 100, 216, 216, 310, 303, | 160413 | /* 1800 */ 116, 117, 217, 22, 120, 100, 223, 217, 217, 164, |
| 158975 | /* 1810 */ 112, 106, 107, 225, 280, 280, 219, 143, 113, 259, | 160414 | /* 1810 */ 223, 106, 107, 220, 125, 24, 217, 219, 113, 217, |
| 158976 | /* 1820 */ 115, 116, 117, 114, 259, 120, 199, 91, 82, 147, | 160415 | /* 1820 */ 115, 116, 117, 217, 311, 120, 226, 112, 304, 281, |
| 158977 | /* 1830 */ 144, 315, 22, 275, 199, 315, 152, 153, 154, 155, | 160416 | /* 1830 */ 281, 220, 114, 143, 260, 259, 152, 153, 154, 155, |
| 158978 | /* 1840 */ 156, 146, 145, 247, 258, 157, 25, 258, 245, 248, | 160417 | /* 1840 */ 156, 199, 91, 316, 82, 316, 147, 144, 22, 199, |
| 158979 | /* 1850 */ 244, 259, 258, 202, 259, 248, 258, 152, 153, 154, | 160418 | /* 1850 */ 249, 276, 157, 146, 260, 145, 278, 152, 153, 154, |
| 158980 | /* 1860 */ 155, 156, 263, 263, 26, 246, 13, 201, 193, 193, | 160419 | /* 1860 */ 155, 156, 259, 248, 260, 260, 259, 259, 249, 245, |
| 158981 | /* 1870 */ 6, 191, 191, 205, 191, 220, 220, 205, 211, 277, | 160420 | /* 1870 */ 247, 246, 25, 264, 264, 201, 13, 6, 193, 193, |
| 158982 | /* 1880 */ 211, 211, 211, 205, 4, 212, 3, 22, 162, 212, | 160421 | /* 1880 */ 212, 206, 191, 191, 191, 212, 206, 221, 212, 212, |
| 158983 | /* 1890 */ 211, 15, 23, 16, 23, 138, 129, 150, 26, 24, | 160422 | /* 1890 */ 221, 213, 4, 206, 213, 212, 3, 22, 162, 15, |
| 158984 | /* 1900 */ 141, 20, 16, 143, 1, 141, 129, 129, 61, 301, | 160423 | /* 1900 */ 23, 16, 23, 138, 150, 129, 25, 24, 141, 20, |
| 158985 | /* 1910 */ 301, 298, 150, 53, 53, 37, 53, 129, 115, 53, | 160424 | /* 1910 */ 16, 143, 1, 141, 302, 302, 299, 129, 129, 61, |
| 158986 | /* 1920 */ 140, 34, 1, 5, 22, 114, 68, 26, 160, 75, | 160425 | /* 1920 */ 150, 53, 53, 37, 129, 53, 53, 115, 1, 34, |
| 158987 | /* 1930 */ 68, 41, 140, 114, 24, 20, 19, 130, 124, 23, | 160426 | /* 1930 */ 140, 5, 22, 114, 160, 68, 75, 25, 68, 41, |
| 158988 | /* 1940 */ 67, 22, 22, 59, 22, 22, 67, 96, 24, 22, | 160427 | /* 1940 */ 140, 114, 24, 20, 19, 130, 124, 67, 24, 67, |
| 158989 | /* 1950 */ 37, 23, 67, 28, 148, 22, 26, 23, 23, 23, | 160428 | /* 1950 */ 22, 22, 22, 96, 23, 22, 59, 22, 67, 37, |
| 158990 | /* 1960 */ 23, 22, 140, 23, 97, 23, 34, 115, 22, 142, | 160429 | /* 1960 */ 28, 23, 148, 22, 25, 23, 23, 23, 23, 22, |
| 158991 | /* 1970 */ 26, 75, 34, 44, 75, 34, 88, 34, 86, 34, | 160430 | /* 1970 */ 140, 97, 23, 23, 115, 22, 142, 25, 88, 75, |
| 158992 | /* 1980 */ 23, 34, 93, 22, 24, 26, 34, 23, 26, 23, | 160431 | /* 1980 */ 34, 44, 34, 75, 23, 34, 86, 22, 34, 34, |
| 158993 | /* 1990 */ 23, 23, 23, 11, 23, 22, 26, 22, 22, 140, | 160432 | /* 1990 */ 34, 24, 93, 25, 25, 23, 34, 23, 23, 23, |
| 158994 | /* 2000 */ 23, 23, 22, 22, 134, 26, 23, 15, 140, 1, | 160433 | /* 2000 */ 23, 11, 23, 25, 22, 22, 22, 1, 23, 23, |
| 158995 | /* 2010 */ 1, 317, 317, 317, 140, 317, 317, 317, 317, 317, | 160434 | /* 2010 */ 22, 22, 25, 15, 23, 1, 140, 25, 140, 318, |
| 158996 | /* 2020 */ 317, 317, 140, 317, 317, 317, 317, 317, 317, 317, | 160435 | /* 2020 */ 318, 134, 318, 318, 318, 318, 318, 318, 318, 318, |
| 158997 | /* 2030 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160436 | /* 2030 */ 318, 318, 140, 318, 318, 318, 140, 318, 318, 318, |
| 158998 | /* 2040 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160437 | /* 2040 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 158999 | /* 2050 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160438 | /* 2050 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159000 | /* 2060 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160439 | /* 2060 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159001 | /* 2070 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160440 | /* 2070 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159002 | /* 2080 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160441 | /* 2080 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159003 | /* 2090 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160442 | /* 2090 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159004 | /* 2100 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160443 | /* 2100 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159005 | /* 2110 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160444 | /* 2110 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159006 | /* 2120 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160445 | /* 2120 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159007 | /* 2130 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160446 | /* 2130 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159008 | /* 2140 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160447 | /* 2140 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159009 | /* 2150 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160448 | /* 2150 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159010 | /* 2160 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160449 | /* 2160 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159011 | /* 2170 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160450 | /* 2170 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159012 | /* 2180 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160451 | /* 2180 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159013 | /* 2190 */ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317, | 160452 | /* 2190 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 159014 | /* 2200 */ 317, 317, 317, 317, 317, 317, 317, | 160453 | /* 2200 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, |
| 160454 | /* 2210 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, | ||
| 160455 | /* 2220 */ 318, | ||
| 159015 | }; | 160456 | }; |
| 159016 | #define YY_SHIFT_COUNT (569) | 160457 | #define YY_SHIFT_COUNT (571) |
| 159017 | #define YY_SHIFT_MIN (0) | 160458 | #define YY_SHIFT_MIN (0) |
| 159018 | #define YY_SHIFT_MAX (2009) | 160459 | #define YY_SHIFT_MAX (2014) |
| 159019 | static const unsigned short int yy_shift_ofst[] = { | 160460 | static const unsigned short int yy_shift_ofst[] = { |
| 159020 | /* 0 */ 1423, 1409, 1454, 1192, 1192, 382, 1252, 1410, 1517, 1684, | 160461 | /* 0 */ 1423, 1409, 1454, 1192, 1192, 610, 1252, 1410, 1517, 1684, |
| 159021 | /* 10 */ 1684, 1684, 221, 0, 0, 180, 1015, 1684, 1684, 1684, | 160462 | /* 10 */ 1684, 1684, 276, 0, 0, 180, 1015, 1684, 1684, 1684, |
| 159022 | /* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, | 160463 | /* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 159023 | /* 30 */ 1049, 1049, 1121, 1121, 54, 616, 382, 382, 382, 382, | 160464 | /* 30 */ 1049, 1049, 1121, 1121, 54, 487, 610, 610, 610, 610, |
| 159024 | /* 40 */ 382, 40, 110, 219, 289, 396, 439, 509, 548, 618, | 160465 | /* 40 */ 610, 40, 110, 219, 289, 396, 439, 509, 548, 618, |
| 159025 | /* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015, | 160466 | /* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015, |
| 159026 | /* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, | 160467 | /* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, |
| 159027 | /* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684, | 160468 | /* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684, |
| @@ -159030,155 +160471,157 @@ static const unsigned short int yy_shift_ofst[] = { | |||
| 159030 | /* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, | 160471 | /* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, |
| 159031 | /* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684, | 160472 | /* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684, |
| 159032 | /* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84, | 160473 | /* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84, |
| 159033 | /* 130 */ 84, 84, 84, 274, 315, 125, 97, 357, 66, 66, | 160474 | /* 130 */ 84, 84, 84, 277, 315, 401, 97, 461, 251, 66, |
| 159034 | /* 140 */ 893, 258, 66, 66, 371, 371, 66, 551, 551, 551, | 160475 | /* 140 */ 66, 51, 1156, 66, 66, 324, 324, 66, 452, 452, |
| 159035 | /* 150 */ 551, 192, 209, 209, 278, 127, 2023, 2023, 621, 621, | 160476 | /* 150 */ 452, 452, 133, 114, 114, 4, 11, 2037, 2037, 621, |
| 159036 | /* 160 */ 621, 201, 398, 398, 398, 398, 939, 939, 442, 936, | 160477 | /* 160 */ 621, 621, 567, 398, 398, 398, 398, 937, 937, 228, |
| 159037 | /* 170 */ 1009, 66, 66, 66, 66, 66, 66, 66, 66, 66, | 160478 | /* 170 */ 251, 331, 1052, 66, 66, 66, 66, 66, 66, 66, |
| 159038 | /* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, | 160479 | /* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 159039 | /* 190 */ 66, 710, 710, 66, 776, 435, 435, 410, 410, 372, | 160480 | /* 190 */ 66, 66, 66, 557, 557, 66, 9, 25, 25, 745, |
| 159040 | /* 200 */ 1097, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 250, 490, | 160481 | /* 200 */ 745, 967, 1088, 2037, 2037, 2037, 2037, 2037, 2037, 2037, |
| 159041 | /* 210 */ 490, 511, 451, 516, 252, 566, 575, 781, 673, 66, | 160482 | /* 210 */ 255, 317, 317, 514, 403, 620, 471, 672, 781, 891, |
| 159042 | /* 220 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 722, | 160483 | /* 220 */ 675, 66, 66, 66, 66, 66, 66, 66, 66, 66, |
| 159043 | /* 230 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, | 160484 | /* 230 */ 66, 508, 66, 66, 66, 66, 66, 66, 66, 66, |
| 159044 | /* 240 */ 66, 66, 790, 790, 790, 66, 66, 66, 883, 66, | 160485 | /* 240 */ 66, 66, 66, 66, 790, 790, 790, 66, 66, 66, |
| 159045 | /* 250 */ 66, 66, 891, 1064, 66, 66, 1212, 66, 66, 66, | 160486 | /* 250 */ 338, 66, 66, 66, 516, 1084, 66, 66, 993, 66, |
| 159046 | /* 260 */ 66, 66, 66, 66, 66, 725, 763, 177, 940, 940, | 160487 | /* 260 */ 66, 66, 66, 66, 66, 66, 66, 732, 1083, 563, |
| 159047 | /* 270 */ 940, 940, 337, 177, 177, 1028, 1053, 670, 1264, 1179, | 160488 | /* 270 */ 994, 994, 994, 994, 337, 563, 563, 1028, 987, 897, |
| 159048 | /* 280 */ 1173, 1254, 1316, 1173, 1316, 1336, 50, 1179, 1179, 50, | 160489 | /* 280 */ 1119, 262, 1214, 1271, 1112, 1214, 1112, 1268, 1239, 262, |
| 159049 | /* 290 */ 1179, 1254, 1336, 1259, 732, 532, 1347, 1347, 1347, 1316, | 160490 | /* 290 */ 262, 1239, 262, 1271, 1268, 1302, 1354, 1278, 1168, 1168, |
| 159050 | /* 300 */ 1236, 1236, 1184, 1356, 1167, 898, 1650, 1650, 1572, 1572, | 160491 | /* 300 */ 1168, 1112, 1303, 1303, 815, 1311, 1264, 1364, 1657, 1657, |
| 159051 | /* 310 */ 1685, 1685, 1572, 1576, 1579, 1712, 1692, 1722, 1722, 1722, | 160492 | /* 310 */ 1595, 1595, 1701, 1701, 1595, 1592, 1596, 1724, 1706, 1730, |
| 159052 | /* 320 */ 1722, 1572, 1732, 1604, 1579, 1579, 1604, 1712, 1692, 1604, | 160493 | /* 320 */ 1730, 1730, 1730, 1595, 1735, 1614, 1596, 1596, 1614, 1724, |
| 159053 | /* 330 */ 1692, 1604, 1572, 1732, 1610, 1707, 1572, 1732, 1751, 1572, | 160494 | /* 330 */ 1706, 1614, 1706, 1614, 1595, 1735, 1621, 1717, 1595, 1735, |
| 159054 | /* 340 */ 1732, 1572, 1732, 1751, 1665, 1665, 1665, 1723, 1766, 1766, | 160495 | /* 340 */ 1758, 1595, 1735, 1595, 1735, 1758, 1679, 1679, 1679, 1734, |
| 159055 | /* 350 */ 1751, 1665, 1664, 1665, 1723, 1665, 1665, 1629, 1772, 1698, | 160496 | /* 350 */ 1781, 1781, 1758, 1679, 1689, 1679, 1734, 1679, 1679, 1645, |
| 159056 | /* 360 */ 1698, 1751, 1674, 1709, 1674, 1709, 1674, 1709, 1674, 1709, | 160497 | /* 360 */ 1791, 1715, 1715, 1758, 1690, 1718, 1690, 1718, 1690, 1718, |
| 159057 | /* 370 */ 1572, 1736, 1736, 1746, 1746, 1682, 1686, 1810, 1572, 1688, | 160498 | /* 370 */ 1690, 1718, 1595, 1751, 1751, 1762, 1762, 1699, 1703, 1826, |
| 159058 | /* 380 */ 1682, 1695, 1697, 1604, 1821, 1838, 1853, 1853, 1864, 1864, | 160499 | /* 380 */ 1595, 1695, 1699, 1707, 1710, 1614, 1847, 1863, 1863, 1871, |
| 159059 | /* 390 */ 1864, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, | 160500 | /* 390 */ 1871, 1871, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, |
| 159060 | /* 400 */ 2023, 2023, 2023, 2023, 2023, 2023, 232, 101, 1131, 1193, | 160501 | /* 400 */ 2037, 2037, 2037, 2037, 2037, 2037, 2037, 193, 837, 1194, |
| 159061 | /* 410 */ 619, 679, 841, 1421, 1286, 115, 1352, 1334, 1361, 1419, | 160502 | /* 410 */ 1212, 506, 832, 1054, 1390, 925, 1435, 1394, 1102, 1332, |
| 159062 | /* 420 */ 1342, 1505, 1531, 1585, 1593, 1605, 1612, 1280, 1337, 1491, | 160503 | /* 420 */ 1419, 1196, 1420, 1425, 1433, 1447, 1457, 1488, 1443, 1379, |
| 159063 | /* 430 */ 1358, 1451, 1332, 1616, 1617, 1425, 1618, 1386, 1431, 1624, | 160504 | /* 430 */ 1572, 1455, 1503, 1453, 1495, 1515, 1506, 1526, 1460, 1489, |
| 159064 | /* 440 */ 1626, 1399, 1460, 1880, 1883, 1865, 1726, 1876, 1877, 1869, | 160505 | /* 440 */ 1581, 1622, 1534, 667, 1888, 1893, 1875, 1736, 1884, 1885, |
| 159065 | /* 450 */ 1871, 1757, 1747, 1767, 1872, 1872, 1875, 1759, 1881, 1760, | 160506 | /* 450 */ 1877, 1879, 1765, 1754, 1776, 1881, 1881, 1883, 1767, 1889, |
| 159066 | /* 460 */ 1886, 1903, 1764, 1777, 1872, 1778, 1847, 1878, 1872, 1762, | 160507 | /* 460 */ 1768, 1894, 1911, 1772, 1788, 1881, 1789, 1858, 1886, 1881, |
| 159067 | /* 470 */ 1860, 1861, 1863, 1866, 1788, 1803, 1887, 1780, 1921, 1918, | 160508 | /* 470 */ 1770, 1868, 1869, 1872, 1873, 1795, 1812, 1895, 1790, 1927, |
| 159068 | /* 480 */ 1902, 1811, 1768, 1858, 1901, 1862, 1854, 1890, 1792, 1819, | 160509 | /* 480 */ 1926, 1910, 1819, 1774, 1867, 1912, 1870, 1861, 1898, 1800, |
| 159069 | /* 490 */ 1910, 1915, 1917, 1807, 1814, 1919, 1873, 1920, 1922, 1916, | 160510 | /* 490 */ 1827, 1918, 1923, 1925, 1815, 1822, 1928, 1880, 1929, 1930, |
| 159070 | /* 500 */ 1923, 1879, 1884, 1924, 1851, 1925, 1927, 1885, 1913, 1928, | 160511 | /* 500 */ 1931, 1933, 1882, 1897, 1924, 1857, 1932, 1935, 1891, 1922, |
| 159071 | /* 510 */ 1806, 1933, 1934, 1935, 1936, 1930, 1937, 1939, 1867, 1822, | 160512 | /* 510 */ 1938, 1814, 1941, 1942, 1943, 1944, 1939, 1945, 1947, 1874, |
| 159072 | /* 520 */ 1940, 1942, 1852, 1932, 1946, 1827, 1944, 1938, 1941, 1943, | 160513 | /* 520 */ 1830, 1949, 1950, 1859, 1946, 1953, 1834, 1952, 1948, 1951, |
| 159073 | /* 530 */ 1945, 1888, 1896, 1892, 1929, 1899, 1889, 1947, 1957, 1961, | 160514 | /* 530 */ 1954, 1955, 1890, 1904, 1900, 1937, 1908, 1899, 1956, 1961, |
| 159074 | /* 540 */ 1960, 1959, 1962, 1952, 1964, 1944, 1966, 1967, 1968, 1969, | 160515 | /* 540 */ 1965, 1967, 1968, 1969, 1962, 1972, 1952, 1974, 1975, 1976, |
| 159075 | /* 550 */ 1970, 1971, 1973, 1982, 1975, 1976, 1977, 1978, 1980, 1981, | 160516 | /* 550 */ 1977, 1978, 1979, 1982, 1990, 1983, 1984, 1985, 1986, 1988, |
| 159076 | /* 560 */ 1979, 1870, 1859, 1868, 1874, 1882, 1983, 1992, 2008, 2009, | 160517 | /* 560 */ 1989, 1987, 1887, 1876, 1878, 1892, 1896, 1992, 1991, 1998, |
| 160518 | /* 570 */ 2006, 2014, | ||
| 159077 | }; | 160519 | }; |
| 159078 | #define YY_REDUCE_COUNT (405) | 160520 | #define YY_REDUCE_COUNT (406) |
| 159079 | #define YY_REDUCE_MIN (-266) | 160521 | #define YY_REDUCE_MIN (-272) |
| 159080 | #define YY_REDUCE_MAX (1683) | 160522 | #define YY_REDUCE_MAX (1693) |
| 159081 | static const short yy_reduce_ofst[] = { | 160523 | static const short yy_reduce_ofst[] = { |
| 159082 | /* 0 */ 111, 168, 272, 760, -177, -175, -192, -190, -182, -179, | 160524 | /* 0 */ 109, 113, 272, 760, -178, -176, -192, -183, -180, -134, |
| 159083 | /* 10 */ 216, 220, 481, -208, -205, -266, -140, -115, 241, 393, | 160525 | /* 10 */ 213, 220, 371, -208, -205, -272, -197, 611, 632, 765, |
| 159084 | /* 20 */ 523, 325, 612, 632, 542, 651, 764, 757, 702, 762, | 160526 | /* 20 */ 786, 392, 943, 989, 503, 651, 1039, -18, 702, 821, |
| 159085 | /* 30 */ 812, 814, -188, 273, 924, 386, 758, 967, 1020, 1052, | 160527 | /* 30 */ 710, 812, -188, 380, -187, 555, 662, 1055, 1063, 1065, |
| 159086 | /* 40 */ 1066, -256, -256, -256, -256, -256, -256, -256, -256, -256, | 160528 | /* 40 */ 1080, -267, -267, -267, -267, -267, -267, -267, -267, -267, |
| 159087 | /* 50 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256, | 160529 | /* 50 */ -267, -267, -267, -267, -267, -267, -267, -267, -267, -267, |
| 159088 | /* 60 */ -256, -256, -256, -256, -256, -256, -256, -256, -256, -256, | 160530 | /* 60 */ -267, -267, -267, -267, -267, -267, -267, -267, -267, -267, |
| 159089 | /* 70 */ -256, -256, -256, -256, -256, -256, -256, -256, 195, 222, | 160531 | /* 70 */ -267, -267, -267, -267, -267, -267, -267, -267, 636, 811, |
| 159090 | /* 80 */ 813, 917, 920, 959, 985, 1006, 1038, 1067, 1069, 1072, | 160532 | /* 80 */ 917, 936, 1006, 1008, 1017, 1060, 1064, 1069, 1075, 1105, |
| 159091 | /* 90 */ 1099, 1103, 1105, 1118, 1135, 1139, 1142, 1146, 1148, 1159, | 160533 | /* 90 */ 1118, 1123, 1125, 1134, 1140, 1159, 1165, 1169, 1174, 1179, |
| 159092 | /* 100 */ 1174, 1178, 1183, 1185, 1187, 1198, 1202, 1246, 1258, 1260, | 160534 | /* 100 */ 1181, 1184, 1186, 1201, 1246, 1259, 1262, 1281, 1293, 1299, |
| 159093 | /* 110 */ 1262, 1288, 1291, 1299, 1304, 1319, 1328, 1330, 1357, 1359, | 160535 | /* 110 */ 1313, 1327, 1341, 1352, 1356, 1358, 1362, 1366, 1395, 1403, |
| 159094 | /* 120 */ 1364, 1366, 1375, 1390, 1395, 1406, 1411, -256, -256, -256, | 160536 | /* 120 */ 1406, 1411, 1424, 1436, 1439, 1450, 1452, -267, -267, -267, |
| 159095 | /* 130 */ -256, -256, -256, -256, -256, 447, -256, 555, -178, 605, | 160537 | /* 130 */ -267, -267, -267, -267, -267, 224, -267, 446, -24, 275, |
| 159096 | /* 140 */ 832, -220, 606, -94, -168, 36, -122, 730, 780, 730, | 160538 | /* 140 */ 546, 518, 573, 560, 53, -181, -111, 485, 606, 671, |
| 159097 | /* 150 */ 780, 918, -136, 338, -256, -256, -256, -256, 80, 80, | 160539 | /* 150 */ 606, 671, 683, 8, 93, -267, -267, -267, -267, 155, |
| 159098 | /* 160 */ 80, 720, 703, 811, 882, 903, -213, -204, 106, 330, | 160540 | /* 160 */ 155, 155, 181, 242, 264, 486, 489, -218, 393, 227, |
| 159099 | /* 170 */ 330, -77, 236, 320, 599, 67, 457, 675, 729, 395, | 160541 | /* 170 */ 604, 347, 347, -171, 431, 650, 715, -166, 562, 609, |
| 159100 | /* 180 */ 268, 611, 969, 1004, 726, 1014, 983, 123, 884, 608, | 160542 | /* 180 */ 716, 764, 18, 823, 769, 833, 838, 957, 759, 119, |
| 159101 | /* 190 */ 1034, 547, 911, 650, 844, 922, 949, 965, 972, 978, | 160543 | /* 190 */ 923, 226, 1014, 542, 603, 451, 949, 654, 659, 762, |
| 159102 | /* 200 */ 449, 970, 718, 784, 1073, 1084, 1023, 1129, -209, -180, | 160544 | /* 200 */ 964, -4, 778, 961, 712, 1082, 1100, 1111, 1026, 1117, |
| 159103 | /* 210 */ -113, 114, 183, 329, 345, 391, 446, 502, 609, 667, | 160545 | /* 210 */ -204, -174, -151, -8, 77, 198, 305, 327, 388, 540, |
| 159104 | /* 220 */ 713, 817, 865, 881, 901, 921, 989, 1191, 1195, 214, | 160546 | /* 220 */ 839, 968, 982, 985, 1004, 1023, 1070, 1086, 1097, 1130, |
| 159105 | /* 230 */ 1223, 1235, 1251, 1367, 1376, 1377, 1383, 1385, 1401, 1402, | 160547 | /* 230 */ 1190, 1163, 1199, 1284, 1297, 1300, 1314, 1339, 1353, 1391, |
| 159106 | /* 240 */ 1403, 1414, 584, 638, 1305, 1420, 1422, 1426, 1294, 1430, | 160548 | /* 240 */ 1402, 1413, 1416, 1417, 803, 1376, 1400, 1428, 1437, 1446, |
| 159107 | /* 250 */ 1435, 1437, 1348, 1329, 1459, 1461, 1412, 1462, 345, 1463, | 160549 | /* 250 */ 1378, 1461, 1464, 1465, 1249, 1329, 1466, 1467, 1414, 1468, |
| 159108 | /* 260 */ 1464, 1465, 1466, 1467, 1468, 1378, 1380, 1427, 1408, 1413, | 160550 | /* 260 */ 305, 1469, 1470, 1471, 1472, 1482, 1483, 1389, 1392, 1438, |
| 159109 | /* 270 */ 1415, 1428, 1294, 1427, 1427, 1433, 1450, 1473, 1381, 1417, | 160551 | /* 270 */ 1426, 1427, 1432, 1434, 1378, 1438, 1438, 1440, 1474, 1499, |
| 159110 | /* 280 */ 1424, 1432, 1434, 1436, 1438, 1387, 1443, 1429, 1439, 1444, | 160552 | /* 280 */ 1399, 1421, 1430, 1456, 1441, 1442, 1444, 1415, 1473, 1431, |
| 159111 | /* 290 */ 1440, 1453, 1388, 1481, 1455, 1457, 1483, 1485, 1488, 1456, | 160553 | /* 290 */ 1445, 1476, 1449, 1478, 1418, 1479, 1477, 1485, 1493, 1494, |
| 159112 | /* 300 */ 1469, 1470, 1441, 1471, 1474, 1512, 1416, 1442, 1519, 1522, | 160554 | /* 300 */ 1496, 1458, 1475, 1480, 1459, 1490, 1484, 1518, 1448, 1451, |
| 159113 | /* 310 */ 1446, 1447, 1523, 1472, 1475, 1476, 1504, 1507, 1511, 1513, | 160555 | /* 310 */ 1537, 1538, 1463, 1481, 1541, 1486, 1487, 1491, 1519, 1514, |
| 159114 | /* 320 */ 1514, 1548, 1553, 1510, 1486, 1487, 1515, 1490, 1528, 1518, | 160556 | /* 320 */ 1521, 1523, 1525, 1552, 1556, 1520, 1492, 1498, 1522, 1497, |
| 159115 | /* 330 */ 1529, 1521, 1564, 1568, 1480, 1484, 1571, 1574, 1555, 1578, | 160557 | /* 330 */ 1539, 1528, 1542, 1532, 1571, 1573, 1500, 1504, 1582, 1584, |
| 159116 | /* 340 */ 1580, 1581, 1583, 1556, 1566, 1567, 1569, 1561, 1570, 1573, | 160558 | /* 340 */ 1563, 1586, 1588, 1589, 1597, 1567, 1579, 1585, 1590, 1568, |
| 159117 | /* 350 */ 1575, 1582, 1584, 1587, 1588, 1590, 1591, 1498, 1506, 1534, | 160559 | /* 350 */ 1583, 1587, 1593, 1591, 1598, 1599, 1600, 1602, 1606, 1513, |
| 159118 | /* 360 */ 1535, 1597, 1560, 1586, 1565, 1589, 1592, 1594, 1595, 1598, | 160560 | /* 360 */ 1524, 1548, 1549, 1611, 1574, 1576, 1594, 1603, 1604, 1607, |
| 159119 | /* 370 */ 1627, 1516, 1520, 1599, 1600, 1601, 1596, 1558, 1635, 1602, | 160561 | /* 370 */ 1605, 1608, 1642, 1527, 1529, 1609, 1610, 1601, 1615, 1575, |
| 159120 | /* 380 */ 1607, 1619, 1603, 1606, 1651, 1666, 1675, 1676, 1680, 1681, | 160562 | /* 380 */ 1650, 1578, 1619, 1623, 1625, 1624, 1674, 1685, 1686, 1691, |
| 159121 | /* 390 */ 1683, 1608, 1609, 1613, 1668, 1667, 1669, 1670, 1671, 1672, | 160563 | /* 390 */ 1692, 1693, 1612, 1613, 1617, 1675, 1668, 1673, 1676, 1677, |
| 159122 | /* 400 */ 1655, 1656, 1673, 1677, 1679, 1678, | 160564 | /* 400 */ 1680, 1666, 1669, 1678, 1681, 1683, 1687, |
| 159123 | }; | 160565 | }; |
| 159124 | static const YYACTIONTYPE yy_default[] = { | 160566 | static const YYACTIONTYPE yy_default[] = { |
| 159125 | /* 0 */ 1623, 1623, 1623, 1453, 1223, 1332, 1223, 1223, 1223, 1453, | 160567 | /* 0 */ 1633, 1633, 1633, 1462, 1230, 1341, 1230, 1230, 1230, 1462, |
| 159126 | /* 10 */ 1453, 1453, 1223, 1362, 1362, 1506, 1254, 1223, 1223, 1223, | 160568 | /* 10 */ 1462, 1462, 1230, 1371, 1371, 1515, 1263, 1230, 1230, 1230, |
| 159127 | /* 20 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1452, 1223, 1223, | 160569 | /* 20 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1461, 1230, 1230, |
| 159128 | /* 30 */ 1223, 1223, 1541, 1541, 1223, 1223, 1223, 1223, 1223, 1223, | 160570 | /* 30 */ 1230, 1230, 1550, 1550, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159129 | /* 40 */ 1223, 1223, 1371, 1223, 1378, 1223, 1223, 1223, 1223, 1223, | 160571 | /* 40 */ 1230, 1230, 1380, 1230, 1387, 1230, 1230, 1230, 1230, 1230, |
| 159130 | /* 50 */ 1454, 1455, 1223, 1223, 1223, 1505, 1507, 1470, 1385, 1384, | 160572 | /* 50 */ 1463, 1464, 1230, 1230, 1230, 1514, 1516, 1479, 1394, 1393, |
| 159131 | /* 60 */ 1383, 1382, 1488, 1349, 1376, 1369, 1373, 1448, 1449, 1447, | 160573 | /* 60 */ 1392, 1391, 1497, 1358, 1385, 1378, 1382, 1457, 1458, 1456, |
| 159132 | /* 70 */ 1451, 1455, 1454, 1223, 1372, 1419, 1433, 1418, 1223, 1223, | 160574 | /* 70 */ 1460, 1464, 1463, 1230, 1381, 1428, 1442, 1427, 1230, 1230, |
| 159133 | /* 80 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160575 | /* 80 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159134 | /* 90 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160576 | /* 90 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159135 | /* 100 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160577 | /* 100 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159136 | /* 110 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160578 | /* 110 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159137 | /* 120 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1427, 1432, 1438, | 160579 | /* 120 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1436, 1441, 1447, |
| 159138 | /* 130 */ 1431, 1428, 1421, 1420, 1422, 1223, 1423, 1223, 1223, 1223, | 160580 | /* 130 */ 1440, 1437, 1430, 1429, 1431, 1230, 1432, 1230, 1254, 1230, |
| 159139 | /* 140 */ 1244, 1296, 1223, 1223, 1223, 1223, 1223, 1525, 1524, 1223, | 160581 | /* 140 */ 1230, 1251, 1305, 1230, 1230, 1230, 1230, 1230, 1534, 1533, |
| 159140 | /* 150 */ 1223, 1254, 1413, 1412, 1424, 1425, 1435, 1434, 1513, 1576, | 160582 | /* 150 */ 1230, 1230, 1263, 1422, 1421, 1433, 1434, 1444, 1443, 1522, |
| 159141 | /* 160 */ 1575, 1471, 1223, 1223, 1223, 1223, 1223, 1223, 1541, 1223, | 160583 | /* 160 */ 1586, 1585, 1480, 1230, 1230, 1230, 1230, 1230, 1230, 1550, |
| 159142 | /* 170 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160584 | /* 170 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159143 | /* 180 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160585 | /* 180 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159144 | /* 190 */ 1223, 1541, 1541, 1223, 1254, 1541, 1541, 1250, 1250, 1356, | 160586 | /* 190 */ 1230, 1230, 1230, 1550, 1550, 1230, 1263, 1550, 1550, 1259, |
| 159145 | /* 200 */ 1223, 1520, 1323, 1323, 1323, 1323, 1332, 1323, 1223, 1223, | 160587 | /* 200 */ 1259, 1365, 1230, 1529, 1332, 1332, 1332, 1332, 1341, 1332, |
| 159146 | /* 210 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160588 | /* 210 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159147 | /* 220 */ 1223, 1223, 1223, 1510, 1508, 1223, 1223, 1223, 1223, 1223, | 160589 | /* 220 */ 1230, 1230, 1230, 1230, 1230, 1519, 1517, 1230, 1230, 1230, |
| 159148 | /* 230 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160590 | /* 230 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159149 | /* 240 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160591 | /* 240 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159150 | /* 250 */ 1223, 1223, 1328, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160592 | /* 250 */ 1230, 1230, 1230, 1230, 1337, 1230, 1230, 1230, 1230, 1230, |
| 159151 | /* 260 */ 1223, 1223, 1223, 1223, 1570, 1223, 1483, 1310, 1328, 1328, | 160593 | /* 260 */ 1230, 1230, 1230, 1230, 1230, 1230, 1579, 1230, 1492, 1319, |
| 159152 | /* 270 */ 1328, 1328, 1330, 1311, 1309, 1322, 1255, 1230, 1615, 1388, | 160594 | /* 270 */ 1337, 1337, 1337, 1337, 1339, 1320, 1318, 1331, 1264, 1237, |
| 159153 | /* 280 */ 1377, 1329, 1351, 1377, 1351, 1612, 1375, 1388, 1388, 1375, | 160595 | /* 280 */ 1625, 1397, 1386, 1338, 1360, 1386, 1360, 1622, 1384, 1397, |
| 159154 | /* 290 */ 1388, 1329, 1612, 1271, 1592, 1266, 1362, 1362, 1362, 1351, | 160596 | /* 290 */ 1397, 1384, 1397, 1338, 1622, 1280, 1602, 1275, 1371, 1371, |
| 159155 | /* 300 */ 1356, 1356, 1450, 1329, 1322, 1223, 1615, 1615, 1337, 1337, | 160597 | /* 300 */ 1371, 1360, 1365, 1365, 1459, 1338, 1331, 1230, 1625, 1625, |
| 159156 | /* 310 */ 1614, 1614, 1337, 1471, 1599, 1397, 1299, 1305, 1305, 1305, | 160598 | /* 310 */ 1346, 1346, 1624, 1624, 1346, 1480, 1609, 1406, 1308, 1314, |
| 159157 | /* 320 */ 1305, 1337, 1241, 1375, 1599, 1599, 1375, 1397, 1299, 1375, | 160599 | /* 320 */ 1314, 1314, 1314, 1346, 1248, 1384, 1609, 1609, 1384, 1406, |
| 159158 | /* 330 */ 1299, 1375, 1337, 1241, 1487, 1609, 1337, 1241, 1461, 1337, | 160600 | /* 330 */ 1308, 1384, 1308, 1384, 1346, 1248, 1496, 1619, 1346, 1248, |
| 159159 | /* 340 */ 1241, 1337, 1241, 1461, 1297, 1297, 1297, 1286, 1223, 1223, | 160601 | /* 340 */ 1470, 1346, 1248, 1346, 1248, 1470, 1306, 1306, 1306, 1295, |
| 159160 | /* 350 */ 1461, 1297, 1271, 1297, 1286, 1297, 1297, 1559, 1223, 1465, | 160602 | /* 350 */ 1230, 1230, 1470, 1306, 1280, 1306, 1295, 1306, 1306, 1568, |
| 159161 | /* 360 */ 1465, 1461, 1355, 1350, 1355, 1350, 1355, 1350, 1355, 1350, | 160603 | /* 360 */ 1230, 1474, 1474, 1470, 1364, 1359, 1364, 1359, 1364, 1359, |
| 159162 | /* 370 */ 1337, 1551, 1551, 1365, 1365, 1370, 1356, 1456, 1337, 1223, | 160604 | /* 370 */ 1364, 1359, 1346, 1560, 1560, 1374, 1374, 1379, 1365, 1465, |
| 159163 | /* 380 */ 1370, 1368, 1366, 1375, 1247, 1289, 1573, 1573, 1569, 1569, | 160605 | /* 380 */ 1346, 1230, 1379, 1377, 1375, 1384, 1298, 1582, 1582, 1578, |
| 159164 | /* 390 */ 1569, 1620, 1620, 1520, 1585, 1254, 1254, 1254, 1254, 1585, | 160606 | /* 390 */ 1578, 1578, 1630, 1630, 1529, 1595, 1263, 1263, 1263, 1263, |
| 159165 | /* 400 */ 1273, 1273, 1255, 1255, 1254, 1585, 1223, 1223, 1223, 1223, | 160607 | /* 400 */ 1595, 1282, 1282, 1264, 1264, 1263, 1595, 1230, 1230, 1230, |
| 159166 | /* 410 */ 1223, 1223, 1580, 1223, 1515, 1472, 1341, 1223, 1223, 1223, | 160608 | /* 410 */ 1230, 1230, 1230, 1590, 1230, 1524, 1481, 1350, 1230, 1230, |
| 159167 | /* 420 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160609 | /* 420 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159168 | /* 430 */ 1223, 1526, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160610 | /* 430 */ 1230, 1230, 1535, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159169 | /* 440 */ 1223, 1223, 1402, 1223, 1226, 1517, 1223, 1223, 1223, 1223, | 160611 | /* 440 */ 1230, 1230, 1230, 1411, 1230, 1233, 1526, 1230, 1230, 1230, |
| 159170 | /* 450 */ 1223, 1223, 1223, 1223, 1379, 1380, 1342, 1223, 1223, 1223, | 160612 | /* 450 */ 1230, 1230, 1230, 1230, 1230, 1388, 1389, 1351, 1230, 1230, |
| 159171 | /* 460 */ 1223, 1223, 1223, 1223, 1394, 1223, 1223, 1223, 1389, 1223, | 160613 | /* 460 */ 1230, 1230, 1230, 1230, 1230, 1403, 1230, 1230, 1230, 1398, |
| 159172 | /* 470 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1611, 1223, 1223, | 160614 | /* 470 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1621, 1230, |
| 159173 | /* 480 */ 1223, 1223, 1223, 1223, 1486, 1485, 1223, 1223, 1339, 1223, | 160615 | /* 480 */ 1230, 1230, 1230, 1230, 1230, 1495, 1494, 1230, 1230, 1348, |
| 159174 | /* 490 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160616 | /* 490 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159175 | /* 500 */ 1223, 1223, 1269, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160617 | /* 500 */ 1230, 1230, 1230, 1278, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159176 | /* 510 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160618 | /* 510 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159177 | /* 520 */ 1223, 1223, 1223, 1223, 1223, 1223, 1367, 1223, 1223, 1223, | 160619 | /* 520 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1376, 1230, 1230, |
| 159178 | /* 530 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160620 | /* 530 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159179 | /* 540 */ 1223, 1556, 1357, 1223, 1223, 1602, 1223, 1223, 1223, 1223, | 160621 | /* 540 */ 1230, 1230, 1565, 1366, 1230, 1230, 1612, 1230, 1230, 1230, |
| 159180 | /* 550 */ 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, 1223, | 160622 | /* 550 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, |
| 159181 | /* 560 */ 1596, 1313, 1404, 1223, 1403, 1407, 1223, 1235, 1223, 1223, | 160623 | /* 560 */ 1230, 1606, 1322, 1413, 1230, 1412, 1416, 1252, 1230, 1242, |
| 160624 | /* 570 */ 1230, 1230, | ||
| 159182 | }; | 160625 | }; |
| 159183 | /********** End of lemon-generated parsing tables *****************************/ | 160626 | /********** End of lemon-generated parsing tables *****************************/ |
| 159184 | 160627 | ||
| @@ -159223,8 +160666,8 @@ static const YYCODETYPE yyFallback[] = { | |||
| 159223 | 0, /* LP => nothing */ | 160666 | 0, /* LP => nothing */ |
| 159224 | 0, /* RP => nothing */ | 160667 | 0, /* RP => nothing */ |
| 159225 | 0, /* AS => nothing */ | 160668 | 0, /* AS => nothing */ |
| 159226 | 59, /* WITHOUT => ID */ | ||
| 159227 | 0, /* COMMA => nothing */ | 160669 | 0, /* COMMA => nothing */ |
| 160670 | 59, /* WITHOUT => ID */ | ||
| 159228 | 59, /* ABORT => ID */ | 160671 | 59, /* ABORT => ID */ |
| 159229 | 59, /* ACTION => ID */ | 160672 | 59, /* ACTION => ID */ |
| 159230 | 59, /* AFTER => ID */ | 160673 | 59, /* AFTER => ID */ |
| @@ -159433,9 +160876,9 @@ struct yyParser { | |||
| 159433 | }; | 160876 | }; |
| 159434 | typedef struct yyParser yyParser; | 160877 | typedef struct yyParser yyParser; |
| 159435 | 160878 | ||
| 160879 | /* #include <assert.h> */ | ||
| 159436 | #ifndef NDEBUG | 160880 | #ifndef NDEBUG |
| 159437 | /* #include <stdio.h> */ | 160881 | /* #include <stdio.h> */ |
| 159438 | /* #include <assert.h> */ | ||
| 159439 | static FILE *yyTraceFILE = 0; | 160882 | static FILE *yyTraceFILE = 0; |
| 159440 | static char *yyTracePrompt = 0; | 160883 | static char *yyTracePrompt = 0; |
| 159441 | #endif /* NDEBUG */ | 160884 | #endif /* NDEBUG */ |
| @@ -159495,8 +160938,8 @@ static const char *const yyTokenName[] = { | |||
| 159495 | /* 22 */ "LP", | 160938 | /* 22 */ "LP", |
| 159496 | /* 23 */ "RP", | 160939 | /* 23 */ "RP", |
| 159497 | /* 24 */ "AS", | 160940 | /* 24 */ "AS", |
| 159498 | /* 25 */ "WITHOUT", | 160941 | /* 25 */ "COMMA", |
| 159499 | /* 26 */ "COMMA", | 160942 | /* 26 */ "WITHOUT", |
| 159500 | /* 27 */ "ABORT", | 160943 | /* 27 */ "ABORT", |
| 159501 | /* 28 */ "ACTION", | 160944 | /* 28 */ "ACTION", |
| 159502 | /* 29 */ "AFTER", | 160945 | /* 29 */ "AFTER", |
| @@ -159672,121 +161115,122 @@ static const char *const yyTokenName[] = { | |||
| 159672 | /* 199 */ "dbnm", | 161115 | /* 199 */ "dbnm", |
| 159673 | /* 200 */ "columnlist", | 161116 | /* 200 */ "columnlist", |
| 159674 | /* 201 */ "conslist_opt", | 161117 | /* 201 */ "conslist_opt", |
| 159675 | /* 202 */ "table_options", | 161118 | /* 202 */ "table_option_set", |
| 159676 | /* 203 */ "select", | 161119 | /* 203 */ "select", |
| 159677 | /* 204 */ "columnname", | 161120 | /* 204 */ "table_option", |
| 159678 | /* 205 */ "carglist", | 161121 | /* 205 */ "columnname", |
| 159679 | /* 206 */ "typetoken", | 161122 | /* 206 */ "carglist", |
| 159680 | /* 207 */ "typename", | 161123 | /* 207 */ "typetoken", |
| 159681 | /* 208 */ "signed", | 161124 | /* 208 */ "typename", |
| 159682 | /* 209 */ "plus_num", | 161125 | /* 209 */ "signed", |
| 159683 | /* 210 */ "minus_num", | 161126 | /* 210 */ "plus_num", |
| 159684 | /* 211 */ "scanpt", | 161127 | /* 211 */ "minus_num", |
| 159685 | /* 212 */ "scantok", | 161128 | /* 212 */ "scanpt", |
| 159686 | /* 213 */ "ccons", | 161129 | /* 213 */ "scantok", |
| 159687 | /* 214 */ "term", | 161130 | /* 214 */ "ccons", |
| 159688 | /* 215 */ "expr", | 161131 | /* 215 */ "term", |
| 159689 | /* 216 */ "onconf", | 161132 | /* 216 */ "expr", |
| 159690 | /* 217 */ "sortorder", | 161133 | /* 217 */ "onconf", |
| 159691 | /* 218 */ "autoinc", | 161134 | /* 218 */ "sortorder", |
| 159692 | /* 219 */ "eidlist_opt", | 161135 | /* 219 */ "autoinc", |
| 159693 | /* 220 */ "refargs", | 161136 | /* 220 */ "eidlist_opt", |
| 159694 | /* 221 */ "defer_subclause", | 161137 | /* 221 */ "refargs", |
| 159695 | /* 222 */ "generated", | 161138 | /* 222 */ "defer_subclause", |
| 159696 | /* 223 */ "refarg", | 161139 | /* 223 */ "generated", |
| 159697 | /* 224 */ "refact", | 161140 | /* 224 */ "refarg", |
| 159698 | /* 225 */ "init_deferred_pred_opt", | 161141 | /* 225 */ "refact", |
| 159699 | /* 226 */ "conslist", | 161142 | /* 226 */ "init_deferred_pred_opt", |
| 159700 | /* 227 */ "tconscomma", | 161143 | /* 227 */ "conslist", |
| 159701 | /* 228 */ "tcons", | 161144 | /* 228 */ "tconscomma", |
| 159702 | /* 229 */ "sortlist", | 161145 | /* 229 */ "tcons", |
| 159703 | /* 230 */ "eidlist", | 161146 | /* 230 */ "sortlist", |
| 159704 | /* 231 */ "defer_subclause_opt", | 161147 | /* 231 */ "eidlist", |
| 159705 | /* 232 */ "orconf", | 161148 | /* 232 */ "defer_subclause_opt", |
| 159706 | /* 233 */ "resolvetype", | 161149 | /* 233 */ "orconf", |
| 159707 | /* 234 */ "raisetype", | 161150 | /* 234 */ "resolvetype", |
| 159708 | /* 235 */ "ifexists", | 161151 | /* 235 */ "raisetype", |
| 159709 | /* 236 */ "fullname", | 161152 | /* 236 */ "ifexists", |
| 159710 | /* 237 */ "selectnowith", | 161153 | /* 237 */ "fullname", |
| 159711 | /* 238 */ "oneselect", | 161154 | /* 238 */ "selectnowith", |
| 159712 | /* 239 */ "wqlist", | 161155 | /* 239 */ "oneselect", |
| 159713 | /* 240 */ "multiselect_op", | 161156 | /* 240 */ "wqlist", |
| 159714 | /* 241 */ "distinct", | 161157 | /* 241 */ "multiselect_op", |
| 159715 | /* 242 */ "selcollist", | 161158 | /* 242 */ "distinct", |
| 159716 | /* 243 */ "from", | 161159 | /* 243 */ "selcollist", |
| 159717 | /* 244 */ "where_opt", | 161160 | /* 244 */ "from", |
| 159718 | /* 245 */ "groupby_opt", | 161161 | /* 245 */ "where_opt", |
| 159719 | /* 246 */ "having_opt", | 161162 | /* 246 */ "groupby_opt", |
| 159720 | /* 247 */ "orderby_opt", | 161163 | /* 247 */ "having_opt", |
| 159721 | /* 248 */ "limit_opt", | 161164 | /* 248 */ "orderby_opt", |
| 159722 | /* 249 */ "window_clause", | 161165 | /* 249 */ "limit_opt", |
| 159723 | /* 250 */ "values", | 161166 | /* 250 */ "window_clause", |
| 159724 | /* 251 */ "nexprlist", | 161167 | /* 251 */ "values", |
| 159725 | /* 252 */ "sclp", | 161168 | /* 252 */ "nexprlist", |
| 159726 | /* 253 */ "as", | 161169 | /* 253 */ "sclp", |
| 159727 | /* 254 */ "seltablist", | 161170 | /* 254 */ "as", |
| 159728 | /* 255 */ "stl_prefix", | 161171 | /* 255 */ "seltablist", |
| 159729 | /* 256 */ "joinop", | 161172 | /* 256 */ "stl_prefix", |
| 159730 | /* 257 */ "indexed_opt", | 161173 | /* 257 */ "joinop", |
| 159731 | /* 258 */ "on_opt", | 161174 | /* 258 */ "indexed_opt", |
| 159732 | /* 259 */ "using_opt", | 161175 | /* 259 */ "on_opt", |
| 159733 | /* 260 */ "exprlist", | 161176 | /* 260 */ "using_opt", |
| 159734 | /* 261 */ "xfullname", | 161177 | /* 261 */ "exprlist", |
| 159735 | /* 262 */ "idlist", | 161178 | /* 262 */ "xfullname", |
| 159736 | /* 263 */ "nulls", | 161179 | /* 263 */ "idlist", |
| 159737 | /* 264 */ "with", | 161180 | /* 264 */ "nulls", |
| 159738 | /* 265 */ "where_opt_ret", | 161181 | /* 265 */ "with", |
| 159739 | /* 266 */ "setlist", | 161182 | /* 266 */ "where_opt_ret", |
| 159740 | /* 267 */ "insert_cmd", | 161183 | /* 267 */ "setlist", |
| 159741 | /* 268 */ "idlist_opt", | 161184 | /* 268 */ "insert_cmd", |
| 159742 | /* 269 */ "upsert", | 161185 | /* 269 */ "idlist_opt", |
| 159743 | /* 270 */ "returning", | 161186 | /* 270 */ "upsert", |
| 159744 | /* 271 */ "filter_over", | 161187 | /* 271 */ "returning", |
| 159745 | /* 272 */ "likeop", | 161188 | /* 272 */ "filter_over", |
| 159746 | /* 273 */ "between_op", | 161189 | /* 273 */ "likeop", |
| 159747 | /* 274 */ "in_op", | 161190 | /* 274 */ "between_op", |
| 159748 | /* 275 */ "paren_exprlist", | 161191 | /* 275 */ "in_op", |
| 159749 | /* 276 */ "case_operand", | 161192 | /* 276 */ "paren_exprlist", |
| 159750 | /* 277 */ "case_exprlist", | 161193 | /* 277 */ "case_operand", |
| 159751 | /* 278 */ "case_else", | 161194 | /* 278 */ "case_exprlist", |
| 159752 | /* 279 */ "uniqueflag", | 161195 | /* 279 */ "case_else", |
| 159753 | /* 280 */ "collate", | 161196 | /* 280 */ "uniqueflag", |
| 159754 | /* 281 */ "vinto", | 161197 | /* 281 */ "collate", |
| 159755 | /* 282 */ "nmnum", | 161198 | /* 282 */ "vinto", |
| 159756 | /* 283 */ "trigger_decl", | 161199 | /* 283 */ "nmnum", |
| 159757 | /* 284 */ "trigger_cmd_list", | 161200 | /* 284 */ "trigger_decl", |
| 159758 | /* 285 */ "trigger_time", | 161201 | /* 285 */ "trigger_cmd_list", |
| 159759 | /* 286 */ "trigger_event", | 161202 | /* 286 */ "trigger_time", |
| 159760 | /* 287 */ "foreach_clause", | 161203 | /* 287 */ "trigger_event", |
| 159761 | /* 288 */ "when_clause", | 161204 | /* 288 */ "foreach_clause", |
| 159762 | /* 289 */ "trigger_cmd", | 161205 | /* 289 */ "when_clause", |
| 159763 | /* 290 */ "trnm", | 161206 | /* 290 */ "trigger_cmd", |
| 159764 | /* 291 */ "tridxby", | 161207 | /* 291 */ "trnm", |
| 159765 | /* 292 */ "database_kw_opt", | 161208 | /* 292 */ "tridxby", |
| 159766 | /* 293 */ "key_opt", | 161209 | /* 293 */ "database_kw_opt", |
| 159767 | /* 294 */ "add_column_fullname", | 161210 | /* 294 */ "key_opt", |
| 159768 | /* 295 */ "kwcolumn_opt", | 161211 | /* 295 */ "add_column_fullname", |
| 159769 | /* 296 */ "create_vtab", | 161212 | /* 296 */ "kwcolumn_opt", |
| 159770 | /* 297 */ "vtabarglist", | 161213 | /* 297 */ "create_vtab", |
| 159771 | /* 298 */ "vtabarg", | 161214 | /* 298 */ "vtabarglist", |
| 159772 | /* 299 */ "vtabargtoken", | 161215 | /* 299 */ "vtabarg", |
| 159773 | /* 300 */ "lp", | 161216 | /* 300 */ "vtabargtoken", |
| 159774 | /* 301 */ "anylist", | 161217 | /* 301 */ "lp", |
| 159775 | /* 302 */ "wqitem", | 161218 | /* 302 */ "anylist", |
| 159776 | /* 303 */ "wqas", | 161219 | /* 303 */ "wqitem", |
| 159777 | /* 304 */ "windowdefn_list", | 161220 | /* 304 */ "wqas", |
| 159778 | /* 305 */ "windowdefn", | 161221 | /* 305 */ "windowdefn_list", |
| 159779 | /* 306 */ "window", | 161222 | /* 306 */ "windowdefn", |
| 159780 | /* 307 */ "frame_opt", | 161223 | /* 307 */ "window", |
| 159781 | /* 308 */ "part_opt", | 161224 | /* 308 */ "frame_opt", |
| 159782 | /* 309 */ "filter_clause", | 161225 | /* 309 */ "part_opt", |
| 159783 | /* 310 */ "over_clause", | 161226 | /* 310 */ "filter_clause", |
| 159784 | /* 311 */ "range_or_rows", | 161227 | /* 311 */ "over_clause", |
| 159785 | /* 312 */ "frame_bound", | 161228 | /* 312 */ "range_or_rows", |
| 159786 | /* 313 */ "frame_bound_s", | 161229 | /* 313 */ "frame_bound", |
| 159787 | /* 314 */ "frame_bound_e", | 161230 | /* 314 */ "frame_bound_s", |
| 159788 | /* 315 */ "frame_exclude_opt", | 161231 | /* 315 */ "frame_bound_e", |
| 159789 | /* 316 */ "frame_exclude", | 161232 | /* 316 */ "frame_exclude_opt", |
| 161233 | /* 317 */ "frame_exclude", | ||
| 159790 | }; | 161234 | }; |
| 159791 | #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ | 161235 | #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ |
| 159792 | 161236 | ||
| @@ -159813,385 +161257,388 @@ static const char *const yyRuleName[] = { | |||
| 159813 | /* 16 */ "ifnotexists ::= IF NOT EXISTS", | 161257 | /* 16 */ "ifnotexists ::= IF NOT EXISTS", |
| 159814 | /* 17 */ "temp ::= TEMP", | 161258 | /* 17 */ "temp ::= TEMP", |
| 159815 | /* 18 */ "temp ::=", | 161259 | /* 18 */ "temp ::=", |
| 159816 | /* 19 */ "create_table_args ::= LP columnlist conslist_opt RP table_options", | 161260 | /* 19 */ "create_table_args ::= LP columnlist conslist_opt RP table_option_set", |
| 159817 | /* 20 */ "create_table_args ::= AS select", | 161261 | /* 20 */ "create_table_args ::= AS select", |
| 159818 | /* 21 */ "table_options ::=", | 161262 | /* 21 */ "table_option_set ::=", |
| 159819 | /* 22 */ "table_options ::= WITHOUT nm", | 161263 | /* 22 */ "table_option_set ::= table_option_set COMMA table_option", |
| 159820 | /* 23 */ "columnname ::= nm typetoken", | 161264 | /* 23 */ "table_option ::= WITHOUT nm", |
| 159821 | /* 24 */ "typetoken ::=", | 161265 | /* 24 */ "table_option ::= nm", |
| 159822 | /* 25 */ "typetoken ::= typename LP signed RP", | 161266 | /* 25 */ "columnname ::= nm typetoken", |
| 159823 | /* 26 */ "typetoken ::= typename LP signed COMMA signed RP", | 161267 | /* 26 */ "typetoken ::=", |
| 159824 | /* 27 */ "typename ::= typename ID|STRING", | 161268 | /* 27 */ "typetoken ::= typename LP signed RP", |
| 159825 | /* 28 */ "scanpt ::=", | 161269 | /* 28 */ "typetoken ::= typename LP signed COMMA signed RP", |
| 159826 | /* 29 */ "scantok ::=", | 161270 | /* 29 */ "typename ::= typename ID|STRING", |
| 159827 | /* 30 */ "ccons ::= CONSTRAINT nm", | 161271 | /* 30 */ "scanpt ::=", |
| 159828 | /* 31 */ "ccons ::= DEFAULT scantok term", | 161272 | /* 31 */ "scantok ::=", |
| 159829 | /* 32 */ "ccons ::= DEFAULT LP expr RP", | 161273 | /* 32 */ "ccons ::= CONSTRAINT nm", |
| 159830 | /* 33 */ "ccons ::= DEFAULT PLUS scantok term", | 161274 | /* 33 */ "ccons ::= DEFAULT scantok term", |
| 159831 | /* 34 */ "ccons ::= DEFAULT MINUS scantok term", | 161275 | /* 34 */ "ccons ::= DEFAULT LP expr RP", |
| 159832 | /* 35 */ "ccons ::= DEFAULT scantok ID|INDEXED", | 161276 | /* 35 */ "ccons ::= DEFAULT PLUS scantok term", |
| 159833 | /* 36 */ "ccons ::= NOT NULL onconf", | 161277 | /* 36 */ "ccons ::= DEFAULT MINUS scantok term", |
| 159834 | /* 37 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc", | 161278 | /* 37 */ "ccons ::= DEFAULT scantok ID|INDEXED", |
| 159835 | /* 38 */ "ccons ::= UNIQUE onconf", | 161279 | /* 38 */ "ccons ::= NOT NULL onconf", |
| 159836 | /* 39 */ "ccons ::= CHECK LP expr RP", | 161280 | /* 39 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc", |
| 159837 | /* 40 */ "ccons ::= REFERENCES nm eidlist_opt refargs", | 161281 | /* 40 */ "ccons ::= UNIQUE onconf", |
| 159838 | /* 41 */ "ccons ::= defer_subclause", | 161282 | /* 41 */ "ccons ::= CHECK LP expr RP", |
| 159839 | /* 42 */ "ccons ::= COLLATE ID|STRING", | 161283 | /* 42 */ "ccons ::= REFERENCES nm eidlist_opt refargs", |
| 159840 | /* 43 */ "generated ::= LP expr RP", | 161284 | /* 43 */ "ccons ::= defer_subclause", |
| 159841 | /* 44 */ "generated ::= LP expr RP ID", | 161285 | /* 44 */ "ccons ::= COLLATE ID|STRING", |
| 159842 | /* 45 */ "autoinc ::=", | 161286 | /* 45 */ "generated ::= LP expr RP", |
| 159843 | /* 46 */ "autoinc ::= AUTOINCR", | 161287 | /* 46 */ "generated ::= LP expr RP ID", |
| 159844 | /* 47 */ "refargs ::=", | 161288 | /* 47 */ "autoinc ::=", |
| 159845 | /* 48 */ "refargs ::= refargs refarg", | 161289 | /* 48 */ "autoinc ::= AUTOINCR", |
| 159846 | /* 49 */ "refarg ::= MATCH nm", | 161290 | /* 49 */ "refargs ::=", |
| 159847 | /* 50 */ "refarg ::= ON INSERT refact", | 161291 | /* 50 */ "refargs ::= refargs refarg", |
| 159848 | /* 51 */ "refarg ::= ON DELETE refact", | 161292 | /* 51 */ "refarg ::= MATCH nm", |
| 159849 | /* 52 */ "refarg ::= ON UPDATE refact", | 161293 | /* 52 */ "refarg ::= ON INSERT refact", |
| 159850 | /* 53 */ "refact ::= SET NULL", | 161294 | /* 53 */ "refarg ::= ON DELETE refact", |
| 159851 | /* 54 */ "refact ::= SET DEFAULT", | 161295 | /* 54 */ "refarg ::= ON UPDATE refact", |
| 159852 | /* 55 */ "refact ::= CASCADE", | 161296 | /* 55 */ "refact ::= SET NULL", |
| 159853 | /* 56 */ "refact ::= RESTRICT", | 161297 | /* 56 */ "refact ::= SET DEFAULT", |
| 159854 | /* 57 */ "refact ::= NO ACTION", | 161298 | /* 57 */ "refact ::= CASCADE", |
| 159855 | /* 58 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt", | 161299 | /* 58 */ "refact ::= RESTRICT", |
| 159856 | /* 59 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt", | 161300 | /* 59 */ "refact ::= NO ACTION", |
| 159857 | /* 60 */ "init_deferred_pred_opt ::=", | 161301 | /* 60 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt", |
| 159858 | /* 61 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED", | 161302 | /* 61 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt", |
| 159859 | /* 62 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE", | 161303 | /* 62 */ "init_deferred_pred_opt ::=", |
| 159860 | /* 63 */ "conslist_opt ::=", | 161304 | /* 63 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED", |
| 159861 | /* 64 */ "tconscomma ::= COMMA", | 161305 | /* 64 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE", |
| 159862 | /* 65 */ "tcons ::= CONSTRAINT nm", | 161306 | /* 65 */ "conslist_opt ::=", |
| 159863 | /* 66 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf", | 161307 | /* 66 */ "tconscomma ::= COMMA", |
| 159864 | /* 67 */ "tcons ::= UNIQUE LP sortlist RP onconf", | 161308 | /* 67 */ "tcons ::= CONSTRAINT nm", |
| 159865 | /* 68 */ "tcons ::= CHECK LP expr RP onconf", | 161309 | /* 68 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf", |
| 159866 | /* 69 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt", | 161310 | /* 69 */ "tcons ::= UNIQUE LP sortlist RP onconf", |
| 159867 | /* 70 */ "defer_subclause_opt ::=", | 161311 | /* 70 */ "tcons ::= CHECK LP expr RP onconf", |
| 159868 | /* 71 */ "onconf ::=", | 161312 | /* 71 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt", |
| 159869 | /* 72 */ "onconf ::= ON CONFLICT resolvetype", | 161313 | /* 72 */ "defer_subclause_opt ::=", |
| 159870 | /* 73 */ "orconf ::=", | 161314 | /* 73 */ "onconf ::=", |
| 159871 | /* 74 */ "orconf ::= OR resolvetype", | 161315 | /* 74 */ "onconf ::= ON CONFLICT resolvetype", |
| 159872 | /* 75 */ "resolvetype ::= IGNORE", | 161316 | /* 75 */ "orconf ::=", |
| 159873 | /* 76 */ "resolvetype ::= REPLACE", | 161317 | /* 76 */ "orconf ::= OR resolvetype", |
| 159874 | /* 77 */ "cmd ::= DROP TABLE ifexists fullname", | 161318 | /* 77 */ "resolvetype ::= IGNORE", |
| 159875 | /* 78 */ "ifexists ::= IF EXISTS", | 161319 | /* 78 */ "resolvetype ::= REPLACE", |
| 159876 | /* 79 */ "ifexists ::=", | 161320 | /* 79 */ "cmd ::= DROP TABLE ifexists fullname", |
| 159877 | /* 80 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select", | 161321 | /* 80 */ "ifexists ::= IF EXISTS", |
| 159878 | /* 81 */ "cmd ::= DROP VIEW ifexists fullname", | 161322 | /* 81 */ "ifexists ::=", |
| 159879 | /* 82 */ "cmd ::= select", | 161323 | /* 82 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select", |
| 159880 | /* 83 */ "select ::= WITH wqlist selectnowith", | 161324 | /* 83 */ "cmd ::= DROP VIEW ifexists fullname", |
| 159881 | /* 84 */ "select ::= WITH RECURSIVE wqlist selectnowith", | 161325 | /* 84 */ "cmd ::= select", |
| 159882 | /* 85 */ "select ::= selectnowith", | 161326 | /* 85 */ "select ::= WITH wqlist selectnowith", |
| 159883 | /* 86 */ "selectnowith ::= selectnowith multiselect_op oneselect", | 161327 | /* 86 */ "select ::= WITH RECURSIVE wqlist selectnowith", |
| 159884 | /* 87 */ "multiselect_op ::= UNION", | 161328 | /* 87 */ "select ::= selectnowith", |
| 159885 | /* 88 */ "multiselect_op ::= UNION ALL", | 161329 | /* 88 */ "selectnowith ::= selectnowith multiselect_op oneselect", |
| 159886 | /* 89 */ "multiselect_op ::= EXCEPT|INTERSECT", | 161330 | /* 89 */ "multiselect_op ::= UNION", |
| 159887 | /* 90 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", | 161331 | /* 90 */ "multiselect_op ::= UNION ALL", |
| 159888 | /* 91 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt", | 161332 | /* 91 */ "multiselect_op ::= EXCEPT|INTERSECT", |
| 159889 | /* 92 */ "values ::= VALUES LP nexprlist RP", | 161333 | /* 92 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt", |
| 159890 | /* 93 */ "values ::= values COMMA LP nexprlist RP", | 161334 | /* 93 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt", |
| 159891 | /* 94 */ "distinct ::= DISTINCT", | 161335 | /* 94 */ "values ::= VALUES LP nexprlist RP", |
| 159892 | /* 95 */ "distinct ::= ALL", | 161336 | /* 95 */ "values ::= values COMMA LP nexprlist RP", |
| 159893 | /* 96 */ "distinct ::=", | 161337 | /* 96 */ "distinct ::= DISTINCT", |
| 159894 | /* 97 */ "sclp ::=", | 161338 | /* 97 */ "distinct ::= ALL", |
| 159895 | /* 98 */ "selcollist ::= sclp scanpt expr scanpt as", | 161339 | /* 98 */ "distinct ::=", |
| 159896 | /* 99 */ "selcollist ::= sclp scanpt STAR", | 161340 | /* 99 */ "sclp ::=", |
| 159897 | /* 100 */ "selcollist ::= sclp scanpt nm DOT STAR", | 161341 | /* 100 */ "selcollist ::= sclp scanpt expr scanpt as", |
| 159898 | /* 101 */ "as ::= AS nm", | 161342 | /* 101 */ "selcollist ::= sclp scanpt STAR", |
| 159899 | /* 102 */ "as ::=", | 161343 | /* 102 */ "selcollist ::= sclp scanpt nm DOT STAR", |
| 159900 | /* 103 */ "from ::=", | 161344 | /* 103 */ "as ::= AS nm", |
| 159901 | /* 104 */ "from ::= FROM seltablist", | 161345 | /* 104 */ "as ::=", |
| 159902 | /* 105 */ "stl_prefix ::= seltablist joinop", | 161346 | /* 105 */ "from ::=", |
| 159903 | /* 106 */ "stl_prefix ::=", | 161347 | /* 106 */ "from ::= FROM seltablist", |
| 159904 | /* 107 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", | 161348 | /* 107 */ "stl_prefix ::= seltablist joinop", |
| 159905 | /* 108 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt", | 161349 | /* 108 */ "stl_prefix ::=", |
| 159906 | /* 109 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", | 161350 | /* 109 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt", |
| 159907 | /* 110 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", | 161351 | /* 110 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt", |
| 159908 | /* 111 */ "dbnm ::=", | 161352 | /* 111 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt", |
| 159909 | /* 112 */ "dbnm ::= DOT nm", | 161353 | /* 112 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt", |
| 159910 | /* 113 */ "fullname ::= nm", | 161354 | /* 113 */ "dbnm ::=", |
| 159911 | /* 114 */ "fullname ::= nm DOT nm", | 161355 | /* 114 */ "dbnm ::= DOT nm", |
| 159912 | /* 115 */ "xfullname ::= nm", | 161356 | /* 115 */ "fullname ::= nm", |
| 159913 | /* 116 */ "xfullname ::= nm DOT nm", | 161357 | /* 116 */ "fullname ::= nm DOT nm", |
| 159914 | /* 117 */ "xfullname ::= nm DOT nm AS nm", | 161358 | /* 117 */ "xfullname ::= nm", |
| 159915 | /* 118 */ "xfullname ::= nm AS nm", | 161359 | /* 118 */ "xfullname ::= nm DOT nm", |
| 159916 | /* 119 */ "joinop ::= COMMA|JOIN", | 161360 | /* 119 */ "xfullname ::= nm DOT nm AS nm", |
| 159917 | /* 120 */ "joinop ::= JOIN_KW JOIN", | 161361 | /* 120 */ "xfullname ::= nm AS nm", |
| 159918 | /* 121 */ "joinop ::= JOIN_KW nm JOIN", | 161362 | /* 121 */ "joinop ::= COMMA|JOIN", |
| 159919 | /* 122 */ "joinop ::= JOIN_KW nm nm JOIN", | 161363 | /* 122 */ "joinop ::= JOIN_KW JOIN", |
| 159920 | /* 123 */ "on_opt ::= ON expr", | 161364 | /* 123 */ "joinop ::= JOIN_KW nm JOIN", |
| 159921 | /* 124 */ "on_opt ::=", | 161365 | /* 124 */ "joinop ::= JOIN_KW nm nm JOIN", |
| 159922 | /* 125 */ "indexed_opt ::=", | 161366 | /* 125 */ "on_opt ::= ON expr", |
| 159923 | /* 126 */ "indexed_opt ::= INDEXED BY nm", | 161367 | /* 126 */ "on_opt ::=", |
| 159924 | /* 127 */ "indexed_opt ::= NOT INDEXED", | 161368 | /* 127 */ "indexed_opt ::=", |
| 159925 | /* 128 */ "using_opt ::= USING LP idlist RP", | 161369 | /* 128 */ "indexed_opt ::= INDEXED BY nm", |
| 159926 | /* 129 */ "using_opt ::=", | 161370 | /* 129 */ "indexed_opt ::= NOT INDEXED", |
| 159927 | /* 130 */ "orderby_opt ::=", | 161371 | /* 130 */ "using_opt ::= USING LP idlist RP", |
| 159928 | /* 131 */ "orderby_opt ::= ORDER BY sortlist", | 161372 | /* 131 */ "using_opt ::=", |
| 159929 | /* 132 */ "sortlist ::= sortlist COMMA expr sortorder nulls", | 161373 | /* 132 */ "orderby_opt ::=", |
| 159930 | /* 133 */ "sortlist ::= expr sortorder nulls", | 161374 | /* 133 */ "orderby_opt ::= ORDER BY sortlist", |
| 159931 | /* 134 */ "sortorder ::= ASC", | 161375 | /* 134 */ "sortlist ::= sortlist COMMA expr sortorder nulls", |
| 159932 | /* 135 */ "sortorder ::= DESC", | 161376 | /* 135 */ "sortlist ::= expr sortorder nulls", |
| 159933 | /* 136 */ "sortorder ::=", | 161377 | /* 136 */ "sortorder ::= ASC", |
| 159934 | /* 137 */ "nulls ::= NULLS FIRST", | 161378 | /* 137 */ "sortorder ::= DESC", |
| 159935 | /* 138 */ "nulls ::= NULLS LAST", | 161379 | /* 138 */ "sortorder ::=", |
| 159936 | /* 139 */ "nulls ::=", | 161380 | /* 139 */ "nulls ::= NULLS FIRST", |
| 159937 | /* 140 */ "groupby_opt ::=", | 161381 | /* 140 */ "nulls ::= NULLS LAST", |
| 159938 | /* 141 */ "groupby_opt ::= GROUP BY nexprlist", | 161382 | /* 141 */ "nulls ::=", |
| 159939 | /* 142 */ "having_opt ::=", | 161383 | /* 142 */ "groupby_opt ::=", |
| 159940 | /* 143 */ "having_opt ::= HAVING expr", | 161384 | /* 143 */ "groupby_opt ::= GROUP BY nexprlist", |
| 159941 | /* 144 */ "limit_opt ::=", | 161385 | /* 144 */ "having_opt ::=", |
| 159942 | /* 145 */ "limit_opt ::= LIMIT expr", | 161386 | /* 145 */ "having_opt ::= HAVING expr", |
| 159943 | /* 146 */ "limit_opt ::= LIMIT expr OFFSET expr", | 161387 | /* 146 */ "limit_opt ::=", |
| 159944 | /* 147 */ "limit_opt ::= LIMIT expr COMMA expr", | 161388 | /* 147 */ "limit_opt ::= LIMIT expr", |
| 159945 | /* 148 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret", | 161389 | /* 148 */ "limit_opt ::= LIMIT expr OFFSET expr", |
| 159946 | /* 149 */ "where_opt ::=", | 161390 | /* 149 */ "limit_opt ::= LIMIT expr COMMA expr", |
| 159947 | /* 150 */ "where_opt ::= WHERE expr", | 161391 | /* 150 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret", |
| 159948 | /* 151 */ "where_opt_ret ::=", | 161392 | /* 151 */ "where_opt ::=", |
| 159949 | /* 152 */ "where_opt_ret ::= WHERE expr", | 161393 | /* 152 */ "where_opt ::= WHERE expr", |
| 159950 | /* 153 */ "where_opt_ret ::= RETURNING selcollist", | 161394 | /* 153 */ "where_opt_ret ::=", |
| 159951 | /* 154 */ "where_opt_ret ::= WHERE expr RETURNING selcollist", | 161395 | /* 154 */ "where_opt_ret ::= WHERE expr", |
| 159952 | /* 155 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret", | 161396 | /* 155 */ "where_opt_ret ::= RETURNING selcollist", |
| 159953 | /* 156 */ "setlist ::= setlist COMMA nm EQ expr", | 161397 | /* 156 */ "where_opt_ret ::= WHERE expr RETURNING selcollist", |
| 159954 | /* 157 */ "setlist ::= setlist COMMA LP idlist RP EQ expr", | 161398 | /* 157 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret", |
| 159955 | /* 158 */ "setlist ::= nm EQ expr", | 161399 | /* 158 */ "setlist ::= setlist COMMA nm EQ expr", |
| 159956 | /* 159 */ "setlist ::= LP idlist RP EQ expr", | 161400 | /* 159 */ "setlist ::= setlist COMMA LP idlist RP EQ expr", |
| 159957 | /* 160 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert", | 161401 | /* 160 */ "setlist ::= nm EQ expr", |
| 159958 | /* 161 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning", | 161402 | /* 161 */ "setlist ::= LP idlist RP EQ expr", |
| 159959 | /* 162 */ "upsert ::=", | 161403 | /* 162 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert", |
| 159960 | /* 163 */ "upsert ::= RETURNING selcollist", | 161404 | /* 163 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning", |
| 159961 | /* 164 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert", | 161405 | /* 164 */ "upsert ::=", |
| 159962 | /* 165 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert", | 161406 | /* 165 */ "upsert ::= RETURNING selcollist", |
| 159963 | /* 166 */ "upsert ::= ON CONFLICT DO NOTHING returning", | 161407 | /* 166 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert", |
| 159964 | /* 167 */ "upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning", | 161408 | /* 167 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert", |
| 159965 | /* 168 */ "returning ::= RETURNING selcollist", | 161409 | /* 168 */ "upsert ::= ON CONFLICT DO NOTHING returning", |
| 159966 | /* 169 */ "insert_cmd ::= INSERT orconf", | 161410 | /* 169 */ "upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning", |
| 159967 | /* 170 */ "insert_cmd ::= REPLACE", | 161411 | /* 170 */ "returning ::= RETURNING selcollist", |
| 159968 | /* 171 */ "idlist_opt ::=", | 161412 | /* 171 */ "insert_cmd ::= INSERT orconf", |
| 159969 | /* 172 */ "idlist_opt ::= LP idlist RP", | 161413 | /* 172 */ "insert_cmd ::= REPLACE", |
| 159970 | /* 173 */ "idlist ::= idlist COMMA nm", | 161414 | /* 173 */ "idlist_opt ::=", |
| 159971 | /* 174 */ "idlist ::= nm", | 161415 | /* 174 */ "idlist_opt ::= LP idlist RP", |
| 159972 | /* 175 */ "expr ::= LP expr RP", | 161416 | /* 175 */ "idlist ::= idlist COMMA nm", |
| 159973 | /* 176 */ "expr ::= ID|INDEXED", | 161417 | /* 176 */ "idlist ::= nm", |
| 159974 | /* 177 */ "expr ::= JOIN_KW", | 161418 | /* 177 */ "expr ::= LP expr RP", |
| 159975 | /* 178 */ "expr ::= nm DOT nm", | 161419 | /* 178 */ "expr ::= ID|INDEXED", |
| 159976 | /* 179 */ "expr ::= nm DOT nm DOT nm", | 161420 | /* 179 */ "expr ::= JOIN_KW", |
| 159977 | /* 180 */ "term ::= NULL|FLOAT|BLOB", | 161421 | /* 180 */ "expr ::= nm DOT nm", |
| 159978 | /* 181 */ "term ::= STRING", | 161422 | /* 181 */ "expr ::= nm DOT nm DOT nm", |
| 159979 | /* 182 */ "term ::= INTEGER", | 161423 | /* 182 */ "term ::= NULL|FLOAT|BLOB", |
| 159980 | /* 183 */ "expr ::= VARIABLE", | 161424 | /* 183 */ "term ::= STRING", |
| 159981 | /* 184 */ "expr ::= expr COLLATE ID|STRING", | 161425 | /* 184 */ "term ::= INTEGER", |
| 159982 | /* 185 */ "expr ::= CAST LP expr AS typetoken RP", | 161426 | /* 185 */ "expr ::= VARIABLE", |
| 159983 | /* 186 */ "expr ::= ID|INDEXED LP distinct exprlist RP", | 161427 | /* 186 */ "expr ::= expr COLLATE ID|STRING", |
| 159984 | /* 187 */ "expr ::= ID|INDEXED LP STAR RP", | 161428 | /* 187 */ "expr ::= CAST LP expr AS typetoken RP", |
| 159985 | /* 188 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over", | 161429 | /* 188 */ "expr ::= ID|INDEXED LP distinct exprlist RP", |
| 159986 | /* 189 */ "expr ::= ID|INDEXED LP STAR RP filter_over", | 161430 | /* 189 */ "expr ::= ID|INDEXED LP STAR RP", |
| 159987 | /* 190 */ "term ::= CTIME_KW", | 161431 | /* 190 */ "expr ::= ID|INDEXED LP distinct exprlist RP filter_over", |
| 159988 | /* 191 */ "expr ::= LP nexprlist COMMA expr RP", | 161432 | /* 191 */ "expr ::= ID|INDEXED LP STAR RP filter_over", |
| 159989 | /* 192 */ "expr ::= expr AND expr", | 161433 | /* 192 */ "term ::= CTIME_KW", |
| 159990 | /* 193 */ "expr ::= expr OR expr", | 161434 | /* 193 */ "expr ::= LP nexprlist COMMA expr RP", |
| 159991 | /* 194 */ "expr ::= expr LT|GT|GE|LE expr", | 161435 | /* 194 */ "expr ::= expr AND expr", |
| 159992 | /* 195 */ "expr ::= expr EQ|NE expr", | 161436 | /* 195 */ "expr ::= expr OR expr", |
| 159993 | /* 196 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", | 161437 | /* 196 */ "expr ::= expr LT|GT|GE|LE expr", |
| 159994 | /* 197 */ "expr ::= expr PLUS|MINUS expr", | 161438 | /* 197 */ "expr ::= expr EQ|NE expr", |
| 159995 | /* 198 */ "expr ::= expr STAR|SLASH|REM expr", | 161439 | /* 198 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr", |
| 159996 | /* 199 */ "expr ::= expr CONCAT expr", | 161440 | /* 199 */ "expr ::= expr PLUS|MINUS expr", |
| 159997 | /* 200 */ "likeop ::= NOT LIKE_KW|MATCH", | 161441 | /* 200 */ "expr ::= expr STAR|SLASH|REM expr", |
| 159998 | /* 201 */ "expr ::= expr likeop expr", | 161442 | /* 201 */ "expr ::= expr CONCAT expr", |
| 159999 | /* 202 */ "expr ::= expr likeop expr ESCAPE expr", | 161443 | /* 202 */ "likeop ::= NOT LIKE_KW|MATCH", |
| 160000 | /* 203 */ "expr ::= expr ISNULL|NOTNULL", | 161444 | /* 203 */ "expr ::= expr likeop expr", |
| 160001 | /* 204 */ "expr ::= expr NOT NULL", | 161445 | /* 204 */ "expr ::= expr likeop expr ESCAPE expr", |
| 160002 | /* 205 */ "expr ::= expr IS expr", | 161446 | /* 205 */ "expr ::= expr ISNULL|NOTNULL", |
| 160003 | /* 206 */ "expr ::= expr IS NOT expr", | 161447 | /* 206 */ "expr ::= expr NOT NULL", |
| 160004 | /* 207 */ "expr ::= NOT expr", | 161448 | /* 207 */ "expr ::= expr IS expr", |
| 160005 | /* 208 */ "expr ::= BITNOT expr", | 161449 | /* 208 */ "expr ::= expr IS NOT expr", |
| 160006 | /* 209 */ "expr ::= PLUS|MINUS expr", | 161450 | /* 209 */ "expr ::= NOT expr", |
| 160007 | /* 210 */ "between_op ::= BETWEEN", | 161451 | /* 210 */ "expr ::= BITNOT expr", |
| 160008 | /* 211 */ "between_op ::= NOT BETWEEN", | 161452 | /* 211 */ "expr ::= PLUS|MINUS expr", |
| 160009 | /* 212 */ "expr ::= expr between_op expr AND expr", | 161453 | /* 212 */ "between_op ::= BETWEEN", |
| 160010 | /* 213 */ "in_op ::= IN", | 161454 | /* 213 */ "between_op ::= NOT BETWEEN", |
| 160011 | /* 214 */ "in_op ::= NOT IN", | 161455 | /* 214 */ "expr ::= expr between_op expr AND expr", |
| 160012 | /* 215 */ "expr ::= expr in_op LP exprlist RP", | 161456 | /* 215 */ "in_op ::= IN", |
| 160013 | /* 216 */ "expr ::= LP select RP", | 161457 | /* 216 */ "in_op ::= NOT IN", |
| 160014 | /* 217 */ "expr ::= expr in_op LP select RP", | 161458 | /* 217 */ "expr ::= expr in_op LP exprlist RP", |
| 160015 | /* 218 */ "expr ::= expr in_op nm dbnm paren_exprlist", | 161459 | /* 218 */ "expr ::= LP select RP", |
| 160016 | /* 219 */ "expr ::= EXISTS LP select RP", | 161460 | /* 219 */ "expr ::= expr in_op LP select RP", |
| 160017 | /* 220 */ "expr ::= CASE case_operand case_exprlist case_else END", | 161461 | /* 220 */ "expr ::= expr in_op nm dbnm paren_exprlist", |
| 160018 | /* 221 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", | 161462 | /* 221 */ "expr ::= EXISTS LP select RP", |
| 160019 | /* 222 */ "case_exprlist ::= WHEN expr THEN expr", | 161463 | /* 222 */ "expr ::= CASE case_operand case_exprlist case_else END", |
| 160020 | /* 223 */ "case_else ::= ELSE expr", | 161464 | /* 223 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr", |
| 160021 | /* 224 */ "case_else ::=", | 161465 | /* 224 */ "case_exprlist ::= WHEN expr THEN expr", |
| 160022 | /* 225 */ "case_operand ::= expr", | 161466 | /* 225 */ "case_else ::= ELSE expr", |
| 160023 | /* 226 */ "case_operand ::=", | 161467 | /* 226 */ "case_else ::=", |
| 160024 | /* 227 */ "exprlist ::=", | 161468 | /* 227 */ "case_operand ::= expr", |
| 160025 | /* 228 */ "nexprlist ::= nexprlist COMMA expr", | 161469 | /* 228 */ "case_operand ::=", |
| 160026 | /* 229 */ "nexprlist ::= expr", | 161470 | /* 229 */ "exprlist ::=", |
| 160027 | /* 230 */ "paren_exprlist ::=", | 161471 | /* 230 */ "nexprlist ::= nexprlist COMMA expr", |
| 160028 | /* 231 */ "paren_exprlist ::= LP exprlist RP", | 161472 | /* 231 */ "nexprlist ::= expr", |
| 160029 | /* 232 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", | 161473 | /* 232 */ "paren_exprlist ::=", |
| 160030 | /* 233 */ "uniqueflag ::= UNIQUE", | 161474 | /* 233 */ "paren_exprlist ::= LP exprlist RP", |
| 160031 | /* 234 */ "uniqueflag ::=", | 161475 | /* 234 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt", |
| 160032 | /* 235 */ "eidlist_opt ::=", | 161476 | /* 235 */ "uniqueflag ::= UNIQUE", |
| 160033 | /* 236 */ "eidlist_opt ::= LP eidlist RP", | 161477 | /* 236 */ "uniqueflag ::=", |
| 160034 | /* 237 */ "eidlist ::= eidlist COMMA nm collate sortorder", | 161478 | /* 237 */ "eidlist_opt ::=", |
| 160035 | /* 238 */ "eidlist ::= nm collate sortorder", | 161479 | /* 238 */ "eidlist_opt ::= LP eidlist RP", |
| 160036 | /* 239 */ "collate ::=", | 161480 | /* 239 */ "eidlist ::= eidlist COMMA nm collate sortorder", |
| 160037 | /* 240 */ "collate ::= COLLATE ID|STRING", | 161481 | /* 240 */ "eidlist ::= nm collate sortorder", |
| 160038 | /* 241 */ "cmd ::= DROP INDEX ifexists fullname", | 161482 | /* 241 */ "collate ::=", |
| 160039 | /* 242 */ "cmd ::= VACUUM vinto", | 161483 | /* 242 */ "collate ::= COLLATE ID|STRING", |
| 160040 | /* 243 */ "cmd ::= VACUUM nm vinto", | 161484 | /* 243 */ "cmd ::= DROP INDEX ifexists fullname", |
| 160041 | /* 244 */ "vinto ::= INTO expr", | 161485 | /* 244 */ "cmd ::= VACUUM vinto", |
| 160042 | /* 245 */ "vinto ::=", | 161486 | /* 245 */ "cmd ::= VACUUM nm vinto", |
| 160043 | /* 246 */ "cmd ::= PRAGMA nm dbnm", | 161487 | /* 246 */ "vinto ::= INTO expr", |
| 160044 | /* 247 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", | 161488 | /* 247 */ "vinto ::=", |
| 160045 | /* 248 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", | 161489 | /* 248 */ "cmd ::= PRAGMA nm dbnm", |
| 160046 | /* 249 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", | 161490 | /* 249 */ "cmd ::= PRAGMA nm dbnm EQ nmnum", |
| 160047 | /* 250 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", | 161491 | /* 250 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP", |
| 160048 | /* 251 */ "plus_num ::= PLUS INTEGER|FLOAT", | 161492 | /* 251 */ "cmd ::= PRAGMA nm dbnm EQ minus_num", |
| 160049 | /* 252 */ "minus_num ::= MINUS INTEGER|FLOAT", | 161493 | /* 252 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP", |
| 160050 | /* 253 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", | 161494 | /* 253 */ "plus_num ::= PLUS INTEGER|FLOAT", |
| 160051 | /* 254 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", | 161495 | /* 254 */ "minus_num ::= MINUS INTEGER|FLOAT", |
| 160052 | /* 255 */ "trigger_time ::= BEFORE|AFTER", | 161496 | /* 255 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END", |
| 160053 | /* 256 */ "trigger_time ::= INSTEAD OF", | 161497 | /* 256 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause", |
| 160054 | /* 257 */ "trigger_time ::=", | 161498 | /* 257 */ "trigger_time ::= BEFORE|AFTER", |
| 160055 | /* 258 */ "trigger_event ::= DELETE|INSERT", | 161499 | /* 258 */ "trigger_time ::= INSTEAD OF", |
| 160056 | /* 259 */ "trigger_event ::= UPDATE", | 161500 | /* 259 */ "trigger_time ::=", |
| 160057 | /* 260 */ "trigger_event ::= UPDATE OF idlist", | 161501 | /* 260 */ "trigger_event ::= DELETE|INSERT", |
| 160058 | /* 261 */ "when_clause ::=", | 161502 | /* 261 */ "trigger_event ::= UPDATE", |
| 160059 | /* 262 */ "when_clause ::= WHEN expr", | 161503 | /* 262 */ "trigger_event ::= UPDATE OF idlist", |
| 160060 | /* 263 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", | 161504 | /* 263 */ "when_clause ::=", |
| 160061 | /* 264 */ "trigger_cmd_list ::= trigger_cmd SEMI", | 161505 | /* 264 */ "when_clause ::= WHEN expr", |
| 160062 | /* 265 */ "trnm ::= nm DOT nm", | 161506 | /* 265 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI", |
| 160063 | /* 266 */ "tridxby ::= INDEXED BY nm", | 161507 | /* 266 */ "trigger_cmd_list ::= trigger_cmd SEMI", |
| 160064 | /* 267 */ "tridxby ::= NOT INDEXED", | 161508 | /* 267 */ "trnm ::= nm DOT nm", |
| 160065 | /* 268 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", | 161509 | /* 268 */ "tridxby ::= INDEXED BY nm", |
| 160066 | /* 269 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", | 161510 | /* 269 */ "tridxby ::= NOT INDEXED", |
| 160067 | /* 270 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", | 161511 | /* 270 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt", |
| 160068 | /* 271 */ "trigger_cmd ::= scanpt select scanpt", | 161512 | /* 271 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt", |
| 160069 | /* 272 */ "expr ::= RAISE LP IGNORE RP", | 161513 | /* 272 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt", |
| 160070 | /* 273 */ "expr ::= RAISE LP raisetype COMMA nm RP", | 161514 | /* 273 */ "trigger_cmd ::= scanpt select scanpt", |
| 160071 | /* 274 */ "raisetype ::= ROLLBACK", | 161515 | /* 274 */ "expr ::= RAISE LP IGNORE RP", |
| 160072 | /* 275 */ "raisetype ::= ABORT", | 161516 | /* 275 */ "expr ::= RAISE LP raisetype COMMA nm RP", |
| 160073 | /* 276 */ "raisetype ::= FAIL", | 161517 | /* 276 */ "raisetype ::= ROLLBACK", |
| 160074 | /* 277 */ "cmd ::= DROP TRIGGER ifexists fullname", | 161518 | /* 277 */ "raisetype ::= ABORT", |
| 160075 | /* 278 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", | 161519 | /* 278 */ "raisetype ::= FAIL", |
| 160076 | /* 279 */ "cmd ::= DETACH database_kw_opt expr", | 161520 | /* 279 */ "cmd ::= DROP TRIGGER ifexists fullname", |
| 160077 | /* 280 */ "key_opt ::=", | 161521 | /* 280 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt", |
| 160078 | /* 281 */ "key_opt ::= KEY expr", | 161522 | /* 281 */ "cmd ::= DETACH database_kw_opt expr", |
| 160079 | /* 282 */ "cmd ::= REINDEX", | 161523 | /* 282 */ "key_opt ::=", |
| 160080 | /* 283 */ "cmd ::= REINDEX nm dbnm", | 161524 | /* 283 */ "key_opt ::= KEY expr", |
| 160081 | /* 284 */ "cmd ::= ANALYZE", | 161525 | /* 284 */ "cmd ::= REINDEX", |
| 160082 | /* 285 */ "cmd ::= ANALYZE nm dbnm", | 161526 | /* 285 */ "cmd ::= REINDEX nm dbnm", |
| 160083 | /* 286 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", | 161527 | /* 286 */ "cmd ::= ANALYZE", |
| 160084 | /* 287 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", | 161528 | /* 287 */ "cmd ::= ANALYZE nm dbnm", |
| 160085 | /* 288 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", | 161529 | /* 288 */ "cmd ::= ALTER TABLE fullname RENAME TO nm", |
| 160086 | /* 289 */ "add_column_fullname ::= fullname", | 161530 | /* 289 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist", |
| 160087 | /* 290 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", | 161531 | /* 290 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm", |
| 160088 | /* 291 */ "cmd ::= create_vtab", | 161532 | /* 291 */ "add_column_fullname ::= fullname", |
| 160089 | /* 292 */ "cmd ::= create_vtab LP vtabarglist RP", | 161533 | /* 292 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm", |
| 160090 | /* 293 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", | 161534 | /* 293 */ "cmd ::= create_vtab", |
| 160091 | /* 294 */ "vtabarg ::=", | 161535 | /* 294 */ "cmd ::= create_vtab LP vtabarglist RP", |
| 160092 | /* 295 */ "vtabargtoken ::= ANY", | 161536 | /* 295 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm", |
| 160093 | /* 296 */ "vtabargtoken ::= lp anylist RP", | 161537 | /* 296 */ "vtabarg ::=", |
| 160094 | /* 297 */ "lp ::= LP", | 161538 | /* 297 */ "vtabargtoken ::= ANY", |
| 160095 | /* 298 */ "with ::= WITH wqlist", | 161539 | /* 298 */ "vtabargtoken ::= lp anylist RP", |
| 160096 | /* 299 */ "with ::= WITH RECURSIVE wqlist", | 161540 | /* 299 */ "lp ::= LP", |
| 160097 | /* 300 */ "wqas ::= AS", | 161541 | /* 300 */ "with ::= WITH wqlist", |
| 160098 | /* 301 */ "wqas ::= AS MATERIALIZED", | 161542 | /* 301 */ "with ::= WITH RECURSIVE wqlist", |
| 160099 | /* 302 */ "wqas ::= AS NOT MATERIALIZED", | 161543 | /* 302 */ "wqas ::= AS", |
| 160100 | /* 303 */ "wqitem ::= nm eidlist_opt wqas LP select RP", | 161544 | /* 303 */ "wqas ::= AS MATERIALIZED", |
| 160101 | /* 304 */ "wqlist ::= wqitem", | 161545 | /* 304 */ "wqas ::= AS NOT MATERIALIZED", |
| 160102 | /* 305 */ "wqlist ::= wqlist COMMA wqitem", | 161546 | /* 305 */ "wqitem ::= nm eidlist_opt wqas LP select RP", |
| 160103 | /* 306 */ "windowdefn_list ::= windowdefn", | 161547 | /* 306 */ "wqlist ::= wqitem", |
| 160104 | /* 307 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", | 161548 | /* 307 */ "wqlist ::= wqlist COMMA wqitem", |
| 160105 | /* 308 */ "windowdefn ::= nm AS LP window RP", | 161549 | /* 308 */ "windowdefn_list ::= windowdefn", |
| 160106 | /* 309 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", | 161550 | /* 309 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn", |
| 160107 | /* 310 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", | 161551 | /* 310 */ "windowdefn ::= nm AS LP window RP", |
| 160108 | /* 311 */ "window ::= ORDER BY sortlist frame_opt", | 161552 | /* 311 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt", |
| 160109 | /* 312 */ "window ::= nm ORDER BY sortlist frame_opt", | 161553 | /* 312 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt", |
| 160110 | /* 313 */ "window ::= frame_opt", | 161554 | /* 313 */ "window ::= ORDER BY sortlist frame_opt", |
| 160111 | /* 314 */ "window ::= nm frame_opt", | 161555 | /* 314 */ "window ::= nm ORDER BY sortlist frame_opt", |
| 160112 | /* 315 */ "frame_opt ::=", | 161556 | /* 315 */ "window ::= frame_opt", |
| 160113 | /* 316 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", | 161557 | /* 316 */ "window ::= nm frame_opt", |
| 160114 | /* 317 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", | 161558 | /* 317 */ "frame_opt ::=", |
| 160115 | /* 318 */ "range_or_rows ::= RANGE|ROWS|GROUPS", | 161559 | /* 318 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt", |
| 160116 | /* 319 */ "frame_bound_s ::= frame_bound", | 161560 | /* 319 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt", |
| 160117 | /* 320 */ "frame_bound_s ::= UNBOUNDED PRECEDING", | 161561 | /* 320 */ "range_or_rows ::= RANGE|ROWS|GROUPS", |
| 160118 | /* 321 */ "frame_bound_e ::= frame_bound", | 161562 | /* 321 */ "frame_bound_s ::= frame_bound", |
| 160119 | /* 322 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", | 161563 | /* 322 */ "frame_bound_s ::= UNBOUNDED PRECEDING", |
| 160120 | /* 323 */ "frame_bound ::= expr PRECEDING|FOLLOWING", | 161564 | /* 323 */ "frame_bound_e ::= frame_bound", |
| 160121 | /* 324 */ "frame_bound ::= CURRENT ROW", | 161565 | /* 324 */ "frame_bound_e ::= UNBOUNDED FOLLOWING", |
| 160122 | /* 325 */ "frame_exclude_opt ::=", | 161566 | /* 325 */ "frame_bound ::= expr PRECEDING|FOLLOWING", |
| 160123 | /* 326 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", | 161567 | /* 326 */ "frame_bound ::= CURRENT ROW", |
| 160124 | /* 327 */ "frame_exclude ::= NO OTHERS", | 161568 | /* 327 */ "frame_exclude_opt ::=", |
| 160125 | /* 328 */ "frame_exclude ::= CURRENT ROW", | 161569 | /* 328 */ "frame_exclude_opt ::= EXCLUDE frame_exclude", |
| 160126 | /* 329 */ "frame_exclude ::= GROUP|TIES", | 161570 | /* 329 */ "frame_exclude ::= NO OTHERS", |
| 160127 | /* 330 */ "window_clause ::= WINDOW windowdefn_list", | 161571 | /* 330 */ "frame_exclude ::= CURRENT ROW", |
| 160128 | /* 331 */ "filter_over ::= filter_clause over_clause", | 161572 | /* 331 */ "frame_exclude ::= GROUP|TIES", |
| 160129 | /* 332 */ "filter_over ::= over_clause", | 161573 | /* 332 */ "window_clause ::= WINDOW windowdefn_list", |
| 160130 | /* 333 */ "filter_over ::= filter_clause", | 161574 | /* 333 */ "filter_over ::= filter_clause over_clause", |
| 160131 | /* 334 */ "over_clause ::= OVER LP window RP", | 161575 | /* 334 */ "filter_over ::= over_clause", |
| 160132 | /* 335 */ "over_clause ::= OVER nm", | 161576 | /* 335 */ "filter_over ::= filter_clause", |
| 160133 | /* 336 */ "filter_clause ::= FILTER LP WHERE expr RP", | 161577 | /* 336 */ "over_clause ::= OVER LP window RP", |
| 160134 | /* 337 */ "input ::= cmdlist", | 161578 | /* 337 */ "over_clause ::= OVER nm", |
| 160135 | /* 338 */ "cmdlist ::= cmdlist ecmd", | 161579 | /* 338 */ "filter_clause ::= FILTER LP WHERE expr RP", |
| 160136 | /* 339 */ "cmdlist ::= ecmd", | 161580 | /* 339 */ "input ::= cmdlist", |
| 160137 | /* 340 */ "ecmd ::= SEMI", | 161581 | /* 340 */ "cmdlist ::= cmdlist ecmd", |
| 160138 | /* 341 */ "ecmd ::= cmdx SEMI", | 161582 | /* 341 */ "cmdlist ::= ecmd", |
| 160139 | /* 342 */ "ecmd ::= explain cmdx SEMI", | 161583 | /* 342 */ "ecmd ::= SEMI", |
| 160140 | /* 343 */ "trans_opt ::=", | 161584 | /* 343 */ "ecmd ::= cmdx SEMI", |
| 160141 | /* 344 */ "trans_opt ::= TRANSACTION", | 161585 | /* 344 */ "ecmd ::= explain cmdx SEMI", |
| 160142 | /* 345 */ "trans_opt ::= TRANSACTION nm", | 161586 | /* 345 */ "trans_opt ::=", |
| 160143 | /* 346 */ "savepoint_opt ::= SAVEPOINT", | 161587 | /* 346 */ "trans_opt ::= TRANSACTION", |
| 160144 | /* 347 */ "savepoint_opt ::=", | 161588 | /* 347 */ "trans_opt ::= TRANSACTION nm", |
| 160145 | /* 348 */ "cmd ::= create_table create_table_args", | 161589 | /* 348 */ "savepoint_opt ::= SAVEPOINT", |
| 160146 | /* 349 */ "columnlist ::= columnlist COMMA columnname carglist", | 161590 | /* 349 */ "savepoint_opt ::=", |
| 160147 | /* 350 */ "columnlist ::= columnname carglist", | 161591 | /* 350 */ "cmd ::= create_table create_table_args", |
| 160148 | /* 351 */ "nm ::= ID|INDEXED", | 161592 | /* 351 */ "table_option_set ::= table_option", |
| 160149 | /* 352 */ "nm ::= STRING", | 161593 | /* 352 */ "columnlist ::= columnlist COMMA columnname carglist", |
| 160150 | /* 353 */ "nm ::= JOIN_KW", | 161594 | /* 353 */ "columnlist ::= columnname carglist", |
| 160151 | /* 354 */ "typetoken ::= typename", | 161595 | /* 354 */ "nm ::= ID|INDEXED", |
| 160152 | /* 355 */ "typename ::= ID|STRING", | 161596 | /* 355 */ "nm ::= STRING", |
| 160153 | /* 356 */ "signed ::= plus_num", | 161597 | /* 356 */ "nm ::= JOIN_KW", |
| 160154 | /* 357 */ "signed ::= minus_num", | 161598 | /* 357 */ "typetoken ::= typename", |
| 160155 | /* 358 */ "carglist ::= carglist ccons", | 161599 | /* 358 */ "typename ::= ID|STRING", |
| 160156 | /* 359 */ "carglist ::=", | 161600 | /* 359 */ "signed ::= plus_num", |
| 160157 | /* 360 */ "ccons ::= NULL onconf", | 161601 | /* 360 */ "signed ::= minus_num", |
| 160158 | /* 361 */ "ccons ::= GENERATED ALWAYS AS generated", | 161602 | /* 361 */ "carglist ::= carglist ccons", |
| 160159 | /* 362 */ "ccons ::= AS generated", | 161603 | /* 362 */ "carglist ::=", |
| 160160 | /* 363 */ "conslist_opt ::= COMMA conslist", | 161604 | /* 363 */ "ccons ::= NULL onconf", |
| 160161 | /* 364 */ "conslist ::= conslist tconscomma tcons", | 161605 | /* 364 */ "ccons ::= GENERATED ALWAYS AS generated", |
| 160162 | /* 365 */ "conslist ::= tcons", | 161606 | /* 365 */ "ccons ::= AS generated", |
| 160163 | /* 366 */ "tconscomma ::=", | 161607 | /* 366 */ "conslist_opt ::= COMMA conslist", |
| 160164 | /* 367 */ "defer_subclause_opt ::= defer_subclause", | 161608 | /* 367 */ "conslist ::= conslist tconscomma tcons", |
| 160165 | /* 368 */ "resolvetype ::= raisetype", | 161609 | /* 368 */ "conslist ::= tcons", |
| 160166 | /* 369 */ "selectnowith ::= oneselect", | 161610 | /* 369 */ "tconscomma ::=", |
| 160167 | /* 370 */ "oneselect ::= values", | 161611 | /* 370 */ "defer_subclause_opt ::= defer_subclause", |
| 160168 | /* 371 */ "sclp ::= selcollist COMMA", | 161612 | /* 371 */ "resolvetype ::= raisetype", |
| 160169 | /* 372 */ "as ::= ID|STRING", | 161613 | /* 372 */ "selectnowith ::= oneselect", |
| 160170 | /* 373 */ "returning ::=", | 161614 | /* 373 */ "oneselect ::= values", |
| 160171 | /* 374 */ "expr ::= term", | 161615 | /* 374 */ "sclp ::= selcollist COMMA", |
| 160172 | /* 375 */ "likeop ::= LIKE_KW|MATCH", | 161616 | /* 375 */ "as ::= ID|STRING", |
| 160173 | /* 376 */ "exprlist ::= nexprlist", | 161617 | /* 376 */ "returning ::=", |
| 160174 | /* 377 */ "nmnum ::= plus_num", | 161618 | /* 377 */ "expr ::= term", |
| 160175 | /* 378 */ "nmnum ::= nm", | 161619 | /* 378 */ "likeop ::= LIKE_KW|MATCH", |
| 160176 | /* 379 */ "nmnum ::= ON", | 161620 | /* 379 */ "exprlist ::= nexprlist", |
| 160177 | /* 380 */ "nmnum ::= DELETE", | 161621 | /* 380 */ "nmnum ::= plus_num", |
| 160178 | /* 381 */ "nmnum ::= DEFAULT", | 161622 | /* 381 */ "nmnum ::= nm", |
| 160179 | /* 382 */ "plus_num ::= INTEGER|FLOAT", | 161623 | /* 382 */ "nmnum ::= ON", |
| 160180 | /* 383 */ "foreach_clause ::=", | 161624 | /* 383 */ "nmnum ::= DELETE", |
| 160181 | /* 384 */ "foreach_clause ::= FOR EACH ROW", | 161625 | /* 384 */ "nmnum ::= DEFAULT", |
| 160182 | /* 385 */ "trnm ::= nm", | 161626 | /* 385 */ "plus_num ::= INTEGER|FLOAT", |
| 160183 | /* 386 */ "tridxby ::=", | 161627 | /* 386 */ "foreach_clause ::=", |
| 160184 | /* 387 */ "database_kw_opt ::= DATABASE", | 161628 | /* 387 */ "foreach_clause ::= FOR EACH ROW", |
| 160185 | /* 388 */ "database_kw_opt ::=", | 161629 | /* 388 */ "trnm ::= nm", |
| 160186 | /* 389 */ "kwcolumn_opt ::=", | 161630 | /* 389 */ "tridxby ::=", |
| 160187 | /* 390 */ "kwcolumn_opt ::= COLUMNKW", | 161631 | /* 390 */ "database_kw_opt ::= DATABASE", |
| 160188 | /* 391 */ "vtabarglist ::= vtabarg", | 161632 | /* 391 */ "database_kw_opt ::=", |
| 160189 | /* 392 */ "vtabarglist ::= vtabarglist COMMA vtabarg", | 161633 | /* 392 */ "kwcolumn_opt ::=", |
| 160190 | /* 393 */ "vtabarg ::= vtabarg vtabargtoken", | 161634 | /* 393 */ "kwcolumn_opt ::= COLUMNKW", |
| 160191 | /* 394 */ "anylist ::=", | 161635 | /* 394 */ "vtabarglist ::= vtabarg", |
| 160192 | /* 395 */ "anylist ::= anylist LP anylist RP", | 161636 | /* 395 */ "vtabarglist ::= vtabarglist COMMA vtabarg", |
| 160193 | /* 396 */ "anylist ::= anylist ANY", | 161637 | /* 396 */ "vtabarg ::= vtabarg vtabargtoken", |
| 160194 | /* 397 */ "with ::=", | 161638 | /* 397 */ "anylist ::=", |
| 161639 | /* 398 */ "anylist ::= anylist LP anylist RP", | ||
| 161640 | /* 399 */ "anylist ::= anylist ANY", | ||
| 161641 | /* 400 */ "with ::=", | ||
| 160195 | }; | 161642 | }; |
| 160196 | #endif /* NDEBUG */ | 161643 | #endif /* NDEBUG */ |
| 160197 | 161644 | ||
| @@ -160318,98 +161765,98 @@ static void yy_destructor( | |||
| 160318 | */ | 161765 | */ |
| 160319 | /********* Begin destructor definitions ***************************************/ | 161766 | /********* Begin destructor definitions ***************************************/ |
| 160320 | case 203: /* select */ | 161767 | case 203: /* select */ |
| 160321 | case 237: /* selectnowith */ | 161768 | case 238: /* selectnowith */ |
| 160322 | case 238: /* oneselect */ | 161769 | case 239: /* oneselect */ |
| 160323 | case 250: /* values */ | 161770 | case 251: /* values */ |
| 160324 | { | 161771 | { |
| 160325 | sqlite3SelectDelete(pParse->db, (yypminor->yy81)); | 161772 | sqlite3SelectDelete(pParse->db, (yypminor->yy303)); |
| 160326 | } | 161773 | } |
| 160327 | break; | 161774 | break; |
| 160328 | case 214: /* term */ | 161775 | case 215: /* term */ |
| 160329 | case 215: /* expr */ | 161776 | case 216: /* expr */ |
| 160330 | case 244: /* where_opt */ | 161777 | case 245: /* where_opt */ |
| 160331 | case 246: /* having_opt */ | 161778 | case 247: /* having_opt */ |
| 160332 | case 258: /* on_opt */ | 161779 | case 259: /* on_opt */ |
| 160333 | case 265: /* where_opt_ret */ | 161780 | case 266: /* where_opt_ret */ |
| 160334 | case 276: /* case_operand */ | 161781 | case 277: /* case_operand */ |
| 160335 | case 278: /* case_else */ | 161782 | case 279: /* case_else */ |
| 160336 | case 281: /* vinto */ | 161783 | case 282: /* vinto */ |
| 160337 | case 288: /* when_clause */ | 161784 | case 289: /* when_clause */ |
| 160338 | case 293: /* key_opt */ | 161785 | case 294: /* key_opt */ |
| 160339 | case 309: /* filter_clause */ | 161786 | case 310: /* filter_clause */ |
| 160340 | { | 161787 | { |
| 160341 | sqlite3ExprDelete(pParse->db, (yypminor->yy404)); | 161788 | sqlite3ExprDelete(pParse->db, (yypminor->yy626)); |
| 160342 | } | 161789 | } |
| 160343 | break; | 161790 | break; |
| 160344 | case 219: /* eidlist_opt */ | 161791 | case 220: /* eidlist_opt */ |
| 160345 | case 229: /* sortlist */ | 161792 | case 230: /* sortlist */ |
| 160346 | case 230: /* eidlist */ | 161793 | case 231: /* eidlist */ |
| 160347 | case 242: /* selcollist */ | 161794 | case 243: /* selcollist */ |
| 160348 | case 245: /* groupby_opt */ | 161795 | case 246: /* groupby_opt */ |
| 160349 | case 247: /* orderby_opt */ | 161796 | case 248: /* orderby_opt */ |
| 160350 | case 251: /* nexprlist */ | 161797 | case 252: /* nexprlist */ |
| 160351 | case 252: /* sclp */ | 161798 | case 253: /* sclp */ |
| 160352 | case 260: /* exprlist */ | 161799 | case 261: /* exprlist */ |
| 160353 | case 266: /* setlist */ | 161800 | case 267: /* setlist */ |
| 160354 | case 275: /* paren_exprlist */ | 161801 | case 276: /* paren_exprlist */ |
| 160355 | case 277: /* case_exprlist */ | 161802 | case 278: /* case_exprlist */ |
| 160356 | case 308: /* part_opt */ | 161803 | case 309: /* part_opt */ |
| 160357 | { | 161804 | { |
| 160358 | sqlite3ExprListDelete(pParse->db, (yypminor->yy70)); | 161805 | sqlite3ExprListDelete(pParse->db, (yypminor->yy562)); |
| 160359 | } | 161806 | } |
| 160360 | break; | 161807 | break; |
| 160361 | case 236: /* fullname */ | 161808 | case 237: /* fullname */ |
| 160362 | case 243: /* from */ | 161809 | case 244: /* from */ |
| 160363 | case 254: /* seltablist */ | 161810 | case 255: /* seltablist */ |
| 160364 | case 255: /* stl_prefix */ | 161811 | case 256: /* stl_prefix */ |
| 160365 | case 261: /* xfullname */ | 161812 | case 262: /* xfullname */ |
| 160366 | { | 161813 | { |
| 160367 | sqlite3SrcListDelete(pParse->db, (yypminor->yy153)); | 161814 | sqlite3SrcListDelete(pParse->db, (yypminor->yy607)); |
| 160368 | } | 161815 | } |
| 160369 | break; | 161816 | break; |
| 160370 | case 239: /* wqlist */ | 161817 | case 240: /* wqlist */ |
| 160371 | { | 161818 | { |
| 160372 | sqlite3WithDelete(pParse->db, (yypminor->yy103)); | 161819 | sqlite3WithDelete(pParse->db, (yypminor->yy43)); |
| 160373 | } | 161820 | } |
| 160374 | break; | 161821 | break; |
| 160375 | case 249: /* window_clause */ | 161822 | case 250: /* window_clause */ |
| 160376 | case 304: /* windowdefn_list */ | 161823 | case 305: /* windowdefn_list */ |
| 160377 | { | 161824 | { |
| 160378 | sqlite3WindowListDelete(pParse->db, (yypminor->yy49)); | 161825 | sqlite3WindowListDelete(pParse->db, (yypminor->yy375)); |
| 160379 | } | 161826 | } |
| 160380 | break; | 161827 | break; |
| 160381 | case 259: /* using_opt */ | 161828 | case 260: /* using_opt */ |
| 160382 | case 262: /* idlist */ | 161829 | case 263: /* idlist */ |
| 160383 | case 268: /* idlist_opt */ | 161830 | case 269: /* idlist_opt */ |
| 160384 | { | 161831 | { |
| 160385 | sqlite3IdListDelete(pParse->db, (yypminor->yy436)); | 161832 | sqlite3IdListDelete(pParse->db, (yypminor->yy240)); |
| 160386 | } | 161833 | } |
| 160387 | break; | 161834 | break; |
| 160388 | case 271: /* filter_over */ | 161835 | case 272: /* filter_over */ |
| 160389 | case 305: /* windowdefn */ | 161836 | case 306: /* windowdefn */ |
| 160390 | case 306: /* window */ | 161837 | case 307: /* window */ |
| 160391 | case 307: /* frame_opt */ | 161838 | case 308: /* frame_opt */ |
| 160392 | case 310: /* over_clause */ | 161839 | case 311: /* over_clause */ |
| 160393 | { | 161840 | { |
| 160394 | sqlite3WindowDelete(pParse->db, (yypminor->yy49)); | 161841 | sqlite3WindowDelete(pParse->db, (yypminor->yy375)); |
| 160395 | } | 161842 | } |
| 160396 | break; | 161843 | break; |
| 160397 | case 284: /* trigger_cmd_list */ | 161844 | case 285: /* trigger_cmd_list */ |
| 160398 | case 289: /* trigger_cmd */ | 161845 | case 290: /* trigger_cmd */ |
| 160399 | { | 161846 | { |
| 160400 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy157)); | 161847 | sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy95)); |
| 160401 | } | 161848 | } |
| 160402 | break; | 161849 | break; |
| 160403 | case 286: /* trigger_event */ | 161850 | case 287: /* trigger_event */ |
| 160404 | { | 161851 | { |
| 160405 | sqlite3IdListDelete(pParse->db, (yypminor->yy262).b); | 161852 | sqlite3IdListDelete(pParse->db, (yypminor->yy570).b); |
| 160406 | } | 161853 | } |
| 160407 | break; | 161854 | break; |
| 160408 | case 312: /* frame_bound */ | 161855 | case 313: /* frame_bound */ |
| 160409 | case 313: /* frame_bound_s */ | 161856 | case 314: /* frame_bound_s */ |
| 160410 | case 314: /* frame_bound_e */ | 161857 | case 315: /* frame_bound_e */ |
| 160411 | { | 161858 | { |
| 160412 | sqlite3ExprDelete(pParse->db, (yypminor->yy117).pExpr); | 161859 | sqlite3ExprDelete(pParse->db, (yypminor->yy81).pExpr); |
| 160413 | } | 161860 | } |
| 160414 | break; | 161861 | break; |
| 160415 | /********* End destructor definitions *****************************************/ | 161862 | /********* End destructor definitions *****************************************/ |
| @@ -160719,385 +162166,388 @@ static const YYCODETYPE yyRuleInfoLhs[] = { | |||
| 160719 | 198, /* (16) ifnotexists ::= IF NOT EXISTS */ | 162166 | 198, /* (16) ifnotexists ::= IF NOT EXISTS */ |
| 160720 | 197, /* (17) temp ::= TEMP */ | 162167 | 197, /* (17) temp ::= TEMP */ |
| 160721 | 197, /* (18) temp ::= */ | 162168 | 197, /* (18) temp ::= */ |
| 160722 | 195, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ | 162169 | 195, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */ |
| 160723 | 195, /* (20) create_table_args ::= AS select */ | 162170 | 195, /* (20) create_table_args ::= AS select */ |
| 160724 | 202, /* (21) table_options ::= */ | 162171 | 202, /* (21) table_option_set ::= */ |
| 160725 | 202, /* (22) table_options ::= WITHOUT nm */ | 162172 | 202, /* (22) table_option_set ::= table_option_set COMMA table_option */ |
| 160726 | 204, /* (23) columnname ::= nm typetoken */ | 162173 | 204, /* (23) table_option ::= WITHOUT nm */ |
| 160727 | 206, /* (24) typetoken ::= */ | 162174 | 204, /* (24) table_option ::= nm */ |
| 160728 | 206, /* (25) typetoken ::= typename LP signed RP */ | 162175 | 205, /* (25) columnname ::= nm typetoken */ |
| 160729 | 206, /* (26) typetoken ::= typename LP signed COMMA signed RP */ | 162176 | 207, /* (26) typetoken ::= */ |
| 160730 | 207, /* (27) typename ::= typename ID|STRING */ | 162177 | 207, /* (27) typetoken ::= typename LP signed RP */ |
| 160731 | 211, /* (28) scanpt ::= */ | 162178 | 207, /* (28) typetoken ::= typename LP signed COMMA signed RP */ |
| 160732 | 212, /* (29) scantok ::= */ | 162179 | 208, /* (29) typename ::= typename ID|STRING */ |
| 160733 | 213, /* (30) ccons ::= CONSTRAINT nm */ | 162180 | 212, /* (30) scanpt ::= */ |
| 160734 | 213, /* (31) ccons ::= DEFAULT scantok term */ | 162181 | 213, /* (31) scantok ::= */ |
| 160735 | 213, /* (32) ccons ::= DEFAULT LP expr RP */ | 162182 | 214, /* (32) ccons ::= CONSTRAINT nm */ |
| 160736 | 213, /* (33) ccons ::= DEFAULT PLUS scantok term */ | 162183 | 214, /* (33) ccons ::= DEFAULT scantok term */ |
| 160737 | 213, /* (34) ccons ::= DEFAULT MINUS scantok term */ | 162184 | 214, /* (34) ccons ::= DEFAULT LP expr RP */ |
| 160738 | 213, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ | 162185 | 214, /* (35) ccons ::= DEFAULT PLUS scantok term */ |
| 160739 | 213, /* (36) ccons ::= NOT NULL onconf */ | 162186 | 214, /* (36) ccons ::= DEFAULT MINUS scantok term */ |
| 160740 | 213, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ | 162187 | 214, /* (37) ccons ::= DEFAULT scantok ID|INDEXED */ |
| 160741 | 213, /* (38) ccons ::= UNIQUE onconf */ | 162188 | 214, /* (38) ccons ::= NOT NULL onconf */ |
| 160742 | 213, /* (39) ccons ::= CHECK LP expr RP */ | 162189 | 214, /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 160743 | 213, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ | 162190 | 214, /* (40) ccons ::= UNIQUE onconf */ |
| 160744 | 213, /* (41) ccons ::= defer_subclause */ | 162191 | 214, /* (41) ccons ::= CHECK LP expr RP */ |
| 160745 | 213, /* (42) ccons ::= COLLATE ID|STRING */ | 162192 | 214, /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 160746 | 222, /* (43) generated ::= LP expr RP */ | 162193 | 214, /* (43) ccons ::= defer_subclause */ |
| 160747 | 222, /* (44) generated ::= LP expr RP ID */ | 162194 | 214, /* (44) ccons ::= COLLATE ID|STRING */ |
| 160748 | 218, /* (45) autoinc ::= */ | 162195 | 223, /* (45) generated ::= LP expr RP */ |
| 160749 | 218, /* (46) autoinc ::= AUTOINCR */ | 162196 | 223, /* (46) generated ::= LP expr RP ID */ |
| 160750 | 220, /* (47) refargs ::= */ | 162197 | 219, /* (47) autoinc ::= */ |
| 160751 | 220, /* (48) refargs ::= refargs refarg */ | 162198 | 219, /* (48) autoinc ::= AUTOINCR */ |
| 160752 | 223, /* (49) refarg ::= MATCH nm */ | 162199 | 221, /* (49) refargs ::= */ |
| 160753 | 223, /* (50) refarg ::= ON INSERT refact */ | 162200 | 221, /* (50) refargs ::= refargs refarg */ |
| 160754 | 223, /* (51) refarg ::= ON DELETE refact */ | 162201 | 224, /* (51) refarg ::= MATCH nm */ |
| 160755 | 223, /* (52) refarg ::= ON UPDATE refact */ | 162202 | 224, /* (52) refarg ::= ON INSERT refact */ |
| 160756 | 224, /* (53) refact ::= SET NULL */ | 162203 | 224, /* (53) refarg ::= ON DELETE refact */ |
| 160757 | 224, /* (54) refact ::= SET DEFAULT */ | 162204 | 224, /* (54) refarg ::= ON UPDATE refact */ |
| 160758 | 224, /* (55) refact ::= CASCADE */ | 162205 | 225, /* (55) refact ::= SET NULL */ |
| 160759 | 224, /* (56) refact ::= RESTRICT */ | 162206 | 225, /* (56) refact ::= SET DEFAULT */ |
| 160760 | 224, /* (57) refact ::= NO ACTION */ | 162207 | 225, /* (57) refact ::= CASCADE */ |
| 160761 | 221, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ | 162208 | 225, /* (58) refact ::= RESTRICT */ |
| 160762 | 221, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ | 162209 | 225, /* (59) refact ::= NO ACTION */ |
| 160763 | 225, /* (60) init_deferred_pred_opt ::= */ | 162210 | 222, /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 160764 | 225, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ | 162211 | 222, /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 160765 | 225, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ | 162212 | 226, /* (62) init_deferred_pred_opt ::= */ |
| 160766 | 201, /* (63) conslist_opt ::= */ | 162213 | 226, /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 160767 | 227, /* (64) tconscomma ::= COMMA */ | 162214 | 226, /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 160768 | 228, /* (65) tcons ::= CONSTRAINT nm */ | 162215 | 201, /* (65) conslist_opt ::= */ |
| 160769 | 228, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ | 162216 | 228, /* (66) tconscomma ::= COMMA */ |
| 160770 | 228, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ | 162217 | 229, /* (67) tcons ::= CONSTRAINT nm */ |
| 160771 | 228, /* (68) tcons ::= CHECK LP expr RP onconf */ | 162218 | 229, /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 160772 | 228, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ | 162219 | 229, /* (69) tcons ::= UNIQUE LP sortlist RP onconf */ |
| 160773 | 231, /* (70) defer_subclause_opt ::= */ | 162220 | 229, /* (70) tcons ::= CHECK LP expr RP onconf */ |
| 160774 | 216, /* (71) onconf ::= */ | 162221 | 229, /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 160775 | 216, /* (72) onconf ::= ON CONFLICT resolvetype */ | 162222 | 232, /* (72) defer_subclause_opt ::= */ |
| 160776 | 232, /* (73) orconf ::= */ | 162223 | 217, /* (73) onconf ::= */ |
| 160777 | 232, /* (74) orconf ::= OR resolvetype */ | 162224 | 217, /* (74) onconf ::= ON CONFLICT resolvetype */ |
| 160778 | 233, /* (75) resolvetype ::= IGNORE */ | 162225 | 233, /* (75) orconf ::= */ |
| 160779 | 233, /* (76) resolvetype ::= REPLACE */ | 162226 | 233, /* (76) orconf ::= OR resolvetype */ |
| 160780 | 189, /* (77) cmd ::= DROP TABLE ifexists fullname */ | 162227 | 234, /* (77) resolvetype ::= IGNORE */ |
| 160781 | 235, /* (78) ifexists ::= IF EXISTS */ | 162228 | 234, /* (78) resolvetype ::= REPLACE */ |
| 160782 | 235, /* (79) ifexists ::= */ | 162229 | 189, /* (79) cmd ::= DROP TABLE ifexists fullname */ |
| 160783 | 189, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ | 162230 | 236, /* (80) ifexists ::= IF EXISTS */ |
| 160784 | 189, /* (81) cmd ::= DROP VIEW ifexists fullname */ | 162231 | 236, /* (81) ifexists ::= */ |
| 160785 | 189, /* (82) cmd ::= select */ | 162232 | 189, /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 160786 | 203, /* (83) select ::= WITH wqlist selectnowith */ | 162233 | 189, /* (83) cmd ::= DROP VIEW ifexists fullname */ |
| 160787 | 203, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ | 162234 | 189, /* (84) cmd ::= select */ |
| 160788 | 203, /* (85) select ::= selectnowith */ | 162235 | 203, /* (85) select ::= WITH wqlist selectnowith */ |
| 160789 | 237, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ | 162236 | 203, /* (86) select ::= WITH RECURSIVE wqlist selectnowith */ |
| 160790 | 240, /* (87) multiselect_op ::= UNION */ | 162237 | 203, /* (87) select ::= selectnowith */ |
| 160791 | 240, /* (88) multiselect_op ::= UNION ALL */ | 162238 | 238, /* (88) selectnowith ::= selectnowith multiselect_op oneselect */ |
| 160792 | 240, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ | 162239 | 241, /* (89) multiselect_op ::= UNION */ |
| 160793 | 238, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ | 162240 | 241, /* (90) multiselect_op ::= UNION ALL */ |
| 160794 | 238, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ | 162241 | 241, /* (91) multiselect_op ::= EXCEPT|INTERSECT */ |
| 160795 | 250, /* (92) values ::= VALUES LP nexprlist RP */ | 162242 | 239, /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 160796 | 250, /* (93) values ::= values COMMA LP nexprlist RP */ | 162243 | 239, /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 160797 | 241, /* (94) distinct ::= DISTINCT */ | 162244 | 251, /* (94) values ::= VALUES LP nexprlist RP */ |
| 160798 | 241, /* (95) distinct ::= ALL */ | 162245 | 251, /* (95) values ::= values COMMA LP nexprlist RP */ |
| 160799 | 241, /* (96) distinct ::= */ | 162246 | 242, /* (96) distinct ::= DISTINCT */ |
| 160800 | 252, /* (97) sclp ::= */ | 162247 | 242, /* (97) distinct ::= ALL */ |
| 160801 | 242, /* (98) selcollist ::= sclp scanpt expr scanpt as */ | 162248 | 242, /* (98) distinct ::= */ |
| 160802 | 242, /* (99) selcollist ::= sclp scanpt STAR */ | 162249 | 253, /* (99) sclp ::= */ |
| 160803 | 242, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ | 162250 | 243, /* (100) selcollist ::= sclp scanpt expr scanpt as */ |
| 160804 | 253, /* (101) as ::= AS nm */ | 162251 | 243, /* (101) selcollist ::= sclp scanpt STAR */ |
| 160805 | 253, /* (102) as ::= */ | 162252 | 243, /* (102) selcollist ::= sclp scanpt nm DOT STAR */ |
| 160806 | 243, /* (103) from ::= */ | 162253 | 254, /* (103) as ::= AS nm */ |
| 160807 | 243, /* (104) from ::= FROM seltablist */ | 162254 | 254, /* (104) as ::= */ |
| 160808 | 255, /* (105) stl_prefix ::= seltablist joinop */ | 162255 | 244, /* (105) from ::= */ |
| 160809 | 255, /* (106) stl_prefix ::= */ | 162256 | 244, /* (106) from ::= FROM seltablist */ |
| 160810 | 254, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ | 162257 | 256, /* (107) stl_prefix ::= seltablist joinop */ |
| 160811 | 254, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ | 162258 | 256, /* (108) stl_prefix ::= */ |
| 160812 | 254, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ | 162259 | 255, /* (109) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 160813 | 254, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ | 162260 | 255, /* (110) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 160814 | 199, /* (111) dbnm ::= */ | 162261 | 255, /* (111) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 160815 | 199, /* (112) dbnm ::= DOT nm */ | 162262 | 255, /* (112) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 160816 | 236, /* (113) fullname ::= nm */ | 162263 | 199, /* (113) dbnm ::= */ |
| 160817 | 236, /* (114) fullname ::= nm DOT nm */ | 162264 | 199, /* (114) dbnm ::= DOT nm */ |
| 160818 | 261, /* (115) xfullname ::= nm */ | 162265 | 237, /* (115) fullname ::= nm */ |
| 160819 | 261, /* (116) xfullname ::= nm DOT nm */ | 162266 | 237, /* (116) fullname ::= nm DOT nm */ |
| 160820 | 261, /* (117) xfullname ::= nm DOT nm AS nm */ | 162267 | 262, /* (117) xfullname ::= nm */ |
| 160821 | 261, /* (118) xfullname ::= nm AS nm */ | 162268 | 262, /* (118) xfullname ::= nm DOT nm */ |
| 160822 | 256, /* (119) joinop ::= COMMA|JOIN */ | 162269 | 262, /* (119) xfullname ::= nm DOT nm AS nm */ |
| 160823 | 256, /* (120) joinop ::= JOIN_KW JOIN */ | 162270 | 262, /* (120) xfullname ::= nm AS nm */ |
| 160824 | 256, /* (121) joinop ::= JOIN_KW nm JOIN */ | 162271 | 257, /* (121) joinop ::= COMMA|JOIN */ |
| 160825 | 256, /* (122) joinop ::= JOIN_KW nm nm JOIN */ | 162272 | 257, /* (122) joinop ::= JOIN_KW JOIN */ |
| 160826 | 258, /* (123) on_opt ::= ON expr */ | 162273 | 257, /* (123) joinop ::= JOIN_KW nm JOIN */ |
| 160827 | 258, /* (124) on_opt ::= */ | 162274 | 257, /* (124) joinop ::= JOIN_KW nm nm JOIN */ |
| 160828 | 257, /* (125) indexed_opt ::= */ | 162275 | 259, /* (125) on_opt ::= ON expr */ |
| 160829 | 257, /* (126) indexed_opt ::= INDEXED BY nm */ | 162276 | 259, /* (126) on_opt ::= */ |
| 160830 | 257, /* (127) indexed_opt ::= NOT INDEXED */ | 162277 | 258, /* (127) indexed_opt ::= */ |
| 160831 | 259, /* (128) using_opt ::= USING LP idlist RP */ | 162278 | 258, /* (128) indexed_opt ::= INDEXED BY nm */ |
| 160832 | 259, /* (129) using_opt ::= */ | 162279 | 258, /* (129) indexed_opt ::= NOT INDEXED */ |
| 160833 | 247, /* (130) orderby_opt ::= */ | 162280 | 260, /* (130) using_opt ::= USING LP idlist RP */ |
| 160834 | 247, /* (131) orderby_opt ::= ORDER BY sortlist */ | 162281 | 260, /* (131) using_opt ::= */ |
| 160835 | 229, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ | 162282 | 248, /* (132) orderby_opt ::= */ |
| 160836 | 229, /* (133) sortlist ::= expr sortorder nulls */ | 162283 | 248, /* (133) orderby_opt ::= ORDER BY sortlist */ |
| 160837 | 217, /* (134) sortorder ::= ASC */ | 162284 | 230, /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 160838 | 217, /* (135) sortorder ::= DESC */ | 162285 | 230, /* (135) sortlist ::= expr sortorder nulls */ |
| 160839 | 217, /* (136) sortorder ::= */ | 162286 | 218, /* (136) sortorder ::= ASC */ |
| 160840 | 263, /* (137) nulls ::= NULLS FIRST */ | 162287 | 218, /* (137) sortorder ::= DESC */ |
| 160841 | 263, /* (138) nulls ::= NULLS LAST */ | 162288 | 218, /* (138) sortorder ::= */ |
| 160842 | 263, /* (139) nulls ::= */ | 162289 | 264, /* (139) nulls ::= NULLS FIRST */ |
| 160843 | 245, /* (140) groupby_opt ::= */ | 162290 | 264, /* (140) nulls ::= NULLS LAST */ |
| 160844 | 245, /* (141) groupby_opt ::= GROUP BY nexprlist */ | 162291 | 264, /* (141) nulls ::= */ |
| 160845 | 246, /* (142) having_opt ::= */ | 162292 | 246, /* (142) groupby_opt ::= */ |
| 160846 | 246, /* (143) having_opt ::= HAVING expr */ | 162293 | 246, /* (143) groupby_opt ::= GROUP BY nexprlist */ |
| 160847 | 248, /* (144) limit_opt ::= */ | 162294 | 247, /* (144) having_opt ::= */ |
| 160848 | 248, /* (145) limit_opt ::= LIMIT expr */ | 162295 | 247, /* (145) having_opt ::= HAVING expr */ |
| 160849 | 248, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ | 162296 | 249, /* (146) limit_opt ::= */ |
| 160850 | 248, /* (147) limit_opt ::= LIMIT expr COMMA expr */ | 162297 | 249, /* (147) limit_opt ::= LIMIT expr */ |
| 160851 | 189, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ | 162298 | 249, /* (148) limit_opt ::= LIMIT expr OFFSET expr */ |
| 160852 | 244, /* (149) where_opt ::= */ | 162299 | 249, /* (149) limit_opt ::= LIMIT expr COMMA expr */ |
| 160853 | 244, /* (150) where_opt ::= WHERE expr */ | 162300 | 189, /* (150) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 160854 | 265, /* (151) where_opt_ret ::= */ | 162301 | 245, /* (151) where_opt ::= */ |
| 160855 | 265, /* (152) where_opt_ret ::= WHERE expr */ | 162302 | 245, /* (152) where_opt ::= WHERE expr */ |
| 160856 | 265, /* (153) where_opt_ret ::= RETURNING selcollist */ | 162303 | 266, /* (153) where_opt_ret ::= */ |
| 160857 | 265, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */ | 162304 | 266, /* (154) where_opt_ret ::= WHERE expr */ |
| 160858 | 189, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ | 162305 | 266, /* (155) where_opt_ret ::= RETURNING selcollist */ |
| 160859 | 266, /* (156) setlist ::= setlist COMMA nm EQ expr */ | 162306 | 266, /* (156) where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 160860 | 266, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */ | 162307 | 189, /* (157) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 160861 | 266, /* (158) setlist ::= nm EQ expr */ | 162308 | 267, /* (158) setlist ::= setlist COMMA nm EQ expr */ |
| 160862 | 266, /* (159) setlist ::= LP idlist RP EQ expr */ | 162309 | 267, /* (159) setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 160863 | 189, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ | 162310 | 267, /* (160) setlist ::= nm EQ expr */ |
| 160864 | 189, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ | 162311 | 267, /* (161) setlist ::= LP idlist RP EQ expr */ |
| 160865 | 269, /* (162) upsert ::= */ | 162312 | 189, /* (162) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 160866 | 269, /* (163) upsert ::= RETURNING selcollist */ | 162313 | 189, /* (163) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 160867 | 269, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ | 162314 | 270, /* (164) upsert ::= */ |
| 160868 | 269, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ | 162315 | 270, /* (165) upsert ::= RETURNING selcollist */ |
| 160869 | 269, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */ | 162316 | 270, /* (166) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 160870 | 269, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ | 162317 | 270, /* (167) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 160871 | 270, /* (168) returning ::= RETURNING selcollist */ | 162318 | 270, /* (168) upsert ::= ON CONFLICT DO NOTHING returning */ |
| 160872 | 267, /* (169) insert_cmd ::= INSERT orconf */ | 162319 | 270, /* (169) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 160873 | 267, /* (170) insert_cmd ::= REPLACE */ | 162320 | 271, /* (170) returning ::= RETURNING selcollist */ |
| 160874 | 268, /* (171) idlist_opt ::= */ | 162321 | 268, /* (171) insert_cmd ::= INSERT orconf */ |
| 160875 | 268, /* (172) idlist_opt ::= LP idlist RP */ | 162322 | 268, /* (172) insert_cmd ::= REPLACE */ |
| 160876 | 262, /* (173) idlist ::= idlist COMMA nm */ | 162323 | 269, /* (173) idlist_opt ::= */ |
| 160877 | 262, /* (174) idlist ::= nm */ | 162324 | 269, /* (174) idlist_opt ::= LP idlist RP */ |
| 160878 | 215, /* (175) expr ::= LP expr RP */ | 162325 | 263, /* (175) idlist ::= idlist COMMA nm */ |
| 160879 | 215, /* (176) expr ::= ID|INDEXED */ | 162326 | 263, /* (176) idlist ::= nm */ |
| 160880 | 215, /* (177) expr ::= JOIN_KW */ | 162327 | 216, /* (177) expr ::= LP expr RP */ |
| 160881 | 215, /* (178) expr ::= nm DOT nm */ | 162328 | 216, /* (178) expr ::= ID|INDEXED */ |
| 160882 | 215, /* (179) expr ::= nm DOT nm DOT nm */ | 162329 | 216, /* (179) expr ::= JOIN_KW */ |
| 160883 | 214, /* (180) term ::= NULL|FLOAT|BLOB */ | 162330 | 216, /* (180) expr ::= nm DOT nm */ |
| 160884 | 214, /* (181) term ::= STRING */ | 162331 | 216, /* (181) expr ::= nm DOT nm DOT nm */ |
| 160885 | 214, /* (182) term ::= INTEGER */ | 162332 | 215, /* (182) term ::= NULL|FLOAT|BLOB */ |
| 160886 | 215, /* (183) expr ::= VARIABLE */ | 162333 | 215, /* (183) term ::= STRING */ |
| 160887 | 215, /* (184) expr ::= expr COLLATE ID|STRING */ | 162334 | 215, /* (184) term ::= INTEGER */ |
| 160888 | 215, /* (185) expr ::= CAST LP expr AS typetoken RP */ | 162335 | 216, /* (185) expr ::= VARIABLE */ |
| 160889 | 215, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */ | 162336 | 216, /* (186) expr ::= expr COLLATE ID|STRING */ |
| 160890 | 215, /* (187) expr ::= ID|INDEXED LP STAR RP */ | 162337 | 216, /* (187) expr ::= CAST LP expr AS typetoken RP */ |
| 160891 | 215, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ | 162338 | 216, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 160892 | 215, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */ | 162339 | 216, /* (189) expr ::= ID|INDEXED LP STAR RP */ |
| 160893 | 214, /* (190) term ::= CTIME_KW */ | 162340 | 216, /* (190) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 160894 | 215, /* (191) expr ::= LP nexprlist COMMA expr RP */ | 162341 | 216, /* (191) expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 160895 | 215, /* (192) expr ::= expr AND expr */ | 162342 | 215, /* (192) term ::= CTIME_KW */ |
| 160896 | 215, /* (193) expr ::= expr OR expr */ | 162343 | 216, /* (193) expr ::= LP nexprlist COMMA expr RP */ |
| 160897 | 215, /* (194) expr ::= expr LT|GT|GE|LE expr */ | 162344 | 216, /* (194) expr ::= expr AND expr */ |
| 160898 | 215, /* (195) expr ::= expr EQ|NE expr */ | 162345 | 216, /* (195) expr ::= expr OR expr */ |
| 160899 | 215, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | 162346 | 216, /* (196) expr ::= expr LT|GT|GE|LE expr */ |
| 160900 | 215, /* (197) expr ::= expr PLUS|MINUS expr */ | 162347 | 216, /* (197) expr ::= expr EQ|NE expr */ |
| 160901 | 215, /* (198) expr ::= expr STAR|SLASH|REM expr */ | 162348 | 216, /* (198) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 160902 | 215, /* (199) expr ::= expr CONCAT expr */ | 162349 | 216, /* (199) expr ::= expr PLUS|MINUS expr */ |
| 160903 | 272, /* (200) likeop ::= NOT LIKE_KW|MATCH */ | 162350 | 216, /* (200) expr ::= expr STAR|SLASH|REM expr */ |
| 160904 | 215, /* (201) expr ::= expr likeop expr */ | 162351 | 216, /* (201) expr ::= expr CONCAT expr */ |
| 160905 | 215, /* (202) expr ::= expr likeop expr ESCAPE expr */ | 162352 | 273, /* (202) likeop ::= NOT LIKE_KW|MATCH */ |
| 160906 | 215, /* (203) expr ::= expr ISNULL|NOTNULL */ | 162353 | 216, /* (203) expr ::= expr likeop expr */ |
| 160907 | 215, /* (204) expr ::= expr NOT NULL */ | 162354 | 216, /* (204) expr ::= expr likeop expr ESCAPE expr */ |
| 160908 | 215, /* (205) expr ::= expr IS expr */ | 162355 | 216, /* (205) expr ::= expr ISNULL|NOTNULL */ |
| 160909 | 215, /* (206) expr ::= expr IS NOT expr */ | 162356 | 216, /* (206) expr ::= expr NOT NULL */ |
| 160910 | 215, /* (207) expr ::= NOT expr */ | 162357 | 216, /* (207) expr ::= expr IS expr */ |
| 160911 | 215, /* (208) expr ::= BITNOT expr */ | 162358 | 216, /* (208) expr ::= expr IS NOT expr */ |
| 160912 | 215, /* (209) expr ::= PLUS|MINUS expr */ | 162359 | 216, /* (209) expr ::= NOT expr */ |
| 160913 | 273, /* (210) between_op ::= BETWEEN */ | 162360 | 216, /* (210) expr ::= BITNOT expr */ |
| 160914 | 273, /* (211) between_op ::= NOT BETWEEN */ | 162361 | 216, /* (211) expr ::= PLUS|MINUS expr */ |
| 160915 | 215, /* (212) expr ::= expr between_op expr AND expr */ | 162362 | 274, /* (212) between_op ::= BETWEEN */ |
| 160916 | 274, /* (213) in_op ::= IN */ | 162363 | 274, /* (213) between_op ::= NOT BETWEEN */ |
| 160917 | 274, /* (214) in_op ::= NOT IN */ | 162364 | 216, /* (214) expr ::= expr between_op expr AND expr */ |
| 160918 | 215, /* (215) expr ::= expr in_op LP exprlist RP */ | 162365 | 275, /* (215) in_op ::= IN */ |
| 160919 | 215, /* (216) expr ::= LP select RP */ | 162366 | 275, /* (216) in_op ::= NOT IN */ |
| 160920 | 215, /* (217) expr ::= expr in_op LP select RP */ | 162367 | 216, /* (217) expr ::= expr in_op LP exprlist RP */ |
| 160921 | 215, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */ | 162368 | 216, /* (218) expr ::= LP select RP */ |
| 160922 | 215, /* (219) expr ::= EXISTS LP select RP */ | 162369 | 216, /* (219) expr ::= expr in_op LP select RP */ |
| 160923 | 215, /* (220) expr ::= CASE case_operand case_exprlist case_else END */ | 162370 | 216, /* (220) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 160924 | 277, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 162371 | 216, /* (221) expr ::= EXISTS LP select RP */ |
| 160925 | 277, /* (222) case_exprlist ::= WHEN expr THEN expr */ | 162372 | 216, /* (222) expr ::= CASE case_operand case_exprlist case_else END */ |
| 160926 | 278, /* (223) case_else ::= ELSE expr */ | 162373 | 278, /* (223) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 160927 | 278, /* (224) case_else ::= */ | 162374 | 278, /* (224) case_exprlist ::= WHEN expr THEN expr */ |
| 160928 | 276, /* (225) case_operand ::= expr */ | 162375 | 279, /* (225) case_else ::= ELSE expr */ |
| 160929 | 276, /* (226) case_operand ::= */ | 162376 | 279, /* (226) case_else ::= */ |
| 160930 | 260, /* (227) exprlist ::= */ | 162377 | 277, /* (227) case_operand ::= expr */ |
| 160931 | 251, /* (228) nexprlist ::= nexprlist COMMA expr */ | 162378 | 277, /* (228) case_operand ::= */ |
| 160932 | 251, /* (229) nexprlist ::= expr */ | 162379 | 261, /* (229) exprlist ::= */ |
| 160933 | 275, /* (230) paren_exprlist ::= */ | 162380 | 252, /* (230) nexprlist ::= nexprlist COMMA expr */ |
| 160934 | 275, /* (231) paren_exprlist ::= LP exprlist RP */ | 162381 | 252, /* (231) nexprlist ::= expr */ |
| 160935 | 189, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 162382 | 276, /* (232) paren_exprlist ::= */ |
| 160936 | 279, /* (233) uniqueflag ::= UNIQUE */ | 162383 | 276, /* (233) paren_exprlist ::= LP exprlist RP */ |
| 160937 | 279, /* (234) uniqueflag ::= */ | 162384 | 189, /* (234) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 160938 | 219, /* (235) eidlist_opt ::= */ | 162385 | 280, /* (235) uniqueflag ::= UNIQUE */ |
| 160939 | 219, /* (236) eidlist_opt ::= LP eidlist RP */ | 162386 | 280, /* (236) uniqueflag ::= */ |
| 160940 | 230, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */ | 162387 | 220, /* (237) eidlist_opt ::= */ |
| 160941 | 230, /* (238) eidlist ::= nm collate sortorder */ | 162388 | 220, /* (238) eidlist_opt ::= LP eidlist RP */ |
| 160942 | 280, /* (239) collate ::= */ | 162389 | 231, /* (239) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 160943 | 280, /* (240) collate ::= COLLATE ID|STRING */ | 162390 | 231, /* (240) eidlist ::= nm collate sortorder */ |
| 160944 | 189, /* (241) cmd ::= DROP INDEX ifexists fullname */ | 162391 | 281, /* (241) collate ::= */ |
| 160945 | 189, /* (242) cmd ::= VACUUM vinto */ | 162392 | 281, /* (242) collate ::= COLLATE ID|STRING */ |
| 160946 | 189, /* (243) cmd ::= VACUUM nm vinto */ | 162393 | 189, /* (243) cmd ::= DROP INDEX ifexists fullname */ |
| 160947 | 281, /* (244) vinto ::= INTO expr */ | 162394 | 189, /* (244) cmd ::= VACUUM vinto */ |
| 160948 | 281, /* (245) vinto ::= */ | 162395 | 189, /* (245) cmd ::= VACUUM nm vinto */ |
| 160949 | 189, /* (246) cmd ::= PRAGMA nm dbnm */ | 162396 | 282, /* (246) vinto ::= INTO expr */ |
| 160950 | 189, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */ | 162397 | 282, /* (247) vinto ::= */ |
| 160951 | 189, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 162398 | 189, /* (248) cmd ::= PRAGMA nm dbnm */ |
| 160952 | 189, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */ | 162399 | 189, /* (249) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 160953 | 189, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 162400 | 189, /* (250) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 160954 | 209, /* (251) plus_num ::= PLUS INTEGER|FLOAT */ | 162401 | 189, /* (251) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 160955 | 210, /* (252) minus_num ::= MINUS INTEGER|FLOAT */ | 162402 | 189, /* (252) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 160956 | 189, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 162403 | 210, /* (253) plus_num ::= PLUS INTEGER|FLOAT */ |
| 160957 | 283, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 162404 | 211, /* (254) minus_num ::= MINUS INTEGER|FLOAT */ |
| 160958 | 285, /* (255) trigger_time ::= BEFORE|AFTER */ | 162405 | 189, /* (255) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 160959 | 285, /* (256) trigger_time ::= INSTEAD OF */ | 162406 | 284, /* (256) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 160960 | 285, /* (257) trigger_time ::= */ | 162407 | 286, /* (257) trigger_time ::= BEFORE|AFTER */ |
| 160961 | 286, /* (258) trigger_event ::= DELETE|INSERT */ | 162408 | 286, /* (258) trigger_time ::= INSTEAD OF */ |
| 160962 | 286, /* (259) trigger_event ::= UPDATE */ | 162409 | 286, /* (259) trigger_time ::= */ |
| 160963 | 286, /* (260) trigger_event ::= UPDATE OF idlist */ | 162410 | 287, /* (260) trigger_event ::= DELETE|INSERT */ |
| 160964 | 288, /* (261) when_clause ::= */ | 162411 | 287, /* (261) trigger_event ::= UPDATE */ |
| 160965 | 288, /* (262) when_clause ::= WHEN expr */ | 162412 | 287, /* (262) trigger_event ::= UPDATE OF idlist */ |
| 160966 | 284, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 162413 | 289, /* (263) when_clause ::= */ |
| 160967 | 284, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */ | 162414 | 289, /* (264) when_clause ::= WHEN expr */ |
| 160968 | 290, /* (265) trnm ::= nm DOT nm */ | 162415 | 285, /* (265) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 160969 | 291, /* (266) tridxby ::= INDEXED BY nm */ | 162416 | 285, /* (266) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 160970 | 291, /* (267) tridxby ::= NOT INDEXED */ | 162417 | 291, /* (267) trnm ::= nm DOT nm */ |
| 160971 | 289, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 162418 | 292, /* (268) tridxby ::= INDEXED BY nm */ |
| 160972 | 289, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 162419 | 292, /* (269) tridxby ::= NOT INDEXED */ |
| 160973 | 289, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 162420 | 290, /* (270) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 160974 | 289, /* (271) trigger_cmd ::= scanpt select scanpt */ | 162421 | 290, /* (271) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 160975 | 215, /* (272) expr ::= RAISE LP IGNORE RP */ | 162422 | 290, /* (272) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 160976 | 215, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */ | 162423 | 290, /* (273) trigger_cmd ::= scanpt select scanpt */ |
| 160977 | 234, /* (274) raisetype ::= ROLLBACK */ | 162424 | 216, /* (274) expr ::= RAISE LP IGNORE RP */ |
| 160978 | 234, /* (275) raisetype ::= ABORT */ | 162425 | 216, /* (275) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 160979 | 234, /* (276) raisetype ::= FAIL */ | 162426 | 235, /* (276) raisetype ::= ROLLBACK */ |
| 160980 | 189, /* (277) cmd ::= DROP TRIGGER ifexists fullname */ | 162427 | 235, /* (277) raisetype ::= ABORT */ |
| 160981 | 189, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 162428 | 235, /* (278) raisetype ::= FAIL */ |
| 160982 | 189, /* (279) cmd ::= DETACH database_kw_opt expr */ | 162429 | 189, /* (279) cmd ::= DROP TRIGGER ifexists fullname */ |
| 160983 | 293, /* (280) key_opt ::= */ | 162430 | 189, /* (280) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 160984 | 293, /* (281) key_opt ::= KEY expr */ | 162431 | 189, /* (281) cmd ::= DETACH database_kw_opt expr */ |
| 160985 | 189, /* (282) cmd ::= REINDEX */ | 162432 | 294, /* (282) key_opt ::= */ |
| 160986 | 189, /* (283) cmd ::= REINDEX nm dbnm */ | 162433 | 294, /* (283) key_opt ::= KEY expr */ |
| 160987 | 189, /* (284) cmd ::= ANALYZE */ | 162434 | 189, /* (284) cmd ::= REINDEX */ |
| 160988 | 189, /* (285) cmd ::= ANALYZE nm dbnm */ | 162435 | 189, /* (285) cmd ::= REINDEX nm dbnm */ |
| 160989 | 189, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */ | 162436 | 189, /* (286) cmd ::= ANALYZE */ |
| 160990 | 189, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 162437 | 189, /* (287) cmd ::= ANALYZE nm dbnm */ |
| 160991 | 189, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | 162438 | 189, /* (288) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 160992 | 294, /* (289) add_column_fullname ::= fullname */ | 162439 | 189, /* (289) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 160993 | 189, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 162440 | 189, /* (290) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 160994 | 189, /* (291) cmd ::= create_vtab */ | 162441 | 295, /* (291) add_column_fullname ::= fullname */ |
| 160995 | 189, /* (292) cmd ::= create_vtab LP vtabarglist RP */ | 162442 | 189, /* (292) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 160996 | 296, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 162443 | 189, /* (293) cmd ::= create_vtab */ |
| 160997 | 298, /* (294) vtabarg ::= */ | 162444 | 189, /* (294) cmd ::= create_vtab LP vtabarglist RP */ |
| 160998 | 299, /* (295) vtabargtoken ::= ANY */ | 162445 | 297, /* (295) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 160999 | 299, /* (296) vtabargtoken ::= lp anylist RP */ | 162446 | 299, /* (296) vtabarg ::= */ |
| 161000 | 300, /* (297) lp ::= LP */ | 162447 | 300, /* (297) vtabargtoken ::= ANY */ |
| 161001 | 264, /* (298) with ::= WITH wqlist */ | 162448 | 300, /* (298) vtabargtoken ::= lp anylist RP */ |
| 161002 | 264, /* (299) with ::= WITH RECURSIVE wqlist */ | 162449 | 301, /* (299) lp ::= LP */ |
| 161003 | 303, /* (300) wqas ::= AS */ | 162450 | 265, /* (300) with ::= WITH wqlist */ |
| 161004 | 303, /* (301) wqas ::= AS MATERIALIZED */ | 162451 | 265, /* (301) with ::= WITH RECURSIVE wqlist */ |
| 161005 | 303, /* (302) wqas ::= AS NOT MATERIALIZED */ | 162452 | 304, /* (302) wqas ::= AS */ |
| 161006 | 302, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */ | 162453 | 304, /* (303) wqas ::= AS MATERIALIZED */ |
| 161007 | 239, /* (304) wqlist ::= wqitem */ | 162454 | 304, /* (304) wqas ::= AS NOT MATERIALIZED */ |
| 161008 | 239, /* (305) wqlist ::= wqlist COMMA wqitem */ | 162455 | 303, /* (305) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 161009 | 304, /* (306) windowdefn_list ::= windowdefn */ | 162456 | 240, /* (306) wqlist ::= wqitem */ |
| 161010 | 304, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 162457 | 240, /* (307) wqlist ::= wqlist COMMA wqitem */ |
| 161011 | 305, /* (308) windowdefn ::= nm AS LP window RP */ | 162458 | 305, /* (308) windowdefn_list ::= windowdefn */ |
| 161012 | 306, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 162459 | 305, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 161013 | 306, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 162460 | 306, /* (310) windowdefn ::= nm AS LP window RP */ |
| 161014 | 306, /* (311) window ::= ORDER BY sortlist frame_opt */ | 162461 | 307, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 161015 | 306, /* (312) window ::= nm ORDER BY sortlist frame_opt */ | 162462 | 307, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 161016 | 306, /* (313) window ::= frame_opt */ | 162463 | 307, /* (313) window ::= ORDER BY sortlist frame_opt */ |
| 161017 | 306, /* (314) window ::= nm frame_opt */ | 162464 | 307, /* (314) window ::= nm ORDER BY sortlist frame_opt */ |
| 161018 | 307, /* (315) frame_opt ::= */ | 162465 | 307, /* (315) window ::= frame_opt */ |
| 161019 | 307, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 162466 | 307, /* (316) window ::= nm frame_opt */ |
| 161020 | 307, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 162467 | 308, /* (317) frame_opt ::= */ |
| 161021 | 311, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */ | 162468 | 308, /* (318) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 161022 | 313, /* (319) frame_bound_s ::= frame_bound */ | 162469 | 308, /* (319) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 161023 | 313, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */ | 162470 | 312, /* (320) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 161024 | 314, /* (321) frame_bound_e ::= frame_bound */ | 162471 | 314, /* (321) frame_bound_s ::= frame_bound */ |
| 161025 | 314, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */ | 162472 | 314, /* (322) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 161026 | 312, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */ | 162473 | 315, /* (323) frame_bound_e ::= frame_bound */ |
| 161027 | 312, /* (324) frame_bound ::= CURRENT ROW */ | 162474 | 315, /* (324) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 161028 | 315, /* (325) frame_exclude_opt ::= */ | 162475 | 313, /* (325) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 161029 | 315, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */ | 162476 | 313, /* (326) frame_bound ::= CURRENT ROW */ |
| 161030 | 316, /* (327) frame_exclude ::= NO OTHERS */ | 162477 | 316, /* (327) frame_exclude_opt ::= */ |
| 161031 | 316, /* (328) frame_exclude ::= CURRENT ROW */ | 162478 | 316, /* (328) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 161032 | 316, /* (329) frame_exclude ::= GROUP|TIES */ | 162479 | 317, /* (329) frame_exclude ::= NO OTHERS */ |
| 161033 | 249, /* (330) window_clause ::= WINDOW windowdefn_list */ | 162480 | 317, /* (330) frame_exclude ::= CURRENT ROW */ |
| 161034 | 271, /* (331) filter_over ::= filter_clause over_clause */ | 162481 | 317, /* (331) frame_exclude ::= GROUP|TIES */ |
| 161035 | 271, /* (332) filter_over ::= over_clause */ | 162482 | 250, /* (332) window_clause ::= WINDOW windowdefn_list */ |
| 161036 | 271, /* (333) filter_over ::= filter_clause */ | 162483 | 272, /* (333) filter_over ::= filter_clause over_clause */ |
| 161037 | 310, /* (334) over_clause ::= OVER LP window RP */ | 162484 | 272, /* (334) filter_over ::= over_clause */ |
| 161038 | 310, /* (335) over_clause ::= OVER nm */ | 162485 | 272, /* (335) filter_over ::= filter_clause */ |
| 161039 | 309, /* (336) filter_clause ::= FILTER LP WHERE expr RP */ | 162486 | 311, /* (336) over_clause ::= OVER LP window RP */ |
| 161040 | 184, /* (337) input ::= cmdlist */ | 162487 | 311, /* (337) over_clause ::= OVER nm */ |
| 161041 | 185, /* (338) cmdlist ::= cmdlist ecmd */ | 162488 | 310, /* (338) filter_clause ::= FILTER LP WHERE expr RP */ |
| 161042 | 185, /* (339) cmdlist ::= ecmd */ | 162489 | 184, /* (339) input ::= cmdlist */ |
| 161043 | 186, /* (340) ecmd ::= SEMI */ | 162490 | 185, /* (340) cmdlist ::= cmdlist ecmd */ |
| 161044 | 186, /* (341) ecmd ::= cmdx SEMI */ | 162491 | 185, /* (341) cmdlist ::= ecmd */ |
| 161045 | 186, /* (342) ecmd ::= explain cmdx SEMI */ | 162492 | 186, /* (342) ecmd ::= SEMI */ |
| 161046 | 191, /* (343) trans_opt ::= */ | 162493 | 186, /* (343) ecmd ::= cmdx SEMI */ |
| 161047 | 191, /* (344) trans_opt ::= TRANSACTION */ | 162494 | 186, /* (344) ecmd ::= explain cmdx SEMI */ |
| 161048 | 191, /* (345) trans_opt ::= TRANSACTION nm */ | 162495 | 191, /* (345) trans_opt ::= */ |
| 161049 | 193, /* (346) savepoint_opt ::= SAVEPOINT */ | 162496 | 191, /* (346) trans_opt ::= TRANSACTION */ |
| 161050 | 193, /* (347) savepoint_opt ::= */ | 162497 | 191, /* (347) trans_opt ::= TRANSACTION nm */ |
| 161051 | 189, /* (348) cmd ::= create_table create_table_args */ | 162498 | 193, /* (348) savepoint_opt ::= SAVEPOINT */ |
| 161052 | 200, /* (349) columnlist ::= columnlist COMMA columnname carglist */ | 162499 | 193, /* (349) savepoint_opt ::= */ |
| 161053 | 200, /* (350) columnlist ::= columnname carglist */ | 162500 | 189, /* (350) cmd ::= create_table create_table_args */ |
| 161054 | 192, /* (351) nm ::= ID|INDEXED */ | 162501 | 202, /* (351) table_option_set ::= table_option */ |
| 161055 | 192, /* (352) nm ::= STRING */ | 162502 | 200, /* (352) columnlist ::= columnlist COMMA columnname carglist */ |
| 161056 | 192, /* (353) nm ::= JOIN_KW */ | 162503 | 200, /* (353) columnlist ::= columnname carglist */ |
| 161057 | 206, /* (354) typetoken ::= typename */ | 162504 | 192, /* (354) nm ::= ID|INDEXED */ |
| 161058 | 207, /* (355) typename ::= ID|STRING */ | 162505 | 192, /* (355) nm ::= STRING */ |
| 161059 | 208, /* (356) signed ::= plus_num */ | 162506 | 192, /* (356) nm ::= JOIN_KW */ |
| 161060 | 208, /* (357) signed ::= minus_num */ | 162507 | 207, /* (357) typetoken ::= typename */ |
| 161061 | 205, /* (358) carglist ::= carglist ccons */ | 162508 | 208, /* (358) typename ::= ID|STRING */ |
| 161062 | 205, /* (359) carglist ::= */ | 162509 | 209, /* (359) signed ::= plus_num */ |
| 161063 | 213, /* (360) ccons ::= NULL onconf */ | 162510 | 209, /* (360) signed ::= minus_num */ |
| 161064 | 213, /* (361) ccons ::= GENERATED ALWAYS AS generated */ | 162511 | 206, /* (361) carglist ::= carglist ccons */ |
| 161065 | 213, /* (362) ccons ::= AS generated */ | 162512 | 206, /* (362) carglist ::= */ |
| 161066 | 201, /* (363) conslist_opt ::= COMMA conslist */ | 162513 | 214, /* (363) ccons ::= NULL onconf */ |
| 161067 | 226, /* (364) conslist ::= conslist tconscomma tcons */ | 162514 | 214, /* (364) ccons ::= GENERATED ALWAYS AS generated */ |
| 161068 | 226, /* (365) conslist ::= tcons */ | 162515 | 214, /* (365) ccons ::= AS generated */ |
| 161069 | 227, /* (366) tconscomma ::= */ | 162516 | 201, /* (366) conslist_opt ::= COMMA conslist */ |
| 161070 | 231, /* (367) defer_subclause_opt ::= defer_subclause */ | 162517 | 227, /* (367) conslist ::= conslist tconscomma tcons */ |
| 161071 | 233, /* (368) resolvetype ::= raisetype */ | 162518 | 227, /* (368) conslist ::= tcons */ |
| 161072 | 237, /* (369) selectnowith ::= oneselect */ | 162519 | 228, /* (369) tconscomma ::= */ |
| 161073 | 238, /* (370) oneselect ::= values */ | 162520 | 232, /* (370) defer_subclause_opt ::= defer_subclause */ |
| 161074 | 252, /* (371) sclp ::= selcollist COMMA */ | 162521 | 234, /* (371) resolvetype ::= raisetype */ |
| 161075 | 253, /* (372) as ::= ID|STRING */ | 162522 | 238, /* (372) selectnowith ::= oneselect */ |
| 161076 | 270, /* (373) returning ::= */ | 162523 | 239, /* (373) oneselect ::= values */ |
| 161077 | 215, /* (374) expr ::= term */ | 162524 | 253, /* (374) sclp ::= selcollist COMMA */ |
| 161078 | 272, /* (375) likeop ::= LIKE_KW|MATCH */ | 162525 | 254, /* (375) as ::= ID|STRING */ |
| 161079 | 260, /* (376) exprlist ::= nexprlist */ | 162526 | 271, /* (376) returning ::= */ |
| 161080 | 282, /* (377) nmnum ::= plus_num */ | 162527 | 216, /* (377) expr ::= term */ |
| 161081 | 282, /* (378) nmnum ::= nm */ | 162528 | 273, /* (378) likeop ::= LIKE_KW|MATCH */ |
| 161082 | 282, /* (379) nmnum ::= ON */ | 162529 | 261, /* (379) exprlist ::= nexprlist */ |
| 161083 | 282, /* (380) nmnum ::= DELETE */ | 162530 | 283, /* (380) nmnum ::= plus_num */ |
| 161084 | 282, /* (381) nmnum ::= DEFAULT */ | 162531 | 283, /* (381) nmnum ::= nm */ |
| 161085 | 209, /* (382) plus_num ::= INTEGER|FLOAT */ | 162532 | 283, /* (382) nmnum ::= ON */ |
| 161086 | 287, /* (383) foreach_clause ::= */ | 162533 | 283, /* (383) nmnum ::= DELETE */ |
| 161087 | 287, /* (384) foreach_clause ::= FOR EACH ROW */ | 162534 | 283, /* (384) nmnum ::= DEFAULT */ |
| 161088 | 290, /* (385) trnm ::= nm */ | 162535 | 210, /* (385) plus_num ::= INTEGER|FLOAT */ |
| 161089 | 291, /* (386) tridxby ::= */ | 162536 | 288, /* (386) foreach_clause ::= */ |
| 161090 | 292, /* (387) database_kw_opt ::= DATABASE */ | 162537 | 288, /* (387) foreach_clause ::= FOR EACH ROW */ |
| 161091 | 292, /* (388) database_kw_opt ::= */ | 162538 | 291, /* (388) trnm ::= nm */ |
| 161092 | 295, /* (389) kwcolumn_opt ::= */ | 162539 | 292, /* (389) tridxby ::= */ |
| 161093 | 295, /* (390) kwcolumn_opt ::= COLUMNKW */ | 162540 | 293, /* (390) database_kw_opt ::= DATABASE */ |
| 161094 | 297, /* (391) vtabarglist ::= vtabarg */ | 162541 | 293, /* (391) database_kw_opt ::= */ |
| 161095 | 297, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ | 162542 | 296, /* (392) kwcolumn_opt ::= */ |
| 161096 | 298, /* (393) vtabarg ::= vtabarg vtabargtoken */ | 162543 | 296, /* (393) kwcolumn_opt ::= COLUMNKW */ |
| 161097 | 301, /* (394) anylist ::= */ | 162544 | 298, /* (394) vtabarglist ::= vtabarg */ |
| 161098 | 301, /* (395) anylist ::= anylist LP anylist RP */ | 162545 | 298, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 161099 | 301, /* (396) anylist ::= anylist ANY */ | 162546 | 299, /* (396) vtabarg ::= vtabarg vtabargtoken */ |
| 161100 | 264, /* (397) with ::= */ | 162547 | 302, /* (397) anylist ::= */ |
| 162548 | 302, /* (398) anylist ::= anylist LP anylist RP */ | ||
| 162549 | 302, /* (399) anylist ::= anylist ANY */ | ||
| 162550 | 265, /* (400) with ::= */ | ||
| 161101 | }; | 162551 | }; |
| 161102 | 162552 | ||
| 161103 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number | 162553 | /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number |
| @@ -161122,385 +162572,388 @@ static const signed char yyRuleInfoNRhs[] = { | |||
| 161122 | -3, /* (16) ifnotexists ::= IF NOT EXISTS */ | 162572 | -3, /* (16) ifnotexists ::= IF NOT EXISTS */ |
| 161123 | -1, /* (17) temp ::= TEMP */ | 162573 | -1, /* (17) temp ::= TEMP */ |
| 161124 | 0, /* (18) temp ::= */ | 162574 | 0, /* (18) temp ::= */ |
| 161125 | -5, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */ | 162575 | -5, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */ |
| 161126 | -2, /* (20) create_table_args ::= AS select */ | 162576 | -2, /* (20) create_table_args ::= AS select */ |
| 161127 | 0, /* (21) table_options ::= */ | 162577 | 0, /* (21) table_option_set ::= */ |
| 161128 | -2, /* (22) table_options ::= WITHOUT nm */ | 162578 | -3, /* (22) table_option_set ::= table_option_set COMMA table_option */ |
| 161129 | -2, /* (23) columnname ::= nm typetoken */ | 162579 | -2, /* (23) table_option ::= WITHOUT nm */ |
| 161130 | 0, /* (24) typetoken ::= */ | 162580 | -1, /* (24) table_option ::= nm */ |
| 161131 | -4, /* (25) typetoken ::= typename LP signed RP */ | 162581 | -2, /* (25) columnname ::= nm typetoken */ |
| 161132 | -6, /* (26) typetoken ::= typename LP signed COMMA signed RP */ | 162582 | 0, /* (26) typetoken ::= */ |
| 161133 | -2, /* (27) typename ::= typename ID|STRING */ | 162583 | -4, /* (27) typetoken ::= typename LP signed RP */ |
| 161134 | 0, /* (28) scanpt ::= */ | 162584 | -6, /* (28) typetoken ::= typename LP signed COMMA signed RP */ |
| 161135 | 0, /* (29) scantok ::= */ | 162585 | -2, /* (29) typename ::= typename ID|STRING */ |
| 161136 | -2, /* (30) ccons ::= CONSTRAINT nm */ | 162586 | 0, /* (30) scanpt ::= */ |
| 161137 | -3, /* (31) ccons ::= DEFAULT scantok term */ | 162587 | 0, /* (31) scantok ::= */ |
| 161138 | -4, /* (32) ccons ::= DEFAULT LP expr RP */ | 162588 | -2, /* (32) ccons ::= CONSTRAINT nm */ |
| 161139 | -4, /* (33) ccons ::= DEFAULT PLUS scantok term */ | 162589 | -3, /* (33) ccons ::= DEFAULT scantok term */ |
| 161140 | -4, /* (34) ccons ::= DEFAULT MINUS scantok term */ | 162590 | -4, /* (34) ccons ::= DEFAULT LP expr RP */ |
| 161141 | -3, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */ | 162591 | -4, /* (35) ccons ::= DEFAULT PLUS scantok term */ |
| 161142 | -3, /* (36) ccons ::= NOT NULL onconf */ | 162592 | -4, /* (36) ccons ::= DEFAULT MINUS scantok term */ |
| 161143 | -5, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */ | 162593 | -3, /* (37) ccons ::= DEFAULT scantok ID|INDEXED */ |
| 161144 | -2, /* (38) ccons ::= UNIQUE onconf */ | 162594 | -3, /* (38) ccons ::= NOT NULL onconf */ |
| 161145 | -4, /* (39) ccons ::= CHECK LP expr RP */ | 162595 | -5, /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 161146 | -4, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */ | 162596 | -2, /* (40) ccons ::= UNIQUE onconf */ |
| 161147 | -1, /* (41) ccons ::= defer_subclause */ | 162597 | -4, /* (41) ccons ::= CHECK LP expr RP */ |
| 161148 | -2, /* (42) ccons ::= COLLATE ID|STRING */ | 162598 | -4, /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 161149 | -3, /* (43) generated ::= LP expr RP */ | 162599 | -1, /* (43) ccons ::= defer_subclause */ |
| 161150 | -4, /* (44) generated ::= LP expr RP ID */ | 162600 | -2, /* (44) ccons ::= COLLATE ID|STRING */ |
| 161151 | 0, /* (45) autoinc ::= */ | 162601 | -3, /* (45) generated ::= LP expr RP */ |
| 161152 | -1, /* (46) autoinc ::= AUTOINCR */ | 162602 | -4, /* (46) generated ::= LP expr RP ID */ |
| 161153 | 0, /* (47) refargs ::= */ | 162603 | 0, /* (47) autoinc ::= */ |
| 161154 | -2, /* (48) refargs ::= refargs refarg */ | 162604 | -1, /* (48) autoinc ::= AUTOINCR */ |
| 161155 | -2, /* (49) refarg ::= MATCH nm */ | 162605 | 0, /* (49) refargs ::= */ |
| 161156 | -3, /* (50) refarg ::= ON INSERT refact */ | 162606 | -2, /* (50) refargs ::= refargs refarg */ |
| 161157 | -3, /* (51) refarg ::= ON DELETE refact */ | 162607 | -2, /* (51) refarg ::= MATCH nm */ |
| 161158 | -3, /* (52) refarg ::= ON UPDATE refact */ | 162608 | -3, /* (52) refarg ::= ON INSERT refact */ |
| 161159 | -2, /* (53) refact ::= SET NULL */ | 162609 | -3, /* (53) refarg ::= ON DELETE refact */ |
| 161160 | -2, /* (54) refact ::= SET DEFAULT */ | 162610 | -3, /* (54) refarg ::= ON UPDATE refact */ |
| 161161 | -1, /* (55) refact ::= CASCADE */ | 162611 | -2, /* (55) refact ::= SET NULL */ |
| 161162 | -1, /* (56) refact ::= RESTRICT */ | 162612 | -2, /* (56) refact ::= SET DEFAULT */ |
| 161163 | -2, /* (57) refact ::= NO ACTION */ | 162613 | -1, /* (57) refact ::= CASCADE */ |
| 161164 | -3, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ | 162614 | -1, /* (58) refact ::= RESTRICT */ |
| 161165 | -2, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ | 162615 | -2, /* (59) refact ::= NO ACTION */ |
| 161166 | 0, /* (60) init_deferred_pred_opt ::= */ | 162616 | -3, /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 161167 | -2, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */ | 162617 | -2, /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 161168 | -2, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ | 162618 | 0, /* (62) init_deferred_pred_opt ::= */ |
| 161169 | 0, /* (63) conslist_opt ::= */ | 162619 | -2, /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 161170 | -1, /* (64) tconscomma ::= COMMA */ | 162620 | -2, /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 161171 | -2, /* (65) tcons ::= CONSTRAINT nm */ | 162621 | 0, /* (65) conslist_opt ::= */ |
| 161172 | -7, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ | 162622 | -1, /* (66) tconscomma ::= COMMA */ |
| 161173 | -5, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */ | 162623 | -2, /* (67) tcons ::= CONSTRAINT nm */ |
| 161174 | -5, /* (68) tcons ::= CHECK LP expr RP onconf */ | 162624 | -7, /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 161175 | -10, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ | 162625 | -5, /* (69) tcons ::= UNIQUE LP sortlist RP onconf */ |
| 161176 | 0, /* (70) defer_subclause_opt ::= */ | 162626 | -5, /* (70) tcons ::= CHECK LP expr RP onconf */ |
| 161177 | 0, /* (71) onconf ::= */ | 162627 | -10, /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 161178 | -3, /* (72) onconf ::= ON CONFLICT resolvetype */ | 162628 | 0, /* (72) defer_subclause_opt ::= */ |
| 161179 | 0, /* (73) orconf ::= */ | 162629 | 0, /* (73) onconf ::= */ |
| 161180 | -2, /* (74) orconf ::= OR resolvetype */ | 162630 | -3, /* (74) onconf ::= ON CONFLICT resolvetype */ |
| 161181 | -1, /* (75) resolvetype ::= IGNORE */ | 162631 | 0, /* (75) orconf ::= */ |
| 161182 | -1, /* (76) resolvetype ::= REPLACE */ | 162632 | -2, /* (76) orconf ::= OR resolvetype */ |
| 161183 | -4, /* (77) cmd ::= DROP TABLE ifexists fullname */ | 162633 | -1, /* (77) resolvetype ::= IGNORE */ |
| 161184 | -2, /* (78) ifexists ::= IF EXISTS */ | 162634 | -1, /* (78) resolvetype ::= REPLACE */ |
| 161185 | 0, /* (79) ifexists ::= */ | 162635 | -4, /* (79) cmd ::= DROP TABLE ifexists fullname */ |
| 161186 | -9, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ | 162636 | -2, /* (80) ifexists ::= IF EXISTS */ |
| 161187 | -4, /* (81) cmd ::= DROP VIEW ifexists fullname */ | 162637 | 0, /* (81) ifexists ::= */ |
| 161188 | -1, /* (82) cmd ::= select */ | 162638 | -9, /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 161189 | -3, /* (83) select ::= WITH wqlist selectnowith */ | 162639 | -4, /* (83) cmd ::= DROP VIEW ifexists fullname */ |
| 161190 | -4, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */ | 162640 | -1, /* (84) cmd ::= select */ |
| 161191 | -1, /* (85) select ::= selectnowith */ | 162641 | -3, /* (85) select ::= WITH wqlist selectnowith */ |
| 161192 | -3, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */ | 162642 | -4, /* (86) select ::= WITH RECURSIVE wqlist selectnowith */ |
| 161193 | -1, /* (87) multiselect_op ::= UNION */ | 162643 | -1, /* (87) select ::= selectnowith */ |
| 161194 | -2, /* (88) multiselect_op ::= UNION ALL */ | 162644 | -3, /* (88) selectnowith ::= selectnowith multiselect_op oneselect */ |
| 161195 | -1, /* (89) multiselect_op ::= EXCEPT|INTERSECT */ | 162645 | -1, /* (89) multiselect_op ::= UNION */ |
| 161196 | -9, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ | 162646 | -2, /* (90) multiselect_op ::= UNION ALL */ |
| 161197 | -10, /* (91) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ | 162647 | -1, /* (91) multiselect_op ::= EXCEPT|INTERSECT */ |
| 161198 | -4, /* (92) values ::= VALUES LP nexprlist RP */ | 162648 | -9, /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 161199 | -5, /* (93) values ::= values COMMA LP nexprlist RP */ | 162649 | -10, /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 161200 | -1, /* (94) distinct ::= DISTINCT */ | 162650 | -4, /* (94) values ::= VALUES LP nexprlist RP */ |
| 161201 | -1, /* (95) distinct ::= ALL */ | 162651 | -5, /* (95) values ::= values COMMA LP nexprlist RP */ |
| 161202 | 0, /* (96) distinct ::= */ | 162652 | -1, /* (96) distinct ::= DISTINCT */ |
| 161203 | 0, /* (97) sclp ::= */ | 162653 | -1, /* (97) distinct ::= ALL */ |
| 161204 | -5, /* (98) selcollist ::= sclp scanpt expr scanpt as */ | 162654 | 0, /* (98) distinct ::= */ |
| 161205 | -3, /* (99) selcollist ::= sclp scanpt STAR */ | 162655 | 0, /* (99) sclp ::= */ |
| 161206 | -5, /* (100) selcollist ::= sclp scanpt nm DOT STAR */ | 162656 | -5, /* (100) selcollist ::= sclp scanpt expr scanpt as */ |
| 161207 | -2, /* (101) as ::= AS nm */ | 162657 | -3, /* (101) selcollist ::= sclp scanpt STAR */ |
| 161208 | 0, /* (102) as ::= */ | 162658 | -5, /* (102) selcollist ::= sclp scanpt nm DOT STAR */ |
| 161209 | 0, /* (103) from ::= */ | 162659 | -2, /* (103) as ::= AS nm */ |
| 161210 | -2, /* (104) from ::= FROM seltablist */ | 162660 | 0, /* (104) as ::= */ |
| 161211 | -2, /* (105) stl_prefix ::= seltablist joinop */ | 162661 | 0, /* (105) from ::= */ |
| 161212 | 0, /* (106) stl_prefix ::= */ | 162662 | -2, /* (106) from ::= FROM seltablist */ |
| 161213 | -7, /* (107) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ | 162663 | -2, /* (107) stl_prefix ::= seltablist joinop */ |
| 161214 | -9, /* (108) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ | 162664 | 0, /* (108) stl_prefix ::= */ |
| 161215 | -7, /* (109) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ | 162665 | -7, /* (109) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 161216 | -7, /* (110) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ | 162666 | -9, /* (110) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 161217 | 0, /* (111) dbnm ::= */ | 162667 | -7, /* (111) seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 161218 | -2, /* (112) dbnm ::= DOT nm */ | 162668 | -7, /* (112) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 161219 | -1, /* (113) fullname ::= nm */ | 162669 | 0, /* (113) dbnm ::= */ |
| 161220 | -3, /* (114) fullname ::= nm DOT nm */ | 162670 | -2, /* (114) dbnm ::= DOT nm */ |
| 161221 | -1, /* (115) xfullname ::= nm */ | 162671 | -1, /* (115) fullname ::= nm */ |
| 161222 | -3, /* (116) xfullname ::= nm DOT nm */ | 162672 | -3, /* (116) fullname ::= nm DOT nm */ |
| 161223 | -5, /* (117) xfullname ::= nm DOT nm AS nm */ | 162673 | -1, /* (117) xfullname ::= nm */ |
| 161224 | -3, /* (118) xfullname ::= nm AS nm */ | 162674 | -3, /* (118) xfullname ::= nm DOT nm */ |
| 161225 | -1, /* (119) joinop ::= COMMA|JOIN */ | 162675 | -5, /* (119) xfullname ::= nm DOT nm AS nm */ |
| 161226 | -2, /* (120) joinop ::= JOIN_KW JOIN */ | 162676 | -3, /* (120) xfullname ::= nm AS nm */ |
| 161227 | -3, /* (121) joinop ::= JOIN_KW nm JOIN */ | 162677 | -1, /* (121) joinop ::= COMMA|JOIN */ |
| 161228 | -4, /* (122) joinop ::= JOIN_KW nm nm JOIN */ | 162678 | -2, /* (122) joinop ::= JOIN_KW JOIN */ |
| 161229 | -2, /* (123) on_opt ::= ON expr */ | 162679 | -3, /* (123) joinop ::= JOIN_KW nm JOIN */ |
| 161230 | 0, /* (124) on_opt ::= */ | 162680 | -4, /* (124) joinop ::= JOIN_KW nm nm JOIN */ |
| 161231 | 0, /* (125) indexed_opt ::= */ | 162681 | -2, /* (125) on_opt ::= ON expr */ |
| 161232 | -3, /* (126) indexed_opt ::= INDEXED BY nm */ | 162682 | 0, /* (126) on_opt ::= */ |
| 161233 | -2, /* (127) indexed_opt ::= NOT INDEXED */ | 162683 | 0, /* (127) indexed_opt ::= */ |
| 161234 | -4, /* (128) using_opt ::= USING LP idlist RP */ | 162684 | -3, /* (128) indexed_opt ::= INDEXED BY nm */ |
| 161235 | 0, /* (129) using_opt ::= */ | 162685 | -2, /* (129) indexed_opt ::= NOT INDEXED */ |
| 161236 | 0, /* (130) orderby_opt ::= */ | 162686 | -4, /* (130) using_opt ::= USING LP idlist RP */ |
| 161237 | -3, /* (131) orderby_opt ::= ORDER BY sortlist */ | 162687 | 0, /* (131) using_opt ::= */ |
| 161238 | -5, /* (132) sortlist ::= sortlist COMMA expr sortorder nulls */ | 162688 | 0, /* (132) orderby_opt ::= */ |
| 161239 | -3, /* (133) sortlist ::= expr sortorder nulls */ | 162689 | -3, /* (133) orderby_opt ::= ORDER BY sortlist */ |
| 161240 | -1, /* (134) sortorder ::= ASC */ | 162690 | -5, /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 161241 | -1, /* (135) sortorder ::= DESC */ | 162691 | -3, /* (135) sortlist ::= expr sortorder nulls */ |
| 161242 | 0, /* (136) sortorder ::= */ | 162692 | -1, /* (136) sortorder ::= ASC */ |
| 161243 | -2, /* (137) nulls ::= NULLS FIRST */ | 162693 | -1, /* (137) sortorder ::= DESC */ |
| 161244 | -2, /* (138) nulls ::= NULLS LAST */ | 162694 | 0, /* (138) sortorder ::= */ |
| 161245 | 0, /* (139) nulls ::= */ | 162695 | -2, /* (139) nulls ::= NULLS FIRST */ |
| 161246 | 0, /* (140) groupby_opt ::= */ | 162696 | -2, /* (140) nulls ::= NULLS LAST */ |
| 161247 | -3, /* (141) groupby_opt ::= GROUP BY nexprlist */ | 162697 | 0, /* (141) nulls ::= */ |
| 161248 | 0, /* (142) having_opt ::= */ | 162698 | 0, /* (142) groupby_opt ::= */ |
| 161249 | -2, /* (143) having_opt ::= HAVING expr */ | 162699 | -3, /* (143) groupby_opt ::= GROUP BY nexprlist */ |
| 161250 | 0, /* (144) limit_opt ::= */ | 162700 | 0, /* (144) having_opt ::= */ |
| 161251 | -2, /* (145) limit_opt ::= LIMIT expr */ | 162701 | -2, /* (145) having_opt ::= HAVING expr */ |
| 161252 | -4, /* (146) limit_opt ::= LIMIT expr OFFSET expr */ | 162702 | 0, /* (146) limit_opt ::= */ |
| 161253 | -4, /* (147) limit_opt ::= LIMIT expr COMMA expr */ | 162703 | -2, /* (147) limit_opt ::= LIMIT expr */ |
| 161254 | -6, /* (148) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ | 162704 | -4, /* (148) limit_opt ::= LIMIT expr OFFSET expr */ |
| 161255 | 0, /* (149) where_opt ::= */ | 162705 | -4, /* (149) limit_opt ::= LIMIT expr COMMA expr */ |
| 161256 | -2, /* (150) where_opt ::= WHERE expr */ | 162706 | -6, /* (150) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 161257 | 0, /* (151) where_opt_ret ::= */ | 162707 | 0, /* (151) where_opt ::= */ |
| 161258 | -2, /* (152) where_opt_ret ::= WHERE expr */ | 162708 | -2, /* (152) where_opt ::= WHERE expr */ |
| 161259 | -2, /* (153) where_opt_ret ::= RETURNING selcollist */ | 162709 | 0, /* (153) where_opt_ret ::= */ |
| 161260 | -4, /* (154) where_opt_ret ::= WHERE expr RETURNING selcollist */ | 162710 | -2, /* (154) where_opt_ret ::= WHERE expr */ |
| 161261 | -9, /* (155) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ | 162711 | -2, /* (155) where_opt_ret ::= RETURNING selcollist */ |
| 161262 | -5, /* (156) setlist ::= setlist COMMA nm EQ expr */ | 162712 | -4, /* (156) where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 161263 | -7, /* (157) setlist ::= setlist COMMA LP idlist RP EQ expr */ | 162713 | -9, /* (157) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 161264 | -3, /* (158) setlist ::= nm EQ expr */ | 162714 | -5, /* (158) setlist ::= setlist COMMA nm EQ expr */ |
| 161265 | -5, /* (159) setlist ::= LP idlist RP EQ expr */ | 162715 | -7, /* (159) setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 161266 | -7, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ | 162716 | -3, /* (160) setlist ::= nm EQ expr */ |
| 161267 | -8, /* (161) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ | 162717 | -5, /* (161) setlist ::= LP idlist RP EQ expr */ |
| 161268 | 0, /* (162) upsert ::= */ | 162718 | -7, /* (162) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 161269 | -2, /* (163) upsert ::= RETURNING selcollist */ | 162719 | -8, /* (163) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 161270 | -12, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ | 162720 | 0, /* (164) upsert ::= */ |
| 161271 | -9, /* (165) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ | 162721 | -2, /* (165) upsert ::= RETURNING selcollist */ |
| 161272 | -5, /* (166) upsert ::= ON CONFLICT DO NOTHING returning */ | 162722 | -12, /* (166) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 161273 | -8, /* (167) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ | 162723 | -9, /* (167) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 161274 | -2, /* (168) returning ::= RETURNING selcollist */ | 162724 | -5, /* (168) upsert ::= ON CONFLICT DO NOTHING returning */ |
| 161275 | -2, /* (169) insert_cmd ::= INSERT orconf */ | 162725 | -8, /* (169) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 161276 | -1, /* (170) insert_cmd ::= REPLACE */ | 162726 | -2, /* (170) returning ::= RETURNING selcollist */ |
| 161277 | 0, /* (171) idlist_opt ::= */ | 162727 | -2, /* (171) insert_cmd ::= INSERT orconf */ |
| 161278 | -3, /* (172) idlist_opt ::= LP idlist RP */ | 162728 | -1, /* (172) insert_cmd ::= REPLACE */ |
| 161279 | -3, /* (173) idlist ::= idlist COMMA nm */ | 162729 | 0, /* (173) idlist_opt ::= */ |
| 161280 | -1, /* (174) idlist ::= nm */ | 162730 | -3, /* (174) idlist_opt ::= LP idlist RP */ |
| 161281 | -3, /* (175) expr ::= LP expr RP */ | 162731 | -3, /* (175) idlist ::= idlist COMMA nm */ |
| 161282 | -1, /* (176) expr ::= ID|INDEXED */ | 162732 | -1, /* (176) idlist ::= nm */ |
| 161283 | -1, /* (177) expr ::= JOIN_KW */ | 162733 | -3, /* (177) expr ::= LP expr RP */ |
| 161284 | -3, /* (178) expr ::= nm DOT nm */ | 162734 | -1, /* (178) expr ::= ID|INDEXED */ |
| 161285 | -5, /* (179) expr ::= nm DOT nm DOT nm */ | 162735 | -1, /* (179) expr ::= JOIN_KW */ |
| 161286 | -1, /* (180) term ::= NULL|FLOAT|BLOB */ | 162736 | -3, /* (180) expr ::= nm DOT nm */ |
| 161287 | -1, /* (181) term ::= STRING */ | 162737 | -5, /* (181) expr ::= nm DOT nm DOT nm */ |
| 161288 | -1, /* (182) term ::= INTEGER */ | 162738 | -1, /* (182) term ::= NULL|FLOAT|BLOB */ |
| 161289 | -1, /* (183) expr ::= VARIABLE */ | 162739 | -1, /* (183) term ::= STRING */ |
| 161290 | -3, /* (184) expr ::= expr COLLATE ID|STRING */ | 162740 | -1, /* (184) term ::= INTEGER */ |
| 161291 | -6, /* (185) expr ::= CAST LP expr AS typetoken RP */ | 162741 | -1, /* (185) expr ::= VARIABLE */ |
| 161292 | -5, /* (186) expr ::= ID|INDEXED LP distinct exprlist RP */ | 162742 | -3, /* (186) expr ::= expr COLLATE ID|STRING */ |
| 161293 | -4, /* (187) expr ::= ID|INDEXED LP STAR RP */ | 162743 | -6, /* (187) expr ::= CAST LP expr AS typetoken RP */ |
| 161294 | -6, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ | 162744 | -5, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 161295 | -5, /* (189) expr ::= ID|INDEXED LP STAR RP filter_over */ | 162745 | -4, /* (189) expr ::= ID|INDEXED LP STAR RP */ |
| 161296 | -1, /* (190) term ::= CTIME_KW */ | 162746 | -6, /* (190) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 161297 | -5, /* (191) expr ::= LP nexprlist COMMA expr RP */ | 162747 | -5, /* (191) expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 161298 | -3, /* (192) expr ::= expr AND expr */ | 162748 | -1, /* (192) term ::= CTIME_KW */ |
| 161299 | -3, /* (193) expr ::= expr OR expr */ | 162749 | -5, /* (193) expr ::= LP nexprlist COMMA expr RP */ |
| 161300 | -3, /* (194) expr ::= expr LT|GT|GE|LE expr */ | 162750 | -3, /* (194) expr ::= expr AND expr */ |
| 161301 | -3, /* (195) expr ::= expr EQ|NE expr */ | 162751 | -3, /* (195) expr ::= expr OR expr */ |
| 161302 | -3, /* (196) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ | 162752 | -3, /* (196) expr ::= expr LT|GT|GE|LE expr */ |
| 161303 | -3, /* (197) expr ::= expr PLUS|MINUS expr */ | 162753 | -3, /* (197) expr ::= expr EQ|NE expr */ |
| 161304 | -3, /* (198) expr ::= expr STAR|SLASH|REM expr */ | 162754 | -3, /* (198) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ |
| 161305 | -3, /* (199) expr ::= expr CONCAT expr */ | 162755 | -3, /* (199) expr ::= expr PLUS|MINUS expr */ |
| 161306 | -2, /* (200) likeop ::= NOT LIKE_KW|MATCH */ | 162756 | -3, /* (200) expr ::= expr STAR|SLASH|REM expr */ |
| 161307 | -3, /* (201) expr ::= expr likeop expr */ | 162757 | -3, /* (201) expr ::= expr CONCAT expr */ |
| 161308 | -5, /* (202) expr ::= expr likeop expr ESCAPE expr */ | 162758 | -2, /* (202) likeop ::= NOT LIKE_KW|MATCH */ |
| 161309 | -2, /* (203) expr ::= expr ISNULL|NOTNULL */ | 162759 | -3, /* (203) expr ::= expr likeop expr */ |
| 161310 | -3, /* (204) expr ::= expr NOT NULL */ | 162760 | -5, /* (204) expr ::= expr likeop expr ESCAPE expr */ |
| 161311 | -3, /* (205) expr ::= expr IS expr */ | 162761 | -2, /* (205) expr ::= expr ISNULL|NOTNULL */ |
| 161312 | -4, /* (206) expr ::= expr IS NOT expr */ | 162762 | -3, /* (206) expr ::= expr NOT NULL */ |
| 161313 | -2, /* (207) expr ::= NOT expr */ | 162763 | -3, /* (207) expr ::= expr IS expr */ |
| 161314 | -2, /* (208) expr ::= BITNOT expr */ | 162764 | -4, /* (208) expr ::= expr IS NOT expr */ |
| 161315 | -2, /* (209) expr ::= PLUS|MINUS expr */ | 162765 | -2, /* (209) expr ::= NOT expr */ |
| 161316 | -1, /* (210) between_op ::= BETWEEN */ | 162766 | -2, /* (210) expr ::= BITNOT expr */ |
| 161317 | -2, /* (211) between_op ::= NOT BETWEEN */ | 162767 | -2, /* (211) expr ::= PLUS|MINUS expr */ |
| 161318 | -5, /* (212) expr ::= expr between_op expr AND expr */ | 162768 | -1, /* (212) between_op ::= BETWEEN */ |
| 161319 | -1, /* (213) in_op ::= IN */ | 162769 | -2, /* (213) between_op ::= NOT BETWEEN */ |
| 161320 | -2, /* (214) in_op ::= NOT IN */ | 162770 | -5, /* (214) expr ::= expr between_op expr AND expr */ |
| 161321 | -5, /* (215) expr ::= expr in_op LP exprlist RP */ | 162771 | -1, /* (215) in_op ::= IN */ |
| 161322 | -3, /* (216) expr ::= LP select RP */ | 162772 | -2, /* (216) in_op ::= NOT IN */ |
| 161323 | -5, /* (217) expr ::= expr in_op LP select RP */ | 162773 | -5, /* (217) expr ::= expr in_op LP exprlist RP */ |
| 161324 | -5, /* (218) expr ::= expr in_op nm dbnm paren_exprlist */ | 162774 | -3, /* (218) expr ::= LP select RP */ |
| 161325 | -4, /* (219) expr ::= EXISTS LP select RP */ | 162775 | -5, /* (219) expr ::= expr in_op LP select RP */ |
| 161326 | -5, /* (220) expr ::= CASE case_operand case_exprlist case_else END */ | 162776 | -5, /* (220) expr ::= expr in_op nm dbnm paren_exprlist */ |
| 161327 | -5, /* (221) case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 162777 | -4, /* (221) expr ::= EXISTS LP select RP */ |
| 161328 | -4, /* (222) case_exprlist ::= WHEN expr THEN expr */ | 162778 | -5, /* (222) expr ::= CASE case_operand case_exprlist case_else END */ |
| 161329 | -2, /* (223) case_else ::= ELSE expr */ | 162779 | -5, /* (223) case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 161330 | 0, /* (224) case_else ::= */ | 162780 | -4, /* (224) case_exprlist ::= WHEN expr THEN expr */ |
| 161331 | -1, /* (225) case_operand ::= expr */ | 162781 | -2, /* (225) case_else ::= ELSE expr */ |
| 161332 | 0, /* (226) case_operand ::= */ | 162782 | 0, /* (226) case_else ::= */ |
| 161333 | 0, /* (227) exprlist ::= */ | 162783 | -1, /* (227) case_operand ::= expr */ |
| 161334 | -3, /* (228) nexprlist ::= nexprlist COMMA expr */ | 162784 | 0, /* (228) case_operand ::= */ |
| 161335 | -1, /* (229) nexprlist ::= expr */ | 162785 | 0, /* (229) exprlist ::= */ |
| 161336 | 0, /* (230) paren_exprlist ::= */ | 162786 | -3, /* (230) nexprlist ::= nexprlist COMMA expr */ |
| 161337 | -3, /* (231) paren_exprlist ::= LP exprlist RP */ | 162787 | -1, /* (231) nexprlist ::= expr */ |
| 161338 | -12, /* (232) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 162788 | 0, /* (232) paren_exprlist ::= */ |
| 161339 | -1, /* (233) uniqueflag ::= UNIQUE */ | 162789 | -3, /* (233) paren_exprlist ::= LP exprlist RP */ |
| 161340 | 0, /* (234) uniqueflag ::= */ | 162790 | -12, /* (234) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 161341 | 0, /* (235) eidlist_opt ::= */ | 162791 | -1, /* (235) uniqueflag ::= UNIQUE */ |
| 161342 | -3, /* (236) eidlist_opt ::= LP eidlist RP */ | 162792 | 0, /* (236) uniqueflag ::= */ |
| 161343 | -5, /* (237) eidlist ::= eidlist COMMA nm collate sortorder */ | 162793 | 0, /* (237) eidlist_opt ::= */ |
| 161344 | -3, /* (238) eidlist ::= nm collate sortorder */ | 162794 | -3, /* (238) eidlist_opt ::= LP eidlist RP */ |
| 161345 | 0, /* (239) collate ::= */ | 162795 | -5, /* (239) eidlist ::= eidlist COMMA nm collate sortorder */ |
| 161346 | -2, /* (240) collate ::= COLLATE ID|STRING */ | 162796 | -3, /* (240) eidlist ::= nm collate sortorder */ |
| 161347 | -4, /* (241) cmd ::= DROP INDEX ifexists fullname */ | 162797 | 0, /* (241) collate ::= */ |
| 161348 | -2, /* (242) cmd ::= VACUUM vinto */ | 162798 | -2, /* (242) collate ::= COLLATE ID|STRING */ |
| 161349 | -3, /* (243) cmd ::= VACUUM nm vinto */ | 162799 | -4, /* (243) cmd ::= DROP INDEX ifexists fullname */ |
| 161350 | -2, /* (244) vinto ::= INTO expr */ | 162800 | -2, /* (244) cmd ::= VACUUM vinto */ |
| 161351 | 0, /* (245) vinto ::= */ | 162801 | -3, /* (245) cmd ::= VACUUM nm vinto */ |
| 161352 | -3, /* (246) cmd ::= PRAGMA nm dbnm */ | 162802 | -2, /* (246) vinto ::= INTO expr */ |
| 161353 | -5, /* (247) cmd ::= PRAGMA nm dbnm EQ nmnum */ | 162803 | 0, /* (247) vinto ::= */ |
| 161354 | -6, /* (248) cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 162804 | -3, /* (248) cmd ::= PRAGMA nm dbnm */ |
| 161355 | -5, /* (249) cmd ::= PRAGMA nm dbnm EQ minus_num */ | 162805 | -5, /* (249) cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 161356 | -6, /* (250) cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 162806 | -6, /* (250) cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 161357 | -2, /* (251) plus_num ::= PLUS INTEGER|FLOAT */ | 162807 | -5, /* (251) cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 161358 | -2, /* (252) minus_num ::= MINUS INTEGER|FLOAT */ | 162808 | -6, /* (252) cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 161359 | -5, /* (253) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 162809 | -2, /* (253) plus_num ::= PLUS INTEGER|FLOAT */ |
| 161360 | -11, /* (254) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 162810 | -2, /* (254) minus_num ::= MINUS INTEGER|FLOAT */ |
| 161361 | -1, /* (255) trigger_time ::= BEFORE|AFTER */ | 162811 | -5, /* (255) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 161362 | -2, /* (256) trigger_time ::= INSTEAD OF */ | 162812 | -11, /* (256) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 161363 | 0, /* (257) trigger_time ::= */ | 162813 | -1, /* (257) trigger_time ::= BEFORE|AFTER */ |
| 161364 | -1, /* (258) trigger_event ::= DELETE|INSERT */ | 162814 | -2, /* (258) trigger_time ::= INSTEAD OF */ |
| 161365 | -1, /* (259) trigger_event ::= UPDATE */ | 162815 | 0, /* (259) trigger_time ::= */ |
| 161366 | -3, /* (260) trigger_event ::= UPDATE OF idlist */ | 162816 | -1, /* (260) trigger_event ::= DELETE|INSERT */ |
| 161367 | 0, /* (261) when_clause ::= */ | 162817 | -1, /* (261) trigger_event ::= UPDATE */ |
| 161368 | -2, /* (262) when_clause ::= WHEN expr */ | 162818 | -3, /* (262) trigger_event ::= UPDATE OF idlist */ |
| 161369 | -3, /* (263) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 162819 | 0, /* (263) when_clause ::= */ |
| 161370 | -2, /* (264) trigger_cmd_list ::= trigger_cmd SEMI */ | 162820 | -2, /* (264) when_clause ::= WHEN expr */ |
| 161371 | -3, /* (265) trnm ::= nm DOT nm */ | 162821 | -3, /* (265) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 161372 | -3, /* (266) tridxby ::= INDEXED BY nm */ | 162822 | -2, /* (266) trigger_cmd_list ::= trigger_cmd SEMI */ |
| 161373 | -2, /* (267) tridxby ::= NOT INDEXED */ | 162823 | -3, /* (267) trnm ::= nm DOT nm */ |
| 161374 | -9, /* (268) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 162824 | -3, /* (268) tridxby ::= INDEXED BY nm */ |
| 161375 | -8, /* (269) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 162825 | -2, /* (269) tridxby ::= NOT INDEXED */ |
| 161376 | -6, /* (270) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 162826 | -9, /* (270) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 161377 | -3, /* (271) trigger_cmd ::= scanpt select scanpt */ | 162827 | -8, /* (271) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 161378 | -4, /* (272) expr ::= RAISE LP IGNORE RP */ | 162828 | -6, /* (272) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 161379 | -6, /* (273) expr ::= RAISE LP raisetype COMMA nm RP */ | 162829 | -3, /* (273) trigger_cmd ::= scanpt select scanpt */ |
| 161380 | -1, /* (274) raisetype ::= ROLLBACK */ | 162830 | -4, /* (274) expr ::= RAISE LP IGNORE RP */ |
| 161381 | -1, /* (275) raisetype ::= ABORT */ | 162831 | -6, /* (275) expr ::= RAISE LP raisetype COMMA nm RP */ |
| 161382 | -1, /* (276) raisetype ::= FAIL */ | 162832 | -1, /* (276) raisetype ::= ROLLBACK */ |
| 161383 | -4, /* (277) cmd ::= DROP TRIGGER ifexists fullname */ | 162833 | -1, /* (277) raisetype ::= ABORT */ |
| 161384 | -6, /* (278) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 162834 | -1, /* (278) raisetype ::= FAIL */ |
| 161385 | -3, /* (279) cmd ::= DETACH database_kw_opt expr */ | 162835 | -4, /* (279) cmd ::= DROP TRIGGER ifexists fullname */ |
| 161386 | 0, /* (280) key_opt ::= */ | 162836 | -6, /* (280) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 161387 | -2, /* (281) key_opt ::= KEY expr */ | 162837 | -3, /* (281) cmd ::= DETACH database_kw_opt expr */ |
| 161388 | -1, /* (282) cmd ::= REINDEX */ | 162838 | 0, /* (282) key_opt ::= */ |
| 161389 | -3, /* (283) cmd ::= REINDEX nm dbnm */ | 162839 | -2, /* (283) key_opt ::= KEY expr */ |
| 161390 | -1, /* (284) cmd ::= ANALYZE */ | 162840 | -1, /* (284) cmd ::= REINDEX */ |
| 161391 | -3, /* (285) cmd ::= ANALYZE nm dbnm */ | 162841 | -3, /* (285) cmd ::= REINDEX nm dbnm */ |
| 161392 | -6, /* (286) cmd ::= ALTER TABLE fullname RENAME TO nm */ | 162842 | -1, /* (286) cmd ::= ANALYZE */ |
| 161393 | -7, /* (287) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 162843 | -3, /* (287) cmd ::= ANALYZE nm dbnm */ |
| 161394 | -6, /* (288) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | 162844 | -6, /* (288) cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 161395 | -1, /* (289) add_column_fullname ::= fullname */ | 162845 | -7, /* (289) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 161396 | -8, /* (290) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 162846 | -6, /* (290) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 161397 | -1, /* (291) cmd ::= create_vtab */ | 162847 | -1, /* (291) add_column_fullname ::= fullname */ |
| 161398 | -4, /* (292) cmd ::= create_vtab LP vtabarglist RP */ | 162848 | -8, /* (292) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 161399 | -8, /* (293) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 162849 | -1, /* (293) cmd ::= create_vtab */ |
| 161400 | 0, /* (294) vtabarg ::= */ | 162850 | -4, /* (294) cmd ::= create_vtab LP vtabarglist RP */ |
| 161401 | -1, /* (295) vtabargtoken ::= ANY */ | 162851 | -8, /* (295) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 161402 | -3, /* (296) vtabargtoken ::= lp anylist RP */ | 162852 | 0, /* (296) vtabarg ::= */ |
| 161403 | -1, /* (297) lp ::= LP */ | 162853 | -1, /* (297) vtabargtoken ::= ANY */ |
| 161404 | -2, /* (298) with ::= WITH wqlist */ | 162854 | -3, /* (298) vtabargtoken ::= lp anylist RP */ |
| 161405 | -3, /* (299) with ::= WITH RECURSIVE wqlist */ | 162855 | -1, /* (299) lp ::= LP */ |
| 161406 | -1, /* (300) wqas ::= AS */ | 162856 | -2, /* (300) with ::= WITH wqlist */ |
| 161407 | -2, /* (301) wqas ::= AS MATERIALIZED */ | 162857 | -3, /* (301) with ::= WITH RECURSIVE wqlist */ |
| 161408 | -3, /* (302) wqas ::= AS NOT MATERIALIZED */ | 162858 | -1, /* (302) wqas ::= AS */ |
| 161409 | -6, /* (303) wqitem ::= nm eidlist_opt wqas LP select RP */ | 162859 | -2, /* (303) wqas ::= AS MATERIALIZED */ |
| 161410 | -1, /* (304) wqlist ::= wqitem */ | 162860 | -3, /* (304) wqas ::= AS NOT MATERIALIZED */ |
| 161411 | -3, /* (305) wqlist ::= wqlist COMMA wqitem */ | 162861 | -6, /* (305) wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 161412 | -1, /* (306) windowdefn_list ::= windowdefn */ | 162862 | -1, /* (306) wqlist ::= wqitem */ |
| 161413 | -3, /* (307) windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 162863 | -3, /* (307) wqlist ::= wqlist COMMA wqitem */ |
| 161414 | -5, /* (308) windowdefn ::= nm AS LP window RP */ | 162864 | -1, /* (308) windowdefn_list ::= windowdefn */ |
| 161415 | -5, /* (309) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 162865 | -3, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 161416 | -6, /* (310) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 162866 | -5, /* (310) windowdefn ::= nm AS LP window RP */ |
| 161417 | -4, /* (311) window ::= ORDER BY sortlist frame_opt */ | 162867 | -5, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 161418 | -5, /* (312) window ::= nm ORDER BY sortlist frame_opt */ | 162868 | -6, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 161419 | -1, /* (313) window ::= frame_opt */ | 162869 | -4, /* (313) window ::= ORDER BY sortlist frame_opt */ |
| 161420 | -2, /* (314) window ::= nm frame_opt */ | 162870 | -5, /* (314) window ::= nm ORDER BY sortlist frame_opt */ |
| 161421 | 0, /* (315) frame_opt ::= */ | 162871 | -1, /* (315) window ::= frame_opt */ |
| 161422 | -3, /* (316) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 162872 | -2, /* (316) window ::= nm frame_opt */ |
| 161423 | -6, /* (317) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 162873 | 0, /* (317) frame_opt ::= */ |
| 161424 | -1, /* (318) range_or_rows ::= RANGE|ROWS|GROUPS */ | 162874 | -3, /* (318) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 161425 | -1, /* (319) frame_bound_s ::= frame_bound */ | 162875 | -6, /* (319) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 161426 | -2, /* (320) frame_bound_s ::= UNBOUNDED PRECEDING */ | 162876 | -1, /* (320) range_or_rows ::= RANGE|ROWS|GROUPS */ |
| 161427 | -1, /* (321) frame_bound_e ::= frame_bound */ | 162877 | -1, /* (321) frame_bound_s ::= frame_bound */ |
| 161428 | -2, /* (322) frame_bound_e ::= UNBOUNDED FOLLOWING */ | 162878 | -2, /* (322) frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 161429 | -2, /* (323) frame_bound ::= expr PRECEDING|FOLLOWING */ | 162879 | -1, /* (323) frame_bound_e ::= frame_bound */ |
| 161430 | -2, /* (324) frame_bound ::= CURRENT ROW */ | 162880 | -2, /* (324) frame_bound_e ::= UNBOUNDED FOLLOWING */ |
| 161431 | 0, /* (325) frame_exclude_opt ::= */ | 162881 | -2, /* (325) frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 161432 | -2, /* (326) frame_exclude_opt ::= EXCLUDE frame_exclude */ | 162882 | -2, /* (326) frame_bound ::= CURRENT ROW */ |
| 161433 | -2, /* (327) frame_exclude ::= NO OTHERS */ | 162883 | 0, /* (327) frame_exclude_opt ::= */ |
| 161434 | -2, /* (328) frame_exclude ::= CURRENT ROW */ | 162884 | -2, /* (328) frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 161435 | -1, /* (329) frame_exclude ::= GROUP|TIES */ | 162885 | -2, /* (329) frame_exclude ::= NO OTHERS */ |
| 161436 | -2, /* (330) window_clause ::= WINDOW windowdefn_list */ | 162886 | -2, /* (330) frame_exclude ::= CURRENT ROW */ |
| 161437 | -2, /* (331) filter_over ::= filter_clause over_clause */ | 162887 | -1, /* (331) frame_exclude ::= GROUP|TIES */ |
| 161438 | -1, /* (332) filter_over ::= over_clause */ | 162888 | -2, /* (332) window_clause ::= WINDOW windowdefn_list */ |
| 161439 | -1, /* (333) filter_over ::= filter_clause */ | 162889 | -2, /* (333) filter_over ::= filter_clause over_clause */ |
| 161440 | -4, /* (334) over_clause ::= OVER LP window RP */ | 162890 | -1, /* (334) filter_over ::= over_clause */ |
| 161441 | -2, /* (335) over_clause ::= OVER nm */ | 162891 | -1, /* (335) filter_over ::= filter_clause */ |
| 161442 | -5, /* (336) filter_clause ::= FILTER LP WHERE expr RP */ | 162892 | -4, /* (336) over_clause ::= OVER LP window RP */ |
| 161443 | -1, /* (337) input ::= cmdlist */ | 162893 | -2, /* (337) over_clause ::= OVER nm */ |
| 161444 | -2, /* (338) cmdlist ::= cmdlist ecmd */ | 162894 | -5, /* (338) filter_clause ::= FILTER LP WHERE expr RP */ |
| 161445 | -1, /* (339) cmdlist ::= ecmd */ | 162895 | -1, /* (339) input ::= cmdlist */ |
| 161446 | -1, /* (340) ecmd ::= SEMI */ | 162896 | -2, /* (340) cmdlist ::= cmdlist ecmd */ |
| 161447 | -2, /* (341) ecmd ::= cmdx SEMI */ | 162897 | -1, /* (341) cmdlist ::= ecmd */ |
| 161448 | -3, /* (342) ecmd ::= explain cmdx SEMI */ | 162898 | -1, /* (342) ecmd ::= SEMI */ |
| 161449 | 0, /* (343) trans_opt ::= */ | 162899 | -2, /* (343) ecmd ::= cmdx SEMI */ |
| 161450 | -1, /* (344) trans_opt ::= TRANSACTION */ | 162900 | -3, /* (344) ecmd ::= explain cmdx SEMI */ |
| 161451 | -2, /* (345) trans_opt ::= TRANSACTION nm */ | 162901 | 0, /* (345) trans_opt ::= */ |
| 161452 | -1, /* (346) savepoint_opt ::= SAVEPOINT */ | 162902 | -1, /* (346) trans_opt ::= TRANSACTION */ |
| 161453 | 0, /* (347) savepoint_opt ::= */ | 162903 | -2, /* (347) trans_opt ::= TRANSACTION nm */ |
| 161454 | -2, /* (348) cmd ::= create_table create_table_args */ | 162904 | -1, /* (348) savepoint_opt ::= SAVEPOINT */ |
| 161455 | -4, /* (349) columnlist ::= columnlist COMMA columnname carglist */ | 162905 | 0, /* (349) savepoint_opt ::= */ |
| 161456 | -2, /* (350) columnlist ::= columnname carglist */ | 162906 | -2, /* (350) cmd ::= create_table create_table_args */ |
| 161457 | -1, /* (351) nm ::= ID|INDEXED */ | 162907 | -1, /* (351) table_option_set ::= table_option */ |
| 161458 | -1, /* (352) nm ::= STRING */ | 162908 | -4, /* (352) columnlist ::= columnlist COMMA columnname carglist */ |
| 161459 | -1, /* (353) nm ::= JOIN_KW */ | 162909 | -2, /* (353) columnlist ::= columnname carglist */ |
| 161460 | -1, /* (354) typetoken ::= typename */ | 162910 | -1, /* (354) nm ::= ID|INDEXED */ |
| 161461 | -1, /* (355) typename ::= ID|STRING */ | 162911 | -1, /* (355) nm ::= STRING */ |
| 161462 | -1, /* (356) signed ::= plus_num */ | 162912 | -1, /* (356) nm ::= JOIN_KW */ |
| 161463 | -1, /* (357) signed ::= minus_num */ | 162913 | -1, /* (357) typetoken ::= typename */ |
| 161464 | -2, /* (358) carglist ::= carglist ccons */ | 162914 | -1, /* (358) typename ::= ID|STRING */ |
| 161465 | 0, /* (359) carglist ::= */ | 162915 | -1, /* (359) signed ::= plus_num */ |
| 161466 | -2, /* (360) ccons ::= NULL onconf */ | 162916 | -1, /* (360) signed ::= minus_num */ |
| 161467 | -4, /* (361) ccons ::= GENERATED ALWAYS AS generated */ | 162917 | -2, /* (361) carglist ::= carglist ccons */ |
| 161468 | -2, /* (362) ccons ::= AS generated */ | 162918 | 0, /* (362) carglist ::= */ |
| 161469 | -2, /* (363) conslist_opt ::= COMMA conslist */ | 162919 | -2, /* (363) ccons ::= NULL onconf */ |
| 161470 | -3, /* (364) conslist ::= conslist tconscomma tcons */ | 162920 | -4, /* (364) ccons ::= GENERATED ALWAYS AS generated */ |
| 161471 | -1, /* (365) conslist ::= tcons */ | 162921 | -2, /* (365) ccons ::= AS generated */ |
| 161472 | 0, /* (366) tconscomma ::= */ | 162922 | -2, /* (366) conslist_opt ::= COMMA conslist */ |
| 161473 | -1, /* (367) defer_subclause_opt ::= defer_subclause */ | 162923 | -3, /* (367) conslist ::= conslist tconscomma tcons */ |
| 161474 | -1, /* (368) resolvetype ::= raisetype */ | 162924 | -1, /* (368) conslist ::= tcons */ |
| 161475 | -1, /* (369) selectnowith ::= oneselect */ | 162925 | 0, /* (369) tconscomma ::= */ |
| 161476 | -1, /* (370) oneselect ::= values */ | 162926 | -1, /* (370) defer_subclause_opt ::= defer_subclause */ |
| 161477 | -2, /* (371) sclp ::= selcollist COMMA */ | 162927 | -1, /* (371) resolvetype ::= raisetype */ |
| 161478 | -1, /* (372) as ::= ID|STRING */ | 162928 | -1, /* (372) selectnowith ::= oneselect */ |
| 161479 | 0, /* (373) returning ::= */ | 162929 | -1, /* (373) oneselect ::= values */ |
| 161480 | -1, /* (374) expr ::= term */ | 162930 | -2, /* (374) sclp ::= selcollist COMMA */ |
| 161481 | -1, /* (375) likeop ::= LIKE_KW|MATCH */ | 162931 | -1, /* (375) as ::= ID|STRING */ |
| 161482 | -1, /* (376) exprlist ::= nexprlist */ | 162932 | 0, /* (376) returning ::= */ |
| 161483 | -1, /* (377) nmnum ::= plus_num */ | 162933 | -1, /* (377) expr ::= term */ |
| 161484 | -1, /* (378) nmnum ::= nm */ | 162934 | -1, /* (378) likeop ::= LIKE_KW|MATCH */ |
| 161485 | -1, /* (379) nmnum ::= ON */ | 162935 | -1, /* (379) exprlist ::= nexprlist */ |
| 161486 | -1, /* (380) nmnum ::= DELETE */ | 162936 | -1, /* (380) nmnum ::= plus_num */ |
| 161487 | -1, /* (381) nmnum ::= DEFAULT */ | 162937 | -1, /* (381) nmnum ::= nm */ |
| 161488 | -1, /* (382) plus_num ::= INTEGER|FLOAT */ | 162938 | -1, /* (382) nmnum ::= ON */ |
| 161489 | 0, /* (383) foreach_clause ::= */ | 162939 | -1, /* (383) nmnum ::= DELETE */ |
| 161490 | -3, /* (384) foreach_clause ::= FOR EACH ROW */ | 162940 | -1, /* (384) nmnum ::= DEFAULT */ |
| 161491 | -1, /* (385) trnm ::= nm */ | 162941 | -1, /* (385) plus_num ::= INTEGER|FLOAT */ |
| 161492 | 0, /* (386) tridxby ::= */ | 162942 | 0, /* (386) foreach_clause ::= */ |
| 161493 | -1, /* (387) database_kw_opt ::= DATABASE */ | 162943 | -3, /* (387) foreach_clause ::= FOR EACH ROW */ |
| 161494 | 0, /* (388) database_kw_opt ::= */ | 162944 | -1, /* (388) trnm ::= nm */ |
| 161495 | 0, /* (389) kwcolumn_opt ::= */ | 162945 | 0, /* (389) tridxby ::= */ |
| 161496 | -1, /* (390) kwcolumn_opt ::= COLUMNKW */ | 162946 | -1, /* (390) database_kw_opt ::= DATABASE */ |
| 161497 | -1, /* (391) vtabarglist ::= vtabarg */ | 162947 | 0, /* (391) database_kw_opt ::= */ |
| 161498 | -3, /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ | 162948 | 0, /* (392) kwcolumn_opt ::= */ |
| 161499 | -2, /* (393) vtabarg ::= vtabarg vtabargtoken */ | 162949 | -1, /* (393) kwcolumn_opt ::= COLUMNKW */ |
| 161500 | 0, /* (394) anylist ::= */ | 162950 | -1, /* (394) vtabarglist ::= vtabarg */ |
| 161501 | -4, /* (395) anylist ::= anylist LP anylist RP */ | 162951 | -3, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ |
| 161502 | -2, /* (396) anylist ::= anylist ANY */ | 162952 | -2, /* (396) vtabarg ::= vtabarg vtabargtoken */ |
| 161503 | 0, /* (397) with ::= */ | 162953 | 0, /* (397) anylist ::= */ |
| 162954 | -4, /* (398) anylist ::= anylist LP anylist RP */ | ||
| 162955 | -2, /* (399) anylist ::= anylist ANY */ | ||
| 162956 | 0, /* (400) with ::= */ | ||
| 161504 | }; | 162957 | }; |
| 161505 | 162958 | ||
| 161506 | static void yy_accept(yyParser*); /* Forward Declaration */ | 162959 | static void yy_accept(yyParser*); /* Forward Declaration */ |
| @@ -161552,16 +163005,16 @@ static YYACTIONTYPE yy_reduce( | |||
| 161552 | { sqlite3FinishCoding(pParse); } | 163005 | { sqlite3FinishCoding(pParse); } |
| 161553 | break; | 163006 | break; |
| 161554 | case 3: /* cmd ::= BEGIN transtype trans_opt */ | 163007 | case 3: /* cmd ::= BEGIN transtype trans_opt */ |
| 161555 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy376);} | 163008 | {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy64);} |
| 161556 | break; | 163009 | break; |
| 161557 | case 4: /* transtype ::= */ | 163010 | case 4: /* transtype ::= */ |
| 161558 | {yymsp[1].minor.yy376 = TK_DEFERRED;} | 163011 | {yymsp[1].minor.yy64 = TK_DEFERRED;} |
| 161559 | break; | 163012 | break; |
| 161560 | case 5: /* transtype ::= DEFERRED */ | 163013 | case 5: /* transtype ::= DEFERRED */ |
| 161561 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); | 163014 | case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6); |
| 161562 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); | 163015 | case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7); |
| 161563 | case 318: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==318); | 163016 | case 320: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==320); |
| 161564 | {yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/} | 163017 | {yymsp[0].minor.yy64 = yymsp[0].major; /*A-overwrites-X*/} |
| 161565 | break; | 163018 | break; |
| 161566 | case 8: /* cmd ::= COMMIT|END trans_opt */ | 163019 | case 8: /* cmd ::= COMMIT|END trans_opt */ |
| 161567 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); | 163020 | case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9); |
| @@ -161584,7 +163037,7 @@ static YYACTIONTYPE yy_reduce( | |||
| 161584 | break; | 163037 | break; |
| 161585 | case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ | 163038 | case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */ |
| 161586 | { | 163039 | { |
| 161587 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy376,0,0,yymsp[-2].minor.yy376); | 163040 | sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy64,0,0,yymsp[-2].minor.yy64); |
| 161588 | } | 163041 | } |
| 161589 | break; | 163042 | break; |
| 161590 | case 14: /* createkw ::= CREATE */ | 163043 | case 14: /* createkw ::= CREATE */ |
| @@ -161592,95 +163045,112 @@ static YYACTIONTYPE yy_reduce( | |||
| 161592 | break; | 163045 | break; |
| 161593 | case 15: /* ifnotexists ::= */ | 163046 | case 15: /* ifnotexists ::= */ |
| 161594 | case 18: /* temp ::= */ yytestcase(yyruleno==18); | 163047 | case 18: /* temp ::= */ yytestcase(yyruleno==18); |
| 161595 | case 21: /* table_options ::= */ yytestcase(yyruleno==21); | 163048 | case 47: /* autoinc ::= */ yytestcase(yyruleno==47); |
| 161596 | case 45: /* autoinc ::= */ yytestcase(yyruleno==45); | 163049 | case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62); |
| 161597 | case 60: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==60); | 163050 | case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72); |
| 161598 | case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70); | 163051 | case 81: /* ifexists ::= */ yytestcase(yyruleno==81); |
| 161599 | case 79: /* ifexists ::= */ yytestcase(yyruleno==79); | 163052 | case 98: /* distinct ::= */ yytestcase(yyruleno==98); |
| 161600 | case 96: /* distinct ::= */ yytestcase(yyruleno==96); | 163053 | case 241: /* collate ::= */ yytestcase(yyruleno==241); |
| 161601 | case 239: /* collate ::= */ yytestcase(yyruleno==239); | 163054 | {yymsp[1].minor.yy64 = 0;} |
| 161602 | {yymsp[1].minor.yy376 = 0;} | ||
| 161603 | break; | 163055 | break; |
| 161604 | case 16: /* ifnotexists ::= IF NOT EXISTS */ | 163056 | case 16: /* ifnotexists ::= IF NOT EXISTS */ |
| 161605 | {yymsp[-2].minor.yy376 = 1;} | 163057 | {yymsp[-2].minor.yy64 = 1;} |
| 161606 | break; | 163058 | break; |
| 161607 | case 17: /* temp ::= TEMP */ | 163059 | case 17: /* temp ::= TEMP */ |
| 161608 | {yymsp[0].minor.yy376 = pParse->db->init.busy==0;} | 163060 | {yymsp[0].minor.yy64 = pParse->db->init.busy==0;} |
| 161609 | break; | 163061 | break; |
| 161610 | case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */ | 163062 | case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */ |
| 161611 | { | 163063 | { |
| 161612 | sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy376,0); | 163064 | sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy51,0); |
| 161613 | } | 163065 | } |
| 161614 | break; | 163066 | break; |
| 161615 | case 20: /* create_table_args ::= AS select */ | 163067 | case 20: /* create_table_args ::= AS select */ |
| 161616 | { | 163068 | { |
| 161617 | sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy81); | 163069 | sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy303); |
| 161618 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81); | 163070 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy303); |
| 161619 | } | 163071 | } |
| 161620 | break; | 163072 | break; |
| 161621 | case 22: /* table_options ::= WITHOUT nm */ | 163073 | case 21: /* table_option_set ::= */ |
| 163074 | {yymsp[1].minor.yy51 = 0;} | ||
| 163075 | break; | ||
| 163076 | case 22: /* table_option_set ::= table_option_set COMMA table_option */ | ||
| 163077 | {yylhsminor.yy51 = yymsp[-2].minor.yy51|yymsp[0].minor.yy51;} | ||
| 163078 | yymsp[-2].minor.yy51 = yylhsminor.yy51; | ||
| 163079 | break; | ||
| 163080 | case 23: /* table_option ::= WITHOUT nm */ | ||
| 161622 | { | 163081 | { |
| 161623 | if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ | 163082 | if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){ |
| 161624 | yymsp[-1].minor.yy376 = TF_WithoutRowid | TF_NoVisibleRowid; | 163083 | yymsp[-1].minor.yy51 = TF_WithoutRowid | TF_NoVisibleRowid; |
| 161625 | }else{ | 163084 | }else{ |
| 161626 | yymsp[-1].minor.yy376 = 0; | 163085 | yymsp[-1].minor.yy51 = 0; |
| 161627 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); | 163086 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); |
| 161628 | } | 163087 | } |
| 161629 | } | 163088 | } |
| 161630 | break; | 163089 | break; |
| 161631 | case 23: /* columnname ::= nm typetoken */ | 163090 | case 24: /* table_option ::= nm */ |
| 161632 | {sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} | 163091 | { |
| 163092 | if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){ | ||
| 163093 | yylhsminor.yy51 = TF_Strict; | ||
| 163094 | }else{ | ||
| 163095 | yylhsminor.yy51 = 0; | ||
| 163096 | sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z); | ||
| 163097 | } | ||
| 163098 | } | ||
| 163099 | yymsp[0].minor.yy51 = yylhsminor.yy51; | ||
| 163100 | break; | ||
| 163101 | case 25: /* columnname ::= nm typetoken */ | ||
| 163102 | {sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);} | ||
| 161633 | break; | 163103 | break; |
| 161634 | case 24: /* typetoken ::= */ | 163104 | case 26: /* typetoken ::= */ |
| 161635 | case 63: /* conslist_opt ::= */ yytestcase(yyruleno==63); | 163105 | case 65: /* conslist_opt ::= */ yytestcase(yyruleno==65); |
| 161636 | case 102: /* as ::= */ yytestcase(yyruleno==102); | 163106 | case 104: /* as ::= */ yytestcase(yyruleno==104); |
| 161637 | {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;} | 163107 | {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;} |
| 161638 | break; | 163108 | break; |
| 161639 | case 25: /* typetoken ::= typename LP signed RP */ | 163109 | case 27: /* typetoken ::= typename LP signed RP */ |
| 161640 | { | 163110 | { |
| 161641 | yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z); | 163111 | yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z); |
| 161642 | } | 163112 | } |
| 161643 | break; | 163113 | break; |
| 161644 | case 26: /* typetoken ::= typename LP signed COMMA signed RP */ | 163114 | case 28: /* typetoken ::= typename LP signed COMMA signed RP */ |
| 161645 | { | 163115 | { |
| 161646 | yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z); | 163116 | yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z); |
| 161647 | } | 163117 | } |
| 161648 | break; | 163118 | break; |
| 161649 | case 27: /* typename ::= typename ID|STRING */ | 163119 | case 29: /* typename ::= typename ID|STRING */ |
| 161650 | {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} | 163120 | {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);} |
| 161651 | break; | 163121 | break; |
| 161652 | case 28: /* scanpt ::= */ | 163122 | case 30: /* scanpt ::= */ |
| 161653 | { | 163123 | { |
| 161654 | assert( yyLookahead!=YYNOCODE ); | 163124 | assert( yyLookahead!=YYNOCODE ); |
| 161655 | yymsp[1].minor.yy504 = yyLookaheadToken.z; | 163125 | yymsp[1].minor.yy600 = yyLookaheadToken.z; |
| 161656 | } | 163126 | } |
| 161657 | break; | 163127 | break; |
| 161658 | case 29: /* scantok ::= */ | 163128 | case 31: /* scantok ::= */ |
| 161659 | { | 163129 | { |
| 161660 | assert( yyLookahead!=YYNOCODE ); | 163130 | assert( yyLookahead!=YYNOCODE ); |
| 161661 | yymsp[1].minor.yy0 = yyLookaheadToken; | 163131 | yymsp[1].minor.yy0 = yyLookaheadToken; |
| 161662 | } | 163132 | } |
| 161663 | break; | 163133 | break; |
| 161664 | case 30: /* ccons ::= CONSTRAINT nm */ | 163134 | case 32: /* ccons ::= CONSTRAINT nm */ |
| 161665 | case 65: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==65); | 163135 | case 67: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==67); |
| 161666 | {pParse->constraintName = yymsp[0].minor.yy0;} | 163136 | {pParse->constraintName = yymsp[0].minor.yy0;} |
| 161667 | break; | 163137 | break; |
| 161668 | case 31: /* ccons ::= DEFAULT scantok term */ | 163138 | case 33: /* ccons ::= DEFAULT scantok term */ |
| 161669 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} | 163139 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy626,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 161670 | break; | 163140 | break; |
| 161671 | case 32: /* ccons ::= DEFAULT LP expr RP */ | 163141 | case 34: /* ccons ::= DEFAULT LP expr RP */ |
| 161672 | {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} | 163142 | {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy626,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);} |
| 161673 | break; | 163143 | break; |
| 161674 | case 33: /* ccons ::= DEFAULT PLUS scantok term */ | 163144 | case 35: /* ccons ::= DEFAULT PLUS scantok term */ |
| 161675 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy404,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} | 163145 | {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy626,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);} |
| 161676 | break; | 163146 | break; |
| 161677 | case 34: /* ccons ::= DEFAULT MINUS scantok term */ | 163147 | case 36: /* ccons ::= DEFAULT MINUS scantok term */ |
| 161678 | { | 163148 | { |
| 161679 | Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy404, 0); | 163149 | Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy626, 0); |
| 161680 | sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]); | 163150 | sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]); |
| 161681 | } | 163151 | } |
| 161682 | break; | 163152 | break; |
| 161683 | case 35: /* ccons ::= DEFAULT scantok ID|INDEXED */ | 163153 | case 37: /* ccons ::= DEFAULT scantok ID|INDEXED */ |
| 161684 | { | 163154 | { |
| 161685 | Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0); | 163155 | Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0); |
| 161686 | if( p ){ | 163156 | if( p ){ |
| @@ -161690,162 +163160,162 @@ static YYACTIONTYPE yy_reduce( | |||
| 161690 | sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n); | 163160 | sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n); |
| 161691 | } | 163161 | } |
| 161692 | break; | 163162 | break; |
| 161693 | case 36: /* ccons ::= NOT NULL onconf */ | 163163 | case 38: /* ccons ::= NOT NULL onconf */ |
| 161694 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy376);} | 163164 | {sqlite3AddNotNull(pParse, yymsp[0].minor.yy64);} |
| 161695 | break; | 163165 | break; |
| 161696 | case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ | 163166 | case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */ |
| 161697 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy376,yymsp[0].minor.yy376,yymsp[-2].minor.yy376);} | 163167 | {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy64,yymsp[0].minor.yy64,yymsp[-2].minor.yy64);} |
| 161698 | break; | 163168 | break; |
| 161699 | case 38: /* ccons ::= UNIQUE onconf */ | 163169 | case 40: /* ccons ::= UNIQUE onconf */ |
| 161700 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy376,0,0,0,0, | 163170 | {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy64,0,0,0,0, |
| 161701 | SQLITE_IDXTYPE_UNIQUE);} | 163171 | SQLITE_IDXTYPE_UNIQUE);} |
| 161702 | break; | 163172 | break; |
| 161703 | case 39: /* ccons ::= CHECK LP expr RP */ | 163173 | case 41: /* ccons ::= CHECK LP expr RP */ |
| 161704 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy404,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);} | 163174 | {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy626,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);} |
| 161705 | break; | 163175 | break; |
| 161706 | case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */ | 163176 | case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */ |
| 161707 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy70,yymsp[0].minor.yy376);} | 163177 | {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy562,yymsp[0].minor.yy64);} |
| 161708 | break; | 163178 | break; |
| 161709 | case 41: /* ccons ::= defer_subclause */ | 163179 | case 43: /* ccons ::= defer_subclause */ |
| 161710 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy376);} | 163180 | {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy64);} |
| 161711 | break; | 163181 | break; |
| 161712 | case 42: /* ccons ::= COLLATE ID|STRING */ | 163182 | case 44: /* ccons ::= COLLATE ID|STRING */ |
| 161713 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} | 163183 | {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);} |
| 161714 | break; | 163184 | break; |
| 161715 | case 43: /* generated ::= LP expr RP */ | 163185 | case 45: /* generated ::= LP expr RP */ |
| 161716 | {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy404,0);} | 163186 | {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy626,0);} |
| 161717 | break; | 163187 | break; |
| 161718 | case 44: /* generated ::= LP expr RP ID */ | 163188 | case 46: /* generated ::= LP expr RP ID */ |
| 161719 | {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy404,&yymsp[0].minor.yy0);} | 163189 | {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy626,&yymsp[0].minor.yy0);} |
| 161720 | break; | 163190 | break; |
| 161721 | case 46: /* autoinc ::= AUTOINCR */ | 163191 | case 48: /* autoinc ::= AUTOINCR */ |
| 161722 | {yymsp[0].minor.yy376 = 1;} | 163192 | {yymsp[0].minor.yy64 = 1;} |
| 161723 | break; | 163193 | break; |
| 161724 | case 47: /* refargs ::= */ | 163194 | case 49: /* refargs ::= */ |
| 161725 | { yymsp[1].minor.yy376 = OE_None*0x0101; /* EV: R-19803-45884 */} | 163195 | { yymsp[1].minor.yy64 = OE_None*0x0101; /* EV: R-19803-45884 */} |
| 161726 | break; | 163196 | break; |
| 161727 | case 48: /* refargs ::= refargs refarg */ | 163197 | case 50: /* refargs ::= refargs refarg */ |
| 161728 | { yymsp[-1].minor.yy376 = (yymsp[-1].minor.yy376 & ~yymsp[0].minor.yy139.mask) | yymsp[0].minor.yy139.value; } | 163198 | { yymsp[-1].minor.yy64 = (yymsp[-1].minor.yy64 & ~yymsp[0].minor.yy83.mask) | yymsp[0].minor.yy83.value; } |
| 161729 | break; | 163199 | break; |
| 161730 | case 49: /* refarg ::= MATCH nm */ | 163200 | case 51: /* refarg ::= MATCH nm */ |
| 161731 | { yymsp[-1].minor.yy139.value = 0; yymsp[-1].minor.yy139.mask = 0x000000; } | 163201 | { yymsp[-1].minor.yy83.value = 0; yymsp[-1].minor.yy83.mask = 0x000000; } |
| 161732 | break; | 163202 | break; |
| 161733 | case 50: /* refarg ::= ON INSERT refact */ | 163203 | case 52: /* refarg ::= ON INSERT refact */ |
| 161734 | { yymsp[-2].minor.yy139.value = 0; yymsp[-2].minor.yy139.mask = 0x000000; } | 163204 | { yymsp[-2].minor.yy83.value = 0; yymsp[-2].minor.yy83.mask = 0x000000; } |
| 161735 | break; | 163205 | break; |
| 161736 | case 51: /* refarg ::= ON DELETE refact */ | 163206 | case 53: /* refarg ::= ON DELETE refact */ |
| 161737 | { yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376; yymsp[-2].minor.yy139.mask = 0x0000ff; } | 163207 | { yymsp[-2].minor.yy83.value = yymsp[0].minor.yy64; yymsp[-2].minor.yy83.mask = 0x0000ff; } |
| 161738 | break; | 163208 | break; |
| 161739 | case 52: /* refarg ::= ON UPDATE refact */ | 163209 | case 54: /* refarg ::= ON UPDATE refact */ |
| 161740 | { yymsp[-2].minor.yy139.value = yymsp[0].minor.yy376<<8; yymsp[-2].minor.yy139.mask = 0x00ff00; } | 163210 | { yymsp[-2].minor.yy83.value = yymsp[0].minor.yy64<<8; yymsp[-2].minor.yy83.mask = 0x00ff00; } |
| 161741 | break; | 163211 | break; |
| 161742 | case 53: /* refact ::= SET NULL */ | 163212 | case 55: /* refact ::= SET NULL */ |
| 161743 | { yymsp[-1].minor.yy376 = OE_SetNull; /* EV: R-33326-45252 */} | 163213 | { yymsp[-1].minor.yy64 = OE_SetNull; /* EV: R-33326-45252 */} |
| 161744 | break; | 163214 | break; |
| 161745 | case 54: /* refact ::= SET DEFAULT */ | 163215 | case 56: /* refact ::= SET DEFAULT */ |
| 161746 | { yymsp[-1].minor.yy376 = OE_SetDflt; /* EV: R-33326-45252 */} | 163216 | { yymsp[-1].minor.yy64 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 161747 | break; | 163217 | break; |
| 161748 | case 55: /* refact ::= CASCADE */ | 163218 | case 57: /* refact ::= CASCADE */ |
| 161749 | { yymsp[0].minor.yy376 = OE_Cascade; /* EV: R-33326-45252 */} | 163219 | { yymsp[0].minor.yy64 = OE_Cascade; /* EV: R-33326-45252 */} |
| 161750 | break; | 163220 | break; |
| 161751 | case 56: /* refact ::= RESTRICT */ | 163221 | case 58: /* refact ::= RESTRICT */ |
| 161752 | { yymsp[0].minor.yy376 = OE_Restrict; /* EV: R-33326-45252 */} | 163222 | { yymsp[0].minor.yy64 = OE_Restrict; /* EV: R-33326-45252 */} |
| 161753 | break; | 163223 | break; |
| 161754 | case 57: /* refact ::= NO ACTION */ | 163224 | case 59: /* refact ::= NO ACTION */ |
| 161755 | { yymsp[-1].minor.yy376 = OE_None; /* EV: R-33326-45252 */} | 163225 | { yymsp[-1].minor.yy64 = OE_None; /* EV: R-33326-45252 */} |
| 161756 | break; | 163226 | break; |
| 161757 | case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ | 163227 | case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ |
| 161758 | {yymsp[-2].minor.yy376 = 0;} | 163228 | {yymsp[-2].minor.yy64 = 0;} |
| 161759 | break; | 163229 | break; |
| 161760 | case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ | 163230 | case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */ |
| 161761 | case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74); | 163231 | case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76); |
| 161762 | case 169: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==169); | 163232 | case 171: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==171); |
| 161763 | {yymsp[-1].minor.yy376 = yymsp[0].minor.yy376;} | 163233 | {yymsp[-1].minor.yy64 = yymsp[0].minor.yy64;} |
| 161764 | break; | 163234 | break; |
| 161765 | case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ | 163235 | case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ |
| 161766 | case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78); | 163236 | case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80); |
| 161767 | case 211: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==211); | 163237 | case 213: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==213); |
| 161768 | case 214: /* in_op ::= NOT IN */ yytestcase(yyruleno==214); | 163238 | case 216: /* in_op ::= NOT IN */ yytestcase(yyruleno==216); |
| 161769 | case 240: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==240); | 163239 | case 242: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==242); |
| 161770 | {yymsp[-1].minor.yy376 = 1;} | 163240 | {yymsp[-1].minor.yy64 = 1;} |
| 161771 | break; | 163241 | break; |
| 161772 | case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ | 163242 | case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ |
| 161773 | {yymsp[-1].minor.yy376 = 0;} | 163243 | {yymsp[-1].minor.yy64 = 0;} |
| 161774 | break; | 163244 | break; |
| 161775 | case 64: /* tconscomma ::= COMMA */ | 163245 | case 66: /* tconscomma ::= COMMA */ |
| 161776 | {pParse->constraintName.n = 0;} | 163246 | {pParse->constraintName.n = 0;} |
| 161777 | break; | 163247 | break; |
| 161778 | case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ | 163248 | case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */ |
| 161779 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy70,yymsp[0].minor.yy376,yymsp[-2].minor.yy376,0);} | 163249 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy562,yymsp[0].minor.yy64,yymsp[-2].minor.yy64,0);} |
| 161780 | break; | 163250 | break; |
| 161781 | case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */ | 163251 | case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */ |
| 161782 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy70,yymsp[0].minor.yy376,0,0,0,0, | 163252 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy562,yymsp[0].minor.yy64,0,0,0,0, |
| 161783 | SQLITE_IDXTYPE_UNIQUE);} | 163253 | SQLITE_IDXTYPE_UNIQUE);} |
| 161784 | break; | 163254 | break; |
| 161785 | case 68: /* tcons ::= CHECK LP expr RP onconf */ | 163255 | case 70: /* tcons ::= CHECK LP expr RP onconf */ |
| 161786 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy404,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);} | 163256 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy626,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);} |
| 161787 | break; | 163257 | break; |
| 161788 | case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ | 163258 | case 71: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */ |
| 161789 | { | 163259 | { |
| 161790 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy70, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy70, yymsp[-1].minor.yy376); | 163260 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy562, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy562, yymsp[-1].minor.yy64); |
| 161791 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy376); | 163261 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy64); |
| 161792 | } | 163262 | } |
| 161793 | break; | 163263 | break; |
| 161794 | case 71: /* onconf ::= */ | 163264 | case 73: /* onconf ::= */ |
| 161795 | case 73: /* orconf ::= */ yytestcase(yyruleno==73); | 163265 | case 75: /* orconf ::= */ yytestcase(yyruleno==75); |
| 161796 | {yymsp[1].minor.yy376 = OE_Default;} | 163266 | {yymsp[1].minor.yy64 = OE_Default;} |
| 161797 | break; | 163267 | break; |
| 161798 | case 72: /* onconf ::= ON CONFLICT resolvetype */ | 163268 | case 74: /* onconf ::= ON CONFLICT resolvetype */ |
| 161799 | {yymsp[-2].minor.yy376 = yymsp[0].minor.yy376;} | 163269 | {yymsp[-2].minor.yy64 = yymsp[0].minor.yy64;} |
| 161800 | break; | 163270 | break; |
| 161801 | case 75: /* resolvetype ::= IGNORE */ | 163271 | case 77: /* resolvetype ::= IGNORE */ |
| 161802 | {yymsp[0].minor.yy376 = OE_Ignore;} | 163272 | {yymsp[0].minor.yy64 = OE_Ignore;} |
| 161803 | break; | 163273 | break; |
| 161804 | case 76: /* resolvetype ::= REPLACE */ | 163274 | case 78: /* resolvetype ::= REPLACE */ |
| 161805 | case 170: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==170); | 163275 | case 172: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==172); |
| 161806 | {yymsp[0].minor.yy376 = OE_Replace;} | 163276 | {yymsp[0].minor.yy64 = OE_Replace;} |
| 161807 | break; | 163277 | break; |
| 161808 | case 77: /* cmd ::= DROP TABLE ifexists fullname */ | 163278 | case 79: /* cmd ::= DROP TABLE ifexists fullname */ |
| 161809 | { | 163279 | { |
| 161810 | sqlite3DropTable(pParse, yymsp[0].minor.yy153, 0, yymsp[-1].minor.yy376); | 163280 | sqlite3DropTable(pParse, yymsp[0].minor.yy607, 0, yymsp[-1].minor.yy64); |
| 161811 | } | 163281 | } |
| 161812 | break; | 163282 | break; |
| 161813 | case 80: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ | 163283 | case 82: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */ |
| 161814 | { | 163284 | { |
| 161815 | sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy70, yymsp[0].minor.yy81, yymsp[-7].minor.yy376, yymsp[-5].minor.yy376); | 163285 | sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy562, yymsp[0].minor.yy303, yymsp[-7].minor.yy64, yymsp[-5].minor.yy64); |
| 161816 | } | 163286 | } |
| 161817 | break; | 163287 | break; |
| 161818 | case 81: /* cmd ::= DROP VIEW ifexists fullname */ | 163288 | case 83: /* cmd ::= DROP VIEW ifexists fullname */ |
| 161819 | { | 163289 | { |
| 161820 | sqlite3DropTable(pParse, yymsp[0].minor.yy153, 1, yymsp[-1].minor.yy376); | 163290 | sqlite3DropTable(pParse, yymsp[0].minor.yy607, 1, yymsp[-1].minor.yy64); |
| 161821 | } | 163291 | } |
| 161822 | break; | 163292 | break; |
| 161823 | case 82: /* cmd ::= select */ | 163293 | case 84: /* cmd ::= select */ |
| 161824 | { | 163294 | { |
| 161825 | SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0}; | 163295 | SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0}; |
| 161826 | sqlite3Select(pParse, yymsp[0].minor.yy81, &dest); | 163296 | sqlite3Select(pParse, yymsp[0].minor.yy303, &dest); |
| 161827 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy81); | 163297 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy303); |
| 161828 | } | 163298 | } |
| 161829 | break; | 163299 | break; |
| 161830 | case 83: /* select ::= WITH wqlist selectnowith */ | 163300 | case 85: /* select ::= WITH wqlist selectnowith */ |
| 161831 | {yymsp[-2].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);} | 163301 | {yymsp[-2].minor.yy303 = attachWithToSelect(pParse,yymsp[0].minor.yy303,yymsp[-1].minor.yy43);} |
| 161832 | break; | 163302 | break; |
| 161833 | case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */ | 163303 | case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */ |
| 161834 | {yymsp[-3].minor.yy81 = attachWithToSelect(pParse,yymsp[0].minor.yy81,yymsp[-1].minor.yy103);} | 163304 | {yymsp[-3].minor.yy303 = attachWithToSelect(pParse,yymsp[0].minor.yy303,yymsp[-1].minor.yy43);} |
| 161835 | break; | 163305 | break; |
| 161836 | case 85: /* select ::= selectnowith */ | 163306 | case 87: /* select ::= selectnowith */ |
| 161837 | { | 163307 | { |
| 161838 | Select *p = yymsp[0].minor.yy81; | 163308 | Select *p = yymsp[0].minor.yy303; |
| 161839 | if( p ){ | 163309 | if( p ){ |
| 161840 | parserDoubleLinkSelect(pParse, p); | 163310 | parserDoubleLinkSelect(pParse, p); |
| 161841 | } | 163311 | } |
| 161842 | yymsp[0].minor.yy81 = p; /*A-overwrites-X*/ | 163312 | yymsp[0].minor.yy303 = p; /*A-overwrites-X*/ |
| 161843 | } | 163313 | } |
| 161844 | break; | 163314 | break; |
| 161845 | case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */ | 163315 | case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */ |
| 161846 | { | 163316 | { |
| 161847 | Select *pRhs = yymsp[0].minor.yy81; | 163317 | Select *pRhs = yymsp[0].minor.yy303; |
| 161848 | Select *pLhs = yymsp[-2].minor.yy81; | 163318 | Select *pLhs = yymsp[-2].minor.yy303; |
| 161849 | if( pRhs && pRhs->pPrior ){ | 163319 | if( pRhs && pRhs->pPrior ){ |
| 161850 | SrcList *pFrom; | 163320 | SrcList *pFrom; |
| 161851 | Token x; | 163321 | Token x; |
| @@ -161855,140 +163325,140 @@ static YYACTIONTYPE yy_reduce( | |||
| 161855 | pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); | 163325 | pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0); |
| 161856 | } | 163326 | } |
| 161857 | if( pRhs ){ | 163327 | if( pRhs ){ |
| 161858 | pRhs->op = (u8)yymsp[-1].minor.yy376; | 163328 | pRhs->op = (u8)yymsp[-1].minor.yy64; |
| 161859 | pRhs->pPrior = pLhs; | 163329 | pRhs->pPrior = pLhs; |
| 161860 | if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; | 163330 | if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue; |
| 161861 | pRhs->selFlags &= ~SF_MultiValue; | 163331 | pRhs->selFlags &= ~SF_MultiValue; |
| 161862 | if( yymsp[-1].minor.yy376!=TK_ALL ) pParse->hasCompound = 1; | 163332 | if( yymsp[-1].minor.yy64!=TK_ALL ) pParse->hasCompound = 1; |
| 161863 | }else{ | 163333 | }else{ |
| 161864 | sqlite3SelectDelete(pParse->db, pLhs); | 163334 | sqlite3SelectDelete(pParse->db, pLhs); |
| 161865 | } | 163335 | } |
| 161866 | yymsp[-2].minor.yy81 = pRhs; | 163336 | yymsp[-2].minor.yy303 = pRhs; |
| 161867 | } | 163337 | } |
| 161868 | break; | 163338 | break; |
| 161869 | case 87: /* multiselect_op ::= UNION */ | 163339 | case 89: /* multiselect_op ::= UNION */ |
| 161870 | case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89); | 163340 | case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91); |
| 161871 | {yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-OP*/} | 163341 | {yymsp[0].minor.yy64 = yymsp[0].major; /*A-overwrites-OP*/} |
| 161872 | break; | 163342 | break; |
| 161873 | case 88: /* multiselect_op ::= UNION ALL */ | 163343 | case 90: /* multiselect_op ::= UNION ALL */ |
| 161874 | {yymsp[-1].minor.yy376 = TK_ALL;} | 163344 | {yymsp[-1].minor.yy64 = TK_ALL;} |
| 161875 | break; | 163345 | break; |
| 161876 | case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ | 163346 | case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */ |
| 161877 | { | 163347 | { |
| 161878 | yymsp[-8].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy70,yymsp[-5].minor.yy153,yymsp[-4].minor.yy404,yymsp[-3].minor.yy70,yymsp[-2].minor.yy404,yymsp[-1].minor.yy70,yymsp[-7].minor.yy376,yymsp[0].minor.yy404); | 163348 | yymsp[-8].minor.yy303 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy562,yymsp[-5].minor.yy607,yymsp[-4].minor.yy626,yymsp[-3].minor.yy562,yymsp[-2].minor.yy626,yymsp[-1].minor.yy562,yymsp[-7].minor.yy64,yymsp[0].minor.yy626); |
| 161879 | } | 163349 | } |
| 161880 | break; | 163350 | break; |
| 161881 | case 91: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ | 163351 | case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */ |
| 161882 | { | 163352 | { |
| 161883 | yymsp[-9].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy70,yymsp[-6].minor.yy153,yymsp[-5].minor.yy404,yymsp[-4].minor.yy70,yymsp[-3].minor.yy404,yymsp[-1].minor.yy70,yymsp[-8].minor.yy376,yymsp[0].minor.yy404); | 163353 | yymsp[-9].minor.yy303 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy562,yymsp[-6].minor.yy607,yymsp[-5].minor.yy626,yymsp[-4].minor.yy562,yymsp[-3].minor.yy626,yymsp[-1].minor.yy562,yymsp[-8].minor.yy64,yymsp[0].minor.yy626); |
| 161884 | if( yymsp[-9].minor.yy81 ){ | 163354 | if( yymsp[-9].minor.yy303 ){ |
| 161885 | yymsp[-9].minor.yy81->pWinDefn = yymsp[-2].minor.yy49; | 163355 | yymsp[-9].minor.yy303->pWinDefn = yymsp[-2].minor.yy375; |
| 161886 | }else{ | 163356 | }else{ |
| 161887 | sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy49); | 163357 | sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy375); |
| 161888 | } | 163358 | } |
| 161889 | } | 163359 | } |
| 161890 | break; | 163360 | break; |
| 161891 | case 92: /* values ::= VALUES LP nexprlist RP */ | 163361 | case 94: /* values ::= VALUES LP nexprlist RP */ |
| 161892 | { | 163362 | { |
| 161893 | yymsp[-3].minor.yy81 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values,0); | 163363 | yymsp[-3].minor.yy303 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy562,0,0,0,0,0,SF_Values,0); |
| 161894 | } | 163364 | } |
| 161895 | break; | 163365 | break; |
| 161896 | case 93: /* values ::= values COMMA LP nexprlist RP */ | 163366 | case 95: /* values ::= values COMMA LP nexprlist RP */ |
| 161897 | { | 163367 | { |
| 161898 | Select *pRight, *pLeft = yymsp[-4].minor.yy81; | 163368 | Select *pRight, *pLeft = yymsp[-4].minor.yy303; |
| 161899 | pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy70,0,0,0,0,0,SF_Values|SF_MultiValue,0); | 163369 | pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy562,0,0,0,0,0,SF_Values|SF_MultiValue,0); |
| 161900 | if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; | 163370 | if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue; |
| 161901 | if( pRight ){ | 163371 | if( pRight ){ |
| 161902 | pRight->op = TK_ALL; | 163372 | pRight->op = TK_ALL; |
| 161903 | pRight->pPrior = pLeft; | 163373 | pRight->pPrior = pLeft; |
| 161904 | yymsp[-4].minor.yy81 = pRight; | 163374 | yymsp[-4].minor.yy303 = pRight; |
| 161905 | }else{ | 163375 | }else{ |
| 161906 | yymsp[-4].minor.yy81 = pLeft; | 163376 | yymsp[-4].minor.yy303 = pLeft; |
| 161907 | } | 163377 | } |
| 161908 | } | 163378 | } |
| 161909 | break; | 163379 | break; |
| 161910 | case 94: /* distinct ::= DISTINCT */ | 163380 | case 96: /* distinct ::= DISTINCT */ |
| 161911 | {yymsp[0].minor.yy376 = SF_Distinct;} | 163381 | {yymsp[0].minor.yy64 = SF_Distinct;} |
| 161912 | break; | 163382 | break; |
| 161913 | case 95: /* distinct ::= ALL */ | 163383 | case 97: /* distinct ::= ALL */ |
| 161914 | {yymsp[0].minor.yy376 = SF_All;} | 163384 | {yymsp[0].minor.yy64 = SF_All;} |
| 161915 | break; | 163385 | break; |
| 161916 | case 97: /* sclp ::= */ | 163386 | case 99: /* sclp ::= */ |
| 161917 | case 130: /* orderby_opt ::= */ yytestcase(yyruleno==130); | 163387 | case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132); |
| 161918 | case 140: /* groupby_opt ::= */ yytestcase(yyruleno==140); | 163388 | case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142); |
| 161919 | case 227: /* exprlist ::= */ yytestcase(yyruleno==227); | 163389 | case 229: /* exprlist ::= */ yytestcase(yyruleno==229); |
| 161920 | case 230: /* paren_exprlist ::= */ yytestcase(yyruleno==230); | 163390 | case 232: /* paren_exprlist ::= */ yytestcase(yyruleno==232); |
| 161921 | case 235: /* eidlist_opt ::= */ yytestcase(yyruleno==235); | 163391 | case 237: /* eidlist_opt ::= */ yytestcase(yyruleno==237); |
| 161922 | {yymsp[1].minor.yy70 = 0;} | 163392 | {yymsp[1].minor.yy562 = 0;} |
| 161923 | break; | 163393 | break; |
| 161924 | case 98: /* selcollist ::= sclp scanpt expr scanpt as */ | 163394 | case 100: /* selcollist ::= sclp scanpt expr scanpt as */ |
| 161925 | { | 163395 | { |
| 161926 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[-2].minor.yy404); | 163396 | yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy562, yymsp[-2].minor.yy626); |
| 161927 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[0].minor.yy0, 1); | 163397 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy562, &yymsp[0].minor.yy0, 1); |
| 161928 | sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy70,yymsp[-3].minor.yy504,yymsp[-1].minor.yy504); | 163398 | sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy562,yymsp[-3].minor.yy600,yymsp[-1].minor.yy600); |
| 161929 | } | 163399 | } |
| 161930 | break; | 163400 | break; |
| 161931 | case 99: /* selcollist ::= sclp scanpt STAR */ | 163401 | case 101: /* selcollist ::= sclp scanpt STAR */ |
| 161932 | { | 163402 | { |
| 161933 | Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); | 163403 | Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0); |
| 161934 | yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy70, p); | 163404 | yymsp[-2].minor.yy562 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy562, p); |
| 161935 | } | 163405 | } |
| 161936 | break; | 163406 | break; |
| 161937 | case 100: /* selcollist ::= sclp scanpt nm DOT STAR */ | 163407 | case 102: /* selcollist ::= sclp scanpt nm DOT STAR */ |
| 161938 | { | 163408 | { |
| 161939 | Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); | 163409 | Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0); |
| 161940 | Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); | 163410 | Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| 161941 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); | 163411 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight); |
| 161942 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, pDot); | 163412 | yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy562, pDot); |
| 161943 | } | 163413 | } |
| 161944 | break; | 163414 | break; |
| 161945 | case 101: /* as ::= AS nm */ | 163415 | case 103: /* as ::= AS nm */ |
| 161946 | case 112: /* dbnm ::= DOT nm */ yytestcase(yyruleno==112); | 163416 | case 114: /* dbnm ::= DOT nm */ yytestcase(yyruleno==114); |
| 161947 | case 251: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==251); | 163417 | case 253: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==253); |
| 161948 | case 252: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==252); | 163418 | case 254: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==254); |
| 161949 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} | 163419 | {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} |
| 161950 | break; | 163420 | break; |
| 161951 | case 103: /* from ::= */ | 163421 | case 105: /* from ::= */ |
| 161952 | case 106: /* stl_prefix ::= */ yytestcase(yyruleno==106); | 163422 | case 108: /* stl_prefix ::= */ yytestcase(yyruleno==108); |
| 161953 | {yymsp[1].minor.yy153 = 0;} | 163423 | {yymsp[1].minor.yy607 = 0;} |
| 161954 | break; | 163424 | break; |
| 161955 | case 104: /* from ::= FROM seltablist */ | 163425 | case 106: /* from ::= FROM seltablist */ |
| 161956 | { | 163426 | { |
| 161957 | yymsp[-1].minor.yy153 = yymsp[0].minor.yy153; | 163427 | yymsp[-1].minor.yy607 = yymsp[0].minor.yy607; |
| 161958 | sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy153); | 163428 | sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy607); |
| 161959 | } | 163429 | } |
| 161960 | break; | 163430 | break; |
| 161961 | case 105: /* stl_prefix ::= seltablist joinop */ | 163431 | case 107: /* stl_prefix ::= seltablist joinop */ |
| 161962 | { | 163432 | { |
| 161963 | if( ALWAYS(yymsp[-1].minor.yy153 && yymsp[-1].minor.yy153->nSrc>0) ) yymsp[-1].minor.yy153->a[yymsp[-1].minor.yy153->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy376; | 163433 | if( ALWAYS(yymsp[-1].minor.yy607 && yymsp[-1].minor.yy607->nSrc>0) ) yymsp[-1].minor.yy607->a[yymsp[-1].minor.yy607->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy64; |
| 161964 | } | 163434 | } |
| 161965 | break; | 163435 | break; |
| 161966 | case 107: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ | 163436 | case 109: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */ |
| 161967 | { | 163437 | { |
| 161968 | yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); | 163438 | yymsp[-6].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy607,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy626,yymsp[0].minor.yy240); |
| 161969 | sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy153, &yymsp[-2].minor.yy0); | 163439 | sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy607, &yymsp[-2].minor.yy0); |
| 161970 | } | 163440 | } |
| 161971 | break; | 163441 | break; |
| 161972 | case 108: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ | 163442 | case 110: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */ |
| 161973 | { | 163443 | { |
| 161974 | yymsp[-8].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy153,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); | 163444 | yymsp[-8].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy607,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy626,yymsp[0].minor.yy240); |
| 161975 | sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy153, yymsp[-4].minor.yy70); | 163445 | sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy607, yymsp[-4].minor.yy562); |
| 161976 | } | 163446 | } |
| 161977 | break; | 163447 | break; |
| 161978 | case 109: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ | 163448 | case 111: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */ |
| 161979 | { | 163449 | { |
| 161980 | yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy81,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); | 163450 | yymsp[-6].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy607,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy303,yymsp[-1].minor.yy626,yymsp[0].minor.yy240); |
| 161981 | } | 163451 | } |
| 161982 | break; | 163452 | break; |
| 161983 | case 110: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ | 163453 | case 112: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */ |
| 161984 | { | 163454 | { |
| 161985 | if( yymsp[-6].minor.yy153==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy404==0 && yymsp[0].minor.yy436==0 ){ | 163455 | if( yymsp[-6].minor.yy607==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy626==0 && yymsp[0].minor.yy240==0 ){ |
| 161986 | yymsp[-6].minor.yy153 = yymsp[-4].minor.yy153; | 163456 | yymsp[-6].minor.yy607 = yymsp[-4].minor.yy607; |
| 161987 | }else if( yymsp[-4].minor.yy153->nSrc==1 ){ | 163457 | }else if( yymsp[-4].minor.yy607->nSrc==1 ){ |
| 161988 | yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); | 163458 | yymsp[-6].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy607,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy626,yymsp[0].minor.yy240); |
| 161989 | if( yymsp[-6].minor.yy153 ){ | 163459 | if( yymsp[-6].minor.yy607 ){ |
| 161990 | SrcItem *pNew = &yymsp[-6].minor.yy153->a[yymsp[-6].minor.yy153->nSrc-1]; | 163460 | SrcItem *pNew = &yymsp[-6].minor.yy607->a[yymsp[-6].minor.yy607->nSrc-1]; |
| 161991 | SrcItem *pOld = yymsp[-4].minor.yy153->a; | 163461 | SrcItem *pOld = yymsp[-4].minor.yy607->a; |
| 161992 | pNew->zName = pOld->zName; | 163462 | pNew->zName = pOld->zName; |
| 161993 | pNew->zDatabase = pOld->zDatabase; | 163463 | pNew->zDatabase = pOld->zDatabase; |
| 161994 | pNew->pSelect = pOld->pSelect; | 163464 | pNew->pSelect = pOld->pSelect; |
| @@ -162001,226 +163471,226 @@ static YYACTIONTYPE yy_reduce( | |||
| 162001 | pOld->zName = pOld->zDatabase = 0; | 163471 | pOld->zName = pOld->zDatabase = 0; |
| 162002 | pOld->pSelect = 0; | 163472 | pOld->pSelect = 0; |
| 162003 | } | 163473 | } |
| 162004 | sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy153); | 163474 | sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy607); |
| 162005 | }else{ | 163475 | }else{ |
| 162006 | Select *pSubquery; | 163476 | Select *pSubquery; |
| 162007 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy153); | 163477 | sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy607); |
| 162008 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy153,0,0,0,0,SF_NestedFrom,0); | 163478 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy607,0,0,0,0,SF_NestedFrom,0); |
| 162009 | yymsp[-6].minor.yy153 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy153,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy404,yymsp[0].minor.yy436); | 163479 | yymsp[-6].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy607,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy626,yymsp[0].minor.yy240); |
| 162010 | } | 163480 | } |
| 162011 | } | 163481 | } |
| 162012 | break; | 163482 | break; |
| 162013 | case 111: /* dbnm ::= */ | 163483 | case 113: /* dbnm ::= */ |
| 162014 | case 125: /* indexed_opt ::= */ yytestcase(yyruleno==125); | 163484 | case 127: /* indexed_opt ::= */ yytestcase(yyruleno==127); |
| 162015 | {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;} | 163485 | {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;} |
| 162016 | break; | 163486 | break; |
| 162017 | case 113: /* fullname ::= nm */ | 163487 | case 115: /* fullname ::= nm */ |
| 162018 | { | 163488 | { |
| 162019 | yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); | 163489 | yylhsminor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); |
| 162020 | if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0); | 163490 | if( IN_RENAME_OBJECT && yylhsminor.yy607 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy607->a[0].zName, &yymsp[0].minor.yy0); |
| 162021 | } | 163491 | } |
| 162022 | yymsp[0].minor.yy153 = yylhsminor.yy153; | 163492 | yymsp[0].minor.yy607 = yylhsminor.yy607; |
| 162023 | break; | 163493 | break; |
| 162024 | case 114: /* fullname ::= nm DOT nm */ | 163494 | case 116: /* fullname ::= nm DOT nm */ |
| 162025 | { | 163495 | { |
| 162026 | yylhsminor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); | 163496 | yylhsminor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 162027 | if( IN_RENAME_OBJECT && yylhsminor.yy153 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy153->a[0].zName, &yymsp[0].minor.yy0); | 163497 | if( IN_RENAME_OBJECT && yylhsminor.yy607 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy607->a[0].zName, &yymsp[0].minor.yy0); |
| 162028 | } | 163498 | } |
| 162029 | yymsp[-2].minor.yy153 = yylhsminor.yy153; | 163499 | yymsp[-2].minor.yy607 = yylhsminor.yy607; |
| 162030 | break; | 163500 | break; |
| 162031 | case 115: /* xfullname ::= nm */ | 163501 | case 117: /* xfullname ::= nm */ |
| 162032 | {yymsp[0].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} | 163502 | {yymsp[0].minor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/} |
| 162033 | break; | 163503 | break; |
| 162034 | case 116: /* xfullname ::= nm DOT nm */ | 163504 | case 118: /* xfullname ::= nm DOT nm */ |
| 162035 | {yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} | 163505 | {yymsp[-2].minor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 162036 | break; | 163506 | break; |
| 162037 | case 117: /* xfullname ::= nm DOT nm AS nm */ | 163507 | case 119: /* xfullname ::= nm DOT nm AS nm */ |
| 162038 | { | 163508 | { |
| 162039 | yymsp[-4].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ | 163509 | yymsp[-4].minor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/ |
| 162040 | if( yymsp[-4].minor.yy153 ) yymsp[-4].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); | 163510 | if( yymsp[-4].minor.yy607 ) yymsp[-4].minor.yy607->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 162041 | } | 163511 | } |
| 162042 | break; | 163512 | break; |
| 162043 | case 118: /* xfullname ::= nm AS nm */ | 163513 | case 120: /* xfullname ::= nm AS nm */ |
| 162044 | { | 163514 | { |
| 162045 | yymsp[-2].minor.yy153 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ | 163515 | yymsp[-2].minor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/ |
| 162046 | if( yymsp[-2].minor.yy153 ) yymsp[-2].minor.yy153->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); | 163516 | if( yymsp[-2].minor.yy607 ) yymsp[-2].minor.yy607->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0); |
| 162047 | } | 163517 | } |
| 162048 | break; | 163518 | break; |
| 162049 | case 119: /* joinop ::= COMMA|JOIN */ | 163519 | case 121: /* joinop ::= COMMA|JOIN */ |
| 162050 | { yymsp[0].minor.yy376 = JT_INNER; } | 163520 | { yymsp[0].minor.yy64 = JT_INNER; } |
| 162051 | break; | 163521 | break; |
| 162052 | case 120: /* joinop ::= JOIN_KW JOIN */ | 163522 | case 122: /* joinop ::= JOIN_KW JOIN */ |
| 162053 | {yymsp[-1].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} | 163523 | {yymsp[-1].minor.yy64 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/} |
| 162054 | break; | 163524 | break; |
| 162055 | case 121: /* joinop ::= JOIN_KW nm JOIN */ | 163525 | case 123: /* joinop ::= JOIN_KW nm JOIN */ |
| 162056 | {yymsp[-2].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} | 163526 | {yymsp[-2].minor.yy64 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/} |
| 162057 | break; | 163527 | break; |
| 162058 | case 122: /* joinop ::= JOIN_KW nm nm JOIN */ | 163528 | case 124: /* joinop ::= JOIN_KW nm nm JOIN */ |
| 162059 | {yymsp[-3].minor.yy376 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} | 163529 | {yymsp[-3].minor.yy64 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/} |
| 162060 | break; | 163530 | break; |
| 162061 | case 123: /* on_opt ::= ON expr */ | 163531 | case 125: /* on_opt ::= ON expr */ |
| 162062 | case 143: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==143); | 163532 | case 145: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==145); |
| 162063 | case 150: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==150); | 163533 | case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152); |
| 162064 | case 152: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==152); | 163534 | case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154); |
| 162065 | case 223: /* case_else ::= ELSE expr */ yytestcase(yyruleno==223); | 163535 | case 225: /* case_else ::= ELSE expr */ yytestcase(yyruleno==225); |
| 162066 | case 244: /* vinto ::= INTO expr */ yytestcase(yyruleno==244); | 163536 | case 246: /* vinto ::= INTO expr */ yytestcase(yyruleno==246); |
| 162067 | {yymsp[-1].minor.yy404 = yymsp[0].minor.yy404;} | 163537 | {yymsp[-1].minor.yy626 = yymsp[0].minor.yy626;} |
| 162068 | break; | 163538 | break; |
| 162069 | case 124: /* on_opt ::= */ | 163539 | case 126: /* on_opt ::= */ |
| 162070 | case 142: /* having_opt ::= */ yytestcase(yyruleno==142); | 163540 | case 144: /* having_opt ::= */ yytestcase(yyruleno==144); |
| 162071 | case 144: /* limit_opt ::= */ yytestcase(yyruleno==144); | 163541 | case 146: /* limit_opt ::= */ yytestcase(yyruleno==146); |
| 162072 | case 149: /* where_opt ::= */ yytestcase(yyruleno==149); | 163542 | case 151: /* where_opt ::= */ yytestcase(yyruleno==151); |
| 162073 | case 151: /* where_opt_ret ::= */ yytestcase(yyruleno==151); | 163543 | case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153); |
| 162074 | case 224: /* case_else ::= */ yytestcase(yyruleno==224); | 163544 | case 226: /* case_else ::= */ yytestcase(yyruleno==226); |
| 162075 | case 226: /* case_operand ::= */ yytestcase(yyruleno==226); | 163545 | case 228: /* case_operand ::= */ yytestcase(yyruleno==228); |
| 162076 | case 245: /* vinto ::= */ yytestcase(yyruleno==245); | 163546 | case 247: /* vinto ::= */ yytestcase(yyruleno==247); |
| 162077 | {yymsp[1].minor.yy404 = 0;} | 163547 | {yymsp[1].minor.yy626 = 0;} |
| 162078 | break; | 163548 | break; |
| 162079 | case 126: /* indexed_opt ::= INDEXED BY nm */ | 163549 | case 128: /* indexed_opt ::= INDEXED BY nm */ |
| 162080 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} | 163550 | {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;} |
| 162081 | break; | 163551 | break; |
| 162082 | case 127: /* indexed_opt ::= NOT INDEXED */ | 163552 | case 129: /* indexed_opt ::= NOT INDEXED */ |
| 162083 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} | 163553 | {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;} |
| 162084 | break; | 163554 | break; |
| 162085 | case 128: /* using_opt ::= USING LP idlist RP */ | 163555 | case 130: /* using_opt ::= USING LP idlist RP */ |
| 162086 | {yymsp[-3].minor.yy436 = yymsp[-1].minor.yy436;} | 163556 | {yymsp[-3].minor.yy240 = yymsp[-1].minor.yy240;} |
| 162087 | break; | 163557 | break; |
| 162088 | case 129: /* using_opt ::= */ | 163558 | case 131: /* using_opt ::= */ |
| 162089 | case 171: /* idlist_opt ::= */ yytestcase(yyruleno==171); | 163559 | case 173: /* idlist_opt ::= */ yytestcase(yyruleno==173); |
| 162090 | {yymsp[1].minor.yy436 = 0;} | 163560 | {yymsp[1].minor.yy240 = 0;} |
| 162091 | break; | 163561 | break; |
| 162092 | case 131: /* orderby_opt ::= ORDER BY sortlist */ | 163562 | case 133: /* orderby_opt ::= ORDER BY sortlist */ |
| 162093 | case 141: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==141); | 163563 | case 143: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==143); |
| 162094 | {yymsp[-2].minor.yy70 = yymsp[0].minor.yy70;} | 163564 | {yymsp[-2].minor.yy562 = yymsp[0].minor.yy562;} |
| 162095 | break; | 163565 | break; |
| 162096 | case 132: /* sortlist ::= sortlist COMMA expr sortorder nulls */ | 163566 | case 134: /* sortlist ::= sortlist COMMA expr sortorder nulls */ |
| 162097 | { | 163567 | { |
| 162098 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70,yymsp[-2].minor.yy404); | 163568 | yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy562,yymsp[-2].minor.yy626); |
| 162099 | sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376); | 163569 | sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy562,yymsp[-1].minor.yy64,yymsp[0].minor.yy64); |
| 162100 | } | 163570 | } |
| 162101 | break; | 163571 | break; |
| 162102 | case 133: /* sortlist ::= expr sortorder nulls */ | 163572 | case 135: /* sortlist ::= expr sortorder nulls */ |
| 162103 | { | 163573 | { |
| 162104 | yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy404); /*A-overwrites-Y*/ | 163574 | yymsp[-2].minor.yy562 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy626); /*A-overwrites-Y*/ |
| 162105 | sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy70,yymsp[-1].minor.yy376,yymsp[0].minor.yy376); | 163575 | sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy562,yymsp[-1].minor.yy64,yymsp[0].minor.yy64); |
| 162106 | } | 163576 | } |
| 162107 | break; | 163577 | break; |
| 162108 | case 134: /* sortorder ::= ASC */ | 163578 | case 136: /* sortorder ::= ASC */ |
| 162109 | {yymsp[0].minor.yy376 = SQLITE_SO_ASC;} | 163579 | {yymsp[0].minor.yy64 = SQLITE_SO_ASC;} |
| 162110 | break; | 163580 | break; |
| 162111 | case 135: /* sortorder ::= DESC */ | 163581 | case 137: /* sortorder ::= DESC */ |
| 162112 | {yymsp[0].minor.yy376 = SQLITE_SO_DESC;} | 163582 | {yymsp[0].minor.yy64 = SQLITE_SO_DESC;} |
| 162113 | break; | 163583 | break; |
| 162114 | case 136: /* sortorder ::= */ | 163584 | case 138: /* sortorder ::= */ |
| 162115 | case 139: /* nulls ::= */ yytestcase(yyruleno==139); | 163585 | case 141: /* nulls ::= */ yytestcase(yyruleno==141); |
| 162116 | {yymsp[1].minor.yy376 = SQLITE_SO_UNDEFINED;} | 163586 | {yymsp[1].minor.yy64 = SQLITE_SO_UNDEFINED;} |
| 162117 | break; | 163587 | break; |
| 162118 | case 137: /* nulls ::= NULLS FIRST */ | 163588 | case 139: /* nulls ::= NULLS FIRST */ |
| 162119 | {yymsp[-1].minor.yy376 = SQLITE_SO_ASC;} | 163589 | {yymsp[-1].minor.yy64 = SQLITE_SO_ASC;} |
| 162120 | break; | 163590 | break; |
| 162121 | case 138: /* nulls ::= NULLS LAST */ | 163591 | case 140: /* nulls ::= NULLS LAST */ |
| 162122 | {yymsp[-1].minor.yy376 = SQLITE_SO_DESC;} | 163592 | {yymsp[-1].minor.yy64 = SQLITE_SO_DESC;} |
| 162123 | break; | 163593 | break; |
| 162124 | case 145: /* limit_opt ::= LIMIT expr */ | 163594 | case 147: /* limit_opt ::= LIMIT expr */ |
| 162125 | {yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,0);} | 163595 | {yymsp[-1].minor.yy626 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy626,0);} |
| 162126 | break; | 163596 | break; |
| 162127 | case 146: /* limit_opt ::= LIMIT expr OFFSET expr */ | 163597 | case 148: /* limit_opt ::= LIMIT expr OFFSET expr */ |
| 162128 | {yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);} | 163598 | {yymsp[-3].minor.yy626 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy626,yymsp[0].minor.yy626);} |
| 162129 | break; | 163599 | break; |
| 162130 | case 147: /* limit_opt ::= LIMIT expr COMMA expr */ | 163600 | case 149: /* limit_opt ::= LIMIT expr COMMA expr */ |
| 162131 | {yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy404,yymsp[-2].minor.yy404);} | 163601 | {yymsp[-3].minor.yy626 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy626,yymsp[-2].minor.yy626);} |
| 162132 | break; | 163602 | break; |
| 162133 | case 148: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ | 163603 | case 150: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */ |
| 162134 | { | 163604 | { |
| 162135 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy153, &yymsp[-1].minor.yy0); | 163605 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy607, &yymsp[-1].minor.yy0); |
| 162136 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy153,yymsp[0].minor.yy404,0,0); | 163606 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy607,yymsp[0].minor.yy626,0,0); |
| 162137 | } | 163607 | } |
| 162138 | break; | 163608 | break; |
| 162139 | case 153: /* where_opt_ret ::= RETURNING selcollist */ | 163609 | case 155: /* where_opt_ret ::= RETURNING selcollist */ |
| 162140 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-1].minor.yy404 = 0;} | 163610 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy562); yymsp[-1].minor.yy626 = 0;} |
| 162141 | break; | 163611 | break; |
| 162142 | case 154: /* where_opt_ret ::= WHERE expr RETURNING selcollist */ | 163612 | case 156: /* where_opt_ret ::= WHERE expr RETURNING selcollist */ |
| 162143 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy70); yymsp[-3].minor.yy404 = yymsp[-2].minor.yy404;} | 163613 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy562); yymsp[-3].minor.yy626 = yymsp[-2].minor.yy626;} |
| 162144 | break; | 163614 | break; |
| 162145 | case 155: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ | 163615 | case 157: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */ |
| 162146 | { | 163616 | { |
| 162147 | sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy153, &yymsp[-4].minor.yy0); | 163617 | sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy607, &yymsp[-4].minor.yy0); |
| 162148 | sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy70,"set list"); | 163618 | sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy562,"set list"); |
| 162149 | yymsp[-5].minor.yy153 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy153, yymsp[-1].minor.yy153); | 163619 | yymsp[-5].minor.yy607 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy607, yymsp[-1].minor.yy607); |
| 162150 | sqlite3Update(pParse,yymsp[-5].minor.yy153,yymsp[-2].minor.yy70,yymsp[0].minor.yy404,yymsp[-6].minor.yy376,0,0,0); | 163620 | sqlite3Update(pParse,yymsp[-5].minor.yy607,yymsp[-2].minor.yy562,yymsp[0].minor.yy626,yymsp[-6].minor.yy64,0,0,0); |
| 162151 | } | 163621 | } |
| 162152 | break; | 163622 | break; |
| 162153 | case 156: /* setlist ::= setlist COMMA nm EQ expr */ | 163623 | case 158: /* setlist ::= setlist COMMA nm EQ expr */ |
| 162154 | { | 163624 | { |
| 162155 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy70, yymsp[0].minor.yy404); | 163625 | yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy562, yymsp[0].minor.yy626); |
| 162156 | sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, 1); | 163626 | sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy562, &yymsp[-2].minor.yy0, 1); |
| 162157 | } | 163627 | } |
| 162158 | break; | 163628 | break; |
| 162159 | case 157: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ | 163629 | case 159: /* setlist ::= setlist COMMA LP idlist RP EQ expr */ |
| 162160 | { | 163630 | { |
| 162161 | yymsp[-6].minor.yy70 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy70, yymsp[-3].minor.yy436, yymsp[0].minor.yy404); | 163631 | yymsp[-6].minor.yy562 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy562, yymsp[-3].minor.yy240, yymsp[0].minor.yy626); |
| 162162 | } | 163632 | } |
| 162163 | break; | 163633 | break; |
| 162164 | case 158: /* setlist ::= nm EQ expr */ | 163634 | case 160: /* setlist ::= nm EQ expr */ |
| 162165 | { | 163635 | { |
| 162166 | yylhsminor.yy70 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy404); | 163636 | yylhsminor.yy562 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy626); |
| 162167 | sqlite3ExprListSetName(pParse, yylhsminor.yy70, &yymsp[-2].minor.yy0, 1); | 163637 | sqlite3ExprListSetName(pParse, yylhsminor.yy562, &yymsp[-2].minor.yy0, 1); |
| 162168 | } | 163638 | } |
| 162169 | yymsp[-2].minor.yy70 = yylhsminor.yy70; | 163639 | yymsp[-2].minor.yy562 = yylhsminor.yy562; |
| 162170 | break; | 163640 | break; |
| 162171 | case 159: /* setlist ::= LP idlist RP EQ expr */ | 163641 | case 161: /* setlist ::= LP idlist RP EQ expr */ |
| 162172 | { | 163642 | { |
| 162173 | yymsp[-4].minor.yy70 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy436, yymsp[0].minor.yy404); | 163643 | yymsp[-4].minor.yy562 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy240, yymsp[0].minor.yy626); |
| 162174 | } | 163644 | } |
| 162175 | break; | 163645 | break; |
| 162176 | case 160: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ | 163646 | case 162: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */ |
| 162177 | { | 163647 | { |
| 162178 | sqlite3Insert(pParse, yymsp[-3].minor.yy153, yymsp[-1].minor.yy81, yymsp[-2].minor.yy436, yymsp[-5].minor.yy376, yymsp[0].minor.yy190); | 163648 | sqlite3Insert(pParse, yymsp[-3].minor.yy607, yymsp[-1].minor.yy303, yymsp[-2].minor.yy240, yymsp[-5].minor.yy64, yymsp[0].minor.yy138); |
| 162179 | } | 163649 | } |
| 162180 | break; | 163650 | break; |
| 162181 | case 161: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ | 163651 | case 163: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */ |
| 162182 | { | 163652 | { |
| 162183 | sqlite3Insert(pParse, yymsp[-4].minor.yy153, 0, yymsp[-3].minor.yy436, yymsp[-6].minor.yy376, 0); | 163653 | sqlite3Insert(pParse, yymsp[-4].minor.yy607, 0, yymsp[-3].minor.yy240, yymsp[-6].minor.yy64, 0); |
| 162184 | } | 163654 | } |
| 162185 | break; | 163655 | break; |
| 162186 | case 162: /* upsert ::= */ | 163656 | case 164: /* upsert ::= */ |
| 162187 | { yymsp[1].minor.yy190 = 0; } | 163657 | { yymsp[1].minor.yy138 = 0; } |
| 162188 | break; | 163658 | break; |
| 162189 | case 163: /* upsert ::= RETURNING selcollist */ | 163659 | case 165: /* upsert ::= RETURNING selcollist */ |
| 162190 | { yymsp[-1].minor.yy190 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy70); } | 163660 | { yymsp[-1].minor.yy138 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy562); } |
| 162191 | break; | 163661 | break; |
| 162192 | case 164: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ | 163662 | case 166: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */ |
| 162193 | { yymsp[-11].minor.yy190 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy70,yymsp[-6].minor.yy404,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404,yymsp[0].minor.yy190);} | 163663 | { yymsp[-11].minor.yy138 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy562,yymsp[-6].minor.yy626,yymsp[-2].minor.yy562,yymsp[-1].minor.yy626,yymsp[0].minor.yy138);} |
| 162194 | break; | 163664 | break; |
| 162195 | case 165: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ | 163665 | case 167: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */ |
| 162196 | { yymsp[-8].minor.yy190 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy70,yymsp[-3].minor.yy404,0,0,yymsp[0].minor.yy190); } | 163666 | { yymsp[-8].minor.yy138 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy562,yymsp[-3].minor.yy626,0,0,yymsp[0].minor.yy138); } |
| 162197 | break; | 163667 | break; |
| 162198 | case 166: /* upsert ::= ON CONFLICT DO NOTHING returning */ | 163668 | case 168: /* upsert ::= ON CONFLICT DO NOTHING returning */ |
| 162199 | { yymsp[-4].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); } | 163669 | { yymsp[-4].minor.yy138 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); } |
| 162200 | break; | 163670 | break; |
| 162201 | case 167: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ | 163671 | case 169: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */ |
| 162202 | { yymsp[-7].minor.yy190 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404,0);} | 163672 | { yymsp[-7].minor.yy138 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy562,yymsp[-1].minor.yy626,0);} |
| 162203 | break; | 163673 | break; |
| 162204 | case 168: /* returning ::= RETURNING selcollist */ | 163674 | case 170: /* returning ::= RETURNING selcollist */ |
| 162205 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy70);} | 163675 | {sqlite3AddReturning(pParse,yymsp[0].minor.yy562);} |
| 162206 | break; | 163676 | break; |
| 162207 | case 172: /* idlist_opt ::= LP idlist RP */ | 163677 | case 174: /* idlist_opt ::= LP idlist RP */ |
| 162208 | {yymsp[-2].minor.yy436 = yymsp[-1].minor.yy436;} | 163678 | {yymsp[-2].minor.yy240 = yymsp[-1].minor.yy240;} |
| 162209 | break; | 163679 | break; |
| 162210 | case 173: /* idlist ::= idlist COMMA nm */ | 163680 | case 175: /* idlist ::= idlist COMMA nm */ |
| 162211 | {yymsp[-2].minor.yy436 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy436,&yymsp[0].minor.yy0);} | 163681 | {yymsp[-2].minor.yy240 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy240,&yymsp[0].minor.yy0);} |
| 162212 | break; | 163682 | break; |
| 162213 | case 174: /* idlist ::= nm */ | 163683 | case 176: /* idlist ::= nm */ |
| 162214 | {yymsp[0].minor.yy436 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} | 163684 | {yymsp[0].minor.yy240 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/} |
| 162215 | break; | 163685 | break; |
| 162216 | case 175: /* expr ::= LP expr RP */ | 163686 | case 177: /* expr ::= LP expr RP */ |
| 162217 | {yymsp[-2].minor.yy404 = yymsp[-1].minor.yy404;} | 163687 | {yymsp[-2].minor.yy626 = yymsp[-1].minor.yy626;} |
| 162218 | break; | 163688 | break; |
| 162219 | case 176: /* expr ::= ID|INDEXED */ | 163689 | case 178: /* expr ::= ID|INDEXED */ |
| 162220 | case 177: /* expr ::= JOIN_KW */ yytestcase(yyruleno==177); | 163690 | case 179: /* expr ::= JOIN_KW */ yytestcase(yyruleno==179); |
| 162221 | {yymsp[0].minor.yy404=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} | 163691 | {yymsp[0].minor.yy626=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 162222 | break; | 163692 | break; |
| 162223 | case 178: /* expr ::= nm DOT nm */ | 163693 | case 180: /* expr ::= nm DOT nm */ |
| 162224 | { | 163694 | { |
| 162225 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); | 163695 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| 162226 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); | 163696 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1); |
| @@ -162228,11 +163698,11 @@ static YYACTIONTYPE yy_reduce( | |||
| 162228 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0); | 163698 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0); |
| 162229 | sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0); | 163699 | sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0); |
| 162230 | } | 163700 | } |
| 162231 | yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); | 163701 | yylhsminor.yy626 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2); |
| 162232 | } | 163702 | } |
| 162233 | yymsp[-2].minor.yy404 = yylhsminor.yy404; | 163703 | yymsp[-2].minor.yy626 = yylhsminor.yy626; |
| 162234 | break; | 163704 | break; |
| 162235 | case 179: /* expr ::= nm DOT nm DOT nm */ | 163705 | case 181: /* expr ::= nm DOT nm DOT nm */ |
| 162236 | { | 163706 | { |
| 162237 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1); | 163707 | Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1); |
| 162238 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); | 163708 | Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1); |
| @@ -162242,26 +163712,26 @@ static YYACTIONTYPE yy_reduce( | |||
| 162242 | sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0); | 163712 | sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0); |
| 162243 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0); | 163713 | sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0); |
| 162244 | } | 163714 | } |
| 162245 | yylhsminor.yy404 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); | 163715 | yylhsminor.yy626 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4); |
| 162246 | } | 163716 | } |
| 162247 | yymsp[-4].minor.yy404 = yylhsminor.yy404; | 163717 | yymsp[-4].minor.yy626 = yylhsminor.yy626; |
| 162248 | break; | 163718 | break; |
| 162249 | case 180: /* term ::= NULL|FLOAT|BLOB */ | 163719 | case 182: /* term ::= NULL|FLOAT|BLOB */ |
| 162250 | case 181: /* term ::= STRING */ yytestcase(yyruleno==181); | 163720 | case 183: /* term ::= STRING */ yytestcase(yyruleno==183); |
| 162251 | {yymsp[0].minor.yy404=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} | 163721 | {yymsp[0].minor.yy626=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/} |
| 162252 | break; | 163722 | break; |
| 162253 | case 182: /* term ::= INTEGER */ | 163723 | case 184: /* term ::= INTEGER */ |
| 162254 | { | 163724 | { |
| 162255 | yylhsminor.yy404 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); | 163725 | yylhsminor.yy626 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1); |
| 162256 | } | 163726 | } |
| 162257 | yymsp[0].minor.yy404 = yylhsminor.yy404; | 163727 | yymsp[0].minor.yy626 = yylhsminor.yy626; |
| 162258 | break; | 163728 | break; |
| 162259 | case 183: /* expr ::= VARIABLE */ | 163729 | case 185: /* expr ::= VARIABLE */ |
| 162260 | { | 163730 | { |
| 162261 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ | 163731 | if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){ |
| 162262 | u32 n = yymsp[0].minor.yy0.n; | 163732 | u32 n = yymsp[0].minor.yy0.n; |
| 162263 | yymsp[0].minor.yy404 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); | 163733 | yymsp[0].minor.yy626 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0); |
| 162264 | sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy404, n); | 163734 | sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy626, n); |
| 162265 | }else{ | 163735 | }else{ |
| 162266 | /* When doing a nested parse, one can include terms in an expression | 163736 | /* When doing a nested parse, one can include terms in an expression |
| 162267 | ** that look like this: #1 #2 ... These terms refer to registers | 163737 | ** that look like this: #1 #2 ... These terms refer to registers |
| @@ -162270,159 +163740,159 @@ static YYACTIONTYPE yy_reduce( | |||
| 162270 | assert( t.n>=2 ); | 163740 | assert( t.n>=2 ); |
| 162271 | if( pParse->nested==0 ){ | 163741 | if( pParse->nested==0 ){ |
| 162272 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); | 163742 | sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t); |
| 162273 | yymsp[0].minor.yy404 = 0; | 163743 | yymsp[0].minor.yy626 = 0; |
| 162274 | }else{ | 163744 | }else{ |
| 162275 | yymsp[0].minor.yy404 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); | 163745 | yymsp[0].minor.yy626 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0); |
| 162276 | if( yymsp[0].minor.yy404 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy404->iTable); | 163746 | if( yymsp[0].minor.yy626 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy626->iTable); |
| 162277 | } | 163747 | } |
| 162278 | } | 163748 | } |
| 162279 | } | 163749 | } |
| 162280 | break; | 163750 | break; |
| 162281 | case 184: /* expr ::= expr COLLATE ID|STRING */ | 163751 | case 186: /* expr ::= expr COLLATE ID|STRING */ |
| 162282 | { | 163752 | { |
| 162283 | yymsp[-2].minor.yy404 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy404, &yymsp[0].minor.yy0, 1); | 163753 | yymsp[-2].minor.yy626 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy626, &yymsp[0].minor.yy0, 1); |
| 162284 | } | 163754 | } |
| 162285 | break; | 163755 | break; |
| 162286 | case 185: /* expr ::= CAST LP expr AS typetoken RP */ | 163756 | case 187: /* expr ::= CAST LP expr AS typetoken RP */ |
| 162287 | { | 163757 | { |
| 162288 | yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); | 163758 | yymsp[-5].minor.yy626 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1); |
| 162289 | sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy404, yymsp[-3].minor.yy404, 0); | 163759 | sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy626, yymsp[-3].minor.yy626, 0); |
| 162290 | } | 163760 | } |
| 162291 | break; | 163761 | break; |
| 162292 | case 186: /* expr ::= ID|INDEXED LP distinct exprlist RP */ | 163762 | case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP */ |
| 162293 | { | 163763 | { |
| 162294 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy376); | 163764 | yylhsminor.yy626 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy562, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy64); |
| 162295 | } | 163765 | } |
| 162296 | yymsp[-4].minor.yy404 = yylhsminor.yy404; | 163766 | yymsp[-4].minor.yy626 = yylhsminor.yy626; |
| 162297 | break; | 163767 | break; |
| 162298 | case 187: /* expr ::= ID|INDEXED LP STAR RP */ | 163768 | case 189: /* expr ::= ID|INDEXED LP STAR RP */ |
| 162299 | { | 163769 | { |
| 162300 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); | 163770 | yylhsminor.yy626 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0); |
| 162301 | } | 163771 | } |
| 162302 | yymsp[-3].minor.yy404 = yylhsminor.yy404; | 163772 | yymsp[-3].minor.yy626 = yylhsminor.yy626; |
| 162303 | break; | 163773 | break; |
| 162304 | case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ | 163774 | case 190: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */ |
| 162305 | { | 163775 | { |
| 162306 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy70, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy376); | 163776 | yylhsminor.yy626 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy562, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy64); |
| 162307 | sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49); | 163777 | sqlite3WindowAttach(pParse, yylhsminor.yy626, yymsp[0].minor.yy375); |
| 162308 | } | 163778 | } |
| 162309 | yymsp[-5].minor.yy404 = yylhsminor.yy404; | 163779 | yymsp[-5].minor.yy626 = yylhsminor.yy626; |
| 162310 | break; | 163780 | break; |
| 162311 | case 189: /* expr ::= ID|INDEXED LP STAR RP filter_over */ | 163781 | case 191: /* expr ::= ID|INDEXED LP STAR RP filter_over */ |
| 162312 | { | 163782 | { |
| 162313 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); | 163783 | yylhsminor.yy626 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0); |
| 162314 | sqlite3WindowAttach(pParse, yylhsminor.yy404, yymsp[0].minor.yy49); | 163784 | sqlite3WindowAttach(pParse, yylhsminor.yy626, yymsp[0].minor.yy375); |
| 162315 | } | 163785 | } |
| 162316 | yymsp[-4].minor.yy404 = yylhsminor.yy404; | 163786 | yymsp[-4].minor.yy626 = yylhsminor.yy626; |
| 162317 | break; | 163787 | break; |
| 162318 | case 190: /* term ::= CTIME_KW */ | 163788 | case 192: /* term ::= CTIME_KW */ |
| 162319 | { | 163789 | { |
| 162320 | yylhsminor.yy404 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); | 163790 | yylhsminor.yy626 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0); |
| 162321 | } | 163791 | } |
| 162322 | yymsp[0].minor.yy404 = yylhsminor.yy404; | 163792 | yymsp[0].minor.yy626 = yylhsminor.yy626; |
| 162323 | break; | 163793 | break; |
| 162324 | case 191: /* expr ::= LP nexprlist COMMA expr RP */ | 163794 | case 193: /* expr ::= LP nexprlist COMMA expr RP */ |
| 162325 | { | 163795 | { |
| 162326 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy70, yymsp[-1].minor.yy404); | 163796 | ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy562, yymsp[-1].minor.yy626); |
| 162327 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); | 163797 | yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0); |
| 162328 | if( yymsp[-4].minor.yy404 ){ | 163798 | if( yymsp[-4].minor.yy626 ){ |
| 162329 | yymsp[-4].minor.yy404->x.pList = pList; | 163799 | yymsp[-4].minor.yy626->x.pList = pList; |
| 162330 | if( ALWAYS(pList->nExpr) ){ | 163800 | if( ALWAYS(pList->nExpr) ){ |
| 162331 | yymsp[-4].minor.yy404->flags |= pList->a[0].pExpr->flags & EP_Propagate; | 163801 | yymsp[-4].minor.yy626->flags |= pList->a[0].pExpr->flags & EP_Propagate; |
| 162332 | } | 163802 | } |
| 162333 | }else{ | 163803 | }else{ |
| 162334 | sqlite3ExprListDelete(pParse->db, pList); | 163804 | sqlite3ExprListDelete(pParse->db, pList); |
| 162335 | } | 163805 | } |
| 162336 | } | 163806 | } |
| 162337 | break; | 163807 | break; |
| 162338 | case 192: /* expr ::= expr AND expr */ | 163808 | case 194: /* expr ::= expr AND expr */ |
| 162339 | {yymsp[-2].minor.yy404=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);} | 163809 | {yymsp[-2].minor.yy626=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy626,yymsp[0].minor.yy626);} |
| 162340 | break; | 163810 | break; |
| 162341 | case 193: /* expr ::= expr OR expr */ | 163811 | case 195: /* expr ::= expr OR expr */ |
| 162342 | case 194: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==194); | 163812 | case 196: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==196); |
| 162343 | case 195: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==195); | 163813 | case 197: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==197); |
| 162344 | case 196: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==196); | 163814 | case 198: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==198); |
| 162345 | case 197: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==197); | 163815 | case 199: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==199); |
| 162346 | case 198: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==198); | 163816 | case 200: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==200); |
| 162347 | case 199: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==199); | 163817 | case 201: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==201); |
| 162348 | {yymsp[-2].minor.yy404=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy404,yymsp[0].minor.yy404);} | 163818 | {yymsp[-2].minor.yy626=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy626,yymsp[0].minor.yy626);} |
| 162349 | break; | 163819 | break; |
| 162350 | case 200: /* likeop ::= NOT LIKE_KW|MATCH */ | 163820 | case 202: /* likeop ::= NOT LIKE_KW|MATCH */ |
| 162351 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} | 163821 | {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/} |
| 162352 | break; | 163822 | break; |
| 162353 | case 201: /* expr ::= expr likeop expr */ | 163823 | case 203: /* expr ::= expr likeop expr */ |
| 162354 | { | 163824 | { |
| 162355 | ExprList *pList; | 163825 | ExprList *pList; |
| 162356 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; | 163826 | int bNot = yymsp[-1].minor.yy0.n & 0x80000000; |
| 162357 | yymsp[-1].minor.yy0.n &= 0x7fffffff; | 163827 | yymsp[-1].minor.yy0.n &= 0x7fffffff; |
| 162358 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy404); | 163828 | pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy626); |
| 162359 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy404); | 163829 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy626); |
| 162360 | yymsp[-2].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); | 163830 | yymsp[-2].minor.yy626 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0); |
| 162361 | if( bNot ) yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy404, 0); | 163831 | if( bNot ) yymsp[-2].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy626, 0); |
| 162362 | if( yymsp[-2].minor.yy404 ) yymsp[-2].minor.yy404->flags |= EP_InfixFunc; | 163832 | if( yymsp[-2].minor.yy626 ) yymsp[-2].minor.yy626->flags |= EP_InfixFunc; |
| 162363 | } | 163833 | } |
| 162364 | break; | 163834 | break; |
| 162365 | case 202: /* expr ::= expr likeop expr ESCAPE expr */ | 163835 | case 204: /* expr ::= expr likeop expr ESCAPE expr */ |
| 162366 | { | 163836 | { |
| 162367 | ExprList *pList; | 163837 | ExprList *pList; |
| 162368 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; | 163838 | int bNot = yymsp[-3].minor.yy0.n & 0x80000000; |
| 162369 | yymsp[-3].minor.yy0.n &= 0x7fffffff; | 163839 | yymsp[-3].minor.yy0.n &= 0x7fffffff; |
| 162370 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404); | 163840 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy626); |
| 162371 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy404); | 163841 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy626); |
| 162372 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404); | 163842 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy626); |
| 162373 | yymsp[-4].minor.yy404 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); | 163843 | yymsp[-4].minor.yy626 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0); |
| 162374 | if( bNot ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); | 163844 | if( bNot ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0); |
| 162375 | if( yymsp[-4].minor.yy404 ) yymsp[-4].minor.yy404->flags |= EP_InfixFunc; | 163845 | if( yymsp[-4].minor.yy626 ) yymsp[-4].minor.yy626->flags |= EP_InfixFunc; |
| 162376 | } | 163846 | } |
| 162377 | break; | 163847 | break; |
| 162378 | case 203: /* expr ::= expr ISNULL|NOTNULL */ | 163848 | case 205: /* expr ::= expr ISNULL|NOTNULL */ |
| 162379 | {yymsp[-1].minor.yy404 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy404,0);} | 163849 | {yymsp[-1].minor.yy626 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy626,0);} |
| 162380 | break; | 163850 | break; |
| 162381 | case 204: /* expr ::= expr NOT NULL */ | 163851 | case 206: /* expr ::= expr NOT NULL */ |
| 162382 | {yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy404,0);} | 163852 | {yymsp[-2].minor.yy626 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy626,0);} |
| 162383 | break; | 163853 | break; |
| 162384 | case 205: /* expr ::= expr IS expr */ | 163854 | case 207: /* expr ::= expr IS expr */ |
| 162385 | { | 163855 | { |
| 162386 | yymsp[-2].minor.yy404 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy404,yymsp[0].minor.yy404); | 163856 | yymsp[-2].minor.yy626 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy626,yymsp[0].minor.yy626); |
| 162387 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-2].minor.yy404, TK_ISNULL); | 163857 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy626, yymsp[-2].minor.yy626, TK_ISNULL); |
| 162388 | } | 163858 | } |
| 162389 | break; | 163859 | break; |
| 162390 | case 206: /* expr ::= expr IS NOT expr */ | 163860 | case 208: /* expr ::= expr IS NOT expr */ |
| 162391 | { | 163861 | { |
| 162392 | yymsp[-3].minor.yy404 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy404,yymsp[0].minor.yy404); | 163862 | yymsp[-3].minor.yy626 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy626,yymsp[0].minor.yy626); |
| 162393 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy404, yymsp[-3].minor.yy404, TK_NOTNULL); | 163863 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy626, yymsp[-3].minor.yy626, TK_NOTNULL); |
| 162394 | } | 163864 | } |
| 162395 | break; | 163865 | break; |
| 162396 | case 207: /* expr ::= NOT expr */ | 163866 | case 209: /* expr ::= NOT expr */ |
| 162397 | case 208: /* expr ::= BITNOT expr */ yytestcase(yyruleno==208); | 163867 | case 210: /* expr ::= BITNOT expr */ yytestcase(yyruleno==210); |
| 162398 | {yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy404, 0);/*A-overwrites-B*/} | 163868 | {yymsp[-1].minor.yy626 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy626, 0);/*A-overwrites-B*/} |
| 162399 | break; | 163869 | break; |
| 162400 | case 209: /* expr ::= PLUS|MINUS expr */ | 163870 | case 211: /* expr ::= PLUS|MINUS expr */ |
| 162401 | { | 163871 | { |
| 162402 | yymsp[-1].minor.yy404 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy404, 0); | 163872 | yymsp[-1].minor.yy626 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy626, 0); |
| 162403 | /*A-overwrites-B*/ | 163873 | /*A-overwrites-B*/ |
| 162404 | } | 163874 | } |
| 162405 | break; | 163875 | break; |
| 162406 | case 210: /* between_op ::= BETWEEN */ | 163876 | case 212: /* between_op ::= BETWEEN */ |
| 162407 | case 213: /* in_op ::= IN */ yytestcase(yyruleno==213); | 163877 | case 215: /* in_op ::= IN */ yytestcase(yyruleno==215); |
| 162408 | {yymsp[0].minor.yy376 = 0;} | 163878 | {yymsp[0].minor.yy64 = 0;} |
| 162409 | break; | 163879 | break; |
| 162410 | case 212: /* expr ::= expr between_op expr AND expr */ | 163880 | case 214: /* expr ::= expr between_op expr AND expr */ |
| 162411 | { | 163881 | { |
| 162412 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404); | 163882 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy626); |
| 162413 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy404); | 163883 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy626); |
| 162414 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy404, 0); | 163884 | yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy626, 0); |
| 162415 | if( yymsp[-4].minor.yy404 ){ | 163885 | if( yymsp[-4].minor.yy626 ){ |
| 162416 | yymsp[-4].minor.yy404->x.pList = pList; | 163886 | yymsp[-4].minor.yy626->x.pList = pList; |
| 162417 | }else{ | 163887 | }else{ |
| 162418 | sqlite3ExprListDelete(pParse->db, pList); | 163888 | sqlite3ExprListDelete(pParse->db, pList); |
| 162419 | } | 163889 | } |
| 162420 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); | 163890 | if( yymsp[-3].minor.yy64 ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0); |
| 162421 | } | 163891 | } |
| 162422 | break; | 163892 | break; |
| 162423 | case 215: /* expr ::= expr in_op LP exprlist RP */ | 163893 | case 217: /* expr ::= expr in_op LP exprlist RP */ |
| 162424 | { | 163894 | { |
| 162425 | if( yymsp[-1].minor.yy70==0 ){ | 163895 | if( yymsp[-1].minor.yy562==0 ){ |
| 162426 | /* Expressions of the form | 163896 | /* Expressions of the form |
| 162427 | ** | 163897 | ** |
| 162428 | ** expr1 IN () | 163898 | ** expr1 IN () |
| @@ -162431,197 +163901,205 @@ static YYACTIONTYPE yy_reduce( | |||
| 162431 | ** simplify to constants 0 (false) and 1 (true), respectively, | 163901 | ** simplify to constants 0 (false) and 1 (true), respectively, |
| 162432 | ** regardless of the value of expr1. | 163902 | ** regardless of the value of expr1. |
| 162433 | */ | 163903 | */ |
| 162434 | sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy404); | 163904 | sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy626); |
| 162435 | yymsp[-4].minor.yy404 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy376 ? "1" : "0"); | 163905 | yymsp[-4].minor.yy626 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy64 ? "1" : "0"); |
| 162436 | }else if( yymsp[-1].minor.yy70->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy70->a[0].pExpr) ){ | 163906 | }else{ |
| 162437 | Expr *pRHS = yymsp[-1].minor.yy70->a[0].pExpr; | 163907 | Expr *pRHS = yymsp[-1].minor.yy562->a[0].pExpr; |
| 162438 | yymsp[-1].minor.yy70->a[0].pExpr = 0; | 163908 | if( yymsp[-1].minor.yy562->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy626->op!=TK_VECTOR ){ |
| 162439 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70); | 163909 | yymsp[-1].minor.yy562->a[0].pExpr = 0; |
| 162440 | pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0); | 163910 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy562); |
| 162441 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy404, pRHS); | 163911 | pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0); |
| 162442 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); | 163912 | yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy626, pRHS); |
| 162443 | }else{ | ||
| 162444 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0); | ||
| 162445 | if( yymsp[-4].minor.yy404 ){ | ||
| 162446 | yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy70; | ||
| 162447 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404); | ||
| 162448 | }else{ | 163913 | }else{ |
| 162449 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70); | 163914 | yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy626, 0); |
| 163915 | if( yymsp[-4].minor.yy626==0 ){ | ||
| 163916 | sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy562); | ||
| 163917 | }else if( yymsp[-4].minor.yy626->pLeft->op==TK_VECTOR ){ | ||
| 163918 | int nExpr = yymsp[-4].minor.yy626->pLeft->x.pList->nExpr; | ||
| 163919 | Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy562); | ||
| 163920 | if( pSelectRHS ){ | ||
| 163921 | parserDoubleLinkSelect(pParse, pSelectRHS); | ||
| 163922 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy626, pSelectRHS); | ||
| 163923 | } | ||
| 163924 | }else{ | ||
| 163925 | yymsp[-4].minor.yy626->x.pList = yymsp[-1].minor.yy562; | ||
| 163926 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy626); | ||
| 163927 | } | ||
| 162450 | } | 163928 | } |
| 162451 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); | 163929 | if( yymsp[-3].minor.yy64 ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0); |
| 162452 | } | 163930 | } |
| 162453 | } | 163931 | } |
| 162454 | break; | 163932 | break; |
| 162455 | case 216: /* expr ::= LP select RP */ | 163933 | case 218: /* expr ::= LP select RP */ |
| 162456 | { | 163934 | { |
| 162457 | yymsp[-2].minor.yy404 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); | 163935 | yymsp[-2].minor.yy626 = sqlite3PExpr(pParse, TK_SELECT, 0, 0); |
| 162458 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy404, yymsp[-1].minor.yy81); | 163936 | sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy626, yymsp[-1].minor.yy303); |
| 162459 | } | 163937 | } |
| 162460 | break; | 163938 | break; |
| 162461 | case 217: /* expr ::= expr in_op LP select RP */ | 163939 | case 219: /* expr ::= expr in_op LP select RP */ |
| 162462 | { | 163940 | { |
| 162463 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0); | 163941 | yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy626, 0); |
| 162464 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, yymsp[-1].minor.yy81); | 163942 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy626, yymsp[-1].minor.yy303); |
| 162465 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); | 163943 | if( yymsp[-3].minor.yy64 ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0); |
| 162466 | } | 163944 | } |
| 162467 | break; | 163945 | break; |
| 162468 | case 218: /* expr ::= expr in_op nm dbnm paren_exprlist */ | 163946 | case 220: /* expr ::= expr in_op nm dbnm paren_exprlist */ |
| 162469 | { | 163947 | { |
| 162470 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); | 163948 | SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); |
| 162471 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); | 163949 | Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0); |
| 162472 | if( yymsp[0].minor.yy70 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy70); | 163950 | if( yymsp[0].minor.yy562 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy562); |
| 162473 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0); | 163951 | yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy626, 0); |
| 162474 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, pSelect); | 163952 | sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy626, pSelect); |
| 162475 | if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0); | 163953 | if( yymsp[-3].minor.yy64 ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0); |
| 162476 | } | 163954 | } |
| 162477 | break; | 163955 | break; |
| 162478 | case 219: /* expr ::= EXISTS LP select RP */ | 163956 | case 221: /* expr ::= EXISTS LP select RP */ |
| 162479 | { | 163957 | { |
| 162480 | Expr *p; | 163958 | Expr *p; |
| 162481 | p = yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); | 163959 | p = yymsp[-3].minor.yy626 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0); |
| 162482 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy81); | 163960 | sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy303); |
| 162483 | } | 163961 | } |
| 162484 | break; | 163962 | break; |
| 162485 | case 220: /* expr ::= CASE case_operand case_exprlist case_else END */ | 163963 | case 222: /* expr ::= CASE case_operand case_exprlist case_else END */ |
| 162486 | { | 163964 | { |
| 162487 | yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy404, 0); | 163965 | yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy626, 0); |
| 162488 | if( yymsp[-4].minor.yy404 ){ | 163966 | if( yymsp[-4].minor.yy626 ){ |
| 162489 | yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy404 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[-1].minor.yy404) : yymsp[-2].minor.yy70; | 163967 | yymsp[-4].minor.yy626->x.pList = yymsp[-1].minor.yy626 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy562,yymsp[-1].minor.yy626) : yymsp[-2].minor.yy562; |
| 162490 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404); | 163968 | sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy626); |
| 162491 | }else{ | 163969 | }else{ |
| 162492 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy70); | 163970 | sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy562); |
| 162493 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404); | 163971 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy626); |
| 162494 | } | 163972 | } |
| 162495 | } | 163973 | } |
| 162496 | break; | 163974 | break; |
| 162497 | case 221: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ | 163975 | case 223: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ |
| 162498 | { | 163976 | { |
| 162499 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[-2].minor.yy404); | 163977 | yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy562, yymsp[-2].minor.yy626); |
| 162500 | yymsp[-4].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy70, yymsp[0].minor.yy404); | 163978 | yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy562, yymsp[0].minor.yy626); |
| 162501 | } | 163979 | } |
| 162502 | break; | 163980 | break; |
| 162503 | case 222: /* case_exprlist ::= WHEN expr THEN expr */ | 163981 | case 224: /* case_exprlist ::= WHEN expr THEN expr */ |
| 162504 | { | 163982 | { |
| 162505 | yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy404); | 163983 | yymsp[-3].minor.yy562 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy626); |
| 162506 | yymsp[-3].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy70, yymsp[0].minor.yy404); | 163984 | yymsp[-3].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy562, yymsp[0].minor.yy626); |
| 162507 | } | 163985 | } |
| 162508 | break; | 163986 | break; |
| 162509 | case 225: /* case_operand ::= expr */ | 163987 | case 227: /* case_operand ::= expr */ |
| 162510 | {yymsp[0].minor.yy404 = yymsp[0].minor.yy404; /*A-overwrites-X*/} | 163988 | {yymsp[0].minor.yy626 = yymsp[0].minor.yy626; /*A-overwrites-X*/} |
| 162511 | break; | 163989 | break; |
| 162512 | case 228: /* nexprlist ::= nexprlist COMMA expr */ | 163990 | case 230: /* nexprlist ::= nexprlist COMMA expr */ |
| 162513 | {yymsp[-2].minor.yy70 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy70,yymsp[0].minor.yy404);} | 163991 | {yymsp[-2].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy562,yymsp[0].minor.yy626);} |
| 162514 | break; | 163992 | break; |
| 162515 | case 229: /* nexprlist ::= expr */ | 163993 | case 231: /* nexprlist ::= expr */ |
| 162516 | {yymsp[0].minor.yy70 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy404); /*A-overwrites-Y*/} | 163994 | {yymsp[0].minor.yy562 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy626); /*A-overwrites-Y*/} |
| 162517 | break; | 163995 | break; |
| 162518 | case 231: /* paren_exprlist ::= LP exprlist RP */ | 163996 | case 233: /* paren_exprlist ::= LP exprlist RP */ |
| 162519 | case 236: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==236); | 163997 | case 238: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==238); |
| 162520 | {yymsp[-2].minor.yy70 = yymsp[-1].minor.yy70;} | 163998 | {yymsp[-2].minor.yy562 = yymsp[-1].minor.yy562;} |
| 162521 | break; | 163999 | break; |
| 162522 | case 232: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ | 164000 | case 234: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */ |
| 162523 | { | 164001 | { |
| 162524 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, | 164002 | sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, |
| 162525 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy70, yymsp[-10].minor.yy376, | 164003 | sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy562, yymsp[-10].minor.yy64, |
| 162526 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy404, SQLITE_SO_ASC, yymsp[-8].minor.yy376, SQLITE_IDXTYPE_APPDEF); | 164004 | &yymsp[-11].minor.yy0, yymsp[0].minor.yy626, SQLITE_SO_ASC, yymsp[-8].minor.yy64, SQLITE_IDXTYPE_APPDEF); |
| 162527 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ | 164005 | if( IN_RENAME_OBJECT && pParse->pNewIndex ){ |
| 162528 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); | 164006 | sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0); |
| 162529 | } | 164007 | } |
| 162530 | } | 164008 | } |
| 162531 | break; | 164009 | break; |
| 162532 | case 233: /* uniqueflag ::= UNIQUE */ | 164010 | case 235: /* uniqueflag ::= UNIQUE */ |
| 162533 | case 275: /* raisetype ::= ABORT */ yytestcase(yyruleno==275); | 164011 | case 277: /* raisetype ::= ABORT */ yytestcase(yyruleno==277); |
| 162534 | {yymsp[0].minor.yy376 = OE_Abort;} | 164012 | {yymsp[0].minor.yy64 = OE_Abort;} |
| 162535 | break; | 164013 | break; |
| 162536 | case 234: /* uniqueflag ::= */ | 164014 | case 236: /* uniqueflag ::= */ |
| 162537 | {yymsp[1].minor.yy376 = OE_None;} | 164015 | {yymsp[1].minor.yy64 = OE_None;} |
| 162538 | break; | 164016 | break; |
| 162539 | case 237: /* eidlist ::= eidlist COMMA nm collate sortorder */ | 164017 | case 239: /* eidlist ::= eidlist COMMA nm collate sortorder */ |
| 162540 | { | 164018 | { |
| 162541 | yymsp[-4].minor.yy70 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy70, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376); | 164019 | yymsp[-4].minor.yy562 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy562, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy64, yymsp[0].minor.yy64); |
| 162542 | } | 164020 | } |
| 162543 | break; | 164021 | break; |
| 162544 | case 238: /* eidlist ::= nm collate sortorder */ | 164022 | case 240: /* eidlist ::= nm collate sortorder */ |
| 162545 | { | 164023 | { |
| 162546 | yymsp[-2].minor.yy70 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy376, yymsp[0].minor.yy376); /*A-overwrites-Y*/ | 164024 | yymsp[-2].minor.yy562 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy64, yymsp[0].minor.yy64); /*A-overwrites-Y*/ |
| 162547 | } | 164025 | } |
| 162548 | break; | 164026 | break; |
| 162549 | case 241: /* cmd ::= DROP INDEX ifexists fullname */ | 164027 | case 243: /* cmd ::= DROP INDEX ifexists fullname */ |
| 162550 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy153, yymsp[-1].minor.yy376);} | 164028 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy607, yymsp[-1].minor.yy64);} |
| 162551 | break; | 164029 | break; |
| 162552 | case 242: /* cmd ::= VACUUM vinto */ | 164030 | case 244: /* cmd ::= VACUUM vinto */ |
| 162553 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy404);} | 164031 | {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy626);} |
| 162554 | break; | 164032 | break; |
| 162555 | case 243: /* cmd ::= VACUUM nm vinto */ | 164033 | case 245: /* cmd ::= VACUUM nm vinto */ |
| 162556 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy404);} | 164034 | {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy626);} |
| 162557 | break; | 164035 | break; |
| 162558 | case 246: /* cmd ::= PRAGMA nm dbnm */ | 164036 | case 248: /* cmd ::= PRAGMA nm dbnm */ |
| 162559 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} | 164037 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 162560 | break; | 164038 | break; |
| 162561 | case 247: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ | 164039 | case 249: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ |
| 162562 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} | 164040 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 162563 | break; | 164041 | break; |
| 162564 | case 248: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ | 164042 | case 250: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ |
| 162565 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} | 164043 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 162566 | break; | 164044 | break; |
| 162567 | case 249: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ | 164045 | case 251: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ |
| 162568 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} | 164046 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 162569 | break; | 164047 | break; |
| 162570 | case 250: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ | 164048 | case 252: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ |
| 162571 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} | 164049 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 162572 | break; | 164050 | break; |
| 162573 | case 253: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ | 164051 | case 255: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */ |
| 162574 | { | 164052 | { |
| 162575 | Token all; | 164053 | Token all; |
| 162576 | all.z = yymsp[-3].minor.yy0.z; | 164054 | all.z = yymsp[-3].minor.yy0.z; |
| 162577 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; | 164055 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 162578 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy157, &all); | 164056 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy95, &all); |
| 162579 | } | 164057 | } |
| 162580 | break; | 164058 | break; |
| 162581 | case 254: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ | 164059 | case 256: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */ |
| 162582 | { | 164060 | { |
| 162583 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy376, yymsp[-4].minor.yy262.a, yymsp[-4].minor.yy262.b, yymsp[-2].minor.yy153, yymsp[0].minor.yy404, yymsp[-10].minor.yy376, yymsp[-8].minor.yy376); | 164061 | sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy64, yymsp[-4].minor.yy570.a, yymsp[-4].minor.yy570.b, yymsp[-2].minor.yy607, yymsp[0].minor.yy626, yymsp[-10].minor.yy64, yymsp[-8].minor.yy64); |
| 162584 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ | 164062 | yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/ |
| 162585 | } | 164063 | } |
| 162586 | break; | 164064 | break; |
| 162587 | case 255: /* trigger_time ::= BEFORE|AFTER */ | 164065 | case 257: /* trigger_time ::= BEFORE|AFTER */ |
| 162588 | { yymsp[0].minor.yy376 = yymsp[0].major; /*A-overwrites-X*/ } | 164066 | { yymsp[0].minor.yy64 = yymsp[0].major; /*A-overwrites-X*/ } |
| 162589 | break; | 164067 | break; |
| 162590 | case 256: /* trigger_time ::= INSTEAD OF */ | 164068 | case 258: /* trigger_time ::= INSTEAD OF */ |
| 162591 | { yymsp[-1].minor.yy376 = TK_INSTEAD;} | 164069 | { yymsp[-1].minor.yy64 = TK_INSTEAD;} |
| 162592 | break; | 164070 | break; |
| 162593 | case 257: /* trigger_time ::= */ | 164071 | case 259: /* trigger_time ::= */ |
| 162594 | { yymsp[1].minor.yy376 = TK_BEFORE; } | 164072 | { yymsp[1].minor.yy64 = TK_BEFORE; } |
| 162595 | break; | 164073 | break; |
| 162596 | case 258: /* trigger_event ::= DELETE|INSERT */ | 164074 | case 260: /* trigger_event ::= DELETE|INSERT */ |
| 162597 | case 259: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==259); | 164075 | case 261: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==261); |
| 162598 | {yymsp[0].minor.yy262.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy262.b = 0;} | 164076 | {yymsp[0].minor.yy570.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy570.b = 0;} |
| 162599 | break; | 164077 | break; |
| 162600 | case 260: /* trigger_event ::= UPDATE OF idlist */ | 164078 | case 262: /* trigger_event ::= UPDATE OF idlist */ |
| 162601 | {yymsp[-2].minor.yy262.a = TK_UPDATE; yymsp[-2].minor.yy262.b = yymsp[0].minor.yy436;} | 164079 | {yymsp[-2].minor.yy570.a = TK_UPDATE; yymsp[-2].minor.yy570.b = yymsp[0].minor.yy240;} |
| 162602 | break; | 164080 | break; |
| 162603 | case 261: /* when_clause ::= */ | 164081 | case 263: /* when_clause ::= */ |
| 162604 | case 280: /* key_opt ::= */ yytestcase(yyruleno==280); | 164082 | case 282: /* key_opt ::= */ yytestcase(yyruleno==282); |
| 162605 | { yymsp[1].minor.yy404 = 0; } | 164083 | { yymsp[1].minor.yy626 = 0; } |
| 162606 | break; | 164084 | break; |
| 162607 | case 262: /* when_clause ::= WHEN expr */ | 164085 | case 264: /* when_clause ::= WHEN expr */ |
| 162608 | case 281: /* key_opt ::= KEY expr */ yytestcase(yyruleno==281); | 164086 | case 283: /* key_opt ::= KEY expr */ yytestcase(yyruleno==283); |
| 162609 | { yymsp[-1].minor.yy404 = yymsp[0].minor.yy404; } | 164087 | { yymsp[-1].minor.yy626 = yymsp[0].minor.yy626; } |
| 162610 | break; | 164088 | break; |
| 162611 | case 263: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ | 164089 | case 265: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */ |
| 162612 | { | 164090 | { |
| 162613 | assert( yymsp[-2].minor.yy157!=0 ); | 164091 | assert( yymsp[-2].minor.yy95!=0 ); |
| 162614 | yymsp[-2].minor.yy157->pLast->pNext = yymsp[-1].minor.yy157; | 164092 | yymsp[-2].minor.yy95->pLast->pNext = yymsp[-1].minor.yy95; |
| 162615 | yymsp[-2].minor.yy157->pLast = yymsp[-1].minor.yy157; | 164093 | yymsp[-2].minor.yy95->pLast = yymsp[-1].minor.yy95; |
| 162616 | } | 164094 | } |
| 162617 | break; | 164095 | break; |
| 162618 | case 264: /* trigger_cmd_list ::= trigger_cmd SEMI */ | 164096 | case 266: /* trigger_cmd_list ::= trigger_cmd SEMI */ |
| 162619 | { | 164097 | { |
| 162620 | assert( yymsp[-1].minor.yy157!=0 ); | 164098 | assert( yymsp[-1].minor.yy95!=0 ); |
| 162621 | yymsp[-1].minor.yy157->pLast = yymsp[-1].minor.yy157; | 164099 | yymsp[-1].minor.yy95->pLast = yymsp[-1].minor.yy95; |
| 162622 | } | 164100 | } |
| 162623 | break; | 164101 | break; |
| 162624 | case 265: /* trnm ::= nm DOT nm */ | 164102 | case 267: /* trnm ::= nm DOT nm */ |
| 162625 | { | 164103 | { |
| 162626 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; | 164104 | yymsp[-2].minor.yy0 = yymsp[0].minor.yy0; |
| 162627 | sqlite3ErrorMsg(pParse, | 164105 | sqlite3ErrorMsg(pParse, |
| @@ -162629,368 +164107,369 @@ static YYACTIONTYPE yy_reduce( | |||
| 162629 | "statements within triggers"); | 164107 | "statements within triggers"); |
| 162630 | } | 164108 | } |
| 162631 | break; | 164109 | break; |
| 162632 | case 266: /* tridxby ::= INDEXED BY nm */ | 164110 | case 268: /* tridxby ::= INDEXED BY nm */ |
| 162633 | { | 164111 | { |
| 162634 | sqlite3ErrorMsg(pParse, | 164112 | sqlite3ErrorMsg(pParse, |
| 162635 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " | 164113 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 162636 | "within triggers"); | 164114 | "within triggers"); |
| 162637 | } | 164115 | } |
| 162638 | break; | 164116 | break; |
| 162639 | case 267: /* tridxby ::= NOT INDEXED */ | 164117 | case 269: /* tridxby ::= NOT INDEXED */ |
| 162640 | { | 164118 | { |
| 162641 | sqlite3ErrorMsg(pParse, | 164119 | sqlite3ErrorMsg(pParse, |
| 162642 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " | 164120 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 162643 | "within triggers"); | 164121 | "within triggers"); |
| 162644 | } | 164122 | } |
| 162645 | break; | 164123 | break; |
| 162646 | case 268: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ | 164124 | case 270: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */ |
| 162647 | {yylhsminor.yy157 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy153, yymsp[-3].minor.yy70, yymsp[-1].minor.yy404, yymsp[-7].minor.yy376, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy504);} | 164125 | {yylhsminor.yy95 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy607, yymsp[-3].minor.yy562, yymsp[-1].minor.yy626, yymsp[-7].minor.yy64, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy600);} |
| 162648 | yymsp[-8].minor.yy157 = yylhsminor.yy157; | 164126 | yymsp[-8].minor.yy95 = yylhsminor.yy95; |
| 162649 | break; | 164127 | break; |
| 162650 | case 269: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ | 164128 | case 271: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */ |
| 162651 | { | 164129 | { |
| 162652 | yylhsminor.yy157 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy436,yymsp[-2].minor.yy81,yymsp[-6].minor.yy376,yymsp[-1].minor.yy190,yymsp[-7].minor.yy504,yymsp[0].minor.yy504);/*yylhsminor.yy157-overwrites-yymsp[-6].minor.yy376*/ | 164130 | yylhsminor.yy95 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy240,yymsp[-2].minor.yy303,yymsp[-6].minor.yy64,yymsp[-1].minor.yy138,yymsp[-7].minor.yy600,yymsp[0].minor.yy600);/*yylhsminor.yy95-overwrites-yymsp[-6].minor.yy64*/ |
| 162653 | } | 164131 | } |
| 162654 | yymsp[-7].minor.yy157 = yylhsminor.yy157; | 164132 | yymsp[-7].minor.yy95 = yylhsminor.yy95; |
| 162655 | break; | 164133 | break; |
| 162656 | case 270: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ | 164134 | case 272: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */ |
| 162657 | {yylhsminor.yy157 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy404, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy504);} | 164135 | {yylhsminor.yy95 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy626, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy600);} |
| 162658 | yymsp[-5].minor.yy157 = yylhsminor.yy157; | 164136 | yymsp[-5].minor.yy95 = yylhsminor.yy95; |
| 162659 | break; | 164137 | break; |
| 162660 | case 271: /* trigger_cmd ::= scanpt select scanpt */ | 164138 | case 273: /* trigger_cmd ::= scanpt select scanpt */ |
| 162661 | {yylhsminor.yy157 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy81, yymsp[-2].minor.yy504, yymsp[0].minor.yy504); /*yylhsminor.yy157-overwrites-yymsp[-1].minor.yy81*/} | 164139 | {yylhsminor.yy95 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy303, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); /*yylhsminor.yy95-overwrites-yymsp[-1].minor.yy303*/} |
| 162662 | yymsp[-2].minor.yy157 = yylhsminor.yy157; | 164140 | yymsp[-2].minor.yy95 = yylhsminor.yy95; |
| 162663 | break; | 164141 | break; |
| 162664 | case 272: /* expr ::= RAISE LP IGNORE RP */ | 164142 | case 274: /* expr ::= RAISE LP IGNORE RP */ |
| 162665 | { | 164143 | { |
| 162666 | yymsp[-3].minor.yy404 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); | 164144 | yymsp[-3].minor.yy626 = sqlite3PExpr(pParse, TK_RAISE, 0, 0); |
| 162667 | if( yymsp[-3].minor.yy404 ){ | 164145 | if( yymsp[-3].minor.yy626 ){ |
| 162668 | yymsp[-3].minor.yy404->affExpr = OE_Ignore; | 164146 | yymsp[-3].minor.yy626->affExpr = OE_Ignore; |
| 162669 | } | 164147 | } |
| 162670 | } | 164148 | } |
| 162671 | break; | 164149 | break; |
| 162672 | case 273: /* expr ::= RAISE LP raisetype COMMA nm RP */ | 164150 | case 275: /* expr ::= RAISE LP raisetype COMMA nm RP */ |
| 162673 | { | 164151 | { |
| 162674 | yymsp[-5].minor.yy404 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); | 164152 | yymsp[-5].minor.yy626 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1); |
| 162675 | if( yymsp[-5].minor.yy404 ) { | 164153 | if( yymsp[-5].minor.yy626 ) { |
| 162676 | yymsp[-5].minor.yy404->affExpr = (char)yymsp[-3].minor.yy376; | 164154 | yymsp[-5].minor.yy626->affExpr = (char)yymsp[-3].minor.yy64; |
| 162677 | } | 164155 | } |
| 162678 | } | 164156 | } |
| 162679 | break; | 164157 | break; |
| 162680 | case 274: /* raisetype ::= ROLLBACK */ | 164158 | case 276: /* raisetype ::= ROLLBACK */ |
| 162681 | {yymsp[0].minor.yy376 = OE_Rollback;} | 164159 | {yymsp[0].minor.yy64 = OE_Rollback;} |
| 162682 | break; | 164160 | break; |
| 162683 | case 276: /* raisetype ::= FAIL */ | 164161 | case 278: /* raisetype ::= FAIL */ |
| 162684 | {yymsp[0].minor.yy376 = OE_Fail;} | 164162 | {yymsp[0].minor.yy64 = OE_Fail;} |
| 162685 | break; | 164163 | break; |
| 162686 | case 277: /* cmd ::= DROP TRIGGER ifexists fullname */ | 164164 | case 279: /* cmd ::= DROP TRIGGER ifexists fullname */ |
| 162687 | { | 164165 | { |
| 162688 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy153,yymsp[-1].minor.yy376); | 164166 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy607,yymsp[-1].minor.yy64); |
| 162689 | } | 164167 | } |
| 162690 | break; | 164168 | break; |
| 162691 | case 278: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ | 164169 | case 280: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */ |
| 162692 | { | 164170 | { |
| 162693 | sqlite3Attach(pParse, yymsp[-3].minor.yy404, yymsp[-1].minor.yy404, yymsp[0].minor.yy404); | 164171 | sqlite3Attach(pParse, yymsp[-3].minor.yy626, yymsp[-1].minor.yy626, yymsp[0].minor.yy626); |
| 162694 | } | 164172 | } |
| 162695 | break; | 164173 | break; |
| 162696 | case 279: /* cmd ::= DETACH database_kw_opt expr */ | 164174 | case 281: /* cmd ::= DETACH database_kw_opt expr */ |
| 162697 | { | 164175 | { |
| 162698 | sqlite3Detach(pParse, yymsp[0].minor.yy404); | 164176 | sqlite3Detach(pParse, yymsp[0].minor.yy626); |
| 162699 | } | 164177 | } |
| 162700 | break; | 164178 | break; |
| 162701 | case 282: /* cmd ::= REINDEX */ | 164179 | case 284: /* cmd ::= REINDEX */ |
| 162702 | {sqlite3Reindex(pParse, 0, 0);} | 164180 | {sqlite3Reindex(pParse, 0, 0);} |
| 162703 | break; | 164181 | break; |
| 162704 | case 283: /* cmd ::= REINDEX nm dbnm */ | 164182 | case 285: /* cmd ::= REINDEX nm dbnm */ |
| 162705 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} | 164183 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 162706 | break; | 164184 | break; |
| 162707 | case 284: /* cmd ::= ANALYZE */ | 164185 | case 286: /* cmd ::= ANALYZE */ |
| 162708 | {sqlite3Analyze(pParse, 0, 0);} | 164186 | {sqlite3Analyze(pParse, 0, 0);} |
| 162709 | break; | 164187 | break; |
| 162710 | case 285: /* cmd ::= ANALYZE nm dbnm */ | 164188 | case 287: /* cmd ::= ANALYZE nm dbnm */ |
| 162711 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} | 164189 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 162712 | break; | 164190 | break; |
| 162713 | case 286: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | 164191 | case 288: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ |
| 162714 | { | 164192 | { |
| 162715 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy153,&yymsp[0].minor.yy0); | 164193 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy607,&yymsp[0].minor.yy0); |
| 162716 | } | 164194 | } |
| 162717 | break; | 164195 | break; |
| 162718 | case 287: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ | 164196 | case 289: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */ |
| 162719 | { | 164197 | { |
| 162720 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; | 164198 | yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n; |
| 162721 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); | 164199 | sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0); |
| 162722 | } | 164200 | } |
| 162723 | break; | 164201 | break; |
| 162724 | case 288: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ | 164202 | case 290: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */ |
| 162725 | { | 164203 | { |
| 162726 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy153, &yymsp[0].minor.yy0); | 164204 | sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy607, &yymsp[0].minor.yy0); |
| 162727 | } | 164205 | } |
| 162728 | break; | 164206 | break; |
| 162729 | case 289: /* add_column_fullname ::= fullname */ | 164207 | case 291: /* add_column_fullname ::= fullname */ |
| 162730 | { | 164208 | { |
| 162731 | disableLookaside(pParse); | 164209 | disableLookaside(pParse); |
| 162732 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy153); | 164210 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy607); |
| 162733 | } | 164211 | } |
| 162734 | break; | 164212 | break; |
| 162735 | case 290: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ | 164213 | case 292: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */ |
| 162736 | { | 164214 | { |
| 162737 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy153, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); | 164215 | sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy607, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 162738 | } | 164216 | } |
| 162739 | break; | 164217 | break; |
| 162740 | case 291: /* cmd ::= create_vtab */ | 164218 | case 293: /* cmd ::= create_vtab */ |
| 162741 | {sqlite3VtabFinishParse(pParse,0);} | 164219 | {sqlite3VtabFinishParse(pParse,0);} |
| 162742 | break; | 164220 | break; |
| 162743 | case 292: /* cmd ::= create_vtab LP vtabarglist RP */ | 164221 | case 294: /* cmd ::= create_vtab LP vtabarglist RP */ |
| 162744 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} | 164222 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 162745 | break; | 164223 | break; |
| 162746 | case 293: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ | 164224 | case 295: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */ |
| 162747 | { | 164225 | { |
| 162748 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy376); | 164226 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy64); |
| 162749 | } | 164227 | } |
| 162750 | break; | 164228 | break; |
| 162751 | case 294: /* vtabarg ::= */ | 164229 | case 296: /* vtabarg ::= */ |
| 162752 | {sqlite3VtabArgInit(pParse);} | 164230 | {sqlite3VtabArgInit(pParse);} |
| 162753 | break; | 164231 | break; |
| 162754 | case 295: /* vtabargtoken ::= ANY */ | 164232 | case 297: /* vtabargtoken ::= ANY */ |
| 162755 | case 296: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==296); | 164233 | case 298: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==298); |
| 162756 | case 297: /* lp ::= LP */ yytestcase(yyruleno==297); | 164234 | case 299: /* lp ::= LP */ yytestcase(yyruleno==299); |
| 162757 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} | 164235 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 162758 | break; | 164236 | break; |
| 162759 | case 298: /* with ::= WITH wqlist */ | 164237 | case 300: /* with ::= WITH wqlist */ |
| 162760 | case 299: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==299); | 164238 | case 301: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==301); |
| 162761 | { sqlite3WithPush(pParse, yymsp[0].minor.yy103, 1); } | 164239 | { sqlite3WithPush(pParse, yymsp[0].minor.yy43, 1); } |
| 162762 | break; | 164240 | break; |
| 162763 | case 300: /* wqas ::= AS */ | 164241 | case 302: /* wqas ::= AS */ |
| 162764 | {yymsp[0].minor.yy552 = M10d_Any;} | 164242 | {yymsp[0].minor.yy534 = M10d_Any;} |
| 162765 | break; | 164243 | break; |
| 162766 | case 301: /* wqas ::= AS MATERIALIZED */ | 164244 | case 303: /* wqas ::= AS MATERIALIZED */ |
| 162767 | {yymsp[-1].minor.yy552 = M10d_Yes;} | 164245 | {yymsp[-1].minor.yy534 = M10d_Yes;} |
| 162768 | break; | 164246 | break; |
| 162769 | case 302: /* wqas ::= AS NOT MATERIALIZED */ | 164247 | case 304: /* wqas ::= AS NOT MATERIALIZED */ |
| 162770 | {yymsp[-2].minor.yy552 = M10d_No;} | 164248 | {yymsp[-2].minor.yy534 = M10d_No;} |
| 162771 | break; | 164249 | break; |
| 162772 | case 303: /* wqitem ::= nm eidlist_opt wqas LP select RP */ | 164250 | case 305: /* wqitem ::= nm eidlist_opt wqas LP select RP */ |
| 162773 | { | 164251 | { |
| 162774 | yymsp[-5].minor.yy329 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy70, yymsp[-1].minor.yy81, yymsp[-3].minor.yy552); /*A-overwrites-X*/ | 164252 | yymsp[-5].minor.yy255 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy562, yymsp[-1].minor.yy303, yymsp[-3].minor.yy534); /*A-overwrites-X*/ |
| 162775 | } | 164253 | } |
| 162776 | break; | 164254 | break; |
| 162777 | case 304: /* wqlist ::= wqitem */ | 164255 | case 306: /* wqlist ::= wqitem */ |
| 162778 | { | 164256 | { |
| 162779 | yymsp[0].minor.yy103 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy329); /*A-overwrites-X*/ | 164257 | yymsp[0].minor.yy43 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy255); /*A-overwrites-X*/ |
| 162780 | } | 164258 | } |
| 162781 | break; | 164259 | break; |
| 162782 | case 305: /* wqlist ::= wqlist COMMA wqitem */ | 164260 | case 307: /* wqlist ::= wqlist COMMA wqitem */ |
| 162783 | { | 164261 | { |
| 162784 | yymsp[-2].minor.yy103 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy103, yymsp[0].minor.yy329); | 164262 | yymsp[-2].minor.yy43 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy43, yymsp[0].minor.yy255); |
| 162785 | } | 164263 | } |
| 162786 | break; | 164264 | break; |
| 162787 | case 306: /* windowdefn_list ::= windowdefn */ | 164265 | case 308: /* windowdefn_list ::= windowdefn */ |
| 162788 | { yylhsminor.yy49 = yymsp[0].minor.yy49; } | 164266 | { yylhsminor.yy375 = yymsp[0].minor.yy375; } |
| 162789 | yymsp[0].minor.yy49 = yylhsminor.yy49; | 164267 | yymsp[0].minor.yy375 = yylhsminor.yy375; |
| 162790 | break; | 164268 | break; |
| 162791 | case 307: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ | 164269 | case 309: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */ |
| 162792 | { | 164270 | { |
| 162793 | assert( yymsp[0].minor.yy49!=0 ); | 164271 | assert( yymsp[0].minor.yy375!=0 ); |
| 162794 | sqlite3WindowChain(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy49); | 164272 | sqlite3WindowChain(pParse, yymsp[0].minor.yy375, yymsp[-2].minor.yy375); |
| 162795 | yymsp[0].minor.yy49->pNextWin = yymsp[-2].minor.yy49; | 164273 | yymsp[0].minor.yy375->pNextWin = yymsp[-2].minor.yy375; |
| 162796 | yylhsminor.yy49 = yymsp[0].minor.yy49; | 164274 | yylhsminor.yy375 = yymsp[0].minor.yy375; |
| 162797 | } | 164275 | } |
| 162798 | yymsp[-2].minor.yy49 = yylhsminor.yy49; | 164276 | yymsp[-2].minor.yy375 = yylhsminor.yy375; |
| 162799 | break; | 164277 | break; |
| 162800 | case 308: /* windowdefn ::= nm AS LP window RP */ | 164278 | case 310: /* windowdefn ::= nm AS LP window RP */ |
| 162801 | { | 164279 | { |
| 162802 | if( ALWAYS(yymsp[-1].minor.yy49) ){ | 164280 | if( ALWAYS(yymsp[-1].minor.yy375) ){ |
| 162803 | yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); | 164281 | yymsp[-1].minor.yy375->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n); |
| 162804 | } | 164282 | } |
| 162805 | yylhsminor.yy49 = yymsp[-1].minor.yy49; | 164283 | yylhsminor.yy375 = yymsp[-1].minor.yy375; |
| 162806 | } | 164284 | } |
| 162807 | yymsp[-4].minor.yy49 = yylhsminor.yy49; | 164285 | yymsp[-4].minor.yy375 = yylhsminor.yy375; |
| 162808 | break; | 164286 | break; |
| 162809 | case 309: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ | 164287 | case 311: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */ |
| 162810 | { | 164288 | { |
| 162811 | yymsp[-4].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, 0); | 164289 | yymsp[-4].minor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, yymsp[-2].minor.yy562, yymsp[-1].minor.yy562, 0); |
| 162812 | } | 164290 | } |
| 162813 | break; | 164291 | break; |
| 162814 | case 310: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ | 164292 | case 312: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */ |
| 162815 | { | 164293 | { |
| 162816 | yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, yymsp[-2].minor.yy70, yymsp[-1].minor.yy70, &yymsp[-5].minor.yy0); | 164294 | yylhsminor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, yymsp[-2].minor.yy562, yymsp[-1].minor.yy562, &yymsp[-5].minor.yy0); |
| 162817 | } | 164295 | } |
| 162818 | yymsp[-5].minor.yy49 = yylhsminor.yy49; | 164296 | yymsp[-5].minor.yy375 = yylhsminor.yy375; |
| 162819 | break; | 164297 | break; |
| 162820 | case 311: /* window ::= ORDER BY sortlist frame_opt */ | 164298 | case 313: /* window ::= ORDER BY sortlist frame_opt */ |
| 162821 | { | 164299 | { |
| 162822 | yymsp[-3].minor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, 0); | 164300 | yymsp[-3].minor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, 0, yymsp[-1].minor.yy562, 0); |
| 162823 | } | 164301 | } |
| 162824 | break; | 164302 | break; |
| 162825 | case 312: /* window ::= nm ORDER BY sortlist frame_opt */ | 164303 | case 314: /* window ::= nm ORDER BY sortlist frame_opt */ |
| 162826 | { | 164304 | { |
| 162827 | yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, yymsp[-1].minor.yy70, &yymsp[-4].minor.yy0); | 164305 | yylhsminor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, 0, yymsp[-1].minor.yy562, &yymsp[-4].minor.yy0); |
| 162828 | } | 164306 | } |
| 162829 | yymsp[-4].minor.yy49 = yylhsminor.yy49; | 164307 | yymsp[-4].minor.yy375 = yylhsminor.yy375; |
| 162830 | break; | 164308 | break; |
| 162831 | case 313: /* window ::= frame_opt */ | 164309 | case 315: /* window ::= frame_opt */ |
| 162832 | case 332: /* filter_over ::= over_clause */ yytestcase(yyruleno==332); | 164310 | case 334: /* filter_over ::= over_clause */ yytestcase(yyruleno==334); |
| 162833 | { | 164311 | { |
| 162834 | yylhsminor.yy49 = yymsp[0].minor.yy49; | 164312 | yylhsminor.yy375 = yymsp[0].minor.yy375; |
| 162835 | } | 164313 | } |
| 162836 | yymsp[0].minor.yy49 = yylhsminor.yy49; | 164314 | yymsp[0].minor.yy375 = yylhsminor.yy375; |
| 162837 | break; | 164315 | break; |
| 162838 | case 314: /* window ::= nm frame_opt */ | 164316 | case 316: /* window ::= nm frame_opt */ |
| 162839 | { | 164317 | { |
| 162840 | yylhsminor.yy49 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy49, 0, 0, &yymsp[-1].minor.yy0); | 164318 | yylhsminor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, 0, 0, &yymsp[-1].minor.yy0); |
| 162841 | } | 164319 | } |
| 162842 | yymsp[-1].minor.yy49 = yylhsminor.yy49; | 164320 | yymsp[-1].minor.yy375 = yylhsminor.yy375; |
| 162843 | break; | 164321 | break; |
| 162844 | case 315: /* frame_opt ::= */ | 164322 | case 317: /* frame_opt ::= */ |
| 162845 | { | 164323 | { |
| 162846 | yymsp[1].minor.yy49 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); | 164324 | yymsp[1].minor.yy375 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0); |
| 162847 | } | 164325 | } |
| 162848 | break; | 164326 | break; |
| 162849 | case 316: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ | 164327 | case 318: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */ |
| 162850 | { | 164328 | { |
| 162851 | yylhsminor.yy49 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy376, yymsp[-1].minor.yy117.eType, yymsp[-1].minor.yy117.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy552); | 164329 | yylhsminor.yy375 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy64, yymsp[-1].minor.yy81.eType, yymsp[-1].minor.yy81.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy534); |
| 162852 | } | 164330 | } |
| 162853 | yymsp[-2].minor.yy49 = yylhsminor.yy49; | 164331 | yymsp[-2].minor.yy375 = yylhsminor.yy375; |
| 162854 | break; | 164332 | break; |
| 162855 | case 317: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ | 164333 | case 319: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */ |
| 162856 | { | 164334 | { |
| 162857 | yylhsminor.yy49 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy376, yymsp[-3].minor.yy117.eType, yymsp[-3].minor.yy117.pExpr, yymsp[-1].minor.yy117.eType, yymsp[-1].minor.yy117.pExpr, yymsp[0].minor.yy552); | 164335 | yylhsminor.yy375 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy64, yymsp[-3].minor.yy81.eType, yymsp[-3].minor.yy81.pExpr, yymsp[-1].minor.yy81.eType, yymsp[-1].minor.yy81.pExpr, yymsp[0].minor.yy534); |
| 162858 | } | 164336 | } |
| 162859 | yymsp[-5].minor.yy49 = yylhsminor.yy49; | 164337 | yymsp[-5].minor.yy375 = yylhsminor.yy375; |
| 162860 | break; | 164338 | break; |
| 162861 | case 319: /* frame_bound_s ::= frame_bound */ | 164339 | case 321: /* frame_bound_s ::= frame_bound */ |
| 162862 | case 321: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==321); | 164340 | case 323: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==323); |
| 162863 | {yylhsminor.yy117 = yymsp[0].minor.yy117;} | 164341 | {yylhsminor.yy81 = yymsp[0].minor.yy81;} |
| 162864 | yymsp[0].minor.yy117 = yylhsminor.yy117; | 164342 | yymsp[0].minor.yy81 = yylhsminor.yy81; |
| 162865 | break; | 164343 | break; |
| 162866 | case 320: /* frame_bound_s ::= UNBOUNDED PRECEDING */ | 164344 | case 322: /* frame_bound_s ::= UNBOUNDED PRECEDING */ |
| 162867 | case 322: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==322); | 164345 | case 324: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==324); |
| 162868 | case 324: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==324); | 164346 | case 326: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==326); |
| 162869 | {yylhsminor.yy117.eType = yymsp[-1].major; yylhsminor.yy117.pExpr = 0;} | 164347 | {yylhsminor.yy81.eType = yymsp[-1].major; yylhsminor.yy81.pExpr = 0;} |
| 162870 | yymsp[-1].minor.yy117 = yylhsminor.yy117; | 164348 | yymsp[-1].minor.yy81 = yylhsminor.yy81; |
| 162871 | break; | 164349 | break; |
| 162872 | case 323: /* frame_bound ::= expr PRECEDING|FOLLOWING */ | 164350 | case 325: /* frame_bound ::= expr PRECEDING|FOLLOWING */ |
| 162873 | {yylhsminor.yy117.eType = yymsp[0].major; yylhsminor.yy117.pExpr = yymsp[-1].minor.yy404;} | 164351 | {yylhsminor.yy81.eType = yymsp[0].major; yylhsminor.yy81.pExpr = yymsp[-1].minor.yy626;} |
| 162874 | yymsp[-1].minor.yy117 = yylhsminor.yy117; | 164352 | yymsp[-1].minor.yy81 = yylhsminor.yy81; |
| 162875 | break; | 164353 | break; |
| 162876 | case 325: /* frame_exclude_opt ::= */ | 164354 | case 327: /* frame_exclude_opt ::= */ |
| 162877 | {yymsp[1].minor.yy552 = 0;} | 164355 | {yymsp[1].minor.yy534 = 0;} |
| 162878 | break; | 164356 | break; |
| 162879 | case 326: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ | 164357 | case 328: /* frame_exclude_opt ::= EXCLUDE frame_exclude */ |
| 162880 | {yymsp[-1].minor.yy552 = yymsp[0].minor.yy552;} | 164358 | {yymsp[-1].minor.yy534 = yymsp[0].minor.yy534;} |
| 162881 | break; | 164359 | break; |
| 162882 | case 327: /* frame_exclude ::= NO OTHERS */ | 164360 | case 329: /* frame_exclude ::= NO OTHERS */ |
| 162883 | case 328: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==328); | 164361 | case 330: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==330); |
| 162884 | {yymsp[-1].minor.yy552 = yymsp[-1].major; /*A-overwrites-X*/} | 164362 | {yymsp[-1].minor.yy534 = yymsp[-1].major; /*A-overwrites-X*/} |
| 162885 | break; | 164363 | break; |
| 162886 | case 329: /* frame_exclude ::= GROUP|TIES */ | 164364 | case 331: /* frame_exclude ::= GROUP|TIES */ |
| 162887 | {yymsp[0].minor.yy552 = yymsp[0].major; /*A-overwrites-X*/} | 164365 | {yymsp[0].minor.yy534 = yymsp[0].major; /*A-overwrites-X*/} |
| 162888 | break; | 164366 | break; |
| 162889 | case 330: /* window_clause ::= WINDOW windowdefn_list */ | 164367 | case 332: /* window_clause ::= WINDOW windowdefn_list */ |
| 162890 | { yymsp[-1].minor.yy49 = yymsp[0].minor.yy49; } | 164368 | { yymsp[-1].minor.yy375 = yymsp[0].minor.yy375; } |
| 162891 | break; | 164369 | break; |
| 162892 | case 331: /* filter_over ::= filter_clause over_clause */ | 164370 | case 333: /* filter_over ::= filter_clause over_clause */ |
| 162893 | { | 164371 | { |
| 162894 | if( yymsp[0].minor.yy49 ){ | 164372 | if( yymsp[0].minor.yy375 ){ |
| 162895 | yymsp[0].minor.yy49->pFilter = yymsp[-1].minor.yy404; | 164373 | yymsp[0].minor.yy375->pFilter = yymsp[-1].minor.yy626; |
| 162896 | }else{ | 164374 | }else{ |
| 162897 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy404); | 164375 | sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy626); |
| 162898 | } | 164376 | } |
| 162899 | yylhsminor.yy49 = yymsp[0].minor.yy49; | 164377 | yylhsminor.yy375 = yymsp[0].minor.yy375; |
| 162900 | } | 164378 | } |
| 162901 | yymsp[-1].minor.yy49 = yylhsminor.yy49; | 164379 | yymsp[-1].minor.yy375 = yylhsminor.yy375; |
| 162902 | break; | 164380 | break; |
| 162903 | case 333: /* filter_over ::= filter_clause */ | 164381 | case 335: /* filter_over ::= filter_clause */ |
| 162904 | { | 164382 | { |
| 162905 | yylhsminor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); | 164383 | yylhsminor.yy375 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 162906 | if( yylhsminor.yy49 ){ | 164384 | if( yylhsminor.yy375 ){ |
| 162907 | yylhsminor.yy49->eFrmType = TK_FILTER; | 164385 | yylhsminor.yy375->eFrmType = TK_FILTER; |
| 162908 | yylhsminor.yy49->pFilter = yymsp[0].minor.yy404; | 164386 | yylhsminor.yy375->pFilter = yymsp[0].minor.yy626; |
| 162909 | }else{ | 164387 | }else{ |
| 162910 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy404); | 164388 | sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy626); |
| 162911 | } | 164389 | } |
| 162912 | } | 164390 | } |
| 162913 | yymsp[0].minor.yy49 = yylhsminor.yy49; | 164391 | yymsp[0].minor.yy375 = yylhsminor.yy375; |
| 162914 | break; | 164392 | break; |
| 162915 | case 334: /* over_clause ::= OVER LP window RP */ | 164393 | case 336: /* over_clause ::= OVER LP window RP */ |
| 162916 | { | 164394 | { |
| 162917 | yymsp[-3].minor.yy49 = yymsp[-1].minor.yy49; | 164395 | yymsp[-3].minor.yy375 = yymsp[-1].minor.yy375; |
| 162918 | assert( yymsp[-3].minor.yy49!=0 ); | 164396 | assert( yymsp[-3].minor.yy375!=0 ); |
| 162919 | } | 164397 | } |
| 162920 | break; | 164398 | break; |
| 162921 | case 335: /* over_clause ::= OVER nm */ | 164399 | case 337: /* over_clause ::= OVER nm */ |
| 162922 | { | 164400 | { |
| 162923 | yymsp[-1].minor.yy49 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); | 164401 | yymsp[-1].minor.yy375 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window)); |
| 162924 | if( yymsp[-1].minor.yy49 ){ | 164402 | if( yymsp[-1].minor.yy375 ){ |
| 162925 | yymsp[-1].minor.yy49->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); | 164403 | yymsp[-1].minor.yy375->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n); |
| 162926 | } | 164404 | } |
| 162927 | } | 164405 | } |
| 162928 | break; | 164406 | break; |
| 162929 | case 336: /* filter_clause ::= FILTER LP WHERE expr RP */ | 164407 | case 338: /* filter_clause ::= FILTER LP WHERE expr RP */ |
| 162930 | { yymsp[-4].minor.yy404 = yymsp[-1].minor.yy404; } | 164408 | { yymsp[-4].minor.yy626 = yymsp[-1].minor.yy626; } |
| 162931 | break; | 164409 | break; |
| 162932 | default: | 164410 | default: |
| 162933 | /* (337) input ::= cmdlist */ yytestcase(yyruleno==337); | 164411 | /* (339) input ::= cmdlist */ yytestcase(yyruleno==339); |
| 162934 | /* (338) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==338); | 164412 | /* (340) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==340); |
| 162935 | /* (339) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=339); | 164413 | /* (341) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=341); |
| 162936 | /* (340) ecmd ::= SEMI */ yytestcase(yyruleno==340); | 164414 | /* (342) ecmd ::= SEMI */ yytestcase(yyruleno==342); |
| 162937 | /* (341) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==341); | 164415 | /* (343) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==343); |
| 162938 | /* (342) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=342); | 164416 | /* (344) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=344); |
| 162939 | /* (343) trans_opt ::= */ yytestcase(yyruleno==343); | 164417 | /* (345) trans_opt ::= */ yytestcase(yyruleno==345); |
| 162940 | /* (344) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==344); | 164418 | /* (346) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==346); |
| 162941 | /* (345) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==345); | 164419 | /* (347) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==347); |
| 162942 | /* (346) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==346); | 164420 | /* (348) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==348); |
| 162943 | /* (347) savepoint_opt ::= */ yytestcase(yyruleno==347); | 164421 | /* (349) savepoint_opt ::= */ yytestcase(yyruleno==349); |
| 162944 | /* (348) cmd ::= create_table create_table_args */ yytestcase(yyruleno==348); | 164422 | /* (350) cmd ::= create_table create_table_args */ yytestcase(yyruleno==350); |
| 162945 | /* (349) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==349); | 164423 | /* (351) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=351); |
| 162946 | /* (350) columnlist ::= columnname carglist */ yytestcase(yyruleno==350); | 164424 | /* (352) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==352); |
| 162947 | /* (351) nm ::= ID|INDEXED */ yytestcase(yyruleno==351); | 164425 | /* (353) columnlist ::= columnname carglist */ yytestcase(yyruleno==353); |
| 162948 | /* (352) nm ::= STRING */ yytestcase(yyruleno==352); | 164426 | /* (354) nm ::= ID|INDEXED */ yytestcase(yyruleno==354); |
| 162949 | /* (353) nm ::= JOIN_KW */ yytestcase(yyruleno==353); | 164427 | /* (355) nm ::= STRING */ yytestcase(yyruleno==355); |
| 162950 | /* (354) typetoken ::= typename */ yytestcase(yyruleno==354); | 164428 | /* (356) nm ::= JOIN_KW */ yytestcase(yyruleno==356); |
| 162951 | /* (355) typename ::= ID|STRING */ yytestcase(yyruleno==355); | 164429 | /* (357) typetoken ::= typename */ yytestcase(yyruleno==357); |
| 162952 | /* (356) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=356); | 164430 | /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358); |
| 162953 | /* (357) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=357); | 164431 | /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359); |
| 162954 | /* (358) carglist ::= carglist ccons */ yytestcase(yyruleno==358); | 164432 | /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360); |
| 162955 | /* (359) carglist ::= */ yytestcase(yyruleno==359); | 164433 | /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361); |
| 162956 | /* (360) ccons ::= NULL onconf */ yytestcase(yyruleno==360); | 164434 | /* (362) carglist ::= */ yytestcase(yyruleno==362); |
| 162957 | /* (361) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==361); | 164435 | /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363); |
| 162958 | /* (362) ccons ::= AS generated */ yytestcase(yyruleno==362); | 164436 | /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364); |
| 162959 | /* (363) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==363); | 164437 | /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365); |
| 162960 | /* (364) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==364); | 164438 | /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366); |
| 162961 | /* (365) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=365); | 164439 | /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367); |
| 162962 | /* (366) tconscomma ::= */ yytestcase(yyruleno==366); | 164440 | /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368); |
| 162963 | /* (367) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=367); | 164441 | /* (369) tconscomma ::= */ yytestcase(yyruleno==369); |
| 162964 | /* (368) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=368); | 164442 | /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370); |
| 162965 | /* (369) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=369); | 164443 | /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371); |
| 162966 | /* (370) oneselect ::= values */ yytestcase(yyruleno==370); | 164444 | /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372); |
| 162967 | /* (371) sclp ::= selcollist COMMA */ yytestcase(yyruleno==371); | 164445 | /* (373) oneselect ::= values */ yytestcase(yyruleno==373); |
| 162968 | /* (372) as ::= ID|STRING */ yytestcase(yyruleno==372); | 164446 | /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374); |
| 162969 | /* (373) returning ::= */ yytestcase(yyruleno==373); | 164447 | /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375); |
| 162970 | /* (374) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=374); | 164448 | /* (376) returning ::= */ yytestcase(yyruleno==376); |
| 162971 | /* (375) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==375); | 164449 | /* (377) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=377); |
| 162972 | /* (376) exprlist ::= nexprlist */ yytestcase(yyruleno==376); | 164450 | /* (378) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==378); |
| 162973 | /* (377) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=377); | 164451 | /* (379) exprlist ::= nexprlist */ yytestcase(yyruleno==379); |
| 162974 | /* (378) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=378); | 164452 | /* (380) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=380); |
| 162975 | /* (379) nmnum ::= ON */ yytestcase(yyruleno==379); | 164453 | /* (381) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=381); |
| 162976 | /* (380) nmnum ::= DELETE */ yytestcase(yyruleno==380); | 164454 | /* (382) nmnum ::= ON */ yytestcase(yyruleno==382); |
| 162977 | /* (381) nmnum ::= DEFAULT */ yytestcase(yyruleno==381); | 164455 | /* (383) nmnum ::= DELETE */ yytestcase(yyruleno==383); |
| 162978 | /* (382) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==382); | 164456 | /* (384) nmnum ::= DEFAULT */ yytestcase(yyruleno==384); |
| 162979 | /* (383) foreach_clause ::= */ yytestcase(yyruleno==383); | 164457 | /* (385) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==385); |
| 162980 | /* (384) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==384); | 164458 | /* (386) foreach_clause ::= */ yytestcase(yyruleno==386); |
| 162981 | /* (385) trnm ::= nm */ yytestcase(yyruleno==385); | 164459 | /* (387) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==387); |
| 162982 | /* (386) tridxby ::= */ yytestcase(yyruleno==386); | 164460 | /* (388) trnm ::= nm */ yytestcase(yyruleno==388); |
| 162983 | /* (387) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==387); | 164461 | /* (389) tridxby ::= */ yytestcase(yyruleno==389); |
| 162984 | /* (388) database_kw_opt ::= */ yytestcase(yyruleno==388); | 164462 | /* (390) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==390); |
| 162985 | /* (389) kwcolumn_opt ::= */ yytestcase(yyruleno==389); | 164463 | /* (391) database_kw_opt ::= */ yytestcase(yyruleno==391); |
| 162986 | /* (390) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==390); | 164464 | /* (392) kwcolumn_opt ::= */ yytestcase(yyruleno==392); |
| 162987 | /* (391) vtabarglist ::= vtabarg */ yytestcase(yyruleno==391); | 164465 | /* (393) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==393); |
| 162988 | /* (392) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==392); | 164466 | /* (394) vtabarglist ::= vtabarg */ yytestcase(yyruleno==394); |
| 162989 | /* (393) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==393); | 164467 | /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==395); |
| 162990 | /* (394) anylist ::= */ yytestcase(yyruleno==394); | 164468 | /* (396) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==396); |
| 162991 | /* (395) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==395); | 164469 | /* (397) anylist ::= */ yytestcase(yyruleno==397); |
| 162992 | /* (396) anylist ::= anylist ANY */ yytestcase(yyruleno==396); | 164470 | /* (398) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==398); |
| 162993 | /* (397) with ::= */ yytestcase(yyruleno==397); | 164471 | /* (399) anylist ::= anylist ANY */ yytestcase(yyruleno==399); |
| 164472 | /* (400) with ::= */ yytestcase(yyruleno==400); | ||
| 162994 | break; | 164473 | break; |
| 162995 | /********** End reduce actions ************************************************/ | 164474 | /********** End reduce actions ************************************************/ |
| 162996 | }; | 164475 | }; |
| @@ -163148,8 +164627,8 @@ SQLITE_PRIVATE void sqlite3Parser( | |||
| 163148 | yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); | 164627 | yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); |
| 163149 | if( yyact >= YY_MIN_REDUCE ){ | 164628 | if( yyact >= YY_MIN_REDUCE ){ |
| 163150 | unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ | 164629 | unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ |
| 163151 | assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); | ||
| 163152 | #ifndef NDEBUG | 164630 | #ifndef NDEBUG |
| 164631 | assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); | ||
| 163153 | if( yyTraceFILE ){ | 164632 | if( yyTraceFILE ){ |
| 163154 | int yysize = yyRuleInfoNRhs[yyruleno]; | 164633 | int yysize = yyRuleInfoNRhs[yyruleno]; |
| 163155 | if( yysize ){ | 164634 | if( yysize ){ |
| @@ -163247,14 +164726,13 @@ SQLITE_PRIVATE void sqlite3Parser( | |||
| 163247 | yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); | 164726 | yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); |
| 163248 | yymajor = YYNOCODE; | 164727 | yymajor = YYNOCODE; |
| 163249 | }else{ | 164728 | }else{ |
| 163250 | while( yypParser->yytos >= yypParser->yystack | 164729 | while( yypParser->yytos > yypParser->yystack ){ |
| 163251 | && (yyact = yy_find_reduce_action( | 164730 | yyact = yy_find_reduce_action(yypParser->yytos->stateno, |
| 163252 | yypParser->yytos->stateno, | 164731 | YYERRORSYMBOL); |
| 163253 | YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE | 164732 | if( yyact<=YY_MAX_SHIFTREDUCE ) break; |
| 163254 | ){ | ||
| 163255 | yy_pop_parser_stack(yypParser); | 164733 | yy_pop_parser_stack(yypParser); |
| 163256 | } | 164734 | } |
| 163257 | if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ | 164735 | if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){ |
| 163258 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); | 164736 | yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
| 163259 | yy_parse_failed(yypParser); | 164737 | yy_parse_failed(yypParser); |
| 163260 | #ifndef YYNOERRORRECOVERY | 164738 | #ifndef YYNOERRORRECOVERY |
| @@ -164397,6 +165875,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr | |||
| 164397 | int lastTokenParsed = -1; /* type of the previous token */ | 165875 | int lastTokenParsed = -1; /* type of the previous token */ |
| 164398 | sqlite3 *db = pParse->db; /* The database connection */ | 165876 | sqlite3 *db = pParse->db; /* The database connection */ |
| 164399 | int mxSqlLen; /* Max length of an SQL string */ | 165877 | int mxSqlLen; /* Max length of an SQL string */ |
| 165878 | Parse *pParentParse = 0; /* Outer parse context, if any */ | ||
| 164400 | #ifdef sqlite3Parser_ENGINEALWAYSONSTACK | 165879 | #ifdef sqlite3Parser_ENGINEALWAYSONSTACK |
| 164401 | yyParser sEngine; /* Space to hold the Lemon-generated Parser object */ | 165880 | yyParser sEngine; /* Space to hold the Lemon-generated Parser object */ |
| 164402 | #endif | 165881 | #endif |
| @@ -164432,7 +165911,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr | |||
| 164432 | assert( pParse->pNewTrigger==0 ); | 165911 | assert( pParse->pNewTrigger==0 ); |
| 164433 | assert( pParse->nVar==0 ); | 165912 | assert( pParse->nVar==0 ); |
| 164434 | assert( pParse->pVList==0 ); | 165913 | assert( pParse->pVList==0 ); |
| 164435 | pParse->pParentParse = db->pParse; | 165914 | pParentParse = db->pParse; |
| 164436 | db->pParse = pParse; | 165915 | db->pParse = pParse; |
| 164437 | while( 1 ){ | 165916 | while( 1 ){ |
| 164438 | n = sqlite3GetToken((u8*)zSql, &tokenType); | 165917 | n = sqlite3GetToken((u8*)zSql, &tokenType); |
| @@ -164547,8 +166026,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr | |||
| 164547 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); | 166026 | sqlite3DeleteTrigger(db, pParse->pNewTrigger); |
| 164548 | } | 166027 | } |
| 164549 | sqlite3DbFree(db, pParse->pVList); | 166028 | sqlite3DbFree(db, pParse->pVList); |
| 164550 | db->pParse = pParse->pParentParse; | 166029 | db->pParse = pParentParse; |
| 164551 | pParse->pParentParse = 0; | ||
| 164552 | assert( nErr==0 || pParse->rc!=SQLITE_OK ); | 166030 | assert( nErr==0 || pParse->rc!=SQLITE_OK ); |
| 164553 | return nErr; | 166031 | return nErr; |
| 164554 | } | 166032 | } |
| @@ -166165,7 +167643,7 @@ SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3 *db, sqlite3_int64 iRowid) | |||
| 166165 | /* | 167643 | /* |
| 166166 | ** Return the number of changes in the most recent call to sqlite3_exec(). | 167644 | ** Return the number of changes in the most recent call to sqlite3_exec(). |
| 166167 | */ | 167645 | */ |
| 166168 | SQLITE_API int sqlite3_changes(sqlite3 *db){ | 167646 | SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3 *db){ |
| 166169 | #ifdef SQLITE_ENABLE_API_ARMOR | 167647 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 166170 | if( !sqlite3SafetyCheckOk(db) ){ | 167648 | if( !sqlite3SafetyCheckOk(db) ){ |
| 166171 | (void)SQLITE_MISUSE_BKPT; | 167649 | (void)SQLITE_MISUSE_BKPT; |
| @@ -166174,11 +167652,14 @@ SQLITE_API int sqlite3_changes(sqlite3 *db){ | |||
| 166174 | #endif | 167652 | #endif |
| 166175 | return db->nChange; | 167653 | return db->nChange; |
| 166176 | } | 167654 | } |
| 167655 | SQLITE_API int sqlite3_changes(sqlite3 *db){ | ||
| 167656 | return (int)sqlite3_changes64(db); | ||
| 167657 | } | ||
| 166177 | 167658 | ||
| 166178 | /* | 167659 | /* |
| 166179 | ** Return the number of changes since the database handle was opened. | 167660 | ** Return the number of changes since the database handle was opened. |
| 166180 | */ | 167661 | */ |
| 166181 | SQLITE_API int sqlite3_total_changes(sqlite3 *db){ | 167662 | SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3 *db){ |
| 166182 | #ifdef SQLITE_ENABLE_API_ARMOR | 167663 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 166183 | if( !sqlite3SafetyCheckOk(db) ){ | 167664 | if( !sqlite3SafetyCheckOk(db) ){ |
| 166184 | (void)SQLITE_MISUSE_BKPT; | 167665 | (void)SQLITE_MISUSE_BKPT; |
| @@ -166187,6 +167668,9 @@ SQLITE_API int sqlite3_total_changes(sqlite3 *db){ | |||
| 166187 | #endif | 167668 | #endif |
| 166188 | return db->nTotalChange; | 167669 | return db->nTotalChange; |
| 166189 | } | 167670 | } |
| 167671 | SQLITE_API int sqlite3_total_changes(sqlite3 *db){ | ||
| 167672 | return (int)sqlite3_total_changes64(db); | ||
| 167673 | } | ||
| 166190 | 167674 | ||
| 166191 | /* | 167675 | /* |
| 166192 | ** Close all open savepoints. This function only manipulates fields of the | 167676 | ** Close all open savepoints. This function only manipulates fields of the |
| @@ -166211,7 +167695,9 @@ SQLITE_PRIVATE void sqlite3CloseSavepoints(sqlite3 *db){ | |||
| 166211 | ** with SQLITE_ANY as the encoding. | 167695 | ** with SQLITE_ANY as the encoding. |
| 166212 | */ | 167696 | */ |
| 166213 | static void functionDestroy(sqlite3 *db, FuncDef *p){ | 167697 | static void functionDestroy(sqlite3 *db, FuncDef *p){ |
| 166214 | FuncDestructor *pDestructor = p->u.pDestructor; | 167698 | FuncDestructor *pDestructor; |
| 167699 | assert( (p->funcFlags & SQLITE_FUNC_BUILTIN)==0 ); | ||
| 167700 | pDestructor = p->u.pDestructor; | ||
| 166215 | if( pDestructor ){ | 167701 | if( pDestructor ){ |
| 166216 | pDestructor->nRef--; | 167702 | pDestructor->nRef--; |
| 166217 | if( pDestructor->nRef==0 ){ | 167703 | if( pDestructor->nRef==0 ){ |
| @@ -166315,7 +167801,7 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){ | |||
| 166315 | 167801 | ||
| 166316 | /* Convert the connection into a zombie and then close it. | 167802 | /* Convert the connection into a zombie and then close it. |
| 166317 | */ | 167803 | */ |
| 166318 | db->magic = SQLITE_MAGIC_ZOMBIE; | 167804 | db->eOpenState = SQLITE_STATE_ZOMBIE; |
| 166319 | sqlite3LeaveMutexAndCloseZombie(db); | 167805 | sqlite3LeaveMutexAndCloseZombie(db); |
| 166320 | return SQLITE_OK; | 167806 | return SQLITE_OK; |
| 166321 | } | 167807 | } |
| @@ -166379,7 +167865,7 @@ SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){ | |||
| 166379 | ** or if the connection has not yet been closed by sqlite3_close_v2(), | 167865 | ** or if the connection has not yet been closed by sqlite3_close_v2(), |
| 166380 | ** then just leave the mutex and return. | 167866 | ** then just leave the mutex and return. |
| 166381 | */ | 167867 | */ |
| 166382 | if( db->magic!=SQLITE_MAGIC_ZOMBIE || connectionIsBusy(db) ){ | 167868 | if( db->eOpenState!=SQLITE_STATE_ZOMBIE || connectionIsBusy(db) ){ |
| 166383 | sqlite3_mutex_leave(db->mutex); | 167869 | sqlite3_mutex_leave(db->mutex); |
| 166384 | return; | 167870 | return; |
| 166385 | } | 167871 | } |
| @@ -166465,7 +167951,7 @@ SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){ | |||
| 166465 | sqlite3_free(db->auth.zAuthPW); | 167951 | sqlite3_free(db->auth.zAuthPW); |
| 166466 | #endif | 167952 | #endif |
| 166467 | 167953 | ||
| 166468 | db->magic = SQLITE_MAGIC_ERROR; | 167954 | db->eOpenState = SQLITE_STATE_ERROR; |
| 166469 | 167955 | ||
| 166470 | /* The temp-database schema is allocated differently from the other schema | 167956 | /* The temp-database schema is allocated differently from the other schema |
| 166471 | ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()). | 167957 | ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()). |
| @@ -166474,8 +167960,11 @@ SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){ | |||
| 166474 | ** structure? | 167960 | ** structure? |
| 166475 | */ | 167961 | */ |
| 166476 | sqlite3DbFree(db, db->aDb[1].pSchema); | 167962 | sqlite3DbFree(db, db->aDb[1].pSchema); |
| 167963 | if( db->xAutovacDestr ){ | ||
| 167964 | db->xAutovacDestr(db->pAutovacPagesArg); | ||
| 167965 | } | ||
| 166477 | sqlite3_mutex_leave(db->mutex); | 167966 | sqlite3_mutex_leave(db->mutex); |
| 166478 | db->magic = SQLITE_MAGIC_CLOSED; | 167967 | db->eOpenState = SQLITE_STATE_CLOSED; |
| 166479 | sqlite3_mutex_free(db->mutex); | 167968 | sqlite3_mutex_free(db->mutex); |
| 166480 | assert( sqlite3LookasideUsed(db,0)==0 ); | 167969 | assert( sqlite3LookasideUsed(db,0)==0 ); |
| 166481 | if( db->lookaside.bMalloced ){ | 167970 | if( db->lookaside.bMalloced ){ |
| @@ -166528,7 +168017,7 @@ SQLITE_PRIVATE void sqlite3RollbackAll(sqlite3 *db, int tripCode){ | |||
| 166528 | /* Any deferred constraint violations have now been resolved. */ | 168017 | /* Any deferred constraint violations have now been resolved. */ |
| 166529 | db->nDeferredCons = 0; | 168018 | db->nDeferredCons = 0; |
| 166530 | db->nDeferredImmCons = 0; | 168019 | db->nDeferredImmCons = 0; |
| 166531 | db->flags &= ~(u64)SQLITE_DeferFKs; | 168020 | db->flags &= ~(u64)(SQLITE_DeferFKs|SQLITE_CorruptRdOnly); |
| 166532 | 168021 | ||
| 166533 | /* If one has been configured, invoke the rollback-hook callback */ | 168022 | /* If one has been configured, invoke the rollback-hook callback */ |
| 166534 | if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){ | 168023 | if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){ |
| @@ -166863,7 +168352,7 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){ | |||
| 166863 | */ | 168352 | */ |
| 166864 | SQLITE_API void sqlite3_interrupt(sqlite3 *db){ | 168353 | SQLITE_API void sqlite3_interrupt(sqlite3 *db){ |
| 166865 | #ifdef SQLITE_ENABLE_API_ARMOR | 168354 | #ifdef SQLITE_ENABLE_API_ARMOR |
| 166866 | if( !sqlite3SafetyCheckOk(db) && (db==0 || db->magic!=SQLITE_MAGIC_ZOMBIE) ){ | 168355 | if( !sqlite3SafetyCheckOk(db) && (db==0 || db->eOpenState!=SQLITE_STATE_ZOMBIE) ){ |
| 166867 | (void)SQLITE_MISUSE_BKPT; | 168356 | (void)SQLITE_MISUSE_BKPT; |
| 166868 | return; | 168357 | return; |
| 166869 | } | 168358 | } |
| @@ -166892,7 +168381,6 @@ SQLITE_PRIVATE int sqlite3CreateFunc( | |||
| 166892 | FuncDestructor *pDestructor | 168381 | FuncDestructor *pDestructor |
| 166893 | ){ | 168382 | ){ |
| 166894 | FuncDef *p; | 168383 | FuncDef *p; |
| 166895 | int nName; | ||
| 166896 | int extraFlags; | 168384 | int extraFlags; |
| 166897 | 168385 | ||
| 166898 | assert( sqlite3_mutex_held(db->mutex) ); | 168386 | assert( sqlite3_mutex_held(db->mutex) ); |
| @@ -166902,7 +168390,7 @@ SQLITE_PRIVATE int sqlite3CreateFunc( | |||
| 166902 | || ((xFinal==0)!=(xStep==0)) /* Both or neither of xFinal and xStep */ | 168390 | || ((xFinal==0)!=(xStep==0)) /* Both or neither of xFinal and xStep */ |
| 166903 | || ((xValue==0)!=(xInverse==0)) /* Both or neither of xValue, xInverse */ | 168391 | || ((xValue==0)!=(xInverse==0)) /* Both or neither of xValue, xInverse */ |
| 166904 | || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) | 168392 | || (nArg<-1 || nArg>SQLITE_MAX_FUNCTION_ARG) |
| 166905 | || (255<(nName = sqlite3Strlen30( zFunctionName))) | 168393 | || (255<sqlite3Strlen30(zFunctionName)) |
| 166906 | ){ | 168394 | ){ |
| 166907 | return SQLITE_MISUSE_BKPT; | 168395 | return SQLITE_MISUSE_BKPT; |
| 166908 | } | 168396 | } |
| @@ -166927,22 +168415,33 @@ SQLITE_PRIVATE int sqlite3CreateFunc( | |||
| 166927 | ** If SQLITE_ANY is specified, add three versions of the function | 168415 | ** If SQLITE_ANY is specified, add three versions of the function |
| 166928 | ** to the hash table. | 168416 | ** to the hash table. |
| 166929 | */ | 168417 | */ |
| 166930 | if( enc==SQLITE_UTF16 ){ | 168418 | switch( enc ){ |
| 166931 | enc = SQLITE_UTF16NATIVE; | 168419 | case SQLITE_UTF16: |
| 166932 | }else if( enc==SQLITE_ANY ){ | 168420 | enc = SQLITE_UTF16NATIVE; |
| 166933 | int rc; | 168421 | break; |
| 166934 | rc = sqlite3CreateFunc(db, zFunctionName, nArg, | 168422 | case SQLITE_ANY: { |
| 166935 | (SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE, | 168423 | int rc; |
| 166936 | pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor); | ||
| 166937 | if( rc==SQLITE_OK ){ | ||
| 166938 | rc = sqlite3CreateFunc(db, zFunctionName, nArg, | 168424 | rc = sqlite3CreateFunc(db, zFunctionName, nArg, |
| 166939 | (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE, | 168425 | (SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE, |
| 166940 | pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor); | 168426 | pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor); |
| 168427 | if( rc==SQLITE_OK ){ | ||
| 168428 | rc = sqlite3CreateFunc(db, zFunctionName, nArg, | ||
| 168429 | (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE, | ||
| 168430 | pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor); | ||
| 168431 | } | ||
| 168432 | if( rc!=SQLITE_OK ){ | ||
| 168433 | return rc; | ||
| 168434 | } | ||
| 168435 | enc = SQLITE_UTF16BE; | ||
| 168436 | break; | ||
| 166941 | } | 168437 | } |
| 166942 | if( rc!=SQLITE_OK ){ | 168438 | case SQLITE_UTF8: |
| 166943 | return rc; | 168439 | case SQLITE_UTF16LE: |
| 166944 | } | 168440 | case SQLITE_UTF16BE: |
| 166945 | enc = SQLITE_UTF16BE; | 168441 | break; |
| 168442 | default: | ||
| 168443 | enc = SQLITE_UTF8; | ||
| 168444 | break; | ||
| 166946 | } | 168445 | } |
| 166947 | #else | 168446 | #else |
| 166948 | enc = SQLITE_UTF8; | 168447 | enc = SQLITE_UTF8; |
| @@ -167039,7 +168538,7 @@ static int createFunctionApi( | |||
| 167039 | xSFunc, xStep, xFinal, xValue, xInverse, pArg | 168538 | xSFunc, xStep, xFinal, xValue, xInverse, pArg |
| 167040 | ); | 168539 | ); |
| 167041 | if( pArg && pArg->nRef==0 ){ | 168540 | if( pArg && pArg->nRef==0 ){ |
| 167042 | assert( rc!=SQLITE_OK ); | 168541 | assert( rc!=SQLITE_OK || (xStep==0 && xFinal==0) ); |
| 167043 | xDestroy(p); | 168542 | xDestroy(p); |
| 167044 | sqlite3_free(pArg); | 168543 | sqlite3_free(pArg); |
| 167045 | } | 168544 | } |
| @@ -167365,6 +168864,34 @@ SQLITE_API void *sqlite3_preupdate_hook( | |||
| 167365 | } | 168864 | } |
| 167366 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ | 168865 | #endif /* SQLITE_ENABLE_PREUPDATE_HOOK */ |
| 167367 | 168866 | ||
| 168867 | /* | ||
| 168868 | ** Register a function to be invoked prior to each autovacuum that | ||
| 168869 | ** determines the number of pages to vacuum. | ||
| 168870 | */ | ||
| 168871 | SQLITE_API int sqlite3_autovacuum_pages( | ||
| 168872 | sqlite3 *db, /* Attach the hook to this database */ | ||
| 168873 | unsigned int (*xCallback)(void*,const char*,u32,u32,u32), | ||
| 168874 | void *pArg, /* Argument to the function */ | ||
| 168875 | void (*xDestructor)(void*) /* Destructor for pArg */ | ||
| 168876 | ){ | ||
| 168877 | #ifdef SQLITE_ENABLE_API_ARMOR | ||
| 168878 | if( !sqlite3SafetyCheckOk(db) ){ | ||
| 168879 | if( xDestructor ) xDestructor(pArg); | ||
| 168880 | return SQLITE_MISUSE_BKPT; | ||
| 168881 | } | ||
| 168882 | #endif | ||
| 168883 | sqlite3_mutex_enter(db->mutex); | ||
| 168884 | if( db->xAutovacDestr ){ | ||
| 168885 | db->xAutovacDestr(db->pAutovacPagesArg); | ||
| 168886 | } | ||
| 168887 | db->xAutovacPages = xCallback; | ||
| 168888 | db->pAutovacPagesArg = pArg; | ||
| 168889 | db->xAutovacDestr = xDestructor; | ||
| 168890 | sqlite3_mutex_leave(db->mutex); | ||
| 168891 | return SQLITE_OK; | ||
| 168892 | } | ||
| 168893 | |||
| 168894 | |||
| 167368 | #ifndef SQLITE_OMIT_WAL | 168895 | #ifndef SQLITE_OMIT_WAL |
| 167369 | /* | 168896 | /* |
| 167370 | ** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint(). | 168897 | ** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint(). |
| @@ -167887,6 +169414,8 @@ SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){ | |||
| 167887 | if( newLimit>=0 ){ /* IMP: R-52476-28732 */ | 169414 | if( newLimit>=0 ){ /* IMP: R-52476-28732 */ |
| 167888 | if( newLimit>aHardLimit[limitId] ){ | 169415 | if( newLimit>aHardLimit[limitId] ){ |
| 167889 | newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ | 169416 | newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ |
| 169417 | }else if( newLimit<1 && limitId==SQLITE_LIMIT_LENGTH ){ | ||
| 169418 | newLimit = 1; | ||
| 167890 | } | 169419 | } |
| 167891 | db->aLimit[limitId] = newLimit; | 169420 | db->aLimit[limitId] = newLimit; |
| 167892 | } | 169421 | } |
| @@ -168158,7 +169687,7 @@ SQLITE_PRIVATE int sqlite3ParseUri( | |||
| 168158 | */ | 169687 | */ |
| 168159 | static const char *uriParameter(const char *zFilename, const char *zParam){ | 169688 | static const char *uriParameter(const char *zFilename, const char *zParam){ |
| 168160 | zFilename += sqlite3Strlen30(zFilename) + 1; | 169689 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| 168161 | while( zFilename[0] ){ | 169690 | while( ALWAYS(zFilename!=0) && zFilename[0] ){ |
| 168162 | int x = strcmp(zFilename, zParam); | 169691 | int x = strcmp(zFilename, zParam); |
| 168163 | zFilename += sqlite3Strlen30(zFilename) + 1; | 169692 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| 168164 | if( x==0 ) return zFilename; | 169693 | if( x==0 ) return zFilename; |
| @@ -168218,8 +169747,8 @@ static int openDatabase( | |||
| 168218 | ** dealt with in the previous code block. Besides these, the only | 169747 | ** dealt with in the previous code block. Besides these, the only |
| 168219 | ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, | 169748 | ** valid input flags for sqlite3_open_v2() are SQLITE_OPEN_READONLY, |
| 168220 | ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, | 169749 | ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE, |
| 168221 | ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask | 169750 | ** SQLITE_OPEN_PRIVATECACHE, SQLITE_OPEN_EXRESCODE, and some reserved |
| 168222 | ** off all other flags. | 169751 | ** bits. Silently mask off all other flags. |
| 168223 | */ | 169752 | */ |
| 168224 | flags &= ~( SQLITE_OPEN_DELETEONCLOSE | | 169753 | flags &= ~( SQLITE_OPEN_DELETEONCLOSE | |
| 168225 | SQLITE_OPEN_EXCLUSIVE | | 169754 | SQLITE_OPEN_EXCLUSIVE | |
| @@ -168254,9 +169783,9 @@ static int openDatabase( | |||
| 168254 | } | 169783 | } |
| 168255 | } | 169784 | } |
| 168256 | sqlite3_mutex_enter(db->mutex); | 169785 | sqlite3_mutex_enter(db->mutex); |
| 168257 | db->errMask = 0xff; | 169786 | db->errMask = (flags & SQLITE_OPEN_EXRESCODE)!=0 ? 0xffffffff : 0xff; |
| 168258 | db->nDb = 2; | 169787 | db->nDb = 2; |
| 168259 | db->magic = SQLITE_MAGIC_BUSY; | 169788 | db->eOpenState = SQLITE_STATE_BUSY; |
| 168260 | db->aDb = db->aDbStatic; | 169789 | db->aDb = db->aDbStatic; |
| 168261 | db->lookaside.bDisable = 1; | 169790 | db->lookaside.bDisable = 1; |
| 168262 | db->lookaside.sz = 0; | 169791 | db->lookaside.sz = 0; |
| @@ -168268,7 +169797,15 @@ static int openDatabase( | |||
| 168268 | db->nextAutovac = -1; | 169797 | db->nextAutovac = -1; |
| 168269 | db->szMmap = sqlite3GlobalConfig.szMmap; | 169798 | db->szMmap = sqlite3GlobalConfig.szMmap; |
| 168270 | db->nextPagesize = 0; | 169799 | db->nextPagesize = 0; |
| 169800 | db->init.azInit = sqlite3StdType; /* Any array of string ptrs will do */ | ||
| 169801 | #ifdef SQLITE_ENABLE_SORTER_MMAP | ||
| 169802 | /* Beginning with version 3.37.0, using the VFS xFetch() API to memory-map | ||
| 169803 | ** the temporary files used to do external sorts (see code in vdbesort.c) | ||
| 169804 | ** is disabled. It can still be used either by defining | ||
| 169805 | ** SQLITE_ENABLE_SORTER_MMAP at compile time or by using the | ||
| 169806 | ** SQLITE_TESTCTRL_SORTER_MMAP test-control at runtime. */ | ||
| 168271 | db->nMaxSorterMmap = 0x7FFFFFFF; | 169807 | db->nMaxSorterMmap = 0x7FFFFFFF; |
| 169808 | #endif | ||
| 168272 | db->flags |= SQLITE_ShortColNames | 169809 | db->flags |= SQLITE_ShortColNames |
| 168273 | | SQLITE_EnableTrigger | 169810 | | SQLITE_EnableTrigger |
| 168274 | | SQLITE_EnableView | 169811 | | SQLITE_EnableView |
| @@ -168416,7 +169953,7 @@ static int openDatabase( | |||
| 168416 | db->aDb[1].zDbSName = "temp"; | 169953 | db->aDb[1].zDbSName = "temp"; |
| 168417 | db->aDb[1].safety_level = PAGER_SYNCHRONOUS_OFF; | 169954 | db->aDb[1].safety_level = PAGER_SYNCHRONOUS_OFF; |
| 168418 | 169955 | ||
| 168419 | db->magic = SQLITE_MAGIC_OPEN; | 169956 | db->eOpenState = SQLITE_STATE_OPEN; |
| 168420 | if( db->mallocFailed ){ | 169957 | if( db->mallocFailed ){ |
| 168421 | goto opendb_out; | 169958 | goto opendb_out; |
| 168422 | } | 169959 | } |
| @@ -168478,12 +170015,12 @@ opendb_out: | |||
| 168478 | sqlite3_mutex_leave(db->mutex); | 170015 | sqlite3_mutex_leave(db->mutex); |
| 168479 | } | 170016 | } |
| 168480 | rc = sqlite3_errcode(db); | 170017 | rc = sqlite3_errcode(db); |
| 168481 | assert( db!=0 || rc==SQLITE_NOMEM ); | 170018 | assert( db!=0 || (rc&0xff)==SQLITE_NOMEM ); |
| 168482 | if( rc==SQLITE_NOMEM ){ | 170019 | if( (rc&0xff)==SQLITE_NOMEM ){ |
| 168483 | sqlite3_close(db); | 170020 | sqlite3_close(db); |
| 168484 | db = 0; | 170021 | db = 0; |
| 168485 | }else if( rc!=SQLITE_OK ){ | 170022 | }else if( rc!=SQLITE_OK ){ |
| 168486 | db->magic = SQLITE_MAGIC_SICK; | 170023 | db->eOpenState = SQLITE_STATE_SICK; |
| 168487 | } | 170024 | } |
| 168488 | *ppDb = db; | 170025 | *ppDb = db; |
| 168489 | #ifdef SQLITE_ENABLE_SQLLOG | 170026 | #ifdef SQLITE_ENABLE_SQLLOG |
| @@ -168494,7 +170031,7 @@ opendb_out: | |||
| 168494 | } | 170031 | } |
| 168495 | #endif | 170032 | #endif |
| 168496 | sqlite3_free_filename(zOpen); | 170033 | sqlite3_free_filename(zOpen); |
| 168497 | return rc & 0xff; | 170034 | return rc; |
| 168498 | } | 170035 | } |
| 168499 | 170036 | ||
| 168500 | 170037 | ||
| @@ -168794,7 +170331,7 @@ SQLITE_API int sqlite3_table_column_metadata( | |||
| 168794 | 170331 | ||
| 168795 | /* Locate the table in question */ | 170332 | /* Locate the table in question */ |
| 168796 | pTab = sqlite3FindTable(db, zTableName, zDbName); | 170333 | pTab = sqlite3FindTable(db, zTableName, zDbName); |
| 168797 | if( !pTab || pTab->pSelect ){ | 170334 | if( !pTab || IsView(pTab) ){ |
| 168798 | pTab = 0; | 170335 | pTab = 0; |
| 168799 | goto error_out; | 170336 | goto error_out; |
| 168800 | } | 170337 | } |
| @@ -168805,7 +170342,7 @@ SQLITE_API int sqlite3_table_column_metadata( | |||
| 168805 | }else{ | 170342 | }else{ |
| 168806 | for(iCol=0; iCol<pTab->nCol; iCol++){ | 170343 | for(iCol=0; iCol<pTab->nCol; iCol++){ |
| 168807 | pCol = &pTab->aCol[iCol]; | 170344 | pCol = &pTab->aCol[iCol]; |
| 168808 | if( 0==sqlite3StrICmp(pCol->zName, zColumnName) ){ | 170345 | if( 0==sqlite3StrICmp(pCol->zCnName, zColumnName) ){ |
| 168809 | break; | 170346 | break; |
| 168810 | } | 170347 | } |
| 168811 | } | 170348 | } |
| @@ -168832,7 +170369,7 @@ SQLITE_API int sqlite3_table_column_metadata( | |||
| 168832 | */ | 170369 | */ |
| 168833 | if( pCol ){ | 170370 | if( pCol ){ |
| 168834 | zDataType = sqlite3ColumnType(pCol,0); | 170371 | zDataType = sqlite3ColumnType(pCol,0); |
| 168835 | zCollSeq = pCol->zColl; | 170372 | zCollSeq = sqlite3ColumnColl(pCol); |
| 168836 | notnull = pCol->notNull!=0; | 170373 | notnull = pCol->notNull!=0; |
| 168837 | primarykey = (pCol->colFlags & COLFLAG_PRIMKEY)!=0; | 170374 | primarykey = (pCol->colFlags & COLFLAG_PRIMKEY)!=0; |
| 168838 | autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0; | 170375 | autoinc = pTab->iPKey==iCol && (pTab->tabFlags & TF_Autoincrement)!=0; |
| @@ -169282,12 +170819,16 @@ SQLITE_API int sqlite3_test_control(int op, ...){ | |||
| 169282 | */ | 170819 | */ |
| 169283 | case SQLITE_TESTCTRL_IMPOSTER: { | 170820 | case SQLITE_TESTCTRL_IMPOSTER: { |
| 169284 | sqlite3 *db = va_arg(ap, sqlite3*); | 170821 | sqlite3 *db = va_arg(ap, sqlite3*); |
| 170822 | int iDb; | ||
| 169285 | sqlite3_mutex_enter(db->mutex); | 170823 | sqlite3_mutex_enter(db->mutex); |
| 169286 | db->init.iDb = sqlite3FindDbName(db, va_arg(ap,const char*)); | 170824 | iDb = sqlite3FindDbName(db, va_arg(ap,const char*)); |
| 169287 | db->init.busy = db->init.imposterTable = va_arg(ap,int); | 170825 | if( iDb>=0 ){ |
| 169288 | db->init.newTnum = va_arg(ap,int); | 170826 | db->init.iDb = iDb; |
| 169289 | if( db->init.busy==0 && db->init.newTnum>0 ){ | 170827 | db->init.busy = db->init.imposterTable = va_arg(ap,int); |
| 169290 | sqlite3ResetAllSchemasOfConnection(db); | 170828 | db->init.newTnum = va_arg(ap,int); |
| 170829 | if( db->init.busy==0 && db->init.newTnum>0 ){ | ||
| 170830 | sqlite3ResetAllSchemasOfConnection(db); | ||
| 170831 | } | ||
| 169291 | } | 170832 | } |
| 169292 | sqlite3_mutex_leave(db->mutex); | 170833 | sqlite3_mutex_leave(db->mutex); |
| 169293 | break; | 170834 | break; |
| @@ -169499,7 +171040,7 @@ SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N){ | |||
| 169499 | if( zFilename==0 || N<0 ) return 0; | 171040 | if( zFilename==0 || N<0 ) return 0; |
| 169500 | zFilename = databaseName(zFilename); | 171041 | zFilename = databaseName(zFilename); |
| 169501 | zFilename += sqlite3Strlen30(zFilename) + 1; | 171042 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| 169502 | while( zFilename[0] && (N--)>0 ){ | 171043 | while( ALWAYS(zFilename) && zFilename[0] && (N--)>0 ){ |
| 169503 | zFilename += sqlite3Strlen30(zFilename) + 1; | 171044 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| 169504 | zFilename += sqlite3Strlen30(zFilename) + 1; | 171045 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| 169505 | } | 171046 | } |
| @@ -169542,12 +171083,14 @@ SQLITE_API sqlite3_int64 sqlite3_uri_int64( | |||
| 169542 | ** corruption. | 171083 | ** corruption. |
| 169543 | */ | 171084 | */ |
| 169544 | SQLITE_API const char *sqlite3_filename_database(const char *zFilename){ | 171085 | SQLITE_API const char *sqlite3_filename_database(const char *zFilename){ |
| 171086 | if( zFilename==0 ) return 0; | ||
| 169545 | return databaseName(zFilename); | 171087 | return databaseName(zFilename); |
| 169546 | } | 171088 | } |
| 169547 | SQLITE_API const char *sqlite3_filename_journal(const char *zFilename){ | 171089 | SQLITE_API const char *sqlite3_filename_journal(const char *zFilename){ |
| 171090 | if( zFilename==0 ) return 0; | ||
| 169548 | zFilename = databaseName(zFilename); | 171091 | zFilename = databaseName(zFilename); |
| 169549 | zFilename += sqlite3Strlen30(zFilename) + 1; | 171092 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| 169550 | while( zFilename[0] ){ | 171093 | while( ALWAYS(zFilename) && zFilename[0] ){ |
| 169551 | zFilename += sqlite3Strlen30(zFilename) + 1; | 171094 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| 169552 | zFilename += sqlite3Strlen30(zFilename) + 1; | 171095 | zFilename += sqlite3Strlen30(zFilename) + 1; |
| 169553 | } | 171096 | } |
| @@ -169558,7 +171101,7 @@ SQLITE_API const char *sqlite3_filename_wal(const char *zFilename){ | |||
| 169558 | return 0; | 171101 | return 0; |
| 169559 | #else | 171102 | #else |
| 169560 | zFilename = sqlite3_filename_journal(zFilename); | 171103 | zFilename = sqlite3_filename_journal(zFilename); |
| 169561 | zFilename += sqlite3Strlen30(zFilename) + 1; | 171104 | if( zFilename ) zFilename += sqlite3Strlen30(zFilename) + 1; |
| 169562 | return zFilename; | 171105 | return zFilename; |
| 169563 | #endif | 171106 | #endif |
| 169564 | } | 171107 | } |
| @@ -170851,17 +172394,18 @@ SQLITE_API extern int sqlite3_fts3_may_be_corrupt; | |||
| 170851 | ** Macros indicating that conditional expressions are always true or | 172394 | ** Macros indicating that conditional expressions are always true or |
| 170852 | ** false. | 172395 | ** false. |
| 170853 | */ | 172396 | */ |
| 170854 | #ifdef SQLITE_COVERAGE_TEST | 172397 | #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST) |
| 170855 | # define ALWAYS(x) (1) | 172398 | # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1 |
| 170856 | # define NEVER(X) (0) | 172399 | #endif |
| 170857 | #elif defined(SQLITE_DEBUG) | 172400 | #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS) |
| 170858 | # define ALWAYS(x) sqlite3Fts3Always((x)!=0) | 172401 | # define ALWAYS(X) (1) |
| 170859 | # define NEVER(x) sqlite3Fts3Never((x)!=0) | 172402 | # define NEVER(X) (0) |
| 170860 | SQLITE_PRIVATE int sqlite3Fts3Always(int b); | 172403 | #elif !defined(NDEBUG) |
| 170861 | SQLITE_PRIVATE int sqlite3Fts3Never(int b); | 172404 | # define ALWAYS(X) ((X)?1:(assert(0),0)) |
| 172405 | # define NEVER(X) ((X)?(assert(0),1):0) | ||
| 170862 | #else | 172406 | #else |
| 170863 | # define ALWAYS(x) (x) | 172407 | # define ALWAYS(X) (X) |
| 170864 | # define NEVER(x) (x) | 172408 | # define NEVER(X) (X) |
| 170865 | #endif | 172409 | #endif |
| 170866 | 172410 | ||
| 170867 | /* | 172411 | /* |
| @@ -171320,6 +172864,7 @@ SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *); | |||
| 171320 | SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db, Fts3Hash*); | 172864 | SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db, Fts3Hash*); |
| 171321 | SQLITE_PRIVATE int sqlite3Fts3InitTerm(sqlite3 *db); | 172865 | SQLITE_PRIVATE int sqlite3Fts3InitTerm(sqlite3 *db); |
| 171322 | #endif | 172866 | #endif |
| 172867 | SQLITE_PRIVATE void *sqlite3Fts3MallocZero(i64 nByte); | ||
| 171323 | 172868 | ||
| 171324 | SQLITE_PRIVATE int sqlite3Fts3OpenTokenizer(sqlite3_tokenizer *, int, const char *, int, | 172869 | SQLITE_PRIVATE int sqlite3Fts3OpenTokenizer(sqlite3_tokenizer *, int, const char *, int, |
| 171325 | sqlite3_tokenizer_cursor ** | 172870 | sqlite3_tokenizer_cursor ** |
| @@ -171377,13 +172922,6 @@ static int fts3EvalStart(Fts3Cursor *pCsr); | |||
| 171377 | static int fts3TermSegReaderCursor( | 172922 | static int fts3TermSegReaderCursor( |
| 171378 | Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **); | 172923 | Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **); |
| 171379 | 172924 | ||
| 171380 | #ifndef SQLITE_AMALGAMATION | ||
| 171381 | # if defined(SQLITE_DEBUG) | ||
| 171382 | SQLITE_PRIVATE int sqlite3Fts3Always(int b) { assert( b ); return b; } | ||
| 171383 | SQLITE_PRIVATE int sqlite3Fts3Never(int b) { assert( !b ); return b; } | ||
| 171384 | # endif | ||
| 171385 | #endif | ||
| 171386 | |||
| 171387 | /* | 172925 | /* |
| 171388 | ** This variable is set to false when running tests for which the on disk | 172926 | ** This variable is set to false when running tests for which the on disk |
| 171389 | ** structures should not be corrupt. Otherwise, true. If it is false, extra | 172927 | ** structures should not be corrupt. Otherwise, true. If it is false, extra |
| @@ -175544,7 +177082,7 @@ SQLITE_PRIVATE void sqlite3Fts3DoclistPrev( | |||
| 175544 | 177082 | ||
| 175545 | assert( nDoclist>0 ); | 177083 | assert( nDoclist>0 ); |
| 175546 | assert( *pbEof==0 ); | 177084 | assert( *pbEof==0 ); |
| 175547 | assert( p || *piDocid==0 ); | 177085 | assert_fts3_nc( p || *piDocid==0 ); |
| 175548 | assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) ); | 177086 | assert( !p || (p>aDoclist && p<&aDoclist[nDoclist]) ); |
| 175549 | 177087 | ||
| 175550 | if( p==0 ){ | 177088 | if( p==0 ){ |
| @@ -176408,8 +177946,8 @@ static void fts3EvalNextRow( | |||
| 176408 | Fts3Expr *pRight = pExpr->pRight; | 177946 | Fts3Expr *pRight = pExpr->pRight; |
| 176409 | sqlite3_int64 iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid); | 177947 | sqlite3_int64 iCmp = DOCID_CMP(pLeft->iDocid, pRight->iDocid); |
| 176410 | 177948 | ||
| 176411 | assert( pLeft->bStart || pLeft->iDocid==pRight->iDocid ); | 177949 | assert_fts3_nc( pLeft->bStart || pLeft->iDocid==pRight->iDocid ); |
| 176412 | assert( pRight->bStart || pLeft->iDocid==pRight->iDocid ); | 177950 | assert_fts3_nc( pRight->bStart || pLeft->iDocid==pRight->iDocid ); |
| 176413 | 177951 | ||
| 176414 | if( pRight->bEof || (pLeft->bEof==0 && iCmp<0) ){ | 177952 | if( pRight->bEof || (pLeft->bEof==0 && iCmp<0) ){ |
| 176415 | fts3EvalNextRow(pCsr, pLeft, pRc); | 177953 | fts3EvalNextRow(pCsr, pLeft, pRc); |
| @@ -177047,6 +178585,9 @@ SQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist( | |||
| 177047 | if( bEofSave==0 && pNear->iDocid==iDocid ) break; | 178585 | if( bEofSave==0 && pNear->iDocid==iDocid ) break; |
| 177048 | } | 178586 | } |
| 177049 | assert( rc!=SQLITE_OK || pPhrase->bIncr==0 ); | 178587 | assert( rc!=SQLITE_OK || pPhrase->bIncr==0 ); |
| 178588 | if( rc==SQLITE_OK && pNear->bEof!=bEofSave ){ | ||
| 178589 | rc = FTS_CORRUPT_VTAB; | ||
| 178590 | } | ||
| 177050 | } | 178591 | } |
| 177051 | if( bTreeEof ){ | 178592 | if( bTreeEof ){ |
| 177052 | while( rc==SQLITE_OK && !pNear->bEof ){ | 178593 | while( rc==SQLITE_OK && !pNear->bEof ){ |
| @@ -177469,6 +179010,7 @@ static int fts3auxNextMethod(sqlite3_vtab_cursor *pCursor){ | |||
| 177469 | if( fts3auxGrowStatArray(pCsr, 2) ) return SQLITE_NOMEM; | 179010 | if( fts3auxGrowStatArray(pCsr, 2) ) return SQLITE_NOMEM; |
| 177470 | memset(pCsr->aStat, 0, sizeof(struct Fts3auxColstats) * pCsr->nStat); | 179011 | memset(pCsr->aStat, 0, sizeof(struct Fts3auxColstats) * pCsr->nStat); |
| 177471 | iCol = 0; | 179012 | iCol = 0; |
| 179013 | rc = SQLITE_OK; | ||
| 177472 | 179014 | ||
| 177473 | while( i<nDoclist ){ | 179015 | while( i<nDoclist ){ |
| 177474 | sqlite3_int64 v = 0; | 179016 | sqlite3_int64 v = 0; |
| @@ -177512,6 +179054,10 @@ static int fts3auxNextMethod(sqlite3_vtab_cursor *pCursor){ | |||
| 177512 | /* State 3. The integer just read is a column number. */ | 179054 | /* State 3. The integer just read is a column number. */ |
| 177513 | default: assert( eState==3 ); | 179055 | default: assert( eState==3 ); |
| 177514 | iCol = (int)v; | 179056 | iCol = (int)v; |
| 179057 | if( iCol<1 ){ | ||
| 179058 | rc = SQLITE_CORRUPT_VTAB; | ||
| 179059 | break; | ||
| 179060 | } | ||
| 177515 | if( fts3auxGrowStatArray(pCsr, iCol+2) ) return SQLITE_NOMEM; | 179061 | if( fts3auxGrowStatArray(pCsr, iCol+2) ) return SQLITE_NOMEM; |
| 177516 | pCsr->aStat[iCol+1].nDoc++; | 179062 | pCsr->aStat[iCol+1].nDoc++; |
| 177517 | eState = 2; | 179063 | eState = 2; |
| @@ -177520,7 +179066,6 @@ static int fts3auxNextMethod(sqlite3_vtab_cursor *pCursor){ | |||
| 177520 | } | 179066 | } |
| 177521 | 179067 | ||
| 177522 | pCsr->iCol = 0; | 179068 | pCsr->iCol = 0; |
| 177523 | rc = SQLITE_OK; | ||
| 177524 | }else{ | 179069 | }else{ |
| 177525 | pCsr->isEof = 1; | 179070 | pCsr->isEof = 1; |
| 177526 | } | 179071 | } |
| @@ -177849,7 +179394,7 @@ static int fts3isspace(char c){ | |||
| 177849 | ** zero the memory before returning a pointer to it. If unsuccessful, | 179394 | ** zero the memory before returning a pointer to it. If unsuccessful, |
| 177850 | ** return NULL. | 179395 | ** return NULL. |
| 177851 | */ | 179396 | */ |
| 177852 | static void *fts3MallocZero(sqlite3_int64 nByte){ | 179397 | SQLITE_PRIVATE void *sqlite3Fts3MallocZero(sqlite3_int64 nByte){ |
| 177853 | void *pRet = sqlite3_malloc64(nByte); | 179398 | void *pRet = sqlite3_malloc64(nByte); |
| 177854 | if( pRet ) memset(pRet, 0, nByte); | 179399 | if( pRet ) memset(pRet, 0, nByte); |
| 177855 | return pRet; | 179400 | return pRet; |
| @@ -177930,7 +179475,7 @@ static int getNextToken( | |||
| 177930 | rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition); | 179475 | rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition); |
| 177931 | if( rc==SQLITE_OK ){ | 179476 | if( rc==SQLITE_OK ){ |
| 177932 | nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken; | 179477 | nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken; |
| 177933 | pRet = (Fts3Expr *)fts3MallocZero(nByte); | 179478 | pRet = (Fts3Expr *)sqlite3Fts3MallocZero(nByte); |
| 177934 | if( !pRet ){ | 179479 | if( !pRet ){ |
| 177935 | rc = SQLITE_NOMEM; | 179480 | rc = SQLITE_NOMEM; |
| 177936 | }else{ | 179481 | }else{ |
| @@ -178185,7 +179730,7 @@ static int getNextNode( | |||
| 178185 | if( fts3isspace(cNext) | 179730 | if( fts3isspace(cNext) |
| 178186 | || cNext=='"' || cNext=='(' || cNext==')' || cNext==0 | 179731 | || cNext=='"' || cNext=='(' || cNext==')' || cNext==0 |
| 178187 | ){ | 179732 | ){ |
| 178188 | pRet = (Fts3Expr *)fts3MallocZero(sizeof(Fts3Expr)); | 179733 | pRet = (Fts3Expr *)sqlite3Fts3MallocZero(sizeof(Fts3Expr)); |
| 178189 | if( !pRet ){ | 179734 | if( !pRet ){ |
| 178190 | return SQLITE_NOMEM; | 179735 | return SQLITE_NOMEM; |
| 178191 | } | 179736 | } |
| @@ -178364,7 +179909,7 @@ static int fts3ExprParse( | |||
| 178364 | && p->eType==FTSQUERY_PHRASE && pParse->isNot | 179909 | && p->eType==FTSQUERY_PHRASE && pParse->isNot |
| 178365 | ){ | 179910 | ){ |
| 178366 | /* Create an implicit NOT operator. */ | 179911 | /* Create an implicit NOT operator. */ |
| 178367 | Fts3Expr *pNot = fts3MallocZero(sizeof(Fts3Expr)); | 179912 | Fts3Expr *pNot = sqlite3Fts3MallocZero(sizeof(Fts3Expr)); |
| 178368 | if( !pNot ){ | 179913 | if( !pNot ){ |
| 178369 | sqlite3Fts3ExprFree(p); | 179914 | sqlite3Fts3ExprFree(p); |
| 178370 | rc = SQLITE_NOMEM; | 179915 | rc = SQLITE_NOMEM; |
| @@ -178398,7 +179943,7 @@ static int fts3ExprParse( | |||
| 178398 | /* Insert an implicit AND operator. */ | 179943 | /* Insert an implicit AND operator. */ |
| 178399 | Fts3Expr *pAnd; | 179944 | Fts3Expr *pAnd; |
| 178400 | assert( pRet && pPrev ); | 179945 | assert( pRet && pPrev ); |
| 178401 | pAnd = fts3MallocZero(sizeof(Fts3Expr)); | 179946 | pAnd = sqlite3Fts3MallocZero(sizeof(Fts3Expr)); |
| 178402 | if( !pAnd ){ | 179947 | if( !pAnd ){ |
| 178403 | sqlite3Fts3ExprFree(p); | 179948 | sqlite3Fts3ExprFree(p); |
| 178404 | rc = SQLITE_NOMEM; | 179949 | rc = SQLITE_NOMEM; |
| @@ -182628,8 +184173,18 @@ static int fts3SegReaderNext( | |||
| 182628 | char *aCopy; | 184173 | char *aCopy; |
| 182629 | PendingList *pList = (PendingList *)fts3HashData(pElem); | 184174 | PendingList *pList = (PendingList *)fts3HashData(pElem); |
| 182630 | int nCopy = pList->nData+1; | 184175 | int nCopy = pList->nData+1; |
| 182631 | pReader->zTerm = (char *)fts3HashKey(pElem); | 184176 | |
| 182632 | pReader->nTerm = fts3HashKeysize(pElem); | 184177 | int nTerm = fts3HashKeysize(pElem); |
| 184178 | if( (nTerm+1)>pReader->nTermAlloc ){ | ||
| 184179 | sqlite3_free(pReader->zTerm); | ||
| 184180 | pReader->zTerm = (char*)sqlite3_malloc((nTerm+1)*2); | ||
| 184181 | if( !pReader->zTerm ) return SQLITE_NOMEM; | ||
| 184182 | pReader->nTermAlloc = (nTerm+1)*2; | ||
| 184183 | } | ||
| 184184 | memcpy(pReader->zTerm, fts3HashKey(pElem), nTerm); | ||
| 184185 | pReader->zTerm[nTerm] = '\0'; | ||
| 184186 | pReader->nTerm = nTerm; | ||
| 184187 | |||
| 182633 | aCopy = (char*)sqlite3_malloc(nCopy); | 184188 | aCopy = (char*)sqlite3_malloc(nCopy); |
| 182634 | if( !aCopy ) return SQLITE_NOMEM; | 184189 | if( !aCopy ) return SQLITE_NOMEM; |
| 182635 | memcpy(aCopy, pList->aData, nCopy); | 184190 | memcpy(aCopy, pList->aData, nCopy); |
| @@ -182882,9 +184437,7 @@ SQLITE_PRIVATE int sqlite3Fts3MsrOvfl( | |||
| 182882 | */ | 184437 | */ |
| 182883 | SQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3SegReader *pReader){ | 184438 | SQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3SegReader *pReader){ |
| 182884 | if( pReader ){ | 184439 | if( pReader ){ |
| 182885 | if( !fts3SegReaderIsPending(pReader) ){ | 184440 | sqlite3_free(pReader->zTerm); |
| 182886 | sqlite3_free(pReader->zTerm); | ||
| 182887 | } | ||
| 182888 | if( !fts3SegReaderIsRootOnly(pReader) ){ | 184441 | if( !fts3SegReaderIsRootOnly(pReader) ){ |
| 182889 | sqlite3_free(pReader->aNode); | 184442 | sqlite3_free(pReader->aNode); |
| 182890 | } | 184443 | } |
| @@ -185076,7 +186629,7 @@ static int nodeReaderNext(NodeReader *p){ | |||
| 185076 | return FTS_CORRUPT_VTAB; | 186629 | return FTS_CORRUPT_VTAB; |
| 185077 | } | 186630 | } |
| 185078 | blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc); | 186631 | blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc); |
| 185079 | if( rc==SQLITE_OK ){ | 186632 | if( rc==SQLITE_OK && ALWAYS(p->term.a!=0) ){ |
| 185080 | memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix); | 186633 | memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix); |
| 185081 | p->term.n = nPrefix+nSuffix; | 186634 | p->term.n = nPrefix+nSuffix; |
| 185082 | p->iOff += nSuffix; | 186635 | p->iOff += nSuffix; |
| @@ -185470,7 +187023,11 @@ static int fts3TermCmp( | |||
| 185470 | int nCmp = MIN(nLhs, nRhs); | 187023 | int nCmp = MIN(nLhs, nRhs); |
| 185471 | int res; | 187024 | int res; |
| 185472 | 187025 | ||
| 185473 | res = (nCmp ? memcmp(zLhs, zRhs, nCmp) : 0); | 187026 | if( nCmp && ALWAYS(zLhs) && ALWAYS(zRhs) ){ |
| 187027 | res = memcmp(zLhs, zRhs, nCmp); | ||
| 187028 | }else{ | ||
| 187029 | res = 0; | ||
| 187030 | } | ||
| 185474 | if( res==0 ) res = nLhs - nRhs; | 187031 | if( res==0 ) res = nLhs - nRhs; |
| 185475 | 187032 | ||
| 185476 | return res; | 187033 | return res; |
| @@ -186114,7 +187671,7 @@ static int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){ | |||
| 186114 | if( aHint ){ | 187671 | if( aHint ){ |
| 186115 | blobGrowBuffer(pHint, nHint, &rc); | 187672 | blobGrowBuffer(pHint, nHint, &rc); |
| 186116 | if( rc==SQLITE_OK ){ | 187673 | if( rc==SQLITE_OK ){ |
| 186117 | memcpy(pHint->a, aHint, nHint); | 187674 | if( ALWAYS(pHint->a!=0) ) memcpy(pHint->a, aHint, nHint); |
| 186118 | pHint->n = nHint; | 187675 | pHint->n = nHint; |
| 186119 | } | 187676 | } |
| 186120 | } | 187677 | } |
| @@ -187231,9 +188788,8 @@ static MatchinfoBuffer *fts3MIBufferNew(size_t nElem, const char *zMatchinfo){ | |||
| 187231 | + sizeof(MatchinfoBuffer); | 188788 | + sizeof(MatchinfoBuffer); |
| 187232 | sqlite3_int64 nStr = strlen(zMatchinfo); | 188789 | sqlite3_int64 nStr = strlen(zMatchinfo); |
| 187233 | 188790 | ||
| 187234 | pRet = sqlite3_malloc64(nByte + nStr+1); | 188791 | pRet = sqlite3Fts3MallocZero(nByte + nStr+1); |
| 187235 | if( pRet ){ | 188792 | if( pRet ){ |
| 187236 | memset(pRet, 0, nByte); | ||
| 187237 | pRet->aMatchinfo[0] = (u8*)(&pRet->aMatchinfo[1]) - (u8*)pRet; | 188793 | pRet->aMatchinfo[0] = (u8*)(&pRet->aMatchinfo[1]) - (u8*)pRet; |
| 187238 | pRet->aMatchinfo[1+nElem] = pRet->aMatchinfo[0] | 188794 | pRet->aMatchinfo[1+nElem] = pRet->aMatchinfo[0] |
| 187239 | + sizeof(u32)*((int)nElem+1); | 188795 | + sizeof(u32)*((int)nElem+1); |
| @@ -187637,11 +189193,10 @@ static int fts3BestSnippet( | |||
| 187637 | ** the required space using malloc(). | 189193 | ** the required space using malloc(). |
| 187638 | */ | 189194 | */ |
| 187639 | nByte = sizeof(SnippetPhrase) * nList; | 189195 | nByte = sizeof(SnippetPhrase) * nList; |
| 187640 | sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc64(nByte); | 189196 | sIter.aPhrase = (SnippetPhrase *)sqlite3Fts3MallocZero(nByte); |
| 187641 | if( !sIter.aPhrase ){ | 189197 | if( !sIter.aPhrase ){ |
| 187642 | return SQLITE_NOMEM; | 189198 | return SQLITE_NOMEM; |
| 187643 | } | 189199 | } |
| 187644 | memset(sIter.aPhrase, 0, nByte); | ||
| 187645 | 189200 | ||
| 187646 | /* Initialize the contents of the SnippetIter object. Then iterate through | 189201 | /* Initialize the contents of the SnippetIter object. Then iterate through |
| 187647 | ** the set of phrases in the expression to populate the aPhrase[] array. | 189202 | ** the set of phrases in the expression to populate the aPhrase[] array. |
| @@ -188205,10 +189760,12 @@ static int fts3MatchinfoLcsCb( | |||
| 188205 | ** position list for the next column. | 189760 | ** position list for the next column. |
| 188206 | */ | 189761 | */ |
| 188207 | static int fts3LcsIteratorAdvance(LcsIterator *pIter){ | 189762 | static int fts3LcsIteratorAdvance(LcsIterator *pIter){ |
| 188208 | char *pRead = pIter->pRead; | 189763 | char *pRead; |
| 188209 | sqlite3_int64 iRead; | 189764 | sqlite3_int64 iRead; |
| 188210 | int rc = 0; | 189765 | int rc = 0; |
| 188211 | 189766 | ||
| 189767 | if( NEVER(pIter==0) ) return 1; | ||
| 189768 | pRead = pIter->pRead; | ||
| 188212 | pRead += sqlite3Fts3GetVarint(pRead, &iRead); | 189769 | pRead += sqlite3Fts3GetVarint(pRead, &iRead); |
| 188213 | if( iRead==0 || iRead==1 ){ | 189770 | if( iRead==0 || iRead==1 ){ |
| 188214 | pRead = 0; | 189771 | pRead = 0; |
| @@ -188242,9 +189799,8 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){ | |||
| 188242 | /* Allocate and populate the array of LcsIterator objects. The array | 189799 | /* Allocate and populate the array of LcsIterator objects. The array |
| 188243 | ** contains one element for each matchable phrase in the query. | 189800 | ** contains one element for each matchable phrase in the query. |
| 188244 | **/ | 189801 | **/ |
| 188245 | aIter = sqlite3_malloc64(sizeof(LcsIterator) * pCsr->nPhrase); | 189802 | aIter = sqlite3Fts3MallocZero(sizeof(LcsIterator) * pCsr->nPhrase); |
| 188246 | if( !aIter ) return SQLITE_NOMEM; | 189803 | if( !aIter ) return SQLITE_NOMEM; |
| 188247 | memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase); | ||
| 188248 | (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter); | 189804 | (void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter); |
| 188249 | 189805 | ||
| 188250 | for(i=0; i<pInfo->nPhrase; i++){ | 189806 | for(i=0; i<pInfo->nPhrase; i++){ |
| @@ -188705,7 +190261,7 @@ SQLITE_PRIVATE void sqlite3Fts3Offsets( | |||
| 188705 | if( rc!=SQLITE_OK ) goto offsets_out; | 190261 | if( rc!=SQLITE_OK ) goto offsets_out; |
| 188706 | 190262 | ||
| 188707 | /* Allocate the array of TermOffset iterators. */ | 190263 | /* Allocate the array of TermOffset iterators. */ |
| 188708 | sCtx.aTerm = (TermOffset *)sqlite3_malloc64(sizeof(TermOffset)*nToken); | 190264 | sCtx.aTerm = (TermOffset *)sqlite3Fts3MallocZero(sizeof(TermOffset)*nToken); |
| 188709 | if( 0==sCtx.aTerm ){ | 190265 | if( 0==sCtx.aTerm ){ |
| 188710 | rc = SQLITE_NOMEM; | 190266 | rc = SQLITE_NOMEM; |
| 188711 | goto offsets_out; | 190267 | goto offsets_out; |
| @@ -188726,13 +190282,13 @@ SQLITE_PRIVATE void sqlite3Fts3Offsets( | |||
| 188726 | const char *zDoc; | 190282 | const char *zDoc; |
| 188727 | int nDoc; | 190283 | int nDoc; |
| 188728 | 190284 | ||
| 188729 | /* Initialize the contents of sCtx.aTerm[] for column iCol. There is | 190285 | /* Initialize the contents of sCtx.aTerm[] for column iCol. This |
| 188730 | ** no way that this operation can fail, so the return code from | 190286 | ** operation may fail if the database contains corrupt records. |
| 188731 | ** fts3ExprIterate() can be discarded. | ||
| 188732 | */ | 190287 | */ |
| 188733 | sCtx.iCol = iCol; | 190288 | sCtx.iCol = iCol; |
| 188734 | sCtx.iTerm = 0; | 190289 | sCtx.iTerm = 0; |
| 188735 | (void)fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx); | 190290 | rc = fts3ExprIterate(pCsr->pExpr, fts3ExprTermOffsetInit, (void*)&sCtx); |
| 190291 | if( rc!=SQLITE_OK ) goto offsets_out; | ||
| 188736 | 190292 | ||
| 188737 | /* Retreive the text stored in column iCol. If an SQL NULL is stored | 190293 | /* Retreive the text stored in column iCol. If an SQL NULL is stored |
| 188738 | ** in column iCol, jump immediately to the next iteration of the loop. | 190294 | ** in column iCol, jump immediately to the next iteration of the loop. |
| @@ -189730,8 +191286,35 @@ static const char jsonIsSpace[] = { | |||
| 189730 | typedef unsigned int u32; | 191286 | typedef unsigned int u32; |
| 189731 | typedef unsigned short int u16; | 191287 | typedef unsigned short int u16; |
| 189732 | typedef unsigned char u8; | 191288 | typedef unsigned char u8; |
| 191289 | # if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST) | ||
| 191290 | # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1 | ||
| 191291 | # endif | ||
| 191292 | # if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS) | ||
| 191293 | # define ALWAYS(X) (1) | ||
| 191294 | # define NEVER(X) (0) | ||
| 191295 | # elif !defined(NDEBUG) | ||
| 191296 | # define ALWAYS(X) ((X)?1:(assert(0),0)) | ||
| 191297 | # define NEVER(X) ((X)?(assert(0),1):0) | ||
| 191298 | # else | ||
| 191299 | # define ALWAYS(X) (X) | ||
| 191300 | # define NEVER(X) (X) | ||
| 191301 | # endif | ||
| 191302 | # define testcase(X) | ||
| 191303 | #endif | ||
| 191304 | #if !defined(SQLITE_DEBUG) && !defined(SQLITE_COVERAGE_TEST) | ||
| 191305 | # define VVA(X) | ||
| 191306 | #else | ||
| 191307 | # define VVA(X) X | ||
| 189733 | #endif | 191308 | #endif |
| 189734 | 191309 | ||
| 191310 | /* | ||
| 191311 | ** Some of the testcase() macros in this file are problematic for gcov | ||
| 191312 | ** in that they generate false-miss errors randomly. This is a gcov problem, | ||
| 191313 | ** not a problem in this case. But to work around it, we disable the | ||
| 191314 | ** problematic test cases for production builds. | ||
| 191315 | */ | ||
| 191316 | #define json_testcase(X) | ||
| 191317 | |||
| 189735 | /* Objects */ | 191318 | /* Objects */ |
| 189736 | typedef struct JsonString JsonString; | 191319 | typedef struct JsonString JsonString; |
| 189737 | typedef struct JsonNode JsonNode; | 191320 | typedef struct JsonNode JsonNode; |
| @@ -189788,13 +191371,14 @@ static const char * const jsonType[] = { | |||
| 189788 | struct JsonNode { | 191371 | struct JsonNode { |
| 189789 | u8 eType; /* One of the JSON_ type values */ | 191372 | u8 eType; /* One of the JSON_ type values */ |
| 189790 | u8 jnFlags; /* JNODE flags */ | 191373 | u8 jnFlags; /* JNODE flags */ |
| 191374 | u8 eU; /* Which union element to use */ | ||
| 189791 | u32 n; /* Bytes of content, or number of sub-nodes */ | 191375 | u32 n; /* Bytes of content, or number of sub-nodes */ |
| 189792 | union { | 191376 | union { |
| 189793 | const char *zJContent; /* Content for INT, REAL, and STRING */ | 191377 | const char *zJContent; /* 1: Content for INT, REAL, and STRING */ |
| 189794 | u32 iAppend; /* More terms for ARRAY and OBJECT */ | 191378 | u32 iAppend; /* 2: More terms for ARRAY and OBJECT */ |
| 189795 | u32 iKey; /* Key for ARRAY objects in json_tree() */ | 191379 | u32 iKey; /* 3: Key for ARRAY objects in json_tree() */ |
| 189796 | u32 iReplace; /* Replacement content for JNODE_REPLACE */ | 191380 | u32 iReplace; /* 4: Replacement content for JNODE_REPLACE */ |
| 189797 | JsonNode *pPatch; /* Node chain of patch for JNODE_PATCH */ | 191381 | JsonNode *pPatch; /* 5: Node chain of patch for JNODE_PATCH */ |
| 189798 | } u; | 191382 | } u; |
| 189799 | }; | 191383 | }; |
| 189800 | 191384 | ||
| @@ -190072,11 +191656,14 @@ static void jsonRenderNode( | |||
| 190072 | JsonString *pOut, /* Write JSON here */ | 191656 | JsonString *pOut, /* Write JSON here */ |
| 190073 | sqlite3_value **aReplace /* Replacement values */ | 191657 | sqlite3_value **aReplace /* Replacement values */ |
| 190074 | ){ | 191658 | ){ |
| 191659 | assert( pNode!=0 ); | ||
| 190075 | if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){ | 191660 | if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){ |
| 190076 | if( pNode->jnFlags & JNODE_REPLACE ){ | 191661 | if( (pNode->jnFlags & JNODE_REPLACE)!=0 && ALWAYS(aReplace!=0) ){ |
| 191662 | assert( pNode->eU==4 ); | ||
| 190077 | jsonAppendValue(pOut, aReplace[pNode->u.iReplace]); | 191663 | jsonAppendValue(pOut, aReplace[pNode->u.iReplace]); |
| 190078 | return; | 191664 | return; |
| 190079 | } | 191665 | } |
| 191666 | assert( pNode->eU==5 ); | ||
| 190080 | pNode = pNode->u.pPatch; | 191667 | pNode = pNode->u.pPatch; |
| 190081 | } | 191668 | } |
| 190082 | switch( pNode->eType ){ | 191669 | switch( pNode->eType ){ |
| @@ -190095,6 +191682,7 @@ static void jsonRenderNode( | |||
| 190095 | } | 191682 | } |
| 190096 | case JSON_STRING: { | 191683 | case JSON_STRING: { |
| 190097 | if( pNode->jnFlags & JNODE_RAW ){ | 191684 | if( pNode->jnFlags & JNODE_RAW ){ |
| 191685 | assert( pNode->eU==1 ); | ||
| 190098 | jsonAppendString(pOut, pNode->u.zJContent, pNode->n); | 191686 | jsonAppendString(pOut, pNode->u.zJContent, pNode->n); |
| 190099 | break; | 191687 | break; |
| 190100 | } | 191688 | } |
| @@ -190102,6 +191690,7 @@ static void jsonRenderNode( | |||
| 190102 | } | 191690 | } |
| 190103 | case JSON_REAL: | 191691 | case JSON_REAL: |
| 190104 | case JSON_INT: { | 191692 | case JSON_INT: { |
| 191693 | assert( pNode->eU==1 ); | ||
| 190105 | jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); | 191694 | jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); |
| 190106 | break; | 191695 | break; |
| 190107 | } | 191696 | } |
| @@ -190117,6 +191706,7 @@ static void jsonRenderNode( | |||
| 190117 | j += jsonNodeSize(&pNode[j]); | 191706 | j += jsonNodeSize(&pNode[j]); |
| 190118 | } | 191707 | } |
| 190119 | if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; | 191708 | if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; |
| 191709 | assert( pNode->eU==2 ); | ||
| 190120 | pNode = &pNode[pNode->u.iAppend]; | 191710 | pNode = &pNode[pNode->u.iAppend]; |
| 190121 | j = 1; | 191711 | j = 1; |
| 190122 | } | 191712 | } |
| @@ -190137,6 +191727,7 @@ static void jsonRenderNode( | |||
| 190137 | j += 1 + jsonNodeSize(&pNode[j+1]); | 191727 | j += 1 + jsonNodeSize(&pNode[j+1]); |
| 190138 | } | 191728 | } |
| 190139 | if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; | 191729 | if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; |
| 191730 | assert( pNode->eU==2 ); | ||
| 190140 | pNode = &pNode[pNode->u.iAppend]; | 191731 | pNode = &pNode[pNode->u.iAppend]; |
| 190141 | j = 1; | 191732 | j = 1; |
| 190142 | } | 191733 | } |
| @@ -190216,7 +191807,9 @@ static void jsonReturn( | |||
| 190216 | } | 191807 | } |
| 190217 | case JSON_INT: { | 191808 | case JSON_INT: { |
| 190218 | sqlite3_int64 i = 0; | 191809 | sqlite3_int64 i = 0; |
| 190219 | const char *z = pNode->u.zJContent; | 191810 | const char *z; |
| 191811 | assert( pNode->eU==1 ); | ||
| 191812 | z = pNode->u.zJContent; | ||
| 190220 | if( z[0]=='-' ){ z++; } | 191813 | if( z[0]=='-' ){ z++; } |
| 190221 | while( z[0]>='0' && z[0]<='9' ){ | 191814 | while( z[0]>='0' && z[0]<='9' ){ |
| 190222 | unsigned v = *(z++) - '0'; | 191815 | unsigned v = *(z++) - '0'; |
| @@ -190239,14 +191832,17 @@ static void jsonReturn( | |||
| 190239 | sqlite3_result_int64(pCtx, i); | 191832 | sqlite3_result_int64(pCtx, i); |
| 190240 | int_done: | 191833 | int_done: |
| 190241 | break; | 191834 | break; |
| 190242 | int_as_real: i=0; /* no break */ deliberate_fall_through | 191835 | int_as_real: ; /* no break */ deliberate_fall_through |
| 190243 | } | 191836 | } |
| 190244 | case JSON_REAL: { | 191837 | case JSON_REAL: { |
| 190245 | double r; | 191838 | double r; |
| 190246 | #ifdef SQLITE_AMALGAMATION | 191839 | #ifdef SQLITE_AMALGAMATION |
| 190247 | const char *z = pNode->u.zJContent; | 191840 | const char *z; |
| 191841 | assert( pNode->eU==1 ); | ||
| 191842 | z = pNode->u.zJContent; | ||
| 190248 | sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); | 191843 | sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); |
| 190249 | #else | 191844 | #else |
| 191845 | assert( pNode->eU==1 ); | ||
| 190250 | r = strtod(pNode->u.zJContent, 0); | 191846 | r = strtod(pNode->u.zJContent, 0); |
| 190251 | #endif | 191847 | #endif |
| 190252 | sqlite3_result_double(pCtx, r); | 191848 | sqlite3_result_double(pCtx, r); |
| @@ -190257,6 +191853,7 @@ static void jsonReturn( | |||
| 190257 | ** json_insert() and json_replace() and those routines do not | 191853 | ** json_insert() and json_replace() and those routines do not |
| 190258 | ** call jsonReturn() */ | 191854 | ** call jsonReturn() */ |
| 190259 | if( pNode->jnFlags & JNODE_RAW ){ | 191855 | if( pNode->jnFlags & JNODE_RAW ){ |
| 191856 | assert( pNode->eU==1 ); | ||
| 190260 | sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, | 191857 | sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, |
| 190261 | SQLITE_TRANSIENT); | 191858 | SQLITE_TRANSIENT); |
| 190262 | }else | 191859 | }else |
| @@ -190264,15 +191861,18 @@ static void jsonReturn( | |||
| 190264 | assert( (pNode->jnFlags & JNODE_RAW)==0 ); | 191861 | assert( (pNode->jnFlags & JNODE_RAW)==0 ); |
| 190265 | if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){ | 191862 | if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){ |
| 190266 | /* JSON formatted without any backslash-escapes */ | 191863 | /* JSON formatted without any backslash-escapes */ |
| 191864 | assert( pNode->eU==1 ); | ||
| 190267 | sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2, | 191865 | sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2, |
| 190268 | SQLITE_TRANSIENT); | 191866 | SQLITE_TRANSIENT); |
| 190269 | }else{ | 191867 | }else{ |
| 190270 | /* Translate JSON formatted string into raw text */ | 191868 | /* Translate JSON formatted string into raw text */ |
| 190271 | u32 i; | 191869 | u32 i; |
| 190272 | u32 n = pNode->n; | 191870 | u32 n = pNode->n; |
| 190273 | const char *z = pNode->u.zJContent; | 191871 | const char *z; |
| 190274 | char *zOut; | 191872 | char *zOut; |
| 190275 | u32 j; | 191873 | u32 j; |
| 191874 | assert( pNode->eU==1 ); | ||
| 191875 | z = pNode->u.zJContent; | ||
| 190276 | zOut = sqlite3_malloc( n+1 ); | 191876 | zOut = sqlite3_malloc( n+1 ); |
| 190277 | if( zOut==0 ){ | 191877 | if( zOut==0 ){ |
| 190278 | sqlite3_result_error_nomem(pCtx); | 191878 | sqlite3_result_error_nomem(pCtx); |
| @@ -190393,12 +191993,13 @@ static int jsonParseAddNode( | |||
| 190393 | const char *zContent /* Content */ | 191993 | const char *zContent /* Content */ |
| 190394 | ){ | 191994 | ){ |
| 190395 | JsonNode *p; | 191995 | JsonNode *p; |
| 190396 | if( pParse->nNode>=pParse->nAlloc ){ | 191996 | if( pParse->aNode==0 || pParse->nNode>=pParse->nAlloc ){ |
| 190397 | return jsonParseAddNodeExpand(pParse, eType, n, zContent); | 191997 | return jsonParseAddNodeExpand(pParse, eType, n, zContent); |
| 190398 | } | 191998 | } |
| 190399 | p = &pParse->aNode[pParse->nNode]; | 191999 | p = &pParse->aNode[pParse->nNode]; |
| 190400 | p->eType = (u8)eType; | 192000 | p->eType = (u8)eType; |
| 190401 | p->jnFlags = 0; | 192001 | p->jnFlags = 0; |
| 192002 | VVA( p->eU = zContent ? 1 : 0 ); | ||
| 190402 | p->n = n; | 192003 | p->n = n; |
| 190403 | p->u.zJContent = zContent; | 192004 | p->u.zJContent = zContent; |
| 190404 | return pParse->nNode++; | 192005 | return pParse->nNode++; |
| @@ -190466,6 +192067,7 @@ static int jsonParseValue(JsonParse *pParse, u32 i){ | |||
| 190466 | /* Parse array */ | 192067 | /* Parse array */ |
| 190467 | iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); | 192068 | iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); |
| 190468 | if( iThis<0 ) return -1; | 192069 | if( iThis<0 ) return -1; |
| 192070 | memset(&pParse->aNode[iThis].u, 0, sizeof(pParse->aNode[iThis].u)); | ||
| 190469 | for(j=i+1;;j++){ | 192071 | for(j=i+1;;j++){ |
| 190470 | while( safe_isspace(z[j]) ){ j++; } | 192072 | while( safe_isspace(z[j]) ){ j++; } |
| 190471 | if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; | 192073 | if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; |
| @@ -190730,6 +192332,7 @@ static JsonParse *jsonParseCached( | |||
| 190730 | ** a match. | 192332 | ** a match. |
| 190731 | */ | 192333 | */ |
| 190732 | static int jsonLabelCompare(JsonNode *pNode, const char *zKey, u32 nKey){ | 192334 | static int jsonLabelCompare(JsonNode *pNode, const char *zKey, u32 nKey){ |
| 192335 | assert( pNode->eU==1 ); | ||
| 190733 | if( pNode->jnFlags & JNODE_RAW ){ | 192336 | if( pNode->jnFlags & JNODE_RAW ){ |
| 190734 | if( pNode->n!=nKey ) return 0; | 192337 | if( pNode->n!=nKey ) return 0; |
| 190735 | return strncmp(pNode->u.zJContent, zKey, nKey)==0; | 192338 | return strncmp(pNode->u.zJContent, zKey, nKey)==0; |
| @@ -190795,6 +192398,7 @@ static JsonNode *jsonLookupStep( | |||
| 190795 | j += jsonNodeSize(&pRoot[j]); | 192398 | j += jsonNodeSize(&pRoot[j]); |
| 190796 | } | 192399 | } |
| 190797 | if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; | 192400 | if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; |
| 192401 | assert( pRoot->eU==2 ); | ||
| 190798 | iRoot += pRoot->u.iAppend; | 192402 | iRoot += pRoot->u.iAppend; |
| 190799 | pRoot = &pParse->aNode[iRoot]; | 192403 | pRoot = &pParse->aNode[iRoot]; |
| 190800 | j = 1; | 192404 | j = 1; |
| @@ -190809,8 +192413,10 @@ static JsonNode *jsonLookupStep( | |||
| 190809 | if( pParse->oom ) return 0; | 192413 | if( pParse->oom ) return 0; |
| 190810 | if( pNode ){ | 192414 | if( pNode ){ |
| 190811 | pRoot = &pParse->aNode[iRoot]; | 192415 | pRoot = &pParse->aNode[iRoot]; |
| 192416 | assert( pRoot->eU==0 ); | ||
| 190812 | pRoot->u.iAppend = iStart - iRoot; | 192417 | pRoot->u.iAppend = iStart - iRoot; |
| 190813 | pRoot->jnFlags |= JNODE_APPEND; | 192418 | pRoot->jnFlags |= JNODE_APPEND; |
| 192419 | VVA( pRoot->eU = 2 ); | ||
| 190814 | pParse->aNode[iLabel].jnFlags |= JNODE_RAW; | 192420 | pParse->aNode[iLabel].jnFlags |= JNODE_RAW; |
| 190815 | } | 192421 | } |
| 190816 | return pNode; | 192422 | return pNode; |
| @@ -190833,6 +192439,7 @@ static JsonNode *jsonLookupStep( | |||
| 190833 | j += jsonNodeSize(&pBase[j]); | 192439 | j += jsonNodeSize(&pBase[j]); |
| 190834 | } | 192440 | } |
| 190835 | if( (pBase->jnFlags & JNODE_APPEND)==0 ) break; | 192441 | if( (pBase->jnFlags & JNODE_APPEND)==0 ) break; |
| 192442 | assert( pBase->eU==2 ); | ||
| 190836 | iBase += pBase->u.iAppend; | 192443 | iBase += pBase->u.iAppend; |
| 190837 | pBase = &pParse->aNode[iBase]; | 192444 | pBase = &pParse->aNode[iBase]; |
| 190838 | j = 1; | 192445 | j = 1; |
| @@ -190866,6 +192473,7 @@ static JsonNode *jsonLookupStep( | |||
| 190866 | j += jsonNodeSize(&pRoot[j]); | 192473 | j += jsonNodeSize(&pRoot[j]); |
| 190867 | } | 192474 | } |
| 190868 | if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; | 192475 | if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; |
| 192476 | assert( pRoot->eU==2 ); | ||
| 190869 | iRoot += pRoot->u.iAppend; | 192477 | iRoot += pRoot->u.iAppend; |
| 190870 | pRoot = &pParse->aNode[iRoot]; | 192478 | pRoot = &pParse->aNode[iRoot]; |
| 190871 | j = 1; | 192479 | j = 1; |
| @@ -190881,8 +192489,10 @@ static JsonNode *jsonLookupStep( | |||
| 190881 | if( pParse->oom ) return 0; | 192489 | if( pParse->oom ) return 0; |
| 190882 | if( pNode ){ | 192490 | if( pNode ){ |
| 190883 | pRoot = &pParse->aNode[iRoot]; | 192491 | pRoot = &pParse->aNode[iRoot]; |
| 192492 | assert( pRoot->eU==0 ); | ||
| 190884 | pRoot->u.iAppend = iStart - iRoot; | 192493 | pRoot->u.iAppend = iStart - iRoot; |
| 190885 | pRoot->jnFlags |= JNODE_APPEND; | 192494 | pRoot->jnFlags |= JNODE_APPEND; |
| 192495 | VVA( pRoot->eU = 2 ); | ||
| 190886 | } | 192496 | } |
| 190887 | return pNode; | 192497 | return pNode; |
| 190888 | } | 192498 | } |
| @@ -191036,9 +192646,13 @@ static void jsonParseFunc( | |||
| 191036 | } | 192646 | } |
| 191037 | jsonPrintf(100, &s,"node %3u: %7s n=%-4d up=%-4d", | 192647 | jsonPrintf(100, &s,"node %3u: %7s n=%-4d up=%-4d", |
| 191038 | i, zType, x.aNode[i].n, x.aUp[i]); | 192648 | i, zType, x.aNode[i].n, x.aUp[i]); |
| 192649 | assert( x.aNode[i].eU==0 || x.aNode[i].eU==1 ); | ||
| 191039 | if( x.aNode[i].u.zJContent!=0 ){ | 192650 | if( x.aNode[i].u.zJContent!=0 ){ |
| 192651 | assert( x.aNode[i].eU==1 ); | ||
| 191040 | jsonAppendRaw(&s, " ", 1); | 192652 | jsonAppendRaw(&s, " ", 1); |
| 191041 | jsonAppendRaw(&s, x.aNode[i].u.zJContent, x.aNode[i].n); | 192653 | jsonAppendRaw(&s, x.aNode[i].u.zJContent, x.aNode[i].n); |
| 192654 | }else{ | ||
| 192655 | assert( x.aNode[i].eU==0 ); | ||
| 191042 | } | 192656 | } |
| 191043 | jsonAppendRaw(&s, "\n", 1); | 192657 | jsonAppendRaw(&s, "\n", 1); |
| 191044 | } | 192658 | } |
| @@ -191221,6 +192835,7 @@ static JsonNode *jsonMergePatch( | |||
| 191221 | const char *zKey; | 192835 | const char *zKey; |
| 191222 | assert( pPatch[i].eType==JSON_STRING ); | 192836 | assert( pPatch[i].eType==JSON_STRING ); |
| 191223 | assert( pPatch[i].jnFlags & JNODE_LABEL ); | 192837 | assert( pPatch[i].jnFlags & JNODE_LABEL ); |
| 192838 | assert( pPatch[i].eU==1 ); | ||
| 191224 | nKey = pPatch[i].n; | 192839 | nKey = pPatch[i].n; |
| 191225 | zKey = pPatch[i].u.zJContent; | 192840 | zKey = pPatch[i].u.zJContent; |
| 191226 | assert( (pPatch[i].jnFlags & JNODE_RAW)==0 ); | 192841 | assert( (pPatch[i].jnFlags & JNODE_RAW)==0 ); |
| @@ -191237,6 +192852,12 @@ static JsonNode *jsonMergePatch( | |||
| 191237 | if( pNew==0 ) return 0; | 192852 | if( pNew==0 ) return 0; |
| 191238 | pTarget = &pParse->aNode[iTarget]; | 192853 | pTarget = &pParse->aNode[iTarget]; |
| 191239 | if( pNew!=&pTarget[j+1] ){ | 192854 | if( pNew!=&pTarget[j+1] ){ |
| 192855 | assert( pTarget[j+1].eU==0 | ||
| 192856 | || pTarget[j+1].eU==1 | ||
| 192857 | || pTarget[j+1].eU==2 ); | ||
| 192858 | testcase( pTarget[j+1].eU==1 ); | ||
| 192859 | testcase( pTarget[j+1].eU==2 ); | ||
| 192860 | VVA( pTarget[j+1].eU = 5 ); | ||
| 191240 | pTarget[j+1].u.pPatch = pNew; | 192861 | pTarget[j+1].u.pPatch = pNew; |
| 191241 | pTarget[j+1].jnFlags |= JNODE_PATCH; | 192862 | pTarget[j+1].jnFlags |= JNODE_PATCH; |
| 191242 | } | 192863 | } |
| @@ -191252,9 +192873,14 @@ static JsonNode *jsonMergePatch( | |||
| 191252 | if( pParse->oom ) return 0; | 192873 | if( pParse->oom ) return 0; |
| 191253 | jsonRemoveAllNulls(pPatch); | 192874 | jsonRemoveAllNulls(pPatch); |
| 191254 | pTarget = &pParse->aNode[iTarget]; | 192875 | pTarget = &pParse->aNode[iTarget]; |
| 192876 | assert( pParse->aNode[iRoot].eU==0 || pParse->aNode[iRoot].eU==2 ); | ||
| 192877 | testcase( pParse->aNode[iRoot].eU==2 ); | ||
| 191255 | pParse->aNode[iRoot].jnFlags |= JNODE_APPEND; | 192878 | pParse->aNode[iRoot].jnFlags |= JNODE_APPEND; |
| 192879 | VVA( pParse->aNode[iRoot].eU = 2 ); | ||
| 191256 | pParse->aNode[iRoot].u.iAppend = iStart - iRoot; | 192880 | pParse->aNode[iRoot].u.iAppend = iStart - iRoot; |
| 191257 | iRoot = iStart; | 192881 | iRoot = iStart; |
| 192882 | assert( pParse->aNode[iPatch].eU==0 ); | ||
| 192883 | VVA( pParse->aNode[iPatch].eU = 5 ); | ||
| 191258 | pParse->aNode[iPatch].jnFlags |= JNODE_PATCH; | 192884 | pParse->aNode[iPatch].jnFlags |= JNODE_PATCH; |
| 191259 | pParse->aNode[iPatch].u.pPatch = &pPatch[i+1]; | 192885 | pParse->aNode[iPatch].u.pPatch = &pPatch[i+1]; |
| 191260 | } | 192886 | } |
| @@ -191396,11 +193022,15 @@ static void jsonReplaceFunc( | |||
| 191396 | pNode = jsonLookup(&x, zPath, 0, ctx); | 193022 | pNode = jsonLookup(&x, zPath, 0, ctx); |
| 191397 | if( x.nErr ) goto replace_err; | 193023 | if( x.nErr ) goto replace_err; |
| 191398 | if( pNode ){ | 193024 | if( pNode ){ |
| 193025 | assert( pNode->eU==0 || pNode->eU==1 || pNode->eU==4 ); | ||
| 193026 | json_testcase( pNode->eU!=0 && pNode->eU!=1 ); | ||
| 191399 | pNode->jnFlags |= (u8)JNODE_REPLACE; | 193027 | pNode->jnFlags |= (u8)JNODE_REPLACE; |
| 193028 | VVA( pNode->eU = 4 ); | ||
| 191400 | pNode->u.iReplace = i + 1; | 193029 | pNode->u.iReplace = i + 1; |
| 191401 | } | 193030 | } |
| 191402 | } | 193031 | } |
| 191403 | if( x.aNode[0].jnFlags & JNODE_REPLACE ){ | 193032 | if( x.aNode[0].jnFlags & JNODE_REPLACE ){ |
| 193033 | assert( x.aNode[0].eU==4 ); | ||
| 191404 | sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); | 193034 | sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); |
| 191405 | }else{ | 193035 | }else{ |
| 191406 | jsonReturnJson(x.aNode, ctx, argv); | 193036 | jsonReturnJson(x.aNode, ctx, argv); |
| @@ -191450,11 +193080,15 @@ static void jsonSetFunc( | |||
| 191450 | }else if( x.nErr ){ | 193080 | }else if( x.nErr ){ |
| 191451 | goto jsonSetDone; | 193081 | goto jsonSetDone; |
| 191452 | }else if( pNode && (bApnd || bIsSet) ){ | 193082 | }else if( pNode && (bApnd || bIsSet) ){ |
| 193083 | json_testcase( pNode->eU!=0 && pNode->eU!=1 && pNode->eU!=4 ); | ||
| 193084 | assert( pNode->eU!=3 || pNode->eU!=5 ); | ||
| 193085 | VVA( pNode->eU = 4 ); | ||
| 191453 | pNode->jnFlags |= (u8)JNODE_REPLACE; | 193086 | pNode->jnFlags |= (u8)JNODE_REPLACE; |
| 191454 | pNode->u.iReplace = i + 1; | 193087 | pNode->u.iReplace = i + 1; |
| 191455 | } | 193088 | } |
| 191456 | } | 193089 | } |
| 191457 | if( x.aNode[0].jnFlags & JNODE_REPLACE ){ | 193090 | if( x.aNode[0].jnFlags & JNODE_REPLACE ){ |
| 193091 | assert( x.aNode[0].eU==4 ); | ||
| 191458 | sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); | 193092 | sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); |
| 191459 | }else{ | 193093 | }else{ |
| 191460 | jsonReturnJson(x.aNode, ctx, argv); | 193094 | jsonReturnJson(x.aNode, ctx, argv); |
| @@ -191805,6 +193439,9 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){ | |||
| 191805 | JsonNode *pUp = &p->sParse.aNode[iUp]; | 193439 | JsonNode *pUp = &p->sParse.aNode[iUp]; |
| 191806 | p->eType = pUp->eType; | 193440 | p->eType = pUp->eType; |
| 191807 | if( pUp->eType==JSON_ARRAY ){ | 193441 | if( pUp->eType==JSON_ARRAY ){ |
| 193442 | assert( pUp->eU==0 || pUp->eU==3 ); | ||
| 193443 | json_testcase( pUp->eU==3 ); | ||
| 193444 | VVA( pUp->eU = 3 ); | ||
| 191808 | if( iUp==p->i-1 ){ | 193445 | if( iUp==p->i-1 ){ |
| 191809 | pUp->u.iKey = 0; | 193446 | pUp->u.iKey = 0; |
| 191810 | }else{ | 193447 | }else{ |
| @@ -191851,12 +193488,15 @@ static void jsonEachComputePath( | |||
| 191851 | pNode = &p->sParse.aNode[i]; | 193488 | pNode = &p->sParse.aNode[i]; |
| 191852 | pUp = &p->sParse.aNode[iUp]; | 193489 | pUp = &p->sParse.aNode[iUp]; |
| 191853 | if( pUp->eType==JSON_ARRAY ){ | 193490 | if( pUp->eType==JSON_ARRAY ){ |
| 193491 | assert( pUp->eU==3 || (pUp->eU==0 && pUp->u.iKey==0) ); | ||
| 193492 | testcase( pUp->eU==0 ); | ||
| 191854 | jsonPrintf(30, pStr, "[%d]", pUp->u.iKey); | 193493 | jsonPrintf(30, pStr, "[%d]", pUp->u.iKey); |
| 191855 | }else{ | 193494 | }else{ |
| 191856 | assert( pUp->eType==JSON_OBJECT ); | 193495 | assert( pUp->eType==JSON_OBJECT ); |
| 191857 | if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--; | 193496 | if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--; |
| 191858 | assert( pNode->eType==JSON_STRING ); | 193497 | assert( pNode->eType==JSON_STRING ); |
| 191859 | assert( pNode->jnFlags & JNODE_LABEL ); | 193498 | assert( pNode->jnFlags & JNODE_LABEL ); |
| 193499 | assert( pNode->eU==1 ); | ||
| 191860 | jsonPrintf(pNode->n+1, pStr, ".%.*s", pNode->n-2, pNode->u.zJContent+1); | 193500 | jsonPrintf(pNode->n+1, pStr, ".%.*s", pNode->n-2, pNode->u.zJContent+1); |
| 191861 | } | 193501 | } |
| 191862 | } | 193502 | } |
| @@ -191878,6 +193518,7 @@ static int jsonEachColumn( | |||
| 191878 | u32 iKey; | 193518 | u32 iKey; |
| 191879 | if( p->bRecursive ){ | 193519 | if( p->bRecursive ){ |
| 191880 | if( p->iRowid==0 ) break; | 193520 | if( p->iRowid==0 ) break; |
| 193521 | assert( p->sParse.aNode[p->sParse.aUp[p->i]].eU==3 ); | ||
| 191881 | iKey = p->sParse.aNode[p->sParse.aUp[p->i]].u.iKey; | 193522 | iKey = p->sParse.aNode[p->sParse.aUp[p->i]].u.iKey; |
| 191882 | }else{ | 193523 | }else{ |
| 191883 | iKey = p->iRowid; | 193524 | iKey = p->iRowid; |
| @@ -191927,6 +193568,7 @@ static int jsonEachColumn( | |||
| 191927 | if( p->eType==JSON_ARRAY ){ | 193568 | if( p->eType==JSON_ARRAY ){ |
| 191928 | jsonPrintf(30, &x, "[%d]", p->iRowid); | 193569 | jsonPrintf(30, &x, "[%d]", p->iRowid); |
| 191929 | }else if( p->eType==JSON_OBJECT ){ | 193570 | }else if( p->eType==JSON_OBJECT ){ |
| 193571 | assert( pThis->eU==1 ); | ||
| 191930 | jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1); | 193572 | jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1); |
| 191931 | } | 193573 | } |
| 191932 | } | 193574 | } |
| @@ -191994,6 +193636,7 @@ static int jsonEachBestIndex( | |||
| 191994 | if( pConstraint->iColumn < JEACH_JSON ) continue; | 193636 | if( pConstraint->iColumn < JEACH_JSON ) continue; |
| 191995 | iCol = pConstraint->iColumn - JEACH_JSON; | 193637 | iCol = pConstraint->iColumn - JEACH_JSON; |
| 191996 | assert( iCol==0 || iCol==1 ); | 193638 | assert( iCol==0 || iCol==1 ); |
| 193639 | testcase( iCol==0 ); | ||
| 191997 | iMask = 1 << iCol; | 193640 | iMask = 1 << iCol; |
| 191998 | if( pConstraint->usable==0 ){ | 193641 | if( pConstraint->usable==0 ){ |
| 191999 | unusableMask |= iMask; | 193642 | unusableMask |= iMask; |
| @@ -192091,6 +193734,8 @@ static int jsonEachFilter( | |||
| 192091 | p->iBegin = p->i = (int)(pNode - p->sParse.aNode); | 193734 | p->iBegin = p->i = (int)(pNode - p->sParse.aNode); |
| 192092 | p->eType = pNode->eType; | 193735 | p->eType = pNode->eType; |
| 192093 | if( p->eType>=JSON_ARRAY ){ | 193736 | if( p->eType>=JSON_ARRAY ){ |
| 193737 | assert( pNode->eU==0 ); | ||
| 193738 | VVA( pNode->eU = 3 ); | ||
| 192094 | pNode->u.iKey = 0; | 193739 | pNode->u.iKey = 0; |
| 192095 | p->iEnd = p->i + pNode->n + 1; | 193740 | p->iEnd = p->i + pNode->n + 1; |
| 192096 | if( p->bRecursive ){ | 193741 | if( p->bRecursive ){ |
| @@ -192333,7 +193978,11 @@ SQLITE_API int sqlite3_json_init( | |||
| 192333 | #endif | 193978 | #endif |
| 192334 | SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */ | 193979 | SQLITE_PRIVATE int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */ |
| 192335 | 193980 | ||
| 192336 | #ifndef SQLITE_AMALGAMATION | 193981 | /* |
| 193982 | ** If building separately, we will need some setup that is normally | ||
| 193983 | ** found in sqliteInt.h | ||
| 193984 | */ | ||
| 193985 | #if !defined(SQLITE_AMALGAMATION) | ||
| 192337 | #include "sqlite3rtree.h" | 193986 | #include "sqlite3rtree.h" |
| 192338 | typedef sqlite3_int64 i64; | 193987 | typedef sqlite3_int64 i64; |
| 192339 | typedef sqlite3_uint64 u64; | 193988 | typedef sqlite3_uint64 u64; |
| @@ -192346,7 +193995,20 @@ typedef unsigned int u32; | |||
| 192346 | #if defined(NDEBUG) && defined(SQLITE_DEBUG) | 193995 | #if defined(NDEBUG) && defined(SQLITE_DEBUG) |
| 192347 | # undef NDEBUG | 193996 | # undef NDEBUG |
| 192348 | #endif | 193997 | #endif |
| 193998 | #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST) | ||
| 193999 | # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1 | ||
| 194000 | #endif | ||
| 194001 | #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS) | ||
| 194002 | # define ALWAYS(X) (1) | ||
| 194003 | # define NEVER(X) (0) | ||
| 194004 | #elif !defined(NDEBUG) | ||
| 194005 | # define ALWAYS(X) ((X)?1:(assert(0),0)) | ||
| 194006 | # define NEVER(X) ((X)?(assert(0),1):0) | ||
| 194007 | #else | ||
| 194008 | # define ALWAYS(X) (X) | ||
| 194009 | # define NEVER(X) (X) | ||
| 192349 | #endif | 194010 | #endif |
| 194011 | #endif /* !defined(SQLITE_AMALGAMATION) */ | ||
| 192350 | 194012 | ||
| 192351 | /* #include <string.h> */ | 194013 | /* #include <string.h> */ |
| 192352 | /* #include <stdio.h> */ | 194014 | /* #include <stdio.h> */ |
| @@ -192404,7 +194066,9 @@ struct Rtree { | |||
| 192404 | u8 nBytesPerCell; /* Bytes consumed per cell */ | 194066 | u8 nBytesPerCell; /* Bytes consumed per cell */ |
| 192405 | u8 inWrTrans; /* True if inside write transaction */ | 194067 | u8 inWrTrans; /* True if inside write transaction */ |
| 192406 | u8 nAux; /* # of auxiliary columns in %_rowid */ | 194068 | u8 nAux; /* # of auxiliary columns in %_rowid */ |
| 194069 | #ifdef SQLITE_ENABLE_GEOPOLY | ||
| 192407 | u8 nAuxNotNull; /* Number of initial not-null aux columns */ | 194070 | u8 nAuxNotNull; /* Number of initial not-null aux columns */ |
| 194071 | #endif | ||
| 192408 | #ifdef SQLITE_DEBUG | 194072 | #ifdef SQLITE_DEBUG |
| 192409 | u8 bCorrupt; /* Shadow table corruption detected */ | 194073 | u8 bCorrupt; /* Shadow table corruption detected */ |
| 192410 | #endif | 194074 | #endif |
| @@ -192686,7 +194350,12 @@ struct RtreeMatchArg { | |||
| 192686 | ** it is not, make it a no-op. | 194350 | ** it is not, make it a no-op. |
| 192687 | */ | 194351 | */ |
| 192688 | #ifndef SQLITE_AMALGAMATION | 194352 | #ifndef SQLITE_AMALGAMATION |
| 192689 | # define testcase(X) | 194353 | # if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_DEBUG) |
| 194354 | unsigned int sqlite3RtreeTestcase = 0; | ||
| 194355 | # define testcase(X) if( X ){ sqlite3RtreeTestcase += __LINE__; } | ||
| 194356 | # else | ||
| 194357 | # define testcase(X) | ||
| 194358 | # endif | ||
| 192690 | #endif | 194359 | #endif |
| 192691 | 194360 | ||
| 192692 | /* | 194361 | /* |
| @@ -192936,18 +194605,6 @@ static void nodeBlobReset(Rtree *pRtree){ | |||
| 192936 | } | 194605 | } |
| 192937 | 194606 | ||
| 192938 | /* | 194607 | /* |
| 192939 | ** Check to see if pNode is the same as pParent or any of the parents | ||
| 192940 | ** of pParent. | ||
| 192941 | */ | ||
| 192942 | static int nodeInParentChain(const RtreeNode *pNode, const RtreeNode *pParent){ | ||
| 192943 | do{ | ||
| 192944 | if( pNode==pParent ) return 1; | ||
| 192945 | pParent = pParent->pParent; | ||
| 192946 | }while( pParent ); | ||
| 192947 | return 0; | ||
| 192948 | } | ||
| 192949 | |||
| 192950 | /* | ||
| 192951 | ** Obtain a reference to an r-tree node. | 194608 | ** Obtain a reference to an r-tree node. |
| 192952 | */ | 194609 | */ |
| 192953 | static int nodeAcquire( | 194610 | static int nodeAcquire( |
| @@ -192963,14 +194620,7 @@ static int nodeAcquire( | |||
| 192963 | ** increase its reference count and return it. | 194620 | ** increase its reference count and return it. |
| 192964 | */ | 194621 | */ |
| 192965 | if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){ | 194622 | if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){ |
| 192966 | if( pParent && !pNode->pParent ){ | 194623 | if( pParent && pParent!=pNode->pParent ){ |
| 192967 | if( nodeInParentChain(pNode, pParent) ){ | ||
| 192968 | RTREE_IS_CORRUPT(pRtree); | ||
| 192969 | return SQLITE_CORRUPT_VTAB; | ||
| 192970 | } | ||
| 192971 | pParent->nRef++; | ||
| 192972 | pNode->pParent = pParent; | ||
| 192973 | }else if( pParent && pNode->pParent && pParent!=pNode->pParent ){ | ||
| 192974 | RTREE_IS_CORRUPT(pRtree); | 194624 | RTREE_IS_CORRUPT(pRtree); |
| 192975 | return SQLITE_CORRUPT_VTAB; | 194625 | return SQLITE_CORRUPT_VTAB; |
| 192976 | } | 194626 | } |
| @@ -193028,7 +194678,7 @@ static int nodeAcquire( | |||
| 193028 | ** are the leaves, and so on. If the depth as specified on the root node | 194678 | ** are the leaves, and so on. If the depth as specified on the root node |
| 193029 | ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt. | 194679 | ** is greater than RTREE_MAX_DEPTH, the r-tree structure must be corrupt. |
| 193030 | */ | 194680 | */ |
| 193031 | if( pNode && rc==SQLITE_OK && iNode==1 ){ | 194681 | if( rc==SQLITE_OK && pNode && iNode==1 ){ |
| 193032 | pRtree->iDepth = readInt16(pNode->zData); | 194682 | pRtree->iDepth = readInt16(pNode->zData); |
| 193033 | if( pRtree->iDepth>RTREE_MAX_DEPTH ){ | 194683 | if( pRtree->iDepth>RTREE_MAX_DEPTH ){ |
| 193034 | rc = SQLITE_CORRUPT_VTAB; | 194684 | rc = SQLITE_CORRUPT_VTAB; |
| @@ -193551,20 +195201,29 @@ static void rtreeNonleafConstraint( | |||
| 193551 | switch( p->op ){ | 195201 | switch( p->op ){ |
| 193552 | case RTREE_TRUE: return; /* Always satisfied */ | 195202 | case RTREE_TRUE: return; /* Always satisfied */ |
| 193553 | case RTREE_FALSE: break; /* Never satisfied */ | 195203 | case RTREE_FALSE: break; /* Never satisfied */ |
| 195204 | case RTREE_EQ: | ||
| 195205 | RTREE_DECODE_COORD(eInt, pCellData, val); | ||
| 195206 | /* val now holds the lower bound of the coordinate pair */ | ||
| 195207 | if( p->u.rValue>=val ){ | ||
| 195208 | pCellData += 4; | ||
| 195209 | RTREE_DECODE_COORD(eInt, pCellData, val); | ||
| 195210 | /* val now holds the upper bound of the coordinate pair */ | ||
| 195211 | if( p->u.rValue<=val ) return; | ||
| 195212 | } | ||
| 195213 | break; | ||
| 193554 | case RTREE_LE: | 195214 | case RTREE_LE: |
| 193555 | case RTREE_LT: | 195215 | case RTREE_LT: |
| 193556 | case RTREE_EQ: | ||
| 193557 | RTREE_DECODE_COORD(eInt, pCellData, val); | 195216 | RTREE_DECODE_COORD(eInt, pCellData, val); |
| 193558 | /* val now holds the lower bound of the coordinate pair */ | 195217 | /* val now holds the lower bound of the coordinate pair */ |
| 193559 | if( p->u.rValue>=val ) return; | 195218 | if( p->u.rValue>=val ) return; |
| 193560 | if( p->op!=RTREE_EQ ) break; /* RTREE_LE and RTREE_LT end here */ | 195219 | break; |
| 193561 | /* Fall through for the RTREE_EQ case */ | ||
| 193562 | 195220 | ||
| 193563 | default: /* RTREE_GT or RTREE_GE, or fallthrough of RTREE_EQ */ | 195221 | default: |
| 193564 | pCellData += 4; | 195222 | pCellData += 4; |
| 193565 | RTREE_DECODE_COORD(eInt, pCellData, val); | 195223 | RTREE_DECODE_COORD(eInt, pCellData, val); |
| 193566 | /* val now holds the upper bound of the coordinate pair */ | 195224 | /* val now holds the upper bound of the coordinate pair */ |
| 193567 | if( p->u.rValue<=val ) return; | 195225 | if( p->u.rValue<=val ) return; |
| 195226 | break; | ||
| 193568 | } | 195227 | } |
| 193569 | *peWithin = NOT_WITHIN; | 195228 | *peWithin = NOT_WITHIN; |
| 193570 | } | 195229 | } |
| @@ -193634,11 +195293,12 @@ static int nodeRowidIndex( | |||
| 193634 | */ | 195293 | */ |
| 193635 | static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){ | 195294 | static int nodeParentIndex(Rtree *pRtree, RtreeNode *pNode, int *piIndex){ |
| 193636 | RtreeNode *pParent = pNode->pParent; | 195295 | RtreeNode *pParent = pNode->pParent; |
| 193637 | if( pParent ){ | 195296 | if( ALWAYS(pParent) ){ |
| 193638 | return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex); | 195297 | return nodeRowidIndex(pRtree, pParent, pNode->iNode, piIndex); |
| 195298 | }else{ | ||
| 195299 | *piIndex = -1; | ||
| 195300 | return SQLITE_OK; | ||
| 193639 | } | 195301 | } |
| 193640 | *piIndex = -1; | ||
| 193641 | return SQLITE_OK; | ||
| 193642 | } | 195302 | } |
| 193643 | 195303 | ||
| 193644 | /* | 195304 | /* |
| @@ -193761,7 +195421,8 @@ static RtreeSearchPoint *rtreeSearchPointNew( | |||
| 193761 | pNew = rtreeEnqueue(pCur, rScore, iLevel); | 195421 | pNew = rtreeEnqueue(pCur, rScore, iLevel); |
| 193762 | if( pNew==0 ) return 0; | 195422 | if( pNew==0 ) return 0; |
| 193763 | ii = (int)(pNew - pCur->aPoint) + 1; | 195423 | ii = (int)(pNew - pCur->aPoint) + 1; |
| 193764 | if( ii<RTREE_CACHE_SZ ){ | 195424 | assert( ii==1 ); |
| 195425 | if( ALWAYS(ii<RTREE_CACHE_SZ) ){ | ||
| 193765 | assert( pCur->aNode[ii]==0 ); | 195426 | assert( pCur->aNode[ii]==0 ); |
| 193766 | pCur->aNode[ii] = pCur->aNode[0]; | 195427 | pCur->aNode[ii] = pCur->aNode[0]; |
| 193767 | }else{ | 195428 | }else{ |
| @@ -193822,7 +195483,7 @@ static void rtreeSearchPointPop(RtreeCursor *p){ | |||
| 193822 | if( p->bPoint ){ | 195483 | if( p->bPoint ){ |
| 193823 | p->anQueue[p->sPoint.iLevel]--; | 195484 | p->anQueue[p->sPoint.iLevel]--; |
| 193824 | p->bPoint = 0; | 195485 | p->bPoint = 0; |
| 193825 | }else if( p->nPoint ){ | 195486 | }else if( ALWAYS(p->nPoint) ){ |
| 193826 | p->anQueue[p->aPoint[0].iLevel]--; | 195487 | p->anQueue[p->aPoint[0].iLevel]--; |
| 193827 | n = --p->nPoint; | 195488 | n = --p->nPoint; |
| 193828 | p->aPoint[0] = p->aPoint[n]; | 195489 | p->aPoint[0] = p->aPoint[n]; |
| @@ -193963,7 +195624,7 @@ static int rtreeRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){ | |||
| 193963 | RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr); | 195624 | RtreeSearchPoint *p = rtreeSearchPointFirst(pCsr); |
| 193964 | int rc = SQLITE_OK; | 195625 | int rc = SQLITE_OK; |
| 193965 | RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc); | 195626 | RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc); |
| 193966 | if( rc==SQLITE_OK && p ){ | 195627 | if( rc==SQLITE_OK && ALWAYS(p) ){ |
| 193967 | *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell); | 195628 | *pRowid = nodeGetRowid(RTREE_OF_CURSOR(pCsr), pNode, p->iCell); |
| 193968 | } | 195629 | } |
| 193969 | return rc; | 195630 | return rc; |
| @@ -193981,7 +195642,7 @@ static int rtreeColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ | |||
| 193981 | RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc); | 195642 | RtreeNode *pNode = rtreeNodeOfFirstSearchPoint(pCsr, &rc); |
| 193982 | 195643 | ||
| 193983 | if( rc ) return rc; | 195644 | if( rc ) return rc; |
| 193984 | if( p==0 ) return SQLITE_OK; | 195645 | if( NEVER(p==0) ) return SQLITE_OK; |
| 193985 | if( i==0 ){ | 195646 | if( i==0 ){ |
| 193986 | sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell)); | 195647 | sqlite3_result_int64(ctx, nodeGetRowid(pRtree, pNode, p->iCell)); |
| 193987 | }else if( i<=pRtree->nDim2 ){ | 195648 | }else if( i<=pRtree->nDim2 ){ |
| @@ -194180,8 +195841,11 @@ static int rtreeFilter( | |||
| 194180 | } | 195841 | } |
| 194181 | if( rc==SQLITE_OK ){ | 195842 | if( rc==SQLITE_OK ){ |
| 194182 | RtreeSearchPoint *pNew; | 195843 | RtreeSearchPoint *pNew; |
| 195844 | assert( pCsr->bPoint==0 ); /* Due to the resetCursor() call above */ | ||
| 194183 | pNew = rtreeSearchPointNew(pCsr, RTREE_ZERO, (u8)(pRtree->iDepth+1)); | 195845 | pNew = rtreeSearchPointNew(pCsr, RTREE_ZERO, (u8)(pRtree->iDepth+1)); |
| 194184 | if( pNew==0 ) return SQLITE_NOMEM; | 195846 | if( NEVER(pNew==0) ){ /* Because pCsr->bPoint was FALSE */ |
| 195847 | return SQLITE_NOMEM; | ||
| 195848 | } | ||
| 194185 | pNew->id = 1; | 195849 | pNew->id = 1; |
| 194186 | pNew->iCell = 0; | 195850 | pNew->iCell = 0; |
| 194187 | pNew->eWithin = PARTLY_WITHIN; | 195851 | pNew->eWithin = PARTLY_WITHIN; |
| @@ -194258,7 +195922,7 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ | |||
| 194258 | struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii]; | 195922 | struct sqlite3_index_constraint *p = &pIdxInfo->aConstraint[ii]; |
| 194259 | 195923 | ||
| 194260 | if( bMatch==0 && p->usable | 195924 | if( bMatch==0 && p->usable |
| 194261 | && p->iColumn==0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ | 195925 | && p->iColumn<=0 && p->op==SQLITE_INDEX_CONSTRAINT_EQ |
| 194262 | ){ | 195926 | ){ |
| 194263 | /* We have an equality constraint on the rowid. Use strategy 1. */ | 195927 | /* We have an equality constraint on the rowid. Use strategy 1. */ |
| 194264 | int jj; | 195928 | int jj; |
| @@ -194464,7 +196128,7 @@ static int ChooseLeaf( | |||
| 194464 | 196128 | ||
| 194465 | int nCell = NCELL(pNode); | 196129 | int nCell = NCELL(pNode); |
| 194466 | RtreeCell cell; | 196130 | RtreeCell cell; |
| 194467 | RtreeNode *pChild; | 196131 | RtreeNode *pChild = 0; |
| 194468 | 196132 | ||
| 194469 | RtreeCell *aCell = 0; | 196133 | RtreeCell *aCell = 0; |
| 194470 | 196134 | ||
| @@ -194511,12 +196175,19 @@ static int AdjustTree( | |||
| 194511 | ){ | 196175 | ){ |
| 194512 | RtreeNode *p = pNode; | 196176 | RtreeNode *p = pNode; |
| 194513 | int cnt = 0; | 196177 | int cnt = 0; |
| 196178 | int rc; | ||
| 194514 | while( p->pParent ){ | 196179 | while( p->pParent ){ |
| 194515 | RtreeNode *pParent = p->pParent; | 196180 | RtreeNode *pParent = p->pParent; |
| 194516 | RtreeCell cell; | 196181 | RtreeCell cell; |
| 194517 | int iCell; | 196182 | int iCell; |
| 194518 | 196183 | ||
| 194519 | if( (++cnt)>1000 || nodeParentIndex(pRtree, p, &iCell) ){ | 196184 | cnt++; |
| 196185 | if( NEVER(cnt>100) ){ | ||
| 196186 | RTREE_IS_CORRUPT(pRtree); | ||
| 196187 | return SQLITE_CORRUPT_VTAB; | ||
| 196188 | } | ||
| 196189 | rc = nodeParentIndex(pRtree, p, &iCell); | ||
| 196190 | if( NEVER(rc!=SQLITE_OK) ){ | ||
| 194520 | RTREE_IS_CORRUPT(pRtree); | 196191 | RTREE_IS_CORRUPT(pRtree); |
| 194521 | return SQLITE_CORRUPT_VTAB; | 196192 | return SQLITE_CORRUPT_VTAB; |
| 194522 | } | 196193 | } |
| @@ -194805,12 +196476,17 @@ static int updateMapping( | |||
| 194805 | xSetMapping = ((iHeight==0)?rowidWrite:parentWrite); | 196476 | xSetMapping = ((iHeight==0)?rowidWrite:parentWrite); |
| 194806 | if( iHeight>0 ){ | 196477 | if( iHeight>0 ){ |
| 194807 | RtreeNode *pChild = nodeHashLookup(pRtree, iRowid); | 196478 | RtreeNode *pChild = nodeHashLookup(pRtree, iRowid); |
| 196479 | RtreeNode *p; | ||
| 196480 | for(p=pNode; p; p=p->pParent){ | ||
| 196481 | if( p==pChild ) return SQLITE_CORRUPT_VTAB; | ||
| 196482 | } | ||
| 194808 | if( pChild ){ | 196483 | if( pChild ){ |
| 194809 | nodeRelease(pRtree, pChild->pParent); | 196484 | nodeRelease(pRtree, pChild->pParent); |
| 194810 | nodeReference(pNode); | 196485 | nodeReference(pNode); |
| 194811 | pChild->pParent = pNode; | 196486 | pChild->pParent = pNode; |
| 194812 | } | 196487 | } |
| 194813 | } | 196488 | } |
| 196489 | if( NEVER(pNode==0) ) return SQLITE_ERROR; | ||
| 194814 | return xSetMapping(pRtree, iRowid, pNode->iNode); | 196490 | return xSetMapping(pRtree, iRowid, pNode->iNode); |
| 194815 | } | 196491 | } |
| 194816 | 196492 | ||
| @@ -194900,11 +196576,12 @@ static int SplitNode( | |||
| 194900 | RtreeNode *pParent = pLeft->pParent; | 196576 | RtreeNode *pParent = pLeft->pParent; |
| 194901 | int iCell; | 196577 | int iCell; |
| 194902 | rc = nodeParentIndex(pRtree, pLeft, &iCell); | 196578 | rc = nodeParentIndex(pRtree, pLeft, &iCell); |
| 194903 | if( rc==SQLITE_OK ){ | 196579 | if( ALWAYS(rc==SQLITE_OK) ){ |
| 194904 | nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell); | 196580 | nodeOverwriteCell(pRtree, pParent, &leftbbox, iCell); |
| 194905 | rc = AdjustTree(pRtree, pParent, &leftbbox); | 196581 | rc = AdjustTree(pRtree, pParent, &leftbbox); |
| 196582 | assert( rc==SQLITE_OK ); | ||
| 194906 | } | 196583 | } |
| 194907 | if( rc!=SQLITE_OK ){ | 196584 | if( NEVER(rc!=SQLITE_OK) ){ |
| 194908 | goto splitnode_out; | 196585 | goto splitnode_out; |
| 194909 | } | 196586 | } |
| 194910 | } | 196587 | } |
| @@ -194979,7 +196656,7 @@ static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){ | |||
| 194979 | */ | 196656 | */ |
| 194980 | iNode = sqlite3_column_int64(pRtree->pReadParent, 0); | 196657 | iNode = sqlite3_column_int64(pRtree->pReadParent, 0); |
| 194981 | for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent); | 196658 | for(pTest=pLeaf; pTest && pTest->iNode!=iNode; pTest=pTest->pParent); |
| 194982 | if( !pTest ){ | 196659 | if( pTest==0 ){ |
| 194983 | rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent); | 196660 | rc2 = nodeAcquire(pRtree, iNode, 0, &pChild->pParent); |
| 194984 | } | 196661 | } |
| 194985 | } | 196662 | } |
| @@ -195010,6 +196687,7 @@ static int removeNode(Rtree *pRtree, RtreeNode *pNode, int iHeight){ | |||
| 195010 | pParent = pNode->pParent; | 196687 | pParent = pNode->pParent; |
| 195011 | pNode->pParent = 0; | 196688 | pNode->pParent = 0; |
| 195012 | rc = deleteCell(pRtree, pParent, iCell, iHeight+1); | 196689 | rc = deleteCell(pRtree, pParent, iCell, iHeight+1); |
| 196690 | testcase( rc!=SQLITE_OK ); | ||
| 195013 | } | 196691 | } |
| 195014 | rc2 = nodeRelease(pRtree, pParent); | 196692 | rc2 = nodeRelease(pRtree, pParent); |
| 195015 | if( rc==SQLITE_OK ){ | 196693 | if( rc==SQLITE_OK ){ |
| @@ -195232,7 +196910,7 @@ static int rtreeInsertCell( | |||
| 195232 | } | 196910 | } |
| 195233 | }else{ | 196911 | }else{ |
| 195234 | rc = AdjustTree(pRtree, pNode, pCell); | 196912 | rc = AdjustTree(pRtree, pNode, pCell); |
| 195235 | if( rc==SQLITE_OK ){ | 196913 | if( ALWAYS(rc==SQLITE_OK) ){ |
| 195236 | if( iHeight==0 ){ | 196914 | if( iHeight==0 ){ |
| 195237 | rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode); | 196915 | rc = rowidWrite(pRtree, pCell->iRowid, pNode->iNode); |
| 195238 | }else{ | 196916 | }else{ |
| @@ -195338,7 +197016,7 @@ static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){ | |||
| 195338 | int rc2; | 197016 | int rc2; |
| 195339 | RtreeNode *pChild = 0; | 197017 | RtreeNode *pChild = 0; |
| 195340 | i64 iChild = nodeGetRowid(pRtree, pRoot, 0); | 197018 | i64 iChild = nodeGetRowid(pRtree, pRoot, 0); |
| 195341 | rc = nodeAcquire(pRtree, iChild, pRoot, &pChild); | 197019 | rc = nodeAcquire(pRtree, iChild, pRoot, &pChild); /* tag-20210916a */ |
| 195342 | if( rc==SQLITE_OK ){ | 197020 | if( rc==SQLITE_OK ){ |
| 195343 | rc = removeNode(pRtree, pChild, pRtree->iDepth-1); | 197021 | rc = removeNode(pRtree, pChild, pRtree->iDepth-1); |
| 195344 | } | 197022 | } |
| @@ -195673,7 +197351,7 @@ static int rtreeQueryStat1(sqlite3 *db, Rtree *pRtree){ | |||
| 195673 | char *zSql; | 197351 | char *zSql; |
| 195674 | sqlite3_stmt *p; | 197352 | sqlite3_stmt *p; |
| 195675 | int rc; | 197353 | int rc; |
| 195676 | i64 nRow = 0; | 197354 | i64 nRow = RTREE_MIN_ROWEST; |
| 195677 | 197355 | ||
| 195678 | rc = sqlite3_table_column_metadata( | 197356 | rc = sqlite3_table_column_metadata( |
| 195679 | db, pRtree->zDb, "sqlite_stat1",0,0,0,0,0,0 | 197357 | db, pRtree->zDb, "sqlite_stat1",0,0,0,0,0,0 |
| @@ -195690,20 +197368,10 @@ static int rtreeQueryStat1(sqlite3 *db, Rtree *pRtree){ | |||
| 195690 | if( rc==SQLITE_OK ){ | 197368 | if( rc==SQLITE_OK ){ |
| 195691 | if( sqlite3_step(p)==SQLITE_ROW ) nRow = sqlite3_column_int64(p, 0); | 197369 | if( sqlite3_step(p)==SQLITE_ROW ) nRow = sqlite3_column_int64(p, 0); |
| 195692 | rc = sqlite3_finalize(p); | 197370 | rc = sqlite3_finalize(p); |
| 195693 | }else if( rc!=SQLITE_NOMEM ){ | ||
| 195694 | rc = SQLITE_OK; | ||
| 195695 | } | ||
| 195696 | |||
| 195697 | if( rc==SQLITE_OK ){ | ||
| 195698 | if( nRow==0 ){ | ||
| 195699 | pRtree->nRowEst = RTREE_DEFAULT_ROWEST; | ||
| 195700 | }else{ | ||
| 195701 | pRtree->nRowEst = MAX(nRow, RTREE_MIN_ROWEST); | ||
| 195702 | } | ||
| 195703 | } | 197371 | } |
| 195704 | sqlite3_free(zSql); | 197372 | sqlite3_free(zSql); |
| 195705 | } | 197373 | } |
| 195706 | 197374 | pRtree->nRowEst = MAX(nRow, RTREE_MIN_ROWEST); | |
| 195707 | return rc; | 197375 | return rc; |
| 195708 | } | 197376 | } |
| 195709 | 197377 | ||
| @@ -195853,9 +197521,12 @@ static int rtreeSqlInit( | |||
| 195853 | sqlite3_str_appendf(p, "UPDATE \"%w\".\"%w_rowid\"SET ", zDb, zPrefix); | 197521 | sqlite3_str_appendf(p, "UPDATE \"%w\".\"%w_rowid\"SET ", zDb, zPrefix); |
| 195854 | for(ii=0; ii<pRtree->nAux; ii++){ | 197522 | for(ii=0; ii<pRtree->nAux; ii++){ |
| 195855 | if( ii ) sqlite3_str_append(p, ",", 1); | 197523 | if( ii ) sqlite3_str_append(p, ",", 1); |
| 197524 | #ifdef SQLITE_ENABLE_GEOPOLY | ||
| 195856 | if( ii<pRtree->nAuxNotNull ){ | 197525 | if( ii<pRtree->nAuxNotNull ){ |
| 195857 | sqlite3_str_appendf(p,"a%d=coalesce(?%d,a%d)",ii,ii+2,ii); | 197526 | sqlite3_str_appendf(p,"a%d=coalesce(?%d,a%d)",ii,ii+2,ii); |
| 195858 | }else{ | 197527 | }else |
| 197528 | #endif | ||
| 197529 | { | ||
| 195859 | sqlite3_str_appendf(p,"a%d=?%d",ii,ii+2); | 197530 | sqlite3_str_appendf(p,"a%d=?%d",ii,ii+2); |
| 195860 | } | 197531 | } |
| 195861 | } | 197532 | } |
| @@ -196120,6 +197791,7 @@ static void rtreenode(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){ | |||
| 196120 | tree.nDim2 = tree.nDim*2; | 197791 | tree.nDim2 = tree.nDim*2; |
| 196121 | tree.nBytesPerCell = 8 + 8 * tree.nDim; | 197792 | tree.nBytesPerCell = 8 + 8 * tree.nDim; |
| 196122 | node.zData = (u8 *)sqlite3_value_blob(apArg[1]); | 197793 | node.zData = (u8 *)sqlite3_value_blob(apArg[1]); |
| 197794 | if( node.zData==0 ) return; | ||
| 196123 | nData = sqlite3_value_bytes(apArg[1]); | 197795 | nData = sqlite3_value_bytes(apArg[1]); |
| 196124 | if( nData<4 ) return; | 197796 | if( nData<4 ) return; |
| 196125 | if( nData<NCELL(&node)*tree.nBytesPerCell ) return; | 197797 | if( nData<NCELL(&node)*tree.nBytesPerCell ) return; |
| @@ -196534,8 +198206,10 @@ static int rtreeCheckTable( | |||
| 196534 | if( pStmt ){ | 198206 | if( pStmt ){ |
| 196535 | nAux = sqlite3_column_count(pStmt) - 2; | 198207 | nAux = sqlite3_column_count(pStmt) - 2; |
| 196536 | sqlite3_finalize(pStmt); | 198208 | sqlite3_finalize(pStmt); |
| 198209 | }else | ||
| 198210 | if( check.rc!=SQLITE_NOMEM ){ | ||
| 198211 | check.rc = SQLITE_OK; | ||
| 196537 | } | 198212 | } |
| 196538 | check.rc = SQLITE_OK; | ||
| 196539 | } | 198213 | } |
| 196540 | 198214 | ||
| 196541 | /* Find number of dimensions in the rtree table. */ | 198215 | /* Find number of dimensions in the rtree table. */ |
| @@ -196949,13 +198623,14 @@ static GeoPoly *geopolyFuncParam( | |||
| 196949 | ){ | 198623 | ){ |
| 196950 | GeoPoly *p = 0; | 198624 | GeoPoly *p = 0; |
| 196951 | int nByte; | 198625 | int nByte; |
| 198626 | testcase( pCtx==0 ); | ||
| 196952 | if( sqlite3_value_type(pVal)==SQLITE_BLOB | 198627 | if( sqlite3_value_type(pVal)==SQLITE_BLOB |
| 196953 | && (nByte = sqlite3_value_bytes(pVal))>=(4+6*sizeof(GeoCoord)) | 198628 | && (nByte = sqlite3_value_bytes(pVal))>=(4+6*sizeof(GeoCoord)) |
| 196954 | ){ | 198629 | ){ |
| 196955 | const unsigned char *a = sqlite3_value_blob(pVal); | 198630 | const unsigned char *a = sqlite3_value_blob(pVal); |
| 196956 | int nVertex; | 198631 | int nVertex; |
| 196957 | if( a==0 ){ | 198632 | if( a==0 ){ |
| 196958 | sqlite3_result_error_nomem(pCtx); | 198633 | if( pCtx ) sqlite3_result_error_nomem(pCtx); |
| 196959 | return 0; | 198634 | return 0; |
| 196960 | } | 198635 | } |
| 196961 | nVertex = (a[1]<<16) + (a[2]<<8) + a[3]; | 198636 | nVertex = (a[1]<<16) + (a[2]<<8) + a[3]; |
| @@ -197782,11 +199457,11 @@ static int geopolyOverlap(GeoPoly *p1, GeoPoly *p2){ | |||
| 197782 | }else{ | 199457 | }else{ |
| 197783 | /* Remove a segment */ | 199458 | /* Remove a segment */ |
| 197784 | if( pActive==pThisEvent->pSeg ){ | 199459 | if( pActive==pThisEvent->pSeg ){ |
| 197785 | pActive = pActive->pNext; | 199460 | pActive = ALWAYS(pActive) ? pActive->pNext : 0; |
| 197786 | }else{ | 199461 | }else{ |
| 197787 | for(pSeg=pActive; pSeg; pSeg=pSeg->pNext){ | 199462 | for(pSeg=pActive; pSeg; pSeg=pSeg->pNext){ |
| 197788 | if( pSeg->pNext==pThisEvent->pSeg ){ | 199463 | if( pSeg->pNext==pThisEvent->pSeg ){ |
| 197789 | pSeg->pNext = pSeg->pNext->pNext; | 199464 | pSeg->pNext = ALWAYS(pSeg->pNext) ? pSeg->pNext->pNext : 0; |
| 197790 | break; | 199465 | break; |
| 197791 | } | 199466 | } |
| 197792 | } | 199467 | } |
| @@ -198030,6 +199705,7 @@ static int geopolyFilter( | |||
| 198030 | RtreeCoord bbox[4]; | 199705 | RtreeCoord bbox[4]; |
| 198031 | RtreeConstraint *p; | 199706 | RtreeConstraint *p; |
| 198032 | assert( argc==1 ); | 199707 | assert( argc==1 ); |
| 199708 | assert( argv[0]!=0 ); | ||
| 198033 | geopolyBBox(0, argv[0], bbox, &rc); | 199709 | geopolyBBox(0, argv[0], bbox, &rc); |
| 198034 | if( rc ){ | 199710 | if( rc ){ |
| 198035 | goto geopoly_filter_end; | 199711 | goto geopoly_filter_end; |
| @@ -198257,6 +199933,7 @@ static int geopolyUpdate( | |||
| 198257 | || !sqlite3_value_nochange(aData[2]) /* UPDATE _shape */ | 199933 | || !sqlite3_value_nochange(aData[2]) /* UPDATE _shape */ |
| 198258 | || oldRowid!=newRowid) /* Rowid change */ | 199934 | || oldRowid!=newRowid) /* Rowid change */ |
| 198259 | ){ | 199935 | ){ |
| 199936 | assert( aData[2]!=0 ); | ||
| 198260 | geopolyBBox(0, aData[2], cell.aCoord, &rc); | 199937 | geopolyBBox(0, aData[2], cell.aCoord, &rc); |
| 198261 | if( rc ){ | 199938 | if( rc ){ |
| 198262 | if( rc==SQLITE_ERROR ){ | 199939 | if( rc==SQLITE_ERROR ){ |
| @@ -198610,7 +200287,10 @@ SQLITE_API int sqlite3_rtree_query_callback( | |||
| 198610 | 200287 | ||
| 198611 | /* Allocate and populate the context object. */ | 200288 | /* Allocate and populate the context object. */ |
| 198612 | pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback)); | 200289 | pGeomCtx = (RtreeGeomCallback *)sqlite3_malloc(sizeof(RtreeGeomCallback)); |
| 198613 | if( !pGeomCtx ) return SQLITE_NOMEM; | 200290 | if( !pGeomCtx ){ |
| 200291 | if( xDestructor ) xDestructor(pContext); | ||
| 200292 | return SQLITE_NOMEM; | ||
| 200293 | } | ||
| 198614 | pGeomCtx->xGeom = 0; | 200294 | pGeomCtx->xGeom = 0; |
| 198615 | pGeomCtx->xQueryFunc = xQueryFunc; | 200295 | pGeomCtx->xQueryFunc = xQueryFunc; |
| 198616 | pGeomCtx->xDestructor = xDestructor; | 200296 | pGeomCtx->xDestructor = xDestructor; |
| @@ -200182,6 +201862,13 @@ SQLITE_API void sqlite3rbu_destroy_vfs(const char *zName); | |||
| 200182 | #endif | 201862 | #endif |
| 200183 | 201863 | ||
| 200184 | /* | 201864 | /* |
| 201865 | ** Name of the URI option that causes RBU to take an exclusive lock as | ||
| 201866 | ** part of the incremental checkpoint operation. | ||
| 201867 | */ | ||
| 201868 | #define RBU_EXCLUSIVE_CHECKPOINT "rbu_exclusive_checkpoint" | ||
| 201869 | |||
| 201870 | |||
| 201871 | /* | ||
| 200185 | ** The rbu_state table is used to save the state of a partially applied | 201872 | ** The rbu_state table is used to save the state of a partially applied |
| 200186 | ** update so that it can be resumed later. The table consists of integer | 201873 | ** update so that it can be resumed later. The table consists of integer |
| 200187 | ** keys mapped to values as follows: | 201874 | ** keys mapped to values as follows: |
| @@ -201265,7 +202952,9 @@ static void rbuTableType( | |||
| 201265 | assert( p->rc==SQLITE_OK ); | 202952 | assert( p->rc==SQLITE_OK ); |
| 201266 | p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[0], &p->zErrmsg, | 202953 | p->rc = prepareFreeAndCollectError(p->dbMain, &aStmt[0], &p->zErrmsg, |
| 201267 | sqlite3_mprintf( | 202954 | sqlite3_mprintf( |
| 201268 | "SELECT (sql LIKE 'create virtual%%'), rootpage" | 202955 | "SELECT " |
| 202956 | " (sql COLLATE nocase BETWEEN 'CREATE VIRTUAL' AND 'CREATE VIRTUAM')," | ||
| 202957 | " rootpage" | ||
| 201269 | " FROM sqlite_schema" | 202958 | " FROM sqlite_schema" |
| 201270 | " WHERE name=%Q", zTab | 202959 | " WHERE name=%Q", zTab |
| 201271 | )); | 202960 | )); |
| @@ -202798,7 +204487,7 @@ static RbuState *rbuLoadState(sqlite3rbu *p){ | |||
| 202798 | break; | 204487 | break; |
| 202799 | 204488 | ||
| 202800 | case RBU_STATE_OALSZ: | 204489 | case RBU_STATE_OALSZ: |
| 202801 | pRet->iOalSz = (u32)sqlite3_column_int64(pStmt, 1); | 204490 | pRet->iOalSz = sqlite3_column_int64(pStmt, 1); |
| 202802 | break; | 204491 | break; |
| 202803 | 204492 | ||
| 202804 | case RBU_STATE_PHASEONESTEP: | 204493 | case RBU_STATE_PHASEONESTEP: |
| @@ -202825,13 +204514,19 @@ static RbuState *rbuLoadState(sqlite3rbu *p){ | |||
| 202825 | /* | 204514 | /* |
| 202826 | ** Open the database handle and attach the RBU database as "rbu". If an | 204515 | ** Open the database handle and attach the RBU database as "rbu". If an |
| 202827 | ** error occurs, leave an error code and message in the RBU handle. | 204516 | ** error occurs, leave an error code and message in the RBU handle. |
| 204517 | ** | ||
| 204518 | ** If argument dbMain is not NULL, then it is a database handle already | ||
| 204519 | ** open on the target database. Use this handle instead of opening a new | ||
| 204520 | ** one. | ||
| 202828 | */ | 204521 | */ |
| 202829 | static void rbuOpenDatabase(sqlite3rbu *p, int *pbRetry){ | 204522 | static void rbuOpenDatabase(sqlite3rbu *p, sqlite3 *dbMain, int *pbRetry){ |
| 202830 | assert( p->rc || (p->dbMain==0 && p->dbRbu==0) ); | 204523 | assert( p->rc || (p->dbMain==0 && p->dbRbu==0) ); |
| 202831 | assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 ); | 204524 | assert( p->rc || rbuIsVacuum(p) || p->zTarget!=0 ); |
| 204525 | assert( dbMain==0 || rbuIsVacuum(p)==0 ); | ||
| 202832 | 204526 | ||
| 202833 | /* Open the RBU database */ | 204527 | /* Open the RBU database */ |
| 202834 | p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1); | 204528 | p->dbRbu = rbuOpenDbhandle(p, p->zRbu, 1); |
| 204529 | p->dbMain = dbMain; | ||
| 202835 | 204530 | ||
| 202836 | if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){ | 204531 | if( p->rc==SQLITE_OK && rbuIsVacuum(p) ){ |
| 202837 | sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p); | 204532 | sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p); |
| @@ -203197,15 +204892,31 @@ static void rbuCheckpointFrame(sqlite3rbu *p, RbuFrame *pFrame){ | |||
| 203197 | 204892 | ||
| 203198 | 204893 | ||
| 203199 | /* | 204894 | /* |
| 203200 | ** Take an EXCLUSIVE lock on the database file. | 204895 | ** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if |
| 204896 | ** successful, or an SQLite error code otherwise. | ||
| 203201 | */ | 204897 | */ |
| 203202 | static void rbuLockDatabase(sqlite3rbu *p){ | 204898 | static int rbuLockDatabase(sqlite3 *db){ |
| 203203 | sqlite3_file *pReal = p->pTargetFd->pReal; | 204899 | int rc = SQLITE_OK; |
| 203204 | assert( p->rc==SQLITE_OK ); | 204900 | sqlite3_file *fd = 0; |
| 203205 | p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_SHARED); | 204901 | sqlite3_file_control(db, "main", SQLITE_FCNTL_FILE_POINTER, &fd); |
| 203206 | if( p->rc==SQLITE_OK ){ | 204902 | |
| 203207 | p->rc = pReal->pMethods->xLock(pReal, SQLITE_LOCK_EXCLUSIVE); | 204903 | if( fd->pMethods ){ |
| 204904 | rc = fd->pMethods->xLock(fd, SQLITE_LOCK_SHARED); | ||
| 204905 | if( rc==SQLITE_OK ){ | ||
| 204906 | rc = fd->pMethods->xLock(fd, SQLITE_LOCK_EXCLUSIVE); | ||
| 204907 | } | ||
| 203208 | } | 204908 | } |
| 204909 | return rc; | ||
| 204910 | } | ||
| 204911 | |||
| 204912 | /* | ||
| 204913 | ** Return true if the database handle passed as the only argument | ||
| 204914 | ** was opened with the rbu_exclusive_checkpoint=1 URI parameter | ||
| 204915 | ** specified. Or false otherwise. | ||
| 204916 | */ | ||
| 204917 | static int rbuExclusiveCheckpoint(sqlite3 *db){ | ||
| 204918 | const char *zUri = sqlite3_db_filename(db, 0); | ||
| 204919 | return sqlite3_uri_boolean(zUri, RBU_EXCLUSIVE_CHECKPOINT, 0); | ||
| 203209 | } | 204920 | } |
| 203210 | 204921 | ||
| 203211 | #if defined(_WIN32_WCE) | 204922 | #if defined(_WIN32_WCE) |
| @@ -203263,18 +204974,24 @@ static void rbuMoveOalFile(sqlite3rbu *p){ | |||
| 203263 | ** In order to ensure that there are no database readers, an EXCLUSIVE | 204974 | ** In order to ensure that there are no database readers, an EXCLUSIVE |
| 203264 | ** lock is obtained here before the *-oal is moved to *-wal. | 204975 | ** lock is obtained here before the *-oal is moved to *-wal. |
| 203265 | */ | 204976 | */ |
| 203266 | rbuLockDatabase(p); | 204977 | sqlite3 *dbMain = 0; |
| 203267 | if( p->rc==SQLITE_OK ){ | 204978 | rbuFileSuffix3(zBase, zWal); |
| 203268 | rbuFileSuffix3(zBase, zWal); | 204979 | rbuFileSuffix3(zBase, zOal); |
| 203269 | rbuFileSuffix3(zBase, zOal); | 204980 | |
| 204981 | /* Re-open the databases. */ | ||
| 204982 | rbuObjIterFinalize(&p->objiter); | ||
| 204983 | sqlite3_close(p->dbRbu); | ||
| 204984 | sqlite3_close(p->dbMain); | ||
| 204985 | p->dbMain = 0; | ||
| 204986 | p->dbRbu = 0; | ||
| 203270 | 204987 | ||
| 203271 | /* Re-open the databases. */ | 204988 | dbMain = rbuOpenDbhandle(p, p->zTarget, 1); |
| 203272 | rbuObjIterFinalize(&p->objiter); | 204989 | if( dbMain ){ |
| 203273 | sqlite3_close(p->dbRbu); | 204990 | assert( p->rc==SQLITE_OK ); |
| 203274 | sqlite3_close(p->dbMain); | 204991 | p->rc = rbuLockDatabase(dbMain); |
| 203275 | p->dbMain = 0; | 204992 | } |
| 203276 | p->dbRbu = 0; | ||
| 203277 | 204993 | ||
| 204994 | if( p->rc==SQLITE_OK ){ | ||
| 203278 | #if defined(_WIN32_WCE) | 204995 | #if defined(_WIN32_WCE) |
| 203279 | { | 204996 | { |
| 203280 | LPWSTR zWideOal; | 204997 | LPWSTR zWideOal; |
| @@ -203301,11 +205018,19 @@ static void rbuMoveOalFile(sqlite3rbu *p){ | |||
| 203301 | #else | 205018 | #else |
| 203302 | p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK; | 205019 | p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK; |
| 203303 | #endif | 205020 | #endif |
| 205021 | } | ||
| 203304 | 205022 | ||
| 203305 | if( p->rc==SQLITE_OK ){ | 205023 | if( p->rc!=SQLITE_OK |
| 203306 | rbuOpenDatabase(p, 0); | 205024 | || rbuIsVacuum(p) |
| 203307 | rbuSetupCheckpoint(p, 0); | 205025 | || rbuExclusiveCheckpoint(dbMain)==0 |
| 203308 | } | 205026 | ){ |
| 205027 | sqlite3_close(dbMain); | ||
| 205028 | dbMain = 0; | ||
| 205029 | } | ||
| 205030 | |||
| 205031 | if( p->rc==SQLITE_OK ){ | ||
| 205032 | rbuOpenDatabase(p, dbMain, 0); | ||
| 205033 | rbuSetupCheckpoint(p, 0); | ||
| 203309 | } | 205034 | } |
| 203310 | } | 205035 | } |
| 203311 | 205036 | ||
| @@ -204056,9 +205781,9 @@ static sqlite3rbu *openRbuHandle( | |||
| 204056 | ** If this is the case, it will have been checkpointed and deleted | 205781 | ** If this is the case, it will have been checkpointed and deleted |
| 204057 | ** when the handle was closed and a second attempt to open the | 205782 | ** when the handle was closed and a second attempt to open the |
| 204058 | ** database may succeed. */ | 205783 | ** database may succeed. */ |
| 204059 | rbuOpenDatabase(p, &bRetry); | 205784 | rbuOpenDatabase(p, 0, &bRetry); |
| 204060 | if( bRetry ){ | 205785 | if( bRetry ){ |
| 204061 | rbuOpenDatabase(p, 0); | 205786 | rbuOpenDatabase(p, 0, 0); |
| 204062 | } | 205787 | } |
| 204063 | } | 205788 | } |
| 204064 | 205789 | ||
| @@ -204153,6 +205878,14 @@ static sqlite3rbu *openRbuHandle( | |||
| 204153 | }else if( p->eStage==RBU_STAGE_MOVE ){ | 205878 | }else if( p->eStage==RBU_STAGE_MOVE ){ |
| 204154 | /* no-op */ | 205879 | /* no-op */ |
| 204155 | }else if( p->eStage==RBU_STAGE_CKPT ){ | 205880 | }else if( p->eStage==RBU_STAGE_CKPT ){ |
| 205881 | if( !rbuIsVacuum(p) && rbuExclusiveCheckpoint(p->dbMain) ){ | ||
| 205882 | /* If the rbu_exclusive_checkpoint=1 URI parameter was specified | ||
| 205883 | ** and an incremental checkpoint is being resumed, attempt an | ||
| 205884 | ** exclusive lock on the db file. If this fails, so be it. */ | ||
| 205885 | p->eStage = RBU_STAGE_DONE; | ||
| 205886 | rbuLockDatabase(p->dbMain); | ||
| 205887 | p->eStage = RBU_STAGE_CKPT; | ||
| 205888 | } | ||
| 204156 | rbuSetupCheckpoint(p, pState); | 205889 | rbuSetupCheckpoint(p, pState); |
| 204157 | }else if( p->eStage==RBU_STAGE_DONE ){ | 205890 | }else if( p->eStage==RBU_STAGE_DONE ){ |
| 204158 | p->rc = SQLITE_DONE; | 205891 | p->rc = SQLITE_DONE; |
| @@ -204190,7 +205923,6 @@ SQLITE_API sqlite3rbu *sqlite3rbu_open( | |||
| 204190 | const char *zState | 205923 | const char *zState |
| 204191 | ){ | 205924 | ){ |
| 204192 | if( zTarget==0 || zRbu==0 ){ return rbuMisuseError(); } | 205925 | if( zTarget==0 || zRbu==0 ){ return rbuMisuseError(); } |
| 204193 | /* TODO: Check that zTarget and zRbu are non-NULL */ | ||
| 204194 | return openRbuHandle(zTarget, zRbu, zState); | 205926 | return openRbuHandle(zTarget, zRbu, zState); |
| 204195 | } | 205927 | } |
| 204196 | 205928 | ||
| @@ -205394,6 +207126,15 @@ SQLITE_API sqlite3_int64 sqlite3rbu_temp_size(sqlite3rbu *pRbu){ | |||
| 205394 | && !defined(SQLITE_OMIT_VIRTUALTABLE) | 207126 | && !defined(SQLITE_OMIT_VIRTUALTABLE) |
| 205395 | 207127 | ||
| 205396 | /* | 207128 | /* |
| 207129 | ** The pager and btree modules arrange objects in memory so that there are | ||
| 207130 | ** always approximately 200 bytes of addressable memory following each page | ||
| 207131 | ** buffer. This way small buffer overreads caused by corrupt database pages | ||
| 207132 | ** do not cause undefined behaviour. This module pads each page buffer | ||
| 207133 | ** by the following number of bytes for the same purpose. | ||
| 207134 | */ | ||
| 207135 | #define DBSTAT_PAGE_PADDING_BYTES 256 | ||
| 207136 | |||
| 207137 | /* | ||
| 205397 | ** Page paths: | 207138 | ** Page paths: |
| 205398 | ** | 207139 | ** |
| 205399 | ** The value of the 'path' column describes the path taken from the | 207140 | ** The value of the 'path' column describes the path taken from the |
| @@ -205460,9 +207201,8 @@ struct StatCell { | |||
| 205460 | /* Size information for a single btree page */ | 207201 | /* Size information for a single btree page */ |
| 205461 | struct StatPage { | 207202 | struct StatPage { |
| 205462 | u32 iPgno; /* Page number */ | 207203 | u32 iPgno; /* Page number */ |
| 205463 | DbPage *pPg; /* Page content */ | 207204 | u8 *aPg; /* Page buffer from sqlite3_malloc() */ |
| 205464 | int iCell; /* Current cell */ | 207205 | int iCell; /* Current cell */ |
| 205465 | |||
| 205466 | char *zPath; /* Path to this page */ | 207206 | char *zPath; /* Path to this page */ |
| 205467 | 207207 | ||
| 205468 | /* Variables populated by statDecodePage(): */ | 207208 | /* Variables populated by statDecodePage(): */ |
| @@ -205674,18 +207414,25 @@ static void statClearCells(StatPage *p){ | |||
| 205674 | } | 207414 | } |
| 205675 | 207415 | ||
| 205676 | static void statClearPage(StatPage *p){ | 207416 | static void statClearPage(StatPage *p){ |
| 207417 | u8 *aPg = p->aPg; | ||
| 205677 | statClearCells(p); | 207418 | statClearCells(p); |
| 205678 | sqlite3PagerUnref(p->pPg); | ||
| 205679 | sqlite3_free(p->zPath); | 207419 | sqlite3_free(p->zPath); |
| 205680 | memset(p, 0, sizeof(StatPage)); | 207420 | memset(p, 0, sizeof(StatPage)); |
| 207421 | p->aPg = aPg; | ||
| 205681 | } | 207422 | } |
| 205682 | 207423 | ||
| 205683 | static void statResetCsr(StatCursor *pCsr){ | 207424 | static void statResetCsr(StatCursor *pCsr){ |
| 205684 | int i; | 207425 | int i; |
| 205685 | sqlite3_reset(pCsr->pStmt); | 207426 | /* In some circumstances, specifically if an OOM has occurred, the call |
| 207427 | ** to sqlite3_reset() may cause the pager to be reset (emptied). It is | ||
| 207428 | ** important that statClearPage() is called to free any page refs before | ||
| 207429 | ** this happens. dbsqlfuzz 9ed3e4e3816219d3509d711636c38542bf3f40b1. */ | ||
| 205686 | for(i=0; i<ArraySize(pCsr->aPage); i++){ | 207430 | for(i=0; i<ArraySize(pCsr->aPage); i++){ |
| 205687 | statClearPage(&pCsr->aPage[i]); | 207431 | statClearPage(&pCsr->aPage[i]); |
| 207432 | sqlite3_free(pCsr->aPage[i].aPg); | ||
| 207433 | pCsr->aPage[i].aPg = 0; | ||
| 205688 | } | 207434 | } |
| 207435 | sqlite3_reset(pCsr->pStmt); | ||
| 205689 | pCsr->iPage = 0; | 207436 | pCsr->iPage = 0; |
| 205690 | sqlite3_free(pCsr->zPath); | 207437 | sqlite3_free(pCsr->zPath); |
| 205691 | pCsr->zPath = 0; | 207438 | pCsr->zPath = 0; |
| @@ -205750,7 +207497,7 @@ static int statDecodePage(Btree *pBt, StatPage *p){ | |||
| 205750 | int isLeaf; | 207497 | int isLeaf; |
| 205751 | int szPage; | 207498 | int szPage; |
| 205752 | 207499 | ||
| 205753 | u8 *aData = sqlite3PagerGetData(p->pPg); | 207500 | u8 *aData = p->aPg; |
| 205754 | u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0]; | 207501 | u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0]; |
| 205755 | 207502 | ||
| 205756 | p->flags = aHdr[0]; | 207503 | p->flags = aHdr[0]; |
| @@ -205821,7 +207568,7 @@ static int statDecodePage(Btree *pBt, StatPage *p){ | |||
| 205821 | if( nPayload>(u32)nLocal ){ | 207568 | if( nPayload>(u32)nLocal ){ |
| 205822 | int j; | 207569 | int j; |
| 205823 | int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4); | 207570 | int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4); |
| 205824 | if( iOff+nLocal>nUsable || nPayload>0x7fffffff ){ | 207571 | if( iOff+nLocal+4>nUsable || nPayload>0x7fffffff ){ |
| 205825 | goto statPageIsCorrupt; | 207572 | goto statPageIsCorrupt; |
| 205826 | } | 207573 | } |
| 205827 | pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4); | 207574 | pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4); |
| @@ -205881,6 +207628,38 @@ static void statSizeAndOffset(StatCursor *pCsr){ | |||
| 205881 | } | 207628 | } |
| 205882 | 207629 | ||
| 205883 | /* | 207630 | /* |
| 207631 | ** Load a copy of the page data for page iPg into the buffer belonging | ||
| 207632 | ** to page object pPg. Allocate the buffer if necessary. Return SQLITE_OK | ||
| 207633 | ** if successful, or an SQLite error code otherwise. | ||
| 207634 | */ | ||
| 207635 | static int statGetPage( | ||
| 207636 | Btree *pBt, /* Load page from this b-tree */ | ||
| 207637 | u32 iPg, /* Page number to load */ | ||
| 207638 | StatPage *pPg /* Load page into this object */ | ||
| 207639 | ){ | ||
| 207640 | int pgsz = sqlite3BtreeGetPageSize(pBt); | ||
| 207641 | DbPage *pDbPage = 0; | ||
| 207642 | int rc; | ||
| 207643 | |||
| 207644 | if( pPg->aPg==0 ){ | ||
| 207645 | pPg->aPg = (u8*)sqlite3_malloc(pgsz + DBSTAT_PAGE_PADDING_BYTES); | ||
| 207646 | if( pPg->aPg==0 ){ | ||
| 207647 | return SQLITE_NOMEM_BKPT; | ||
| 207648 | } | ||
| 207649 | memset(&pPg->aPg[pgsz], 0, DBSTAT_PAGE_PADDING_BYTES); | ||
| 207650 | } | ||
| 207651 | |||
| 207652 | rc = sqlite3PagerGet(sqlite3BtreePager(pBt), iPg, &pDbPage, 0); | ||
| 207653 | if( rc==SQLITE_OK ){ | ||
| 207654 | const u8 *a = sqlite3PagerGetData(pDbPage); | ||
| 207655 | memcpy(pPg->aPg, a, pgsz); | ||
| 207656 | sqlite3PagerUnref(pDbPage); | ||
| 207657 | } | ||
| 207658 | |||
| 207659 | return rc; | ||
| 207660 | } | ||
| 207661 | |||
| 207662 | /* | ||
| 205884 | ** Move a DBSTAT cursor to the next entry. Normally, the next | 207663 | ** Move a DBSTAT cursor to the next entry. Normally, the next |
| 205885 | ** entry will be the next page, but in aggregated mode (pCsr->isAgg!=0), | 207664 | ** entry will be the next page, but in aggregated mode (pCsr->isAgg!=0), |
| 205886 | ** the next entry is the next btree. | 207665 | ** the next entry is the next btree. |
| @@ -205898,7 +207677,7 @@ static int statNext(sqlite3_vtab_cursor *pCursor){ | |||
| 205898 | pCsr->zPath = 0; | 207677 | pCsr->zPath = 0; |
| 205899 | 207678 | ||
| 205900 | statNextRestart: | 207679 | statNextRestart: |
| 205901 | if( pCsr->aPage[0].pPg==0 ){ | 207680 | if( pCsr->iPage<0 ){ |
| 205902 | /* Start measuring space on the next btree */ | 207681 | /* Start measuring space on the next btree */ |
| 205903 | statResetCounts(pCsr); | 207682 | statResetCounts(pCsr); |
| 205904 | rc = sqlite3_step(pCsr->pStmt); | 207683 | rc = sqlite3_step(pCsr->pStmt); |
| @@ -205910,7 +207689,7 @@ statNextRestart: | |||
| 205910 | pCsr->isEof = 1; | 207689 | pCsr->isEof = 1; |
| 205911 | return sqlite3_reset(pCsr->pStmt); | 207690 | return sqlite3_reset(pCsr->pStmt); |
| 205912 | } | 207691 | } |
| 205913 | rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg, 0); | 207692 | rc = statGetPage(pBt, iRoot, &pCsr->aPage[0]); |
| 205914 | pCsr->aPage[0].iPgno = iRoot; | 207693 | pCsr->aPage[0].iPgno = iRoot; |
| 205915 | pCsr->aPage[0].iCell = 0; | 207694 | pCsr->aPage[0].iCell = 0; |
| 205916 | if( !pCsr->isAgg ){ | 207695 | if( !pCsr->isAgg ){ |
| @@ -205961,9 +207740,8 @@ statNextRestart: | |||
| 205961 | 207740 | ||
| 205962 | if( !p->iRightChildPg || p->iCell>p->nCell ){ | 207741 | if( !p->iRightChildPg || p->iCell>p->nCell ){ |
| 205963 | statClearPage(p); | 207742 | statClearPage(p); |
| 205964 | if( pCsr->iPage>0 ){ | 207743 | pCsr->iPage--; |
| 205965 | pCsr->iPage--; | 207744 | if( pCsr->isAgg && pCsr->iPage<0 ){ |
| 205966 | }else if( pCsr->isAgg ){ | ||
| 205967 | /* label-statNext-done: When computing aggregate space usage over | 207745 | /* label-statNext-done: When computing aggregate space usage over |
| 205968 | ** an entire btree, this is the exit point from this function */ | 207746 | ** an entire btree, this is the exit point from this function */ |
| 205969 | return SQLITE_OK; | 207747 | return SQLITE_OK; |
| @@ -205982,7 +207760,7 @@ statNextRestart: | |||
| 205982 | }else{ | 207760 | }else{ |
| 205983 | p[1].iPgno = p->aCell[p->iCell].iChildPg; | 207761 | p[1].iPgno = p->aCell[p->iCell].iChildPg; |
| 205984 | } | 207762 | } |
| 205985 | rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg, 0); | 207763 | rc = statGetPage(pBt, p[1].iPgno, &p[1]); |
| 205986 | pCsr->nPage++; | 207764 | pCsr->nPage++; |
| 205987 | p[1].iCell = 0; | 207765 | p[1].iCell = 0; |
| 205988 | if( !pCsr->isAgg ){ | 207766 | if( !pCsr->isAgg ){ |
| @@ -206112,6 +207890,7 @@ static int statFilter( | |||
| 206112 | } | 207890 | } |
| 206113 | 207891 | ||
| 206114 | if( rc==SQLITE_OK ){ | 207892 | if( rc==SQLITE_OK ){ |
| 207893 | pCsr->iPage = -1; | ||
| 206115 | rc = statNext(pCursor); | 207894 | rc = statNext(pCursor); |
| 206116 | } | 207895 | } |
| 206117 | return rc; | 207896 | return rc; |
| @@ -207063,7 +208842,7 @@ static int sessionSerializeValue( | |||
| 207063 | 208842 | ||
| 207064 | if( aBuf ){ | 208843 | if( aBuf ){ |
| 207065 | sessionVarintPut(&aBuf[1], n); | 208844 | sessionVarintPut(&aBuf[1], n); |
| 207066 | if( n ) memcpy(&aBuf[nVarint + 1], z, n); | 208845 | if( n>0 ) memcpy(&aBuf[nVarint + 1], z, n); |
| 207067 | } | 208846 | } |
| 207068 | 208847 | ||
| 207069 | nByte = 1 + nVarint + n; | 208848 | nByte = 1 + nVarint + n; |
| @@ -207668,16 +209447,32 @@ static int sessionTableInfo( | |||
| 207668 | }else if( rc==SQLITE_ERROR ){ | 209447 | }else if( rc==SQLITE_ERROR ){ |
| 207669 | zPragma = sqlite3_mprintf(""); | 209448 | zPragma = sqlite3_mprintf(""); |
| 207670 | }else{ | 209449 | }else{ |
| 209450 | *pazCol = 0; | ||
| 209451 | *pabPK = 0; | ||
| 209452 | *pnCol = 0; | ||
| 209453 | if( pzTab ) *pzTab = 0; | ||
| 207671 | return rc; | 209454 | return rc; |
| 207672 | } | 209455 | } |
| 207673 | }else{ | 209456 | }else{ |
| 207674 | zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); | 209457 | zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis); |
| 207675 | } | 209458 | } |
| 207676 | if( !zPragma ) return SQLITE_NOMEM; | 209459 | if( !zPragma ){ |
| 209460 | *pazCol = 0; | ||
| 209461 | *pabPK = 0; | ||
| 209462 | *pnCol = 0; | ||
| 209463 | if( pzTab ) *pzTab = 0; | ||
| 209464 | return SQLITE_NOMEM; | ||
| 209465 | } | ||
| 207677 | 209466 | ||
| 207678 | rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); | 209467 | rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0); |
| 207679 | sqlite3_free(zPragma); | 209468 | sqlite3_free(zPragma); |
| 207680 | if( rc!=SQLITE_OK ) return rc; | 209469 | if( rc!=SQLITE_OK ){ |
| 209470 | *pazCol = 0; | ||
| 209471 | *pabPK = 0; | ||
| 209472 | *pnCol = 0; | ||
| 209473 | if( pzTab ) *pzTab = 0; | ||
| 209474 | return rc; | ||
| 209475 | } | ||
| 207681 | 209476 | ||
| 207682 | nByte = nThis + 1; | 209477 | nByte = nThis + 1; |
| 207683 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ | 209478 | while( SQLITE_ROW==sqlite3_step(pStmt) ){ |
| @@ -208095,7 +209890,11 @@ static int sessionFindTable( | |||
| 208095 | ){ | 209890 | ){ |
| 208096 | rc = sqlite3session_attach(pSession, zName); | 209891 | rc = sqlite3session_attach(pSession, zName); |
| 208097 | if( rc==SQLITE_OK ){ | 209892 | if( rc==SQLITE_OK ){ |
| 208098 | for(pRet=pSession->pTable; pRet->pNext; pRet=pRet->pNext); | 209893 | pRet = pSession->pTable; |
| 209894 | while( ALWAYS(pRet) && pRet->pNext ){ | ||
| 209895 | pRet = pRet->pNext; | ||
| 209896 | } | ||
| 209897 | assert( pRet!=0 ); | ||
| 208099 | assert( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) ); | 209898 | assert( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) ); |
| 208100 | } | 209899 | } |
| 208101 | } | 209900 | } |
| @@ -208868,6 +210667,7 @@ static int sessionAppendUpdate( | |||
| 208868 | int i; /* Used to iterate through columns */ | 210667 | int i; /* Used to iterate through columns */ |
| 208869 | u8 *pCsr = p->aRecord; /* Used to iterate through old.* values */ | 210668 | u8 *pCsr = p->aRecord; /* Used to iterate through old.* values */ |
| 208870 | 210669 | ||
| 210670 | assert( abPK!=0 ); | ||
| 208871 | sessionAppendByte(pBuf, SQLITE_UPDATE, &rc); | 210671 | sessionAppendByte(pBuf, SQLITE_UPDATE, &rc); |
| 208872 | sessionAppendByte(pBuf, p->bIndirect, &rc); | 210672 | sessionAppendByte(pBuf, p->bIndirect, &rc); |
| 208873 | for(i=0; i<sqlite3_column_count(pStmt); i++){ | 210673 | for(i=0; i<sqlite3_column_count(pStmt); i++){ |
| @@ -209172,12 +210972,14 @@ static int sessionGenerateChangeset( | |||
| 209172 | SessionBuffer buf = {0,0,0}; /* Buffer in which to accumlate changeset */ | 210972 | SessionBuffer buf = {0,0,0}; /* Buffer in which to accumlate changeset */ |
| 209173 | int rc; /* Return code */ | 210973 | int rc; /* Return code */ |
| 209174 | 210974 | ||
| 209175 | assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0 ) ); | 210975 | assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0) ); |
| 210976 | assert( xOutput!=0 || (pnChangeset!=0 && ppChangeset!=0) ); | ||
| 209176 | 210977 | ||
| 209177 | /* Zero the output variables in case an error occurs. If this session | 210978 | /* Zero the output variables in case an error occurs. If this session |
| 209178 | ** object is already in the error state (sqlite3_session.rc != SQLITE_OK), | 210979 | ** object is already in the error state (sqlite3_session.rc != SQLITE_OK), |
| 209179 | ** this call will be a no-op. */ | 210980 | ** this call will be a no-op. */ |
| 209180 | if( xOutput==0 ){ | 210981 | if( xOutput==0 ){ |
| 210982 | assert( pnChangeset!=0 && ppChangeset!=0 ); | ||
| 209181 | *pnChangeset = 0; | 210983 | *pnChangeset = 0; |
| 209182 | *ppChangeset = 0; | 210984 | *ppChangeset = 0; |
| 209183 | } | 210985 | } |
| @@ -209191,8 +210993,8 @@ static int sessionGenerateChangeset( | |||
| 209191 | for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){ | 210993 | for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){ |
| 209192 | if( pTab->nEntry ){ | 210994 | if( pTab->nEntry ){ |
| 209193 | const char *zName = pTab->zName; | 210995 | const char *zName = pTab->zName; |
| 209194 | int nCol; /* Number of columns in table */ | 210996 | int nCol = 0; /* Number of columns in table */ |
| 209195 | u8 *abPK; /* Primary key array */ | 210997 | u8 *abPK = 0; /* Primary key array */ |
| 209196 | const char **azCol = 0; /* Table columns */ | 210998 | const char **azCol = 0; /* Table columns */ |
| 209197 | int i; /* Used to iterate through hash buckets */ | 210999 | int i; /* Used to iterate through hash buckets */ |
| 209198 | sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ | 211000 | sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */ |
| @@ -209230,6 +211032,7 @@ static int sessionGenerateChangeset( | |||
| 209230 | sessionAppendCol(&buf, pSel, iCol, &rc); | 211032 | sessionAppendCol(&buf, pSel, iCol, &rc); |
| 209231 | } | 211033 | } |
| 209232 | }else{ | 211034 | }else{ |
| 211035 | assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */ | ||
| 209233 | rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK); | 211036 | rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK); |
| 209234 | } | 211037 | } |
| 209235 | }else if( p->op!=SQLITE_INSERT ){ | 211038 | }else if( p->op!=SQLITE_INSERT ){ |
| @@ -209290,7 +211093,10 @@ SQLITE_API int sqlite3session_changeset( | |||
| 209290 | int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */ | 211093 | int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */ |
| 209291 | void **ppChangeset /* OUT: Buffer containing changeset */ | 211094 | void **ppChangeset /* OUT: Buffer containing changeset */ |
| 209292 | ){ | 211095 | ){ |
| 209293 | int rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset); | 211096 | int rc; |
| 211097 | |||
| 211098 | if( pnChangeset==0 || ppChangeset==0 ) return SQLITE_MISUSE; | ||
| 211099 | rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset); | ||
| 209294 | assert( rc || pnChangeset==0 | 211100 | assert( rc || pnChangeset==0 |
| 209295 | || pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize | 211101 | || pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize |
| 209296 | ); | 211102 | ); |
| @@ -209305,6 +211111,7 @@ SQLITE_API int sqlite3session_changeset_strm( | |||
| 209305 | int (*xOutput)(void *pOut, const void *pData, int nData), | 211111 | int (*xOutput)(void *pOut, const void *pData, int nData), |
| 209306 | void *pOut | 211112 | void *pOut |
| 209307 | ){ | 211113 | ){ |
| 211114 | if( xOutput==0 ) return SQLITE_MISUSE; | ||
| 209308 | return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0); | 211115 | return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0); |
| 209309 | } | 211116 | } |
| 209310 | 211117 | ||
| @@ -209316,6 +211123,7 @@ SQLITE_API int sqlite3session_patchset_strm( | |||
| 209316 | int (*xOutput)(void *pOut, const void *pData, int nData), | 211123 | int (*xOutput)(void *pOut, const void *pData, int nData), |
| 209317 | void *pOut | 211124 | void *pOut |
| 209318 | ){ | 211125 | ){ |
| 211126 | if( xOutput==0 ) return SQLITE_MISUSE; | ||
| 209319 | return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0); | 211127 | return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0); |
| 209320 | } | 211128 | } |
| 209321 | 211129 | ||
| @@ -209331,6 +211139,7 @@ SQLITE_API int sqlite3session_patchset( | |||
| 209331 | int *pnPatchset, /* OUT: Size of buffer at *ppChangeset */ | 211139 | int *pnPatchset, /* OUT: Size of buffer at *ppChangeset */ |
| 209332 | void **ppPatchset /* OUT: Buffer containing changeset */ | 211140 | void **ppPatchset /* OUT: Buffer containing changeset */ |
| 209333 | ){ | 211141 | ){ |
| 211142 | if( pnPatchset==0 || ppPatchset==0 ) return SQLITE_MISUSE; | ||
| 209334 | return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset); | 211143 | return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset); |
| 209335 | } | 211144 | } |
| 209336 | 211145 | ||
| @@ -210294,11 +212103,11 @@ static int sessionChangesetInvert( | |||
| 210294 | } | 212103 | } |
| 210295 | 212104 | ||
| 210296 | assert( rc==SQLITE_OK ); | 212105 | assert( rc==SQLITE_OK ); |
| 210297 | if( pnInverted ){ | 212106 | if( pnInverted && ALWAYS(ppInverted) ){ |
| 210298 | *pnInverted = sOut.nBuf; | 212107 | *pnInverted = sOut.nBuf; |
| 210299 | *ppInverted = sOut.aBuf; | 212108 | *ppInverted = sOut.aBuf; |
| 210300 | sOut.aBuf = 0; | 212109 | sOut.aBuf = 0; |
| 210301 | }else if( sOut.nBuf>0 ){ | 212110 | }else if( sOut.nBuf>0 && ALWAYS(xOutput!=0) ){ |
| 210302 | rc = xOutput(pOut, sOut.aBuf, sOut.nBuf); | 212111 | rc = xOutput(pOut, sOut.aBuf, sOut.nBuf); |
| 210303 | } | 212112 | } |
| 210304 | 212113 | ||
| @@ -210754,7 +212563,7 @@ static int sessionBindRow( | |||
| 210754 | 212563 | ||
| 210755 | for(i=0; rc==SQLITE_OK && i<nCol; i++){ | 212564 | for(i=0; rc==SQLITE_OK && i<nCol; i++){ |
| 210756 | if( !abPK || abPK[i] ){ | 212565 | if( !abPK || abPK[i] ){ |
| 210757 | sqlite3_value *pVal; | 212566 | sqlite3_value *pVal = 0; |
| 210758 | (void)xValue(pIter, i, &pVal); | 212567 | (void)xValue(pIter, i, &pVal); |
| 210759 | if( pVal==0 ){ | 212568 | if( pVal==0 ){ |
| 210760 | /* The value in the changeset was "undefined". This indicates a | 212569 | /* The value in the changeset was "undefined". This indicates a |
| @@ -211897,9 +213706,9 @@ static int sessionChangegroupOutput( | |||
| 211897 | if( rc==SQLITE_OK ){ | 213706 | if( rc==SQLITE_OK ){ |
| 211898 | if( xOutput ){ | 213707 | if( xOutput ){ |
| 211899 | if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf); | 213708 | if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf); |
| 211900 | }else{ | 213709 | }else if( ppOut ){ |
| 211901 | *ppOut = buf.aBuf; | 213710 | *ppOut = buf.aBuf; |
| 211902 | *pnOut = buf.nBuf; | 213711 | if( pnOut ) *pnOut = buf.nBuf; |
| 211903 | buf.aBuf = 0; | 213712 | buf.aBuf = 0; |
| 211904 | } | 213713 | } |
| 211905 | } | 213714 | } |
| @@ -212299,7 +214108,7 @@ static int sessionRebase( | |||
| 212299 | if( sOut.nBuf>0 ){ | 214108 | if( sOut.nBuf>0 ){ |
| 212300 | rc = xOutput(pOut, sOut.aBuf, sOut.nBuf); | 214109 | rc = xOutput(pOut, sOut.aBuf, sOut.nBuf); |
| 212301 | } | 214110 | } |
| 212302 | }else{ | 214111 | }else if( ppOut ){ |
| 212303 | *ppOut = (void*)sOut.aBuf; | 214112 | *ppOut = (void*)sOut.aBuf; |
| 212304 | *pnOut = sOut.nBuf; | 214113 | *pnOut = sOut.nBuf; |
| 212305 | sOut.aBuf = 0; | 214114 | sOut.aBuf = 0; |
| @@ -213042,8 +214851,20 @@ typedef sqlite3_uint64 u64; | |||
| 213042 | #endif | 214851 | #endif |
| 213043 | 214852 | ||
| 213044 | #define testcase(x) | 214853 | #define testcase(x) |
| 213045 | #define ALWAYS(x) 1 | 214854 | |
| 213046 | #define NEVER(x) 0 | 214855 | #if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST) |
| 214856 | # define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1 | ||
| 214857 | #endif | ||
| 214858 | #if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS) | ||
| 214859 | # define ALWAYS(X) (1) | ||
| 214860 | # define NEVER(X) (0) | ||
| 214861 | #elif !defined(NDEBUG) | ||
| 214862 | # define ALWAYS(X) ((X)?1:(assert(0),0)) | ||
| 214863 | # define NEVER(X) ((X)?(assert(0),1):0) | ||
| 214864 | #else | ||
| 214865 | # define ALWAYS(X) (X) | ||
| 214866 | # define NEVER(X) (X) | ||
| 214867 | #endif | ||
| 213047 | 214868 | ||
| 213048 | #define MIN(x,y) (((x) < (y)) ? (x) : (y)) | 214869 | #define MIN(x,y) (((x) < (y)) ? (x) : (y)) |
| 213049 | #define MAX(x,y) (((x) > (y)) ? (x) : (y)) | 214870 | #define MAX(x,y) (((x) > (y)) ? (x) : (y)) |
| @@ -213103,7 +214924,7 @@ SQLITE_API extern int sqlite3_fts5_may_be_corrupt; | |||
| 213103 | ** A version of memcmp() that does not cause asan errors if one of the pointer | 214924 | ** A version of memcmp() that does not cause asan errors if one of the pointer |
| 213104 | ** parameters is NULL and the number of bytes to compare is zero. | 214925 | ** parameters is NULL and the number of bytes to compare is zero. |
| 213105 | */ | 214926 | */ |
| 213106 | #define fts5Memcmp(s1, s2, n) ((n)==0 ? 0 : memcmp((s1), (s2), (n))) | 214927 | #define fts5Memcmp(s1, s2, n) ((n)<=0 ? 0 : memcmp((s1), (s2), (n))) |
| 213107 | 214928 | ||
| 213108 | /* Mark a function parameter as unused, to suppress nuisance compiler | 214929 | /* Mark a function parameter as unused, to suppress nuisance compiler |
| 213109 | ** warnings. */ | 214930 | ** warnings. */ |
| @@ -213442,6 +215263,9 @@ static void sqlite3Fts5IndexCloseReader(Fts5Index*); | |||
| 213442 | */ | 215263 | */ |
| 213443 | static const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*); | 215264 | static const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*); |
| 213444 | static int sqlite3Fts5IterNextScan(Fts5IndexIter*); | 215265 | static int sqlite3Fts5IterNextScan(Fts5IndexIter*); |
| 215266 | static void *sqlite3Fts5StructureRef(Fts5Index*); | ||
| 215267 | static void sqlite3Fts5StructureRelease(void*); | ||
| 215268 | static int sqlite3Fts5StructureTest(Fts5Index*, void*); | ||
| 213445 | 215269 | ||
| 213446 | 215270 | ||
| 213447 | /* | 215271 | /* |
| @@ -214219,9 +216043,9 @@ struct fts5yyParser { | |||
| 214219 | }; | 216043 | }; |
| 214220 | typedef struct fts5yyParser fts5yyParser; | 216044 | typedef struct fts5yyParser fts5yyParser; |
| 214221 | 216045 | ||
| 216046 | /* #include <assert.h> */ | ||
| 214222 | #ifndef NDEBUG | 216047 | #ifndef NDEBUG |
| 214223 | /* #include <stdio.h> */ | 216048 | /* #include <stdio.h> */ |
| 214224 | /* #include <assert.h> */ | ||
| 214225 | static FILE *fts5yyTraceFILE = 0; | 216049 | static FILE *fts5yyTraceFILE = 0; |
| 214226 | static char *fts5yyTracePrompt = 0; | 216050 | static char *fts5yyTracePrompt = 0; |
| 214227 | #endif /* NDEBUG */ | 216051 | #endif /* NDEBUG */ |
| @@ -215158,8 +216982,8 @@ static void sqlite3Fts5Parser( | |||
| 215158 | fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact); | 216982 | fts5yyact = fts5yy_find_shift_action((fts5YYCODETYPE)fts5yymajor,fts5yyact); |
| 215159 | if( fts5yyact >= fts5YY_MIN_REDUCE ){ | 216983 | if( fts5yyact >= fts5YY_MIN_REDUCE ){ |
| 215160 | unsigned int fts5yyruleno = fts5yyact - fts5YY_MIN_REDUCE; /* Reduce by this rule */ | 216984 | unsigned int fts5yyruleno = fts5yyact - fts5YY_MIN_REDUCE; /* Reduce by this rule */ |
| 215161 | assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ); | ||
| 215162 | #ifndef NDEBUG | 216985 | #ifndef NDEBUG |
| 216986 | assert( fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ); | ||
| 215163 | if( fts5yyTraceFILE ){ | 216987 | if( fts5yyTraceFILE ){ |
| 215164 | int fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; | 216988 | int fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno]; |
| 215165 | if( fts5yysize ){ | 216989 | if( fts5yysize ){ |
| @@ -215257,14 +217081,13 @@ static void sqlite3Fts5Parser( | |||
| 215257 | fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion); | 217081 | fts5yy_destructor(fts5yypParser, (fts5YYCODETYPE)fts5yymajor, &fts5yyminorunion); |
| 215258 | fts5yymajor = fts5YYNOCODE; | 217082 | fts5yymajor = fts5YYNOCODE; |
| 215259 | }else{ | 217083 | }else{ |
| 215260 | while( fts5yypParser->fts5yytos >= fts5yypParser->fts5yystack | 217084 | while( fts5yypParser->fts5yytos > fts5yypParser->fts5yystack ){ |
| 215261 | && (fts5yyact = fts5yy_find_reduce_action( | 217085 | fts5yyact = fts5yy_find_reduce_action(fts5yypParser->fts5yytos->stateno, |
| 215262 | fts5yypParser->fts5yytos->stateno, | 217086 | fts5YYERRORSYMBOL); |
| 215263 | fts5YYERRORSYMBOL)) > fts5YY_MAX_SHIFTREDUCE | 217087 | if( fts5yyact<=fts5YY_MAX_SHIFTREDUCE ) break; |
| 215264 | ){ | ||
| 215265 | fts5yy_pop_parser_stack(fts5yypParser); | 217088 | fts5yy_pop_parser_stack(fts5yypParser); |
| 215266 | } | 217089 | } |
| 215267 | if( fts5yypParser->fts5yytos < fts5yypParser->fts5yystack || fts5yymajor==0 ){ | 217090 | if( fts5yypParser->fts5yytos <= fts5yypParser->fts5yystack || fts5yymajor==0 ){ |
| 215268 | fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion); | 217091 | fts5yy_destructor(fts5yypParser,(fts5YYCODETYPE)fts5yymajor,&fts5yyminorunion); |
| 215269 | fts5yy_parse_failed(fts5yypParser); | 217092 | fts5yy_parse_failed(fts5yypParser); |
| 215270 | #ifndef fts5YYNOERRORRECOVERY | 217093 | #ifndef fts5YYNOERRORRECOVERY |
| @@ -216127,7 +217950,6 @@ static void sqlite3Fts5BufferAppendBlob( | |||
| 216127 | u32 nData, | 217950 | u32 nData, |
| 216128 | const u8 *pData | 217951 | const u8 *pData |
| 216129 | ){ | 217952 | ){ |
| 216130 | assert_nc( *pRc || nData>=0 ); | ||
| 216131 | if( nData ){ | 217953 | if( nData ){ |
| 216132 | if( fts5BufferGrow(pRc, pBuf, nData) ) return; | 217954 | if( fts5BufferGrow(pRc, pBuf, nData) ) return; |
| 216133 | memcpy(&pBuf->p[pBuf->n], pData, nData); | 217955 | memcpy(&pBuf->p[pBuf->n], pData, nData); |
| @@ -216237,9 +218059,8 @@ static int sqlite3Fts5PoslistNext64( | |||
| 216237 | return 1; | 218059 | return 1; |
| 216238 | }else{ | 218060 | }else{ |
| 216239 | i64 iOff = *piOff; | 218061 | i64 iOff = *piOff; |
| 216240 | int iVal; | 218062 | u32 iVal; |
| 216241 | fts5FastGetVarint32(a, i, iVal); | 218063 | fts5FastGetVarint32(a, i, iVal); |
| 216242 | assert( iVal>=0 ); | ||
| 216243 | if( iVal<=1 ){ | 218064 | if( iVal<=1 ){ |
| 216244 | if( iVal==0 ){ | 218065 | if( iVal==0 ){ |
| 216245 | *pi = i; | 218066 | *pi = i; |
| @@ -216247,6 +218068,7 @@ static int sqlite3Fts5PoslistNext64( | |||
| 216247 | } | 218068 | } |
| 216248 | fts5FastGetVarint32(a, i, iVal); | 218069 | fts5FastGetVarint32(a, i, iVal); |
| 216249 | iOff = ((i64)iVal) << 32; | 218070 | iOff = ((i64)iVal) << 32; |
| 218071 | assert( iOff>=0 ); | ||
| 216250 | fts5FastGetVarint32(a, i, iVal); | 218072 | fts5FastGetVarint32(a, i, iVal); |
| 216251 | if( iVal<2 ){ | 218073 | if( iVal<2 ){ |
| 216252 | /* This is a corrupt record. So stop parsing it here. */ | 218074 | /* This is a corrupt record. So stop parsing it here. */ |
| @@ -216258,7 +218080,7 @@ static int sqlite3Fts5PoslistNext64( | |||
| 216258 | *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF); | 218080 | *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF); |
| 216259 | } | 218081 | } |
| 216260 | *pi = i; | 218082 | *pi = i; |
| 216261 | assert( *piOff>=iOff ); | 218083 | assert_nc( *piOff>=iOff ); |
| 216262 | return 0; | 218084 | return 0; |
| 216263 | } | 218085 | } |
| 216264 | } | 218086 | } |
| @@ -217033,6 +218855,7 @@ static int sqlite3Fts5ConfigParse( | |||
| 217033 | z = fts5ConfigSkipWhitespace(z); | 218855 | z = fts5ConfigSkipWhitespace(z); |
| 217034 | if( z && *z=='=' ){ | 218856 | if( z && *z=='=' ){ |
| 217035 | bOption = 1; | 218857 | bOption = 1; |
| 218858 | assert( zOne!=0 ); | ||
| 217036 | z++; | 218859 | z++; |
| 217037 | if( bMustBeCol ) z = 0; | 218860 | if( bMustBeCol ) z = 0; |
| 217038 | } | 218861 | } |
| @@ -217049,7 +218872,11 @@ static int sqlite3Fts5ConfigParse( | |||
| 217049 | rc = SQLITE_ERROR; | 218872 | rc = SQLITE_ERROR; |
| 217050 | }else{ | 218873 | }else{ |
| 217051 | if( bOption ){ | 218874 | if( bOption ){ |
| 217052 | rc = fts5ConfigParseSpecial(pGlobal, pRet, zOne, zTwo?zTwo:"", pzErr); | 218875 | rc = fts5ConfigParseSpecial(pGlobal, pRet, |
| 218876 | ALWAYS(zOne)?zOne:"", | ||
| 218877 | zTwo?zTwo:"", | ||
| 218878 | pzErr | ||
| 218879 | ); | ||
| 217053 | }else{ | 218880 | }else{ |
| 217054 | rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr); | 218881 | rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr); |
| 217055 | zOne = 0; | 218882 | zOne = 0; |
| @@ -217567,6 +219394,7 @@ static void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...){ | |||
| 217567 | va_list ap; | 219394 | va_list ap; |
| 217568 | va_start(ap, zFmt); | 219395 | va_start(ap, zFmt); |
| 217569 | if( pParse->rc==SQLITE_OK ){ | 219396 | if( pParse->rc==SQLITE_OK ){ |
| 219397 | assert( pParse->zErr==0 ); | ||
| 217570 | pParse->zErr = sqlite3_vmprintf(zFmt, ap); | 219398 | pParse->zErr = sqlite3_vmprintf(zFmt, ap); |
| 217571 | pParse->rc = SQLITE_ERROR; | 219399 | pParse->rc = SQLITE_ERROR; |
| 217572 | } | 219400 | } |
| @@ -217865,6 +219693,7 @@ static i64 fts5ExprSynonymRowid(Fts5ExprTerm *pTerm, int bDesc, int *pbEof){ | |||
| 217865 | int bRetValid = 0; | 219693 | int bRetValid = 0; |
| 217866 | Fts5ExprTerm *p; | 219694 | Fts5ExprTerm *p; |
| 217867 | 219695 | ||
| 219696 | assert( pTerm ); | ||
| 217868 | assert( pTerm->pSynonym ); | 219697 | assert( pTerm->pSynonym ); |
| 217869 | assert( bDesc==0 || bDesc==1 ); | 219698 | assert( bDesc==0 || bDesc==1 ); |
| 217870 | for(p=pTerm; p; p=p->pSynonym){ | 219699 | for(p=pTerm; p; p=p->pSynonym){ |
| @@ -219305,7 +221134,7 @@ static int sqlite3Fts5ExprClonePhrase( | |||
| 219305 | sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase)); | 221134 | sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase)); |
| 219306 | } | 221135 | } |
| 219307 | 221136 | ||
| 219308 | if( rc==SQLITE_OK ){ | 221137 | if( rc==SQLITE_OK && ALWAYS(sCtx.pPhrase) ){ |
| 219309 | /* All the allocations succeeded. Put the expression object together. */ | 221138 | /* All the allocations succeeded. Put the expression object together. */ |
| 219310 | pNew->pIndex = pExpr->pIndex; | 221139 | pNew->pIndex = pExpr->pIndex; |
| 219311 | pNew->pConfig = pExpr->pConfig; | 221140 | pNew->pConfig = pExpr->pConfig; |
| @@ -219576,9 +221405,8 @@ static void sqlite3Fts5ParseSetColset( | |||
| 219576 | ){ | 221405 | ){ |
| 219577 | Fts5Colset *pFree = pColset; | 221406 | Fts5Colset *pFree = pColset; |
| 219578 | if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){ | 221407 | if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){ |
| 219579 | pParse->rc = SQLITE_ERROR; | 221408 | sqlite3Fts5ParseError(pParse, |
| 219580 | pParse->zErr = sqlite3_mprintf( | 221409 | "fts5: column queries are not supported (detail=none)" |
| 219581 | "fts5: column queries are not supported (detail=none)" | ||
| 219582 | ); | 221410 | ); |
| 219583 | }else{ | 221411 | }else{ |
| 219584 | fts5ParseSetColset(pParse, pExpr, pColset, &pFree); | 221412 | fts5ParseSetColset(pParse, pExpr, pColset, &pFree); |
| @@ -219752,13 +221580,10 @@ static Fts5ExprNode *sqlite3Fts5ParseNode( | |||
| 219752 | || pPhrase->nTerm>1 | 221580 | || pPhrase->nTerm>1 |
| 219753 | || (pPhrase->nTerm>0 && pPhrase->aTerm[0].bFirst) | 221581 | || (pPhrase->nTerm>0 && pPhrase->aTerm[0].bFirst) |
| 219754 | ){ | 221582 | ){ |
| 219755 | assert( pParse->rc==SQLITE_OK ); | 221583 | sqlite3Fts5ParseError(pParse, |
| 219756 | pParse->rc = SQLITE_ERROR; | ||
| 219757 | assert( pParse->zErr==0 ); | ||
| 219758 | pParse->zErr = sqlite3_mprintf( | ||
| 219759 | "fts5: %s queries are not supported (detail!=full)", | 221584 | "fts5: %s queries are not supported (detail!=full)", |
| 219760 | pNear->nPhrase==1 ? "phrase": "NEAR" | 221585 | pNear->nPhrase==1 ? "phrase": "NEAR" |
| 219761 | ); | 221586 | ); |
| 219762 | sqlite3_free(pRet); | 221587 | sqlite3_free(pRet); |
| 219763 | pRet = 0; | 221588 | pRet = 0; |
| 219764 | } | 221589 | } |
| @@ -220290,6 +222115,15 @@ struct Fts5PoslistPopulator { | |||
| 220290 | int bMiss; | 222115 | int bMiss; |
| 220291 | }; | 222116 | }; |
| 220292 | 222117 | ||
| 222118 | /* | ||
| 222119 | ** Clear the position lists associated with all phrases in the expression | ||
| 222120 | ** passed as the first argument. Argument bLive is true if the expression | ||
| 222121 | ** might be pointing to a real entry, otherwise it has just been reset. | ||
| 222122 | ** | ||
| 222123 | ** At present this function is only used for detail=col and detail=none | ||
| 222124 | ** fts5 tables. This implies that all phrases must be at most 1 token | ||
| 222125 | ** in size, as phrase matches are not supported without detail=full. | ||
| 222126 | */ | ||
| 220293 | static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){ | 222127 | static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){ |
| 220294 | Fts5PoslistPopulator *pRet; | 222128 | Fts5PoslistPopulator *pRet; |
| 220295 | pRet = sqlite3_malloc64(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase); | 222129 | pRet = sqlite3_malloc64(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase); |
| @@ -220299,7 +222133,7 @@ static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int b | |||
| 220299 | for(i=0; i<pExpr->nPhrase; i++){ | 222133 | for(i=0; i<pExpr->nPhrase; i++){ |
| 220300 | Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist; | 222134 | Fts5Buffer *pBuf = &pExpr->apExprPhrase[i]->poslist; |
| 220301 | Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode; | 222135 | Fts5ExprNode *pNode = pExpr->apExprPhrase[i]->pNode; |
| 220302 | assert( pExpr->apExprPhrase[i]->nTerm==1 ); | 222136 | assert( pExpr->apExprPhrase[i]->nTerm<=1 ); |
| 220303 | if( bLive && | 222137 | if( bLive && |
| 220304 | (pBuf->n==0 || pNode->iRowid!=pExpr->pRoot->iRowid || pNode->bEof) | 222138 | (pBuf->n==0 || pNode->iRowid!=pExpr->pRoot->iRowid || pNode->bEof) |
| 220305 | ){ | 222139 | ){ |
| @@ -220850,7 +222684,7 @@ static int sqlite3Fts5HashWrite( | |||
| 220850 | p->bContent = 1; | 222684 | p->bContent = 1; |
| 220851 | }else{ | 222685 | }else{ |
| 220852 | /* Append a new column value, if necessary */ | 222686 | /* Append a new column value, if necessary */ |
| 220853 | assert( iCol>=p->iCol ); | 222687 | assert_nc( iCol>=p->iCol ); |
| 220854 | if( iCol!=p->iCol ){ | 222688 | if( iCol!=p->iCol ){ |
| 220855 | if( pHash->eDetail==FTS5_DETAIL_FULL ){ | 222689 | if( pHash->eDetail==FTS5_DETAIL_FULL ){ |
| 220856 | pPtr[p->nData++] = 0x01; | 222690 | pPtr[p->nData++] = 0x01; |
| @@ -221655,8 +223489,11 @@ static int fts5BufferCompareBlob( | |||
| 221655 | ** res = *pLeft - *pRight | 223489 | ** res = *pLeft - *pRight |
| 221656 | */ | 223490 | */ |
| 221657 | static int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){ | 223491 | static int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){ |
| 221658 | int nCmp = MIN(pLeft->n, pRight->n); | 223492 | int nCmp, res; |
| 221659 | int res = fts5Memcmp(pLeft->p, pRight->p, nCmp); | 223493 | nCmp = MIN(pLeft->n, pRight->n); |
| 223494 | assert( nCmp<=0 || pLeft->p!=0 ); | ||
| 223495 | assert( nCmp<=0 || pRight->p!=0 ); | ||
| 223496 | res = fts5Memcmp(pLeft->p, pRight->p, nCmp); | ||
| 221660 | return (res==0 ? (pLeft->n - pRight->n) : res); | 223497 | return (res==0 ? (pLeft->n - pRight->n) : res); |
| 221661 | } | 223498 | } |
| 221662 | 223499 | ||
| @@ -221752,6 +223589,7 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){ | |||
| 221752 | return pRet; | 223589 | return pRet; |
| 221753 | } | 223590 | } |
| 221754 | 223591 | ||
| 223592 | |||
| 221755 | /* | 223593 | /* |
| 221756 | ** Release a reference to data record returned by an earlier call to | 223594 | ** Release a reference to data record returned by an earlier call to |
| 221757 | ** fts5DataRead(). | 223595 | ** fts5DataRead(). |
| @@ -221876,6 +223714,58 @@ static void fts5StructureRef(Fts5Structure *pStruct){ | |||
| 221876 | pStruct->nRef++; | 223714 | pStruct->nRef++; |
| 221877 | } | 223715 | } |
| 221878 | 223716 | ||
| 223717 | static void *sqlite3Fts5StructureRef(Fts5Index *p){ | ||
| 223718 | fts5StructureRef(p->pStruct); | ||
| 223719 | return (void*)p->pStruct; | ||
| 223720 | } | ||
| 223721 | static void sqlite3Fts5StructureRelease(void *p){ | ||
| 223722 | if( p ){ | ||
| 223723 | fts5StructureRelease((Fts5Structure*)p); | ||
| 223724 | } | ||
| 223725 | } | ||
| 223726 | static int sqlite3Fts5StructureTest(Fts5Index *p, void *pStruct){ | ||
| 223727 | if( p->pStruct!=(Fts5Structure*)pStruct ){ | ||
| 223728 | return SQLITE_ABORT; | ||
| 223729 | } | ||
| 223730 | return SQLITE_OK; | ||
| 223731 | } | ||
| 223732 | |||
| 223733 | /* | ||
| 223734 | ** Ensure that structure object (*pp) is writable. | ||
| 223735 | ** | ||
| 223736 | ** This function is a no-op if (*pRc) is not SQLITE_OK when it is called. If | ||
| 223737 | ** an error occurs, (*pRc) is set to an SQLite error code before returning. | ||
| 223738 | */ | ||
| 223739 | static void fts5StructureMakeWritable(int *pRc, Fts5Structure **pp){ | ||
| 223740 | Fts5Structure *p = *pp; | ||
| 223741 | if( *pRc==SQLITE_OK && p->nRef>1 ){ | ||
| 223742 | i64 nByte = sizeof(Fts5Structure)+(p->nLevel-1)*sizeof(Fts5StructureLevel); | ||
| 223743 | Fts5Structure *pNew; | ||
| 223744 | pNew = (Fts5Structure*)sqlite3Fts5MallocZero(pRc, nByte); | ||
| 223745 | if( pNew ){ | ||
| 223746 | int i; | ||
| 223747 | memcpy(pNew, p, nByte); | ||
| 223748 | for(i=0; i<p->nLevel; i++) pNew->aLevel[i].aSeg = 0; | ||
| 223749 | for(i=0; i<p->nLevel; i++){ | ||
| 223750 | Fts5StructureLevel *pLvl = &pNew->aLevel[i]; | ||
| 223751 | nByte = sizeof(Fts5StructureSegment) * pNew->aLevel[i].nSeg; | ||
| 223752 | pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(pRc, nByte); | ||
| 223753 | if( pLvl->aSeg==0 ){ | ||
| 223754 | for(i=0; i<p->nLevel; i++){ | ||
| 223755 | sqlite3_free(pNew->aLevel[i].aSeg); | ||
| 223756 | } | ||
| 223757 | sqlite3_free(pNew); | ||
| 223758 | return; | ||
| 223759 | } | ||
| 223760 | memcpy(pLvl->aSeg, p->aLevel[i].aSeg, nByte); | ||
| 223761 | } | ||
| 223762 | p->nRef--; | ||
| 223763 | pNew->nRef = 1; | ||
| 223764 | } | ||
| 223765 | *pp = pNew; | ||
| 223766 | } | ||
| 223767 | } | ||
| 223768 | |||
| 221879 | /* | 223769 | /* |
| 221880 | ** Deserialize and return the structure record currently stored in serialized | 223770 | ** Deserialize and return the structure record currently stored in serialized |
| 221881 | ** form within buffer pData/nData. | 223771 | ** form within buffer pData/nData. |
| @@ -221977,9 +223867,11 @@ static int fts5StructureDecode( | |||
| 221977 | } | 223867 | } |
| 221978 | 223868 | ||
| 221979 | /* | 223869 | /* |
| 221980 | ** | 223870 | ** Add a level to the Fts5Structure.aLevel[] array of structure object |
| 223871 | ** (*ppStruct). | ||
| 221981 | */ | 223872 | */ |
| 221982 | static void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){ | 223873 | static void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){ |
| 223874 | fts5StructureMakeWritable(pRc, ppStruct); | ||
| 221983 | if( *pRc==SQLITE_OK ){ | 223875 | if( *pRc==SQLITE_OK ){ |
| 221984 | Fts5Structure *pStruct = *ppStruct; | 223876 | Fts5Structure *pStruct = *ppStruct; |
| 221985 | int nLevel = pStruct->nLevel; | 223877 | int nLevel = pStruct->nLevel; |
| @@ -222773,6 +224665,7 @@ static void fts5SegIterInit( | |||
| 222773 | 224665 | ||
| 222774 | if( p->rc==SQLITE_OK ){ | 224666 | if( p->rc==SQLITE_OK ){ |
| 222775 | pIter->iLeafOffset = 4; | 224667 | pIter->iLeafOffset = 4; |
| 224668 | assert( pIter->pLeaf!=0 ); | ||
| 222776 | assert_nc( pIter->pLeaf->nn>4 ); | 224669 | assert_nc( pIter->pLeaf->nn>4 ); |
| 222777 | assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 ); | 224670 | assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 ); |
| 222778 | pIter->iPgidxOff = pIter->pLeaf->szLeaf+1; | 224671 | pIter->iPgidxOff = pIter->pLeaf->szLeaf+1; |
| @@ -222875,8 +224768,12 @@ static void fts5SegIterReverseNewPage(Fts5Index *p, Fts5SegIter *pIter){ | |||
| 222875 | int iRowidOff; | 224768 | int iRowidOff; |
| 222876 | iRowidOff = fts5LeafFirstRowidOff(pNew); | 224769 | iRowidOff = fts5LeafFirstRowidOff(pNew); |
| 222877 | if( iRowidOff ){ | 224770 | if( iRowidOff ){ |
| 222878 | pIter->pLeaf = pNew; | 224771 | if( iRowidOff>=pNew->szLeaf ){ |
| 222879 | pIter->iLeafOffset = iRowidOff; | 224772 | p->rc = FTS5_CORRUPT; |
| 224773 | }else{ | ||
| 224774 | pIter->pLeaf = pNew; | ||
| 224775 | pIter->iLeafOffset = iRowidOff; | ||
| 224776 | } | ||
| 222880 | } | 224777 | } |
| 222881 | } | 224778 | } |
| 222882 | 224779 | ||
| @@ -223156,7 +225053,7 @@ static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ | |||
| 223156 | if( pDlidx ){ | 225053 | if( pDlidx ){ |
| 223157 | int iSegid = pIter->pSeg->iSegid; | 225054 | int iSegid = pIter->pSeg->iSegid; |
| 223158 | pgnoLast = fts5DlidxIterPgno(pDlidx); | 225055 | pgnoLast = fts5DlidxIterPgno(pDlidx); |
| 223159 | pLast = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, pgnoLast)); | 225056 | pLast = fts5LeafRead(p, FTS5_SEGMENT_ROWID(iSegid, pgnoLast)); |
| 223160 | }else{ | 225057 | }else{ |
| 223161 | Fts5Data *pLeaf = pIter->pLeaf; /* Current leaf data */ | 225058 | Fts5Data *pLeaf = pIter->pLeaf; /* Current leaf data */ |
| 223162 | 225059 | ||
| @@ -223183,7 +225080,7 @@ static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ | |||
| 223183 | ** forward to find the page containing the last rowid. */ | 225080 | ** forward to find the page containing the last rowid. */ |
| 223184 | for(pgno=pIter->iLeafPgno+1; !p->rc && pgno<=pSeg->pgnoLast; pgno++){ | 225081 | for(pgno=pIter->iLeafPgno+1; !p->rc && pgno<=pSeg->pgnoLast; pgno++){ |
| 223185 | i64 iAbs = FTS5_SEGMENT_ROWID(pSeg->iSegid, pgno); | 225082 | i64 iAbs = FTS5_SEGMENT_ROWID(pSeg->iSegid, pgno); |
| 223186 | Fts5Data *pNew = fts5DataRead(p, iAbs); | 225083 | Fts5Data *pNew = fts5LeafRead(p, iAbs); |
| 223187 | if( pNew ){ | 225084 | if( pNew ){ |
| 223188 | int iRowid, bTermless; | 225085 | int iRowid, bTermless; |
| 223189 | iRowid = fts5LeafFirstRowidOff(pNew); | 225086 | iRowid = fts5LeafFirstRowidOff(pNew); |
| @@ -223214,6 +225111,10 @@ static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ | |||
| 223214 | pIter->pLeaf = pLast; | 225111 | pIter->pLeaf = pLast; |
| 223215 | pIter->iLeafPgno = pgnoLast; | 225112 | pIter->iLeafPgno = pgnoLast; |
| 223216 | iOff = fts5LeafFirstRowidOff(pLast); | 225113 | iOff = fts5LeafFirstRowidOff(pLast); |
| 225114 | if( iOff>pLast->szLeaf ){ | ||
| 225115 | p->rc = FTS5_CORRUPT; | ||
| 225116 | return; | ||
| 225117 | } | ||
| 223217 | iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid); | 225118 | iOff += fts5GetVarint(&pLast->p[iOff], (u64*)&pIter->iRowid); |
| 223218 | pIter->iLeafOffset = iOff; | 225119 | pIter->iLeafOffset = iOff; |
| 223219 | 225120 | ||
| @@ -223222,7 +225123,6 @@ static void fts5SegIterReverse(Fts5Index *p, Fts5SegIter *pIter){ | |||
| 223222 | }else{ | 225123 | }else{ |
| 223223 | pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast); | 225124 | pIter->iEndofDoclist = fts5LeafFirstTermOff(pLast); |
| 223224 | } | 225125 | } |
| 223225 | |||
| 223226 | } | 225126 | } |
| 223227 | 225127 | ||
| 223228 | fts5SegIterReverseInitPage(p, pIter); | 225128 | fts5SegIterReverseInitPage(p, pIter); |
| @@ -223274,21 +225174,20 @@ static void fts5LeafSeek( | |||
| 223274 | Fts5SegIter *pIter, /* Iterator to seek */ | 225174 | Fts5SegIter *pIter, /* Iterator to seek */ |
| 223275 | const u8 *pTerm, int nTerm /* Term to search for */ | 225175 | const u8 *pTerm, int nTerm /* Term to search for */ |
| 223276 | ){ | 225176 | ){ |
| 223277 | int iOff; | 225177 | u32 iOff; |
| 223278 | const u8 *a = pIter->pLeaf->p; | 225178 | const u8 *a = pIter->pLeaf->p; |
| 223279 | int szLeaf = pIter->pLeaf->szLeaf; | 225179 | u32 n = (u32)pIter->pLeaf->nn; |
| 223280 | int n = pIter->pLeaf->nn; | ||
| 223281 | 225180 | ||
| 223282 | u32 nMatch = 0; | 225181 | u32 nMatch = 0; |
| 223283 | u32 nKeep = 0; | 225182 | u32 nKeep = 0; |
| 223284 | u32 nNew = 0; | 225183 | u32 nNew = 0; |
| 223285 | u32 iTermOff; | 225184 | u32 iTermOff; |
| 223286 | int iPgidx; /* Current offset in pgidx */ | 225185 | u32 iPgidx; /* Current offset in pgidx */ |
| 223287 | int bEndOfPage = 0; | 225186 | int bEndOfPage = 0; |
| 223288 | 225187 | ||
| 223289 | assert( p->rc==SQLITE_OK ); | 225188 | assert( p->rc==SQLITE_OK ); |
| 223290 | 225189 | ||
| 223291 | iPgidx = szLeaf; | 225190 | iPgidx = (u32)pIter->pLeaf->szLeaf; |
| 223292 | iPgidx += fts5GetVarint32(&a[iPgidx], iTermOff); | 225191 | iPgidx += fts5GetVarint32(&a[iPgidx], iTermOff); |
| 223293 | iOff = iTermOff; | 225192 | iOff = iTermOff; |
| 223294 | if( iOff>n ){ | 225193 | if( iOff>n ){ |
| @@ -223354,15 +225253,15 @@ static void fts5LeafSeek( | |||
| 223354 | if( pIter->pLeaf==0 ) return; | 225253 | if( pIter->pLeaf==0 ) return; |
| 223355 | a = pIter->pLeaf->p; | 225254 | a = pIter->pLeaf->p; |
| 223356 | if( fts5LeafIsTermless(pIter->pLeaf)==0 ){ | 225255 | if( fts5LeafIsTermless(pIter->pLeaf)==0 ){ |
| 223357 | iPgidx = pIter->pLeaf->szLeaf; | 225256 | iPgidx = (u32)pIter->pLeaf->szLeaf; |
| 223358 | iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff); | 225257 | iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff); |
| 223359 | if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){ | 225258 | if( iOff<4 || (i64)iOff>=pIter->pLeaf->szLeaf ){ |
| 223360 | p->rc = FTS5_CORRUPT; | 225259 | p->rc = FTS5_CORRUPT; |
| 223361 | return; | 225260 | return; |
| 223362 | }else{ | 225261 | }else{ |
| 223363 | nKeep = 0; | 225262 | nKeep = 0; |
| 223364 | iTermOff = iOff; | 225263 | iTermOff = iOff; |
| 223365 | n = pIter->pLeaf->nn; | 225264 | n = (u32)pIter->pLeaf->nn; |
| 223366 | iOff += fts5GetVarint32(&a[iOff], nNew); | 225265 | iOff += fts5GetVarint32(&a[iOff], nNew); |
| 223367 | break; | 225266 | break; |
| 223368 | } | 225267 | } |
| @@ -223730,7 +225629,7 @@ static void fts5SegIterGotoPage( | |||
| 223730 | fts5SegIterNextPage(p, pIter); | 225629 | fts5SegIterNextPage(p, pIter); |
| 223731 | assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno ); | 225630 | assert( p->rc!=SQLITE_OK || pIter->iLeafPgno==iLeafPgno ); |
| 223732 | 225631 | ||
| 223733 | if( p->rc==SQLITE_OK ){ | 225632 | if( p->rc==SQLITE_OK && ALWAYS(pIter->pLeaf!=0) ){ |
| 223734 | int iOff; | 225633 | int iOff; |
| 223735 | u8 *a = pIter->pLeaf->p; | 225634 | u8 *a = pIter->pLeaf->p; |
| 223736 | int n = pIter->pLeaf->szLeaf; | 225635 | int n = pIter->pLeaf->szLeaf; |
| @@ -224162,7 +226061,11 @@ static void fts5SegiterPoslist( | |||
| 224162 | Fts5Colset *pColset, | 226061 | Fts5Colset *pColset, |
| 224163 | Fts5Buffer *pBuf | 226062 | Fts5Buffer *pBuf |
| 224164 | ){ | 226063 | ){ |
| 226064 | assert( pBuf!=0 ); | ||
| 226065 | assert( pSeg!=0 ); | ||
| 224165 | if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){ | 226066 | if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){ |
| 226067 | assert( pBuf->p!=0 ); | ||
| 226068 | assert( pBuf->nSpace >= pBuf->n+pSeg->nPos+FTS5_DATA_ZERO_PADDING ); | ||
| 224166 | memset(&pBuf->p[pBuf->n+pSeg->nPos], 0, FTS5_DATA_ZERO_PADDING); | 226069 | memset(&pBuf->p[pBuf->n+pSeg->nPos], 0, FTS5_DATA_ZERO_PADDING); |
| 224167 | if( pColset==0 ){ | 226070 | if( pColset==0 ){ |
| 224168 | fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback); | 226071 | fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback); |
| @@ -224386,6 +226289,7 @@ static void fts5IterSetOutputs_Full(Fts5Iter *pIter, Fts5SegIter *pSeg){ | |||
| 224386 | } | 226289 | } |
| 224387 | 226290 | ||
| 224388 | static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){ | 226291 | static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){ |
| 226292 | assert( pIter!=0 || (*pRc)!=SQLITE_OK ); | ||
| 224389 | if( *pRc==SQLITE_OK ){ | 226293 | if( *pRc==SQLITE_OK ){ |
| 224390 | Fts5Config *pConfig = pIter->pIndex->pConfig; | 226294 | Fts5Config *pConfig = pIter->pIndex->pConfig; |
| 224391 | if( pConfig->eDetail==FTS5_DETAIL_NONE ){ | 226295 | if( pConfig->eDetail==FTS5_DETAIL_NONE ){ |
| @@ -224457,7 +226361,10 @@ static void fts5MultiIterNew( | |||
| 224457 | } | 226361 | } |
| 224458 | } | 226362 | } |
| 224459 | *ppOut = pNew = fts5MultiIterAlloc(p, nSeg); | 226363 | *ppOut = pNew = fts5MultiIterAlloc(p, nSeg); |
| 224460 | if( pNew==0 ) return; | 226364 | if( pNew==0 ){ |
| 226365 | assert( p->rc!=SQLITE_OK ); | ||
| 226366 | goto fts5MultiIterNew_post_check; | ||
| 226367 | } | ||
| 224461 | pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC)); | 226368 | pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC)); |
| 224462 | pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY)); | 226369 | pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY)); |
| 224463 | pNew->pColset = pColset; | 226370 | pNew->pColset = pColset; |
| @@ -224521,6 +226428,10 @@ static void fts5MultiIterNew( | |||
| 224521 | fts5MultiIterFree(pNew); | 226428 | fts5MultiIterFree(pNew); |
| 224522 | *ppOut = 0; | 226429 | *ppOut = 0; |
| 224523 | } | 226430 | } |
| 226431 | |||
| 226432 | fts5MultiIterNew_post_check: | ||
| 226433 | assert( (*ppOut)!=0 || p->rc!=SQLITE_OK ); | ||
| 226434 | return; | ||
| 224524 | } | 226435 | } |
| 224525 | 226436 | ||
| 224526 | /* | 226437 | /* |
| @@ -224568,7 +226479,8 @@ static void fts5MultiIterNew2( | |||
| 224568 | ** False otherwise. | 226479 | ** False otherwise. |
| 224569 | */ | 226480 | */ |
| 224570 | static int fts5MultiIterEof(Fts5Index *p, Fts5Iter *pIter){ | 226481 | static int fts5MultiIterEof(Fts5Index *p, Fts5Iter *pIter){ |
| 224571 | assert( p->rc | 226482 | assert( pIter!=0 || p->rc!=SQLITE_OK ); |
| 226483 | assert( p->rc!=SQLITE_OK | ||
| 224572 | || (pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf==0)==pIter->base.bEof | 226484 | || (pIter->aSeg[ pIter->aFirst[1].iFirst ].pLeaf==0)==pIter->base.bEof |
| 224573 | ); | 226485 | ); |
| 224574 | return (p->rc || pIter->base.bEof); | 226486 | return (p->rc || pIter->base.bEof); |
| @@ -225372,6 +227284,7 @@ static void fts5IndexMergeLevel( | |||
| 225372 | ** and last leaf page number at the same time. */ | 227284 | ** and last leaf page number at the same time. */ |
| 225373 | fts5WriteFinish(p, &writer, &pSeg->pgnoLast); | 227285 | fts5WriteFinish(p, &writer, &pSeg->pgnoLast); |
| 225374 | 227286 | ||
| 227287 | assert( pIter!=0 || p->rc!=SQLITE_OK ); | ||
| 225375 | if( fts5MultiIterEof(p, pIter) ){ | 227288 | if( fts5MultiIterEof(p, pIter) ){ |
| 225376 | int i; | 227289 | int i; |
| 225377 | 227290 | ||
| @@ -225472,7 +227385,7 @@ static void fts5IndexAutomerge( | |||
| 225472 | Fts5Structure **ppStruct, /* IN/OUT: Current structure of index */ | 227385 | Fts5Structure **ppStruct, /* IN/OUT: Current structure of index */ |
| 225473 | int nLeaf /* Number of output leaves just written */ | 227386 | int nLeaf /* Number of output leaves just written */ |
| 225474 | ){ | 227387 | ){ |
| 225475 | if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 ){ | 227388 | if( p->rc==SQLITE_OK && p->pConfig->nAutomerge>0 && ALWAYS((*ppStruct)!=0) ){ |
| 225476 | Fts5Structure *pStruct = *ppStruct; | 227389 | Fts5Structure *pStruct = *ppStruct; |
| 225477 | u64 nWrite; /* Initial value of write-counter */ | 227390 | u64 nWrite; /* Initial value of write-counter */ |
| 225478 | int nWork; /* Number of work-quanta to perform */ | 227391 | int nWork; /* Number of work-quanta to perform */ |
| @@ -226582,11 +228495,15 @@ static int sqlite3Fts5IndexQuery( | |||
| 226582 | /* Scan multiple terms in the main index */ | 228495 | /* Scan multiple terms in the main index */ |
| 226583 | int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0; | 228496 | int bDesc = (flags & FTS5INDEX_QUERY_DESC)!=0; |
| 226584 | fts5SetupPrefixIter(p, bDesc, iPrefixIdx, buf.p, nToken+1, pColset,&pRet); | 228497 | fts5SetupPrefixIter(p, bDesc, iPrefixIdx, buf.p, nToken+1, pColset,&pRet); |
| 226585 | assert( p->rc!=SQLITE_OK || pRet->pColset==0 ); | 228498 | if( pRet==0 ){ |
| 226586 | fts5IterSetOutputCb(&p->rc, pRet); | 228499 | assert( p->rc!=SQLITE_OK ); |
| 226587 | if( p->rc==SQLITE_OK ){ | 228500 | }else{ |
| 226588 | Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst]; | 228501 | assert( pRet->pColset==0 ); |
| 226589 | if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg); | 228502 | fts5IterSetOutputCb(&p->rc, pRet); |
| 228503 | if( p->rc==SQLITE_OK ){ | ||
| 228504 | Fts5SegIter *pSeg = &pRet->aSeg[pRet->aFirst[1].iFirst]; | ||
| 228505 | if( pSeg->pLeaf ) pRet->xSetOutputs(pRet, pSeg); | ||
| 228506 | } | ||
| 226590 | } | 228507 | } |
| 226591 | } | 228508 | } |
| 226592 | 228509 | ||
| @@ -226834,7 +228751,7 @@ static int fts5QueryCksum( | |||
| 226834 | Fts5IndexIter *pIter = 0; | 228751 | Fts5IndexIter *pIter = 0; |
| 226835 | int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter); | 228752 | int rc = sqlite3Fts5IndexQuery(p, z, n, flags, 0, &pIter); |
| 226836 | 228753 | ||
| 226837 | while( rc==SQLITE_OK && 0==sqlite3Fts5IterEof(pIter) ){ | 228754 | while( rc==SQLITE_OK && ALWAYS(pIter!=0) && 0==sqlite3Fts5IterEof(pIter) ){ |
| 226838 | i64 rowid = pIter->iRowid; | 228755 | i64 rowid = pIter->iRowid; |
| 226839 | 228756 | ||
| 226840 | if( eDetail==FTS5_DETAIL_NONE ){ | 228757 | if( eDetail==FTS5_DETAIL_NONE ){ |
| @@ -227199,6 +229116,7 @@ static int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum, int bUseCksum | |||
| 227199 | Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */ | 229116 | Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */ |
| 227200 | Fts5Iter *pIter; /* Used to iterate through entire index */ | 229117 | Fts5Iter *pIter; /* Used to iterate through entire index */ |
| 227201 | Fts5Structure *pStruct; /* Index structure */ | 229118 | Fts5Structure *pStruct; /* Index structure */ |
| 229119 | int iLvl, iSeg; | ||
| 227202 | 229120 | ||
| 227203 | #ifdef SQLITE_DEBUG | 229121 | #ifdef SQLITE_DEBUG |
| 227204 | /* Used by extra internal tests only run if NDEBUG is not defined */ | 229122 | /* Used by extra internal tests only run if NDEBUG is not defined */ |
| @@ -227209,15 +229127,16 @@ static int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum, int bUseCksum | |||
| 227209 | 229127 | ||
| 227210 | /* Load the FTS index structure */ | 229128 | /* Load the FTS index structure */ |
| 227211 | pStruct = fts5StructureRead(p); | 229129 | pStruct = fts5StructureRead(p); |
| 229130 | if( pStruct==0 ){ | ||
| 229131 | assert( p->rc!=SQLITE_OK ); | ||
| 229132 | return fts5IndexReturn(p); | ||
| 229133 | } | ||
| 227212 | 229134 | ||
| 227213 | /* Check that the internal nodes of each segment match the leaves */ | 229135 | /* Check that the internal nodes of each segment match the leaves */ |
| 227214 | if( pStruct ){ | 229136 | for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){ |
| 227215 | int iLvl, iSeg; | 229137 | for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){ |
| 227216 | for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){ | 229138 | Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg]; |
| 227217 | for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){ | 229139 | fts5IndexIntegrityCheckSegment(p, pSeg); |
| 227218 | Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg]; | ||
| 227219 | fts5IndexIntegrityCheckSegment(p, pSeg); | ||
| 227220 | } | ||
| 227221 | } | 229140 | } |
| 227222 | } | 229141 | } |
| 227223 | 229142 | ||
| @@ -229164,7 +231083,8 @@ static int fts5FilterMethod( | |||
| 229164 | pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->p.base.zErrMsg | 231083 | pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->p.base.zErrMsg |
| 229165 | ); | 231084 | ); |
| 229166 | if( rc==SQLITE_OK ){ | 231085 | if( rc==SQLITE_OK ){ |
| 229167 | if( pCsr->ePlan==FTS5_PLAN_ROWID ){ | 231086 | if( pRowidEq!=0 ){ |
| 231087 | assert( pCsr->ePlan==FTS5_PLAN_ROWID ); | ||
| 229168 | sqlite3_bind_value(pCsr->pStmt, 1, pRowidEq); | 231088 | sqlite3_bind_value(pCsr->pStmt, 1, pRowidEq); |
| 229169 | }else{ | 231089 | }else{ |
| 229170 | sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iFirstRowid); | 231090 | sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iFirstRowid); |
| @@ -230582,7 +232502,7 @@ static void fts5SourceIdFunc( | |||
| 230582 | ){ | 232502 | ){ |
| 230583 | assert( nArg==0 ); | 232503 | assert( nArg==0 ); |
| 230584 | UNUSED_PARAM2(nArg, apUnused); | 232504 | UNUSED_PARAM2(nArg, apUnused); |
| 230585 | sqlite3_result_text(pCtx, "fts5: 2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5", -1, SQLITE_TRANSIENT); | 232505 | sqlite3_result_text(pCtx, "fts5: 2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62", -1, SQLITE_TRANSIENT); |
| 230586 | } | 232506 | } |
| 230587 | 232507 | ||
| 230588 | /* | 232508 | /* |
| @@ -231133,12 +233053,16 @@ static int fts5StorageDeleteFromIndex( | |||
| 231133 | if( pConfig->abUnindexed[iCol-1]==0 ){ | 233053 | if( pConfig->abUnindexed[iCol-1]==0 ){ |
| 231134 | const char *zText; | 233054 | const char *zText; |
| 231135 | int nText; | 233055 | int nText; |
| 233056 | assert( pSeek==0 || apVal==0 ); | ||
| 233057 | assert( pSeek!=0 || apVal!=0 ); | ||
| 231136 | if( pSeek ){ | 233058 | if( pSeek ){ |
| 231137 | zText = (const char*)sqlite3_column_text(pSeek, iCol); | 233059 | zText = (const char*)sqlite3_column_text(pSeek, iCol); |
| 231138 | nText = sqlite3_column_bytes(pSeek, iCol); | 233060 | nText = sqlite3_column_bytes(pSeek, iCol); |
| 231139 | }else{ | 233061 | }else if( ALWAYS(apVal) ){ |
| 231140 | zText = (const char*)sqlite3_value_text(apVal[iCol-1]); | 233062 | zText = (const char*)sqlite3_value_text(apVal[iCol-1]); |
| 231141 | nText = sqlite3_value_bytes(apVal[iCol-1]); | 233063 | nText = sqlite3_value_bytes(apVal[iCol-1]); |
| 233064 | }else{ | ||
| 233065 | continue; | ||
| 231142 | } | 233066 | } |
| 231143 | ctx.szCol = 0; | 233067 | ctx.szCol = 0; |
| 231144 | rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, | 233068 | rc = sqlite3Fts5Tokenize(pConfig, FTS5_TOKENIZE_DOCUMENT, |
| @@ -231774,8 +233698,9 @@ static int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol){ | |||
| 231774 | 233698 | ||
| 231775 | assert( p->pConfig->bColumnsize ); | 233699 | assert( p->pConfig->bColumnsize ); |
| 231776 | rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0); | 233700 | rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0); |
| 231777 | if( rc==SQLITE_OK ){ | 233701 | if( pLookup ){ |
| 231778 | int bCorrupt = 1; | 233702 | int bCorrupt = 1; |
| 233703 | assert( rc==SQLITE_OK ); | ||
| 231779 | sqlite3_bind_int64(pLookup, 1, iRowid); | 233704 | sqlite3_bind_int64(pLookup, 1, iRowid); |
| 231780 | if( SQLITE_ROW==sqlite3_step(pLookup) ){ | 233705 | if( SQLITE_ROW==sqlite3_step(pLookup) ){ |
| 231781 | const u8 *aBlob = sqlite3_column_blob(pLookup, 0); | 233706 | const u8 *aBlob = sqlite3_column_blob(pLookup, 0); |
| @@ -231788,6 +233713,8 @@ static int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol){ | |||
| 231788 | if( bCorrupt && rc==SQLITE_OK ){ | 233713 | if( bCorrupt && rc==SQLITE_OK ){ |
| 231789 | rc = FTS5_CORRUPT; | 233714 | rc = FTS5_CORRUPT; |
| 231790 | } | 233715 | } |
| 233716 | }else{ | ||
| 233717 | assert( rc!=SQLITE_OK ); | ||
| 231791 | } | 233718 | } |
| 231792 | 233719 | ||
| 231793 | return rc; | 233720 | return rc; |
| @@ -234478,6 +236405,7 @@ struct Fts5VocabCursor { | |||
| 234478 | 236405 | ||
| 234479 | int bEof; /* True if this cursor is at EOF */ | 236406 | int bEof; /* True if this cursor is at EOF */ |
| 234480 | Fts5IndexIter *pIter; /* Term/rowid iterator object */ | 236407 | Fts5IndexIter *pIter; /* Term/rowid iterator object */ |
| 236408 | void *pStruct; /* From sqlite3Fts5StructureRef() */ | ||
| 234481 | 236409 | ||
| 234482 | int nLeTerm; /* Size of zLeTerm in bytes */ | 236410 | int nLeTerm; /* Size of zLeTerm in bytes */ |
| 234483 | char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */ | 236411 | char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */ |
| @@ -234791,7 +236719,7 @@ static int fts5VocabOpenMethod( | |||
| 234791 | } | 236719 | } |
| 234792 | 236720 | ||
| 234793 | if( rc==SQLITE_OK ){ | 236721 | if( rc==SQLITE_OK ){ |
| 234794 | int nByte = pFts5->pConfig->nCol * sizeof(i64)*2 + sizeof(Fts5VocabCursor); | 236722 | i64 nByte = pFts5->pConfig->nCol * sizeof(i64)*2 + sizeof(Fts5VocabCursor); |
| 234795 | pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte); | 236723 | pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte); |
| 234796 | } | 236724 | } |
| 234797 | 236725 | ||
| @@ -234811,6 +236739,8 @@ static int fts5VocabOpenMethod( | |||
| 234811 | static void fts5VocabResetCursor(Fts5VocabCursor *pCsr){ | 236739 | static void fts5VocabResetCursor(Fts5VocabCursor *pCsr){ |
| 234812 | pCsr->rowid = 0; | 236740 | pCsr->rowid = 0; |
| 234813 | sqlite3Fts5IterClose(pCsr->pIter); | 236741 | sqlite3Fts5IterClose(pCsr->pIter); |
| 236742 | sqlite3Fts5StructureRelease(pCsr->pStruct); | ||
| 236743 | pCsr->pStruct = 0; | ||
| 234814 | pCsr->pIter = 0; | 236744 | pCsr->pIter = 0; |
| 234815 | sqlite3_free(pCsr->zLeTerm); | 236745 | sqlite3_free(pCsr->zLeTerm); |
| 234816 | pCsr->nLeTerm = -1; | 236746 | pCsr->nLeTerm = -1; |
| @@ -234888,9 +236818,11 @@ static int fts5VocabInstanceNext(Fts5VocabCursor *pCsr){ | |||
| 234888 | static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ | 236818 | static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){ |
| 234889 | Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; | 236819 | Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor; |
| 234890 | Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab; | 236820 | Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab; |
| 234891 | int rc = SQLITE_OK; | ||
| 234892 | int nCol = pCsr->pFts5->pConfig->nCol; | 236821 | int nCol = pCsr->pFts5->pConfig->nCol; |
| 236822 | int rc; | ||
| 234893 | 236823 | ||
| 236824 | rc = sqlite3Fts5StructureTest(pCsr->pFts5->pIndex, pCsr->pStruct); | ||
| 236825 | if( rc!=SQLITE_OK ) return rc; | ||
| 234894 | pCsr->rowid++; | 236826 | pCsr->rowid++; |
| 234895 | 236827 | ||
| 234896 | if( pTab->eType==FTS5_VOCAB_INSTANCE ){ | 236828 | if( pTab->eType==FTS5_VOCAB_INSTANCE ){ |
| @@ -235064,6 +236996,9 @@ static int fts5VocabFilterMethod( | |||
| 235064 | if( rc==SQLITE_OK ){ | 236996 | if( rc==SQLITE_OK ){ |
| 235065 | Fts5Index *pIndex = pCsr->pFts5->pIndex; | 236997 | Fts5Index *pIndex = pCsr->pFts5->pIndex; |
| 235066 | rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter); | 236998 | rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter); |
| 236999 | if( rc==SQLITE_OK ){ | ||
| 237000 | pCsr->pStruct = sqlite3Fts5StructureRef(pIndex); | ||
| 237001 | } | ||
| 235067 | } | 237002 | } |
| 235068 | if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){ | 237003 | if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){ |
| 235069 | rc = fts5VocabInstanceNewTerm(pCsr); | 237004 | rc = fts5VocabInstanceNewTerm(pCsr); |
| @@ -235508,10 +237443,6 @@ SQLITE_API int sqlite3_stmt_init( | |||
| 235508 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ | 237443 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ |
| 235509 | 237444 | ||
| 235510 | /************** End of stmt.c ************************************************/ | 237445 | /************** End of stmt.c ************************************************/ |
| 235511 | #if __LINE__!=235511 | ||
| 235512 | #undef SQLITE_SOURCE_ID | ||
| 235513 | #define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafaalt2" | ||
| 235514 | #endif | ||
| 235515 | /* Return the source-id for this library */ | 237446 | /* Return the source-id for this library */ |
| 235516 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } | 237447 | SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } |
| 235517 | /************************** End of sqlite3.c ******************************/ | 237448 | /************************** End of sqlite3.c ******************************/ |