|
49 | 49 | * Portions Copyright (c) 1994, Regents of the University of California |
50 | 50 | * |
51 | 51 | * IDENTIFICATION |
52 | | - * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.147 2005/08/27 22:37:00 tgl Exp $ |
| 52 | + * $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.148 2005/10/05 17:19:19 tgl Exp $ |
53 | 53 | * |
54 | 54 | *------------------------------------------------------------------------- |
55 | 55 | */ |
@@ -1898,17 +1898,23 @@ join_in_selectivity(JoinPath *path, PlannerInfo *root) |
1898 | 1898 | void |
1899 | 1899 | set_function_size_estimates(PlannerInfo*root,RelOptInfo*rel) |
1900 | 1900 | { |
| 1901 | +RangeTblEntry*rte; |
| 1902 | + |
1901 | 1903 | /* Should only be applied to base relations that are functions */ |
1902 | 1904 | Assert(rel->relid>0); |
1903 | | -Assert(rel->rtekind==RTE_FUNCTION); |
| 1905 | +rte=rt_fetch(rel->relid,root->parse->rtable); |
| 1906 | +Assert(rte->rtekind==RTE_FUNCTION); |
1904 | 1907 |
|
1905 | 1908 | /* |
1906 | 1909 | * Estimate number of rows the function itself will return. |
1907 | 1910 | * |
1908 | | - * XXX no idea how to do this yet; butshould at least check whether |
| 1911 | + * XXX no idea how to do this yet; butwe can at least check whether |
1909 | 1912 | * function returns set or not... |
1910 | 1913 | */ |
1911 | | -rel->tuples=1000; |
| 1914 | +if (expression_returns_set(rte->funcexpr)) |
| 1915 | +rel->tuples=1000; |
| 1916 | +else |
| 1917 | +rel->tuples=1; |
1912 | 1918 |
|
1913 | 1919 | /* Now estimate number of output rows, etc */ |
1914 | 1920 | set_baserel_size_estimates(root,rel); |
|