Lines Matching defs:term

6701 ** remember the string long-term should make their own copy.  Applications that
7461 ** ^Each term of aOrderBy records a column of the ORDER BY clause.
7579 ** an operator that is part of a constraint term in the WHERE clause of
13105 ** <li> By querying the index for all synonyms of each query term
13107 ** tokenizer may provide multiple synonyms for a single term
13125 ** <li> By adding multiple synonyms for a single term to the FTS index.
13361 ** level of recursion for each term. A stack overflow can result
17978 CollSeq *aColl[1]; /* Collating sequence for each term of the key */
18572 ** The SrcItem object represents a single term in the FROM clause of a query.
18866 #define SF_MultiValue 0x0000400 /* Single VALUES term with multiple rows */
29559 /* The 0x7ffff00 limit term is explained in comments on sqlite3Malloc() */
32222 if( pList->a[i].fg.bUsingTerm ) fprintf(stdout, "(USING-term) ");
32945 ** (via the sqlite3FaultSim() term of the conditional) for testing
43401 ** previous term of the directory if it is something other than "..".
58388 ** The third term of the test was added to fix ticket #2565.
61182 /* Optimization note: Adding the "pgno<=1" term before "pgno==0" here
63448 ** terms of the sequence whereas s0 omits the final term.
73180 ** this lock. The iTable<1 term disables the check for corrupt schemas. */
92696 CollSeq *pColl; /* Collating sequence to use on this term */
93716 ** the Mem.uTemp field of each term should hold the serial-type that will
93717 ** be used for that term in the generated record:
95041 ** term, substitute >= for > and < for <=. e.g. if the search term
95055 ** term, substitute <= for < and > for >=. */
103858 ** Create a new expression term for the column specified by pMatch and
103859 ** iColumn. Append this new expression term to the FULL JOIN Match set
103860 ** in *ppList. Create a new *ppList if this is the first term in the
104979 ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause.
105014 ** pE is a pointer to an expression which is a single term in the
105019 ** ORDER BY term is not an integer index into the result set. That
105034 Expr *pE /* The specific ORDER BY term */
105046 /* Resolve all names in the ORDER BY term expression
105076 ** Generate an ORDER BY or GROUP BY term out-of-range error.
105081 int i, /* The index (1-based) of the term out of range */
105086 "%r %s BY term out of range - should be "
105093 ** each term of the ORDER BY clause is a constant integer between 1
105173 /* Convert the ORDER BY term into an integer column number iCol,
105201 sqlite3ErrorMsg(pParse, "%r ORDER BY term does not match any "
105210 ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of
105211 ** the SELECT statement pSelect. If any term is reference to a
105213 ** field) then convert that term into a copy of the corresponding result set
105284 ** This routine resolves each term of the clause into an expression.
105285 ** If the order-by term is an integer I between 1 and N (where N is the
105288 ** the order-by term is an identifier that corresponds to the AS-name of
105289 ** a result-set expression, then the term resolves to a copy of the
105305 struct ExprList_item *pItem; /* A term of the ORDER BY clause */
105328 /* The ORDER BY term is an integer constant. Again, set the column
105330 ** order-by term to a copy of the result-set expression */
105339 /* Otherwise, treat the ORDER BY term as an ordinary expression */
105528 ** the sub-query back to the parent query. At this point each term
105543 ** If there is an ORDER BY clause on a term of a compound-select other
105544 ** than the right-most term, then that is a syntax error. But the error
105584 /* Advance to the next term of the compound
105634 ** The "x" term of the order by is replaced by "a+b" to render:
106265 ** just the expression for the i-th term of the result set, and may
106827 sqlite3ErrorMsg(pParse, "IN(...) element has %d term%s - expected %d",
107670 ** For each term of the vector assignment, append new entries to the
107909 ** then convert it into an TK_TRUEFALSE term. Return non-zero if
107994 /* If pWalker->eCode is 2 then any term of the expression that comes from
108160 /* Check if pExpr is identical to any GROUP BY term. If so, consider
108186 ** This routine is used to determine if a term of the HAVING clause can
108188 ** the value of the HAVING clause term must be the same for all members of
108189 ** a "group". The requirement that the GROUP BY term must be BINARY
108195 ** sequence as the GROUP BY term, but that is much harder to check,
108415 if( pSrc->nSrc!=1 ) return 0; /* Single term in FROM clause */
108642 ** and for the term on the LHS of the IN to have no affinity. */
110360 ** for function overloading. But we use the B term in "glob(B,A)".
110588 ** or if there is no matching Ei, the ELSE term Y, or if there is
110589 ** no ELSE term, NULL.
110941 Expr compLeft; /* The x>=y term */
110942 Expr compRight; /* The x<=z term */
111395 ** If pParse is NULL (the normal case) then any TK_VARIABLE term in
111713 ** a term of the form x=y does not prove that y is not null if x
122400 ** This routine is called by the parser to add a new term to the
122403 ** if this is the first term of the FROM clause. pTable and pDatabase
122404 ** are the name of the table and database named in the FROM clause term.
122406 ** usual case. If the term has an alias, then pAlias points to the
122407 ** alias token. If the term is a subquery, then pSubquery is the
122413 ** term added.
123900 ** is a limit/offset term to enforce.
123907 ** term for the DELETE or UPDATE statement. For example:
128381 ** that the "OLD.zToCol" term is on the LHS of the = operator, so
128392 /* For ON UPDATE, construct the next term of the WHEN clause.
129447 /* If the INSERT statement included an IDLIST term, then make sure
129594 /* If there is no IDLIST term but the table has an integer primary
131423 return 0; /* FROM clause must have exactly one term */
137844 /* For a long-term use prepared statement avoid the use of
138593 ** And set the Expr.w.iJoin to iTable for every term in the
138597 ** the OUTER JOIN processing logic that this term is part of the
138611 ** term until after the t2 loop of the join. In that way, a
138642 ** Convert every term that is marked with EP_OuterON and w.iJoin==iTable into
138643 ** an ordinary term that omits the EP_OuterON mark. Or if iTable<0, then
138756 char *zName; /* Name of the term in the USING clause */
140342 /* Column names are determined by the left-most term of a compound select */
140709 ** left-most term of the select that has a collating sequence.
140812 Select *pFirstRec; /* Left-most recursive term */
140893 ** recursive term of the CTE.
141706 ** the ORDER BY clause covers every term of the result set. Add
142396 ** (17c) every term within the subquery compound must have a FROM clause
142422 ** ORDER BY clause of the parent must be copies of a term returned
142483 Select *pParent; /* Current UNION ALL term of the other query */
142648 SELECTTRACE(1,pParse,p,("flatten %u.%p from term %d\n",
142759 /* The following loop runs once for each term in a compound-subquery
142985 ** is a constant expression and where the term must be true because it
142986 ** is part of the AND-connected terms of the expression. For each term
143128 ** only attempted if the "a=123" term uses the default BINARY collation.
143138 ** term "x=10" will cause the second WHERE term to become "10 LIKE 10",
143260 ** But if the (b2=2) term were to be pushed down into the bb subquery,
143296 SrcItem *pSrc /* The subquery term of the outer FROM clause */
143320 /* Only the first term of a compound can have a WITH clause. But make
143601 ** Check to see if the FROM clause term pFrom has table-valued function
143697 SrcItem *pFrom /* The FROM clause term to check */
143713 /* The FROM term contains a schema qualifier (ex: main.t1) and so
143718 /* The FROM term is specifically excluded from matching a CTE.
143721 ** (2) This is the first term in the FROM clause of an UPDATE.
143732 Select *pRecTerm; /* Left-most recursive term */
144209 struct ExprList_item *pX; /* Newly added ExprList term */
144705 ** A term of the HAVING expression is eligible for transfer if it consists
144860 ** If any term of pSrc, or any SF_NestedFrom sub-query, is not the same
145044 ("LEFT-JOIN simplifies to JOIN on term %d\n",i));
145051 /* No futher action if this term of the FROM clause is no a subquery */
145194 /* For each term in the FROM clause, do two things:
147249 ** Return true if the pExpr term from the RETURNING clause argument
147255 Expr *pTerm /* A term in the RETURNING clause */
149291 Expr *pTerm; /* One term of the conflict-target clause */
149382 /* Column ii of the index did not match any term of the conflict target.
151374 ** each term in the FROM clause (which is to say, for each of the
151422 ** term of a join. Every term of the FROM clause will have at least
151426 ** potential way of implementing that FROM-clause term, together with
151431 ** one WhereLoop object per FROM clause term, that satisfy all dependencies
151533 ** When a term is of the form:
151552 ** If a term in the WHERE clause does not match either of the two previous
151574 Expr *pExpr; /* Pointer to the subexpression that is this term */
151575 WhereClause *pWC; /* The clause this term is part of */
151581 int iParent; /* Disable pWC->a[iParent] when this term disabled */
151600 #define TERM_CODED 0x0004 /* This term is already coded */
151605 #define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */
151607 #define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */
151657 WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
151746 ** increased by SQLITE_QUERY_PLANNER_LIMIT_INCR before each term of the FROM
151905 #define WO_NOOP 0x1000 /* This term does not restrict search space */
151906 #define WO_ROWVAL 0x2000 /* A row-value term */
151964 ** pStr holds the text of an expression that we are building up one term
151965 ** at a time. This routine adds a new term to the end of the expression.
151973 int iTerm, /* Zero-based index of first term. */
152234 ** Disable a term in the WHERE clause. Except, do not disable the term
152238 ** Consider the term t2.z='ok' in the following queries:
152245 ** in the ON clause. The term is disabled in (3) because it is not part
152246 ** of a LEFT OUTER JOIN. In (1), the term is not disabled.
152248 ** Disabling a term causes that term to not be tested in the inner loop
152256 ** If all the children of a term are disabled, then that term is also
152264 ** Only the parent term was in the original WHERE clause. The child1
152269 ** Usually the parent term is marked as TERM_CODED. But if the parent
152270 ** term was originally TERM_LIKE, then the parent gets TERM_LIKECOND instead.
152271 ** The TERM_LIKECOND marking indicates that the term should be coded inside
152448 ** ORDER BY term exactly matches one of the terms of the
152471 ** Generate code for a single equality term of the WHERE clause. An equality
152472 ** term can be either X=expr or X IN (...). pTerm is the term to be
152487 WhereTerm *pTerm, /* The term of the WHERE clause to be coded */
152489 int iEq, /* Index of the equality term within this level */
152625 /* As an optimization, try to disable the WHERE clause term that is
152628 ** by omitting the term.
152630 ** But do not disable the term unless we are certain that the term is
152699 WhereTerm *pTerm; /* A single constraint term */
152948 WhereTerm *pEndRange /* Hint this end-of-scan boundary term if not NULL */
153033 /* If we survive all prior tests, that means this term is worth hinting */
153256 WhereTerm *pTerm; /* A WHERE clause term */
153258 SrcItem *pTabItem; /* FROM clause term being coded */
153614 ** The z<10 term of the following cannot be used, only
153615 ** the x=5 term:
153872 /* For a seek-scan that has a range on the lowest term of the index,
154027 ** Then, for each indexed term, the following. The arguments to
154032 ** sqlite3WhereBegin(<term>)
154126 ** Then for every term xN, evaluate as the subexpression: xN AND y
154135 ** This optimization also only applies if the (x1 OR x2 OR ...) term
154179 /* Run a separate WHERE clause for each term of the OR clause. After
154187 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
154188 Expr *pOrExpr = pOrTerm->pExpr; /* Current OR clause term */
154189 Expr *pDelete; /* Local copy of OR clause term */
154203 /* Loop through table entries that match term pOrTerm. */
154275 /* The pSubWInfo->untestedTerms flag means that this OR term
154276 ** contained one or more AND term from a notReady table. The
154288 ** uses an index, and this is either the first OR-connected term
154309 /* Finish the loop through table entries that match term pOrTerm. */
154793 ** allowed for an indexable WHERE clause term. The allowed operators are
155166 ** Mark term iChild as being a child of term iParent
155196 ** add a new virtual AND term to pWC that is the combination of the
155219 int idxNew; /* Index in pWC of the next virtual term */
155250 ** Analyze a term that consists of two or more OR-connected
155256 ** This routine analyzes terms such as the middle term in the above example.
155257 ** A WhereOrTerm object is computed and attached to the term under
155263 ** The term being analyzed must have two or more of OR-connected subterms.
155278 ** term that is an equivalent IN expression. In other words, if the term
155283 ** then create a new virtual term like this:
155290 ** has x=A (for the same x and A) then add a new virtual conjunct term to the
155318 ** All examples A through E above satisfy case 3. But if a term
155334 ** zero. This term is not useful for search.
155339 int idxTerm /* Index of the OR-term to be analyzed */
155344 WhereTerm *pTerm = &pWC->a[idxTerm]; /* The term to be analyzed */
155345 Expr *pExpr = pTerm->pExpr; /* The expression of the term */
155348 WhereTerm *pOrTerm; /* A Sub-term within the pOrWc */
155356 ** object that is attached to the original OR clause term.
155410 /* Skip this term for now. We revisit it when we process the
155411 ** corresponding TERM_VIRTUAL term */
155462 ** case means that every term of the OR clause is of the form
155468 ** or table2.column as the LHS if either is common to every term of
155494 ** current term is from the first iteration. So skip this term. */
155500 /* This term must be of the form t1.a==t2.b where t2 is in the
155501 ** chngToIN set but t1 is not. This term will be either preceded
155502 ** or follwed by an inverted copy (t2.b==t1.a). Skip this term
155526 ** table and column is common to every term in the OR clause */
155555 ** case 1. In that case, construct a new virtual term that is
155662 ** in any index. Return TRUE (1) if pExpr is an indexed term and return
155738 ** term of the form "Y <op> X" is added to the WHERE clause and
155739 ** analyzed separately. The original term is marked with TERM_COPIED
155740 ** and the new term is marked with TERM_DYNAMIC (because it's pExpr
155742 ** is a commuted copy of a prior term.) The original term has nChild=1
155743 ** and the copy has idxParent set to the index of the original term.
155748 int idxTerm /* Index of the term to be analyzed */
155751 WhereTerm *pTerm; /* The term to be analyzed */
155910 /* If a term is the BETWEEN operator, create two new virtual terms
155921 ** term. That means that if the BETWEEN term is coded, the children are
155923 ** BETWEEN term is skipped.
155950 /* Analyze a term that is composed of two or more subterms connected by
155961 ** virtual term of that form.
155963 ** The virtual term must be tagged with TERM_VNULL.
156085 /* If there is a vector == or IS term - e.g. "(a, b) == (?, ?)" - create
156119 /* If there is a vector IN term - e.g. "(a, b) IN (SELECT ...)" - create
156120 ** a virtual term for each vector component. The expression object
156121 ** used by each such virtual term is pExpr (the full vector IN(...)
156123 ** the vector on the LHS that the virtual term represents.
156149 /* Add a WO_AUX auxiliary term to the constraint set if the
156239 ** OFFSET (if eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET) term to the
156240 ** where-clause passed as the first argument. The value for the term
156314 /* This term is a vector operation that has been decomposed into
156373 /* Verify that every term past pWC->nBase is virtual */
156507 SrcItem *pItem, /* The FROM clause term to process */
156861 int iCur; /* The cursor on the LHS of the term */
156862 i16 iColumn; /* The column on the LHS of the term. -1 for IPK */
156865 WhereTerm *pTerm; /* The term being tested */
157026 ** Search for a term in the WHERE clause that is of the form "X <op> <expr>"
157029 ** the op parameter. Return a pointer to the term. Return 0 if not found.
157035 ** The term returned might by Y=<expr> if there is another constraint in
157048 ** exist, try to return a term that does not use WO_EQUIV.
157172 ** list, or else the WHERE clause contains a term of the form "col=X",
157177 ** contain a "col=X" term are subject to a NOT NULL constraint.
157310 const WhereTerm *pTerm, /* WHERE clause term to check */
157335 ** Return TRUE if the WHERE clause term pTerm is of a form where it
157340 const WhereTerm *pTerm, /* WHERE clause term to check */
157373 const SrcItem *pSrc, /* The FROM clause term to get the next index */
157378 WhereTerm *pTerm; /* A single term of the WHERE clause */
157397 SrcItem *pTabItem; /* FROM clause term being indexed */
157607 WhereLevel *pLevel, /* Make a Bloom filter for this FROM term */
157614 const WhereTerm *pWCEnd; /* Last WHERE clause term */
157721 SrcItem *pSrc, /* The FROM clause term that is the vtab */
157745 ** Mark each term with the TERM_OK flag. Set nTerm to the number of
158165 ** If it is not NULL, pTerm is a term that provides an upper or lower
158170 ** If the user explicitly specified a likelihood() value for this term,
158172 ** input rows. Otherwise, this function assumes that an "IS NOT NULL" term
158173 ** has a likelihood of 0.50, and any other term a likelihood of 0.25.
158227 ** If pLower is NULL, or a value cannot be extracted from the term, L is
158606 tRowcnt nEst; /* Number of rows for a single term */
158854 ** (3) Every WHERE clause term used by X is also used by Y
158882 if( j<0 ) return 0; /* X not a subset of Y since term X[i] not used by Y */
158902 ** WHERE clause terms than Y and that every WHERE clause term used by X is
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
159160 ** the WhereLoop.nOut field for every such WHERE clause term.
159336 SrcItem *pSrc, /* FROM clause term being analyzed */
159449 ** In this case there is a separate term for each of (x) and (y).
159451 ** for each such term. The following loop checks that pTerm is the
159452 ** first such term in use, and sets nIn back to 0 if it is not. */
159560 ** be visited by the index scan before considering term pTerm, or the
159610 "STAT4 determines term has low selectivity:\n");
159616 /* If the term has previously been used with an assumption of
159934 SrcItem *pSrc; /* The FROM clause btree term to add */
160193 ** Return true if pTerm is a virtual table LIMIT or OFFSET term.
160343 /* If there is an IN(...) term handled as an == (separate call to
160345 ** OFFSET term handled as well, the plan is unusable. Set output
160554 SrcItem *pSrc; /* The FROM clause term to search */
160606 /* If the plan produced by the earlier call uses an IN(...) term, call
160732 WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n",
160918 u8 isMatch; /* iColumn matches a term of the ORDER BY clause */
160928 WhereTerm *pTerm; /* A single term of the WHERE clause */
160930 CollSeq *pColl; /* COLLATE function from an ORDER BY clause term */
160994 /* Mark off any ORDER BY term X that is a column in the table of
160995 ** the current loop for which there is term in the WHERE
161071 ** If the current term is a column of an ((?,?) IN (SELECT...))
161075 ** considered to match an ORDER BY term.
161128 /* Find the ORDER BY term that corresponds to the j-th column
161129 ** of the index and mark that ORDER BY term off
161293 ** The (Y/X) term is implemented using stack variable rScale
161488 ** The term "((pTo->isOrdered^isOrdered)&0x80)==0" is equivalent
161966 ** by the WHERE_SELFCULL flag on the term.)
162292 /* Assign a bit from the bitmask to every term in the FROM clause.
162294 ** The N-th term of the FROM clause is assigned a bitmask of 1<<N.
162331 ** (constant expressions). Evaluate each such term, and jump over all the
162611 /* This is one term of an OR-optimization using the PRIMARY KEY of a
165200 ** the ORDER BY term in the window, and that argument op is OP_Ge, it generates
165208 ** If the sort-order for the ORDER BY term in the window is DESC, then the
166432 /* Add a single new term to an ExprList that is used to store a
167943 /* 216 */ "term",
168086 /* 33 */ "ccons ::= DEFAULT scantok term",
168088 /* 35 */ "ccons ::= DEFAULT PLUS scantok term",
168089 /* 36 */ "ccons ::= DEFAULT MINUS scantok term",
168235 /* 182 */ "term ::= NULL|FLOAT|BLOB",
168236 /* 183 */ "term ::= STRING",
168237 /* 184 */ "term ::= INTEGER",
168245 /* 192 */ "term ::= CTIME_KW",
168434 /* 381 */ "expr ::= term",
168591 case 216: /* term */
168997 215, /* (33) ccons ::= DEFAULT scantok term */
168999 215, /* (35) ccons ::= DEFAULT PLUS scantok term */
169000 215, /* (36) ccons ::= DEFAULT MINUS scantok term */
169146 216, /* (182) term ::= NULL|FLOAT|BLOB */
169147 216, /* (183) term ::= STRING */
169148 216, /* (184) term ::= INTEGER */
169156 216, /* (192) term ::= CTIME_KW */
169345 217, /* (381) expr ::= term */
169407 -3, /* (33) ccons ::= DEFAULT scantok term */
169409 -4, /* (35) ccons ::= DEFAULT PLUS scantok term */
169410 -4, /* (36) ccons ::= DEFAULT MINUS scantok term */
169556 -1, /* (182) term ::= NULL|FLOAT|BLOB */
169557 -1, /* (183) term ::= STRING */
169558 -1, /* (184) term ::= INTEGER */
169566 -1, /* (192) term ::= CTIME_KW */
169755 -1, /* (381) expr ::= term */
169960 case 33: /* ccons ::= DEFAULT scantok term */
169966 case 35: /* ccons ::= DEFAULT PLUS scantok term */
169969 case 36: /* ccons ::= DEFAULT MINUS scantok term */
170558 case 182: /* term ::= NULL|FLOAT|BLOB */
170559 case 183: /* term ::= STRING */ yytestcase(yyruleno==183);
170562 case 184: /* term ::= INTEGER */
170628 case 192: /* term ::= CTIME_KW */
171311 /* (381) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=381);
178764 ** given term. Doclists hold docids and associated token positions.
178819 ** Segment leaf nodes store terms and doclists, ordered by term. Leaf
178826 ** varint nTerm; (length of first term)
178827 ** char pTerm[nTerm]; (content of first term)
178828 ** varint nDoclist; (length of term's associated doclist)
178832 ** varint nPrefix; (length of prefix shared with previous term)
178834 ** char pTermSuffix[nSuffix];(unshared suffix of next term)
178835 ** varint nDoclist; (length of term's associated doclist)
178844 ** of a node is reached, the next term is in the node with the next
178850 ** node (a leaf node with a single term and doclist). The goal of
178874 ** varint nTerm; (length of first term)
178875 ** char pTerm[nTerm]; (content of first term)
178878 ** varint nPrefix; (length of shared prefix with previous term)
178880 ** char pTermSuffix[nSuffix]; (unshared suffix of next term)
178890 ** than the first term encoded (or all terms if no term is encoded).
178892 ** than pTerm[i+1], the subtree for that term will be rooted at
178893 ** iBlockid+i. Interior nodes only store enough term data to
178894 ** distinguish adjacent children (if the rightmost term of the left
178895 ** child is "something", and the leftmost term of the right child is
178983 ** index into the term index, we clearly cannot simply update the term
179846 char *zTerm; /* Pointer to term buffer */
180426 ** term may be quoted, but the <key> may not.
181515 ** a b-tree for a term or term prefix. The node data is passed to this
181516 ** function via the zNode/nNode parameters. The term to search for is
181520 ** of the child node that heads the sub-tree that may contain the term.
181523 ** that heads a sub-tree that may contain a term for which zTerm/nTerm is
181530 int nTerm, /* Size of term zTerm in bytes */
181541 int isFirstTerm = 1; /* True when processing first term on page */
181543 int nBuffer = 0; /* Total term size */
181566 int nSuffix; /* Size of term suffix */
181567 int nPrefix = 0; /* Size of term prefix */
181569 /* Load the next term on the node into zBuffer. Use realloc() to expand
181601 /* Compare the term we are searching for with the term just loaded from
181602 ** the interior node. If the specified term is greater than or equal
181603 ** to the term from the interior node, then all terms on the sub-tree
181607 ** If the interior node term is larger than the specified term, then
181608 ** the tree headed by iChild may contain the specified term.
181636 ** contains a term. This function searches the sub-tree headed by the zNode
181637 ** node for the range of leaf nodes that may contain the specified term
181638 ** or terms for which the specified term is a prefix.
181641 ** left-most leaf node in the tree that may contain the specified term.
181643 ** right-most leaf node that may contain a term for which the specified
181644 ** term is a prefix.
181647 ** the specified term or any terms for which it is a prefix. However, if the
181657 int nTerm, /* Size of term zTerm in bytes */
182125 ** large number of) doclists for each term that matches a prefix query.
182405 char *pList, /* Position list (no 0x00 term) */
182500 ** This function is called with the doclist for each term that matches
182516 /* If this is the first term selected, copy the doclist to the output
182709 ** passed as the 4th argument also scan the doclist for term zTerm/nTerm.
182726 ** Open an Fts3MultiSegReader to scan the doclist for term zTerm/nTerm. Or,
182801 ** This function retrieves the doclist for the specified term (or term
182812 Fts3MultiSegReader *pSegcsr; /* Seg-reader cursor for this term */
182814 Fts3SegFilter filter; /* Segment term filter configuration */
183799 ** segment b-tree (if the term is not a prefix or it is a prefix for which
185179 ** then any snippet() should ony highlight the "a" term, not the "b"
185810 "CREATE TABLE x(term, col, documents, occurrences, languageid HIDDEN)"
185922 /* This vtab delivers always results in "ORDER BY term ASC" order. */
185930 /* Search for equality and range constraints on the "term" column.
186080 ** increment the column 0 "nDoc" count for this term.
186138 int iEq = -1; /* Index of term=? value in apVal */
186139 int iGe = -1; /* Index of term>=? value in apVal */
186140 int iLe = -1; /* Index of term<=? value in apVal */
186238 case 0: /* term */
188841 char *zEnd; /* Pointer to nul-term of zCopy */
190046 int nTerm; /* Number of bytes in current term */
190047 char *zTerm; /* Pointer to current term */
190076 char *zTerm; /* Pointer to previous term buffer */
190109 char *zTerm; /* Pointer to previous term buffer */
190579 sqlite3_int64 iPos, /* Position of term for entry to add */
190727 /* Add the term to the terms index */
190732 /* Add the term to each of the prefix indexes that it is not too
190750 ** fts3PendingTermsAdd() are to add term/position-list pairs for the
190801 ** operation. It adds entries for each term in the new record to the
191195 ** Move the iterator passed as the first argument to the next term in the
191196 ** segment. If successful, SQLITE_OK is returned. If there is no next term,
191206 int nPrefix; /* Number of bytes in term prefix */
191207 int nSuffix; /* Number of bytes in term suffix */
191326 ** with the current term.
191352 ** associated with the current term.
191551 ** an array of pending terms by term. This occurs as part of flushing
191576 ** through each term in the pending-terms table. Or, if isPrefixIter is
191577 ** non-zero, it iterates through each term and its prefixes. For example, if
191600 Fts3HashElem **aElem = 0; /* Array of term hash entries to scan */
191631 /* If more than one term matches the prefix, sort the Fts3HashElem
191632 ** objects in term order using qsort(). This uses the same comparison
191640 /* The query is a simple term lookup that matches at most one term in
191682 ** term is a prefix of another, the longer term is considered the
191746 ** Compare the term that the Fts3SegReader object passed as the first argument
191747 ** points to with the term specified by arguments zTerm and nTerm.
191750 ** -ve if the pSeg term is less than zTerm/nTerm, 0 if the two terms are
191751 ** equal, or +ve if the pSeg term is greater than zTerm/nTerm.
191756 int nTerm /* Size of term zTerm in bytes */
191895 const char *zPrev, /* Buffer containing previous term */
191897 const char *zNext, /* Buffer containing next term */
191907 ** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
191908 ** (according to memcmp) than the previous term.
191914 const char *zTerm, /* Pointer to buffer containing term */
191915 int nTerm /* Size of term in bytes */
191921 /* First try to append the term to the current node. Return early if
191942 /* An unusual case: this is the first term to be added to the node
191957 /* There is no prefix-length field for first term in a node */
191988 ** If this is the first node in the tree, the term is added to it.
191990 ** Otherwise, the term is not added to the new node, it is left empty for
191991 ** now. Instead, the term is inserted into the parent of pTree. If pTree
192114 ** Add a term to the segment being constructed by the SegmentWriter object
192115 ** *ppWriter. When adding the first term to a segment, *ppWriter should
192125 const char *zTerm, /* Pointer to buffer containing term */
192126 int nTerm, /* Size of term in bytes */
192130 int nPrefix; /* Size of term prefix in bytes */
192131 int nSuffix; /* Size of term suffix in bytes */
192187 /* Add the current term to the interior node tree. The term added to
192190 ** a) be greater than the largest term on the leaf node just written
192193 ** b) be less than or equal to the term about to be added to the new
192229 /* Append the prefix-compressed term and doclist to the buffer. */
192240 /* Save the current term so that it can be used to prefix-compress the next.
192242 ** zTerm is transient, so take a copy of the term data. Otherwise, just
192647 /* If the Fts3SegFilter defines a specific term (or term prefix) to search
192648 ** for, then advance each segment iterator until it points to a term of
192649 ** equal or greater value than the specified term. This prevents many
192651 ** b-tree leaf nodes contain more than one term.
192696 /* Advance each segment iterator until it points to the term zTerm/nTerm. */
192731 ** then the entire doclist for the term is available in
192794 ** forward. Then sort the list in order of current term again.
192815 /* If this is a prefix-search, and if the term that apSegment[0] points
192819 ** Similarly, if this is a search for an exact match, and the first term
192859 /* The current term of the first nMerge entries in the array
192861 ** and a single term returned with the merged doclist.
193116 Fts3SegFilter filter; /* Segment term filter condition */
193625 Blob term; /* Current term */
193663 int bFirst = (p->term.n==0); /* True for first term on the node */
193664 int nPrefix = 0; /* Bytes to copy from previous term */
193679 if( nPrefix>p->term.n || nSuffix>p->nNode-p->iOff || nSuffix==0 ){
193682 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
193683 if( rc==SQLITE_OK && ALWAYS(p->term.a!=0) ){
193684 memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
193685 p->term.n = nPrefix+nSuffix;
193706 sqlite3_free(p->term.a);
193823 ** Append a term and (optionally) doclist to the FTS segment node currently
193830 ** The term to be appended is passed via arguments zTerm/nTerm. For a
193835 ** term written to the node. Otherwise, pPrev contains a copy of the
193836 ** previous term. Before this function returns, it is updated to contain a
193848 Blob *pPrev, /* Buffer containing previous term written */
193849 const char *zTerm, /* New term to write */
193855 int bFirst = (pPrev->n==0); /* True if this is the first term written */
193856 int nPrefix; /* Size of term prefix in bytes */
193857 int nSuffix; /* Size of term suffix in bytes */
193892 ** Append the current term and doclist pointed to by cursor pCsr to the
193900 Fts3MultiSegReader *pCsr /* Cursor containing term and doclist */
193908 int nPrefix; /* Size of prefix shared with previous term */
193921 /* If the current block is not empty, and if adding this term/doclist
193928 /* Add the current term to the parent node. The term added to the
193931 ** a) be greater than the largest term on the leaf node just written
193934 ** b) be less than or equal to the term about to be added to the new
194066 ** Compare the term in buffer zLhs (size in bytes nLhs) with that in
194067 ** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of
194193 if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){
194240 blobGrowBuffer(&pNode->key, reader.term.n, &rc);
194242 assert_fts3_nc( reader.term.n>0 || reader.aNode==0 );
194243 if( reader.term.n>0 ){
194244 memcpy(pNode->key.a, reader.term.a, reader.term.n);
194246 pNode->key.n = reader.term.n;
194503 Blob prev = {0, 0, 0}; /* Previous term written to new node */
194521 int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm);
194527 pNew, &prev, reader.term.a, reader.term.n,
195065 const char *zTerm, /* Pointer to buffer containing term */
195827 int n; /* Length of z in bytes (excl. nul-term) */
196339 ** query term. That is, the final term of the snippet is always a term
196340 ** that requires highlighting. For example, if 'X' is a highlighted term
196341 ** and '.' is a non-highlighted term, BestSnippet() may select:
196347 ** non-highlighted terms to the right of the final highlighted term as there
196348 ** are to the left of the first highlighted term. For example, to this:
196355 ** actually contains terms that follow the final highlighted term.
196428 const char *zOpen, /* String inserted before highlighted term */
196429 const char *zClose, /* String inserted after highlighted term */
196521 /* Set isHighlight to true if this term should be highlighted. */
196539 ** delta-encoded list of term offsets within a single column of a single
196542 ** contains the position of the first matching term in the column data).
197250 i64 iOff; /* Offset of this term from read positions */
214393 ** 0x01 There is a schema=? term in the WHERE clause
214394 ** 0x02 There is a name=? term in the WHERE clause
214395 ** 0x04 There is an aggregate=? term in the WHERE clause
221766 ** <li> By querying the index for all synonyms of each query term
221768 ** tokenizer may provide multiple synonyms for a single term
221786 ** <li> By adding multiple synonyms for a single term to the FTS index.
222544 const char *pTerm, int nTerm, /* Query term */
222556 const char **pzTerm, /* OUT: term (nul-terminated) */
224894 ** (1e-6) - roughly the same as a term that appears in just over
225356 /* Calculate a hash value for this term. This is the same hash checksum
226459 ** An instance of the following structure represents a single search term
226460 ** or term prefix.
226463 u8 bPrefix; /* True for a prefix term */
226465 char *zTerm; /* nul-terminated term */
226466 Fts5IndexIter *pIter; /* Iterator for this term */
226902 ** All individual term iterators in pPhrase are guaranteed to be valid and
226935 /* Initialize a term iterator for each term in the phrase */
227256 ** Initialize all term iterators in the pNear object. If any term is found
227261 ** SQLITE_OK. It is not considered an error if some term matches zero
227391 ** All individual term iterators in pNear are guaranteed to be valid when
227392 ** this function is called. This function checks if all term iterators
227465 ** Advance the first term iterator in the first phrase of pNear. Set output
227541 ** of a single term only, grab pointers into the poslist managed by the
227806 /* Initialize all term iterators in the NEAR object. */
229467 ** to accumuluate "term -> doclist" content before it is flused to a level-0
229929 ** Query the hash table for a doclist associated with term pTerm/nTerm.
229934 const char *pTerm, int nTerm, /* Query term */
229987 const char **pzTerm, /* OUT: term (nul-terminated) */
230031 ** As well as the main term index, there may be up to 31 prefix indexes.
230109 ** Most of each segment leaf is taken up by term/doclist data. The
230110 ** general format of term/doclist, starting with the first term
230113 ** varint : size of first term
230114 ** blob: first term data
230117 ** varint: number of bytes in common with previous term
230118 ** varint: number of bytes of new term data (nNew)
230119 ** blob: nNew bytes of new term data
230156 ** and occurs before the first term (otherwise 0).
230162 ** The page footer consists of a single varint for each term located
230163 ** on the page. Each varint is the byte offset of the current term
230166 ** the first term, the second is the byte offset of the second less that
230169 ** The term/doclist format described above is accurate if the entire
230170 ** term/doclist data fits on a single leaf page. If this is not the case,
230173 ** + if the first rowid on a page occurs before the first term, it
230178 ** + the first term on each page is stored in the same way as the
230179 ** very first term of the segment:
230181 ** varint : size of first term
230182 ** blob: first term data
230354 Fts5Buffer term; /* Buffer containing previous term on page */
230369 u8 bFirstTermInPage; /* True if next term will be first in leaf */
230371 int nEmpty; /* Number of contiguous term-less nodes */
230377 Fts5Buffer btterm; /* Next term to insert into %_idx table */
230388 ** Object for iterating through a single segment, visiting each term/rowid
230408 ** Leaf page number containing the last term read from the segment. And
230409 ** the offset immediately following the term data.
230416 ** has been exhausted. Do not proceed to the next term in the segment.
230426 ** For each rowid on the page corresponding to the current term, the
230431 ** Index of current term on iTermLeafPgno.
230444 /* The page and offset from which the current term was read. The offset
230460 Fts5Buffer term; /* Current term */
230480 ** false if it contains at least one term.
230490 ** visiting each term/rowid pair in the merged data.
230501 ** points to the smaller term/rowid combination. Iterators at EOF are
231403 ** doclist is associated with (the one featuring the term).
231695 ** "nSuffix" field of a term. Function parameter nKeep contains the value
231697 ** the first term in the segment).
231701 ** Fts5SegIter.term
231714 if( iOff+nNew>pIter->pLeaf->szLeaf || nKeep>pIter->term.n || nNew==0 ){
231718 pIter->term.n = nKeep;
231719 fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
231720 assert( pIter->term.n<=pIter->term.nSpace );
231874 /* iTermLeafOffset may be equal to szLeaf if the term is the last
231964 int *pbNewTerm /* OUT: Set for new term */
232008 sqlite3Fts5BufferSet(&p->rc,&pIter->term, (int)strlen(zTerm), (u8*)zTerm);
232036 int *pbNewTerm /* OUT: Set for new term */
232088 sqlite3Fts5BufferSet(&p->rc, &pIter->term, (int)strlen(zTerm),
232189 ** term may not be stored on the current page. So search forward to
232249 ** There is a doclist-index associated with the final term on the current
232250 ** page. If the current term is the last term on the page, load the
232263 ** term. */
232276 ** function searches the leaf page for a term matching (pTerm/nTerm).
232278 ** If the specified term is found on the page, then the iterator is left
232279 ** pointing to it. If argument bGe is zero and the term is not found,
232282 ** If bGe is non-zero and the specified term is not found, then the
232283 ** iterator is left pointing to the smallest term in the segment that
232284 ** is larger than the specified term, even if this term is not on the
232316 /* Figure out how many new bytes are in this term */
232357 /* Read the nKeep field of the next term. */
232397 fts5BufferSet(&p->rc, &pIter->term, nKeep, pTerm);
232398 fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
232418 "segid=? AND term<=? ORDER BY term DESC LIMIT 1",
232426 ** Initialize the object pIter to point to term pTerm/nTerm within segment
232427 ** pSeg. If there is no such term in the index, the iterator is set to EOF.
232450 ** contain term (pTerm/nTerm), if it is present in the segment. */
232496 ** 3) the iterator points to an entry with term (pTerm/nTerm), or
232498 ** to an entry with a term greater than or equal to (pTerm/nTerm).
232502 || fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)==0 /* 3 */
232503 || (bGe && fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)>0) /* 4 */
232508 ** Initialize the object pIter to point to term pTerm/nTerm within the
232509 ** in-memory hash table. If there is no such term in the hash-table, the
232554 sqlite3Fts5BufferSet(&p->rc, &pIter->term, n, z);
232575 fts5BufferFree(&pIter->term);
232606 int nMin = MIN(p1->term.n, p2->term.n);
232607 int res = fts5Memcmp(p1->term.p, p2->term.p, nMin);
232608 if( res==0 ) res = p1->term.n - p2->term.n;
232645 || fts5BufferCompare(&pFirst->term, &p1->term)
232705 int res = fts5BufferCompare(&p1->term, &p2->term);
232855 ** points to the same term though - just a different rowid. This function
232960 int *pbNewTerm /* OUT: True if *might* be new term */
233448 ** The iterator initially points to the first term/rowid entry in the
233634 ** Return a pointer to a buffer containing the term associated with the
233639 *pn = p->term.n;
233640 return p->term.p;
233799 ** last term on leaf page (pWriter->iBtPage) is completed.
233801 ** The doclist-index for that term is currently stored in-memory within the
233806 ** Fts5SegWriter.btterm currently contains the first term on page iBtPage.
233830 ** at least one term. Argument (nTerm/pTerm) is the split-key - a term that
233832 ** smaller than the first term on the new leaf.
233840 int nTerm, const u8 *pTerm /* First term on new page */
233865 /* Increment the "number of sequential leaves without a term" counter. */
233955 /* No term was written to this page. */
233983 ** Append term pTerm/nTerm to the segment being written by the writer passed
233994 int nPrefix; /* Bytes of prefix compression for term */
233997 int nMin = MIN(pPage->term.n, nTerm);
234025 /* This is the first term on a leaf that is not the leftmost leaf in
234026 ** the segment b-tree. In this case it is necessary to add a term to
234027 ** the b-tree hierarchy that is (a) larger than the largest term
234029 ** this term. In other words, a prefix of (pTerm/nTerm) that is one
234031 ** previous term.
234033 ** Usually, the previous term is available in pPage->term. The exception
234034 ** is if this is the first term written in an incremental-merge step.
234035 ** In this case the previous term is not available, so just write a
234039 if( pPage->term.n ){
234040 n = 1 + fts5PrefixCompress(nMin, pPage->term.p, pTerm);
234047 nPrefix = fts5PrefixCompress(nMin, pPage->term.p, pTerm);
234051 /* Append the number of bytes of new data, then the term data itself
234056 /* Update the Fts5PageWriter.term field. */
234057 fts5BufferSet(&p->rc, &pPage->term, nTerm, pTerm);
234156 fts5BufferFree(&pLeaf->term);
234192 "INSERT INTO '%q'.'%q_idx'(segid,term,pgno) VALUES(?,?,?)",
234248 fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
234249 fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
234306 Fts5Buffer term;
234310 int bTermWritten = 0; /* True if current term already output */
234316 memset(&term, 0, sizeof(Fts5Buffer));
234365 if( nTerm!=term.n || fts5Memcmp(pTerm, term.p, nTerm) ){
234369 fts5BufferSet(&p->rc, &term, nTerm, pTerm);
234377 /* This is a new term. Append a term to the output segment. */
234433 fts5BufferFree(&term);
234609 ** term/doclist currently stored within the hash table. */
234614 const char *zTerm; /* Buffer containing term */
234615 const u8 *pDoclist; /* Pointer to doclist for this term */
234618 /* Write the term for this entry to disk. */
235274 int nTerm = pSeg->term.n;
235275 const u8 *pTerm = pSeg->term.p;
235429 "segid, term, pgno, PRIMARY KEY(segid, term)",
235654 ** Move to the next matching term/rowid. Used by the fts5vocab module.
235665 if( pSeg->pLeaf && pSeg->term.p[0]!=FTS5_MAIN_PREFIX ){
235687 ** Return the current term.
235936 Fts5Buffer *pPrev, /* Previous term */
235937 const char *z, int n, /* Possibly new term to test */
235947 const char *zTerm = (const char*)&pPrev->p[1]; /* term sans prefix-byte */
236099 "SELECT segid, term, (pgno>>1), (pgno&1) FROM %Q.'%q_idx' WHERE segid=%d "
236121 /* Check that the leaf contains at least one term, and that it is equal
236124 ** location before the term. */
236128 int iOff; /* Offset of first term on leaf */
236130 int nTerm; /* Size of term on leaf in bytes */
236131 int res; /* Comparison of term and split-key */
236242 Fts5Buffer term = {0,0,0}; /* Buffer used to hold most recent term */
236270 ** As each term visited by the linear scans, a separate query for the
236271 ** same term is performed. cksum3 is calculated based on the entries
236278 int n; /* Size of term in bytes */
236284 /* If this is a new term, query for it. Update cksum3 with the results. */
236285 fts5TestTerm(p, &term, z, n, cksum2, &cksum3);
236303 fts5TestTerm(p, &term, 0, 0, cksum2, &cksum3);
236310 fts5BufferFree(&term);
236599 Fts5Buffer term; /* Current term read from page */
236606 memset(&term, 0, sizeof(Fts5Buffer));
236608 /* Decode any entries that occur before the first term. */
236620 /* Read the term data for the next term*/
236622 term.n = nKeep;
236623 fts5BufferAppendBlob(&rc, &term, nAppend, &a[iOff]);
236625 &rc, &s, " term=%.*s", term.n, (const char*)term.p
236629 /* Figure out where the doclist for this term ends */
236645 fts5BufferFree(&term);
236647 Fts5Buffer term; /* Current term read from page */
236656 memset(&term, 0, sizeof(Fts5Buffer));
236687 ** first term. */
236696 int bFirst = (iPgidxOff==szLeaf); /* True for first term on page */
236717 if( nByte>term.n ){
236721 term.n = nByte;
236728 fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]);
236732 &rc, &s, " term=%.*s", term.n, (const char*)term.p
236737 fts5BufferFree(&term);
243482 ** CREATE TABLE vocab(term, col, doc, cnt, PRIMARY KEY(term, col));
243484 ** One row for each term/column combination. The value of $doc is set to
243485 ** the number of fts5 rows that contain at least one instance of term
243486 ** $term within column $col. Field $cnt is set to the total number of
243487 ** instances of term $term in column $col (in any row of the fts5 table).
243490 ** CREATE TABLE vocab(term, doc, cnt, PRIMARY KEY(term));
243492 ** One row for each term in the database. The value of $doc is set to
243493 ** the number of fts5 rows that contain at least one instance of term
243494 ** $term. Field $cnt is set to the total number of instances of term
243495 ** $term in the database.
243498 ** CREATE TABLE vocab(term, doc, col, offset, PRIMARY KEY(<all-fields>));
243500 ** One row for each term instance in the database.
243530 char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */
243539 Fts5Buffer term; /* Current value of 'term' column */
243550 #define FTS5_VOCAB_COL_SCHEMA "term, col, doc, cnt"
243551 #define FTS5_VOCAB_ROW_SCHEMA "term, doc, cnt"
243552 #define FTS5_VOCAB_INST_SCHEMA "term, doc, col, offset"
243721 ** term <= ?
243722 ** term == ?
243723 ** term >= ?
243744 if( p->iColumn==0 ){ /* term column */
243772 ** the "term" column (column 0). So if the user has requested this
243773 ** specifically - "ORDER BY term" or "ORDER BY term ASC" - set the
243877 sqlite3Fts5BufferFree(&pCsr->term);
243900 sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);
243975 sqlite3Fts5BufferSet(&rc, &pCsr->term, nTerm, (const u8*)zTerm);
244042 if( nTerm!=pCsr->term.n
244043 || (nTerm>0 && memcmp(zTerm, pCsr->term.p, nTerm))
244156 pCtx, (const char*)pCsr->term.p, pCsr->term.n, SQLITE_TRANSIENT