diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-16 22:30:52 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-11-16 22:30:52 +0000 |
commit | a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d (patch) | |
tree | 1c32737389b2530e7152dc2287161b36d9001e8c /src/backend/utils/adt/sets.c | |
parent | cff23842a4c68301ddf34559c7af383bb5557054 (diff) | |
download | postgresql-a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d.tar.gz postgresql-a933ee38bbb8dffbc48a3363a94ff6f2a9f7964d.zip |
Change SearchSysCache coding conventions so that a reference count is
maintained for each cache entry. A cache entry will not be freed until
the matching ReleaseSysCache call has been executed. This eliminates
worries about cache entries getting dropped while still in use. See
my posting to pg-hackers of even date for more info.
Diffstat (limited to 'src/backend/utils/adt/sets.c')
-rw-r--r-- | src/backend/utils/adt/sets.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/src/backend/utils/adt/sets.c b/src/backend/utils/adt/sets.c index 9a5f05134cd..6f64847dcab 100644 --- a/src/backend/utils/adt/sets.c +++ b/src/backend/utils/adt/sets.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.33 2000/08/24 03:29:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.34 2000/11/16 22:30:31 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -77,9 +77,11 @@ SetDefine(char *querystr, char *typename) */ CommandCounterIncrement(); - tup = SearchSysCacheTuple(PROCOID, - ObjectIdGetDatum(setoid), - 0, 0, 0); + procrel = heap_openr(ProcedureRelationName, RowExclusiveLock); + + tup = SearchSysCache(PROCOID, + ObjectIdGetDatum(setoid), + 0, 0, 0); if (!HeapTupleIsValid(tup)) elog(ERROR, "SetDefine: unable to define set %s", querystr); @@ -105,25 +107,15 @@ SetDefine(char *querystr, char *typename) replNull[i] = ' '; /* change the pg_proc tuple */ - procrel = heap_openr(ProcedureRelationName, RowExclusiveLock); + newtup = heap_modifytuple(tup, + procrel, + replValue, + replNull, + repl); - tup = SearchSysCacheTuple(PROCOID, - ObjectIdGetDatum(setoid), - 0, 0, 0); - if (HeapTupleIsValid(tup)) - { - newtup = heap_modifytuple(tup, - procrel, - replValue, - replNull, - repl); + heap_update(procrel, &newtup->t_self, newtup, NULL); - heap_update(procrel, &tup->t_self, newtup, NULL); - - setoid = newtup->t_data->t_oid; - } - else - elog(ERROR, "SetDefine: could not find new set oid tuple"); + setoid = newtup->t_data->t_oid; if (RelationGetForm(procrel)->relhasindex) { @@ -133,9 +125,13 @@ SetDefine(char *querystr, char *typename) CatalogIndexInsert(idescs, Num_pg_proc_indices, procrel, newtup); CatalogCloseIndices(Num_pg_proc_indices, idescs); } - heap_close(procrel, RowExclusiveLock); + heap_freetuple(newtup); } + ReleaseSysCache(tup); + + heap_close(procrel, RowExclusiveLock); + return setoid; } |