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
6805 typedef struct Select Select;
8427 #define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */
8748 ** of a SELECT statement.
8758 Select *pSelect; /* NULL for tables. Points to definition if a view. */
8997 ** code for a SELECT that contains aggregate functions.
9005 ** original Select structure that describes the SELECT statement. These
9076 ** Expr.x.pSelect is used if the expression is a sub-select or an expression of
9077 ** the form "<lhs> IN (SELECT ...)". If the EP_xIsSelect bit is set in the
9085 ** expression is used as a result in an aggregate SELECT, then the
9136 Select *pSelect; /* Used for sub-selects and "<expr> IN (<select>)" */
9226 ** as the list of "expr AS ID" fields following a "SELECT" or in the
9296 ** The following structure describes the FROM clause of a SELECT statement.
9319 Select *pSelect; /* A SELECT statement used in place of a table name */
9320 u8 isPopulated; /* Temporary table associated with SELECT is populated */
9451 ** be NULL. The pSrc corresponds to the FROM clause of a SELECT or
9453 ** pEList corresponds to the result set of a SELECT and is NULL for
9484 ** needed to generate code for a single SELECT statement.
9502 struct Select {
9512 Select *pPrior; /* Prior select in a compound select statement */
9513 Select *pNext; /* Next select to the left in a compound */
9514 Select *pRightmost; /* Right-most select in a compound select statement */
9518 int addrOpenEphm[3]; /* OP_OpenEphem opcodes related to this select */
9522 ** Allowed values for Select.selFlags. The "SF" prefix stands for
9523 ** "Select Flag".
9534 ** The results of a select can be distributed in several ways. The
9535 ** "SRT" prefix means "SELECT Result Type".
9710 int nHeight; /* Expression tree height of current sub-select */
9789 * "SELECT" statement. The meanings of the other members is determined by the
9794 * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then
9795 * this stores a pointer to the SELECT statement. Otherwise NULL.
9821 Select *pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */
9914 int (*xSelectCallback)(Walker*,Select*); /* Callback for SELECTs */
9925 SQLITE_PRIVATE int sqlite3WalkSelect(Walker*, Select*);
9926 SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
9927 SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
10104 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
10114 SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,Select*);
10130 SQLITE_PRIVATE void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int);
10147 SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int);
10154 Token*, Select*, Expr*, IdList*);
10164 SQLITE_PRIVATE int sqlite3Select(Parse*, Select*, SelectDest*);
10165 SQLITE_PRIVATE Select *sqlite3SelectNew(Parse*,ExprList*,SrcList*,Expr*,ExprList*,
10167 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3*, Select*);
10241 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
10268 SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3*,Select*);
10270 ExprList*,Select*,u8);
10310 SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
10404 SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
10406 SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
10407 SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
10574 SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *);
43201 ** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance
43882 ** to evaluate "IN (SELECT ...)" and similar clauses.
44375 ** happen while processing an "INSERT INTO ... SELECT" statement), it
49142 /* Select a master journal file name */
51205 ** select list of a SELECT statement) that may cause a malloc() failure. If
56122 ** The second algorithm is to select a rowid at random and see if
56124 ** succeeded. If the random rowid does exist, we select a new one
57087 "SELECT name, rootpage, sql FROM '%q'.%s WHERE %s",
58083 ** row. This can be NULL to have the virtual table select the new
59248 ** Walk all expressions associated with SELECT statement p. Do
59249 ** not invoke the SELECT callback on p, but do (of course) invoke
59250 ** any expr callbacks and SELECT callbacks that come from subqueries.
59253 SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){
59266 ** FROM clause of SELECT statement p. Do not invoke the select
59271 SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){
59288 ** Call sqlite3WalkExpr() for every expression in Select statement p.
59290 ** on the compound select chain, p->pPrior.
59298 SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
59348 ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY x
59352 ** SELECT random()%5 AS x, count(*) FROM tab GROUP BY random()%5
59603 ** SELECT a+b AS x FROM table WHERE x<10;
59920 ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause.
59953 ** ORDER BY of a compound SELECT. The expression has not been
59961 ** SELECT statement. Return the index i of the matching column,
59971 Select *pSelect, /* The SELECT statement with the ORDER BY clause */
60028 ** Analyze the ORDER BY clause in a compound SELECT statement. Modify
60030 ** and N where N is the number of columns in the compound SELECT.
60035 ** are matched against result set expressions of compound SELECT
60036 ** beginning with the left-most SELECT and working toward the right.
60044 Select *pSelect /* The SELECT statement containing the ORDER BY */
60124 ** the SELECT statement pSelect. If any term is reference to a
60134 Select *pSelect, /* The SELECT statement containing the clause */
60165 ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
60166 ** The Name context of the SELECT statement is pNC. zType is either
60171 ** number of columns in the result set of the SELECT) then the expression
60183 NameContext *pNC, /* The name context of the SELECT statement */
60184 Select *pSelect, /* The SELECT statement holding pOrderBy */
60230 ** Resolve names in the SELECT statement p and all of its descendents.
60232 static int resolveSelectStep(Walker *pWalker, Select *p){
60233 NameContext *pOuterNC; /* Context that contains this SELECT */
60234 NameContext sNC; /* Name context of this SELECT */
60235 int isCompound; /* True if p is a compound select */
60241 Select *pLeftmost; /* Left-most of SELECT of a compound */
60254 ** already expanded this SELECT. However, if this is a subquery within
60257 ** sqlite3SelectPrep() do all of the processing for this SELECT.
60333 ** other expressions in the SELECT statement. This is so that
60353 /* Process the ORDER BY clause for singleton SELECT statements.
60354 ** The ORDER BY clause for compounds SELECT statements is handled
60389 /* Resolve the ORDER BY on a compound SELECT after all terms of
60426 ** size of an AS clause in the result-set of a SELECT. The Z expression
60431 ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x;
60435 ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b;
60487 ** Resolve all names in all expressions of a SELECT and in all
60488 ** decendents of the SELECT, including compounds off of p->pPrior,
60495 ** All SELECT statements should have been expanded using
60500 Select *p, /* The SELECT statement being coded. */
60501 NameContext *pOuterNC /* Name context for parent SELECT statement */
60534 ** or a sub-select with a column as the return value, then the
60542 ** SELECT * FROM t1 WHERE a;
60543 ** SELECT a AS b FROM t1 WHERE b;
60544 ** SELECT * FROM t1 WHERE (select a from t1);
60813 static void heightOfSelect(Select *p, int *pnHeight){
60857 ** by the select statement passed as an argument.
60859 SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *p){
61335 ** expression lists, ID lists, and select statements. The copies can
61442 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){
61443 Select *pNew;
61467 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *p, int flags){
61650 static int selectNodeIsConstant(Walker *pWalker, Select *NotUsed){
61843 ** x IN (SELECT ...)
61845 ** Where the SELECT... clause is as specified by the parameter to this
61848 ** The Select object passed in has already been preprocessed and no
61852 static int isCandidateForInOpt(Select *p){
61856 if( p==0 ) return 0; /* right-hand side of IN is SELECT */
61857 if( p->pPrior ) return 0; /* Not a compound SELECT */
61897 ** An existing b-tree may only be used if the SELECT is of the simple
61900 ** SELECT <column> FROM <table>
61923 ** for the duration of the query (i.e. the SELECT within the (...)
61938 Select *p; /* SELECT to the right of IN operator */
62044 ** (SELECT a FROM b) -- subquery
62045 ** EXISTS (SELECT a FROM b) -- EXISTS subquery
62047 ** x IN (SELECT a FROM b) -- IN operator with subquery on the right
62059 ** (not a SELECT or EXISTS) and that the RHS might contains NULLs.
62070 ** For a SELECT or EXISTS operator, return the register that holds the
62076 Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
62116 /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
62119 ** from the SELECT or the <exprlist>.
62121 ** If the 'x' expression is a column value, or the SELECT...
62124 ** SELECT... statement are columns, then numeric affinity is used
62126 ** 'x' nor the SELECT... statement are columns, then numeric affinity
62135 /* Case 1: expr IN (SELECT ...)
62137 ** Generate code to write the results of the select into the temporary
62219 /* If this has to be a scalar SELECT. Generate code to put the
62220 ** value of this select in a memory cell and record the number
62226 Select *pSel; /* SELECT statement to encode */
62227 SelectDest dest; /* How to deal with SELECt result */
62269 ** x IN (SELECT ...)
64149 static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
64522 ** Generate the text of a WHERE expression which can be used to select all
64538 ** Generate the text of a WHERE expression which can be used to select all
65341 ** rows of the table the index will select. If D is the count of distinct
65604 "SELECT idx, stat FROM %Q.sqlite_stat1", sInfo.zDatabase);
65622 "SELECT idx,sampleno,sample FROM %Q.sqlite_stat2", sInfo.zDatabase);
65751 ** SELECT sqlite_attach(x, y, z)
65925 ** SELECT sqlite_detach(x)
66158 Select *pSelect /* The SELECT statement to be fixed to one database */
67921 ** "CREATE TABLE ... AS SELECT ..." statement. The column names of
67922 ** the new table will match the result set of the SELECT.
67928 Select *pSelect /* Select from a "CREATE ... AS SELECT" */
68009 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
68013 ** Once the SELECT has been coded by sqlite3Select(), it is in a
68135 Select *pSelect, /* A SELECT statement that will become the new view */
68170 /* Make a copy of the entire SELECT statement that defines the view.
68212 Select *pSel; /* Copy of the SELECT that implements the view */
68237 ** CREATE VIEW one AS SELECT * FROM two;
68238 ** CREATE VIEW two AS SELECT * FROM one;
68245 ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;
68246 ** SELECT * FROM temp.ex1;
68258 ** to be permanent. So the computation is done on a copy of the SELECT
69702 ** SELECT statement that the subquery encodes. The pTable and
69715 Select *pSubquery, /* A subquery used in place of a table name */
70727 Select *pDup;
70772 Expr *pInClause = NULL; /* WHERE rowid IN ( select ) */
70773 Expr *pSelectRowid = NULL; /* SELECT rowid ... */
70775 SrcList *pSelectSrc = NULL; /* SELECT rowid FROM x ... (dup of pSrc) */
70776 Select *pSelect = NULL; /* Complete SELECT tree */
70786 /* We only need to generate a select expression if there
70795 /* Generate a select expression tree to enforce the limit/offset
70800 ** SELECT rowid FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1
70810 ** and the SELECT subtree. */
70817 /* generate the SELECT expression tree. */
73767 Select *pSelect = 0; /* If RESTRICT, "SELECT RAISE(...)" */
74129 ** a statement of the form "INSERT INTO <iDb, pTab> SELECT ..." can
74130 ** run without using temporary table for the results of the SELECT.
74320 Select *pSelect, /* A SELECT statement to use as the data source */
74329 ** insert into TABLE (IDLIST) select
74337 ** NULL and pSelect is a pointer to the select statement used to generate
74341 ** select with data coming from a VALUES clause, the code executes
74352 ** INSERT INTO <table> SELECT ...
74354 ** If the SELECT clause is of the restricted form "SELECT * FROM <table2>" -
74355 ** in other words if the SELECT pulls all columns from a single table
74375 ** and the SELECT clause does not read from <table> at any time.
74381 ** A: setup for the SELECT
74382 ** loop over the rows in the SELECT
74386 ** cleanup after the SELECT
74393 ** insert the select result into <table> from R..R+n
74398 ** values from a SELECT but the data is being inserted into a table
74399 ** that is also read as part of the SELECT. In the third form,
74401 ** the select. The template is like this:
74406 ** A: setup for the SELECT
74407 ** loop over the tables in the SELECT
74411 ** cleanup after the SELECT
74431 Select *pSelect, /* A SELECT statement to use as the data source */
74447 int useTempTable = 0; /* Store SELECT results in intermediate table */
74451 int addrSelect = 0; /* Address of coroutine that implements the SELECT */
74452 SelectDest dest; /* Destination for SELECT on rhs of INSERT */
74458 int regFromSelect = 0;/* Base register for data coming from SELECT */
74465 int regEof = 0; /* Register recording end of SELECT data */
74540 ** INSERT INTO <table1> SELECT * FROM <table2>;
74560 ** is coming from a SELECT statement, then generate a co-routine that
74561 ** produces a single row of the SELECT on each invocation. The
74565 /* Data is coming from a SELECT. Generate code to implement that SELECT
74572 ** A: setup for the SELECT
74573 ** loop over the tables in the SELECT
74577 ** cleanup after the SELECT
74583 ** SELECT result into registers dest.iMem...dest.iMem+dest.nMem-1.
74585 ** the SELECT completes, it sets the EOF flag stored in regEof.
74591 VdbeComment((v, "SELECT eof flag"));
74596 VdbeComment((v, "Jump over SELECT coroutine"));
74598 /* Resolve the expressions in the SELECT statement and execute it. */
74607 VdbeComment((v, "End of SELECT coroutine"));
74615 /* Set useTempTable to TRUE if the result of the SELECT statement
74617 ** FALSE if each* row of the SELECT can be written directly into
74621 ** of the tables being read by the SELECT statement. Also use a
74629 /* Invoke the coroutine to extract information from the SELECT
74782 ** insert the select result into <table> from R..R+n
74996 ** is a SELECT statement.
75559 ** INSERT INTO tab1 SELECT * FROM tab2;
75570 ** (4) The result set of the SELECT statement is "*"
75572 ** (5) The SELECT statement has no WHERE, HAVING, ORDER BY, GROUP BY,
75575 ** (6) The SELECT statement is a simple (not a compound) select that
75590 Select *pSelect, /* A SELECT statement to use as the data source */
75594 ExprList *pEList; /* The result set of the SELECT */
75595 Table *pSrc; /* The table in the FROM clause of SELECT */
75611 return 0; /* Must be of the form INSERT INTO ... SELECT ... */
75635 return 0; /* SELECT may not have a WHERE clause */
75638 return 0; /* SELECT may not have an ORDER BY clause */
75643 return 0; /* SELECT may not have a GROUP BY clause */
75646 return 0; /* SELECT may not have a LIMIT clause */
75650 return 0; /* SELECT may not be a compound query */
75653 return 0; /* SELECT may not be DISTINCT */
78698 "SELECT name, rootpage, sql FROM '%q'.%s",
78876 ** created by a sub-select). In this case the return value of this
79241 /************** Begin file select.c ******************************************/
79254 ** to handle SELECT statements in SQLite.
79259 ** Delete all the content of a Select structure but do not deallocate
79260 ** the select structure itself.
79262 static void clearSelect(sqlite3 *db, Select *p){
79287 ** Allocate a new Select structure and return a pointer to that
79290 SQLITE_PRIVATE Select *sqlite3SelectNew(
79302 Select *pNew;
79303 Select standin;
79337 ** Delete the given Select structure and all of its substructures.
79339 SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){
79467 ** WHERE clause expression of a SELECT statement. The new term, which
79526 ** SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.b AND t1.x=5
79547 ** This routine processes the join information for a SELECT statement.
79551 ** The terms of a FROM clause are contained in the Select.pSrc structure.
79552 ** The left most table is the first entry in Select.pSrc. The right-most
79560 static int sqliteProcessJoin(Parse *pParse, Select *p){
79655 Select *pSelect, /* The whole SELECT statement */
79694 Select *p, /* The SELECT statement being coded */
79735 ** Generate an error message when a SELECT is used within a subexpression
79736 ** (example: "a IN (SELECT * FROM table)") but it has more than 1 result
79742 SelectDest *pDest, /* Destination of SELECT results */
79743 int nExpr /* Number of result columns returned by SELECT */
79748 "a SELECT that is part of an expression");
79757 ** of a SELECT.
79766 Select *p, /* The complete select statement being coded */
79813 ** values returned by the SELECT are not required.
79820 /* If the DISTINCT keyword was present on the SELECT statement
79883 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
79914 /* If this is a scalar select that is part of an expression, then
79953 /* Discard the results. This is used for SELECT statements inside
79956 ** about the actual results of the select.
79980 ** implement that clause. If the ExprList is the result set of a SELECT
80025 Select *p, /* The SELECT statement */
80126 ** result-set expression in all of the following SELECT statements is
80129 ** SELECT col FROM tbl;
80130 ** SELECT (SELECT col FROM tbl;
80131 ** SELECT (SELECT col FROM tbl);
80132 ** SELECT abc FROM (SELECT col AS abc FROM tbl);
80158 Select *pS = 0; /* Select the column is extracted from */
80174 /* At one time, code such as "SELECT new.x" within a trigger would
80181 ** SELECT (SELECT t1.col) FROM FROM t1;
80184 ** sub-select. In this case, set the column type to NULL, even
80189 ** "(SELECT t1.col)", the correct type is returned (see the TK_SELECT
80196 /* The "table" is actually a sub-select or a view in the FROM clause
80197 ** of the SELECT statement. Return the declaration type and origin
80198 ** data for the result-set column of the sub-select.
80202 ** rowid of the sub-select or view. This expression is legal (see
80234 /* The expression is a sub-select. Return the declaration type and
80235 ** origin info for the single column in the result set of the SELECT
80239 Select *pS = pExpr->x.pSelect;
80385 ** that form the result set of a SELECT statement) compute appropriate
80478 ** a SELECT statement.
80484 ** This routine requires that all identifiers in the SELECT
80491 Select *pSelect /* SELECT used to determine types and collations */
80521 ** Given a SELECT statement, generate a Table structure that describes
80522 ** the result set of that SELECT.
80524 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
80575 ** Compute the iLimit and iOffset fields of the SELECT based on the
80590 ** SELECT statements.
80592 static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
80644 ** the result set for the compound-select statement "p". Return NULL if
80647 ** The collating sequence for the compound select is taken from the
80648 ** left-most term of the select that has a collating sequence.
80650 static CollSeq *multiSelectCollSeq(Parse *pParse, Select *p, int iCol){
80668 Select *p, /* The right-most of SELECTs to be coded */
80688 ** SELECT a FROM t1 UNION SELECT b FROM t2 UNION SELECT c FROM t3
80692 ** SELECT c FROM t3
80694 ** `-----> SELECT b FROM t2
80696 ** `------> SELECT a FROM t1
80698 ** The arrows in the diagram above represent the Select.pPrior pointer.
80707 Select *p, /* The right-most of SELECTs to be coded */
80711 Select *pPrior; /* Another SELECT immediately to our left */
80714 Select *pDelete = 0; /* Chain of simple selects to delete */
80718 ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
80767 /* Generate code for the left and right SELECT statements.
80810 /* We can reuse a temporary table generated by a SELECT to our
80831 /* Code the SELECT statements to our left
80840 /* Code the current SELECT statement
80876 Select *pFirst = p;
80924 /* Code the current SELECT into temporary table "tab2"
80948 Select *pFirst = p;
80972 ** temporary tables needed to implement the compound select.
80975 ** This section is run by the right-most SELECT statement only.
80976 ** SELECT statements to the left always skip this part. The right-most
80977 ** SELECT might also skip this part if it has no ORDER BY clause and
80983 Select *pLoop; /* For looping through SELECT statements */
81033 ** SELECT statment.
81053 Select *p, /* The SELECT statement */
81106 /* If we are creating a set for an "expr IN (SELECT ...)" construct,
81133 /* If this is a scalar select that is part of an expression, then
81189 ** Alternative compound select code generator for cases when there
81239 ** following nextX causes a jump to the end of the select processing.
81276 Select *p, /* The right-most of SELECTs to be coded */
81280 Select *pPrior; /* Another SELECT immediately to our left */
81284 int regAddrA; /* Address register for select-A coroutine */
81285 int regEofA; /* Flag to indicate when select-A is complete */
81286 int regAddrB; /* Address register for select-B coroutine */
81287 int regEofB; /* Flag to indicate when select-B is complete */
81288 int addrSelectA; /* Address of the select-A coroutine */
81289 int addrSelectB; /* Address of the select-B coroutine */
81294 int addrEofA; /* Address of the select-A-exhausted subroutine */
81295 int addrEofB; /* Address of the select-B-exhausted subroutine */
81299 int regLimitA; /* Limit register for select-A */
81300 int regLimitB; /* Limit register for select-A */
81305 int labelEnd; /* Label for the end of the overall SELECT stmt */
81463 /* Generate a coroutine to evaluate the SELECT statement to the
81464 ** left of the compound operator - the "A" select.
81466 VdbeNoopComment((v, "Begin coroutine for left SELECT"));
81471 VdbeNoopComment((v, "End coroutine for left SELECT"));
81473 /* Generate a coroutine to evaluate the SELECT statement on
81474 ** the right - the "B" select
81477 VdbeNoopComment((v, "Begin coroutine for right SELECT"));
81487 VdbeNoopComment((v, "End coroutine for right SELECT"));
81490 ** select as the next output row of the compound select.
81498 ** select as the next output row of the compound select.
81507 /* Generate a subroutine to run when the results from select A
81508 ** are exhausted and only data in select B remains.
81520 /* Generate a subroutine to run when the results from select B
81521 ** are exhausted and only data in select A remains.
81598 Select *pFirst = pPrior;
81619 static void substSelect(sqlite3*, Select *, int, ExprList *);
81629 ** FROM clause of a SELECT such that the VDBE cursor assigned to that
81680 Select *p, /* SELECT statement in which to make substitutions */
81695 assert( pSrc ); /* Even for (SELECT 1) we have: pSrc!=0 but pSrc->nSrc==0 */
81713 ** SELECT a FROM (SELECT x+y AS a FROM t1 WHERE z<100) WHERE a>5
81723 ** a single flat select, like this:
81725 ** SELECT x+y AS a FROM t1 WHERE z<100 AND a>5
81768 ** (15) The outer query is not part of a compound select or the
81776 ** (17) The sub-query is not a compound select, or it is a UNION ALL
81780 ** * is not itself part of a compound select,
81788 ** (18) If the sub-query is a compound select, then all terms of the
81795 ** (20) If the sub-query is a compound select, then it must not use
81813 Select *p, /* The parent or outer SELECT statement */
81815 int isAgg, /* True if outer SELECT uses aggregate functions */
81819 Select *pParent;
81820 Select *pSub; /* The inner query or "subquery" */
81821 Select *pSub1; /* Pointer to the rightmost select in sub-query */
81888 ** t1 LEFT OUTER JOIN (SELECT * FROM t2 WHERE t2.x>0)
81906 /* Restriction 17: If the sub-query is a compound SELECT, then it must
81907 ** use only the UNION ALL operator. And none of the simple select queries
81908 ** that make up the compound SELECT are allowed to be aggregate or distinct
81945 /* If the sub-query is a compound SELECT statement, then (by restrictions
81949 ** SELECT <expr-list> FROM (<sub-query>) <where-clause>
81955 ** select statements in the compound sub-query.
81959 ** SELECT a+1 FROM (
81960 ** SELECT x FROM tab
81962 ** SELECT y FROM tab
81964 ** SELECT abs(z*2) FROM tab2
81969 ** SELECT x+1 FROM tab WHERE x+1!=5
81971 ** SELECT y+1 FROM tab WHERE y+1!=5
81973 ** SELECT abs(z*2)+1 FROM tab2 WHERE abs(z*2)+1!=5
81979 Select *pNew;
81982 Select *pPrior = p->pPrior;
82077 ** SELECT * FROM tabA, (SELECT * FROM sub1, sub2), tabB;
82107 ** SELECT a+5, b*10 FROM (SELECT x*3 AS a, y+10 AS b FROM t1) WHERE a>b;
82160 ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;
82181 ** Analyze the SELECT statement passed as an argument to see if it
82191 static u8 minMaxQuery(Select *p){
82212 ** The select statement passed as the first argument is an aggregate query.
82214 ** function tests if the SELECT is of the form:
82216 ** SELECT count(*) FROM <tbl>
82218 ** where table is a database table, not a sub-select or view. If the query
82222 static Table *isSimpleCount(Select *p, AggInfo *pAggInfo){
82271 ** This routine is a Walker callback for "expanding" a SELECT statement.
82279 ** fill pTabList->a[].pSelect with a copy of the SELECT statement
82280 ** that implements the view. A copy is made of the view's SELECT
82294 static int selectExpander(Walker *pWalker, Select *p){
82313 ** the FROM clause of the SELECT statement.
82317 /* Look up every table named in the FROM clause of the select. If
82331 Select *pSel = pFrom->pSelect;
82332 /* A sub-query in the FROM clause of a SELECT */
82528 ** This routine "expands" a SELECT statement and all of its subqueries.
82529 ** For additional information on what it means to "expand" a SELECT
82532 ** Expanding a SELECT statement is the first step in processing a
82533 ** SELECT statement. The SELECT statement must be expanded before
82540 static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
82563 static int selectAddSubqueryTypeInfo(Walker *pWalker, Select *p){
82577 /* A sub-query in the FROM clause of a SELECT */
82578 Select *pSel = pFrom->pSelect;
82592 ** SELECT statement.
82596 static void sqlite3SelectAddTypeInfo(Parse *pParse, Select *pSelect){
82608 ** This routine sets of a SELECT statement for processing. The
82617 ** This routine acts recursively on all subqueries within the SELECT.
82621 Select *p, /* The SELECT statement being coded. */
82748 ** Generate code for the SELECT statement given in the p argument.
82767 ** results. Used to implement "IN (SELECT ...)".
82790 ** SRT_Discard Throw the results away. This is used by SELECT
82798 ** This routine does NOT free the Select structure passed in. The
82803 Select *p, /* The SELECT statement being coded. */
82809 int isAgg; /* True for select lists like "count(*)" */
82811 SrcList *pTabList; /* List of tables to select from */
82861 Select *pSub = pItem->pSelect;
82867 ** tree refered to by this, the parent select. The child select
82910 Select *pLoop, *pRight = 0;
82920 sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
83027 int addrEnd; /* End of processing for this SELECT */
83050 ** SELECT statement.
83281 ** SELECT count(*) FROM <tbl>
83334 ** SELECT min(x) FROM ...
83335 ** SELECT max(x) FROM ...
83348 ** + If the query is a "SELECT min(x)", then the loop coded by
83410 /* The SELECT was successfully coded. Set the return code to 0
83416 ** successful coding of the SELECT.
83420 /* Identify column names if results of the SELECT are to be output.
83438 ** parse structures such as Select or Expr. Such printouts are useful
83440 ** during the execution of complex SELECT statements.
83471 SQLITE_PRIVATE void sqlite3PrintSelect(Select *p, int indent){
83527 /************** End of select.c **********************************************/
84051 ** Turn a SELECT statement (that the pSelect parameter points to) into
84054 ** The parser calls this routine when it finds a SELECT statement in
84057 SQLITE_PRIVATE TriggerStep *sqlite3TriggerSelectStep(sqlite3 *db, Select *pSelect){
84105 Select *pSelect, /* A SELECT statement that supplies values */
84455 Select *pSelect = sqlite3SelectDup(db, pStep->pSelect, 0);
85421 ExprList *pEList = 0; /* The result set of the SELECT statement */
85422 Select *pSelect = 0; /* The SELECT statement */
85424 int ephemTab; /* Table holding the result of the SELECT */
85432 /* Construct the SELECT statement that will find the new values for
85679 "SELECT 'CREATE TABLE vacuum_db.' || substr(sql,14) "
85685 "SELECT 'CREATE INDEX vacuum_db.' || substr(sql,14)"
85689 "SELECT 'CREATE UNIQUE INDEX vacuum_db.' || substr(sql,21) "
85694 ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
85698 "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
85699 "|| ' SELECT * FROM main.' || quote(name) || ';'"
85709 "SELECT 'DELETE FROM vacuum_db.' || quote(name) || ';' "
85714 "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
85715 "|| ' SELECT * FROM main.' || quote(name) || ';' "
85728 " SELECT type, name, tbl_name, rootpage, sql"
87183 static Bitmask exprSelectTableUsage(WhereMaskSet*, Select*);
87210 static Bitmask exprSelectTableUsage(WhereMaskSet *pMaskSet, Select *pS){
88105 ** pOrderBy is an ORDER BY clause from a SELECT statement. pTab is the
88106 ** left-most table in the FROM clause of that same SELECT statement and
88956 ** in the SELECT statement, then no indexes are considered. However, the
89064 ** If there exists a WHERE term of the form "x IN (SELECT ...)", then
89065 ** the sub-select is assumed to return 25 rows for the purposes of
89069 ** Set to true if there was at least one "x IN (SELECT ...)" term used
89090 ** columns of the table used by the SELECT statement are present in
89095 ** SELECT a, b FROM tbl WHERE a = 1;
89096 ** SELECT a, b, c FROM tbl WHERE a = 1;
89314 ** (1) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x WHERE t2.z='ok'
89315 ** (2) SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.x AND t2.z='ok'
89316 ** (3) SELECT * FROM t1, t2 WHERE t1.a=t2.x AND t2.z='ok'
89481 ** SELECT ... FROM t1 AS t2, t1 WHERE t1.a = t2.b;
89800 int isMinQuery = 0; /* If this is an optimized SELECT min(x).. */
89820 ** was passed to this function to implement a "SELECT min(x) ..."
89988 ** SELECT * FROM t1 WHERE a=5 OR b=7 OR (c=11 AND d=13)
90230 ** the FROM clause of a select. (INSERT and UPDATE statements are the
90231 ** same as a SELECT with only a single table in the FROM clause.) For
90234 ** SELECT * FROM t1, t2, t3 WHERE ...;
90295 ** *ppOrderBy is a pointer to the ORDER BY clause of a SELECT statement,
90485 ** cost. However, this meant that SQLite could select the wrong plan
90490 ** SELECT * FROM t2, t1 WHERE t2.rowid = t1.a;
90894 ** LIMIT clause of a SELECT statement.
91056 Select* yy3;
91801 "SELECT", "DISTINCT", "DOT", "FROM",
91812 "select", "column", "columnid", "type",
91876 /* 33 */ "create_table_args ::= AS select",
91953 /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
91955 /* 112 */ "cmd ::= select",
91956 /* 113 */ "select ::= oneselect",
91957 /* 114 */ "select ::= select multiselect_op oneselect",
91961 /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
91978 /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
92017 /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
92072 /* 229 */ "expr ::= LP select RP",
92073 /* 230 */ "expr ::= expr in_op LP select RP",
92075 /* 232 */ "expr ::= EXISTS LP select RP",
92136 /* 293 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
92138 /* 295 */ "trigger_cmd ::= select",
92251 case 160: /* select */
93032 case 33: /* create_table_args ::= AS select */
93214 case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
93224 case 112: /* cmd ::= select */
93231 case 113: /* select ::= oneselect */
93234 case 114: /* select ::= select multiselect_op oneselect */
93248 case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
93312 case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
93322 Select *pSubquery;
93438 case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
93655 case 229: /* expr ::= LP select RP */
93669 case 230: /* expr ::= expr in_op LP select RP */
93700 case 232: /* expr ::= EXISTS LP select RP */
93886 case 293: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
93892 case 295: /* trigger_cmd ::= select */
94503 testcase( i==18 ); /* SELECT */
98823 ** "SELECT block FROM %_segments WHERE blockid BETWEEN ? AND ?
98874 ** SELECT docid FROM ex1 WHERE b MATCH 'one two three';
99606 const char *zTerm, /* Term to select leaves for */
100583 "SELECT * FROM %Q.'%q_content' WHERE docid = ?", /* non-full-table-scan */
100584 "SELECT * FROM %Q.'%q_content'", /* full-table-scan */
100604 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
100946 ** SELECT optimize(t) FROM t LIMIT 1;
101964 const char zSql[] = "SELECT fts3_tokenizer(?)";
102038 ** SELECT fts3_exprtest('simple', 'Bill col2:Bloggs', 'col1', 'col2');
103188 ** SELECT <function-name>(<key-name>);
103189 ** SELECT <function-name>(<key-name>, <pointer>);
103376 ** SELECT <function-name>(<key-name>, <input-string>);
103377 ** SELECT <function-name>(<key-name>, <pointer>);
103390 ** SELECT fts_tokenizer_test('simple', 'I don't see how');
103493 const char zSql[] = "SELECT fts3_tokenizer(?, ?)";
103515 const char zSql[] = "SELECT fts3_tokenizer(?)";
103550 ** SELECT fts3_tokenizer_internal_test();
104043 /* 1 */ "SELECT NOT EXISTS(SELECT docid FROM %Q.'%q_content' WHERE rowid!=?)",
104047 /* 5 */ "SELECT * FROM %Q.'%q_content' WHERE rowid=?",
104048 /* 6 */ "SELECT coalesce(max(idx)+1, 0) FROM %Q.'%q_segdir' WHERE level=?",
104050 /* 8 */ "SELECT coalesce(max(blockid)+1, 1) FROM %Q.'%q_segments'",
104054 /* 10 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
104056 /* 11 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
104059 /* 12 */ "SELECT count(*) FROM %Q.'%q_segdir' WHERE level = ?",
104060 /* 13 */ "SELECT count(*), max(level) FROM %Q.'%q_segdir'",
104065 /* 17 */ "SELECT block FROM %Q.'%q_segments' WHERE blockid = ?",
104549 ** SELECT max(idx) FROM %_segdir WHERE level = :iLevel
104725 /* Move the leaf-range SELECT statement to the aLeavesStmt[] array,
104781 "SELECT block FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ? "
104933 ** SELECT
108901 /* Select the child node which will be enlarged the least if pCell
109862 ** Select a currently unused rowid for a new r-tree record.
110102 "SELECT data FROM '%q'.'%q_node' WHERE nodeno = :1",
110107 "SELECT nodeno FROM '%q'.'%q_rowid' WHERE rowid = :1",
110112 "SELECT parentnode FROM '%q'.'%q_parent' WHERE nodeno = :1",
110308 ** SELECT rtreenode(2, data) FROM rt_node;
110807 ** SELECT icu_load_collation(<locale>, <collation-name>);