PG版本 9.5.5
pg_pathman 版本 1.3
问题:
今天用户上报一个问题,在跑建表脚本之后数据库连接被驳回,然后不清楚表是否创建成功。
再连到数据库做任何操作都会报如下错误:
ERROR: could not determine which collation to use for string comparison
HINT: Use the COLLATE clause to set the collation explicitly.
用户的表定义如下:
-- Table: public.a_pathman_range_par_test
-- DROP TABLE public.a_pathman_range_par_test;
CREATE TABLE public.a_pathman_range_par_test
(
statstime text NOT NULL,
iter integer
)
WITH (
OIDS=FALSE
);
select
create_range_partitions(
'a_pathman_range_par_test'::regclass
,'statstime'::text
,'201706'::anyelement
,'1'::integer
,3
,false --是否迁移数据)
经专家各方分析,认定是伪类型anyelement触发pg_pathman的一个bug。
解决方法:
停库pg stop
修改配置文件
vi postgresql.conf 先去掉pg_pathman:
shared_preload_libraries = 'repmgr_funcs,pg_stat_statements,auto_explain,pg_pathman'
启库 pg start
删除 pg_pathman插件: drop extension pg_pathman;
删除问题分区表:drop table if EXISTS a_pathman_range_par_test CASCADE ;
重装pg_pathman插件:create extension pg_pathman;
检查pathman版本,最新为1.3
\dx
List of installed extensions
Name | Version | Schema | Description
------------+---------+------------+--------------------------------
pg_pathman | 1.3 | public | Partitioning tool
再停库,将postgresql.conf还原,然后启库。
为避免bug,表的定义应该是:
CREATE TABLE public.a_pathman_range_par_test
(
statstime date NOT NULL, --也可以是timestamp,要看你需求的时间精度
iter integer
)
select
create_range_partitions(
'a_pathman_range_par_test'::regclass
,'statstime'::text
,'20170601'::date
,'1 day'::interval
,3
,false --是否迁移数据)