Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uNw2l-00CACs-BJ for pgsql-bugs@arkaria.postgresql.org; Sat, 07 Jun 2025 16:05:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uNw2j-00Dxnz-7k for pgsql-bugs@arkaria.postgresql.org; Sat, 07 Jun 2025 16:05:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uNw2i-00Dxnr-U3 for pgsql-bugs@lists.postgresql.org; Sat, 07 Jun 2025 16:05:13 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uNw2h-000lw7-27 for pgsql-bugs@lists.postgresql.org; Sat, 07 Jun 2025 16:05:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 557G57jI015086; Sat, 7 Jun 2025 12:05:07 -0400 From: Tom Lane To: Luke Muther cc: pgsql-bugs@lists.postgresql.org Subject: Re: Function Error Response Is Not Clear In-reply-to: References: Comments: In-reply-to Luke Muther message dated "Thu, 05 Jun 2025 22:50:23 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <15084.1749312307.1@sss.pgh.pa.us> Date: Sat, 07 Jun 2025 12:05:07 -0400 Message-ID: <15085.1749312307@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Luke Muther writes: > Some functions if they are missing the correct arguments give vague error > messages while others give specific ones. Yeah, it's difficult to move the goalposts here at reasonable cost. The functions that you are complaining about do not go through the normal parsing process for functions; instead they have hard-wired grammar productions: /* * Special expressions that are considered to be functions. */ func_expr_common_subexpr: ... | NULLIF '(' a_expr ',' a_expr ')' ... | COALESCE '(' expr_list ')' and Bison just doesn't do any better than "syntax error" if it cannot find a match in the grammar. In these particular cases we could make the grammar production more agnostic and complain about wrong-number-of-arguments in parse analysis. However that idea doesn't go very far, because most of the variants of func_expr_common_subexpr have weird SQL-spec-mandated special syntax, eg | TRIM '(' trim_list ')' ... trim_list: a_expr FROM expr_list | FROM expr_list | expr_list ; So I don't see an easy way to make more than a very small dent in the problem. If you're feeling motivated to research this and look for a better answer, please do. regards, tom lane