aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-04-02 01:16:17 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-04-02 01:16:17 +0000
commit5dde1db4e1ae336b5fa2cff3a82ec8bfc10562d4 (patch)
treedee4e26d65889d65cc0732ca16f57747948b501b /src
parent591cbf673baa92498890914311e7f498d46f2dad (diff)
downloadpostgresql-5dde1db4e1ae336b5fa2cff3a82ec8bfc10562d4.tar.gz
postgresql-5dde1db4e1ae336b5fa2cff3a82ec8bfc10562d4.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/pl/plpgsql/src/pl_exec.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 5ed58cd69eb..49f6fb4c84d 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -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,26 +4544,23 @@ exec_simple_cast_value(Datum value, Oid valtype,
Oid reqtype, int32 reqtypmod,
bool isnull)
{
- if (!isnull)
+ if (valtype != reqtype || reqtypmod != -1)
{
- if (valtype != reqtype || reqtypmod != -1)
- {
- Oid typinput;
- Oid typioparam;
- FmgrInfo finfo_input;
+ Oid typinput;
+ 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,
- valtype,
- reqtype,
- &finfo_input,
- typioparam,
- reqtypmod,
- isnull);
- }
+ value = exec_cast_value(value,
+ valtype,
+ reqtype,
+ &finfo_input,
+ typioparam,
+ reqtypmod,
+ isnull);
}
return value;