From d51461c5d0ea016f08b717ca80433d869dd31fad Mon Sep 17 00:00:00 2001 From: Onur Tirtir Date: Thu, 24 Aug 2023 16:34:35 +0300 Subject: [PATCH] Use correct errorCode for the errors thrown when the db is in recovery --- src/backend/distributed/commands/multi_copy.c | 3 ++- src/backend/distributed/metadata/metadata_cache.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/distributed/commands/multi_copy.c b/src/backend/distributed/commands/multi_copy.c index eeed0a025fe..ec86f3f61ef 100644 --- a/src/backend/distributed/commands/multi_copy.c +++ b/src/backend/distributed/commands/multi_copy.c @@ -425,7 +425,8 @@ EnsureCopyCanRunOnRelation(Oid relationId) */ if (RecoveryInProgress() && WritableStandbyCoordinator) { - ereport(ERROR, (errmsg("COPY command to Citus tables is not allowed in " + ereport(ERROR, (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION), + errmsg("COPY command to Citus tables is not allowed in " "read-only mode"), errhint("All COPY commands to citus tables happen via 2PC, " "and 2PC requires the database to be in a writable state."), diff --git a/src/backend/distributed/metadata/metadata_cache.c b/src/backend/distributed/metadata/metadata_cache.c index 79c21030188..5ccd4a512a8 100644 --- a/src/backend/distributed/metadata/metadata_cache.c +++ b/src/backend/distributed/metadata/metadata_cache.c @@ -354,7 +354,8 @@ EnsureModificationsCanRun(void) { if (RecoveryInProgress() && !WritableStandbyCoordinator) { - ereport(ERROR, (errmsg("writing to worker nodes is not currently allowed"), + ereport(ERROR, (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION), + errmsg("writing to worker nodes is not currently allowed"), errdetail("the database is read-only"))); } @@ -415,7 +416,8 @@ EnsureModificationsCanRunOnRelation(Oid relationId) if (modifiedTableReplicated) { - ereport(ERROR, (errmsg("writing to worker nodes is not currently " + ereport(ERROR, (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION), + errmsg("writing to worker nodes is not currently " "allowed for replicated tables such as reference " "tables or hash distributed tables with replication " "factor greater than 1."),