diff --git a/src/test/regress/expected/alter_database_from_nonmain_db.out b/src/test/regress/expected/alter_database_from_nonmain_db.out index d38975405..937dc9b9d 100644 --- a/src/test/regress/expected/alter_database_from_nonmain_db.out +++ b/src/test/regress/expected/alter_database_from_nonmain_db.out @@ -13,6 +13,9 @@ CREATE TABLESPACE "ts-needs\!escape2" LOCATION :'alter_db_tablespace'; \c - - - :worker_2_port \set alter_db_tablespace :abs_srcdir '/tmp_check/ts5' CREATE TABLESPACE "ts-needs\!escape2" LOCATION :'alter_db_tablespace'; +-- Below tests test the ALTER DATABASE command from main and non-main databases +-- The tests are run on the master and worker nodes to ensure that the command is +-- executed on all nodes. \c test_alter_db_from_nonmain_db set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; @@ -55,7 +58,7 @@ SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "ts-needs\\!escape2", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} (3 rows) -\c test_alter_db_from_nonmain_db - - :worker_1_port +\c test_alter_db_from_nonmain_db - - :worker_2_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" set tablespace "pg_default"; @@ -88,6 +91,8 @@ DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE "ts-needs\!escape2" DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx +-- In the below tests, we test the ALTER DATABASE ..set tablespace command +-- repeatedly to ensure that the command does not stuck when executed multiple times \c regression - - :worker_1_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; @@ -101,40 +106,6 @@ NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE "ts-needs\! DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE "ts-needs\!escape2" DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -\c regression - - :master_port -SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; - node_type | result ---------------------------------------------------------------------- - coordinator (local) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "ts-needs\\!escape2", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} - worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "ts-needs\\!escape2", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} - worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "ts-needs\\!escape2", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} -(3 rows) - -\c regression - - :worker_1_port -set citus.log_remote_commands = true; -set citus.grep_remote_commands = "%ALTER DATABASE%"; -alter database "altered_database!'2" set tablespace "pg_default"; -NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE pg_default -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE pg_default -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -\c regression - - :master_port -SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; - node_type | result ---------------------------------------------------------------------- - coordinator (local) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "pg_default", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} - worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "pg_default", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} - worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "pg_default", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} -(3 rows) - -\c regression - - :worker_1_port -set citus.log_remote_commands = true; -set citus.grep_remote_commands = "%ALTER DATABASE%"; -alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; -NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE "ts-needs\!escape2" -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE "ts-needs\!escape2" -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx alter database "altered_database!'2" set tablespace "pg_default"; NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE pg_default DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx @@ -178,34 +149,6 @@ NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE "ts-needs\! DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE "ts-needs\!escape2" DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -\c regression - - :master_port -SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; - node_type | result ---------------------------------------------------------------------- - coordinator (local) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "ts-needs\\!escape2", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} - worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "ts-needs\\!escape2", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} - worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "ts-needs\\!escape2", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} -(3 rows) - -\c regression - - :worker_2_port -alter database "altered_database!'2" set tablespace "pg_default"; -\c regression - - :master_port -SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; - node_type | result ---------------------------------------------------------------------- - coordinator (local) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "pg_default", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} - worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "pg_default", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} - worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "pg_default", "daticurules": null, "datallowconn": true, "datconnlimit": -1, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} -(3 rows) - -\c regression - - :worker_2_port -set citus.log_remote_commands = true; -set citus.grep_remote_commands = "%ALTER DATABASE%"; -alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; -NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE "ts-needs\!escape2" -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx -NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE "ts-needs\!escape2" -DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx alter database "altered_database!'2" set tablespace "pg_default"; NOTICE: issuing ALTER DATABASE "altered_database!'2" SET TABLESPACE pg_default DETAIL: on server postgres@localhost:xxxxx connectionId: xxxxxxx @@ -329,7 +272,7 @@ SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "ts-needs\\!escape2", "daticurules": null, "datallowconn": true, "datconnlimit": 0, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} (3 rows) -\c regression - - :worker_2_port +\c regression - - :worker_1_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" with @@ -394,7 +337,7 @@ SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER worker node (remote) | {"database_properties": {"datacl": null, "datname": "altered_database!'2", "datctype": "C", "encoding": "UTF8", "datcollate": "C", "tablespace": "ts-needs\\!escape2", "daticurules": null, "datallowconn": true, "datconnlimit": 0, "daticulocale": null, "datistemplate": false, "database_owner": "postgres", "datcollversion": null, "datlocprovider": "c"}, "pg_dist_object_record_for_db_exists": true, "stale_pg_dist_object_record_for_a_db_exists": false} (3 rows) -\c regression - - :worker_1_port +\c regression - - :worker_2_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" owner to test_owner_non_main_db; @@ -545,7 +488,7 @@ select name,setting from pg_settings log_duration | on (1 row) -\c test_alter_db_from_nonmain_db - - :worker_2_port +\c test_alter_db_from_nonmain_db - - :worker_1_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" RESET log_duration; @@ -607,7 +550,7 @@ select name,setting from pg_settings statement_timeout | 1000 (1 row) -\c regression - - :worker_2_port +\c regression - - :worker_1_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" set statement_timeout to DEFAULT; diff --git a/src/test/regress/sql/alter_database_from_nonmain_db.sql b/src/test/regress/sql/alter_database_from_nonmain_db.sql index 4be89112e..1343fba0f 100644 --- a/src/test/regress/sql/alter_database_from_nonmain_db.sql +++ b/src/test/regress/sql/alter_database_from_nonmain_db.sql @@ -17,6 +17,10 @@ CREATE TABLESPACE "ts-needs\!escape2" LOCATION :'alter_db_tablespace'; \set alter_db_tablespace :abs_srcdir '/tmp_check/ts5' CREATE TABLESPACE "ts-needs\!escape2" LOCATION :'alter_db_tablespace'; +-- Below tests test the ALTER DATABASE command from main and non-main databases +-- The tests are run on the master and worker nodes to ensure that the command is +-- executed on all nodes. + \c test_alter_db_from_nonmain_db set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; @@ -38,7 +42,7 @@ alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; \c regression - - :master_port SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; -\c test_alter_db_from_nonmain_db - - :worker_1_port +\c test_alter_db_from_nonmain_db - - :worker_2_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" set tablespace "pg_default"; @@ -54,23 +58,14 @@ alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; alter database "altered_database!'2" set tablespace "pg_default"; alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; +-- In the below tests, we test the ALTER DATABASE ..set tablespace command +-- repeatedly to ensure that the command does not stuck when executed multiple times + \c regression - - :worker_1_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" set tablespace "pg_default"; alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; -\c regression - - :master_port -SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; -\c regression - - :worker_1_port -set citus.log_remote_commands = true; -set citus.grep_remote_commands = "%ALTER DATABASE%"; -alter database "altered_database!'2" set tablespace "pg_default"; -\c regression - - :master_port -SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; -\c regression - - :worker_1_port -set citus.log_remote_commands = true; -set citus.grep_remote_commands = "%ALTER DATABASE%"; -alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; alter database "altered_database!'2" set tablespace "pg_default"; alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; alter database "altered_database!'2" set tablespace "pg_default"; @@ -81,18 +76,9 @@ alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; \c regression - - :worker_2_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; + alter database "altered_database!'2" set tablespace "pg_default"; alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; -\c regression - - :master_port -SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; -\c regression - - :worker_2_port -alter database "altered_database!'2" set tablespace "pg_default"; -\c regression - - :master_port -SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; -\c regression - - :worker_2_port -set citus.log_remote_commands = true; -set citus.grep_remote_commands = "%ALTER DATABASE%"; -alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; alter database "altered_database!'2" set tablespace "pg_default"; alter database "altered_database!'2" set tablespace "ts-needs\!escape2"; alter database "altered_database!'2" set tablespace "pg_default"; @@ -130,7 +116,7 @@ alter database "altered_database!'2" with \c regression - - :master_port SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; -\c regression - - :worker_2_port +\c regression - - :worker_1_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; @@ -169,7 +155,7 @@ set default_transaction_read_only = false; \c regression - - :master_port SELECT * FROM public.check_database_on_all_nodes($$altered_database!''2$$) ORDER BY node_type; -\c regression - - :worker_1_port +\c regression - - :worker_2_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" owner to test_owner_non_main_db; @@ -243,7 +229,7 @@ select name,setting from pg_settings select name,setting from pg_settings where name ='log_duration'; -\c test_alter_db_from_nonmain_db - - :worker_2_port +\c test_alter_db_from_nonmain_db - - :worker_1_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" RESET log_duration; @@ -277,7 +263,7 @@ select name,setting from pg_settings where name ='statement_timeout'; -\c regression - - :worker_2_port +\c regression - - :worker_1_port set citus.log_remote_commands = true; set citus.grep_remote_commands = "%ALTER DATABASE%"; alter database "altered_database!'2" set statement_timeout to DEFAULT;