pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: scott.marlowe <scott.marlowe@ihs.com>
Cc: elein <elein@varlena.com>
Cc: news.postgresql.org <jlim@natsoft.com.my>
Cc: pgsql-sql@postgresql.org
Subject: Re: CHAR(n) always trims trailing spaces in 7.4
Date: Tue, 17 Feb 2004 19:25:47 -0500
Message-ID: <19236.1077063947@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.33.0402171706530.31955-100000@css120.ihs.com>
References: <Pine.LNX.4.33.0402171706530.31955-100000@css120.ihs.com>

"scott.marlowe" <scott.marlowe@ihs.com> writes:
> But then this:
> select 'x'||' '||'x'
> should produce xx, but it produces x x.

No, because the imputed type of those literals is text.  You'd have to
cast the middle guy to char(n) explicitly to make its trailing spaces go
away when it's reconverted to text.

The real issue here is that trailing spaces in char(n) are semantically
insignificant according to the SQL spec.  The spec is pretty vague about
which operations should actually honor that insignificance --- it's
clear that comparisons should, less clear about other things.  I think
the 7.4 behavior is more consistent than what we had before, but I'm
willing to be persuaded to change it again if someone can give an
alternate definition that's more workable than this one.

			regards, tom lane



view thread (17+ messages)  latest in thread

Message-ID: <19236.1077063947@sss.pgh.pa.us>
Permalink:  ../19236.1077063947@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/19236.1077063947@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, scott.marlowe@ihs.com, elein@varlena.com, jlim@natsoft.com.my
  Subject: Re: CHAR(n) always trims trailing spaces in 7.4
  In-Reply-To: <19236.1077063947@sss.pgh.pa.us>

* 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