From: Fujii Masao <fujii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Improve HINT message that FDW reports when there are no valid op
Date: Tue, 26 Oct 2021 15:49:21 +0000
Message-ID: <E1mfOhV-0000f9-Ro@gemulon.postgresql.org> (raw)
Improve HINT message that FDW reports when there are no valid options.
The foreign data wrapper's validator function provides a HINT message with
list of valid options for the object specified in CREATE or ALTER command,
when the option given in the command is invalid. Previously
postgresql_fdw_validator() and the validator functions for postgres_fdw and
dblink_fdw worked in that way even there were no valid options in the object,
which could lead to the HINT message with empty list (because there were
no valid options). For example, ALTER FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (format 'csv') reported the following ERROR and HINT messages.
This behavior was confusing.
ERROR: invalid option "format"
HINT: Valid options in this context are:
There is no such issue in file_fdw. The validator function for file_fdw
reports the HINT message "There are no valid options in this context."
instead in that case.
This commit improves postgresql_fdw_validator() and the validator functions
for postgres_fdw and dblink_fdw so that they do likewise. For example,
this change causes the above ALTER FOREIGN DATA WRAPPER command to
report the following messages.
ERROR: invalid option "nonexistent"
HINT: There are no valid options in this context.
Author: Kosei Masumura
Reviewed-by: Bharath Rupireddy, Fujii Masao
Discussion: https://postgr.es/m/557d06cebe19081bfcc83ee2affc98d3@oss.nttdata.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/5fedf7417b69295294b154a219edd8a26eaa6ab6
Modified Files
--------------
contrib/dblink/dblink.c | 6 ++++--
contrib/dblink/expected/dblink.out | 4 ++++
contrib/dblink/sql/dblink.sql | 3 +++
contrib/postgres_fdw/expected/postgres_fdw.out | 6 +++++-
contrib/postgres_fdw/option.c | 6 ++++--
contrib/postgres_fdw/sql/postgres_fdw.sql | 5 ++++-
src/backend/foreign/foreign.c | 6 ++++--
src/test/regress/expected/foreign_data.out | 3 +++
src/test/regress/sql/foreign_data.sql | 2 ++
9 files changed, 33 insertions(+), 8 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: fujii@postgresql.org
Subject: Re: pgsql: Improve HINT message that FDW reports when there are no valid op
In-Reply-To: <E1mfOhV-0000f9-Ro@gemulon.postgresql.org>
References: <E1mfOhV-0000f9-Ro@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox