Skip site navigation (1) Skip section navigation (2)

Re: BUG #4939: error query result

From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: "limaozeng" <limaozeng(at)163(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4939: error query result
Date: 2009-07-24 03:35:27
Message-ID: 20090724122233.93EC.52131E4D@oss.ntt.co.jp (view raw or flat)
Thread:
Lists: pgsql-bugs
"limaozeng" <limaozeng(at)163(dot)com> wrote:

> select * from t where str in (user, 'abc...ijk');
>     str                                                      
> -----------
>  mzli
>  abc...xyz
> (2 rows)
> 
> only 'mzli' ought to be appeared in the result list.

Your query is interpreted as
  select * from t::name where str in (user::name, 'abc...ijk'::name);

Strings are truncated in 63 bytes by casting to "name" type,
and the first 63 bytes of unexpected row matched the head
of values in the IN clause.

It should work if you cast "user" to text type.
=# select * from t where str in (user::text, 'abc...ijk');

The result might be a designed behavior, but is very surprising.
What should we care for it?

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center



In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2009-07-24 05:02:00
Subject: Re: BUG #4939: error query result
Previous:From: limaozengDate: 2009-07-24 01:50:55
Subject: BUG #4939: error query result

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group