Re: [HACKERS] postgres_fdw bug in 9.6
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>,
Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>,
Jeff Janes <jeff.janes@gmail.com>, David Steele <david@pgmasters.net>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2018-01-20T05:20:44Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes: > Well, I'm a little stumped. When I do it the way you did it, it fails > with the same error you got: > contrib_regression=# EXPLAIN (VERBOSE, COSTS OFF) > SELECT * FROM ft1, ft2, ft4, ft5 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = ft4.c1 > AND ft1.c1 = ft5.c1 FOR UPDATE; > ERROR: outer pathkeys do not match mergeclauses > But when I add the same command to postgres_fdw.sql and run it as part > of the regression tests, it works. I tried adding it at the end with > \c beforehand so that there wouldn't be any temporary settings in > effect. I duplicated those results, and then added an ANALYZE, and then it fails: *************** *** 7548,7550 **** --- 7595,7604 ---- (4 rows) RESET enable_partition_wise_join; + \c - + analyze "S 1"."T 1"; + -- multi-way join involving multiple merge joins + EXPLAIN (VERBOSE, COSTS OFF) + SELECT * FROM ft1, ft2, ft4, ft5 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = ft4.c1 + AND ft1.c1 = ft5.c1 FOR UPDATE; + ERROR: outer pathkeys do not match mergeclauses So apparently the reason our manual tests replicated the failure is that an auto-analyze happened in between. Now that I realize that, I find that the manual query doesn't fail if executed *immediately* after the regression test run. Wait a minute, repeat, it does fail. OTOH, put the same ANALYZE before the test case where it is in the script, no change. So the contributing factors here are (1) there are a bunch of data changes to "S 1"."T 1" further down in the script than where you added the test case, and (2) you need an auto-analyze to have seen those changes before the problematic plan gets picked. It looks like Etsuro-san's proposed patch locks down the choice of plan more tightly, which is probably a reasonable answer. regards, tom lane
Commits
-
Fix test case for 'outer pathkeys do not match mergeclauses' fix.
- d397f558d555 9.6.7 landed
- 92123c6ea212 10.2 landed
- 99f6a17dd62a 11.0 landed
-
postgres_fdw: Avoid 'outer pathkeys do not match mergeclauses' error.
- 4a81c022975e 9.6.7 landed
- 3f05a30b50a7 10.2 landed
- 4bbf6edfbd5d 11.0 landed
-
postgres_fdw: Consider foreign joining and foreign sorting together.
- aa09cd242fa7 9.6.0 cited
-
Allow foreign and custom joins to handle EvalPlanQual rechecks.
- 385f337c9f39 9.6.0 cited
-
Allow FDWs to push down quals without breaking EvalPlanQual rechecks.
- 5fc4c26db512 9.6.0 cited