diff --git a/regress/expected/catalog.out b/regress/expected/catalog.out index 8a83f45a6..4fca3e6ab 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 6bc19814c..59a720f06 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 c298324c8..bb21f8a9c 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);