Skip site navigation (1) Skip section navigation (2)

How hard would it be to support LIKE in return declaration of generic record function calls ?

From: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: How hard would it be to support LIKE in return declaration of generic record function calls ?
Date: 2012-05-02 11:40:34
Message-ID: 1335958834.3106.454.camel@hvost (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi Hackers

How hard would it be to add support for LIKE syntax, similar to table
def in field list declaration for generic record functions

What I'dd like to be able to do is to have a generic json_to_record
function 

CREATE OR REPLACE RECORD json_to_record(json) RETURNS RECORD AS $$
...
$$ LANGUAGE ... ;

and then be able to call it like this

insert into test2 
select * from json_to_record(jrec json) as (like test2);

ERROR:  syntax error at or near "like"

instead of explicitly spelling out the structure of table test2 in the
AS part.

insert into test2 
select * from json_to_record(jrec json)
                         as (id int, data2 test, tstamp timestamp);
INSERT 0 1


PS.

As a pie-in-the-sky wish I'd prefer of course even simpler syntax of

insert into test2 json_to_record(jrec json);

or at least  

insert into test2 json_to_record(jrec json)::test2;

:)
- 
-------
Hannu Krosing
PostgreSQL Unlimited Scalability and Performance Consultant
2ndQuadrant Nordic
PG Admin Book: http://www.2ndQuadrant.com/books/


Responses

pgsql-hackers by date

Next:From: Peter GeogheganDate: 2012-05-02 11:47:01
Subject: Re: Have we out-grown Flex?
Previous:From: Jeroen VermeulenDate: 2012-05-02 11:16:12
Subject: Re: extending relations more efficiently

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group