Home | History | Annotate | Download | only in dist

Lines Matching refs:Select

116 **    * Terms in the result set of a SELECT statement
117 ** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
156 ** The maximum number of terms in a compound SELECT statement.
157 ** The code generator for compound SELECT statements does one
161 ** any limit on the number of terms in a compount SELECT.
2395 ** select random [ROWID | ROWIDs] when inserting new records into a table that
2463 ** disallows everything except [SELECT] statements.
2830 ** result set of a [SELECT] or the maximum number of columns in an index
2837 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
3218 ** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
3222 ** that implements the [SELECT] statement. ^The second parameter is the
3246 ** [SELECT] statement.
3295 ** If this statement is a [SELECT] statement and the Nth column of the
3296 ** returned result set of that [SELECT] is a table column (not an
3308 ** SELECT c1 + 1, c1 FROM t1;
4937 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
6143 ** SQLite checks if there are any currently executing SELECT statements
6800 typedef struct Select Select;
8422 #define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */
8743 ** of a SELECT statement.
8753 Select *pSelect; /* NULL for tables. Points to definition if a view. */
8992 ** code for a SELECT that contains aggregate functions.
9000 ** original Select structure that describes the SELECT statement. These
9071 ** Expr.x.pSelect is used if the expression is a sub-select or an expression of
9072 ** the form "<lhs> IN (SELECT ...)". If the EP_xIsSelect bit is set in the
9080 ** expression is used as a result in an aggregate SELECT, then the
9131 Select *pSelect; /* Used for sub-selects and "<expr> IN (<select>)" */
9221 ** as the list of "expr AS ID" fields following a "SELECT" or in the
9291 ** The following structure describes the FROM clause of a SELECT statement.
9314 Select *pSelect; /* A SELECT statement used in place of a table name */
9315 u8 isPopulated; /* Temporary table associated with SELECT is populated */
9446 ** be NULL. The pSrc corresponds to the FROM clause of a SELECT or
9448 ** pEList corresponds to the result set of a SELECT and is NULL for
9479 ** needed to generate code for a single SELECT statement.
9497 struct Select {
9507 Select *pPrior; /* Prior select in a compound select statement */
9508 Select *pNext; /* Next select to the left in a compound */
9509 Select *pRightmost; /* Right-most select in a compound select statement */
9513 int addrOpenEphm[3]; /* OP_OpenEphem opcodes related to this select */
9517 ** Allowed values for Select.selFlags. The "SF" prefix stands for
9518 ** "Select Flag".
9529 ** The results of a select can be distributed in several ways. The
9530 ** "SRT" prefix means "SELECT Result Type".
9705 int nHeight; /* Expression tree height of current sub-select */
9784 * "SELECT" statement. The meanings of the other members is determined by the
9789 * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then
9790 * this stores a pointer to the SELECT statement. Otherwise NULL.
9816 Select *pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */
9909 int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */
9920 SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
9921 SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
9922 SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
10099 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
10109 SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,Select*);
10125 SQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int);
10142 SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int);
10149 Token*, Select*, Expr*, IdList*);
10159 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
10160 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
10162 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
10236 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
10263 SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
10265 ExprList*,Select*,u8);
10305 SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
10399 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
10401 SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
10402 SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
10569 SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *);
43190 ** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance
43871 ** to evaluate "IN (SELECT ...)" and similar clauses.
44364 ** happen while processing an "INSERT INTO ... SELECT" statement), it
49131 /* Select a master journal file name */
51194 ** select list of a SELECT statement) that may cause a malloc() failure. If
56111 ** The second algorithm is to select a rowid at random and see if
56113 ** succeeded. If the random rowid does exist, we select a new one
57076 "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s",
58072 ** row. This can be NULL to have the virtual table select the new
59237 ** Walk all expressions associated with SELECT statement p. Do
59238 ** not invoke the SELECT callback on p, but do (of course) invoke
59239 ** any expr callbacks and SELECT callbacks that come from subqueries.
59242 SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){
59255 ** FROM clause of SELECT statement p. Do not invoke the select
59260 SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){
59277 ** Call sqlite3WalkExpr() for every expression in Select statement p.
59279 ** on the compound select chain, p->pPrior.
59287 SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
59337 ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x
59341 ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5
59592 ** SELECT a+b AS x FROM table WHERE x<10;
59909 ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause.
59942 ** ORDER BY of a compound SELECT. The expression has not been
59950 ** SELECT statement. Return the index i of the matching column,
59960 Select *pSelect, /* The SELECT statement with the ORDER BY clause */
60017 ** Analyze the ORDER BY clause in a compound SELECT statement. Modify
60019 ** and N where N is the number of columns in the compound SELECT.
60024 ** are matched against result set expressions of compound SELECT
60025 ** beginning with the left-most SELECT and working toward the right.
60033 Select *pSelect /* The SELECT statement containing the ORDER BY */
60113 ** the SELECT statement pSelect. If any term is reference to a
60123 Select *pSelect, /* The SELECT statement containing the clause */
60154 ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
60155 ** The Name context of the SELECT
60160 ** number of columns in the result set of the SELECT) then the expression
60172 NameContext *pNC, /* The name context of the SELECT statement */
60173 Select *pSelect, /* The SELECT statement holding pOrderBy */
60219 ** Resolve names in the SELECT statement p and all of its descendents.
60221 static int resolveSelectStep(Walker *pWalker, Select *p){
60222 NameContext *pOuterNC; /* Context that contains this SELECT */
60223 NameContext sNC; /* Name context of this SELECT */
60224 int isCompound; /* True if p is a compound select */
60230 Select *pLeftmost; /* Left-most of SELECT of a compound */
60243 ** already expanded this SELECT. However, if this is a subquery within
60246 ** sqlite3SelectPrep() do all of the processing for this SELECT.
60322 ** other expressions in the SELECT statement. This is so that
60342 /* Process the ORDER BY clause for singleton SELECT statements.
60343 ** The ORDER BY clause for compounds SELECT statements is handled
60378 /* Resolve the ORDER BY on a compound SELECT after all terms of
60415 ** size of an AS clause in the result-set of a SELECT. The Z expression
60420 ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x;
60424 ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b;
60476 ** Resolve all names in all expressions of a SELECT and in all
60477 ** decendents of the SELECT, including compounds off of p->pPrior,
60484 ** All SELECT statements should have been expanded using
60489 Select *p, /* The SELECT statement being coded. */
60490 NameContext *pOuterNC /* Name context for parent SELECT statement */
60523 ** or a sub-select with a column as the return value, then the
60531 ** SELECT * FROM t1 WHERE a;
60532 ** SELECT a AS b FROM t1 WHERE b;
60533 ** SELECT * FROM t1 WHERE (select a from t1);
60802 static void heightOfSelect(Select *p, int *pnHeight){
60846 ** by the select statement passed as an argument.
60848 SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *p){
61324 ** expression lists, ID lists, and select statements. The copies can
61431 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){
61432 Select *pNew;
61456 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){
61639 static int selectNodeIsConstant(Walker *pWalker, Select *NotUsed){
61832 ** x IN (SELECT ...)
61834 ** Where the SELECT... clause is as specified by the parameter to this
61837 ** The Select object passed in has already been preprocessed and no
61841 static int isCandidateForInOpt(Select *p){
61845 if( p==0 ) return 0; /* right-hand side of IN is SELECT */
61846 if( p->pPrior ) return 0; /* Not a compound SELECT */
61886 ** An existing b-tree may only be used if the SELECT is of the simple
61889 ** SELECT <column> FROM <table>
61912 ** for the duration of the query (i.e. the SELECT within the (...)
61927 Select *p; /* SELECT to the right of IN operator */
62033 ** (SELECT a FROM b) -- subquery
62034 ** EXISTS (SELECT a FROM b) -- EXISTS subquery
62036 ** x IN (SELECT a FROM b) -- IN operator with subquery on the right
62048 ** (not a SELECT or EXISTS) and that the RHS might contains NULLs.
62059 ** For a SELECT or EXISTS operator, return the register that holds the
62065 Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
62105 /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
62108 ** from the SELECT or the <exprlist>.
62110 ** If the 'x' expression is a column value, or the SELECT...
62113 ** SELECT... statement are columns, then numeric affinity is used
62115 ** 'x' nor the SELECT... statement are columns, then numeric affinity
62124 /* Case 1: expr IN (SELECT ...)
62126 ** Generate code to write the results of the select into the temporary
62208 /* If this has to be a scalar SELECT. Generate code to put the
62209 ** value of this select in a memory cell and record the number
62215 Select *pSel; /* SELECT statement to encode */
62216 SelectDest dest; /* How to deal with SELECt result */
62258 ** x IN (SELECT ...)
64138 static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
64511 ** Generate the text of a WHERE expression which can be used to select all
64527 ** Generate the text of a WHERE expression which can be used to select all
65330 ** rows of the table the index will select. If D is the count of distinct
65593 "SELECT idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase);
65611 "SELECT idx,sampleno,sample FROM %Q.sqlite_stat2", sInfo.zDatabase);
65740 ** SELECT sqlite_attach(x, y, z)
65914 ** SELECT sqlite_detach(x)
66147 Select *pSelect /* The SELECT statement to be fixed to one database */
67910 ** "CREATE TABLE ... AS SELECT ..." statement. The column names of
67911 ** the new table will match the result set of the SELECT.
67917 Select *pSelect /* Select from a "CREATE ... AS SELECT" */
67998 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
68002 ** Once the SELECT has been coded by sqlite3Select(), it is in a
68124 Select *pSelect, /* A SELECT statement that will become the new view */
68159 /* Make a copy of the entire SELECT statement that defines the view.
68201 Select *pSel; /* Copy of the SELECT that implements the view */
68226 ** CREATE VIEW one AS SELECT * FROM two;
68227 ** CREATE VIEW two AS SELECT * FROM one;
68234 ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;
68235 ** SELECT * FROM temp.ex1;
68247 ** to be permanent. So the computation is done on a copy of the SELECT
69691 ** SELECT statement that the subquery encodes. The pTable and
69704 Select *pSubquery, /* A subquery used in place of a table name */
70716 Select *pDup;
70761 Expr *pInClause = NULL; /* WHERE rowid IN ( select ) */
70762 Expr *pSelectRowid = NULL; /* SELECT rowid ... */
70764 SrcList *pSelectSrc = NULL; /* SELECT rowid FROM x ... (dup of pSrc) */
70765 Select *pSelect = NULL; /* Complete SELECT tree */
70775 /* We only need to generate a select expression if there
70784 /* Generate a select expression tree to enforce the limit/offset
70789 ** SELECT rowid FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1
70799 ** and the SELECT subtree. */
70806 /* generate the SELECT expression tree. */
73756 Select *pSelect = 0; /* If RESTRICT, "SELECT RAISE(...)" */
74118 ** a statement of the form "INSERT INTO <iDb, pTab> SELECT ..." can
74119 ** run without using temporary table for the results of the SELECT.
74309 Select *pSelect, /* A SELECT statement to use as the data source */
74318 ** insert into TABLE (IDLIST) select
74326 ** NULL and pSelect is a pointer to the select statement used to generate
74330 ** select with data coming from a VALUES clause, the code executes
74341 ** INSERT INTO <table> SELECT ...
74343 ** If the SELECT clause is of the restricted form "SELECT * FROM <table2>" -
74344 ** in other words if the SELECT pulls all columns from a single table
74364 ** and the SELECT clause does not read from <table> at any time.
74370 ** A: setup for the SELECT
74371 ** loop over the rows in the SELECT
74375 ** cleanup after the SELECT
74382 ** insert the select result into <table> from R..R+n
74387 ** values from a SELECT but the data is being inserted into a table
74388 ** that is also read as part of the SELECT. In the third form,
74390 ** the select. The template is like this:
74395 ** A: setup for the SELECT
74396 ** loop over the tables in the SELECT
74400 ** cleanup after the SELECT
74420 Select *pSelect, /* A SELECT statement to use as the data source */
74436 int useTempTable = 0; /* Store SELECT results in intermediate table */
74440 int addrSelect = 0; /* Address of coroutine that implements the SELECT */
74441 SelectDest dest; /* Destination for SELECT on rhs of INSERT */
74447 int regFromSelect = 0;/* Base register for data coming from SELECT */
74454 int regEof = 0; /* Register recording end of SELECT data */
74529 ** INSERT INTO <table1> SELECT * FROM <table2>;
74549 ** is coming from a SELECT statement, then generate a co-routine that
74550 ** produces a single row of the SELECT on each invocation. The
74554 /* Data is coming from a SELECT. Generate code to implement that SELECT
74561 ** A: setup for the SELECT
74562 ** loop over the tables in the SELECT
74566 ** cleanup after the SELECT
74572 ** SELECT result into registers dest.iMem...dest.iMem+dest.nMem-1.
74574 ** the SELECT completes, it sets the EOF flag stored in regEof.
74580 VdbeComment((v, "SELECT eof flag"));
74585 VdbeComment((v, "Jump over SELECT coroutine"));
74587 /* Resolve the expressions in the SELECT statement and execute it. */
74596 VdbeComment((v, "End of SELECT coroutine"));
74604 /* Set useTempTable to TRUE if the result of the SELECT statement
74606 ** FALSE if each* row of the SELECT can be written directly into
74610 ** of the tables being read by the SELECT statement. Also use a
74618 /* Invoke the coroutine to extract information from the SELECT
74771 ** insert the select result into <table> from R..R+n
74985 ** is a SELECT statement.
75548 ** INSERT INTO tab1 SELECT * FROM tab2;
75559 ** (4) The result set of the SELECT statement is "*"
75561 ** (5) The SELECT statement has no WHERE, HAVING, ORDER BY, GROUP BY,
75564 ** (6) The SELECT statement is a simple (not a compound) select that
75579 Select *pSelect, /* A SELECT statement to use as the data source */
75583 ExprList *pEList; /* The result set of the SELECT */
75584 Table *pSrc; /* The table in the FROM clause of SELECT */
75600 return 0; /* Must be of the form INSERT INTO ... SELECT ... */
75624 return 0; /* SELECT may not have a WHERE clause */
75627 return 0; /* SELECT may not have an ORDER BY clause */
75632 return 0; /* SELECT may not have a GROUP BY clause */
75635 return 0; /* SELECT may not have a LIMIT clause */
75639 return 0; /* SELECT may not be a compound query */
75642 return 0; /* SELECT may not be DISTINCT */
78687 "SELECT name, rootpage, sql FROM '%q'.%s",
78865 ** created by a sub-select). In this case the return value of this
79230 /************** Begin file select.c ******************************************/
79243 ** to handle SELECT statements in SQLite.
79248 ** Delete all the content of a Select structure but do not deallocate
79249 ** the select structure itself.
79251 static void clearSelect(sqlite3 *db, Select *p){
79276 ** Allocate a new Select structure and return a pointer to that
79279 SQLITE_PRIVATE Select *sqlite3SelectNew(
79291 Select *pNew;
79292 Select standin;
79326 ** Delete the given Select structure and all of its substructures.
79328 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){
79456 ** WHERE clause expression of a SELECT statement. The new term, which
79515 ** SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5
79536 ** This routine processes the join information for a SELECT statement.
79540 ** The terms of a FROM clause are contained in the Select.pSrc structure.
79541 ** The left most table is the first entry in Select.pSrc. The right-most
79549 static int sqliteProcessJoin(Parse *pParse, Select *p){
79644 Select *pSelect, /* The whole SELECT statement */
79683 Select *p, /* The SELECT statement being coded */
79724 ** Generate an error message when a SELECT is used within a subexpression
79725 ** (example: "a IN (SELECT * FROM table)") but it has more than 1 result
79731 SelectDest *pDest, /* Destination of SELECT results */
79732 int nExpr /* Number of result columns returned by SELECT */
79737 "a SELECT that is part of an expression");
79746 ** of a SELECT.
79755 Select *p, /* The complete select statement being coded */
79802 ** values returned by the SELECT are not required.
79809 /* If the DISTINCT keyword was present on the SELECT statement
79872 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
79903 /* If this is a scalar select that is part of an expression, then
79942 /* Discard the results. This is used for SELECT statements inside
79945 ** about the actual results of the select.
79969 ** implement that clause. If the ExprList is the result set of a SELECT
80014 Select *p, /* The SELECT statement */
80115 ** result-set expression in all of the following SELECT statements is
80118 ** SELECT col FROM tbl;
80119 ** SELECT (SELECT col FROM tbl;
80120 ** SELECT (SELECT col FROM tbl);
80121 ** SELECT abc FROM (SELECT col AS abc FROM tbl);
80147 Select *pS = 0; /* Select the column is extracted from */
80163 /* At one time, code such as "SELECT new.x" within a trigger would
80170 ** SELECT (SELECT t1.col) FROM FROM t1;
80173 ** sub-select. In this case, set the column type to NULL, even
80178 ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT
80185 /* The "table" is actually a sub-select or a view in the FROM clause
80186 ** of the SELECT statement. Return the declaration type and origin
80187 ** data for the result-set column of the sub-select.
80191 ** rowid of the sub-select or view. This expression is legal (see
80223 /* The expression is a sub-select. Return the declaration type and
80224 ** origin info for the single column in the result set of the SELECT
80228 Select *pS = pExpr->x.pSelect;
80374 ** that form the result set of a SELECT statement) compute appropriate
80467 ** a SELECT statement.
80473 ** This routine requires that all identifiers in the SELECT
80480 Select *pSelect /* SELECT used to determine types and collations */
80510 ** Given a SELECT statement, generate a Table structure that describes
80511 ** the result set of that SELECT.
80513 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
80564 ** Compute the iLimit and iOffset fields of the SELECT based on the
80579 ** SELECT statements.
80581 static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
80633 ** the result set for the compound-select statement "p". Return NULL if
80636 ** The collating sequence for the compound select is taken from the
80637 ** left-most term of the select that has a collating sequence.
80639 static CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){
80657 Select *p, /* The right-most of SELECTs to be coded */
80677 ** SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3
80681 ** SELECT c FROM t3
80683 ** `-----> SELECT b FROM t2
80685 ** `------> SELECT a FROM t1
80687 ** The arrows in the diagram above represent the Select.pPrior pointer.
80696 Select *p, /* The right-most of SELECTs to be coded */
80700 Select *pPrior; /* Another SELECT immediately to our left */
80703 Select *pDelete = 0; /* Chain of simple selects to delete */
80707 ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
80756 /* Generate code for the left and right SELECT statements.
80799 /* We can reuse a temporary table generated by a SELECT to our
80820 /* Code the SELECT statements to our left
80829 /* Code the current SELECT statement
80865 Select *pFirst = p;
80913 /* Code the current SELECT into temporary table "tab2"
80937 Select *pFirst = p;
80961 ** temporary tables needed to implement the compound select.
80964 ** This section is run by the right-most SELECT statement only.
80965 ** SELECT statements to the left always skip this part. The right-most
80966 ** SELECT might also skip this part if it has no ORDER BY clause and
80972 Select *pLoop; /* For looping through SELECT statements */
81022 ** SELECT statment.
81042 Select *p, /* The SELECT statement */
81095 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
81122 /* If this is a scalar select that is part of an expression, then
81178 ** Alternative compound select code generator for cases when there
81228 ** following nextX causes a jump to the end of the select processing.
81265 Select *p, /* The right-most of SELECTs to be coded */
81269 Select *pPrior; /* Another SELECT immediately to our left */
81273 int regAddrA; /* Address register for select-A coroutine */
81274 int regEofA; /* Flag to indicate when select-A is complete */
81275 int regAddrB; /* Address register for select-B coroutine */
81276 int regEofB; /* Flag to indicate when select-B is complete */
81277 int addrSelectA; /* Address of the select-A coroutine */
81278 int addrSelectB; /* Address of the select-B coroutine */
81283 int addrEofA; /* Address of the select-A-exhausted subroutine */
81284 int addrEofB; /* Address of the select-B-exhausted subroutine */
81288 int regLimitA; /* Limit register for select-A */
81289 int regLimitB; /* Limit register for select-A */
81294 int labelEnd; /* Label for the end of the overall SELECT stmt */
81452 /* Generate a coroutine to evaluate the SELECT statement to the
81453 ** left of the compound operator - the "A" select.
81455 VdbeNoopComment((v, "Begin coroutine for left SELECT"));
81460 VdbeNoopComment((v, "End coroutine for left SELECT"));
81462 /* Generate a coroutine to evaluate the SELECT statement on
81463 ** the right - the "B" select
81466 VdbeNoopComment((v, "Begin coroutine for right SELECT"));
81476 VdbeNoopComment((v, "End coroutine for right SELECT"));
81479 ** select as the next output row of the compound select.
81487 ** select as the next output row of the compound select.
81496 /* Generate a subroutine to run when the results from select A
81497 ** are exhausted and only data in select B remains.
81509 /* Generate a subroutine to run when the results from select B
81510 ** are exhausted and only data in select A remains.
81587 Select *pFirst = pPrior;
81608 static void substSelect(sqlite3*, Select *, int, ExprList *);
81618 ** FROM clause of a SELECT such that the VDBE cursor assigned to that
81669 Select *p, /* SELECT statement in which to make substitutions */
81684 assert( pSrc ); /* Even for (SELECT 1) we have: pSrc!=0 but pSrc->nSrc==0 */
81702 ** SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5
81712 ** a single flat select, like this:
81714 ** SELECT x+y AS a FROM t1 WHERE z<100 AND a>5
81757 ** (15) The outer query is not part of a compound select or the
81765 ** (17) The sub-query is not a compound select, or it is a UNION ALL
81769 ** * is not itself part of a compound select,
81777 ** (18) If the sub-query is a compound select, then all terms of the
81784 ** (20) If the sub-query is a compound select, then it must not use
81802 Select *p, /* The parent or outer SELECT statement */
81804 int isAgg, /* True if outer SELECT uses aggregate functions */
81808 Select *pParent;
81809 Select *pSub; /* The inner query or "subquery" */
81810 Select *pSub1; /* Pointer to the rightmost select in sub-query */
81877 ** t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0)
81895 /* Restriction 17: If the sub-query is a compound SELECT, then it must
81896 ** use only the UNION ALL operator. And none of the simple select queries
81897 SELECT are allowed to be aggregate or distinct
81934 /* If the sub-query is a compound SELECT statement, then (by restrictions
81938 ** SELECT <expr-list> FROM (<sub-query>) <where-clause>
81944 ** select statements in the compound sub-query.
81948 ** SELECT a+1 FROM (
81949 ** SELECT x FROM tab
81951 ** SELECT y FROM tab
81953 ** SELECT abs(z*2) FROM tab2
81958 ** SELECT x+1 FROM tab WHERE x+1!=5
81960 ** SELECT y+1 FROM tab WHERE y+1!=5
81962 ** SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5
81968 Select *pNew;
81971 Select *pPrior = p->pPrior;
82066 ** SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB;
82096 ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b;
82149 ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;
82170 ** Analyze the SELECT statement passed as an argument to see if it
82180 static u8 minMaxQuery(Select *p){
82201 ** The select statement passed as the first argument is an aggregate query.
82203 ** function tests if the SELECT is of the form:
82205 ** SELECT count(*) FROM <tbl>
82207 ** where table is a database table, not a sub-select or view. If the query
82211 static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
82260 ** This routine is a Walker callback for "expanding" a SELECT statement.
82268 ** fill pTabList->a[].pSelect with a copy of the SELECT statement
82269 ** that implements the view. A copy is made of the view's SELECT
82283 static int selectExpander(Walker *pWalker, Select *p){
82302 ** the FROM clause of the SELECT statement.
82306 /* Look up every table named in the FROM clause of the select. If
82320 Select *pSel = pFrom->pSelect;
82321 /* A sub-query in the FROM clause of a SELECT */
82517 ** This routine "expands" a SELECT statement and all of its subqueries.
82518 ** For additional information on what it means to "expand" a SELECT
82521 ** Expanding a SELECT statement is the first step in processing a
82522 ** SELECT statement. The SELECT statement must be expanded before
82529 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
82552 static int selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
82566 /* A sub-query in the FROM clause of a SELECT */
82567 Select *pSel = pFrom->pSelect;
82581 ** SELECT statement.
82585 static void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){
82597 ** This routine sets of a SELECT statement for processing. The
82606 ** This routine acts recursively on all subqueries within the SELECT.
82610 Select *p, /* The SELECT statement being coded. */
82737 ** Generate code for the SELECT statement given in the p argument.
82756 ** results. Used to implement "IN (SELECT ...)".
82779 ** SRT_Discard Throw the results away. This is used by SELECT
82787 ** This routine does NOT free the Select structure passed in. The
82792 Select *p, /* The SELECT statement being coded. */
82798 int isAgg; /* True for select lists like "count(*)" */
82800 SrcList *pTabList; /* List of tables to select from */
82850 Select *pSub = pItem->pSelect;
82856 ** tree refered to by this, the parent select. The child select
82899 Select *pLoop, *pRight = 0;
82909 sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
83016 int addrEnd; /* End of processing for this SELECT */
83039 ** SELECT statement.
83270 ** SELECT count(*) FROM <tbl>
83323 ** SELECT min(x) FROM ...
83324 ** SELECT max(x) FROM ...
83337 ** + If the query is a "SELECT min(x)", then the loop coded by
83399 /* The SELECT was successfully coded. Set the return code to 0
83405 ** successful coding of the SELECT.
83409 /* Identify column names if results of the SELECT are to be output.
83427 ** parse structures such as Select or Expr. Such printouts are useful
83429 ** during the execution of complex SELECT statements.
83460 SQLITE_PRIVATE void sqlite3PrintSelect(Select *p, int indent){
83516 /************** End of select.c **********************************************/
84040 ** Turn a SELECT statement (that the pSelect parameter points to) into
84043 ** The parser calls this routine when it finds a SELECT statement in
84046 SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect){
84094 Select *pSelect, /* A SELECT statement that supplies values */
84444 Select *pSelect = sqlite3SelectDup(db, pStep->pSelect, 0);
85410 ExprList *pEList = 0; /* The result set of the SELECT statement */
85411 Select *pSelect = 0; /* The SELECT statement */
85413 int ephemTab; /* Table holding the result of the SELECT */
85421 /* Construct the SELECT statement that will find the new values for
85668 "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) "
85674 "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)"
85678 "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) "
85683 ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
85687 "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
85688 "|| ' SELECT * FROM main.' || quote(name) || ';'"
85698 "SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' "
85703 "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
85704 "|| ' SELECT * FROM main.' || quote(name) || ';' "
85717 " SELECT type, name, tbl_name, rootpage, sql"
87172 static Bitmask exprSelectTableUsage(WhereMaskSet*, Select*);
87199 static Bitmask exprSelectTableUsage(WhereMaskSet *pMaskSet, Select *pS){
88094 ** pOrderBy is an ORDER BY clause from a SELECT statement. pTab is the
88095 ** left-most table in the FROM clause of that same SELECT statement and
88945 ** in the SELECT statement, then no indexes are considered. However, the
89053 ** If there exists a WHERE term of the form "x IN (SELECT ...)", then
89054 ** the sub-select is assumed to return 25 rows for the purposes of
89058 ** Set to true if there was at least one "x IN (SELECT ...)" term used
89079 ** columns of the table used by the SELECT statement are present in
89084 ** SELECT a, b FROM tbl WHERE a = 1;
89085 ** SELECT a, b, c FROM tbl WHERE a = 1;
89303 ** (1) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok'
89304 ** (2) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok'
89305 ** (3) SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok'
89470 ** SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b;
89789 int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */
89809 ** was passed to this function to implement a "SELECT min(x) ..."
89977 ** SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13)
90219 ** the FROM clause of a select. (INSERT and UPDATE statements are the
90220 ** same as a SELECT with only a single table in the FROM clause.) For
90223 ** SELECT * FROM t1, t2, t3 WHERE ...;
90284 ** *ppOrderBy is a pointer to the ORDER BY clause of a SELECT statement,
90474 ** cost. However, this meant that SQLite could select the wrong plan
90479 ** SELECT * FROM t2, t1 WHERE t2.rowid = t1.a;
90883 ** LIMIT clause of a SELECT statement.
91045 Select* yy3;
91790 "SELECT", "DISTINCT", "DOT", "FROM",
91801 "select", "column", "columnid", "type",
91865 /* 33 */ "create_table_args ::= AS select",
91942 /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
91944 /* 112 */ "cmd ::= select",
91945 /* 113 */ "select ::= oneselect",
91946 /* 114 */ "select ::= select multiselect_op oneselect",
91950 /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
91967 /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
92006 /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
92061 /* 229 */ "expr ::= LP select RP",
92062 /* 230 */ "expr ::= expr in_op LP select RP",
92064 /* 232 */ "expr ::= EXISTS LP select RP",
92125 /* 293 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
92127 /* 295 */ "trigger_cmd ::= select",
92240 case 160: /* select */
93021 case 33: /* create_table_args ::= AS select */
93203 case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
93213 case 112: /* cmd ::= select */
93220 case 113: /* select ::= oneselect */
93223 case 114: /* select ::= select multiselect_op oneselect */
93237 case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
93301 case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
93311 Select *pSubquery;
93427 case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
93644 case 229: /* expr ::= LP select RP */
93658 case 230: /* expr ::= expr in_op LP select RP */
93689 case 232: /* expr ::= EXISTS LP select RP */
93875 case 293: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
93881 case 295: /* trigger_cmd ::= select */
94492 testcase( i==18 ); /* SELECT */
98789 ** "SELECT block FROM %_segments WHERE blockid BETWEEN ? AND ?
98840 ** SELECT docid FROM ex1 WHERE b MATCH 'one two three';
99572 const char *zTerm, /* Term to select leaves for */
100549 "SELECT * FROM %Q.'%q_content' WHERE docid = ?", /* non-full-table-scan */
100550 "SELECT * FROM %Q.'%q_content'", /* full-table-scan */
100570 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
100912 ** SELECT optimize(t) FROM t LIMIT 1;
101924 const char zSql[] = "SELECT fts3_tokenizer(?)";
101998 ** SELECT fts3_exprtest('simple', 'Bill col2:Bloggs', 'col1', 'col2');
103148 ** SELECT <function-name>(<key-name>);
103149 ** SELECT <function-name>(<key-name>, <pointer>);
103336 ** SELECT <function-name>(<key-name>, <input-string>);
103337 ** SELECT <function-name>(<key-name>, <pointer>);
103350 ** SELECT fts_tokenizer_test('simple', 'I don't see how');
103453 const char zSql[] = "SELECT fts3_tokenizer(?, ?)";
103475 const char zSql[] = "SELECT fts3_tokenizer(?)";
103510 ** SELECT fts3_tokenizer_internal_test();
104003 /* 1 */ "SELECT NOT EXISTS(SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)",
104007 /* 5 */ "SELECT * FROM %Q.'%q_content' WHERE rowid=?",
104008 /* 6 */ "SELECT coalesce(max(idx)+1, 0) FROM %Q.'%q_segdir' WHERE level=?",
104010 /* 8 */ "SELECT coalesce(max(blockid)+1, 1) FROM %Q.'%q_segments'",
104014 /* 10 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
104016 SELECT idx, start_block, leaves_end_block, end_block, root "
104019 /* 12 */ "SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?",
104020 /* 13 */ "SELECT count(*), max(level) FROM %Q.'%q_segdir'",
104025 /* 17 */ "SELECT block FROM %Q.'%q_segments' WHERE blockid = ?",
104509 ** SELECT max(idx) FROM %_segdir WHERE level = :iLevel
104685 /* Move the leaf-range SELECT statement to the aLeavesStmt[] array,
104741 "SELECT block FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ? "
104893 ** SELECT
108861 /* Select the child node which will be enlarged the least if pCell
109822 ** Select a currently unused rowid for a new r-tree record.
110062 "SELECT data FROM '%q'.'%q_node' WHERE nodeno = :1",
110067 "SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = :1",
110072 "SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = :1",
110268 ** SELECT rtreenode(2, data) FROM rt_node;
110767 ** SELECT icu_load_collation(<locale>, <collation-name>);