From: | Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: [Bug] Inconsistent result for inheritance and FOR UPDATE. |
Date: | 2014-12-12 02:05:45 |
Message-ID: | 548A4D79.3050502@lab.ntt.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
(2014/12/12 10:37), Tom Lane wrote:
> Yeah, this is clearly a thinko: really, nothing in the planner should
> be using get_parse_rowmark(). I looked around for other errors of the
> same type and found that postgresGetForeignPlan() is also using
> get_parse_rowmark(). While that's harmless at the moment because we
> don't support foreign tables as children, it's still wrong. Will
> fix that too.
I don't think we need to fix that too. In order to support that, I'm
proposing to modify postgresGetForeignPlan() in the following way [1]
(see fdw-inh-5.patch).
*** a/contrib/postgres_fdw/postgres_fdw.c
--- b/contrib/postgres_fdw/postgres_fdw.c
***************
*** 824,834 **** postgresGetForeignPlan(PlannerInfo *root,
{
RowMarkClause *rc = get_parse_rowmark(root->parse, baserel->relid);
if (rc)
{
/*
! * Relation is specified as a FOR UPDATE/SHARE target, so handle
! * that.
*
* For now, just ignore any [NO] KEY specification, since (a) it's
* not clear what that means for a remote table that we don't have
--- 824,847 ----
{
RowMarkClause *rc = get_parse_rowmark(root->parse, baserel->relid);
+ /*
+ * It's possible that relation is contained in an inheritance set and
+ * that parent relation is selected FOR UPDATE/SHARE. If so, get the
+ * RowMarkClause for parent relation.
+ */
+ if (rc == NULL)
+ {
+ PlanRowMark *prm = get_plan_rowmark(root->rowMarks, baserel->relid);
+
+ if (prm && prm->rti != prm->prti)
+ rc = get_parse_rowmark(root->parse, prm->prti);
+ }
+
if (rc)
{
/*
! * Relation or parent relation is specified as a FOR UPDATE/SHARE
! * target, so handle that.
*
* For now, just ignore any [NO] KEY specification, since (a) it's
* not clear what that means for a remote table that we don't have
[1] http://www.postgresql.org/message-id/5487BB9D.7070605@lab.ntt.co.jp
Thanks,
Best regards,
Etsuro Fujita
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2014-12-12 02:19:52 | Re: [Bug] Inconsistent result for inheritance and FOR UPDATE. |
Previous Message | Tom Lane | 2014-12-12 01:37:34 | Re: [Bug] Inconsistent result for inheritance and FOR UPDATE. |