Re: BUG #12458: Comparison with CHAR is inconsistent between string types

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: tneumann(at)users(dot)sourceforge(dot)net
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #12458: Comparison with CHAR is inconsistent between string types
Date: 2015-01-08 08:07:38
Message-ID: CA+HiwqHjF2JW7E1LhK4UXEnWhOxMcMV7ke+ensode-eH8yz+cg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jan 8, 2015 at 6:39 AM, <tneumann(at)users(dot)sourceforge(dot)net> wrote:
> The following two queries return different results:
>
> select 'A'::char(1)='A '::text;
> select 'A'::char(1)='A '::varchar(10);
>
> I would expect both queries to return "true", and this is also suggested by
> the documentation (section 8.3.), but the text comparison returns false.
>

Quick inspection of pg_operator suggests there is no '=' operator that
takes varchar as either of the operands. Not sure why that is so. It
appears the comparison proceeds using =(char, char) operator with the
varchar operand appropriately coerced. Hence the result.

Thanks,
Amit

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message john.reilly 2015-01-08 14:10:57 BUG #12461: Incorrect PSQL User Login in Windows
Previous Message mingli 2015-01-08 07:27:55 How to init a new BuildFarm Server on my linux system