Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | New assert()s added to verify that the Expr.token value is used correctly. Ticket #3743. (CVS 6378) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
cf3d84ab73b7f519921a984f88bdad81 |
User & Date: | drh 2009-03-24 15:31:28.000 |
Context
2009-03-24
| ||
16:27 | Include sqliteInt.h in test_async.c so that the asynchronous VFS tests will run even if SQLITE_OS_UNIX is not explicitly defined. (CVS 6379) (check-in: 29b0d6a3fe user: drh tags: trunk) | |
15:31 | New assert()s added to verify that the Expr.token value is used correctly. Ticket #3743. (CVS 6378) (check-in: cf3d84ab73 user: drh tags: trunk) | |
15:08 | Changes to insure that lookaside memory allocations are never used to hold schema content. Ticket #3743. (CVS 6377) (check-in: ea74d8dc62 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.423 2009/03/24 15:31:28 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, |
︙ | ︙ | |||
404 405 406 407 408 409 410 | pNew->iAgg = -1; pNew->span.z = (u8*)""; if( pToken ){ int c; assert( pToken->dyn==0 ); pNew->span = *pToken; | | | | > > | 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | pNew->iAgg = -1; pNew->span.z = (u8*)""; if( pToken ){ int c; assert( pToken->dyn==0 ); pNew->span = *pToken; /* The pToken->z value is read-only. But the new expression ** node created here might be passed to sqlite3DequoteExpr() which ** will attempt to modify pNew->token.z. Hence, if the token ** is quoted, make a copy now so that DequoteExpr() will change ** the copy rather than the original text. */ if( pToken->n>=2 && ((c = pToken->z[0])=='\'' || c=='"' || c=='[' || c=='`') ){ sqlite3TokenCopy(db, &pNew->token, pToken); }else{ pNew->token = *pToken; pNew->flags |= EP_Dequoted; VVA_ONLY( pNew->vvaFlags |= EVVA_ReadOnlyToken; ) } }else if( pLeft ){ if( pRight ){ if( pRight->span.dyn==0 && pLeft->span.dyn==0 ){ sqlite3ExprSpan(pNew, &pLeft->span, &pRight->span); } if( pRight->flags & EP_ExpCollate ){ |
︙ | ︙ | |||
656 657 658 659 660 661 662 663 664 665 666 667 668 669 | /* ** The Expr.token field might be a string literal that is quoted. ** If so, remove the quotation marks. */ void sqlite3DequoteExpr(sqlite3 *db, Expr *p){ if( !ExprHasAnyProperty(p, EP_Dequoted) ){ ExprSetProperty(p, EP_Dequoted); sqlite3Dequote((char*)p->token.z); } } /* ** Return the number of bytes allocated for the expression structure ** passed as the first argument. This is always one of EXPR_FULLSIZE, | > | 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | /* ** The Expr.token field might be a string literal that is quoted. ** If so, remove the quotation marks. */ void sqlite3DequoteExpr(sqlite3 *db, Expr *p){ if( !ExprHasAnyProperty(p, EP_Dequoted) ){ ExprSetProperty(p, EP_Dequoted); assert( (p->vvaFlags & EVVA_ReadOnlyToken)==0 ); sqlite3Dequote((char*)p->token.z); } } /* ** Return the number of bytes allocated for the expression structure ** passed as the first argument. This is always one of EXPR_FULLSIZE, |
︙ | ︙ |
Changes to src/sqliteInt.h.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2001 September 15 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Internal interface definitions for SQLite. ** ** @(#) $Id: sqliteInt.h,v 1.847 2009/03/24 15:31:28 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ /* ** Include the configuration header output by 'configure' if we're using the ** autoconf-based build |
︙ | ︙ | |||
1454 1455 1456 1457 1458 1459 1460 | ** If the EP_TokenOnly flag is set in Expr.flags, then only EXPR_TOKENONLYSIZE ** bytes of space are allocated for the expression structure. This is enough ** space to store all fields up to and including the "Token token;" field. */ struct Expr { u8 op; /* Operation performed by this node */ char affinity; /* The affinity of the column or 0 if not a column */ | > | | 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 | ** If the EP_TokenOnly flag is set in Expr.flags, then only EXPR_TOKENONLYSIZE ** bytes of space are allocated for the expression structure. This is enough ** space to store all fields up to and including the "Token token;" field. */ struct Expr { u8 op; /* Operation performed by this node */ char affinity; /* The affinity of the column or 0 if not a column */ VVA_ONLY(u8 vvaFlags;) /* Flags used for VV&A only. EVVA_* below. */ u16 flags; /* Various flags. EP_* See below */ Token token; /* An operand token */ /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no ** space is allocated for the fields below this point. An attempt to ** access them will result in a segfault or malfunction. *********************************************************************/ |
︙ | ︙ | |||
1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 | #define EP_IntValue 0x0800 /* Integer value contained in iTable */ #define EP_xIsSelect 0x1000 /* x.pSelect is valid (otherwise x.pList is) */ #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */ #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */ #define EP_SpanOnly 0x8000 /* Expr struct is EXPR_SPANONLYSIZE bytes only */ /* ** These macros can be used to test, set, or clear bits in the ** Expr.flags field. */ #define ExprHasProperty(E,P) (((E)->flags&(P))==(P)) #define ExprHasAnyProperty(E,P) (((E)->flags&(P))!=0) #define ExprSetProperty(E,P) (E)->flags|=(P) | > > > > > > > > > | 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 | #define EP_IntValue 0x0800 /* Integer value contained in iTable */ #define EP_xIsSelect 0x1000 /* x.pSelect is valid (otherwise x.pList is) */ #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */ #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */ #define EP_SpanOnly 0x8000 /* Expr struct is EXPR_SPANONLYSIZE bytes only */ /* ** The following are the meanings of bits in the Expr.vvaFlags field. ** This information is only used when SQLite is compiled with ** SQLITE_DEBUG defined. */ #ifndef NDEBUG #define EVVA_ReadOnlyToken 0x01 /* Expr.token.z is read-only */ #endif /* ** These macros can be used to test, set, or clear bits in the ** Expr.flags field. */ #define ExprHasProperty(E,P) (((E)->flags&(P))==(P)) #define ExprHasAnyProperty(E,P) (((E)->flags&(P))!=0) #define ExprSetProperty(E,P) (E)->flags|=(P) |
︙ | ︙ |