Re: BUG #12458: Comparison with CHAR is inconsistent between string types - Mailing list pgsql-bugs

From Amit Langote
Subject Re: BUG #12458: Comparison with CHAR is inconsistent between string types
Date
Msg-id CA+HiwqHjF2JW7E1LhK4UXEnWhOxMcMV7ke+ensode-eH8yz+cg@mail.gmail.com
Whole thread Raw
In response to BUG #12458: Comparison with CHAR is inconsistent between string types  (tneumann@users.sourceforge.net)
Responses Re: BUG #12458: Comparison with CHAR is inconsistent between string types  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Thu, Jan 8, 2015 at 6:39 AM,  <tneumann@users.sourceforge.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

pgsql-bugs by date:

Previous
From: David G Johnston
Date:
Subject: Re: BUG #12460: Extracting epoch from timestamp string incorrectly assumes "with time zone"
Next
From: mingli
Date:
Subject: How to init a new BuildFarm Server on my linux system