Improve error message for CREATE SCHEMA .. CREATE TABLE (#7024)

Improve error message for CREATE SCHEMA .. CREATE TABLE when
enable_schema_based_sharding is enabled.
create_schema_elements
Ahmet Gedemenli 2023-06-21 15:24:09 +03:00 committed by GitHub
parent 565c5260fd
commit 44e3c3b9c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -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.")));
}
/*

View File

@ -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);