pg.ddx.io pgaudit/pgaudit GitHub issues and pull requests
help / color / mirror / Atom feedRe: [pgaudit/pgaudit] PR #324: Add exception for fetch statement to stack check.
7+ messages / 2 participants
[nested] [flat]
* [pgaudit/pgaudit] PR #324: Add exception for fetch statement to stack check.
@ 2026-06-26 08:46 "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
0 siblings, 0 replies; 7+ messages in thread
From: dwsteele (@dwsteele) @ 2026-06-26 08:46 UTC (permalink / raw)
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
A fetch statement can be on the stack when another command is executed if the cursor is fetched with a row limit, e.g. JDBC setFetchSize(), which leaves the portal suspended. If this happens the user will get a 'pgaudit stack is not empty' error.
Prevent this by allowing fetch statements on the stack when a new command runs, and add a FETCH case to the stack check test.
inline patch 1: pgaudit.c, t/010_check_stack.pl (+9/-2 lines) download inline-1.patch
diff --git a/pgaudit.c b/pgaudit.c
index a1b01d4..1cab0fa 100644
--- a/pgaudit.c
+++ b/pgaudit.c
@@ -1645,7 +1645,7 @@ pgaudit_ProcessUtility_hook(PlannedStmt *pstmt,
{
/*
* If the stack is not empty then the only allowed entries are call
- * statements or open, select, show, and explain cursors
+ * statements or open, select, show, explain, and fetch cursors
*/
if (auditEventStack != NULL)
{
@@ -1656,7 +1656,8 @@ pgaudit_ProcessUtility_hook(PlannedStmt *pstmt,
if (nextItem->auditEvent.commandTag != T_SelectStmt &&
nextItem->auditEvent.commandTag != T_VariableShowStmt &&
nextItem->auditEvent.commandTag != T_ExplainStmt &&
- nextItem->auditEvent.commandTag != T_CallStmt)
+ nextItem->auditEvent.commandTag != T_CallStmt &&
+ nextItem->auditEvent.commandTag != T_FetchStmt)
{
elog(ERROR, "pgaudit stack is not empty");
}
diff --git a/t/010_check_stack.pl b/t/010_check_stack.pl
index 8e07121..5563671 100644
--- a/t/010_check_stack.pl
+++ b/t/010_check_stack.pl
@@ -200,6 +200,12 @@ sub pg_connect
stmt => q{CALL pcursor('cc')},
log => qr/AUDIT:.*,CALL,/,
},
+ {
+ name => 'FETCH',
+ setup => ['DECLARE c CURSOR FOR SELECT generate_series(1, 5)'],
+ stmt => 'FETCH ALL FROM c',
+ log => qr/AUDIT:.*,FETCH,/,
+ },
);
# Run each scenario on its own connection: optionally set up state, run the
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgaudit/pgaudit] PR #324: Add exception for fetch statement to stack check.
@ 2026-06-26 08:46 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: dwsteele (@dwsteele) @ 2026-06-26 08:46 UTC (permalink / raw)
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
@dwsteele assigned @dwsteele.
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgaudit/pgaudit] PR #324: Add exception for fetch statement to stack check.
@ 2026-06-26 08:46 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: dwsteele (@dwsteele) @ 2026-06-26 08:46 UTC (permalink / raw)
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
@dwsteele applied label "bug".
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgaudit/pgaudit] PR #324 (approved): Add exception for fetch statement to stack check.
@ 2026-06-28 19:09 ` "pgguru (@pgguru)" <noreply+pgguru@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: pgguru (@pgguru) @ 2026-06-28 19:09 UTC (permalink / raw)
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
Are these being backported I assume?
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgaudit/pgaudit] PR #324: Add exception for fetch statement to stack check.
@ 2026-06-29 02:01 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: dwsteele (@dwsteele) @ 2026-06-29 02:01 UTC (permalink / raw)
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
> Are these being backported I assume?
Yes, this is a bug so it will be back-ported. Thank you for for the review!
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgaudit/pgaudit] PR #324: Add exception for fetch statement to stack check.
@ 2026-06-29 02:04 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: dwsteele (@dwsteele) @ 2026-06-29 02:04 UTC (permalink / raw)
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
@dwsteele closed this.
^ permalink raw [nested|flat] 7+ messages in thread
* Re: [pgaudit/pgaudit] PR #324: Add exception for fetch statement to stack check.
@ 2026-06-29 02:04 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
5 siblings, 0 replies; 7+ messages in thread
From: dwsteele (@dwsteele) @ 2026-06-29 02:04 UTC (permalink / raw)
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
@dwsteele merged this (commit 3104214bad06).
^ permalink raw [nested|flat] 7+ messages in thread
end of thread, other threads:[~2026-06-29 02:04 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-06-26 08:46 [pgaudit/pgaudit] PR #324: Add exception for fetch statement to stack check. "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
2026-06-26 08:46 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
2026-06-26 08:46 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
2026-06-28 19:09 ` Re: [pgaudit/pgaudit] PR #324 (approved): Add exception for fetch statement to stack check. "pgguru (@pgguru)" <noreply+pgguru@github.com>
2026-06-29 02:01 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
2026-06-29 02:04 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
2026-06-29 02:04 ` "dwsteele (@dwsteele)" <noreply+dwsteele@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox