From: Nikita Tatunov <hollow653@gmail.com>
To: korablev@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH] sql: xfer optimization issue
Date: Fri, 20 Jul 2018 14:56:58 +0300 [thread overview]
Message-ID: <CAEi+_aoHpmAccjtZz6OS385K_pyq0v20NLMWGyn=CoqUOGiKEw@mail.gmail.com> (raw)
In-Reply-To: <E37E5F64-93FC-4C32-8BAE-E70723B92F25@tarantool.org>
[-- Attachment #1: Type: text/plain, Size: 4392 bytes --]
Hello, Nikita! Thank you for review!
пт, 20 июл. 2018 г. в 6:20, n.pettik <korablev@tarantool.org>:
> 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)) {
>
> AFAIK we don’t use == false comparison. Instead simply use !
> is_rr_action_default.
>
>
Done.
> > 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) {
>
> Flags are usually tested with & operation:
>
> if (pOp->p5 & OPFLAG_XFER_OPT != 0)
>
>
Fixed it.
> > 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
>
> You can simplify it to:
>
> return aftr - bfr;
>
> :)
>
>
True. Fixed it.
> Also
>
> >+ /* The Vdbe we're building*/
> >+ Vdbe *v = sqlite3GetVdbe(pParse);
>
> Use ’struct’ modifier for complex types.
> And put dot at the end of comment.
>
>
Fixed.
diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
index 3c3bf37..4f52fa5 100644
--- a/src/box/sql/insert.c
+++ b/src/box/sql/insert.c
@@ -1869,7 +1869,7 @@ xferOptimization(Parse * pParse, /* Parser context */
* table (tab1) is initially empty.
*/
- /* The Vdbe we're building*/
+ /* The Vdbe struct we're building. */
Vdbe *v = sqlite3GetVdbe(pParse);
iSrc = pParse->nTab++;
iDest = pParse->nTab++;
@@ -1887,7 +1887,7 @@ xferOptimization(Parse * pParse, /* Parser context */
* That block generates code to make that determination.
*/
if (!(onError == ON_CONFLICT_ACTION_ABORT &&
- is_err_action_default == false)) {
+ !is_err_action_default)) {
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iDest, 0);
VdbeCoverage(v);
emptyDestTest = sqlite3VdbeAddOp0(v, OP_Goto);
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index bc169d9..aa7f250 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 == OPFLAG_XFER_OPT) {
+ if ((pOp->p5 & OPFLAG_XFER_OPT) != 0) {
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 29f0efe..05d30c6 100755
--- a/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
+++ b/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
@@ -9,12 +9,7 @@ local function do_xfer_test(test_number, return_code)
test:do_test(
test_name,
function()
- if (aftr - bfr == 1) then
- return {1}
- end
- if (aftr == bfr) then
- return {0}
- end
+ return {aftr - bfr}
end, {
-- <test_name>
return_code
[-- Attachment #2: Type: text/html, Size: 7657 bytes --]
next prev parent reply other threads:[~2018-07-20 11:57 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 15:32 [tarantool-patches] " N.Tatunov
2018-04-18 16:33 ` [tarantool-patches] " Hollow111
2018-04-19 11:22 ` n.pettik
2018-04-19 15:36 ` Hollow111
2018-04-20 1:02 ` n.pettik
2018-04-20 15:09 ` Hollow111
2018-04-20 16:09 ` n.pettik
2018-04-20 17:59 ` Hollow111
2018-04-23 23:40 ` n.pettik
2018-04-27 15:45 ` Hollow111
2018-05-03 22:57 ` n.pettik
2018-05-04 12:54 ` Hollow111
2018-06-28 10:18 ` Alexander Turenko
2018-07-09 15:50 ` Alexander Turenko
2018-07-16 12:54 ` Nikita Tatunov
2018-07-16 13:06 ` n.pettik
2018-07-16 13:20 ` Nikita Tatunov
2018-07-16 18:37 ` Nikita Tatunov
2018-07-16 19:12 ` n.pettik
2018-07-16 21:27 ` Nikita Tatunov
2018-07-18 15:13 ` n.pettik
2018-07-18 20:18 ` Nikita Tatunov
2018-07-19 0:20 ` n.pettik
2018-07-19 17:26 ` Nikita Tatunov
2018-07-20 3:20 ` n.pettik
2018-07-20 11:56 ` Nikita Tatunov [this message]
2018-07-20 16:43 ` n.pettik
2018-07-20 16:58 ` Nikita Tatunov
2018-07-29 1:12 ` Alexander Turenko
2018-07-29 11:23 ` n.pettik
2018-07-29 15:16 ` Alexander Turenko
2018-07-30 18:33 ` Nikita Tatunov
2018-07-30 22:17 ` Alexander Turenko
2018-07-31 11:48 ` Nikita Tatunov
2018-07-31 13:29 ` Alexander Turenko
2018-07-31 17:04 ` Nikita Tatunov
2018-07-31 17:44 ` Alexander Turenko
2018-08-21 16:43 ` Kirill Yukhin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAEi+_aoHpmAccjtZz6OS385K_pyq0v20NLMWGyn=CoqUOGiKEw@mail.gmail.com' \
--to=hollow653@gmail.com \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [PATCH] sql: xfer optimization issue' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox