PgAdmin comes with built-in support for debugging your Pl/PgSQL programs. However in order to enable this, you’ll have to compile and install extra plug-in to PostgreSQL.

I Googled a lot but didn’t find one single post with all steps so here we go: ( I did this on my Ubuntu)

  • Prepare environment:

By default, Ubuntu doen’t come with the most recent PostgreSQL. You can do the following to add PostgreSQL’s offical repository so you get the most up-to-date version (v9.6 at the time of writing). Refer to

Create file /etc/apt/sources.list.d/pgdg.list, and add following line:


Import the repository signing key, and update the package lists:

  • Install development tools (if you don’t have or found error in below make):

  • Install development modules:

  • Clone and build the PL/pgSQL server-side debugger

The source can be found here, (use “snapshot” to download all files in one go)

  •  Configuration

Once installed, edit /etc/postgresql/9.4/main/postgresql.conf to enable the debugger pluggin:

# Search for: shared_preload_libraries
# Edit the entry to add the library ‘plugin_debugger’:

shared_preload_libraries = ‘plugin_debugger’

(Refer to

  • Restart PostgreSQL

  • Enable this extension in PostgreSQL

The following is done at each DB level, not instance level. So log into the DB and run following SQL:



Enable debug in PostgreSQL
Tagged on:                 

3 thoughts on “Enable debug in PostgreSQL

  • March 18, 2018 at 10:12 am

    Thanks for the post. I am getting closer…
    during compiling, however I am getting the following error:
    In file included from pldbgapi.c:98:0:
    /usr/include/postgresql/9.6/server/libpq/libpq-be.h:36:27: fatal error: gssapi/gssapi.h: No such file or
    compilation terminated.
    Wonder if you have any suggestion. Thanks in advance.

    • March 1, 2019 at 10:35 pm



Leave a Reply

Your email address will not be published. Required fields are marked *

30 − 26 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.