Re: Error position support for ComputeIndexAttrs - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Error position support for ComputeIndexAttrs
Date
Msg-id 884405.1767547705@sss.pgh.pa.us
Whole thread Raw
In response to Re: Error position support for ComputeIndexAttrs  (jian he <jian.universality@gmail.com>)
List pgsql-hackers
jian he <jian.universality@gmail.com> 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



pgsql-hackers by date:

Previous
From: Jim Jones
Date:
Subject: Re: libxml2 video about its abandonment
Next
From: Andreas Karlsson
Date:
Subject: Re: Optimize JsonbContainerTypeName by reordering type checks