Several minor remarks.
@@ -1885,12 +1881,11 @@ xferOptimization(Parse * pParse, /* Parser
context */
/*
* Xfer optimization is unable to correctly insert data
- * in case there's a conflict action other than *_ABORT.
- * This is the reason we want to only run it if the
- * destination table is initially empty.
+ * in case there's a conflict action other than
+ * explicit *_ABORT. This is the reason we want to only
+ * run it if the destination table is initially empty.
* That block generates code to make that determination.
*/
-
if (!(onError == ON_CONFLICT_ACTION_ABORT &&
is_err_action_default == false)) {
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0);
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 5f9bc13..bc169d9 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -4009,7 +4009,7 @@ case OP_RowData: {
u32 n;
#ifdef SQLITE_TEST
- if (pOp->p5 == 1) {
+ if (pOp->p5 == OPFLAG_XFER_OPT) {
pOp->p5 = 0;
sql_xfer_count++;
}
diff --git a/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
b/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
index 34f603f..29f0efe 100755
--- a/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
+++ b/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
@@ -1,9 +1,29 @@
+local function do_xfer_test(test_number, return_code)
+ test_name = string.format("xfer-optimization-1.%d", test_number)
+ test:do_test(
+ test_name,
+ function()
+ if (aftr - bfr == 1) then
+ return {1}
+ end
+ if (aftr == bfr) then
+ return {0}
+ end
+ /* The Vdbe we're building*/
+ Vdbe *v = sqlite3GetVdbe(pParse);