pgsql: Improve HINT message that FDW reports when there are no valid op - Mailing list pgsql-committers

From Fujii Masao
Subject pgsql: Improve HINT message that FDW reports when there are no valid op
Date
Msg-id E1mfOhV-0000f9-Ro@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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(-)


pgsql-committers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: pgsql: Ensure that slots are zeroed before use
Next
From: Andres Freund
Date:
Subject: Re: pgsql: Refactor the sslfiles Makefile target for ease of use