Re: BUG #16726: Invalid input syntax is not a useful error message - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #16726: Invalid input syntax is not a useful error message
Date
Msg-id 20201119133135.GA31339@alvherre.pgsql
Whole thread Raw
In response to BUG #16726: Invalid input syntax is not a useful error message  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
On 2020-Nov-18, PG Bug reporting form wrote:

> I also tried curly braces ( as suggested by your awful documentation ), but
> this just leads to 
> `syntax error at or near "{"`

Actually, curly braces work just fine:

=# create table users (some_uuid_field uuid);
CREATE TABLE

=# insert into users values ('{dec3d6c4-c32e-45c6-0000-1eae3df44fbf}');
INSERT 0 1

(I fixed the broken UUID value, obviously.)

The problem with that, I suspect, is that you *replaced* the
single-quote delimiters with braces, rather than *add* the braces inside
the quoted literal.  That's what gives the error message you suggest:

=# insert into users values ({dec3d6c4-c32e-45c6-0000-1eae3df44fbf});
ERROR:  syntax error at or near "{"
LÍNEA 1: insert into users values ({dec3d6c4-c32e-45c6-0000-1eae3df44...
                                   ^


> What I want:

> b) That your error messages FOR ONCE are not useless and tell me the
> expected syntax, you are wasting millions of hours of developer time and
> human life, because you can not be asked to make useful error messages.

I think you're suggesting something like this:

insert into users values ('{dec3d6c4-c32e-45c6-000-1eae3df44fbf}');
ERROR:  invalid input syntax for type uuid: "{dec3d6c4-c32e-45c6-000-1eae3df44fbf}"
LÍNEA 1: insert into users values ('{dec3d6c4-c32e-45c6-000-1eae3df44...
                                   ^
HINT: Valid UUID values are of the form 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'.

This is not impossible, but I think it'd be overkill, and it fails to
convey that there are other possible formats (if we tried to list them
all, it'd be pretty cumbersome).  Would this be really all that
valuable?

However, before embarking on such an implementation, you would certainly
owe this group an apology for your rudeness and an admission that we do
spend a lot of time producing pretty decent error messages most of the
time.



pgsql-bugs by date:

Previous
From: Andres Freund
Date:
Subject: Re: BUG #16722: PG hanging on COPY when table has close to 2^32 toasts in the table.
Next
From: PG Bug reporting form
Date:
Subject: BUG #16730: Create table like with inheritance and self referencing index