From 92d18b3508eeece9ac90105bdc924b7a769b81d1 Mon Sep 17 00:00:00 2001 From: Dmitry Simonenko Date: Wed, 13 Oct 2021 16:14:32 +0300 Subject: [PATCH] Allow owner change of a data node Allow previously blocked `ALTER SERVER OWNER TO` operation on a data node foreign server. Fix #3617 --- src/process_utility.c | 21 +-------------------- tsl/test/expected/data_node.out | 4 ++-- tsl/test/sql/data_node.sql | 5 +++-- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/process_utility.c b/src/process_utility.c index 4121fc9b6d9..58b8dc1766c 100644 --- a/src/process_utility.c +++ b/src/process_utility.c @@ -412,22 +412,6 @@ process_alter_foreign_server(ProcessUtilityArgs *args) return DDL_CONTINUE; } -static DDLResult -process_alter_owner(ProcessUtilityArgs *args) -{ - AlterOwnerStmt *stmt = (AlterOwnerStmt *) args->parsetree; - - if ((stmt->objectType == OBJECT_FOREIGN_SERVER) && - block_on_foreign_server(strVal(stmt->object))) - { - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("alter owner not supported on a TimescaleDB data node"))); - } - - return DDL_CONTINUE; -} - static void process_altertableschema(ProcessUtilityArgs *args) { @@ -3773,9 +3757,6 @@ process_ddl_command_start(ProcessUtilityArgs *args) case T_AlterForeignServerStmt: handler = process_alter_foreign_server; break; - case T_AlterOwnerStmt: - handler = process_alter_owner; - break; case T_CreateForeignServerStmt: handler = process_create_foreign_server_start; break; @@ -3846,7 +3827,7 @@ process_ddl_command_start(ProcessUtilityArgs *args) } if (handler == NULL) - return false; + return DDL_CONTINUE; if (check_read_only) #if PG13_GE diff --git a/tsl/test/expected/data_node.out b/tsl/test/expected/data_node.out index ee142bca804..c28a9298722 100644 --- a/tsl/test/expected/data_node.out +++ b/tsl/test/expected/data_node.out @@ -82,9 +82,9 @@ ALTER SERVER data_node_1 OPTIONS (DROP sslmode); ERROR: alter server not supported on a TimescaleDB data node ALTER SERVER data_node_1 RENAME TO data_node_k; ERROR: rename not supported on a TimescaleDB data node -ALTER SERVER data_node_1 OWNER TO CURRENT_USER; -ERROR: alter owner not supported on a TimescaleDB data node \set ON_ERROR_STOP 1 +-- Make sure changing server owner is allowed +ALTER SERVER data_node_1 OWNER TO CURRENT_USER; -- List foreign data nodes SELECT node_name, "options" FROM timescaledb_information.data_nodes ORDER BY node_name; node_name | options diff --git a/tsl/test/sql/data_node.sql b/tsl/test/sql/data_node.sql index 41aa86be7e8..1e99b745faa 100644 --- a/tsl/test/sql/data_node.sql +++ b/tsl/test/sql/data_node.sql @@ -55,15 +55,16 @@ SELECT * FROM add_data_node('data_node_2', host => 'localhost', database => :'DN SELECT * FROM add_data_node('data_node_3', host => 'localhost', database => :'DN_DBNAME_3'); - -- Test altering server command is blocked \set ON_ERROR_STOP 0 ALTER SERVER data_node_1 OPTIONS (SET fdw_startup_cost '110.0'); ALTER SERVER data_node_1 OPTIONS (DROP sslmode); ALTER SERVER data_node_1 RENAME TO data_node_k; -ALTER SERVER data_node_1 OWNER TO CURRENT_USER; \set ON_ERROR_STOP 1 +-- Make sure changing server owner is allowed +ALTER SERVER data_node_1 OWNER TO CURRENT_USER; + -- List foreign data nodes SELECT node_name, "options" FROM timescaledb_information.data_nodes ORDER BY node_name;