This is an automated email from the ASF dual-hosted git repository. jgemignani pushed a commit to branch PG12 in repository https://gitbox.apache.org/repos/asf/age.git
commit fd49347a685b5d6f05fc3b781b5ad46bf4901716 Author: Shoaib <[email protected]> AuthorDate: Mon Aug 22 17:38:01 2022 +0200 Graph names with empty string '' are no more allowed. (#251) --- regress/expected/catalog.out | 6 ++++-- regress/sql/catalog.sql | 2 +- src/backend/commands/graph_commands.c | 11 +++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/regress/expected/catalog.out b/regress/expected/catalog.out index 19ef801..f2b2965 100644 --- a/regress/expected/catalog.out +++ b/regress/expected/catalog.out @@ -97,9 +97,11 @@ SELECT count(*) FROM pg_namespace WHERE nspname = 'g'; -- invalid cases SELECT create_graph(NULL); -ERROR: graph name must not be NULL +ERROR: graph name can not be NULL SELECT drop_graph(NULL); -ERROR: graph name must not be NULL +ERROR: graph name can not be NULL +SELECT create_graph(''); +ERROR: graph name can not be empty -- -- alter_graph() RENAME function tests -- diff --git a/regress/sql/catalog.sql b/regress/sql/catalog.sql index 641ef2e..306a7a5 100644 --- a/regress/sql/catalog.sql +++ b/regress/sql/catalog.sql @@ -52,7 +52,7 @@ SELECT count(*) FROM pg_namespace WHERE nspname = 'g'; -- invalid cases SELECT create_graph(NULL); SELECT drop_graph(NULL); - +SELECT create_graph(''); -- -- alter_graph() RENAME function tests -- diff --git a/src/backend/commands/graph_commands.c b/src/backend/commands/graph_commands.c index 6ef0b3c..28052f7 100644 --- a/src/backend/commands/graph_commands.c +++ b/src/backend/commands/graph_commands.c @@ -66,11 +66,18 @@ Datum create_graph(PG_FUNCTION_ARGS) if (PG_ARGISNULL(0)) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("graph name must not be NULL"))); + errmsg("graph name can not be NULL"))); } graph_name = PG_GETARG_NAME(0); graph_name_str = NameStr(*graph_name); + + if (strlen(graph_name_str) == 0) + { + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("graph name can not be empty"))); + } if (graph_exists(graph_name_str)) { ereport(ERROR, @@ -157,7 +164,7 @@ Datum drop_graph(PG_FUNCTION_ARGS) if (PG_ARGISNULL(0)) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), - errmsg("graph name must not be NULL"))); + errmsg("graph name can not be NULL"))); } graph_name = PG_GETARG_NAME(0); cascade = PG_GETARG_BOOL(1);
