Commit 6c412f06 authored by Tom Lane's avatar Tom Lane

Change CREATE TYPE to require datatype output and send functions to have

only one argument.  (Per recent discussion, the option to accept multiple
arguments is pretty useless for user-defined types, and would be a likely
source of security holes if it was used.)  Simplify call sites of
output/send functions to not bother passing more than one argument.
parent ae793ff6
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.54 2005/01/04 00:39:53 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.55 2005/05/01 18:56:17 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -107,13 +107,10 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> ( ...@@ -107,13 +107,10 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> (
(or the type's own OID for a composite type), (or the type's own OID for a composite type),
and the third is the <literal>typmod</> of the destination column, if known and the third is the <literal>typmod</> of the destination column, if known
(-1 will be passed if not). (-1 will be passed if not).
The input function should return a value of the data type itself. The input function must return a value of the data type itself.
The output function may be The output function must be
declared as taking one argument of the new data type, or as taking declared as taking one argument of the new data type.
two arguments of which the second is type <type>oid</type>. The output function must return type <type>cstring</type>.
The second argument is again the array element type OID for array types
or the type OID for composite types.
The output function should return type <type>cstring</type>.
</para> </para>
<para> <para>
...@@ -137,11 +134,8 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> ( ...@@ -137,11 +134,8 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> (
<replaceable class="parameter">send_function</replaceable> converts <replaceable class="parameter">send_function</replaceable> converts
from the internal representation to the external binary representation. from the internal representation to the external binary representation.
If this function is not supplied, the type cannot participate in binary If this function is not supplied, the type cannot participate in binary
output. The send function may be output. The send function must be
declared as taking one argument of the new data type, or as taking declared as taking one argument of the new data type.
two arguments of which the second is type <type>oid</type>.
The second argument is again the array element type OID for array types
or the type OID for composite types.
The send function must return type <type>bytea</type>. The send function must return type <type>bytea</type>.
</para> </para>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.89 2005/04/23 17:45:35 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.90 2005/05/01 18:56:17 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -48,7 +48,6 @@ typedef struct ...@@ -48,7 +48,6 @@ typedef struct
{ /* Per-attribute information */ { /* Per-attribute information */
Oid typoutput; /* Oid for the type's text output fn */ Oid typoutput; /* Oid for the type's text output fn */
Oid typsend; /* Oid for the type's binary output fn */ Oid typsend; /* Oid for the type's binary output fn */
Oid typioparam; /* param to pass to the output fn */
bool typisvarlena; /* is it varlena (ie possibly toastable)? */ bool typisvarlena; /* is it varlena (ie possibly toastable)? */
int16 format; /* format code for this column */ int16 format; /* format code for this column */
FmgrInfo finfo; /* Precomputed call info for output fn */ FmgrInfo finfo; /* Precomputed call info for output fn */
...@@ -263,7 +262,6 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ...@@ -263,7 +262,6 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs)
{ {
getTypeOutputInfo(typeinfo->attrs[i]->atttypid, getTypeOutputInfo(typeinfo->attrs[i]->atttypid,
&thisState->typoutput, &thisState->typoutput,
&thisState->typioparam,
&thisState->typisvarlena); &thisState->typisvarlena);
fmgr_info(thisState->typoutput, &thisState->finfo); fmgr_info(thisState->typoutput, &thisState->finfo);
} }
...@@ -271,7 +269,6 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ...@@ -271,7 +269,6 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs)
{ {
getTypeBinaryOutputInfo(typeinfo->attrs[i]->atttypid, getTypeBinaryOutputInfo(typeinfo->attrs[i]->atttypid,
&thisState->typsend, &thisState->typsend,
&thisState->typioparam,
&thisState->typisvarlena); &thisState->typisvarlena);
fmgr_info(thisState->typsend, &thisState->finfo); fmgr_info(thisState->typsend, &thisState->finfo);
} }
...@@ -338,10 +335,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) ...@@ -338,10 +335,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
/* Text output */ /* Text output */
char *outputstr; char *outputstr;
outputstr = DatumGetCString(FunctionCall3(&thisState->finfo, outputstr = DatumGetCString(FunctionCall1(&thisState->finfo,
attr, attr));
ObjectIdGetDatum(thisState->typioparam),
Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false); pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false);
pfree(outputstr); pfree(outputstr);
} }
...@@ -350,9 +345,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self) ...@@ -350,9 +345,8 @@ printtup(TupleTableSlot *slot, DestReceiver *self)
/* Binary output */ /* Binary output */
bytea *outputbytes; bytea *outputbytes;
outputbytes = DatumGetByteaP(FunctionCall2(&thisState->finfo, outputbytes = DatumGetByteaP(FunctionCall1(&thisState->finfo,
attr, attr));
ObjectIdGetDatum(thisState->typioparam)));
/* We assume the result will not have been toasted */ /* We assume the result will not have been toasted */
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4); pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
pq_sendbytes(&buf, VARDATA(outputbytes), pq_sendbytes(&buf, VARDATA(outputbytes),
...@@ -439,10 +433,8 @@ printtup_20(TupleTableSlot *slot, DestReceiver *self) ...@@ -439,10 +433,8 @@ printtup_20(TupleTableSlot *slot, DestReceiver *self)
else else
attr = origattr; attr = origattr;
outputstr = DatumGetCString(FunctionCall3(&thisState->finfo, outputstr = DatumGetCString(FunctionCall1(&thisState->finfo,
attr, attr));
ObjectIdGetDatum(thisState->typioparam),
Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
pq_sendcountedtext(&buf, outputstr, strlen(outputstr), true); pq_sendcountedtext(&buf, outputstr, strlen(outputstr), true);
pfree(outputstr); pfree(outputstr);
...@@ -534,8 +526,7 @@ debugtup(TupleTableSlot *slot, DestReceiver *self) ...@@ -534,8 +526,7 @@ debugtup(TupleTableSlot *slot, DestReceiver *self)
attr; attr;
char *value; char *value;
bool isnull; bool isnull;
Oid typoutput, Oid typoutput;
typioparam;
bool typisvarlena; bool typisvarlena;
for (i = 0; i < natts; ++i) for (i = 0; i < natts; ++i)
...@@ -544,7 +535,7 @@ debugtup(TupleTableSlot *slot, DestReceiver *self) ...@@ -544,7 +535,7 @@ debugtup(TupleTableSlot *slot, DestReceiver *self)
if (isnull) if (isnull)
continue; continue;
getTypeOutputInfo(typeinfo->attrs[i]->atttypid, getTypeOutputInfo(typeinfo->attrs[i]->atttypid,
&typoutput, &typioparam, &typisvarlena); &typoutput, &typisvarlena);
/* /*
* If we have a toasted datum, forcibly detoast it here to avoid * If we have a toasted datum, forcibly detoast it here to avoid
...@@ -555,10 +546,8 @@ debugtup(TupleTableSlot *slot, DestReceiver *self) ...@@ -555,10 +546,8 @@ debugtup(TupleTableSlot *slot, DestReceiver *self)
else else
attr = origattr; attr = origattr;
value = DatumGetCString(OidFunctionCall3(typoutput, value = DatumGetCString(OidFunctionCall1(typoutput,
attr, attr));
ObjectIdGetDatum(typioparam),
Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
printatt((unsigned) i + 1, typeinfo->attrs[i], value); printatt((unsigned) i + 1, typeinfo->attrs[i], value);
...@@ -647,9 +636,8 @@ printtup_internal_20(TupleTableSlot *slot, DestReceiver *self) ...@@ -647,9 +636,8 @@ printtup_internal_20(TupleTableSlot *slot, DestReceiver *self)
else else
attr = origattr; attr = origattr;
outputbytes = DatumGetByteaP(FunctionCall2(&thisState->finfo, outputbytes = DatumGetByteaP(FunctionCall1(&thisState->finfo,
attr, attr));
ObjectIdGetDatum(thisState->typioparam)));
/* We assume the result will not have been toasted */ /* We assume the result will not have been toasted */
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4); pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
pq_sendbytes(&buf, VARDATA(outputbytes), pq_sendbytes(&buf, VARDATA(outputbytes),
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.202 2005/04/14 20:03:23 tgl Exp $ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.203 2005/05/01 18:56:17 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -850,10 +850,8 @@ InsertOneValue(char *value, int i) ...@@ -850,10 +850,8 @@ InsertOneValue(char *value, int i)
CStringGetDatum(value), CStringGetDatum(value),
ObjectIdGetDatum(typioparam), ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)); Int32GetDatum(-1));
prt = DatumGetCString(OidFunctionCall3(typoutput, prt = DatumGetCString(OidFunctionCall1(typoutput,
values[i], values[i]));
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)));
elog(DEBUG4, "inserted -> %s", prt); elog(DEBUG4, "inserted -> %s", prt);
pfree(prt); pfree(prt);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.240 2005/04/14 20:03:23 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.241 2005/05/01 18:56:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1178,8 +1178,6 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1178,8 +1178,6 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
Form_pg_attribute *attr; Form_pg_attribute *attr;
FmgrInfo *out_functions; FmgrInfo *out_functions;
bool *force_quote; bool *force_quote;
Oid *typioparams;
bool *isvarlena;
char *string; char *string;
ListCell *cur; ListCell *cur;
MemoryContext oldcontext; MemoryContext oldcontext;
...@@ -1194,22 +1192,21 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1194,22 +1192,21 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
* Get info about the columns we need to process. * Get info about the columns we need to process.
*/ */
out_functions = (FmgrInfo *) palloc(num_phys_attrs * sizeof(FmgrInfo)); out_functions = (FmgrInfo *) palloc(num_phys_attrs * sizeof(FmgrInfo));
typioparams = (Oid *) palloc(num_phys_attrs * sizeof(Oid));
isvarlena = (bool *) palloc(num_phys_attrs * sizeof(bool));
force_quote = (bool *) palloc(num_phys_attrs * sizeof(bool)); force_quote = (bool *) palloc(num_phys_attrs * sizeof(bool));
foreach(cur, attnumlist) foreach(cur, attnumlist)
{ {
int attnum = lfirst_int(cur); int attnum = lfirst_int(cur);
Oid out_func_oid; Oid out_func_oid;
bool isvarlena;
if (binary) if (binary)
getTypeBinaryOutputInfo(attr[attnum - 1]->atttypid, getTypeBinaryOutputInfo(attr[attnum - 1]->atttypid,
&out_func_oid, &typioparams[attnum - 1], &out_func_oid,
&isvarlena[attnum - 1]); &isvarlena);
else else
getTypeOutputInfo(attr[attnum - 1]->atttypid, getTypeOutputInfo(attr[attnum - 1]->atttypid,
&out_func_oid, &typioparams[attnum - 1], &out_func_oid,
&isvarlena[attnum - 1]); &isvarlena);
fmgr_info(out_func_oid, &out_functions[attnum - 1]); fmgr_info(out_func_oid, &out_functions[attnum - 1]);
if (list_member_int(force_quote_atts, attnum)) if (list_member_int(force_quote_atts, attnum))
...@@ -1321,10 +1318,8 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1321,10 +1318,8 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
{ {
if (!binary) if (!binary)
{ {
string = DatumGetCString(FunctionCall3(&out_functions[attnum - 1], string = DatumGetCString(FunctionCall1(&out_functions[attnum - 1],
value, value));
ObjectIdGetDatum(typioparams[attnum - 1]),
Int32GetDatum(attr[attnum - 1]->atttypmod)));
if (csv_mode) if (csv_mode)
{ {
CopyAttributeOutCSV(string, delim, quote, escape, CopyAttributeOutCSV(string, delim, quote, escape,
...@@ -1339,9 +1334,8 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1339,9 +1334,8 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
{ {
bytea *outputbytes; bytea *outputbytes;
outputbytes = DatumGetByteaP(FunctionCall2(&out_functions[attnum - 1], outputbytes = DatumGetByteaP(FunctionCall1(&out_functions[attnum - 1],
value, value));
ObjectIdGetDatum(typioparams[attnum - 1])));
/* We assume the result will not have been toasted */ /* We assume the result will not have been toasted */
CopySendInt32(VARSIZE(outputbytes) - VARHDRSZ); CopySendInt32(VARSIZE(outputbytes) - VARHDRSZ);
CopySendData(VARDATA(outputbytes), CopySendData(VARDATA(outputbytes),
...@@ -1366,8 +1360,6 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1366,8 +1360,6 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
MemoryContextDelete(mycontext); MemoryContextDelete(mycontext);
pfree(out_functions); pfree(out_functions);
pfree(typioparams);
pfree(isvarlena);
pfree(force_quote); pfree(force_quote);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.70 2005/04/14 20:03:24 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.71 2005/05/01 18:56:18 tgl Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
...@@ -920,12 +920,11 @@ findTypeInputFunction(List *procname, Oid typeOid) ...@@ -920,12 +920,11 @@ findTypeInputFunction(List *procname, Oid typeOid)
static Oid static Oid
findTypeOutputFunction(List *procname, Oid typeOid) findTypeOutputFunction(List *procname, Oid typeOid)
{ {
Oid argList[2]; Oid argList[1];
Oid procOid; Oid procOid;
/* /*
* Output functions can take a single argument of the type, or two * Output functions can take a single argument of the type.
* arguments (data value, element OID).
* *
* For backwards compatibility we allow OPAQUE in place of the actual * For backwards compatibility we allow OPAQUE in place of the actual
* type name; if we see this, we issue a warning and fix up the * type name; if we see this, we issue a warning and fix up the
...@@ -937,24 +936,11 @@ findTypeOutputFunction(List *procname, Oid typeOid) ...@@ -937,24 +936,11 @@ findTypeOutputFunction(List *procname, Oid typeOid)
if (OidIsValid(procOid)) if (OidIsValid(procOid))
return procOid; return procOid;
argList[1] = OIDOID;
procOid = LookupFuncName(procname, 2, argList, true);
if (OidIsValid(procOid))
return procOid;
/* No luck, try it with OPAQUE */ /* No luck, try it with OPAQUE */
argList[0] = OPAQUEOID; argList[0] = OPAQUEOID;
procOid = LookupFuncName(procname, 1, argList, true); procOid = LookupFuncName(procname, 1, argList, true);
if (!OidIsValid(procOid))
{
argList[1] = OIDOID;
procOid = LookupFuncName(procname, 2, argList, true);
}
if (OidIsValid(procOid)) if (OidIsValid(procOid))
{ {
/* Found, but must complain and fix the pg_proc entry */ /* Found, but must complain and fix the pg_proc entry */
...@@ -1016,12 +1002,11 @@ findTypeReceiveFunction(List *procname, Oid typeOid) ...@@ -1016,12 +1002,11 @@ findTypeReceiveFunction(List *procname, Oid typeOid)
static Oid static Oid
findTypeSendFunction(List *procname, Oid typeOid) findTypeSendFunction(List *procname, Oid typeOid)
{ {
Oid argList[2]; Oid argList[1];
Oid procOid; Oid procOid;
/* /*
* Send functions can take a single argument of the type, or two * Send functions can take a single argument of the type.
* arguments (data value, element OID).
*/ */
argList[0] = typeOid; argList[0] = typeOid;
...@@ -1029,12 +1014,6 @@ findTypeSendFunction(List *procname, Oid typeOid) ...@@ -1029,12 +1014,6 @@ findTypeSendFunction(List *procname, Oid typeOid)
if (OidIsValid(procOid)) if (OidIsValid(procOid))
return procOid; return procOid;
argList[1] = OIDOID;
procOid = LookupFuncName(procname, 2, argList, true);
if (OidIsValid(procOid))
return procOid;
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION), (errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("function %s does not exist", errmsg("function %s does not exist",
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.137 2005/03/29 02:53:53 neilc Exp $ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.138 2005/05/01 18:56:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -632,9 +632,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) ...@@ -632,9 +632,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
result; result;
bool isnull; bool isnull;
Oid typoid, Oid typoid,
foutoid, foutoid;
typioparam;
int32 typmod;
bool typisvarlena; bool typisvarlena;
SPI_result = 0; SPI_result = 0;
...@@ -651,17 +649,11 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) ...@@ -651,17 +649,11 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
return NULL; return NULL;
if (fnumber > 0) if (fnumber > 0)
{
typoid = tupdesc->attrs[fnumber - 1]->atttypid; typoid = tupdesc->attrs[fnumber - 1]->atttypid;
typmod = tupdesc->attrs[fnumber - 1]->atttypmod;
}
else else
{
typoid = (SystemAttributeDefinition(fnumber, true))->atttypid; typoid = (SystemAttributeDefinition(fnumber, true))->atttypid;
typmod = -1;
}
getTypeOutputInfo(typoid, &foutoid, &typioparam, &typisvarlena); getTypeOutputInfo(typoid, &foutoid, &typisvarlena);
/* /*
* If we have a toasted datum, forcibly detoast it here to avoid * If we have a toasted datum, forcibly detoast it here to avoid
...@@ -672,10 +664,8 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) ...@@ -672,10 +664,8 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
else else
val = origval; val = origval;
result = OidFunctionCall3(foutoid, result = OidFunctionCall1(foutoid,
val, val);
ObjectIdGetDatum(typioparam),
Int32GetDatum(typmod));
/* Clean up detoasted copy, if any */ /* Clean up detoasted copy, if any */
if (val != origval) if (val != origval)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.75 2005/04/19 22:35:15 tgl Exp $ * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.76 2005/05/01 18:56:18 tgl Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -345,7 +345,6 @@ print_expr(Node *expr, List *rtable) ...@@ -345,7 +345,6 @@ print_expr(Node *expr, List *rtable)
{ {
Const *c = (Const *) expr; Const *c = (Const *) expr;
Oid typoutput; Oid typoutput;
Oid typioparam;
bool typIsVarlena; bool typIsVarlena;
char *outputstr; char *outputstr;
...@@ -356,12 +355,10 @@ print_expr(Node *expr, List *rtable) ...@@ -356,12 +355,10 @@ print_expr(Node *expr, List *rtable)
} }
getTypeOutputInfo(c->consttype, getTypeOutputInfo(c->consttype,
&typoutput, &typioparam, &typIsVarlena); &typoutput, &typIsVarlena);
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall1(typoutput,
c->constvalue, c->constvalue));
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)));
printf("%s", outputstr); printf("%s", outputstr);
pfree(outputstr); pfree(outputstr);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.79 2005/03/29 03:01:31 tgl Exp $ * $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.80 2005/05/01 18:56:18 tgl Exp $
* *
* NOTES * NOTES
* This cruft is the server side of PQfn. * This cruft is the server side of PQfn.
...@@ -149,31 +149,25 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format) ...@@ -149,31 +149,25 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
if (format == 0) if (format == 0)
{ {
Oid typoutput, Oid typoutput;
typioparam;
bool typisvarlena; bool typisvarlena;
char *outputstr; char *outputstr;
getTypeOutputInfo(rettype, &typoutput, &typioparam, &typisvarlena); getTypeOutputInfo(rettype, &typoutput, &typisvarlena);
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall1(typoutput,
retval, retval));
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)));
pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false); pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false);
pfree(outputstr); pfree(outputstr);
} }
else if (format == 1) else if (format == 1)
{ {
Oid typsend, Oid typsend;
typioparam;
bool typisvarlena; bool typisvarlena;
bytea *outputbytes; bytea *outputbytes;
getTypeBinaryOutputInfo(rettype, getTypeBinaryOutputInfo(rettype, &typsend, &typisvarlena);
&typsend, &typioparam, &typisvarlena); outputbytes = DatumGetByteaP(OidFunctionCall1(typsend,
outputbytes = DatumGetByteaP(OidFunctionCall2(typsend, retval));
retval,
ObjectIdGetDatum(typioparam)));
/* We assume the result will not have been toasted */ /* We assume the result will not have been toasted */
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4); pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
pq_sendbytes(&buf, VARDATA(outputbytes), pq_sendbytes(&buf, VARDATA(outputbytes),
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.119 2005/03/29 03:01:31 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.120 2005/05/01 18:56:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -885,7 +885,6 @@ array_out(PG_FUNCTION_ARGS) ...@@ -885,7 +885,6 @@ array_out(PG_FUNCTION_ARGS)
bool typbyval; bool typbyval;
char typalign; char typalign;
char typdelim; char typdelim;
Oid typioparam;
char *p, char *p,
*tmp, *tmp,
*retval, *retval,
...@@ -944,7 +943,6 @@ array_out(PG_FUNCTION_ARGS) ...@@ -944,7 +943,6 @@ array_out(PG_FUNCTION_ARGS)
typbyval = my_extra->typbyval; typbyval = my_extra->typbyval;
typalign = my_extra->typalign; typalign = my_extra->typalign;
typdelim = my_extra->typdelim; typdelim = my_extra->typdelim;
typioparam = my_extra->typioparam;
ndim = ARR_NDIM(v); ndim = ARR_NDIM(v);
dims = ARR_DIMS(v); dims = ARR_DIMS(v);
...@@ -986,10 +984,8 @@ array_out(PG_FUNCTION_ARGS) ...@@ -986,10 +984,8 @@ array_out(PG_FUNCTION_ARGS)
bool needquote; bool needquote;
itemvalue = fetch_att(p, typbyval, typlen); itemvalue = fetch_att(p, typbyval, typlen);
values[i] = DatumGetCString(FunctionCall3(&my_extra->proc, values[i] = DatumGetCString(FunctionCall1(&my_extra->proc,
itemvalue, itemvalue));
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)));
p = att_addlength(p, typlen, PointerGetDatum(p)); p = att_addlength(p, typlen, PointerGetDatum(p));
p = (char *) att_align(p, typalign); p = (char *) att_align(p, typalign);
...@@ -1344,7 +1340,6 @@ array_send(PG_FUNCTION_ARGS) ...@@ -1344,7 +1340,6 @@ array_send(PG_FUNCTION_ARGS)
int typlen; int typlen;
bool typbyval; bool typbyval;
char typalign; char typalign;
Oid typioparam;
char *p; char *p;
int nitems, int nitems,
i; i;
...@@ -1389,7 +1384,6 @@ array_send(PG_FUNCTION_ARGS) ...@@ -1389,7 +1384,6 @@ array_send(PG_FUNCTION_ARGS)
typlen = my_extra->typlen; typlen = my_extra->typlen;
typbyval = my_extra->typbyval; typbyval = my_extra->typbyval;
typalign = my_extra->typalign; typalign = my_extra->typalign;
typioparam = my_extra->typioparam;
ndim = ARR_NDIM(v); ndim = ARR_NDIM(v);
dim = ARR_DIMS(v); dim = ARR_DIMS(v);
...@@ -1416,9 +1410,8 @@ array_send(PG_FUNCTION_ARGS) ...@@ -1416,9 +1410,8 @@ array_send(PG_FUNCTION_ARGS)
itemvalue = fetch_att(p, typbyval, typlen); itemvalue = fetch_att(p, typbyval, typlen);
outputbytes = DatumGetByteaP(FunctionCall2(&my_extra->proc, outputbytes = DatumGetByteaP(FunctionCall1(&my_extra->proc,
itemvalue, itemvalue));
ObjectIdGetDatum(typioparam)));
/* We assume the result will not have been toasted */ /* We assume the result will not have been toasted */
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4); pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
pq_sendbytes(&buf, VARDATA(outputbytes), pq_sendbytes(&buf, VARDATA(outputbytes),
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.10 2005/04/30 20:04:33 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.11 2005/05/01 18:56:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -362,17 +362,14 @@ record_out(PG_FUNCTION_ARGS) ...@@ -362,17 +362,14 @@ record_out(PG_FUNCTION_ARGS)
getTypeOutputInfo(column_type, getTypeOutputInfo(column_type,
&column_info->typiofunc, &column_info->typiofunc,
&column_info->typioparam,
&typIsVarlena); &typIsVarlena);
fmgr_info_cxt(column_info->typiofunc, &column_info->proc, fmgr_info_cxt(column_info->typiofunc, &column_info->proc,
fcinfo->flinfo->fn_mcxt); fcinfo->flinfo->fn_mcxt);
column_info->column_type = column_type; column_info->column_type = column_type;
} }
value = DatumGetCString(FunctionCall3(&column_info->proc, value = DatumGetCString(FunctionCall1(&column_info->proc,
values[i], values[i]));
ObjectIdGetDatum(column_info->typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
/* Detect whether we need double quotes for this value */ /* Detect whether we need double quotes for this value */
nq = (value[0] == '\0'); /* force quotes for empty string */ nq = (value[0] == '\0'); /* force quotes for empty string */
...@@ -702,16 +699,14 @@ record_send(PG_FUNCTION_ARGS) ...@@ -702,16 +699,14 @@ record_send(PG_FUNCTION_ARGS)
getTypeBinaryOutputInfo(column_type, getTypeBinaryOutputInfo(column_type,
&column_info->typiofunc, &column_info->typiofunc,
&column_info->typioparam,
&typIsVarlena); &typIsVarlena);
fmgr_info_cxt(column_info->typiofunc, &column_info->proc, fmgr_info_cxt(column_info->typiofunc, &column_info->proc,
fcinfo->flinfo->fn_mcxt); fcinfo->flinfo->fn_mcxt);
column_info->column_type = column_type; column_info->column_type = column_type;
} }
outputbytes = DatumGetByteaP(FunctionCall2(&column_info->proc, outputbytes = DatumGetByteaP(FunctionCall1(&column_info->proc,
values[i], values[i]));
ObjectIdGetDatum(column_info->typioparam)));
/* We assume the result will not have been toasted */ /* We assume the result will not have been toasted */
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4); pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* back to source text * back to source text
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.194 2005/04/30 08:08:50 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.195 2005/05/01 18:56:18 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -3594,7 +3594,6 @@ get_const_expr(Const *constval, deparse_context *context) ...@@ -3594,7 +3594,6 @@ get_const_expr(Const *constval, deparse_context *context)
{ {
StringInfo buf = context->buf; StringInfo buf = context->buf;
Oid typoutput; Oid typoutput;
Oid typioparam;
bool typIsVarlena; bool typIsVarlena;
char *extval; char *extval;
char *valptr; char *valptr;
...@@ -3613,12 +3612,10 @@ get_const_expr(Const *constval, deparse_context *context) ...@@ -3613,12 +3612,10 @@ get_const_expr(Const *constval, deparse_context *context)
} }
getTypeOutputInfo(constval->consttype, getTypeOutputInfo(constval->consttype,
&typoutput, &typioparam, &typIsVarlena); &typoutput, &typIsVarlena);
extval = DatumGetCString(OidFunctionCall3(typoutput, extval = DatumGetCString(OidFunctionCall1(typoutput,
constval->constvalue, constval->constvalue));
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)));
switch (constval->consttype) switch (constval->consttype)
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.119 2005/02/23 22:46:17 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.120 2005/05/01 18:56:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2174,7 +2174,6 @@ array_to_text(PG_FUNCTION_ARGS) ...@@ -2174,7 +2174,6 @@ array_to_text(PG_FUNCTION_ARGS)
int typlen; int typlen;
bool typbyval; bool typbyval;
char typalign; char typalign;
Oid typioparam;
StringInfo result_str = makeStringInfo(); StringInfo result_str = makeStringInfo();
int i; int i;
ArrayMetaState *my_extra; ArrayMetaState *my_extra;
...@@ -2221,7 +2220,6 @@ array_to_text(PG_FUNCTION_ARGS) ...@@ -2221,7 +2220,6 @@ array_to_text(PG_FUNCTION_ARGS)
typlen = my_extra->typlen; typlen = my_extra->typlen;
typbyval = my_extra->typbyval; typbyval = my_extra->typbyval;
typalign = my_extra->typalign; typalign = my_extra->typalign;
typioparam = my_extra->typioparam;
for (i = 0; i < nitems; i++) for (i = 0; i < nitems; i++)
{ {
...@@ -2230,10 +2228,8 @@ array_to_text(PG_FUNCTION_ARGS) ...@@ -2230,10 +2228,8 @@ array_to_text(PG_FUNCTION_ARGS)
itemvalue = fetch_att(p, typbyval, typlen); itemvalue = fetch_att(p, typbyval, typlen);
value = DatumGetCString(FunctionCall3(&my_extra->proc, value = DatumGetCString(FunctionCall1(&my_extra->proc,
itemvalue, itemvalue));
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)));
if (i > 0) if (i > 0)
appendStringInfo(result_str, "%s%s", fldsep, value); appendStringInfo(result_str, "%s%s", fldsep, value);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.124 2005/04/14 20:03:26 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.125 2005/05/01 18:56:19 tgl Exp $
* *
* NOTES * NOTES
* Eventually, the index information should go through here, too. * Eventually, the index information should go through here, too.
...@@ -1214,6 +1214,10 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, ...@@ -1214,6 +1214,10 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
* to typelem elsewhere in the code are wrong, if they are associated with * to typelem elsewhere in the code are wrong, if they are associated with
* I/O calls and not with actual subscripting operations! (But see * I/O calls and not with actual subscripting operations! (But see
* bootstrap.c, which can't conveniently use this routine.) * bootstrap.c, which can't conveniently use this routine.)
*
* As of PostgreSQL 8.1, output functions receive only the value itself
* and not any auxiliary parameters, so the name of this routine is now
* a bit of a misnomer ... it should be getTypeInputParam.
*/ */
Oid Oid
getTypeIOParam(HeapTuple typeTuple) getTypeIOParam(HeapTuple typeTuple)
...@@ -1698,8 +1702,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam) ...@@ -1698,8 +1702,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
* Get info needed for printing values of a type * Get info needed for printing values of a type
*/ */
void void
getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typIOParam, getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
bool *typIsVarlena)
{ {
HeapTuple typeTuple; HeapTuple typeTuple;
Form_pg_type pt; Form_pg_type pt;
...@@ -1723,7 +1726,6 @@ getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typIOParam, ...@@ -1723,7 +1726,6 @@ getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typIOParam,
format_type_be(type)))); format_type_be(type))));
*typOutput = pt->typoutput; *typOutput = pt->typoutput;
*typIOParam = getTypeIOParam(typeTuple);
*typIsVarlena = (!pt->typbyval) && (pt->typlen == -1); *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
ReleaseSysCache(typeTuple); ReleaseSysCache(typeTuple);
...@@ -1770,8 +1772,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam) ...@@ -1770,8 +1772,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
* Get info needed for binary output of values of a type * Get info needed for binary output of values of a type
*/ */
void void
getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typIOParam, getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
bool *typIsVarlena)
{ {
HeapTuple typeTuple; HeapTuple typeTuple;
Form_pg_type pt; Form_pg_type pt;
...@@ -1795,7 +1796,6 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typIOParam, ...@@ -1795,7 +1796,6 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typIOParam,
format_type_be(type)))); format_type_be(type))));
*typSend = pt->typsend; *typSend = pt->typsend;
*typIOParam = getTypeIOParam(typeTuple);
*typIsVarlena = (!pt->typbyval) && (pt->typlen == -1); *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
ReleaseSysCache(typeTuple); ReleaseSysCache(typeTuple);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>. * Written by Peter Eisentraut <peter_e@gmx.net>.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.260 2005/04/21 19:18:13 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.261 2005/05/01 18:56:19 tgl Exp $
* *
*-------------------------------------------------------------------- *--------------------------------------------------------------------
*/ */
...@@ -3992,10 +3992,8 @@ flatten_set_variable_args(const char *name, List *args) ...@@ -3992,10 +3992,8 @@ flatten_set_variable_args(const char *name, List *args)
Int32GetDatum(arg->typename->typmod)); Int32GetDatum(arg->typename->typmod));
intervalout = intervalout =
DatumGetCString(DirectFunctionCall3(interval_out, DatumGetCString(DirectFunctionCall1(interval_out,
interval, interval));
ObjectIdGetDatum(InvalidOid),
Int32GetDatum(-1)));
appendStringInfo(&buf, "INTERVAL '%s'", intervalout); appendStringInfo(&buf, "INTERVAL '%s'", intervalout);
} }
else else
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.98 2005/04/14 20:03:27 tgl Exp $ * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.99 2005/05/01 18:56:19 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -89,11 +89,9 @@ extern Oid get_typ_typrelid(Oid typid); ...@@ -89,11 +89,9 @@ extern Oid get_typ_typrelid(Oid typid);
extern Oid get_element_type(Oid typid); extern Oid get_element_type(Oid typid);
extern Oid get_array_type(Oid typid); extern Oid get_array_type(Oid typid);
extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam); extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);
extern void getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typIOParam, extern void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena);
bool *typIsVarlena);
extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam); extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typIOParam, extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);
bool *typIsVarlena);
extern Oid getBaseType(Oid typid); extern Oid getBaseType(Oid typid);
extern int32 get_typavgwidth(Oid typid, int32 typmod); extern int32 get_typavgwidth(Oid typid, int32 typmod);
extern int32 get_attavgwidth(Oid relid, AttrNumber attnum); extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS. * ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.71 2005/04/01 19:34:06 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.72 2005/05/01 18:56:19 tgl Exp $
* *
**********************************************************************/ **********************************************************************/
...@@ -83,7 +83,6 @@ typedef struct plperl_proc_desc ...@@ -83,7 +83,6 @@ typedef struct plperl_proc_desc
Oid result_typioparam; Oid result_typioparam;
int nargs; int nargs;
FmgrInfo arg_out_func[FUNC_MAX_ARGS]; FmgrInfo arg_out_func[FUNC_MAX_ARGS];
Oid arg_typioparam[FUNC_MAX_ARGS];
bool arg_is_rowtype[FUNC_MAX_ARGS]; bool arg_is_rowtype[FUNC_MAX_ARGS];
SV *reference; SV *reference;
} plperl_proc_desc; } plperl_proc_desc;
...@@ -707,10 +706,8 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo) ...@@ -707,10 +706,8 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
{ {
char *tmp; char *tmp;
tmp = DatumGetCString(FunctionCall3(&(desc->arg_out_func[i]), tmp = DatumGetCString(FunctionCall1(&(desc->arg_out_func[i]),
fcinfo->arg[i], fcinfo->arg[i]));
ObjectIdGetDatum(desc->arg_typioparam[i]),
Int32GetDatum(-1)));
XPUSHs(sv_2mortal(newSVpv(tmp, 0))); XPUSHs(sv_2mortal(newSVpv(tmp, 0)));
pfree(tmp); pfree(tmp);
} }
...@@ -1322,7 +1319,6 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -1322,7 +1319,6 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
prodesc->arg_is_rowtype[i] = false; prodesc->arg_is_rowtype[i] = false;
perm_fmgr_info(typeStruct->typoutput, perm_fmgr_info(typeStruct->typoutput,
&(prodesc->arg_out_func[i])); &(prodesc->arg_out_func[i]));
prodesc->arg_typioparam[i] = getTypeIOParam(typeTup);
} }
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
...@@ -1386,7 +1382,6 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc) ...@@ -1386,7 +1382,6 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
char *attname; char *attname;
char *outputstr; char *outputstr;
Oid typoutput; Oid typoutput;
Oid typioparam;
bool typisvarlena; bool typisvarlena;
int namelen; int namelen;
...@@ -1406,12 +1401,10 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc) ...@@ -1406,12 +1401,10 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
/* XXX should have a way to cache these lookups */ /* XXX should have a way to cache these lookups */
getTypeOutputInfo(tupdesc->attrs[i]->atttypid, getTypeOutputInfo(tupdesc->attrs[i]->atttypid,
&typoutput, &typioparam, &typisvarlena); &typoutput, &typisvarlena);
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall1(typoutput,
attr, attr));
ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
hv_store(hv, attname, namelen, newSVpv(outputstr, 0), 0); hv_store(hv, attname, namelen, newSVpv(outputstr, 0), 0);
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.135 2005/04/07 14:53:04 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.136 2005/05/01 18:56:19 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -3881,15 +3881,11 @@ static char * ...@@ -3881,15 +3881,11 @@ static char *
convert_value_to_string(Datum value, Oid valtype) convert_value_to_string(Datum value, Oid valtype)
{ {
Oid typoutput; Oid typoutput;
Oid typioparam;
bool typIsVarlena; bool typIsVarlena;
getTypeOutputInfo(valtype, &typoutput, &typioparam, &typIsVarlena); getTypeOutputInfo(valtype, &typoutput, &typIsVarlena);
return DatumGetCString(OidFunctionCall3(typoutput, return DatumGetCString(OidFunctionCall1(typoutput, value));
value,
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)));
} }
/* ---------- /* ----------
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS. * ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.95 2005/03/29 00:17:25 tgl Exp $ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.96 2005/05/01 18:56:19 tgl Exp $
* *
**********************************************************************/ **********************************************************************/
...@@ -112,7 +112,6 @@ typedef struct pltcl_proc_desc ...@@ -112,7 +112,6 @@ typedef struct pltcl_proc_desc
Oid result_typioparam; Oid result_typioparam;
int nargs; int nargs;
FmgrInfo arg_out_func[FUNC_MAX_ARGS]; FmgrInfo arg_out_func[FUNC_MAX_ARGS];
Oid arg_typioparam[FUNC_MAX_ARGS];
bool arg_is_rowtype[FUNC_MAX_ARGS]; bool arg_is_rowtype[FUNC_MAX_ARGS];
} pltcl_proc_desc; } pltcl_proc_desc;
...@@ -555,10 +554,8 @@ pltcl_func_handler(PG_FUNCTION_ARGS) ...@@ -555,10 +554,8 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
{ {
char *tmp; char *tmp;
tmp = DatumGetCString(FunctionCall3(&prodesc->arg_out_func[i], tmp = DatumGetCString(FunctionCall1(&prodesc->arg_out_func[i],
fcinfo->arg[i], fcinfo->arg[i]));
ObjectIdGetDatum(prodesc->arg_typioparam[i]),
Int32GetDatum(-1)));
UTF_BEGIN; UTF_BEGIN;
Tcl_DStringAppendElement(&tcl_cmd, UTF_E2U(tmp)); Tcl_DStringAppendElement(&tcl_cmd, UTF_E2U(tmp));
UTF_END; UTF_END;
...@@ -1160,7 +1157,6 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) ...@@ -1160,7 +1157,6 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
prodesc->arg_is_rowtype[i] = false; prodesc->arg_is_rowtype[i] = false;
perm_fmgr_info(typeStruct->typoutput, perm_fmgr_info(typeStruct->typoutput,
&(prodesc->arg_out_func[i])); &(prodesc->arg_out_func[i]));
prodesc->arg_typioparam[i] = getTypeIOParam(typeTup);
snprintf(buf, sizeof(buf), "%d", i + 1); snprintf(buf, sizeof(buf), "%d", i + 1);
} }
...@@ -2172,7 +2168,6 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, ...@@ -2172,7 +2168,6 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
CONST84 char *attname; CONST84 char *attname;
HeapTuple typeTup; HeapTuple typeTup;
Oid typoutput; Oid typoutput;
Oid typioparam;
CONST84 char **arrptr; CONST84 char **arrptr;
CONST84 char **nameptr; CONST84 char **nameptr;
...@@ -2223,7 +2218,6 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, ...@@ -2223,7 +2218,6 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
tupdesc->attrs[i]->atttypid); tupdesc->attrs[i]->atttypid);
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput; typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
/************************************************************ /************************************************************
...@@ -2236,10 +2230,8 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, ...@@ -2236,10 +2230,8 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
************************************************************/ ************************************************************/
if (!isnull && OidIsValid(typoutput)) if (!isnull && OidIsValid(typoutput))
{ {
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall1(typoutput,
attr, attr));
ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
UTF_BEGIN; UTF_BEGIN;
Tcl_SetVar2(interp, *arrptr, *nameptr, UTF_E2U(outputstr), 0); Tcl_SetVar2(interp, *arrptr, *nameptr, UTF_E2U(outputstr), 0);
UTF_END; UTF_END;
...@@ -2267,7 +2259,6 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, ...@@ -2267,7 +2259,6 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
char *attname; char *attname;
HeapTuple typeTup; HeapTuple typeTup;
Oid typoutput; Oid typoutput;
Oid typioparam;
for (i = 0; i < tupdesc->natts; i++) for (i = 0; i < tupdesc->natts; i++)
{ {
...@@ -2297,7 +2288,6 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, ...@@ -2297,7 +2288,6 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
tupdesc->attrs[i]->atttypid); tupdesc->attrs[i]->atttypid);
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput; typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
/************************************************************ /************************************************************
...@@ -2310,10 +2300,8 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, ...@@ -2310,10 +2300,8 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
************************************************************/ ************************************************************/
if (!isnull && OidIsValid(typoutput)) if (!isnull && OidIsValid(typoutput))
{ {
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall1(typoutput,
attr, attr));
ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
Tcl_DStringAppendElement(retval, attname); Tcl_DStringAppendElement(retval, attname);
UTF_BEGIN; UTF_BEGIN;
Tcl_DStringAppendElement(retval, UTF_E2U(outputstr)); Tcl_DStringAppendElement(retval, UTF_E2U(outputstr));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment