aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r--src/backend/utils/adt/arrayfuncs.c26
-rw-r--r--src/backend/utils/adt/rowtypes.c91
-rw-r--r--src/backend/utils/adt/ruleutils.c5
-rw-r--r--src/backend/utils/adt/varlena.c5
4 files changed, 64 insertions, 63 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 1de3ff13a7d..dba7353ba58 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.127 2006/03/05 15:58:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.128 2006/04/04 19:35:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -787,14 +787,14 @@ ReadArrayStr(char *arrayStr,
pg_strcasecmp(itemstart, "NULL") == 0)
{
/* it's a NULL item */
+ values[i] = InputFunctionCall(inputproc, NULL,
+ typioparam, typmod);
nulls[i] = true;
}
else
{
- values[i] = FunctionCall3(inputproc,
- CStringGetDatum(itemstart),
- ObjectIdGetDatum(typioparam),
- Int32GetDatum(typmod));
+ values[i] = InputFunctionCall(inputproc, itemstart,
+ typioparam, typmod);
nulls[i] = false;
}
}
@@ -1018,8 +1018,7 @@ array_out(PG_FUNCTION_ARGS)
Datum itemvalue;
itemvalue = fetch_att(p, typbyval, typlen);
- values[i] = DatumGetCString(FunctionCall1(&my_extra->proc,
- itemvalue));
+ values[i] = OutputFunctionCall(&my_extra->proc, itemvalue);
p = att_addlength(p, typlen, PointerGetDatum(p));
p = (char *) att_align(p, typalign);
@@ -1357,6 +1356,8 @@ ReadArrayBinary(StringInfo buf,
if (itemlen == -1)
{
/* -1 length means NULL */
+ values[i] = ReceiveFunctionCall(receiveproc, NULL,
+ typioparam, typmod);
nulls[i] = true;
continue;
}
@@ -1378,10 +1379,8 @@ ReadArrayBinary(StringInfo buf,
buf->data[buf->cursor] = '\0';
/* Now call the element's receiveproc */
- values[i] = FunctionCall3(receiveproc,
- PointerGetDatum(&elem_buf),
- ObjectIdGetDatum(typioparam),
- Int32GetDatum(typmod));
+ values[i] = ReceiveFunctionCall(receiveproc, &elem_buf,
+ typioparam, typmod);
nulls[i] = false;
/* Trouble if it didn't eat the whole buffer */
@@ -1515,10 +1514,7 @@ array_send(PG_FUNCTION_ARGS)
bytea *outputbytes;
itemvalue = fetch_att(p, typbyval, typlen);
-
- outputbytes = DatumGetByteaP(FunctionCall1(&my_extra->proc,
- itemvalue));
- /* We assume the result will not have been toasted */
+ outputbytes = SendFunctionCall(&my_extra->proc, itemvalue);
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
pq_sendbytes(&buf, VARDATA(outputbytes),
VARSIZE(outputbytes) - VARHDRSZ);
diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c
index 9d7fcaa413a..bb61dc29568 100644
--- a/src/backend/utils/adt/rowtypes.c
+++ b/src/backend/utils/adt/rowtypes.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.14 2006/03/05 15:58:43 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.15 2006/04/04 19:35:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -136,6 +136,7 @@ record_in(PG_FUNCTION_ARGS)
{
ColumnIOData *column_info = &my_extra->columns[i];
Oid column_type = tupdesc->attrs[i]->atttypid;
+ char *column_data;
/* Ignore dropped columns in datatype, but fill with nulls */
if (tupdesc->attrs[i]->attisdropped)
@@ -161,7 +162,7 @@ record_in(PG_FUNCTION_ARGS)
/* Check for null: completely empty input means null */
if (*ptr == ',' || *ptr == ')')
{
- values[i] = (Datum) 0;
+ column_data = NULL;
nulls[i] = 'n';
}
else
@@ -207,27 +208,29 @@ record_in(PG_FUNCTION_ARGS)
appendStringInfoChar(&buf, ch);
}
- /*
- * Convert the column value
- */
- if (column_info->column_type != column_type)
- {
- getTypeInputInfo(column_type,
- &column_info->typiofunc,
- &column_info->typioparam);
- fmgr_info_cxt(column_info->typiofunc, &column_info->proc,
- fcinfo->flinfo->fn_mcxt);
- column_info->column_type = column_type;
- }
-
- values[i] = FunctionCall3(&column_info->proc,
- CStringGetDatum(buf.data),
- ObjectIdGetDatum(column_info->typioparam),
- Int32GetDatum(tupdesc->attrs[i]->atttypmod));
+ column_data = buf.data;
nulls[i] = ' ';
}
/*
+ * Convert the column value
+ */
+ if (column_info->column_type != column_type)
+ {
+ getTypeInputInfo(column_type,
+ &column_info->typiofunc,
+ &column_info->typioparam);
+ fmgr_info_cxt(column_info->typiofunc, &column_info->proc,
+ fcinfo->flinfo->fn_mcxt);
+ column_info->column_type = column_type;
+ }
+
+ values[i] = InputFunctionCall(&column_info->proc,
+ column_data,
+ column_info->typioparam,
+ tupdesc->attrs[i]->atttypmod);
+
+ /*
* Prep for next column
*/
needComma = true;
@@ -372,8 +375,7 @@ record_out(PG_FUNCTION_ARGS)
column_info->column_type = column_type;
}
- value = DatumGetCString(FunctionCall1(&column_info->proc,
- values[i]));
+ value = OutputFunctionCall(&column_info->proc, values[i]);
/* Detect whether we need double quotes for this value */
nq = (value[0] == '\0'); /* force quotes for empty string */
@@ -505,6 +507,9 @@ record_recv(PG_FUNCTION_ARGS)
Oid column_type = tupdesc->attrs[i]->atttypid;
Oid coltypoid;
int itemlen;
+ StringInfoData item_buf;
+ StringInfo bufptr;
+ char csave;
/* Ignore dropped columns in datatype, but fill with nulls */
if (tupdesc->attrs[i]->attisdropped)
@@ -532,8 +537,9 @@ record_recv(PG_FUNCTION_ARGS)
if (itemlen == -1)
{
/* -1 length means NULL */
- values[i] = (Datum) 0;
+ bufptr = NULL;
nulls[i] = 'n';
+ csave = 0; /* keep compiler quiet */
}
else
{
@@ -543,9 +549,6 @@ record_recv(PG_FUNCTION_ARGS)
* We assume we can scribble on the input buffer so as to maintain
* the convention that StringInfos have a trailing null.
*/
- StringInfoData item_buf;
- char csave;
-
item_buf.data = &buf->data[buf->cursor];
item_buf.maxlen = itemlen + 1;
item_buf.len = itemlen;
@@ -556,23 +559,28 @@ record_recv(PG_FUNCTION_ARGS)
csave = buf->data[buf->cursor];
buf->data[buf->cursor] = '\0';
- /* Now call the column's receiveproc */
- if (column_info->column_type != column_type)
- {
- getTypeBinaryInputInfo(column_type,
- &column_info->typiofunc,
- &column_info->typioparam);
- fmgr_info_cxt(column_info->typiofunc, &column_info->proc,
- fcinfo->flinfo->fn_mcxt);
- column_info->column_type = column_type;
- }
-
- values[i] = FunctionCall3(&column_info->proc,
- PointerGetDatum(&item_buf),
- ObjectIdGetDatum(column_info->typioparam),
- Int32GetDatum(tupdesc->attrs[i]->atttypmod));
+ bufptr = &item_buf;
nulls[i] = ' ';
+ }
+ /* Now call the column's receiveproc */
+ if (column_info->column_type != column_type)
+ {
+ getTypeBinaryInputInfo(column_type,
+ &column_info->typiofunc,
+ &column_info->typioparam);
+ fmgr_info_cxt(column_info->typiofunc, &column_info->proc,
+ fcinfo->flinfo->fn_mcxt);
+ column_info->column_type = column_type;
+ }
+
+ values[i] = ReceiveFunctionCall(&column_info->proc,
+ bufptr,
+ column_info->typioparam,
+ tupdesc->attrs[i]->atttypmod);
+
+ if (bufptr)
+ {
/* Trouble if it didn't eat the whole buffer */
if (item_buf.cursor != itemlen)
ereport(ERROR,
@@ -712,8 +720,7 @@ record_send(PG_FUNCTION_ARGS)
column_info->column_type = column_type;
}
- outputbytes = DatumGetByteaP(FunctionCall1(&column_info->proc,
- values[i]));
+ outputbytes = SendFunctionCall(&column_info->proc, values[i]);
/* We assume the result will not have been toasted */
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 714140e0617..f8daab6eeaf 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -2,7 +2,7 @@
* ruleutils.c - Functions to convert stored expressions/querytrees
* back to source text
*
- * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.217 2006/03/16 00:31:55 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.218 2006/04/04 19:35:36 tgl Exp $
**********************************************************************/
#include "postgres.h"
@@ -3921,8 +3921,7 @@ get_const_expr(Const *constval, deparse_context *context)
getTypeOutputInfo(constval->consttype,
&typoutput, &typIsVarlena);
- extval = DatumGetCString(OidFunctionCall1(typoutput,
- constval->constvalue));
+ extval = OidOutputFunctionCall(typoutput, constval->constvalue);
switch (constval->consttype)
{
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index b936b8219dd..79dc0178a80 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.145 2006/03/05 15:58:44 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.146 2006/04/04 19:35:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2580,8 +2580,7 @@ array_to_text(PG_FUNCTION_ARGS)
{
itemvalue = fetch_att(p, typbyval, typlen);
- value = DatumGetCString(FunctionCall1(&my_extra->proc,
- itemvalue));
+ value = OutputFunctionCall(&my_extra->proc, itemvalue);
if (printed)
appendStringInfo(&buf, "%s%s", fldsep, value);