diff --git a/dbms/tests/queries/0_stateless/00612_http_max_query_size.reference b/dbms/tests/queries/0_stateless/00612_http_max_query_size.reference new file mode 100644 index 00000000000..4c0bc3caef2 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00612_http_max_query_size.reference @@ -0,0 +1,9 @@ +- +Max query size exceeded +1 +2 +3 +4 +5 +Max query size exceeded +- diff --git a/dbms/tests/queries/0_stateless/00612_http_max_query_size.sh b/dbms/tests/queries/0_stateless/00612_http_max_query_size.sh new file mode 100755 index 00000000000..f24f11b0d68 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00612_http_max_query_size.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. $CURDIR/../shell_config.sh + +echo 'select 1' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL}/?max_query_size=8 -d @- 2>&1 | grep -o "Max query size exceeded" +echo - +echo 'select 1' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL}/?max_query_size=7 -d @- 2>&1 | grep -o "Max query size exceeded" + +echo 'drop table if exists test.tab' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @- +echo 'create table test.tab (key UInt64, val UInt64) engine = MergeTree order by key' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @- +echo 'into test.tab values (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)' | ${CLICKHOUSE_CURL} -sSg "${CLICKHOUSE_URL}/?max_query_size=30&query=insert" -d @- +echo 'select val from test.tab order by val' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @- +echo 'drop table test.tab' | ${CLICKHOUSE_CURL} -sSg ${CLICKHOUSE_URL} -d @- + +echo " +import requests +import os + +url = os.environ['CLICKHOUSE_URL'] +if not url.startswith('http'): + url = 'http://' + url +q = 'select sum(number) from (select * from system.numbers limit 10000000) where number = 0' + +def gen_data(q): + yield q + yield ''.join([' '] * (1024 - len(q))) + + pattern = ''' or toString(number) = '{}'\n''' + + for i in range(1, 4 * 1024): + yield pattern.format(str(i).zfill(1024 - len(pattern) + 2)) + +s = requests.Session() +resp = s.post(url + '/?max_query_size={}'.format(1 << 21), timeout=1, data=gen_data(q), stream=True, + headers = {'Connection': 'close'}) + +for line in resp.iter_lines(): + print line +" | python | grep -o "Max query size exceeded" +echo - +