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