Re: Allowing implicit 'text' -> xml|json|jsonb (was: PL/pgSQL 2) - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: Allowing implicit 'text' -> xml|json|jsonb (was: PL/pgSQL 2)
Date
Msg-id CAHyXU0yFjaAga1awQgbAEzLHLveC3TUMcEf1Fht=WVhscjFynQ@mail.gmail.com
Whole thread Raw
In response to Re: Allowing implicit 'text' -> xml|json|jsonb (was: PL/pgSQL 2)  (Craig Ringer <craig@2ndquadrant.com>)
List pgsql-hackers
On Fri, Sep 5, 2014 at 2:04 AM, Craig Ringer <craig@2ndquadrant.com> wrote:
> On 09/05/2014 12:04 AM, Pavel Stehule wrote:
>>
>> But some missing casts are well - I found lot performance issues based
>> on using wrong data types - integers, dates in text column.
>
> Of course! That's why the default implicit casts were removed, and for
> good reason. I'm only talking about a narrow class of a few specific types.
>
> I think maybe a _few_ types need to be implicitly convertable from text,
> but that's about it.
>
> text -> jsonb
> text -> json
> text -> xml
> text -> hstore
> text -> uuid
> text -> (user defined enum)
>
> ... mainly because otherwise app devs need frustrating workarounds (or
> giving up on the PostgreSQL native types and just using 'text' columns),
> and because in all these cases PostgreSQL will validate the input.

That seems pretty reasonable.  If you do that along with redefining
certain functions like lpad() to take "any" instead of text you'd
eliminate most of the headaches.

merlin



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: VIP: explain of running query
Next
From: Oskari Saarenmaa
Date:
Subject: [PATCH] parser: optionally warn about missing AS for column and table aliases