| 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 13:07:22 | 
| Message-ID: | CAMbWs48rRcdmjj=v7=6HBrBVVEB9_UvE7GbGB3tZQqffWDrgsQ@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On Fri, Oct 14, 2022 at 7:19 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
>
> 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.
>
Or maybe we can make it even earlier, when we expand an RTE for a
partitioned table and add result tables to leaf_result_relids.
--- a/src/backend/optimizer/util/inherit.c
+++ b/src/backend/optimizer/util/inherit.c
@@ -627,6 +627,16 @@ expand_single_inheritance_child(PlannerInfo *root,
RangeTblEntry *parentrte,
      root->leaf_result_relids = bms_add_member(root->leaf_result_relids,
                                                childRTindex);
+     if (parse->commandType == CMD_MERGE &&
+         childrte->relkind == RELKIND_FOREIGN_TABLE)
+     {
+         ereport(ERROR,
+                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                  errmsg("cannot execute MERGE on relation \"%s\"",
+                         RelationGetRelationName(childrel)),
+                  errdetail_relkind_not_supported(childrte->relkind)));
+     }
Thanks
Richard
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bharath Rupireddy | 2022-10-14 13:21:05 | Re: Move backup-related code to xlogbackup.c/.h | 
| Previous Message | Drouvot, Bertrand | 2022-10-14 13:04:34 | Re: Patch proposal: make use of regular expressions for the username in pg_hba.conf |