jian he <[email protected]> writes:
> 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.

Yeah, the actual problem is that the column name(s) in Constraint are
just a list of String nodes without per-name locations.
transformIndexConstraint throws some errors using constraint->location
that really ought to point at an individual column name, so there's
room for improvement there, as seen in this example from the
regression tests:

-- UNIQUE with a range column/PERIOD that isn't there:
CREATE TABLE temporal_rng3 (
  id INTEGER,
  CONSTRAINT temporal_rng3_uq UNIQUE (id, valid_at WITHOUT OVERLAPS)
);
ERROR:  column "valid_at" named in key does not exist
LINE 3:   CONSTRAINT temporal_rng3_uq UNIQUE (id, valid_at WITHOUT O...
          ^

But this seems like material for a separate patch.

                        regards, tom lane


Reply via email to