PG pldebugger插件安装

下载pldebugger安装包:

http://git.postgresql.org/gitweb/所有第三方插件都可在此下载,此处下载pldebugger.git

解压并编译安装

上传安装包到服务器并解压

cd pldebugger  
export PATH=/home/digoal/pgsql9.6/bin:$PATH  

USE_PGXS=1 make clean  
USE_PGXS=1 make  
USE_PGXS=1 make install  

修改配置

cd $PGDATA  
vi postgresql.conf  
shared_preload_libraries = '$libdir/plugin_debugger'  

重启数据库服务

pg_ctl restart -m fast  			

如何调试存储过程

\1. 在需要调试存储过程的目标数据库中,安装pldbgapi插件

postgres=# create extension pldbgapi ;  
CREATE EXTENSION  

\2. 创建被调试的测试代码(如果已经有目标函数了,请忽略此步骤)

create or replace function debugger_test (i int) returns int as $$    
declare    
v_result int;    
begin    
v_result := 0;    
if i<0 then    
  raise notice 'Please enter i >=0.';    
  raise exception '';    
end if;    
for x in 0..i loop    
v_result := v_result + x;    
end loop;    
return v_result;    
exception    
when others then    
  v_result := 0;    
  return v_result;    
end;    
$$ language plpgsql;   

\3. 打开pgAdmin客户端,使用pgAdmin登陆到这个数据库, 右键点击函数,点击调试选项。
在这里插入图片描述

https://yq.aliyun.com/articles/74417

posted @ 2019-07-21 11:55  岳麓丹枫  阅读(1612)  评论(0编辑  收藏  举报