1.安装插件session_exec报错:
[postgres@SQL-2 session_exec-master]$ make pg_config=/bin/pg_config
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DLINUX_OOM_SCORE_ADJ=0 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -fPIC -I. -I. -I/usr/include/pgsql/server -I/usr/include/pgsql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o session_exec.o session_exec.c
session_exec.c: In function ‘exec_function’:
session_exec.c:65:2: error: too many arguments to function ‘FuncnameGetCandidates’ ##参数太多
clist = FuncnameGetCandidates(names, 0, NIL, false, false, true);
^
In file included from session_exec.c:24:0:
/usr/include/pgsql/server/catalog/namespace.h:72:26: note: declared here
extern FuncCandidateList FuncnameGetCandidates(List *names,
^
make: *** [session_exec.o] Error 1

2.报错分析:
从报错中,可以看出,安装的插件中使用的函数:FuncnameGetCandidates 的参数与声明中的不符。
查看pg头文件声明中的文件:
/usr/include/pgsql/server/catalog/namespace.h
extern FuncCandidateList FuncnameGetCandidates(List *names,
int nargs, List *argnames,
bool expand_variadic,
bool expand_defaults);
看下测试环境中的声明:
extern FuncCandidateList FuncnameGetCandidates(List *names,
int nargs, List *argnames,
bool expand_variadic,
bool expand_defaults,
bool missing_ok);
可以看出,上面的声明,比下面少一个参数:bool missing_ok,故会出现报错。
3.查找namespace.n文件:
发现有两个,如下:
/usr/include/pgsql/server/catalog/namespace.h
/opt/app/pgsql/include/postgresql/server/catalog/namespace.h
4.查询安装的pg软件:


发现竟然有这么多。
因为我的pg软件版本是10.17,用安装包安装的:安装包文件:postgresql-10.17-1-linux-x64-binaries.tar.gz
所以,这个9.2版本、10.22版本的pg都不是我的pg,可以卸载,我直接卸载了9.2版本的:
rpm -e postgresql-9.2.24.8.el7_9.x86_64以及其他两个。
然后,查看pg_config,发现pg_config位置指定错误:
[postgres@SQL-2 session_exec-master]$ which pg_config
/usr/pgsql-10/bin/pg_config
5.继续安装插件session_exec:
[postgres@SQL-2 session_exec-master]$ make pg_config=/opt/app/pgsql/bin/pg_config
Makefile:15: /usr/pgsql-10/lib/pgxs/src/makefiles/pgxs.mk: No such file or directory
make: *** No rule to make target `/usr/pgsql-10/lib/pgxs/src/makefiles/pgxs.mk'. Stop.
又出现问题,这次应该还是pg版本的问题,卸载pg10.22:
[root@SQL-2 ~]# rpm -e pg_cron_10-1.4.2-1.el7.x86_64
[root@SQL-2 ~]# rpm -e postgresql10-server-10.22-1PGDG.rhel7.x86_64
[root@SQL-2 ~]# rpm -e postgresql10-10.22-1PGDG.rhel7.x86_64
[root@SQL-2 ~]# rpm -e pg_rman-1.3.13-1.pg10.rhel8.x86_64
[root@SQL-2 ~]# rpm -e postgresql10-libs-10.22-1PGDG.rhel7.x86_64
6.卸载后,无法找到pg_config:
[postgres@SQL-2 ~]$ which pg_config
/usr/bin/which: no pg_config in (/opt/dtstack/java/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/bin:/data/hadoop_base/bin:/data/hadoop_base/sbin:/home/postgres/.local/bin:/home/postgres/bin:/usr/pgsql-10/bin:/home/postgres/.local/bin:/home/postgres/bin:/usr/pgsql-10/bin:/home/postgres/.local/bin:/home/postgres/bin:/usr/pgsql-10/bin:/home/postgres/.local/bin:/home/postgres/bin:/usr/pgsql-10/bin)
7.指定pg_config:
vi .bash_profie
export PATH=$PATH:$PG_RMAN/bin:/opt/app/pgsql/bin/
source .bash_profie
[postgres@SQL-2 ~]$ which pg_config
/opt/app/pgsql/bin/pg_config
8.继续安装插件:
[postgres@SQL-2 session_exec-master]$ make pg_config=/opt/app/pgsql/bin/pg_config
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -DMAP_HUGETLB=0x40000 -fPIC -I. -I./ -I/opt/app/pgsql/include/postgresql/server -I/opt/app/pgsql/include/postgresql/internal -I/opt/local/Current/include -D_GNU_SOURCE -I/opt/local/Current/include/libxml2 -I/opt/local/Current/include -c -o session_exec.o session_exec.c
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -O2 -DMAP_HUGETLB=0x40000 -fPIC -shared -o session_exec.so session_exec.o -L/opt/app/pgsql/lib -L/opt/local/Current/lib -Wl,--as-needed -Wl,-rpath,'/opt/app/pgsql/lib',--enable-new-dtags
[postgres@SQL-2 session_exec-master]$ make pg_config=/opt/app/pgsql/bin/pg_config install
/bin/mkdir -p '/opt/app/pgsql/lib/postgresql'
/usr/bin/install -c -m 755 session_exec.so '/opt/app/pgsql/lib/postgresql/session_exec.so'
成功。




