public inbox for [email protected]  
help / color / mirror / Atom feed
From: jian he <[email protected]>
To: Kirill Reshke <[email protected]>
Cc: Amul Sul <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: Error position support for ComputeIndexAttrs
Date: Sun, 4 Jan 2026 12:19:25 +0800
Message-ID: <CACJufxHv13cw9g-mM+skF4JrhAA4dULFvQctwvDpuOL4mwKoRA@mail.gmail.com> (raw)
In-Reply-To: <CALdSSPjm8dB6ypEkivNMQp48U6YRv0VofX7KndS2Nq0DZO+OKg@mail.gmail.com>
References: <CACJufxH3OgXF1hrzGAaWyNtye2jHEmk9JbtrtGv-KJK6tsGo5w@mail.gmail.com>
	<CAAJ_b95FOL6uEUb6p4=ho7Bj=HFBpzhRh5G0G2--YH9qHxt0rw@mail.gmail.com>
	<CACJufxHQLuROz_1MjuvNSp+QgtLfNH_noiq18mZBhB8Mk01_=g@mail.gmail.com>
	<CALdSSPjm8dB6ypEkivNMQp48U6YRv0VofX7KndS2Nq0DZO+OKg@mail.gmail.com>

On Wed, Dec 31, 2025 at 10:37 PM Kirill Reshke <[email protected]> wrote:
>
> 4)  DefineIndex inside ATAddIndex. It is triggered for patterns like
> "alter table t add constraint c unique (ii);" - current patch set
> missing support for them. I tried to pass pstate here, but no success,
> because exprLocation returns -1 in ComputeIndexAttrs. Please see my
> attempt attached. I guess this can be completed to get location
> support, but I do not have any time today.

hi.

This will not work for ``ALTER TABLE t ADD CONSTRAINT c UNIQUE (ii);``.
In this case, gram.y produces a single Constraint node, and Constraint node
contain only one location field. However, a unique location is required for each
IndexElem node.
Simply assigning the same location value to all IndexElem nodes does not seem
worth the effort required to add support for this.

see transformIndexConstraint:
``
foreach(lc, constraint->keys)
{
            /* OK, add it to the index definition */
            iparam = makeNode(IndexElem);
             ........
            iparam->location = -1;
            index->indexParams = lappend(index->indexParams, iparam);
}
``

also
``ALTER TABLE t ADD CONSTRAINT c UNIQUE (ii);``
the Constraint.location is the location of the word "CONSTRAINT",
which is far from the IndexElem location we want to report.


--
jian
https://www.enterprisedb.com






view thread (3+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Error position support for ComputeIndexAttrs
  In-Reply-To: <CACJufxHv13cw9g-mM+skF4JrhAA4dULFvQctwvDpuOL4mwKoRA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox