Re: chr(3) and 3::text - Mailing list pgsql-novice

From Tom Lane
Subject Re: chr(3) and 3::text
Date
Msg-id 5568.1585411346@sss.pgh.pa.us
Whole thread Raw
In response to Re: chr(3) and 3::text  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-novice
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Sat, Mar 28, 2020 at 8:09 AM gmail Vladimir Koković <
> vladimir.kokovic@gmail.com> wrote:
>> Main question is, why is 3::text == '3' ?

> Its that way because :: is defined to make it that way.

More concretely: for most types, casting to text is defined to produce the
textual representation of the value.  An unadorned literal 3 starts life
as type integer, so what you've got here is an integer-to-text cast,
and that's going to convert the integer the same way it would be output.

            regards, tom lane



pgsql-novice by date:

Previous
From: gmail Vladimir Koković
Date:
Subject: Re: chr(3) and 3::text
Next
From: "David G. Johnston"
Date:
Subject: Re: chr(3) and 3::text