summaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2004-06-06 00:41:28 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2004-06-06 00:41:28 +0000
commitc541bb86e9ec8fed37b23df6a0df703d0bde4dfa (patch)
treeb4cff96eecc86e338274ec5d7355918efe9c149e /src/backend/executor
parentc3a153afed84e29dac664bdc6123724a9e3a906f (diff)
downloadpostgresql-c541bb86e9ec8fed37b23df6a0df703d0bde4dfa.tar.gz
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.
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execTuples.c16
-rw-r--r--src/backend/executor/nodeAgg.c22
-rw-r--r--src/backend/executor/spi.c8
3 files changed, 17 insertions, 29 deletions
diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c
index 8dd8cfc394..950d9d7f3b 100644
--- a/src/backend/executor/execTuples.c
+++ b/src/backend/executor/execTuples.c
@@ -15,7 +15,7 @@
*
*
* 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)
Oid atttypeid;
Oid attinfuncid;
FmgrInfo *attinfuncinfo;
- Oid *attelems;
+ Oid *attioparams;
int32 *atttypmods;
AttInMetadata *attinmeta;
@@ -699,7 +699,7 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc)
* attribute
*/
attinfuncinfo = (FmgrInfo *) palloc0(natts * sizeof(FmgrInfo));
- attelems = (Oid *) palloc0(natts * sizeof(Oid));
+ attioparams = (Oid *) palloc0(natts * sizeof(Oid));
atttypmods = (int32 *) palloc0(natts * sizeof(int32));
for (i = 0; i < natts; i++)
@@ -708,13 +708,13 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc)
if (!tupdesc->attrs[i]->attisdropped)
{
atttypeid = tupdesc->attrs[i]->atttypid;
- getTypeInputInfo(atttypeid, &attinfuncid, &attelems[i]);
+ getTypeInputInfo(atttypeid, &attinfuncid, &attioparams[i]);
fmgr_info(attinfuncid, &attinfuncinfo[i]);
atttypmods[i] = tupdesc->attrs[i]->atttypmod;
}
}
attinmeta->attinfuncs = attinfuncinfo;
- attinmeta->attelems = attelems;
+ attinmeta->attioparams = attioparams;
attinmeta->atttypmods = atttypmods;
return attinmeta;
@@ -732,7 +732,7 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
Datum *dvalues;
char *nulls;
int i;
- Oid attelem;
+ Oid attioparam;
int32 atttypmod;
HeapTuple tuple;
@@ -747,12 +747,12 @@ BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
/* Non-dropped attributes */
if (values[i] != NULL)
{
- attelem = attinmeta->attelems[i];
+ attioparam = attinmeta->attioparams[i];
atttypmod = attinmeta->atttypmods[i];
dvalues[i] = FunctionCall3(&attinmeta->attinfuncs[i],
CStringGetDatum(values[i]),
- ObjectIdGetDatum(attelem),
+ ObjectIdGetDatum(attioparam),
Int32GetDatum(atttypmod));
nulls[i] = ' ';
}
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 265828f4c1..119f5da346 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -45,7 +45,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* 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)
static Datum
GetAggInitVal(Datum textInitVal, Oid transtype)
{
- char *strInitVal;
- HeapTuple tup;
Oid typinput,
- typelem;
+ typioparam;
+ char *strInitVal;
Datum initVal;
+ getTypeInputInfo(transtype, &typinput, &typioparam);
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,
CStringGetDatum(strInitVal),
- ObjectIdGetDatum(typelem),
+ ObjectIdGetDatum(typioparam),
Int32GetDatum(-1));
-
pfree(strInitVal);
return initVal;
}
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 047b8fa2aa..f5f2850b98 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -8,7 +8,7 @@
*
*
* 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)
bool isnull;
Oid typoid,
foutoid,
- typelem;
+ typioparam;
int32 typmod;
bool typisvarlena;
@@ -566,7 +566,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
typmod = -1;
}
- getTypeOutputInfo(typoid, &foutoid, &typelem, &typisvarlena);
+ getTypeOutputInfo(typoid, &foutoid, &typioparam, &typisvarlena);
/*
* If we have a toasted datum, forcibly detoast it here to avoid
@@ -579,7 +579,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
result = OidFunctionCall3(foutoid,
val,
- ObjectIdGetDatum(typelem),
+ ObjectIdGetDatum(typioparam),
Int32GetDatum(typmod));
/* Clean up detoasted copy, if any */