On Wed, Jul 29, 2015 at 12:53 PM, Joe Conway <m...@joeconway.com> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 07/29/2015 09:40 AM, Corey Huinker wrote: >> Say I've got a table my_partitioned_table (key1 integer, key2 >> integer, metric1 integer, metric2 integer); >> >> And I've got many partitions on that table. My code lets you do >> something like this: >> >> select key1, key2, sum(metric1) as a_sum_of_sums, sum(metric2) as >> another_sum_of_sums from >> execute_buncha_queries(null::my_partitioned_table, >> 'connection_string_thats_just_a_loopback', array['select key1, >> key2, sum(metric1), sum(metric2) from my_partition_p1 group by >> 1,2', 'select key1, key2, sum(metric1), sum(metric2) from >> my_partition_p2 group by 1,2', ...]) group by 1,2 > >> I can't put a cast around execute_buncha_queries because the >> function won't know how to cast the results coming back from >> dblink. > > Ok, gotcha. So Tom's nearby comment about allowing the > "p_rowtype%TYPE" syntax to be used in the CAST is spot on (as usual). > In other words, to get a complete solution for you we would need to > make both things work, so you could do this inside plpgsql: > > select * from cast(dblink(connstr, sql) as p_rowtype%TYPE);
Would this be a pl/pgsql only solution? merlin -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers