Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteea4976

Browse files
committed
Fix an old problem in decompilation of CASE constructs: the ruleutils.c code
looks for a CaseTestExpr to figure out what the parser did, but it failed toconsider the possibility that an implicit coercion might be inserted abovethe CaseTestExpr. This could result in an Assert failure in some cases(but correct results if Asserts weren't enabled), or an "unexpected CASE WHENclause" error in other cases. Per report from Alan Li.Back-patch to 8.1; problem doesn't exist before that because CASE wasimplemented differently.
1 parent59a64e3 commiteea4976

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.295 2009/01/07 13:44:36 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.296 2009/02/25 18:00:01 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -4575,24 +4575,29 @@ get_rule_expr(Node *node, deparse_context *context,
45754575
* which we have to show "TRUE" or "FALSE". Also,
45764576
* depending on context the original CaseTestExpr
45774577
* might have been reduced to a Const (but we won't
4578-
* see "WHEN Const").
4578+
* see "WHEN Const"). We have also to consider the
4579+
* possibility that an implicit coercion was inserted
4580+
* between the CaseTestExpr and the operator.
45794581
*/
45804582
if (IsA(w,OpExpr))
45814583
{
4584+
List*args= ((OpExpr*)w)->args;
4585+
Node*lhs;
45824586
Node*rhs;
45834587

4584-
Assert(IsA(linitial(((OpExpr*)w)->args),
4585-
CaseTestExpr)||
4586-
IsA(linitial(((OpExpr*)w)->args),
4587-
Const));
4588-
rhs= (Node*)lsecond(((OpExpr*)w)->args);
4588+
Assert(list_length(args)==2);
4589+
lhs=strip_implicit_coercions(linitial(args));
4590+
Assert(IsA(lhs,CaseTestExpr)||
4591+
IsA(lhs,Const));
4592+
rhs= (Node*)lsecond(args);
45894593
get_rule_expr(rhs,context, false);
45904594
}
4591-
elseif (IsA(w,CaseTestExpr))
4595+
elseif (IsA(strip_implicit_coercions(w),
4596+
CaseTestExpr))
45924597
appendStringInfo(buf,"TRUE");
45934598
elseif (not_clause(w))
45944599
{
4595-
Assert(IsA(get_notclausearg((Expr*)w),
4600+
Assert(IsA(strip_implicit_coercions((Node*)get_notclausearg((Expr*)w)),
45964601
CaseTestExpr));
45974602
appendStringInfo(buf,"FALSE");
45984603
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp