From: Tomas Vondra Date: Sun, 22 Jan 2017 19:40:00 +0000 (+0100) Subject: make sure LockRows paths preserve distribution, update plans in xc_for_update X-Git-Tag: XL_10_R1BETA1~406 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=de3c55cab4aa3eca0463fbf31ded3d35ff77f2a5;p=postgres-xl.git make sure LockRows paths preserve distribution, update plans in xc_for_update LockRows paths were not preserving the subpath's distribution, so fix that. Also update minor plan difference (VERBOSE now shows sort key for the redistribution step). --- diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index ae8faf3a2a..7bd7840786 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -4350,6 +4350,8 @@ create_lockrows_path(PlannerInfo *root, RelOptInfo *rel, pathnode->path.parallel_workers = 0; pathnode->path.rows = subpath->rows; + pathnode->path.distribution = copyObject(subpath->distribution); + /* * The result cannot be assumed sorted, since locking might cause the sort * key columns to be replaced with new values. diff --git a/src/test/regress/expected/xc_for_update.out b/src/test/regress/expected/xc_for_update.out index 5d4476bd2f..30a2f07321 100644 --- a/src/test/regress/expected/xc_for_update.out +++ b/src/test/regress/expected/xc_for_update.out @@ -218,6 +218,7 @@ explain (costs off, num_nodes off, nodes off, verbose on) select * from t1 join -> Remote Subquery Scan on all Output: t3.val, t3.val2 Distribute results by H: val2 + Sort Key: t3.val2 -> Sort Output: t3.val, t3.val2 Sort Key: t3.val2 @@ -231,6 +232,7 @@ explain (costs off, num_nodes off, nodes off, verbose on) select * from t1 join -> Remote Subquery Scan on all Output: t1.val, t1.val2 Distribute results by H: val2 + Sort Key: t1.val2 -> Sort Output: t1.val, t1.val2 Sort Key: t1.val2 @@ -241,12 +243,13 @@ explain (costs off, num_nodes off, nodes off, verbose on) select * from t1 join -> Remote Subquery Scan on all Output: t2.val, t2.val2 Distribute results by H: val2 + Sort Key: t2.val2 -> Sort Output: t2.val, t2.val2 Sort Key: t2.val2 -> Seq Scan on public.t2 Output: t2.val, t2.val2 -(36 rows) +(39 rows) explain (costs off, num_nodes off, nodes off, verbose on) select * from t1 join t2 on (t1.val2 = t2.val2) join t3 on (t1.val2 = t3.val2) for update; ERROR: FOR UPDATE is not allowed with joins @@ -422,8 +425,8 @@ explain (costs off, num_nodes off, nodes off, verbose on) WITH q1 AS (SELECT * select * from p1 order by 1 for update; a | b -----+----- - 77 | 88 55 | 66 + 77 | 88 111 | 222 123 | 345 (4 rows)