From bdca82f44d0e0168dece56cbd53b54ba142f328f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 22 Feb 2011 19:23:23 -0500 Subject: Add a relkind field to RangeTblEntry to avoid some syscache lookups. The recent additions for FDW support required checking foreign-table-ness in several places in the parse/plan chain. While it's not clear whether that would really result in a noticeable slowdown, it seems best to avoid any performance risk by keeping a copy of the relation's relkind in RangeTblEntry. That might have some other uses later, anyway. Per discussion. --- src/backend/utils/adt/ruleutils.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/backend/utils/adt/ruleutils.c') diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index cd64235438e..d9b359465a2 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -628,6 +628,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) if (!isnull) { Node *qual; + char relkind; deparse_context context; deparse_namespace dpns; RangeTblEntry *oldrte; @@ -637,10 +638,13 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) qual = stringToNode(TextDatumGetCString(value)); + relkind = get_rel_relkind(trigrec->tgrelid); + /* Build minimal OLD and NEW RTEs for the rel */ oldrte = makeNode(RangeTblEntry); oldrte->rtekind = RTE_RELATION; oldrte->relid = trigrec->tgrelid; + oldrte->relkind = relkind; oldrte->eref = makeAlias("old", NIL); oldrte->inh = false; oldrte->inFromCl = true; @@ -648,6 +652,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) newrte = makeNode(RangeTblEntry); newrte->rtekind = RTE_RELATION; newrte->relid = trigrec->tgrelid; + newrte->relkind = relkind; newrte->eref = makeAlias("new", NIL); newrte->inh = false; newrte->inFromCl = true; @@ -2125,6 +2130,7 @@ deparse_context_for(const char *aliasname, Oid relid) rte = makeNode(RangeTblEntry); rte->rtekind = RTE_RELATION; rte->relid = relid; + rte->relkind = RELKIND_RELATION; /* no need for exactness here */ rte->eref = makeAlias(aliasname, NIL); rte->inh = false; rte->inFromCl = true; @@ -4004,7 +4010,6 @@ get_name_for_var_field(Var *var, int fieldno, switch (rte->rtekind) { case RTE_RELATION: - case RTE_SPECIAL: case RTE_VALUES: /* -- cgit v1.2.3