[Tarantool-patches] [PATCH] sql: reset values to be bound after execution

Eugene Leonovich gen.work at gmail.com
Sat Apr 4 00:23:10 MSK 2020


On Fri, Apr 3, 2020 at 8:22 PM Nikita Pettik <korablev at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20200403/8b600ba4/attachment.html>


More information about the Tarantool-patches mailing list