| 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 13:39:52 |
| Message-ID: | b42b73151003150639h26be3fc8m60812c7b9d6d8db7@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Sat, Mar 13, 2010 at 1:38 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I wonder if it could work to treat the result of a "record->fieldname"
> operator as being of UNKNOWN type initially, and resolve its actual
> type in the parser in the same way we do for undecorated literals
> and parameters, to wit
> * you can explicitly cast it, viz
> (record->fieldname)::bigint
> * you can let it be inferred from context, such as the type
> of whatever it's compared to
> * throw error if type is not inferrable
> Then at runtime, if the actual type of the field turns out to not be
> what the parser inferred, either throw error or attempt a run-time
> type coercion. Throwing error seems safer, because it would avoid
> surprises of both semantic (unexpected behavior) and performance
> (expensive conversion you weren't expecting to happen) varieties.
> But possibly an automatic coercion would be useful enough to justify
> those risks.
the casting rules are completely reasonable. Throwing an error seems
like a better choice. Better to be strict now and relax the rules
later. record->fieldname takes a string (possibly a variable)? If
so, his would nail the problem. This would work with run time typed
records (new, etc)?
merlin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew Dunstan | 2010-03-15 14:02:39 | Re: Dyamic updates of NEW with pl/pgsql |
| Previous Message | Dimitri Fontaine | 2010-03-15 12:47:21 | Re: Getting to beta1 |