Backend assertion failure on \d
Running the following against HEAD and REL8_3_6:
create table foo (a varchar(500));
create view bar as select case foo.a when '1' then 'foo' else 'bar' end as
fa from foo;
\d bar
Causes as assertion in the backend:
TRAP: FailedAssertion("!(((((Node*)(((list_head(((OpExpr *)
w)->args))->data.ptr_value)))->type) == T_CaseTestExpr) ||
((((Node*)(((list_head(((OpExpr *) w)->args))->data.ptr_value)))->type) ==
T_Const))", File: "ruleutils.c", Line: 4587
)
LOG: server process (PID 28408) was terminated by signal 6: Aborted
Attached is a simple patch that appears to fix this problem, not sure if it
suffices in general.
Alan
Attachments:
fix.difftext/x-patch; charset=US-ASCII; name=fix.diffDownload
*** a/src/backend/utils/adt/ruleutils.c
--- b/src/backend/utils/adt/ruleutils.c
*************** get_rule_expr(Node *node, deparse_contex
*** 4582,4592 ****
Node *rhs;
Assert(IsA(linitial(((OpExpr *) w)->args),
CaseTestExpr) ||
IsA(linitial(((OpExpr *) w)->args),
! Const));
rhs = (Node *) lsecond(((OpExpr *) w)->args);
get_rule_expr(rhs, context, false);
}
else if (IsA(w, CaseTestExpr))
appendStringInfo(buf, "TRUE");
--- 4582,4594 ----
Node *rhs;
Assert(IsA(linitial(((OpExpr *) w)->args),
CaseTestExpr) ||
IsA(linitial(((OpExpr *) w)->args),
! Const) ||
! IsA(linitial(((OpExpr *) w)->args),
! RelabelType));
rhs = (Node *) lsecond(((OpExpr *) w)->args);
get_rule_expr(rhs, context, false);
}
else if (IsA(w, CaseTestExpr))
appendStringInfo(buf, "TRUE");
Alan Li wrote:
Running the following against HEAD and REL8_3_6:
Same problem exists in 8.2 and 8.1 as well. The code in ruleutils.c is
similar in 8.0 as well, except that the Assertion isn't there.
create table foo (a varchar(500));
create view bar as select case foo.a when '1' then 'foo' else 'bar' end as
fa from foo;
\d barCauses as assertion in the backend:
TRAP: FailedAssertion("!(((((Node*)(((list_head(((OpExpr *)
w)->args))->data.ptr_value)))->type) == T_CaseTestExpr) ||
((((Node*)(((list_head(((OpExpr *) w)->args))->data.ptr_value)))->type) ==
T_Const))", File: "ruleutils.c", Line: 4587
)
LOG: server process (PID 28408) was terminated by signal 6: AbortedAttached is a simple patch that appears to fix this problem, not sure if it
suffices in general.
Looks good to me, at least.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
Alan Li <alanwli@gmail.com> writes:
Running the following against HEAD and REL8_3_6:
create table foo (a varchar(500));
create view bar as select case foo.a when '1' then 'foo' else 'bar' end as
fa from foo;
\d bar
Causes as assertion in the backend:
Thanks for the report. Looks like I forgot to consider the possibility
that type coercion nodes would get inserted atop the CaseTestExpr.
You can break the other paths here too if you try things like
case foo when true then ...
where foo is of a domain over boolean.
Will fix.
regards, tom lane