Re: String literal doesn't autocast to text type

From: Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: String literal doesn't autocast to text type
Date: 2016-03-04 18:29:05
Message-ID: 06D13A01-78AE-42B3-BB11-0EEAE89F0A80@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> On 04 Mar 2016, at 21:08, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Alex Ignatov <a(dot)ignatov(at)postgrespro(dot)ru> writes:
>> Why string literal like 'Hello world!' doesnt automagicaly cast to text
>> type?
>
> Because it's not necessarily a string. It might be meant to be point,
> or json, or any number of other types.
>
>> Sure we can create our cast:
>> postgres=# create cast (unknown as text) with inout as implicit;
>> CREATE CAST
>
> That's a seriously bad idea; it will have all sorts of corner-case
> effects that you aren't expecting.
>
> There has been some talk of forcing unknown to text in the output
> columns of a sub-SELECT, which would fix the example you show with
> a lot less risk of side-effects elsewhere. But it's not exactly
> trivial because of interactions with INSERT ... SELECT.
>
> regards, tom lane
Oh! Thank you , Tom!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2016-03-04 18:33:40 Re: multiple UNIQUE indices for FK
Previous Message Alex Ignatov 2016-03-04 18:24:03 Re: String literal doesn't autocast to text type