Improve reporting of "conflicting or redundant options" errors.
authorDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 15 Jul 2021 07:49:45 +0000 (08:49 +0100)
committerDean Rasheed <dean.a.rasheed@gmail.com>
Thu, 15 Jul 2021 07:49:45 +0000 (08:49 +0100)
commit2bfb50b3df11399ed80347dd03bfaf8cd5acf962
tree126051120d4735ba8619d4102a65e92d366f36e0
parentffc9ddaea33f6dfd3dfa95828a0970fbb617bf8a
Improve reporting of "conflicting or redundant options" errors.

When reporting "conflicting or redundant options" errors, try to
ensure that errposition() is used, to help the user identify the
offending option.

Formerly, errposition() was invoked in less than 60% of cases. This
patch raises that to over 90%, but there remain a few places where the
ParseState is not readily available. Using errdetail() might improve
the error in such cases, but that is left as a task for the future.

Additionally, since this error is thrown from over 100 places in the
codebase, introduce a dedicated function to throw it, reducing code
duplication.

Extracted from a slightly larger patch by Vignesh C. Reviewed by
Bharath Rupireddy, Alvaro Herrera, Dilip Kumar, Hou Zhijie, Peter
Smith, Daniel Gustafsson, Julien Rouhaud and me.

Discussion: https://postgr.es/m/CALDaNm33FFSS5tVyvmkoK2cCMuDVxcui=gFrjti9ROfynqSAGA@mail.gmail.com
22 files changed:
src/backend/catalog/aclchk.c
src/backend/commands/copy.c
src/backend/commands/dbcommands.c
src/backend/commands/define.c
src/backend/commands/extension.c
src/backend/commands/foreigncmds.c
src/backend/commands/functioncmds.c
src/backend/commands/publicationcmds.c
src/backend/commands/sequence.c
src/backend/commands/subscriptioncmds.c
src/backend/commands/typecmds.c
src/backend/commands/user.c
src/backend/parser/parse_utilcmd.c
src/backend/tcop/utility.c
src/include/commands/defrem.h
src/include/commands/publicationcmds.h
src/include/commands/subscriptioncmds.h
src/include/commands/typecmds.h
src/include/commands/user.h
src/test/regress/expected/copy2.out
src/test/regress/expected/foreign_data.out
src/test/regress/expected/publication.out