ClickHouse/tests/queries/0_stateless/00955_complex_prepared_statements.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
1.6 KiB
Bash
Raw Normal View History

2019-06-04 18:15:32 +00:00
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
2020-12-28 11:46:53 +00:00
# shellcheck source=../shell_config.sh
2020-08-01 00:51:12 +00:00
. "$CURDIR"/../shell_config.sh
2019-06-04 18:15:32 +00:00
2019-06-16 22:05:43 +00:00
EXCEPTION_TEXT="Code: 457."
2019-06-05 23:31:14 +00:00
2019-06-04 18:15:32 +00:00
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS ps";
$CLICKHOUSE_CLIENT -q "CREATE TABLE ps (
a Array(UInt32), da Array(Array(UInt8)),
t Tuple(Int16, String), dt Tuple(UInt8, Tuple(String, UInt8)),
n Nullable(Date)
) ENGINE = Memory";
$CLICKHOUSE_CLIENT -q "INSERT INTO ps VALUES (
[1, 2], [[1, 1], [2, 2]],
(1, 'Hello'), (1, ('dt', 2)),
NULL)";
$CLICKHOUSE_CLIENT -q "INSERT INTO ps VALUES (
[10, 10, 10], [[10], [10], [10]],
(10, 'Test'), (10, ('dt', 10)),
'2015-02-15')";
2019-06-05 23:31:14 +00:00
$CLICKHOUSE_CLIENT --max_threads=1 --param_aui="[1, 2]" \
2019-06-04 18:15:32 +00:00
-q "SELECT t FROM ps WHERE a = {aui:Array(UInt16)}";
2019-06-05 23:31:14 +00:00
$CLICKHOUSE_CLIENT --max_threads=1 --param_d_a="[[1, 1], [2, 2]]" \
2019-06-04 18:15:32 +00:00
-q "SELECT dt FROM ps WHERE da = {d_a:Array(Array(UInt8))}";
2019-06-05 23:31:14 +00:00
$CLICKHOUSE_CLIENT --max_threads=1 --param_tisd="(10, 'Test')" \
2019-06-04 18:15:32 +00:00
-q "SELECT a FROM ps WHERE t = {tisd:Tuple(Int16, String)}";
2019-06-05 23:31:14 +00:00
$CLICKHOUSE_CLIENT --max_threads=1 --param_d_t="(10, ('dt', 10))" \
2019-06-04 18:15:32 +00:00
-q "SELECT da FROM ps WHERE dt = {d_t:Tuple(UInt8, Tuple(String, UInt8))}";
2019-06-05 23:31:14 +00:00
$CLICKHOUSE_CLIENT --max_threads=1 --param_nd="2015-02-15" \
2019-06-04 18:15:32 +00:00
-q "SELECT * FROM ps WHERE n = {nd:Nullable(Date)}";
2019-06-05 23:31:14 +00:00
# Must throw an exception to avoid SQL injection
$CLICKHOUSE_CLIENT --max_threads=1 --param_injection="[1] OR 1" \
-q "SELECT * FROM ps WHERE a = {injection:Array(UInt32)}" 2>&1 \
2019-06-16 22:05:43 +00:00
| grep -o "$EXCEPTION_TEXT"
2019-06-04 18:15:32 +00:00
$CLICKHOUSE_CLIENT -q "DROP TABLE ps";