Tarantool development patches archive
 help / color / mirror / Atom feed
From: Eugene Leonovich <gen.work@gmail.com>
To: Nikita Pettik <korablev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH] sql: reset values to be bound after execution
Date: Fri, 3 Apr 2020 23:23:10 +0200	[thread overview]
Message-ID: <CADqioP3VAyY6Y4w2nP6u=u+DOF7Usbn+i4D_QxMy_RrD2edyfw@mail.gmail.com> (raw)
In-Reply-To: <a950d9b0064a61901c71355afa4bf69a8d639545.1585936372.git.korablev@tarantool.org>

[-- Attachment #1: Type: text/plain, Size: 1531 bytes --]

On Fri, Apr 3, 2020 at 8:22 PM Nikita Pettik <korablev@tarantool.org> wrote:

> +execute(s.stmt_id, {{[':a'] = 1}, {[':b'] = 2}});
> + | ---
> + | - metadata:
> + |   - name: :a
> + |     type: integer
> + |   - name: :b
> + |     type: integer
> + |   - name: :c
> + |     type: boolean
> + |   rows:
> + |   - [1, 2, null]
>

I wonder, shouldn't an error be thrown if there are not enough parameters
passed?
I just checked Postgres and MySQL, optional parameters are forbidden on
both systems:

Postgres
------------------------------------------------------------------------------------------
PREPARE foo (int, int, int) AS SELECT $1, $2, $3;
EXECUTE foo(1, 2, 3);
 ?column? | ?column? | ?column?
----------+----------+----------
        1 |        2 |        3
(1 row)

EXECUTE foo(1, 2);
ERROR:  wrong number of parameters for prepared statement "foo"
DETAIL:  Expected 3 parameters but got 2.
------------------------------------------------------------------------------------------

MySQL
------------------------------------------------------------------------------------------
PREPARE foo FROM 'SELECT ?, ?, ?';


SET @a = 1;


SET @b = 2;


SET @c = 3;
EXECUTE foo USING @a, @b, @c;
+------+------+------+
| ?    | ?    | ?    |
+------+------+------+
| 0x31 | 0x32 | 0x33 |
+------+------+------+

EXECUTE foo USING @a, @b;
ERROR 1210 (HY000): Incorrect arguments to EXECUTE
------------------------------------------------------------------------------------------


-- 
Thank you and best regards,
Eugene Leonovich

[-- Attachment #2: Type: text/html, Size: 3008 bytes --]

  parent reply	other threads:[~2020-04-03 21:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03 18:22 Nikita Pettik
2020-04-03 20:07 ` Konstantin Osipov
2020-04-06 11:20   ` Nikita Pettik
2020-04-06 21:27   ` Vladislav Shpilevoy
2020-04-07 11:40     ` Nikita Pettik
2020-04-03 21:23 ` Eugene Leonovich [this message]
2020-04-06 12:15   ` Nikita Pettik

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='CADqioP3VAyY6Y4w2nP6u=u+DOF7Usbn+i4D_QxMy_RrD2edyfw@mail.gmail.com' \
    --to=gen.work@gmail.com \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] sql: reset values to be bound after execution' \
    /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