mirror of https://github.com/citusdata/citus.git
Handles null comment cases
parent
d8448dd088
commit
e258122fde
|
@ -323,10 +323,9 @@ DeparseDatabaseCommentStmt(Node *node)
|
||||||
|
|
||||||
char *databaseName = strVal(stmt->object);
|
char *databaseName = strVal(stmt->object);
|
||||||
|
|
||||||
|
char *comment = stmt->comment!=NULL?quote_literal_cstr(stmt->comment):"NULL";
|
||||||
|
|
||||||
appendStringInfo(&str, "COMMENT ON DATABASE %s IS %s;",
|
appendStringInfo(&str, "COMMENT ON DATABASE %s IS %s;",databaseName,comment);
|
||||||
databaseName,
|
|
||||||
quote_literal_cstr(stmt->comment));
|
|
||||||
|
|
||||||
return str.data;
|
return str.data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,11 +543,9 @@ DeparseRoleCommentStmt(Node *node)
|
||||||
initStringInfo(&str);
|
initStringInfo(&str);
|
||||||
|
|
||||||
char *roleName = strVal(stmt->object);
|
char *roleName = strVal(stmt->object);
|
||||||
|
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,
|
|
||||||
quote_literal_cstr(stmt->comment));
|
|
||||||
|
|
||||||
return str.data;
|
return str.data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ create database test1;
|
||||||
comment on DATABASE test1 is 'test-comment';
|
comment on DATABASE test1 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';
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
result
|
result
|
||||||
|
@ -21,10 +21,10 @@ WHERE d.datname = 'test1';
|
||||||
comment on DATABASE test1 is 'comment-needs\!escape';
|
comment on DATABASE test1 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';
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
result
|
result
|
||||||
|
@ -32,6 +32,22 @@ WHERE d.datname = 'test1';
|
||||||
comment-needs\!escape
|
comment-needs\!escape
|
||||||
comment-needs\!escape
|
comment-needs\!escape
|
||||||
comment-needs\!escape
|
comment-needs\!escape
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
comment on DATABASE test1 is null;
|
||||||
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT ds.description AS database_comment
|
||||||
|
FROM pg_database d
|
||||||
|
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
||||||
|
WHERE d.datname = 'test1';
|
||||||
|
$$
|
||||||
|
);
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
drop DATABASE test1;
|
drop DATABASE test1;
|
||||||
|
|
|
@ -31,6 +31,22 @@ SELECT result FROM run_command_on_all_nodes(
|
||||||
comment-needs\!escape
|
comment-needs\!escape
|
||||||
comment-needs\!escape
|
comment-needs\!escape
|
||||||
comment-needs\!escape
|
comment-needs\!escape
|
||||||
|
(3 rows)
|
||||||
|
|
||||||
|
comment on role role1 is NULL;
|
||||||
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT ds.description AS role_comment
|
||||||
|
FROM pg_roles r
|
||||||
|
LEFT JOIN pg_shdescription ds ON r.oid = ds.objoid
|
||||||
|
WHERE r.rolname = 'role1';
|
||||||
|
$$
|
||||||
|
);
|
||||||
|
result
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(3 rows)
|
(3 rows)
|
||||||
|
|
||||||
drop role role1;
|
drop role role1;
|
||||||
|
|
|
@ -27,6 +27,17 @@ SELECT result FROM run_command_on_all_nodes(
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
|
|
||||||
|
comment on DATABASE test1 is null;
|
||||||
|
|
||||||
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT ds.description AS database_comment
|
||||||
|
FROM pg_database d
|
||||||
|
LEFT JOIN pg_shdescription ds ON d.oid = ds.objoid
|
||||||
|
WHERE d.datname = 'test1';
|
||||||
|
$$
|
||||||
|
);
|
||||||
|
|
||||||
drop DATABASE test1;
|
drop DATABASE test1;
|
||||||
reset citus.enable_create_database_propagation;
|
reset citus.enable_create_database_propagation;
|
||||||
reset citus.grep_remote_commands;
|
reset citus.grep_remote_commands;
|
||||||
|
|
|
@ -26,6 +26,17 @@ SELECT result FROM run_command_on_all_nodes(
|
||||||
$$
|
$$
|
||||||
);
|
);
|
||||||
|
|
||||||
|
comment on role role1 is NULL;
|
||||||
|
|
||||||
|
SELECT result FROM run_command_on_all_nodes(
|
||||||
|
$$
|
||||||
|
SELECT ds.description AS role_comment
|
||||||
|
FROM pg_roles r
|
||||||
|
LEFT JOIN pg_shdescription ds ON r.oid = ds.objoid
|
||||||
|
WHERE r.rolname = 'role1';
|
||||||
|
$$
|
||||||
|
);
|
||||||
|
|
||||||
drop role role1;
|
drop role role1;
|
||||||
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