mirror of
https://github.com/postgres/postgres.git
synced 2025-11-28 11:44:57 +03:00
Back-patch fix to prevent core dump in EXPLAIN if optimizer has
simplified function call to a constant. (7.3 won't actually execute such a plan anyway, but core dump is bad regardless.)
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994-5, Regents of the University of California
|
* Portions Copyright (c) 1994-5, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.89.2.1 2002/12/06 19:28:13 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.89.2.2 2002/12/12 16:16:58 tgl Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -367,19 +367,28 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan,
|
|||||||
RangeTblEntry *rte = rt_fetch(((Scan *) plan)->scanrelid,
|
RangeTblEntry *rte = rt_fetch(((Scan *) plan)->scanrelid,
|
||||||
es->rtable);
|
es->rtable);
|
||||||
Expr *expr;
|
Expr *expr;
|
||||||
Func *funcnode;
|
|
||||||
Oid funcid;
|
|
||||||
char *proname;
|
char *proname;
|
||||||
|
|
||||||
/* Assert it's on a RangeFunction */
|
/* Assert it's on a RangeFunction */
|
||||||
Assert(rte->rtekind == RTE_FUNCTION);
|
Assert(rte->rtekind == RTE_FUNCTION);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the expression is still a function call, we can get
|
||||||
|
* the real name of the function. Otherwise, punt (this
|
||||||
|
* can happen if the optimizer simplified away the function
|
||||||
|
* call, for example).
|
||||||
|
*/
|
||||||
expr = (Expr *) rte->funcexpr;
|
expr = (Expr *) rte->funcexpr;
|
||||||
funcnode = (Func *) expr->oper;
|
if (expr && IsA(expr, Expr) && expr->opType == FUNC_EXPR)
|
||||||
funcid = funcnode->funcid;
|
{
|
||||||
|
Func *funcnode = (Func *) expr->oper;
|
||||||
|
Oid funcid = funcnode->funcid;
|
||||||
|
|
||||||
/* We only show the func name, not schema name */
|
/* We only show the func name, not schema name */
|
||||||
proname = get_func_name(funcid);
|
proname = get_func_name(funcid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
proname = rte->eref->aliasname;
|
||||||
|
|
||||||
appendStringInfo(str, " on %s",
|
appendStringInfo(str, " on %s",
|
||||||
quote_identifier(proname));
|
quote_identifier(proname));
|
||||||
|
|||||||
Reference in New Issue
Block a user