From: Nikita Pettik <korablev@tarantool.org>
To: Eugene Leonovich <gen.work@gmail.com>
Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org
Subject: Re: [Tarantool-patches] [PATCH] sql: reset values to be bound after execution
Date: Mon, 6 Apr 2020 12:15:51 +0000 [thread overview]
Message-ID: <20200406121551.GD20849@tarantool.org> (raw)
In-Reply-To: <CADqioP3VAyY6Y4w2nP6u=u+DOF7Usbn+i4D_QxMy_RrD2edyfw@mail.gmail.com>
On 03 Apr 23:23, Eugene Leonovich wrote:
> 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 guess it works just as it was implemented long ago. Some users may
rely on this 'feature'. So personally I would rather not change it.
> 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
prev parent reply other threads:[~2020-04-06 12:15 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
2020-04-06 12:15 ` Nikita Pettik [this message]
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=20200406121551.GD20849@tarantool.org \
--to=korablev@tarantool.org \
--cc=gen.work@gmail.com \
--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