Re: Dyamic updates of NEW with pl/pgsql

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, David Fetter <david(at)fetter(dot)org>, depesz(at)depesz(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Dyamic updates of NEW with pl/pgsql
Date: 2010-03-15 16:53:45
Message-ID: b42b73151003150953j400606ddtc932c58113b32da@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 15, 2010 at 12:19 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
>> On Mon, Mar 15, 2010 at 11:37 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> If we make the implementation be such that "(rec->field)::foo" forces
>>> a runtime cast to foo (rather than throwing an error if it's not type
>>> foo already)
>
>> yeah...explicit cast should always do 'best effort'
>
> Probably so.  But is it worth inventing some other notation that says
> "expect this field to be of type foo", with an error rather than runtime
> cast if it's not?  If we go with treating the result of -> like UNKNOWN,
> then you wouldn't need that in cases where the parser guesses the right
> type.  But there are going to be cases where you need to override the
> guess without necessarily wanting to buy into a forced conversion.

Maybe. That behaves like oid vector to PQexecParams, right? Suggests
a type but does not perform a cast. I see your point but I think it's
going to go over the heads of most people...type association vs type
coercion. Maybe instead you could just supply typeof function in
order to provide very rigorous checking when wanted and presumably
allow things like pointing the assignment at a special field.

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2010-03-15 17:09:59 WIP: simple allocator
Previous Message Tom Lane 2010-03-15 16:19:13 Re: Dyamic updates of NEW with pl/pgsql