+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 |
+------+------+------+
------------------------------------------------------------------------------------------