Skip to content

Commit 64701a5

Browse files
committed
Update README and enrich ApiQuery documentation
Refined `README.md` links, environment variables formatting, and plugin installation instructions. Expanded `ApiQuery` class comments to improve clarity and explain properties, use cases, and behavior of query operations.
1 parent de0419f commit 64701a5

File tree

2 files changed

+105
-26
lines changed

2 files changed

+105
-26
lines changed

README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Debug PL/pg stored procedures, functions, triggers and views from Intellij IDEs
1111

1212
- Debug queries from editor by selecting a [function call](#debug-a-routine-from-the-editor)
1313
- Debug routines and triggers from [database explorer](#debug-a-routine-from-the-database-explorer)
14-
- Full support for variables inspection with [Docker custom debugger](https://github.com/ng-galien/idea-plpgdebugger/blob/221/docker/README.md)
14+
- Full support for variables inspection with [Docker custom debugger](https://github.com/ng-galien/pldebugger/tree/print-vars/docker)
1515

1616
Visit the plugin [page](https://plugins.jetbrains.com/plugin/18419-postgresql-debugger) at JetBrains.
1717
Report a bug or a problem => [Create an issue](https://github.com/ng-galien/idea-plpgdebugger/issues/new/choose)
@@ -149,14 +149,13 @@ The standard pldbgapi does not send back composite variable, but you can put it
149149
You must first install the debugger extension and activate the shared library onto the server.
150150

151151
```shell
152-
EXPORT TAG = 11 # or 11, 12, 13, 14, 15
153-
EXPORT PG_LIB=postgresql-server-dev-${TAG}
154-
EXPORT PG_BRANCH=REL_${TAG}_STABLE
155-
EXPORT PLUGIN_BRANCH=print-vars
152+
export TAG=11 # or 11, 12, 13, 14, 15
153+
export PG_LIB=postgresql-server-dev-${TAG}
154+
export PG_BRANCH=REL_${TAG}_STABLE
155+
export PLUGIN_BRANCH=print-vars
156156

157157
# Install dependencies
158-
apt --yes update && apt --yes upgrade && apt --yes install git build-essential libreadline-dev zlib1g-dev bison libkrb5-dev flex $PG_LIB \
159-
#
158+
apt --yes update && apt --yes upgrade && apt --yes install git build-essential libreadline-dev zlib1g-dev bison libkrb5-dev flex $PG_LIB
160159
cd /usr/src/
161160
# Install postgres source
162161
git clone -b $PG_BRANCH --single-branch https://github.com/postgres/postgres.git
@@ -176,10 +175,10 @@ Follow these [instructions for PgAdmin](https://www.pgadmin.org/docs/pgadmin4/de
176175
### Intellij IDE
177176

178177
- Using IDE built-in plugin system:
179-
178+
180179
<kbd>Settings/Preferences</kbd> > <kbd>Plugins</kbd> > <kbd>Marketplace</kbd> > <kbd>Search for "idea-plpgdebugger"</kbd> >
181180
<kbd>Install Plugin</kbd>
182-
181+
183182
- Manually:
184183

185184
Download the [latest release](https://github.com/ng-galien/idea-plpgdebugger/releases/latest) and install it manually using

src/main/kotlin/net/plpgsql/ideadebugger/command/ApiQuery.kt

Lines changed: 97 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,50 @@ import net.plpgsql.ideadebugger.Producer
1919
import 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
*/
2932
enum 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

Comments
 (0)