This commit is contained in:
kssenii 2022-06-24 03:24:54 +02:00
parent 812ab9bd6b
commit 6cb1d60883
2 changed files with 21 additions and 1 deletions

View File

@ -335,7 +335,13 @@ DatabasePtr DatabaseFactory::getImpl(const ASTCreateQuery & create, const String
configuration.password = safeGetLiteralValue<String>(engine_args[3], engine_name);
if (engine_args.size() >= 5)
configuration.schema = safeGetLiteralValue<String>(engine_args[4], engine_name);
{
auto arg_value = engine_args[4]->as<ASTLiteral>()->value;
if (arg_value.getType() == Field::Types::Which::String)
configuration.schema = safeGetLiteralValue<String>(engine_args[4], engine_name);
else
use_table_cache = safeGetLiteralValue<UInt8>(engine_args[4], engine_name);
}
}
if (engine_args.size() >= 6)

View File

@ -320,6 +320,20 @@ def test_predefined_connection_configuration(started_cluster):
cursor.execute("DROP SCHEMA IF EXISTS test_schema CASCADE")
def test_postgres_database_old_syntax(started_cluster):
conn = get_postgres_conn(started_cluster, True)
cursor = conn.cursor()
node1.query(
"""
DROP DATABASE IF EXISTS test_database;
CREATE DATABASE test_database ENGINE = PostgreSQL('postgres1:5432', 'test_database', 'postgres', 'mysecretpassword', 1);
"""
)
create_postgres_table(cursor, "test_table")
assert "test_table" in node1.query("SHOW TABLES FROM test_database")
if __name__ == "__main__":
cluster.start()
input("Cluster created, press any key to destroy...")