Commit c541bb86 authored by Tom Lane's avatar Tom Lane

Infrastructure for I/O of composite types: arrange for the I/O routines

of a composite type to get that type's OID as their second parameter,
in place of typelem which is useless.  The actual changes are mostly
centralized in getTypeInputInfo and siblings, but I had to fix a few
places that were fetching pg_type.typelem for themselves instead of
using the lsyscache.c routines.  Also, I renamed all the related variables
from 'typelem' to 'typioparam' to discourage people from assuming that
they necessarily contain array element types.
parent c3a153af
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.50 2004/05/16 23:22:07 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.51 2004/06/06 00:41:25 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -102,13 +102,15 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> ( ...@@ -102,13 +102,15 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> (
or as taking three arguments of types or as taking three arguments of types
<type>cstring</type>, <type>oid</type>, <type>integer</type>. <type>cstring</type>, <type>oid</type>, <type>integer</type>.
The first argument is the input text as a C string, the second The first argument is the input text as a C string, the second
argument is the element type in case this is an array type, argument is the element type's OID in case this is an array 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.
The input function should return a value of the data type itself. The input function should return a value of the data type itself.
The output function may be The output function may be
declared as taking one argument of the new data type, or as taking declared as taking one argument of the new data type, or as taking
two arguments of which the second is type <type>oid</type>. two arguments of which the second is type <type>oid</type>.
The second argument is again the array element type for array types. 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>. The output function should return type <type>cstring</type>.
</para> </para>
...@@ -128,14 +130,16 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> ( ...@@ -128,14 +130,16 @@ CREATE TYPE <replaceable class="parameter">name</replaceable> (
and <type>oid</type>. It must return a value of the data type itself. and <type>oid</type>. It must return a value of the data type itself.
(The first argument is a pointer to a <type>StringInfo</type> buffer (The first argument is a pointer to a <type>StringInfo</type> buffer
holding the received byte string; the optional second argument is the holding the received byte string; the optional second argument is the
element type in case this is an array type.) Similarly, the optional element type OID in case this is an array type, or the type's own OID for a
composite type.) Similarly, the optional
<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 may be
declared as taking one argument of the new data type, or as taking declared as taking one argument of the new data type, or as taking
two arguments of which the second is type <type>oid</type>. two arguments of which the second is type <type>oid</type>.
The second argument is again the array element type for array types. 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.82 2004/06/04 20:35:21 tgl Exp $ * $PostgreSQL: pgsql/src/backend/access/common/printtup.c,v 1.83 2004/06/06 00:41:25 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -51,7 +51,7 @@ typedef struct ...@@ -51,7 +51,7 @@ 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 typelem; /* typelem value to pass to the 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 */
...@@ -278,7 +278,7 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ...@@ -278,7 +278,7 @@ 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->typelem, &thisState->typioparam,
&thisState->typisvarlena); &thisState->typisvarlena);
fmgr_info(thisState->typoutput, &thisState->finfo); fmgr_info(thisState->typoutput, &thisState->finfo);
} }
...@@ -286,7 +286,7 @@ printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs) ...@@ -286,7 +286,7 @@ 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->typelem, &thisState->typioparam,
&thisState->typisvarlena); &thisState->typisvarlena);
fmgr_info(thisState->typsend, &thisState->finfo); fmgr_info(thisState->typsend, &thisState->finfo);
} }
...@@ -356,7 +356,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -356,7 +356,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
outputstr = DatumGetCString(FunctionCall3(&thisState->finfo, outputstr = DatumGetCString(FunctionCall3(&thisState->finfo,
attr, attr,
ObjectIdGetDatum(thisState->typelem), ObjectIdGetDatum(thisState->typioparam),
Int32GetDatum(typeinfo->attrs[i]->atttypmod))); Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false); pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false);
pfree(outputstr); pfree(outputstr);
...@@ -368,7 +368,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -368,7 +368,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
outputbytes = DatumGetByteaP(FunctionCall2(&thisState->finfo, outputbytes = DatumGetByteaP(FunctionCall2(&thisState->finfo,
attr, attr,
ObjectIdGetDatum(thisState->typelem))); 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),
...@@ -458,7 +458,7 @@ printtup_20(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -458,7 +458,7 @@ printtup_20(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
outputstr = DatumGetCString(FunctionCall3(&thisState->finfo, outputstr = DatumGetCString(FunctionCall3(&thisState->finfo,
attr, attr,
ObjectIdGetDatum(thisState->typelem), ObjectIdGetDatum(thisState->typioparam),
Int32GetDatum(typeinfo->attrs[i]->atttypmod))); Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
pq_sendcountedtext(&buf, outputstr, strlen(outputstr), true); pq_sendcountedtext(&buf, outputstr, strlen(outputstr), true);
pfree(outputstr); pfree(outputstr);
...@@ -557,7 +557,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -557,7 +557,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
char *value; char *value;
bool isnull; bool isnull;
Oid typoutput, Oid typoutput,
typelem; typioparam;
bool typisvarlena; bool typisvarlena;
for (i = 0; i < natts; ++i) for (i = 0; i < natts; ++i)
...@@ -566,7 +566,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -566,7 +566,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
if (isnull) if (isnull)
continue; continue;
getTypeOutputInfo(typeinfo->attrs[i]->atttypid, getTypeOutputInfo(typeinfo->attrs[i]->atttypid,
&typoutput, &typelem, &typisvarlena); &typoutput, &typioparam, &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
...@@ -579,7 +579,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -579,7 +579,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
value = DatumGetCString(OidFunctionCall3(typoutput, value = DatumGetCString(OidFunctionCall3(typoutput,
attr, attr,
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(typeinfo->attrs[i]->atttypmod))); Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
printatt((unsigned) i + 1, typeinfo->attrs[i], value); printatt((unsigned) i + 1, typeinfo->attrs[i], value);
...@@ -672,7 +672,7 @@ printtup_internal_20(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self) ...@@ -672,7 +672,7 @@ printtup_internal_20(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
outputbytes = DatumGetByteaP(FunctionCall2(&thisState->finfo, outputbytes = DatumGetByteaP(FunctionCall2(&thisState->finfo,
attr, attr,
ObjectIdGetDatum(thisState->typelem))); 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.183 2004/06/03 02:08:02 tgl Exp $ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.184 2004/06/06 00:41:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -803,9 +803,11 @@ InsertOneTuple(Oid objectid) ...@@ -803,9 +803,11 @@ InsertOneTuple(Oid objectid)
void void
InsertOneValue(char *value, int i) InsertOneValue(char *value, int i)
{ {
int typeindex; Oid typoid;
Oid typioparam;
Oid typinput;
Oid typoutput;
char *prt; char *prt;
struct typmap **app;
AssertArg(i >= 0 || i < MAXATTR); AssertArg(i >= 0 || i < MAXATTR);
...@@ -813,51 +815,59 @@ InsertOneValue(char *value, int i) ...@@ -813,51 +815,59 @@ InsertOneValue(char *value, int i)
if (Typ != NULL) if (Typ != NULL)
{ {
struct typmap **app;
struct typmap *ap; struct typmap *ap;
elog(DEBUG4, "Typ != NULL"); elog(DEBUG5, "Typ != NULL");
typoid = boot_reldesc->rd_att->attrs[i]->atttypid;
app = Typ; app = Typ;
while (*app && (*app)->am_oid != boot_reldesc->rd_att->attrs[i]->atttypid) while (*app && (*app)->am_oid != typoid)
++app; ++app;
ap = *app; ap = *app;
if (ap == NULL) if (ap == NULL)
{ elog(ERROR, "could not find atttypid %u in Typ list", typoid);
elog(FATAL, "could not find atttypid %u in Typ list",
boot_reldesc->rd_att->attrs[i]->atttypid); /* XXX this should match getTypeIOParam() */
} if (ap->am_typ.typtype == 'c')
values[i] = OidFunctionCall3(ap->am_typ.typinput, typioparam = typoid;
CStringGetDatum(value), else
ObjectIdGetDatum(ap->am_typ.typelem), typioparam = ap->am_typ.typelem;
Int32GetDatum(-1));
prt = DatumGetCString(OidFunctionCall3(ap->am_typ.typoutput, typinput = ap->am_typ.typinput;
values[i], typoutput = ap->am_typ.typoutput;
ObjectIdGetDatum(ap->am_typ.typelem),
Int32GetDatum(-1)));
elog(DEBUG4, " -> %s", prt);
pfree(prt);
} }
else else
{ {
int typeindex;
/* XXX why is typoid determined differently in this path? */
typoid = attrtypes[i]->atttypid;
for (typeindex = 0; typeindex < n_types; typeindex++) for (typeindex = 0; typeindex < n_types; typeindex++)
{ {
if (TypInfo[typeindex].oid == attrtypes[i]->atttypid) if (TypInfo[typeindex].oid == typoid)
break; break;
} }
if (typeindex >= n_types) if (typeindex >= n_types)
elog(ERROR, "type oid %u not found", attrtypes[i]->atttypid); elog(ERROR, "type oid %u not found", typoid);
elog(DEBUG4, "Typ == NULL, typeindex = %u", typeindex); elog(DEBUG5, "Typ == NULL, typeindex = %u", typeindex);
values[i] = OidFunctionCall3(TypInfo[typeindex].inproc,
CStringGetDatum(value), /* XXX there are no composite types in TypInfo */
ObjectIdGetDatum(TypInfo[typeindex].elem), typioparam = TypInfo[typeindex].elem;
Int32GetDatum(-1));
prt = DatumGetCString(OidFunctionCall3(TypInfo[typeindex].outproc, typinput = TypInfo[typeindex].inproc;
values[i], typoutput = TypInfo[typeindex].outproc;
ObjectIdGetDatum(TypInfo[typeindex].elem),
Int32GetDatum(-1)));
elog(DEBUG4, " -> %s", prt);
pfree(prt);
} }
elog(DEBUG4, "inserted");
values[i] = OidFunctionCall3(typinput,
CStringGetDatum(value),
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1));
prt = DatumGetCString(OidFunctionCall3(typoutput,
values[i],
ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)));
elog(DEBUG4, "inserted -> %s", prt);
pfree(prt);
} }
/* ---------------- /* ----------------
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.225 2004/06/05 19:48:07 tgl Exp $ * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.226 2004/06/06 00:41:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -143,7 +143,7 @@ static char *CopyReadAttributeCSV(const char *delim, const char *null_print, ...@@ -143,7 +143,7 @@ static char *CopyReadAttributeCSV(const char *delim, const char *null_print,
char *quote, char *escape, char *quote, char *escape,
CopyReadResult *result, bool *isnull); CopyReadResult *result, bool *isnull);
static Datum CopyReadBinaryAttribute(int column_no, FmgrInfo *flinfo, static Datum CopyReadBinaryAttribute(int column_no, FmgrInfo *flinfo,
Oid typelem, bool *isnull); Oid typioparam, bool *isnull);
static void CopyAttributeOut(char *string, char *delim); static void CopyAttributeOut(char *string, char *delim);
static void CopyAttributeOutCSV(char *string, char *delim, char *quote, static void CopyAttributeOutCSV(char *string, char *delim, char *quote,
char *escape, bool force_quote); char *escape, bool force_quote);
...@@ -1143,7 +1143,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1143,7 +1143,7 @@ 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 *elements; Oid *typioparams;
bool *isvarlena; bool *isvarlena;
char *string; char *string;
Snapshot mySnapshot; Snapshot mySnapshot;
...@@ -1160,7 +1160,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1160,7 +1160,7 @@ 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));
elements = (Oid *) palloc(num_phys_attrs * sizeof(Oid)); typioparams = (Oid *) palloc(num_phys_attrs * sizeof(Oid));
isvarlena = (bool *) palloc(num_phys_attrs * sizeof(bool)); 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)
...@@ -1170,11 +1170,11 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1170,11 +1170,11 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
if (binary) if (binary)
getTypeBinaryOutputInfo(attr[attnum - 1]->atttypid, getTypeBinaryOutputInfo(attr[attnum - 1]->atttypid,
&out_func_oid, &elements[attnum - 1], &out_func_oid, &typioparams[attnum - 1],
&isvarlena[attnum - 1]); &isvarlena[attnum - 1]);
else else
getTypeOutputInfo(attr[attnum - 1]->atttypid, getTypeOutputInfo(attr[attnum - 1]->atttypid,
&out_func_oid, &elements[attnum - 1], &out_func_oid, &typioparams[attnum - 1],
&isvarlena[attnum - 1]); &isvarlena[attnum - 1]);
fmgr_info(out_func_oid, &out_functions[attnum - 1]); fmgr_info(out_func_oid, &out_functions[attnum - 1]);
...@@ -1290,7 +1290,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1290,7 +1290,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
{ {
string = DatumGetCString(FunctionCall3(&out_functions[attnum - 1], string = DatumGetCString(FunctionCall3(&out_functions[attnum - 1],
value, value,
ObjectIdGetDatum(elements[attnum - 1]), ObjectIdGetDatum(typioparams[attnum - 1]),
Int32GetDatum(attr[attnum - 1]->atttypmod))); Int32GetDatum(attr[attnum - 1]->atttypmod)));
if (csv_mode) if (csv_mode)
{ {
...@@ -1308,7 +1308,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1308,7 +1308,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
outputbytes = DatumGetByteaP(FunctionCall2(&out_functions[attnum - 1], outputbytes = DatumGetByteaP(FunctionCall2(&out_functions[attnum - 1],
value, value,
ObjectIdGetDatum(elements[attnum - 1]))); 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),
...@@ -1333,7 +1333,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1333,7 +1333,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids,
MemoryContextDelete(mycontext); MemoryContextDelete(mycontext);
pfree(out_functions); pfree(out_functions);
pfree(elements); pfree(typioparams);
pfree(isvarlena); pfree(isvarlena);
pfree(force_quote); pfree(force_quote);
} }
...@@ -1442,8 +1442,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1442,8 +1442,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
num_defaults; num_defaults;
FmgrInfo *in_functions; FmgrInfo *in_functions;
FmgrInfo oid_in_function; FmgrInfo oid_in_function;
Oid *elements; Oid *typioparams;
Oid oid_in_element; Oid oid_typioparam;
ExprState **constraintexprs; ExprState **constraintexprs;
bool *force_notnull; bool *force_notnull;
bool hasConstraints = false; bool hasConstraints = false;
...@@ -1501,7 +1501,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1501,7 +1501,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
* (Which input function we use depends on text/binary format choice.) * (Which input function we use depends on text/binary format choice.)
*/ */
in_functions = (FmgrInfo *) palloc(num_phys_attrs * sizeof(FmgrInfo)); in_functions = (FmgrInfo *) palloc(num_phys_attrs * sizeof(FmgrInfo));
elements = (Oid *) palloc(num_phys_attrs * sizeof(Oid)); typioparams = (Oid *) palloc(num_phys_attrs * sizeof(Oid));
defmap = (int *) palloc(num_phys_attrs * sizeof(int)); defmap = (int *) palloc(num_phys_attrs * sizeof(int));
defexprs = (ExprState **) palloc(num_phys_attrs * sizeof(ExprState *)); defexprs = (ExprState **) palloc(num_phys_attrs * sizeof(ExprState *));
constraintexprs = (ExprState **) palloc0(num_phys_attrs * sizeof(ExprState *)); constraintexprs = (ExprState **) palloc0(num_phys_attrs * sizeof(ExprState *));
...@@ -1513,13 +1513,13 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1513,13 +1513,13 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
if (attr[attnum - 1]->attisdropped) if (attr[attnum - 1]->attisdropped)
continue; continue;
/* Fetch the input function and typelem info */ /* Fetch the input function and typioparam info */
if (binary) if (binary)
getTypeBinaryInputInfo(attr[attnum - 1]->atttypid, getTypeBinaryInputInfo(attr[attnum - 1]->atttypid,
&in_func_oid, &elements[attnum - 1]); &in_func_oid, &typioparams[attnum - 1]);
else else
getTypeInputInfo(attr[attnum - 1]->atttypid, getTypeInputInfo(attr[attnum - 1]->atttypid,
&in_func_oid, &elements[attnum - 1]); &in_func_oid, &typioparams[attnum - 1]);
fmgr_info(in_func_oid, &in_functions[attnum - 1]); fmgr_info(in_func_oid, &in_functions[attnum - 1]);
if (list_member_int(force_notnull_atts, attnum)) if (list_member_int(force_notnull_atts, attnum))
...@@ -1628,7 +1628,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1628,7 +1628,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
if (file_has_oids && binary) if (file_has_oids && binary)
{ {
getTypeBinaryInputInfo(OIDOID, getTypeBinaryInputInfo(OIDOID,
&in_func_oid, &oid_in_element); &in_func_oid, &oid_typioparam);
fmgr_info(in_func_oid, &oid_in_function); fmgr_info(in_func_oid, &oid_in_function);
} }
...@@ -1757,7 +1757,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1757,7 +1757,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
copy_attname = NameStr(attr[m]->attname); copy_attname = NameStr(attr[m]->attname);
values[m] = FunctionCall3(&in_functions[m], values[m] = FunctionCall3(&in_functions[m],
CStringGetDatum(string), CStringGetDatum(string),
ObjectIdGetDatum(elements[m]), ObjectIdGetDatum(typioparams[m]),
Int32GetDatum(attr[m]->atttypmod)); Int32GetDatum(attr[m]->atttypmod));
nulls[m] = ' '; nulls[m] = ' ';
copy_attname = NULL; copy_attname = NULL;
...@@ -1800,8 +1800,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1800,8 +1800,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
copy_attname = "oid"; copy_attname = "oid";
loaded_oid = loaded_oid =
DatumGetObjectId(CopyReadBinaryAttribute(0, DatumGetObjectId(CopyReadBinaryAttribute(0,
&oid_in_function, &oid_in_function,
oid_in_element, oid_typioparam,
&isnull)); &isnull));
if (isnull || loaded_oid == InvalidOid) if (isnull || loaded_oid == InvalidOid)
ereport(ERROR, ereport(ERROR,
...@@ -1820,7 +1820,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1820,7 +1820,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
i++; i++;
values[m] = CopyReadBinaryAttribute(i, values[m] = CopyReadBinaryAttribute(i,
&in_functions[m], &in_functions[m],
elements[m], typioparams[m],
&isnull); &isnull);
nulls[m] = isnull ? 'n' : ' '; nulls[m] = isnull ? 'n' : ' ';
copy_attname = NULL; copy_attname = NULL;
...@@ -1941,7 +1941,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, ...@@ -1941,7 +1941,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids,
pfree(nulls); pfree(nulls);
pfree(in_functions); pfree(in_functions);
pfree(elements); pfree(typioparams);
pfree(defmap); pfree(defmap);
pfree(defexprs); pfree(defexprs);
pfree(constraintexprs); pfree(constraintexprs);
...@@ -2429,7 +2429,7 @@ CopyReadAttributeCSV(const char *delim, const char *null_print, char *quote, ...@@ -2429,7 +2429,7 @@ CopyReadAttributeCSV(const char *delim, const char *null_print, char *quote,
* Read a binary attribute * Read a binary attribute
*/ */
static Datum static Datum
CopyReadBinaryAttribute(int column_no, FmgrInfo *flinfo, Oid typelem, CopyReadBinaryAttribute(int column_no, FmgrInfo *flinfo, Oid typioparam,
bool *isnull) bool *isnull)
{ {
int32 fld_size; int32 fld_size;
...@@ -2469,7 +2469,7 @@ CopyReadBinaryAttribute(int column_no, FmgrInfo *flinfo, Oid typelem, ...@@ -2469,7 +2469,7 @@ CopyReadBinaryAttribute(int column_no, FmgrInfo *flinfo, Oid typelem,
/* Call the column type's binary input converter */ /* Call the column type's binary input converter */
result = FunctionCall2(flinfo, result = FunctionCall2(flinfo,
PointerGetDatum(&attribute_buf), PointerGetDatum(&attribute_buf),
ObjectIdGetDatum(typelem)); ObjectIdGetDatum(typioparam));
/* Trouble if it didn't eat the whole buffer */ /* Trouble if it didn't eat the whole buffer */
if (attribute_buf.cursor != attribute_buf.len) if (attribute_buf.cursor != attribute_buf.len)
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.79 2004/05/30 23:40:26 neilc Exp $ * $PostgreSQL: pgsql/src/backend/executor/execTuples.c,v 1.80 2004/06/06 00:41:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -685,7 +685,7 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc) ...@@ -685,7 +685,7 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc)
Oid atttypeid; Oid atttypeid;
Oid attinfuncid; Oid attinfuncid;
FmgrInfo *attinfuncinfo; FmgrInfo *attinfuncinfo;
Oid *attelems; Oid *attioparams;
int32 *atttypmods; int32 *atttypmods;
AttInMetadata *attinmeta; AttInMetadata *attinmeta;
...@@ -699,7 +699,7 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc) ...@@ -699,7 +699,7 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc)
* attribute * attribute
*/ */
attinfuncinfo = (FmgrInfo *) palloc0(natts * sizeof(FmgrInfo)); attinfuncinfo = (FmgrInfo *) palloc0(natts * sizeof(FmgrInfo));
attelems = (Oid *) palloc0(natts * sizeof(Oid)); attioparams = (Oid *) palloc0(natts * sizeof(Oid));
atttypmods = (int32 *) palloc0(natts * sizeof(int32)); atttypmods = (int32 *) palloc0(natts * sizeof(int32));
for (i = 0; i < natts; i++) for (i = 0; i < natts; i++)
...@@ -708,13 +708,13 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc) ...@@ -708,13 +708,13 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc)
if (!tupdesc->attrs[i]->attisdropped) if (!tupdesc->attrs[i]->attisdropped)
{ {
atttypeid = tupdesc->attrs[i]->atttypid; atttypeid = tupdesc->attrs[i]->atttypid;
getTypeInputInfo(atttypeid, &attinfuncid, &attelems[i]); getTypeInputInfo(atttypeid, &attinfuncid, &attioparams[i]);
fmgr_info(attinfuncid, &attinfuncinfo[i]); fmgr_info(attinfuncid, &attinfuncinfo[i]);
atttypmods[i] = tupdesc->attrs[i]->atttypmod; atttypmods[i] = tupdesc->attrs[i]->atttypmod;
} }
} }
attinmeta->attinfuncs = attinfuncinfo; attinmeta->attinfuncs = attinfuncinfo;
attinmeta->attelems = attelems; attinmeta->attioparams = attioparams;
attinmeta->atttypmods = atttypmods; attinmeta->atttypmods = atttypmods;
return attinmeta; return attinmeta;
...@@ -732,7 +732,7 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values) ...@@ -732,7 +732,7 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
Datum *dvalues; Datum *dvalues;
char *nulls; char *nulls;
int i; int i;
Oid attelem; Oid attioparam;
int32 atttypmod; int32 atttypmod;
HeapTuple tuple; HeapTuple tuple;
...@@ -747,12 +747,12 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values) ...@@ -747,12 +747,12 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
/* Non-dropped attributes */ /* Non-dropped attributes */
if (values[i] != NULL) if (values[i] != NULL)
{ {
attelem = attinmeta->attelems[i]; attioparam = attinmeta->attioparams[i];
atttypmod = attinmeta->atttypmods[i]; atttypmod = attinmeta->atttypmods[i];
dvalues[i] = FunctionCall3(&attinmeta->attinfuncs[i], dvalues[i] = FunctionCall3(&attinmeta->attinfuncs[i],
CStringGetDatum(values[i]), CStringGetDatum(values[i]),
ObjectIdGetDatum(attelem), ObjectIdGetDatum(attioparam),
Int32GetDatum(atttypmod)); Int32GetDatum(atttypmod));
nulls[i] = ' '; nulls[i] = ' ';
} }
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,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/executor/nodeAgg.c,v 1.121 2004/05/30 23:40:26 neilc Exp $ * $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.122 2004/06/06 00:41:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1357,29 +1357,17 @@ ExecInitAgg(Agg *node, EState *estate) ...@@ -1357,29 +1357,17 @@ ExecInitAgg(Agg *node, EState *estate)
static Datum static Datum
GetAggInitVal(Datum textInitVal, Oid transtype) GetAggInitVal(Datum textInitVal, Oid transtype)
{ {
char *strInitVal;
HeapTuple tup;
Oid typinput, Oid typinput,
typelem; typioparam;
char *strInitVal;
Datum initVal; Datum initVal;
getTypeInputInfo(transtype, &typinput, &typioparam);
strInitVal = DatumGetCString(DirectFunctionCall1(textout, textInitVal)); strInitVal = DatumGetCString(DirectFunctionCall1(textout, textInitVal));
tup = SearchSysCache(TYPEOID,
ObjectIdGetDatum(transtype),
0, 0, 0);
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for type %u", transtype);
typinput = ((Form_pg_type) GETSTRUCT(tup))->typinput;
typelem = ((Form_pg_type) GETSTRUCT(tup))->typelem;
ReleaseSysCache(tup);
initVal = OidFunctionCall3(typinput, initVal = OidFunctionCall3(typinput,
CStringGetDatum(strInitVal), CStringGetDatum(strInitVal),
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)); Int32GetDatum(-1));
pfree(strInitVal); pfree(strInitVal);
return initVal; return initVal;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.116 2004/06/04 20:35:21 tgl Exp $ * $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.117 2004/06/06 00:41:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -538,7 +538,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) ...@@ -538,7 +538,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
bool isnull; bool isnull;
Oid typoid, Oid typoid,
foutoid, foutoid,
typelem; typioparam;
int32 typmod; int32 typmod;
bool typisvarlena; bool typisvarlena;
...@@ -566,7 +566,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) ...@@ -566,7 +566,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
typmod = -1; typmod = -1;
} }
getTypeOutputInfo(typoid, &foutoid, &typelem, &typisvarlena); getTypeOutputInfo(typoid, &foutoid, &typioparam, &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
...@@ -579,7 +579,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) ...@@ -579,7 +579,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
result = OidFunctionCall3(foutoid, result = OidFunctionCall3(foutoid,
val, val,
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(typmod)); Int32GetDatum(typmod));
/* Clean up detoasted copy, if any */ /* Clean up detoasted copy, if any */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.68 2004/05/30 23:40:27 neilc Exp $ * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.69 2004/06/06 00:41:26 tgl Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "postgres.h" #include "postgres.h"
#include "access/printtup.h" #include "access/printtup.h"
#include "catalog/pg_type.h"
#include "lib/stringinfo.h" #include "lib/stringinfo.h"
#include "nodes/print.h" #include "nodes/print.h"
#include "optimizer/clauses.h" #include "optimizer/clauses.h"
...@@ -345,9 +344,9 @@ print_expr(Node *expr, List *rtable) ...@@ -345,9 +344,9 @@ print_expr(Node *expr, List *rtable)
else if (IsA(expr, Const)) else if (IsA(expr, Const))
{ {
Const *c = (Const *) expr; Const *c = (Const *) expr;
HeapTuple typeTup;
Oid typoutput; Oid typoutput;
Oid typelem; Oid typioparam;
bool typIsVarlena;
char *outputstr; char *outputstr;
if (c->constisnull) if (c->constisnull)
...@@ -356,18 +355,12 @@ print_expr(Node *expr, List *rtable) ...@@ -356,18 +355,12 @@ print_expr(Node *expr, List *rtable)
return; return;
} }
typeTup = SearchSysCache(TYPEOID, getTypeOutputInfo(c->consttype,
ObjectIdGetDatum(c->consttype), &typoutput, &typioparam, &typIsVarlena);
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", c->consttype);
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
ReleaseSysCache(typeTup);
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall3(typoutput,
c->constvalue, c->constvalue,
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(-1))); 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/parser/parse_coerce.c,v 2.117 2004/05/30 23:40:35 neilc Exp $ * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.118 2004/06/06 00:41:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -356,14 +356,10 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids, ...@@ -356,14 +356,10 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *target_typeids,
/* /*
* If input is an untyped string constant, assume we can convert * If input is an untyped string constant, assume we can convert
* it to anything except a class type. * it to anything.
*/ */
if (inputTypeId == UNKNOWNOID) if (inputTypeId == UNKNOWNOID)
{
if (ISCOMPLEX(targetTypeId))
return false;
continue; continue;
}
/* /*
* If pg_cast shows that we can coerce, accept. This test now * If pg_cast shows that we can coerce, accept. This test now
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.68 2004/06/03 19:41:46 tgl Exp $ * $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.69 2004/06/06 00:41:26 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -323,83 +323,24 @@ typeTypeRelid(Type typ) ...@@ -323,83 +323,24 @@ typeTypeRelid(Type typ)
return typtup->typrelid; return typtup->typrelid;
} }
#ifdef NOT_USED /*
Oid * Given a type structure and a string, returns the internal representation
typeTypElem(Type typ) * of that string
{ */
Form_pg_type typtup;
typtup = (Form_pg_type) GETSTRUCT(typ);
return typtup->typelem;
}
#endif
#ifdef NOT_USED
/* Given a type structure, return the in-conversion function of the type */
Oid
typeInfunc(Type typ)
{
Form_pg_type typtup;
typtup = (Form_pg_type) GETSTRUCT(typ);
return typtup->typinput;
}
#endif
#ifdef NOT_USED
/* Given a type structure, return the out-conversion function of the type */
Oid
typeOutfunc(Type typ)
{
Form_pg_type typtup;
typtup = (Form_pg_type) GETSTRUCT(typ);
return typtup->typoutput;
}
#endif
/* Given a type structure and a string, returns the internal form of
that string */
Datum Datum
stringTypeDatum(Type tp, char *string, int32 atttypmod) stringTypeDatum(Type tp, char *string, int32 atttypmod)
{ {
Oid op; Oid typinput;
Oid typelem; Oid typioparam;
op = ((Form_pg_type) GETSTRUCT(tp))->typinput; typinput = ((Form_pg_type) GETSTRUCT(tp))->typinput;
typelem = ((Form_pg_type) GETSTRUCT(tp))->typelem; /* XXX - used for typioparam = getTypeIOParam(tp);
* array_in */ return OidFunctionCall3(typinput,
return OidFunctionCall3(op,
CStringGetDatum(string), CStringGetDatum(string),
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(atttypmod)); Int32GetDatum(atttypmod));
} }
/* Given a type id, returns the out-conversion function of the type */
#ifdef NOT_USED
Oid
typeidOutfunc(Oid type_id)
{
HeapTuple typeTuple;
Form_pg_type type;
Oid outfunc;
typeTuple = SearchSysCache(TYPEOID,
ObjectIdGetDatum(type_id),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", type_id);
type = (Form_pg_type) GETSTRUCT(typeTuple);
outfunc = type->typoutput;
ReleaseSysCache(typeTuple);
return outfunc;
}
#endif
/* given a typeid, return the type's typrelid (associated relation, if any) */ /* given a typeid, return the type's typrelid (associated relation, if any) */
Oid Oid
typeidTypeRelid(Oid type_id) typeidTypeRelid(Oid type_id)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.72 2004/04/19 17:22:31 momjian Exp $ * $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.73 2004/06/06 00:41:27 tgl Exp $
* *
* NOTES * NOTES
* This cruft is the server side of PQfn. * This cruft is the server side of PQfn.
...@@ -150,14 +150,14 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format) ...@@ -150,14 +150,14 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
if (format == 0) if (format == 0)
{ {
Oid typoutput, Oid typoutput,
typelem; typioparam;
bool typisvarlena; bool typisvarlena;
char *outputstr; char *outputstr;
getTypeOutputInfo(rettype, &typoutput, &typelem, &typisvarlena); getTypeOutputInfo(rettype, &typoutput, &typioparam, &typisvarlena);
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall3(typoutput,
retval, retval,
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(-1))); Int32GetDatum(-1)));
pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false); pq_sendcountedtext(&buf, outputstr, strlen(outputstr), false);
pfree(outputstr); pfree(outputstr);
...@@ -165,15 +165,15 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format) ...@@ -165,15 +165,15 @@ SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
else if (format == 1) else if (format == 1)
{ {
Oid typsend, Oid typsend,
typelem; typioparam;
bool typisvarlena; bool typisvarlena;
bytea *outputbytes; bytea *outputbytes;
getTypeBinaryOutputInfo(rettype, getTypeBinaryOutputInfo(rettype,
&typsend, &typelem, &typisvarlena); &typsend, &typioparam, &typisvarlena);
outputbytes = DatumGetByteaP(OidFunctionCall2(typsend, outputbytes = DatumGetByteaP(OidFunctionCall2(typsend,
retval, retval,
ObjectIdGetDatum(typelem))); 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),
...@@ -467,11 +467,11 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip, ...@@ -467,11 +467,11 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip,
if (aformat == 0) if (aformat == 0)
{ {
Oid typInput; Oid typinput;
Oid typElem; Oid typioparam;
char *pstring; char *pstring;
getTypeInputInfo(fip->argtypes[i], &typInput, &typElem); getTypeInputInfo(fip->argtypes[i], &typinput, &typioparam);
/* /*
* Since stringinfo.c keeps a trailing null in place even for * Since stringinfo.c keeps a trailing null in place even for
...@@ -483,9 +483,9 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip, ...@@ -483,9 +483,9 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip,
pg_client_to_server((unsigned char *) abuf.data, pg_client_to_server((unsigned char *) abuf.data,
argsize); argsize);
fcinfo->arg[i] = fcinfo->arg[i] =
OidFunctionCall3(typInput, OidFunctionCall3(typinput,
CStringGetDatum(pstring), CStringGetDatum(pstring),
ObjectIdGetDatum(typElem), ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)); Int32GetDatum(-1));
/* Free result of encoding conversion, if any */ /* Free result of encoding conversion, if any */
if (pstring != abuf.data) if (pstring != abuf.data)
...@@ -493,15 +493,15 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip, ...@@ -493,15 +493,15 @@ parse_fcall_arguments(StringInfo msgBuf, struct fp_info * fip,
} }
else if (aformat == 1) else if (aformat == 1)
{ {
Oid typReceive; Oid typreceive;
Oid typElem; Oid typioparam;
/* Call the argument type's binary input converter */ /* Call the argument type's binary input converter */
getTypeBinaryInputInfo(fip->argtypes[i], &typReceive, &typElem); getTypeBinaryInputInfo(fip->argtypes[i], &typreceive, &typioparam);
fcinfo->arg[i] = OidFunctionCall2(typReceive, fcinfo->arg[i] = OidFunctionCall2(typreceive,
PointerGetDatum(&abuf), PointerGetDatum(&abuf),
ObjectIdGetDatum(typElem)); ObjectIdGetDatum(typioparam));
/* Trouble if it didn't eat the whole buffer */ /* Trouble if it didn't eat the whole buffer */
if (abuf.cursor != abuf.len) if (abuf.cursor != abuf.len)
...@@ -557,8 +557,8 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip, ...@@ -557,8 +557,8 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip,
for (i = 0; i < nargs; ++i) for (i = 0; i < nargs; ++i)
{ {
int argsize; int argsize;
Oid typReceive; Oid typreceive;
Oid typElem; Oid typioparam;
argsize = pq_getmsgint(msgBuf, 4); argsize = pq_getmsgint(msgBuf, 4);
if (argsize == -1) if (argsize == -1)
...@@ -582,11 +582,11 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip, ...@@ -582,11 +582,11 @@ parse_fcall_arguments_20(StringInfo msgBuf, struct fp_info * fip,
argsize); argsize);
/* Call the argument type's binary input converter */ /* Call the argument type's binary input converter */
getTypeBinaryInputInfo(fip->argtypes[i], &typReceive, &typElem); getTypeBinaryInputInfo(fip->argtypes[i], &typreceive, &typioparam);
fcinfo->arg[i] = OidFunctionCall2(typReceive, fcinfo->arg[i] = OidFunctionCall2(typreceive,
PointerGetDatum(&abuf), PointerGetDatum(&abuf),
ObjectIdGetDatum(typElem)); ObjectIdGetDatum(typioparam));
/* Trouble if it didn't eat the whole buffer */ /* Trouble if it didn't eat the whole buffer */
if (abuf.cursor != abuf.len) if (abuf.cursor != abuf.len)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.418 2004/06/03 02:08:03 tgl Exp $ * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.419 2004/06/06 00:41:27 tgl Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -1432,11 +1432,11 @@ exec_bind_message(StringInfo input_message) ...@@ -1432,11 +1432,11 @@ exec_bind_message(StringInfo input_message)
if (pformat == 0) if (pformat == 0)
{ {
Oid typInput; Oid typinput;
Oid typElem; Oid typioparam;
char *pstring; char *pstring;
getTypeInputInfo(ptype, &typInput, &typElem); getTypeInputInfo(ptype, &typinput, &typioparam);
/* /*
* We have to do encoding conversion before * We have to do encoding conversion before
...@@ -1446,9 +1446,9 @@ exec_bind_message(StringInfo input_message) ...@@ -1446,9 +1446,9 @@ exec_bind_message(StringInfo input_message)
pg_client_to_server((unsigned char *) pbuf.data, pg_client_to_server((unsigned char *) pbuf.data,
plength); plength);
params[i].value = params[i].value =
OidFunctionCall3(typInput, OidFunctionCall3(typinput,
CStringGetDatum(pstring), CStringGetDatum(pstring),
ObjectIdGetDatum(typElem), ObjectIdGetDatum(typioparam),
Int32GetDatum(-1)); Int32GetDatum(-1));
/* Free result of encoding conversion, if any */ /* Free result of encoding conversion, if any */
if (pstring != pbuf.data) if (pstring != pbuf.data)
...@@ -1456,19 +1456,19 @@ exec_bind_message(StringInfo input_message) ...@@ -1456,19 +1456,19 @@ exec_bind_message(StringInfo input_message)
} }
else if (pformat == 1) else if (pformat == 1)
{ {
Oid typReceive; Oid typreceive;
Oid typElem; Oid typioparam;
/* /*
* Call the parameter type's binary input * Call the parameter type's binary input
* converter * converter
*/ */
getTypeBinaryInputInfo(ptype, &typReceive, &typElem); getTypeBinaryInputInfo(ptype, &typreceive, &typioparam);
params[i].value = params[i].value =
OidFunctionCall2(typReceive, OidFunctionCall2(typreceive,
PointerGetDatum(&pbuf), PointerGetDatum(&pbuf),
ObjectIdGetDatum(typElem)); ObjectIdGetDatum(typioparam));
/* Trouble if it didn't eat the whole buffer */ /* Trouble if it didn't eat the whole buffer */
if (pbuf.cursor != pbuf.len) if (pbuf.cursor != pbuf.len)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.102 2004/01/07 18:56:28 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.103 2004/06/06 00:41:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -75,12 +75,12 @@ ...@@ -75,12 +75,12 @@
static int ArrayCount(char *str, int *dim, char typdelim); static int ArrayCount(char *str, int *dim, char typdelim);
static Datum *ReadArrayStr(char *arrayStr, int nitems, int ndim, int *dim, static Datum *ReadArrayStr(char *arrayStr, int nitems, int ndim, int *dim,
FmgrInfo *inputproc, Oid typelem, int32 typmod, FmgrInfo *inputproc, Oid typioparam, int32 typmod,
char typdelim, char typdelim,
int typlen, bool typbyval, char typalign, int typlen, bool typbyval, char typalign,
int *nbytes); int *nbytes);
static Datum *ReadArrayBinary(StringInfo buf, int nitems, static Datum *ReadArrayBinary(StringInfo buf, int nitems,
FmgrInfo *receiveproc, Oid typelem, FmgrInfo *receiveproc, Oid typioparam,
int typlen, bool typbyval, char typalign, int typlen, bool typbyval, char typalign,
int *nbytes); int *nbytes);
static void CopyArrayEls(char *p, Datum *values, int nitems, static void CopyArrayEls(char *p, Datum *values, int nitems,
...@@ -130,7 +130,7 @@ array_in(PG_FUNCTION_ARGS) ...@@ -130,7 +130,7 @@ array_in(PG_FUNCTION_ARGS)
bool typbyval; bool typbyval;
char typalign; char typalign;
char typdelim; char typdelim;
Oid typelem; Oid typioparam;
char *string_save, char *string_save,
*p; *p;
int i, int i,
...@@ -166,7 +166,7 @@ array_in(PG_FUNCTION_ARGS) ...@@ -166,7 +166,7 @@ array_in(PG_FUNCTION_ARGS)
get_type_io_data(element_type, IOFunc_input, get_type_io_data(element_type, IOFunc_input,
&my_extra->typlen, &my_extra->typbyval, &my_extra->typlen, &my_extra->typbyval,
&my_extra->typalign, &my_extra->typdelim, &my_extra->typalign, &my_extra->typdelim,
&my_extra->typelem, &my_extra->typiofunc); &my_extra->typioparam, &my_extra->typiofunc);
fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc, fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc,
fcinfo->flinfo->fn_mcxt); fcinfo->flinfo->fn_mcxt);
my_extra->element_type = element_type; my_extra->element_type = element_type;
...@@ -175,7 +175,7 @@ array_in(PG_FUNCTION_ARGS) ...@@ -175,7 +175,7 @@ array_in(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;
typelem = my_extra->typelem; typioparam = my_extra->typioparam;
/* Make a modifiable copy of the input */ /* Make a modifiable copy of the input */
/* XXX why are we allocating an extra 2 bytes here? */ /* XXX why are we allocating an extra 2 bytes here? */
...@@ -299,7 +299,7 @@ array_in(PG_FUNCTION_ARGS) ...@@ -299,7 +299,7 @@ array_in(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION), (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("missing left brace"))); errmsg("missing left brace")));
dataPtr = ReadArrayStr(p, nitems, ndim, dim, &my_extra->proc, typelem, dataPtr = ReadArrayStr(p, nitems, ndim, dim, &my_extra->proc, typioparam,
typmod, typdelim, typlen, typbyval, typalign, typmod, typdelim, typlen, typbyval, typalign,
&nbytes); &nbytes);
nbytes += ARR_OVERHEAD(ndim); nbytes += ARR_OVERHEAD(ndim);
...@@ -439,7 +439,7 @@ ReadArrayStr(char *arrayStr, ...@@ -439,7 +439,7 @@ ReadArrayStr(char *arrayStr,
int ndim, int ndim,
int *dim, int *dim,
FmgrInfo *inputproc, FmgrInfo *inputproc,
Oid typelem, Oid typioparam,
int32 typmod, int32 typmod,
char typdelim, char typdelim,
int typlen, int typlen,
...@@ -571,7 +571,7 @@ ReadArrayStr(char *arrayStr, ...@@ -571,7 +571,7 @@ ReadArrayStr(char *arrayStr,
values[i] = FunctionCall3(inputproc, values[i] = FunctionCall3(inputproc,
CStringGetDatum(itemstart), CStringGetDatum(itemstart),
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(typmod)); Int32GetDatum(typmod));
} }
...@@ -675,7 +675,7 @@ array_out(PG_FUNCTION_ARGS) ...@@ -675,7 +675,7 @@ array_out(PG_FUNCTION_ARGS)
bool typbyval; bool typbyval;
char typalign; char typalign;
char typdelim; char typdelim;
Oid typelem; Oid typioparam;
char *p, char *p,
*tmp, *tmp,
*retval, *retval,
...@@ -716,7 +716,7 @@ array_out(PG_FUNCTION_ARGS) ...@@ -716,7 +716,7 @@ array_out(PG_FUNCTION_ARGS)
get_type_io_data(element_type, IOFunc_output, get_type_io_data(element_type, IOFunc_output,
&my_extra->typlen, &my_extra->typbyval, &my_extra->typlen, &my_extra->typbyval,
&my_extra->typalign, &my_extra->typdelim, &my_extra->typalign, &my_extra->typdelim,
&my_extra->typelem, &my_extra->typiofunc); &my_extra->typioparam, &my_extra->typiofunc);
fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc, fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc,
fcinfo->flinfo->fn_mcxt); fcinfo->flinfo->fn_mcxt);
my_extra->element_type = element_type; my_extra->element_type = element_type;
...@@ -725,7 +725,7 @@ array_out(PG_FUNCTION_ARGS) ...@@ -725,7 +725,7 @@ 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;
typelem = my_extra->typelem; typioparam = my_extra->typioparam;
ndim = ARR_NDIM(v); ndim = ARR_NDIM(v);
dim = ARR_DIMS(v); dim = ARR_DIMS(v);
...@@ -754,7 +754,7 @@ array_out(PG_FUNCTION_ARGS) ...@@ -754,7 +754,7 @@ array_out(PG_FUNCTION_ARGS)
itemvalue = fetch_att(p, typbyval, typlen); itemvalue = fetch_att(p, typbyval, typlen);
values[i] = DatumGetCString(FunctionCall3(&my_extra->proc, values[i] = DatumGetCString(FunctionCall3(&my_extra->proc,
itemvalue, itemvalue,
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(-1))); 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);
...@@ -871,7 +871,7 @@ array_recv(PG_FUNCTION_ARGS) ...@@ -871,7 +871,7 @@ array_recv(PG_FUNCTION_ARGS)
int typlen; int typlen;
bool typbyval; bool typbyval;
char typalign; char typalign;
Oid typelem; Oid typioparam;
int i, int i,
nitems; nitems;
int32 nbytes; int32 nbytes;
...@@ -946,7 +946,7 @@ array_recv(PG_FUNCTION_ARGS) ...@@ -946,7 +946,7 @@ array_recv(PG_FUNCTION_ARGS)
get_type_io_data(element_type, IOFunc_receive, get_type_io_data(element_type, IOFunc_receive,
&my_extra->typlen, &my_extra->typbyval, &my_extra->typlen, &my_extra->typbyval,
&my_extra->typalign, &my_extra->typdelim, &my_extra->typalign, &my_extra->typdelim,
&my_extra->typelem, &my_extra->typiofunc); &my_extra->typioparam, &my_extra->typiofunc);
if (!OidIsValid(my_extra->typiofunc)) if (!OidIsValid(my_extra->typiofunc))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION), (errcode(ERRCODE_UNDEFINED_FUNCTION),
...@@ -959,9 +959,9 @@ array_recv(PG_FUNCTION_ARGS) ...@@ -959,9 +959,9 @@ array_recv(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;
typelem = my_extra->typelem; typioparam = my_extra->typioparam;
dataPtr = ReadArrayBinary(buf, nitems, &my_extra->proc, typelem, dataPtr = ReadArrayBinary(buf, nitems, &my_extra->proc, typioparam,
typlen, typbyval, typalign, typlen, typbyval, typalign,
&nbytes); &nbytes);
nbytes += ARR_OVERHEAD(ndim); nbytes += ARR_OVERHEAD(ndim);
...@@ -994,7 +994,7 @@ static Datum * ...@@ -994,7 +994,7 @@ static Datum *
ReadArrayBinary(StringInfo buf, ReadArrayBinary(StringInfo buf,
int nitems, int nitems,
FmgrInfo *receiveproc, FmgrInfo *receiveproc,
Oid typelem, Oid typioparam,
int typlen, int typlen,
bool typbyval, bool typbyval,
char typalign, char typalign,
...@@ -1037,7 +1037,7 @@ ReadArrayBinary(StringInfo buf, ...@@ -1037,7 +1037,7 @@ ReadArrayBinary(StringInfo buf,
/* Now call the element's receiveproc */ /* Now call the element's receiveproc */
values[i] = FunctionCall2(receiveproc, values[i] = FunctionCall2(receiveproc,
PointerGetDatum(&elem_buf), PointerGetDatum(&elem_buf),
ObjectIdGetDatum(typelem)); ObjectIdGetDatum(typioparam));
/* Trouble if it didn't eat the whole buffer */ /* Trouble if it didn't eat the whole buffer */
if (elem_buf.cursor != itemlen) if (elem_buf.cursor != itemlen)
...@@ -1086,7 +1086,7 @@ array_send(PG_FUNCTION_ARGS) ...@@ -1086,7 +1086,7 @@ array_send(PG_FUNCTION_ARGS)
int typlen; int typlen;
bool typbyval; bool typbyval;
char typalign; char typalign;
Oid typelem; Oid typioparam;
char *p; char *p;
int nitems, int nitems,
i; i;
...@@ -1118,7 +1118,7 @@ array_send(PG_FUNCTION_ARGS) ...@@ -1118,7 +1118,7 @@ array_send(PG_FUNCTION_ARGS)
get_type_io_data(element_type, IOFunc_send, get_type_io_data(element_type, IOFunc_send,
&my_extra->typlen, &my_extra->typbyval, &my_extra->typlen, &my_extra->typbyval,
&my_extra->typalign, &my_extra->typdelim, &my_extra->typalign, &my_extra->typdelim,
&my_extra->typelem, &my_extra->typiofunc); &my_extra->typioparam, &my_extra->typiofunc);
if (!OidIsValid(my_extra->typiofunc)) if (!OidIsValid(my_extra->typiofunc))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_FUNCTION), (errcode(ERRCODE_UNDEFINED_FUNCTION),
...@@ -1131,7 +1131,7 @@ array_send(PG_FUNCTION_ARGS) ...@@ -1131,7 +1131,7 @@ 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;
typelem = my_extra->typelem; typioparam = my_extra->typioparam;
ndim = ARR_NDIM(v); ndim = ARR_NDIM(v);
dim = ARR_DIMS(v); dim = ARR_DIMS(v);
...@@ -1160,7 +1160,7 @@ array_send(PG_FUNCTION_ARGS) ...@@ -1160,7 +1160,7 @@ array_send(PG_FUNCTION_ARGS)
outputbytes = DatumGetByteaP(FunctionCall2(&my_extra->proc, outputbytes = DatumGetByteaP(FunctionCall2(&my_extra->proc,
itemvalue, itemvalue,
ObjectIdGetDatum(typelem))); 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),
......
...@@ -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.169 2004/05/30 23:40:36 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.170 2004/06/06 00:41:27 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -3445,8 +3445,9 @@ static void ...@@ -3445,8 +3445,9 @@ static void
get_const_expr(Const *constval, deparse_context *context) get_const_expr(Const *constval, deparse_context *context)
{ {
StringInfo buf = context->buf; StringInfo buf = context->buf;
HeapTuple typetup; Oid typoutput;
Form_pg_type typeStruct; Oid typioparam;
bool typIsVarlena;
char *extval; char *extval;
char *valptr; char *valptr;
bool isfloat = false; bool isfloat = false;
...@@ -3463,17 +3464,12 @@ get_const_expr(Const *constval, deparse_context *context) ...@@ -3463,17 +3464,12 @@ get_const_expr(Const *constval, deparse_context *context)
return; return;
} }
typetup = SearchSysCache(TYPEOID, getTypeOutputInfo(constval->consttype,
ObjectIdGetDatum(constval->consttype), &typoutput, &typioparam, &typIsVarlena);
0, 0, 0);
if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup failed for type %u", constval->consttype);
typeStruct = (Form_pg_type) GETSTRUCT(typetup);
extval = DatumGetCString(OidFunctionCall3(typeStruct->typoutput, extval = DatumGetCString(OidFunctionCall3(typoutput,
constval->constvalue, constval->constvalue,
ObjectIdGetDatum(typeStruct->typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(-1))); Int32GetDatum(-1)));
switch (constval->consttype) switch (constval->consttype)
...@@ -3570,8 +3566,6 @@ get_const_expr(Const *constval, deparse_context *context) ...@@ -3570,8 +3566,6 @@ get_const_expr(Const *constval, deparse_context *context)
if (needlabel) if (needlabel)
appendStringInfo(buf, "::%s", appendStringInfo(buf, "::%s",
format_type_with_typemod(constval->consttype, -1)); format_type_with_typemod(constval->consttype, -1));
ReleaseSysCache(typetup);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.114 2004/05/30 23:40:36 neilc Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.115 2004/06/06 00:41:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2172,7 +2172,7 @@ array_to_text(PG_FUNCTION_ARGS) ...@@ -2172,7 +2172,7 @@ array_to_text(PG_FUNCTION_ARGS)
int typlen; int typlen;
bool typbyval; bool typbyval;
char typalign; char typalign;
Oid typelem; Oid typioparam;
StringInfo result_str = makeStringInfo(); StringInfo result_str = makeStringInfo();
int i; int i;
ArrayMetaState *my_extra; ArrayMetaState *my_extra;
...@@ -2211,7 +2211,7 @@ array_to_text(PG_FUNCTION_ARGS) ...@@ -2211,7 +2211,7 @@ array_to_text(PG_FUNCTION_ARGS)
get_type_io_data(element_type, IOFunc_output, get_type_io_data(element_type, IOFunc_output,
&my_extra->typlen, &my_extra->typbyval, &my_extra->typlen, &my_extra->typbyval,
&my_extra->typalign, &my_extra->typdelim, &my_extra->typalign, &my_extra->typdelim,
&my_extra->typelem, &my_extra->typiofunc); &my_extra->typioparam, &my_extra->typiofunc);
fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc, fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc,
fcinfo->flinfo->fn_mcxt); fcinfo->flinfo->fn_mcxt);
my_extra->element_type = element_type; my_extra->element_type = element_type;
...@@ -2219,7 +2219,7 @@ array_to_text(PG_FUNCTION_ARGS) ...@@ -2219,7 +2219,7 @@ 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;
typelem = my_extra->typelem; typioparam = my_extra->typioparam;
for (i = 0; i < nitems; i++) for (i = 0; i < nitems; i++)
{ {
...@@ -2230,7 +2230,7 @@ array_to_text(PG_FUNCTION_ARGS) ...@@ -2230,7 +2230,7 @@ array_to_text(PG_FUNCTION_ARGS)
value = DatumGetCString(FunctionCall3(&my_extra->proc, value = DatumGetCString(FunctionCall3(&my_extra->proc,
itemvalue, itemvalue,
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(-1))); Int32GetDatum(-1)));
if (i > 0) if (i > 0)
......
...@@ -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.112 2003/12/03 17:45:09 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.113 2004/06/06 00:41:27 tgl Exp $
* *
* NOTES * NOTES
* Eventually, the index information should go through here, too. * Eventually, the index information should go through here, too.
...@@ -1174,11 +1174,37 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, ...@@ -1174,11 +1174,37 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
ReleaseSysCache(tp); ReleaseSysCache(tp);
} }
/*
* getTypeIOParam
* Given a pg_type row, select the type OID to pass to I/O functions
*
* Formerly, all I/O functions were passed pg_type.typelem as their second
* parameter, but we now have a more complex rule about what to pass.
* This knowledge is intended to be centralized here --- direct references
* to typelem elsewhere in the code are wrong, if they are associated with
* I/O calls and not with actual subscripting operations! (But see
* bootstrap.c, which can't conveniently use this routine.)
*/
Oid
getTypeIOParam(HeapTuple typeTuple)
{
Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
/*
* Composite types get their own OID as parameter; array types get
* their typelem as parameter; everybody else gets zero.
*/
if (typeStruct->typtype == 'c')
return HeapTupleGetOid(typeTuple);
else
return typeStruct->typelem;
}
/* /*
* get_type_io_data * get_type_io_data
* *
* A six-fer: given the type OID, return typlen, typbyval, typalign, * A six-fer: given the type OID, return typlen, typbyval, typalign,
* typdelim, typelem, and IO function OID. The IO function * typdelim, typioparam, and IO function OID. The IO function
* returned is controlled by IOFuncSelector * returned is controlled by IOFuncSelector
*/ */
void void
...@@ -1188,7 +1214,7 @@ get_type_io_data(Oid typid, ...@@ -1188,7 +1214,7 @@ get_type_io_data(Oid typid,
bool *typbyval, bool *typbyval,
char *typalign, char *typalign,
char *typdelim, char *typdelim,
Oid *typelem, Oid *typioparam,
Oid *func) Oid *func)
{ {
HeapTuple typeTuple; HeapTuple typeTuple;
...@@ -1205,7 +1231,7 @@ get_type_io_data(Oid typid, ...@@ -1205,7 +1231,7 @@ get_type_io_data(Oid typid,
*typbyval = typeStruct->typbyval; *typbyval = typeStruct->typbyval;
*typalign = typeStruct->typalign; *typalign = typeStruct->typalign;
*typdelim = typeStruct->typdelim; *typdelim = typeStruct->typdelim;
*typelem = typeStruct->typelem; *typioparam = getTypeIOParam(typeTuple);
switch (which_func) switch (which_func)
{ {
case IOFunc_input: case IOFunc_input:
...@@ -1355,7 +1381,7 @@ get_typdefault(Oid typid) ...@@ -1355,7 +1381,7 @@ get_typdefault(Oid typid)
/* Convert C string to a value of the given type */ /* Convert C string to a value of the given type */
datum = OidFunctionCall3(type->typinput, datum = OidFunctionCall3(type->typinput,
CStringGetDatum(strDefaultVal), CStringGetDatum(strDefaultVal),
ObjectIdGetDatum(type->typelem), ObjectIdGetDatum(getTypeIOParam(typeTuple)),
Int32GetDatum(-1)); Int32GetDatum(-1));
/* Build a Const node containing the value */ /* Build a Const node containing the value */
expr = (Node *) makeConst(typid, expr = (Node *) makeConst(typid,
...@@ -1607,7 +1633,7 @@ get_array_type(Oid typid) ...@@ -1607,7 +1633,7 @@ get_array_type(Oid typid)
* Get info needed for converting values of a type to internal form * Get info needed for converting values of a type to internal form
*/ */
void void
getTypeInputInfo(Oid type, Oid *typInput, Oid *typElem) getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
{ {
HeapTuple typeTuple; HeapTuple typeTuple;
Form_pg_type pt; Form_pg_type pt;
...@@ -1631,7 +1657,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typElem) ...@@ -1631,7 +1657,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typElem)
format_type_be(type)))); format_type_be(type))));
*typInput = pt->typinput; *typInput = pt->typinput;
*typElem = pt->typelem; *typIOParam = getTypeIOParam(typeTuple);
ReleaseSysCache(typeTuple); ReleaseSysCache(typeTuple);
} }
...@@ -1642,7 +1668,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typElem) ...@@ -1642,7 +1668,7 @@ getTypeInputInfo(Oid type, Oid *typInput, Oid *typElem)
* 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 *typElem, getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typIOParam,
bool *typIsVarlena) bool *typIsVarlena)
{ {
HeapTuple typeTuple; HeapTuple typeTuple;
...@@ -1667,7 +1693,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem, ...@@ -1667,7 +1693,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem,
format_type_be(type)))); format_type_be(type))));
*typOutput = pt->typoutput; *typOutput = pt->typoutput;
*typElem = pt->typelem; *typIOParam = getTypeIOParam(typeTuple);
*typIsVarlena = (!pt->typbyval) && (pt->typlen == -1); *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
ReleaseSysCache(typeTuple); ReleaseSysCache(typeTuple);
...@@ -1679,7 +1705,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem, ...@@ -1679,7 +1705,7 @@ getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem,
* Get info needed for binary input of values of a type * Get info needed for binary input of values of a type
*/ */
void void
getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typElem) getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
{ {
HeapTuple typeTuple; HeapTuple typeTuple;
Form_pg_type pt; Form_pg_type pt;
...@@ -1703,7 +1729,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typElem) ...@@ -1703,7 +1729,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typElem)
format_type_be(type)))); format_type_be(type))));
*typReceive = pt->typreceive; *typReceive = pt->typreceive;
*typElem = pt->typelem; *typIOParam = getTypeIOParam(typeTuple);
ReleaseSysCache(typeTuple); ReleaseSysCache(typeTuple);
} }
...@@ -1714,7 +1740,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typElem) ...@@ -1714,7 +1740,7 @@ getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typElem)
* 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 *typElem, getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typIOParam,
bool *typIsVarlena) bool *typIsVarlena)
{ {
HeapTuple typeTuple; HeapTuple typeTuple;
...@@ -1739,7 +1765,7 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typElem, ...@@ -1739,7 +1765,7 @@ getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typElem,
format_type_be(type)))); format_type_be(type))));
*typSend = pt->typsend; *typSend = pt->typsend;
*typElem = pt->typelem; *typIOParam = getTypeIOParam(typeTuple);
*typIsVarlena = (!pt->typbyval) && (pt->typlen == -1); *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
ReleaseSysCache(typeTuple); ReleaseSysCache(typeTuple);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* Copyright (c) 2002-2003, PostgreSQL Global Development Group * Copyright (c) 2002-2003, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/include/funcapi.h,v 1.11 2004/04/01 21:28:46 tgl Exp $ * $PostgreSQL: pgsql/src/include/funcapi.h,v 1.12 2004/06/06 00:41:27 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -40,8 +40,8 @@ typedef struct AttInMetadata ...@@ -40,8 +40,8 @@ typedef struct AttInMetadata
/* array of attribute type input function finfo */ /* array of attribute type input function finfo */
FmgrInfo *attinfuncs; FmgrInfo *attinfuncs;
/* array of attribute type typelem */ /* array of attribute type i/o parameter OIDs */
Oid *attelems; Oid *attioparams;
/* array of attribute typmod */ /* array of attribute typmod */
int32 *atttypmods; int32 *atttypmods;
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, 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/array.h,v 1.46 2003/11/29 22:41:15 pgsql Exp $ * $PostgreSQL: pgsql/src/include/utils/array.h,v 1.47 2004/06/06 00:41:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -59,7 +59,7 @@ typedef struct ArrayMetaState ...@@ -59,7 +59,7 @@ typedef struct ArrayMetaState
bool typbyval; bool typbyval;
char typalign; char typalign;
char typdelim; char typdelim;
Oid typelem; Oid typioparam;
Oid typiofunc; Oid typiofunc;
FmgrInfo proc; FmgrInfo proc;
} ArrayMetaState; } ArrayMetaState;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2003, 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.86 2003/12/03 17:45:10 tgl Exp $ * $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.87 2004/06/06 00:41:28 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -71,13 +71,14 @@ extern bool get_typbyval(Oid typid); ...@@ -71,13 +71,14 @@ extern bool get_typbyval(Oid typid);
extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval); extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
char *typalign); char *typalign);
extern Oid getTypeIOParam(HeapTuple typeTuple);
extern void get_type_io_data(Oid typid, extern void get_type_io_data(Oid typid,
IOFuncSelector which_func, IOFuncSelector which_func,
int16 *typlen, int16 *typlen,
bool *typbyval, bool *typbyval,
char *typalign, char *typalign,
char *typdelim, char *typdelim,
Oid *typelem, Oid *typioparam,
Oid *func); Oid *func);
extern char get_typstorage(Oid typid); extern char get_typstorage(Oid typid);
extern int32 get_typtypmod(Oid typid); extern int32 get_typtypmod(Oid typid);
...@@ -86,11 +87,11 @@ extern char get_typtype(Oid typid); ...@@ -86,11 +87,11 @@ extern char get_typtype(Oid typid);
extern Oid get_typ_typrelid(Oid typid); 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 *typElem); extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);
extern void getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typElem, extern void getTypeOutputInfo(Oid type, Oid *typOutput, Oid *typIOParam,
bool *typIsVarlena); bool *typIsVarlena);
extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typElem); extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);
extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typElem, extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, Oid *typIOParam,
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);
......
...@@ -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.43 2004/04/01 21:28:46 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.44 2004/06/06 00:41:28 tgl Exp $
* *
**********************************************************************/ **********************************************************************/
...@@ -79,10 +79,10 @@ typedef struct plperl_proc_desc ...@@ -79,10 +79,10 @@ typedef struct plperl_proc_desc
CommandId fn_cmin; CommandId fn_cmin;
bool lanpltrusted; bool lanpltrusted;
FmgrInfo result_in_func; FmgrInfo result_in_func;
Oid result_in_elem; Oid result_typioparam;
int nargs; int nargs;
FmgrInfo arg_out_func[FUNC_MAX_ARGS]; FmgrInfo arg_out_func[FUNC_MAX_ARGS];
Oid arg_out_elem[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;
...@@ -428,7 +428,7 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo) ...@@ -428,7 +428,7 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo)
tmp = DatumGetCString(FunctionCall3(&(desc->arg_out_func[i]), tmp = DatumGetCString(FunctionCall3(&(desc->arg_out_func[i]),
fcinfo->arg[i], fcinfo->arg[i],
ObjectIdGetDatum(desc->arg_out_elem[i]), ObjectIdGetDatum(desc->arg_typioparam[i]),
Int32GetDatum(-1))); Int32GetDatum(-1)));
XPUSHs(sv_2mortal(newSVpv(tmp, 0))); XPUSHs(sv_2mortal(newSVpv(tmp, 0)));
pfree(tmp); pfree(tmp);
...@@ -506,7 +506,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) ...@@ -506,7 +506,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
{ {
retval = FunctionCall3(&prodesc->result_in_func, retval = FunctionCall3(&prodesc->result_in_func,
PointerGetDatum(SvPV(perlret, PL_na)), PointerGetDatum(SvPV(perlret, PL_na)),
ObjectIdGetDatum(prodesc->result_in_elem), ObjectIdGetDatum(prodesc->result_typioparam),
Int32GetDatum(-1)); Int32GetDatum(-1));
} }
...@@ -671,7 +671,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -671,7 +671,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
} }
perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func)); perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func));
prodesc->result_in_elem = typeStruct->typelem; prodesc->result_typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
} }
...@@ -715,7 +715,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -715,7 +715,7 @@ 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_out_elem[i] = typeStruct->typelem; prodesc->arg_typioparam[i] = getTypeIOParam(typeTup);
} }
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
...@@ -776,7 +776,7 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc) ...@@ -776,7 +776,7 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
char *outputstr; char *outputstr;
HeapTuple typeTup; HeapTuple typeTup;
Oid typoutput; Oid typoutput;
Oid typelem; Oid typioparam;
output = sv_2mortal(newSVpv("{", 0)); output = sv_2mortal(newSVpv("{", 0));
...@@ -817,7 +817,7 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc) ...@@ -817,7 +817,7 @@ plperl_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;
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
/************************************************************ /************************************************************
...@@ -825,7 +825,7 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc) ...@@ -825,7 +825,7 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
************************************************************/ ************************************************************/
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall3(typoutput,
attr, attr,
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod))); Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
sv_catpvf(output, "'%s' => '%s',", attname, outputstr); sv_catpvf(output, "'%s' => '%s',", attname, outputstr);
pfree(outputstr); pfree(outputstr);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.76 2004/06/03 22:56:43 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.77 2004/06/06 00:41:28 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -383,7 +383,7 @@ do_compile(FunctionCallInfo fcinfo, ...@@ -383,7 +383,7 @@ do_compile(FunctionCallInfo fcinfo,
{ {
function->fn_retbyval = typeStruct->typbyval; function->fn_retbyval = typeStruct->typbyval;
function->fn_rettyplen = typeStruct->typlen; function->fn_rettyplen = typeStruct->typlen;
function->fn_rettypelem = typeStruct->typelem; function->fn_rettypioparam = getTypeIOParam(typeTup);
perm_fmgr_info(typeStruct->typinput, &(function->fn_retinput)); perm_fmgr_info(typeStruct->typinput, &(function->fn_retinput));
/* /*
...@@ -1704,7 +1704,7 @@ build_datatype(HeapTuple typeTup, int32 typmod) ...@@ -1704,7 +1704,7 @@ build_datatype(HeapTuple typeTup, int32 typmod)
typ->typlen = typeStruct->typlen; typ->typlen = typeStruct->typlen;
typ->typbyval = typeStruct->typbyval; typ->typbyval = typeStruct->typbyval;
typ->typrelid = typeStruct->typrelid; typ->typrelid = typeStruct->typrelid;
typ->typelem = typeStruct->typelem; typ->typioparam = getTypeIOParam(typeTup);
perm_fmgr_info(typeStruct->typinput, &(typ->typinput)); perm_fmgr_info(typeStruct->typinput, &(typ->typinput));
typ->atttypmod = typmod; typ->atttypmod = typmod;
......
...@@ -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.105 2004/06/05 19:48:09 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.106 2004/06/06 00:41:28 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -171,7 +171,7 @@ static char *convert_value_to_string(Datum value, Oid valtype); ...@@ -171,7 +171,7 @@ static char *convert_value_to_string(Datum value, Oid valtype);
static Datum exec_cast_value(Datum value, Oid valtype, static Datum exec_cast_value(Datum value, Oid valtype,
Oid reqtype, Oid reqtype,
FmgrInfo *reqinput, FmgrInfo *reqinput,
Oid reqtypelem, Oid reqtypioparam,
int32 reqtypmod, int32 reqtypmod,
bool *isnull); bool *isnull);
static Datum exec_simple_cast_value(Datum value, Oid valtype, static Datum exec_simple_cast_value(Datum value, Oid valtype,
...@@ -393,7 +393,7 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) ...@@ -393,7 +393,7 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
estate.retval = exec_cast_value(estate.retval, estate.rettype, estate.retval = exec_cast_value(estate.retval, estate.rettype,
func->fn_rettype, func->fn_rettype,
&(func->fn_retinput), &(func->fn_retinput),
func->fn_rettypelem, func->fn_rettypioparam,
-1, -1,
&fcinfo->isnull); &fcinfo->isnull);
...@@ -1268,7 +1268,7 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt) ...@@ -1268,7 +1268,7 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt)
value = exec_eval_expr(estate, stmt->lower, &isnull, &valtype); value = exec_eval_expr(estate, stmt->lower, &isnull, &valtype);
value = exec_cast_value(value, valtype, var->datatype->typoid, value = exec_cast_value(value, valtype, var->datatype->typoid,
&(var->datatype->typinput), &(var->datatype->typinput),
var->datatype->typelem, var->datatype->typioparam,
var->datatype->atttypmod, &isnull); var->datatype->atttypmod, &isnull);
if (isnull) if (isnull)
ereport(ERROR, ereport(ERROR,
...@@ -1284,7 +1284,7 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt) ...@@ -1284,7 +1284,7 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt)
value = exec_eval_expr(estate, stmt->upper, &isnull, &valtype); value = exec_eval_expr(estate, stmt->upper, &isnull, &valtype);
value = exec_cast_value(value, valtype, var->datatype->typoid, value = exec_cast_value(value, valtype, var->datatype->typoid,
&(var->datatype->typinput), &(var->datatype->typinput),
var->datatype->typelem, var->datatype->typioparam,
var->datatype->atttypmod, &isnull); var->datatype->atttypmod, &isnull);
if (isnull) if (isnull)
ereport(ERROR, ereport(ERROR,
...@@ -2674,7 +2674,7 @@ exec_assign_value(PLpgSQL_execstate * estate, ...@@ -2674,7 +2674,7 @@ exec_assign_value(PLpgSQL_execstate * estate,
newvalue = exec_cast_value(value, valtype, var->datatype->typoid, newvalue = exec_cast_value(value, valtype, var->datatype->typoid,
&(var->datatype->typinput), &(var->datatype->typinput),
var->datatype->typelem, var->datatype->typioparam,
var->datatype->atttypmod, var->datatype->atttypmod,
isNull); isNull);
...@@ -2917,8 +2917,7 @@ exec_assign_value(PLpgSQL_execstate * estate, ...@@ -2917,8 +2917,7 @@ exec_assign_value(PLpgSQL_execstate * estate,
bool havenullsubscript, bool havenullsubscript,
oldarrayisnull; oldarrayisnull;
Oid arraytypeid, Oid arraytypeid,
arrayelemtypeid, arrayelemtypeid;
arrayInputFn;
int16 elemtyplen; int16 elemtyplen;
bool elemtypbyval; bool elemtypbyval;
char elemtypalign; char elemtypalign;
...@@ -2954,7 +2953,7 @@ exec_assign_value(PLpgSQL_execstate * estate, ...@@ -2954,7 +2953,7 @@ exec_assign_value(PLpgSQL_execstate * estate,
exec_eval_datum(estate, target, InvalidOid, exec_eval_datum(estate, target, InvalidOid,
&arraytypeid, &oldarrayval, &oldarrayisnull); &arraytypeid, &oldarrayval, &oldarrayisnull);
getTypeInputInfo(arraytypeid, &arrayInputFn, &arrayelemtypeid); arrayelemtypeid = get_element_type(arraytypeid);
if (!OidIsValid(arrayelemtypeid)) if (!OidIsValid(arrayelemtypeid))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH), (errcode(ERRCODE_DATATYPE_MISMATCH),
...@@ -3672,19 +3671,16 @@ make_tuple_from_row(PLpgSQL_execstate * estate, ...@@ -3672,19 +3671,16 @@ make_tuple_from_row(PLpgSQL_execstate * estate,
static char * static char *
convert_value_to_string(Datum value, Oid valtype) convert_value_to_string(Datum value, Oid valtype)
{ {
Oid typOutput; Oid typoutput;
Oid typElem; Oid typioparam;
bool typIsVarlena; bool typIsVarlena;
FmgrInfo finfo_output;
getTypeOutputInfo(valtype, &typOutput, &typElem, &typIsVarlena); getTypeOutputInfo(valtype, &typoutput, &typioparam, &typIsVarlena);
fmgr_info(typOutput, &finfo_output); return DatumGetCString(OidFunctionCall3(typoutput,
value,
return DatumGetCString(FunctionCall3(&finfo_output, ObjectIdGetDatum(typioparam),
value, Int32GetDatum(-1)));
ObjectIdGetDatum(typElem),
Int32GetDatum(-1)));
} }
/* ---------- /* ----------
...@@ -3695,7 +3691,7 @@ static Datum ...@@ -3695,7 +3691,7 @@ static Datum
exec_cast_value(Datum value, Oid valtype, exec_cast_value(Datum value, Oid valtype,
Oid reqtype, Oid reqtype,
FmgrInfo *reqinput, FmgrInfo *reqinput,
Oid reqtypelem, Oid reqtypioparam,
int32 reqtypmod, int32 reqtypmod,
bool *isnull) bool *isnull)
{ {
...@@ -3712,7 +3708,7 @@ exec_cast_value(Datum value, Oid valtype, ...@@ -3712,7 +3708,7 @@ exec_cast_value(Datum value, Oid valtype,
extval = convert_value_to_string(value, valtype); extval = convert_value_to_string(value, valtype);
value = FunctionCall3(reqinput, value = FunctionCall3(reqinput,
CStringGetDatum(extval), CStringGetDatum(extval),
ObjectIdGetDatum(reqtypelem), ObjectIdGetDatum(reqtypioparam),
Int32GetDatum(reqtypmod)); Int32GetDatum(reqtypmod));
pfree(extval); pfree(extval);
} }
...@@ -3738,19 +3734,19 @@ exec_simple_cast_value(Datum value, Oid valtype, ...@@ -3738,19 +3734,19 @@ exec_simple_cast_value(Datum value, Oid valtype,
{ {
if (valtype != reqtype || reqtypmod != -1) if (valtype != reqtype || reqtypmod != -1)
{ {
Oid typInput; Oid typinput;
Oid typElem; Oid typioparam;
FmgrInfo finfo_input; FmgrInfo finfo_input;
getTypeInputInfo(reqtype, &typInput, &typElem); getTypeInputInfo(reqtype, &typinput, &typioparam);
fmgr_info(typInput, &finfo_input); fmgr_info(typinput, &finfo_input);
value = exec_cast_value(value, value = exec_cast_value(value,
valtype, valtype,
reqtype, reqtype,
&finfo_input, &finfo_input,
typElem, typioparam,
reqtypmod, reqtypmod,
isnull); isnull);
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.46 2004/06/03 22:56:43 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.47 2004/06/06 00:41:28 tgl Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -160,7 +160,7 @@ typedef struct ...@@ -160,7 +160,7 @@ typedef struct
int16 typlen; /* stuff copied from its pg_type entry */ int16 typlen; /* stuff copied from its pg_type entry */
bool typbyval; bool typbyval;
Oid typrelid; Oid typrelid;
Oid typelem; Oid typioparam;
FmgrInfo typinput; /* lookup info for typinput function */ FmgrInfo typinput; /* lookup info for typinput function */
int32 atttypmod; /* typmod (taken from someplace else) */ int32 atttypmod; /* typmod (taken from someplace else) */
} PLpgSQL_type; } PLpgSQL_type;
...@@ -557,7 +557,7 @@ typedef struct PLpgSQL_function ...@@ -557,7 +557,7 @@ typedef struct PLpgSQL_function
int fn_rettyplen; int fn_rettyplen;
bool fn_retbyval; bool fn_retbyval;
FmgrInfo fn_retinput; FmgrInfo fn_retinput;
Oid fn_rettypelem; Oid fn_rettypioparam;
bool fn_retistuple; bool fn_retistuple;
bool fn_retset; bool fn_retset;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.48 2004/06/05 19:48:09 tgl Exp $ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.49 2004/06/06 00:41:28 tgl Exp $
* *
********************************************************************* *********************************************************************
*/ */
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "nodes/makefuncs.h" #include "nodes/makefuncs.h"
#include "parser/parse_type.h" #include "parser/parse_type.h"
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/typcache.h" #include "utils/typcache.h"
...@@ -70,7 +71,7 @@ typedef struct PLyDatumToOb ...@@ -70,7 +71,7 @@ typedef struct PLyDatumToOb
{ {
PLyDatumToObFunc func; PLyDatumToObFunc func;
FmgrInfo typfunc; FmgrInfo typfunc;
Oid typelem; Oid typioparam;
bool typbyval; bool typbyval;
} PLyDatumToOb; } PLyDatumToOb;
...@@ -92,7 +93,7 @@ typedef union PLyTypeInput ...@@ -92,7 +93,7 @@ typedef union PLyTypeInput
typedef struct PLyObToDatum typedef struct PLyObToDatum
{ {
FmgrInfo typfunc; FmgrInfo typfunc;
Oid typelem; Oid typioparam;
bool typbyval; bool typbyval;
} PLyObToDatum; } PLyObToDatum;
...@@ -238,10 +239,10 @@ static void PLy_procedure_delete(PLyProcedure *); ...@@ -238,10 +239,10 @@ static void PLy_procedure_delete(PLyProcedure *);
static void PLy_typeinfo_init(PLyTypeInfo *); static void PLy_typeinfo_init(PLyTypeInfo *);
static void PLy_typeinfo_dealloc(PLyTypeInfo *); static void PLy_typeinfo_dealloc(PLyTypeInfo *);
static void PLy_output_datum_func(PLyTypeInfo *, Form_pg_type); static void PLy_output_datum_func(PLyTypeInfo *, HeapTuple);
static void PLy_output_datum_func2(PLyObToDatum *, Form_pg_type); static void PLy_output_datum_func2(PLyObToDatum *, HeapTuple);
static void PLy_input_datum_func(PLyTypeInfo *, Oid, Form_pg_type); static void PLy_input_datum_func(PLyTypeInfo *, Oid, HeapTuple);
static void PLy_input_datum_func2(PLyDatumToOb *, Oid, Form_pg_type); static void PLy_input_datum_func2(PLyDatumToOb *, Oid, HeapTuple);
static void PLy_output_tuple_funcs(PLyTypeInfo *, TupleDesc); static void PLy_output_tuple_funcs(PLyTypeInfo *, TupleDesc);
static void PLy_input_tuple_funcs(PLyTypeInfo *, TupleDesc); static void PLy_input_tuple_funcs(PLyTypeInfo *, TupleDesc);
...@@ -565,7 +566,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata, ...@@ -565,7 +566,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
modvalues[i] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc, modvalues[i] = FunctionCall3(&proc->result.out.r.atts[atti].typfunc,
CStringGetDatum(src), CStringGetDatum(src),
ObjectIdGetDatum(proc->result.out.r.atts[atti].typelem), ObjectIdGetDatum(proc->result.out.r.atts[atti].typioparam),
Int32GetDatum(tupdesc->attrs[atti]->atttypmod)); Int32GetDatum(tupdesc->attrs[atti]->atttypmod));
modnulls[i] = ' '; modnulls[i] = ' ';
...@@ -850,7 +851,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc) ...@@ -850,7 +851,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
plrv_sc = PyString_AsString(plrv_so); plrv_sc = PyString_AsString(plrv_so);
rv = FunctionCall3(&proc->result.out.d.typfunc, rv = FunctionCall3(&proc->result.out.d.typfunc,
PointerGetDatum(plrv_sc), PointerGetDatum(plrv_sc),
ObjectIdGetDatum(proc->result.out.d.typelem), ObjectIdGetDatum(proc->result.out.d.typioparam),
Int32GetDatum(-1)); Int32GetDatum(-1));
} }
...@@ -956,7 +957,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc) ...@@ -956,7 +957,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
dt = FunctionCall3(&(proc->args[i].in.d.typfunc), dt = FunctionCall3(&(proc->args[i].in.d.typfunc),
fcinfo->arg[i], fcinfo->arg[i],
ObjectIdGetDatum(proc->args[i].in.d.typelem), ObjectIdGetDatum(proc->args[i].in.d.typioparam),
Int32GetDatum(-1)); Int32GetDatum(-1));
ct = DatumGetCString(dt); ct = DatumGetCString(dt);
arg = (proc->args[i].in.d.func) (ct); arg = (proc->args[i].in.d.func) (ct);
...@@ -1119,7 +1120,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, ...@@ -1119,7 +1120,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup); rvTypeStruct = (Form_pg_type) GETSTRUCT(rvTypeTup);
if (rvTypeStruct->typtype != 'c') if (rvTypeStruct->typtype != 'c')
PLy_output_datum_func(&proc->result, rvTypeStruct); PLy_output_datum_func(&proc->result, rvTypeTup);
else else
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
...@@ -1160,7 +1161,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid, ...@@ -1160,7 +1161,7 @@ PLy_procedure_create(FunctionCallInfo fcinfo, Oid tgreloid,
if (argTypeStruct->typtype != 'c') if (argTypeStruct->typtype != 'c')
PLy_input_datum_func(&(proc->args[i]), PLy_input_datum_func(&(proc->args[i]),
procStruct->proargtypes[i], procStruct->proargtypes[i],
argTypeStruct); argTypeTup);
else else
proc->args[i].is_rowtype = 2; /* still need to set I/O funcs */ proc->args[i].is_rowtype = 2; /* still need to set I/O funcs */
...@@ -1327,7 +1328,6 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) ...@@ -1327,7 +1328,6 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
for (i = 0; i < desc->natts; i++) for (i = 0; i < desc->natts; i++)
{ {
HeapTuple typeTup; HeapTuple typeTup;
Form_pg_type typeStruct;
if (desc->attrs[i]->attisdropped) if (desc->attrs[i]->attisdropped)
continue; continue;
...@@ -1338,11 +1338,10 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) ...@@ -1338,11 +1338,10 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
if (!HeapTupleIsValid(typeTup)) if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", elog(ERROR, "cache lookup failed for type %u",
desc->attrs[i]->atttypid); desc->attrs[i]->atttypid);
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
PLy_input_datum_func2(&(arg->in.r.atts[i]), PLy_input_datum_func2(&(arg->in.r.atts[i]),
desc->attrs[i]->atttypid, desc->attrs[i]->atttypid,
typeStruct); typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
} }
...@@ -1365,7 +1364,6 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) ...@@ -1365,7 +1364,6 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
for (i = 0; i < desc->natts; i++) for (i = 0; i < desc->natts; i++)
{ {
HeapTuple typeTup; HeapTuple typeTup;
Form_pg_type typeStruct;
if (desc->attrs[i]->attisdropped) if (desc->attrs[i]->attisdropped)
continue; continue;
...@@ -1376,52 +1374,55 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc) ...@@ -1376,52 +1374,55 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
if (!HeapTupleIsValid(typeTup)) if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup failed for type %u", elog(ERROR, "cache lookup failed for type %u",
desc->attrs[i]->atttypid); desc->attrs[i]->atttypid);
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
PLy_output_datum_func2(&(arg->out.r.atts[i]), typeStruct); PLy_output_datum_func2(&(arg->out.r.atts[i]), typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
} }
} }
void void
PLy_output_datum_func(PLyTypeInfo * arg, Form_pg_type typeStruct) PLy_output_datum_func(PLyTypeInfo * arg, HeapTuple typeTup)
{ {
enter(); enter();
if (arg->is_rowtype > 0) if (arg->is_rowtype > 0)
elog(ERROR, "PLyTypeInfo struct is initialized for a Tuple"); elog(ERROR, "PLyTypeInfo struct is initialized for a Tuple");
arg->is_rowtype = 0; arg->is_rowtype = 0;
PLy_output_datum_func2(&(arg->out.d), typeStruct); PLy_output_datum_func2(&(arg->out.d), typeTup);
} }
void void
PLy_output_datum_func2(PLyObToDatum * arg, Form_pg_type typeStruct) PLy_output_datum_func2(PLyObToDatum * arg, HeapTuple typeTup)
{ {
Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
enter(); enter();
perm_fmgr_info(typeStruct->typinput, &arg->typfunc); perm_fmgr_info(typeStruct->typinput, &arg->typfunc);
arg->typelem = typeStruct->typelem; arg->typioparam = getTypeIOParam(typeTup);
arg->typbyval = typeStruct->typbyval; arg->typbyval = typeStruct->typbyval;
} }
void void
PLy_input_datum_func(PLyTypeInfo * arg, Oid typeOid, Form_pg_type typeStruct) PLy_input_datum_func(PLyTypeInfo * arg, Oid typeOid, HeapTuple typeTup)
{ {
enter(); enter();
if (arg->is_rowtype > 0) if (arg->is_rowtype > 0)
elog(ERROR, "PLyTypeInfo struct is initialized for Tuple"); elog(ERROR, "PLyTypeInfo struct is initialized for Tuple");
arg->is_rowtype = 0; arg->is_rowtype = 0;
PLy_input_datum_func2(&(arg->in.d), typeOid, typeStruct); PLy_input_datum_func2(&(arg->in.d), typeOid, typeTup);
} }
void void
PLy_input_datum_func2(PLyDatumToOb * arg, Oid typeOid, Form_pg_type typeStruct) PLy_input_datum_func2(PLyDatumToOb * arg, Oid typeOid, HeapTuple typeTup)
{ {
Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
/* Get the type's conversion information */ /* Get the type's conversion information */
perm_fmgr_info(typeStruct->typoutput, &arg->typfunc); perm_fmgr_info(typeStruct->typoutput, &arg->typfunc);
arg->typelem = typeStruct->typelem; arg->typioparam = getTypeIOParam(typeTup);
arg->typbyval = typeStruct->typbyval; arg->typbyval = typeStruct->typbyval;
/* Determine which kind of Python object we will convert to */ /* Determine which kind of Python object we will convert to */
...@@ -1569,7 +1570,7 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc) ...@@ -1569,7 +1570,7 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
{ {
vdat = FunctionCall3(&info->in.r.atts[i].typfunc, vdat = FunctionCall3(&info->in.r.atts[i].typfunc,
vattr, vattr,
ObjectIdGetDatum(info->in.r.atts[i].typelem), ObjectIdGetDatum(info->in.r.atts[i].typioparam),
Int32GetDatum(desc->attrs[i]->atttypmod)); Int32GetDatum(desc->attrs[i]->atttypmod));
vsrc = DatumGetCString(vdat); vsrc = DatumGetCString(vdat);
...@@ -2027,7 +2028,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args) ...@@ -2027,7 +2028,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
plan->types[i] = HeapTupleGetOid(typeTup); plan->types[i] = HeapTupleGetOid(typeTup);
typeStruct = (Form_pg_type) GETSTRUCT(typeTup); typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
if (typeStruct->typtype != 'c') if (typeStruct->typtype != 'c')
PLy_output_datum_func(&plan->args[i], typeStruct); PLy_output_datum_func(&plan->args[i], typeTup);
else else
{ {
PyErr_SetString(PLy_exc_spi_error, PyErr_SetString(PLy_exc_spi_error,
...@@ -2193,7 +2194,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit) ...@@ -2193,7 +2194,7 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, int limit)
plan->values[i] = plan->values[i] =
FunctionCall3(&(plan->args[i].out.d.typfunc), FunctionCall3(&(plan->args[i].out.d.typfunc),
CStringGetDatum(sv), CStringGetDatum(sv),
ObjectIdGetDatum(plan->args[i].out.d.typelem), ObjectIdGetDatum(plan->args[i].out.d.typioparam),
Int32GetDatum(-1)); Int32GetDatum(-1));
Py_DECREF(so); Py_DECREF(so);
......
...@@ -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.85 2004/05/30 23:40:41 neilc Exp $ * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.86 2004/06/06 00:41:28 tgl Exp $
* *
**********************************************************************/ **********************************************************************/
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#include "access/heapam.h" #include "access/heapam.h"
#include "catalog/pg_language.h" #include "catalog/pg_language.h"
#include "catalog/pg_proc.h" #include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "commands/trigger.h" #include "commands/trigger.h"
#include "executor/spi.h" #include "executor/spi.h"
#include "fmgr.h" #include "fmgr.h"
...@@ -59,6 +58,7 @@ ...@@ -59,6 +58,7 @@
#include "parser/parse_type.h" #include "parser/parse_type.h"
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/typcache.h" #include "utils/typcache.h"
...@@ -105,10 +105,10 @@ typedef struct pltcl_proc_desc ...@@ -105,10 +105,10 @@ typedef struct pltcl_proc_desc
CommandId fn_cmin; CommandId fn_cmin;
bool lanpltrusted; bool lanpltrusted;
FmgrInfo result_in_func; FmgrInfo result_in_func;
Oid result_in_elem; Oid result_typioparam;
int nargs; int nargs;
FmgrInfo arg_out_func[FUNC_MAX_ARGS]; FmgrInfo arg_out_func[FUNC_MAX_ARGS];
Oid arg_out_elem[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;
...@@ -123,7 +123,7 @@ typedef struct pltcl_query_desc ...@@ -123,7 +123,7 @@ typedef struct pltcl_query_desc
int nargs; int nargs;
Oid *argtypes; Oid *argtypes;
FmgrInfo *arginfuncs; FmgrInfo *arginfuncs;
Oid *argtypelems; Oid *argtypioparams;
} pltcl_query_desc; } pltcl_query_desc;
...@@ -543,7 +543,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS) ...@@ -543,7 +543,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
tmp = DatumGetCString(FunctionCall3(&prodesc->arg_out_func[i], tmp = DatumGetCString(FunctionCall3(&prodesc->arg_out_func[i],
fcinfo->arg[i], fcinfo->arg[i],
ObjectIdGetDatum(prodesc->arg_out_elem[i]), ObjectIdGetDatum(prodesc->arg_typioparam[i]),
Int32GetDatum(-1))); Int32GetDatum(-1)));
UTF_BEGIN; UTF_BEGIN;
Tcl_DStringAppendElement(&tcl_cmd, UTF_E2U(tmp)); Tcl_DStringAppendElement(&tcl_cmd, UTF_E2U(tmp));
...@@ -622,7 +622,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS) ...@@ -622,7 +622,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
UTF_BEGIN; UTF_BEGIN;
retval = FunctionCall3(&prodesc->result_in_func, retval = FunctionCall3(&prodesc->result_in_func,
PointerGetDatum(UTF_U2E(interp->result)), PointerGetDatum(UTF_U2E(interp->result)),
ObjectIdGetDatum(prodesc->result_in_elem), ObjectIdGetDatum(prodesc->result_typioparam),
Int32GetDatum(-1)); Int32GetDatum(-1));
UTF_END; UTF_END;
} }
...@@ -908,7 +908,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) ...@@ -908,7 +908,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
int attnum; int attnum;
HeapTuple typeTup; HeapTuple typeTup;
Oid typinput; Oid typinput;
Oid typelem; Oid typioparam;
FmgrInfo finfo; FmgrInfo finfo;
/************************************************************ /************************************************************
...@@ -943,7 +943,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) ...@@ -943,7 +943,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
elog(ERROR, "cache lookup failed for type %u", elog(ERROR, "cache lookup failed for type %u",
tupdesc->attrs[attnum - 1]->atttypid); tupdesc->attrs[attnum - 1]->atttypid);
typinput = ((Form_pg_type) GETSTRUCT(typeTup))->typinput; typinput = ((Form_pg_type) GETSTRUCT(typeTup))->typinput;
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
/************************************************************ /************************************************************
...@@ -955,7 +955,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) ...@@ -955,7 +955,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
modvalues[attnum - 1] = modvalues[attnum - 1] =
FunctionCall3(&finfo, FunctionCall3(&finfo,
CStringGetDatum(UTF_U2E(ret_value)), CStringGetDatum(UTF_U2E(ret_value)),
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[attnum - 1]->atttypmod)); Int32GetDatum(tupdesc->attrs[attnum - 1]->atttypmod));
UTF_END; UTF_END;
} }
...@@ -1150,7 +1150,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) ...@@ -1150,7 +1150,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
} }
perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func)); perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func));
prodesc->result_in_elem = typeStruct->typelem; prodesc->result_typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
} }
...@@ -1198,7 +1198,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid) ...@@ -1198,7 +1198,7 @@ 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_out_elem[i] = typeStruct->typelem; prodesc->arg_typioparam[i] = getTypeIOParam(typeTup);
snprintf(buf, sizeof(buf), "%d", i + 1); snprintf(buf, sizeof(buf), "%d", i + 1);
} }
...@@ -1820,7 +1820,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, ...@@ -1820,7 +1820,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
qdesc->nargs = nargs; qdesc->nargs = nargs;
qdesc->argtypes = (Oid *) malloc(nargs * sizeof(Oid)); qdesc->argtypes = (Oid *) malloc(nargs * sizeof(Oid));
qdesc->arginfuncs = (FmgrInfo *) malloc(nargs * sizeof(FmgrInfo)); qdesc->arginfuncs = (FmgrInfo *) malloc(nargs * sizeof(FmgrInfo));
qdesc->argtypelems = (Oid *) malloc(nargs * sizeof(Oid)); qdesc->argtypioparams = (Oid *) malloc(nargs * sizeof(Oid));
/************************************************************ /************************************************************
* Prepare to start a controlled return through all * Prepare to start a controlled return through all
...@@ -1833,7 +1833,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, ...@@ -1833,7 +1833,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
pltcl_restart_in_progress = 1; pltcl_restart_in_progress = 1;
free(qdesc->argtypes); free(qdesc->argtypes);
free(qdesc->arginfuncs); free(qdesc->arginfuncs);
free(qdesc->argtypelems); free(qdesc->argtypioparams);
free(qdesc); free(qdesc);
ckfree((char *) args); ckfree((char *) args);
return TCL_ERROR; return TCL_ERROR;
...@@ -1865,7 +1865,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, ...@@ -1865,7 +1865,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
qdesc->argtypes[i] = HeapTupleGetOid(typeTup); qdesc->argtypes[i] = HeapTupleGetOid(typeTup);
perm_fmgr_info(((Form_pg_type) GETSTRUCT(typeTup))->typinput, perm_fmgr_info(((Form_pg_type) GETSTRUCT(typeTup))->typinput,
&(qdesc->arginfuncs[i])); &(qdesc->arginfuncs[i]));
qdesc->argtypelems[i] = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; qdesc->argtypioparams[i] = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
list_free(typename->names); list_free(typename->names);
...@@ -2117,7 +2117,7 @@ pltcl_SPI_execp(ClientData cdata, Tcl_Interp *interp, ...@@ -2117,7 +2117,7 @@ pltcl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
argvalues[j] = argvalues[j] =
FunctionCall3(&qdesc->arginfuncs[j], FunctionCall3(&qdesc->arginfuncs[j],
CStringGetDatum(UTF_U2E(callargs[j])), CStringGetDatum(UTF_U2E(callargs[j])),
ObjectIdGetDatum(qdesc->argtypelems[j]), ObjectIdGetDatum(qdesc->argtypioparams[j]),
Int32GetDatum(-1)); Int32GetDatum(-1));
UTF_END; UTF_END;
} }
...@@ -2339,7 +2339,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, ...@@ -2339,7 +2339,7 @@ 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 typelem; Oid typioparam;
CONST84 char **arrptr; CONST84 char **arrptr;
CONST84 char **nameptr; CONST84 char **nameptr;
...@@ -2390,7 +2390,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, ...@@ -2390,7 +2390,7 @@ 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;
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
/************************************************************ /************************************************************
...@@ -2405,7 +2405,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname, ...@@ -2405,7 +2405,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, CONST84 char *arrayname,
{ {
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall3(typoutput,
attr, attr,
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod))); 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);
...@@ -2434,7 +2434,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, ...@@ -2434,7 +2434,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
char *attname; char *attname;
HeapTuple typeTup; HeapTuple typeTup;
Oid typoutput; Oid typoutput;
Oid typelem; Oid typioparam;
for (i = 0; i < tupdesc->natts; i++) for (i = 0; i < tupdesc->natts; i++)
{ {
...@@ -2464,7 +2464,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, ...@@ -2464,7 +2464,7 @@ 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;
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; typioparam = getTypeIOParam(typeTup);
ReleaseSysCache(typeTup); ReleaseSysCache(typeTup);
/************************************************************ /************************************************************
...@@ -2479,7 +2479,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, ...@@ -2479,7 +2479,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
{ {
outputstr = DatumGetCString(OidFunctionCall3(typoutput, outputstr = DatumGetCString(OidFunctionCall3(typoutput,
attr, attr,
ObjectIdGetDatum(typelem), ObjectIdGetDatum(typioparam),
Int32GetDatum(tupdesc->attrs[i]->atttypmod))); Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
Tcl_DStringAppendElement(retval, attname); Tcl_DStringAppendElement(retval, attname);
UTF_BEGIN; UTF_BEGIN;
......
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