and support multiple procedural languages, such as PLpgSQL, PL/Python, PL/Perl, PL/Tcl, and PL/Java. You can use these languages to create functions or stored procedures. PolarDB provides the pldebugger extension to help you debug them.
Prerequisites
You must use pgAdmin 4 client V4.19 or later. For download instructions, see the pgAdmin Download page.
Usage notes
PolarDB limits the number of concurrent debugging sessions for the pldebugger extension. Each cluster supports a maximum of three active debugging sessions. If you require more than three debugging sessions, go to Quota Center. Find the quota named PolarDB PG pldebugger plug-in usage, and in the Operation column, click Apply to request an increase.
For example, if three debugging sessions are active, a fourth will fail to start. To resolve this, close one of the active sessions.
Create the extension
Use a privileged account to create the extension.
CREATE EXTENSION IF NOT EXISTS pldbgapi;
Use the extension
-
To connect to a PolarDB cluster by using pgAdmin 4, see .
-
Find the function that you want to debug, right-click the function, and then select Debugging > Debug.
-
This opens the pldebugger panel in pgAdmin 4.
declare v_result int; begin v_result := 0; if i<0 then raise notice 'Please enter i >=0.'; raise exception ''; end if; for x in 0..i loop v_result := v_result + x; end loop; return v_result; exception when others then return -1; end;-
In the function debugging panel on the right side of the pgAdmin 4 page, you can step through the target function. For example, you can use
step into/overandcontinue, set breakpoints, or stop the execution. -
At the bottom of the pgAdmin 4 page, you can view local variables, debugging results, and the function stack.
-
Monitor debugging connections
PolarDB provides a function to monitor pldebugger connections. This function returns the current number of active connections and the configured maximum limit.
This function is supported only on PolarDB for PostgreSQL with .
SELECT * FROM polar_monitor_pldebugger_count();
The following result is returned:
current_connection | max_connection
--------------------+----------------
6 | 6
(1 row)
-
current_connection: The number of connections currently in use. -
max_connection: The maximum number of debugging connections allowed by default.
The example output shows six connections are in use. Because each pldebugger session uses two connections, this indicates three active pldebugger processes, which is the maximum number allowed.