Re: Fix error message for MERGE foreign tables

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: bt22nakamorit <bt22nakamorit(at)oss(dot)nttdata(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix error message for MERGE foreign tables
Date: 2022-10-14 04:26:19
Message-ID: CAMbWs4_-Gn_gW-36+JW_4wLFi+z6e3SxiHOTyjXZYnHfV8N8Qw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 14, 2022 at 12:07 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

>
> On Fri, Oct 14, 2022 at 10:59 AM bt22nakamorit <
> bt22nakamorit(at)oss(dot)nttdata(dot)com> wrote:
>
>> Hi,
>>
>> MERGE command does not accept foreign tables as targets.
>> When a foreign table is specified as a target, it shows error messages
>> like this:
>>
>> -- ERROR: cannot execute MERGE on relation "child1"
>> -- DETAIL: This operation is not supported for foreign tables.
>>
>> However, when a partitioned table includes foreign tables as partitions
>> and MERGE is executed on the partitioned table, following error message
>> shows.
>>
>> -- ERROR: unexpected operation: 5
>>
>> The latter error message is unclear, and should be the same as the
>> former one.
>> The attached patch adds the code to display error the former error
>> messages in the latter case.
>> Any thoughts?
>
>
> +1. The new message is an improvement to the default one.
>
> I wonder if we can provide more details in the error message, such as
> foreign table name.
>

Maybe something like below, so that we keep it consistent with the case
of a foreign table being specified as a target.

--- a/contrib/postgres_fdw/postgres_fdw.c
+++ b/contrib/postgres_fdw/postgres_fdw.c
@@ -1872,6 +1872,13 @@ postgresPlanForeignModify(PlannerInfo *root,
returningList,
&retrieved_attrs);
break;
+ case CMD_MERGE:
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot execute MERGE on relation \"%s\"",
+ RelationGetRelationName(rel)),
+
errdetail_relkind_not_supported(rel->rd_rel->relkind)));
+ break;

Thanks
Richard

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-10-14 04:29:38 Re: Perform streaming logical transactions by background workers and parallel apply
Previous Message Richard Guo 2022-10-14 04:07:27 Re: Fix error message for MERGE foreign tables