postgresql扩展test--sql复制出现错误.

摘要:坑是要有的,也是必须要跳的,但跳下去的时候,要勇敢的再爬上来.

首先确定一点Extension 中的Makefile错误是本文的根源.

make install时 下面是错误的输出结果:

me@me:~/Desktop/postgresql-10.1/contrib/test$ make install
make -C ../../src/interfaces/libpq all
make[1]: Entering directory '/home/me/Desktop/postgresql-10.1/src/interfaces/libpq'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/me/Desktop/postgresql-10.1/src/interfaces/libpq'
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I../../src/interfaces/libpq -I. -I. -I../../src/include  -D_GNU_SOURCE -I/usr/include/libxml2   -c -o test.o test.c
test.c: In function ‘_PG_init’:
test.c:63:24: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
  my_ProcessUtility_hook= record_detable_info;
                        ^
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -shared -o test.so test.o -L../../src/port -L../../src/common -Wl,--as-needed -Wl,-rpath,'/opt/HighGo/postgresql10.1/lib',--enable-new-dtags  -L../../src/interfaces/libpq -lpq 
/bin/mkdir -p '/opt/HighGo/postgresql10.1/lib'
/bin/mkdir -p '/opt/HighGo/postgresql10.1/share/contrib'
/usr/bin/install -c -m 755  test.so '/opt/HighGo/postgresql10.1/lib/test.so'
/usr/bin/install -c -m 644 ./test--1.0.sql  
/opt/HighGo/postgresql10.1/share/contrib/

黑体字copy错误:  按照正规路径应该是

/opt/HighGo/postgresql10.1/share/extension/

修改Makefile之前:

# contrib/test/Makefile

MODULE_big = test
OBJS	= test.o
PG_CPPFLAGS = -I$(libpq_srcdir)
SHLIB_LINK = $(libpq)
SHLIB_PREREQS = submake-libpq

# the db name is hard-coded in the tests
override USE_MODULE_DB =

ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/test
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

修改之后:

# contrib/test/Makefile

MODULE_big = test
OBJS	= test.o
PG_CPPFLAGS = -I$(libpq_srcdir)
SHLIB_LINK = $(libpq)
SHLIB_PREREQS = submake-libpq

# the db name is hard-coded in the tests
EXTENSION = test
DATA = test--1.0.sql
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
else
subdir = contrib/test
top_builddir = ../..
include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk
endif

待更>>>>>

MODULES 代表要创建的动态库列表,不要包含动态库后缀:例如:MODULES = file_fdw 就会成成 file_fdw.so文件。(见:extension/file_fdw)

MODULE_big 根据OBJS 里面的.o 文件生成的动态库。

SHLIB_LINK MODULE_big所需要的依赖库

PROGRAM 根据OBJS 里面的.o文件生成的可执行文件。

PG_LIBS PROGRAM所需要的依赖库

EXTENSION 扩展的名字(必须要有一个与改名字相同的控制文件(control))

REGRESS 回归测试列表(没有后缀)

REGRESS_OPTS 回归测试额外的配置

EXTRA_CLEAN ‘make clean’ 额外要删除的对象,一般为你插件生成的对象

PG_CPPFLAGS 编译参数,该参数为编译程序的时候用相当于CPPFLAGS,如:添加头文件 -I *.h

PGFILEDESC 描述文件

参考:https://blog.csdn.net/akakakak250/article/details/78418203


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值