Re: deparsing utility commands - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: deparsing utility commands
Date
Msg-id 20150820164614.GQ5232@alvherre.pgsql
Whole thread Raw
In response to Re: deparsing utility commands  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
Responses Re: deparsing utility commands  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
List pgsql-hackers
Shulgin, Oleksandr wrote:

> A particularly nasty one is:
> 
> ERROR:  index "cwi_replaced_pkey" does not exist
> 
> The test statement that's causing it is this one:
> 
> ALTER TABLE cwi_test DROP CONSTRAINT cwi_uniq_idx,
> ADD CONSTRAINT cwi_replaced_pkey PRIMARY KEY
> USING INDEX cwi_uniq2_idx;
> 
> Which gets deparsed as:
> 
> ALTER TABLE cwi_test DROP CONSTRAINT cwi_uniq_idx,
> ADD CONSTRAINT cwi_replaced_pkey PRIMARY KEY
> USING INDEX cwi_replaced_pkey;
> 
> The problem is that during constraint transformation, the index is being
> renamed to match the constraint name and at the deparse stage the original
> index name appears to be lost completely...  I haven't figure out if
> there's a way around unless we introduce a new field in IndexStmt
> (originalName?) to cover exactly this corner case.

Oh :-(  Hmm, modifying parse nodes should normally be considered last
resort, and at the same time identifying objects based on names rather
than OIDs is frowned upon.  But I don't see any way to handle this
otherwise.  I'm not sure what's the best solution for this one.

> The updated versions of the core-support patch and the contrib modules are
> attached.

Please try to split things up, or at least don't mix more than it
already is.  For instance, the tsconfig mapping stuff should be its own
patch; we can probably make a case for pushing that on its own.

Also I see you added one caller of EventTriggerInhibitCommandCollection.
I don't like that crap at all and I think we would be better off if we
were able to remove it completely.  Please see whether it's possible to
handle this case in some other way.

You seem to have squashed the patches?  Please keep the split out.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Kevin Burke
Date:
Subject: Annotating pg_dump/pg_restore
Next
From: Peter Geoghegan
Date:
Subject: Re: Using quicksort for every external sort run