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

Commit8685c47

Browse files
committed
Fix performance issue in exprTypmod(): for a COALESCE expression, it
recursed twice on its first argument, leading to exponential time spenton a deep nest of COALESCEs ... such as a deeply nested FULL JOIN wouldproduce. Per report from Matt Carter.
1 parentb410475 commit8685c47

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎src/backend/parser/parse_expr.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.185 2005/10/15 02:49:22 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.186 2005/11/18 23:08:00 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1664,8 +1664,12 @@ exprTypmod(Node *expr)
16641664
int32typmod;
16651665
ListCell*arg;
16661666

1667+
if (exprType((Node*)linitial(cexpr->args))!=coalescetype)
1668+
return-1;
16671669
typmod=exprTypmod((Node*)linitial(cexpr->args));
1668-
foreach(arg,cexpr->args)
1670+
if (typmod<0)
1671+
return-1;/* no point in trying harder */
1672+
for_each_cell(arg,lnext(list_head(cexpr->args)))
16691673
{
16701674
Node*e= (Node*)lfirst(arg);
16711675

@@ -1688,8 +1692,12 @@ exprTypmod(Node *expr)
16881692
int32typmod;
16891693
ListCell*arg;
16901694

1695+
if (exprType((Node*)linitial(mexpr->args))!=minmaxtype)
1696+
return-1;
16911697
typmod=exprTypmod((Node*)linitial(mexpr->args));
1692-
foreach(arg,mexpr->args)
1698+
if (typmod<0)
1699+
return-1;/* no point in trying harder */
1700+
for_each_cell(arg,lnext(list_head(mexpr->args)))
16931701
{
16941702
Node*e= (Node*)lfirst(arg);
16951703

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp