anyelement -> anyrange - Mailing list pgsql-hackers

From Jim Nasby
Subject anyelement -> anyrange
Date
Msg-id 787ba701-72dd-9a05-3085-45607159288f@BlueTreble.com
Whole thread Raw
Responses Re: anyelement -> anyrange  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Any reason why we can create a function that accepts anyelement and 
returns anyarray, but can't do the same with anyrange? Could we attempt 
to match each range subtype looking for a match?

create function range__create(anyelement,anyelement,text = '[]') RETURNS 
anyrange LANGUAGE plpgsql AS $body$
BEGIN
RETURN int4range($1,$2,$3)
END$body$;
ERROR:  42P13: cannot determine result data type
DETAIL:  A function returning "anyrange" must have at least one 
"anyrange" argument.

create function array__create(anyelement,anyelement) RETURNS anyarray 
LANGUAGE plpgsql AS $body$
BEGIN
RETURN array[$1,$2];
END$body$;
CREATE FUNCTION
-- 
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)   mobile: 512-569-9461



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: max_parallel_degree > 0 for 9.6 beta
Next
From: Tom Lane
Date:
Subject: Re: anyelement -> anyrange