On 2019/04/26 23:12, Alvaro Herrera wrote:
> On 2019-Apr-25, Amit Langote wrote:
>
>> BTW, this will need to be back-patched to 11.
>
> Done, thanks for the patch. I added the test in master, but obviously
> it doesn't work in pg11, so I just verified manually that relispartition
> is set correctly.
Thank you.
> I don't think it's worth doing more, though there are
> other things that are affected by a bogus relispartition marking for an
> index (example: creating the index in the last partition that didn't
> have it, should mark the index on parent valid; I think that would fail
> to propagate to upper levels correctly.)
Hmm, I couldn't see any misbehavior for this example:
create table p (a int, b int) partition by list (a);
create table p1 partition of p for values in (1) partition by list (b);
create table p11 partition of p1 for values in (1);
create index on only p (a);
create index on only p1 (a);
alter index p_a_idx attach partition p1_a_idx ;
select relname, relispartition from pg_class where relname like 'p%idx';
relname │ relispartition
──────────┼────────────────
p_a_idx │ f
p1_a_idx │ t
(2 rows)
\d p
Table "public.p"
Column │ Type │ Collation │ Nullable │ Default
────────┼─────────┼───────────┼──────────┼─────────
a │ integer │ │ │
b │ integer │ │ │
Partition key: LIST (a)
Indexes:
"p_a_idx" btree (a) INVALID
Number of partitions: 1 (Use \d+ to list them.)
create index on p11 (a);
alter index p1_a_idx attach partition p11_a_idx ;
select relname, relispartition from pg_class where relname like 'p%idx';
relname │ relispartition
───────────┼────────────────
p_a_idx │ f
p1_a_idx │ t
p11_a_idx │ t
(3 rows)
\d p
Table "public.p"
Column │ Type │ Collation │ Nullable │ Default
────────┼─────────┼───────────┼──────────┼─────────
a │ integer │ │ │
b │ integer │ │ │
Partition key: LIST (a)
Indexes:
"p_a_idx" btree (a)
Number of partitions: 1 (Use \d+ to list them.)
Maybe, because the code path we fixed has nothing to do with this case?
Thanks,
Amit