mirror of https://github.com/citusdata/citus.git
Fixes review comments
parent
ce43bc7c29
commit
77bad0b90e
|
@ -712,20 +712,14 @@ List *
|
||||||
DatabaseCommentObjectAddress(Node *node, bool missing_ok, bool isPostprocess)
|
DatabaseCommentObjectAddress(Node *node, bool missing_ok, bool isPostprocess)
|
||||||
{
|
{
|
||||||
CommentStmt *stmt = castNode(CommentStmt, node);
|
CommentStmt *stmt = castNode(CommentStmt, node);
|
||||||
|
Relation relation;
|
||||||
Assert(stmt->objtype == OBJECT_DATABASE);
|
Assert(stmt->objtype == OBJECT_DATABASE);
|
||||||
|
|
||||||
char *databaseName = strVal(stmt->object);
|
ObjectAddress objectAddress = get_object_address(stmt->objtype, stmt->object,
|
||||||
|
&relation, AccessExclusiveLock,
|
||||||
|
missing_ok);
|
||||||
|
|
||||||
Oid objid = get_database_oid(databaseName, missing_ok);
|
ObjectAddress *objectAddressCopy = palloc0(sizeof(ObjectAddress));
|
||||||
|
*objectAddressCopy = objectAddress;
|
||||||
if (!OidIsValid(objid))
|
return list_make1(objectAddressCopy);
|
||||||
{
|
|
||||||
ereport(ERROR, (errmsg("database \"%s\" does not exist", databaseName)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ObjectAddress *address = palloc0(sizeof(ObjectAddress));
|
|
||||||
ObjectAddressSet(*address, DatabaseRelationId, objid);
|
|
||||||
return list_make1(address);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1423,20 +1423,14 @@ List *
|
||||||
RoleCommentObjectAddress(Node *node, bool missing_ok, bool isPostprocess)
|
RoleCommentObjectAddress(Node *node, bool missing_ok, bool isPostprocess)
|
||||||
{
|
{
|
||||||
CommentStmt *stmt = castNode(CommentStmt, node);
|
CommentStmt *stmt = castNode(CommentStmt, node);
|
||||||
|
Relation relation;
|
||||||
Assert(stmt->objtype == OBJECT_ROLE);
|
Assert(stmt->objtype == OBJECT_ROLE);
|
||||||
|
|
||||||
char *roleName = strVal(stmt->object);
|
ObjectAddress objectAddress = get_object_address(stmt->objtype, stmt->object,
|
||||||
|
&relation, AccessExclusiveLock,
|
||||||
|
missing_ok);
|
||||||
|
|
||||||
Oid objid = get_role_oid(roleName, missing_ok);
|
ObjectAddress *objectAddressCopy = palloc0(sizeof(ObjectAddress));
|
||||||
|
*objectAddressCopy = objectAddress;
|
||||||
if (!OidIsValid(objid))
|
return list_make1(objectAddressCopy);
|
||||||
{
|
|
||||||
ereport(ERROR, (errmsg("role \"%s\" does not exist", roleName)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ObjectAddress *address = palloc0(sizeof(ObjectAddress));
|
|
||||||
ObjectAddressSet(*address, AuthIdRelationId, objid);
|
|
||||||
return list_make1(address);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,7 +321,7 @@ DeparseDatabaseCommentStmt(Node *node)
|
||||||
StringInfoData str = { 0 };
|
StringInfoData str = { 0 };
|
||||||
initStringInfo(&str);
|
initStringInfo(&str);
|
||||||
|
|
||||||
char *databaseName = strVal(stmt->object);
|
char const *databaseName = quote_identifier(strVal(stmt->object));
|
||||||
|
|
||||||
char *comment = stmt->comment != NULL ? quote_literal_cstr(stmt->comment) : "NULL";
|
char *comment = stmt->comment != NULL ? quote_literal_cstr(stmt->comment) : "NULL";
|
||||||
|
|
||||||
|
|
|
@ -542,7 +542,7 @@ DeparseRoleCommentStmt(Node *node)
|
||||||
StringInfoData str = { 0 };
|
StringInfoData str = { 0 };
|
||||||
initStringInfo(&str);
|
initStringInfo(&str);
|
||||||
|
|
||||||
char *roleName = strVal(stmt->object);
|
char const *roleName = quote_identifier(strVal(stmt->object));
|
||||||
char *comment = stmt->comment != NULL ? quote_literal_cstr(stmt->comment) : "NULL";
|
char *comment = stmt->comment != NULL ? quote_literal_cstr(stmt->comment) : "NULL";
|
||||||
|
|
||||||
appendStringInfo(&str, "COMMENT ON ROLE %s IS %s;", roleName, comment);
|
appendStringInfo(&str, "COMMENT ON ROLE %s IS %s;", roleName, comment);
|
||||||
|
|
|
@ -246,8 +246,8 @@ extern List * CreateDatabaseStmtObjectAddress(Node *node, bool missingOk,
|
||||||
bool isPostprocess);
|
bool isPostprocess);
|
||||||
extern void EnsureSupportedCreateDatabaseCommand(CreatedbStmt *stmt);
|
extern void EnsureSupportedCreateDatabaseCommand(CreatedbStmt *stmt);
|
||||||
extern char * CreateDatabaseDDLCommand(Oid dbId);
|
extern char * CreateDatabaseDDLCommand(Oid dbId);
|
||||||
extern List * DatabaseCommentObjectAddress(Node *node, bool missing_ok, bool
|
extern List * DatabaseCommentObjectAddress(Node *node, bool missing_ok,
|
||||||
isPostprocess);
|
bool isPostprocess);
|
||||||
|
|
||||||
|
|
||||||
/* domain.c - forward declarations */
|
/* domain.c - forward declarations */
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
set citus.log_remote_commands to on;
|
set citus.log_remote_commands to on;
|
||||||
set citus.enable_create_database_propagation to on;
|
set citus.enable_create_database_propagation to on;
|
||||||
set citus.grep_remote_commands to 'COMMENT ON DATABASE';
|
set citus.grep_remote_commands to 'COMMENT ON DATABASE';
|
||||||
create database test1;
|
create database "test1-\!escape";
|
||||||
comment on DATABASE test1 is 'test-comment';
|
comment on DATABASE "test1-\!escape" is 'test-comment';
|
||||||
SELECT result FROM run_command_on_all_nodes(
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
$$
|
$$
|
||||||
SELECT ds.description AS database_comment
|
SELECT ds.description AS database_comment
|
||||||
FROM pg_database d
|
FROM pg_database d
|
||||||
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
||||||
WHERE d.datname = 'test1';
|
WHERE d.datname = 'test1-\!escape';
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
result
|
result
|
||||||
|
@ -18,13 +18,13 @@ SELECT result FROM run_command_on_all_nodes(
|
||||||
test-comment
|
test-comment
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
comment on DATABASE test1 is 'comment-needs\!escape';
|
comment on DATABASE "test1-\!escape" is 'comment-needs\!escape';
|
||||||
SELECT result FROM run_command_on_all_nodes(
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
$$
|
$$
|
||||||
SELECT ds.description AS database_comment
|
SELECT ds.description AS database_comment
|
||||||
FROM pg_database d
|
FROM pg_database d
|
||||||
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
||||||
WHERE d.datname = 'test1';
|
WHERE d.datname = 'test1-\!escape';
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
result
|
result
|
||||||
|
@ -34,13 +34,13 @@ SELECT result FROM run_command_on_all_nodes(
|
||||||
comment-needs\!escape
|
comment-needs\!escape
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
comment on DATABASE test1 is null;
|
comment on DATABASE "test1-\!escape" is null;
|
||||||
SELECT result FROM run_command_on_all_nodes(
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
$$
|
$$
|
||||||
SELECT ds.description AS database_comment
|
SELECT ds.description AS database_comment
|
||||||
FROM pg_database d
|
FROM pg_database d
|
||||||
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
||||||
WHERE d.datname = 'test1';
|
WHERE d.datname = 'test1-\!escape';
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
result
|
result
|
||||||
|
@ -50,7 +50,7 @@ SELECT result FROM run_command_on_all_nodes(
|
||||||
|
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
drop DATABASE test1;
|
drop DATABASE "test1-\!escape";
|
||||||
reset citus.enable_create_database_propagation;
|
reset citus.enable_create_database_propagation;
|
||||||
reset citus.grep_remote_commands;
|
reset citus.grep_remote_commands;
|
||||||
reset citus.log_remote_commands;
|
reset citus.log_remote_commands;
|
||||||
|
|
|
@ -3,42 +3,42 @@ set citus.log_remote_commands to on;
|
||||||
set citus.enable_create_database_propagation to on;
|
set citus.enable_create_database_propagation to on;
|
||||||
set citus.grep_remote_commands to 'COMMENT ON DATABASE';
|
set citus.grep_remote_commands to 'COMMENT ON DATABASE';
|
||||||
|
|
||||||
create database test1;
|
create database "test1-\!escape";
|
||||||
|
|
||||||
comment on DATABASE test1 is 'test-comment';
|
comment on DATABASE "test1-\!escape" is 'test-comment';
|
||||||
|
|
||||||
SELECT result FROM run_command_on_all_nodes(
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
$$
|
$$
|
||||||
SELECT ds.description AS database_comment
|
SELECT ds.description AS database_comment
|
||||||
FROM pg_database d
|
FROM pg_database d
|
||||||
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
||||||
WHERE d.datname = 'test1';
|
WHERE d.datname = 'test1-\!escape';
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
|
|
||||||
comment on DATABASE test1 is 'comment-needs\!escape';
|
comment on DATABASE "test1-\!escape" is 'comment-needs\!escape';
|
||||||
|
|
||||||
SELECT result FROM run_command_on_all_nodes(
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
$$
|
$$
|
||||||
SELECT ds.description AS database_comment
|
SELECT ds.description AS database_comment
|
||||||
FROM pg_database d
|
FROM pg_database d
|
||||||
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
||||||
WHERE d.datname = 'test1';
|
WHERE d.datname = 'test1-\!escape';
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
|
|
||||||
comment on DATABASE test1 is null;
|
comment on DATABASE "test1-\!escape" is null;
|
||||||
|
|
||||||
SELECT result FROM run_command_on_all_nodes(
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
$$
|
$$
|
||||||
SELECT ds.description AS database_comment
|
SELECT ds.description AS database_comment
|
||||||
FROM pg_database d
|
FROM pg_database d
|
||||||
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
||||||
WHERE d.datname = 'test1';
|
WHERE d.datname = 'test1-\!escape';
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
|
|
||||||
drop DATABASE test1;
|
drop DATABASE "test1-\!escape";
|
||||||
reset citus.enable_create_database_propagation;
|
reset citus.enable_create_database_propagation;
|
||||||
reset citus.grep_remote_commands;
|
reset citus.grep_remote_commands;
|
||||||
reset citus.log_remote_commands;
|
reset citus.log_remote_commands;
|
||||||
|
|
Loading…
Reference in New Issue