Function Error Response Is Not Clear

From: Luke Muther <lmutes8(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Function Error Response Is Not Clear
Date: 2025-06-06 02:50:23
Message-ID: CACavRX+U2mZ2-K7M=QqLOJz_tzviDdvZHVBe=AXdZxCFD4_+Dw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

To whom it may concern,

Some functions if they are missing the correct arguments give vague error
messages while others give specific ones.

Specific error message example query 1:
SELECT sum();
Specific error message example output 1:
ERROR: function sum() does not exist
LINE 1: SELECT sum();
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

Specific error message example query 2:
SELECT sum();
Specific error message example output 2:
ERROR: function lower() does not exist
LINE 1: SELECT lower();
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.

Vague error message example query 1:
SELECT nullif();
Vague error message example output 1:
ERROR: syntax error at or near ")"
LINE 1: SELECT nullif();
^

Vague error message example query 2:
SELECT nullif(1);
Vague error message example output 2:
ERROR: syntax error at or near ")"
LINE 1: SELECT nullif(1);
^

Vague error message example query 1:
SELECT coalesce();
Vague error message example output 1:
ERROR: syntax error at or near ")"
LINE 1: SELECT coalesce();
^

These examples it is clear the function is the issue, but in my actual
query there were many parentheses nearby so I thought I had mismatched
parentheses for a while and it sent me hunting for the wrong thing wasting
precious time on a production bugfix mid-crisis. I do not know if any other
function besides NULLIF and COALESCE are affected by this. They are just
the two I happened to test.

Best,
Luke

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Kapila 2025-06-06 03:21:54 Re: Logical replication 'invalid memory alloc request size 1585837200' after upgrading to 17.5
Previous Message Joseph Ayers 2025-06-05 23:08:20 Re: BUG #18940: PostgreSQL 18beta1 fails 'collate.windows.win1252' regression when building with MSYS/mingw