SQLite

Check-in [8362d88324]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Do not attempt to walk a TokenOnly or SpanOnly expression tree node. Ticket #3791. (CVS 6469)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8362d883248f00a8ec7294bf027fd19758aec5f2
User & Date: drh 2009-04-08 12:21:31.000
Context
2009-04-08
13:51
Minor refactoring of the expression-compaction logic for clarity of presentation. New comments added. The EXPRDUP_DISTINCTSPAN flag is removed as obsolete. (CVS 6470) (check-in: 44ded2ea67 user: drh tags: trunk)
12:21
Do not attempt to walk a TokenOnly or SpanOnly expression tree node. Ticket #3791. (CVS 6469) (check-in: 8362d88324 user: drh tags: trunk)
11:49
Add a comment to printf.c - no changes to code. (CVS 6468) (check-in: ee5a4a0e59 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/walker.c.
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 walking the parser tree for
** an SQL statement.
**
** $Id: walker.c,v 1.2 2009/02/19 14:39:25 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
#include <string.h>


/*







|







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 walking the parser tree for
** an SQL statement.
**
** $Id: walker.c,v 1.3 2009/04/08 12:21:31 drh Exp $
*/
#include "sqliteInt.h"
#include <stdlib.h>
#include <string.h>


/*
37
38
39
40
41
42
43



44
45
46
47
48
49
50
51
52
**
** The return value from this routine is WRC_Abort to abandon the tree walk
** and WRC_Continue to continue.
*/
int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
  int rc;
  if( pExpr==0 ) return WRC_Continue;



  rc = pWalker->xExprCallback(pWalker, pExpr);
  if( rc==WRC_Continue ){
    if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
    if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
    if( ExprHasProperty(pExpr, EP_xIsSelect) ){
      if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
    }else{
      if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
    }







>
>
>

|







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
**
** The return value from this routine is WRC_Abort to abandon the tree walk
** and WRC_Continue to continue.
*/
int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
  int rc;
  if( pExpr==0 ) return WRC_Continue;
  testcase( ExprHasProperty(pExpr, EP_TokenOnly) );
  testcase( ExprHasProperty(pExpr, EP_SpanOnly) );
  testcase( ExprHasProperty(pExpr, EP_Reduced) );
  rc = pWalker->xExprCallback(pWalker, pExpr);
  if( rc==WRC_Continue && !ExprHasAnyProperty(pExpr,EP_TokenOnly|EP_SpanOnly) ){
    if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
    if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
    if( ExprHasProperty(pExpr, EP_xIsSelect) ){
      if( sqlite3WalkSelect(pWalker, pExpr->x.pSelect) ) return WRC_Abort;
    }else{
      if( sqlite3WalkExprList(pWalker, pExpr->x.pList) ) return WRC_Abort;
    }
Added test/tkt3791.test.
























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 2009 April 2
#
# 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.
#
#***********************************************************************
#
# Ticket #3791:  A segfault when inserting into a table that contains
# an arbitrary expression as its default value.
#
# $Id: tkt3791.test,v 1.1 2009/04/08 12:21:31 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_test tkt3791-1.1 {
  db eval {
    CREATE TABLE t1(x, y DEFAULT(datetime('now')));
    INSERT INTO t1(x) VALUES(1);
    SELECT x, length(y) FROM t1;
  }
} {1 19}

finish_test