From 89a75397e02236e262c196490e7fbc01c75cdf81 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 11 Sep 2013 14:57:11 +0000 Subject: [PATCH 1/6] Add test cases to cover TPC-H Q8. FossilOrigin-Name: eb5cef8351d12c0f8550dac96ee7a6e495975b5a --- manifest | 11 +-- manifest.uuid | 2 +- test/tpch01.test | 187 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+), 6 deletions(-) create mode 100644 test/tpch01.test diff --git a/manifest b/manifest index 11dfa9b55b..cc548c6232 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Deterministically\sinitialize\sthe\sPRNG\sused\sas\sa\stie-breaker\sin\sthe\sANALYZE\ncommand,\sso\sthat\sthe\sanalysis\sis\salways\sthe\ssame\sgiven\sthe\ssame\sdatabase.\nThis\ssimplifies\stesting. -D 2013-09-10T01:41:25.676 +C Add\stest\scases\sto\scover\sTPC-H\sQ8. +D 2013-09-11T14:57:11.714 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -964,6 +964,7 @@ F test/tkt3992.test f3e7d548ac26f763b47bc0f750da3d03c81071da F test/tkt3997.test a335fa41ca3985660a139df7b734a26ef53284bd F test/tkt4018.test 7c2c9ba4df489c676a0a7a0e809a1fb9b2185bd1 F test/tokenize.test ce430a7aed48fc98301611429595883fdfcab5d7 +F test/tpch01.test 8f4ac52f62f3e9f6bce0889105aecdf0275e331b F test/trace.test 4b36a41a3e9c7842151af6da5998f5080cdad9e5 F test/trace2.test e7a988fdd982cdec62f1f1f34b0360e6476d01a0 F test/trans.test 6e1b4c6a42dba31bd65f8fa5e61a2708e08ddde6 @@ -1111,7 +1112,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P d6e361d7fb8013d616af91ef2c10038c97d1be5f -R f0dc49c77588220f9d25d9d712edfe4a +P 48ed8b565b84c8fa7898c2f9817c01f7e9c9182e +R b9522deba37561644e51654b6b510026 U drh -Z e68c71d629e67be96bb05aa541d1ef71 +Z 8b5488a345e69fd6a7996d8b2149a33e diff --git a/manifest.uuid b/manifest.uuid index b31980649d..d5a16fdb23 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -48ed8b565b84c8fa7898c2f9817c01f7e9c9182e \ No newline at end of file +eb5cef8351d12c0f8550dac96ee7a6e495975b5a \ No newline at end of file diff --git a/test/tpch01.test b/test/tpch01.test new file mode 100644 index 0000000000..2d099d63fb --- /dev/null +++ b/test/tpch01.test @@ -0,0 +1,187 @@ +# 2013-09-05 +# +# 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. +# +#*********************************************************************** +# +# TPC-H test queries. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix tpch01 + +do_execsql_test tpch01-1.0 { + CREATE TABLE NATION ( N_NATIONKEY INTEGER NOT NULL, + N_NAME CHAR(25) NOT NULL, + N_REGIONKEY INTEGER NOT NULL, + N_COMMENT VARCHAR(152)); + CREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL, + R_NAME CHAR(25) NOT NULL, + R_COMMENT VARCHAR(152)); + CREATE TABLE PART ( P_PARTKEY INTEGER NOT NULL, + P_NAME VARCHAR(55) NOT NULL, + P_MFGR CHAR(25) NOT NULL, + P_BRAND CHAR(10) NOT NULL, + P_TYPE VARCHAR(25) NOT NULL, + P_SIZE INTEGER NOT NULL, + P_CONTAINER CHAR(10) NOT NULL, + P_RETAILPRICE DECIMAL(15,2) NOT NULL, + P_COMMENT VARCHAR(23) NOT NULL ); + CREATE TABLE SUPPLIER ( S_SUPPKEY INTEGER NOT NULL, + S_NAME CHAR(25) NOT NULL, + S_ADDRESS VARCHAR(40) NOT NULL, + S_NATIONKEY INTEGER NOT NULL, + S_PHONE CHAR(15) NOT NULL, + S_ACCTBAL DECIMAL(15,2) NOT NULL, + S_COMMENT VARCHAR(101) NOT NULL); + CREATE TABLE PARTSUPP ( PS_PARTKEY INTEGER NOT NULL, + PS_SUPPKEY INTEGER NOT NULL, + PS_AVAILQTY INTEGER NOT NULL, + PS_SUPPLYCOST DECIMAL(15,2) NOT NULL, + PS_COMMENT VARCHAR(199) NOT NULL ); + CREATE TABLE CUSTOMER ( C_CUSTKEY INTEGER NOT NULL, + C_NAME VARCHAR(25) NOT NULL, + C_ADDRESS VARCHAR(40) NOT NULL, + C_NATIONKEY INTEGER NOT NULL, + C_PHONE CHAR(15) NOT NULL, + C_ACCTBAL DECIMAL(15,2) NOT NULL, + C_MKTSEGMENT CHAR(10) NOT NULL, + C_COMMENT VARCHAR(117) NOT NULL); + CREATE TABLE ORDERS ( O_ORDERKEY INTEGER NOT NULL, + O_CUSTKEY INTEGER NOT NULL, + O_ORDERSTATUS CHAR(1) NOT NULL, + O_TOTALPRICE DECIMAL(15,2) NOT NULL, + O_ORDERDATE DATE NOT NULL, + O_ORDERPRIORITY CHAR(15) NOT NULL, + O_CLERK CHAR(15) NOT NULL, + O_SHIPPRIORITY INTEGER NOT NULL, + O_COMMENT VARCHAR(79) NOT NULL); + CREATE TABLE LINEITEM ( L_ORDERKEY INTEGER NOT NULL, + L_PARTKEY INTEGER NOT NULL, + L_SUPPKEY INTEGER NOT NULL, + L_LINENUMBER INTEGER NOT NULL, + L_QUANTITY DECIMAL(15,2) NOT NULL, + L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL, + L_DISCOUNT DECIMAL(15,2) NOT NULL, + L_TAX DECIMAL(15,2) NOT NULL, + L_RETURNFLAG CHAR(1) NOT NULL, + L_LINESTATUS CHAR(1) NOT NULL, + L_SHIPDATE DATE NOT NULL, + L_COMMITDATE DATE NOT NULL, + L_RECEIPTDATE DATE NOT NULL, + L_SHIPINSTRUCT CHAR(25) NOT NULL, + L_SHIPMODE CHAR(10) NOT NULL, + L_COMMENT VARCHAR(44) NOT NULL); + CREATE INDEX npki on nation(N_NATIONKEY); + CREATE INDEX rpki on region(R_REGIONKEY); + CREATE INDEX ppki on part(P_PARTKEY); + CREATE INDEX spki on supplier(S_SUPPKEY); + CREATE INDEX pspki on partsupp(PS_PARTKEY, PS_SUPPKEY); + CREATE INDEX cpki on customer(C_CUSTKEY); + CREATE INDEX opki on orders(O_ORDERKEY); + CREATE INDEX lpki on lineitem(L_ORDERKEY, L_LINENUMBER); + CREATE INDEX nrki on nation(n_regionkey); + CREATE INDEX snki on supplier(s_nationkey); + CREATE INDEX cnki on customer(c_nationkey); + CREATE INDEX ocki on orders(O_CUSTKEY); + CREATE INDEX odi on orders(O_ORDERDATE); + CREATE INDEX lpki2 on lineitem(L_PARTKEY); + CREATE INDEX lski on lineitem(L_SUPPKEY); + CREATE INDEX lsdi on lineitem(L_SHIPDATE); + CREATE INDEX lcdi on lineitem(L_COMMITDATE); + CREATE INDEX lrdi on lineitem(L_RECEIPTDATE); + CREATE INDEX bootleg_nni on nation(N_NAME); + CREATE INDEX bootleg_psi on part(p_size); + CREATE INDEX bootleg_pti on part(p_type); + ANALYZE sqlite_master; + INSERT INTO sqlite_stat1 VALUES('LINEITEM','lrdi','600572 236'); + INSERT INTO sqlite_stat1 VALUES('LINEITEM','lcdi','600572 244'); + INSERT INTO sqlite_stat1 VALUES('LINEITEM','lsdi','600572 238'); + INSERT INTO sqlite_stat1 VALUES('LINEITEM','lski','600572 601'); + INSERT INTO sqlite_stat1 VALUES('LINEITEM','lpki2','600572 31'); + INSERT INTO sqlite_stat1 VALUES('LINEITEM','lpki','600572 5 1'); + INSERT INTO sqlite_stat1 VALUES('ORDERS','odi','150000 63'); + INSERT INTO sqlite_stat1 VALUES('ORDERS','ocki','150000 15'); + INSERT INTO sqlite_stat1 VALUES('ORDERS','opki','150000 1'); + INSERT INTO sqlite_stat1 VALUES('CUSTOMER','cnki','15000 600'); + INSERT INTO sqlite_stat1 VALUES('CUSTOMER','cpki','15000 1'); + INSERT INTO sqlite_stat1 VALUES('PARTSUPP','pspki','80000 4 1'); + INSERT INTO sqlite_stat1 VALUES('SUPPLIER','snki','1000 40'); + INSERT INTO sqlite_stat1 VALUES('SUPPLIER','spki','1000 1'); + INSERT INTO sqlite_stat1 VALUES('PART','bootleg_pti','20000 134'); + INSERT INTO sqlite_stat1 VALUES('PART','bootleg_psi','20000 400'); + INSERT INTO sqlite_stat1 VALUES('PART','ppki','20000 1'); + INSERT INTO sqlite_stat1 VALUES('REGION','rpki','5 1'); + INSERT INTO sqlite_stat1 VALUES('NATION','bootleg_nni','25 1'); + INSERT INTO sqlite_stat1 VALUES('NATION','nrki','25 5'); + INSERT INTO sqlite_stat1 VALUES('NATION','npki','25 1'); + ANALYZE sqlite_master; +} {} + +do_test tpch01-1.1 { + unset -nocomplain ::eqpres + set ::eqpres [db eval {EXPLAIN QUERY PLAN + select + o_year, + sum(case + when nation = 'EGYPT' then volume + else 0 + end) / sum(volume) as mkt_share + from + ( + select + strftime('%Y', o_orderdate) as o_year, + l_extendedprice * (1 - l_discount) as volume, + n2.n_name as nation + from + part, + supplier, + lineitem, + orders, + customer, + nation n1, + nation n2, + region + where + p_partkey = l_partkey + and s_suppkey = l_suppkey + and l_orderkey = o_orderkey + and o_custkey = c_custkey + and c_nationkey = n1.n_nationkey + and n1.n_regionkey = r_regionkey + and r_name = 'MIDDLE EAST' + and s_nationkey = n2.n_nationkey + and o_orderdate between '1995-01-01' and '1996-12-31' + and p_type = 'LARGE PLATED STEEL' + ) as all_nations + group by + o_year + order by + o_year;}] + set ::eqpres +} {/0 0 0 {SEARCH TABLE part USING INDEX bootleg_pti .P_TYPE=..} 0 1 2 {SEARCH TABLE lineitem USING INDEX lpki2 .L_PARTKEY=..}.*/} +do_test tpch01-1.1b { + set ::eqpres +} {/.* customer .* nation AS n1 .* nation AS n2 .*/} + +do_eqp_test tpch01-1.2 { +select + c_custkey, c_name, sum(l_extendedprice * (1 - l_discount)) as revenue, + c_acctbal, n_name, c_address, c_phone, c_comment +from + customer, orders, lineitem, nation +where + c_custkey = o_custkey and l_orderkey = o_orderkey + and o_orderdate >= '1994-08-01' and o_orderdate < date('1994-08-01', '+3 month') + and l_returnflag = 'R' and c_nationkey = n_nationkey +group by + c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment +order by + revenue desc; +} {0 0 1 {SEARCH TABLE orders USING INDEX odi (O_ORDERDATE>? AND O_ORDERDATE Date: Thu, 12 Sep 2013 00:54:59 +0000 Subject: [PATCH 2/6] Fix harmless compiler warning. FossilOrigin-Name: 2b510614dc6d878bd49eb428f167014f7f2e2568 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index cc548c6232..e561aa5847 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stest\scases\sto\scover\sTPC-H\sQ8. -D 2013-09-11T14:57:11.714 +C Fix\sharmless\scompiler\swarning. +D 2013-09-12T00:54:59.015 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -203,7 +203,7 @@ F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 243fb37f47dc072fc59839ea241ff0a17c8d76e6 -F src/os_win.c bb592dfb850e4ee3e4caecce461dca74dc40936d +F src/os_win.c af9db76467add89679d3ebb451069c2f842ecd3c F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f @@ -1112,7 +1112,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 48ed8b565b84c8fa7898c2f9817c01f7e9c9182e -R b9522deba37561644e51654b6b510026 -U drh -Z 8b5488a345e69fd6a7996d8b2149a33e +P eb5cef8351d12c0f8550dac96ee7a6e495975b5a +R bf7885bb1c586c43940718dd93c9bac5 +U mistachkin +Z ad1bbbbf78cb709221466a1e4ff47ba4 diff --git a/manifest.uuid b/manifest.uuid index d5a16fdb23..d77a97bee1 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eb5cef8351d12c0f8550dac96ee7a6e495975b5a \ No newline at end of file +2b510614dc6d878bd49eb428f167014f7f2e2568 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 72d6e8ba5c..3cadd036ab 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -3919,6 +3919,7 @@ static const sqlite3_io_methods winIoMethod = { ** sqlite3_vfs object. */ +#if 0 /* ** Convert a filename from whatever the underlying operating system ** supports for filenames into UTF-8. Space to hold the result is @@ -3937,6 +3938,7 @@ static char *winConvertToUtf8Filename(const void *zFilename){ /* caller will handle out of memory */ return zConverted; } +#endif /* ** Convert a UTF-8 filename into whatever form the underlying From 4a1f4ff53bd6be2f083f3fc77e6df8941ec24c59 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 12 Sep 2013 01:33:53 +0000 Subject: [PATCH 3/6] Remove two obsolete fields from the sqlite3 object. FossilOrigin-Name: 117fa5fbc9bed1a7b982c8ddc21b7e228905ccb4 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 2 -- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e561aa5847..6cddbe1bc9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning. -D 2013-09-12T00:54:59.015 +C Remove\stwo\sobsolete\sfields\sfrom\sthe\ssqlite3\sobject. +D 2013-09-12T01:33:53.069 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -221,7 +221,7 @@ F src/shell.c d920a891ca09b8bd262cced7fb0ab9d723f7a747 F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h 32e959dba9899360ce4ae3cd6cc77b4a8df277e8 +F src/sqliteInt.h 600a1da8ca71c919a1a270146b052a66a128533a F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1112,7 +1112,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P eb5cef8351d12c0f8550dac96ee7a6e495975b5a -R bf7885bb1c586c43940718dd93c9bac5 -U mistachkin -Z ad1bbbbf78cb709221466a1e4ff47ba4 +P 2b510614dc6d878bd49eb428f167014f7f2e2568 +R c3304550dc7e156a767f11782ed297f6 +U drh +Z 81bb05c3046a00cec99b12eff1620df6 diff --git a/manifest.uuid b/manifest.uuid index d77a97bee1..8f27c878e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2b510614dc6d878bd49eb428f167014f7f2e2568 \ No newline at end of file +117fa5fbc9bed1a7b982c8ddc21b7e228905ccb4 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 6b3fbe8518..f017229f71 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -921,8 +921,6 @@ struct sqlite3 { void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*); void *pCollNeededArg; sqlite3_value *pErr; /* Most recent error message */ - char *zErrMsg; /* Most recent error message (UTF-8 encoded) */ - char *zErrMsg16; /* Most recent error message (UTF-16 encoded) */ union { volatile int isInterrupted; /* True if sqlite3_interrupt has been called */ double notUsed1; /* Spacer */ From 36ca5359dc5eed1886a3f97bb9bac1ae90957989 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 12 Sep 2013 01:47:57 +0000 Subject: [PATCH 4/6] Fix a couple more harmless compiler warnings. FossilOrigin-Name: 59708674f66e06c9c31c1a24f2f1c51f0bf4fa3e --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 16 +++++++++++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 6cddbe1bc9..121d808050 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\stwo\sobsolete\sfields\sfrom\sthe\ssqlite3\sobject. -D 2013-09-12T01:33:53.069 +C Fix\sa\scouple\smore\sharmless\scompiler\swarnings. +D 2013-09-12T01:47:57.395 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -203,7 +203,7 @@ F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 243fb37f47dc072fc59839ea241ff0a17c8d76e6 -F src/os_win.c af9db76467add89679d3ebb451069c2f842ecd3c +F src/os_win.c d18f670eeca4ab3da61230628d9042dfa282bd89 F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f @@ -1112,7 +1112,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 2b510614dc6d878bd49eb428f167014f7f2e2568 -R c3304550dc7e156a767f11782ed297f6 -U drh -Z 81bb05c3046a00cec99b12eff1620df6 +P 117fa5fbc9bed1a7b982c8ddc21b7e228905ccb4 +R 381ae7788d46844675761732daa8c2f7 +U mistachkin +Z 423fbd0e140db731445f28d728ebdbaa diff --git a/manifest.uuid b/manifest.uuid index 8f27c878e4..e87cede53b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -117fa5fbc9bed1a7b982c8ddc21b7e228905ccb4 \ No newline at end of file +59708674f66e06c9c31c1a24f2f1c51f0bf4fa3e \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 3cadd036ab..c1b95d565e 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -108,6 +108,14 @@ # define winIsDirSep(a) (((a) == '/') || ((a) == '\\')) #endif +/* +** This macro is used when a local variable is set to a value that is +** [sometimes] not used by the code (e.g. via conditional compilation). +*/ +#ifndef UNUSED_VARIABLE_VALUE +# define UNUSED_VARIABLE_VALUE(x) (void)(x) +#endif + /* ** Returns the string that should be used as the directory separator. */ @@ -358,7 +366,8 @@ const sqlite3_mem_methods *sqlite3MemGetWin32(void); */ #ifdef SQLITE_TEST int sqlite3_os_type = 0; -#else +#elif !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \ + defined(SQLITE_WIN32_HAS_ANSI) && defined(SQLITE_WIN32_HAS_WIDE) static int sqlite3_os_type = 0; #endif @@ -3185,7 +3194,6 @@ static int winDelete(sqlite3_vfs *,const char*,int); static void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){ winShmNode **pp; winShmNode *p; - BOOL bRc; assert( winShmMutexHeld() ); OSTRACE(("SHM-PURGE pid=%lu, deleteFlag=%d\n", osGetCurrentProcessId(), deleteFlag)); @@ -3195,12 +3203,14 @@ static void winShmPurge(sqlite3_vfs *pVfs, int deleteFlag){ int i; if( p->mutex ) sqlite3_mutex_free(p->mutex); for(i=0; inRegion; i++){ - bRc = osUnmapViewOfFile(p->aRegion[i].pMap); + BOOL bRc = osUnmapViewOfFile(p->aRegion[i].pMap); OSTRACE(("SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\n", osGetCurrentProcessId(), i, bRc ? "ok" : "failed")); + UNUSED_VARIABLE_VALUE(bRc); bRc = osCloseHandle(p->aRegion[i].hMap); OSTRACE(("SHM-PURGE-CLOSE pid=%lu, region=%d, rc=%s\n", osGetCurrentProcessId(), i, bRc ? "ok" : "failed")); + UNUSED_VARIABLE_VALUE(bRc); } if( p->hFile.h!=NULL && p->hFile.h!=INVALID_HANDLE_VALUE ){ SimulateIOErrorBenign(1); From a9cb5be49aed9014dfc7fcc74f7bf4bfe62909cf Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 12 Sep 2013 02:09:05 +0000 Subject: [PATCH 5/6] For error log messages generated by the Win32 native allocator, make sure the correct format specifier is used for the value returned by GetLastError(). FossilOrigin-Name: 75a8a8c1b39725d36db627536d0c69401f8e0815 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 121d808050..b4006aefdd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scouple\smore\sharmless\scompiler\swarnings. -D 2013-09-12T01:47:57.395 +C For\serror\slog\smessages\sgenerated\sby\sthe\sWin32\snative\sallocator,\smake\ssure\sthe\scorrect\sformat\sspecifier\sis\sused\sfor\sthe\svalue\sreturned\sby\sGetLastError(). +D 2013-09-12T02:09:05.258 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -203,7 +203,7 @@ F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 243fb37f47dc072fc59839ea241ff0a17c8d76e6 -F src/os_win.c d18f670eeca4ab3da61230628d9042dfa282bd89 +F src/os_win.c 0e73f891dd806b82a76d4e19179c532f02236b86 F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f @@ -1112,7 +1112,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 117fa5fbc9bed1a7b982c8ddc21b7e228905ccb4 -R 381ae7788d46844675761732daa8c2f7 +P 59708674f66e06c9c31c1a24f2f1c51f0bf4fa3e +R 1ed3fe4d70c0b22924a418f004301c6c U mistachkin -Z 423fbd0e140db731445f28d728ebdbaa +Z 0449c470c02ad9774090312d2090be91 diff --git a/manifest.uuid b/manifest.uuid index e87cede53b..85af47ce04 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -59708674f66e06c9c31c1a24f2f1c51f0bf4fa3e \ No newline at end of file +75a8a8c1b39725d36db627536d0c69401f8e0815 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index c1b95d565e..10016ed423 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -1168,7 +1168,7 @@ static void *winMemMalloc(int nBytes){ assert( nBytes>=0 ); p = osHeapAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, (SIZE_T)nBytes); if( !p ){ - sqlite3_log(SQLITE_NOMEM, "failed to HeapAlloc %u bytes (%d), heap=%p", + sqlite3_log(SQLITE_NOMEM, "failed to HeapAlloc %u bytes (%lu), heap=%p", nBytes, osGetLastError(), (void*)hHeap); } return p; @@ -1189,7 +1189,7 @@ static void winMemFree(void *pPrior){ #endif if( !pPrior ) return; /* Passing NULL to HeapFree is undefined. */ if( !osHeapFree(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior) ){ - sqlite3_log(SQLITE_NOMEM, "failed to HeapFree block %p (%d), heap=%p", + sqlite3_log(SQLITE_NOMEM, "failed to HeapFree block %p (%lu), heap=%p", pPrior, osGetLastError(), (void*)hHeap); } } @@ -1215,7 +1215,7 @@ static void *winMemRealloc(void *pPrior, int nBytes){ p = osHeapReAlloc(hHeap, SQLITE_WIN32_HEAP_FLAGS, pPrior, (SIZE_T)nBytes); } if( !p ){ - sqlite3_log(SQLITE_NOMEM, "failed to %s %u bytes (%d), heap=%p", + sqlite3_log(SQLITE_NOMEM, "failed to %s %u bytes (%lu), heap=%p", pPrior ? "HeapReAlloc" : "HeapAlloc", nBytes, osGetLastError(), (void*)hHeap); } @@ -1239,7 +1239,7 @@ static int winMemSize(void *p){ if( !p ) return 0; n = osHeapSize(hHeap, SQLITE_WIN32_HEAP_FLAGS, p); if( n==(SIZE_T)-1 ){ - sqlite3_log(SQLITE_NOMEM, "failed to HeapSize block %p (%d), heap=%p", + sqlite3_log(SQLITE_NOMEM, "failed to HeapSize block %p (%lu), heap=%p", p, osGetLastError(), (void*)hHeap); return 0; } @@ -1269,7 +1269,7 @@ static int winMemInit(void *pAppData){ SQLITE_WIN32_HEAP_MAX_SIZE); if( !pWinMemData->hHeap ){ sqlite3_log(SQLITE_NOMEM, - "failed to HeapCreate (%d), flags=%u, initSize=%u, maxSize=%u", + "failed to HeapCreate (%lu), flags=%u, initSize=%u, maxSize=%u", osGetLastError(), SQLITE_WIN32_HEAP_FLAGS, SQLITE_WIN32_HEAP_INIT_SIZE, SQLITE_WIN32_HEAP_MAX_SIZE); return SQLITE_NOMEM; @@ -1281,7 +1281,7 @@ static int winMemInit(void *pAppData){ pWinMemData->hHeap = osGetProcessHeap(); if( !pWinMemData->hHeap ){ sqlite3_log(SQLITE_NOMEM, - "failed to GetProcessHeap (%d)", osGetLastError()); + "failed to GetProcessHeap (%lu)", osGetLastError()); return SQLITE_NOMEM; } pWinMemData->bOwned = FALSE; @@ -1309,7 +1309,7 @@ static void winMemShutdown(void *pAppData){ #endif if( pWinMemData->bOwned ){ if( !osHeapDestroy(pWinMemData->hHeap) ){ - sqlite3_log(SQLITE_NOMEM, "failed to HeapDestroy (%d), heap=%p", + sqlite3_log(SQLITE_NOMEM, "failed to HeapDestroy (%lu), heap=%p", osGetLastError(), (void*)pWinMemData->hHeap); } pWinMemData->bOwned = FALSE; From c5cd124900f463df0410da7f30e8d47ec07810d5 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 12 Sep 2013 16:50:49 +0000 Subject: [PATCH 6/6] Increase the number of bits available in Expr.flags. Other tweaks aimed at making expression processing more robust. FossilOrigin-Name: 579a512538528cf4bb4381ba393c5d9e7310086b --- manifest | 29 ++++++++++++++------------ manifest.uuid | 2 +- src/attach.c | 2 +- src/expr.c | 54 ++++++++++++++++++++++++------------------------- src/parse.y | 5 +++-- src/resolve.c | 6 +++--- src/select.c | 4 ++-- src/sqliteInt.h | 53 ++++++++++++++++++++++-------------------------- src/walker.c | 2 +- 9 files changed, 77 insertions(+), 80 deletions(-) diff --git a/manifest b/manifest index b4006aefdd..16e249cf48 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\serror\slog\smessages\sgenerated\sby\sthe\sWin32\snative\sallocator,\smake\ssure\sthe\scorrect\sformat\sspecifier\sis\sused\sfor\sthe\svalue\sreturned\sby\sGetLastError(). -D 2013-09-12T02:09:05.258 +C Increase\sthe\snumber\sof\sbits\savailable\sin\sExpr.flags.\s\sOther\stweaks\saimed\sat\nmaking\sexpression\sprocessing\smore\srobust. +D 2013-09-12T16:50:49.178 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -158,7 +158,7 @@ F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 2af0330bb1b601af7a7789bf7229675fd772a083 F src/analyze.c d322972af09e3f8debb45f420dfe3ded142b108b -F src/attach.c eeb8d9d2c791caa0a54a835170ea898e96c2802d +F src/attach.c 4a2b6a6d9b5f9fd55a8b59488ff7929fef73a195 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 2f1987981139bd2f6d8c728d64bf09fb387443c3 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb @@ -172,7 +172,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c 2dc64ca360b7d7da481183ea920a813a0c203c97 -F src/expr.c 33ae44812d25799000dbcfd54bb2142b30cdd049 +F src/expr.c 7f93e51fd7ca0d3ea1be2715a29c86a69e7b1e93 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c be866cd8c4fa6cae98ba33109578fd1a3311ee5b F src/func.c 7650d35651bb0ca903d24f4e5e944bfdaac9f152 @@ -206,7 +206,7 @@ F src/os_unix.c 243fb37f47dc072fc59839ea241ff0a17c8d76e6 F src/os_win.c 0e73f891dd806b82a76d4e19179c532f02236b86 F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c -F src/parse.y 27c6b4138497d6f8360ba7847da6ed48033f957f +F src/parse.y a97566d6da75075589a7c716d1bda14b586cf8da F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222 F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63 @@ -214,14 +214,14 @@ F src/pragma.c 3aa3d8c8623b7b71c5b1bfb72dcc31fb0c25665f F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68 -F src/resolve.c 9d53899cc6e1f4ec0b4632d07e97d57827bf63b9 +F src/resolve.c d336be12493bb376c6756c214379c727cd8c01a8 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c 9239586282bd146ec5843a2cde7d54cd7816cf78 +F src/select.c d96bcdbc2e7de89cb72febeccd232746f67839fd F src/shell.c d920a891ca09b8bd262cced7fb0ab9d723f7a747 F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h 600a1da8ca71c919a1a270146b052a66a128533a +F src/sqliteInt.h e4cb0c8700ca77889570bf30cf75a5c56f297615 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -289,7 +289,7 @@ F src/vdbetrace.c e7ec40e1999ff3c6414424365d5941178966dcbc F src/vtab.c 5a423b042eb1402ef77697d03d6a67378d97bc8d F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 -F src/walker.c 4fa43583d0a84b48f93b1e88f11adf2065be4e73 +F src/walker.c e9e593d5bb798c3e67fc3893dfe7055c9e7d8d74 F src/where.c b5d59b899b85aa03800905ecdc0a17565d51a6ab F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 @@ -1112,7 +1112,10 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 59708674f66e06c9c31c1a24f2f1c51f0bf4fa3e -R 1ed3fe4d70c0b22924a418f004301c6c -U mistachkin -Z 0449c470c02ad9774090312d2090be91 +P 75a8a8c1b39725d36db627536d0c69401f8e0815 +R 14e40117cf5ed4a868935b4adf8b8b0d +T *branch * expr-tuning +T *sym-expr-tuning * +T -sym-trunk * +U drh +Z e578fc31598c846285e1a40bbc280fc4 diff --git a/manifest.uuid b/manifest.uuid index 85af47ce04..5ea118d1db 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -75a8a8c1b39725d36db627536d0c69401f8e0815 \ No newline at end of file +579a512538528cf4bb4381ba393c5d9e7310086b \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 6d965ace65..805305dab6 100644 --- a/src/attach.c +++ b/src/attach.c @@ -509,7 +509,7 @@ int sqlite3FixExpr( Expr *pExpr /* The expression to be fixed to one database */ ){ while( pExpr ){ - if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ) break; + if( ExprHasProperty(pExpr, EP_TokenOnly) ) break; if( ExprHasProperty(pExpr, EP_xIsSelect) ){ if( sqlite3FixSelect(pFix, pExpr->x.pSelect) ) return 1; }else{ diff --git a/src/expr.c b/src/expr.c index 6587ee1f78..82623b14ba 100644 --- a/src/expr.c +++ b/src/expr.c @@ -596,7 +596,7 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){ const char *z; if( pExpr==0 ) return; - assert( !ExprHasAnyProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) ); + assert( !ExprHasProperty(pExpr, EP_IntValue|EP_Reduced|EP_TokenOnly) ); z = pExpr->u.zToken; assert( z!=0 ); assert( z[0]!=0 ); @@ -666,12 +666,12 @@ void sqlite3ExprDelete(sqlite3 *db, Expr *p){ if( p==0 ) return; /* Sanity check: Assert that the IntValue is non-negative if it exists */ assert( !ExprHasProperty(p, EP_IntValue) || p->u.iValue>=0 ); - if( !ExprHasAnyProperty(p, EP_TokenOnly) ){ + if( !ExprHasProperty(p, EP_TokenOnly) ){ + /* The Expr.x union is never used at the same time as Expr.pRight */ + assert( p->x.pList==0 || p->pRight==0 ); sqlite3ExprDelete(db, p->pLeft); sqlite3ExprDelete(db, p->pRight); - if( !ExprHasProperty(p, EP_Reduced) && (p->flags2 & EP2_MallocedToken)!=0 ){ - sqlite3DbFree(db, p->u.zToken); - } + if( ExprHasProperty(p, EP_MemToken) ) sqlite3DbFree(db, p->u.zToken); if( ExprHasProperty(p, EP_xIsSelect) ){ sqlite3SelectDelete(db, p->x.pSelect); }else{ @@ -734,10 +734,10 @@ static int dupedExprStructSize(Expr *p, int flags){ if( 0==(flags&EXPRDUP_REDUCE) ){ nSize = EXPR_FULLSIZE; }else{ - assert( !ExprHasAnyProperty(p, EP_TokenOnly|EP_Reduced) ); + assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); assert( !ExprHasProperty(p, EP_FromJoin) ); - assert( (p->flags2 & EP2_MallocedToken)==0 ); - assert( (p->flags2 & EP2_Irreducible)==0 ); + assert( !ExprHasProperty(p, EP_MemToken) ); + assert( !ExprHasProperty(p, EP_Irreduce) ); if( p->pLeft || p->pRight || p->x.pList ){ nSize = EXPR_REDUCEDSIZE | EP_Reduced; }else{ @@ -834,7 +834,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ } /* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags appropriately. */ - pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static); + pNew->flags &= ~(EP_Reduced|EP_TokenOnly|EP_Static|EP_MemToken); pNew->flags |= nStructSize & (EP_Reduced|EP_TokenOnly); pNew->flags |= staticFlag; @@ -854,7 +854,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ } /* Fill in pNew->pLeft and pNew->pRight. */ - if( ExprHasAnyProperty(pNew, EP_Reduced|EP_TokenOnly) ){ + if( ExprHasProperty(pNew, EP_Reduced|EP_TokenOnly) ){ zAlloc += dupedExprNodeSize(p, flags); if( ExprHasProperty(pNew, EP_Reduced) ){ pNew->pLeft = exprDup(db, p->pLeft, EXPRDUP_REDUCE, &zAlloc); @@ -864,8 +864,7 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags, u8 **pzBuffer){ *pzBuffer = zAlloc; } }else{ - pNew->flags2 = 0; - if( !ExprHasAnyProperty(p, EP_TokenOnly) ){ + if( !ExprHasProperty(p, EP_TokenOnly) ){ pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0); pNew->pRight = sqlite3ExprDup(db, p->pRight, 0); } @@ -1175,7 +1174,7 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){ /* If pWalker->u.i is 3 then any term of the expression that comes from ** the ON or USING clauses of a join disqualifies the expression ** from being considered constant. */ - if( pWalker->u.i==3 && ExprHasAnyProperty(pExpr, EP_FromJoin) ){ + if( pWalker->u.i==3 && ExprHasProperty(pExpr, EP_FromJoin) ){ pWalker->u.i = 0; return WRC_Abort; } @@ -1606,7 +1605,7 @@ int sqlite3FindInIndex(Parse *pParse, Expr *pX, int *prNotFound){ }else{ testcase( pParse->nQueryLoop>0 ); pParse->nQueryLoop = 0; - if( pX->pLeft->iColumn<0 && !ExprHasAnyProperty(pX, EP_xIsSelect) ){ + if( pX->pLeft->iColumn<0 && !ExprHasProperty(pX, EP_xIsSelect) ){ eType = IN_INDEX_ROWID; } } @@ -1675,7 +1674,7 @@ int sqlite3CodeSubselect( ** If all of the above are false, then we can run this code just once ** save the results, and reuse the same result on subsequent invocations. */ - if( !ExprHasAnyProperty(pExpr, EP_VarSelect) ){ + if( !ExprHasProperty(pExpr, EP_VarSelect) ){ testAddr = sqlite3CodeOnce(pParse); } @@ -2615,7 +2614,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ assert( !ExprHasProperty(pExpr, EP_xIsSelect) ); testcase( op==TK_CONST_FUNC ); testcase( op==TK_FUNCTION ); - if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){ + if( ExprHasProperty(pExpr, EP_TokenOnly) ){ pFarg = 0; }else{ pFarg = pExpr->x.pList; @@ -2846,9 +2845,9 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ ** WHEN x=eN THEN rN ELSE y END ** ** X (if it exists) is in pExpr->pLeft. - ** Y is in pExpr->pRight. The Y is also optional. If there is no - ** ELSE clause and no other term matches, then the result of the - ** exprssion is NULL. + ** Y is in the last element of pExpr->x.pList if pExpr->x.pList->nExpr is + ** odd. The Y is also optional. If the number of elements in x.pList + ** is even, then Y is omitted and the "otherwise" result is NULL. ** Ei is in pExpr->pList->a[i*2] and Ri is pExpr->pList->a[i*2+1]. ** ** The result of the expression is the Ri for the first matching Ei, @@ -2869,7 +2868,6 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ VVA_ONLY( int iCacheLevel = pParse->iCacheLevel; ) assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList ); - assert((pExpr->x.pList->nExpr % 2) == 0); assert(pExpr->x.pList->nExpr > 0); pEList = pExpr->x.pList; aListelem = pEList->a; @@ -2891,7 +2889,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){ ** purposes and possibly overwritten. */ regFree1 = 0; } - for(i=0; ipRight ){ + if( (nExpr&1)!=0 ){ sqlite3ExprCachePush(pParse); - sqlite3ExprCode(pParse, pExpr->pRight, target); + sqlite3ExprCode(pParse, pEList->a[nExpr-1].pExpr, target); sqlite3ExprCachePop(pParse, 1); }else{ sqlite3VdbeAddOp2(v, OP_Null, 0, target); @@ -3155,7 +3153,7 @@ void sqlite3ExplainExpr(Vdbe *pOut, Expr *pExpr){ case TK_CONST_FUNC: case TK_FUNCTION: { ExprList *pFarg; /* List of function arguments */ - if( ExprHasAnyProperty(pExpr, EP_TokenOnly) ){ + if( ExprHasProperty(pExpr, EP_TokenOnly) ){ pFarg = 0; }else{ pFarg = pExpr->x.pList; @@ -3821,8 +3819,8 @@ int sqlite3ExprCompare(Expr *pA, Expr *pB, int iTab){ if( pA==0||pB==0 ){ return pB==pA ? 0 : 2; } - assert( !ExprHasAnyProperty(pA, EP_TokenOnly|EP_Reduced) ); - assert( !ExprHasAnyProperty(pB, EP_TokenOnly|EP_Reduced) ); + assert( !ExprHasProperty(pA, EP_TokenOnly|EP_Reduced) ); + assert( !ExprHasProperty(pB, EP_TokenOnly|EP_Reduced) ); if( ExprHasProperty(pA, EP_xIsSelect) || ExprHasProperty(pB, EP_xIsSelect) ){ return 2; } @@ -4036,7 +4034,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ struct SrcList_item *pItem = pSrcList->a; for(i=0; inSrc; i++, pItem++){ struct AggInfo_col *pCol; - assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) ); + assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); if( pExpr->iTable==pItem->iCursor ){ /* If we reach this point, it means that pExpr refers to a table ** that is in the FROM clause of the aggregate query. @@ -4131,7 +4129,7 @@ static int analyzeAggregate(Walker *pWalker, Expr *pExpr){ } /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry */ - assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) ); + assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); ExprSetIrreducible(pExpr); pExpr->iAgg = (i16)i; pExpr->pAggInfo = pAggInfo; diff --git a/src/parse.y b/src/parse.y index e9c8a15635..1e8d7f751c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1081,12 +1081,13 @@ expr(A) ::= expr(W) between_op(N) expr(X) AND expr(Y). [BETWEEN] { /* CASE expressions */ expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). { - A.pExpr = sqlite3PExpr(pParse, TK_CASE, X, Z, 0); + A.pExpr = sqlite3PExpr(pParse, TK_CASE, X, 0, 0); if( A.pExpr ){ - A.pExpr->x.pList = Y; + A.pExpr->x.pList = Z ? sqlite3ExprListAppend(pParse,Y,Z) : Y; sqlite3ExprSetHeight(pParse, A.pExpr); }else{ sqlite3ExprListDelete(pParse->db, Y); + sqlite3ExprDelete(pParse->db, Z); } A.zStart = C.z; A.zEnd = &E.z[E.n]; diff --git a/src/resolve.c b/src/resolve.c index 43a3870e23..54ce3adf54 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -129,7 +129,7 @@ static void resolveAlias( if( !ExprHasProperty(pExpr, EP_IntValue) && pExpr->u.zToken!=0 ){ assert( (pExpr->flags & (EP_Reduced|EP_TokenOnly))==0 ); pExpr->u.zToken = sqlite3DbStrDup(db, pExpr->u.zToken); - pExpr->flags2 |= EP2_MallocedToken; + pExpr->flags |= EP_MemToken; } sqlite3DbFree(db, pDup); } @@ -229,7 +229,7 @@ static int lookupName( assert( pNC ); /* the name context cannot be NULL. */ assert( zCol ); /* The Z in X.Y.Z cannot be NULL */ - assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) ); + assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); /* Initialize the node to no-match */ pExpr->iTable = -1; @@ -591,7 +591,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ pParse = pNC->pParse; assert( pParse==pWalker->pParse ); - if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return WRC_Prune; + if( ExprHasProperty(pExpr, EP_Resolved) ) return WRC_Prune; ExprSetProperty(pExpr, EP_Resolved); #ifndef NDEBUG if( pNC->pSrcList && pNC->pSrcList->nAlloc>0 ){ diff --git a/src/select.c b/src/select.c index 6e409e73a5..f0dbf80918 100644 --- a/src/select.c +++ b/src/select.c @@ -264,7 +264,7 @@ static void addWhereTerm( pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0); if( pEq && isOuterJoin ){ ExprSetProperty(pEq, EP_FromJoin); - assert( !ExprHasAnyProperty(pEq, EP_TokenOnly|EP_Reduced) ); + assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) ); ExprSetIrreducible(pEq); pEq->iRightJoinTable = (i16)pE2->iTable; } @@ -300,7 +300,7 @@ static void addWhereTerm( static void setJoinExpr(Expr *p, int iTable){ while( p ){ ExprSetProperty(p, EP_FromJoin); - assert( !ExprHasAnyProperty(p, EP_TokenOnly|EP_Reduced) ); + assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) ); ExprSetIrreducible(p); p->iRightJoinTable = (i16)iTable; setJoinExpr(p->pLeft, iTable); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f017229f71..7585613621 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -1722,7 +1722,7 @@ typedef int ynVar; struct Expr { u8 op; /* Operation performed by this node */ char affinity; /* The affinity of the column or 0 if not a column */ - u16 flags; /* Various flags. EP_* See below */ + u32 flags; /* Various flags. EP_* See below */ union { char *zToken; /* Token value. Zero terminated and dequoted */ int iValue; /* Non-negative integer value if EP_IntValue */ @@ -1736,8 +1736,8 @@ struct Expr { Expr *pLeft; /* Left subnode */ Expr *pRight; /* Right subnode */ union { - ExprList *pList; /* Function arguments or in " IN ( IN (