X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 643365288A for ; Mon, 15 Aug 2005 21:43:54 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80314-07 for ; Tue, 16 Aug 2005 00:43:52 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 6EEFB528B4 for ; Mon, 15 Aug 2005 21:43:51 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7G0hoPH004297 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Aug 2005 18:43:52 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7G0hnOZ071908; Mon, 15 Aug 2005 18:43:49 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7G0hncw071907; Mon, 15 Aug 2005 18:43:49 -0600 (MDT) (envelope-from mfuhr) Date: Mon, 15 Aug 2005 18:43:49 -0600 From: Michael Fuhr To: Tom Lane Cc: Sebastian Siewior , pgsql-sql@postgresql.org Subject: Re: Problem with a Pettern Matching Check Message-ID: <20050816004349.GA71850@winnie.fuhr.org> References: <20050816001950.2225e5b8@mikejones.ghb.fh-furtwangen.de> <20050815224208.GA51332@winnie.fuhr.org> <18684.1124151683@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18684.1124151683@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/107 X-Sequence-Number: 22335 On Mon, Aug 15, 2005 at 08:21:23PM -0400, Tom Lane wrote: > Michael Fuhr writes: > > The CHAR(3) specification causes the value to be space-padded, so > > '1' becomes '1 ' (the digit "one" followed by two spaces). > > Actually, we seem to be going out of our way to make this case fail. > Given that we consider trailing spaces in char(n) to be semantically > insignificant, would it make sense to strip them before doing the > regex pattern match? How standards-compliant would that be? Does the standard specify what should happen when using SIMILAR TO with a char(n) value? I notice that equality and SQL regular expressions treat trailing spaces differently -- is that intentional or accidental? CREATE TABLE foo (test char(3)); INSERT INTO foo VALUES ('1'); SELECT test, test = '1', test SIMILAR TO '1' FROM foo; test | ?column? | ?column? ------+----------+---------- 1 | t | f (1 row) SELECT test, test = '1 ', test SIMILAR TO '1 ' FROM foo; test | ?column? | ?column? ------+----------+---------- 1 | t | t (1 row) > That would happen automatically if we allowed > the char(n) value to promote to text --- and the only reason it's > not doing so is that there's an extra ~ operator definition that > specifically prevents that (bpcharregexeq). "bpcharregexeq" -- didn't Philip Glass write the score to that? -- Michael Fuhr