Skip to content

Commit d960165

Browse files
author
Alexander Korotkov
committed
Make postgres_fdw results agnostic to return order.
1 parent 192b5e1 commit d960165

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

contrib/postgres_fdw/expected/postgres_fdw.out

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,9 @@ UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING
27842784
Remote SQL: UPDATE "S 1"."T 1" SET c2 = (c2 + 400), c3 = (c3 || '_update7'::text) WHERE ((("C 1" % 10) = 7)) RETURNING "C 1", c2, c3, c4, c5, c6, c7, c8
27852785
(4 rows)
27862786

2787-
UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *;
2787+
WITH updated AS (
2788+
UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *
2789+
) SELECT * FROM updated ORDER BY c1;
27882790
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
27892791
------+-----+--------------------+------------------------------+--------------------------+----+------------+-----
27902792
7 | 407 | 00007_update7 | Thu Jan 08 00:00:00 1970 PST | Thu Jan 08 00:00:00 1970 | 7 | 7 | foo
@@ -2927,7 +2929,9 @@ EXPLAIN (verbose, costs off)
29272929
Remote SQL: DELETE FROM "S 1"."T 1" WHERE ((("C 1" % 10) = 5)) RETURNING "C 1", c4
29282930
(4 rows)
29292931

2930-
DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4;
2932+
WITH deleted AS (
2933+
DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4
2934+
) SELECT * FROM deleted ORDER BY c1;
29312935
c1 | c4
29322936
------+------------------------------
29332937
5 | Tue Jan 06 00:00:00 1970 PST
@@ -3953,7 +3957,9 @@ INSERT INTO ft2 (c1,c2,c3,c6) VALUES (1218, 818, 'ggg', '(--;') RETURNING *;
39533957
1218 | 818 | ggg_trig_update | | | (--; | ft2 |
39543958
(1 row)
39553959

3956-
UPDATE ft2 SET c2 = c2 + 600 WHERE c1 % 10 = 8 AND c1 < 1200 RETURNING *;
3960+
WITH updated AS (
3961+
UPDATE ft2 SET c2 = c2 + 600 WHERE c1 % 10 = 8 AND c1 < 1200 RETURNING *
3962+
) SELECT * FROM updated ORDER BY c1;
39573963
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
39583964
------+-----+------------------------+------------------------------+--------------------------+----+------------+-----
39593965
8 | 608 | 00008_trig_update | Fri Jan 09 00:00:00 1970 PST | Fri Jan 09 00:00:00 1970 | 8 | 8 | foo

contrib/postgres_fdw/sql/postgres_fdw.sql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,15 +669,19 @@ UPDATE ft2 SET c2 = c2 + 300, c3 = c3 || '_update3' WHERE c1 % 10 = 3;
669669
UPDATE ft2 SET c2 = c2 + 300, c3 = c3 || '_update3' WHERE c1 % 10 = 3;
670670
EXPLAIN (verbose, costs off)
671671
UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *; -- can be pushed down
672-
UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *;
672+
WITH updated AS (
673+
UPDATE ft2 SET c2 = c2 + 400, c3 = c3 || '_update7' WHERE c1 % 10 = 7 RETURNING *
674+
) SELECT * FROM updated ORDER BY c1;
673675
EXPLAIN (verbose, costs off)
674676
UPDATE ft2 SET c2 = ft2.c2 + 500, c3 = ft2.c3 || '_update9', c7 = DEFAULT
675677
FROM ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 9; -- can't be pushed down
676678
UPDATE ft2 SET c2 = ft2.c2 + 500, c3 = ft2.c3 || '_update9', c7 = DEFAULT
677679
FROM ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 9;
678680
EXPLAIN (verbose, costs off)
679681
DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4; -- can be pushed down
680-
DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4;
682+
WITH deleted AS (
683+
DELETE FROM ft2 WHERE c1 % 10 = 5 RETURNING c1, c4
684+
) SELECT * FROM deleted ORDER BY c1;
681685
EXPLAIN (verbose, costs off)
682686
DELETE FROM ft2 USING ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 2; -- can't be pushed down
683687
DELETE FROM ft2 USING ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 2;
@@ -704,7 +708,9 @@ CREATE TRIGGER t1_br_insert BEFORE INSERT OR UPDATE
704708

705709
INSERT INTO ft2 (c1,c2,c3) VALUES (1208, 818, 'fff') RETURNING *;
706710
INSERT INTO ft2 (c1,c2,c3,c6) VALUES (1218, 818, 'ggg', '(--;') RETURNING *;
707-
UPDATE ft2 SET c2 = c2 + 600 WHERE c1 % 10 = 8 AND c1 < 1200 RETURNING *;
711+
WITH updated AS (
712+
UPDATE ft2 SET c2 = c2 + 600 WHERE c1 % 10 = 8 AND c1 < 1200 RETURNING *
713+
) SELECT * FROM updated ORDER BY c1;
708714

709715
-- Test errors thrown on remote side during update
710716
ALTER TABLE "S 1"."T 1" ADD CONSTRAINT c2positive CHECK (c2 >= 0);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy