Skip to content

Commit ff47670

Browse files
committed
[PGPRO-7614] Fix conflict between atx and pgv_free()
Tags: pg_variables, atx
1 parent ffdf242 commit ff47670

6 files changed

+747
-2
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ env:
3535
- PG_VERSION=11 LEVEL=nightmare
3636
- PG_VERSION=11 LEVEL=hardcore
3737
- PG_VERSION=11
38-
- PG_VERSION=10
3938

4039
# XXX: consider fixing nightmare mode
4140
matrix:

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ DATA_built = $(EXTENSION)--$(EXTVERSION).sql
1010

1111
PGFILEDESC = "pg_variables - sessional variables"
1212

13-
REGRESS = pg_variables pg_variables_any pg_variables_trans pg_variables_atx
13+
REGRESS = pg_variables pg_variables_any pg_variables_trans pg_variables_atx \
14+
pg_variables_atx_pkg
1415

1516
ifdef USE_PGXS
1617
PG_CONFIG = pg_config

expected/pg_variables_atx_pkg.out

+274
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
--
2+
-- PGPRO-7614: function pgv_free() inside autonomous transaction
3+
--
4+
select pgv_free();
5+
pgv_free
6+
----------
7+
8+
(1 row)
9+
10+
--
11+
--
12+
-- Functions pgv_free() + pgv_get() inside autonomous transaction; package
13+
-- with regular variable; autonomous transaction with commit.
14+
--
15+
BEGIN;
16+
SELECT pgv_set('vars', 'int1', 1);
17+
pgv_set
18+
---------
19+
20+
(1 row)
21+
22+
BEGIN AUTONOMOUS;
23+
SELECT pgv_get('vars', 'int1', null::int);
24+
pgv_get
25+
---------
26+
1
27+
(1 row)
28+
29+
SELECT pgv_free();
30+
pgv_free
31+
----------
32+
33+
(1 row)
34+
35+
-- ERROR: unrecognized package "vars"
36+
SELECT pgv_get('vars', 'int1', null::int);
37+
ERROR: unrecognized package "vars"
38+
COMMIT;
39+
-- ERROR: unrecognized package "vars"
40+
SELECT pgv_get('vars', 'int1', null::int);
41+
ERROR: unrecognized package "vars"
42+
ROLLBACK;
43+
--
44+
--
45+
-- Function pgv_free() inside autonomous transaction; package with
46+
-- regular variable; autonomous transaction with commit.
47+
--
48+
BEGIN;
49+
SELECT pgv_set('vars', 'int1', 1);
50+
pgv_set
51+
---------
52+
53+
(1 row)
54+
55+
BEGIN AUTONOMOUS;
56+
SELECT pgv_free();
57+
pgv_free
58+
----------
59+
60+
(1 row)
61+
62+
COMMIT;
63+
-- ERROR: unrecognized package "vars"
64+
SELECT pgv_get('vars', 'int1', null::int);
65+
ERROR: unrecognized package "vars"
66+
ROLLBACK;
67+
--
68+
--
69+
-- Function pgv_free() inside autonomous transaction; package with
70+
-- regular variable; autonomous transaction with rollback.
71+
--
72+
BEGIN;
73+
SELECT pgv_set('vars', 'int1', 1);
74+
pgv_set
75+
---------
76+
77+
(1 row)
78+
79+
BEGIN AUTONOMOUS;
80+
SELECT pgv_free();
81+
pgv_free
82+
----------
83+
84+
(1 row)
85+
86+
ROLLBACK;
87+
-- ERROR: unrecognized package "vars"
88+
SELECT pgv_get('vars', 'int1', null::int);
89+
ERROR: unrecognized package "vars"
90+
ROLLBACK;
91+
--
92+
--
93+
-- Function pgv_free() inside autonomous transaction; package with
94+
-- transactional variable; autonomous transaction with rollback.
95+
--
96+
BEGIN;
97+
SELECT pgv_set('vars', 'int1', 1, true);
98+
pgv_set
99+
---------
100+
101+
(1 row)
102+
103+
BEGIN AUTONOMOUS;
104+
SELECT pgv_free();
105+
pgv_free
106+
----------
107+
108+
(1 row)
109+
110+
ROLLBACK;
111+
SELECT pgv_get('vars', 'int1', null::int);
112+
pgv_get
113+
---------
114+
1
115+
(1 row)
116+
117+
ROLLBACK;
118+
--
119+
--
120+
-- Function pgv_free() inside autonomous transaction; package with
121+
-- transactional variable; autonomous transaction with commit.
122+
--
123+
BEGIN;
124+
SELECT pgv_set('vars', 'int1', 1, true);
125+
pgv_set
126+
---------
127+
128+
(1 row)
129+
130+
BEGIN AUTONOMOUS;
131+
SELECT pgv_free();
132+
pgv_free
133+
----------
134+
135+
(1 row)
136+
137+
COMMIT;
138+
-- ERROR: unrecognized package "vars"
139+
SELECT pgv_get('vars', 'int1', null::int);
140+
ERROR: unrecognized package "vars"
141+
ROLLBACK;
142+
--
143+
--
144+
-- Function pgv_free() inside recursive autonomous transactions.
145+
--
146+
BEGIN;
147+
BEGIN AUTONOMOUS;
148+
SELECT pgv_set('vars', 'int1', 1);
149+
pgv_set
150+
---------
151+
152+
(1 row)
153+
154+
BEGIN AUTONOMOUS;
155+
BEGIN AUTONOMOUS;
156+
SELECT pgv_free();
157+
pgv_free
158+
----------
159+
160+
(1 row)
161+
162+
COMMIT;
163+
-- ERROR: unrecognized package "vars"
164+
SELECT pgv_get('vars', 'int1', null::int);
165+
ERROR: unrecognized package "vars"
166+
COMMIT;
167+
-- ERROR: unrecognized package "vars"
168+
SELECT pgv_get('vars', 'int1', null::int);
169+
ERROR: unrecognized package "vars"
170+
COMMIT;
171+
ROLLBACK;
172+
--
173+
--
174+
-- Function pgv_free() inside recursive autonomous transactions;
175+
-- recreating the package after deletion with using regular
176+
-- variable.
177+
--
178+
BEGIN;
179+
SELECT pgv_set('vars', 'int1', 1);
180+
pgv_set
181+
---------
182+
183+
(1 row)
184+
185+
BEGIN AUTONOMOUS;
186+
BEGIN AUTONOMOUS;
187+
SELECT pgv_get('vars', 'int1', null::int);
188+
pgv_get
189+
---------
190+
1
191+
(1 row)
192+
193+
BEGIN AUTONOMOUS;
194+
SELECT pgv_free();
195+
pgv_free
196+
----------
197+
198+
(1 row)
199+
200+
COMMIT;
201+
-- ERROR: unrecognized package "vars"
202+
SELECT pgv_get('vars', 'int1', null::int);
203+
ERROR: unrecognized package "vars"
204+
COMMIT;
205+
SELECT pgv_set('vars', 'int1', 2);
206+
pgv_set
207+
---------
208+
209+
(1 row)
210+
211+
COMMIT;
212+
SELECT pgv_get('vars', 'int1', null::int);
213+
pgv_get
214+
---------
215+
2
216+
(1 row)
217+
218+
ROLLBACK;
219+
--
220+
--
221+
-- Function pgv_free() inside recursive autonomous transactions;
222+
-- recreating the package after deletion with using transactional
223+
-- variable.
224+
--
225+
BEGIN;
226+
SELECT pgv_set('vars', 'int1', 1);
227+
pgv_set
228+
---------
229+
230+
(1 row)
231+
232+
BEGIN AUTONOMOUS;
233+
BEGIN AUTONOMOUS;
234+
SELECT pgv_get('vars', 'int1', null::int);
235+
pgv_get
236+
---------
237+
1
238+
(1 row)
239+
240+
BEGIN AUTONOMOUS;
241+
SELECT pgv_free();
242+
pgv_free
243+
----------
244+
245+
(1 row)
246+
247+
COMMIT;
248+
-- ERROR: unrecognized package "vars"
249+
SELECT pgv_get('vars', 'int1', null::int);
250+
ERROR: unrecognized package "vars"
251+
COMMIT;
252+
SELECT pgv_set('vars', 'int1', 2, true);
253+
pgv_set
254+
---------
255+
256+
(1 row)
257+
258+
SELECT pgv_list();
259+
pgv_list
260+
---------------
261+
(vars,int1,t)
262+
(1 row)
263+
264+
COMMIT;
265+
-- ERROR: unrecognized package "vars"
266+
SELECT pgv_get('vars', 'int1', null::int);
267+
ERROR: unrecognized package "vars"
268+
ROLLBACK;
269+
select pgv_free();
270+
pgv_free
271+
----------
272+
273+
(1 row)
274+

0 commit comments

Comments
 (0)