PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16178
PG Version11.6
OSUbuntu 18
Opened2019-12-23 09:23:46+00
Reported byIndrek Kalluste
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16178
Logged by:          Indrek Kalluste
Email address:      (redacted)
PostgreSQL version: 11.6
Operating system:   Ubuntu 18
Description:        

If you run script:

CREATE SCHEMA IF NOT EXISTS moninfo_2ndq;
CREATE OR REPLACE LANGUAGE plpythonu;


CREATE TYPE moninfo_2ndq.mondata_int AS (name text, value bigint);

CREATE OR REPLACE FUNCTION moninfo_2ndq.pg_wal_info()
RETURNS SETOF moninfo_2ndq.mondata_int AS
$$
  import os

  filelist = os.listdir('pg_wal')
  yield 'PGSERVER.pg_xlog_files', len(filelist)

  dirsize = 0
  for filename in filelist:
    dirsize += os.path.getsize('pg_wal/'+filename)
  
  yield 'PGSERVER.pg_xlog_size', dirsize

$$ language plpythonu security definer;

select * from moninfo_2ndq.pg_wal_info();

---------------------
Exit postgres
---------------------

DROP SCHEMA IF EXISTS moninfo_2ndq CASCADE;
CREATE SCHEMA IF NOT EXISTS moninfo_2ndq;
CREATE TYPE moninfo_2ndq.mondata_int AS (name text, value bigint);

DROP LANGUAGE plpythonu;
CREATE EXTENSION plpython3u;

DROP FUNCTION IF EXISTS moninfo_2ndq.pg_wal_info();
CREATE OR REPLACE FUNCTION moninfo_2ndq.pg_wal_info()
    RETURNS SETOF moninfo_2ndq.mondata_int AS
$$
  import os

  if(os.path.exists('pg_xlog')):
    wal_dir = 'pg_xlog/'
  else:
    wal_dir = 'pg_wal/'

  filelist = os.listdir(wal_dir)

  yield 'PGSERVER.pg_wal_files', len(filelist)

  dirsize = 0
  for filename in filelist:
    dirsize += os.path.getsize(os.path.join(wal_dir,filename))

  yield 'PGSERVER.pg_wal_size', dirsize

$$ language plpython3u security definer;

select * from moninfo_2ndq.pg_wal_info();

#######
And try to run pg_upgrade check, it fails

/usr/lib/postgresql/12/bin/pg_upgrade \
--old-datadir=/var/lib/postgresql/11/main \
--new-datadir=/var/lib/postgresql/12/main \
--old-bindir=/usr/lib/postgresql/11/bin \
--new-bindir=/usr/lib/postgresql/12/bin \
--old-options '-c config_file=/etc/postgresql/11/main/postgresql.conf' \
--new-options '-c config_file=/etc/postgresql/12/main/postgresql.conf' \
--check

I get error: 
could not load library "$libdir/plpython2": ERROR:  could not access file
"$libdir/plpython2": No such file or directory
Database: test

Doing the same thing with extensions works fine.

Messages

DateAuthorSubject
2019-12-23 09:23:46+00PG Bug reporting formBUG #16178: DROP LANGUAGE plpythonu; doesn't actually drop language.
2019-12-23 13:46:33+00Tom LaneRe: BUG #16178: DROP LANGUAGE plpythonu; doesn't actually drop language.