- 論壇徽章:
- 0
|
本文系轉(zhuǎn)載他人文章 用PG做了些項(xiàng)目,積累了些經(jīng)驗(yàn),其中之一就是在PG下調(diào)試function。
可以設(shè)置break point,單步調(diào)試,就象在eclipse里面調(diào)試java code,一個(gè)很復(fù)雜的function通過這種方式很快就找出問題,大大提高開發(fā)效率。(注:要求pg8.2及以上版本)
PG默認(rèn)是不支持function調(diào)試的,要在PG里調(diào)試function得安裝enterpriseDB提供的pg插件edb-debugger(PL/pgSQL
Debugger. Currently requires PostgreSQL 8.2 or higher (or EnterpriseDB
8.1.4 or higher). The PL/pgSQL debugger lets you step through PL/pgSQL
code, set and clear breakpoints, view and modify variables, and walk
through the call stack)
安裝edb-debugger:
1)源碼方式安裝pg,(這里不作詳細(xì)說明,請參照我的另一篇文章)
2)下載edb-debugger
地址:http://pgfoundry.org/projects/edb-debugger/,目前最新版本為0.92
3)解壓edb-debugger到pg的源碼目錄下的contrib下面(我的目錄:/home/lyb/postgresql-8.3.3/contrib/pldebugger),進(jìn)入pldebugger目錄。
4)make
5)make install
好,現(xiàn)在edb-debugger已經(jīng)安裝完成
配置pg
1)更改數(shù)據(jù)庫目錄下的postgresql.conf,加入如下紅色語句:
#shared_preload_libraries = '' # (change requires restart)(這個(gè)系統(tǒng)默認(rèn)下是注釋掉的,在這句下面加入下面語句)
shared_preload_libraries = '$libdir/plugins/plugin_debugger'(這是新加入的)
2)重新啟動pg
3)在要進(jìn)行調(diào)試的數(shù)據(jù)庫里執(zhí)行pldbgapi.sql文件,這個(gè)文件在你pg安裝目錄的share/postgresql/contrib/下面
調(diào)試pg的function
1)打開pgadmin3,打開你要調(diào)試的數(shù)據(jù)庫,在你要調(diào)試的function上右擊,這時(shí)你會發(fā)現(xiàn)多了一項(xiàng)Debugging,占擊子項(xiàng)中的debug就可對function進(jìn)行調(diào)試了。
2)我的調(diào)試圖
|
|