Re: PostgreSQL Inheritance and column mapping

From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL Inheritance and column mapping
Date: 2014-10-03 07:49:45
Message-ID: 542E5519.5090300@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 03/10/2014 05:54, Jim Nasby wrote:
> On 10/2/14, 9:00 AM, Tom Lane wrote:
>> Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> writes:
>>> Was there ever any discussion.thought about being able to follow a non-strict by name
>>> column mapping between inherited tables and father tables?
>> No. You could use a view with UNION ALL perhaps.
> FWIW, I've had some less than stellar results with that (admittedly, back on 8.4).
>
> The other thing you could do is something like:
>
> ALTER TABLE invoice_document RENAME TO invoice_document_raw;
> ALTER TABLE invoice_document_raw RENAME invoice_no TO doc_no;
> CREATE VIEW invoice_document AS
> SELECT ...
> , doc_no AS invoice_no
> , ...
> FROM invoice_document_raw
> ;
>
> If you make that view writable then no one needs to know that you renamed the column in the underlying table.

That is a brilliant idea, thank you!
One problem is that the tables are a part of a 100-node replication system base on a heavily hacked
version of DBMirror, over a non-TCPIP Satellite network. That would require rewriting rules
and deploying this across the remote nodes.
I would be afraid to run the ALTER TABLE ... RENAME TO command in this system.
So, we could just bite the bullet and get our team rewrite all programs.

--
Achilleas Mantzios
Head of IT DEV
IT DEPT
Dynacom Tankers Mgmt

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2014-10-03 07:57:08 Re: Getting my Database name in a C Extension
Previous Message Cedric Berger 2014-10-03 07:31:54 Re: Getting my Database name in a C Extension