Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V8yjv-0002D3-GU for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Aug 2013 20:29:19 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V8yjv-0003bu-01 for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Aug 2013 20:29:19 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V8yjt-0003bj-Ka for pgsql-hackers@postgresql.org; Mon, 12 Aug 2013 20:29:17 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V8yjq-000404-MB for pgsql-hackers@postgresql.org; Mon, 12 Aug 2013 20:29:16 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1V8yjm-0005it-43; Mon, 12 Aug 2013 16:29:10 -0400 Date: Mon, 12 Aug 2013 16:29:10 -0400 From: Bruce Momjian To: Tom Lane Cc: amutu@amutu.com, PostgreSQL-development Subject: Re: [BUGS] BUG #8335: trim() un-document behaviour Message-ID: <20130812202910.GE12510@momjian.us> References: <20130807161953.GZ11189@momjian.us> <19166.1376060775@sss.pgh.pa.us> <20130809162359.GA3353@momjian.us> <20130812141144.GA12510@momjian.us> <21732.1376330108@sss.pgh.pa.us> <22386.1376331481@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <22386.1376331481@sss.pgh.pa.us> User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -4.7 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On Mon, Aug 12, 2013 at 02:18:01PM -0400, Tom Lane wrote: > No, wait, I take that back. I was thinking that the function call would > dump out as trim(x, y) but actually none of the underlying functions > are named just "trim"; they're btrim, ltrim, or rtrim. So actually the > dump/reload scenario does not have anything to do with the trim_list > production --- the underlying functions just parse normally in any case. Right, TRIM is really just a wrapper around btrim/rtrim/ltrim. > The question remains why it's a good idea to mess with a syntax behavior > that's been like that for a dozen years or more. I don't see any upside > to doing that. As an example of a downside, right now if you try to > pass extra arguments to TRIM() you'll get > > regression=# select trim(1,2,3); > ERROR: function pg_catalog.btrim(integer, integer, integer) does not exist > LINE 1: select trim(1,2,3); > ^ > HINT: No function matches the given name and argument types. You might need to add explicit type casts. > > You might wonder why the message mentions "btrim" not "trim", but at least > the complaint is reasonably on-topic. After this patch, you'd just get > a "syntax error" message, which doesn't seem helpful at all. Well, btrim/rtrim/ltrim only take two arguments, so allowing three for it to fail later really doesn't seem to help much, compared to a syntax error. We did have someone confused by what we have now, as well as me, so I think there is a reason to clean this up. It would be a backward-compatible change, though. To document this, I think we would need to add only one line: trim([leading | trailing | both] [characters] from string) new trim([leading | trailing | both] [from] string [, characters]) Of course, that second line is non-standard --- do we have to mention that? -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers