diff options
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plperl/plperl.c | 54 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_comp.c | 92 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 53 | ||||
| -rw-r--r-- | src/pl/tcl/pltcl.c | 69 |
4 files changed, 168 insertions, 100 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index c1516ea692..81a4cd75d4 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -33,7 +33,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.14 2000/10/24 17:01:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.15 2000/11/16 22:30:49 tgl Exp $ * **********************************************************************/ @@ -521,9 +521,9 @@ plperl_func_handler(PG_FUNCTION_ARGS) /************************************************************ * Lookup the pg_proc tuple by Oid ************************************************************/ - procTup = SearchSysCacheTuple(PROCOID, - ObjectIdGetDatum(fcinfo->flinfo->fn_oid), - 0, 0, 0); + procTup = SearchSysCache(PROCOID, + ObjectIdGetDatum(fcinfo->flinfo->fn_oid), + 0, 0, 0); if (!HeapTupleIsValid(procTup)) { free(prodesc->proname); @@ -537,9 +537,9 @@ plperl_func_handler(PG_FUNCTION_ARGS) * Get the required information for input conversion of the * return value. ************************************************************/ - typeTup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), - 0, 0, 0); + typeTup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(procStruct->prorettype), + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { free(prodesc->proname); @@ -560,6 +560,8 @@ plperl_func_handler(PG_FUNCTION_ARGS) prodesc->result_in_elem = (Oid) (typeStruct->typelem); prodesc->result_in_len = typeStruct->typlen; + ReleaseSysCache(typeTup); + /************************************************************ * Get the required information for output conversion * of all procedure arguments @@ -567,9 +569,9 @@ plperl_func_handler(PG_FUNCTION_ARGS) prodesc->nargs = procStruct->pronargs; for (i = 0; i < prodesc->nargs; i++) { - typeTup = SearchSysCacheTuple(TYPEOID, + typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(procStruct->proargtypes[i]), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { free(prodesc->proname); @@ -587,7 +589,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) fmgr_info(typeStruct->typoutput, &(prodesc->arg_out_func[i])); prodesc->arg_out_elem[i] = (Oid) (typeStruct->typelem); prodesc->arg_out_len[i] = typeStruct->typlen; - + ReleaseSysCache(typeTup); } /************************************************************ @@ -617,6 +619,8 @@ plperl_func_handler(PG_FUNCTION_ARGS) ************************************************************/ hv_store(plperl_proc_hash, internal_proname, proname_len, newSViv((IV) prodesc), 0); + + ReleaseSysCache(procTup); } else { @@ -744,9 +748,9 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) /************************************************************ * Lookup the pg_proc tuple by Oid ************************************************************/ - procTup = SearchSysCacheTuple(PROCOID, - ObjectIdGetDatum(fcinfo->flinfo->fn_oid), - 0, 0, 0); + procTup = SearchSysCache(PROCOID, + ObjectIdGetDatum(fcinfo->flinfo->fn_oid), + 0, 0, 0); if (!HeapTupleIsValid(procTup)) { free(prodesc->proname); @@ -819,6 +823,8 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) hashent = Tcl_CreateHashEntry(plperl_proc_hash, prodesc->proname, &hashnew); Tcl_SetHashValue(hashent, (ClientData) prodesc); + + ReleaseSysCache(procTup); } else { @@ -1068,9 +1074,9 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) * Lookup the attribute type in the syscache * for the input function ************************************************************/ - typeTup = SearchSysCacheTuple(TYPEOID, + typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[attnum - 1]->atttypid), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { elog(ERROR, "plperl: Cache lookup for attribute '%s' type %u failed", @@ -1079,6 +1085,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS) } typinput = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typinput); typelem = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typelem); + ReleaseSysCache(typeTup); /************************************************************ * Set the attribute to NOT NULL and convert the contents @@ -1538,9 +1545,9 @@ plperl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, ************************************************************/ for (i = 0; i < nargs; i++) { - typeTup = SearchSysCacheTuple(TYPNAME, - PointerGetDatum(args[i]), - 0, 0, 0); + typeTup = SearchSysCache(TYPNAME, + PointerGetDatum(args[i]), + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "plperl: Cache lookup of type %s failed", args[i]); qdesc->argtypes[i] = typeTup->t_data->t_oid; @@ -1549,6 +1556,7 @@ plperl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, qdesc->argtypelems[i] = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; qdesc->argvalues[i] = (Datum) NULL; qdesc->arglen[i] = (int) (((Form_pg_type) GETSTRUCT(typeTup))->typlen); + ReleaseSysCache(typeTup); } /************************************************************ @@ -2084,9 +2092,9 @@ plperl_set_tuple_values(Tcl_Interp *interp, char *arrayname, * Lookup the attribute type in the syscache * for the output function ************************************************************/ - typeTup = SearchSysCacheTuple(TYPEOID, + typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { elog(ERROR, "plperl: Cache lookup for attribute '%s' type %u failed", @@ -2095,6 +2103,7 @@ plperl_set_tuple_values(Tcl_Interp *interp, char *arrayname, typoutput = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typoutput); typelem = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typelem); + ReleaseSysCache(typeTup); /************************************************************ * If there is a value, set the variable @@ -2156,9 +2165,9 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc) * Lookup the attribute type in the syscache * for the output function ************************************************************/ - typeTup = SearchSysCacheTuple(TYPEOID, + typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { elog(ERROR, "plperl: Cache lookup for attribute '%s' type %u failed", @@ -2167,6 +2176,7 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc) typoutput = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typoutput); typelem = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typelem); + ReleaseSysCache(typeTup); /************************************************************ * If there is a value, append the attribute name and the diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index bed9589096..c0fe596897 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.23 2000/08/31 13:26:16 wieck Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.24 2000/11/16 22:30:50 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -53,7 +53,6 @@ #include "access/heapam.h" #include "utils/syscache.h" -#include "utils/catcache.h" #include "catalog/catname.h" #include "catalog/pg_proc.h" #include "catalog/pg_type.h" @@ -131,9 +130,9 @@ plpgsql_compile(Oid fn_oid, int functype) * Lookup the pg_proc tuple by Oid * ---------- */ - procTup = SearchSysCacheTuple(PROCOID, - ObjectIdGetDatum(fn_oid), - 0, 0, 0); + procTup = SearchSysCache(PROCOID, + ObjectIdGetDatum(fn_oid), + 0, 0, 0); if (!HeapTupleIsValid(procTup)) elog(ERROR, "plpgsql: cache lookup for proc %u failed", fn_oid); @@ -176,9 +175,9 @@ plpgsql_compile(Oid fn_oid, int functype) * Lookup the functions return type * ---------- */ - typeTup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), 0, 0, 0); - + typeTup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(procStruct->prorettype), + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { plpgsql_comperrinfo(); @@ -195,6 +194,7 @@ plpgsql_compile(Oid fn_oid, int functype) function->fn_rettypelem = typeStruct->typelem; fmgr_info(typeStruct->typinput, &(function->fn_retinput)); } + ReleaseSysCache(typeTup); /* ---------- * Create the variables for the procedures parameters @@ -208,9 +208,9 @@ plpgsql_compile(Oid fn_oid, int functype) * Get the parameters type * ---------- */ - typeTup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(procStruct->proargtypes[i]), 0, 0, 0); - + typeTup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(procStruct->proargtypes[i]), + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { plpgsql_comperrinfo(); @@ -276,6 +276,7 @@ plpgsql_compile(Oid fn_oid, int functype) arg_varnos[i] = var->varno; } + ReleaseSysCache(typeTup); } break; @@ -512,6 +513,7 @@ plpgsql_compile(Oid fn_oid, int functype) function->datums[i] = plpgsql_Datums[i]; function->action = plpgsql_yylval.program; + ReleaseSysCache(procTup); /* ---------- * Finally return the compiled function @@ -608,8 +610,9 @@ plpgsql_parse_word(char *word) * ---------- */ typeXlated = xlateSqlType(cp); - typeTup = SearchSysCacheTuple(TYPENAME, - PointerGetDatum(typeXlated), 0, 0, 0); + typeTup = SearchSysCache(TYPENAME, + PointerGetDatum(typeXlated), + 0, 0, 0); if (HeapTupleIsValid(typeTup)) { PLpgSQL_type *typ; @@ -618,6 +621,7 @@ plpgsql_parse_word(char *word) if (typeStruct->typrelid != InvalidOid) { + ReleaseSysCache(typeTup); pfree(cp); return T_WORD; } @@ -634,6 +638,7 @@ plpgsql_parse_word(char *word) plpgsql_yylval.dtype = typ; + ReleaseSysCache(typeTup); pfree(cp); return T_DTYPE; } @@ -933,8 +938,9 @@ plpgsql_parse_wordtype(char *word) * ---------- */ typeXlated = xlateSqlType(cp); - typeTup = SearchSysCacheTuple(TYPENAME, - PointerGetDatum(typeXlated), 0, 0, 0); + typeTup = SearchSysCache(TYPENAME, + PointerGetDatum(typeXlated), + 0, 0, 0); if (HeapTupleIsValid(typeTup)) { PLpgSQL_type *typ; @@ -943,6 +949,7 @@ plpgsql_parse_wordtype(char *word) if (typeStruct->typrelid != InvalidOid) { + ReleaseSysCache(typeTup); pfree(cp); return T_ERROR; } @@ -959,6 +966,7 @@ plpgsql_parse_wordtype(char *word) plpgsql_yylval.dtype = typ; + ReleaseSysCache(typeTup); pfree(cp); return T_DTYPE; } @@ -1045,8 +1053,9 @@ plpgsql_parse_dblwordtype(char *string) * First word could also be a table name * ---------- */ - classtup = SearchSysCacheTuple(RELNAME, - PointerGetDatum(word1), 0, 0, 0); + classtup = SearchSysCache(RELNAME, + PointerGetDatum(word1), + 0, 0, 0); if (!HeapTupleIsValid(classtup)) { pfree(word1); @@ -1060,6 +1069,7 @@ plpgsql_parse_dblwordtype(char *string) classStruct = (Form_pg_class) GETSTRUCT(classtup); if (classStruct->relkind != 'r' && classStruct->relkind != 's') { + ReleaseSysCache(classtup); pfree(word1); return T_ERROR; } @@ -1068,31 +1078,33 @@ plpgsql_parse_dblwordtype(char *string) * Fetch the named table field and it's type * ---------- */ - attrtup = SearchSysCacheTuple(ATTNAME, - ObjectIdGetDatum(classtup->t_data->t_oid), - PointerGetDatum(word2), 0, 0); + attrtup = SearchSysCache(ATTNAME, + ObjectIdGetDatum(classtup->t_data->t_oid), + PointerGetDatum(word2), + 0, 0); if (!HeapTupleIsValid(attrtup)) { + ReleaseSysCache(classtup); pfree(word1); return T_ERROR; } attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup); - typetup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(attrStruct->atttypid), 0, 0, 0); + typetup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(attrStruct->atttypid), + 0, 0, 0); if (!HeapTupleIsValid(typetup)) { plpgsql_comperrinfo(); elog(ERROR, "cache lookup for type %u of %s.%s failed", attrStruct->atttypid, word1, word2); } + typeStruct = (Form_pg_type) GETSTRUCT(typetup); /* ---------- * Found that - build a compiler type struct and return it * ---------- */ - typeStruct = (Form_pg_type) GETSTRUCT(typetup); - typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type)); typ->typname = DatumGetCString(DirectFunctionCall1(nameout, @@ -1105,6 +1117,9 @@ plpgsql_parse_dblwordtype(char *string) plpgsql_yylval.dtype = typ; + ReleaseSysCache(classtup); + ReleaseSysCache(attrtup); + ReleaseSysCache(typetup); pfree(word1); return T_DTYPE; } @@ -1138,8 +1153,9 @@ plpgsql_parse_wordrowtype(char *string) cp = strchr(word1, '%'); *cp = '\0'; - classtup = SearchSysCacheTuple(RELNAME, - PointerGetDatum(word1), 0, 0, 0); + classtup = SearchSysCache(RELNAME, + PointerGetDatum(word1), + 0, 0, 0); if (!HeapTupleIsValid(classtup)) { plpgsql_comperrinfo(); @@ -1156,8 +1172,9 @@ plpgsql_parse_wordrowtype(char *string) * Fetch the tables pg_type tuple too * ---------- */ - typetup = SearchSysCacheTuple(TYPENAME, - PointerGetDatum(word1), 0, 0, 0); + typetup = SearchSysCache(TYPENAME, + PointerGetDatum(word1), + 0, 0, 0); if (!HeapTupleIsValid(typetup)) { plpgsql_comperrinfo(); @@ -1178,15 +1195,18 @@ plpgsql_parse_wordrowtype(char *string) row->fieldnames = malloc(sizeof(char *) * row->nfields); row->varnos = malloc(sizeof(int) * row->nfields); + ReleaseSysCache(typetup); + for (i = 0; i < row->nfields; i++) { /* ---------- * Get the attribute and it's type * ---------- */ - attrtup = SearchSysCacheTuple(ATTNUM, - ObjectIdGetDatum(classtup->t_data->t_oid), - (Datum) (i + 1), 0, 0); + attrtup = SearchSysCache(ATTNUM, + ObjectIdGetDatum(classtup->t_data->t_oid), + Int16GetDatum(i + 1), + 0, 0); if (!HeapTupleIsValid(attrtup)) { plpgsql_comperrinfo(); @@ -1198,8 +1218,9 @@ plpgsql_parse_wordrowtype(char *string) cp = DatumGetCString(DirectFunctionCall1(nameout, NameGetDatum(&(attrStruct->attname)))); - typetup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(attrStruct->atttypid), 0, 0, 0); + typetup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(attrStruct->atttypid), + 0, 0, 0); if (!HeapTupleIsValid(typetup)) { plpgsql_comperrinfo(); @@ -1238,6 +1259,9 @@ plpgsql_parse_wordrowtype(char *string) var->isnull = true; var->shouldfree = false; + ReleaseSysCache(typetup); + ReleaseSysCache(attrtup); + plpgsql_adddatum((PLpgSQL_datum *) var); /* ---------- @@ -1248,6 +1272,8 @@ plpgsql_parse_wordrowtype(char *string) row->varnos[i] = var->varno; } + ReleaseSysCache(classtup); + /* ---------- * Return the complete row definition * ---------- diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 9c094a0739..565e304f64 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.31 2000/09/12 19:41:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.32 2000/11/16 22:30:50 tgl Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -1641,10 +1641,12 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) extval = "<NULL>"; else { - typetup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(var->datatype->typoid), 0, 0, 0); + typetup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(var->datatype->typoid), + 0, 0, 0); if (!HeapTupleIsValid(typetup)) - elog(ERROR, "cache lookup for type %u failed (1)", var->datatype->typoid); + elog(ERROR, "cache lookup for type %u failed (1)", + var->datatype->typoid); typeStruct = (Form_pg_type) GETSTRUCT(typetup); fmgr_info(typeStruct->typoutput, &finfo_output); @@ -1652,6 +1654,7 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) var->value, ObjectIdGetDatum(typeStruct->typelem), Int32GetDatum(var->datatype->atttypmod))); + ReleaseSysCache(typetup); } plpgsql_dstring_append(&ds, extval); break; @@ -1961,21 +1964,24 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate, * Get the C-String representation. * ---------- */ - typetup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(restype), 0, 0, 0); + typetup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(restype), + 0, 0, 0); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup for type %u failed (1)", restype); typeStruct = (Form_pg_type) GETSTRUCT(typetup); fmgr_info(typeStruct->typoutput, &finfo_output); querystr = DatumGetCString(FunctionCall3(&finfo_output, - query, - ObjectIdGetDatum(typeStruct->typelem), - Int32GetDatum(-1))); + query, + ObjectIdGetDatum(typeStruct->typelem), + Int32GetDatum(-1))); if(!typeStruct->typbyval) pfree((void *)query); + ReleaseSysCache(typetup); + /* ---------- * Call SPI_exec() without preparing a saved plan. * The returncode can be any OK except for OK_SELECT. @@ -2064,8 +2070,9 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) * Get the C-String representation. * ---------- */ - typetup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(restype), 0, 0, 0); + typetup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(restype), + 0, 0, 0); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup for type %u failed (1)", restype); typeStruct = (Form_pg_type) GETSTRUCT(typetup); @@ -2079,6 +2086,8 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) if(!typeStruct->typbyval) pfree((void *)query); + ReleaseSysCache(typetup); + /* ---------- * Run the query * ---------- @@ -2283,8 +2292,9 @@ exec_assign_value(PLpgSQL_execstate * estate, */ atttype = SPI_gettypeid(rec->tupdesc, i + 1); atttypmod = rec->tupdesc->attrs[i]->atttypmod; - typetup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(atttype), 0, 0, 0); + typetup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(atttype), + 0, 0, 0); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup for type %u failed", atttype); typeStruct = (Form_pg_type) GETSTRUCT(typetup); @@ -2299,6 +2309,7 @@ exec_assign_value(PLpgSQL_execstate * estate, nulls[i] = 'n'; else nulls[i] = ' '; + ReleaseSysCache(typetup); } /* ---------- @@ -2603,9 +2614,13 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, * so that we can free the expression context. */ if (! *isNull) - retval = datumCopy(retval, - get_typbyval(*rettype), - get_typlen(*rettype)); + { + int16 typeLength; + bool byValue; + + get_typlenbyval(*rettype, &typeLength, &byValue); + retval = datumCopy(retval, byValue, typeLength); + } FreeExprContext(econtext); @@ -2726,8 +2741,9 @@ exec_cast_value(Datum value, Oid valtype, FmgrInfo finfo_output; char *extval; - typetup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(valtype), 0, 0, 0); + typetup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(valtype), + 0, 0, 0); if (!HeapTupleIsValid(typetup)) elog(ERROR, "cache lookup for type %u failed", valtype); typeStruct = (Form_pg_type) GETSTRUCT(typetup); @@ -2742,6 +2758,7 @@ exec_cast_value(Datum value, Oid valtype, ObjectIdGetDatum(reqtypelem), Int32GetDatum(reqtypmod)); pfree(extval); + ReleaseSysCache(typetup); } } diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 0c2ec992b7..8658cac306 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -31,7 +31,7 @@ * ENHANCEMENTS, OR MODIFICATIONS. * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.28 2000/07/19 11:53:02 wieck Exp $ + * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.29 2000/11/16 22:30:52 tgl Exp $ * **********************************************************************/ @@ -437,9 +437,9 @@ pltcl_func_handler(PG_FUNCTION_ARGS) /************************************************************ * Lookup the pg_proc tuple by Oid ************************************************************/ - procTup = SearchSysCacheTuple(PROCOID, - ObjectIdGetDatum(fcinfo->flinfo->fn_oid), - 0, 0, 0); + procTup = SearchSysCache(PROCOID, + ObjectIdGetDatum(fcinfo->flinfo->fn_oid), + 0, 0, 0); if (!HeapTupleIsValid(procTup)) { free(prodesc->proname); @@ -452,9 +452,9 @@ pltcl_func_handler(PG_FUNCTION_ARGS) /************************************************************ * Lookup the pg_language tuple by Oid ************************************************************/ - langTup = SearchSysCacheTuple(LANGOID, - ObjectIdGetDatum(procStruct->prolang), - 0, 0, 0); + langTup = SearchSysCache(LANGOID, + ObjectIdGetDatum(procStruct->prolang), + 0, 0, 0); if (!HeapTupleIsValid(langTup)) { free(prodesc->proname); @@ -469,14 +469,15 @@ pltcl_func_handler(PG_FUNCTION_ARGS) interp = pltcl_safe_interp; else interp = pltcl_norm_interp; + ReleaseSysCache(langTup); /************************************************************ * Get the required information for input conversion of the * return value. ************************************************************/ - typeTup = SearchSysCacheTuple(TYPEOID, - ObjectIdGetDatum(procStruct->prorettype), - 0, 0, 0); + typeTup = SearchSysCache(TYPEOID, + ObjectIdGetDatum(procStruct->prorettype), + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { free(prodesc->proname); @@ -496,6 +497,8 @@ pltcl_func_handler(PG_FUNCTION_ARGS) fmgr_info(typeStruct->typinput, &(prodesc->result_in_func)); prodesc->result_in_elem = typeStruct->typelem; + ReleaseSysCache(typeTup); + /************************************************************ * Get the required information for output conversion * of all procedure arguments @@ -504,9 +507,9 @@ pltcl_func_handler(PG_FUNCTION_ARGS) proc_internal_args[0] = '\0'; for (i = 0; i < prodesc->nargs; i++) { - typeTup = SearchSysCacheTuple(TYPEOID, + typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(procStruct->proargtypes[i]), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { free(prodesc->proname); @@ -523,6 +526,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS) strcat(proc_internal_args, " "); sprintf(buf, "__PLTcl_Tup_%d", i + 1); strcat(proc_internal_args, buf); + ReleaseSysCache(typeTup); continue; } else @@ -536,6 +540,8 @@ pltcl_func_handler(PG_FUNCTION_ARGS) strcat(proc_internal_args, " "); sprintf(buf, "%d", i + 1); strcat(proc_internal_args, buf); + + ReleaseSysCache(typeTup); } /************************************************************ @@ -591,6 +597,8 @@ pltcl_func_handler(PG_FUNCTION_ARGS) hashent = Tcl_CreateHashEntry(pltcl_proc_hash, prodesc->proname, &hashnew); Tcl_SetHashValue(hashent, (ClientData) prodesc); + + ReleaseSysCache(procTup); } else { @@ -800,9 +808,9 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) /************************************************************ * Lookup the pg_proc tuple by Oid ************************************************************/ - procTup = SearchSysCacheTuple(PROCOID, - ObjectIdGetDatum(fcinfo->flinfo->fn_oid), - 0, 0, 0); + procTup = SearchSysCache(PROCOID, + ObjectIdGetDatum(fcinfo->flinfo->fn_oid), + 0, 0, 0); if (!HeapTupleIsValid(procTup)) { free(prodesc->proname); @@ -815,9 +823,9 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) /************************************************************ * Lookup the pg_language tuple by Oid ************************************************************/ - langTup = SearchSysCacheTuple(LANGOID, - ObjectIdGetDatum(procStruct->prolang), - 0, 0, 0); + langTup = SearchSysCache(LANGOID, + ObjectIdGetDatum(procStruct->prolang), + 0, 0, 0); if (!HeapTupleIsValid(langTup)) { free(prodesc->proname); @@ -832,6 +840,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) interp = pltcl_safe_interp; else interp = pltcl_norm_interp; + ReleaseSysCache(langTup); /************************************************************ * Create the tcl command to define the internal @@ -896,6 +905,8 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) hashent = Tcl_CreateHashEntry(pltcl_proc_hash, prodesc->proname, &hashnew); Tcl_SetHashValue(hashent, (ClientData) prodesc); + + ReleaseSysCache(procTup); } else { @@ -1151,9 +1162,9 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) * Lookup the attribute type in the syscache * for the input function ************************************************************/ - typeTup = SearchSysCacheTuple(TYPEOID, + typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[attnum - 1]->atttypid), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { elog(ERROR, "pltcl: Cache lookup for attribute '%s' type %u failed", @@ -1162,6 +1173,7 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS) } typinput = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typinput); typelem = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typelem); + ReleaseSysCache(typeTup); /************************************************************ * Set the attribute to NOT NULL and convert the contents @@ -1706,9 +1718,9 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, ************************************************************/ for (i = 0; i < nargs; i++) { - typeTup = SearchSysCacheTuple(TYPENAME, - PointerGetDatum(args[i]), - 0, 0, 0); + typeTup = SearchSysCache(TYPENAME, + PointerGetDatum(args[i]), + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) elog(ERROR, "pltcl: Cache lookup of type %s failed", args[i]); qdesc->argtypes[i] = typeTup->t_data->t_oid; @@ -1717,6 +1729,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, qdesc->argtypelems[i] = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; qdesc->argvalues[i] = (Datum) NULL; qdesc->arglen[i] = (int) (((Form_pg_type) GETSTRUCT(typeTup))->typlen); + ReleaseSysCache(typeTup); } /************************************************************ @@ -2263,9 +2276,9 @@ pltcl_set_tuple_values(Tcl_Interp *interp, char *arrayname, * Lookup the attribute type in the syscache * for the output function ************************************************************/ - typeTup = SearchSysCacheTuple(TYPEOID, + typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { elog(ERROR, "pltcl: Cache lookup for attribute '%s' type %u failed", @@ -2274,6 +2287,7 @@ pltcl_set_tuple_values(Tcl_Interp *interp, char *arrayname, typoutput = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typoutput); typelem = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typelem); + ReleaseSysCache(typeTup); /************************************************************ * If there is a value, set the variable @@ -2332,9 +2346,9 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, * Lookup the attribute type in the syscache * for the output function ************************************************************/ - typeTup = SearchSysCacheTuple(TYPEOID, + typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), - 0, 0, 0); + 0, 0, 0); if (!HeapTupleIsValid(typeTup)) { elog(ERROR, "pltcl: Cache lookup for attribute '%s' type %u failed", @@ -2343,6 +2357,7 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc, typoutput = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typoutput); typelem = (Oid) (((Form_pg_type) GETSTRUCT(typeTup))->typelem); + ReleaseSysCache(typeTup); /************************************************************ * If there is a value, append the attribute name and the |
