| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2008 August 18 | 2 ** 2008 August 18 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** | 12 ** |
| 13 ** This file contains routines used for walking the parser tree and | 13 ** This file contains routines used for walking the parser tree and |
| 14 ** resolve all identifiers by associating them with a particular | 14 ** resolve all identifiers by associating them with a particular |
| 15 ** table and column. | 15 ** table and column. |
| 16 */ | 16 */ |
| 17 #include "sqliteInt.h" | 17 #include "sqliteInt.h" |
| 18 #include <stdlib.h> | |
| 19 #include <string.h> | |
| 20 | 18 |
| 21 /* | 19 /* |
| 22 ** Walk the expression tree pExpr and increase the aggregate function | 20 ** Walk the expression tree pExpr and increase the aggregate function |
| 23 ** depth (the Expr.op2 field) by N on every TK_AGG_FUNCTION node. | 21 ** depth (the Expr.op2 field) by N on every TK_AGG_FUNCTION node. |
| 24 ** This needs to occur when copying a TK_AGG_FUNCTION node from an | 22 ** This needs to occur when copying a TK_AGG_FUNCTION node from an |
| 25 ** outer query into an inner subquery. | 23 ** outer query into an inner subquery. |
| 26 ** | 24 ** |
| 27 ** incrAggFunctionDepth(pExpr,n) is the main routine. incrAggDepth(..) | 25 ** incrAggFunctionDepth(pExpr,n) is the main routine. incrAggDepth(..) |
| 28 ** is a helper function - a callback for the tree walker. | 26 ** is a helper function - a callback for the tree walker. |
| 29 */ | 27 */ |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 testcase( pNC->ncFlags & NC_PartIdx ); | 212 testcase( pNC->ncFlags & NC_PartIdx ); |
| 215 testcase( pNC->ncFlags & NC_IsCheck ); | 213 testcase( pNC->ncFlags & NC_IsCheck ); |
| 216 if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){ | 214 if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){ |
| 217 /* Silently ignore database qualifiers inside CHECK constraints and | 215 /* Silently ignore database qualifiers inside CHECK constraints and |
| 218 ** partial indices. Do not raise errors because that might break | 216 ** partial indices. Do not raise errors because that might break |
| 219 ** legacy and because it does not hurt anything to just ignore the | 217 ** legacy and because it does not hurt anything to just ignore the |
| 220 ** database name. */ | 218 ** database name. */ |
| 221 zDb = 0; | 219 zDb = 0; |
| 222 }else{ | 220 }else{ |
| 223 for(i=0; i<db->nDb; i++){ | 221 for(i=0; i<db->nDb; i++){ |
| 224 assert( db->aDb[i].zName ); | 222 assert( db->aDb[i].zDbSName ); |
| 225 if( sqlite3StrICmp(db->aDb[i].zName,zDb)==0 ){ | 223 if( sqlite3StrICmp(db->aDb[i].zDbSName,zDb)==0 ){ |
| 226 pSchema = db->aDb[i].pSchema; | 224 pSchema = db->aDb[i].pSchema; |
| 227 break; | 225 break; |
| 228 } | 226 } |
| 229 } | 227 } |
| 230 } | 228 } |
| 231 } | 229 } |
| 232 | 230 |
| 233 /* Start at the inner-most context and move outward until a match is found */ | 231 /* Start at the inner-most context and move outward until a match is found */ |
| 234 while( pNC && cnt==0 ){ | 232 while( pNC && cnt==0 ){ |
| 235 ExprList *pEList; | 233 ExprList *pEList; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ | 391 if( zAs!=0 && sqlite3StrICmp(zAs, zCol)==0 ){ |
| 394 Expr *pOrig; | 392 Expr *pOrig; |
| 395 assert( pExpr->pLeft==0 && pExpr->pRight==0 ); | 393 assert( pExpr->pLeft==0 && pExpr->pRight==0 ); |
| 396 assert( pExpr->x.pList==0 ); | 394 assert( pExpr->x.pList==0 ); |
| 397 assert( pExpr->x.pSelect==0 ); | 395 assert( pExpr->x.pSelect==0 ); |
| 398 pOrig = pEList->a[j].pExpr; | 396 pOrig = pEList->a[j].pExpr; |
| 399 if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){ | 397 if( (pNC->ncFlags&NC_AllowAgg)==0 && ExprHasProperty(pOrig, EP_Agg) ){ |
| 400 sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); | 398 sqlite3ErrorMsg(pParse, "misuse of aliased aggregate %s", zAs); |
| 401 return WRC_Abort; | 399 return WRC_Abort; |
| 402 } | 400 } |
| 401 if( sqlite3ExprVectorSize(pOrig)!=1 ){ |
| 402 sqlite3ErrorMsg(pParse, "row value misused"); |
| 403 return WRC_Abort; |
| 404 } |
| 403 resolveAlias(pParse, pEList, j, pExpr, "", nSubquery); | 405 resolveAlias(pParse, pEList, j, pExpr, "", nSubquery); |
| 404 cnt = 1; | 406 cnt = 1; |
| 405 pMatch = 0; | 407 pMatch = 0; |
| 406 assert( zTab==0 && zDb==0 ); | 408 assert( zTab==0 && zDb==0 ); |
| 407 goto lookupname_end; | 409 goto lookupname_end; |
| 408 } | 410 } |
| 409 } | 411 } |
| 410 } | 412 } |
| 411 | 413 |
| 412 /* Advance to the next name context. The loop will exit when either | 414 /* Advance to the next name context. The loop will exit when either |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 ** Or a database, table and column: ID.ID.ID | 618 ** Or a database, table and column: ID.ID.ID |
| 617 */ | 619 */ |
| 618 case TK_DOT: { | 620 case TK_DOT: { |
| 619 const char *zColumn; | 621 const char *zColumn; |
| 620 const char *zTable; | 622 const char *zTable; |
| 621 const char *zDb; | 623 const char *zDb; |
| 622 Expr *pRight; | 624 Expr *pRight; |
| 623 | 625 |
| 624 /* if( pSrcList==0 ) break; */ | 626 /* if( pSrcList==0 ) break; */ |
| 625 notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr); | 627 notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr); |
| 626 /*notValid(pParse, pNC, "the \".\" operator", NC_PartIdx|NC_IsCheck, 1);*/ | |
| 627 pRight = pExpr->pRight; | 628 pRight = pExpr->pRight; |
| 628 if( pRight->op==TK_ID ){ | 629 if( pRight->op==TK_ID ){ |
| 629 zDb = 0; | 630 zDb = 0; |
| 630 zTable = pExpr->pLeft->u.zToken; | 631 zTable = pExpr->pLeft->u.zToken; |
| 631 zColumn = pRight->u.zToken; | 632 zColumn = pRight->u.zToken; |
| 632 }else{ | 633 }else{ |
| 633 assert( pRight->op==TK_DOT ); | 634 assert( pRight->op==TK_DOT ); |
| 634 zDb = pExpr->pLeft->u.zToken; | 635 zDb = pExpr->pLeft->u.zToken; |
| 635 zTable = pRight->pLeft->u.zToken; | 636 zTable = pRight->pLeft->u.zToken; |
| 636 zColumn = pRight->pRight->u.zToken; | 637 zColumn = pRight->pRight->u.zToken; |
| 637 } | 638 } |
| 638 return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr); | 639 return lookupName(pParse, zDb, zTable, zColumn, pNC, pExpr); |
| 639 } | 640 } |
| 640 | 641 |
| 641 /* Resolve function names | 642 /* Resolve function names |
| 642 */ | 643 */ |
| 643 case TK_FUNCTION: { | 644 case TK_FUNCTION: { |
| 644 ExprList *pList = pExpr->x.pList; /* The argument list */ | 645 ExprList *pList = pExpr->x.pList; /* The argument list */ |
| 645 int n = pList ? pList->nExpr : 0; /* Number of arguments */ | 646 int n = pList ? pList->nExpr : 0; /* Number of arguments */ |
| 646 int no_such_func = 0; /* True if no such function exists */ | 647 int no_such_func = 0; /* True if no such function exists */ |
| 647 int wrong_num_args = 0; /* True if wrong number of arguments */ | 648 int wrong_num_args = 0; /* True if wrong number of arguments */ |
| 648 int is_agg = 0; /* True if is an aggregate function */ | 649 int is_agg = 0; /* True if is an aggregate function */ |
| 649 int auth; /* Authorization to use the function */ | |
| 650 int nId; /* Number of characters in function name */ | 650 int nId; /* Number of characters in function name */ |
| 651 const char *zId; /* The function name. */ | 651 const char *zId; /* The function name. */ |
| 652 FuncDef *pDef; /* Information about the function */ | 652 FuncDef *pDef; /* Information about the function */ |
| 653 u8 enc = ENC(pParse->db); /* The database encoding */ | 653 u8 enc = ENC(pParse->db); /* The database encoding */ |
| 654 | 654 |
| 655 assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); | 655 assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); |
| 656 notValid(pParse, pNC, "functions", NC_PartIdx); | |
| 657 zId = pExpr->u.zToken; | 656 zId = pExpr->u.zToken; |
| 658 nId = sqlite3Strlen30(zId); | 657 nId = sqlite3Strlen30(zId); |
| 659 pDef = sqlite3FindFunction(pParse->db, zId, nId, n, enc, 0); | 658 pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0); |
| 660 if( pDef==0 ){ | 659 if( pDef==0 ){ |
| 661 pDef = sqlite3FindFunction(pParse->db, zId, nId, -2, enc, 0); | 660 pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0); |
| 662 if( pDef==0 ){ | 661 if( pDef==0 ){ |
| 663 no_such_func = 1; | 662 no_such_func = 1; |
| 664 }else{ | 663 }else{ |
| 665 wrong_num_args = 1; | 664 wrong_num_args = 1; |
| 666 } | 665 } |
| 667 }else{ | 666 }else{ |
| 668 is_agg = pDef->xFunc==0; | 667 is_agg = pDef->xFinalize!=0; |
| 669 if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){ | 668 if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){ |
| 670 ExprSetProperty(pExpr, EP_Unlikely|EP_Skip); | 669 ExprSetProperty(pExpr, EP_Unlikely|EP_Skip); |
| 671 if( n==2 ){ | 670 if( n==2 ){ |
| 672 pExpr->iTable = exprProbability(pList->a[1].pExpr); | 671 pExpr->iTable = exprProbability(pList->a[1].pExpr); |
| 673 if( pExpr->iTable<0 ){ | 672 if( pExpr->iTable<0 ){ |
| 674 sqlite3ErrorMsg(pParse, | 673 sqlite3ErrorMsg(pParse, |
| 675 "second argument to likelihood() must be a " | 674 "second argument to likelihood() must be a " |
| 676 "constant between 0.0 and 1.0"); | 675 "constant between 0.0 and 1.0"); |
| 677 pNC->nErr++; | 676 pNC->nErr++; |
| 678 } | 677 } |
| 679 }else{ | 678 }else{ |
| 680 /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is | 679 /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is |
| 681 ** equivalent to likelihood(X, 0.0625). | 680 ** equivalent to likelihood(X, 0.0625). |
| 682 ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is | 681 ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is |
| 683 ** short-hand for likelihood(X,0.0625). | 682 ** short-hand for likelihood(X,0.0625). |
| 684 ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand | 683 ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand |
| 685 ** for likelihood(X,0.9375). | 684 ** for likelihood(X,0.9375). |
| 686 ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent | 685 ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent |
| 687 ** to likelihood(X,0.9375). */ | 686 ** to likelihood(X,0.9375). */ |
| 688 /* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */ | 687 /* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */ |
| 689 pExpr->iTable = pDef->zName[0]=='u' ? 8388608 : 125829120; | 688 pExpr->iTable = pDef->zName[0]=='u' ? 8388608 : 125829120; |
| 690 } | 689 } |
| 691 } | 690 } |
| 692 #ifndef SQLITE_OMIT_AUTHORIZATION | 691 #ifndef SQLITE_OMIT_AUTHORIZATION |
| 693 auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0, pDef->zName, 0); | 692 { |
| 694 if( auth!=SQLITE_OK ){ | 693 int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0); |
| 695 if( auth==SQLITE_DENY ){ | 694 if( auth!=SQLITE_OK ){ |
| 696 sqlite3ErrorMsg(pParse, "not authorized to use function: %s", | 695 if( auth==SQLITE_DENY ){ |
| 697 pDef->zName); | 696 sqlite3ErrorMsg(pParse, "not authorized to use function: %s", |
| 698 pNC->nErr++; | 697 pDef->zName); |
| 698 pNC->nErr++; |
| 699 } |
| 700 pExpr->op = TK_NULL; |
| 701 return WRC_Prune; |
| 699 } | 702 } |
| 700 pExpr->op = TK_NULL; | |
| 701 return WRC_Prune; | |
| 702 } | 703 } |
| 703 #endif | 704 #endif |
| 704 if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){ | 705 if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){ |
| 705 /* For the purposes of the EP_ConstFunc flag, date and time | 706 /* For the purposes of the EP_ConstFunc flag, date and time |
| 706 ** functions and other functions that change slowly are considered | 707 ** functions and other functions that change slowly are considered |
| 707 ** constant because they are constant for the duration of one query */ | 708 ** constant because they are constant for the duration of one query */ |
| 708 ExprSetProperty(pExpr,EP_ConstFunc); | 709 ExprSetProperty(pExpr,EP_ConstFunc); |
| 709 } | 710 } |
| 710 if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ | 711 if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){ |
| 711 /* Date/time functions that use 'now', and other functions like | 712 /* Date/time functions that use 'now', and other functions like |
| 712 ** sqlite_version() that might change over time cannot be used | 713 ** sqlite_version() that might change over time cannot be used |
| 713 ** in an index. */ | 714 ** in an index. */ |
| 714 notValid(pParse, pNC, "non-deterministic functions", NC_IdxExpr); | 715 notValid(pParse, pNC, "non-deterministic functions", |
| 716 NC_IdxExpr|NC_PartIdx); |
| 715 } | 717 } |
| 716 } | 718 } |
| 717 if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){ | 719 if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){ |
| 718 sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId); | 720 sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId); |
| 719 pNC->nErr++; | 721 pNC->nErr++; |
| 720 is_agg = 0; | 722 is_agg = 0; |
| 721 }else if( no_such_func && pParse->db->init.busy==0 ){ | 723 }else if( no_such_func && pParse->db->init.busy==0 |
| 724 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION |
| 725 && pParse->explain==0 |
| 726 #endif |
| 727 ){ |
| 722 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); | 728 sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId); |
| 723 pNC->nErr++; | 729 pNC->nErr++; |
| 724 }else if( wrong_num_args ){ | 730 }else if( wrong_num_args ){ |
| 725 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()", | 731 sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()", |
| 726 nId, zId); | 732 nId, zId); |
| 727 pNC->nErr++; | 733 pNC->nErr++; |
| 728 } | 734 } |
| 729 if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg; | 735 if( is_agg ) pNC->ncFlags &= ~NC_AllowAgg; |
| 730 sqlite3WalkExprList(pWalker, pList); | 736 sqlite3WalkExprList(pWalker, pList); |
| 731 if( is_agg ){ | 737 if( is_agg ){ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 756 #endif | 762 #endif |
| 757 case TK_IN: { | 763 case TK_IN: { |
| 758 testcase( pExpr->op==TK_IN ); | 764 testcase( pExpr->op==TK_IN ); |
| 759 if( ExprHasProperty(pExpr, EP_xIsSelect) ){ | 765 if( ExprHasProperty(pExpr, EP_xIsSelect) ){ |
| 760 int nRef = pNC->nRef; | 766 int nRef = pNC->nRef; |
| 761 notValid(pParse, pNC, "subqueries", NC_IsCheck|NC_PartIdx|NC_IdxExpr); | 767 notValid(pParse, pNC, "subqueries", NC_IsCheck|NC_PartIdx|NC_IdxExpr); |
| 762 sqlite3WalkSelect(pWalker, pExpr->x.pSelect); | 768 sqlite3WalkSelect(pWalker, pExpr->x.pSelect); |
| 763 assert( pNC->nRef>=nRef ); | 769 assert( pNC->nRef>=nRef ); |
| 764 if( nRef!=pNC->nRef ){ | 770 if( nRef!=pNC->nRef ){ |
| 765 ExprSetProperty(pExpr, EP_VarSelect); | 771 ExprSetProperty(pExpr, EP_VarSelect); |
| 772 pNC->ncFlags |= NC_VarSelect; |
| 766 } | 773 } |
| 767 } | 774 } |
| 768 break; | 775 break; |
| 769 } | 776 } |
| 770 case TK_VARIABLE: { | 777 case TK_VARIABLE: { |
| 771 notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr); | 778 notValid(pParse, pNC, "parameters", NC_IsCheck|NC_PartIdx|NC_IdxExpr); |
| 772 break; | 779 break; |
| 773 } | 780 } |
| 781 case TK_BETWEEN: |
| 782 case TK_EQ: |
| 783 case TK_NE: |
| 784 case TK_LT: |
| 785 case TK_LE: |
| 786 case TK_GT: |
| 787 case TK_GE: |
| 788 case TK_IS: |
| 789 case TK_ISNOT: { |
| 790 int nLeft, nRight; |
| 791 if( pParse->db->mallocFailed ) break; |
| 792 assert( pExpr->pLeft!=0 ); |
| 793 nLeft = sqlite3ExprVectorSize(pExpr->pLeft); |
| 794 if( pExpr->op==TK_BETWEEN ){ |
| 795 nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[0].pExpr); |
| 796 if( nRight==nLeft ){ |
| 797 nRight = sqlite3ExprVectorSize(pExpr->x.pList->a[1].pExpr); |
| 798 } |
| 799 }else{ |
| 800 assert( pExpr->pRight!=0 ); |
| 801 nRight = sqlite3ExprVectorSize(pExpr->pRight); |
| 802 } |
| 803 if( nLeft!=nRight ){ |
| 804 testcase( pExpr->op==TK_EQ ); |
| 805 testcase( pExpr->op==TK_NE ); |
| 806 testcase( pExpr->op==TK_LT ); |
| 807 testcase( pExpr->op==TK_LE ); |
| 808 testcase( pExpr->op==TK_GT ); |
| 809 testcase( pExpr->op==TK_GE ); |
| 810 testcase( pExpr->op==TK_IS ); |
| 811 testcase( pExpr->op==TK_ISNOT ); |
| 812 testcase( pExpr->op==TK_BETWEEN ); |
| 813 sqlite3ErrorMsg(pParse, "row value misused"); |
| 814 } |
| 815 break; |
| 816 } |
| 774 } | 817 } |
| 775 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue; | 818 return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue; |
| 776 } | 819 } |
| 777 | 820 |
| 778 /* | 821 /* |
| 779 ** pEList is a list of expressions which are really the result set of the | 822 ** pEList is a list of expressions which are really the result set of the |
| 780 ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause. | 823 ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause. |
| 781 ** This routine checks to see if pE is a simple identifier which corresponds | 824 ** This routine checks to see if pE is a simple identifier which corresponds |
| 782 ** to the AS-name of one of the terms of the expression list. If it is, | 825 ** to the AS-name of one of the terms of the expression list. If it is, |
| 783 ** this routine return an integer between 1 and N where N is the number of | 826 ** this routine return an integer between 1 and N where N is the number of |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 { | 1429 { |
| 1387 Parse *pParse = pNC->pParse; | 1430 Parse *pParse = pNC->pParse; |
| 1388 if( sqlite3ExprCheckHeight(pParse, pExpr->nHeight+pNC->pParse->nHeight) ){ | 1431 if( sqlite3ExprCheckHeight(pParse, pExpr->nHeight+pNC->pParse->nHeight) ){ |
| 1389 return 1; | 1432 return 1; |
| 1390 } | 1433 } |
| 1391 pParse->nHeight += pExpr->nHeight; | 1434 pParse->nHeight += pExpr->nHeight; |
| 1392 } | 1435 } |
| 1393 #endif | 1436 #endif |
| 1394 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg); | 1437 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg); |
| 1395 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg); | 1438 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg); |
| 1396 memset(&w, 0, sizeof(w)); | 1439 w.pParse = pNC->pParse; |
| 1397 w.xExprCallback = resolveExprStep; | 1440 w.xExprCallback = resolveExprStep; |
| 1398 w.xSelectCallback = resolveSelectStep; | 1441 w.xSelectCallback = resolveSelectStep; |
| 1399 w.pParse = pNC->pParse; | 1442 w.xSelectCallback2 = 0; |
| 1443 w.walkerDepth = 0; |
| 1444 w.eCode = 0; |
| 1400 w.u.pNC = pNC; | 1445 w.u.pNC = pNC; |
| 1401 sqlite3WalkExpr(&w, pExpr); | 1446 sqlite3WalkExpr(&w, pExpr); |
| 1402 #if SQLITE_MAX_EXPR_DEPTH>0 | 1447 #if SQLITE_MAX_EXPR_DEPTH>0 |
| 1403 pNC->pParse->nHeight -= pExpr->nHeight; | 1448 pNC->pParse->nHeight -= pExpr->nHeight; |
| 1404 #endif | 1449 #endif |
| 1405 if( pNC->nErr>0 || w.pParse->nErr>0 ){ | 1450 if( pNC->nErr>0 || w.pParse->nErr>0 ){ |
| 1406 ExprSetProperty(pExpr, EP_Error); | 1451 ExprSetProperty(pExpr, EP_Error); |
| 1407 } | 1452 } |
| 1408 if( pNC->ncFlags & NC_HasAgg ){ | 1453 if( pNC->ncFlags & NC_HasAgg ){ |
| 1409 ExprSetProperty(pExpr, EP_Agg); | 1454 ExprSetProperty(pExpr, EP_Agg); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 sSrc.nSrc = 1; | 1530 sSrc.nSrc = 1; |
| 1486 sSrc.a[0].zName = pTab->zName; | 1531 sSrc.a[0].zName = pTab->zName; |
| 1487 sSrc.a[0].pTab = pTab; | 1532 sSrc.a[0].pTab = pTab; |
| 1488 sSrc.a[0].iCursor = -1; | 1533 sSrc.a[0].iCursor = -1; |
| 1489 sNC.pParse = pParse; | 1534 sNC.pParse = pParse; |
| 1490 sNC.pSrcList = &sSrc; | 1535 sNC.pSrcList = &sSrc; |
| 1491 sNC.ncFlags = type; | 1536 sNC.ncFlags = type; |
| 1492 if( sqlite3ResolveExprNames(&sNC, pExpr) ) return; | 1537 if( sqlite3ResolveExprNames(&sNC, pExpr) ) return; |
| 1493 if( pList ) sqlite3ResolveExprListNames(&sNC, pList); | 1538 if( pList ) sqlite3ResolveExprListNames(&sNC, pList); |
| 1494 } | 1539 } |
| OLD | NEW |