postgres_fdw: Fix test that didn't test what it claimed.

Antonin Houska reported that the planner does consider pushing
postgres_fdw_abs() to the remote side, which happens because we make
it shippable earlier in the test case file.

Jeevan Chalke provided this patch, which changes the join
condition to use random(), which is not shippable, instead.
Antonin reviewed the patch.

Discussion: http://postgr.es/m/15265.1511985971@localhost
This commit is contained in:
Robert Haas 2017-12-01 13:47:00 -05:00
parent 87c37e3291
commit 9502227805
2 changed files with 14 additions and 12 deletions

View file

@ -3160,21 +3160,23 @@ drop operator public.<^(int, int);
-- Input relation to aggregate push down hook is not safe to pushdown and thus -- Input relation to aggregate push down hook is not safe to pushdown and thus
-- the aggregate cannot be pushed down to foreign server. -- the aggregate cannot be pushed down to foreign server.
explain (verbose, costs off) explain (verbose, costs off)
select count(t1.c3) from ft1 t1, ft1 t2 where t1.c1 = postgres_fdw_abs(t1.c2); select count(t1.c3) from ft2 t1 left join ft2 t2 on (t1.c1 = random() * t2.c2);
QUERY PLAN QUERY PLAN
---------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------
Aggregate Aggregate
Output: count(t1.c3) Output: count(t1.c3)
-> Nested Loop -> Nested Loop Left Join
Output: t1.c3 Output: t1.c3
-> Foreign Scan on public.ft1 t2 Join Filter: ((t1.c1)::double precision = (random() * (t2.c2)::double precision))
Remote SQL: SELECT NULL FROM "S 1"."T 1" -> Foreign Scan on public.ft2 t1
Output: t1.c3, t1.c1
Remote SQL: SELECT "C 1", c3 FROM "S 1"."T 1"
-> Materialize -> Materialize
Output: t1.c3 Output: t2.c2
-> Foreign Scan on public.ft1 t1 -> Foreign Scan on public.ft2 t2
Output: t1.c3 Output: t2.c2
Remote SQL: SELECT c3 FROM "S 1"."T 1" WHERE (("C 1" = public.postgres_fdw_abs(c2))) Remote SQL: SELECT c2 FROM "S 1"."T 1"
(11 rows) (13 rows)
-- Subquery in FROM clause having aggregate -- Subquery in FROM clause having aggregate
explain (verbose, costs off) explain (verbose, costs off)

View file

@ -829,7 +829,7 @@ drop operator public.<^(int, int);
-- Input relation to aggregate push down hook is not safe to pushdown and thus -- Input relation to aggregate push down hook is not safe to pushdown and thus
-- the aggregate cannot be pushed down to foreign server. -- the aggregate cannot be pushed down to foreign server.
explain (verbose, costs off) explain (verbose, costs off)
select count(t1.c3) from ft1 t1, ft1 t2 where t1.c1 = postgres_fdw_abs(t1.c2); select count(t1.c3) from ft2 t1 left join ft2 t2 on (t1.c1 = random() * t2.c2);
-- Subquery in FROM clause having aggregate -- Subquery in FROM clause having aggregate
explain (verbose, costs off) explain (verbose, costs off)