PolarDB for PostgreSQL(Compatible with Oracle) 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 extension to debug stored procedures.

Prerequisites

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.

Precautions

PolarDB limits the maximum number of connections to the pldebugger extension. Each cluster can have up to three connections to the pldebugger extension. To use more than three connections on a cluster, go to the Quota Center. Click Apply in the Actions column corresponding to PolarDB PG pldebugger plug-in use.

Otherwise, if you need to initiate a new connection between your cluster and pldebugger in addition to three existing connections, you must close one of the existing connections.

Create the pldebugger extension.

Create and debug the extension as the polar_superuser user.

postgres=# CREATE EXTENSION if not exists pldbgapi;
CREATE EXTENSION

Use the pldebugger extension

  1. Use pgAdmin 4 to connect to the PolarDB cluster. For more information, see Connect to a PolarDB cluster.
  2. Find the function to be debugged, right-click the function, and choose Debugging > Debug.
    Use pldebugger - 1
  3. Use the pldebugger extension 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 example shows that six connections are used. Each pldebugger debugging process requires two connections. Therefore, three debugging processes exist in the preceding example. A maximum of three pldebugger processes are allowed.