Improved error reporting in format()

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Improved error reporting in format()
Date: 2016-01-02 23:57:48
Message-ID: 568863FC.9030209@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The current error message for an invalid format conversion type is
extremely confusing except in the simplest of uses:

select format( '% moo');
ERROR: unrecognized conversion type specifier " "

Obviously in that example you can figure out what's going on, but
frequently format() is used in a complex context where it's not at all
obvious that format is the problem. Even worse, "conversion" makes it
sound like a localization issue.

Attached patch clarifies that %-related error messages with hints as
well as (IMHO) improving the clarity of the message:

select format( '% moo');
ERROR: unrecognized format() type specifier " "
HINT: For a single "%" use "%%"

I also made the use of "format()" consistent in all the other error
messages.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com

Attachment Content-Type Size
patch.diff text/plain 1.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2016-01-03 00:13:00 Re: Fwd: Core dump with nested CREATE TEMP TABLE
Previous Message Andres Freund 2016-01-02 21:31:49 Re: Some 9.5beta2 backend processes not terminating properly?