mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Disallow usage of --query and --queries-file
This commit is contained in:
parent
3a3cee586a
commit
8574559e23
@ -1180,6 +1180,9 @@ void Client::processOptions(const OptionsDescription & options_description,
|
||||
|
||||
void Client::processConfig()
|
||||
{
|
||||
if (config().has("query") && config().has("queries-file"))
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Options '--query' and '--queries-file' cannot be specified at the same time");
|
||||
|
||||
/// Batch mode is enabled if one of the following is true:
|
||||
/// - -q (--query) command line option is present.
|
||||
/// The value of the option is used as the text of query (or of multiple queries).
|
||||
|
@ -516,12 +516,12 @@ void LocalServer::updateLoggerLevel(const String & logs_level)
|
||||
|
||||
void LocalServer::processConfig()
|
||||
{
|
||||
if (config().has("query") && config().has("queries-file"))
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Options '--query' and '--queries-file' cannot be specified at the same time");
|
||||
|
||||
delayed_interactive = config().has("interactive") && (config().has("query") || config().has("queries-file"));
|
||||
if (is_interactive && !delayed_interactive)
|
||||
{
|
||||
if (config().has("query") && config().has("queries-file"))
|
||||
throw Exception(ErrorCodes::BAD_ARGUMENTS, "Specify either `query` or `queries-file` option");
|
||||
|
||||
if (config().has("multiquery"))
|
||||
is_multiquery = true;
|
||||
}
|
||||
|
@ -4,3 +4,7 @@
|
||||
3
|
||||
1 2
|
||||
3 4
|
||||
BAD_ARGUMENTS
|
||||
BAD_ARGUMENTS
|
||||
BAD_ARGUMENTS
|
||||
BAD_ARGUMENTS
|
||||
|
@ -5,20 +5,29 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
echo "SELECT 1;" > 01523_client_local_queries_file_parameter_tmp.sql
|
||||
$CLICKHOUSE_CLIENT --queries-file=01523_client_local_queries_file_parameter_tmp.sql 2>&1
|
||||
## Use process ID ($$) for uniqueness of file name
|
||||
TEMP_SQL_FILE_NAME=$"01523_client_local_queries_file_parameter_tmp_$$.sql"
|
||||
echo "SELECT 1;" > "$TEMP_SQL_FILE_NAME"
|
||||
$CLICKHOUSE_CLIENT --queries-file="$TEMP_SQL_FILE_NAME" 2>&1
|
||||
|
||||
echo "CREATE TABLE 01523_test(value Int32) ENGINE=Log;
|
||||
INSERT INTO 01523_test
|
||||
VALUES (1), (2), (3);
|
||||
SELECT * FROM 01523_test;
|
||||
DROP TABLE 01523_test;" > 01523_client_local_queries_file_parameter_tmp.sql
|
||||
$CLICKHOUSE_CLIENT --queries-file=01523_client_local_queries_file_parameter_tmp.sql 2>&1
|
||||
DROP TABLE 01523_test;" > "$TEMP_SQL_FILE_NAME"
|
||||
$CLICKHOUSE_CLIENT --queries-file="$TEMP_SQL_FILE_NAME" 2>&1
|
||||
|
||||
echo "CREATE TABLE 01523_test (a Int64, b Int64) ENGINE = File(CSV, stdin);
|
||||
SELECT a, b FROM 01523_test;
|
||||
DROP TABLE 01523_test;" > 01523_client_local_queries_file_parameter_tmp.sql
|
||||
DROP TABLE 01523_test;" > "$TEMP_SQL_FILE_NAME"
|
||||
|
||||
echo -e "1,2\n3,4" | $CLICKHOUSE_LOCAL --queries-file=01523_client_local_queries_file_parameter_tmp.sql 2>&1
|
||||
echo -e "1,2\n3,4" | $CLICKHOUSE_LOCAL --queries-file="$TEMP_SQL_FILE_NAME" 2>&1
|
||||
|
||||
rm 01523_client_local_queries_file_parameter_tmp.sql
|
||||
# Simultaneously passing --queries-file + --query is prohibited.
|
||||
echo "SELECT 1;" > "$TEMP_SQL_FILE_NAME"
|
||||
$CLICKHOUSE_LOCAL --queries-file="$TEMP_SQL_FILE_NAME" -q "SELECT 1;" 2>&1 | grep -o 'BAD_ARGUMENTS'
|
||||
$CLICKHOUSE_CLIENT --queries-file="$TEMP_SQL_FILE_NAME" -q "SELECT 2;" 2>&1 | grep -o 'BAD_ARGUMENTS'
|
||||
$CLICKHOUSE_LOCAL --queries-file="$TEMP_SQL_FILE_NAME" --query "SELECT 3;" 2>&1 | grep -o 'BAD_ARGUMENTS'
|
||||
$CLICKHOUSE_CLIENT --queries-file="$TEMP_SQL_FILE_NAME" --query "SELECT 4;" 2>&1 | grep -o 'BAD_ARGUMENTS'
|
||||
|
||||
rm "$TEMP_SQL_FILE_NAME"
|
||||
|
@ -8,6 +8,8 @@ Empty query
|
||||
BAD_ARGUMENTS
|
||||
BAD_ARGUMENTS
|
||||
BAD_ARGUMENTS
|
||||
BAD_ARGUMENTS
|
||||
BAD_ARGUMENTS
|
||||
Bad arguments
|
||||
Bad arguments
|
||||
Bad arguments
|
||||
|
@ -13,6 +13,10 @@ $CLICKHOUSE_LOCAL --multiquery "SELECT 200; S" 2>&1 | grep -o 'Syntax error'
|
||||
$CLICKHOUSE_LOCAL --multiquery "; SELECT 201;" 2>&1 | grep -o 'Empty query'
|
||||
$CLICKHOUSE_LOCAL --multiquery "; S; SELECT 202" 2>&1 | grep -o 'Empty query'
|
||||
|
||||
# Simultaneously passing --queries-file + --query (multiquery) is prohibited.
|
||||
$CLICKHOUSE_LOCAL --queries-file "queries.csv" --multiquery "SELECT 250;" 2>&1 | grep -o 'BAD_ARGUMENTS'
|
||||
$CLICKHOUSE_CLIENT --queries-file "queries.csv" --multiquery "SELECT 251;" 2>&1 | grep -o 'BAD_ARGUMENTS'
|
||||
|
||||
# Error expectation cases.
|
||||
# -n <SQL> is prohibited
|
||||
$CLICKHOUSE_LOCAL -n "SELECT 301" 2>&1 | grep -o 'BAD_ARGUMENTS'
|
||||
|
Loading…
Reference in New Issue
Block a user