summaryrefslogtreecommitdiff
path: root/src/pl
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-08-24 15:00:47 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-08-24 15:00:47 +0000
commit976246cc7e4d8b673fc62fe6daa61c76d94af1af (patch)
treeb61ea3f5bbd8fa025587754bc90c3fd43889337c /src/pl
parentcf4d885c67744637d82f6fec657e8205578c5905 (diff)
downloadpostgresql-976246cc7e4d8b673fc62fe6daa61c76d94af1af.tar.gz
The cstring datatype can now be copied, passed around, etc. The typlen
value '-2' is used to indicate a variable-width type whose width is computed as strlen(datum)+1. Everything that looks at typlen is updated except for array support, which Joe Conway is working on; at the moment it wouldn't work to try to create an array of cstring.
Diffstat (limited to 'src/pl')
-rw-r--r--src/pl/plpgsql/src/pl_exec.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 1ce072c578..c6522c35b9 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.57 2002/08/20 05:28:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.58 2002/08/24 15:00:47 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -362,17 +362,13 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
*/
if (!fcinfo->isnull && !func->fn_retbyval)
{
- int len;
- Datum tmp;
+ Size len;
+ void *tmp;
- if (func->fn_rettyplen < 0)
- len = VARSIZE(estate.retval);
- else
- len = func->fn_rettyplen;
-
- tmp = (Datum) SPI_palloc(len);
- memcpy((void *) tmp, (void *) estate.retval, len);
- estate.retval = tmp;
+ len = datumGetSize(estate.retval, false, func->fn_rettyplen);
+ tmp = (void *) SPI_palloc(len);
+ memcpy(tmp, DatumGetPointer(estate.retval), len);
+ estate.retval = PointerGetDatum(tmp);
}
}
}
@@ -2682,7 +2678,7 @@ exec_assign_value(PLpgSQL_execstate * estate,
if (var->freeval)
{
- pfree((void *) (var->value));
+ pfree(DatumGetPointer(var->value));
var->freeval = false;
}
@@ -2705,16 +2701,9 @@ exec_assign_value(PLpgSQL_execstate * estate,
if (!var->datatype->typbyval && !*isNull)
{
if (newvalue == value)
- {
- int len;
-
- if (var->datatype->typlen < 0)
- len = VARSIZE(newvalue);
- else
- len = var->datatype->typlen;
- var->value = (Datum) palloc(len);
- memcpy((void *) (var->value), (void *) newvalue, len);
- }
+ var->value = datumCopy(newvalue,
+ false,
+ var->datatype->typlen);
else
var->value = newvalue;
var->freeval = true;