Debian Codegraph @

contrib/postgres_fdw/sql/query_cancel.sql

raw
1 SELECT version() ~ 'cygwin' AS skip_test \gset
2 \if :skip_test
3 \quit
4 \endif
5
6 -- Let's test canceling a remote query. Use a table that does not have
7 -- remote_estimate enabled, else there will be multiple queries to the
8 -- remote and we might unluckily send the cancel in between two of them.
9 -- First let's confirm that the query is actually pushed down.
10 EXPLAIN (VERBOSE, COSTS OFF)
11 SELECT count(*) FROM ft1 a CROSS JOIN ft1 b CROSS JOIN ft1 c CROSS JOIN ft1 d;
12
13 BEGIN;
14 -- Make sure that connection is open and set up.
15 SELECT count(*) FROM ft1 a;
16 -- On most machines, 10ms will be enough to be sure that we've sent the slow
17 -- query. We may sometimes exercise the race condition where we send cancel
18 -- before the remote side starts the query, but that's fine too.
19 SET LOCAL statement_timeout = '10ms';
20 -- This would take very long if not canceled:
21 SELECT count(*) FROM ft1 a CROSS JOIN ft1 b CROSS JOIN ft1 c CROSS JOIN ft1 d;
22 COMMIT;