diff options
author | Tom Lane | 2004-04-01 21:28:47 +0000 |
---|---|---|
committer | Tom Lane | 2004-04-01 21:28:47 +0000 |
commit | 375369acd1c621bdc683c58bc9c31d4e79d14849 (patch) | |
tree | f29974842cea4105c92da6031bac736ddf5f833a /contrib/tablefunc/tablefunc.c | |
parent | 8590a62b75d3dba24609eb46b34fac13ed881d9e (diff) |
Replace TupleTableSlot convention for whole-row variables and function
results with tuples as ordinary varlena Datums. This commit does not
in itself do much for us, except eliminate the horrid memory leak
associated with evaluation of whole-row variables. However, it lays the
groundwork for allowing composite types as table columns, and perhaps
some other useful features as well. Per my proposal of a few days ago.
Diffstat (limited to 'contrib/tablefunc/tablefunc.c')
-rw-r--r-- | contrib/tablefunc/tablefunc.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c index 622164b91b5..3eccebf476f 100644 --- a/contrib/tablefunc/tablefunc.c +++ b/contrib/tablefunc/tablefunc.c @@ -351,7 +351,6 @@ crosstab(PG_FUNCTION_ARGS) TupleDesc ret_tupdesc; int call_cntr; int max_calls; - TupleTableSlot *slot; AttInMetadata *attinmeta; SPITupleTable *spi_tuptable = NULL; TupleDesc spi_tupdesc; @@ -429,10 +428,10 @@ crosstab(PG_FUNCTION_ARGS) if (functyptype == 'c') { - /* Build a tuple description for a functypeid tuple */ + /* Build a tuple description for a named composite type */ tupdesc = TypeGetTupleDesc(functypeid, NIL); } - else if (functyptype == 'p' && functypeid == RECORDOID) + else if (functypeid == RECORDOID) { if (fcinfo->nargs != 2) ereport(ERROR, @@ -461,12 +460,6 @@ crosstab(PG_FUNCTION_ARGS) errmsg("return and sql tuple descriptions are " \ "incompatible"))); - /* allocate a slot for a tuple with this tupdesc */ - slot = TupleDescGetSlot(tupdesc); - - /* assign slot to function context */ - funcctx->slot = slot; - /* * Generate attribute metadata needed later to produce tuples from * raw C strings @@ -499,9 +492,6 @@ crosstab(PG_FUNCTION_ARGS) call_cntr = funcctx->call_cntr; max_calls = funcctx->max_calls; - /* return slot for our tuple */ - slot = funcctx->slot; - /* user context info */ fctx = (crosstab_fctx *) funcctx->user_fctx; lastrowid = fctx->lastrowid; @@ -621,7 +611,7 @@ crosstab(PG_FUNCTION_ARGS) tuple = BuildTupleFromCStrings(attinmeta, values); /* make the tuple into a datum */ - result = TupleGetDatum(slot, tuple); + result = HeapTupleGetDatum(tuple); /* Clean up */ for (i = 0; i < num_categories + 1; i++) @@ -1675,7 +1665,7 @@ make_crosstab_tupledesc(TupleDesc spi_tupdesc, int num_categories) strcpy(attname, "rowname"); TupleDescInitEntry(tupdesc, attnum, attname, sql_atttypid, - -1, 0, false); + -1, 0); /* now the category values columns */ sql_attr = spi_tupdesc->attrs[2]; @@ -1687,7 +1677,7 @@ make_crosstab_tupledesc(TupleDesc spi_tupdesc, int num_categories) sprintf(attname, "category_%d", i + 1); TupleDescInitEntry(tupdesc, attnum, attname, sql_atttypid, - -1, 0, false); + -1, 0); } return tupdesc; |