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/optimizer/plan/subselect.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/optimizer/plan/subselect.c')
-rw-r--r-- | src/backend/optimizer/plan/subselect.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index 296164acb89..c36e7fe7b81 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.44 2000/10/26 21:36:09 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.45 2000/11/16 22:30:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ #include "optimizer/subselect.h" #include "parser/parse_expr.h" #include "parser/parse_oper.h" -#include "utils/lsyscache.h" +#include "utils/syscache.h" Index PlannerQueryLevel; /* level of current query */ @@ -271,8 +271,11 @@ make_subplan(SubLink *slink) pfree(var); /* var is only needed for new_param */ Assert(IsA(oper, Oper)); - tup = get_operator_tuple(oper->opno); - Assert(HeapTupleIsValid(tup)); + tup = SearchSysCache(OPEROID, + ObjectIdGetDatum(oper->opno), + 0, 0, 0); + if (! HeapTupleIsValid(tup)) + elog(ERROR, "cache lookup failed for operator %u", oper->opno); opform = (Form_pg_operator) GETSTRUCT(tup); /* @@ -283,6 +286,8 @@ make_subplan(SubLink *slink) exprType(lefthand), opform->oprleft); right = make_operand("", (Node *) prm, prm->paramtype, opform->oprright); + ReleaseSysCache(tup); + newoper = lappend(newoper, make_opclause(oper, (Var *) left, @@ -401,15 +406,14 @@ make_subplan(SubLink *slink) Node *left, *right; - /* - * XXX really ought to fill in constlen and constbyval - * correctly, but right now ExecEvalExpr won't look at them... - */ - con = makeConst(te->resdom->restype, 0, 0, true, 0, 0, 0); + con = makeNullConst(te->resdom->restype); Assert(IsA(oper, Oper)); - tup = get_operator_tuple(oper->opno); - Assert(HeapTupleIsValid(tup)); + tup = SearchSysCache(OPEROID, + ObjectIdGetDatum(oper->opno), + 0, 0, 0); + if (! HeapTupleIsValid(tup)) + elog(ERROR, "cache lookup failed for operator %u", oper->opno); opform = (Form_pg_operator) GETSTRUCT(tup); /* @@ -420,6 +424,8 @@ make_subplan(SubLink *slink) exprType(lefthand), opform->oprleft); right = make_operand("", (Node *) con, con->consttype, opform->oprright); + ReleaseSysCache(tup); + newoper = lappend(newoper, make_opclause(oper, (Var *) left, |