Re: Change error code for hstore syntax error - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Change error code for hstore syntax error
Date
Msg-id 32686.1457725746@sss.pgh.pa.us
Whole thread Raw
In response to Change error code for hstore syntax error  (Sherrylyn Branchaw <sbranchaw@gmail.com>)
Responses Re: Change error code for hstore syntax error  (Sherrylyn Branchaw <sbranchaw@gmail.com>)
List pgsql-hackers
Sherrylyn Branchaw <sbranchaw@gmail.com> writes:
> The hstore module uses elog() to default to ERRCODE_INTERNAL_ERROR
> (SQLSTATE XX000) when the error message reads "Syntax error near '%c' at
> position %d".

Yeah, that is entirely bogus.  No user-facing error report should ever
return ERRCODE_INTERNAL_ERROR.

> I propose to switch to ereport() to return ERRCODE_SYNTAX_ERROR (SQLSTATE
> 42601), on the grounds that it's more transparent.

Hm, class 42 is generally meant for SQL-level syntax errors.  Are these
errors not coming from subroutines of hstore_in()?  I think our usual
convention is to use ERRCODE_INVALID_TEXT_REPRESENTATION for complaints
that a data value does not meet its type's conventions.  In any case
it seems closer to class 22 than 42.

While you're at it, please make the error message texts conform to
our style guidelines:
http://www.postgresql.org/docs/devel/static/error-style-guide.html

These seem to have multiple problems, starting with incorrect
capitalization and extending to failure to quote the whole string
being complained of.

In short, though, +1 for improving this stuff.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Sherrylyn Branchaw
Date:
Subject: Change error code for hstore syntax error
Next
From: Salvador Fandiño
Date:
Subject: Saving SRF context