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

Commitd4d2385

Browse files
committed
If the alternatives for a CASE construct all have the same typmod,
use that typmod not -1 as the typmod of the CASE result.Part of response to bug#513.
1 parente433bf5 commitd4d2385

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

‎src/backend/parser/parse_expr.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.104 2001/10/2505:49:39 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.105 2001/11/12 20:05:24 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -806,6 +806,37 @@ exprTypmod(Node *expr)
806806
caseT_RelabelType:
807807
return ((RelabelType*)expr)->resulttypmod;
808808
break;
809+
caseT_CaseExpr:
810+
{
811+
/*
812+
* If all the alternatives agree on type/typmod, return
813+
* that typmod, else use -1
814+
*/
815+
CaseExpr*cexpr= (CaseExpr*)expr;
816+
Oidcasetype=cexpr->casetype;
817+
int32typmod;
818+
List*arg;
819+
820+
if (!cexpr->defresult)
821+
return-1;
822+
if (exprType(cexpr->defresult)!=casetype)
823+
return-1;
824+
typmod=exprTypmod(cexpr->defresult);
825+
if (typmod<0)
826+
return-1;/* no point in trying harder */
827+
foreach(arg,cexpr->args)
828+
{
829+
CaseWhen*w= (CaseWhen*)lfirst(arg);
830+
831+
Assert(IsA(w,CaseWhen));
832+
if (exprType(w->result)!=casetype)
833+
return-1;
834+
if (exprTypmod(w->result)!=typmod)
835+
return-1;
836+
}
837+
returntypmod;
838+
}
839+
break;
809840
default:
810841
break;
811842
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp