From be8c95ef6e9effd8e60b0ec34a71bc1a6a6f3785 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 19 Dec 2012 17:10:16 +0000 Subject: [PATCH] Backport to the 3.7.15 branch the fix to the segfault problem of ticket [a7b7803e8d1e869] which involved the use of "AS" named result columns as logical terms of the WHERE clause. Also, change the version number to 3.7.15.1. FossilOrigin-Name: bae528f486f51d0516c3ff2a983cb2e61a6a173f --- VERSION | 2 +- configure | 22 +++++------ manifest | 25 +++++++------ manifest.uuid | 2 +- src/where.c | 5 ++- test/tkt-a7b7803e.test | 84 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+), 27 deletions(-) create mode 100644 test/tkt-a7b7803e.test diff --git a/VERSION b/VERSION index 03d7b8fb9b..f19a6be7c7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.7.15 +3.7.15.1 diff --git a/configure b/configure index badc9da34e..63d62ce105 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.62 for sqlite 3.7.15. +# Generated by GNU Autoconf 2.62 for sqlite 3.7.15.1. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. @@ -743,8 +743,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.7.15' -PACKAGE_STRING='sqlite 3.7.15' +PACKAGE_VERSION='3.7.15.1' +PACKAGE_STRING='sqlite 3.7.15.1' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. @@ -1484,7 +1484,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.7.15 to adapt to many kinds of systems. +\`configure' configures sqlite 3.7.15.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1549,7 +1549,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.7.15:";; + short | recursive ) echo "Configuration of sqlite 3.7.15.1:";; esac cat <<\_ACEOF @@ -1665,7 +1665,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.7.15 +sqlite configure 3.7.15.1 generated by GNU Autoconf 2.62 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1679,7 +1679,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.7.15, which was +It was created by sqlite $as_me 3.7.15.1, which was generated by GNU Autoconf 2.62. Invocation command line was $ $0 $@ @@ -14033,7 +14033,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.7.15, which was +This file was extended by sqlite $as_me 3.7.15.1, which was generated by GNU Autoconf 2.62. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14086,7 +14086,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -sqlite config.status 3.7.15 +sqlite config.status 3.7.15.1 configured by $0, generated by GNU Autoconf 2.62, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" @@ -14519,7 +14519,8 @@ $debug || if test -n "$CONFIG_FILES"; then -ac_cr=' ' +ac_cr=' +' ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' @@ -15754,4 +15755,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:$LINENO: WARNING: Unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: Unrecognized options: $ac_unrecognized_opts" >&2;} fi - diff --git a/manifest b/manifest index b0a4c45629..d3909292d5 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Version\s3.7.15 -D 2012-12-12T13:36:53.477 +C Backport\sto\sthe\s3.7.15\sbranch\s\nthe\sfix\sto\sthe\ssegfault\sproblem\sof\sticket\s[a7b7803e8d1e869]\swhich\sinvolved\nthe\suse\sof\s"AS"\snamed\sresult\scolumns\sas\slogical\sterms\sof\sthe\sWHERE\sclause.\nAlso,\schange\sthe\sversion\snumber\sto\s3.7.15.1. +D 2012-12-19T17:10:16.499 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 690d441a758cbffd13e814dc2724a721a6ebd400 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc 5a3b6f34d263b01f8b798c291fac1529fd650308 F Makefile.vxworks b18ad88e9a8c6a001f5cf4a389116a4f1a7ab45f F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 -F VERSION edab4af5a4623f8198833ea481ce98ab53750a8d +F VERSION 9f73b1223dd440610dbd758b233c59a7af234434 F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F addopcodes.awk 17dc593f791f874d2c23a0f9360850ded0286531 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 @@ -15,7 +15,7 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 0921066a13130082764ab4ab6456f7b5bebe56de F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 252992f6588107ebd5d17c956d90cf7484580c6f x +F configure 7b407a89c39c477e064e3ce128b613a533317d80 x F configure.ac 81c43d151d0b0e406be056394cc9ff4cb3fd0444 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 334dbf6621b8fb8790297ec1abf3cfa4621709d1 @@ -250,7 +250,7 @@ F src/vtab.c b05e5f1f4902461ba9f5fc49bb7eb7c3a0741a83 F src/wal.c f5c7b5027d0ed0e9bc9afeb4a3a8dfea762ec7d2 F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3d75ba73de15e0f8cd0737643badbeb0e002f07b -F src/where.c 53b991af50dab230b319b098bcb90fc7cd82da47 +F src/where.c 74d72b1613aac386f9baf1a46c75f67784f082ba F test/8_3_names.test 631ea964a3edb091cf73c3b540f6bcfdb36ce823 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -783,6 +783,7 @@ F test/tkt-8454a207b9.test c583a9f814a82a2b5ba95207f55001c9f0cd816c F test/tkt-91e2e8ba6f.test 08c4f94ae07696b05c9b822da0b4e5337a2f54c5 F test/tkt-94c04eaadb.test fa9c71192f7e2ea2d51bf078bc34e8da6088bf71 F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67 +F test/tkt-a7b7803e.test 159ef554234fa1f9fb318c751b284bd1cf858da4 F test/tkt-b1d3a2e531.test 610ef582413171b379652663111b1f996d9f8f78 F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0 F test/tkt-b72787b1.test a95e8cdad0b98af1853ac7f0afd4ab27b77bf5f3 @@ -1025,10 +1026,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 81d9ee0f0df7f283e69ba1c2845339ea3318cd66 -R 6da93546e03c634583a9df9f228276ed -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.7.15 * -U dan -Z c2b6a5ded805ac723be241fad17cc751 +P cd0b37c52658bfdf992b1e3dc467bae1835a94ae +R 37df6a77f239e5cf5347f1930acc76e7 +T *branch * branch-3.7.15 +T *sym-branch-3.7.15 * +T -sym-trunk * +U drh +Z eb40a4838ecc9791bafcdeaed13051da diff --git a/manifest.uuid b/manifest.uuid index 940b7402c1..3d7a643697 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cd0b37c52658bfdf992b1e3dc467bae1835a94ae \ No newline at end of file +bae528f486f51d0516c3ff2a983cb2e61a6a173f \ No newline at end of file diff --git a/src/where.c b/src/where.c index 98369db6d2..52c974fc4b 100644 --- a/src/where.c +++ b/src/where.c @@ -403,7 +403,7 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){ pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]); } pTerm = &pWC->a[idx = pWC->nTerm++]; - pTerm->pExpr = p; + pTerm->pExpr = sqlite3ExprSkipCollate(p); pTerm->wtFlags = wtFlags; pTerm->pWC = pWC; pTerm->iParent = -1; @@ -1188,7 +1188,8 @@ static void exprAnalyze( } pTerm = &pWC->a[idxTerm]; pMaskSet = pWC->pMaskSet; - pExpr = sqlite3ExprSkipCollate(pTerm->pExpr); + pExpr = pTerm->pExpr; + assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE ); prereqLeft = exprTableUsage(pMaskSet, pExpr->pLeft); op = pExpr->op; if( op==TK_IN ){ diff --git a/test/tkt-a7b7803e.test b/test/tkt-a7b7803e.test new file mode 100644 index 0000000000..b617cf6df2 --- /dev/null +++ b/test/tkt-a7b7803e.test @@ -0,0 +1,84 @@ +# 2012 December 19 +# +# 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. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. Specifically, +# it tests that ticket [a7b7803e8d1e8699cd8a460a38133b98892d2e17] has +# been fixed. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +source $testdir/lock_common.tcl +source $testdir/malloc_common.tcl + +do_test tkt-a7b7803e.1 { + db eval { + CREATE TABLE t1(a,b); + INSERT INTO t1 VALUES(0,'first'),(99,'fuzzy'); + SELECT (t1.a==0) AS x, b + FROM t1 + WHERE a=0 OR x; + } +} {1 first} +do_test tkt-a7b7803e.2 { + db eval { + SELECT a, (t1.b='fuzzy') AS x + FROM t1 + WHERE x + } +} {99 1} +do_test tkt-a7b7803e.3 { + db eval { + SELECT (a=99) AS x, (t1.b='fuzzy') AS y, * + FROM t1 + WHERE x AND y + } +} {1 1 99 fuzzy} +do_test tkt-a7b7803e.4 { + db eval { + SELECT (a=99) AS x, (t1.b='first') AS y, * + FROM t1 + WHERE x OR y + ORDER BY a + } +} {0 1 0 first 1 0 99 fuzzy} +do_test tkt-a7b7803e.5 { + db eval { + SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b + FROM t1 M, t1 N + WHERE x OR y + ORDER BY M.a, N.a + } +} {0 first 1 first 1 fuzzy 1 first 1 fuzzy 0 fuzzy} +do_test tkt-a7b7803e.6 { + db eval { + SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b + FROM t1 M, t1 N + WHERE x AND y + ORDER BY M.a, N.a + } +} {1 fuzzy 1 first} +do_test tkt-a7b7803e.7 { + db eval { + SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b + FROM t1 M JOIN t1 N ON x AND y + ORDER BY M.a, N.a + } +} {1 fuzzy 1 first} +do_test tkt-a7b7803e.8 { + db eval { + SELECT (M.a=99) AS x, M.b, (N.b='first') AS y, N.b + FROM t1 M JOIN t1 N ON x + ORDER BY M.a, N.a + } +} {1 fuzzy 1 first 1 fuzzy 0 fuzzy} + + +finish_test -- 2.47.2