Lines Matching refs:p
83 Token *p; in sqliteJoinType() local
102 p = apAll[i]; in sqliteJoinType()
104 if( p->n==keywords[j].nChar in sqliteJoinType()
105 && sqliteStrNICmp(p->z, keywords[j].zKeyword, p->n)==0 ){ in sqliteJoinType()
194 static void setJoinExpr(Expr *p){ in setJoinExpr() argument
195 while( p ){ in setJoinExpr()
196 ExprSetProperty(p, EP_FromJoin); in setJoinExpr()
197 setJoinExpr(p->pLeft); in setJoinExpr()
198 p = p->pRight; in setJoinExpr()
209 static int sqliteProcessJoin(Parse *pParse, Select *p){ in sqliteProcessJoin() argument
212 pSrc = p->pSrc; in sqliteProcessJoin()
232 addWhereTerm(pTab->aCol[j].zName, pTab, pOther->pTab, &p->pWhere); in sqliteProcessJoin()
250 if( p->pWhere==0 ){ in sqliteProcessJoin()
251 p->pWhere = pTerm->pOn; in sqliteProcessJoin()
253 p->pWhere = sqliteExpr(TK_AND, p->pWhere, pTerm->pOn, 0); in sqliteProcessJoin()
277 addWhereTerm(pList->a[j].zName, pTerm->pTab, pOther->pTab, &p->pWhere); in sqliteProcessJoin()
287 void sqliteSelectDelete(Select *p){ in sqliteSelectDelete() argument
288 if( p==0 ) return; in sqliteSelectDelete()
289 sqliteExprListDelete(p->pEList); in sqliteSelectDelete()
290 sqliteSrcListDelete(p->pSrc); in sqliteSelectDelete()
291 sqliteExprDelete(p->pWhere); in sqliteSelectDelete()
292 sqliteExprListDelete(p->pGroupBy); in sqliteSelectDelete()
293 sqliteExprDelete(p->pHaving); in sqliteSelectDelete()
294 sqliteExprListDelete(p->pOrderBy); in sqliteSelectDelete()
295 sqliteSelectDelete(p->pPrior); in sqliteSelectDelete()
296 sqliteFree(p->zSelect); in sqliteSelectDelete()
297 sqliteFree(p); in sqliteSelectDelete()
372 Select *p, /* The SELECT statement being coded */ in codeLimiter() argument
377 if( p->iOffset>=0 ){ in codeLimiter()
380 sqliteVdbeAddOp(v, OP_MemIncr, p->iOffset, addr); in codeLimiter()
386 if( p->iLimit>=0 ){ in codeLimiter()
387 sqliteVdbeAddOp(v, OP_MemIncr, p->iLimit, iBreak); in codeLimiter()
402 Select *p, /* The complete select statement being coded */ in selectInnerLoop() argument
425 codeLimiter(v, p, iContinue, iBreak, 0); in selectInnerLoop()
457 codeLimiter(v, p, iContinue, iBreak, nColumn); in selectInnerLoop()
583 Select *p, /* The SELECT statement */ in generateSortTail() argument
595 codeLimiter(v, p, addr, end2, 1); in generateSortTail()
667 Expr *p = pEList->a[i].pExpr; in generateColumnTypes() local
669 if( p==0 ) continue; in generateColumnTypes()
670 if( p->op==TK_COLUMN && pTabList ){ in generateColumnTypes()
672 int iCol = p->iColumn; in generateColumnTypes()
673 for(j=0; j<pTabList->nSrc && pTabList->a[j].iCursor!=p->iTable; j++){} in generateColumnTypes()
684 if( sqliteExprType(p)==SQLITE_SO_TEXT ){ in generateColumnTypes()
715 Expr *p; in generateColumnNames() local
717 p = pEList->a[i].pExpr; in generateColumnNames()
718 if( p==0 ) continue; in generateColumnNames()
724 if( p->op==TK_COLUMN && pTabList ){ in generateColumnNames()
727 int iCol = p->iColumn; in generateColumnNames()
728 for(j=0; j<pTabList->nSrc && pTabList->a[j].iCursor!=p->iTable; j++){} in generateColumnNames()
738 if( !shortNames && !fullNames && p->span.z && p->span.z[0] ){ in generateColumnNames()
739 int addr = sqliteVdbeOp3(v,OP_ColumnName, i, p2, p->span.z, p->span.n); in generateColumnNames()
752 }else if( p->span.z && p->span.z[0] ){ in generateColumnNames()
753 int addr = sqliteVdbeOp3(v,OP_ColumnName, i, p2, p->span.z, p->span.n); in generateColumnNames()
757 assert( p->op!=TK_COLUMN || pTabList==0 ); in generateColumnNames()
806 Expr *p, *pR; in sqliteResultSetOfSelect() local
809 }else if( (p=pEList->a[i].pExpr)->op==TK_DOT in sqliteResultSetOfSelect()
810 && (pR=p->pRight)!=0 && pR->token.z && pR->token.z[0] ){ in sqliteResultSetOfSelect()
823 }else if( p->span.z && p->span.z[0] ){ in sqliteResultSetOfSelect()
824 sqliteSetNString(&pTab->aCol[i].zName, p->span.z, p->span.n, 0); in sqliteResultSetOfSelect()
858 static int fillInColumnList(Parse *pParse, Select *p){ in fillInColumnList() argument
864 if( p==0 || p->pSrc==0 ) return 1; in fillInColumnList()
865 pTabList = p->pSrc; in fillInColumnList()
866 pEList = p->pEList; in fillInColumnList()
921 if( sqliteProcessJoin(pParse, p) ) return 1; in fillInColumnList()
1031 p->pEList = pNew; in fillInColumnList()
1049 void sqliteSelectUnbind(Select *p){ in sqliteSelectUnbind() argument
1051 SrcList *pSrc = p->pSrc; in sqliteSelectUnbind()
1053 if( p==0 ) return; in sqliteSelectUnbind()
1197 static void multiSelectSortOrder(Select *p, ExprList *pOrderBy){ in multiSelectSortOrder() argument
1201 if( p==0 ){ in multiSelectSortOrder()
1207 multiSelectSortOrder(p->pPrior, pOrderBy); in multiSelectSortOrder()
1208 pEList = p->pEList; in multiSelectSortOrder()
1237 static void computeLimitRegisters(Parse *pParse, Select *p){ in computeLimitRegisters() argument
1247 if( p->nLimit>=0 ){ in computeLimitRegisters()
1251 sqliteVdbeAddOp(v, OP_Integer, -p->nLimit, 0); in computeLimitRegisters()
1253 p->iLimit = iMem; in computeLimitRegisters()
1255 if( p->nOffset>0 ){ in computeLimitRegisters()
1259 sqliteVdbeAddOp(v, OP_Integer, -p->nOffset, 0); in computeLimitRegisters()
1261 p->iOffset = iMem; in computeLimitRegisters()
1295 static int multiSelect(Parse *pParse, Select *p, int eDest, int iParm){ in multiSelect() argument
1303 if( p==0 || p->pPrior==0 ) return 1; in multiSelect()
1304 pPrior = p->pPrior; in multiSelect()
1307 selectOpName(p->op)); in multiSelect()
1312 selectOpName(p->op)); in multiSelect()
1330 switch( p->op ){ in multiSelect()
1332 if( p->pOrderBy==0 ){ in multiSelect()
1333 pPrior->nLimit = p->nLimit; in multiSelect()
1334 pPrior->nOffset = p->nOffset; in multiSelect()
1337 p->pPrior = 0; in multiSelect()
1338 p->iLimit = pPrior->iLimit; in multiSelect()
1339 p->iOffset = pPrior->iOffset; in multiSelect()
1340 p->nLimit = -1; in multiSelect()
1341 p->nOffset = 0; in multiSelect()
1342 rc = sqliteSelect(pParse, p, eDest, iParm, 0, 0, 0); in multiSelect()
1343 p->pPrior = pPrior; in multiSelect()
1357 priorOp = p->op==TK_ALL ? SRT_Table : SRT_Union; in multiSelect()
1358 if( eDest==priorOp && p->pOrderBy==0 && p->nLimit<0 && p->nOffset==0 ){ in multiSelect()
1368 if( p->pOrderBy in multiSelect()
1369 && matchOrderbyToColumn(pParse, p, p->pOrderBy, unionTab, 1) ){ in multiSelect()
1372 if( p->op!=TK_ALL ){ in multiSelect()
1387 switch( p->op ){ in multiSelect()
1392 p->pPrior = 0; in multiSelect()
1393 pOrderBy = p->pOrderBy; in multiSelect()
1394 p->pOrderBy = 0; in multiSelect()
1395 nLimit = p->nLimit; in multiSelect()
1396 p->nLimit = -1; in multiSelect()
1397 nOffset = p->nOffset; in multiSelect()
1398 p->nOffset = 0; in multiSelect()
1399 rc = sqliteSelect(pParse, p, op, unionTab, 0, 0, 0); in multiSelect()
1400 p->pPrior = pPrior; in multiSelect()
1401 p->pOrderBy = pOrderBy; in multiSelect()
1402 p->nLimit = nLimit; in multiSelect()
1403 p->nOffset = nOffset; in multiSelect()
1411 assert( p->pEList ); in multiSelect()
1413 generateColumnNames(pParse, 0, p->pEList); in multiSelect()
1414 generateColumnTypes(pParse, p->pSrc, p->pEList); in multiSelect()
1419 computeLimitRegisters(pParse, p); in multiSelect()
1421 multiSelectSortOrder(p, p->pOrderBy); in multiSelect()
1422 rc = selectInnerLoop(pParse, p, p->pEList, unionTab, p->pEList->nExpr, in multiSelect()
1423 p->pOrderBy, -1, eDest, iParm, in multiSelect()
1430 if( p->pOrderBy ){ in multiSelect()
1431 generateSortTail(p, v, p->pEList->nExpr, eDest, iParm); in multiSelect()
1447 if( p->pOrderBy && matchOrderbyToColumn(pParse,p,p->pOrderBy,tab1,1) ){ in multiSelect()
1462 p->pPrior = 0; in multiSelect()
1463 nLimit = p->nLimit; in multiSelect()
1464 p->nLimit = -1; in multiSelect()
1465 nOffset = p->nOffset; in multiSelect()
1466 p->nOffset = 0; in multiSelect()
1467 rc = sqliteSelect(pParse, p, SRT_Union, tab2, 0, 0, 0); in multiSelect()
1468 p->pPrior = pPrior; in multiSelect()
1469 p->nLimit = nLimit; in multiSelect()
1470 p->nOffset = nOffset; in multiSelect()
1476 assert( p->pEList ); in multiSelect()
1478 generateColumnNames(pParse, 0, p->pEList); in multiSelect()
1479 generateColumnTypes(pParse, p->pSrc, p->pEList); in multiSelect()
1484 computeLimitRegisters(pParse, p); in multiSelect()
1487 multiSelectSortOrder(p, p->pOrderBy); in multiSelect()
1488 rc = selectInnerLoop(pParse, p, p->pEList, tab1, p->pEList->nExpr, in multiSelect()
1489 p->pOrderBy, -1, eDest, iParm, in multiSelect()
1497 if( p->pOrderBy ){ in multiSelect()
1498 generateSortTail(p, v, p->pEList->nExpr, eDest, iParm); in multiSelect()
1503 assert( p->pEList && pPrior->pEList ); in multiSelect()
1504 if( p->pEList->nExpr!=pPrior->pEList->nExpr ){ in multiSelect()
1506 " do not have the same number of result columns", selectOpName(p->op)); in multiSelect()
1637 Select *p, /* The parent or outer SELECT statement */ in flattenSubquery() argument
1652 if( p==0 ) return 0; in flattenSubquery()
1653 pSrc = p->pSrc; in flattenSubquery()
1665 if( (p->isDistinct || p->nLimit>=0) && subqueryIsAgg ) return 0; in flattenSubquery()
1666 if( p->pOrderBy && pSub->pOrderBy ) return 0; in flattenSubquery()
1730 p->pSrc = pSrc; in flattenSubquery()
1754 substExprList(p->pEList, iParent, pSub->pEList); in flattenSubquery()
1755 pList = p->pEList; in flattenSubquery()
1763 substExprList(p->pGroupBy, iParent, pSub->pEList); in flattenSubquery()
1764 substExpr(p->pHaving, iParent, pSub->pEList); in flattenSubquery()
1767 assert( p->pOrderBy==0 ); in flattenSubquery()
1768 p->pOrderBy = pSub->pOrderBy; in flattenSubquery()
1770 }else if( p->pOrderBy ){ in flattenSubquery()
1771 substExprList(p->pOrderBy, iParent, pSub->pEList); in flattenSubquery()
1779 assert( p->pHaving==0 ); in flattenSubquery()
1780 p->pHaving = p->pWhere; in flattenSubquery()
1781 p->pWhere = pWhere; in flattenSubquery()
1782 substExpr(p->pHaving, iParent, pSub->pEList); in flattenSubquery()
1785 if( p->pHaving ){ in flattenSubquery()
1786 p->pHaving = sqliteExpr(TK_AND, p->pHaving, pHaving, 0); in flattenSubquery()
1788 p->pHaving = pHaving; in flattenSubquery()
1791 assert( p->pGroupBy==0 ); in flattenSubquery()
1792 p->pGroupBy = sqliteExprListDup(pSub->pGroupBy); in flattenSubquery()
1793 }else if( p->pWhere==0 ){ in flattenSubquery()
1794 p->pWhere = pWhere; in flattenSubquery()
1796 substExpr(p->pWhere, iParent, pSub->pEList); in flattenSubquery()
1798 p->pWhere = sqliteExpr(TK_AND, p->pWhere, pWhere, 0); in flattenSubquery()
1805 p->isDistinct = p->isDistinct || pSub->isDistinct; in flattenSubquery()
1811 if( p->nLimit<0 ){ in flattenSubquery()
1812 p->nLimit = pSub->nLimit; in flattenSubquery()
1813 }else if( p->nLimit+p->nOffset > pSub->nLimit+pSub->nOffset ){ in flattenSubquery()
1814 p->nLimit = pSub->nLimit + pSub->nOffset - p->nOffset; in flattenSubquery()
1817 p->nOffset += pSub->nOffset; in flattenSubquery()
1846 static int simpleMinMaxQuery(Parse *pParse, Select *p, int eDest, int iParm){ in simpleMinMaxQuery() argument
1863 if( p->pGroupBy || p->pHaving || p->pWhere ) return 0; in simpleMinMaxQuery()
1864 pSrc = p->pSrc; in simpleMinMaxQuery()
1866 pEList = p->pEList; in simpleMinMaxQuery()
1908 generateColumnTypes(pParse, p->pSrc, p->pEList); in simpleMinMaxQuery()
1924 computeLimitRegisters(pParse, p); in simpleMinMaxQuery()
1950 selectInnerLoop(pParse, p, &eList, 0, 0, 0, -1, eDest, iParm, cont, cont); in simpleMinMaxQuery()
2011 Select *p, /* The SELECT statement being coded. */ in sqliteSelect() argument
2032 if( sqlite_malloc_failed || pParse->nErr || p==0 ) return 1; in sqliteSelect()
2037 if( p->pPrior ){ in sqliteSelect()
2038 return multiSelect(pParse, p, eDest, iParm); in sqliteSelect()
2043 pTabList = p->pSrc; in sqliteSelect()
2044 pWhere = p->pWhere; in sqliteSelect()
2045 pOrderBy = p->pOrderBy; in sqliteSelect()
2046 pGroupBy = p->pGroupBy; in sqliteSelect()
2047 pHaving = p->pHaving; in sqliteSelect()
2048 isDistinct = p->isDistinct; in sqliteSelect()
2064 if( fillInColumnList(pParse, p) ){ in sqliteSelect()
2067 pWhere = p->pWhere; in sqliteSelect()
2068 pEList = p->pEList; in sqliteSelect()
2209 pTabList->a[i].iCursor, p, i, &isAgg); in sqliteSelect()
2213 pTabList = p->pSrc; in sqliteSelect()
2214 pWhere = p->pWhere; in sqliteSelect()
2216 pOrderBy = p->pOrderBy; in sqliteSelect()
2218 pGroupBy = p->pGroupBy; in sqliteSelect()
2219 pHaving = p->pHaving; in sqliteSelect()
2220 isDistinct = p->isDistinct; in sqliteSelect()
2226 if( simpleMinMaxQuery(pParse, p, eDest, iParm) ){ in sqliteSelect()
2242 computeLimitRegisters(pParse, p); in sqliteSelect()
2335 if( selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, distinct, eDest, in sqliteSelect()
2394 if( selectInnerLoop(pParse, p, pEList, 0, 0, pOrderBy, distinct, eDest, in sqliteSelect()
2408 generateSortTail(p, v, pEList->nExpr, eDest, iParm); in sqliteSelect()
2418 assert( pParent->pSrc->a[parentTab].pSelect==p ); in sqliteSelect()
2419 sqliteSelectDelete(p); in sqliteSelect()