pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <kgrittn@ymail.com>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: t.katsumata1122@gmail.com <t.katsumata1122@gmail.com>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: [BUGS] BUG #8542: Materialized View with another column_name does not work?
Date: Fri, 1 Nov 2013 01:16:47 -0700 (PDT)
Message-ID: <1383293807.9149.YahooMailNeo@web162904.mail.bf1.yahoo.com> (raw)
In-Reply-To: <CAB7nPqSaCFY8HqrLhUJgLmGJxfzDuMtP+Kx0SUUraZp5Mrkw8g@mail.gmail.com>
References: <E1VYBzB-0004BW-K6@wrigleys.postgresql.org>
	<1383258177.17099.YahooMailNeo@web162903.mail.bf1.yahoo.com>
	<CAB7nPqSaCFY8HqrLhUJgLmGJxfzDuMtP+Kx0SUUraZp5Mrkw8g@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

Michael Paquier <michael.paquier@gmail.com> wrote:

> I am not sure that adding a boolean flag introducing a concept
> related to matview inside checkRuleResultList is the best
> approach to solve that. checkRuleResultList is something related
> only to rules, and has nothing related to matviews in it yet.

Well, I was tempted to keep that concept in DefineQueryRewrite()
where the call is made, by calling  the new bool something like
requireColumnNameMatch and not having checkRuleResultList()
continue to use isSelect for that purpose at all. 
DefineQueryRewrite() already references RELKIND_RELATION once,
RELKIND_MATVIEW twice, and RELKIND_VIEW three times, so it would
hardly be introducing a new concept there.  I did it the way I did
in the posted patch because it seemed to more nearly match what Tom
was suggesting.

> I have been pondering myself about this issue, and wouldn't it be
> better to directly enforce targetList in checkRuleResultList call
> at an upper level with the column name list given by users if
> there is any instead of the list of columns of the SELECT query?
>
> After looking closely at the code this looks to be a better
> approach from a general viewpoint. I didn't got the time to write
> a patch but this is the conclusion I reached after some analysis
> at least...

That doesn't sound like something we could back-patch.

Anyway, I'm not sure why that would be better.  We have rewrite
rules on three kinds of relations -- tables, views, and
materialized views.  In general, a materialized view tends to
support the properties of both a view and a table, with a few
points in the rewrite code that need to pay attention to which kind
of relation the rule applies to.  Among the various validations for
the rewrite, this one validation (matching column names) does not
apply to a non-SELECT rule with a RETURNING clause or to a SELECT
rule which populates a materialized view.  If you were to move the
code to exclude this validation for the latter case, wouldn't you
also need to move the validation for the former case?  Where would
you put that?

-- 
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (9+ messages)  latest in thread

Message-ID: <1383293807.9149.YahooMailNeo@web162904.mail.bf1.yahoo.com>
Permalink:  ../1383293807.9149.YahooMailNeo@web162904.mail.bf1.yahoo.com/
Also on:    postgresql.org/message-id/1383293807.9149.YahooMailNeo@web162904.mail.bf1.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: kgrittn@ymail.com, michael.paquier@gmail.com, t.katsumata1122@gmail.com, pgsql-hackers@postgresql.org
  Subject: Re: [BUGS] BUG #8542: Materialized View with another column_name does not work?
  In-Reply-To: <1383293807.9149.YahooMailNeo@web162904.mail.bf1.yahoo.com>
  References: <E1VYBzB-0004BW-K6@wrigleys.postgresql.org> <1383258177.17099.YahooMailNeo@web162903.mail.bf1.yahoo.com> <CAB7nPqSaCFY8HqrLhUJgLmGJxfzDuMtP+Kx0SUUraZp5Mrkw8g@mail.gmail.com> <1383293807.9149.YahooMailNeo@web162904.mail.bf1.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox