Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From 11f343c9263f0619 To baf47264cf3ff913
2025-01-03
| ||
15:09 | Update the built-in SQLite to the latest 3.48.0 beta. check-in: c48d949499 user: drh tags: trunk | |
2024-12-31
| ||
22:38 | Update the built-in SQLite to the latest 3.48.0 beta. check-in: baf47264cf user: drh tags: trunk | |
2024-12-12
| ||
17:59 | Add the COPYRIGHT.md file to the top-level directory. check-in: 984fad8d01 user: drh tags: trunk | |
17:57 | Update the license statement on the main source code file. check-in: 11f343c926 user: drh tags: trunk | |
2024-11-15
| ||
00:01 | Enhanced to verify that the correct number of rows is returned from each query. See SQLite Forum post 115a6fedd9. check-in: c5ec0e8e41 user: drh tags: trunk | |
Added COPYRIGHT.md.
|
Changes to src/sqlite3.c.
1 2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | - + + - + + + | /****************************************************************************** ** This file is an amalgamation of many separate C source files from SQLite |
︙ | |||
458 459 460 461 462 463 464 | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | - - - + + + | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ |
︙ | |||
964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 | 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | + + + + + + + + | ** read-only media and cannot be changed even by processes with ** elevated privileges. ** ** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying ** filesystem supports doing multiple write operations atomically when those ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and ** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. ** ** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read ** from the database file in amounts that are not a multiple of the ** page size and that do not begin at a page boundary. Without this ** property, SQLite is careful to only do full-page reads and write ** on aligned pages, with the one exception that it will do a sub-page ** read of the first page to access the database header. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 #define SQLITE_IOCAP_ATOMIC1K 0x00000004 #define SQLITE_IOCAP_ATOMIC2K 0x00000008 #define SQLITE_IOCAP_ATOMIC4K 0x00000010 #define SQLITE_IOCAP_ATOMIC8K 0x00000020 #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 #define SQLITE_IOCAP_SUBPAGE_READ 0x00008000 /* ** CAPI3REF: File Locking Levels ** ** SQLite uses one of these integer values as the second ** argument to calls it makes to the xLock() and xUnlock() methods ** of an [sqlite3_io_methods] object. These values are ordered from |
︙ | |||
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 | 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 | + | ** <li> [SQLITE_IOCAP_ATOMIC64K] ** <li> [SQLITE_IOCAP_SAFE_APPEND] ** <li> [SQLITE_IOCAP_SEQUENTIAL] ** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN] ** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE] ** <li> [SQLITE_IOCAP_IMMUTABLE] ** <li> [SQLITE_IOCAP_BATCH_ATOMIC] ** <li> [SQLITE_IOCAP_SUBPAGE_READ] ** </ul> ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values ** mean that writes of blocks that are nnn bytes in size and ** are aligned to an address which is an integer multiple of ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means |
︙ | |||
1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 | 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 | + + + + + | ** ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]] ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This ** opcode causes the xFileControl method to swap the file handle with the one ** pointed to by the pArg argument. This capability is used during testing ** and only needs to be supported when SQLITE_TEST is defined. ** ** <li>[[SQLITE_FCNTL_NULL_IO]] ** The [SQLITE_FCNTL_NULL_IO] opcode sets the low-level file descriptor ** or file handle for the [sqlite3_file] object such that it will no longer ** read or write to the database file. ** ** <li>[[SQLITE_FCNTL_WAL_BLOCK]] ** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might ** be advantageous to block on the next WAL lock if the lock is not immediately ** available. The WAL subsystem issues this signal during rare ** circumstances in order to fix a problem with priority inversion. ** Applications should <em>not</em> use this file-control. ** |
︙ | |||
1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 | 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 | + | #define SQLITE_FCNTL_SIZE_LIMIT 36 #define SQLITE_FCNTL_CKPT_DONE 37 #define SQLITE_FCNTL_RESERVE_BYTES 38 #define SQLITE_FCNTL_CKPT_START 39 #define SQLITE_FCNTL_EXTERNAL_READER 40 #define SQLITE_FCNTL_CKSM_FILE 41 #define SQLITE_FCNTL_RESET_CACHE 42 #define SQLITE_FCNTL_NULL_IO 43 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
︙ | |||
2934 2935 2936 2937 2938 2939 2940 | 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 | - + + + + + | ** CAPI3REF: Count The Number Of Rows Modified ** METHOD: sqlite3 ** ** ^These functions return the number of rows modified, inserted or ** deleted by the most recently completed INSERT, UPDATE or DELETE ** statement on the database connection specified by the only parameter. ** The two functions are identical except for the type of the return value |
︙ | |||
4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 | 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 | + + + + + + + + + + + | ** prepared statements, regardless of whether or not they use this ** flag. ** ** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt> ** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler ** to return an error (error code SQLITE_ERROR) if the statement uses ** any virtual tables. ** ** [[SQLITE_PREPARE_DONT_LOG]] <dt>SQLITE_PREPARE_DONT_LOG</dt> ** <dd>The SQLITE_PREPARE_DONT_LOG flag prevents SQL compiler ** errors from being sent to the error log defined by ** [SQLITE_CONFIG_LOG]. This can be used, for example, to do test ** compiles to see if some SQL syntax is well-formed, without generating ** messages on the global error log when it is not. If the test compile ** fails, the sqlite3_prepare_v3() call returns the same error indications ** with or without this flag; it just omits the call to [sqlite3_log()] that ** logs the error. ** </dl> */ #define SQLITE_PREPARE_PERSISTENT 0x01 #define SQLITE_PREPARE_NORMALIZE 0x02 #define SQLITE_PREPARE_NO_VTAB 0x04 #define SQLITE_PREPARE_DONT_LOG 0x10 /* ** CAPI3REF: Compiling An SQL Statement ** KEYWORDS: {SQL statement compiler} ** METHOD: sqlite3 ** CONSTRUCTOR: sqlite3_stmt ** |
︙ | |||
11192 11193 11194 11195 11196 11197 11198 | 11225 11226 11227 11228 11229 11230 11231 11232 11233 11234 11235 11236 11237 11238 11239 | - + | # define SQLITE_THREADSAFE 0 # endif #endif #if 0 } /* End of the 'extern "C"' block */ #endif |
︙ | |||
13443 13444 13445 13446 13447 13448 13449 | 13476 13477 13478 13479 13480 13481 13482 13483 13484 13485 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 13497 13498 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 13509 13510 13511 | - - - + + + + + + + + + + + + + + + + + + | ** ** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken) ** This is used to access token iToken of phrase hit iIdx within the ** current row. If iIdx is less than zero or greater than or equal to the ** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, ** output variable (*ppToken) is set to point to a buffer containing the ** matching document token, and (*pnToken) to the size of that buffer in |
︙ | |||
13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 | 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 | + | #if 0 } /* end of the 'extern "C"' block */ #endif #endif /* _FTS5_H */ /******** End of fts5.h *********/ #endif /* SQLITE3_H */ /************** End of sqlite3.h *********************************************/ /************** Continuing where we left off in sqliteInt.h ******************/ /* ** Reuse the STATIC_LRU for mutex access to sqlite3_temp_directory. */ |
︙ | |||
13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 | 13978 13979 13980 13981 13982 13983 13984 13985 13986 13987 13988 13989 13990 13991 13992 | + | ** ** The hard limit is the ability of a 32-bit signed integer ** to count the size: 2^31-1 or 2147483647. */ #ifndef SQLITE_MAX_LENGTH # define SQLITE_MAX_LENGTH 1000000000 #endif #define SQLITE_MIN_LENGTH 30 /* Minimum value for the length limit */ /* ** This is the maximum number of ** ** * Columns in a table ** * Columns in an index ** * Columns in a view |
︙ | |||
13994 13995 13996 13997 13998 13999 14000 14001 14002 | 14044 14045 14046 14047 14048 14049 14050 14051 14052 14053 14054 14055 14056 14057 14058 14059 14060 14061 14062 14063 14064 | + + + + - + | */ #ifndef SQLITE_MAX_VDBE_OP # define SQLITE_MAX_VDBE_OP 250000000 #endif /* ** The maximum number of arguments to an SQL function. ** ** This value has a hard upper limit of 32767 due to storage ** constraints (it needs to fit inside a i16). We keep it ** lower than that to prevent abuse. */ #ifndef SQLITE_MAX_FUNCTION_ARG |
︙ | |||
15998 15999 16000 16001 16002 16003 16004 16005 16006 16007 16008 16009 16010 16011 | 16052 16053 16054 16055 16056 16057 16058 16059 16060 16061 16062 16063 16064 16065 16066 16067 16068 16069 16070 16071 16072 16073 16074 16075 16076 16077 16078 16079 16080 16081 | + + + + + + + + + + + + + + + + | #define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */ #define isWalMode(x) ((x)==PAGER_JOURNALMODE_WAL) /* ** The argument to this macro is a file descriptor (type sqlite3_file*). ** Return 0 if it is not open, or non-zero (but not 1) if it is. ** ** This is so that expressions can be written as: ** ** if( isOpen(pPager->jfd) ){ ... ** ** instead of ** ** if( pPager->jfd->pMethods ){ ... */ #define isOpen(pFd) ((pFd)->pMethods!=0) /* ** Flags that make up the mask passed to sqlite3PagerGet(). */ #define PAGER_GET_NOCONTENT 0x01 /* Do not load data from disk */ #define PAGER_GET_READONLY 0x02 /* Read-only page is acceptable */ /* |
︙ | |||
17023 17024 17025 17026 17027 17028 17029 | 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 | - + | /************** End of opcodes.h *********************************************/ /************** Continuing where we left off in vdbe.h ***********************/ /* ** Additional non-public SQLITE_PREPARE_* flags */ #define SQLITE_PREPARE_SAVESQL 0x80 /* Preserve SQL text */ |
︙ | |||
17738 17739 17740 17741 17742 17743 17744 | 17808 17809 17810 17811 17812 17813 17814 17815 17816 17817 17818 17819 17820 17821 17822 17823 17824 17825 17826 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + - | */ #define SQLITE_FUNC_HASH_SZ 23 struct FuncDefHash { FuncDef *a[SQLITE_FUNC_HASH_SZ]; /* Hash table for functions */ }; #define SQLITE_FUNC_HASH(C,L) (((C)+(L))%SQLITE_FUNC_HASH_SZ) |
︙ | |||
17939 17940 17941 17942 17943 17944 17945 | 17973 17974 17975 17976 17977 17978 17979 17980 17981 17982 17983 17984 17985 17986 | - - - | */ sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */ sqlite3 *pUnlockConnection; /* Connection to watch for unlock */ void *pUnlockArg; /* Argument to xUnlockNotify */ void (*xUnlockNotify)(void **, int); /* Unlock notify callback */ sqlite3 *pNextBlocked; /* Next in list of all blocked connections */ #endif |
︙ | |||
18100 18101 18102 18103 18104 18105 18106 | 18131 18132 18133 18134 18135 18136 18137 18138 18139 18140 18141 18142 18143 18144 18145 | - + | ** For per-connection application-defined functions, a pointer to this ** structure is held in the db->aHash hash table. ** ** The u.pHash field is used by the global built-ins. The u.pDestructor ** field is used by per-connection app-def functions. */ struct FuncDef { |
︙ | |||
19796 19797 19798 19799 19800 19801 19802 | 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 | - + | ** in register pDest->iSDParm then abandon the rest ** of the query. This destination implies "LIMIT 1". ** ** SRT_Set The result must be a single column. Store each ** row of result as the key in table pDest->iSDParm. ** Apply the affinity pDest->affSdst before storing ** results. if pDest->iSDParm2 is positive, then it is |
︙ | |||
22848 22849 22850 22851 22852 22853 22854 | 22879 22880 22881 22882 22883 22884 22885 22886 22887 22888 22889 22890 22891 22892 | - - - | #endif #ifdef SQLITE_UNLINK_AFTER_CLOSE "UNLINK_AFTER_CLOSE", #endif #ifdef SQLITE_UNTESTABLE "UNTESTABLE", #endif |
︙ | |||
23698 23699 23700 23701 23702 23703 23704 | 23726 23727 23728 23729 23730 23731 23732 23733 23734 23735 23736 23737 23738 23739 23740 | - + | FuncDef *pFunc; /* Pointer to function information */ Mem *pMem; /* Memory cell used to store aggregate context */ Vdbe *pVdbe; /* The VM that owns this context */ int iOp; /* Instruction number of OP_Function */ int isError; /* Error code returned by the function. */ u8 enc; /* Encoding to use for results */ u8 skipFlag; /* Skip accumulator loading if true */ |
︙ | |||
23845 23846 23847 23848 23849 23850 23851 23852 23853 23854 23855 23856 23857 23858 | 23873 23874 23875 23876 23877 23878 23879 23880 23881 23882 23883 23884 23885 23886 23887 | + | KeyInfo keyinfo; UnpackedRecord *pUnpacked; /* Unpacked version of aRecord[] */ UnpackedRecord *pNewUnpacked; /* Unpacked version of new.* record */ int iNewReg; /* Register for new.* values */ int iBlobWrite; /* Value returned by preupdate_blobwrite() */ i64 iKey1; /* First key value passed to hook */ i64 iKey2; /* Second key value passed to hook */ Mem oldipk; /* Memory cell holding "old" IPK value */ Mem *aNew; /* Array of new.* values */ Table *pTab; /* Schema object being updated */ Index *pPk; /* PK index if pTab is WITHOUT ROWID */ sqlite3_value **apDflt; /* Array of default values, if required */ }; /* |
︙ | |||
32294 32295 32296 32297 32298 32299 32300 32301 32302 32303 32304 32305 32306 32307 | 32323 32324 32325 32326 32327 32328 32329 32330 32331 32332 32333 32334 32335 32336 32337 | + | SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExpr){ while( pExpr && (ExprHasProperty(pExpr,EP_OuterON|EP_InnerON) || pExpr->w.iOfst<=0) ){ pExpr = pExpr->pLeft; } if( pExpr==0 ) return; if( ExprHasProperty(pExpr, EP_FromDDL) ) return; db->errByteOffset = pExpr->w.iOfst; } /* ** Enlarge the memory allocation on a StrAccum object so that it is ** able to accept at least N more bytes of text. ** |
︙ | |||
33023 33024 33025 33026 33027 33028 33029 | 33053 33054 33055 33056 33057 33058 33059 33060 33061 33062 33063 33064 33065 33066 33067 | - + | if( pItem->fg.fromDDL ){ sqlite3_str_appendf(&x, " DDL"); } if( pItem->fg.isCte ){ sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse); } if( pItem->fg.isOn || (pItem->fg.isUsing==0 && pItem->u3.pOn!=0) ){ |
︙ | |||
34107 34108 34109 34110 34111 34112 34113 34114 34115 34116 34117 34118 34119 34120 | 34137 34138 34139 34140 34141 34142 34143 34144 34145 34146 34147 34148 34149 34150 34151 34152 34153 34154 | + + + + | ** parameters. These variants are intended to be used from a symbolic ** debugger, such as "gdb", during interactive debugging sessions. ** ** This routines are given external linkage so that they will always be ** accessible to the debugging, and to avoid warnings about unused ** functions. But these routines only exist in debugging builds, so they ** do not contaminate the interface. ** ** See Also: ** ** sqlite3ShowWhereTerm() in where.c */ SQLITE_PRIVATE void sqlite3ShowExpr(const Expr *p){ sqlite3TreeViewExpr(0,p,0); } SQLITE_PRIVATE void sqlite3ShowExprList(const ExprList *p){ sqlite3TreeViewExprList(0,p,0,0);} SQLITE_PRIVATE void sqlite3ShowIdList(const IdList *p){ sqlite3TreeViewIdList(0,p,0,0); } SQLITE_PRIVATE void sqlite3ShowSrcList(const SrcList *p){ sqlite3TreeViewSrcList(0,p); } SQLITE_PRIVATE void sqlite3ShowSelect(const Select *p){ sqlite3TreeViewSelect(0,p,0); } SQLITE_PRIVATE void sqlite3ShowWith(const With *p){ sqlite3TreeViewWith(0,p,0); } |
︙ | |||
35683 35684 35685 35686 35687 35688 35689 35690 | 35717 35718 35719 35720 35721 35722 35723 35724 35725 35726 35727 35728 35729 35730 35731 35732 | + - | u64 s = 0; /* significand */ int d = 0; /* adjust exponent for shifting decimal point */ int esign = 1; /* sign of exponent */ int e = 0; /* exponent */ int eValid = 1; /* True exponent is either not used or is well-formed */ int nDigit = 0; /* Number of digits processed */ int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */ u64 s2; /* round-tripped significand */ double rr[2]; |
︙ | |||
35787 35788 35789 35790 35791 35792 35793 | 35821 35822 35823 35824 35825 35826 35827 35828 35829 35830 35831 35832 35833 35834 35835 35836 35837 35838 35839 35840 35841 35842 35843 35844 35845 35846 35847 35848 35849 35850 35851 35852 35853 35854 35855 35856 35857 35858 35859 35860 | - + - - - + + + + + + + + + - + + + + + + | goto atof_return; } /* adjust exponent by d, and update sign */ e = (e*esign) + d; /* Try to adjust the exponent to make it smaller */ |
︙ | |||
36991 36992 36993 36994 36995 36996 36997 | 37036 37037 37038 37039 37040 37041 37042 37043 37044 37045 37046 37047 37048 37049 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | const char *z = (const char*)&pIn[i+2]; if( strncmp(z,zName,nName)==0 && z[nName]==0 ) return pIn[i]; i += pIn[i+1]; }while( i<mx ); return 0; } |
︙ | |||
38770 38771 38772 38773 38774 38775 38776 | 38717 38718 38719 38720 38721 38722 38723 38724 38725 38726 38727 38728 38729 38730 38731 | - + | # define F_GETLK 5 # define F_SETLK 6 # define F_SETLKW 7 # endif # endif #else /* !SQLITE_WASI */ # ifndef HAVE_FCHMOD |
︙ | |||
42544 42545 42546 42547 42548 42549 42550 42551 42552 42553 42554 42555 42556 42557 | 42491 42492 42493 42494 42495 42496 42497 42498 42499 42500 42501 42502 42503 42504 42505 42506 42507 42508 42509 | + + + + + | } case SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: { int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE); return rc ? SQLITE_IOERR_ROLLBACK_ATOMIC : SQLITE_OK; } #endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */ case SQLITE_FCNTL_NULL_IO: { osClose(pFile->h); pFile->h = -1; return SQLITE_OK; } case SQLITE_FCNTL_LOCKSTATE: { *(int*)pArg = pFile->eFileLock; return SQLITE_OK; } case SQLITE_FCNTL_LAST_ERRNO: { *(int*)pArg = pFile->lastErrno; return SQLITE_OK; |
︙ | |||
42685 42686 42687 42688 42689 42690 42691 42692 42693 42694 42695 42696 42697 42698 | 42637 42638 42639 42640 42641 42642 42643 42644 42645 42646 42647 42648 42649 42650 42651 | + | } #endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */ /* Set the POWERSAFE_OVERWRITE flag if requested. */ if( pFd->ctrlFlags & UNIXFILE_PSOW ){ pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE; } pFd->deviceCharacteristics |= SQLITE_IOCAP_SUBPAGE_READ; pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; } } #else #include <sys/dcmd_blk.h> #include <sys/statvfs.h> |
︙ | |||
50424 50425 50426 50427 50428 50429 50430 50431 50432 50433 50434 50435 50436 50437 | 50377 50378 50379 50380 50381 50382 50383 50384 50385 50386 50387 50388 50389 50390 50391 50392 50393 50394 50395 | + + + + + | pFile->h = *phFile; *phFile = hOldFile; OSTRACE(("FCNTL oldFile=%p, newFile=%p, rc=SQLITE_OK\n", hOldFile, pFile->h)); return SQLITE_OK; } #endif case SQLITE_FCNTL_NULL_IO: { (void)osCloseHandle(pFile->h); pFile->h = NULL; return SQLITE_OK; } case SQLITE_FCNTL_TEMPFILENAME: { char *zTFile = 0; int rc = winGetTempname(pFile->pVfs, &zTFile); if( rc==SQLITE_OK ){ *(char**)pArg = zTFile; } OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc))); |
︙ | |||
50485 50486 50487 50488 50489 50490 50491 | 50443 50444 50445 50446 50447 50448 50449 50450 50451 50452 50453 50454 50455 50456 50457 | - + | } /* ** Return a vector of device characteristics. */ static int winDeviceCharacteristics(sqlite3_file *id){ winFile *p = (winFile*)id; |
︙ | |||
51873 51874 51875 51876 51877 51878 51879 | 51831 51832 51833 51834 51835 51836 51837 51838 51839 51840 51841 51842 51843 51844 51845 | - + | /* If argument zPath is a NULL pointer, this function is required to open ** a temporary file. Use this buffer to store the file name in. */ char *zTmpname = 0; /* For temporary filename, if necessary. */ int rc = SQLITE_OK; /* Function Return Code */ #if !defined(NDEBUG) || SQLITE_OS_WINCE |
︙ | |||
58074 58075 58076 58077 58078 58079 58080 | 58032 58033 58034 58035 58036 58037 58038 58039 58040 58041 58042 58043 58044 58045 58046 58047 58048 58049 58050 58051 58052 58053 58054 58055 58056 58057 58058 58059 58060 58061 58062 58063 58064 58065 58066 58067 58068 58069 58070 58071 58072 | - - - - - - - - - - - - - - - - - + + + + + + - - + + - + + + + + + | */ #if SQLITE_MAX_MMAP_SIZE>0 # define USEFETCH(x) ((x)->bUseFetch) #else # define USEFETCH(x) 0 #endif |
︙ | |||
59365 59366 59367 59368 59369 59370 59371 | 59317 59318 59319 59320 59321 59322 59323 59324 59325 59326 59327 59328 59329 59330 59331 | - + | ** https://bugzilla.mozilla.org/show_bug.cgi?id=1072773 */ rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags); } } pPager->journalOff = 0; }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST |
︙ | |||
67523 67524 67525 67526 67527 67528 67529 | 67475 67476 67477 67478 67479 67480 67481 67482 67483 67484 67485 67486 67487 67488 67489 | - + | pWal->pWiValue = 0; } return SQLITE_IOERR_IN_PAGE; } /* ** Assert that the Wal.lockMask mask, which indicates the locks held |
︙ | |||
68075 68076 68077 68078 68079 68080 68081 | 68027 68028 68029 68030 68031 68032 68033 68034 68035 68036 68037 68038 68039 68040 68041 | - - - - | ** checkpoint process do as much work as possible. This routine might ** update values of the aReadMark[] array in the header, but if it does ** so it takes care to hold an exclusive lock on the corresponding ** WAL_READ_LOCK() while changing values. */ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){ volatile WalCkptInfo *pInfo; /* Checkpoint information in wal-index */ |
︙ | |||
68185 68186 68187 68188 68189 68190 68191 | 68133 68134 68135 68136 68137 68138 68139 68140 68141 68142 68143 68144 68145 68146 68147 68148 68149 68150 68151 68152 68153 68154 68155 68156 68157 68158 68159 68160 68161 68162 68163 68164 68165 68166 68167 68168 68169 68170 68171 68172 68173 68174 68175 68176 68177 68178 68179 68180 68181 68182 68183 68184 68185 68186 68187 68188 68189 68190 68191 68192 68193 68194 68195 68196 68197 68198 68199 68200 68201 68202 68203 68204 68205 68206 68207 68208 68209 68210 68211 68212 68213 68214 68215 68216 68217 68218 68219 68220 68221 68222 68223 68224 68225 68226 68227 68228 68229 68230 68231 68232 68233 68234 68235 68236 68237 68238 68239 68240 68241 68242 68243 68244 68245 68246 68247 68248 68249 68250 68251 68252 68253 68254 68255 68256 68257 68258 68259 68260 68261 68262 68263 68264 68265 68266 68267 68268 68269 68270 68271 68272 68273 68274 68275 68276 68277 68278 68279 68280 68281 68282 68283 68284 68285 68286 68287 | + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } } assert( pWal->nWiData>0 ); assert( pWal->apWiData[0]!=0 ); pInfo = walCkptInfo(pWal); SEH_INJECT_FAULT; { u32 mxReadMark; /* Largest aReadMark[] value */ int mxI; /* Index of largest aReadMark[] value */ int i; /* Loop counter */ u32 mxFrame; /* Wal frame to lock to */ |
︙ | |||
87199 87200 87201 87202 87203 87204 87205 87206 87207 87208 87209 87210 87211 87212 | 87153 87154 87155 87156 87157 87158 87159 87160 87161 87162 87163 87164 87165 87166 87167 | + | ** Mem.db = db ** Mem.szMalloc = 0 ** ** All other fields of Mem can safely remain uninitialized for now. They ** will be initialized before use. */ static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){ assert( db!=0 ); if( N>0 ){ do{ p->flags = flags; p->db = db; p->szMalloc = 0; #ifdef SQLITE_DEBUG p->pScopyFrom = 0; |
︙ | |||
87224 87225 87226 87227 87228 87229 87230 87231 87232 87233 87234 87235 87236 87237 | 87179 87180 87181 87182 87183 87184 87185 87186 87187 87188 87189 87190 87191 87192 87193 | + | ** will be unchanged. Mem elements which had something freed will be ** set to MEM_Undefined. */ static void releaseMemArray(Mem *p, int N){ if( p && N ){ Mem *pEnd = &p[N]; sqlite3 *db = p->db; assert( db!=0 ); if( db->pnBytesFreed ){ do{ if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc); }while( (++p)<pEnd ); return; } do{ |
︙ | |||
87704 87705 87706 87707 87708 87709 87710 87711 87712 87713 87714 87715 87716 87717 | 87660 87661 87662 87663 87664 87665 87666 87667 87668 87669 87670 87671 87672 87673 87674 | + | struct ReusableSpace x; /* Reusable bulk memory */ assert( p!=0 ); assert( p->nOp>0 ); assert( pParse!=0 ); assert( p->eVdbeState==VDBE_INIT_STATE ); assert( pParse==p->pParse ); assert( pParse->db==p->db ); p->pVList = pParse->pVList; pParse->pVList = 0; db = p->db; assert( db->mallocFailed==0 ); nVar = pParse->nVar; nMem = pParse->nMem; nCursor = pParse->nTab; |
︙ | |||
90584 90585 90586 90587 90588 90589 90590 90591 90592 90593 90594 90595 90596 90597 | 90541 90542 90543 90544 90545 90546 90547 90548 90549 90550 90551 90552 90553 90554 90555 | + | db->pPreUpdate = &preupdate; db->xPreUpdateCallback(db->pPreUpdateArg, db, op, zDb, zTbl, iKey1, iKey2); db->pPreUpdate = 0; sqlite3DbFree(db, preupdate.aRecord); vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pUnpacked); vdbeFreeUnpacked(db, preupdate.keyinfo.nKeyField+1, preupdate.pNewUnpacked); sqlite3VdbeMemRelease(&preupdate.oldipk); if( preupdate.aNew ){ int i; for(i=0; i<pCsr->nField; i++){ sqlite3VdbeMemRelease(&preupdate.aNew[i]); } sqlite3DbNNFreeNN(db, preupdate.aNew); } |
︙ | |||
91940 91941 91942 91943 91944 91945 91946 | 91898 91899 91900 91901 91902 91903 91904 91905 91906 91907 91908 91909 91910 91911 91912 | - + | ** ** Specifically, this is called from within: ** ** sqlite3_column_int() ** sqlite3_column_int64() ** sqlite3_column_text() ** sqlite3_column_text16() |
︙ | |||
92802 92803 92804 92805 92806 92807 92808 | 92760 92761 92762 92763 92764 92765 92766 92767 92768 92769 92770 92771 92772 92773 92774 92775 92776 92777 92778 92779 92780 92781 92782 92783 92784 92785 92786 92787 92788 92789 92790 92791 92792 92793 92794 92795 92796 92797 92798 92799 92800 92801 92802 92803 92804 92805 92806 92807 92808 92809 92810 92811 92812 92813 92814 92815 92816 92817 92818 92819 92820 92821 92822 92823 92824 92825 92826 92827 92828 92829 92830 92831 | - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx); } if( iIdx>=p->pCsr->nField || iIdx<0 ){ rc = SQLITE_RANGE; goto preupdate_old_out; } |
︙ | |||
93403 93404 93405 93406 93407 93408 93409 93410 93411 93412 93413 93414 93415 93416 | 93365 93366 93367 93368 93369 93370 93371 93372 93373 93374 93375 93376 93377 93378 93379 93380 93381 93382 93383 93384 93385 93386 93387 93388 93389 93390 93391 93392 93393 93394 93395 93396 93397 93398 93399 93400 93401 93402 93403 93404 93405 93406 93407 93408 93409 93410 93411 93412 93413 93414 93415 93416 93417 93418 93419 93420 93421 93422 93423 93424 93425 93426 93427 93428 93429 93430 93431 93432 93433 93434 93435 93436 93437 93438 93439 93440 93441 93442 93443 93444 93445 93446 93447 93448 93449 93450 93451 93452 93453 93454 93455 93456 93457 93458 93459 93460 93461 93462 93463 93464 93465 93466 93467 93468 93469 93470 93471 93472 93473 93474 93475 93476 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. */ /* #include "sqliteInt.h" */ /* #include "vdbeInt.h" */ /* ** High-resolution hardware timer used for debugging and testing only. */ #if defined(VDBE_PROFILE) \ || defined(SQLITE_PERFORMANCE_TRACE) \ || defined(SQLITE_ENABLE_STMT_SCANSTATUS) /************** Include hwtime.h in the middle of vdbe.c *********************/ /************** Begin file hwtime.h ******************************************/ /* ** 2008 May 27 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ****************************************************************************** ** ** This file contains inline asm code for retrieving "high-performance" ** counters for x86 and x86_64 class CPUs. */ #ifndef SQLITE_HWTIME_H #define SQLITE_HWTIME_H /* ** The following routine only works on Pentium-class (or newer) processors. ** It uses the RDTSC opcode to read the cycle count value out of the ** processor and returns that value. This can be used for high-res ** profiling. */ #if !defined(__STRICT_ANSI__) && \ (defined(__GNUC__) || defined(_MSC_VER)) && \ (defined(i386) || defined(__i386__) || defined(_M_IX86)) #if defined(__GNUC__) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned int lo, hi; __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); return (sqlite_uint64)hi << 32 | lo; } #elif defined(_MSC_VER) __declspec(naked) __inline sqlite_uint64 __cdecl sqlite3Hwtime(void){ __asm { rdtsc ret ; return value at EDX:EAX } } #endif #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__x86_64__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned int lo, hi; __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); return (sqlite_uint64)hi << 32 | lo; } #elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) && defined(__ppc__)) __inline__ sqlite_uint64 sqlite3Hwtime(void){ unsigned long long retval; unsigned long junk; __asm__ __volatile__ ("\n\ 1: mftbu %1\n\ mftb %L0\n\ mftbu %0\n\ cmpw %0,%1\n\ bne 1b" : "=r" (retval), "=r" (junk)); return retval; } #else /* ** asm() is needed for hardware timing support. Without asm(), ** disable the sqlite3Hwtime() routine. ** ** sqlite3Hwtime() is only used for some obscure debugging ** and analysis configurations, not in any deliverable, so this ** should not be a great loss. */ SQLITE_PRIVATE sqlite_uint64 sqlite3Hwtime(void){ return ((sqlite_uint64)0); } #endif #endif /* !defined(SQLITE_HWTIME_H) */ /************** End of hwtime.h **********************************************/ /************** Continuing where we left off in vdbe.c ***********************/ #endif /* ** Invoke this macro on memory cells just prior to changing the ** value of the cell. This macro verifies that shallow copies are ** not misused. A shallow copy of a string or blob just copies a ** pointer to the string or blob, not the content. If the original ** is changed while the copy is still in use, the string or blob might ** be changed out from under the copy. This macro verifies that nothing |
︙ | |||
97911 97912 97913 97914 97915 97916 97917 97918 97919 97920 97921 97922 97923 97924 97925 97926 97927 | 97971 97972 97973 97974 97975 97976 97977 97978 97979 97980 97981 97982 97983 97984 97985 97986 97987 97988 97989 | + + | pCx->pgnoRoot = SCHEMA_ROOT; rc = sqlite3BtreeCursor(pCx->ub.pBtx, SCHEMA_ROOT, BTREE_WRCSR, 0, pCx->uc.pCursor); pCx->isTable = 1; } } pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED); assert( p->apCsr[pOp->p1]==pCx ); if( rc ){ assert( !sqlite3BtreeClosesWithCursor(pCx->ub.pBtx, pCx->uc.pCursor) ); sqlite3BtreeClose(pCx->ub.pBtx); p->apCsr[pOp->p1] = 0; /* Not required; helps with static analysis */ }else{ assert( sqlite3BtreeClosesWithCursor(pCx->ub.pBtx, pCx->uc.pCursor) ); } } } if( rc ) goto abort_due_to_error; pCx->nullRow = 1; |
︙ | |||
102433 102434 102435 102436 102437 102438 102439 | 102495 102496 102497 102498 102499 102500 102501 102502 102503 102504 102505 102506 102507 102508 102509 | - + | ** ** For loop elements, P3 is the estimated code of each invocation of this ** element. ** ** As with all opcodes, the meanings of the parameters for OP_Explain ** are subject to change from one release to the next. Applications ** should not attempt to interpret or use any of the information |
︙ | |||
109843 109844 109845 109846 109847 109848 109849 | 109905 109906 109907 109908 109909 109910 109911 109912 109913 109914 109915 109916 109917 109918 109919 | - + | p4 = sqlite3BinaryCompareCollSeq(pParse, pRight, pLeft); }else{ p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight); } p5 = binaryCompareP5(pLeft, pRight, jumpIfNull); addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1, (void*)p4, P4_COLLSEQ); |
︙ | |||
112010 112011 112012 112013 112014 112015 112016 | 112072 112073 112074 112075 112076 112077 112078 112079 112080 112081 112082 112083 112084 112085 112086 | - + | ** (3) pSrc cannot be part of the left operand for a RIGHT JOIN. ** (Is there some way to relax this constraint?) ** ** (4) If pSrc is the right operand of a LEFT JOIN, then... ** (4a) pExpr must come from an ON clause.. ** (4b) and specifically the ON clause associated with the LEFT JOIN. ** |
︙ | |||
115544 115545 115546 115547 115548 115549 115550 115551 | 115606 115607 115608 115609 115610 115611 115612 115613 115614 115615 115616 115617 115618 115619 115620 115621 115622 115623 115624 115625 115626 115627 115628 115629 115630 115631 115632 115633 115634 115635 115636 115637 115638 115639 115640 115641 115642 115643 115644 115645 115646 115647 115648 115649 115650 | + + + - + - + + + + + - + - | ** or NULL value - then the VDBE currently being prepared is configured ** to re-prepare each time a new value is bound to variable pVar. ** ** Additionally, if pExpr is a simple SQL value and the value is the ** same as that currently bound to variable pVar, non-zero is returned. ** Otherwise, if the values are not the same or if pExpr is not a simple ** SQL value, zero is returned. ** ** If the SQLITE_EnableQPSG flag is set on the database connection, then ** this routine always returns false. */ |
︙ | |||
115594 115595 115596 115597 115598 115599 115600 | 115662 115663 115664 115665 115666 115667 115668 115669 115670 115671 115672 115673 115674 115675 115676 115677 115678 115679 115680 115681 115682 115683 115684 115685 115686 115687 115688 115689 115690 115691 115692 | - - - + + + - - - + - - + + | ** returns 2, then you do not really know for certain if the two ** expressions are the same. But if you get a 0 or 1 return, then you ** can be sure the expressions are the same. In the places where ** this routine is used, it does not hurt to get an extra 2 - that ** just might result in some slightly slower code. But returning ** an incorrect 0 or 1 could lead to a malfunction. ** |
︙ | |||
115806 115807 115808 115809 115810 115811 115812 115813 115814 115815 115816 115817 115818 | 115872 115873 115874 115875 115876 115877 115878 115879 115880 115881 115882 115883 115884 115885 115886 115887 115888 115889 115890 115891 115892 115893 115894 115895 115896 115897 115898 115899 115900 115901 115902 115903 115904 115905 115906 115907 115908 115909 115910 115911 115912 115913 115914 115915 115916 115917 115918 115919 115920 115921 115922 115923 115924 115925 115926 115927 115928 115929 115930 115931 115932 115933 115934 115935 115936 115937 115938 115939 115940 115941 115942 115943 115944 115945 115946 115947 115948 115949 115950 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + | case TK_BITNOT: case TK_NOT: { return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1); } } return 0; } /* ** Return true if the boolean value of the expression is always either ** FALSE or NULL. */ static int sqlite3ExprIsNotTrue(Expr *pExpr){ int v; if( pExpr->op==TK_NULL ) return 1; if( pExpr->op==TK_TRUEFALSE && sqlite3ExprTruthValue(pExpr)==0 ) return 1; v = 1; if( sqlite3ExprIsInteger(pExpr, &v, 0) && v==0 ) return 1; return 0; } /* ** Return true if the expression is one of the following: ** ** CASE WHEN x THEN y END ** CASE WHEN x THEN y ELSE NULL END ** CASE WHEN x THEN y ELSE false END ** iif(x,y) ** iif(x,y,NULL) ** iif(x,y,false) */ static int sqlite3ExprIsIIF(sqlite3 *db, const Expr *pExpr){ ExprList *pList; if( pExpr->op==TK_FUNCTION ){ const char *z = pExpr->u.zToken; FuncDef *pDef; if( (z[0]!='i' && z[0]!='I') ) return 0; if( pExpr->x.pList==0 ) return 0; pDef = sqlite3FindFunction(db, z, pExpr->x.pList->nExpr, ENC(db), 0); #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION if( pDef==0 ) return 0; #else if( NEVER(pDef==0) ) return 0; #endif if( (pDef->funcFlags & SQLITE_FUNC_INLINE)==0 ) return 0; if( SQLITE_PTR_TO_INT(pDef->pUserData)!=INLINEFUNC_iif ) return 0; }else if( pExpr->op==TK_CASE ){ if( pExpr->pLeft!=0 ) return 0; }else{ return 0; } pList = pExpr->x.pList; assert( pList!=0 ); if( pList->nExpr==2 ) return 1; if( pList->nExpr==3 && sqlite3ExprIsNotTrue(pList->a[2].pExpr) ) return 1; return 0; } /* ** Return true if we can prove the pE2 will always be true if pE1 is ** true. Return false if we cannot complete the proof or if pE2 might ** be false. Examples: ** |
︙ | |||
115852 115853 115854 115855 115856 115857 115858 115859 115860 115861 115862 115863 115864 115865 | 115970 115971 115972 115973 115974 115975 115976 115977 115978 115979 115980 115981 115982 115983 115984 115985 115986 | + + + | return 1; } if( pE2->op==TK_NOTNULL && exprImpliesNotNull(pParse, pE1, pE2->pLeft, iTab, 0) ){ return 1; } if( sqlite3ExprIsIIF(pParse->db, pE1) ){ return sqlite3ExprImpliesExpr(pParse,pE1->x.pList->a[0].pExpr,pE2,iTab); } return 0; } /* This is a helper function to impliesNotNullRow(). In this routine, ** set pWalker->eCode to one only if *both* of the input expressions ** separately have the implies-not-null-row property. */ |
︙ | |||
121263 121264 121265 121266 121267 121268 121269 | 121384 121385 121386 121387 121388 121389 121390 121391 121392 121393 121394 121395 121396 121397 | - - - - - - - - - | db->mDbFlags &= ~(DBFLAG_SchemaKnownOk); if( !REOPEN_AS_MEMDB(db) ){ rc = sqlite3Init(db, &zErrDyn); } sqlite3BtreeLeaveAll(db); assert( zErrDyn==0 || rc!=SQLITE_OK ); } |
︙ | |||
121769 121770 121771 121772 121773 121774 121775 | 121881 121882 121883 121884 121885 121886 121887 121888 121889 121890 121891 121892 121893 121894 121895 | - + - - - - | int iDb /* Index of containing database. */ ){ sqlite3 *db = pParse->db; /* Database handle */ char *zDb = db->aDb[iDb].zDbSName; /* Schema name of attached database */ int rc; /* Auth callback return code */ if( db->init.busy ) return SQLITE_OK; |
︙ | |||
121880 121881 121882 121883 121884 121885 121886 | 121988 121989 121990 121991 121992 121993 121994 121995 121996 121997 121998 121999 122000 122001 122002 | - + - - - - | ** The following testcase() macros show that any of the 3rd through 6th ** parameters can be either NULL or a string. */ testcase( zArg1==0 ); testcase( zArg2==0 ); testcase( zArg3==0 ); testcase( pParse->zAuthContext==0 ); |
︙ | |||
122117 122118 122119 122120 122121 122122 122123 | 122221 122222 122223 122224 122225 122226 122227 122228 122229 122230 122231 122232 122233 122234 | - - - - - - - - - - - | sqlite3VdbeAddOp2(v, OP_Next, pReturning->iRetCur, addrRewind+1); VdbeCoverage(v); sqlite3VdbeJumpHere(v, addrRewind); } } sqlite3VdbeAddOp0(v, OP_Halt); |
︙ | |||
122256 122257 122258 122259 122260 122261 122262 | 122349 122350 122351 122352 122353 122354 122355 122356 122357 122358 122359 122360 122361 122362 122363 122364 122365 122366 122367 122368 122369 122370 122371 122372 122373 122374 122375 122376 122377 122378 122379 122380 | - - - - - - - - - - - - - - - - - | sqlite3RunParser(pParse, zSql); db->mDbFlags = savedDbFlags; sqlite3DbFree(db, zSql); memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ); pParse->nested--; } |
︙ | |||
125949 125950 125951 125952 125953 125954 125955 | 126025 126026 126027 126028 126029 126030 126031 126032 126033 126034 126035 126036 126037 126038 | - - - | } pDb = &db->aDb[iDb]; assert( pTab!=0 ); if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 && db->init.busy==0 && pTblName!=0 |
︙ | |||
129659 129660 129661 129662 129663 129664 129665 | 129732 129733 129734 129735 129736 129737 129738 129739 129740 129741 129742 129743 129744 129745 129746 129747 129748 129749 129750 129751 129752 129753 129754 | - - + | sqlite3_value **argv ){ const unsigned char *z; const unsigned char *z2; int len; int p0type; i64 p1, p2; |
︙ | |||
129693 129694 129695 129696 129697 129698 129699 | 129765 129766 129767 129768 129769 129770 129771 129772 129773 129774 129775 129776 129777 129778 129779 129780 129781 129782 129783 129784 129785 129786 129787 129788 129789 129790 129791 129792 129793 129794 129795 129796 129797 129798 129799 129800 129801 129802 129803 129804 129805 129806 129807 129808 129809 129810 129811 129812 129813 129814 129815 129816 129817 129818 129819 129820 129821 129822 129823 129824 129825 129826 129827 129828 129829 129830 129831 129832 129833 129834 129835 129836 129837 129838 129839 129840 129841 129842 129843 129844 129845 129846 129847 129848 129849 129850 129851 129852 129853 129854 | - + - - - - + + + - + - + - + - - - - + + + + + - + + + - + - + - + - + | ** as substr(X,1,N) - it returns the first N characters of X. This ** is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8] ** from 2009-02-02 for compatibility of applications that exploited the ** old buggy behavior. */ if( p1==0 ) p1 = 1; /* <rdar://problem/6778339> */ #endif if( argc==3 ){ |
︙ | |||
131983 131984 131985 131986 131987 131988 131989 | 132057 132058 132059 132060 132061 132062 132063 132064 132065 132066 132067 132068 132069 132070 | - - - | #ifdef SQLITE_SOUNDEX FUNCTION(soundex, 1, 0, 0, soundexFunc ), #endif #ifndef SQLITE_OMIT_LOAD_EXTENSION SFUNCTION(load_extension, 1, 0, 0, loadExt ), SFUNCTION(load_extension, 2, 0, 0, loadExt ), #endif |
︙ | |||
132122 132123 132124 132125 132126 132127 132128 132129 132130 132131 132132 132133 132134 132135 132136 | 132193 132194 132195 132196 132197 132198 132199 132200 132201 132202 132203 132204 132205 132206 132207 132208 132209 132210 | + + + | MFUNCTION(sqrt, 1, sqrt, math1Func ), MFUNCTION(radians, 1, degToRad, math1Func ), MFUNCTION(degrees, 1, radToDeg, math1Func ), MFUNCTION(pi, 0, 0, piFunc ), #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */ FUNCTION(sign, 1, 0, 0, signFunc ), INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ), INLINE_FUNC(iif, 2, INLINEFUNC_iif, 0 ), INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ), INLINE_FUNC(if, 2, INLINEFUNC_iif, 0 ), INLINE_FUNC(if, 3, INLINEFUNC_iif, 0 ), }; #ifndef SQLITE_OMIT_ALTERTABLE sqlite3AlterFunctions(); #endif sqlite3WindowFunctions(); sqlite3RegisterDateTimeFunctions(); sqlite3RegisterJsonFunctions(); |
︙ | |||
140635 140636 140637 140638 140639 140640 140641 | 140709 140710 140711 140712 140713 140714 140715 140716 140717 140718 140719 140720 140721 140722 | - - - - - - | }else{ u64 mask = pPragma->iArg; /* Mask of bits to set or clear. */ if( db->autoCommit==0 ){ /* Foreign key support may not be enabled or disabled while not ** in auto-commit mode. */ mask &= ~(SQLITE_ForeignKeys); } |
︙ | |||
140776 140777 140778 140779 140780 140781 140782 | 140844 140845 140846 140847 140848 140849 140850 140851 140852 140853 140854 140855 140856 140857 140858 140859 | + - + | Table *pTab; if( k==0 ){ initNCol = 0; break; } pTab = sqliteHashData(k); if( pTab->nCol==0 ){ char *zSql = sqlite3MPrintf(db, "SELECT*FROM\"%w\"", pTab->zName); if( zSql ){ sqlite3_stmt *pDummy = 0; (void)sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_DONT_LOG, |
︙ | |||
141257 141258 141259 141260 141261 141262 141263 | 141326 141327 141328 141329 141330 141331 141332 141333 141334 141335 141336 141337 141338 141339 141340 | - + | /* Make sure sufficient number of registers have been allocated */ sqlite3TouchRegister(pParse, 8+cnt); sqlite3VdbeAddOp3(v, OP_Null, 0, 8, 8+cnt); sqlite3ClearTempRegCache(pParse); /* Do the b-tree integrity checks */ sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY); |
︙ | |||
142877 142878 142879 142880 142881 142882 142883 | 142946 142947 142948 142949 142950 142951 142952 142953 142954 142955 142956 142957 142958 142959 142960 | - - - - - - - + - | #ifndef SQLITE_OMIT_UTF16 /* If opening the main database, set ENC(db). */ encoding = (u8)meta[BTREE_TEXT_ENCODING-1] & 3; if( encoding==0 ) encoding = SQLITE_UTF8; #else encoding = SQLITE_UTF8; #endif |
︙ | |||
147582 147583 147584 147585 147586 147587 147588 147589 147590 147591 147592 147593 147594 | 147644 147645 147646 147647 147648 147649 147650 147651 147652 147653 147654 147655 147656 147657 147658 147659 147660 147661 147662 147663 147664 147665 147666 147667 147668 147669 147670 147671 147672 147673 147674 147675 147676 147677 147678 147679 147680 147681 147682 147683 | + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - | if( db->mallocFailed ){ sqlite3ExprDelete(db, pNew); return pExpr; } if( pSubst->isOuterJoin ){ ExprSetProperty(pNew, EP_CanBeNull); } if( pNew->op==TK_TRUEFALSE ){ pNew->u.iValue = sqlite3ExprTruthValue(pNew); pNew->op = TK_INTEGER; ExprSetProperty(pNew, EP_IntValue); } /* Ensure that the expression now has an implicit collation sequence, ** just as it did when it was a column of a view or sub-query. */ { CollSeq *pNat = sqlite3ExprCollSeq(pSubst->pParse, pNew); CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pSubst->pCList->a[iColumn].pExpr ); if( pNat!=pColl || (pNew->op!=TK_COLUMN && pNew->op!=TK_COLLATE) ){ pNew = sqlite3ExprAddCollateString(pSubst->pParse, pNew, (pColl ? pColl->zName : "BINARY") ); } } ExprClearProperty(pNew, EP_Collate); if( ExprHasProperty(pExpr,EP_OuterON|EP_InnerON) ){ sqlite3SetJoinExpr(pNew, pExpr->w.iJoin, pExpr->flags & (EP_OuterON|EP_InnerON)); } sqlite3ExprDelete(db, pExpr); pExpr = pNew; |
︙ | |||
148344 148345 148346 148347 148348 148349 148350 148351 148352 148353 148354 148355 148356 148357 148358 148359 | 148406 148407 148408 148409 148410 148411 148412 148413 148414 148415 148416 148417 148418 148419 148420 148421 148422 148423 148424 148425 148426 148427 148428 148429 | + - | if( pSrc==0 ) break; pParent->pSrc = pSrc; } /* Transfer the FROM clause terms from the subquery into the ** outer query. */ iNewParent = pSubSrc->a[0].iCursor; for(i=0; i<nSubSrc; i++){ SrcItem *pItem = &pSrc->a[i+iFrom]; assert( pItem->fg.isTabFunc==0 ); assert( pItem->fg.isSubquery || pItem->fg.fixedSchema || pItem->u4.zDatabase==0 ); if( pItem->fg.isUsing ) sqlite3IdListDelete(db, pItem->u3.pUsing); *pItem = pSubSrc->a[i]; pItem->fg.jointype |= ltorj; |
︙ | |||
148393 148394 148395 148396 148397 148398 148399 148400 148401 148402 148403 148404 148405 148406 | 148455 148456 148457 148458 148459 148460 148461 148462 148463 148464 148465 148466 148467 148468 148469 | + | assert( pParent->pOrderBy==0 ); pParent->pOrderBy = pOrderBy; pSub->pOrderBy = 0; } pWhere = pSub->pWhere; pSub->pWhere = 0; if( isOuterJoin>0 ){ assert( pSubSrc->nSrc==1 ); sqlite3SetJoinExpr(pWhere, iNewParent, EP_OuterON); } if( pWhere ){ if( pParent->pWhere ){ pParent->pWhere = sqlite3PExpr(pParse, TK_AND, pWhere, pParent->pWhere); }else{ pParent->pWhere = pWhere; |
︙ | |||
150496 150497 150498 150499 150500 150501 150502 | 150559 150560 150561 150562 150563 150564 150565 150566 150567 150568 150569 150570 150571 150572 150573 | - + | sqlite3VdbeAddOp3(v, OP_Column, pF->iOBTab, iBaseCol+j, regSubtype); sqlite3VdbeAddOp2(v, OP_SetSubtype, regSubtype, regAgg+j); } sqlite3ReleaseTempReg(pParse, regSubtype); } sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
︙ | |||
150659 150660 150661 150662 150663 150664 150665 | 150722 150723 150724 150725 150726 150727 150728 150729 150730 150731 150732 150733 150734 150735 150736 | - + | } if( regHit==0 && pAggInfo->nAccumulator ) regHit = ++pParse->nMem; sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0, (char *)pColl, P4_COLLSEQ); } sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i)); sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF); |
︙ | |||
151492 151493 151494 151495 151496 151497 151498 | 151555 151556 151557 151558 151559 151560 151561 151562 151563 151564 151565 151566 151567 151568 151569 | - + | TREETRACE(0x4000,pParse,p, ("After WHERE-clause push-down into subquery %d:\n", pSub->selId)); sqlite3TreeViewSelect(0, p, 0); } #endif assert( pSubq->pSelect && (pSub->selFlags & SF_PushDown)!=0 ); }else{ |
︙ | |||
154053 154054 154055 154056 154057 154058 154059 | 154116 154117 154118 154119 154120 154121 154122 154123 154124 154125 154126 154127 154128 154129 154130 | - + | (v, "Call: %s.%s", (p->zName?p->zName:"fkey"), onErrorText(orconf))); /* Set the P5 operand of the OP_Program instruction to non-zero if ** recursive invocation of this trigger program is disallowed. Recursive ** invocation is disallowed if (a) the sub-program is really a trigger, ** not a foreign key action, and (b) the flag to enable recursive triggers ** is clear. */ |
︙ | |||
158266 158267 158268 158269 158270 158271 158272 158273 158274 158275 158276 158277 158278 158279 158280 158281 158282 | 158329 158330 158331 158332 158333 158334 158335 158336 158337 158338 158339 158340 158341 158342 158343 158344 158345 158346 158347 158348 158349 158350 158351 158352 158353 | + + + + + + + + | u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */ ); SQLITE_PRIVATE int sqlite3WhereExplainBloomFilter( const Parse *pParse, /* Parse context */ const WhereInfo *pWInfo, /* WHERE clause */ const WhereLevel *pLevel /* Bloom filter on this level */ ); SQLITE_PRIVATE void sqlite3WhereAddExplainText( Parse *pParse, /* Parse context */ int addr, SrcList *pTabList, /* Table list this loop refers to */ WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */ u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */ ); #else # define sqlite3WhereExplainOneScan(u,v,w,x) 0 # define sqlite3WhereExplainBloomFilter(u,v,w) 0 # define sqlite3WhereAddExplainText(u,v,w,x,y) #endif /* SQLITE_OMIT_EXPLAIN */ #ifdef SQLITE_ENABLE_STMT_SCANSTATUS SQLITE_PRIVATE void sqlite3WhereAddScanStatus( Vdbe *v, /* Vdbe to add scanstatus entry to */ SrcList *pSrclist, /* FROM clause pLvl reads data from */ WhereLevel *pLvl, /* Level to add scanstatus() entry for */ int addrExplain /* Address of OP_Explain (or 0) */ |
︙ | |||
158470 158471 158472 158473 158474 158475 158476 | 158541 158542 158543 158544 158545 158546 158547 158548 158549 158550 158551 158552 158553 158554 158555 158556 158557 158558 158559 158560 158561 158562 158563 158564 158565 158566 158567 158568 158569 158570 158571 158572 158573 158574 158575 158576 158577 158578 158579 158580 158581 158582 158583 158584 158585 158586 | - + - - - - - + - + - + + - + + - + + + + - | if( pLoop->wsFlags&WHERE_TOP_LIMIT ){ explainAppendTerm(pStr, pIndex, pLoop->u.btree.nTop, j, i, "<"); } sqlite3_str_append(pStr, ")", 1); } /* |
︙ | |||
158525 158526 158527 158528 158529 158530 158531 | 158596 158597 158598 158599 158600 158601 158602 158603 158604 158605 158606 158607 158608 158609 158610 | - + | if( isSearch ){ zFmt = "PRIMARY KEY"; } }else if( flags & WHERE_PARTIALIDX ){ zFmt = "AUTOMATIC PARTIAL COVERING INDEX"; }else if( flags & WHERE_AUTO_INDEX ){ zFmt = "AUTOMATIC COVERING INDEX"; |
︙ | |||
158577 158578 158579 158580 158581 158582 158583 158584 158585 | 158648 158649 158650 158651 158652 158653 158654 158655 158656 158657 158658 158659 158660 158661 158662 158663 158664 158665 158666 158667 158668 158669 158670 158671 158672 158673 158674 158675 158676 158677 158678 158679 158680 158681 158682 158683 158684 158685 158686 158687 158688 158689 158690 158691 158692 158693 158694 158695 158696 158697 158698 158699 158700 158701 158702 158703 158704 158705 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + | if( pLoop->nOut>=10 ){ sqlite3_str_appendf(&str, " (~%llu rows)", sqlite3LogEstToInt(pLoop->nOut)); }else{ sqlite3_str_append(&str, " (~1 row)", 9); } #endif #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN) zMsg = sqlite3StrAccumFinish(&str); sqlite3ExplainBreakpoint("",zMsg); #endif assert( pOp->opcode==OP_Explain ); assert( pOp->p4type==P4_DYNAMIC || pOp->p4.z==0 ); sqlite3DbFree(db, pOp->p4.z); pOp->p4type = P4_DYNAMIC; pOp->p4.z = sqlite3StrAccumFinish(&str); } } /* ** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN ** command, or if stmt_scanstatus_v2() stats are enabled, or if SQLITE_DEBUG ** was defined at compile-time. If it is not a no-op, a single OP_Explain ** opcode is added to the output to describe the table scan strategy in pLevel. ** ** If an OP_Explain opcode is added to the VM, its address is returned. ** Otherwise, if no OP_Explain is coded, zero is returned. */ SQLITE_PRIVATE int sqlite3WhereExplainOneScan( Parse *pParse, /* Parse context */ SrcList *pTabList, /* Table list this loop refers to */ WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */ u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */ ){ int ret = 0; #if !defined(SQLITE_DEBUG) if( sqlite3ParseToplevel(pParse)->explain==2 || IS_STMT_SCANSTATUS(pParse->db) ) #endif { if( (pLevel->pWLoop->wsFlags & WHERE_MULTI_OR)==0 && (wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){ Vdbe *v = pParse->pVdbe; int addr = sqlite3VdbeCurrentAddr(v); |
︙ | |||
158680 158681 158682 158683 158684 158685 158686 158687 158688 | 158790 158791 158792 158793 158794 158795 158796 158797 158798 158799 158800 158801 158802 158803 158804 158805 158806 158807 | + - + | sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iTabCur); } if( wsFlags & WHERE_INDEXED ){ sqlite3VdbeScanStatusRange(v, addrExplain, -1, pLvl->iIdxCur); } }else{ int addr; VdbeOp *pOp; assert( pSrclist->a[pLvl->iFrom].fg.isSubquery ); addr = pSrclist->a[pLvl->iFrom].u4.pSubq->addrFillSub; |
︙ | |||
158935 158936 158937 158938 158939 158940 158941 158942 158943 158944 158945 158946 158947 158948 | 159046 159047 159048 159049 159050 159051 159052 159053 159054 159055 159056 159057 159058 159059 159060 | + | } sqlite3ExprListDelete(db, pOrigRhs); if( pOrigLhs ){ sqlite3ExprListDelete(db, pOrigLhs); pNew->pLeft->x.pList = pLhs; } pSelect->pEList = pRhs; pSelect->selId = ++pParse->nSelect; /* Req'd for SubrtnSig validity */ if( pLhs && pLhs->nExpr==1 ){ /* Take care here not to generate a TK_VECTOR containing only a ** single value. Since the parser never creates such a vector, some ** of the subroutines do not handle this case. */ Expr *p = pLhs->a[0].pExpr; pLhs->a[0].pExpr = 0; sqlite3ExprDelete(db, pNew->pLeft); |
︙ | |||
164007 164008 164009 164010 164011 164012 164013 | 164119 164120 164121 164122 164123 164124 164125 164126 164127 164128 164129 164130 164131 164132 164133 | - + | testcase( ExprHasProperty(pTerm->pExpr, EP_InnerON) ); if( !ExprHasProperty(pTerm->pExpr, EP_OuterON|EP_InnerON) || pTerm->pExpr->w.iJoin != pSrc->iCursor ){ return 0; } if( (pSrc->fg.jointype & (JT_LEFT|JT_RIGHT))!=0 |
︙ | |||
165500 165501 165502 165503 165504 165505 165506 | 165612 165613 165614 165615 165616 165617 165618 165619 165620 165621 165622 165623 165624 165625 165626 | - + | } assert( pBuilder->nRecValid==nRecValid ); return rc; } #endif /* SQLITE_ENABLE_STAT4 */ |
︙ | |||
165543 165544 165545 165546 165547 165548 165549 165550 165551 165552 165553 165554 165555 165556 | 165655 165656 165657 165658 165659 165660 165661 165662 165663 165664 165665 165666 165667 165668 165669 165670 165671 | + + + | } if( pTerm->iParent>=0 ){ sqlite3DebugPrintf(" iParent=%d", pTerm->iParent); } sqlite3DebugPrintf("\n"); sqlite3TreeViewExpr(0, pTerm->pExpr, 0); } } SQLITE_PRIVATE void sqlite3ShowWhereTerm(WhereTerm *pTerm){ sqlite3WhereTermPrint(pTerm, 0); } #endif #ifdef WHERETRACE_ENABLED /* ** Show the complete content of a WhereClause */ |
︙ | |||
165751 165752 165753 165754 165755 165756 165757 | 165866 165867 165868 165869 165870 165871 165872 165873 165874 165875 165876 165877 165878 165879 165880 | - + | /* ** Return TRUE if X is a proper subset of Y but is of equal or less cost. ** In other words, return true if all constraints of X are also part of Y ** and Y has additional constraints that might speed the search that X lacks ** but the cost of running X is not more than the cost of running Y. ** |
︙ | |||
166729 166730 166731 166732 166733 166734 166735 | 166844 166845 166846 166847 166848 166849 166850 166851 166852 166853 166854 166855 166856 166857 | - | if( jointype & JT_LTORJ ) return 0; pParse = pWC->pWInfo->pParse; while( pWhere->op==TK_AND ){ if( !whereUsablePartialIndex(iTab,jointype,pWC,pWhere->pLeft) ) return 0; pWhere = pWhere->pRight; } |
︙ | |||
169390 169391 169392 169393 169394 169395 169396 | 169504 169505 169506 169507 169508 169509 169510 169511 169512 169513 169514 169515 169516 169517 169518 | - + | || pTerm->pExpr->w.iJoin!=pItem->iCursor ){ break; } } if( hasRightJoin && ExprHasProperty(pTerm->pExpr, EP_InnerON) |
︙ | |||
170310 170311 170312 170313 170314 170315 170316 170317 170318 170319 170320 170321 170322 170323 | 170424 170425 170426 170427 170428 170429 170430 170431 170432 170433 170434 170435 170436 170437 170438 | + | static void sqlite3WhereOpcodeRewriteTrace( sqlite3 *db, int pc, VdbeOp *pOp ){ if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return; sqlite3VdbePrintOp(0, pc, pOp); sqlite3ShowWhereTerm(0); /* So compiler won't complain about unused func */ } #endif /* ** Generate the end of the WHERE loop. See comments on ** sqlite3WhereBegin() for additional information. */ |
︙ | |||
170609 170610 170611 170612 170613 170614 170615 | 170724 170725 170726 170727 170728 170729 170730 170731 170732 170733 170734 170735 170736 170737 170738 170739 170740 170741 170742 170743 170744 170745 170746 170747 170748 170749 170750 170751 170752 170753 170754 170755 170756 170757 170758 170759 | - + - - - - + + + + + + + + + + + + + + + + + + | x = sqlite3StorageColumnToTable(pTab,x); } x = sqlite3TableColumnToIndex(pIdx, x); if( x>=0 ){ pOp->p2 = x; pOp->p1 = pLevel->iIdxCur; OpcodeRewriteTrace(db, k, pOp); |
︙ | |||
172324 172325 172326 172327 172328 172329 172330 172331 172332 172333 172334 172335 172336 172337 172338 172339 172340 172341 172342 172343 172344 172345 172346 172347 172348 172349 172350 172351 172352 172353 172354 172355 172356 172357 172358 172359 172360 172361 172362 172363 172364 172365 172366 172367 172368 172369 172370 172371 | 172453 172454 172455 172456 172457 172458 172459 172460 172461 172462 172463 172464 172465 172466 172467 172468 172469 172470 172471 172472 172473 172474 172475 172476 172477 172478 172479 172480 172481 172482 172483 172484 172485 172486 172487 172488 172489 172490 172491 172492 172493 172494 172495 172496 172497 172498 172499 172500 172501 172502 172503 172504 172505 172506 172507 172508 172509 172510 172511 172512 172513 172514 172515 172516 172517 172518 172519 172520 172521 | + + + + + + + + + + + + + + - - - - - - - - - - - - - | Vdbe *v = sqlite3GetVdbe(pParse); Window *pWin; for(pWin=pMWin; pWin; pWin=pWin->pNextWin){ FuncDef *pFunc = pWin->pWFunc; int regArg; int nArg = pWin->bExprArgs ? 0 : windowArgCount(pWin); int i; int addrIf = 0; assert( bInverse==0 || pWin->eStart!=TK_UNBOUNDED ); /* All OVER clauses in the same window function aggregate step must ** be the same. */ assert( pWin==pMWin || sqlite3WindowCompare(pParse,pWin,pMWin,0)!=1 ); for(i=0; i<nArg; i++){ if( i!=1 || pFunc->zName!=nth_valueName ){ sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+i, reg+i); }else{ sqlite3VdbeAddOp3(v, OP_Column, pMWin->iEphCsr, pWin->iArgCol+i, reg+i); } } regArg = reg; if( pWin->pFilter ){ int regTmp; assert( ExprUseXList(pWin->pOwner) ); assert( pWin->bExprArgs || !nArg ||nArg==pWin->pOwner->x.pList->nExpr ); assert( pWin->bExprArgs || nArg ||pWin->pOwner->x.pList==0 ); regTmp = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp3(v, OP_Column, csr, pWin->iArgCol+nArg,regTmp); addrIf = sqlite3VdbeAddOp3(v, OP_IfNot, regTmp, 0, 1); VdbeCoverage(v); sqlite3ReleaseTempReg(pParse, regTmp); } if( pMWin->regStartRowid==0 && (pFunc->funcFlags & SQLITE_FUNC_MINMAX) && (pWin->eStart!=TK_UNBOUNDED) ){ int addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, regArg); VdbeCoverage(v); if( bInverse==0 ){ sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1, 1); sqlite3VdbeAddOp2(v, OP_SCopy, regArg, pWin->regApp); sqlite3VdbeAddOp3(v, OP_MakeRecord, pWin->regApp, 2, pWin->regApp+2); sqlite3VdbeAddOp2(v, OP_IdxInsert, pWin->csrApp, pWin->regApp+2); }else{ sqlite3VdbeAddOp4Int(v, OP_SeekGE, pWin->csrApp, 0, regArg, 1); VdbeCoverageNeverTaken(v); sqlite3VdbeAddOp1(v, OP_Delete, pWin->csrApp); sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2); } sqlite3VdbeJumpHere(v, addrIsNull); }else if( pWin->regApp ){ assert( pWin->pFilter==0 ); assert( pFunc->zName==nth_valueName || pFunc->zName==first_valueName ); assert( bInverse==0 || bInverse==1 ); sqlite3VdbeAddOp2(v, OP_AddImm, pWin->regApp+1-bInverse, 1); }else if( pFunc->xSFunc!=noopStepFunc ){ |
︙ | |||
172404 172405 172406 172407 172408 172409 172410 | 172534 172535 172536 172537 172538 172539 172540 172541 172542 172543 172544 172545 172546 172547 172548 172549 172550 172551 172552 172553 172554 | - + - + + | assert( ExprUseXList(pWin->pOwner) ); pColl = sqlite3ExprNNCollSeq(pParse, pWin->pOwner->x.pList->a[0].pExpr); sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ); } sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep, bInverse, regArg, pWin->regAccum); sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF); |
︙ | |||
173835 173836 173837 173838 173839 173840 173841 173842 173843 173844 173845 173846 173847 173848 | 173966 173967 173968 173969 173970 173971 173972 173973 173974 173975 173976 173977 173978 173979 173980 173981 173982 173983 173984 173985 173986 | + + + + + + + | ** UPDATE ON (a,b,c) ** ** Then the "b" IdList records the list "a,b,c". */ struct TrigEvent { int a; IdList * b; }; struct FrameBound { int eType; Expr *pExpr; }; /* ** Generate a syntax error */ static void parserSyntaxError(Parse *pParse, Token *p){ sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", p); } /* ** Disable lookaside memory allocation for objects that might be ** shared across database connections. */ static void disableLookaside(Parse *pParse){ sqlite3 *db = pParse->db; |
︙ | |||
177728 177729 177730 177731 177732 177733 177734 | 177866 177867 177868 177869 177870 177871 177872 177873 177874 177875 177876 177877 177878 177879 177880 177881 177882 177883 177884 | + + + - + + | { sqlite3DropTable(pParse, yymsp[0].minor.yy203, 1, yymsp[-1].minor.yy144); } break; case 84: /* cmd ::= select */ { SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0}; if( (pParse->db->mDbFlags & DBFLAG_EncodingFixed)!=0 || sqlite3ReadSchema(pParse)==SQLITE_OK ){ |
︙ | |||
178199 178200 178201 178202 178203 178204 178205 | 178341 178342 178343 178344 178345 178346 178347 178348 178349 178350 178351 178352 178353 178354 178355 | - + | }else{ /* When doing a nested parse, one can include terms in an expression ** that look like this: #1 #2 ... These terms refer to registers ** in the virtual machine. #N is the N-th register. */ Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/ assert( t.n>=2 ); if( pParse->nested==0 ){ |
︙ | |||
179047 179048 179049 179050 179051 179052 179053 | 179189 179190 179191 179192 179193 179194 179195 179196 179197 179198 179199 179200 179201 179202 179203 | - + | sqlite3ParserARG_FETCH sqlite3ParserCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ if( TOKEN.z[0] ){ |
︙ | |||
180538 180539 180540 180541 180542 180543 180544 | 180680 180681 180682 180683 180684 180685 180686 180687 180688 180689 180690 180691 180692 180693 180694 180695 180696 | + - + + | if( db->mallocFailed ){ pParse->rc = SQLITE_NOMEM_BKPT; } if( pParse->zErrMsg || (pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE) ){ if( pParse->zErrMsg==0 ){ pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc)); } if( (pParse->prepFlags & SQLITE_PREPARE_DONT_LOG)==0 ){ |
︙ | |||
182511 182512 182513 182514 182515 182516 182517 | 182655 182656 182657 182658 182659 182660 182661 182662 182663 182664 182665 182666 182667 182668 | - - - - | } sqlite3HashClear(&db->aModule); #endif sqlite3Error(db, SQLITE_OK); /* Deallocates any cached error strings. */ sqlite3ValueFree(db->pErr); sqlite3CloseExtensions(db); |
︙ | |||
183949 183950 183951 183952 183953 183954 183955 | 184089 184090 184091 184092 184093 184094 184095 184096 184097 184098 184099 184100 184101 184102 184103 184104 | - - + + | #endif #if SQLITE_MAX_COMPOUND_SELECT<2 # error SQLITE_MAX_COMPOUND_SELECT must be at least 2 #endif #if SQLITE_MAX_VDBE_OP<40 # error SQLITE_MAX_VDBE_OP must be at least 40 #endif |
︙ | |||
184017 184018 184019 184020 184021 184022 184023 | 184157 184158 184159 184160 184161 184162 184163 184164 184165 184166 184167 184168 184169 184170 184171 184172 | - - + + | if( limitId<0 || limitId>=SQLITE_N_LIMIT ){ return -1; } oldLimit = db->aLimit[limitId]; if( newLimit>=0 ){ /* IMP: R-52476-28732 */ if( newLimit>aHardLimit[limitId] ){ newLimit = aHardLimit[limitId]; /* IMP: R-51463-25634 */ |
︙ | |||
185362 185363 185364 185365 185366 185367 185368 | 185502 185503 185504 185505 185506 185507 185508 185509 185510 185511 185512 185513 185514 185515 | - | volatile int x = 0; assert( /*side-effects-ok*/ (x = va_arg(ap,int))!=0 ); rc = x; #if defined(SQLITE_DEBUG) /* Invoke these debugging routines so that the compiler does not ** issue "defined but not used" warnings. */ if( x==9999 ){ |
︙ | |||
189794 189795 189796 189797 189798 189799 189800 189801 189802 189803 189804 189805 189806 189807 189808 189809 189810 189811 | 189933 189934 189935 189936 189937 189938 189939 189940 189941 189942 189943 189944 189945 189946 189947 189948 189949 189950 189951 189952 189953 189954 189955 | + + + + + | /* Never set both isSaveLeft and isExact for the same invocation. */ assert( isSaveLeft==0 || isExact==0 ); assert_fts3_nc( p!=0 && *p1!=0 && *p2!=0 ); if( *p1==POS_COLUMN ){ p1++; p1 += fts3GetVarint32(p1, &iCol1); /* iCol1==0 indicates corruption. Column 0 does not have a POS_COLUMN ** entry, so this is actually end-of-doclist. */ if( iCol1==0 ) return 0; } if( *p2==POS_COLUMN ){ p2++; p2 += fts3GetVarint32(p2, &iCol2); /* As above, iCol2==0 indicates corruption. */ if( iCol2==0 ) return 0; } while( 1 ){ if( iCol1==iCol2 ){ char *pSave = p; sqlite3_int64 iPrev = 0; sqlite3_int64 iPos1 = 0; |
︙ | |||
192968 192969 192970 192971 192972 192973 192974 | 193112 193113 193114 193115 193116 193117 193118 193119 193120 193121 193122 193123 193124 193125 193126 | - + | /* Allocate temporary working space. */ for(p=pExpr; p->pLeft; p=p->pLeft){ assert( p->pRight->pPhrase->doclist.nList>0 ); nTmp += p->pRight->pPhrase->doclist.nList; } nTmp += p->pPhrase->doclist.nList; |
︙ | |||
193619 193620 193621 193622 193623 193624 193625 | 193763 193764 193765 193766 193767 193768 193769 193770 193771 193772 193773 193774 193775 193776 193777 | - + | */ #ifdef SQLITE_DEBUG SQLITE_PRIVATE int sqlite3Fts3Corrupt(){ return SQLITE_CORRUPT_VTAB; } #endif |
︙ | |||
194521 194522 194523 194524 194525 194526 194527 | 194665 194666 194667 194668 194669 194670 194671 194672 194673 194674 194675 194676 194677 194678 194679 194680 194681 194682 194683 194684 194685 194686 194687 194688 194689 194690 194691 194692 194693 194694 194695 194696 194697 194698 194699 194700 194701 194702 194703 194704 194705 194706 194707 194708 194709 194710 194711 194712 194713 194714 194715 194716 194717 194718 194719 194720 194721 194722 194723 194724 194725 194726 194727 194728 194729 194730 194731 194732 194733 194734 194735 194736 194737 194738 | - - - + + + + - - - - + + + + + - - - - - - - + + - - - + + + + + | const char *zByte; int nByte = 0, iBegin = 0, iEnd = 0, iPos = 0; rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos); if( rc==SQLITE_OK ){ Fts3PhraseToken *pToken; p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken)); |
︙ | |||
215393 215394 215395 215396 215397 215398 215399 | 215536 215537 215538 215539 215540 215541 215542 215543 215544 215545 215546 215547 215548 215549 215550 215551 | - + | #else sqlite3_str_appendf(pOut, " %d", cell.aCoord[jj].i); #endif } sqlite3_str_append(pOut, "}", 1); } errCode = sqlite3_str_errcode(pOut); |
︙ | |||
217910 217911 217912 217913 217914 217915 217916 | 218053 218054 218055 218056 218057 218058 218059 218060 218061 218062 218063 218064 218065 218066 218067 | - + | pGeomCtx->xDestructor = xDestructor; pGeomCtx->pContext = pContext; return sqlite3_create_function_v2(db, zQueryFunc, -1, SQLITE_ANY, (void *)pGeomCtx, geomCallback, 0, 0, rtreeFreeCallback ); } |
︙ | |||
218501 218502 218503 218504 218505 218506 218507 | 218644 218645 218646 218647 218648 218649 218650 218651 218652 218653 218654 218655 218656 218657 218658 | - + | p->xFunc, 0, 0 ); } return rc; } |
︙ | |||
226175 226176 226177 226178 226179 226180 226181 226182 226183 226184 226185 226186 226187 226188 | 226318 226319 226320 226321 226322 226323 226324 226325 226326 226327 226328 226329 226330 226331 226332 226333 | + + | if( rc==SQLITE_OK ){ const void *pData = sqlite3_value_blob(argv[3]); if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){ unsigned char *aPage = sqlite3PagerGetData(pDbPage); memcpy(aPage, pData, szPage); pTab->pgnoTrunc = 0; } }else{ pTab->pgnoTrunc = 0; } sqlite3PagerUnref(pDbPage); return rc; update_fail: sqlite3_free(pVtab->zErrMsg); pVtab->zErrMsg = sqlite3_mprintf("%s", zErr); |
︙ | |||
226208 226209 226210 226211 226212 226213 226214 | 226353 226354 226355 226356 226357 226358 226359 226360 226361 226362 226363 226364 226365 226366 226367 226368 226369 226370 226371 | + + - + + + | /* Invoke sqlite3PagerTruncate() as necessary, just prior to COMMIT */ static int dbpageSync(sqlite3_vtab *pVtab){ DbpageTable *pTab = (DbpageTable *)pVtab; if( pTab->pgnoTrunc>0 ){ Btree *pBt = pTab->db->aDb[pTab->iDbTrunc].pBt; Pager *pPager = sqlite3BtreePager(pBt); sqlite3BtreeEnter(pBt); if( pTab->pgnoTrunc<sqlite3BtreeLastPage(pBt) ){ |
︙ | |||
232802 232803 232804 232805 232806 232807 232808 | 232951 232952 232953 232954 232955 232956 232957 232958 232959 232960 232961 232962 232963 232964 232965 232966 232967 232968 232969 232970 232971 232972 232973 232974 232975 232976 232977 232978 232979 232980 232981 232982 232983 232984 232985 232986 232987 232988 232989 232990 232991 232992 232993 232994 232995 232996 232997 232998 232999 233000 | - + + + + + + + + + + + + + + + + + + + + + + + + + + + | } #endif /* SQLITE_ENABLE_SESSION && SQLITE_ENABLE_PREUPDATE_HOOK */ /************** End of sqlite3session.c **************************************/ /************** Begin file fts5.c ********************************************/ |
︙ | |||
233112 233113 233114 233115 233116 233117 233118 | 233287 233288 233289 233290 233291 233292 233293 233294 233295 233296 233297 233298 233299 233300 233301 233302 233303 233304 233305 233306 233307 233308 233309 233310 233311 233312 233313 233314 233315 233316 233317 233318 233319 233320 233321 233322 | - - - + + + + + + + + + + + + + + + + + + | ** ** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken) ** This is used to access token iToken of phrase hit iIdx within the ** current row. If iIdx is less than zero or greater than or equal to the ** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, ** output variable (*ppToken) is set to point to a buffer containing the ** matching document token, and (*pnToken) to the size of that buffer in |
︙ | |||
233801 233802 233803 233804 233805 233806 233807 | 233991 233992 233993 233994 233995 233996 233997 233998 233999 234000 234001 234002 234003 234004 234005 234006 | - + + | int nAutomerge; /* 'automerge' setting */ int nCrisisMerge; /* Maximum allowed segments per level */ int nUsermerge; /* 'usermerge' setting */ int nHashSize; /* Bytes of memory for in-memory hash */ char *zRank; /* Name of rank function */ char *zRankArgs; /* Arguments to rank function */ int bSecureDelete; /* 'secure-delete' */ |
︙ | |||
234058 234059 234060 234061 234062 234063 234064 | 234249 234250 234251 234252 234253 234254 234255 234256 234257 234258 234259 234260 234261 234262 234263 234264 234265 234266 234267 234268 234269 234270 | - + + + + + + + + | static void *sqlite3Fts5StructureRef(Fts5Index*); static void sqlite3Fts5StructureRelease(void*); static int sqlite3Fts5StructureTest(Fts5Index*, void*); /* ** Used by xInstToken(): */ |
︙ | |||
238272 238273 238274 238275 238276 238277 238278 238279 238280 238281 238282 238283 238284 238285 | 238470 238471 238472 238473 238474 238475 238476 238477 238478 238479 238480 238481 238482 238483 238484 238485 238486 238487 238488 238489 238490 238491 238492 238493 238494 238495 238496 | + + + + + + + + + + + + + | bVal = sqlite3_value_int(pVal); } if( bVal<0 ){ *pbBadkey = 1; }else{ pConfig->bSecureDelete = (bVal ? 1 : 0); } } else if( 0==sqlite3_stricmp(zKey, "insttoken") ){ int bVal = -1; if( SQLITE_INTEGER==sqlite3_value_numeric_type(pVal) ){ bVal = sqlite3_value_int(pVal); } if( bVal<0 ){ *pbBadkey = 1; }else{ pConfig->bPrefixInsttoken = (bVal ? 1 : 0); } }else{ *pbBadkey = 1; } return rc; } /* |
︙ | |||
241407 241408 241409 241410 241411 241412 241413 | 241618 241619 241620 241621 241622 241623 241624 241625 241626 241627 241628 241629 241630 241631 241632 | - + | for(pT=&pExpr->apExprPhrase[i]->aTerm[0]; pT; pT=pT->pSynonym){ if( (pT->nQueryTerm==nQuery || (pT->nQueryTerm<nQuery && pT->bPrefix)) && memcmp(pT->pTerm, pToken, pT->nQueryTerm)==0 ){ int rc = sqlite3Fts5PoslistWriterAppend( &pExpr->apExprPhrase[i]->poslist, &p->aPopulator[i].writer, p->iOff ); |
︙ | |||
241600 241601 241602 241603 241604 241605 241606 | 241811 241812 241813 241814 241815 241816 241817 241818 241819 241820 241821 241822 241823 241824 241825 241826 241827 241828 241829 241830 241831 241832 | - - - - - - - - + + + + + + + + - | return SQLITE_RANGE; } pPhrase = pExpr->apExprPhrase[iPhrase]; if( iToken<0 || iToken>=pPhrase->nTerm ){ return SQLITE_RANGE; } pTerm = &pPhrase->aTerm[iToken]; |
︙ | |||
248423 248424 248425 248426 248427 248428 248429 248430 248431 248432 248433 248434 248435 248436 248437 248438 248439 | 248633 248634 248635 248636 248637 248638 248639 248640 248641 248642 248643 248644 248645 248646 248647 248648 248649 248650 248651 248652 248653 248654 248655 248656 248657 248658 248659 248660 248661 248662 248663 248664 248665 248666 248667 248668 248669 248670 248671 248672 248673 248674 248675 248676 248677 248678 248679 248680 248681 248682 248683 248684 248685 248686 248687 248688 248689 248690 248691 248692 248693 248694 248695 248696 248697 248698 248699 248700 248701 248702 248703 248704 248705 248706 248707 248708 248709 248710 248711 248712 248713 248714 248715 248716 248717 248718 248719 248720 248721 248722 248723 248724 248725 248726 248727 248728 248729 248730 248731 248732 248733 248734 248735 248736 248737 248738 248739 248740 248741 248742 248743 248744 248745 248746 248747 248748 248749 248750 248751 248752 248753 248754 248755 248756 248757 248758 248759 248760 248761 248762 248763 248764 248765 248766 248767 248768 248769 248770 248771 248772 248773 248774 248775 248776 248777 248778 248779 248780 248781 248782 248783 248784 248785 248786 248787 248788 248789 248790 248791 248792 248793 248794 248795 248796 248797 248798 248799 248800 248801 248802 248803 248804 248805 248806 248807 248808 248809 248810 248811 248812 248813 248814 248815 248816 248817 248818 248819 248820 248821 248822 248823 248824 248825 248826 248827 248828 248829 248830 248831 248832 248833 248834 248835 248836 248837 248838 248839 248840 248841 248842 248843 248844 248845 248846 248847 248848 248849 248850 248851 248852 248853 248854 248855 248856 248857 248858 248859 248860 248861 248862 248863 248864 248865 248866 248867 248868 248869 248870 248871 248872 248873 248874 248875 248876 248877 248878 248879 248880 248881 248882 248883 248884 248885 248886 248887 248888 248889 248890 248891 248892 248893 248894 248895 248896 248897 248898 248899 248900 248901 248902 248903 248904 248905 248906 248907 248908 248909 248910 248911 248912 248913 248914 248915 248916 248917 248918 248919 248920 248921 248922 248923 248924 248925 248926 248927 248928 248929 248930 248931 248932 248933 248934 248935 248936 248937 248938 248939 248940 248941 248942 248943 248944 248945 248946 248947 248948 248949 248950 248951 248952 248953 248954 248955 248956 248957 248958 248959 248960 248961 248962 248963 248964 248965 248966 248967 248968 248969 248970 248971 248972 248973 248974 248975 248976 248977 248978 248979 248980 248981 248982 248983 248984 248985 248986 248987 248988 248989 248990 248991 248992 248993 248994 248995 248996 248997 248998 248999 249000 249001 249002 249003 249004 249005 249006 249007 249008 249009 249010 249011 249012 249013 249014 249015 249016 249017 249018 249019 249020 249021 249022 249023 249024 249025 249026 249027 249028 249029 249030 249031 249032 249033 249034 249035 249036 249037 249038 249039 249040 249041 249042 249043 249044 249045 249046 249047 249048 249049 249050 249051 249052 249053 249054 249055 249056 249057 249058 249059 249060 249061 249062 249063 249064 249065 249066 249067 249068 249069 249070 249071 249072 249073 249074 249075 249076 249077 249078 249079 249080 249081 249082 249083 249084 249085 249086 249087 249088 249089 249090 249091 249092 249093 249094 249095 249096 249097 249098 249099 249100 249101 249102 249103 249104 249105 249106 249107 249108 249109 249110 249111 249112 249113 249114 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + - - - + + - - - - + + + + - + - + - + - - - - - - - - - - - + - - - - - - - - - - - - + + - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - - + + - - + + - - + + - - - + + + + + + + + + + + - + | fts5BufferFree(p1); fts5BufferFree(&tmp); memset(&out.p[out.n], 0, FTS5_DATA_ZERO_PADDING); *p1 = out; } /* ** Iterate through a range of entries in the FTS index, invoking the xVisit ** callback for each of them. ** ** Parameter pToken points to an nToken buffer containing an FTS index term ** (i.e. a document term with the preceding 1 byte index identifier - ** FTS5_MAIN_PREFIX or similar). If bPrefix is true, then the call visits ** all entries for terms that have pToken/nToken as a prefix. If bPrefix ** is false, then only entries with pToken/nToken as the entire key are ** visited. ** ** If the current table is a tokendata=1 table, then if bPrefix is true then ** each index term is treated separately. However, if bPrefix is false, then ** all index terms corresponding to pToken/nToken are collapsed into a single ** term before the callback is invoked. ** ** The callback invoked for each entry visited is specified by paramter xVisit. ** Each time it is invoked, it is passed a pointer to the Fts5Index object, ** a copy of the 7th paramter to this function (pCtx) and a pointer to the ** iterator that indicates the current entry. If the current entry is the ** first with a new term (i.e. different from that of the previous entry, ** including the very first term), then the final two parameters are passed ** a pointer to the term and its size in bytes, respectively. If the current ** entry is not the first associated with its term, these two parameters ** are passed 0. ** ** If parameter pColset is not NULL, then it is used to filter entries before ** the callback is invoked. */ static int fts5VisitEntries( Fts5Index *p, /* Fts5 index object */ Fts5Colset *pColset, /* Columns filter to apply, or NULL */ u8 *pToken, /* Buffer containing token */ int nToken, /* Size of buffer pToken in bytes */ int bPrefix, /* True for a prefix scan */ void (*xVisit)(Fts5Index*, void *pCtx, Fts5Iter *pIter, const u8*, int), void *pCtx /* Passed as second argument to xVisit() */ ){ const int flags = (bPrefix ? FTS5INDEX_QUERY_SCAN : 0) | FTS5INDEX_QUERY_SKIPEMPTY | FTS5INDEX_QUERY_NOOUTPUT; Fts5Iter *p1 = 0; /* Iterator used to gather data from index */ int bNewTerm = 1; Fts5Structure *pStruct = fts5StructureRead(p); fts5MultiIterNew(p, pStruct, flags, pColset, pToken, nToken, -1, 0, &p1); fts5IterSetOutputCb(&p->rc, p1); for( /* no-op */ ; fts5MultiIterEof(p, p1)==0; fts5MultiIterNext2(p, p1, &bNewTerm) ){ Fts5SegIter *pSeg = &p1->aSeg[ p1->aFirst[1].iFirst ]; int nNew = 0; const u8 *pNew = 0; p1->xSetOutputs(p1, pSeg); if( p->rc ) break; if( bNewTerm ){ nNew = pSeg->term.n; pNew = pSeg->term.p; if( nNew<nToken || memcmp(pToken, pNew, nToken) ) break; } xVisit(p, pCtx, p1, pNew, nNew); } fts5MultiIterFree(p1); fts5StructureRelease(pStruct); return p->rc; } /* ** Usually, a tokendata=1 iterator (struct Fts5TokenDataIter) accumulates an ** array of these for each row it visits (so all iRowid fields are the same). ** Or, for an iterator used by an "ORDER BY rank" query, it accumulates an ** array of these for the entire query (in which case iRowid fields may take ** a variety of values). ** ** Each instance in the array indicates the iterator (and therefore term) ** associated with position iPos of rowid iRowid. This is used by the ** xInstToken() API. ** ** iRowid: ** Rowid for the current entry. ** ** iPos: ** Position of current entry within row. In the usual ((iCol<<32)+iOff) ** format (e.g. see macros FTS5_POS2COLUMN() and FTS5_POS2OFFSET()). ** ** iIter: ** If the Fts5TokenDataIter iterator that the entry is part of is ** actually an iterator (i.e. with nIter>0, not just a container for ** Fts5TokenDataMap structures), then this variable is an index into ** the apIter[] array. The corresponding term is that which the iterator ** at apIter[iIter] currently points to. ** ** Or, if the Fts5TokenDataIter iterator is just a container object ** (nIter==0), then iIter is an index into the term.p[] buffer where ** the term is stored. ** ** nByte: ** In the case where iIter is an index into term.p[], this variable ** is the size of the term in bytes. If iIter is an index into apIter[], ** this variable is unused. */ struct Fts5TokenDataMap { i64 iRowid; /* Row this token is located in */ i64 iPos; /* Position of token */ int iIter; /* Iterator token was read from */ int nByte; /* Length of token in bytes (or 0) */ }; /* ** An object used to supplement Fts5Iter for tokendata=1 iterators. ** ** This object serves two purposes. The first is as a container for an array ** of Fts5TokenDataMap structures, which are used to find the token required ** when the xInstToken() API is used. This is done by the nMapAlloc, nMap and ** aMap[] variables. */ struct Fts5TokenDataIter { int nMapAlloc; /* Allocated size of aMap[] in entries */ int nMap; /* Number of valid entries in aMap[] */ Fts5TokenDataMap *aMap; /* Array of (rowid+pos -> token) mappings */ /* The following are used for prefix-queries only. */ Fts5Buffer terms; /* The following are used for other full-token tokendata queries only. */ int nIter; int nIterAlloc; Fts5PoslistReader *aPoslistReader; int *aPoslistToIter; Fts5Iter *apIter[1]; }; /* ** The two input arrays - a1[] and a2[] - are in sorted order. This function ** merges the two arrays together and writes the result to output array ** aOut[]. aOut[] is guaranteed to be large enough to hold the result. ** ** Duplicate entries are copied into the output. So the size of the output ** array is always (n1+n2) entries. */ static void fts5TokendataMerge( Fts5TokenDataMap *a1, int n1, /* Input array 1 */ Fts5TokenDataMap *a2, int n2, /* Input array 2 */ Fts5TokenDataMap *aOut /* Output array */ ){ int i1 = 0; int i2 = 0; assert( n1>=0 && n2>=0 ); while( i1<n1 || i2<n2 ){ Fts5TokenDataMap *pOut = &aOut[i1+i2]; if( i2>=n2 || (i1<n1 && ( a1[i1].iRowid<a2[i2].iRowid || (a1[i1].iRowid==a2[i2].iRowid && a1[i1].iPos<=a2[i2].iPos) ))){ memcpy(pOut, &a1[i1], sizeof(Fts5TokenDataMap)); i1++; }else{ memcpy(pOut, &a2[i2], sizeof(Fts5TokenDataMap)); i2++; } } } /* ** Append a mapping to the token-map belonging to object pT. */ static void fts5TokendataIterAppendMap( Fts5Index *p, Fts5TokenDataIter *pT, int iIter, int nByte, i64 iRowid, i64 iPos ){ if( p->rc==SQLITE_OK ){ if( pT->nMap==pT->nMapAlloc ){ int nNew = pT->nMapAlloc ? pT->nMapAlloc*2 : 64; int nAlloc = nNew * sizeof(Fts5TokenDataMap); Fts5TokenDataMap *aNew; aNew = (Fts5TokenDataMap*)sqlite3_realloc(pT->aMap, nAlloc); if( aNew==0 ){ p->rc = SQLITE_NOMEM; return; } pT->aMap = aNew; pT->nMapAlloc = nNew; } pT->aMap[pT->nMap].iRowid = iRowid; pT->aMap[pT->nMap].iPos = iPos; pT->aMap[pT->nMap].iIter = iIter; pT->aMap[pT->nMap].nByte = nByte; pT->nMap++; } } /* ** Sort the contents of the pT->aMap[] array. ** ** The sorting algorithm requries a malloc(). If this fails, an error code ** is left in Fts5Index.rc before returning. */ static void fts5TokendataIterSortMap(Fts5Index *p, Fts5TokenDataIter *pT){ Fts5TokenDataMap *aTmp = 0; int nByte = pT->nMap * sizeof(Fts5TokenDataMap); aTmp = (Fts5TokenDataMap*)sqlite3Fts5MallocZero(&p->rc, nByte); if( aTmp ){ Fts5TokenDataMap *a1 = pT->aMap; Fts5TokenDataMap *a2 = aTmp; i64 nHalf; for(nHalf=1; nHalf<pT->nMap; nHalf=nHalf*2){ int i1; for(i1=0; i1<pT->nMap; i1+=(nHalf*2)){ int n1 = MIN(nHalf, pT->nMap-i1); int n2 = MIN(nHalf, pT->nMap-i1-n1); fts5TokendataMerge(&a1[i1], n1, &a1[i1+n1], n2, &a2[i1]); } SWAPVAL(Fts5TokenDataMap*, a1, a2); } if( a1!=pT->aMap ){ memcpy(pT->aMap, a1, pT->nMap*sizeof(Fts5TokenDataMap)); } sqlite3_free(aTmp); #ifdef SQLITE_DEBUG { int ii; for(ii=1; ii<pT->nMap; ii++){ Fts5TokenDataMap *p1 = &pT->aMap[ii-1]; Fts5TokenDataMap *p2 = &pT->aMap[ii]; assert( p1->iRowid<p2->iRowid || (p1->iRowid==p2->iRowid && p1->iPos<=p2->iPos) ); } } #endif } } /* ** Delete an Fts5TokenDataIter structure and its contents. */ static void fts5TokendataIterDelete(Fts5TokenDataIter *pSet){ if( pSet ){ int ii; for(ii=0; ii<pSet->nIter; ii++){ fts5MultiIterFree(pSet->apIter[ii]); } fts5BufferFree(&pSet->terms); sqlite3_free(pSet->aPoslistReader); sqlite3_free(pSet->aMap); sqlite3_free(pSet); } } /* ** fts5VisitEntries() context object used by fts5SetupPrefixIterTokendata() ** to pass data to prefixIterSetupTokendataCb(). */ typedef struct TokendataSetupCtx TokendataSetupCtx; struct TokendataSetupCtx { Fts5TokenDataIter *pT; /* Object being populated with mappings */ int iTermOff; /* Offset of current term in terms.p[] */ int nTermByte; /* Size of current term in bytes */ }; /* ** fts5VisitEntries() callback used by fts5SetupPrefixIterTokendata(). This ** callback adds an entry to the Fts5TokenDataIter.aMap[] array for each ** position in the current position-list. It doesn't matter that some of ** these may be out of order - they will be sorted later. */ static void prefixIterSetupTokendataCb( Fts5Index *p, void *pCtx, Fts5Iter *p1, const u8 *pNew, int nNew ){ TokendataSetupCtx *pSetup = (TokendataSetupCtx*)pCtx; int iPosOff = 0; i64 iPos = 0; if( pNew ){ pSetup->nTermByte = nNew-1; pSetup->iTermOff = pSetup->pT->terms.n; fts5BufferAppendBlob(&p->rc, &pSetup->pT->terms, nNew-1, pNew+1); } while( 0==sqlite3Fts5PoslistNext64( p1->base.pData, p1->base.nData, &iPosOff, &iPos ) ){ fts5TokendataIterAppendMap(p, pSetup->pT, pSetup->iTermOff, pSetup->nTermByte, p1->base.iRowid, iPos ); } } /* ** Context object passed by fts5SetupPrefixIter() to fts5VisitEntries(). */ typedef struct PrefixSetupCtx PrefixSetupCtx; struct PrefixSetupCtx { void (*xMerge)(Fts5Index*, Fts5Buffer*, int, Fts5Buffer*); void (*xAppend)(Fts5Index*, u64, Fts5Iter*, Fts5Buffer*); i64 iLastRowid; int nMerge; Fts5Buffer *aBuf; int nBuf; Fts5Buffer doclist; TokendataSetupCtx *pTokendata; }; /* ** fts5VisitEntries() callback used by fts5SetupPrefixIter() */ static void prefixIterSetupCb( Fts5Index *p, void *pCtx, Fts5Iter *p1, const u8 *pNew, int nNew ){ PrefixSetupCtx *pSetup = (PrefixSetupCtx*)pCtx; const int nMerge = pSetup->nMerge; if( p1->base.nData>0 ){ if( p1->base.iRowid<=pSetup->iLastRowid && pSetup->doclist.n>0 ){ int i; for(i=0; p->rc==SQLITE_OK && pSetup->doclist.n; i++){ int i1 = i*nMerge; int iStore; assert( i1+nMerge<=pSetup->nBuf ); for(iStore=i1; iStore<i1+nMerge; iStore++){ if( pSetup->aBuf[iStore].n==0 ){ fts5BufferSwap(&pSetup->doclist, &pSetup->aBuf[iStore]); fts5BufferZero(&pSetup->doclist); break; } } if( iStore==i1+nMerge ){ pSetup->xMerge(p, &pSetup->doclist, nMerge, &pSetup->aBuf[i1]); for(iStore=i1; iStore<i1+nMerge; iStore++){ fts5BufferZero(&pSetup->aBuf[iStore]); } } } pSetup->iLastRowid = 0; } pSetup->xAppend( p, (u64)p1->base.iRowid-(u64)pSetup->iLastRowid, p1, &pSetup->doclist ); pSetup->iLastRowid = p1->base.iRowid; } if( pSetup->pTokendata ){ prefixIterSetupTokendataCb(p, (void*)pSetup->pTokendata, p1, pNew, nNew); } } static void fts5SetupPrefixIter( Fts5Index *p, /* Index to read from */ int bDesc, /* True for "ORDER BY rowid DESC" */ int iIdx, /* Index to scan for data */ u8 *pToken, /* Buffer containing prefix to match */ int nToken, /* Size of buffer pToken in bytes */ Fts5Colset *pColset, /* Restrict matches to these columns */ Fts5Iter **ppIter /* OUT: New iterator */ ){ Fts5Structure *pStruct; PrefixSetupCtx s; TokendataSetupCtx s2; |
︙ | |||
248813 248814 248815 248816 248817 248818 248819 | 249354 249355 249356 249357 249358 249359 249360 249361 249362 249363 249364 249365 249366 249367 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ** Ensure the segment-iterator passed as the only argument points to EOF. */ static void fts5SegIterSetEOF(Fts5SegIter *pSeg){ fts5DataRelease(pSeg->pLeaf); pSeg->pLeaf = 0; } |
︙ | |||
248881 248882 248883 248884 248885 248886 248887 | 249390 249391 249392 249393 249394 249395 249396 249397 249398 249399 249400 249401 249402 249403 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | pRet->apIter[pRet->nIter++] = pAppend; } assert( pRet==0 || pRet->nIter<=pRet->nIterAlloc ); return pRet; } |
︙ | |||
248969 248970 248971 248972 248973 248974 248975 | 249430 249431 249432 249433 249434 249435 249436 249437 249438 249439 249440 249441 249442 249443 249444 | - + | pIter->base.bEof = 1; }else{ int eDetail = pIter->pIndex->pConfig->eDetail; pIter->base.bEof = 0; pIter->base.iRowid = iRowid; if( nHit==1 && eDetail==FTS5_DETAIL_FULL ){ |
︙ | |||
249222 249223 249224 249225 249226 249227 249228 249229 249230 249231 249232 249233 249234 249235 249236 249237 249238 249239 249240 249241 249242 | 249683 249684 249685 249686 249687 249688 249689 249690 249691 249692 249693 249694 249695 249696 249697 249698 249699 249700 249701 249702 249703 249704 249705 249706 249707 249708 249709 249710 249711 | + - | } } if( p->rc==SQLITE_OK ){ pRet = fts5MultiIterAlloc(p, 0); } if( pRet ){ pRet->nSeg = 0; pRet->pTokenDataIter = pSet; if( pSet ){ fts5IterSetOutputsTokendata(pRet); }else{ pRet->base.bEof = 1; } }else{ fts5TokendataIterDelete(pSet); } fts5StructureRelease(pStruct); fts5BufferFree(&bSeek); return pRet; } |
︙ | |||
249260 249261 249262 249263 249264 249265 249266 249267 249268 249269 249270 249271 249272 249273 249274 249275 | 249721 249722 249723 249724 249725 249726 249727 249728 249729 249730 249731 249732 249733 249734 249735 249736 249737 249738 249739 249740 249741 249742 | + + + + + + | /* If the QUERY_SCAN flag is set, all other flags must be clear. */ assert( (flags & FTS5INDEX_QUERY_SCAN)==0 || flags==FTS5INDEX_QUERY_SCAN ); if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){ int iIdx = 0; /* Index to search */ int iPrefixIdx = 0; /* +1 prefix index */ int bTokendata = pConfig->bTokendata; assert( buf.p!=0 ); if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken); /* The NOTOKENDATA flag is set when each token in a tokendata=1 table ** should be treated individually, instead of merging all those with ** a common prefix into a single entry. This is used, for example, by ** queries performed as part of an integrity-check, or by the fts5vocab ** module. */ if( flags & (FTS5INDEX_QUERY_NOTOKENDATA|FTS5INDEX_QUERY_SCAN) ){ bTokendata = 0; } /* Figure out which index to search and set iIdx accordingly. If this ** is a prefix query for which there is no prefix index, set iIdx to ** greater than pConfig->nPrefix to indicate that the query will be |
︙ | |||
249292 249293 249294 249295 249296 249297 249298 | 249759 249760 249761 249762 249763 249764 249765 249766 249767 249768 249769 249770 249771 249772 249773 249774 249775 249776 249777 249778 249779 249780 249781 249782 249783 249784 249785 249786 | - + - + | int nIdxChar = pConfig->aPrefix[iIdx-1]; if( nIdxChar==nChar ) break; if( nIdxChar==nChar+1 ) iPrefixIdx = iIdx; } } if( bTokendata && iIdx==0 ){ |
︙ | |||
249341 249342 249343 249344 249345 249346 249347 | 249808 249809 249810 249811 249812 249813 249814 249815 249816 249817 249818 249819 249820 249821 249822 249823 | + - + | */ /* ** Move to the next matching rowid. */ static int sqlite3Fts5IterNext(Fts5IndexIter *pIndexIter){ Fts5Iter *pIter = (Fts5Iter*)pIndexIter; assert( pIter->pIndex->rc==SQLITE_OK ); if( pIter->nSeg==0 ){ |
︙ | |||
249378 249379 249380 249381 249382 249383 249384 | 249846 249847 249848 249849 249850 249851 249852 249853 249854 249855 249856 249857 249858 249859 249860 249861 249862 249863 249864 249865 249866 249867 249868 249869 249870 249871 249872 249873 249874 249875 249876 249877 249878 249879 249880 249881 249882 249883 249884 249885 249886 249887 249888 249889 249890 249891 249892 249893 249894 249895 249896 249897 249898 249899 249900 249901 249902 249903 249904 249905 249906 249907 249908 249909 249910 249911 249912 249913 249914 249915 249916 249917 249918 249919 249920 249921 249922 249923 249924 249925 249926 249927 249928 249929 249930 249931 249932 249933 249934 249935 249936 249937 249938 249939 249940 249941 249942 249943 249944 249945 249946 249947 249948 249949 249950 249951 249952 249953 249954 249955 249956 | + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - + + + + + + + + + + + | /* ** Move to the next matching rowid that occurs at or after iMatch. The ** definition of "at or after" depends on whether this iterator iterates ** in ascending or descending rowid order. */ static int sqlite3Fts5IterNextFrom(Fts5IndexIter *pIndexIter, i64 iMatch){ Fts5Iter *pIter = (Fts5Iter*)pIndexIter; if( pIter->nSeg==0 ){ |
︙ | |||
249441 249442 249443 249444 249445 249446 249447 | 249966 249967 249968 249969 249970 249971 249972 249973 249974 249975 249976 249977 249978 249979 249980 249981 249982 249983 249984 249985 249986 249987 249988 249989 249990 249991 249992 249993 249994 249995 249996 249997 249998 249999 250000 250001 250002 250003 250004 250005 250006 250007 250008 250009 250010 250011 250012 250013 250014 250015 250016 250017 250018 250019 250020 250021 250022 250023 250024 250025 250026 250027 250028 250029 250030 250031 250032 250033 250034 250035 250036 250037 250038 250039 250040 250041 250042 250043 250044 | + - - - + + + + + + + + - + + + - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + | }else{ break; } } } if( i2>i1 ){ if( pIter->nSeg==0 ){ |
︙ | |||
251390 251391 251392 251393 251394 251395 251396 251397 251398 251399 251400 251401 251402 251403 | 251935 251936 251937 251938 251939 251940 251941 251942 251943 251944 251945 251946 251947 251948 251949 | + | /* ** Size of header on fts5_locale() values. And macro to access a buffer ** containing a copy of the header from an Fts5Config pointer. */ #define FTS5_LOCALE_HDR_SIZE ((int)sizeof( ((Fts5Global*)0)->aLocaleHdr )) #define FTS5_LOCALE_HDR(pConfig) ((const u8*)(pConfig->pGlobal->aLocaleHdr)) #define FTS5_INSTTOKEN_SUBTYPE 73 /* ** Each auxiliary function registered with the FTS5 module is represented ** by an object of the following type. All such objects are stored as part ** of the Fts5Global.pAux list. */ struct Fts5Auxiliary { |
︙ | |||
251929 251930 251931 251932 251933 251934 251935 251936 251937 251938 251939 251940 251941 251942 | 252475 252476 252477 252478 252479 252480 252481 252482 252483 252484 252485 252486 252487 252488 252489 | + | if( p->op==SQLITE_INDEX_CONSTRAINT_MATCH || (p->op==SQLITE_INDEX_CONSTRAINT_EQ && iCol>=nCol) ){ /* A MATCH operator or equivalent */ if( p->usable==0 || iCol<0 ){ /* As there exists an unusable MATCH constraint this is an ** unusable plan. Return SQLITE_CONSTRAINT. */ idxStr[iIdxStr] = 0; return SQLITE_CONSTRAINT; }else{ if( iCol==nCol+1 ){ if( bSeenRank ) continue; idxStr[iIdxStr++] = 'r'; bSeenRank = 1; }else{ |
︙ | |||
252714 252715 252716 252717 252718 252719 252720 252721 252722 252723 252724 252725 252726 252727 | 253261 253262 253263 253264 253265 253266 253267 253268 253269 253270 253271 253272 253273 253274 253275 | + | int bOrderByRank; /* True if ORDER BY rank */ sqlite3_value *pRank = 0; /* rank MATCH ? expression (or NULL) */ sqlite3_value *pRowidEq = 0; /* rowid = ? expression (or NULL) */ sqlite3_value *pRowidLe = 0; /* rowid <= ? expression (or NULL) */ sqlite3_value *pRowidGe = 0; /* rowid >= ? expression (or NULL) */ int iCol; /* Column on LHS of MATCH operator */ char **pzErrmsg = pConfig->pzErrmsg; int bPrefixInsttoken = pConfig->bPrefixInsttoken; int i; int iIdxStr = 0; Fts5Expr *pExpr = 0; assert( pConfig->bLock==0 ); if( pCsr->ePlan ){ fts5FreeCursorComponents(pCsr); |
︙ | |||
252749 252750 252751 252752 252753 252754 252755 252756 252757 252758 252759 252760 252761 252762 | 253297 253298 253299 253300 253301 253302 253303 253304 253305 253306 253307 253308 253309 253310 253311 253312 253313 | + + + | char *zText = 0; int bFreeAndReset = 0; int bInternal = 0; rc = fts5ExtractExprText(pConfig, apVal[i], &zText, &bFreeAndReset); if( rc!=SQLITE_OK ) goto filter_out; if( zText==0 ) zText = ""; if( sqlite3_value_subtype(apVal[i])==FTS5_INSTTOKEN_SUBTYPE ){ pConfig->bPrefixInsttoken = 1; } iCol = 0; do{ iCol = iCol*10 + (idxStr[iIdxStr]-'0'); iIdxStr++; }while( idxStr[iIdxStr]>='0' && idxStr[iIdxStr]<='9' ); |
︙ | |||
252889 252890 252891 252892 252893 252894 252895 252896 252897 252898 252899 252900 252901 252902 | 253440 253441 253442 253443 253444 253445 253446 253447 253448 253449 253450 253451 253452 253453 253454 | + | rc = fts5NextMethod(pCursor); } } filter_out: sqlite3Fts5ExprFree(pExpr); pConfig->pzErrmsg = pzErrmsg; pConfig->bPrefixInsttoken = bPrefixInsttoken; return rc; } /* ** This is the xEof method of the virtual table. SQLite calls this ** routine to find out if it has reached the end of a result set. */ |
︙ | |||
254884 254885 254886 254887 254888 254889 254890 | 255436 255437 255438 255439 255440 255441 255442 255443 255444 255445 255446 255447 255448 255449 255450 | - + | static void fts5SourceIdFunc( sqlite3_context *pCtx, /* Function call context */ int nArg, /* Number of args */ sqlite3_value **apUnused /* Function arguments */ ){ assert( nArg==0 ); UNUSED_PARAM2(nArg, apUnused); |
︙ | |||
254947 254948 254949 254950 254951 254952 254953 254954 254955 254956 254957 254958 254959 254960 | 255499 255500 255501 255502 255503 255504 255505 255506 255507 255508 255509 255510 255511 255512 255513 255514 255515 255516 255517 255518 255519 255520 255521 255522 255523 255524 255525 255526 | + + + + + + + + + + + + + + | (*pCsr++) = 0x00; if( zText ) memcpy(pCsr, zText, nText); assert( &pCsr[nText]==&pBlob[nBlob] ); sqlite3_result_blob(pCtx, pBlob, nBlob, sqlite3_free); } } /* ** Implementation of fts5_insttoken() function. */ static void fts5InsttokenFunc( sqlite3_context *pCtx, /* Function call context */ int nArg, /* Number of args */ sqlite3_value **apArg /* Function arguments */ ){ assert( nArg==1 ); (void)nArg; sqlite3_result_value(pCtx, apArg[0]); sqlite3_result_subtype(pCtx, FTS5_INSTTOKEN_SUBTYPE); } /* ** Return true if zName is the extension on one of the shadow tables used ** by this module. */ static int fts5ShadowName(const char *zName){ static const char *azName[] = { |
︙ | |||
255077 255078 255079 255080 255081 255082 255083 | 255643 255644 255645 255646 255647 255648 255649 255650 255651 255652 255653 255654 255655 255656 255657 255658 255659 255660 255661 255662 255663 255664 255665 255666 | - + + + + + + + + | SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS, p, fts5SourceIdFunc, 0, 0 ); } if( rc==SQLITE_OK ){ rc = sqlite3_create_function( db, "fts5_locale", 2, |
︙ | |||
258005 258006 258007 258008 258009 258010 258011 | 258578 258579 258580 258581 258582 258583 258584 258585 258586 258587 258588 258589 258590 258591 258592 258593 258594 258595 258596 258597 258598 258599 258600 258601 258602 258603 258604 258605 258606 258607 258608 258609 258610 258611 258612 258613 258614 258615 258616 258617 258618 258619 258620 258621 258622 258623 258624 258625 258626 258627 258628 | - - + + + - + + + + - | ){ TrigramTokenizer *p = (TrigramTokenizer*)pTok; int rc = SQLITE_OK; char aBuf[32]; char *zOut = aBuf; int ii; const unsigned char *zIn = (const unsigned char*)pText; |
︙ | |||
260075 260076 260077 260078 260079 260080 260081 | 260651 260652 260653 260654 260655 260656 260657 260658 260659 260660 260661 260662 260663 260664 260665 | - + | }; void *p = (void*)pGlobal; return sqlite3_create_module_v2(db, "fts5vocab", &fts5Vocab, p, 0); } |
︙ | |||
260431 260432 260433 260434 260435 260436 260437 260438 | 261007 261008 261009 261010 261011 261012 261013 261014 261015 | + | } #endif /* SQLITE_CORE */ #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */ /************** End of stmt.c ************************************************/ /* Return the source-id for this library */ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } #endif /* SQLITE_AMALGAMATION */ /************************** End of sqlite3.c ******************************/ |
Changes to src/sqlite3.h.
︙ | |||
142 143 144 145 146 147 148 | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | - - - + + + | ** been edited in any way since it was last checked in, then the last ** four hexadecimal digits of the hash may be modified. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ |
︙ | |||
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | + + + + + + + + | ** read-only media and cannot be changed even by processes with ** elevated privileges. ** ** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying ** filesystem supports doing multiple write operations atomically when those ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and ** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. ** ** The SQLITE_IOCAP_SUBPAGE_READ property means that it is ok to read ** from the database file in amounts that are not a multiple of the ** page size and that do not begin at a page boundary. Without this ** property, SQLite is careful to only do full-page reads and write ** on aligned pages, with the one exception that it will do a sub-page ** read of the first page to access the database header. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 #define SQLITE_IOCAP_ATOMIC1K 0x00000004 #define SQLITE_IOCAP_ATOMIC2K 0x00000008 #define SQLITE_IOCAP_ATOMIC4K 0x00000010 #define SQLITE_IOCAP_ATOMIC8K 0x00000020 #define SQLITE_IOCAP_ATOMIC16K 0x00000040 #define SQLITE_IOCAP_ATOMIC32K 0x00000080 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 #define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 #define SQLITE_IOCAP_SUBPAGE_READ 0x00008000 /* ** CAPI3REF: File Locking Levels ** ** SQLite uses one of these integer values as the second ** argument to calls it makes to the xLock() and xUnlock() methods ** of an [sqlite3_io_methods] object. These values are ordered from |
︙ | |||
810 811 812 813 814 815 816 817 818 819 820 821 822 823 | 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 | + | ** <li> [SQLITE_IOCAP_ATOMIC64K] ** <li> [SQLITE_IOCAP_SAFE_APPEND] ** <li> [SQLITE_IOCAP_SEQUENTIAL] ** <li> [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN] ** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE] ** <li> [SQLITE_IOCAP_IMMUTABLE] ** <li> [SQLITE_IOCAP_BATCH_ATOMIC] ** <li> [SQLITE_IOCAP_SUBPAGE_READ] ** </ul> ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of ** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values ** mean that writes of blocks that are nnn bytes in size and ** are aligned to an address which is an integer multiple of ** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means |
︙ | |||
1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 | 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | + + + + + | ** ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]] ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This ** opcode causes the xFileControl method to swap the file handle with the one ** pointed to by the pArg argument. This capability is used during testing ** and only needs to be supported when SQLITE_TEST is defined. ** ** <li>[[SQLITE_FCNTL_NULL_IO]] ** The [SQLITE_FCNTL_NULL_IO] opcode sets the low-level file descriptor ** or file handle for the [sqlite3_file] object such that it will no longer ** read or write to the database file. ** ** <li>[[SQLITE_FCNTL_WAL_BLOCK]] ** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might ** be advantageous to block on the next WAL lock if the lock is not immediately ** available. The WAL subsystem issues this signal during rare ** circumstances in order to fix a problem with priority inversion. ** Applications should <em>not</em> use this file-control. ** |
︙ | |||
1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 | 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 | + | #define SQLITE_FCNTL_SIZE_LIMIT 36 #define SQLITE_FCNTL_CKPT_DONE 37 #define SQLITE_FCNTL_RESERVE_BYTES 38 #define SQLITE_FCNTL_CKPT_START 39 #define SQLITE_FCNTL_EXTERNAL_READER 40 #define SQLITE_FCNTL_CKSM_FILE 41 #define SQLITE_FCNTL_RESET_CACHE 42 #define SQLITE_FCNTL_NULL_IO 43 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE #define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO |
︙ | |||
2618 2619 2620 2621 2622 2623 2624 | 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 | - + + + + + | ** CAPI3REF: Count The Number Of Rows Modified ** METHOD: sqlite3 ** ** ^These functions return the number of rows modified, inserted or ** deleted by the most recently completed INSERT, UPDATE or DELETE ** statement on the database connection specified by the only parameter. ** The two functions are identical except for the type of the return value |
︙ | |||
4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 | 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 | + + + + + + + + + + + | ** prepared statements, regardless of whether or not they use this ** flag. ** ** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt> ** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler ** to return an error (error code SQLITE_ERROR) if the statement uses ** any virtual tables. ** ** [[SQLITE_PREPARE_DONT_LOG]] <dt>SQLITE_PREPARE_DONT_LOG</dt> ** <dd>The SQLITE_PREPARE_DONT_LOG flag prevents SQL compiler ** errors from being sent to the error log defined by ** [SQLITE_CONFIG_LOG]. This can be used, for example, to do test ** compiles to see if some SQL syntax is well-formed, without generating ** messages on the global error log when it is not. If the test compile ** fails, the sqlite3_prepare_v3() call returns the same error indications ** with or without this flag; it just omits the call to [sqlite3_log()] that ** logs the error. ** </dl> */ #define SQLITE_PREPARE_PERSISTENT 0x01 #define SQLITE_PREPARE_NORMALIZE 0x02 #define SQLITE_PREPARE_NO_VTAB 0x04 #define SQLITE_PREPARE_DONT_LOG 0x10 /* ** CAPI3REF: Compiling An SQL Statement ** KEYWORDS: {SQL statement compiler} ** METHOD: sqlite3 ** CONSTRUCTOR: sqlite3_stmt ** |
︙ | |||
10876 10877 10878 10879 10880 10881 10882 | 10906 10907 10908 10909 10910 10911 10912 10913 10914 10915 10916 10917 10918 10919 10920 | - + | # define SQLITE_THREADSAFE 0 # endif #endif #ifdef __cplusplus } /* End of the 'extern "C"' block */ #endif |
︙ | |||
13127 13128 13129 13130 13131 13132 13133 | 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 13168 13169 13170 13171 13172 13173 13174 13175 13176 13177 13178 13179 13180 13181 13182 13183 13184 13185 13186 13187 13188 13189 13190 13191 13192 | - - - + + + + + + + + + + + + + + + + + + | ** ** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken) ** This is used to access token iToken of phrase hit iIdx within the ** current row. If iIdx is less than zero or greater than or equal to the ** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise, ** output variable (*ppToken) is set to point to a buffer containing the ** matching document token, and (*pnToken) to the size of that buffer in |
︙ | |||
13568 13569 13570 13571 13572 13573 13574 | 13613 13614 13615 13616 13617 13618 13619 13620 | + | #ifdef __cplusplus } /* end of the 'extern "C"' block */ #endif #endif /* _FTS5_H */ /******** End of fts5.h *********/ #endif /* SQLITE3_H */ |