Update 03221_create_if_not_exists_setting test to a .sql test

This commit is contained in:
Peter Nguyen 2024-08-12 07:42:55 -06:00
parent d31c56e0d9
commit 83d20bee00
2 changed files with 6 additions and 30 deletions

View File

@ -1,43 +1,23 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
SET create_if_not_exists=0; -- Default
# $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 "
CREATE TABLE example_table (id UInt32) ENGINE=MergeTree() ORDER BY id; -- { serverError TABLE_ALREADY_EXISTS }
DROP DATABASE IF EXISTS example_database;
CREATE DATABASE example_database;
CREATE DATABASE example_database;
" 2> /dev/null
echo $?
CREATE DATABASE example_database; -- { serverError DATABASE_ALREADY_EXISTS }
$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 IF EXISTS example_database;
DROP TABLE IF EXISTS example_table;
"
DROP TABLE IF EXISTS example_table;