Re: dblink: add polymorphic functions.

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: dblink: add polymorphic functions.
Дата
Msg-id 55B91316.6070704@joeconway.com
обсуждение исходный текст
Ответ на Re: dblink: add polymorphic functions.  (Corey Huinker <corey.huinker@gmail.com>)
Ответы Re: dblink: add polymorphic functions.  (Corey Huinker <corey.huinker@gmail.com>)
Re: dblink: add polymorphic functions.  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-hackers
-----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);

where potentially connstr, sql, p_rowtype are all passed to plpgsql as
arguments. Correct?

Joe

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (GNU/Linux)

iQIcBAEBAgAGBQJVuRMWAAoJEDfy90M199hlT5sP/3GuKbvZC7Ods3i2SqtTGbTo
raFiKM87ZznswldNjDHVBEp+OntXzb0JbPUf6n/YJoEJGWE95wb40jez5snAV9lO
aJ7CD9P235OgVh7QVTeWIW5Who8Yj1Xx6NF/Gz/06pGoAXQj1QoznnUPYixur4dT
znjWW3XY6eFpfLzIBKIJmcskOKezgqj2F/kRJpgGYVaEm3okVkjubDjmPM5Vbaaa
sd/lDI5ByceIImzL8LaFeBWwUGLYRsP02zamfPiz3p1zMb+ViBvS+NiBG0kMZMCt
bzy6g0kxbLaxkKy/oEQXqinCNY3hEn8eZ7w4Os/3Zk9PCacZAKDrXfqBDTuE6zio
wy/nwBnoTvdBSk0gl+MKoVlmoy0iAV7Hl/R/KtdNdpCTL4Ja6R5V2c/sjWazxAg4
PymaTXi4/SNWTFwAYGJUfGL+i3CMNQfp4U/tGTVPGFZ8thss7FTVNIVR6ZcAzuPM
EHYDZ8cGaewqDF/HdPlJl4ypxF3aS8tzzApiFVpu35+2WHEacwljDV40l8z9Ee1V
E7R0oxG55fgRJKvLSn5Oj59U2iBXgcu0zLLhBhaVyOYhcIZbWe6xvF1UN/RNcOuz
Se10lYSXCTmz3q61HyCNnWFcOtgYSeFA3Lc79vgxJoZWmwnpHYoFEjQxr3qHFeeK
svkoix7k7t7YZUXGebbg
=vM1F
-----END PGP SIGNATURE-----



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: upgrade failure from 9.5 to head
Следующее
От: Corey Huinker
Дата:
Сообщение: Re: dblink: add polymorphic functions.