tada / pljava

PL/Java is a free add-on module that brings Java™ Stored Procedures, Triggers, Functions, Aggregates, Operators, Types, etc., to the PostgreSQL™ backend.
http://tada.github.io/pljava/
Other
238 stars 77 forks source link

Restore "installed by `LOAD` then packaged as extension" #445

Closed jcflack closed 1 year ago

jcflack commented 1 year ago

PL/Java supports a pre-extension, legacy installation method just using the LOAD command. It can still have some uses, such as when a DBA does not have write access to the directories where official extension files have to go. And PL/Java has supported later packaging such an 'unpackaged' installation into extension form. (The old PostgreSQL syntax for that, CREATE EXTENSION FROM unpackaged, was dropped in PG 13, but an equivalent sequence of steps still works).

That packaging used to rely on CREATE OR REPLACE silently absorbing a preexisting object into the current extension. However, since postgres/postgres@b9b21ac, CREATE OR REPLACE instead fails if the object exists and is not yet an extension member. Therefore, the few objects for which PL/Java does CREATE OR REPLACE within the InstallHelper.groundwork method also need to have conditional ALTER EXTENSION ADD done in that method first. (Conditional, because in the case where the unpackaged installation might also be an older PL/Java version, some objects we'll CREATE OR REPLACE for the current version might not be there yet.)

Only those few objects must be treated that way; ALTER EXTENSION ADD for the rest can still be done in the extension update script where anyone would expect.