Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 1/1] sql: disallow returning many rows from subselect
Date: Mon, 2 Jul 2018 17:14:26 +0300	[thread overview]
Message-ID: <1ea436b1-2471-2b8a-8223-c12095308994@tarantool.org> (raw)
In-Reply-To: <7ba69010-2e21-9e4f-d923-4061ddecf4cf@tarantool.org>

> And I have pushed more minor fixes on the branch. Please,
> squash.
Ok, tnx.

> 1. How can it be != NULL?
If user has manually wrote LIMIT expression,
like this
SELECT b FROM t1 WHERE a = (SELECT a FROM t1 WHERE b=6 LIMIT 1);
or this
SELECT b FROM t1 WHERE a = (SELECT a FROM t1 WHERE b=6 LIMIT (SELECT b-1 FROM t1 WHERE a =1));

> 2. ExprSerProperty does not check for pSel->pLimit == NULL, so it crashes on
> OOM.
-                               ExprSetProperty(pSel->pLimit, EP_System);
+                               if (pSel->pLimit != NULL) {
+                                       ExprSetProperty(pSel->pLimit,
+                                                       EP_System);
+                               }

(If pLimit is NULL sqlite3Select returns with -1 at the beginning).

> 3. I do not see where do you set an appropriate error code (p5).
> 4. Same.
@@ -2145,6 +2145,7 @@ computeLimitRegisters(Parse * pParse, Select * p, int iBreak)
                                sqlite3VdbeAddOp4(v, OP_Halt,
                                                  SQL_TARANTOOL_ERROR,
                                                  0, 0, error, P4_STATIC);
+                               sqlite3VdbeChangeP5(v, ER_SQL_EXECUTE);
                                sqlite3VdbeResolveLabel(v, no_err);
                                sqlite3ReleaseTempReg(pParse, r1);
 
@@ -5452,6 +5453,7 @@ vdbe_code_raise_on_multiple_rows(struct Parse *parser, int limit_reg, int end_ma
        sqlite3VdbeAddOp4(v, OP_Halt, SQL_TARANTOOL_ERROR,
                          ON_CONFLICT_ACTION_FAIL, 0,
                          error, P4_STATIC);
+       sqlite3VdbeChangeP5(v, SQL_TARANTOOL_ERROR);


> 5. Why do you have two runtime checks for the same auto limit?
There are in totally different branches, with no intersection on runtime checks.
The prev. one make return few lines bellow vdbe_code_raise_on_multiple_rows.

> 6. Why not 0x20000?
No reason.
-#define SF_SingleRow      0x40000
+#define SF_SingleRow      0x20000

  reply	other threads:[~2018-07-02 14:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 11:55 [tarantool-patches] [PATCH v1 " Kirill Shcherbatov
2018-06-19 17:56 ` [tarantool-patches] " n.pettik
2018-06-27 15:30   ` [tarantool-patches] [PATCH v2 " Kirill Shcherbatov
2018-06-27 15:40   ` Kirill Shcherbatov
2018-06-28 13:04     ` [tarantool-patches] " n.pettik
2018-06-28 17:08       ` Kirill Shcherbatov
2018-06-29 13:15         ` n.pettik
2018-07-02  7:17           ` Kirill Shcherbatov
2018-07-02  8:45             ` n.pettik
2018-07-02 13:30               ` Vladislav Shpilevoy
2018-07-02 14:14                 ` Kirill Shcherbatov [this message]
2018-07-02 14:42                   ` Vladislav Shpilevoy
2018-07-02 14:52                     ` Kirill Shcherbatov
2018-07-02 17:58                       ` Vladislav Shpilevoy
2018-07-03  8:06 ` [tarantool-patches] Re: [PATCH v1 " 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=1ea436b1-2471-2b8a-8223-c12095308994@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH v2 1/1] sql: disallow returning many rows from subselect' \
    /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