postgresqlplpython

Upgrade postgresql 9.6 -> postgresql 13 blocked by missing plpython2 extension, but I can't seem to remove the extension


I'm trying to upgrade a system from Postgresql 9.6 to Postgresql 13 using pg_upgrade shipped with Postgresql 13. This upgrade fails with the error:

Your installation references loadable libraries that are missing from the new installation.  You 
can add these libraries to the new installation,
or remove the functions using them from the old installation.  A list of
problem libraries is in the file:
   loadable_libraries.txt

Failure, exiting
-bash-4.2$ cat loadable_libraries.txt
could not load library "$libdir/plpython2": ERROR:  could not access file "$libdir/plpython2": No such file or directory
In database: infohub

This error seems clear to me, the infohub database uses the plpython2 extension, which isn't installed (and doesn't even exist) for postgresql 13.

My problem is that I've tried removing the extension and pg_upgrade still fails with the above error.

postgres=# \c infohub
psql (13.0, server 9.6.19)
You are now connected to database "infohub" as user "postgres".
infohub=# DROP EXTENSION plpythonu CASCADE ;
DROP EXTENSION

I tried using this statement to check if there are any function

infohub=# select  DISTINCT l.lanname as function_language
from pg_proc p
left join pg_language l on p.prolang = l.oid
;


function_language

-------------------  
internal  
sql   
c   
plpgsql  
(4 rows)

Best I can tell, there are no functions that depend on plpythonu (or plpython2), however pg_upgrade still gives me the above error about a missing extension.

Any help or idea would be greatly appreciated.


Solution

  • Run the following statement in all databases:

    SELECT oid::regprocedure
    FROM pg_catalog.pg_proc
    WHERE probin = '$libdir/plpython2';
    

    Then you know which functions are at fault and can remove them.