PolarDB for PostgreSQL supports multiple stored procedure languages (SPLs) such as PL/pgSQL, PL/Python, PL/Perl, PL/Tcl, and PL/Java. You can use these SPLs to create functions or stored procedures. PolarDB provides the pldebugger plug-in to debug stored procedures.


The version of the pgAdmin 4 client is v4.19 or later. For more information about how to download the pgAdmin 4 client, see Download.


PolarDB limits the maximum number of connections to the pldebugger plug-in. Each cluster can have up to three connections to the pldebugger plug-in. If your cluster must have more than three connections to the pldebugger plug-in, Submit a ticket.

For example, if you need to initiate a fourth connection between your cluster and pldebugger, submit a ticket to ask after-sales personnel to close one of the existing three connections.

Create pldebugger

Create and debug the plug-in as the polar_superuser user.

postgres=# CREATE EXTENSION if not exists pldbgapi;

Use pldebugger

  1. Use pgAdmin 4 to connect to the PolarDB cluster. For more information, see .
  2. Find the function to be debugged, right-click the function, and choose Debugging > Debug.
    Use pldebugger - 1
  3. Use the pldebugger plug-in in pgAdmin 4.
    Use pldebugger - 2
    • In the function debugging section on the right of the pgAdmin 4 page, you can perform step-by-step operations to debug the function, such as step into/over, continue, set breakpoints, and stop.
    • At the bottom of the pgAdmin 4 page, you can view the local variables, debugging results, and function stacks during the debugging.

Monitor connections to pldebugger

PolarDB allows you to monitor the connections to pldebugger. You can use the following function to query the number of existing connections and the default maximum number of connections to pldebugger:

postgres=# select * from polar_monitor_pldebugger_count();
 current_connection | max_connection
                  6 |              6
(1 row)
  • current_connection: the number of existing connections.
  • max_connection: the default maximum number of connections.

The preceding output shows that the number of existing connections to pldebugger is 6. Each pldebugger debugging process requires two connections. Therefore, three debugging processes exist in the preceding example. A maximum of three pldebugger processes are allowed.