]> granicus.if.org Git - postgresql/commitdiff
Be a bit less cavalier with both the code and the comment for UNKNOWN fix.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Aug 2010 17:31:43 +0000 (17:31 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Aug 2010 17:31:43 +0000 (17:31 +0000)
src/pl/plpgsql/src/pl_exec.c

index b19db02e2828a96339527213e29e36f19aa311d1..223eaf9db5574189ef7334a8434c1a2080956230 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.264 2010/08/19 16:54:43 heikki Exp $
+ *       $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.265 2010/08/19 17:31:43 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -5524,14 +5524,16 @@ exec_eval_using_params(PLpgSQL_execstate *estate, List *params)
                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. 
+                        * Treat 'unknown' parameters as text, since that's what most
+                        * people would expect. SPI_execute_with_args can coerce unknown
+                        * constants in a more intelligent way, but not unknown Params.
+                        * This code also takes care of copying into the right context.
+                        * Note we assume 'unknown' has the representation of C-string.
                         */
                        ppd->types[i] = TEXTOID;
                        if (!isnull)
                        {
-                               ppd->values[i] = CStringGetTextDatum((char *) ppd->values[i]);
+                               ppd->values[i] = CStringGetTextDatum(DatumGetCString(ppd->values[i]));
                                ppd->freevals[i] = true;
                        }
                }