Re: select statement fails

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: select statement fails
Date: 2008-04-10 08:13:33
Message-ID: ftkiap$2fco$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shane Ambler 2008-04-10 08:37:23 Re: include PostgreSQL utilities into 3rd party program package
Previous Message laser 2008-04-10 08:03:15 visibility rule in a EXECUTE with multi sql