aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-08-19 16:54:51 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-08-19 16:54:51 +0000
commit075abb17875831a005ab4752b260ad0a532115bb (patch)
tree9f8ca9e61f273463b49c65ee333f127fc9362ec4
parentfd91b7d39aae5a02cfedf89da5f4589cfef2082e (diff)
downloadpostgresql-075abb17875831a005ab4752b260ad0a532115bb.tar.gz
postgresql-075abb17875831a005ab4752b260ad0a532115bb.zip
Revert patch to coerce 'unknown' type parameters in the backend. As Tom
pointed out, it would need a 2nd pass after the whole query is processed to correctly check that an unknown Param is coerced to the same target type everywhere. Adding the 2nd pass would add a lot more code, which doesn't seem worth the risk given that there isn't much of a use case for passing unknown Params in the first place. The code would work without that check, but it might be confusing and the behavior would be different from the varparams case. Instead, just coerce all unknown params in a PL/pgSQL USING clause to text. That's simple, and is usually what users expect. Revert the patch in CVS HEAD and master, and backpatch the new solution to 8.4. Unlike the previous solution, this applies easily to 8.4 too.
-rw-r--r--src/pl/plpgsql/src/pl_exec.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index d83756f7cf2..b1ab8299608 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.244.2.7 2010/08/09 18:50:29 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.244.2.8 2010/08/19 16:54:51 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -5428,8 +5428,22 @@ exec_eval_using_params(PLpgSQL_execstate *estate, List *params)
ppd->nulls[i] = isnull ? 'n' : ' ';
ppd->freevals[i] = false;
+ if (ppd->types[i] == UNKNOWNOID)
+ {
+ /*
+ * Treat 'unknown' parameters as text, that's what most people
+ * would expect. The backend can coerce unknown constants in a
+ * more intelligent way, but not unknown Params.
+ */
+ ppd->types[i] = TEXTOID;
+ if (!isnull)
+ {
+ ppd->values[i] = CStringGetTextDatum((char *) ppd->values[i]);
+ ppd->freevals[i] = true;
+ }
+ }
/* pass-by-ref non null values must be copied into plpgsql context */
- if (!isnull)
+ else if (!isnull)
{
int16 typLen;
bool typByVal;