mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Fix for postgres as well
This commit is contained in:
parent
06229c1ba6
commit
cc7f771093
@ -390,6 +390,7 @@ ASTPtr DatabasePostgreSQL::getCreateTableQueryImpl(const String & table_name, Co
|
||||
|
||||
auto create_table_query = std::make_shared<ASTCreateQuery>();
|
||||
auto table_storage_define = database_engine_define->clone();
|
||||
table_storage_define->as<ASTStorage>()->engine->kind = ASTFunction::Kind::TABLE_ENGINE;
|
||||
create_table_query->set(create_table_query->storage, table_storage_define);
|
||||
|
||||
auto columns_declare_list = std::make_shared<ASTColumns>();
|
||||
|
@ -187,6 +187,7 @@ ASTPtr DatabaseSQLite::getCreateTableQueryImpl(const String & table_name, Contex
|
||||
}
|
||||
auto table_storage_define = database_engine_define->clone();
|
||||
ASTStorage * ast_storage = table_storage_define->as<ASTStorage>();
|
||||
ast_storage->engine->kind = ASTFunction::Kind::TABLE_ENGINE;
|
||||
auto storage_engine_arguments = ast_storage->engine->arguments;
|
||||
auto table_id = storage->getStorageID();
|
||||
/// Add table_name to engine arguments
|
||||
|
@ -1022,6 +1022,7 @@ def test_memory_leak(started_cluster):
|
||||
clickhouse_node.query("DROP DATABASE test_database")
|
||||
clickhouse_node.restart_clickhouse()
|
||||
|
||||
|
||||
def test_password_leak(started_cluster):
|
||||
with contextlib.closing(
|
||||
MySQLNodeInstance(
|
||||
@ -1038,4 +1039,6 @@ def test_password_leak(started_cluster):
|
||||
clickhouse_node.query(
|
||||
"CREATE DATABASE test_database ENGINE = MySQL('mysql57:3306', 'test_database', 'root', 'clickhouse') SETTINGS connection_auto_close = 1"
|
||||
)
|
||||
assert "clickhouse" not in clickhouse_node.query("SHOW CREATE test_database.test_table")
|
||||
assert "clickhouse" not in clickhouse_node.query(
|
||||
"SHOW CREATE test_database.test_table"
|
||||
)
|
||||
|
@ -400,6 +400,36 @@ def test_datetime(started_cluster):
|
||||
assert "DateTime64(6)" in node1.query("show create table pg.test")
|
||||
|
||||
|
||||
def test_postgresql_password_leak(started_cluster):
|
||||
conn = get_postgres_conn(
|
||||
started_cluster.postgres_ip, started_cluster.postgres_port, database=True
|
||||
)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("CREATE SCHEMA test_schema")
|
||||
cursor.execute("CREATE TABLE test_schema.table1 (a integer)")
|
||||
cursor.execute("CREATE TABLE table2 (a integer)")
|
||||
|
||||
node1.query(
|
||||
"CREATE DATABASE postgres_database ENGINE = PostgreSQL('postgres1:5432', 'postgres_database', 'postgres', 'mysecretpassword', 'test_schema')"
|
||||
)
|
||||
|
||||
node1.query(
|
||||
"CREATE DATABASE postgres_database2 ENGINE = PostgreSQL('postgres1:5432', 'postgres_database', 'postgres', 'mysecretpassword')"
|
||||
)
|
||||
|
||||
assert "mysecretpassword" not in node1.query("SHOW CREATE postgres_database.table1")
|
||||
assert "mysecretpassword" not in node1.query(
|
||||
"SHOW CREATE postgres_database2.table2"
|
||||
)
|
||||
|
||||
node1.query("DROP DATABASE postgres_database")
|
||||
node1.query("DROP DATABASE postgres_database2")
|
||||
|
||||
cursor.execute("DROP SCHEMA test_schema CASCADE")
|
||||
cursor.execute("DROP TABLE table2")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cluster.start()
|
||||
input("Cluster created, press any key to destroy...")
|
||||
|
Loading…
Reference in New Issue
Block a user