Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc6c3b3b

Browse files
committed
Remove gratuitous assumptions about what make_modifytable can see.
For no clearly good reason, make_modifytable assumed that itcould not reach its get-the-FDW-info-the-hard-way path in MERGE.It's currently possible to demonstrate that assertion failing,which seems to be due to an upstream planner bug; but there's nogood reason to do it like this at all. Let's apply the principleof separation of concerns and make the MERGE check separately,after getting or not getting the fdwroutine pointer.Per report from Alexander Lakhin. No test case, since I thinkthe potential test condition will go away soon.Discussion:https://postgr.es/m/36bee393-b351-16ac-93b2-d46d83637e45@gmail.com
1 parenta316a3b commitc6c3b3b

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

‎src/backend/optimizer/plan/createplan.c

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7093,38 +7093,36 @@ make_modifytable(PlannerInfo *root, Plan *subplan,
70937093
RelOptInfo*resultRel=root->simple_rel_array[rti];
70947094

70957095
fdwroutine=resultRel->fdwroutine;
7096-
7097-
/*
7098-
* MERGE is not currently supported for foreign tables and we
7099-
* already checked when the table mentioned in the query is
7100-
* foreign; but we can still get here if a partitioned table has a
7101-
* foreign table as partition. Disallow that now, to avoid an
7102-
* uglier error message later.
7103-
*/
7104-
if (operation==CMD_MERGE&&fdwroutine!=NULL)
7105-
{
7106-
RangeTblEntry*rte=root->simple_rte_array[rti];
7107-
7108-
ereport(ERROR,
7109-
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7110-
errmsg("cannot execute MERGE on relation \"%s\"",
7111-
get_rel_name(rte->relid)),
7112-
errdetail_relkind_not_supported(rte->relkind));
7113-
}
7114-
71157096
}
71167097
else
71177098
{
71187099
RangeTblEntry*rte=planner_rt_fetch(rti,root);
71197100

7120-
Assert(rte->rtekind==RTE_RELATION);
7121-
Assert(operation!=CMD_MERGE);
7122-
if (rte->relkind==RELKIND_FOREIGN_TABLE)
7101+
if (rte->rtekind==RTE_RELATION&&
7102+
rte->relkind==RELKIND_FOREIGN_TABLE)
71237103
fdwroutine=GetFdwRoutineByRelId(rte->relid);
71247104
else
71257105
fdwroutine=NULL;
71267106
}
71277107

7108+
/*
7109+
* MERGE is not currently supported for foreign tables. We already
7110+
* checked that when the table mentioned in the query is foreign; but
7111+
* we can still get here if a partitioned table has a foreign table as
7112+
* partition. Disallow that now, to avoid an uglier error message
7113+
* later.
7114+
*/
7115+
if (operation==CMD_MERGE&&fdwroutine!=NULL)
7116+
{
7117+
RangeTblEntry*rte=planner_rt_fetch(rti,root);
7118+
7119+
ereport(ERROR,
7120+
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
7121+
errmsg("cannot execute MERGE on relation \"%s\"",
7122+
get_rel_name(rte->relid)),
7123+
errdetail_relkind_not_supported(rte->relkind));
7124+
}
7125+
71287126
/*
71297127
* Try to modify the foreign table directly if (1) the FDW provides
71307128
* callback functions needed for that and (2) there are no local

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp