How hard would it be to support LIKE in return declaration of generic record function calls ? - Mailing list pgsql-hackers

From Hannu Krosing
Subject How hard would it be to support LIKE in return declaration of generic record function calls ?
Date
Msg-id 1335958834.3106.454.camel@hvost
Whole thread Raw
Responses Re: How hard would it be to support LIKE in return declaration of generic record function calls ?
List 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/



pgsql-hackers by date:

Previous
From: Jeroen Vermeulen
Date:
Subject: Re: extending relations more efficiently
Next
From: Peter Geoghegan
Date:
Subject: Re: Have we out-grown Flex?