pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
\d+ fails on index on partition
2+ messages / 2 participants
[nested] [flat]

* \d+ fails on index on partition
@ 2018-09-27 20:00  Justin Pryzby <pryzby@telsasoft.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Justin Pryzby @ 2018-09-27 20:00 UTC (permalink / raw)
  To: pgsql-hackers; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>

For indices inherited from relkind=p:

pryzbyj=# CREATE TABLE tt(i int)PARTITION BY RANGE(i);
pryzbyj=# CREATE TABLE tt1 PARTITION OF tt DEFAULT;
pryzbyj=# CREATE INDEX ON tt((0+i));
pryzbyj=# ALTER INDEX tt1_expr_idx ALTER COLUMN 1 SET STATISTICS 123;
pryzbyj=# \d+ tt1_expr_idx 
ERROR:  42809: "tt1_expr_idx" is an index
LOCATION:  heap_open, heapam.c:1305

Failing due to:
********* QUERY **********
SELECT inhparent::pg_catalog.regclass,
  pg_catalog.pg_get_expr(c.relpartbound, inhrelid),
  pg_catalog.pg_get_partition_constraintdef(inhrelid)
FROM pg_catalog.pg_class c JOIN pg_catalog.pg_inherits i ON c.oid = inhrelid
WHERE c.oid = '40129092' AND c.relispartition;
**************************

pg_get_partition_constraintdef() doesn't like being passed a relkind='I',
"ATTACH"ed index, which I guess is included in pg_inherit (commit 8b08f7d48):

pryzbyj=# SELECT inhparent::regclass, inhrelid::regclass, * FROM pg_inherits WHERE inhrelid='tt1_expr_idx'::regclass;
inhparent | tt_expr_idx
inhrelid  | tt1_expr_idx
inhrelid  | 40129092
inhparent | 40129091
inhseqno  | 1

I'll spare you the burden of any fix I might attempt to cobble together.

Justin




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: \d+ fails on index on partition
@ 2018-09-27 20:51  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Justin Pryzby <pryzby@telsasoft.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2018-09-27 20:51 UTC (permalink / raw)
  To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: pgsql-hackers@postgresql.org, Alvaro Herrera <alvherre@2ndquadrant.com>

Justin Pryzby <pryzby@telsasoft.com> writes:
> pg_get_partition_constraintdef() doesn't like being passed a relkind='I',

It'll also fall over if the passed OID isn't a relation at all, which
is also very much not-nice for SQL-exposed inquiry functions.

I'm inclined to fix this by

(1) inventing an lsyscache function to fetch relispartition, which
will have the behavior of returning false for a lookup failure
(which is generally consistent with the behavior of most of the
other lsyscache functions).

(2) replace the if (rel->rd_rel->relispartition) check in
get_partition_qual_relid with a test like if (get_rel_relispartition(relid)),
and don't open the Relation at all unless that succeeds.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-09-27 20:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-09-27 20:00 \d+ fails on index on partition Justin Pryzby <pryzby@telsasoft.com>
2018-09-27 20:51 ` Tom Lane <tgl@sss.pgh.pa.us>

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