From c893454bb8f1ff89d43cc099c14b560a5c975630 Mon Sep 17 00:00:00 2001 From: Gokhan Gulbiz Date: Wed, 29 Mar 2023 09:12:24 +0300 Subject: [PATCH] Improve error messages --- src/backend/distributed/commands/table.c | 6 ++++-- src/test/regress/expected/generated_identity.out | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/backend/distributed/commands/table.c b/src/backend/distributed/commands/table.c index 4c32ae50f..ebef80ad5 100644 --- a/src/backend/distributed/commands/table.c +++ b/src/backend/distributed/commands/table.c @@ -3993,10 +3993,12 @@ ErrorIfTableHasUnsupportedIdentityColumn(Oid relationId) if (attributeForm->attidentity && attributeForm->atttypid != INT8OID) { - relation_close(relation, AccessShareLock); + char *qualifiedRelationName = generate_qualified_relation_name(relationId); ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg( - "cannot complete operation on a table with smallint/int identity column"))); + "cannot complete operation on %s with smallint/int identity column", qualifiedRelationName), + errhint( + "Use bigint identity column instead."))); } } diff --git a/src/test/regress/expected/generated_identity.out b/src/test/regress/expected/generated_identity.out index 6500baf57..f47675388 100644 --- a/src/test/regress/expected/generated_identity.out +++ b/src/test/regress/expected/generated_identity.out @@ -21,9 +21,11 @@ CREATE TABLE smallint_identity_column ( a smallint GENERATED BY DEFAULT AS IDENTITY ); SELECT create_distributed_table('smallint_identity_column', 'a'); -ERROR: cannot complete operation on a table with smallint/int identity column +ERROR: cannot complete operation on generated_identities.smallint_identity_column with smallint/int identity column +HINT: Use bigint identity column instead. SELECT create_distributed_table_concurrently('smallint_identity_column', 'a'); -ERROR: cannot complete operation on a table with smallint/int identity column +ERROR: cannot complete operation on generated_identities.smallint_identity_column with smallint/int identity column +HINT: Use bigint identity column instead. SELECT create_reference_table('smallint_identity_column'); ERROR: cannot complete operation on a table with identity column SELECT citus_add_local_table_to_metadata('smallint_identity_column'); @@ -38,9 +40,11 @@ CREATE TABLE int_identity_column ( a int GENERATED BY DEFAULT AS IDENTITY ); SELECT create_distributed_table('int_identity_column', 'a'); -ERROR: cannot complete operation on a table with smallint/int identity column +ERROR: cannot complete operation on generated_identities.int_identity_column with smallint/int identity column +HINT: Use bigint identity column instead. SELECT create_distributed_table_concurrently('int_identity_column', 'a'); -ERROR: cannot complete operation on a table with smallint/int identity column +ERROR: cannot complete operation on generated_identities.int_identity_column with smallint/int identity column +HINT: Use bigint identity column instead. SELECT create_reference_table('int_identity_column'); ERROR: cannot complete operation on a table with identity column SELECT citus_add_local_table_to_metadata('int_identity_column');