Skip to content

Commit 8402fab

Browse files
committed
file_fdw: Improve error message
The hint looked a bit confusing when there were no valid options to hint about.
1 parent 4ad5cbe commit 8402fab

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

contrib/file_fdw/file_fdw.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,10 @@ file_fdw_validator(PG_FUNCTION_ARGS)
230230
ereport(ERROR,
231231
(errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
232232
errmsg("invalid option \"%s\"", def->defname),
233-
errhint("Valid options in this context are: %s",
234-
buf.data)));
233+
buf.len > 0
234+
? errhint("Valid options in this context are: %s",
235+
buf.data)
236+
: errhint("There are no valid options in this context.")));
235237
}
236238

237239
/*

contrib/file_fdw/output/file_fdw.source

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ SELECT * FROM text_csv;
114114
-- force_not_null is not allowed to be specified at any foreign object level:
115115
ALTER FOREIGN DATA WRAPPER file_fdw OPTIONS (ADD force_not_null '*'); -- ERROR
116116
ERROR: invalid option "force_not_null"
117-
HINT: Valid options in this context are:
117+
HINT: There are no valid options in this context.
118118
ALTER SERVER file_server OPTIONS (ADD force_not_null '*'); -- ERROR
119119
ERROR: invalid option "force_not_null"
120-
HINT: Valid options in this context are:
120+
HINT: There are no valid options in this context.
121121
CREATE USER MAPPING FOR public SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
122122
ERROR: invalid option "force_not_null"
123-
HINT: Valid options in this context are:
123+
HINT: There are no valid options in this context.
124124
CREATE FOREIGN TABLE tbl () SERVER file_server OPTIONS (force_not_null '*'); -- ERROR
125125
ERROR: invalid option "force_not_null"
126126
HINT: Valid options in this context are: filename, format, header, delimiter, quote, escape, null, encoding

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy