From 44e3c3b9c6923d4e2c22a9838d96f088cac410e4 Mon Sep 17 00:00:00 2001 From: Ahmet Gedemenli Date: Wed, 21 Jun 2023 15:24:09 +0300 Subject: [PATCH] Improve error message for CREATE SCHEMA .. CREATE TABLE (#7024) Improve error message for CREATE SCHEMA .. CREATE TABLE when enable_schema_based_sharding is enabled. --- src/backend/distributed/commands/schema.c | 9 +++++---- src/test/regress/expected/schema_based_sharding.out | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backend/distributed/commands/schema.c b/src/backend/distributed/commands/schema.c index c16b87fa2..966a264d6 100644 --- a/src/backend/distributed/commands/schema.c +++ b/src/backend/distributed/commands/schema.c @@ -95,10 +95,11 @@ PostprocessCreateSchemaStmt(Node *node, const char *queryString) if (CreateSchemaStmtCreatesTable(createSchemaStmt)) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot create tenant table in CREATE " - "SCHEMA statement"), - errhint("Use CREATE TABLE statement to create " - "tenant tables."))); + errmsg("cannot create distributed schema and table in a " + "single statement"), + errhint("SET citus.enable_schema_based_sharding TO off, " + "or create the schema and table in separate " + "commands."))); } /* diff --git a/src/test/regress/expected/schema_based_sharding.out b/src/test/regress/expected/schema_based_sharding.out index ad456ad8e..00198d7dc 100644 --- a/src/test/regress/expected/schema_based_sharding.out +++ b/src/test/regress/expected/schema_based_sharding.out @@ -314,8 +314,8 @@ WHERE schemaid::regnamespace::text IN ('tenant_1', 'tenant_2'); -- verify that we don't allow creating tenant tables via CREATE SCHEMA command CREATE SCHEMA schema_using_schema_elements CREATE TABLE test_table(a int, b text); -ERROR: cannot create tenant table in CREATE SCHEMA statement -HINT: Use CREATE TABLE statement to create tenant tables. +ERROR: cannot create distributed schema and table in a single statement +HINT: SET citus.enable_schema_based_sharding TO off, or create the schema and table in separate commands. CREATE SCHEMA tenant_4; CREATE TABLE tenant_4.tbl_1(a int, b text); CREATE TABLE tenant_4.tbl_2(a int, b text);