Re: proposal: auxiliary functions for record type

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Florian Pflug <fgp(at)phlo(dot)org>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proposal: auxiliary functions for record type
Date: 2010-12-16 12:21:42
Message-ID: AANLkTi=ivuqaK000hFNPMqGnda8k_-mMkALC1kPyh+nP@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2010/12/16 Florian Pflug <fgp(at)phlo(dot)org>:
> On Dec13, 2010, at 08:23 , Pavel Stehule wrote:
>> There is a second possibility - and hardly simpler. We can use a
>> specialised statement with own parser/executor node. Then
>> implementation should be really simply
>>
>> syntax:
>>
>> EXTRACT_VALUE(expr1 FROM expr2 AS typename) ... RETURNS typename
>
>
> In principle, that looks nice. I'm fairly certain, however, that
> any proposal that adds special syntax just for this will very like
> get shot down quickly, so I don't really want to go there.
>
> However, I've just had an epiphany I think. Why not copy a page out
> of dblink's book, and make it
>
> select * from record_get(<record>, <field1>,  ..., <fieldn>) as (field varchar, value <type>)
>
> The result would be
>
>  field    | value
> (varchar) | (<type>)
> --------------------
> field1    | value1
> ...
> fieldn    | valuen
>
> If value1 ... value_n are able to be casted to <type>, and an error otherwise.
>
> If dblink is able to pull that off, so should we, or am I missing
> something?

no, it could work. I am not sure if it has a necessary ergonomic (I
don't like to write a record descriptor), but I think so we found a
combination, that can work. What about two functions:

record_get(rec, field, field, field) that returns a (text, text)
and
record_get_raw(rec, field, field, field) that returns a some common
type and should be enhanced with record descriptor

?

Regards

Pavel

>
> best regards,
> Florian Pflug
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Smith 2010-12-16 12:32:46 Re: [PATCH] V3: Idle in transaction cancellation
Previous Message Greg Smith 2010-12-16 11:48:17 Re: Instrument checkpoint sync calls