public inbox for [email protected]  
help / color / mirror / Atom feed
From: Peter Eisentraut <[email protected]>
To: pgsql-hackers <[email protected]>
Subject: table inheritance versus column compression and storage settings
Date: Mon, 4 Dec 2023 11:52:43 +0100
Message-ID: <[email protected]> (raw)

I found the way that MergeAttributes() handles column compression and 
storage settings very weird.

For example, I don't understand the purpose of this error:

create table t1 (a int, b text compression pglz);

create table t1a (b text compression lz4) inherits (t1);
...
ERROR:  42804: column "b" has a compression method conflict
DETAIL:  pglz versus lz4

or this:

create table t2 (a int, b text compression lz4);

create table t12 () inherits (t1, t2);
...
ERROR:  column "b" has a compression method conflict
DETAIL:  pglz versus lz4

And we can't override it in the child, per the first example.

But this works:

create table t1a (a int, b text compression lz4);
alter table t1a inherit t1;

Also, you can change the settings in the child using ALTER TABLE ... SET 
COMPRESSION (which is also how pg_dump will represent the above 
constructions), so the restrictions at CREATE TABLE time don't seem to 
make much sense.

Looking at the code, I suspect these rules were just sort of 
copy-and-pasted from the nearby rules for types and collations.  The 
latter are needed so that a table with inheritance children can present 
a logically consistent view of the data.  But compression and storage 
are physical properties that are not logically visible, so every table 
in an inheritance hierarchy can have their own setting.

I think the rules should be approximately like this (both for 
compression and storage):

- A newly created child inherits the settings from the parent.
- A newly created child can override the settings.
- Attaching a child changes nothing.
- When inheriting from multiple parents with different settings, an 
explicit setting in the child is required.

Thoughts?






view thread (2+ messages)

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: table inheritance versus column compression and storage settings
  In-Reply-To: <[email protected]>

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

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