BUG #16178: DROP LANGUAGE plpythonu; doesn't actually drop language.

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: indreek(at)gmail(dot)com
Subject: BUG #16178: DROP LANGUAGE plpythonu; doesn't actually drop language.
Date: 2019-12-23 09:23:46
Message-ID: 16178-d556fe3d69ee5271@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16178
Logged by: Indrek Kalluste
Email address: indreek(at)gmail(dot)com
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.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Magnus Hagander 2019-12-23 12:45:02 Re: PostgreSQL\12\bin\pg_ctl.exe - Trojan detected
Previous Message Michael Paquier 2019-12-23 01:59:56 Re: REINDEX CONCURRENTLY unexpectedly fails