Re: dblink: add polymorphic functions.
От | Merlin Moncure |
---|---|
Тема | Re: dblink: add polymorphic functions. |
Дата | |
Msg-id | CAHyXU0yqreh8biDN5G-i1Sv=JG85do5o9QZ=6NqnZaPtYgUGqg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: dblink: add polymorphic functions. (Joe Conway <mail@joeconway.com>) |
Ответы |
Re: dblink: add polymorphic functions.
|
Список | pgsql-hackers |
On Wed, Jul 29, 2015 at 12:53 PM, Joe Conway <mail@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
В списке pgsql-hackers по дате отправления: