Search Postgresql Archives

Defining functions for arrays of any number type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'm working on a package of functions that compute statistics on
arrays of numbers. For example this one computes a histogram from a
bunch of values plus some bucket characteristics:

CREATE OR REPLACE FUNCTION
array_to_hist(double precision[], double precision, double precision, int)
RETURNS int[]
AS 'aggs_for_arrays', 'array_to_hist'
LANGUAGE c;

Now suppose I wanted this function to accept not just arrays of double
precision values, but arrays of any numeric type. I don't see any
pseudotype like that in this list:

http://www.postgresql.org/docs/9.3/static/datatype-pseudo.html

So how would you declare this function? Should I use anyarray for the
first parameter and anyelement for the next two (start of first bucket
and bucket width), and then just have the implementation complain if
the type isn't numeric? Or is there a better way than that?

Is it legal to define a bunch of functions all called `array_to_hist`
for the different numeric types, and have them all implemented by the
same C function?

Thanks,
Paul

-- 
_________________________________
Pulchritudo splendor veritatis.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux