pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Sebastian Siewior <lavish@kamp-dsl.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: Problem with a Pettern Matching Check
Date: Mon, 15 Aug 2005 18:43:49 -0600
Message-ID: <20050816004349.GA71850@winnie.fuhr.org> (raw)
In-Reply-To: <18684.1124151683@sss.pgh.pa.us>
References: <20050816001950.2225e5b8@mikejones.ghb.fh-furtwangen.de>
	<20050815224208.GA51332@winnie.fuhr.org>
	<18684.1124151683@sss.pgh.pa.us>

On Mon, Aug 15, 2005 at 08:21:23PM -0400, Tom Lane wrote:
> Michael Fuhr <mike@fuhr.org> 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



view thread (9+ messages)  latest in thread

Message-ID: <20050816004349.GA71850@winnie.fuhr.org>
Permalink:  ../20050816004349.GA71850@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20050816004349.GA71850@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mike@fuhr.org, tgl@sss.pgh.pa.us, lavish@kamp-dsl.de
  Subject: Re: Problem with a Pettern Matching Check
  In-Reply-To: <20050816004349.GA71850@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox