Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Simplifications to expr.c in support of full coverage testing. (CVS 6665) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
309adb5e22af2735b69460c164d870ae |
User & Date: | drh 2009-05-21 20:41:32.000 |
Context
2009-05-22
| ||
01:00 | Fix an 8-byte alignment problem on HP/UX. Ticket #3869 (CVS 6666) (check-in: fc64f85092 user: drh tags: trunk) | |
2009-05-21
| ||
20:41 | Simplifications to expr.c in support of full coverage testing. (CVS 6665) (check-in: 309adb5e22 user: drh tags: trunk) | |
15:15 | In the CLI in the ".dump" command, do not attempt to clear the sqlite_sequence table until the first row of content of that table is seen. Ticket #3867 (CVS 6664) (check-in: bedd5ad194 user: drh tags: trunk) | |
Changes
Changes to src/expr.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** ** $Id: expr.c,v 1.435 2009/05/21 20:41:32 drh Exp $ */ #include "sqliteInt.h" /* ** Return the 'affinity' of the expression pExpr if any. ** ** If pExpr is a column, a reference to a column via an 'AS' alias, |
︙ | ︙ | |||
82 83 84 85 86 87 88 | /* ** Return the default collation sequence for the expression pExpr. If ** there is no default collation type, return 0. */ CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){ CollSeq *pColl = 0; Expr *p = pExpr; | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | /* ** Return the default collation sequence for the expression pExpr. If ** there is no default collation type, return 0. */ CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){ CollSeq *pColl = 0; Expr *p = pExpr; while( ALWAYS(p) ){ int op; pColl = p->pColl; if( pColl ) break; op = p->op; if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_REGISTER) && p->pTab!=0 ){ /* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally ** a TK_COLUMN but was previously evaluated and cached in a register */ |
︙ | ︙ | |||
408 409 410 411 412 413 414 | assert( pToken->dyn==0 ); pNew->span = *pToken; if( pToken->n>=2 && ((c = pToken->z[0])=='\'' || c=='"' || c=='[' || c=='`') ){ sqlite3TokenCopy(db, &pNew->token, pToken); if( pNew->token.z ){ pNew->token.n = sqlite3Dequote((char*)pNew->token.z); | | | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | assert( pToken->dyn==0 ); pNew->span = *pToken; if( pToken->n>=2 && ((c = pToken->z[0])=='\'' || c=='"' || c=='[' || c=='`') ){ sqlite3TokenCopy(db, &pNew->token, pToken); if( pNew->token.z ){ pNew->token.n = sqlite3Dequote((char*)pNew->token.z); assert( pNew->token.n==(unsigned)sqlite3Strlen30((char*)pNew->token.z)); } if( c=='"' ) pNew->flags |= EP_DblQuoted; }else{ pNew->token = *pToken; } pNew->token.quoted = 0; }else if( pLeft ){ |
︙ | ︙ | |||
464 465 466 467 468 469 470 | ** ** This routine is called by the parser to deal with on of those terms. ** It immediately generates code to store the value in a memory location. ** The returns an expression that will code to extract the value from ** that memory location as needed. */ Expr *sqlite3RegisterExpr(Parse *pParse, Token *pToken){ | < < | 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | ** ** This routine is called by the parser to deal with on of those terms. ** It immediately generates code to store the value in a memory location. ** The returns an expression that will code to extract the value from ** that memory location as needed. */ Expr *sqlite3RegisterExpr(Parse *pParse, Token *pToken){ Expr *p; if( pParse->nested==0 ){ sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", pToken); return sqlite3PExpr(pParse, TK_NULL, 0, 0, 0); } p = sqlite3PExpr(pParse, TK_REGISTER, 0, 0, pToken); if( p==0 ){ return 0; /* Malloc failed */ } p->iTable = atoi((char*)&pToken->z[1]); return p; } |
︙ | ︙ | |||
544 545 546 547 548 549 550 | ** Wildcards consisting of a single "?" are assigned the next sequential ** variable number. ** ** Wildcards of the form "?nnn" are assigned the number "nnn". We make ** sure "nnn" is not too be to avoid a denial of service attack when ** the SQL statement comes from an external source. ** | | | 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | ** Wildcards consisting of a single "?" are assigned the next sequential ** variable number. ** ** Wildcards of the form "?nnn" are assigned the number "nnn". We make ** sure "nnn" is not too be to avoid a denial of service attack when ** the SQL statement comes from an external source. ** ** Wildcards of the form ":aaa", "@aaa", or "$aaa" are assigned the same number ** as the previous instance of the same wildcard. Or if this is the first ** instance of the wildcard, the next sequenial variable number is ** assigned. */ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){ Token *pToken; sqlite3 *db = pParse->db; |
︙ | ︙ | |||
578 579 580 581 582 583 584 | sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d", db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]); } if( i>pParse->nVar ){ pParse->nVar = i; } }else{ | | < | | | | 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 | sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d", db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]); } if( i>pParse->nVar ){ pParse->nVar = i; } }else{ /* Wildcards like ":aaa", "$aaa" or "@aaa". Reuse the same variable ** number as the prior appearance of the same name, or if the name ** has never appeared before, reuse the same variable number */ int i; u32 n; n = pToken->n; for(i=0; i<pParse->nVarExpr; i++){ Expr *pE = pParse->apVarExpr[i]; assert( pE!=0 ); if( pE->token.n==n && memcmp(pE->token.z, pToken->z, n)==0 ){ pExpr->iTable = pE->iTable; break; } } if( i>=pParse->nVarExpr ){ pExpr->iTable = ++pParse->nVar; if( pParse->nVarExpr>=pParse->nVarExprAlloc-1 ){ |
︙ | ︙ |