Re: [GENERAL] select statement fails

2008-04-10 Thread Tom Lane
"Andrus" <[EMAIL PROTECTED]> writes: > 1. SQL assumes that CHARACTER(n) column is always padded with spaces in > right. > So casting to text should preserve spaces. No, it should not. In CHAR(n), trailing spaces are semantically insignificant; 'foo' and 'foo ' are considered equal. In TEXT they

Re: [GENERAL] select statement fails

2008-04-10 Thread Erik Jones
On Apr 10, 2008, at 3:13 AM, Andrus wrote: Albe, select * from test where tc=' '::text; Because the arguments to the operator "=" are of different type, implicit type conversion takes place. "character(1)" will by converted to "text", during this conversion trailing blanks will be ignored, as

Re: [GENERAL] select statement fails

2008-04-10 Thread Martijn van Oosterhout
On Thu, Apr 10, 2008 at 11:13:33AM +0300, Andrus wrote: > 1. SQL assumes that CHARACTER(n) column is always padded with spaces in > right. > So casting to text should preserve spaces. > Why PostgreSQL cast to text violates SQL ? It says it is padded with spaces, but it also says that these spaces

Re: [GENERAL] select statement fails

2008-04-10 Thread Andrus
Albe, >> select * from test where tc=' '::text; >Because the arguments to the operator "=" are of different type, >implicit type conversion takes place. >"character(1)" will by converted to "text", during this conversion >trailing blanks will be ignored, as befits the "character(n)" type. Thank y

Re: [GENERAL] select statement fails

2008-04-09 Thread Francisco Figueiredo Jr.
On Wed, Apr 9, 2008 at 1:31 PM, Francisco Figueiredo Jr. <[EMAIL PROTECTED]> wrote: > > > > > > > > > > Ask the .npgsql mailing lists. They'll be able to tell you. There must be > a > > way of handling "non-standard" types in any case. > > > > Hi all! > > We are already working on that. Th

Re: [GENERAL] select statement fails

2008-04-09 Thread Francisco Figueiredo Jr.
> > > > > > Ask the .npgsql mailing lists. They'll be able to tell you. There must be a > way of handling "non-standard" types in any case. > Hi all! We are already working on that. The cast problem is indeed a bug in Npgsql. We already have a one line fix for it. Check it out here: http://pgf

Re: [GENERAL] select statement fails

2008-04-09 Thread Richard Huxton
Andrus wrote: ALTER TABLE...ALTER COLUMN...TYPE will do it within one statement. It will require a lock on the table though. 1. This is part of composite primary key. It is discriminator column and cannot contain empty string, only single char is allowed. char(1) doesn't enforce that. It enf

Re: [GENERAL] select statement fails

2008-04-09 Thread Andrus
> ALTER TABLE...ALTER COLUMN...TYPE will do it within one statement. It will > require a lock on the table though. 1. This is part of composite primary key. It is discriminator column and cannot contain empty string, only single char is allowed. 2. I'm afraid that this will broke existing applic

Re: [GENERAL] select statement fails

2008-04-09 Thread Albe Laurenz
Andrus wrote: > Any idea why the following select statement does not return rows ? > This select statement is generated by npgsql2 beta 3 so I > cannot change it in my application. > How to fix without changing select statement ? > > Andrus. > > create temp table test ( tc char(1) ); > insert int

Re: [GENERAL] select statement fails

2008-04-09 Thread Richard Huxton
Andrus Moor wrote: Richard, It doesn't return rows because you're using a space-padded type (char) to try and store a space. I think you probably want varchar(1) instead. thank you. I have production database whose schema cannot changed easily. ALTER TABLE...ALTER COLUMN...TYPE will do it

Re: [GENERAL] select statement fails

2008-04-09 Thread Richard Huxton
Andrus wrote: Any idea why the following select statement does not return rows ? This select statement is generated by npgsql2 beta 3 so I cannot change it in my application. How to fix without changing select statement ? Andrus. create temp table test ( tc char(1) ); insert into test values(

[GENERAL] select statement fails

2008-04-09 Thread Andrus
Any idea why the following select statement does not return rows ? This select statement is generated by npgsql2 beta 3 so I cannot change it in my application. How to fix without changing select statement ? Andrus. create temp table test ( tc char(1) ); insert into test values(' '); select * fr