| From: | jian he <jian(dot)universality(at)gmail(dot)com> |
|---|---|
| To: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
| Cc: | Amul Sul <sulamul(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Error position support for ComputeIndexAttrs |
| Date: | 2026-01-04 04:19:25 |
| Message-ID: | CACJufxHv13cw9g-mM+skF4JrhAA4dULFvQctwvDpuOL4mwKoRA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Dec 31, 2025 at 10:37 PM Kirill Reshke <reshkekirill(at)gmail(dot)com> 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-01-04 04:30:36 | Re: DOC: fixes multiple errors in alter table doc |
| Previous Message | Chao Li | 2026-01-04 03:19:47 | intarray: fix an edge case int32 overflow bug |