Re: select statement fails - Mailing list pgsql-general

From Andrus
Subject Re: select statement fails
Date
Msg-id ftkiap$2fco$1@news.hub.org
Whole thread Raw
In response to select statement fails  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: select statement fails  (Martijn van Oosterhout <kleptog@svana.org>)
Re: select statement fails  (Erik Jones <erik@myemma.com>)
Re: select statement fails  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
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 you.

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 ?

2.

create table test ( tc char(1) );
create index tc on test(tc);
select * from test where tc='x'::text;

I'm afraid that if test table has large number of rows, PostgreSQL is not
capable to use index for this query doe to the cast to text.
Is it so ?

Andrus.



pgsql-general by date:

Previous
From: CMOS
Date:
Subject: how to use postgre sql from inside process
Next
From: Dan99
Date:
Subject: Re: slow pgsql tables - need to vacuum?