Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V8zWa-0004Fk-42 for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Aug 2013 21:19:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1V8zWZ-0000uh-K6 for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Aug 2013 21:19:35 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V8zWY-0000uZ-J0 for pgsql-hackers@postgresql.org; Mon, 12 Aug 2013 21:19:34 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1V8zWV-0004wP-Mf for pgsql-hackers@postgresql.org; Mon, 12 Aug 2013 21:19:33 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1V8zWU-0000MU-DN; Mon, 12 Aug 2013 17:19:30 -0400 Date: Mon, 12 Aug 2013 17:19:30 -0400 From: Bruce Momjian To: Tom Lane Cc: amutu@amutu.com, PostgreSQL-development Subject: Re: [BUGS] BUG #8335: trim() un-document behaviour Message-ID: <20130812211930.GG12510@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> <20130812202910.GE12510@momjian.us> <26073.1376341103@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="BRE3mIcgqKzpedwo" Content-Disposition: inline In-Reply-To: <26073.1376341103@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 --BRE3mIcgqKzpedwo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Aug 12, 2013 at 04:58:23PM -0400, Tom Lane wrote: > Bruce Momjian writes: > > 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. > > backward-INcompatible, I assume you meant. Yes. > > 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? > > The second line is wrong no? We don't allow the LEADING etc keywords > in the expr_list alternative. Anyway, I'm dubious that we really want > to document a nonstandard syntax --- that would just be encouraging > people to use it, to little benefit. Well, we just call trim_list rule the TRIM keyword rule, so it sure does work: SELECT trim(LEADING FROM 'abc', 'a'); ltrim ------- bc So, you are saying we should just leave it undocumented? It is true we have gotten near-zero complaints about it in the past. > Now that I've thought about this some more, I think that there was some > previous discussion around this syntax production, and that the reason > we left it like this is that we wanted to leave the door open for > user-defined trim functions that might take extra arguments. That > discussion probably predated 7.3 (when we added schemas) because the > code's current habit of forcing a "pg_catalog" prefix would make it > a little bit painful to add such functions. Still, you could do it > with superuser privileges. Not sure how strong that argument is, > but I think that's where we left it years ago. Oh, that does make sense why we had this syntax so open. Attached are docs that add the new syntax, and mention it is non-standard; you can see the output here: http://momjian.us/tmp/pgsql/functions-string.html#FUNCTIONS-STRING-SQL We do document three syntaxes for substring() in the same table, one row for each, so there is precedent for doing this. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. + --BRE3mIcgqKzpedwo Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="trim.diff" diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml new file mode 100644 index 6154621..4a4a360 *** a/doc/src/sgml/func.sgml --- b/doc/src/sgml/func.sgml *************** *** 1296,1301 **** --- 1296,1320 ---- + trim + + trim(leading | trailing + | both from + string + , characters + ) + + text + + Non-standard version of trim() + + trim(both 'x' from 'xTomxx') + Tom + + + + + upper upper(string) --BRE3mIcgqKzpedwo Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --BRE3mIcgqKzpedwo--