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/proclang.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/proclang.c')
-rw-r--r-- | src/backend/commands/proclang.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index ec8aec7005f..5d4d3f09bf7 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -48,7 +48,6 @@ void CreateProceduralLanguage(CreatePLangStmt *stmt) { char languageName[NAMEDATALEN]; - HeapTuple langTup; HeapTuple procTup; Oid typev[FUNC_MAX_ARGS]; @@ -77,10 +76,9 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) */ case_translate_language_name(stmt->plname, languageName); - langTup = SearchSysCacheTuple(LANGNAME, - PointerGetDatum(languageName), - 0, 0, 0); - if (HeapTupleIsValid(langTup)) + if (SearchSysCacheExists(LANGNAME, + PointerGetDatum(languageName), + 0, 0, 0)) elog(ERROR, "Language %s already exists", languageName); /* ---------------- @@ -89,21 +87,17 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) * ---------------- */ memset(typev, 0, sizeof(typev)); - procTup = SearchSysCacheTuple(PROCNAME, - PointerGetDatum(stmt->plhandler), - Int32GetDatum(0), - PointerGetDatum(typev), - 0); + procTup = SearchSysCache(PROCNAME, + PointerGetDatum(stmt->plhandler), + Int32GetDatum(0), + PointerGetDatum(typev), + 0); if (!HeapTupleIsValid(procTup)) - { elog(ERROR, "PL handler function %s() doesn't exist", stmt->plhandler); - } if (((Form_pg_proc) GETSTRUCT(procTup))->prorettype != InvalidOid) - { elog(ERROR, "PL handler function %s() isn't of return type Opaque", stmt->plhandler); - } /* ---------------- * Insert the new language into pg_language @@ -123,6 +117,8 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) values[i++] = DirectFunctionCall1(textin, CStringGetDatum(stmt->plcompiler)); + ReleaseSysCache(procTup); + rel = heap_openr(LanguageRelationName, RowExclusiveLock); tupDesc = rel->rd_att; @@ -173,9 +169,9 @@ DropProceduralLanguage(DropPLangStmt *stmt) rel = heap_openr(LanguageRelationName, RowExclusiveLock); - langTup = SearchSysCacheTupleCopy(LANGNAME, - PointerGetDatum(languageName), - 0, 0, 0); + langTup = SearchSysCacheCopy(LANGNAME, + PointerGetDatum(languageName), + 0, 0, 0); if (!HeapTupleIsValid(langTup)) elog(ERROR, "Language %s doesn't exist", languageName); |