Skip to content

Commit a6a399a

Browse files
committed
[PGPRO-7614] Do not free hash_seq_search scans of parent transaction
Tags: pg_variables, atx
1 parent ff47670 commit a6a399a

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

expected/pg_variables_atx_pkg.out

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,27 @@ ERROR: unrecognized package "vars"
266266
SELECT pgv_get('vars', 'int1', null::int);
267267
ERROR: unrecognized package "vars"
268268
ROLLBACK;
269+
--
270+
--
271+
-- Do not free hash_seq_search scans of parent transaction.
272+
--
273+
BEGIN;
274+
SELECT pgv_insert('test', 'x', row (1::int, 2::int), false);
275+
pgv_insert
276+
------------
277+
278+
(1 row)
279+
280+
DECLARE r1_cur CURSOR FOR SELECT pgv_select('test', 'x');
281+
FETCH 1 IN r1_cur;
282+
pgv_select
283+
------------
284+
(1,2)
285+
(1 row)
286+
287+
BEGIN AUTONOMOUS;
288+
ROLLBACK;
289+
ROLLBACK;
269290
select pgv_free();
270291
pgv_free
271292
----------

expected/pg_variables_atx_pkg_1.out

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,31 @@ WARNING: there is no transaction in progress
296296
1
297297
(1 row)
298298

299+
ROLLBACK;
300+
WARNING: there is no transaction in progress
301+
--
302+
--
303+
-- Do not free hash_seq_search scans of parent transaction.
304+
--
305+
BEGIN;
306+
SELECT pgv_insert('test', 'x', row (1::int, 2::int), false);
307+
pgv_insert
308+
------------
309+
310+
(1 row)
311+
312+
DECLARE r1_cur CURSOR FOR SELECT pgv_select('test', 'x');
313+
FETCH 1 IN r1_cur;
314+
pgv_select
315+
------------
316+
(1,2)
317+
(1 row)
318+
319+
BEGIN AUTONOMOUS;
320+
ERROR: syntax error at or near "AUTONOMOUS"
321+
LINE 1: BEGIN AUTONOMOUS;
322+
^
323+
ROLLBACK;
299324
ROLLBACK;
300325
WARNING: there is no transaction in progress
301326
select pgv_free();

pg_variables.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,7 +2951,11 @@ freeStatsLists(void)
29512951
{
29522952
VariableStatEntry *entry = (VariableStatEntry *) lfirst(cell);
29532953

2954+
#ifdef PGPRO_EE
2955+
hash_seq_term_all_levels(entry->status);
2956+
#else
29542957
hash_seq_term(entry->status);
2958+
#endif
29552959
}
29562960

29572961
variables_stats = NIL;
@@ -2960,7 +2964,11 @@ freeStatsLists(void)
29602964
{
29612965
PackageStatEntry *entry = (PackageStatEntry *) lfirst(cell);
29622966

2967+
#ifdef PGPRO_EE
2968+
hash_seq_term_all_levels(entry->status);
2969+
#else
29632970
hash_seq_term(entry->status);
2971+
#endif
29642972
}
29652973

29662974
packages_stats = NIL;

sql/pg_variables_atx_pkg.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,16 @@ BEGIN;
131131
-- ERROR: unrecognized package "vars"
132132
SELECT pgv_get('vars', 'int1', null::int);
133133
ROLLBACK;
134+
--
135+
--
136+
-- Do not free hash_seq_search scans of parent transaction.
137+
--
138+
BEGIN;
139+
SELECT pgv_insert('test', 'x', row (1::int, 2::int), false);
140+
DECLARE r1_cur CURSOR FOR SELECT pgv_select('test', 'x');
141+
FETCH 1 IN r1_cur;
142+
BEGIN AUTONOMOUS;
143+
ROLLBACK;
144+
ROLLBACK;
134145

135146
select pgv_free();

0 commit comments

Comments
 (0)