Re: unsupportable composite type partition keys
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Langote <amitlangote09@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-12-22T21:51:15Z
Lists: pgsql-hackers
Attachments
- disallow-pseudotype-partition-keys.patch (text/x-diff) patch
- recurse-into-ranges-too.patch (text/x-diff) patch
I wrote: > Now as far as point 1 goes, I think it's not really that awful to use > CheckAttributeType() with a dummy attribute name. The attached > incomplete patch uses "partition key" which causes it to emit errors > like > regression=# create table fool (a int, b int) partition by list ((row(a, b))); > ERROR: column "partition key" has pseudo-type record > I don't think that that's unacceptable. But if we wanted to improve it, > we could imagine adding another flag, say CHKATYPE_IS_PARTITION_KEY, > that doesn't affect CheckAttributeType's semantics, just the wording of > the error messages it throws. Here's a fleshed-out patch that does it like that. While poking at this, I also started to wonder why CheckAttributeType wasn't recursing into ranges, since those are our other kind of container type. And the answer is that it must, because we allow creation of ranges over composite types: regression=# create table foo (f1 int, f2 int); CREATE TABLE regression=# create type foorange as range (subtype = foo); CREATE TYPE regression=# alter table foo add column r foorange; ALTER TABLE Simple things still work on table foo, but surely this is exactly what CheckAttributeType is supposed to be preventing. With the second attached patch you get regression=# alter table foo add column r foorange; ERROR: composite type foo cannot be made a member of itself The second patch needs to go back all the way, the first one only as far as we have partitions. regards, tom lane
Commits
-
Fix CheckAttributeType's handling of collations for ranges.
- f521ef0ae319 9.4.26 landed
- de3d2df75169 10.12 landed
- 74b35eb468dc 13.0 landed
- 742c646c1987 9.6.17 landed
- 65aa155135a5 12.2 landed
- 59047b6d0c93 9.5.21 landed
- 25dc267a1be5 11.7 landed
-
Improve comments in utils/rel.h.
- fbe0232358c1 13.0 landed
-
Allow whole-row Vars to be used in partitioning expressions.
- bb4114a4e2c6 13.0 landed
-
Remove equalPartitionDescs().
- 42f74f49367b 13.0 landed
-
Load relcache entries' partitioning data on-demand, not immediately.
- 5b9312378e2f 13.0 landed
-
Disallow partition key expressions that return pseudo-types.
- ea1205a02a03 10.12 landed
- 7fbb39a967ea 12.2 landed
- 281dd22ac015 11.7 landed
- 39ebb943de9d 13.0 landed
-
Prevent a rowtype from being included in itself via a range.
- 6609c3ad984b 9.5.21 landed
- 4af2531d0393 10.12 landed
- 354d913f9745 9.6.17 landed
- 31dfa40a8341 11.7 landed
- 0d245d13c643 9.4.26 landed
- fc7695891d35 13.0 landed
- 976cb11f6c58 12.2 landed