plpgsql's exec_simple_cast_value() mistakenly supposed that it could bypass
casting effort whenever the input value was NULL. However this prevents application of not-null domain constraints in the cases that use this function, as illustrated in bug #4741. Since this function isn't meant for use in performance-critical paths anyway, this certainly seems like another case of "premature optimization is the root of all evil". Back-patch as far as 8.2; older versions made no effort to enforce domain constraints here anyway.
This commit is contained in:
parent
591cbf673b
commit
5dde1db4e1
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.202.2.4 2009/02/27 10:27:33 heikki Exp $
|
||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.202.2.5 2009/04/02 01:16:17 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -4544,8 +4544,6 @@ exec_simple_cast_value(Datum value, Oid valtype,
|
||||
Oid reqtype, int32 reqtypmod,
|
||||
bool isnull)
|
||||
{
|
||||
if (!isnull)
|
||||
{
|
||||
if (valtype != reqtype || reqtypmod != -1)
|
||||
{
|
||||
Oid typinput;
|
||||
@ -4564,7 +4562,6 @@ exec_simple_cast_value(Datum value, Oid valtype,
|
||||
reqtypmod,
|
||||
isnull);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user