Raise Notice is to Postgres what print is to Python. You can use it occasionally, but if you have serious development work to do, you should use debugging tools.


1. Install the pgAdmin Debugger

Postgres’ official stored procedure debugging tool is pgAdmin Debugger, which is a server extension. The utility doesn’t come with PostgresqL-Server or pgAdmin, so you’ll have to download and install it yourself.

Here is Ubuntu as an example to introduce its installation: first, it does not support apt install. Visit https://packages.ubuntu.com/bionic/postgresql-10-pldebugger web pages, depending on your operating system architecture, download the binary file to the local. It is a.deb installation package and then executes:

Sudo DPKG -i postgresql-10-pldebugger_1-0-3-g71AC998-1_amd64. deb --output-- (Reading database... 84865 files and directories currently installed.) Preparing to unpack Postgresql - 10 - pldebugger_1. 0-3 - _amd64 g71ac998-1. Deb... Unpacking postgresqL-10-pldebugger (1:1.0-3-G71AC998-1) over (1:1.0-3-G71AC998-1) over (1:1.0-3-G71AC998-1) over (1:1.0-3-G71AC998-1) over (1:1.0-3-G71AC998-1) Setting up postgresqL-10-pldebugger (1:1.0-3-G71AC998-1) Processing Triggers for PostgresQL - Common (190.pgdg16.04 +1)... Building PostgreSQL dictionaries from installed myspell/hunspell packages... Removing obsolete dictionary files:Copy the code

2. The configuration

Modify/etc/postgres / 10 / main/postgresql. Conf is as follows:

shared_preload_libraries = '$libdir/plugin_debugger'Copy the code

Notice that the values here are just as they are. And then restart the server

sudo service postgresql restartCopy the code

Check main*. Log in /var/log/postgresql to check whether the service is successfully started. Execute in the query window

show shared_preload_libraries
---output---
$libdir/plugin_debuggerCopy the code

If the preceding output is displayed, the installation is successful.

3. Enable debugging on the client

  1. First, load the debug extension in the PGadmin window, noting that the scope of this extension is database-level:

2. Load the stored procedure and start debugging. Note that you must first write the stored procedure, store it on the server, and then load it. You cannot write and debug the procedure in the Query Tool window.