Add test 03221_create_if_not_exists_setting

This commit is contained in:
Peter Nguyen 2024-08-11 16:01:48 -06:00
parent 2af1134c08
commit cc0412c553
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,4 @@
57
82
0
0

View File

@ -0,0 +1,43 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
# $CLICKHOUSE_CLIENT -mn -q "SET create_if_not_exists=0;" # Default
$CLICKHOUSE_CLIENT -mn -q "
DROP TABLE IF EXISTS example_table;
CREATE TABLE example_table (id UInt32) ENGINE=MergeTree() ORDER BY id;
CREATE TABLE example_table (id UInt32) ENGINE=MergeTree() ORDER BY id;
" 2> /dev/null
# ensure failed error code
echo $?
$CLICKHOUSE_CLIENT -mn -q "
DROP DATABASE IF EXISTS example_database;
CREATE DATABASE example_database;
CREATE DATABASE example_database;
" 2> /dev/null
echo $?
$CLICKHOUSE_CLIENT -mn -q "
SET create_if_not_exists=1;
DROP TABLE IF EXISTS example_table;
CREATE TABLE example_table (id UInt32) ENGINE=MergeTree() ORDER BY id;
CREATE TABLE example_table (id UInt32) ENGINE=MergeTree() ORDER BY id;
"
# ensure successful error code
echo $?
$CLICKHOUSE_CLIENT -mn -q "
SET create_if_not_exists=1;
DROP DATABASE IF EXISTS example_database;
CREATE DATABASE example_database;
CREATE DATABASE example_database;
"
echo $?
$CLICKHOUSE_CLIENT -mn -q "
DROP DATABASE example_database;
DROP TABLE example_table;
"