From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, Jesper Pedersen <jesper(dot)pedersen(at)redhat(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Maksim Milyutin <milyutinma(at)gmail(dot)com>, Jaime Casanova <jaime(dot)casanova(at)2ndquadrant(dot)com> |
Subject: | Re: [HACKERS] Proposal: Local indexes for partitioned table |
Date: | 2018-01-24 16:20:06 |
Message-ID: | 20180124162006.pmapfiznhgngwtjf@alvherre.pgsql |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David Rowley wrote:
> 10. You've added code to get_relation_info() to handle partitioned
> indexes, but that code is skipped due to:
>
> /*
> * Make list of indexes. Ignore indexes on system catalogs if told to.
> * Don't bother with indexes for an inheritance parent, either.
> */
> if (inhparent ||
>
> The new code should either be removed, or you should load the index
> list for a partitioned table.
I realized that this wasn't an oversight after all. You can invoke this
code, and it fails in current master:
CREATE TABLE at_partitioned (col1 INT) PARTITION BY RANGE (col1);
CREATE INDEX ON at_partitioned (col1);
CREATE TABLE at_regular2 (col2 INT);
SELECT col2 FROM at_regular2 fk LEFT OUTER JOIN at_partitioned pk ON (col1 = col2);
fails with:
ERROR: could not open file "base/16384/16395": No such file or directory
where the mentioned path corresponds to the index filenode:
alvherre=# select oid::regclass, relkind from pg_class where relfilenode = '16395';
oid │ relkind
─────────────────────────┼─────────
at_partitioned_col1_idx │ I
(1 fila)
The error comes from get_relation_info called for at_partitioned, where the
rte->inh flag is false. So this is the correct behavior: we consider the
table on its own, not as an inheritance parent, and so the code is not skipped.
Backtrace:
(gdb) bt
#0 errfinish (dummy=0)
at /pgsql/source/master/src/backend/utils/error/elog.c:414
#1 0x0000564936f79365 in mdopen (reln=<optimized out>,
forknum=forknum(at)entry=MAIN_FORKNUM, behavior=behavior(at)entry=1)
at /pgsql/source/master/src/backend/storage/smgr/md.c:606
#2 0x0000564936f7983b in mdopen (behavior=1, forknum=MAIN_FORKNUM,
reln=0x5649382f8dd0)
at /pgsql/source/master/src/backend/storage/smgr/md.c:922
#3 mdnblocks (reln=0x5649382f8dd0, forknum=MAIN_FORKNUM)
at /pgsql/source/master/src/backend/storage/smgr/md.c:875
#4 0x0000564936eeb6ea in get_relation_info (root=root(at)entry=0x5649382ef398,
relationObjectId=16385, inhparent=<optimized out>,
rel=rel(at)entry=0x5649382f0198)
at /pgsql/source/master/src/backend/optimizer/util/plancat.c:377
#5 0x0000564936eeee55 in build_simple_rel (root=root(at)entry=0x5649382ef398,
relid=2, parent=parent(at)entry=0x0)
at /pgsql/source/master/src/backend/optimizer/util/relnode.c:182
#6 0x0000564936ec6f23 in add_base_rels_to_query (
root=root(at)entry=0x5649382ef398, jtnode=<optimized out>)
at /pgsql/source/master/src/backend/optimizer/plan/initsplan.c:113
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-01-24 16:47:31 | Re: [HACKERS] Patch: Add --no-comments to skip COMMENTs with pg_dump |
Previous Message | John Scalia | 2018-01-24 16:07:21 | Documentation update |