Обсуждение: pg_upgrade with C-language extensions?

Поиск
Список
Период
Сортировка

pg_upgrade with C-language extensions?

От
Craig James
Дата:
I can't figure out how to get pg_upgrade to work when I have my own C-language extension.

Say I have this:

CREATE OR REPLACE FUNCTION my_foo() RETURNS integer
AS '/usr/local/mycompany/lib/libmystuff_pg.so', 'my_foo'
LANGUAGE c VOLATILE;

When I run "pg_upgrade ... --check", it complains that it won't be able to do the update because libmystuff_pg.so isn't available.

OK, fair enough. But ... pg_upgrade has to be able to run both 8.4.17 and 9.5.3 at the same time. So if I compile libmystuff_pg.so against 9.3.5, it won't work for 8.4.17, and vice versa.  On the other hand, if I compile two versions of libmystuff_pg.so, one for 8.4.17 and one for 9.3.5, then the "CREATE OR REPLACE" will have the wrong path for one or the other.

How is this supposed to be done? The only thing I can think of is maybe I should put libmystuff_pg.so into the Postgres lib directory and then leave the path off of the "CREATE OR REPLACE" statement. I don't like mixing my code with Postgres code, but is that the only way?

Thanks,
Craig

Re: pg_upgrade with C-language extensions?

От
Matheus de Oliveira
Дата:

On Fri, Aug 15, 2014 at 1:56 PM, Craig James <cjames@emolecules.com> wrote:
The only thing I can think of is maybe I should put libmystuff_pg.so into the Postgres lib directory and then leave the path off of the "CREATE OR REPLACE" statement. I don't like mixing my code with Postgres code, but is that the only way?


I guess this is the exactly and correct way of doing this. If you manage your application build process properly, you should be able to use the same --prefix as PostgreSQL or even getting the libdir straight from pg_config.

Other option is to do it during the upgrade and them chage it back to your own path. I myself dislike this option.

As you are upgrading, also considering providing the installation of your library with CREATE EXTENSION command, so you can manage installations and versions on a more advanced manner.

Best regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres