ALTER TYPE 3: add facility to identify further no-work cases
Noah Misch <noah@leadboat.com>
From: Noah Misch <noah@leadboat.com>
To: pgsql-hackers@postgresql.org
Date: 2011-01-09T22:03:53Z
Lists: pgsql-hackers
Attachments
- at3-exemptor.patch (text/plain) patch
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.