Here I'm posting a function to convert array to records. any other suggestions are welcome
create or replace function array_to_records(int[]) RETURNS SETOF record AS $$ DECLARE ret_rec record; a int; b int; BEGIN b = length(array_dims($1)); a = substr(array_dims($1),4, (b-4) ); FOR i IN 1.. a LOOP FOR ret_rec IN select i, $1[i] LOOP RETURN NEXT ret_rec; END LOOP; END LOOP; RETURN; END; $$ LANGUAGE 'plpgsql';