summaryrefslogtreecommitdiffstats
path: root/src/test/modules/worker_spi/expected/worker_spi.out
blob: dc0a79bf7598385a7be98873481e33e296bdcd16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
CREATE EXTENSION worker_spi;
SELECT worker_spi_launch(4) IS NOT NULL;
 ?column? 
----------
 t
(1 row)

-- wait until the worker completes its initialization
DO $$
DECLARE
	visible bool;
	loops int := 0;
BEGIN
	LOOP
		visible := table_name IS NOT NULL
			FROM information_schema.tables
			WHERE table_schema = 'schema4' AND table_name = 'counted';
		IF visible OR loops > 120 * 10 THEN EXIT; END IF;
		PERFORM pg_sleep(0.1);
		loops := loops + 1;
	END LOOP;
END
$$;
INSERT INTO schema4.counted VALUES ('total', 0), ('delta', 1);
SELECT pg_reload_conf();
 pg_reload_conf 
----------------
 t
(1 row)

-- wait until the worker has processed the tuple we just inserted
DO $$
DECLARE
	count int;
	loops int := 0;
BEGIN
	LOOP
		count := count(*) FROM schema4.counted WHERE type = 'delta';
		IF count = 0 OR loops > 120 * 10 THEN EXIT; END IF;
		PERFORM pg_sleep(0.1);
		loops := loops + 1;
	END LOOP;
END
$$;
SELECT * FROM schema4.counted;
 type  | value 
-------+-------
 total |     1
(1 row)