| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2001 September 15 | 2 ** 2001 September 15 |
| 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 ** |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 } | 571 } |
| 572 if( i>pParse->nVar ){ | 572 if( i>pParse->nVar ){ |
| 573 pParse->nVar = (int)i; | 573 pParse->nVar = (int)i; |
| 574 } | 574 } |
| 575 }else{ | 575 }else{ |
| 576 /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable | 576 /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable |
| 577 ** number as the prior appearance of the same name, or if the name | 577 ** number as the prior appearance of the same name, or if the name |
| 578 ** has never appeared before, reuse the same variable number | 578 ** has never appeared before, reuse the same variable number |
| 579 */ | 579 */ |
| 580 int i; | 580 int i; |
| 581 u32 n; |
| 582 n = sqlite3Strlen30(z); |
| 581 for(i=0; i<pParse->nVarExpr; i++){ | 583 for(i=0; i<pParse->nVarExpr; i++){ |
| 582 Expr *pE = pParse->apVarExpr[i]; | 584 Expr *pE = pParse->apVarExpr[i]; |
| 583 assert( pE!=0 ); | 585 assert( pE!=0 ); |
| 584 if( strcmp(pE->u.zToken, z)==0 ){ | 586 if( memcmp(pE->u.zToken, z, n)==0 && pE->u.zToken[n]==0 ){ |
| 585 pExpr->iColumn = pE->iColumn; | 587 pExpr->iColumn = pE->iColumn; |
| 586 break; | 588 break; |
| 587 } | 589 } |
| 588 } | 590 } |
| 589 if( i>=pParse->nVarExpr ){ | 591 if( i>=pParse->nVarExpr ){ |
| 590 pExpr->iColumn = (ynVar)(++pParse->nVar); | 592 pExpr->iColumn = (ynVar)(++pParse->nVar); |
| 591 if( pParse->nVarExpr>=pParse->nVarExprAlloc-1 ){ | 593 if( pParse->nVarExpr>=pParse->nVarExprAlloc-1 ){ |
| 592 pParse->nVarExprAlloc += pParse->nVarExprAlloc + 10; | 594 pParse->nVarExprAlloc += pParse->nVarExprAlloc + 10; |
| 593 pParse->apVarExpr = | 595 pParse->apVarExpr = |
| 594 sqlite3DbReallocOrFree( | 596 sqlite3DbReallocOrFree( |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 nToken = sqlite3Strlen30(p->u.zToken) + 1; | 774 nToken = sqlite3Strlen30(p->u.zToken) + 1; |
| 773 }else{ | 775 }else{ |
| 774 nToken = 0; | 776 nToken = 0; |
| 775 } | 777 } |
| 776 if( isReduced ){ | 778 if( isReduced ){ |
| 777 assert( ExprHasProperty(p, EP_Reduced)==0 ); | 779 assert( ExprHasProperty(p, EP_Reduced)==0 ); |
| 778 memcpy(zAlloc, p, nNewSize); | 780 memcpy(zAlloc, p, nNewSize); |
| 779 }else{ | 781 }else{ |
| 780 int nSize = exprStructSize(p); | 782 int nSize = exprStructSize(p); |
| 781 memcpy(zAlloc, p, nSize); | 783 memcpy(zAlloc, p, nSize); |
| 782 if( EXPR_FULLSIZE>nSize ){ | 784 memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); |
| 783 memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize); | |
| 784 } | |
| 785 } | 785 } |
| 786 | 786 |
| 787 /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ | 787 /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ |
| 788 pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static); | 788 pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static); |
| 789 pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly); | 789 pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly); |
| 790 pNew->flags |= staticFlag; | 790 pNew->flags |= staticFlag; |
| 791 | 791 |
| 792 /* Copy the p->u.zToken string, if any. */ | 792 /* Copy the p->u.zToken string, if any. */ |
| 793 if( nToken ){ | 793 if( nToken ){ |
| 794 char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize]; | 794 char *zToken = pNew->u.zToken = (char*)&zAlloc[nNewSize]; |
| (...skipping 2951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3746 } | 3746 } |
| 3747 return i; | 3747 return i; |
| 3748 } | 3748 } |
| 3749 void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){ | 3749 void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){ |
| 3750 sqlite3ExprCacheRemove(pParse, iReg, nReg); | 3750 sqlite3ExprCacheRemove(pParse, iReg, nReg); |
| 3751 if( nReg>pParse->nRangeReg ){ | 3751 if( nReg>pParse->nRangeReg ){ |
| 3752 pParse->nRangeReg = nReg; | 3752 pParse->nRangeReg = nReg; |
| 3753 pParse->iRangeReg = iReg; | 3753 pParse->iRangeReg = iReg; |
| 3754 } | 3754 } |
| 3755 } | 3755 } |
| OLD | NEW |