You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by jo...@apache.org on 2022/08/22 15:38:07 UTC
[age] branch master updated: Graph names with empty string '' are no more allowed. (#251)
This is an automated email from the ASF dual-hosted git repository.
joshinnis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/age.git
The following commit(s) were added to refs/heads/master by this push:
new dbc4584 Graph names with empty string '' are no more allowed. (#251)
dbc4584 is described below
commit dbc4584786655f848cf698a04713f47bb73f8ca9
Author: Shoaib <mu...@gmail.com>
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 8a83f45..4fca3e6 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 6bc1981..59a720f 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 c298324..bb21f8a 100644
--- a/src/backend/commands/graph_commands.c
+++ b/src/backend/commands/graph_commands.c
@@ -67,11 +67,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,
@@ -158,7 +165,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);