From 720f8805f90f94f3026bcc7c2b18c0c479e6d679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=87=E5=BA=B7?= Date: Tue, 27 Jul 2021 20:32:04 +0800 Subject: [PATCH] refactor --- src/Parsers/ASTDatabaseOrNone.cpp | 5 +++++ src/Parsers/ASTDatabaseOrNone.h | 16 ++++++++++++++++ src/Parsers/ParserDatabaseOrNone.cpp | 5 +++++ src/Parsers/ParserDatabaseOrNone.h | 16 ++++++++++++++++ .../01939_user_with_default_database.reference | 2 ++ .../01939_user_with_default_database.sh | 10 ++++++++-- 6 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/Parsers/ASTDatabaseOrNone.cpp create mode 100644 src/Parsers/ASTDatabaseOrNone.h create mode 100644 src/Parsers/ParserDatabaseOrNone.cpp create mode 100644 src/Parsers/ParserDatabaseOrNone.h diff --git a/src/Parsers/ASTDatabaseOrNone.cpp b/src/Parsers/ASTDatabaseOrNone.cpp new file mode 100644 index 00000000000..18cd5c7134d --- /dev/null +++ b/src/Parsers/ASTDatabaseOrNone.cpp @@ -0,0 +1,5 @@ +// +// Created by max_w on 2021/7/27. +// + +#include "ASTDatabaseOrNone.h" diff --git a/src/Parsers/ASTDatabaseOrNone.h b/src/Parsers/ASTDatabaseOrNone.h new file mode 100644 index 00000000000..0c1615c4df9 --- /dev/null +++ b/src/Parsers/ASTDatabaseOrNone.h @@ -0,0 +1,16 @@ +// +// Created by max_w on 2021/7/27. +// + +#ifndef CLICKHOUSE_ASTDATABASEORNONE_H +#define CLICKHOUSE_ASTDATABASEORNONE_H + + + +class ASTDatabaseOrNone { + +}; + + + +#endif //CLICKHOUSE_ASTDATABASEORNONE_H diff --git a/src/Parsers/ParserDatabaseOrNone.cpp b/src/Parsers/ParserDatabaseOrNone.cpp new file mode 100644 index 00000000000..0a1cb6caa6f --- /dev/null +++ b/src/Parsers/ParserDatabaseOrNone.cpp @@ -0,0 +1,5 @@ +// +// Created by max_w on 2021/7/27. +// + +#include "ParserDatabaseOrNone.h" diff --git a/src/Parsers/ParserDatabaseOrNone.h b/src/Parsers/ParserDatabaseOrNone.h new file mode 100644 index 00000000000..7c35b663aab --- /dev/null +++ b/src/Parsers/ParserDatabaseOrNone.h @@ -0,0 +1,16 @@ +// +// Created by max_w on 2021/7/27. +// + +#ifndef CLICKHOUSE_PARSERDATABASEORNONE_H +#define CLICKHOUSE_PARSERDATABASEORNONE_H + + + +class ParserDatabaseOrNone { + +}; + + + +#endif //CLICKHOUSE_PARSERDATABASEORNONE_H diff --git a/tests/queries/0_stateless/01939_user_with_default_database.reference b/tests/queries/0_stateless/01939_user_with_default_database.reference index 4bd73da9c9b..8c8ff7e3007 100644 --- a/tests/queries/0_stateless/01939_user_with_default_database.reference +++ b/tests/queries/0_stateless/01939_user_with_default_database.reference @@ -1,2 +1,4 @@ default db_01939 +CREATE USER u_01939 +CREATE USER u_01939 DEFAULT DATABASE NONE diff --git a/tests/queries/0_stateless/01939_user_with_default_database.sh b/tests/queries/0_stateless/01939_user_with_default_database.sh index 5b865c41e05..6dcd288797b 100755 --- a/tests/queries/0_stateless/01939_user_with_default_database.sh +++ b/tests/queries/0_stateless/01939_user_with_default_database.sh @@ -5,8 +5,8 @@ CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # shellcheck source=../shell_config.sh . "$CUR_DIR"/../shell_config.sh -${CLICKHOUSE_CLIENT_BINARY} --query "drop database if exists db_01939" -${CLICKHOUSE_CLIENT_BINARY} --query "create database db_01939" +${CLICKHOUSE_CLIENT_BINARY} --query "create database if not exists db_01939" +${CLICKHOUSE_CLIENT_BINARY} --query "create database if not exists NONE" #create user by sql ${CLICKHOUSE_CLIENT_BINARY} --query "drop user if exists u_01939" @@ -15,5 +15,11 @@ ${CLICKHOUSE_CLIENT_BINARY} --query "create user u_01939 default database db_01 ${CLICKHOUSE_CLIENT_BINARY} --query "SELECT currentDatabase();" ${CLICKHOUSE_CLIENT_BINARY} --user=u_01939 --query "SELECT currentDatabase();" +${CLICKHOUSE_CLIENT_BINARY} --query "alter user u_01939 default database NONE" +${CLICKHOUSE_CLIENT_BINARY} --query "show create user u_01939" +${CLICKHOUSE_CLIENT_BINARY} --query "alter user u_01939 default database \`NONE\`" +${CLICKHOUSE_CLIENT_BINARY} --query "show create user u_01939" + ${CLICKHOUSE_CLIENT_BINARY} --query "drop user u_01939 " ${CLICKHOUSE_CLIENT_BINARY} --query "drop database db_01939" +${CLICKHOUSE_CLIENT_BINARY} --query "drop database NONE"