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.
This commit is contained in:
parent
fd91b7d39a
commit
075abb1787
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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->nulls[i] = isnull ? 'n' : ' ';
|
||||||
ppd->freevals[i] = false;
|
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 */
|
/* pass-by-ref non null values must be copied into plpgsql context */
|
||||||
if (!isnull)
|
else if (!isnull)
|
||||||
{
|
{
|
||||||
int16 typLen;
|
int16 typLen;
|
||||||
bool typByVal;
|
bool typByVal;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user