Re: select statement fails - Mailing list pgsql-general

From Albe Laurenz
Subject Re: select statement fails
Date
Msg-id D960CB61B694CF459DCFB4B0128514C201FA5AB9@exadv11.host.magwien.gv.at
Whole thread Raw
In response to select statement fails  ("Andrus" <kobruleht2@hot.ee>)
List pgsql-general
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(' ');
> 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.

You can get what you probably want by:

create temp table test ( tc varchar(1) );

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: "Albe Laurenz"
Date:
Subject: Re: wrong query result
Next
From: "Markus Wollny"
Date:
Subject: Re: tsvector_update_trigger throws error "column is not of tsvector type"