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

From Tom Lane
Subject Re: ALTER TYPE 3: add facility to identify further no-work cases
Date
Msg-id 28474.1296084597@sss.pgh.pa.us
Whole thread Raw
In response to Re: ALTER TYPE 3: add facility to identify further no-work cases  (Noah Misch <noah@leadboat.com>)
Responses Re: ALTER TYPE 3: add facility to identify further no-work cases  (Noah Misch <noah@leadboat.com>)
List pgsql-hackers
Noah Misch <noah@leadboat.com> writes:
> If we hook this into eval_const_expressions, it definitely seems
> cleaner to attach the auxiliary function to the pg_proc.  Otherwise,
> we'd reconstruct which cast led to each function call -- is there even
> enough information available to do so unambiguously?

As far as that goes, yes there is --- otherwise ruleutils would be
unable to reverse-list cast constructs.  IIRC the function call is
marked as being a cast, and you get the source and dest type IDs
from ordinary exprType() inspection.

> For the syntax, then, would a new common_func_opt_item of "WHEN func" fit?

WHEN is appropriate for the restricted CAST case, but it doesn't seem
like le mot juste for a general function option, unless we restrict
the helper function to return boolean which is not what I had in mind.

> That covers fully-removable casts, but ALTER TABLE still needs to identify casts
> that may throw errors but never change the value's binary representation.

I remain completely unexcited about optimizing that case, especially if
it doesn't fit into a general framework.  The bang for the buck ratio
is not good: too much work, too much uglification, too little return.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Jan Urbański
Date:
Subject: Re: Re: [COMMITTERS] pgsql: Get rid of the global variable holding the error state
Next
From: Peter Eisentraut
Date:
Subject: Re: pl/python refactoring