Re: unsupportable composite type partition keys
Amit Langote <amitlangote09@gmail.com>
From: Amit Langote <amitlangote09@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-12-19T05:15:34Z
Lists: pgsql-hackers
On Wed, Dec 18, 2019 at 10:38 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Amit Langote <amitlangote09@gmail.com> writes:
> > On Wed, Dec 18, 2019 at 2:12 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> Hm. Seems like the restrictions here ought to be just about the same
> >> as on index columns, no?
>
> > We also need to disallow self-referencing composite type in the case
> > of partitioning, because otherwise it leads to infinite recursion
> > shown in my first email.
>
> My point is basically that CheckAttributeType already covers that
> issue, as well as a lot of others. So why isn't the partitioning
> code using it?
My reason to not use it was that the error message that are produced
are not quite helpful in this case; compare what my patch produces vs.
what one gets with CheckAttributeType("expr", ...):
a int,
b int
) PARTITION BY RANGE (((a, b)));
-ERROR: partition key cannot be of anonymous or self-referencing composite type
-LINE 4: ) PARTITION BY RANGE (((a, b)));
- ^
+ERROR: column "expr" has pseudo-type record
CREATE TABLE partitioned (
a int,
b int
) PARTITION BY RANGE ((row(a, b)));
-ERROR: partition key cannot be of anonymous or self-referencing composite type
-LINE 4: ) PARTITION BY RANGE ((row(a, b)));
- ^
+ERROR: column "expr" has pseudo-type record
CREATE TABLE partitioned (
a int,
b int
) PARTITION BY RANGE ((row(a, b)::partitioned));
-ERROR: partition key cannot be of anonymous or self-referencing composite type
-LINE 4: ) PARTITION BY RANGE ((row(a, b)::partitioned));
- ^
+ERROR: composite type partitioned cannot be made a member of itself
Thanks,
Amit
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