Lines Matching refs:index
1865 ** CAPI3REF: Maximum xShmLock index
2741 ** process a table with generated columns and a descending index. This is
4317 ** result set of a [SELECT] or the maximum number of columns in an index
4345 ** <dd>The maximum index number of any [parameter] in an SQL statement.)^
4766 ** ^The second argument is the index of the SQL parameter to be set.
4767 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
4769 ** occurrences have the same index as the first occurrence.
4770 ** ^The index for named parameters can be looked up using the
4771 ** [sqlite3_bind_parameter_index()] API if desired. ^The index
4874 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
4905 ** ^(This routine actually returns the index of the largest (rightmost)
4930 ** ^The first host parameter has an index of 1, not 0.
4948 ** ^Return the index of an SQL parameter given its name. ^The
4949 ** index value returned is suitable for use as the second
5271 ** and the second argument is the index of the column for which information
5272 ** should be returned. ^The leftmost column of the result set has the index 0.
5277 ** column index is out of range, the result is undefined.
5578 ** index expressions, or the WHERE clause of partial indexes.
7449 ** ^(The index of the column is stored in
7552 int idxNum; /* Number used to identify the index */
7556 double estimatedCost; /* Estimated cost of using this index */
7831 ** <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE
8895 ** an index.
9981 ** must be an index into the aConstraint[] array belonging to the
10211 ** J being a 0-based index into P->aConstraint[], then this routine
10291 ** to a zero-terminated UTF-8 string containing the name of the index or table
10482 ** the index of the column being written. In other cases, where the
13044 ** FTS index.
13047 ** against the FTS index. The tokenizer is being called to tokenize
13100 ** 1st place" entries are added to the index for tokens "i", "won",
13105 ** <li> By querying the index for all synonyms of each query term
13108 ** within the document. FTS5 then queries the index for each
13125 ** <li> By adding multiple synonyms for a single term to the FTS index.
13129 ** added to the FTS index for "i", "won", "first", "1st" and
13136 ** FTS index corresponding to both forms of the first token.
13160 ** extra data to the FTS index or require FTS5 to query for multiple terms,
13172 ** because the index contains entries for both "first" and "1st", prefix
13174 ** extra entries are added to the FTS index, this method uses more space
13182 ** extra disk space, as no extra entries are added to the FTS index.
13184 ** as separate queries of the FTS index are required for each synonym.
13307 ** limits the size of a row in a table or index.
13320 ** * Columns in an index
14397 ** table or index. This is an unsigned integer type. For 99.9% of
15618 ** The BTREE_BULKLOAD flag is set on index cursors when the index is going
15627 #define BTREE_BULKLOAD 0x00000001 /* Used to full index in sorted order */
15647 ** the main table row automatically deletes corresponding index rows,
15694 ** entry in either an index or table btree.
15998 ** into an index into the Parse.aLabel[] array that contains the resolved
17123 int nAnalysisLimit; /* Number of index rows to ANALYZE */
17249 #define SQLITE_CoverIdxScan 0x00000020 /* Covering index scans */
17250 #define SQLITE_OrderByIdxJoin 0x00000040 /* ORDER BY of joins via index */
17271 #define SQLITE_IndexedExpr 0x01000000 /* Pull exprs from index when able */
17555 ** "table column index" This is the index of the column in the
17556 ** Table.aCol[] array, and also the index of
17559 ** "storage column index" This is the index of the column in the
17561 ** opcode. The storage column index is less than
17562 ** or equal to the table column index. It is
17581 u16 iDflt; /* 1-based index of DEFAULT. 0 means "none" */
17965 ** comparison of the two index keys.
17968 ** are nField slots for the columns of an index then one extra slot
17974 u16 nKeyField; /* Number of key columns in the index */
17993 ** the key of an index. A blob encoding of a record is created by
17998 ** an index b+tree. The goal of the search is to find the entry that
18040 ** Each SQL index is represented in memory by an
18045 ** we have the following table and index:
18054 ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].
18055 ** The second column to be indexed (c1) has an index of 0 in
18060 ** it means this is not a unique index. Otherwise it is a unique index
18066 ** for a fast test to see if an index can serve as a covering index.
18068 ** is *not* available in the index. Thus the expression
18069 ** "colUsed & colNotIdxed" will be non-zero if the index is not a
18070 ** covering index. The most significant bit of of colNotIdxed will always
18073 ** and we have to assume either that the index is not covering, or use
18075 ** the index is covering.
18086 char *zName; /* Name of this index */
18087 i16 *aiColumn; /* Which columns are used by this index. 1st is 0 */
18091 Index *pNext; /* The next index associated with the same table */
18092 Schema *pSchema; /* Schema containing this index */
18094 const char **azColl; /* Array of collation sequence names for index */
18097 Pgno tnum; /* DB Page containing root of this index */
18100 u16 nColumn; /* Number of columns stored in the index */
18103 unsigned bUnordered:1; /* Use this index for == or IN queries only */
18106 unsigned isCovering:1; /* True if this is a covering index */
18109 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
18119 tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
18120 tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */
18131 #define SQLITE_IDXTYPE_IPK 3 /* INTEGER PRIMARY KEY index */
18133 /* Return true if index X is a PRIMARY KEY index */
18136 /* Return true if index X is a UNIQUE index */
18184 ** pointer to this structure. The Expr.iAgg field is the index in
18195 u8 useSortingIdx; /* In direct mode, reference the sorting index rather
18197 int sortingIdx; /* Cursor number of the sorting index */
18199 int nSortingColumn; /* Number of columns in the sorting index */
18208 i16 iSorterColumn; /* Column number in the sorting index */
18276 ** character '?' in the original SQL) then the Expr.iTable holds the index
18347 ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
18358 ** for a column of an index on an expression */
18749 #define NC_PartIdx 0x000002 /* True if resolving a partial index WHERE */
18786 Expr *pUpsertTargetWhere; /* WHERE clause for partial index targets */
18803 int iIdxCur; /* Index of the first index cursor */
18893 ** SRT_Union Store results as a key in a temporary index
18896 ** SRT_Except Remove results from the temporary index pDest->iSDParm.
18942 ** an index). Append a sequence number so that all entries
18947 ** index at pDest->iSDParm+1 hold all prior stores.
18953 ** key. If (pDest->iSDParm>0), then the table is an index
18955 ** each index record in this case.
18957 #define SRT_Union 1 /* Store result as keys in an index */
18958 #define SRT_Except 2 /* Remove result from a UNION index */
18976 #define SRT_Set 11 /* Store results as keys in an index */
19058 ** For each index X that has as one of its arguments either an expression
19060 ** the value of the expression can simply be read from the index, then
19065 ** is read from the index rather than being recomputed.
19068 Expr *pExpr; /* The expression contained in the index */
19069 int iDataCur; /* The data cursor associated with the index */
19070 int iIdxCur; /* The index cursor */
19071 int iIdxCol; /* The index column that contains value of pExpr */
19075 const char *zIdxName; /* Name of index, used only for bytecode comments */
19131 int iSelfTab; /* Table associated with an index on expr, or negative
19200 Index *pNewIndex; /* An index being constructed by CREATE INDEX.
19290 #define OPFLAG_AUXDELETE 0x04 /* OP_Delete: index in a DELETE op */
19572 struct IdxCover *pIdxCover; /* Check for index coverage */
19579 struct CoveringIndexCheck *pCovIdxCk; /* Check for covering index */
20851 #define IN_INDEX_INDEX_ASC 3 /* Existing index ASCENDING */
20852 #define IN_INDEX_INDEX_DESC 4 /* Existing index DESCENDING */
22062 ** index (here shown as [256-OP_Ne]) would be out-of-bounds and thus
22171 # error "Compile-time disabling of covering index scan using the\
22478 ** - On either an index or a table
22501 u32 *aAltMap; /* Mapping from table to index column numbers */
22519 VdbeCursor *pAltCursor; /* Associated index cursor from which to read */
22525 KeyInfo *pKeyInfo; /* Info about index keys needed by index cursors */
22806 char *zName; /* Name of table or index */
22933 Index *pPk; /* PK index if pTab is WITHOUT ROWID */
24170 int idx /* Parameter index of the modifier */
26355 ** We often identify a chunk by its index in mem3.aPool[]. When
26356 ** this is done, the chunk index refers to the second block of
26357 ** the chunk. In this way, the first chunk has an index of 1.
26358 ** A chunk index of 0 means "no such chunk" and is the equivalent
26414 ** iKeyBlk is the index of the key chunk. Most new allocations
26454 ** Unlink the chunk at index i from
26488 ** Link the chunk at index i into either the appropriate
27274 /* Set iBlock to the index of the block pointed to by pOld in
41143 ** When multiple threads all reference the same wal-index, each thread
41145 ** of this unixShmNode object. In other words, each wal-index is opened
41666 ** Check to see if it has been allocated (i.e. if the wal-index file is
49318 sqlite3_int64 sz; /* Current size of wal-index file */
49323 ** Check to see if it has been allocated (i.e. if the wal-index file is
52290 u32 iSize; /* Maximum bit index. Max iSize is 4,294,967,296. */
55472 ** heap-memory for the wal-index. Otherwise, if the argument is NULL or the
62484 ** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes
62499 ** In any case, all savepoints with an index greater than iSavepoint
63114 ** lock on the database file and use heap-memory to store the wal-index
63124 ** heap-memory for the wal-index instead of the VFS shared-memory
63471 ** To start a read transaction, the reader records the index of the last
63485 ** data structure called the wal-index is maintained to expedite the
63490 ** Conceptually, the wal-index is shared memory, though VFS implementations
63491 ** might choose to implement the wal-index using a mmapped file. Because
63492 ** the wal-index is shared memory, SQLite does not support journal_mode=WAL
63496 ** In the default unix and windows implementation, the wal-index is a mmapped
63498 ** reason, the wal-index is sometimes called the "shm" file.
63500 ** The wal-index is transient. After a crash, the wal-index can (and should
63502 ** to either truncate or zero the header of the wal-index when the last
63503 ** connection to it closes. Because the wal-index is transient, it can
63506 ** as big endian, the wal-index can store multi-byte values in the native
63509 ** The purpose of the wal-index is to answer this question quickly: Given
63510 ** a page number P and a maximum frame index M, return the index of the
63514 ** The wal-index consists of a header region, followed by an one or
63515 ** more index blocks.
63517 ** The wal-index header contains the total number of frames within the WAL
63520 ** Each index block except for the first contains information on
63521 ** HASHTABLE_NPAGE frames. The first index block contains information on
63523 ** HASHTABLE_NPAGE are selected so that together the wal-index header and
63524 ** first index block are the same size as all other index blocks in the
63525 ** wal-index. The values are:
63530 ** Each index block contains two sections, a page-mapping that contains the
63532 ** that allows readers to query an index block for a specific page number.
63534 ** for the first index block) 32-bit page numbers. The first entry in the
63535 ** first index-block contains the database page number corresponding to the
63536 ** first frame in the WAL file. The first entry in the second index block
63540 ** The last index block in a wal-index usually contains less than the full
63547 ** can be found by scanning the page-mapping sections of each index block
63548 ** starting with the last index block and moving toward the first, and
63549 ** within each index block, starting at the end and moving toward the
63558 ** 1-based index of an entry in the mapping section of the same
63559 ** index block. Let K be the 1-based index of the largest entry in
63560 ** the mapping section. (For index blocks other than the last, K will
63561 ** always be exactly HASHTABLE_NPAGE (4096) and for the last index block
63573 ** be at index iUnused. (iUnused might be less than iKey if there was
63579 ** current index block. Otherwise the iMax-th mapping entry of the
63580 ** current index block corresponds to the last entry that references
63583 ** A hash search begins with the last index block and moves toward the
63584 ** first index block, looking for entries corresponding to page P. On
63585 ** average, only two or three slots in each index block need to be
63587 ** establish that no such entry exists in the block. Each index block
63588 ** holds over 4000 entries. So two or three index blocks are sufficient
63597 ** and to the wal-index) might be using a different value K1, where K1>K0.
63626 ** The maximum (and only) versions of the wal and wal-index formats
63633 ** Similarly, if a client successfully reads a wal-index header (i.e. the
63649 ** is for the index number to indicate a byte offset into the
63650 ** WalCkptInfo.aLock[] array in the wal-index header. In other words, all
63670 ** The following object holds a copy of the wal-index header content.
63672 ** The actual header in the wal-index consists of two copies of this
63683 u32 iVersion; /* Wal-index version */
63697 ** A copy of the following object occurs in the wal-index immediately
63766 ** wal-index file (also known as the -shm file):
63875 volatile u32 **apWiData; /* Pointer to wal-index content in memory */
63887 WalIndexHdr hdr; /* Wal-index header for current transaction */
63918 ** Each page of the wal-index mapping contains a hash-table made up of
63928 ** the largest index).
63947 } aSegment[1]; /* One for every 32KB page in the wal-index */
63951 ** Define the parameters of the hash tables in the wal-index file. There
63953 ** wal-index.
63955 ** Changing any of these constants will alter the wal-index format and
63964 ** wal-index is smaller than usual. This is so that there is a complete
63965 ** hash-table on each aligned 32KB page of the wal-index.
63969 /* The wal-index is divided into pages of WALINDEX_PGSZ bytes each. */
63975 ** Obtain a pointer to the iPage'th page of the wal-index. The wal-index
63976 ** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are
63979 ** If the wal-index is currently smaller the iPage pages then the size
63980 ** of the wal-index might be increased, but only if it is safe to do
63981 ** so. It is safe to enlarge the wal-index if pWal->writeLock is true
64053 ** Return a pointer to the WalCkptInfo structure in the wal-index.
64061 ** Return a pointer to the WalIndexHdr structure in the wal-index.
64152 ** Write the header information in pWal->hdr into the wal-index.
64343 ** of a page hash table in the wal-index. This becomes the return value
64348 volatile ht_slot *aHash; /* Start of the wal-index hash table */
64355 ** page iHash of the wal-index. The wal-index is broken into 32KB pages
64359 ** in the wal-index file. Set pLoc->iZero to one less than the frame
64392 ** Return the number of the wal-index page that contains the hash-table
64394 ** iFrame. The wal-index is broken up into 32KB pages. Wal-index pages
64491 ** Set an entry in the wal-index that will map database page number
64496 WalHashLoc sLoc; /* Wal-index hash table location */
64500 /* Assuming the wal-index file was successfully mapped, populate the
64574 ** Recover the wal-index by reading the write-ahead log file.
64577 ** wal-index to prevent other threads/processes from doing anything
64578 ** with the WAL or wal-index while recovery is running. The
64624 u32 iPg; /* Current 32KB wal-index page */
64804 ** Close an open wal-index.
64826 ** client from unlinking the WAL or wal-index file. If another process
64835 sqlite3_vfs *pVfs, /* vfs module to open wal and wal-index */
64944 ** same WalIterator object. Write into *piFrame the frame index where
64954 u32 *piFrame /* OUT: Wal frame index of next page */
64992 ** of indices such that the aRight[] contains every index that appears in
65002 ** When that happens, omit the aLeft[X] and use the aRight[Y] index.
65012 int iLeft = 0; /* Current index in aLeft */
65013 int iRight = 0; /* Current index in aRight */
65014 int iOut = 0; /* Current index in output buffer */
65185 ht_slot *aIndex; /* Sorted index for this segment */
65325 ** The cache of the wal-index header must be valid to call this function.
65346 ** new wal-index header. It should be passed a pseudo-random value (i.e.
65389 ** This routine uses and updates the nBackfill field of the wal-index header.
65427 /* Compute in mxSafeFrame the index of the last frame of the WAL that is
65562 ** wal-index header in shared memory, as all subsequent reader or
65566 ** the wal-index header do not match the contents of the
65567 ** file-system. To avoid this, update the wal-index header to
65612 int isDelete = 0; /* True to unlink wal and wal-index files */
65618 ** the wal and wal-index files.
65668 ** Try to read the wal-index header. Return 0 on success and 1 if
65671 ** The wal-index is in shared memory. Another thread or process might
65689 /* The first page of the wal-index must be mapped at this point. */
65698 ** There are two copies of the header at the beginning of the wal-index.
65743 ** Read the wal-index header from the wal-index and into pWal->hdr.
65745 ** wal-index from the WAL before returning.
65747 ** Set *pChanged to 1 if the wal-index header value in pWal->hdr is
65751 ** If the wal-index header is successfully read, return SQLITE_OK.
65757 volatile u32 *page0; /* Chunk of wal-index containing header */
65759 /* Ensure that page 0 of the wal-index (the page that contains the
65760 ** wal-index header) is mapped. Return early if an error occurs here.
65789 /* If the first page of the wal-index has been mapped, try to read the
65790 ** wal-index header immediately, without holding any lock. This usually
65791 ** works, but may fail if the wal-index header is corrupt or currently
65812 /* If the wal-index header is still malformed even while holding
65829 ** sure the wal-index was not constructed with some future format that
65864 ** The *-wal file has been read and an appropriate wal-index has been
65872 ** WAL_RETRY, then the heap memory wal-index has been discarded and
65909 ** cause the heap-memory WAL-index to be discarded and the actual
65933 ** Assume the in-memory WAL-index substitute is correct and load it
65947 ** wal-index header has mxFrame==0, then it must be safe to proceed
65964 ** Return WAL_RETRY which will cause the in-memory WAL-index to be
65982 ** wal file since the heap-memory wal-index was created. If so, the
65983 ** heap-memory wal-index is discarded and WAL_RETRY returned to
66037 ** to make a copy of the wal-index header into pWal->hdr. If the
66038 ** wal-index header has changed, *pChanged is set to 1 (as an indication
66040 ** flushed.) When useWal==1, the wal-index header is assumed to already
66051 ** bad luck when there is lots of contention for the wal-index, but that
66077 volatile WalCkptInfo *pInfo; /* Checkpoint information in wal-index */
66242 ** value in the aReadMark[] array or the contents of the wal-index
66245 ** It is necessary to check that the wal-index header did not change
66255 ** Before checking that the live wal-index header has not changed
66264 ** checkpointer that set nBackfill was not working with a wal-index
66370 ** it takes a snapshot of the state of the WAL and wal-index for the current
66372 ** Other threads might append new content to the WAL and wal-index but
66428 ** is populated with the wal-index header corresponding to the head
66517 /* If the "last page" field of the wal-index header snapshot is 0, then
66533 ** that adds entries to the wal-index (and possibly to this hash
66556 int iKey; /* Hash slot index */
66583 ** of the wal-index file content. Make sure the results agree with the
66725 /* Restore the clients cache of the wal-index header to the state it
66825 ** wal-index header to reflect this.
66828 ** at this point. But updating the actual wal-index header is also
67174 /* Append data to the wal-index. It is not necessary to lock the
67175 ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index
67202 /* If this is a commit, update the wal-index header too. */
67238 int isChanged = 0; /* True if a new wal-index header is loaded */
67293 /* Read the wal-index header. */
67320 /* If a new wal-index header was loaded before the checkpoint was
67322 ** out of date. So zero the cached wal-index header to ensure that
67428 ** heap-memory for the wal-index. Otherwise, if the argument is NULL or the
67602 ** BTrees. Each BTree is identified by the index of its root page. The
67792 ** plus 2 bytes for the index to the cell in the page header). Such
67841 u8 intKey; /* True if table b-trees. False for index b-trees */
67865 u8 *aCellIdx; /* The cell index area */
68069 ** The entry is identified by its MemPage and the index in
68112 u16 ix; /* Current index for apPage[iPage] */
68113 u16 aiIdx[BTCURSOR_MAX_DEPTH-1]; /* Current index in apPage[i] */
68786 ** When writing to an index that resides in a sharable database, the
68790 ** the table corresponding to the index being written, this
68793 ** Instead of a lock on the table/index rooted at page iRoot, the caller may
68800 int isIndex, /* True if iRoot is the root of an index b-tree */
68817 /* If the client is reading or writing an index and the schema is
68828 ** written. For index b-trees, it is the root page of the associated
68872 ** table or index rooted at iRoot because other shared connections are
68873 ** simultaneously reading that same table or index.
68881 ** For example, before writing to any part of the table or index
69294 /* For an index btree, save the complete key content. It is possible
69426 ** In this version of BtreeMoveto, pKey is a packed index record
69432 const void *pKey, /* Packed key if the btree is an index */
69438 UnpackedRecord *pIdxKey; /* Unpacked index key */
69674 int iPtrmap; /* Pointer map page index */
69710 ** Given a btree page and a cell index (0 means the first cell on
69788 ** btreeParseCellPtrIndex() => index btree nodes
69791 ** all MemPage types and that references the cell by index rather than
69932 int iCell, /* The cell index. First cell is 0 */
69949 ** cellSizePtr() => all index nodes & table leaf nodes
70125 int iCellFirst; /* First allowable cell index */
70126 int iCellLast; /* Last possible cell index */
70308 ** as the first argument. Write into *pIdx the index into pPage->aData[]
70556 ** interior index b-tree page. */
70559 ** leaf index b-tree page. */
73069 ** an index greater than all savepoints created explicitly using
73146 ** this cursor will only be used to seek to and delete entries of an index
73149 ** in which index entries are automatically deleted when corresponding table
73371 ** ordinary table btree. If the cursor points to an index btree or
73411 ** of data. For index btrees, this will be the size of the key.
73772 ** pCur can be pointing to either a table or an index b-tree.
73774 ** pCur is pointing to an index b-tree then the key section is read.
73824 ** the key if index btrees (pPage->intKey==0) and is the data for
73936 ** pCur->idx is set to the cell index that contains the pointer
73939 ** the largest cell index.
73979 ** structure the flags byte is set to 0x02 or 0x0A, indicating an index
74027 ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
74278 ** be the right kind (index or table) of b-tree page. Otherwise
74408 /* Move the cursor so that it points to an entry in an index table
74436 UnpackedRecord *pIdxKey, /* Unpacked index key */
74522 ** be the right kind (index or table) of b-tree page. Otherwise
74534 ** the maximum number of record bytes stored on an index B-Tree
74573 testcase( nCell==2 ); /* Minimum legal index key size */
74694 ** cursor corresponds to an SQL index and this routine could have been
74695 ** skipped if the SQL index had been a unique index. The F argument
74787 ** the cursor corresponds to an SQL index and this routine could have been
74788 ** skipped if the SQL index had been a unique index. The F argument is a
74932 /* Decrement the free-list count by 1. Set iTrunk to the index of the
75674 ** Insert a new cell on pPage at cell index "i". pCell points to the
75681 ** in pTemp or the original pCell) and also record its index.
75751 /* In a corrupt database where an entry in the cell index section of
75828 ** The order of cells is in the array is for an index btree is:
75839 ** For an index btree, the apEnd[] array holds pointer to the end of page
76018 int i = iFirst; /* Loop counter - cell index to insert */
76525 int cntOld[NB+2]; /* Old index in b.apCell[] */
76541 ** index iParentIdx. This scenario comes about when this function
76690 ** table-interior, index-leaf, or index-interior).
76779 ** size of all cells on the i-th page and cntNew[] which is the index
77609 ** For an index btree (used for indexes and WITHOUT ROWID tables), the
77623 ** point for (pKey,nKey) before doing the insertion. For index btrees,
77663 ** than one table or index with the same root page as used by the cursor.
77688 ** expecting an index b-tree, then the caller should be inserting blob
77738 /* This is an index or a WITHOUT ROWID table */
78745 ** pCur->aiIdx[pCur->iPage] value is set to the index of the parent cell
78980 ** The upper 16 bits are the index of the first byte of a range and the
78981 ** lower 16 bits are the index of the last byte of that range.
79240 ** pointer index, and the gap between the cell pointer index and the start
80687 ** If a table contains a numeric value and an index is based on the
80690 ** that the index and table are consistent. See ticket
81529 ** empty boolean index.
81951 int nCol = pIdx->nColumn; /* Number of index columns including rowid */
82329 ** structures intended to be compared against sample index keys stored
82348 ** corresponding column within index pIdx is applied to it. Before
82435 int i; /* Column index */
82891 ** NC_IdxExpr means called as part of an index expression. NC_PartIdx
82892 ** means in the WHERE clause of a partial index. NC_GenCol means called
83649 const char *zName /* Name of table or index being scanned */
84005 ** index given.
84633 int *piAddr, /* OUT: Write index into (*paOp)[] here */
86224 ** data and index records. Each serialized value consists of a
86228 ** In an SQLite index record, the serial type is stored directly before
86641 ** This function compares two index or table record keys in the same way
87043 ** This function compares the two table rows or index records
87254 return 0; /* Corrupt index */
87502 ** pCur points at an index entry created using the OP_MakeRecord opcode.
87517 /* Get the size of the index entry. Only indices entries of less
87526 /* Read in the complete content of the index entry */
87533 /* The index entry must begin with a header size */
87543 /* The last field of the index should be an integer - the ROWID.
87563 /* Fetch the integer off the end of the index record */
87578 ** Compare the key of the index entry that cursor pC is pointing to against
87584 ** omits the rowid at the end. The rowid at the end of the index entry
87739 zContext = "an index";
89594 ** Return the name of a wildcard parameter. Return NULL if the index
89606 ** Given a wildcard parameter name, return the index of the variable
90142 ** the host parameter index is found by scanning the prepared
90144 ** parameter index is known, locate the value in p->aVar[]. Then render
90513 int nField, /* Number of fields in the table or index */
91240 ** the one at index P2 from the beginning of
93614 ** in an index. The OP_Column opcode can decode the record later.
93618 ** field of the index key.
93623 ** If P4 is NULL then all index fields have the affinity BLOB.
93628 ** * If SQLITE_ENABLE_NULL_TRIM is enabled, then the P5 is the index
93705 ** index of the right-most column with a non-NULL default value */
93947 ** Store the number of entries (an integer value) in the table or index
94233 ** P1 is the index of the database file on which the transaction is
94234 ** started. Index 0 is the main database file and index 1 is the
94417 /* See note about index shifting on OP_ReadCookie */
94458 ** object, then table being opened must be an [index b-tree] where the
94460 ** sequence of that index b-tree. Otherwise, if P4 is an integer
94491 ** Open a read/write cursor named P1 on the table or index whose root
94497 ** object, then table being opened must be an [index b-tree] where the
94499 ** sequence of that index b-tree. Otherwise, if P4 is an integer
94509 ** and subsequently delete entries in an index btree. This is a
94542 ** index, then fall through into OP_OpenRead to force a reopen */
94678 ** The cursor points to a BTree table if P4==0 and to a BTree index
94680 ** that defines the format of keys in the index.
94740 /* If a transient index is required, create it by calling
94778 ** a transient index that is specifically designed to sort large
94870 ** table or index for cursor P1 are used. P4 is a 64-bit integer
94872 ** first 63 columns of the table or index that are actually used
94890 ** to an SQL index, then P3 is the first in an array of P4 registers
94891 ** that are used as an unpacked index key.
94917 ** to an SQL index, then P3 is the first in an array of P4 registers
94918 ** that are used as an unpacked index key.
94935 ** to an SQL index, then P3 is the first in an array of P4 registers
94936 ** that are used as an unpacked index key.
94953 ** to an SQL index, then P3 is the first in an array of P4 registers
94954 ** that are used as an unpacked index key.
95008 /* The OPFLAG_SEEKEQ/BTREE_SEEK_EQ flag is only set on index cursors */
95189 ** This opcode helps to optimize IN operators on a multi-column index
95190 ** where the IN operator is on the later terms of the index by avoiding
95235 ** to sqlite3BtreeNext() moved the cursor off the end of the index
95358 ** The seekHit integer represents the maximum of terms in an index for which
95360 ** than the total number of equality terms in an index lookup, then the
95415 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
95432 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
95448 ** record. Cursor P1 is an index btree. P2 is a jump destination.
95457 ** a key P3:N that will match some record in the index. We want to know
95459 ** index. If it is not possible, we can skips some work. So if seekHit
95482 ** Cursor P1 is on an index btree. If the record identified by P3 and P4
95485 ** P1 index btree has a matching key prefix. If there are no matches, jump
95600 ** P1 is the index of a cursor open on an SQL table btree (with integer
95612 ** The OP_NotFound opcode performs the same operation on index btrees
95624 ** P1 is the index of a cursor open on an SQL table btree (with integer
95635 ** The OP_NotFound opcode performs the same operation on index btrees
95983 ** of table - intkey or index. This opcode is used as part of copying
95986 ** P1. If they are opened on index tables, P3 is not used.
96021 ** associated index entries. Exactly one of those deletes is the "primary"
96223 ** If cursor P1 is an index, then the content is the key of the row.
96382 ** will refer to the last entry in the database table or index.
96383 ** If the table or index is empty and P2>0, then jump immediately to P2.
96384 ** If P2 is 0 or if the table or index is not empty, fall through
96468 ** Sorting is accomplished by writing records into a sorting index,
96469 ** then rewinding that index and playing it back from beginning to
96488 ** will refer to the first entry in the database table or index.
96489 ** If the table or index is empty, jump immediately to P2.
96490 ** If the table or index is not empty, fall through to the following
96532 ** table or index. If there are no more key/value pairs then fall through
96544 ** means P1 is an SQL index and that this instruction could have been
96545 ** omitted if that index had been unique. P3 is usually 0. P3 is
96556 ** table or index. If there is no previous key/value pairs then fall through
96569 ** means P1 is an SQL index and that this instruction could have been
96570 ** omitted if that index had been unique. P3 is usually 0. P3 is
96641 ** Register P2 holds an SQL index key made using the
96643 ** into the index P1. Data for the entry is nil.
96646 ** key of reg(P2). In that case, P3 is the index of the first register
96699 ** Register P2 holds an SQL index key made using the
96725 ** an unpacked index key. This opcode removes that entry from the
96726 ** index opened by cursor P1.
96729 ** if no matching index entry is found. This happens when running
96730 ** an UPDATE or DELETE statement and the index entry to be updated
96761 rc = sqlite3ReportError(SQLITE_CORRUPT_INDEX, __LINE__, "index corruption");
96773 ** P1 is an open index cursor and P3 is a cursor on the corresponding
96793 ** the end of the index key pointed to by cursor P1. This integer should be
96794 ** the rowid of the table entry to which this index entry points.
96800 VdbeCursor *pC; /* The P1 index cursor */
96862 VdbeCursor *pC; /* The P1 index cursor */
96876 ** The P4 register values beginning with P3 form an unpacked index
96877 ** key that omits the PRIMARY KEY. Compare this key value against the index
96881 ** If the P1 index entry is greater than or equal to the key value
96887 ** The P4 register values beginning with P3 form an unpacked index
96888 ** key that omits the PRIMARY KEY. Compare this key value against the index
96892 ** If the P1 index entry is greater than the key value
96898 ** The P4 register values beginning with P3 form an unpacked index
96900 ** the index that P1 is currently pointing to, ignoring the PRIMARY KEY or
96901 ** ROWID on the P1 index.
96903 ** If the P1 index entry is less than the key value then jump to P2.
96909 ** The P4 register values beginning with P3 form an unpacked index
96911 ** the index that P1 is currently pointing to, ignoring the PRIMARY KEY or
96912 ** ROWID on the P1 index.
96914 ** If the P1 index entry is less than or equal to the key value then jump
96993 ** Delete an entire database table or index whose root page in the database
97053 ** Delete all contents of the database table or index whose root page
97055 ** remove the table or index from the database file.
97119 ** it must be 2 (BTREE_BLOBKEY) for an index or WITHOUT ROWID table.
97238 ** of that table into the internal index hash table. This will cause
97266 ** the index named P4 in database P1. This is called after an index
97384 /* The boolean index is empty */
97389 /* A value was pulled from the index */
98252 ** P1 is the index of the database in sqlite3.aDb[] of the database
98461 /* Grab the index number and argc parameters */
99807 ** the complete record for an index entry
99988 ** aTree element is set to the index of it.
99992 ** values), it doesn't matter which index is stored.
99995 ** above contains the index of the smallest of each block of 4 PmaReaders
99996 ** And so on. So that aTree[1] contains the index of the PmaReader that
100686 ** Initialize the temporary index cursor just opened as a sorter cursor.
101424 /* If pReadr1 contained the smaller value, set aTree[i] to its index.
101430 ** set aTree[i] to its index and update pReadr1. If vdbeSorterCompare()
102771 pCur->zType = "index";
103886 ** pExpr->iDb Set the index in db->aDb[] of the database X
104397 ** index is a covering index. The correct answer is still obtained
104489 const char *zIn = "partial index WHERE clauses";
104490 if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
104736 ** in an index or generated column. Curiously, they can be used
105019 ** ORDER BY term is not an integer index into the result set. That
105023 ** SELECT statement. Return the index i of the matching column,
105062 ** in the result set. Return an 1-based index of the matching
105081 int i, /* The index (1-based) of the term out of range */
105621 ** Expr.iColumn The column index in X.Y. -1 for the rowid.
106115 ** if the index with affinity idx_affinity may be used to implement
108325 p->y.pTab==0 || /* Reference to column of index on expression */
108435 ** Generate code that checks the left-most column of index table iCur to see if
108479 ** and the *piTab parameter is set to the index of that cursor.
108484 ** IN_INDEX_INDEX_ASC - The cursor was opened on an ascending index.
108485 ** IN_INDEX_INDEX_DESC - The cursor was opened on a descending index.
108507 ** membership test. When the IN_INDEX_LOOP bit is set, the IN index will
108514 ** a UNIQUE constraint or index.
108519 ** index can be found with the specified <columns> as its left-most.
108544 ** offset of the index column that matches the i'th column returned by the
108545 ** SELECT. For example, if the expression and selected index are:
108559 int *piTab /* OUT: index to use */
108587 /* Check to see if an existing table or index can be used to
108627 ** use any index of the RHS table. */
108651 /* Search for an existing index that will work for this IN operator */
108653 Bitmask colUsed; /* Columns of the index used */
108666 continue; /* This index is not unique over the IN RHS columns */
108670 colUsed = 0; /* Columns of index used so far */
108695 /* If we reach this point, that means the index pIdx is usable */
108720 } /* End if not an rowid index */
108721 } /* End attempt to optimize using an index */
108723 /* If no preexisting index is available for the IN clause
108741 /* Could not find an existing table or index to use as the RHS b-tree.
108858 ** column is used to build the index keys. If both 'x' and the
108984 ** For each expression, build an index key from the evaluation and
108986 ** that columns affinity when building index keys. If <expr> is not
109114 ** the first row into an array of registers and return the index of
109239 int *aiMap = 0; /* Map from vector field to index column */
109293 ** so that the fields are in the same order as an existing index. The
109295 ** the field order that matches the RHS index.
109316 /* If sqlite3FindInIndex() did not find or create an index that is
109540 ** appropriate for the iIdxCol-th column of index pIdx.
109544 Index *pIdx, /* The index whose column is to be loaded */
109546 int iIdxCol, /* The column of the index to be loaded */
109547 int regOut /* Store the index column value in this register */
109690 ** the result in continguous temporary registers. Return the index of
109854 ** If it is, then resolve the expression by reading from the index and
109876 /* If the index is on a NULL row due to an outer join, then we
109877 ** cannot extract the value from the index. The value must be
109991 ** generated columns or for inserting into partial index.
110034 /* Coding an expression that is part of an index where column names
110035 ** in the index refer to the table to which the index belongs */
110479 ** i is the index of the column. For a new.rowid reference, p1 is
111795 ** index only, without having to do a search for the corresponding
111796 ** table entry. The IdxCover.pIdx field is the index. IdxCover.iCur
111800 Index *pIdx; /* The index to be tested for coverage */
111801 int iCur; /* Cursor number for the table corresponding to the index */
111806 ** pWalker->u.pIdxCover->iCur can be satisfied using the index
111821 ** Determine if an index pIdx on table with cursor iCur contains will
111822 ** the expression pExpr. Return true if the index does cover the
111824 ** that are not found in the index pIdx.
111826 ** An index covering an expression means that the expression can be
111827 ** evaluated using only the index and without having to lookup the
111831 Expr *pExpr, /* The index to be tested */
111833 Index *pIdx /* The index that might be used for coverage */
112027 ** Add a new element to the pAggInfo->aCol[] array. Return the index of
112043 ** Add a new element to the pAggInfo->aFunc[] array. Return the index of
112478 /* Check that a table or index named 'zName' does not already exist
112486 "there is already another table or index with this name: %s", zName);
112545 "WHERE (type!='index' OR tbl_name=%Q COLLATE nocase)"
112558 " AND type='index' THEN "
112562 "(type='table' OR type='index' OR type='trigger');",
112758 ** index.
112953 ** altered. Set iCol to be the index of the column being renamed */
112981 " AND (type != 'index' OR tbl_name = %Q)",
114297 ** 2: Object type ("view", "table", "trigger" or "index").
114379 ** argv[0]: An integer - the index of the schema containing the table
114381 ** argv[2]: An integer - the index of the column to remove.
114471 /* Find the index of the column being dropped. */
114649 ** There is normally one row per index, with the index identified by the
114651 ** which the index belongs. In each such row, the stat column will be
114653 ** list is the number of rows in the index. (This is the same as the
114655 ** integer is the average number of rows in the index that have the same
114656 ** value in the first column of the index. The third integer is the average
114657 ** number of rows in the index that have the same value for the first two
114659 ** the index which have the same value for the first N-1 columns. For
114660 ** a K-column index, there will be K+1 integers in the stat column. If
114661 ** the index is unique, then the last integer will be 1.
114667 ** the index is unordered and will not use the index for a range query.
114678 ** about the distribution of keys within an index. The index is identified by
114680 ** the index belongs. There are usually 10 rows in the sqlite_stat2
114681 ** table for each index.
114683 ** The sqlite_stat2 entries for an index that have sampleno between 0 and 9
114684 ** inclusive are samples of the left-most key value in the index taken at
114685 ** evenly spaced points along the index. Let the number of samples be S
114686 ** (10 in the standard build) and let C be the number of rows in the index.
114691 ** For i between 0 and S-1. Conceptually, the index space is divided into
114712 ** The sqlite_stat4 table contains multiple entries for each index.
114713 ** The idx column names the index and the tbl column is the table of the
114714 ** index. If the idx and tbl columns are the same, then the sample is
114716 ** binary encoding of a key from the index. The nEq column is a
114718 ** of entries in the index whose left-most column exactly matches
114720 ** is the approximate number of entries in the index where the
114724 ** integer in nLt contains the number of entries in the index where the
114726 ** The K-th integer in the nLt entry is the number of index entries
114729 ** number of distinct entries in the index that are less than the
114732 ** There can be an arbitrary number of sqlite_stat4 entries per index.
114741 ** looks at the left-most column of the index. The sqlite_stat3.sample
114743 ** of a blob encoding of the complete index key as is found in
114776 const char *zWhere, /* Delete entries for this table or index */
114892 int nCol; /* Number of columns in index + pk/rowid */
114893 int nKeyCol; /* Number of index columns w/o the pk/rowid */
114987 ** N: The number of columns in the index including the rowid/pk (note 1)
114988 ** K: The number of columns in the index excluding the rowid/pk.
114989 ** C: Estimated number of rows in the index
114992 ** Note 1: In the special case of the covering index that implements a
114998 ** PRIMARY KEY of the table. The covering index that implements the
115012 int nCol; /* Number of columns in index being sampled */
115250 ** Field iChng of the index being scanned has changed. So at this point
115252 ** index. The value of anEq[iChng] and subsequent anEq[] elements are
115268 /* Check that no sample contains an anEq[] entry with an index of
115298 ** samples from the index being analyzed into the StatAccum object.
115333 ** to the current row of the index. */
115440 ** table for this index.
115443 ** the index. The first integer in the list is the total number of
115444 ** entries in the index. There is one additional integer in the list
115446 ** the number of rows matched by a equality query on the index using
115448 ** if the index is on columns (a,b) and the sqlite_stat1 value is
115451 ** * the index contains 100 rows,
115549 ** of the k-th column of the pIdx index.
115554 int k /* Which column index */
115579 Index *pOnlyIdx, /* If not NULL, only analyze this one index */
115585 Index *pIdx; /* An index to being analyzed */
115586 int iIdxCur; /* Cursor open on index being analyzed */
115595 int regChng = iMem++; /* Index of changed index field */
115600 int regIdxname = iMem++; /* Register containing index name */
115645 ** to use for scanning indexes (iIdxCur). No index cursor is opened at
115658 const char *zIdxName; /* Name of the index */
115673 /* Populate the register containing the index name. */
115715 /* Open a read-only cursor on the index being analyzed. */
115723 ** (1) the number of columns in the index including the rowid
115726 ** (3) estimated number of rows in the index,
115778 /* For a single-column UNIQUE index, once we have found a non-NULL
115913 /* Create a single sqlite_stat1 entry containing NULL as the index
115935 ** Generate code that will cause the most recent index analysis to
115972 ** a database. If pOnlyIdx is not NULL then it is a single index
116034 /* Form 3: Analyze the table or index named as an argument */
116074 Index *pIndex /* Handle extra flags for this index, if not NULL */
116132 ** This callback is invoked once for each index when reading the
116136 ** argv[1] = name of the index (might be NULL)
116172 ** sqlite_stat1 entries for this index. In that case just clobber
116239 ** once the trailing PK fields are considered all index keys are
116249 tRowcnt nRow; /* Number of rows in index */
116251 i64 nDist100; /* Number of distinct values in index */
116264 ** occur in the stat4 table for this index. Set sumEq to the sum of
116286 ** Look up an index by name. Or, if the name of a WITHOUT ROWID table
116287 ** is supplied instead, find the PRIMARY KEY index for that table.
116323 Index *pPrevIdx = 0; /* Previous index in the loop */
116339 Index *pIdx; /* Pointer to the index object */
116390 Index *pIdx; /* Pointer to the index object */
116391 int nCol = 1; /* Number of columns in index */
117089 const char *zType, /* "view", "trigger", or "index" */
117090 const Token *pName /* Name of the view, trigger, or index */
117115 ** These routines are used to make sure that an index, trigger, or
117335 int iDb; /* The index of the database the expression refers to */
117987 ** a particular index given the name of that index
117988 ** and the name of the database that contains the index.
117992 ** table and the first matching index is returned. (No checking
117993 ** for duplicate index names is done.) The search order is
118015 ** Reclaim the memory used by an index
118032 ** For the index called zIdxName which is found in the database iDb,
118033 ** unlike that index from its Table then remove the index from
118034 ** the index hash table and free all memory structures associated
118035 ** with the index.
118049 /* Justification of ALWAYS(); The index must be on the list of
118093 ** Reset the schema for the database at index iDb. Also reset the
118412 ** function returns the index of the named database in db->aDb[], or
118432 ** index of the named database in db->aDb[], or -1 if the named db
118457 ** pName2) that stores the unqualified table name. The index of the
118506 ** unqualified name for a new schema object (table, index, view or
118551 ** Return the PRIMARY KEY index of a table
118560 ** Convert an table column number into a index column number. That is,
118562 ** find the (first) offset of that column in index pIdx. Or return -1
118563 ** if column iCol is not used in index pIdx.
118576 ** The storage column number (0,1,2,....) is the index of the value
118578 ** is the index (0,1,2,...) of the column in the CREATE TABLE statement.
118599 ** The storage column number (0,1,2,....) is the index of the value
118604 ** The true column number is the index (0,1,2,...) of the column in
118749 ** index or table name in the same database. Issue an error message if
118773 sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);
119297 ** field of the table under construction to be the index of the
119302 ** index for the key. No index is created for INTEGER PRIMARY KEYs.
119432 ** then an index may have been created on this column before the
119688 ** Estimate the average size of a row for an index.
119704 ** first nCol entries of an index.
119716 ** Return true if any of the first nKey entries of index pIdx exactly
119718 ** PRIMARY KEY index. pIdx is an index on the same table. pIdx may
119719 ** or may not be the same index as pPk.
119753 ** all other bits (all columns that are not in the index). The
119758 ** not considered to be covered by the index, even if they are in the
119759 ** index, because we do not trust the logic in whereIndexExprTrans() to be
119761 ** and convert them into references to the index. Hence we always want
119766 ** to determine if the index is covering index.
119795 ** for the PRIMARY KEY as the primary key index is now
119800 ** so that the PRIMARY KEY is a covering index. The surplus
119839 /* Locate the PRIMARY KEY index. Or, if this table was originally
119840 ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index.
119918 /* This index is a superset of the primary key */
119939 /* Add all table columns to the PRIMARY KEY index
120046 ** index definition are tagged this way to help ensure that we do
120098 Index *pIdx; /* An implied index of the table */
120676 ** root-page of a table or index in database iDb has changed from iFrom
120682 ** have the same rootpage number as the real table or index that is
120685 ** or tables and not the table/index that is actually being moved.
120754 ** table and index root-pages in order, starting with the numerically
120804 const char *zName /* Name of index or table */
121196 ** Generate code that will erase and refill index *pIdx. This is
121197 ** used to initialize a newly created index or to recompute the
121198 ** content of an index in response to a REINDEX command.
121200 ** if memRootPage is not negative, it means that the index is newly
121202 ** root page number of the index. If memRootPage is negative, then
121203 ** the index already exists and must be cleared before being refilled and
121204 ** the root page number of the index is taken from pIndex->tnum.
121213 Pgno tnum; /* Root page of index */
121216 KeyInfo *pKey; /* KeyInfo for index */
121217 int regRecord; /* Register holding assembled index record */
121246 /* Open the table. Loop through all rows of the table, inserting index
121285 /* This OP_SeekEnd opcode makes index insert for a REINDEX go much
121314 i16 nCol, /* Total number of columns in the index */
121318 Index *p; /* Allocated index object */
121362 ** Create a new index for an SQL table. pName1.pName2 is the name of the index
121364 ** be NULL for a primary key or an index that is created to satisfy a
121375 Token *pName1, /* First part of index name. May be NULL */
121376 Token *pName2, /* Second part of index name. May be NULL */
121377 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */
121383 int ifNotExist, /* Omit error if index already exists */
121384 u8 idxType /* The index type */
121387 Index *pIndex = 0; /* The index to be created */
121388 char *zName = 0; /* Name of the index */
121392 int sortOrderMask; /* 1 to honor DESC in index. 0 to ignore. */
121396 Token *pName = 0; /* Unqualified name of the index to create */
121401 Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
121423 /* Use the two-part index name to determine the database
121433 /* If the index name was unqualified, check if the table
121445 sqlite3FixInit(&sFix, pParse, iDb, "index", pName);
121456 "cannot create a TEMP index on non-TEMP table \"%s\"",
121495 ** Find the name of the index. Make sure there is not already another
121496 ** index or table with the same name.
121500 ** one of the index names collides with the name of a temporary table or
121501 ** index, then we will continue to process this index.
121511 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName,"index",pTab->zName) ){
121523 sqlite3ErrorMsg(pParse, "index %s already exists", zName);
121541 /* Automatic index names generated from within sqlite3_declare_vtab()
121542 ** must have names that are distinct from normal automatic index names.
121549 /* Check for authorization to create an index.
121580 sqlite3ExprListCheckLength(pParse, pList, "index");
121597 ** Allocate the index structure.
121625 /* Check to see if we should honor DESC requests on index columns
121633 /* Analyze the list of expressions that form the terms of the index and
121638 ** TODO: Issue a warning if two or more columns of the index are identical.
121640 ** index key.
121648 Expr *pCExpr; /* The i-th index expression */
121709 /* Append the table key to the end of the index. For WITHOUT ROWID
121735 /* If this index contains every column of its table, then mark
121736 ** it as a covering index */
121751 /* This routine has been called to create an automatic index as a
121759 ** Either way, check to see if the table already has such an index. If
121791 /* This constraint creates the same index as a previous
121796 ** explicitly specified behavior for the index.
121846 ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then
121847 ** emit code to allocate the index rootpage on disk and make an entry for
121848 ** the index in the sqlite_schema table and populate the index with
121850 ** table to parse the schema, or if this index is the PRIMARY KEY index
121853 ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY
121854 ** or UNIQUE index in a CREATE TABLE statement. Since the table
121855 ** has just been created, it contains no data and the index initialization
121868 /* Create the rootpage for the index using CreateIndex. But before
121870 ** Index.tnum. This is required in case this index is actually a
121884 /* A named index with an explicit CREATE INDEX statement */
121888 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
121893 /* Add an entry in sqlite_schema for this index
121896 "INSERT INTO %Q." LEGACY_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);",
121905 /* Fill the index with data and reparse the schema. Code an OP_Expire
121912 sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName), 0);
121936 ** point at most a single index (the newly added index) will be out of
121937 ** order. So we have to reorder at most one index. */
121953 ** of the index list. In other words, no other index type ever
121954 ** comes after a REPLACE index on the list. */
121972 ** aiRowEst[0] is supposed to contain the number of elements in the index.
121975 ** first column of the index. aiRowEst[2] is an estimate of the number
121977 ** of the index. And so forth. It must always be the case that
121997 /* Set the first entry (number of rows in the index) to the estimated
121999 ** for a partial index.
122027 ** This routine will drop an existing named index. This routine
122047 sqlite3ErrorMsg(pParse, "no such index: %S", pName->a);
122056 sqlite3ErrorMsg(pParse, "index associated with UNIQUE "
122077 /* Generate code to remove the index and from the schema table */
122082 "DELETE FROM %Q." LEGACY_SCHEMA_TABLE " WHERE name=%Q AND type='index'",
122107 ** returned. *pIdx is set to the index of the new array entry in this case.
122117 int *pIdx /* Write the index of a new slot here */
122181 ** Return the index in pList of the identifier named zId. Return -1
122357 ** Assign VdbeCursor index numbers to all tables in a SrcList
122752 ** inserting multiple rows in a table, or inserting a row and index entries.)
122812 Index *pIdx /* The index that triggers the constraint */
122822 sqlite3_str_appendf(&errMsg, "index '%q'", pIdx->zName);
122890 Index *pIndex; /* An index associated with pTab */
122911 int iDb; /* The database index number */
122937 ** collating function. Forms 3 and 4 rebuild the named index or all
122943 char *z; /* Name of a table or index */
122946 Index *pIndex; /* An index associated with pTab */
122947 int iDb; /* The database index number */
122949 Token *pObjName; /* Name of the table or index to be reindexed */
123024 /* Deactivate the index because it contains an unknown collating
123025 ** sequence. The only way to reactive the index is to reload the
123027 ** reactive the index. The application had the chance to register
123028 ** the missing index using the collation-needed callback. For
123725 ** pSrc->a[0].pIndex Pointer to the INDEXED BY index, if there is one
123988 int iIdxCur = 0; /* Cursor number of the first index */
123999 Index *pPk; /* The PRIMARY KEY index on the table */
124398 ** in the case of a rowid table, or the PRIMARY KEY index in the case
124402 ** cursor number iIdxCur+i for the i-th index.
124425 ** then it identifies an index cursor (from within array of cursors
124426 ** starting at iIdxCur) that already points to the index entry to be deleted.
124435 int iIdxCur, /* First index cursor */
124520 /* Delete the index and table entries. Skip this step if pTab is really
124566 ** index entries associated with a single row of a single table, pTab
124572 ** for rowid tables or to the primary key index for WITHOUT ROWID
124576 ** cursor number iIdxCur+i for the i-th index. (The pTab->pIndex
124577 ** index is the 0-th index.)
124586 int iIdxCur, /* First index cursor */
124591 int r1 = -1; /* Register holding an index key */
124592 int iPartIdxLabel; /* Jump destination for skipping partial index entries */
124593 Index *pIdx; /* Current index */
124594 Index *pPrior = 0; /* Prior index */
124596 Index *pPk; /* PRIMARY KEY index, or NULL for rowid tables */
124617 ** Generate code that will assemble an index key and stores it in register
124618 ** regOut. The key with be for index pIdx which is an index on pTab.
124619 ** iCur is the index of a cursor open on the pTab table and pointing to
124621 ** iCur must be the cursor of the PRIMARY KEY index.
124624 ** registers that holds the elements of the index key. The
124629 ** to that label if pIdx is a partial index that should be skipped.
124631 ** A partial index should be skipped if its WHERE clause evaluates
124632 ** to false or null. If pIdx is not a partial index, *piPartIdxLabel
124638 ** a pointer to a different index for which an index key has just been
124639 ** computed into register regPrior. If the current pIdx index is generating
124645 ** PRIMARY KEY columns of the index.
124649 Index *pIdx, /* The index for which to generate a key */
124653 int *piPartIdxLabel, /* OUT: Jump to this label to skip partial index */
124654 Index *pPrior, /* Previously generated index key */
124683 /* This column was already computed by the previous index */
124691 ** But we are getting ready to store this value back into an index, where
124706 ** because it was a partial index, then this routine should be called to
126033 ** whose index is a power of two: 1, 2, 4, 8, 16, 32, ... */
127271 ** search the schema for a unique index on the parent key columns.
127275 ** is set to point to the unique index.
127281 ** array is the index of the child table column that is mapped by the FK
127283 ** of index *ppIdx. The second element of the array is the index of the
127287 ** If the required index cannot be found, either because:
127310 FKey *pFKey, /* Foreign key to find index for */
127311 Index **ppIdx, /* OUT: Unique index on parent table */
127312 int **paiCol /* OUT: Map of index columns in pFKey */
127355 /* pIdx is a UNIQUE index (or a PRIMARY KEY) and has the right number
127357 ** column of pFKey, then this index is a winner. */
127361 ** the PRIMARY KEY of table pParent. The PRIMARY KEY index may be
127373 ** index matches those columns. Also, check that the index uses
127383 /* If the index uses a collation sequence that is different from
127384 ** the default collation sequence for the column, this index is
127448 Index *pIdx, /* Unique index on parent key columns in pTab */
127996 ** For a DELETE operation, parameter regOld is passed the index of the
128053 /* Find the parent table of this foreign key. Also find a unique index
128112 ** a cursor to use to search the unique index on the parent key columns
128141 Index *pIdx = 0; /* Foreign key index for pFKey */
128352 Index *pIdx = 0; /* Parent key index for this FK */
128625 ** If pTab is a WITHOUT ROWID table, then it is the PRIMARY KEY index
128631 int iDb, /* The database index in sqlite3.aDb[] */
128656 ** Return a pointer to the column affinity string associated with index
128669 ** rowid that appears as the last column in every index.
128671 ** Memory for the buffer containing the column index affinity string
128677 /* The first time a column affinity string for a particular index is
129233 ** foreach index on <table>
129234 ** open a write cursor on the <table> index
129235 ** open a read cursor on the corresponding <table2> index
129301 int iIdxCur = 0; /* First index cursor */
129323 int *aRegIdx = 0; /* One register allocated to each index */
129453 ** the index into IDLIST of the primary key column. ipkColumn is
129454 ** the index of the primary key as it appears in IDLIST, not as
129455 ** is appears in the original table. (The index of the INTEGER
129596 ** column index in the original table definition.
129930 /* Generate code to check constraints and generate index keys and
130086 ** 2018-09-15: pExpr might also be an expression for an index-on-expressions.
130140 /* When IndexIterator.eType==1, then each index is an array of instances
130144 Index *p; /* The index */
130145 int ix; /* Which entry in the original Table.pIndex list is this index*/
130148 /* Return the first index on the list */
130160 /* Return the next index from the list. Return NULL when out of indexes */
130206 ** The code generated by this routine will store new index entries into
130207 ** registers identified by aRegIdx[]. No index entry is created for
130215 ** entry of aRegIdx[] past the last index. It is important that the
130224 ** index when operating on a WITHOUT ROWID table. iIdxCur is the cursor
130225 ** for the first index in the pTab->pIndex list. Cursors for other indices
130271 int *aRegIdx, /* Use register aRegIdx[i] for index i. 0 for unused */
130272 int iDataCur, /* Canonical data cursor (main table or PK index) */
130273 int iIdxCur, /* First index cursor */
130285 Index *pPk = 0; /* The PRIMARY KEY index for WITHOUT ROWID tables */
130316 /* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for
130318 ** pPk index or 1 for a rowid table. In other words, nPkField is the
130498 ** (B) Unique index constraints that do not have OE_Replace as their
130500 ** (C) Unique index that do use OE_Replace by default.
130690 ** the triggers and remove both the table and index b-tree entries.
130694 ** GenerateRowIndexDelete(). This removes the index b-tree entries
130755 ** index and making sure that duplicate entries do not already exist.
130758 ** This loop also handles the case of the PRIMARY KEY index for a
130767 int iThisCur; /* Cursor for this UNIQUE index */
130783 VdbeNoopComment((v, "prep index %s", pIdx->zName));
130796 /* Create a record for this index entry as it should appear after
130828 /* In an UPDATE operation, if this index is the PRIMARY KEY index
130841 continue; /* pIdx is not a UNIQUE index */
130849 /* Figure out if the upsert clause applies to this index */
130883 /* Check to see if the new index entry will be unique */
130894 /* Conflict only if the rowid of the existing index entry
130903 /* Extract the PRIMARY KEY from the end of the index entry and
130919 ** For a UNIQUE index, only conflict if the PRIMARY KEY values
130920 ** of the matched index row are different from the original PRIMARY
130946 /* Generate code that executes if the new index entry is not unique */
131004 /* Bypass the recheck if this partial index is not defined
131122 ** PK index. This function adds code to invoke the pre-update hook,
131158 int iIdxCur, /* First index cursor */
131160 int *aRegIdx, /* Register used by each index. 0 for unused indices */
131166 Index *pIdx; /* An index being inserted or updated */
131226 ** the table itself, but the PRIMARY KEY index in the case of a WITHOUT
131227 ** ROWID table) is returned in *piDataCur. The first index cursor is
131231 ** or the first index for WITHOUT ROWID tables) if it is non-negative.
131236 ** of *piIdxCurs, depending on where the PRIMARY KEY index appears on the
131248 u8 *aToOpen, /* If not NULL: boolean for each table and index */
131250 int *piIdxCur /* Write the first index cursor number here */
131311 ** Check to see if index pSrc is compatible as a source of data
131312 ** for index pDest in an insert transfer optimization. The rules
131313 ** for a compatible index:
131315 ** * The index is over the same set of columns
131319 ** * The index has the exact same WHERE clause
131339 return 0; /* Different expressions in the index */
131364 ** performance. Raw index records are transferred in the same way.
131402 int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
131565 return 0; /* pDestIdx has no corresponding index in pSrc */
131630 ** of index entries might need to change.)
131632 ** (2) The destination has a unique index. (The xfer optimization
131708 ** index will be populated by inserting keys in strictly sorted
134631 int iDb; /* Database index for <database> */
134649 ** index of the database this pragma is being applied to in db.aDb[]. */
135581 /* If there is no index named zRight, check to see if there is a
135583 ** structure of the PRIMARY KEY index for that table. */
135828 /* Generate code to query the parent index for a matching parent
135909 ** then iDb is set to the index of the database identified by <db>.
135960 Index *pIdx; /* An index on pTab */
136004 Index *pPrior = 0; /* Previous index */
136025 ** reg[8+i] counts the number of entries in the i-th index
136029 sqlite3VdbeAddOp2(v, OP_Integer, 0, 8+j); /* index entries counter */
136212 /* Validate index entries for the current row */
136221 /* Verify that an index entry exists for the current table row */
136226 sqlite3VdbeLoadString(v, 4, " missing from index ");
136251 sqlite3VdbeLoadString(v, 3, "non-unique entry in index ");
136262 sqlite3VdbeLoadString(v, 2, "wrong # of entries in index ");
136397 ** creating or dropping a table or index). The schema version is used by
136586 Index *pIdx; /* An index of the table */
136614 szThreshold = 0; /* Always analyze if any index lacks statistics */
136722 ** in each index that it looks at. Return the new limit.
136921 /* Figure out the best index to use to search a pragma virtual table.
136923 ** There are not really any index choices. But we want to encourage the
137200 ** Check to see if any sibling index (another index on the same table)
137231 ** argv[0] = type of object: "table", "index", "trigger", or "view".
137233 ** argv[2] = associated table if an index or trigger
137234 ** argv[3] = root page number for table or index. 0 for trigger or view.
137263 ** structures that describe the table, index, or view.
137309 /* If the SQL column is blank it means this is an index that
137311 ** constraint for a CREATE TABLE. The index should have already
137313 ** to do here is record the root page number for that index.
137318 corruptSchema(pData, argv, "orphan index");
137335 ** data structures for a single database file. The index of the
137678 ** Convert a schema pointer into the iDb index that indicates
137693 ** -32768 as the incorrect index into db->aDb[] is much
138245 ** example, assuming there is no index that can be used for the ORDER BY,
138520 ** Return the index of a column in a table. Return -1 if the column
138554 ** When found, set *piTab and *piCol to the table index and column index
138564 int *piTab, /* Write index of pSrc->a[] here */
138565 int *piCol, /* Write index of pSrc->a[*piTab].pTab->aCol[] here */
139096 int iTab, /* A sorting index used to test for distinctness */
139207 ** statement with an ORDER BY that is not optimized by an index. It
139397 ** iOrderByCol value to one more than the index of the ORDER BY
139534 ** on an ephemeral index. If the current row is already present
139535 ** in the index, do not write it to the output. If not, add the
139536 ** current row to the index and proceed with writing it to the
139652 ** index with pSO->nExpr+2 columns. Build a key using pSO for the first
139670 ** on a second ephemeral index that holds all values every previously
139721 ** Allocate a KeyInfo object sufficient for an index of N key columns and
139779 ** KeyInfo structure is appropriate for initializing a virtual index to
139782 ** index to implement a DISTINCT test.
143493 ** INDEXED BY clause, then try to locate the specified index. If there
143494 ** was such a clause and the named index cannot be found, return
143510 sqlite3ErrorMsg(pParse, "no such index: %s", zIndexedBy, 0);
143773 sqlite3ErrorMsg(pParse, "no such index: \"%s\"", pFrom->u1.zIndexedBy);
144089 /* Locate the index named by the INDEXED BY clause, if any. */
144165 int iDb; /* Schema index for this data src */
145393 ** The second form is preferred as a single index (or temp-table) may be
145396 ** BY and DISTINCT, and an index or separate temp-table for the other.
145421 /* If there is an ORDER BY clause, then create an ephemeral index to
145422 ** do the sorting. But this sorting ephemeral index might end up
145425 ** changed to an OP_Noop once we figure out that the sorting index is
145473 /* Open an ephemeral index to use for the distinct set.
145520 /* If sorting index that was created by a prior OP_OpenEphemeral
145596 ** database index that causes rows to be grouped together as required
145717 int addrSortingIdx; /* The OP_OpenEphemeral for the sorting index */
145737 /* If there is a GROUP BY clause we might need a sorting index to
145738 ** implement it. Allocate that sorting index now. If it turns out
145767 ** it might be a single loop that uses an index to extract information
145790 ** each row into a sorting index, terminate the first loop,
145791 ** then loop over the sorting index in order to get the output
145840 /* If the index or temporary table used by the GROUP BY sort
145974 ** is better to execute the op on an index, as indexes are almost
145980 KeyInfo *pKeyInfo = 0; /* Keyinfo for scanned index */
145981 Index *pBest = 0; /* Best index found so far */
145987 /* Search for the index that has the lowest scan cost.
145989 ** (2011-04-15) Do not do a full scan of an unordered index.
145991 ** (2013-10-03) Do not count the entries in a partial index.
147789 ** with an index greater than 32 may be accessed, 0xffffffff is returned.
147927 ** Check to see if column iCol of index pIdx references any of the
147931 ** index and incorrect answers.
147938 Index *pIdx, /* The index to check */
147939 int iCol, /* Which column of the index to check */
147944 assert( iIdxCol!=XN_ROWID ); /* Cannot index rowid */
147956 ** Check to see if index pIdx is a partial index whose conditional
147958 ** the index is subject to change and false if the index is guaranteed
147961 ** index and incorrect answers.
147968 Index *pIdx, /* The index to check */
148015 ** table iEph as index keys, using OP_IdxInsert.
148140 Index *pPk; /* The PRIMARY KEY index for WITHOUT ROWID tables */
148145 int iIdxCur; /* Cursor for the first index */
148147 int *aRegIdx = 0; /* Registers for to each index and the main table */
148148 int *aXRef = 0; /* aXRef[i] is the index in pChanges->a[] of the
148255 ** The index cursors might not be used, but if they are used they
148300 ** of the UPDATE statement. Also find the column index
148407 /* There is one entry in the aRegIdx[] array for each index on the table
148409 ** the key for accessing each index.
148572 ** or index, causing a single-pass approach to malfunction. */
148581 ** be used if any column of the index used for the scan is being
148582 ** updated. Otherwise, if there is an index on "b", statements like
148588 ** strategy that uses an index for which one or more columns are being
148646 /* Open every index that needs updating. */
148757 ** table and index records, and as the values for any new.* references
148882 /* Delete the index entries associated with the current record. */
148901 ** is the column index supplied by the user.
148926 /* Insert the new index entries and the new record. */
149122 Index *pPk; /* PRIMARY KEY index */
149302 ** includes both the list of columns and the optional partial-index
149330 ** single column of an index. The sCol[0] node will be the TK_COLLATE
149373 break; /* Column ii of the index matches column jj of target */
149377 /* The target contains no match for column jj of the index */
149382 /* Column ii of the index did not match any term of the conflict target.
149383 ** Continue the search with the next index. */
149421 ** a particular index pIdx, return a pointer to the particular ON CONFLICT
149422 ** clause that applies to the index. Or, if the index is not subject to
149811 " WHERE type='index'",
151406 int iBase; /* Base register of multi-key index record */
151411 Index *pCoveringIdx; /* Possible covering index for WHERE_MULTI_OR */
151441 u8 iSortIdx; /* Sorting index number. 0==None */
151442 LogEst rSetup; /* One-time setup cost (ex: create transient index) */
151627 Expr *pIdxExpr; /* Search for this index expression */
151733 #define SQLITE_BLDF1_INDEXED 0x0001 /* An index is used */
151734 #define SQLITE_BLDF1_UNIQUE 0x0002 /* All keys of a UNIQUE index used */
151739 ** index+constraint combinations the query planner will consider for a
151748 ** able to propose a some index+constraint combinations even if the initial
151819 Index *pIdx /* Must be compatible with this index, if not NULL */
151924 #define WHERE_IDX_ONLY 0x00000040 /* Use index only - omit table */
151931 #define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
151934 #define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
151936 #define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
151952 ** Return the name of the i-th column of the pIdx index.
151973 int iTerm, /* Zero-based index of first term. */
152008 ** is run and there is an index on (a, b), then this function returns a
152375 ** the vector contains only index terms and those terms are in the correct
152387 ** Since only columns e and c can be used with the index, in that order,
152475 ** The current value for the constraint is left in a register, the index
152626 ** driving the index as it will always be true. The correct answer is
152645 ** index scan.
152647 ** For example, consider table t1(a,b,c,d,e,f) with index i1(a,b,c).
152649 ** The index has as many as three equality constraints, but in this
152653 ** in consecutive registers and the index of the first register is returned.
152666 ** the index of the first memory cell in that range. The code that
152674 ** copy of the column affinity string of the index allocated using
152682 ** In the example above, the index on t1(a) has TEXT affinity. But since
152685 ** a key to search the index. Hence the first byte in the returned affinity
152698 Index *pIdx; /* The index being used for this loop */
152706 /* This module is only called on query plans that use an index. */
152842 int iIdxCur; /* Cursor for the index, if pIdx!=0. Unused otherwise */
152843 Index *pIdx; /* The index used to access the table */
152848 ** for a cursor hint on an index cursor. For TK_COLUMN nodes that reference
152850 ** accessed through the index. If it cannot, then set pWalker->eCode to 1.
152910 ** by pCCurHint.iTabCur, and an index is being used (which we will
152912 ** an access of the index rather than the original table.
153024 /* For an index scan, make sure referenced columns are actually in
153025 ** the index. */
153050 ** a rowid value just read from cursor iIdxCur, open on index pIdx. This
153063 ** lookup on the index, thus avoiding an expensive seek operation. To
153067 ** column of the index, then the corresponding array entry is set to (i+1).
153068 ** If the column does not appear in the index at all, the array entry is set
153070 ** wants is in the index and if it is, it will substitute the index cursor
153148 ** a partial index that is driving a query loop. Look through all of the
153176 ** before the corresponding index search has been performed. This routine
153178 ** can be checked prior to doing the index lookup. If there are available
153180 ** index lookup. The idea is that a Bloom filter check is way faster than
153181 ** an index lookup, and the Bloom filter might return false, meaning that
153182 ** the index lookup can be skipped.
153596 /* Case 4: A scan using an index.
153600 ** left-most columns of the index. It may also contain
153605 ** index is on (x,y,z), then the following clauses are all
153624 ** constraints but an index is selected anyway, in order
153653 int iIdxCur; /* The VDBE cursor for the index */
153660 int omitTable; /* True if we use the index only */
153708 /* If the WHERE_BIGNULL_SORT flag is set, then index column nEq uses
153711 ** index entries for which the column is null and for those for which
153730 /* If we are doing a reverse order scan on an ascending index, or
153731 ** a forward order scan on a descending index, interchange the
153741 /* In case OP_SeekScan is used, ensure that the index cursor does not
153766 /* Seek the index cursor to the start of the range. */
153872 /* For a seek-scan that has a range on the lowest term of the index,
153916 /* Check if the index cursor is past the end of the range. */
153958 /* pIdx is a covering index. No need to access the main table. */
153973 /* If a partial index is driving the loop, try to eliminate WHERE clause
153975 ** the partial index.
154050 ** use an ephemeral index instead of a RowSet to record the primary
154056 Index *pCov = 0; /* Potential covering index (or NULL) */
154057 int iCovCur = pParse->nTab++; /* Cursor used for index scans (if any) */
154100 ** equivalent to an empty rowset. Or, create an ephemeral index
154147 ** in the subquery might be resolved to index-references for the index on
154149 ** is invoked from a different OR branch that uses a different index, such
154150 ** index-references will not work. tag-20220303a
154283 ** index, and the index is opened using the same cursor number
154285 ** be possible to use that index as a covering index.
154288 ** uses an index, and this is either the first OR-connected term
154289 ** processed or the index is the same as that used by all previous
154290 ** terms, set pCov to the candidate covering index. Otherwise, set
154291 ** pCov to NULL to indicate that no candidate covering index will
154344 /* Case 6: There is no usable index. We must do a complete
154518 ** both the iMatch index and the regBloom Bloom filter.
154741 ** The index in pWC->a[] of the new WhereTerm is returned on success.
155313 ** potentially be used with an index if an appropriate index exists.
155314 ** This analysis does not consider whether or not the index exists; that
155476 int iColumn = -1; /* Column index on lhs of IN operator */
155662 ** in any index. Return TRUE (1) if pExpr is an indexed term and return
155670 ** might be added to an automatic index later.
155743 ** and the copy has idxParent set to the index of the original term.
155752 WhereMaskSet *pMaskSet; /* Set of table index masks */
155812 extraRight = x-1; /* ON clause terms may not be used with an index
155922 ** skipped. Or, if the children are satisfied by an index, the original
156122 ** expression). The WhereTerm.u.x.iField variable identifies the index within
156195 ** an index for tables to the left of the join.
156711 ** table and iaCur[1] gets the cursor used by an auxiliary index.
156732 ** the data cursor to the row selected by the index cursor.
156957 ** This is whereScanInit() for the case of an index on an expression.
156973 ** iCur. Or if pIdx!=0 then X is column iColumn of index pIdx. pIdx
156984 ** index pIdx.
156992 Index *pIdx /* Must be compatible with this index */
157027 ** where X is a reference to the iColumn of table iCur or of index pIdx
157056 Index *pIdx /* Must be compatible with this index, if not NULL */
157079 ** of index pIdx.
157081 ** If such an expression is found, its index in pList->a[] is returned. If
157089 int iCol /* Column of index to match */
157112 ** Return TRUE if the iCol-th column of index pIdx is NOT NULL
157169 ** 1. The index is itself UNIQUE, and
157171 ** 2. All of the columns in the index are either part of the pDistinct
157174 ** comparison and select-list expressions must match those of the index.
157176 ** 3. All of those index columns for which the WHERE clause does not
157189 /* This index implies that the DISTINCT qualifier is redundant. */
157215 ** automatic index being generated.
157336 ** could be used with an index to access pSrc, assuming an appropriate
157337 ** index existed.
157366 ** Generate code to construct the Index object for an automatic index
157368 ** makes use of the automatic index.
157373 const SrcItem *pSrc, /* The FROM clause term to get the next index */
157375 WhereLevel *pLevel /* Write new index here */
157377 int nKeyCol; /* Number of columns in the constructed index */
157380 Index *pIdx; /* Object describing the transient index */
157384 int addrTop; /* Top of the index fill loop */
157385 int regRecord; /* Register holding an index record */
157402 ** transient index on 2nd and subsequent iterations of the loop. */
157407 /* Count the number of columns that will be added to the index
157416 /* Make the automatic index a partial index if there are terms in the
157435 "automatic index on %s(%s)", pTable->zName,
157454 ** covering index. A "covering index" is an index that contains all
157455 ** columns that are needed by the query. With a covering index, the
157457 ** be a covering index because the index will not be updated if the
157458 ** original table changes and the index and table cannot both be used
157472 /* Construct the Index object to describe this index */
157476 pIdx->zName = "auto-index";
157502 /* Add additional columns needed to make the automatic index into
157503 ** a covering index */
157522 /* Create the automatic index */
157533 /* Fill the automatic index with content */
157972 ** index. Store the results in aStat as follows:
157977 ** Return the index of the sample that is the smallest sample that
157978 ** is greater than or equal to pRec. Note that this index is not an index
157979 ** into the aSample[] array - it is an index into a virtual set of samples
158190 ** Return the affinity for a single column of an index.
158206 ** range-scan on a skip-scan index. For example:
158214 ** on the stat4 data for the index. this scan will be peformed multiple
158313 ** by scanning an index for a range of values. The range may have an upper
158316 ** example, assuming that index p is on t1(a):
158326 ** The value in (pBuilder->pNew->u.btree.nEq) is the number of the index
158328 ** equality constraints optimized by the proposed index scan. For example,
158329 ** assuming index p is on t1(a, b), and the SQL query is:
158334 ** left-most column of the index). Or, if the query is:
158341 ** number of rows that the index scan is expected to visit without
158343 ** rows in the index. Assuming no error occurs, *pnOut is adjusted (reduced)
158376 ** the index that are less than the lower bound of the range query. The
158379 ** columns of the index, and $L is the value in pLower.
158419 /* The roles of pLower and pUpper are swapped for a DESC index */
158495 ** index. While a closed range (e.g. col BETWEEN ? AND ?) is estimated to
158496 ** match 1/64 of the index. */
158519 ** column of an index and sqlite_stat4 histogram data is available
158520 ** for that index. When pExpr==NULL that means the constraint is
158551 /* If values are not available for all fields of the index to the left
158856 ** (5) If X is a covering index, than Y is too
158864 ** was added because a covering index probably deserves to have a lower cost
158865 ** than a non-covering index even if it is a proper subset.
158959 ** or the cost of building an automatic index (NlogN) and the NlogN
158964 /* whereLoopAddBtree() always generates and inserts the automatic index
158969 /* Any loop using an appliation-defined index (or PRIMARY KEY or
158971 ** than an automatic index. Unless it is a skip-scan. */
159145 ** index.
159147 ** For every WHERE clause term that is not used by the index
159152 ** TUNING: For every WHERE clause term that is not used by the index
159195 /* If there are extra terms in the WHERE clause not used by an index
159245 ** in the vector can be optimized using column nEq of the index. This
159253 ** and the index:
159263 Index *pIdx, /* The index to be used for a inequality constraint */
159264 int nEq, /* Number of prior equality constraints on same index */
159273 ** of the index. If not, exit the loop. */
159290 ** order of the index column is the same as the sort order of the
159291 ** leftmost index column. */
159324 ** index pIndex. Try to match one more.
159332 ** a fake index used for the INTEGER PRIMARY KEY.
159337 Index *pProbe, /* An index on pSrc */
159466 ** to the left in the same index. If the IN operator is on
159467 ** the left-most index column, M==N.
159470 ** from the index lookup and instead do a scan of the M elements,
159477 ** with the index, as using an index has better worst-case behavior.
159479 ** the index. Do not bother with this optimization on very small
159560 ** be visited by the index scan before considering term pTerm, or the
159640 /* Set rCostIdx to the cost of visiting selected rows in index. Add
159641 ** it to pNew->rRun, which is currently set to the cost of the index
159642 ** seek only. Then, if this is a non-covering index, add the cost of
159686 ** available for the left-most terms of the index, and if the average
159690 ** is almost always quicker than an index seek (even though if the index
159766 /* Check to see if a partial index with pPartIndexWhere can be used
159770 int iTab, /* The table for which we want an index */
159773 Expr *pWhere /* The WHERE clause from the partial index */
159804 Index *pIdx; /* The index */
159812 ** make sure that column is covered by the index pCk->pIdx. We know that
159816 ** If the index does not cover the column, then set pWalk->eCode to
159819 ** If this node does not disprove that the index can be a covering index,
159824 const Index *pIdx; /* The index of interest */
159825 const i16 *aiColumn; /* Columns contained in the index */
159826 u16 nColumn; /* Number of columns in the index */
159842 ** pIdx is an index that covers all of the low-number columns used by
159847 ** Return 0 if pIdx is a covering index. Return non-zero if pIdx is
159848 ** not a covering index or if we are unable to determine if pIdx is a
159849 ** covering index.
159872 /* pIdx does not index any columns greater than 62, but we know from
159874 ** covering index */
159896 ** For a full scan, assuming the table (or index) contains nRow rows:
159899 ** cost = nRow * K // scan of covering index
159900 ** cost = nRow * (K+3.0) // scan of non-covering index
159903 ** estimated average size of the index and table records.
159905 ** For an index scan, where nVisit is the number of index rows visited
159907 ** the index b-tree:
159909 ** cost = nSeek * (log(nRow) + K * nVisit) // covering index
159910 ** cost = nSeek * (log(nRow) + (K+3.0) * nVisit) // non-covering index
159919 ** log(nRow) factor is omitted from a non-covering index scan in order to
159920 ** bias the scoring in favor of using an index, since the worst-case
159921 ** performance of using an index is far better than the worst-case performance
159929 Index *pProbe; /* An index we are evaluating */
159930 Index sPk; /* A fake index object for the primary key */
159931 LogEst aiRowEstPk[2]; /* The aiRowLogEst[] value for the sPk index */
159932 i16 aiColumnPk = -1; /* The aColumn[] value for the sPk index */
159953 /* An INDEXED BY clause specifies a particular index to use */
159959 ** variable sPk to represent the rowid primary key index. Make this
159960 ** fake index the first in a chain of Index objects with all of the real
159996 /* Generate auto-index WhereLoops */
160009 /* TUNING: One-time cost for computing the automatic index is
160025 /* TUNING: Each index lookup yields 20 rows in the table. This
160027 ** of knowing how selective the index will ultimately be. It would
160040 ** consider index pProbe. */
160049 continue; /* Partial index inappropriate for this query */
160068 /* Integer primary key index */
160075 ** since index lookups have better worst-case performance if our
160078 ** At 2.75, a full table scan is preferred over using an index on
160081 ** to use an index in that case, since the constraint might be for
160082 ** the scarcer of the two values, and in that case an index lookup is
160111 /* Full scan via index */
160126 /* The cost of visiting the index rows is N*K, where K is
160128 ** index and table rows. */
160131 /* If this is a non-covering index scan, add in the cost of
160134 ** satisfied using just the index, and that do not require a
160145 /* pTerm can be evaluated using just the index. So reduce
160160 /* Do not do an SCAN of a index-on-expression in a RIGHT JOIN
160161 ** because the cursor used to access the index might not be
160175 /* If a non-unique index is used, or if a prefix of the key for
160176 ** unique index is used (making the index functionally non-unique)
160699 /* The multi-index OR optimization does not work for RIGHT and FULL JOIN */
160785 ** following where there is an index on "y":
160790 ** index lookup. And other similarly odd results. */
160921 u16 nColumn; /* Total number of ordered columns in the index */
160931 Index *pIndex; /* The index associated with pLoop */
160941 ** (a) All index columns match with WHERE_COLUMN_EQ.
160942 ** (b) The index is unique
160951 ** UNIQUE since a UNIQUE column or index can have multiple rows that
161043 /* All relevant terms of the index must also be non-NULL in order
161051 /* Loop through all columns of the index and deal with the ones
161067 ** terms imply that the index is not UNIQUE NOT NULL in which case
161102 ** (revIdx) for the j-th column of the index.
161129 ** of the index and mark that ORDER BY term off
161195 } /* end Loop over all index columns */
161388 ** index. */
161398 ** of computing an automatic index is not paid back within the first 28
161399 ** rows, then do not use the automatic index. */
161430 /* Do not use an automatic index if the this loop is expected
161432 ** automatic index usage on an outer loop, but sometimes an automatic
161433 ** index is useful in the outer loop of a correlated subquery. */
161790 /* TUNING: Cost of a unique index lookup is 15 */
162027 ** The index pIdx is used by a query and contains one or more expressions.
162028 ** In other words pIdx is an index on an expression. iIdxCur is the cursor
162029 ** number for the index and iDataCur is the cursor number for the corresponding
162033 ** each of the expressions in the index so that the expression code generator
162035 ** references to the corresponding column of the index.
162039 Index *pIdx, /* The index-on-expression that contains the expressions */
162163 ** The iIdxCur parameter is the cursor number of an index. If
162164 ** WHERE_OR_SUBCLAUSE is set, iIdxCur is the cursor number of an index
162168 ** be used to compute the appropriate cursor depending on which index is
162179 int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
162541 int iDb; /* Index of database containing table/index */
162612 ** WITHOUT ROWID table. No need for a separate index */
162763 ** index rather than the main table. In SQLITE_DEBUG mode, we want
162894 ** "a = ? AND b IN (...)", where the index is on (a, b). If
163002 /* If this scan uses an index, make VDBE code substitutions to read data
163003 ** from the index instead of from the table where possible. In some cases
163011 ** reference the index.
163079 /* Unable to translate the table reference into an index
164575 ** store the start and end index of the current frame. */
171939 /* aKWOffset[i] is the index into zKWText[] of the start of
175048 /* SQLITE_RANGE */ "column index out of range",
176257 ** If an invalid limit index is supplied, report -1.
176360 int iIn; /* Input character index */
176361 int iOut = 0; /* Output character index */
178728 /* The full-text index is stored in a series of b+tree (-like)
178766 ** A position is the index of a word within the document. The first
178781 ** varint column; (index of new column)
178790 ** memory. A "position" is an index of a token in the token stream
178921 ** idx - index within level
178983 ** index into the term index, we clearly cannot simply update the term
178984 ** index when a document is deleted or updated. For deletions, we
179156 ** *piEndOffset. *piStartOffset should be set to the index of the first
179158 ** to the index of the first byte just past the end of the token in
179376 ** FTS4 virtual tables may maintain multiple indexes - one index of all terms
179380 ** It is possible to determine which index a b+-tree belongs to based on the
179381 ** value stored in the "%_segdir.level" column. Given this value L, the index
179383 ** level values between 0 and 1023 (inclusive) belong to index 0, all levels
179384 ** between 1024 and 2047 to index 1, and so on.
179386 ** It is considered impossible for an index to use more than 1024 levels. In
179504 ** A connection to a fulltext index is an instance of the following
179545 ** The following array of hash tables is used to buffer pending index
179550 ** A single FTS4 table may have multiple full-text indexes. For each index
179551 ** there is an entry in the aIndex[] array. Index 0 is an index of all the
179552 ** terms that appear in the document set. Each subsequent index in aIndex[]
179553 ** is an index of prefixes of a specific length.
179563 int nPrefix; /* Prefix length (0 for main terms index) */
179564 Fts3Hash hPending; /* Pending terms table for this index */
179636 ** FTS3_FULLTEXT_SEARCH. If so, then Fts3Cursor.eSearch - 2 is the index
179650 #define FTS3_FULLTEXT_SEARCH 2 /* Full-text index search */
180655 ** always maintain the main "terms" index, but may also maintain one or
180827 int iCol; /* Column index */
181234 ** support index-info flags. In that case this function is a no-op.
181498 ** table is missing a row that is present in the full-text index.
181876 int iCol1; /* The current column index in pp1 */
181877 int iCol2; /* The current column index in pp2 */
181902 ** for the same column (the column with index iCol1 and iCol2).
182678 ** Set up a cursor object for iterating through a full-text index or a
182751 int bFound = 0; /* True once an index has been found */
182934 ** If idxNum>=FTS3_FULLTEXT_SEARCH then use the full text index. The
182941 int idxNum, /* Strategy index */
184072 ** tokens or prefix tokens that cannot use a prefix-index. */
184655 ** table actually contains the same data as the index. To prevent this from
184680 ** to retrieve the entire doclist for the token from the full-text index.
186127 int idxNum, /* Strategy index */
187337 ** The iDefaultCol parameter should be passed the index of the table column
188051 int iToken; /* index of next token to be returned */
189234 int iToken; /* index of next token to be returned */
189761 int idxNum, /* Strategy index */
189918 ** When full-text index nodes are loaded from disk, the buffer that they
189920 ** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer
190012 ** terms when querying the full-text index. See functions:
190221 ** if no level in the FTS index contains more than ? segments, the statement
190236 ** Delete the %_segdir entry on absolute level :1 with index :2. */
190246 ** level :1 with index value :2. */
190252 ** entry located on absolute level :3 with index :4. */
190266 ** Return the largest relative level in the FTS index or indexes. */
190431 ** Within each language id, a separate index is maintained to store the
190433 ** "prefix=" option). And each index consists of multiple levels ("relative
190436 ** All three of these values (the language id, the specific index and the
190437 ** level within the index) are encoded in 64-bit integer values stored
190442 ** Specifically, each language-id/index combination is allocated 1024
190443 ** 64-bit integer level values ("absolute levels"). The main terms index
190444 ** for language-id 0 is allocate values 0-1023. The first prefix index
190449 ** absolute levels that corresponds to language-id iLangid and index
190727 /* Add the term to the terms index */
190949 ** full-text index.
190999 ** This function allocates a new level iLevel index in the segdir table.
191001 ** with 0, so the allocated index is one greater than the value returned
191008 ** allocated index is 0.
191010 ** If successful, *piIdx is set to the allocated index slot and SQLITE_OK
191027 /* Set variable iNext to the next available segdir index at level iLevel. */
191042 ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
191043 ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
191641 ** the index. All that is required is a straight hash-lookup.
192347 ** Set *pnMax to the largest segment level in the database for the index
192385 ** within its index. Assuming no error occurs, *pbMax is set to 1 if
193020 ** segments in this index on levels greater than iAbsLevel. If there is
193056 /* Loop through all %_segdir entries for segments in this index with
193114 sqlite3_int64 iNewLevel = 0; /* Level/index to create new segment at */
193119 i64 iMaxLevel = 0; /* Max level number for this index/langid */
193140 ** index. The idx of the new segment is always 0. */
193150 ** available segment index at level iLevel+1. The call to
193438 ** The entire FTS index is discarded and rebuilt. If the table is one
193439 ** created using the content=xxx option, then the new index is based on
193993 /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment
194121 ** It checks if the existing segment with index value iIdx at absolute level
194155 /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */
194277 ** Determine the largest segment index value that exists within absolute
194287 sqlite3_int64 iAbsLevel, /* Absolute index of input segments */
194288 int *piIdx /* OUT: Next free index at iAbsLevel+1 */
194291 sqlite3_stmt *pOutputIdx = 0; /* SQL used to find output index */
195061 ** Return a 64-bit checksum for the FTS index entry specified by the
195086 ** Return a checksum of all entries in the FTS index that correspond to
195164 ** Check if the contents of the FTS index match the current contents of the
195174 u64 cksum1 = 0; /* Checksum based on FTS index contents */
195178 /* This block calculates the checksum according to the FTS index. */
195256 ** the FTS index are correct, return SQLITE_OK. Or, if the contents of the
195257 ** FTS index are incorrect, return SQLITE_CORRUPT_VTAB.
195266 ** + The index number (0 for the main index, 1 for the first prefix
195267 ** index etc.),
195274 ** The checksums for all entries in the index are XORed together to create
195275 ** a single checksum for the entire index.
195279 ** 1. By scanning the contents of the FTS index, and
196646 ** file system. This is done because the full-text index doclist is required
196647 ** to calculate these values properly, and the full-text index doclist is
198116 ** The 7 most significant bits in flags are an index into the aiOff[]
198970 ** instance to the JsonParse. Return the index in pParse->aNode[] of the
199003 ** index of the first character past the end of the value parsed.
200693 int i; /* Loop counter or computed array index */
201189 u8 iCell; /* Cell index within the node */
201771 ** Remove the cell with index iCell from node pNode.
201870 int iCell /* The cell index from which to extract the ID */
201882 int iCell, /* The index of the cell within the node */
202301 ** integer value equal to iRowid. Return the index of this cell.
202323 ** Return the index of the cell containing a pointer to node pNode
203782 ** Delete the cell at index iCell of node pNode. After removing the
204119 ** Parameter iCol is the index of the leftmost column involved in the
205476 ** to silence (incorrect) UBSAN warnings if the array index is too large.
208291 ** Additionally, because the index updates are likely to be applied in
208295 ** One way to improve the situation is to sort the operations on each index
208296 ** by index key before applying them to the b-tree. This leads to an IO
208297 ** pattern that resembles a single linear scan through the index b-tree,
208947 ** Only valid if STAGE==1. The target database name of the index
208953 ** table/index.
208960 ** Valid if STAGE==4. The 64-bit checksum associated with the wal-index
209057 ** * each index of the table (zero or more points to visit), and
209064 ** index. Or clear otherwise.
209088 const char *zIdx; /* Name of target db index (or null) */
209090 int iPkTnum; /* If eType==EXTERNAL, root of PK index */
209091 int bUnique; /* Current index is unique */
209114 ** 3: Table has an external PK index.
209133 #define RBU_IDX_DELETE 4 /* Delete a row from an aux. index b-tree */
209134 #define RBU_IDX_INSERT 5 /* Insert on an aux. index b-tree */
209172 ** no b-tree operations are required on index b-trees. Or if the
209174 ** required (one delete and one insert on each index b-tree).
209177 ** PK does not exist. In this case no operations are required on index
209623 ** the current object (table/index pair).
209806 " WHERE type='index' AND tbl_name = ?"
209964 ** RBU_PK_EXTERNAL: Table has an external PK index.
209969 ** parameter. Unless the table has an external primary key index
209971 ** if the table does have an external primary key index, then *piPk
209972 ** is set to the root page number of the primary key index before
209981 ** }else if( "PRAGMA index_list()" for the table contains a "pk" index ){
209982 ** if( the index that is the pk exists in sqlite_schema ){
209983 ** *piPK = rootpage of that index.
210128 ** the table (not index) that the iterator currently points to.
210294 ** updating a table (not an index). The table may be a rowid table or
210357 ** current operation is writing content to an index. If possible, it
210358 ** queries the target index b-tree for the largest key already written to
210363 ** * The index contains no DESC columns, and
210364 ** * The last key written to the index before the operation was
210369 ** (index-field1, index-field2, ...) > (?, ?, ...)
210472 ** index object currently indicated by the iterator object passed as the
210476 ** If the index is of the following form:
210779 ** The iterator currently points to a table (not index) of type
210796 sqlite3_stmt *pXInfo = 0; /* PRAGMA index_xinfo = <pk-index> */
210834 ** a table (not index) with an external primary key, this function is a
210839 ** used to access that PK index. For example, if the target table is
210851 int tnum = pIter->iPkTnum; /* Root page of PK index */
210853 const char *zIdx = 0; /* Name of PK index */
210859 /* Figure out the name of the primary key index for the current table.
210911 ** a table (not an index) when this function is called. This function
211036 "SELECT trim(sql) FROM sqlite_schema WHERE type='index' AND name=?"
211161 /* Create the imposter table used to write to this index. */
211170 /* Create the statement to insert index entries */
211179 /* And to delete index entries */
211778 ** Return the current wal-index header checksum for the target database
211807 ** being resumed. In this case, if the checksum of the wal-index-header
212702 "WHERE type='index' AND tbl_name = %Q", sqlite3_value_text(apVal[0]))
214254 " name TEXT," /* 0 Name of table or index */
214873 case 0x02: /* index internal */
214877 case 0x0A: /* index leaf */
221705 ** FTS index.
221708 ** against the FTS index. The tokenizer is being called to tokenize
221761 ** 1st place" entries are added to the index for tokens "i", "won",
221766 ** <li> By querying the index for all synonyms of each query term
221769 ** within the document. FTS5 then queries the index for each
221786 ** <li> By adding multiple synonyms for a single term to the FTS index.
221790 ** added to the FTS index for "i", "won", "first", "1st" and
221797 ** FTS index corresponding to both forms of the first token.
221821 ** extra data to the FTS index or require FTS5 to query for multiple terms,
221833 ** because the index contains entries for both "first" and "1st", prefix
221835 ** extra entries are added to the FTS index, this method uses more space
221843 ** extra disk space, as no extra entries are added to the FTS index.
221845 ** as separate queries of the FTS index are required for each synonym.
222006 ** Maximum segments permitted in a single index
222107 ** INSERT INTO tbl(tbl, rank) VALUES('prefix-index', $bPrefixIndex);
222112 char *zDb; /* Database holding FTS index (e.g. "main") */
222113 char *zName; /* Name of FTS index */
222307 #define FTS5INDEX_QUERY_TEST_NOIDX 0x0004 /* Do not use prefix index */
222350 Fts5Index *p, /* FTS index to query */
222385 ** Insert or remove data to or from the index. Each time a document is
222386 ** added to or removed from the index, this function is called one or more
222398 const char *pToken, int nToken /* Token to add or remove to or from index */
222497 Fts5Index *pIndex; /* Full-text index */
222533 const char *pToken, int nToken /* Token to add or remove to or from index */
224324 int iInst; /* Next phrase instance index */
227409 int i, j; /* Phrase and token index, respectively */
227845 ** Begin iterating through the set of documents in index pIdx matched by
229691 const char *pToken, int nToken /* Token to add or remove to or from index */
230018 ** Low level access to the FTS index stored in the database file. The
230031 ** As well as the main term index, there may be up to 31 prefix indexes.
230040 ** * large doclists that span many pages have associated "doclist index"
230075 ** The set of segments that make up an index - the index structure - are
230078 ** SQLite varints. If the FTS table features more than one index (because
230101 ** The first value is the number of rows in the index. Then, for each column
230187 ** a single leaf record only. The format of each doclist index leaf page
230193 ** * Page number of fts index leaf page. As a varint.
230201 ** Internal doclist index nodes are:
230233 #define FTS5_DATA_DLI_B 1 /* Doclist-index flag (1 bit) */
230276 int szLeaf; /* Size of leaf without page-index */
230324 ** The contents of the "structure" record for each index are represented
230342 int nLevel; /* Number of levels in this index */
230353 Fts5Buffer pgidx; /* Buffer containing page-index */
230383 u16 iFirst; /* aSeg[] index of firstest iterator */
230457 Fts5DlidxIter *pDlidx; /* If there is a doclist-index */
230500 ** comparison in this context is the index of the iterator that currently
230504 ** aFirst[1] contains the index in aSeg[] of the iterator that points to
230533 ** of a doclist-index record.
230536 ** Record containing the doclist-index data.
231051 /* TODO: Do we need this if the leaf-index is appended? Probably... */
231145 ** Return the total number of segments in index structure pStruct. This
231240 ** Return a copy of index structure pStruct. Except, promote as many
231271 ** A new segment has just been written to level iLvl of index structure
231336 ** doclist-index page is reached, return non-zero.
231397 ** points to the first rowid in the doclist-index.
231400 ** pointer to doclist-index record,
231518 ** Free a doclist-index iterator object allocated by fts5DlidxIterInit().
231760 Fts5Index *p, /* FTS index object */
232249 ** There is a doclist-index associated with the final term on the current
232251 ** doclist-index from disk and initialize an iterator at (pIter->pDlidx).
232262 ** early without loading the doclist-index (as it belongs to a different
232427 ** pSeg. If there is no such term in the index, the iterator is set to EOF.
232441 int bDlidx = 0; /* True if there is a doclist-index */
232673 ** If the returned value is non-zero, then it is the index of an entry
233453 Fts5Structure *pStruct, /* Structure of specific index */
233780 ** If the current doclist-index accumulating in pWriter->aDlidx[] is large
233788 ** to the database, also write the doclist-index to disk. */
233801 ** The doclist-index for that term is currently stored in-memory within the
233857 /* If there were no rowids on the leaf page either and the doclist-index
233881 ** doclist-index.
233896 /* The current doclist-index page is full. Write it to disk and push
233898 ** doclist-index leaf page) up into the next level of the b-tree
234084 ** buffer, in case a doclist-index is required. */
234202 /* Bind the current output segment id to the index-writer. This is an
234256 /* Set up the new page-index array */
234294 Fts5Structure **ppStruct, /* IN/OUT: Stucture of index */
234438 ** Do up to nPg pages of automerge work on the index.
234444 Fts5Structure **ppStruct, /* IN/OUT: Current structure of index */
234473 /* If nBest is still 0, then the index must be empty. */
234503 Fts5Structure **ppStruct, /* IN/OUT: Current structure of index */
234524 Fts5Structure **ppStruct /* IN/OUT: Current structure of index */
234584 /* Obtain a reference to the index structure and allocate a new segment-id
235240 Fts5Iter *p1 = 0; /* Iterator used to gather data from index */
235389 ** function populates it with the initial structure objects for each index,
235513 ** Insert or remove data to or from the index. Each time a document is
235514 ** added to or removed from the index, this function is called one or more
235526 const char *pToken, int nToken /* Token to add or remove to or from index */
235535 /* Add the entry to the main terms index. */
235559 Fts5Index *p, /* FTS index to query */
235574 int iPrefixIdx = 0; /* +1 prefix index */
235577 /* Figure out which index to search and set iIdx accordingly. If this
235578 ** is a prefix query for which there is no prefix index, set iIdx to
235580 ** satisfied by scanning multiple terms in the main index.
235583 ** prefix-query. Instead of using a prefix-index (if one exists),
235584 ** evaluate the prefix query using the main FTS index. This is used
235603 /* Straight index lookup */
235613 /* Scan multiple terms in the main index */
235820 ** visited regardless of whether the doclist-index identified by parameters
235826 int iLeaf /* Load doclist-index for this leaf */
235860 Fts5Index *p, /* Fts5 index object */
235863 int n, /* Size of index key in bytes */
235964 ** the index is disabled are the same. In both ASC and DESC order.
235974 ** character stored in the main fts index, which will cause the
236156 /* If there is a doclist-index, check that it looks right. */
236158 Fts5DlidxIter *pDlidx = 0; /* For iterating through doclist index */
236203 /* TODO: Check there is no doclist index */
236222 ** Run internal checks to ensure that the FTS index (a) is internally
236235 Fts5Iter *pIter; /* Used to iterate through entire index */
236246 /* Load the FTS index structure */
236262 ** based on all expected entries in the FTS index (including prefix index
236264 ** actual contents of FTS index is identical.
236267 ** variable cksum2) based on entries extracted from the full-text index
236268 ** while doing a linear scan of each individual index in turn.
237210 /* Open the index sub-system */
237284 ** support index-info flags. In that case this function is a no-op.
238035 int idxNum, /* Strategy index */
238382 }else if( 0==sqlite3_stricmp("prefix-index", zCmd) ){
240122 ** Tokenization callback used when inserting tokens into the FTS index.
240144 ** delete-markers to the FTS index necessary to delete it. Do not actually
240292 /* Delete the index records */
240323 ** Delete all entries in the FTS5 index.
240486 ** Insert new entries into the FTS index and %_docsize table.
240638 ** Check that the contents of the FTS index match that of the %_content
240663 /* Generate the expected index checksum based on the contents of the
240736 /* Pass the expected checksum down to the FTS index module. It will
240738 ** inspecting the index itself. */
242467 ** The 7 most significant bits in flags are an index into the aiOff[]
243478 ** existing FTS5 index. The module may create several different types of
244067 int idxNum, /* Strategy index */