diff options
-rw-r--r-- | src/backend/access/heap/tuptoaster.c | 7 | ||||
-rw-r--r-- | src/backend/parser/parse_coerce.c | 6 | ||||
-rw-r--r-- | src/backend/parser/parse_target.c | 5 | ||||
-rw-r--r-- | src/backend/utils/adt/rowtypes.c | 10 | ||||
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 3 | ||||
-rw-r--r-- | src/backend/utils/cache/typcache.c | 4 | ||||
-rw-r--r-- | src/pl/plperl/plperl.c | 6 | ||||
-rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 8 | ||||
-rw-r--r-- | src/pl/plpython/plpython.c | 4 | ||||
-rw-r--r-- | src/pl/tcl/pltcl.c | 4 |
10 files changed, 45 insertions, 12 deletions
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c index c06b3b8d36a..02af9d8e455 100644 --- a/src/backend/access/heap/tuptoaster.c +++ b/src/backend/access/heap/tuptoaster.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.47 2005/01/01 05:43:06 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/tuptoaster.c,v 1.47.4.1 2006/01/17 17:33:34 tgl Exp $ * * * INTERFACE ROUTINES @@ -820,6 +820,7 @@ toast_flatten_tuple_attribute(Datum value, if (tupleDesc == NULL) return value; /* not a composite type */ + tupleDesc = CreateTupleDescCopy(tupleDesc); att = tupleDesc->attrs; numAttrs = tupleDesc->natts; @@ -866,7 +867,10 @@ toast_flatten_tuple_attribute(Datum value, * If nothing to untoast, just return the original tuple. */ if (!need_change) + { + FreeTupleDesc(tupleDesc); return value; + } /* * Calculate the new size of the tuple. Header size should not @@ -903,6 +907,7 @@ toast_flatten_tuple_attribute(Datum value, for (i = 0; i < numAttrs; i++) if (toast_free[i]) pfree(DatumGetPointer(toast_values[i])); + FreeTupleDesc(tupleDesc); return PointerGetDatum(new_data); } diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index 125c218bb55..869e870b66c 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.126.4.1 2006/01/12 22:29:22 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.126.4.2 2006/01/17 17:33:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -700,7 +700,7 @@ coerce_record_to_complex(ParseState *pstate, Node *node, format_type_be(RECORDOID), format_type_be(targetTypeId)))); - tupdesc = lookup_rowtype_tupdesc(targetTypeId, -1); + tupdesc = CreateTupleDescCopy(lookup_rowtype_tupdesc(targetTypeId, -1)); newargs = NIL; ucolno = 1; arg = list_head(args); @@ -758,6 +758,8 @@ coerce_record_to_complex(ParseState *pstate, Node *node, format_type_be(targetTypeId)), errdetail("Input has too many columns."))); + FreeTupleDesc(tupdesc); + rowexpr = makeNode(RowExpr); rowexpr->args = newargs; rowexpr->row_typeid = targetTypeId; diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index a6b1edbe48d..fc1ddc3dadb 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.129.4.1 2005/12/14 16:30:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.129.4.2 2006/01/17 17:33:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -839,6 +839,7 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind) /* Verify it's a composite type, and get the tupdesc */ tupleDesc = lookup_rowtype_tupdesc(exprType(expr), exprTypmod(expr)); + tupleDesc = CreateTupleDescCopy(tupleDesc); /* Generate a list of references to the individual fields */ numAttrs = tupleDesc->natts; @@ -889,6 +890,8 @@ ExpandIndirectionStar(ParseState *pstate, A_Indirection *ind) te_list = lappend(te_list, te); } + FreeTupleDesc(tupleDesc); + return te_list; } diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c index 603072886e2..6f9c8aca0ce 100644 --- a/src/backend/utils/adt/rowtypes.c +++ b/src/backend/utils/adt/rowtypes.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.8.4.2 2005/04/30 20:04:46 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.8.4.3 2006/01/17 17:33:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -79,6 +79,7 @@ record_in(PG_FUNCTION_ARGS) errmsg("input of anonymous composite types is not implemented"))); tupTypmod = -1; /* for all non-anonymous types */ tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); ncolumns = tupdesc->natts; /* @@ -257,6 +258,7 @@ record_in(PG_FUNCTION_ARGS) pfree(buf.data); pfree(values); pfree(nulls); + FreeTupleDesc(tupdesc); PG_RETURN_HEAPTUPLEHEADER(result); } @@ -284,6 +286,7 @@ record_out(PG_FUNCTION_ARGS) tupType = HeapTupleHeaderGetTypeId(rec); tupTypmod = HeapTupleHeaderGetTypMod(rec); tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); ncolumns = tupdesc->natts; /* Build a temporary HeapTuple control structure */ @@ -408,6 +411,7 @@ record_out(PG_FUNCTION_ARGS) pfree(values); pfree(nulls); + FreeTupleDesc(tupdesc); PG_RETURN_CSTRING(buf.data); } @@ -444,6 +448,7 @@ record_recv(PG_FUNCTION_ARGS) errmsg("input of anonymous composite types is not implemented"))); tupTypmod = -1; /* for all non-anonymous types */ tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); ncolumns = tupdesc->natts; /* @@ -593,6 +598,7 @@ record_recv(PG_FUNCTION_ARGS) heap_freetuple(tuple); pfree(values); pfree(nulls); + FreeTupleDesc(tupdesc); PG_RETURN_HEAPTUPLEHEADER(result); } @@ -620,6 +626,7 @@ record_send(PG_FUNCTION_ARGS) tupType = HeapTupleHeaderGetTypeId(rec); tupTypmod = HeapTupleHeaderGetTypMod(rec); tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); ncolumns = tupdesc->natts; /* Build a temporary HeapTuple control structure */ @@ -722,6 +729,7 @@ record_send(PG_FUNCTION_ARGS) pfree(values); pfree(nulls); + FreeTupleDesc(tupdesc); PG_RETURN_BYTEA_P(pq_endtypsend(&buf)); } diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 63ec591edfb..a2552f4722a 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.188.4.2 2005/07/15 18:40:20 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.188.4.3 2006/01/17 17:33:34 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -3245,6 +3245,7 @@ get_rule_expr(Node *node, deparse_context *context, if (rowexpr->row_typeid != RECORDOID) { tupdesc = lookup_rowtype_tupdesc(rowexpr->row_typeid, -1); + tupdesc = CreateTupleDescCopy(tupdesc); Assert(list_length(rowexpr->args) <= tupdesc->natts); } diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c index 7e15f884f61..b719f99d82d 100644 --- a/src/backend/utils/cache/typcache.c +++ b/src/backend/utils/cache/typcache.c @@ -36,7 +36,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.11 2004/12/31 22:01:25 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.11.4.1 2006/01/17 17:33:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -383,6 +383,8 @@ lookup_default_opclass(Oid type_id, Oid am_id) * * Note: returned TupleDesc points to cached copy; caller must copy it * if intending to scribble on it or keep a reference for a long time. + * ("A long time" basically means "across any possible cache flush", + * which typically could occur at any relation open or catalog lookup.) */ TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod) diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index c14e6eb60f9..96c8705e225 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -33,7 +33,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.67.4.4 2006/01/08 15:51:18 adunstan Exp $ + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.67.4.5 2006/01/17 17:33:35 tgl Exp $ * **********************************************************************/ @@ -705,12 +705,14 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo) tupType = HeapTupleHeaderGetTypeId(td); tupTypmod = HeapTupleHeaderGetTypMod(td); tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); /* Build a temporary HeapTuple control structure */ tmptup.t_len = HeapTupleHeaderGetDatumLength(td); tmptup.t_data = td; hashref = plperl_hash_from_tuple(&tmptup, tupdesc); XPUSHs(sv_2mortal(hashref)); + FreeTupleDesc(tupdesc); } else { @@ -1009,7 +1011,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) */ td = get_function_tupdesc(prodesc->result_oid, (ReturnSetInfo *) fcinfo->resultinfo); - /* td = CreateTupleDescCopy(td); */ + td = CreateTupleDescCopy(td); attinmeta = TupleDescGetAttInMetadata(td); tup = plperl_build_tuple_result(perlhash, attinmeta); diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 9d17ead258f..d1a3a098dc2 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.127.4.4 2006/01/03 22:48:28 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.127.4.5 2006/01/17 17:33:36 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -273,12 +273,14 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo) tupType = HeapTupleHeaderGetTypeId(td); tupTypmod = HeapTupleHeaderGetTypMod(td); tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); /* Build a temporary HeapTuple control structure */ tmptup.t_len = HeapTupleHeaderGetDatumLength(td); ItemPointerSetInvalid(&(tmptup.t_self)); tmptup.t_tableOid = InvalidOid; tmptup.t_data = td; exec_move_row(&estate, NULL, row, &tmptup, tupdesc); + FreeTupleDesc(tupdesc); } else { @@ -2948,12 +2950,14 @@ exec_assign_value(PLpgSQL_execstate *estate, tupType = HeapTupleHeaderGetTypeId(td); tupTypmod = HeapTupleHeaderGetTypMod(td); tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); /* Build a temporary HeapTuple control structure */ tmptup.t_len = HeapTupleHeaderGetDatumLength(td); ItemPointerSetInvalid(&(tmptup.t_self)); tmptup.t_tableOid = InvalidOid; tmptup.t_data = td; exec_move_row(estate, NULL, row, &tmptup, tupdesc); + FreeTupleDesc(tupdesc); } break; } @@ -2990,12 +2994,14 @@ exec_assign_value(PLpgSQL_execstate *estate, tupType = HeapTupleHeaderGetTypeId(td); tupTypmod = HeapTupleHeaderGetTypMod(td); tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); /* Build a temporary HeapTuple control structure */ tmptup.t_len = HeapTupleHeaderGetDatumLength(td); ItemPointerSetInvalid(&(tmptup.t_self)); tmptup.t_tableOid = InvalidOid; tmptup.t_data = td; exec_move_row(estate, rec, NULL, &tmptup, tupdesc); + FreeTupleDesc(tupdesc); } break; } diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c index b93a94c8826..851a89ae2ab 100644 --- a/src/pl/plpython/plpython.c +++ b/src/pl/plpython/plpython.c @@ -29,7 +29,7 @@ * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.58.4.4 2006/01/10 00:33:48 neilc Exp $ + * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.58.4.5 2006/01/17 17:33:37 tgl Exp $ * ********************************************************************* */ @@ -861,6 +861,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc) tupType = HeapTupleHeaderGetTypeId(td); tupTypmod = HeapTupleHeaderGetTypMod(td); tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); /* Set up I/O funcs if not done yet */ if (proc->args[i].is_rowtype != 1) @@ -871,6 +872,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc) tmptup.t_data = td; arg = PLyDict_FromTuple(&(proc->args[i]), &tmptup, tupdesc); + FreeTupleDesc(tupdesc); } } else diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index a95344759a3..7928f3eb761 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -31,7 +31,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.94 2004/11/21 21:17:05 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.94.4.1 2006/01/17 17:33:37 tgl Exp $ * **********************************************************************/ @@ -533,6 +533,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS) tupType = HeapTupleHeaderGetTypeId(td); tupTypmod = HeapTupleHeaderGetTypMod(td); tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod); + tupdesc = CreateTupleDescCopy(tupdesc); /* Build a temporary HeapTuple control structure */ tmptup.t_len = HeapTupleHeaderGetDatumLength(td); tmptup.t_data = td; @@ -541,6 +542,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS) pltcl_build_tuple_argument(&tmptup, tupdesc, &list_tmp); Tcl_DStringAppendElement(&tcl_cmd, Tcl_DStringValue(&list_tmp)); + FreeTupleDesc(tupdesc); } } else |