On Dec11, 2010, at 17:55 , Pavel Stehule wrote:
> It same trick, that I use in record_set_fields.
Oh, I see. Sorry, must haven missed that when I read your blog entry.
> But I don't want to
> use it for reading of value. I don't like it. You don't need to know a
> value, you have to know a type - NULL::type. it is just not nice :).
Well, no, it's not the most elegant API on earth, that's for sure. But I my opinion, it isn't so bad that it rectifies casting everything to text.
> though about it too, and maybe is a time for new polymorphic type
> "anytype" - and then you don't need to write a litte bit strange
> it can be "fieldvalue(myrec, type1, false)"
Hm, I don't think the ability to write just "type1" instead of "NULL::type1" is worth the necessary effort.
If anything, I'd allow function to use anyelement as their return value *without* having any polymorphic arguments. You'd need to surround calls to such function with a CAST() expression, unless something else determines the type. In pl/pgsql, for example, one could allow the CAST() to be skipped for assignment to variables. Then, you could write
v_value := fieldvalue(myrec, 'f1', true)
That'd at least free you from having to specify the type in some cases. But still, even this seems to be a lot of effort for quite little gain...
In response to
pgsql-hackers by date
|Next:||From: Heikki Linnakangas||Date: 2010-12-11 21:03:23|
|Subject: Re: [COMMITTERS] pgsql: Reduce spurious Hot Standby conflicts from
|Previous:||From: Jeff Janes||Date: 2010-12-11 20:18:02|
|Subject: Re: unlogged tables|