Fixes review notes

grant_database_2pc_onur_1
gurkanindibay 2024-02-20 13:30:01 +03:00
parent a8fae40417
commit 971a4869a9
4 changed files with 23 additions and 11 deletions

View File

@ -1703,7 +1703,28 @@ IsStatementSupportedFromNonMainDb(Node *parsetree)
{
if (type == NonMainDbSupportedStatements[i].statementType)
{
return true;
if (NonMainDbSupportedStatements[i].supportedObjectTypes == NULL)
{
return true;
}
else
{
if (type == T_GrantStmt)
{
GrantStmt *stmt = castNode(GrantStmt, parsetree);
/* check if stmt->objtype is in supportedObjectTypes */
for (int j = 0; j <
NonMainDbSupportedStatements[i].supportedObjectTypesSize; j++)
{
if (stmt->objtype ==
NonMainDbSupportedStatements[i].supportedObjectTypes[j])
{
return true;
}
}
return false;
}
}
}
}

View File

@ -467,4 +467,5 @@ grant connect,temp,temporary on database test_2pc_db to public;
drop database test_2pc_db;
set citus.enable_create_database_propagation to off;
DROP SCHEMA grant_on_database_propagation_non_maindb CASCADE;
reset citus.enable_create_database_propagation;
---------------------------------------------------------------------

View File

@ -4,7 +4,6 @@
set citus.enable_create_database_propagation to on;
create database test_2pc_db;
show citus.main_db;
revoke connect,temp,temporary on database test_2pc_db from public;
CREATE SCHEMA grant_on_database_propagation_non_maindb;

View File

@ -1,16 +1,11 @@
CREATE SCHEMA metadata_sync_2pc_schema;
SET search_path TO metadata_sync_2pc_schema;
set citus.enable_create_database_propagation to on;
CREATE DATABASE metadata_sync_2pc_db;
revoke connect,temp,temporary on database metadata_sync_2pc_db from public;
\c metadata_sync_2pc_db
SHOW citus.main_db;
@ -44,7 +39,6 @@ select check_database_privileges('grant_role2pc''_user3','metadata_sync_2pc_db',
set citus.enable_create_database_propagation to on;
select 1 from citus_add_node('localhost', :worker_2_port);
select result FROM run_command_on_all_nodes($$
SELECT array_to_json(array_agg(row_to_json(t)))
FROM (
@ -60,7 +54,6 @@ select check_database_privileges('grant_role2pc''_user1','metadata_sync_2pc_db',
select check_database_privileges('grant_role2pc''_user2','metadata_sync_2pc_db',ARRAY['CONNECT']);
select check_database_privileges('grant_role2pc''_user3','metadata_sync_2pc_db',ARRAY['CREATE','CONNECT','TEMP','TEMPORARY']);
\c metadata_sync_2pc_db
revoke "grant_role2pc'_user1","grant_role2pc'_user2" from grant_role2pc_user4,grant_role2pc_user5 granted by "grant_role2pc'_user3";
@ -76,9 +69,7 @@ revoke CREATE on database metadata_sync_2pc_db from "grant_role2pc'_user1";
drop user "grant_role2pc'_user1","grant_role2pc'_user2","grant_role2pc'_user3",grant_role2pc_user4,grant_role2pc_user5;
set citus.enable_create_database_propagation to on;
drop database metadata_sync_2pc_db;
drop schema metadata_sync_2pc_schema;
reset citus.enable_create_database_propagation;
reset search_path;