Re: Enhanced error message to include hint messages for redundant options error

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: vignesh C <vignesh21@gmail.com>
Cc: "houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Dilip Kumar <dilipbalaut@gmail.com>
Date: 2021-05-12T23:28:23Z
Lists: pgsql-hackers
You can avoid duplicating the ereport like this:

+               ereport(ERROR,
+                               (errcode(ERRCODE_SYNTAX_ERROR),
+                                errmsg("option \"%s\" specified more than once", defel->defname),
+                                parser ? parser_errposition(pstate, defel->location) : 0));

... also, since e3a87b4991cc you can now elide the parens around the
auxiliary function calls:

+        ereport(ERROR,
+                errcode(ERRCODE_SYNTAX_ERROR),
+                errmsg("option \"%s\" specified more than once", defel->defname),
+                parser ? parser_errposition(pstate, defel->location) : 0));

Please do add a pg_attribute_noreturn() decorator.  I'm not sure if any
compilers will complain about the code flow if you have that, but I
expect many (all?) will if you don't.

-- 
Álvaro Herrera       Valdivia, Chile
"Java is clearly an example of money oriented programming"  (A. Stepanov)



Commits

  1. Improve reporting of "conflicting or redundant options" errors.

  2. Refactor function parse_subscription_options.