mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
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
bfd17f94b6
commit
24a814f441
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.236 2009/03/26 22:26:08 petere Exp $
|
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.237 2009/04/02 01:16:11 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -4754,26 +4754,23 @@ exec_simple_cast_value(Datum value, Oid valtype,
|
|||||||
Oid reqtype, int32 reqtypmod,
|
Oid reqtype, int32 reqtypmod,
|
||||||
bool isnull)
|
bool isnull)
|
||||||
{
|
{
|
||||||
if (!isnull)
|
if (valtype != reqtype || reqtypmod != -1)
|
||||||
{
|
{
|
||||||
if (valtype != reqtype || reqtypmod != -1)
|
Oid typinput;
|
||||||
{
|
Oid typioparam;
|
||||||
Oid typinput;
|
FmgrInfo finfo_input;
|
||||||
Oid typioparam;
|
|
||||||
FmgrInfo finfo_input;
|
|
||||||
|
|
||||||
getTypeInputInfo(reqtype, &typinput, &typioparam);
|
getTypeInputInfo(reqtype, &typinput, &typioparam);
|
||||||
|
|
||||||
fmgr_info(typinput, &finfo_input);
|
fmgr_info(typinput, &finfo_input);
|
||||||
|
|
||||||
value = exec_cast_value(value,
|
value = exec_cast_value(value,
|
||||||
valtype,
|
valtype,
|
||||||
reqtype,
|
reqtype,
|
||||||
&finfo_input,
|
&finfo_input,
|
||||||
typioparam,
|
typioparam,
|
||||||
reqtypmod,
|
reqtypmod,
|
||||||
isnull);
|
isnull);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user