Fix set_rel_width() to do something reasonable with non-Var items in a
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 11 Jul 2009 04:09:33 +0000 (04:09 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 11 Jul 2009 04:09:33 +0000 (04:09 +0000)
commitdbdfa7e4719ffd4b0e89dce9a8067b6829f59a55
treeeeac1c06ee3f4da97663e97f7503808e5462f808
parenteb740a6b854f8bf5ba21d5127b6d5be1bfe035e2
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 than
a Var was a RowExpr representing a whole-row child Var, but as of 8.4's
expanded ability to flatten appendrel members, we can get arbitrary expressions
in there.  Use the expression's type info and get_typavgwidth() to produce
an at-least-marginally-sane result.  Note that get_typavgwidth()'s fallback
estimate (32 bytes) is the same as what was here before, so there will be
no behavioral change for RowExprs.  Noted while looking at recent gripe
about constant quals pushed down to FunctionScan appendrel members ...
not only were we failing to recognize the constant qual, we were getting
the width estimate wrong :-(
src/backend/optimizer/path/costsize.c