default sorting behavior for index

From: Zhihong Yu <zyu(at)yugabyte(dot)com>
To: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: default sorting behavior for index
Date: 2022-09-20 16:34:25
Message-ID: CALNJ-vR1mMREaYb65_Pm722aVNyFhAiLo3mpaHCyMjozaEAWtA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
I was looking at this check in src/backend/parser/parse_utilcmd.c w.r.t.
constraint:

if (indclass->values[i] != defopclass ||
attform->attcollation != index_rel->rd_indcollation[i]
||
attoptions != (Datum) 0 ||
index_rel->rd_indoption[i] != 0)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("index \"%s\" column number %d does not
have default sorting behavior", index_name, i + 1),
errdetail("Cannot create a primary key or
unique constraint using such an index."),

It seems this first came in via `Indexes with INCLUDE columns and their
support in B-tree`

If the index has DESC sorting order, why it cannot be used to back a
constraint ?
Some concrete sample would help me understand this.

Thanks

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-09-20 16:49:46 Re: cataloguing NOT NULL constraints
Previous Message Alvaro Herrera 2022-09-20 16:21:25 Re: A question about wording in messages