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