| From: | Richard Yen <richyen3(at)gmail(dot)com> |
|---|---|
| To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | [PATCH] Clarify CREATE INDEX IF NOT EXISTS output for invalid indexes |
| Date: | 2026-11-07 18:56:56 |
| Message-ID: | CAKH4vDihJL8q9SuqFZkzZcvbvN38y0BZTaYs=_2PJUr8uvsRVA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello Hackers,
I've encountered a number of users (mostly people who do not use a database
on a day-to-day basis, such as consultants and support engineers, and
therefore unfamiliar with the state of the database they're working with)
who have experienced challenges when attempting to use CREATE INDEX IF NOT
EXISTS. Specifically, if the index creation was attempted previously but
failed, the CREATE INDEX IF NOT EXISTS syntax happily reports that the
index exists, but falls short of identifying it as invalid. In more than
one instance, such users lose a fair amount of time wondering why a query
is not choosing the index, only to discover minutes (or hours) later that
it is an invalid index.
As such, I'm proposing a small patch to make the notice from CREATE INDEX
IF NOT EXISTS more informative when the existing index is invalid.
The patch preserves the existing notice and adds detail when the
conflicting relation has pg_index.indisvalid = false:
NOTICE: relation "idx_test" already exists, skipping
DETAIL: The existing index is invalid.
Would this additional detail be useful? Comments on the wording and
approach are welcome.
Thank you for your consideration,
Richard
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Report-invalid-index-in-CREATE-INDEX-IF-NOT-EXISTS.patch | application/octet-stream | 6.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2026-11-07 20:10:57 | Re: ci: Follow-up CI patches |
| Previous Message | Joel Jacobson | 2026-11-07 18:18:43 | Re: Logical Implication |