Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V7pU6-0005nG-S2 for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Aug 2013 16:24:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V7pU6-0004yD-8z for pgsql-bugs@arkaria.postgresql.org; Fri, 09 Aug 2013 16:24:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V7pU5-0004y6-Cx for pgsql-bugs@postgresql.org; Fri, 09 Aug 2013 16:24:13 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V7pTx-0006Az-LC for pgsql-bugs@postgresql.org; Fri, 09 Aug 2013 16:24:12 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1V7pTr-0003ng-G9; Fri, 09 Aug 2013 12:23:59 -0400 Date: Fri, 9 Aug 2013 12:23:59 -0400 From: Bruce Momjian To: Tom Lane Cc: amutu@amutu.com, pgsql-bugs@postgresql.org Subject: Re: BUG #8335: trim() un-document behaviour Message-ID: <20130809162359.GA3353@momjian.us> References: <20130807161953.GZ11189@momjian.us> <19166.1376060775@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19166.1376060775@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Fri, Aug 9, 2013 at 11:06:15AM -0400, Tom Lane wrote: > Bruce Momjian writes: > > The attached patch swaps the arguments in the parser, and allows your > > expected behavior: > > This patch is completely unsafe. It will break stored rules, which may > contain calls using the existing argument order (which will be dumped > without any of the SQL-spec syntactic sugar). To say nothing of existing > applications that may be relying on calling the underlying functions with > their existing argument order. > > The inconsistency in argument order is unfortunate but we're long since > stuck with it, I'm afraid. Yes, I have thought about this some more and another problem is that rtrim/btrim/ltrim() use the source string first, so having trim() have the source string second when using a comma is very confusing, e.g.: -- with patch SELECT trim('x', 'xabcx'); btrim ------- abc -- btrim SELECT btrim('xabcx', 'x'); btrim ------- abc I think we can either document what we have, or remove the ability to use comma with trim(). If we go with documentation, it is going to look confusing as the optional modifier is going to be on the source string, e.g.: SELECT trim(both 'xabcx', 'x'); btrim ------- abc We could modify the grammar to force the modifier on the second argument, but that is more parser states for limited value. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs