Sure; the function is created programmatically as part of schema creation,
by the same user who owns (almost) everything else in the database.  The
definition looks like this:

        CREATE OR REPLACE FUNCTION datastore_unpack(
            data_times TIMESTAMP WITH TIME ZONE[],
            data_values DOUBLE PRECISION[],
            OUT data_time TIMESTAMP WITH TIME ZONE,
            OUT data_value DOUBLE PRECISION
        ) RETURNS SETOF RECORD AS $$
            SELECT $1[rowx] AS data_time, $2[rowx] AS data_value
            FROM generate_series(1, array_upper($1, 1)) AS rowx;
        $$ LANGUAGE SQL STABLE;

It takes two parallel arrays and unpacks them into a set of records.

Reply via email to