mirror of https://github.com/citusdata/citus.git
Fixes pg15 tests
parent
d323ab8c51
commit
736894472e
|
@ -1536,267 +1536,3 @@ SET client_min_messages TO ERROR;
|
||||||
DROP SCHEMA pg15 CASCADE;
|
DROP SCHEMA pg15 CASCADE;
|
||||||
DROP ROLE rls_tenant_1;
|
DROP ROLE rls_tenant_1;
|
||||||
DROP ROLE rls_tenant_2;
|
DROP ROLE rls_tenant_2;
|
||||||
-- create/drop database for pg > 15
|
|
||||||
\set create_drop_db_tablespace :abs_srcdir '/tmp_check/ts3'
|
|
||||||
CREATE TABLESPACE create_drop_db_tablespace LOCATION :'create_drop_db_tablespace';
|
|
||||||
\c - - - :worker_1_port
|
|
||||||
\set create_drop_db_tablespace :abs_srcdir '/tmp_check/ts4'
|
|
||||||
CREATE TABLESPACE create_drop_db_tablespace LOCATION :'create_drop_db_tablespace';
|
|
||||||
\c - - - :worker_2_port
|
|
||||||
\set create_drop_db_tablespace :abs_srcdir '/tmp_check/ts5'
|
|
||||||
CREATE TABLESPACE create_drop_db_tablespace LOCATION :'create_drop_db_tablespace';
|
|
||||||
\c - - - :master_port
|
|
||||||
create user create_drop_db_test_user;
|
|
||||||
set citus.enable_create_database_propagation=on;
|
|
||||||
SET citus.log_remote_commands = true;
|
|
||||||
set citus.grep_remote_commands = '%CREATE DATABASE%';
|
|
||||||
CREATE DATABASE mydatabase
|
|
||||||
WITH TEMPLATE = 'template0'
|
|
||||||
OWNER = create_drop_db_test_user
|
|
||||||
CONNECTION LIMIT = 10
|
|
||||||
ENCODING = 'UTF8'
|
|
||||||
STRATEGY = 'wal_log'
|
|
||||||
LOCALE = ''
|
|
||||||
LC_COLLATE = 'POSIX'
|
|
||||||
LC_CTYPE = 'POSIX'
|
|
||||||
ICU_LOCALE = 'und'
|
|
||||||
LOCALE_PROVIDER = 'icu'
|
|
||||||
COLLATION_VERSION = '1.0'
|
|
||||||
TABLESPACE = create_drop_db_tablespace
|
|
||||||
ALLOW_CONNECTIONS = true
|
|
||||||
IS_TEMPLATE = false
|
|
||||||
OID = 966345;
|
|
||||||
NOTICE: issuing CREATE DATABASE mydatabase TEMPLATE template0 OWNER create_drop_db_test_user CONNECTION LIMIT 10 ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE '' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' ICU_LOCALE 'und' LOCALE_PROVIDER 'icu' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS true IS_TEMPLATE false OID 966345
|
|
||||||
NOTICE: issuing CREATE DATABASE mydatabase TEMPLATE template0 OWNER create_drop_db_test_user CONNECTION LIMIT 10 ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE '' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' ICU_LOCALE 'und' LOCALE_PROVIDER 'icu' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS true IS_TEMPLATE false OID 966345
|
|
||||||
SELECT result from run_command_on_all_nodes(
|
|
||||||
$$
|
|
||||||
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
|
||||||
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
|
||||||
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
|
||||||
pd.datcollate , pd. datctype , pd.datacl,
|
|
||||||
pa.rolname AS database_owner, pt.spcname AS tablespace
|
|
||||||
FROM pg_database pd
|
|
||||||
JOIN pg_authid pa ON pd.datdba = pa.oid
|
|
||||||
join pg_tablespace pt on pd.dattablespace = pt.oid
|
|
||||||
WHERE datname = 'mydatabase'
|
|
||||||
) q2
|
|
||||||
$$
|
|
||||||
) ORDER BY result;
|
|
||||||
result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
[{"datacl": null, "datname": "mydatabase", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": 10, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
[{"datacl": null, "datname": "mydatabase", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": 10, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
[{"datacl": null, "datname": "mydatabase", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": 10, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
drop database mydatabase;
|
|
||||||
SELECT result from run_command_on_all_nodes(
|
|
||||||
$$
|
|
||||||
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
|
||||||
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
|
||||||
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
|
||||||
pd.datcollate , pd. datctype , pd.datacl,
|
|
||||||
pa.rolname AS database_owner, pt.spcname AS tablespace
|
|
||||||
FROM pg_database pd
|
|
||||||
JOIN pg_authid pa ON pd.datdba = pa.oid
|
|
||||||
join pg_tablespace pt on pd.dattablespace = pt.oid
|
|
||||||
WHERE datname = 'mydatabase'
|
|
||||||
) q2
|
|
||||||
$$
|
|
||||||
) ORDER BY result;
|
|
||||||
result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
select 1 from citus_remove_node('localhost', :worker_2_port);
|
|
||||||
?column?
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SET citus.log_remote_commands = true;
|
|
||||||
set citus.grep_remote_commands = '%CREATE DATABASE%';
|
|
||||||
CREATE DATABASE mydatabase2
|
|
||||||
WITH OWNER = create_drop_db_test_user
|
|
||||||
ENCODING = 'UTF8'
|
|
||||||
STRATEGY = 'wal_log'
|
|
||||||
LOCALE = 'en_US.utf8'
|
|
||||||
LC_COLLATE = 'POSIX'
|
|
||||||
LC_CTYPE = 'POSIX'
|
|
||||||
COLLATION_VERSION = '1.0'
|
|
||||||
TABLESPACE = create_drop_db_tablespace
|
|
||||||
ALLOW_CONNECTIONS = true
|
|
||||||
IS_TEMPLATE = false
|
|
||||||
OID = 966345;
|
|
||||||
NOTICE: issuing CREATE DATABASE mydatabase2 OWNER create_drop_db_test_user ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE 'en_US.utf8' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS true IS_TEMPLATE false OID 966345
|
|
||||||
SET citus.log_remote_commands = false;
|
|
||||||
SELECT result from run_command_on_all_nodes(
|
|
||||||
$$
|
|
||||||
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
|
||||||
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
|
||||||
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
|
||||||
pd.datcollate , pd. datctype , pd.datacl,
|
|
||||||
pa.rolname AS database_owner, pt.spcname AS tablespace
|
|
||||||
FROM pg_database pd
|
|
||||||
JOIN pg_authid pa ON pd.datdba = pa.oid
|
|
||||||
join pg_tablespace pt on pd.dattablespace = pt.oid
|
|
||||||
WHERE datname = 'mydatabase2'
|
|
||||||
) q2
|
|
||||||
$$
|
|
||||||
) ORDER BY result;
|
|
||||||
result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SET citus.log_remote_commands = true;
|
|
||||||
select 1 from citus_add_node('localhost', :worker_2_port);
|
|
||||||
NOTICE: issuing SET citus.enable_ddl_propagation TO 'off';select pg_catalog.citus_internal_database_command( 'CREATE DATABASE postgres OWNER = postgres ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' TABLESPACE = pg_default ALLOW_CONNECTIONS = ''true'' IS_TEMPLATE = ''false''');select pg_catalog.citus_internal_database_command( 'CREATE DATABASE regression OWNER = postgres ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' TABLESPACE = pg_default ALLOW_CONNECTIONS = ''true'' IS_TEMPLATE = ''false''');select pg_catalog.citus_internal_database_command( 'CREATE DATABASE template1 OWNER = postgres ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' TABLESPACE = pg_default ALLOW_CONNECTIONS = ''true'' IS_TEMPLATE = ''true''');select pg_catalog.citus_internal_database_command( 'CREATE DATABASE template0 OWNER = postgres ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' TABLESPACE = pg_default ALLOW_CONNECTIONS = ''false'' IS_TEMPLATE = ''true''');select pg_catalog.citus_internal_database_command( 'CREATE DATABASE mydatabase2 OWNER = create_drop_db_test_user ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' COLLATION_VERSION = ''1.0'' TABLESPACE = create_drop_db_tablespace ALLOW_CONNECTIONS = ''true'' IS_TEMPLATE = ''false''');ALTER ROLE ALL IN DATABASE regression SET lc_messages = 'C';ALTER ROLE ALL IN DATABASE regression SET lc_monetary = 'C';ALTER ROLE ALL IN DATABASE regression SET lc_numeric = 'C';ALTER ROLE ALL IN DATABASE regression SET lc_time = 'C';ALTER ROLE ALL IN DATABASE regression SET bytea_output = 'hex';ALTER ROLE ALL IN DATABASE regression SET timezone_abbreviations = 'Default';SET citus.enable_ddl_propagation TO 'on'
|
|
||||||
?column?
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SET citus.log_remote_commands = false;
|
|
||||||
SELECT result from run_command_on_all_nodes(
|
|
||||||
$$
|
|
||||||
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
|
||||||
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
|
||||||
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
|
||||||
pd.datcollate , pd. datctype , pd.datacl,
|
|
||||||
pa.rolname AS database_owner, pt.spcname AS tablespace
|
|
||||||
FROM pg_database pd
|
|
||||||
JOIN pg_authid pa ON pd.datdba = pa.oid
|
|
||||||
join pg_tablespace pt on pd.dattablespace = pt.oid
|
|
||||||
WHERE datname = 'mydatabase2'
|
|
||||||
) q2
|
|
||||||
$$
|
|
||||||
) ORDER BY result;
|
|
||||||
result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SET citus.log_remote_commands = true;
|
|
||||||
set citus.grep_remote_commands = '%DROP DATABASE%';
|
|
||||||
drop database mydatabase2;
|
|
||||||
NOTICE: issuing DROP DATABASE mydatabase2
|
|
||||||
NOTICE: issuing DROP DATABASE mydatabase2
|
|
||||||
SET citus.log_remote_commands = false;
|
|
||||||
SELECT result from run_command_on_all_nodes(
|
|
||||||
$$
|
|
||||||
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
|
||||||
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
|
||||||
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
|
||||||
pd.datcollate , pd. datctype , pd.datacl,
|
|
||||||
pa.rolname AS database_owner, pt.spcname AS tablespace
|
|
||||||
FROM pg_database pd
|
|
||||||
JOIN pg_authid pa ON pd.datdba = pa.oid
|
|
||||||
join pg_tablespace pt on pd.dattablespace = pt.oid
|
|
||||||
WHERE datname = 'mydatabase'
|
|
||||||
) q2
|
|
||||||
$$
|
|
||||||
) ORDER BY result;
|
|
||||||
result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SET citus.log_remote_commands = true;
|
|
||||||
set citus.grep_remote_commands = '%CREATE DATABASE%';
|
|
||||||
-- create a template database with all options set and allow connections false
|
|
||||||
CREATE DATABASE my_template_database
|
|
||||||
WITH TEMPLATE = 'template0'
|
|
||||||
OWNER = create_drop_db_test_user
|
|
||||||
ENCODING = 'UTF8'
|
|
||||||
STRATEGY = 'wal_log'
|
|
||||||
LOCALE = 'en_US.utf8'
|
|
||||||
LC_COLLATE = 'POSIX'
|
|
||||||
LC_CTYPE = 'POSIX'
|
|
||||||
ICU_LOCALE = 'en-US'
|
|
||||||
LOCALE_PROVIDER = 'icu'
|
|
||||||
COLLATION_VERSION = '1.0'
|
|
||||||
TABLESPACE = create_drop_db_tablespace
|
|
||||||
ALLOW_CONNECTIONS = false
|
|
||||||
IS_TEMPLATE = true;
|
|
||||||
NOTICE: issuing CREATE DATABASE my_template_database TEMPLATE template0 OWNER create_drop_db_test_user ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE 'en_US.utf8' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' ICU_LOCALE 'en-US' LOCALE_PROVIDER 'icu' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS false IS_TEMPLATE true
|
|
||||||
NOTICE: issuing CREATE DATABASE my_template_database TEMPLATE template0 OWNER create_drop_db_test_user ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE 'en_US.utf8' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' ICU_LOCALE 'en-US' LOCALE_PROVIDER 'icu' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS false IS_TEMPLATE true
|
|
||||||
SET citus.log_remote_commands = false;
|
|
||||||
SELECT result from run_command_on_all_nodes(
|
|
||||||
$$
|
|
||||||
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
|
||||||
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
|
||||||
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
|
||||||
pd.datcollate , pd. datctype , pd.datacl,
|
|
||||||
pa.rolname AS database_owner, pt.spcname AS tablespace
|
|
||||||
FROM pg_database pd
|
|
||||||
JOIN pg_authid pa ON pd.datdba = pa.oid
|
|
||||||
join pg_tablespace pt on pd.dattablespace = pt.oid
|
|
||||||
WHERE datname = 'my_template_database'
|
|
||||||
) q2
|
|
||||||
$$
|
|
||||||
) ORDER BY result;
|
|
||||||
result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
[{"datacl": null, "datname": "my_template_database", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": false, "datconnlimit": -1, "datistemplate": true, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
[{"datacl": null, "datname": "my_template_database", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": false, "datconnlimit": -1, "datistemplate": true, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
[{"datacl": null, "datname": "my_template_database", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": false, "datconnlimit": -1, "datistemplate": true, "database_owner": "create_drop_db_test_user"}]
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SET citus.log_remote_commands = true;
|
|
||||||
--template databases could not be dropped so we need to change the template flag
|
|
||||||
SELECT result from run_command_on_all_nodes(
|
|
||||||
$$
|
|
||||||
UPDATE pg_database SET datistemplate = false WHERE datname = 'my_template_database'
|
|
||||||
$$
|
|
||||||
) ORDER BY result;
|
|
||||||
result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
UPDATE 1
|
|
||||||
UPDATE 1
|
|
||||||
UPDATE 1
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
;
|
|
||||||
set citus.grep_remote_commands = '%DROP DATABASE%';
|
|
||||||
drop database my_template_database;
|
|
||||||
NOTICE: issuing DROP DATABASE my_template_database
|
|
||||||
NOTICE: issuing DROP DATABASE my_template_database
|
|
||||||
SET citus.log_remote_commands = false;
|
|
||||||
SELECT result from run_command_on_all_nodes(
|
|
||||||
$$
|
|
||||||
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
|
||||||
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
|
||||||
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
|
||||||
pd.datcollate , pd. datctype , pd.datacl,
|
|
||||||
pa.rolname AS database_owner, pt.spcname AS tablespace
|
|
||||||
FROM pg_database pd
|
|
||||||
JOIN pg_authid pa ON pd.datdba = pa.oid
|
|
||||||
join pg_tablespace pt on pd.dattablespace = pt.oid
|
|
||||||
WHERE datname = 'my_template_database'
|
|
||||||
) q2
|
|
||||||
$$
|
|
||||||
) ORDER BY result;
|
|
||||||
result
|
|
||||||
---------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
\c - - - :master_port
|
|
||||||
drop tablespace create_drop_db_tablespace;
|
|
||||||
\c - - - :worker_1_port
|
|
||||||
drop tablespace create_drop_db_tablespace;
|
|
||||||
\c - - - :worker_2_port
|
|
||||||
drop tablespace create_drop_db_tablespace;
|
|
||||||
\c - - - :master_port
|
|
||||||
drop user create_drop_db_test_user;
|
|
||||||
|
|
|
@ -0,0 +1,284 @@
|
||||||
|
--
|
||||||
|
-- PG15
|
||||||
|
--
|
||||||
|
SHOW server_version \gset
|
||||||
|
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||||
|
\gset
|
||||||
|
\if :server_version_ge_15
|
||||||
|
\else
|
||||||
|
\q
|
||||||
|
\endif
|
||||||
|
-- create/drop database for pg > 15
|
||||||
|
\set create_drop_db_tablespace :abs_srcdir '/tmp_check/ts3'
|
||||||
|
CREATE TABLESPACE create_drop_db_tablespace LOCATION :'create_drop_db_tablespace';
|
||||||
|
\c - - - :worker_1_port
|
||||||
|
\set create_drop_db_tablespace :abs_srcdir '/tmp_check/ts4'
|
||||||
|
CREATE TABLESPACE create_drop_db_tablespace LOCATION :'create_drop_db_tablespace';
|
||||||
|
\c - - - :worker_2_port
|
||||||
|
\set create_drop_db_tablespace :abs_srcdir '/tmp_check/ts5'
|
||||||
|
CREATE TABLESPACE create_drop_db_tablespace LOCATION :'create_drop_db_tablespace';
|
||||||
|
\c - - - :master_port
|
||||||
|
create user create_drop_db_test_user;
|
||||||
|
set citus.enable_create_database_propagation=on;
|
||||||
|
SET citus.log_remote_commands = true;
|
||||||
|
set citus.grep_remote_commands = '%CREATE DATABASE%';
|
||||||
|
CREATE DATABASE mydatabase
|
||||||
|
WITH TEMPLATE = 'template0'
|
||||||
|
OWNER = create_drop_db_test_user
|
||||||
|
CONNECTION LIMIT = 10
|
||||||
|
ENCODING = 'UTF8'
|
||||||
|
STRATEGY = 'wal_log'
|
||||||
|
LOCALE = ''
|
||||||
|
LC_COLLATE = 'POSIX'
|
||||||
|
LC_CTYPE = 'POSIX'
|
||||||
|
ICU_LOCALE = 'und'
|
||||||
|
LOCALE_PROVIDER = 'icu'
|
||||||
|
COLLATION_VERSION = '1.0'
|
||||||
|
TABLESPACE = create_drop_db_tablespace
|
||||||
|
ALLOW_CONNECTIONS = true
|
||||||
|
IS_TEMPLATE = false
|
||||||
|
OID = 966345;
|
||||||
|
NOTICE: issuing CREATE DATABASE mydatabase TEMPLATE template0 OWNER create_drop_db_test_user CONNECTION LIMIT 10 ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE '' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' ICU_LOCALE 'und' LOCALE_PROVIDER 'icu' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS true IS_TEMPLATE false OID 966345
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
NOTICE: issuing CREATE DATABASE mydatabase TEMPLATE template0 OWNER create_drop_db_test_user CONNECTION LIMIT 10 ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE '' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' ICU_LOCALE 'und' LOCALE_PROVIDER 'icu' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS true IS_TEMPLATE false OID 966345
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
SELECT result from run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
||||||
|
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
||||||
|
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
||||||
|
pd.datcollate , pd. datctype , pd.datacl,
|
||||||
|
pa.rolname AS database_owner, pt.spcname AS tablespace
|
||||||
|
FROM pg_database pd
|
||||||
|
JOIN pg_authid pa ON pd.datdba = pa.oid
|
||||||
|
join pg_tablespace pt on pd.dattablespace = pt.oid
|
||||||
|
WHERE datname = 'mydatabase'
|
||||||
|
) q2
|
||||||
|
$$
|
||||||
|
) ORDER BY result;
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
[{"datacl": null, "datname": "mydatabase", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": 10, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
[{"datacl": null, "datname": "mydatabase", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": 10, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
[{"datacl": null, "datname": "mydatabase", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": 10, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
drop database mydatabase;
|
||||||
|
SELECT result from run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
||||||
|
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
||||||
|
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
||||||
|
pd.datcollate , pd. datctype , pd.datacl,
|
||||||
|
pa.rolname AS database_owner, pt.spcname AS tablespace
|
||||||
|
FROM pg_database pd
|
||||||
|
JOIN pg_authid pa ON pd.datdba = pa.oid
|
||||||
|
join pg_tablespace pt on pd.dattablespace = pt.oid
|
||||||
|
WHERE datname = 'mydatabase'
|
||||||
|
) q2
|
||||||
|
$$
|
||||||
|
) ORDER BY result;
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
select citus_remove_node('localhost', :worker_2_port);
|
||||||
|
citus_remove_node
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET citus.log_remote_commands = true;
|
||||||
|
set citus.grep_remote_commands = '%CREATE DATABASE%';
|
||||||
|
CREATE DATABASE mydatabase2
|
||||||
|
WITH OWNER = create_drop_db_test_user
|
||||||
|
ENCODING = 'UTF8'
|
||||||
|
STRATEGY = 'wal_log'
|
||||||
|
LOCALE = 'en_US.utf8'
|
||||||
|
LC_COLLATE = 'POSIX'
|
||||||
|
LC_CTYPE = 'POSIX'
|
||||||
|
COLLATION_VERSION = '1.0'
|
||||||
|
TABLESPACE = create_drop_db_tablespace
|
||||||
|
ALLOW_CONNECTIONS = true
|
||||||
|
IS_TEMPLATE = false
|
||||||
|
OID = 966345;
|
||||||
|
NOTICE: issuing CREATE DATABASE mydatabase2 OWNER create_drop_db_test_user ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE 'en_US.utf8' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS true IS_TEMPLATE false OID 966345
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
SET citus.log_remote_commands = false;
|
||||||
|
SELECT result from run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
||||||
|
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
||||||
|
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
||||||
|
pd.datcollate , pd. datctype , pd.datacl,
|
||||||
|
pa.rolname AS database_owner, pt.spcname AS tablespace
|
||||||
|
FROM pg_database pd
|
||||||
|
JOIN pg_authid pa ON pd.datdba = pa.oid
|
||||||
|
join pg_tablespace pt on pd.dattablespace = pt.oid
|
||||||
|
WHERE datname = 'mydatabase2'
|
||||||
|
) q2
|
||||||
|
$$
|
||||||
|
) ORDER BY result;
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
(2 rows)
|
||||||
|
|
||||||
|
SET citus.log_remote_commands = true;
|
||||||
|
select 1 from citus_add_node('localhost', :worker_2_port);
|
||||||
|
NOTICE: issuing SET citus.enable_ddl_propagation TO 'off';select pg_catalog.citus_internal_database_command( 'CREATE DATABASE postgres OWNER = postgres ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' TABLESPACE = pg_default ALLOW_CONNECTIONS = ''true'' IS_TEMPLATE = ''false''');select pg_catalog.citus_internal_database_command( 'CREATE DATABASE regression OWNER = postgres ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' TABLESPACE = pg_default ALLOW_CONNECTIONS = ''true'' IS_TEMPLATE = ''false''');select pg_catalog.citus_internal_database_command( 'CREATE DATABASE template1 OWNER = postgres ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' TABLESPACE = pg_default ALLOW_CONNECTIONS = ''true'' IS_TEMPLATE = ''true''');select pg_catalog.citus_internal_database_command( 'CREATE DATABASE template0 OWNER = postgres ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' TABLESPACE = pg_default ALLOW_CONNECTIONS = ''false'' IS_TEMPLATE = ''true''');select pg_catalog.citus_internal_database_command( 'CREATE DATABASE mydatabase2 OWNER = create_drop_db_test_user ENCODING = ''UTF8'' LC_COLLATE = ''C'' LC_CTYPE = ''C'' LOCALE_PROVIDER = ''libc'' COLLATION_VERSION = ''1.0'' TABLESPACE = create_drop_db_tablespace ALLOW_CONNECTIONS = ''true'' IS_TEMPLATE = ''false''');ALTER ROLE ALL IN DATABASE regression SET lc_messages = 'C';ALTER ROLE ALL IN DATABASE regression SET lc_monetary = 'C';ALTER ROLE ALL IN DATABASE regression SET lc_numeric = 'C';ALTER ROLE ALL IN DATABASE regression SET lc_time = 'C';ALTER ROLE ALL IN DATABASE regression SET bytea_output = 'hex';ALTER ROLE ALL IN DATABASE regression SET timezone_abbreviations = 'Default';SET citus.enable_ddl_propagation TO 'on'
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
?column?
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET citus.log_remote_commands = false;
|
||||||
|
SELECT result from run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
||||||
|
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
||||||
|
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
||||||
|
pd.datcollate , pd. datctype , pd.datacl,
|
||||||
|
pa.rolname AS database_owner, pt.spcname AS tablespace
|
||||||
|
FROM pg_database pd
|
||||||
|
JOIN pg_authid pa ON pd.datdba = pa.oid
|
||||||
|
join pg_tablespace pt on pd.dattablespace = pt.oid
|
||||||
|
WHERE datname = 'mydatabase2'
|
||||||
|
) q2
|
||||||
|
$$
|
||||||
|
) ORDER BY result;
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
[{"datacl": null, "datname": "mydatabase2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": true, "datconnlimit": -1, "datistemplate": false, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SET citus.log_remote_commands = true;
|
||||||
|
set citus.grep_remote_commands = '%DROP DATABASE%';
|
||||||
|
drop database mydatabase2;
|
||||||
|
NOTICE: issuing DROP DATABASE mydatabase2
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
NOTICE: issuing DROP DATABASE mydatabase2
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
SET citus.log_remote_commands = false;
|
||||||
|
SELECT result from run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
||||||
|
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
||||||
|
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
||||||
|
pd.datcollate , pd. datctype , pd.datacl,
|
||||||
|
pa.rolname AS database_owner, pt.spcname AS tablespace
|
||||||
|
FROM pg_database pd
|
||||||
|
JOIN pg_authid pa ON pd.datdba = pa.oid
|
||||||
|
join pg_tablespace pt on pd.dattablespace = pt.oid
|
||||||
|
WHERE datname = 'mydatabase'
|
||||||
|
) q2
|
||||||
|
$$
|
||||||
|
) ORDER BY result;
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SET citus.log_remote_commands = true;
|
||||||
|
set citus.grep_remote_commands = '%CREATE DATABASE%';
|
||||||
|
-- create a template database with all options set and allow connections false
|
||||||
|
CREATE DATABASE my_template_database
|
||||||
|
WITH TEMPLATE = 'template0'
|
||||||
|
OWNER = create_drop_db_test_user
|
||||||
|
ENCODING = 'UTF8'
|
||||||
|
STRATEGY = 'wal_log'
|
||||||
|
LOCALE = 'en_US.utf8'
|
||||||
|
LC_COLLATE = 'POSIX'
|
||||||
|
LC_CTYPE = 'POSIX'
|
||||||
|
ICU_LOCALE = 'en-US'
|
||||||
|
LOCALE_PROVIDER = 'icu'
|
||||||
|
COLLATION_VERSION = '1.0'
|
||||||
|
TABLESPACE = create_drop_db_tablespace
|
||||||
|
ALLOW_CONNECTIONS = false
|
||||||
|
IS_TEMPLATE = true;
|
||||||
|
NOTICE: issuing CREATE DATABASE my_template_database TEMPLATE template0 OWNER create_drop_db_test_user ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE 'en_US.utf8' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' ICU_LOCALE 'en-US' LOCALE_PROVIDER 'icu' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS false IS_TEMPLATE true
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
NOTICE: issuing CREATE DATABASE my_template_database TEMPLATE template0 OWNER create_drop_db_test_user ENCODING 'UTF8' STRATEGY 'wal_log' LOCALE 'en_US.utf8' LC_COLLATE 'POSIX' LC_CTYPE 'POSIX' ICU_LOCALE 'en-US' LOCALE_PROVIDER 'icu' COLLATION_VERSION '1.0' TABLESPACE create_drop_db_tablespace ALLOW_CONNECTIONS false IS_TEMPLATE true
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
SET citus.log_remote_commands = false;
|
||||||
|
SELECT result from run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
||||||
|
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
||||||
|
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
||||||
|
pd.datcollate , pd. datctype , pd.datacl,
|
||||||
|
pa.rolname AS database_owner, pt.spcname AS tablespace
|
||||||
|
FROM pg_database pd
|
||||||
|
JOIN pg_authid pa ON pd.datdba = pa.oid
|
||||||
|
join pg_tablespace pt on pd.dattablespace = pt.oid
|
||||||
|
WHERE datname = 'my_template_database'
|
||||||
|
) q2
|
||||||
|
$$
|
||||||
|
) ORDER BY result;
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
[{"datacl": null, "datname": "my_template_database", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": false, "datconnlimit": -1, "datistemplate": true, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
[{"datacl": null, "datname": "my_template_database", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": false, "datconnlimit": -1, "datistemplate": true, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
[{"datacl": null, "datname": "my_template_database", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "create_drop_db_tablespace", "datallowconn": false, "datconnlimit": -1, "datistemplate": true, "database_owner": "create_drop_db_test_user"}]
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
SET citus.log_remote_commands = true;
|
||||||
|
--template databases could not be dropped so we need to change the template flag
|
||||||
|
SELECT result from run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
UPDATE pg_database SET datistemplate = false WHERE datname = 'my_template_database'
|
||||||
|
$$
|
||||||
|
) ORDER BY result;
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
UPDATE 1
|
||||||
|
UPDATE 1
|
||||||
|
UPDATE 1
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
;
|
||||||
|
set citus.grep_remote_commands = '%DROP DATABASE%';
|
||||||
|
drop database my_template_database;
|
||||||
|
NOTICE: issuing DROP DATABASE my_template_database
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
NOTICE: issuing DROP DATABASE my_template_database
|
||||||
|
DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx
|
||||||
|
SET citus.log_remote_commands = false;
|
||||||
|
SELECT result from run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT jsonb_agg(to_jsonb(q2.*)) FROM (
|
||||||
|
SELECT pd.datname, pg_encoding_to_char(pd.encoding) as encoding,
|
||||||
|
pd.datistemplate, pd.datallowconn, pd.datconnlimit,
|
||||||
|
pd.datcollate , pd. datctype , pd.datacl,
|
||||||
|
pa.rolname AS database_owner, pt.spcname AS tablespace
|
||||||
|
FROM pg_database pd
|
||||||
|
JOIN pg_authid pa ON pd.datdba = pa.oid
|
||||||
|
join pg_tablespace pt on pd.dattablespace = pt.oid
|
||||||
|
WHERE datname = 'my_template_database'
|
||||||
|
) q2
|
||||||
|
$$
|
||||||
|
) ORDER BY result;
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
\c - - - :master_port
|
||||||
|
drop tablespace create_drop_db_tablespace;
|
||||||
|
\c - - - :worker_1_port
|
||||||
|
drop tablespace create_drop_db_tablespace;
|
||||||
|
\c - - - :worker_2_port
|
||||||
|
drop tablespace create_drop_db_tablespace;
|
||||||
|
\c - - - :master_port
|
||||||
|
drop user create_drop_db_test_user;
|
|
@ -7,6 +7,7 @@ SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
|
||||||
\if :server_version_ge_15
|
\if :server_version_ge_15
|
||||||
\else
|
\else
|
||||||
\q
|
\q
|
||||||
|
\endif
|
||||||
|
|
||||||
-- create/drop database for pg > 15
|
-- create/drop database for pg > 15
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue