aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2012-05-17 20:20:33 +0300
committerPeter Eisentraut <peter_e@gmx.net>2012-05-17 20:20:33 +0300
commit8402fab4112144a039157583b7e3368b8e31db3a (patch)
tree39cb4314b38b7030c17dbc4b14c3fdd40b25d9d1
parent4ad5cbedf6ea3186a286c61a164703b107f6a138 (diff)
downloadpostgresql-8402fab4112144a039157583b7e3368b8e31db3a.tar.gz
postgresql-8402fab4112144a039157583b7e3368b8e31db3a.zip
file_fdw: Improve error message
The hint looked a bit confusing when there were no valid options to hint about.
-rw-r--r--contrib/file_fdw/file_fdw.c6
-rw-r--r--contrib/file_fdw/output/file_fdw.source6
2 files changed, 7 insertions, 5 deletions
diff --git a/contrib/file_fdw/file_fdw.c b/contrib/file_fdw/file_fdw.c
index 9ada736a48c..66fd0e62cc8 100644
--- a/contrib/file_fdw/file_fdw.c
+++ b/contrib/file_fdw/file_fdw.c
@@ -230,8 +230,10 @@ file_fdw_validator(PG_FUNCTION_ARGS)
ereport(ERROR,
(errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
errmsg("invalid option \"%s\"", def->defname),
- errhint("Valid options in this context are: %s",
- buf.data)));
+ buf.len > 0
+ ? errhint("Valid options in this context are: %s",
+ buf.data)
+ : errhint("There are no valid options in this context.")));
}
/*
diff --git a/contrib/file_fdw/output/file_fdw.source b/contrib/file_fdw/output/file_fdw.source
index 84f07501a04..6f906e1fc8c 100644
--- a/contrib/file_fdw/output/file_fdw.source
+++ b/contrib/file_fdw/output/file_fdw.source
@@ -114,13 +114,13 @@ SELECT * FROM text_csv;
-- force_not_null is not allowed to be specified at any foreign object level:
ALTER FOREIGN DATA WRAPPER file_fdw OPTIONS (ADD force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null"
-HINT: Valid options in this context are:
+HINT: There are no valid options in this context.
ALTER SERVER file_server OPTIONS (ADD force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null"
-HINT: Valid options in this context are:
+HINT: There are no valid options in this context.
CREATE USER MAPPING FOR public SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null"
-HINT: Valid options in this context are:
+HINT: There are no valid options in this context.
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null"
HINT: Valid options in this context are: filename, format, header, delimiter, quote, escape, null, encoding