使用 cstore_fdw 升级 PostgreSQL 数据库

Upgrading PostgreSQL database with cstore_fdw

我正在尝试将 PostgreSQL 数据库从 11.2 升级到 12.2,它有 cstore_fdw 扩展名。据我所知,这不受支持,所以我将所有 cstore 外部表迁移到本机表,删除了扩展名:

create schema cstore_backup;

-- executed the results of all of these:

select
  format ('create table cstore_backup.%s_%s as select * from %s.%s;',
  foreign_table_schema, foreign_table_name,
  foreign_table_schema, foreign_table_name)
from information_schema.foreign_tables ft 
where foreign_server_name = 'cstore_server';

select
  format ('drop foreign table %s.%s;',
  foreign_table_schema, foreign_table_name)
from information_schema.foreign_tables ft 
where foreign_server_name = 'cstore_server';

DROP SERVER cstore_server;

drop extension cstore_fdw;

我删除了文件夹(迁移后我会把它们放回cstore):

rm -fr /apps/pgdata11.2.0/cstore_fdw
rm -f /usr/local/psql11.2/share/postgresql/extension/cst*

我从 postgresql.conf 文件中删除了引用。

当我运行pg_upgrade:

$BIN/pg_upgrade \
  --old-bindir=/usr/local/psql11.2/bin \
  --new-bindir=/usr/local/psql12.2/bin \
  --old-datadir=/apps/pgdata11.2.0 \
  --new-datadir=/apps/pgdata12.2.0 \
  --old-port=5432 \
  --new-port=5432 \
  --jobs=4 --link --username=postgres --check

我仍然在 loadable_libraries.txt 输出文件中收到此消息:

could not load library "/usr/local/psql11.2/lib/postgresql/cstore_fdw.so": ERROR: could not load library "/usr/local/psql11.2/lib/postgresql/cstore_fdw.so": /usr/local/psql11.2/lib/postgresql/cstore_fdw.so: undefined symbol: ExecClearTuple

我很难过。 cstore_fdw 仍然驻留在我的安装中的什么地方?

感谢您的建议...事实证明,public 模式中有一些引用扩展的剩余函数,即使它完全消失了。我找到了所有这些:

select * from pg_proc where prosrc ilike '%cstore%'

删除它们中的每一个都解决了问题。

drop function public.cstore_clean_table_resources(oid);
drop function public.cstore_ddl_event_end_trigger();
drop function public.cstore_drop_trigger();
drop function public.cstore_fdw_handler();
drop function public.cstore_fdw_validator(text[], oid);
drop function public.cstore_table_size(relation regclass);