ALTER TYPE 3: add facility to identify further no-work cases - Mailing list pgsql-hackers

From Noah Misch
Subject ALTER TYPE 3: add facility to identify further no-work cases
Date
Msg-id 20110109220353.GD5777@tornado.leadboat.com
Whole thread Raw
Responses Re: ALTER TYPE 3: add facility to identify further no-work cases  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Here I add the notion of an "exemptor function", a property of a cast that
determines when calls to the cast would be superfluous.  Such calls can be
removed, reduced to RelabelType expressions, or annotated (via a new field in
FuncExpr) with the applicable exemptions.  I modify various parse_coerce.c
functions to retrieve, call, and act on these exemptor functions; this includes
GetCoerceExemptions() from the last patch.  I did opt to make
find_typmod_coercion_function return COERCION_PATH_RELABELTYPE when no work is
needed, rather than COERCION_PATH_NONE; this makes it consistent with
find_coercion_pathway's use of that enumeration.

To demonstrate the functionality, I add exemptor functions for varchar and xml.
Originally I was only going to start with varchar, but xml tests the other major
code path, and the exemptor function for xml is dead simple.

This helps on conversions like varchar(4)->varchar(8) and text->xml.

Attachment

pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: ALTER TYPE 2: skip already-provable no-work rewrites
Next
From: Noah Misch
Date:
Subject: ALTER TYPE 4: temporal data types