Skip to content

Commit

Permalink
Allow owner change of a data node
Browse files Browse the repository at this point in the history
Allow previously blocked `ALTER SERVER OWNER TO` operation
on a data node foreign server.

Fix #3617
  • Loading branch information
pmwkaa committed Oct 13, 2021
1 parent fffd6c2 commit 92d18b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
21 changes: 1 addition & 20 deletions src/process_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tsl/test/expected/data_node.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tsl/test/sql/data_node.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 92d18b3

Please sign in to comment.