Re: Fix error message for MERGE foreign tables

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, bt22nakamorit <bt22nakamorit(at)oss(dot)nttdata(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix error message for MERGE foreign tables
Date: 2022-10-14 11:19:01
Message-ID: CAMbWs4_+c7mBD24XtAyaG-4d7pwqpycHr3VzEOCMgHCuOUEBRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 14, 2022 at 5:24 PM Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
wrote:

> Actually, I hadn't realized that the originally submitted patch had the
> test in postgres_fdw only, but we really want it to catch any FDW, so it
> needs to be somewhere more general. The best place I found to put this
> test is in make_modifytable ... I searched for some earlier place in the
> planner to do it, but couldn't find anything.
>
> So what do people think about this?

Good point. I agree that the test should be in a more general place.

I wonder if we can make it earlier in grouping_planner() just before we
add ModifyTablePath.

--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -1772,6 +1772,17 @@ grouping_planner(PlannerInfo *root, double
tuple_fraction)
/* Build per-target-rel lists needed by ModifyTable */
resultRelations = lappend_int(resultRelations,
resultRelation);
+ if (parse->commandType == CMD_MERGE &&
+ this_result_rel->fdwroutine != NULL)
+ {
+ RangeTblEntry *rte = root->simple_rte_array[resultRelation];
+
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot execute MERGE on relation \"%s\"",
+ get_rel_name(rte->relid)),
+ errdetail_relkind_not_supported(rte->relkind));
+ }

Thanks
Richard

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2022-10-14 11:22:35 Re: New docs chapter on Transaction Management and related changes
Previous Message Bharath Rupireddy 2022-10-14 10:08:20 Re: Improve description of XLOG_RUNNING_XACTS