I don't understand why these functions behave differently. The fact that they have a different arity shouldn't affect my ability to quote them.

janus@janus-ux305ca ~ % psql
psql (14.11 (Debian 14.11-1.pgdg110+1))
Type "help" for help.

janus=> select least(1,2);
(1 row)

janus=> select "least"(1,2);
ERROR:  function least(integer, integer) does not exist
LINE 1: select "least"(1,2);
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
janus=> select "count"(1);
(1 row)

What is the correct terminology that explains the difference in behaviour?


1 Answer 1


LEAST (and GREATEST, and COALESCE, etc.) are not SQL functions, this is why they are listed in the "Conditional expressions" section of the manual. Subsequently, the SQL quoting rules do not apply to them; they're much like the other SQL keywords.

Figuring out why the Postgres developers chose to implement them in this manner, I'll leave as an excercie for the reader (or an opportunity for one of them to answer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.