blob: 11010f451483204bd6dc2d86d9fbeb860e50e5e7 [file] [log] [blame]
-- This case test that if lc related GUCs are synchronized
-- between QD and QEs.
CREATE TABLE test_lc(c1 int8, c2 date) DISTRIBUTED BY (c1);
CREATE OR REPLACE FUNCTION public.segment_setting(guc text)
RETURNS SETOF text EXECUTE ON ALL SEGMENTS AS $$
BEGIN RETURN NEXT pg_catalog.current_setting(guc); END
$$ LANGUAGE plpgsql;
INSERT INTO test_lc values ('4567890123456789', '2022-08-01');
INSERT INTO test_lc values ('-4567890123456789', '2022-09-01');
-- Test if lc_monetary is synced
SHOW lc_monetary;
lc_monetary
-------------
C
(1 row)
SELECT to_char(c1, 'L9999999999999999.000') FROM test_lc;
to_char
------------------------
4567890123456789.000
-4567890123456789.000
(2 rows)
SET lc_monetary = 'en_US.utf8';
SELECT to_char(c1, 'L9999999999999999.000') FROM test_lc;
to_char
------------------------
$ 4567890123456789.000
$-4567890123456789.000
(2 rows)
-- If the QE processes are exited for whatever the reason,
-- QD should sync the lc_monetary to the newly created QEs.
SELECT pg_terminate_backend(pid) FROM gp_dist_random('pg_stat_activity') WHERE sess_id
in (SELECT sess_id from pg_stat_activity WHERE pid in (SELECT pg_backend_pid())) ;
ERROR: terminating connection due to administrator command (seg0 slice1 11.158.187.228:7002 pid=114366)
-- Should output the results given lc_monetary = 'en_US.utf8'
SELECT to_char(c1, 'L9999999999999999.000') FROM test_lc;
to_char
------------------------
$ 4567890123456789.000
$-4567890123456789.000
(2 rows)
RESET lc_monetary;
-- Test if lc_time is synced
SHOW lc_time;
lc_time
---------
C
(1 row)
SELECT to_char(c2, 'DD TMMON YYYY') FROM test_lc;
to_char
-------------
01 AUG 2022
01 SEP 2022
(2 rows)
SET lc_time = 'en_US.utf8';
-- Since 'C' and 'en_US.utf8' time formatting will output the same result, and in
-- some environments, we don't know which kind of locale it supports. So we just
-- use segment_setting to checking the setting of lc_time on QEs.
SELECT segment_setting('lc_time');
segment_setting
-----------------
en_US.utf8
en_US.utf8
en_US.utf8
(3 rows)
-- If the QE processes are exited for whatever the reason,
-- QD should sync the lc_time to the newly created QEs.
SELECT pg_terminate_backend(pid) FROM gp_dist_random('pg_stat_activity') WHERE sess_id
in (SELECT sess_id from pg_stat_activity WHERE pid in (SELECT pg_backend_pid())) ;
ERROR: terminating connection due to administrator command (seg1 slice1 11.158.187.228:7003 pid=114379)
SELECT segment_setting('lc_time');
segment_setting
-----------------
en_US.utf8
en_US.utf8
en_US.utf8
(3 rows)
DROP FUNCTION public.segment_setting(guc text);
DROP TABLE test_lc;