Install pldebugger for PostgreSQL on Ubuntu 18/19/20.04

The debugger may be used to debug PL/pgSQL functions in PostgreSQL, as well as EDB-SPL functions, stored procedures and packages in EDB Postgres Advanced Server. The pldebugger is available as an extension for your PostgreSQL database. 

For this guide we have already set up PostgreSQL version 12 on a Ubuntu 20.04. These instructions can also be applied if you are running an earlier or later release of PostgreSQL in your environment.

 

Install Prerequisites

sudo apt install build-essential clang-10
sudo apt install postgresql-server-dev-12
sudo apt install openssl
sudo apt install krb5-multidev
sudo apt install libkrb5-dev
sudo apt install libssl-dev

 

Clone pldebugger

cd /usr/local/src
sudo git clone https://git.postgresql.org/git/pldebugger.git

 

Install Debugger

cd pldebugger
export USE_PGXS=1
make
You will need to set appropriate permission on the following directories:
sudo chown -R your_username:your_username /usr/lib/postgresql
sudo chown -R your_username:your_username /usr/share/postgresql
sudo chown -R your_username:your_username /usr/share/doc/postgresql-doc-12
make install
Now revert the permission back to root:
sudo chown -R root:root /usr/lib/postgresql
sudo chown -R root:root /usr/share/postgresql
sudo chown -R root:root /usr/share/doc/postgresql-doc-12
Next, edit postgresql.conf file with any of your favorite text editor:
sudo nano /etc/postgresql/12/main/postgresql.conf
Find the following line, uncomment and add plugin_debugger like below:
shared_preload_libraries = 'plugin_debugger'

Save and close the editor when you are finished.

Restart PostgreSQL to take changes into effect:

sudo pg_ctlcluster --mod fast 12 main restart
sudo systemctl restart postgresql
sudo systemctl status postgresql
Next, connect to a PostgreSQL database, you would like to enable debugging and type below on postgres=# prompt to install the pldbgapi extension:
psql -h localhost -U postgres

CREATE EXTENSION pldbgapi;

\q

 

Wrapping up

You now have successfully installed pldebugger for your PostgreSQL database on Ubuntu 18/19/20.04.

1 comment:

  1. Thank you very much, excellent guide.

    Just add two things, in Ubuntu 20.04 it is required to install clang-10:

    $ sudo apt install clang-10

    And the directory "/usr/share/doc/postgresql-doc-12" does not exist, it must be created:

    $ sudo mkdir /usr/share/doc/postgresql-doc-12

    ReplyDelete

Comments with links will not be published.

Powered by Blogger.