Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-06-03 Thread elein
Apparently the ::char is cast to varchar and then text? That explains x || ' ' || x On Tue, Feb 17, 2004 at 05:07:24PM -0700, scott.marlowe wrote: > On Tue, 17 Feb 2004, Tom Lane wrote: > > > elein <[EMAIL PROTECTED]> writes: > > > This is an example of the problem. It used to expand > > > the m

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-19 Thread Tom Lane
elein <[EMAIL PROTECTED]> writes: > Somewhere the space trimming occurs. The cast from char(n) to text (or varchar) is what's doing the trimming in 7.4. I think you can mostly revert the change by changing that pg_cast entry to specify no conversion function instead of rtrim(). However that would

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-19 Thread elein
I guess I am asking about the cast sequence from char(n) to text. (' '::char(n))::text trims spaces. This is wrong, imo. ' '::text does not trim spaces. ' '::char(n) does not trim spaces and pads. char(n) should not trim spaces, right? And it doesn't on an inser

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread Tom Lane
elein <[EMAIL PROTECTED]> writes: > So exactly what is the order of casts that produces > different results with: > 'x' || ' ' || 'x' and 'x' || ' '::char15 || 'x' > Are operators being invoked both (text,text)? The only relevant operator is "text || text" (there are also some || operators

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread elein
So exactly what is the order of casts that produces different results with: 'x' || ' ' || 'x' and 'x' || ' '::char15 || 'x' Are operators being invoked both (text,text)? I'm trying to understand the precedence that causes the different results. elein On Tue, Feb 17, 2004 at 10:53:17PM

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread Jeremy Smith
eremy -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Richard Huxton Sent: Wednesday, February 18, 2004 4:40 AM To: Tom Lane; scott.marlowe Cc: elein; news.postgresql.org; [EMAIL PROTECTED] Subject: Re: [SQL] CHAR(n) always trims trailing spaces in 7.4 On Wednes

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > I've never really understood the rationale behind char(n) in SQL databases > (other than as backward compatibility with some old mainframe DB). There are (or were) systems in which the benefit of using fixed-width columns is a lot higher than it is in

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread Richard Huxton
On Wednesday 18 February 2004 00:25, Tom Lane wrote: > "scott.marlowe" <[EMAIL PROTECTED]> 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) expl

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread Tom Lane
elein <[EMAIL PROTECTED]> writes: > Apparently the ::char is cast to varchar and then text? No, directly to text, because the || operator is defined as taking text inputs. But there's no practical difference between text and varchar on this point. regards, tom lane -

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread terry
From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of scott.marlowe > Sent: Tuesday, February 17, 2004 7:07 PM > To: Tom Lane > Cc: elein; news.postgresql.org; [EMAIL PROTECTED] > Subject: Re: [SQL] CHAR(n) always trims trailing spaces in 7.4 > > > On Tue, 17 Feb 2004,

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread Tom Lane
"scott.marlowe" <[EMAIL PROTECTED]> 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 t

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread scott.marlowe
On Tue, 17 Feb 2004, Tom Lane wrote: > elein <[EMAIL PROTECTED]> writes: > > This is an example of the problem. It used to expand > > the middle thing to 15. > > > elein=# select 'x' || ' '::char(15) || 'x'; > > ?column? > > -- > > xx > > (1 row) > > Still does, but then the spaces g

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread elein
So the problem is there. But blaming it on char was wrong. It should be blamed on the varchar change. Hey, I thought the truncation was for varchar and not text? It was for both? It would be semantically tricky to change the operator. The precendence is to convert to text. Now with the implicit

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread Tom Lane
elein <[EMAIL PROTECTED]> writes: > This is an example of the problem. It used to expand > the middle thing to 15. > elein=# select 'x' || ' '::char(15) || 'x'; > ?column? > -- > xx > (1 row) Still does, but then the spaces go away again when the value goes into the concatenation, bec

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread elein
This is an example of the problem. It used to expand the middle thing to 15. elein=# select 'x' || ' '::char(15) || 'x'; ?column? -- xx (1 row) On Tue, Feb 17, 2004 at 06:10:56PM -0500, Tom Lane wrote: > "news.postgresql.org" <[EMAIL PROTECTED]> writes: > > I just discovered the foll

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread Tom Lane
"news.postgresql.org" <[EMAIL PROTECTED]> writes: > I just discovered the following change to CHAR(n) (taken from varlena.com, > general bits, issue 62). The description you quote doesn't appear to have much of anything to do with the actual behavior of 7.4. 7.4 will trim trailing spaces when con

[SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread news.postgresql.org
Hello, I just discovered the following change to CHAR(n) (taken from varlena.com, general bits, issue 62). This will cause me serious heart-ache, back-ache and bug-ache if we upgrade to 7.4. Is there any compatibility flag available to use pre-7.4 behaviour for CHAR(n)? Regards, John ==