Allow function scan to bypass tuplestore

Rebase on pg version REL_8_3_23

Known issue: In the "rangefuncs" regression test, one query should give
"ERROR:  function return row and query-specified return row do not match"
but instead gives "ERROR:  invalid memory alloc request size 2139062146"