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

Commit014be15

Browse files
committed
Fix set_rel_width() to do something reasonable with non-Var items in a
RelOptInfo targetlist. It used to be that the only possibility other thana Var was a RowExpr representing a whole-row child Var, but as of 8.4'sexpanded ability to flatten appendrel members, we can get arbitrary expressionsin there. Use the expression's type info and get_typavgwidth() to producean at-least-marginally-sane result. Note that get_typavgwidth()'s fallbackestimate (32 bytes) is the same as what was here before, so there will beno behavioral change for RowExprs. Noted while looking at recent gripeabout constant quals pushed down to FunctionScan appendrel members ...not only were we failing to recognize the constant qual, we were gettingthe width estimate wrong :-(
1 parente7370ba commit014be15

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎src/backend/optimizer/path/costsize.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
* Portions Copyright (c) 1994, Regents of the University of California
5555
*
5656
* IDENTIFICATION
57-
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.209 2009/06/1114:48:58 momjian Exp $
57+
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.210 2009/07/1104:09:33 tgl Exp $
5858
*
5959
*-------------------------------------------------------------------------
6060
*/
@@ -2997,8 +2997,16 @@ set_rel_width(PlannerInfo *root, RelOptInfo *rel)
29972997
}
29982998
else
29992999
{
3000-
/* For now, punt on whole-row child Vars */
3001-
tuple_width+=32;/* arbitrary */
3000+
/*
3001+
* We could be looking at an expression pulled up from a subquery,
3002+
* or a ROW() representing a whole-row child Var, etc. Do what
3003+
* we can using the expression type information.
3004+
*/
3005+
int32item_width;
3006+
3007+
item_width=get_typavgwidth(exprType(node),exprTypmod(node));
3008+
Assert(item_width>0);
3009+
tuple_width+=item_width;
30023010
}
30033011
}
30043012
Assert(tuple_width >=0);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp