视频1 视频21 视频41 视频61 视频文章1 视频文章21 视频文章41 视频文章61 推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37 推荐39 推荐41 推荐43 推荐45 推荐47 推荐49 关键词1 关键词101 关键词201 关键词301 关键词401 关键词501 关键词601 关键词701 关键词801 关键词901 关键词1001 关键词1101 关键词1201 关键词1301 关键词1401 关键词1501 关键词1601 关键词1701 关键词1801 关键词1901 视频扩展1 视频扩展6 视频扩展11 视频扩展16 文章1 文章201 文章401 文章601 文章801 文章1001 资讯1 资讯501 资讯1001 资讯1501 标签1 标签501 标签1001 关键词1 关键词501 关键词1001 关键词1501 专题2001
PostgreSQL9.1.3plpgsqldebuggermodule
2020-11-09 11:20:31 责编:小采
文档


今天一位网友在群里面问PostgreSQL 9.0如何debug 函数. 我记得在8.3的时候有一个插件叫edb-debugger是可以使用的. 手头上没有9.0

今天一位网友在群里面问PostgreSQL 9.0如何debug 函数. 我记得在8.3的时候有一个插件叫edb-debugger是可以使用的. 手头上没有9.0的数据库, 于是测试了一下在9.1上能不能用, 结果是编译不通过.

最后找到了解决办法, 记录如下.

在pgfoundry中有一个开源的edb-debugger插件可以用来调试PostgreSQL的PLPGSQL函数.

但是这个版本太老, 在PostgreSQL 9.1中无法编译通过, 报错如下.

make

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fpic -I. -I. -I../../src/include -D_GNU_SOURCE -I/usr/include/libxml2 -c -o pldbgapi.o pldbgapi.c

pldbgapi.c: In function ‘pldbg_attach_to_port’:

pldbgapi.c:346: warning: implicit declaration of function ‘MAKE_OFFSET’

pldbgapi.c: In function ‘pldbg_wait_for_target’:

pldbgapi.c:474: warning: implicit declaration of function ‘SHM_OFFSET_VALID’

pldbgapi.c:476: warning: implicit declaration of function ‘MAKE_PTR’

pldbgapi.c:476: warning: cast to pointer from integer of different size

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fpic -L../../src/port -Wl,-rpath,'/opt/pgsql/lib',--enable-new-dtags -shared -o pldbgapi.so pldbgapi.o

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv -fpic -I. -I. -I../../src/include -D_GNU_SOURCE -I/usr/include/libxml2 -c -o targetinfo.o targetinfo.c

targetinfo.c: In function ‘getTriggerFuncOid’:

targetinfo.c:268: error: ‘SnapshotNow’ undeclared (first use in this function)

targetinfo.c:268: error: (Each undeclared identifier is reported only once

targetinfo.c:268: error: for each function it appears in.)

targetinfo.c: In function ‘getProcOidBySig’:

targetinfo.c:508: error: too few arguments to function ‘FuncnameGetCandidates’

targetinfo.c: In function ‘getProcOidByName’:

targetinfo.c:555: error: too few arguments to function ‘FuncnameGetCandidates’

make: *** [targetinfo.o] Error 1

rm pldbgapi.o

不知道为什么不更新了, 作者是这两位.

在EDB发布的EDB-AS版本中是包含了debugger的.

只是直接把它的so文件拷贝到开源版本的PostgreSQL中无法使用.

例如我把EDB-AS 9.1.2.2版本的$libdir/plugins/plugin_debugger.so文件拷贝到开源的PostgreSQL $PGHOME/lib/plugins/目录下.

配置postgresql.conf

在启动数据库时报错如下 :

这个NonSPLFunctionContext在PostgresPlus/9.1AS/include/server/utils/elog.h 文件里面定义的.

但是把它拷贝到开源的PostgreSQL的/opt/pgsql/include/server/utils/elog.h后依旧.


虽然pgfoundry里面提供下载的只有0.9.3版本, 庆幸的是cvs里面有最新的.

请见参考链接, 把这些文件下载过了后放到源码的contrib目录里面新建一个debugger目录.

编译过程 :

make

make install

修改数据库配置文件 :

重启数据库,

在需要调试的数据库里面使用超级用户安装函数和类.

CREATE TYPE

CREATE TYPE

CREATE TYPE

CREATE TYPE

CREATE TYPE

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

CREATE FUNCTION

创建一个测试函数 :

使用pgAdmin登陆到这个数据库, 右键点击函数的时候就有调试选项了.


一个调试页面截图 :

下载本文
显示全文
专题