From 40be5549018908e34d2d9963cafa3f03708ea947 Mon Sep 17 00:00:00 2001 From: Eren Basak Date: Mon, 7 Nov 2016 11:25:45 -0800 Subject: [PATCH] Add Column Definition List for Output Columns for master_add_node This change allows seeing the names of columns of `master_add_node`, using `SELECT * FROM master_add_node(...)` by specifying output columns in UDF definition. --- src/backend/distributed/Makefile | 4 +++- .../distributed/citus--6.0-17--6.0-18.sql | 21 +++++++++++++++++++ src/backend/distributed/citus.control | 2 +- .../expected/multi_cluster_management.out | 10 ++++----- src/test/regress/expected/multi_extension.out | 1 + .../regress/sql/multi_cluster_management.sql | 4 ++-- src/test/regress/sql/multi_extension.sql | 1 + 7 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 src/backend/distributed/citus--6.0-17--6.0-18.sql diff --git a/src/backend/distributed/Makefile b/src/backend/distributed/Makefile index bd52c961d1c..c0210b92db9 100644 --- a/src/backend/distributed/Makefile +++ b/src/backend/distributed/Makefile @@ -8,7 +8,7 @@ EXTENSION = citus EXTVERSIONS = 5.0 5.0-1 5.0-2 \ 5.1-1 5.1-2 5.1-3 5.1-4 5.1-5 5.1-6 5.1-7 5.1-8 \ 5.2-1 5.2-2 5.2-3 5.2-4 \ - 6.0-1 6.0-2 6.0-3 6.0-4 6.0-5 6.0-6 6.0-7 6.0-8 6.0-9 6.0-10 6.0-11 6.0-12 6.0-13 6.0-14 6.0-15 6.0-16 6.0-17 + 6.0-1 6.0-2 6.0-3 6.0-4 6.0-5 6.0-6 6.0-7 6.0-8 6.0-9 6.0-10 6.0-11 6.0-12 6.0-13 6.0-14 6.0-15 6.0-16 6.0-17 6.0-18 # All citus--*.sql files in the source directory DATA = $(patsubst $(citus_abs_srcdir)/%.sql,%.sql,$(wildcard $(citus_abs_srcdir)/$(EXTENSION)--*--*.sql)) @@ -92,6 +92,8 @@ $(EXTENSION)--6.0-16.sql: $(EXTENSION)--6.0-15.sql $(EXTENSION)--6.0-15--6.0-16. cat $^ > $@ $(EXTENSION)--6.0-17.sql: $(EXTENSION)--6.0-16.sql $(EXTENSION)--6.0-16--6.0-17.sql cat $^ > $@ +$(EXTENSION)--6.0-18.sql: $(EXTENSION)--6.0-17.sql $(EXTENSION)--6.0-17--6.0-18.sql + cat $^ > $@ NO_PGXS = 1 diff --git a/src/backend/distributed/citus--6.0-17--6.0-18.sql b/src/backend/distributed/citus--6.0-17--6.0-18.sql new file mode 100644 index 00000000000..035cc722774 --- /dev/null +++ b/src/backend/distributed/citus--6.0-17--6.0-18.sql @@ -0,0 +1,21 @@ +/* citus--6.0-17--6.0-18.sql */ + +SET search_path = 'pg_catalog'; + +DROP FUNCTION IF EXISTS master_add_node(text, integer); + +CREATE FUNCTION master_add_node(nodename text, + nodeport integer, + OUT nodeid integer, + OUT groupid integer, + OUT nodename text, + OUT nodeport integer, + OUT noderack text, + OUT hasmetadata boolean) + RETURNS record + LANGUAGE C STRICT + AS 'MODULE_PATHNAME', $$master_add_node$$; +COMMENT ON FUNCTION master_add_node(nodename text, nodeport integer) + IS 'add node to the cluster'; + +RESET search_path; diff --git a/src/backend/distributed/citus.control b/src/backend/distributed/citus.control index b52f787be2b..63d1859f16c 100644 --- a/src/backend/distributed/citus.control +++ b/src/backend/distributed/citus.control @@ -1,6 +1,6 @@ # Citus extension comment = 'Citus distributed database' -default_version = '6.0-17' +default_version = '6.0-18' module_pathname = '$libdir/citus' relocatable = false schema = pg_catalog diff --git a/src/test/regress/expected/multi_cluster_management.out b/src/test/regress/expected/multi_cluster_management.out index a5e3fd5c934..1fe3204805c 100644 --- a/src/test/regress/expected/multi_cluster_management.out +++ b/src/test/regress/expected/multi_cluster_management.out @@ -22,11 +22,11 @@ SELECT master_get_active_worker_nodes(); (localhost,57637) (2 rows) --- try to add the node again when it is activated -SELECT master_add_node('localhost', :worker_1_port); - master_add_node ---------------------------------- - (1,1,localhost,57637,default,f) +-- try to add a node that is already in the cluster +SELECT * FROM master_add_node('localhost', :worker_1_port); + nodeid | groupid | nodename | nodeport | noderack | hasmetadata +--------+---------+-----------+----------+----------+------------- + 1 | 1 | localhost | 57637 | default | f (1 row) -- get the active nodes diff --git a/src/test/regress/expected/multi_extension.out b/src/test/regress/expected/multi_extension.out index 04720eb4107..16940c74572 100644 --- a/src/test/regress/expected/multi_extension.out +++ b/src/test/regress/expected/multi_extension.out @@ -57,6 +57,7 @@ ALTER EXTENSION citus UPDATE TO '6.0-14'; ALTER EXTENSION citus UPDATE TO '6.0-15'; ALTER EXTENSION citus UPDATE TO '6.0-16'; ALTER EXTENSION citus UPDATE TO '6.0-17'; +ALTER EXTENSION citus UPDATE TO '6.0-18'; -- ensure no objects were created outside pg_catalog SELECT COUNT(*) FROM pg_depend AS pgd, diff --git a/src/test/regress/sql/multi_cluster_management.sql b/src/test/regress/sql/multi_cluster_management.sql index 79e44d7577c..9225bc2c31d 100644 --- a/src/test/regress/sql/multi_cluster_management.sql +++ b/src/test/regress/sql/multi_cluster_management.sql @@ -10,8 +10,8 @@ SELECT master_add_node('localhost', :worker_2_port); -- get the active nodes SELECT master_get_active_worker_nodes(); --- try to add the node again when it is activated -SELECT master_add_node('localhost', :worker_1_port); +-- try to add a node that is already in the cluster +SELECT * FROM master_add_node('localhost', :worker_1_port); -- get the active nodes SELECT master_get_active_worker_nodes(); diff --git a/src/test/regress/sql/multi_extension.sql b/src/test/regress/sql/multi_extension.sql index 76c39ce3ea9..c375969df99 100644 --- a/src/test/regress/sql/multi_extension.sql +++ b/src/test/regress/sql/multi_extension.sql @@ -57,6 +57,7 @@ ALTER EXTENSION citus UPDATE TO '6.0-14'; ALTER EXTENSION citus UPDATE TO '6.0-15'; ALTER EXTENSION citus UPDATE TO '6.0-16'; ALTER EXTENSION citus UPDATE TO '6.0-17'; +ALTER EXTENSION citus UPDATE TO '6.0-18'; -- ensure no objects were created outside pg_catalog SELECT COUNT(*)