aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manifest18
-rw-r--r--manifest.uuid2
-rw-r--r--src/expr.c75
-rw-r--r--test/check.test30
-rw-r--r--test/checkfault.test41
5 files changed, 119 insertions, 47 deletions
diff --git a/manifest b/manifest
index 8e7cfbf9d..35d331730 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\sWITHOUT\sROWID\stable\slogic\sso\sthat\sit\sgenerates\sa\scorrect\sKeyInfo\nobject\sfor\stables\sthat\shave\sa\sPRIMARY\sKEY\scontaining\sthe\ssame\scolumn\sused\nmore\sthan\sonce\swith\sdifferent\scollating\ssequences.\s\sEnhance\sthe\sindex_xinfo\npragma\sto\sassist\sin\stesting\sthe\sabove.\sFix\sfor\sticket\s[fd3aec0c7e3e2998].
-D 2019-07-17T12:49:16.424
+C When\sprocessing\sa\sBETWEEN\sor\sCASE\sexpression,\savoid\stransforming\sa\snode\sof\sthe\soriginal\sexpression\sinto\sa\sTK_REGISTER\snode.\sInstead,\stake\sa\scopy\sand\suse\sit\sinstead.\sFix\sfor\s[1be72aab9].
+D 2019-07-17T14:34:17.365
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -474,7 +474,7 @@ F src/date.c e1d8ac7102f3f283e63e13867acb0efa33861cf34f0faf4cdbaf9fa7a1eb7041
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
F src/dbstat.c c12833de69cb655751487d2c5a59607e36be1c58ba1f4bd536609909ad47b319
F src/delete.c d08c9e01a2664afd12edcfa3a9c6578517e8ff8735f35509582693adbe0edeaf
-F src/expr.c 896c4576cd88a0dc5b5ae0abd236b507b778105b58744bd8974fac98fc432b4c
+F src/expr.c f1d87bc9f2d0f14df97b768d5a3d4e4e606fbe45372bc9a0cb6a2623d1933e6d
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
F src/fkey.c ab1971900477e93b6aaabf160d2d1c79c06edd9227441ccfaf0de7e7431d7f48
F src/func.c 905c0424900979fade3731b4a271592059425c988cb7d5b245032253712dd7c8
@@ -725,7 +725,8 @@ F test/capi3d.test aba917805573a03deed961a21f07a5a84505ad0a616f7e3fc1508844a15bc
F test/capi3e.test 3d49c01ef2a1a55f41d73cba2b23b5059ec460fe
F test/cast.test 3619f0c58c2e4b2a94aa86e75607e497d34ef40ab74418e71aef7b4ca5155895
F test/cffault.test 9d6b20606afe712374952eec4f8fd74b1a8097ef
-F test/check.test dcc952a127c394ce0de2aa634d26c78207e855327cc63a24d3638ca8fbfa641e
+F test/check.test e6527bed2b5557ffdbf5680765c4ae6fe61e9b68b7ee69a7f776787a4527b5da
+F test/checkfault.test da6cb3d50247169efcb20bdf57863a3ccfa1d27d9e55cd324f0680096970f014
F test/chunksize.test 427d87791743486cbf0c3b8c625002f3255cb3a89c6eba655a98923b1387b760
F test/close.test eccbad8ecd611d974cbf47278c3d4e5874faf02d811338d5d348af42d56d647c
F test/closure01.test 9905883f1b171a4638f98fc764879f154e214a306d3d8daf412a15e7f3a9b1e0
@@ -1836,8 +1837,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P fe014288ac03cdf0dc5410b7d45cad4768759b52746c0a22bce2fc03779c5d5a 340378c1e60da80263523776f4b6366a9d332a7ee25986637e8b157f4e8e4bd3
-R 5f5f2ffbc62c0e7052c26dec78f9d9ee
-T +closed 340378c1e60da80263523776f4b6366a9d332a7ee25986637e8b157f4e8e4bd3
-U drh
-Z a8a117274901c94c5f21fbb39eeada13
+P 84a51a755c18ac8253080db6eec505df894ee3b1e97cfa8e61039ac38001e270
+R b1d6ad05577abecc48e59e3ebea1a6ed
+U dan
+Z f2c9fb7d68d7563adaf07df958f5d837
diff --git a/manifest.uuid b/manifest.uuid
index f902dda7d..02af7a70e 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-84a51a755c18ac8253080db6eec505df894ee3b1e97cfa8e61039ac38001e270 \ No newline at end of file
+7ef7b23cbb1b9ace9f853238d9133320c153e6c3417e6823ab6394ee1fe56358 \ No newline at end of file
diff --git a/src/expr.c b/src/expr.c
index 9ba81a845..56b3148ed 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1087,16 +1087,6 @@ static int exprStructSize(Expr *p){
}
/*
-** Copy the complete content of an Expr node, taking care not to read
-** past the end of the structure for a reduced-size version of the source
-** Expr.
-*/
-static void exprNodeCopy(Expr *pDest, Expr *pSrc){
- memset(pDest, 0, sizeof(Expr));
- memcpy(pDest, pSrc, exprStructSize(pSrc));
-}
-
-/*
** The dupedExpr*Size() routines each return the number of bytes required
** to store a copy of an expression or expression tree. They differ in
** how much of the tree is measured.
@@ -4048,6 +4038,8 @@ expr_code_doover:
Expr opCompare; /* The X==Ei expression */
Expr *pX; /* The X expression */
Expr *pTest = 0; /* X==Ei (form A) or just Ei (form B) */
+ Expr *pDel = 0;
+ sqlite3 *db = pParse->db;
assert( !ExprHasProperty(pExpr, EP_xIsSelect) && pExpr->x.pList );
assert(pExpr->x.pList->nExpr > 0);
@@ -4056,13 +4048,17 @@ expr_code_doover:
nExpr = pEList->nExpr;
endLabel = sqlite3VdbeMakeLabel(pParse);
if( (pX = pExpr->pLeft)!=0 ){
- exprNodeCopy(&tempX, pX);
+ pDel = sqlite3ExprDup(db, pX, 0);
+ if( db->mallocFailed ){
+ sqlite3ExprDelete(db, pDel);
+ break;
+ }
testcase( pX->op==TK_COLUMN );
- exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));
+ exprToRegister(pDel, exprCodeVector(pParse, pDel, &regFree1));
testcase( regFree1==0 );
memset(&opCompare, 0, sizeof(opCompare));
opCompare.op = TK_EQ;
- opCompare.pLeft = &tempX;
+ opCompare.pLeft = pDel;
pTest = &opCompare;
/* Ticket b351d95f9cd5ef17e9d9dbae18f5ca8611190001:
** The value in regFree1 might get SCopy-ed into the file result.
@@ -4090,6 +4086,7 @@ expr_code_doover:
}else{
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
}
+ sqlite3ExprDelete(db, pDel);
sqlite3VdbeResolveLabel(v, endLabel);
break;
}
@@ -4371,40 +4368,44 @@ static void exprCodeBetween(
void (*xJump)(Parse*,Expr*,int,int), /* Action to take */
int jumpIfNull /* Take the jump if the BETWEEN is NULL */
){
- Expr exprAnd; /* The AND operator in x>=y AND x<=z */
+ Expr exprAnd; /* The AND operator in x>=y AND x<=z */
Expr compLeft; /* The x>=y term */
Expr compRight; /* The x<=z term */
- Expr exprX; /* The x subexpression */
int regFree1 = 0; /* Temporary use register */
+ Expr *pDel = 0;
+ sqlite3 *db = pParse->db;
memset(&compLeft, 0, sizeof(Expr));
memset(&compRight, 0, sizeof(Expr));
memset(&exprAnd, 0, sizeof(Expr));
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
- exprNodeCopy(&exprX, pExpr->pLeft);
- exprAnd.op = TK_AND;
- exprAnd.pLeft = &compLeft;
- exprAnd.pRight = &compRight;
- compLeft.op = TK_GE;
- compLeft.pLeft = &exprX;
- compLeft.pRight = pExpr->x.pList->a[0].pExpr;
- compRight.op = TK_LE;
- compRight.pLeft = &exprX;
- compRight.pRight = pExpr->x.pList->a[1].pExpr;
- exprToRegister(&exprX, exprCodeVector(pParse, &exprX, &regFree1));
- if( xJump ){
- xJump(pParse, &exprAnd, dest, jumpIfNull);
- }else{
- /* Mark the expression is being from the ON or USING clause of a join
- ** so that the sqlite3ExprCodeTarget() routine will not attempt to move
- ** it into the Parse.pConstExpr list. We should use a new bit for this,
- ** for clarity, but we are out of bits in the Expr.flags field so we
- ** have to reuse the EP_FromJoin bit. Bummer. */
- exprX.flags |= EP_FromJoin;
- sqlite3ExprCodeTarget(pParse, &exprAnd, dest);
+ pDel = sqlite3ExprDup(db, pExpr->pLeft, 0);
+ if( db->mallocFailed==0 ){
+ exprAnd.op = TK_AND;
+ exprAnd.pLeft = &compLeft;
+ exprAnd.pRight = &compRight;
+ compLeft.op = TK_GE;
+ compLeft.pLeft = pDel;
+ compLeft.pRight = pExpr->x.pList->a[0].pExpr;
+ compRight.op = TK_LE;
+ compRight.pLeft = pDel;
+ compRight.pRight = pExpr->x.pList->a[1].pExpr;
+ exprToRegister(pDel, exprCodeVector(pParse, pDel, &regFree1));
+ if( xJump ){
+ xJump(pParse, &exprAnd, dest, jumpIfNull);
+ }else{
+ /* Mark the expression is being from the ON or USING clause of a join
+ ** so that the sqlite3ExprCodeTarget() routine will not attempt to move
+ ** it into the Parse.pConstExpr list. We should use a new bit for this,
+ ** for clarity, but we are out of bits in the Expr.flags field so we
+ ** have to reuse the EP_FromJoin bit. Bummer. */
+ pDel->flags |= EP_FromJoin;
+ sqlite3ExprCodeTarget(pParse, &exprAnd, dest);
+ }
+ sqlite3ReleaseTempReg(pParse, regFree1);
}
- sqlite3ReleaseTempReg(pParse, regFree1);
+ sqlite3ExprDelete(db, pDel);
/* Ensure adequate test coverage */
testcase( xJump==sqlite3ExprIfTrue && jumpIfNull==0 && regFree1==0 );
diff --git a/test/check.test b/test/check.test
index dcd3c186c..b703c75b0 100644
--- a/test/check.test
+++ b/test/check.test
@@ -495,4 +495,34 @@ do_execsql_test 10.1 {
PRAGMA integrity_check;
} {ok}
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 11.0 {
+ CREATE TABLE t1 (Col0 CHECK(1 COLLATE BINARY BETWEEN 1 AND 1) ) ;
+}
+do_execsql_test 11.1 {
+ INSERT INTO t1 VALUES (NULL);
+}
+do_execsql_test 11.2 {
+ INSERT INTO t1 VALUES (NULL);
+}
+
+do_execsql_test 11.3 {
+ CREATE TABLE t2(b, a CHECK(
+ CASE 'abc' COLLATE nocase WHEN a THEN 1 ELSE 0 END)
+ );
+}
+do_execsql_test 11.4 {
+ INSERT INTO t2(a) VALUES('abc');
+}
+do_execsql_test 11.5 {
+ INSERT INTO t2(b, a) VALUES(1, 'abc'||'');
+}
+do_execsql_test 11.6 {
+ INSERT INTO t2(b, a) VALUES(2, 'abc');
+}
+
+finish_test
+
+
finish_test
diff --git a/test/checkfault.test b/test/checkfault.test
new file mode 100644
index 000000000..3b18a6466
--- /dev/null
+++ b/test/checkfault.test
@@ -0,0 +1,41 @@
+# 2019 July 17
+#
+# 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 contains fault-injection test cases for the
+# sqlite3_db_cacheflush API.
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+set testprefix cffault
+source $testdir/malloc_common.tcl
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1 (Col0 CHECK(1 COLLATE BINARY BETWEEN 1 AND 1) ) ;
+ CREATE TABLE t2(b, a CHECK(
+ CASE 'abc' COLLATE nocase WHEN a THEN 1 ELSE 0 END)
+ );
+}
+
+do_faultsim_test 1.1 -faults oom* -body {
+ execsql { INSERT INTO t1 VALUES ('ABCDEFG') }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+do_faultsim_test 1.2 -faults oom* -body {
+ execsql { INSERT INTO t2(a) VALUES('abc') }
+} -test {
+ faultsim_test_result {0 {}}
+}
+
+
+finish_test