| From: | Sami Imseih <samimseih(at)gmail(dot)com> |
|---|---|
| To: | Mohamed ALi <moali(dot)pg(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Michael Paquier <michael(at)paquier(dot)xyz> |
| Subject: | Re: [PATCH] doc: Document that invalid indexes are skipped during ATTACH PARTITION |
| Date: | 2026-05-15 19:57:30 |
| Message-ID: | CAA5RZ0vmMCFNR1Dz5foqomrPSzFpwmMsKvX_dE7FhsuNM565rA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
> added logic to skip invalid indexes when ALTER TABLE ... ATTACH
> PARTITION matches partition indexes to the parent table's indexes.
> This prevents choosing an incomplete partitioned index as a match,
> which could create inconsistent partition index trees.
>
> However, this behavior was never documented. A user who has an
> invalid index on a partition (e.g., from a failed CREATE INDEX
> CONCURRENTLY) may be surprised when ATTACH PARTITION silently
> creates a new index instead of attaching the existing one.
Rght.
-- Before ATTACH: index marked invalid
indexrelid | indisvalid
---------------+------------
child_val_idx | f
(1 row)
-- After ATTACH: invalid index skipped, new one created
indexrelid | indisvalid
----------------+------------
child_val_idx | f
child_val_idx1 | t
(2 rows)
The current documentation says "or, if an equivalent index already exists,
it will be attached to the target table's...", but makes no mention that this
equivalent index must be valid. What about we just reinforce that point
in the current lines of documentation. I also think it's better to flip things
around where the positive case of an equivalent index being found goes
first.
```
- For each index in the target table, a corresponding
- one will be created in the attached table; or, if an equivalent
- index already exists, it will be attached to the target table's index,
- as if <command>ALTER INDEX ATTACH PARTITION</command> had been executed.
+ For each index in the target table, if a valid equivalent
+ index already exists in the partition, it will be attached
+ to the target table's index, as if
+ <command>ALTER INDEX ATTACH PARTITION</command> had been executed;
+ otherwise, a corresponding one will be created.
```
What do you think?
--
Sami
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-05-15 20:21:01 | Re: Track skipped tables during autovacuum and autoanalyze |
| Previous Message | Tom Lane | 2026-05-15 19:54:10 | Re: Order of tables dumped by pg_dump |