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/commands/remove.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/commands/remove.c')
-rw-r--r-- | src/backend/commands/remove.c | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c index a8ad2620ef7..fdcd0e7e744 100644 --- a/src/backend/commands/remove.c +++ b/src/backend/commands/remove.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.54 2000/10/16 17:08:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.55 2000/11/16 22:30:18 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -73,11 +73,11 @@ RemoveOperator(char *operatorName, /* operator name */ relation = heap_openr(OperatorRelationName, RowExclusiveLock); - tup = SearchSysCacheTupleCopy(OPERNAME, - PointerGetDatum(operatorName), - ObjectIdGetDatum(typeId1), - ObjectIdGetDatum(typeId2), - CharGetDatum(oprtype)); + tup = SearchSysCacheCopy(OPERNAME, + PointerGetDatum(operatorName), + ObjectIdGetDatum(typeId1), + ObjectIdGetDatum(typeId2), + CharGetDatum(oprtype)); if (HeapTupleIsValid(tup)) { @@ -254,14 +254,11 @@ RemoveType(char *typeName) /* type name to be removed */ relation = heap_openr(TypeRelationName, RowExclusiveLock); - tup = SearchSysCacheTuple(TYPENAME, - PointerGetDatum(typeName), - 0, 0, 0); + tup = SearchSysCache(TYPENAME, + PointerGetDatum(typeName), + 0, 0, 0); if (!HeapTupleIsValid(tup)) - { - heap_close(relation, RowExclusiveLock); elog(ERROR, "RemoveType: type '%s' does not exist", typeName); - } typeOid = tup->t_data->t_oid; @@ -271,19 +268,20 @@ RemoveType(char *typeName) /* type name to be removed */ heap_delete(relation, &tup->t_self, NULL); - /* Now, Delete the "array of" that type */ + ReleaseSysCache(tup); + + /* Also, delete the "array of" that type */ shadow_type = makeArrayTypeName(typeName); - tup = SearchSysCacheTuple(TYPENAME, - PointerGetDatum(shadow_type), - 0, 0, 0); + tup = SearchSysCache(TYPENAME, + PointerGetDatum(shadow_type), + 0, 0, 0); if (!HeapTupleIsValid(tup)) - { - heap_close(relation, RowExclusiveLock); elog(ERROR, "RemoveType: type '%s' does not exist", shadow_type); - } heap_delete(relation, &tup->t_self, NULL); + ReleaseSysCache(tup); + heap_close(relation, RowExclusiveLock); } @@ -321,12 +319,11 @@ RemoveFunction(char *functionName, /* function name to be removed */ argList[i] = InvalidOid; else { - tup = SearchSysCacheTuple(TYPENAME, - PointerGetDatum(typnam), - 0, 0, 0); - if (!HeapTupleIsValid(tup)) + argList[i] = GetSysCacheOid(TYPENAME, + PointerGetDatum(typnam), + 0, 0, 0); + if (!OidIsValid(argList[i])) elog(ERROR, "RemoveFunction: type '%s' not found", typnam); - argList[i] = tup->t_data->t_oid; } } @@ -337,11 +334,12 @@ RemoveFunction(char *functionName, /* function name to be removed */ } relation = heap_openr(ProcedureRelationName, RowExclusiveLock); - tup = SearchSysCacheTuple(PROCNAME, - PointerGetDatum(functionName), - Int32GetDatum(nargs), - PointerGetDatum(argList), - 0); + + tup = SearchSysCache(PROCNAME, + PointerGetDatum(functionName), + Int32GetDatum(nargs), + PointerGetDatum(argList), + 0); if (!HeapTupleIsValid(tup)) func_error("RemoveFunction", functionName, nargs, argList, NULL); @@ -359,6 +357,8 @@ RemoveFunction(char *functionName, /* function name to be removed */ heap_delete(relation, &tup->t_self, NULL); + ReleaseSysCache(tup); + heap_close(relation, RowExclusiveLock); } @@ -370,7 +370,6 @@ RemoveAggregate(char *aggName, char *aggType) Oid basetypeID = InvalidOid; bool defined; - /* * if a basetype is passed in, then attempt to find an aggregate for * that specific type. @@ -405,10 +404,11 @@ RemoveAggregate(char *aggName, char *aggType) } relation = heap_openr(AggregateRelationName, RowExclusiveLock); - tup = SearchSysCacheTuple(AGGNAME, - PointerGetDatum(aggName), - ObjectIdGetDatum(basetypeID), - 0, 0); + + tup = SearchSysCache(AGGNAME, + PointerGetDatum(aggName), + ObjectIdGetDatum(basetypeID), + 0, 0); if (!HeapTupleIsValid(tup)) { @@ -431,5 +431,7 @@ RemoveAggregate(char *aggName, char *aggType) heap_delete(relation, &tup->t_self, NULL); + ReleaseSysCache(tup); + heap_close(relation, RowExclusiveLock); } |