Commit 8402fab4 authored by Peter Eisentraut's avatar Peter Eisentraut

file_fdw: Improve error message

The hint looked a bit confusing when there were no valid options to
hint about.
parent 4ad5cbed
...@@ -230,8 +230,10 @@ file_fdw_validator(PG_FUNCTION_ARGS) ...@@ -230,8 +230,10 @@ file_fdw_validator(PG_FUNCTION_ARGS)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FDW_INVALID_OPTION_NAME), (errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
errmsg("invalid option \"%s\"", def->defname), errmsg("invalid option \"%s\"", def->defname),
errhint("Valid options in this context are: %s", buf.len > 0
buf.data))); ? errhint("Valid options in this context are: %s",
buf.data)
: errhint("There are no valid options in this context.")));
} }
/* /*
......
...@@ -114,13 +114,13 @@ SELECT * FROM text_csv; ...@@ -114,13 +114,13 @@ SELECT * FROM text_csv;
-- force_not_null is not allowed to be specified at any foreign object level: -- 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 ALTER FOREIGN DATA WRAPPER file_fdw OPTIONS (ADD force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null" 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 ALTER SERVER file_server OPTIONS (ADD force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null" 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 CREATE USER MAPPING FOR public SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null" 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 CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
ERROR: invalid option "force_not_null" ERROR: invalid option "force_not_null"
HINT: Valid options in this context are: filename, format, header, delimiter, quote, escape, null, encoding HINT: Valid options in this context are: filename, format, header, delimiter, quote, escape, null, encoding
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment