MERGE command for inheritance - Mailing list pgsql-hackers

From Boxuan Zhai
Subject MERGE command for inheritance
Date
Msg-id AANLkTik34fNx6QSbQP+SB8BTjiCDygsBqSMQqpUHJDFW@mail.gmail.com
Whole thread Raw
Responses Re: MERGE command for inheritance
Re: MERGE command for inheritance
Re: MERGE command for inheritance
List pgsql-hackers
Hi,
 
These days I am considering what else can be done for MERGE, And, I find inheritance tables in postgres is not supported by our MERGE command yet.

Currently, MERGE command is only able to handle the target table itself, and its children tables are not involved in the process.

I am not sure if inheritance of MERGE is needed by postgres. If we need, I may propose two methods for implementing it.
 
An easy way to do it is use a rule-like strategy. We can generate new MERGE query statements with the children table as their target tables. Then the new
query statement will be planned and executed in the normal way. This process can be put in the rewriter, before the queries are planned.
This method is quite easy but seems not follow the tradition of inheritance in Postgres.
 
 
The difficult way is to generate the plans for children table in planner, as the other commands like UPDATE and DELETE. However, because the structure of
MERGE plan is much more complex than the ordinary ModifyTable plans, this job may not as simple as we expected. We need to adjust both the main plan and the
merge actions to fit the children tables, which is not straight forward.
 
I would like to know your opinions on this problem.
 
PS: for my investigation on the inheritance actions, I find that although the children tables are modified by the UPDATE or DELETE commands on their ancestor tables, the rules defined on them are not activated during the query. Is this the case (I hope I am not asking a stupid question)? And, if so, I may ask why we want it to act like this.
 
Boxuan

pgsql-hackers by date:

Previous
From: Boxuan Zhai
Date:
Subject: Re: MERGE Specification
Next
From: David Fetter
Date:
Subject: Re: pg_restore should accept multiple -t switches?