postgres_fdw: Split out the query_cancel test to its own file
authorAlvaro Herrera <[email protected]>
Mon, 22 Jul 2024 10:49:57 +0000 (12:49 +0200)
committerAlvaro Herrera <[email protected]>
Mon, 22 Jul 2024 10:49:57 +0000 (12:49 +0200)
This allows us to skip it in Cygwin, where it's reportedly flaky because
of platform bugs or something.

Backpatch to 17, where the test was introduced by commit 2466d6654f85.

Reported-by: Alexander Lakhin <[email protected]>
Discussion: https://postgr.es/m/e4d0cb33-6be5-e4d5-ae49-9eac3ff2b005@gmail.com

contrib/postgres_fdw/Makefile
contrib/postgres_fdw/expected/postgres_fdw.out
contrib/postgres_fdw/expected/query_cancel.out [new file with mode: 0644]
contrib/postgres_fdw/expected/query_cancel_1.out [new file with mode: 0644]
contrib/postgres_fdw/meson.build
contrib/postgres_fdw/sql/postgres_fdw.sql
contrib/postgres_fdw/sql/query_cancel.sql [new file with mode: 0644]

index c1b0cad453f25cf56c24b614ac2cb506791dd258..b9fa69930529ba28b0e12413090bb9fa62a4a39b 100644 (file)
@@ -16,7 +16,7 @@ SHLIB_LINK_INTERNAL = $(libpq)
 EXTENSION = postgres_fdw
 DATA = postgres_fdw--1.0.sql postgres_fdw--1.0--1.1.sql
 
-REGRESS = postgres_fdw
+REGRESS = postgres_fdw query_cancel
 
 ifdef USE_PGXS
 PG_CONFIG = pg_config
index 8f0886f2ff66af87a0e409ef8cae160d134a262f..39b2b317e873652b1e5864bd61aa3488aae388bf 100644 (file)
@@ -2760,22 +2760,6 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c
 (10 rows)
 
 ALTER VIEW v4 OWNER TO regress_view_owner;
--- Make sure this big CROSS JOIN query is pushed down
-EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5;
-                                                                             QUERY PLAN                                                                              
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Foreign Scan
-   Output: (count(*))
-   Relations: Aggregate on ((((public.ft1) INNER JOIN (public.ft2)) INNER JOIN (public.ft4)) INNER JOIN (public.ft5))
-   Remote SQL: SELECT count(*) FROM ((("S 1"."T 1" r1 INNER JOIN "S 1"."T 1" r2 ON (TRUE)) INNER JOIN "S 1"."T 3" r4 ON (TRUE)) INNER JOIN "S 1"."T 4" r6 ON (TRUE))
-(4 rows)
-
--- Make sure query cancellation works
-BEGIN;
-SET LOCAL statement_timeout = '10ms';
-select count(*) from ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5; -- this takes very long
-ERROR:  canceling statement due to statement timeout
-COMMIT;
 -- ====================================================================
 -- Check that userid to use when querying the remote table is correctly
 -- propagated into foreign rels present in subqueries under an UNION ALL
diff --git a/contrib/postgres_fdw/expected/query_cancel.out b/contrib/postgres_fdw/expected/query_cancel.out
new file mode 100644 (file)
index 0000000..afef67a
--- /dev/null
@@ -0,0 +1,20 @@
+SELECT version() ~ 'cygwin' AS skip_test \gset
+\if :skip_test
+\quit
+\endif
+-- Make sure this big CROSS JOIN query is pushed down
+EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5;
+                                                                             QUERY PLAN                                                                              
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ Foreign Scan
+   Output: (count(*))
+   Relations: Aggregate on ((((public.ft1) INNER JOIN (public.ft2)) INNER JOIN (public.ft4)) INNER JOIN (public.ft5))
+   Remote SQL: SELECT count(*) FROM ((("S 1"."T 1" r1 INNER JOIN "S 1"."T 1" r2 ON (TRUE)) INNER JOIN "S 1"."T 3" r4 ON (TRUE)) INNER JOIN "S 1"."T 4" r6 ON (TRUE))
+(4 rows)
+
+-- Make sure query cancellation works
+BEGIN;
+SET LOCAL statement_timeout = '10ms';
+select count(*) from ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5; -- this takes very long
+ERROR:  canceling statement due to statement timeout
+COMMIT;
diff --git a/contrib/postgres_fdw/expected/query_cancel_1.out b/contrib/postgres_fdw/expected/query_cancel_1.out
new file mode 100644 (file)
index 0000000..c909f29
--- /dev/null
@@ -0,0 +1,3 @@
+SELECT version() ~ 'cygwin' AS skip_test \gset
+\if :skip_test
+\quit
index 2b86d8a6eebc10e0bb28cbe517321da7ec0094dd..f0803ee077ee669f8744778b568c605333cbf474 100644 (file)
@@ -36,6 +36,7 @@ tests += {
   'regress': {
     'sql': [
       'postgres_fdw',
+      'query_cancel',
     ],
     'regress_args': ['--dlpath', meson.build_root() / 'src/test/regress'],
   },
index 733c10377121d012bb24db4fec6a2b7a176f164f..8be9f99c192253c849e27ddca8d0e2c419316555 100644 (file)
@@ -742,14 +742,6 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c
 SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10;
 ALTER VIEW v4 OWNER TO regress_view_owner;
 
--- Make sure this big CROSS JOIN query is pushed down
-EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5;
--- Make sure query cancellation works
-BEGIN;
-SET LOCAL statement_timeout = '10ms';
-select count(*) from ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5; -- this takes very long
-COMMIT;
-
 -- ====================================================================
 -- Check that userid to use when querying the remote table is correctly
 -- propagated into foreign rels present in subqueries under an UNION ALL
diff --git a/contrib/postgres_fdw/sql/query_cancel.sql b/contrib/postgres_fdw/sql/query_cancel.sql
new file mode 100644 (file)
index 0000000..8f11f3f
--- /dev/null
@@ -0,0 +1,12 @@
+SELECT version() ~ 'cygwin' AS skip_test \gset
+\if :skip_test
+\quit
+\endif
+
+-- Make sure this big CROSS JOIN query is pushed down
+EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5;
+-- Make sure query cancellation works
+BEGIN;
+SET LOCAL statement_timeout = '10ms';
+select count(*) from ft1 CROSS JOIN ft2 CROSS JOIN ft4 CROSS JOIN ft5; -- this takes very long
+COMMIT;