@@ -19,32 +19,50 @@ import net.plpgsql.ideadebugger.Producer
1919import net.plpgsql.ideadebugger.SELECT_NULL
2020
2121/* *
22- * API queries.
22+ * API queries for the PL/pgSQL debugger .
2323 *
24- * @property sql The SQL query.
25- * @property producer The producer.
26- * @property disableDecoration Disable decoration.
27- * @property print Print.
24+ * This enum defines all the SQL queries used by the debugger to interact with the PostgreSQL database.
25+ * Each enum value represents a specific query operation with its corresponding SQL statement and result producer.
26+ *
27+ * @property sql The SQL query to be executed.
28+ * @property producer The producer that converts the query result to a specific data type.
29+ * @property disableDecoration Whether to disable SQL decoration for this query.
30+ * @property print Whether to print the query execution in the debug console.
2831 */
2932enum class ApiQuery (val sql : String ,
3033 val producer : Producer <Any >,
3134 val disableDecoration : Boolean = false ,
3235 val print : Boolean = true ) {
33- // Do nothing.
36+ /* *
37+ * A void query that does nothing.
38+ * Used as a placeholder or when no operation is needed.
39+ */
3440 VOID (
3541 SELECT_NULL ,
3642 Producer { PlApiVoid () }),
37- // Execute a simple query
43+
44+ /* *
45+ * Executes a raw SQL query without returning any result.
46+ * The query is passed as a parameter and executed as-is without decoration.
47+ */
3848 RAW_VOID (
3949 " %s" ,
4050 Producer { PlApiVoid () },
4151 true
4252 ),
43- // Execute a simple query and return a boolean.
53+
54+ /* *
55+ * Executes a raw SQL query and returns a boolean result.
56+ * Used for simple boolean operations.
57+ */
4458 RAW_BOOL (
4559 " %s" ,
4660 Producer { PlApiBoolean (it.bool()) }),
47- // Get the current session.
61+
62+ /* *
63+ * Retrieves information about the current debugging sessions.
64+ * Returns active PostgreSQL sessions with the debugger application name.
65+ */
4866 PG_ACTIVITY (
4967 """
5068 SELECT pid,
@@ -56,26 +74,46 @@ enum class ApiQuery(val sql: String,
5674 AND pid <> pg_backend_pid();
5775 """ ,
5876 Producer { PlActivity (it.long(), it.string(), it.string(), it.string()) }),
59- // Terminate a session.
77+
78+ /* *
79+ * Terminates a PostgreSQL backend session.
80+ * Used to cancel a debugging session.
81+ */
6082 PG_CANCEL (
6183 """
6284 SELECT pg_terminate_backend(%s);
6385 """ ,
6486 Producer { PlApiBoolean (it.bool()) }
6587 ),
66- // Create a debugger listener.
88+
89+ /* *
90+ * Creates a debugger listener in the PostgreSQL server.
91+ * This is the first step in establishing a debugging session.
92+ */
6793 CREATE_LISTENER (
6894 " pldbg_create_listener()" ,
6995 Producer { PlApiInt (it.int()) }),
70- // Wait for a target.
96+
97+ /* *
98+ * Waits for a target function to be executed in debug mode.
99+ * Blocks until a function is called with debugging enabled.
100+ */
71101 WAIT_FOR_TARGET (
72102 " pldbg_wait_for_target(%s)" ,
73103 Producer { PlApiInt (it.int()) }),
74- // Abort a target.
104+
105+ /* *
106+ * Aborts the current debugging target.
107+ * Terminates the current debugging session.
108+ */
75109 ABORT (
76110 " pldbg_abort_target(%s)" ,
77111 Producer { PlApiBoolean (it.bool()) }),
78- // Step over and return the line number and the function source
112+
113+ /* *
114+ * Steps over the current line in the debugged function.
115+ * Returns the new position (function OID, line number) and a hash of the function source.
116+ */
79117 STEP_OVER (
80118 """
81119 SELECT step.func,
@@ -84,6 +122,11 @@ enum class ApiQuery(val sql: String,
84122 FROM pldbg_step_over(%s) step;
85123 """ ,
86124 Producer { PlApiStep (it.long(), it.int(), it.string()) }),
125+
126+ /* *
127+ * Steps into a function call at the current line.
128+ * Returns the new position (function OID, line number) and a hash of the function source.
129+ */
87130 STEP_INTO (
88131 """
89132 SELECT step.func,
@@ -92,6 +135,11 @@ enum class ApiQuery(val sql: String,
92135 FROM pldbg_step_into(%s) step;
93136 """ ,
94137 Producer { PlApiStep (it.long(), it.int(), it.string()) }),
138+
139+ /* *
140+ * Continues execution until the next breakpoint or the end of the function.
141+ * Returns the new position (function OID, line number) and a hash of the function source.
142+ */
95143 STEP_CONTINUE (
96144 """
97145 SELECT step.func,
@@ -101,6 +149,10 @@ enum class ApiQuery(val sql: String,
101149 """ ,
102150 Producer { PlApiStep (it.long(), it.int(), it.string()) }),
103151
152+ /* *
153+ * Lists all breakpoints in the current debugging session.
154+ * Returns the function OID and line number for each breakpoint.
155+ */
104156 LIST_BREAKPOINT (
105157 """
106158 SELECT bp.func,
@@ -109,16 +161,35 @@ enum class ApiQuery(val sql: String,
109161 FROM pldbg_get_breakpoints(%s) bp;
110162 """ ,
111163 Producer { PlApiStep (it.long(), it.int(), it.string()) }),
164+
165+ /* *
166+ * Sets a global breakpoint for a specific function.
167+ * Global breakpoints are triggered whenever the function is called.
168+ */
112169 SET_GLOBAL_BREAKPOINT (
113170 " pldbg_set_global_breakpoint(%s, %s, -1, NULL)" ,
114171 Producer { PlApiBoolean (it.bool()) }),
172+
173+ /* *
174+ * Sets a breakpoint at a specific line in a function.
175+ * Returns true if the breakpoint was successfully set.
176+ */
115177 SET_BREAKPOINT (
116178 " pldbg_set_breakpoint(%s, %s, %s)" ,
117179 Producer { PlApiBoolean (it.bool()) }),
180+
181+ /* *
182+ * Removes a breakpoint from a specific line in a function.
183+ * Returns true if the breakpoint was successfully removed.
184+ */
118185 DROP_BREAKPOINT (
119186 " pldbg_drop_breakpoint(%s, %s, %s)" ,
120187 Producer { PlApiBoolean (it.bool()) }),
121188
189+ /* *
190+ * Retrieves the current call stack of the debugged function.
191+ * Returns information about each stack frame including function OID, line number, and source hash.
192+ */
122193 GET_STACK (
123194 """
124195 SELECT
@@ -137,6 +208,12 @@ enum class ApiQuery(val sql: String,
137208 )
138209 }
139210 ),
211+
212+ /* *
213+ * Retrieves all variables in the current stack frame.
214+ * Joins with pg_type to get detailed type information for each variable.
215+ * Returns variable information including name, type, value, and metadata.
216+ */
140217 GET_RAW_VARIABLES (
141218 """
142219 SELECT
@@ -172,6 +249,12 @@ enum class ApiQuery(val sql: String,
172249 )
173250 }
174251 ),
252+
253+ /* *
254+ * Retrieves variables in JSON format.
255+ * Used for custom variable queries with JSON output.
256+ * The SQL query is provided as a parameter.
257+ */
175258 GET_JSON_VARIABLES (
176259 sql = " %s" ,
177260 producer = Producer {
@@ -365,6 +448,3 @@ enum class ApiQuery(val sql: String,
365448 }
366449 ),
367450}
368-
369-
370-
0 commit comments