@@ -139,7 +139,8 @@ def test_simple_query(config):
139
139
-> Seq Scan on bar \(Current loop: actual rows=9, loop number=1\)"""
140
140
141
141
qs = query_state (config ,acon ,query ,num_steps )
142
- assert len (qs )== 1 and qs [0 ][0 ]== query and re .match (expected ,qs [0 ][1 ])
142
+ assert len (qs )== 1 and qs [0 ][0 ]== acon .get_backend_pid ()and qs [0 ][1 ]== 0 \
143
+ and qs [0 ][2 ]== query and re .match (expected ,qs [0 ][3 ])and qs [0 ][4 ]== None
143
144
assert len (notices )== 0
144
145
145
146
n_close ((acon ,))
@@ -161,8 +162,11 @@ def test_concurrent_access(config):
161
162
162
163
qs1 ,qs2 = acurs1 .fetchall (),acurs2 .fetchall ()
163
164
assert len (qs1 )== len (qs2 )== 1 \
164
- and qs1 [0 ][0 ]== qs2 [0 ][0 ]== query \
165
- and len (qs1 [0 ][1 ])> 0 and len (qs2 [0 ][1 ])> 0
165
+ and qs1 [0 ][0 ]== qs2 [0 ][0 ]== acon3 .get_backend_pid () \
166
+ and qs1 [0 ][1 ]== qs2 [0 ][1 ]== 0 \
167
+ and qs1 [0 ][2 ]== qs2 [0 ][2 ]== query \
168
+ and len (qs1 [0 ][3 ])> 0 and len (qs2 [0 ][3 ])> 0 \
169
+ and qs1 [0 ][4 ]== qs2 [0 ][4 ]== None
166
170
assert len (notices )== 0
167
171
168
172
n_close ((acon1 ,acon2 ,acon3 ))
@@ -199,11 +203,13 @@ def test_nested_call(config):
199
203
200
204
qs = query_state (config ,acon ,call_function ,num_steps )
201
205
assert len (qs )== 2 \
202
- and qs [0 ][0 ]== call_function and qs [0 ][1 ]== expected \
203
- and qs [1 ][0 ]== nested_query and re .match (expected_nested ,qs [1 ][1 ])
206
+ and qs [0 ][0 ]== qs [1 ][0 ]== acon .get_backend_pid () \
207
+ and qs [0 ][1 ]== 0 and qs [1 ][1 ]== 1 \
208
+ and qs [0 ][2 ]== call_function and qs [0 ][3 ]== expected \
209
+ and qs [1 ][2 ]== nested_query and re .match (expected_nested ,qs [1 ][3 ]) \
210
+ and qs [0 ][4 ]== qs [1 ][4 ]== None
204
211
assert len (notices )== 0
205
212
206
-
207
213
util_curs .execute (drop_function )
208
214
209
215
util_conn .close ()
@@ -228,7 +234,10 @@ def test_insert_on_conflict(config):
228
234
util_conn .commit ()
229
235
230
236
qs = query_state (config ,acon ,query ,num_steps )
231
- assert len (qs )== 1 and qs [0 ][0 ]== query and qs [0 ][1 ]== expected
237
+ assert len (qs )== 1 \
238
+ and qs [0 ][0 ]== acon .get_backend_pid ()and qs [0 ][1 ]== 0 \
239
+ and qs [0 ][2 ]== query and qs [0 ][3 ]== expected \
240
+ and qs [0 ][4 ]== None
232
241
assert len (notices )== 0
233
242
234
243
util_curs .execute (drop_field_uniqueness )
@@ -278,14 +287,22 @@ def test_trigger(config):
278
287
279
288
qs = query_state (config ,acon ,query ,num_steps , {'triggers' :True })
280
289
assert len (qs )== 2 \
281
- and qs [0 ][0 ]== query and qs [0 ][1 ]== expected_upper + '\n ' + trigger_suffix \
282
- and qs [1 ][0 ]== 'SELECT new.c1 in (select c1 from foo)' and qs [1 ][1 ]== expected_inner
290
+ and qs [0 ][0 ]== acon .get_backend_pid ()and qs [0 ][1 ]== 0 \
291
+ and qs [0 ][2 ]== query and qs [0 ][3 ]== expected_upper + '\n ' + trigger_suffix \
292
+ and qs [0 ][4 ]== None \
293
+ and qs [1 ][0 ]== acon .get_backend_pid ()and qs [1 ][1 ]== 1 \
294
+ and qs [1 ][2 ]== 'SELECT new.c1 in (select c1 from foo)' and qs [1 ][3 ]== expected_inner \
295
+ and qs [1 ][4 ]== None
283
296
assert len (notices )== 0
284
297
285
298
qs = query_state (config ,acon ,query ,num_steps , {'triggers' :False })
286
299
assert len (qs )== 2 \
287
- and qs [0 ][0 ]== query and qs [0 ][1 ]== expected_upper \
288
- and qs [1 ][0 ]== 'SELECT new.c1 in (select c1 from foo)' and qs [1 ][1 ]== expected_inner
300
+ and qs [0 ][0 ]== acon .get_backend_pid ()and qs [0 ][1 ]== 0 \
301
+ and qs [0 ][2 ]== query and qs [0 ][3 ]== expected_upper \
302
+ and qs [0 ][4 ]== None \
303
+ and qs [1 ][0 ]== acon .get_backend_pid ()and qs [1 ][1 ]== 1 \
304
+ and qs [1 ][2 ]== 'SELECT new.c1 in (select c1 from foo)' and qs [1 ][3 ]== expected_inner \
305
+ and qs [1 ][4 ]== None
289
306
assert len (notices )== 0
290
307
291
308
util_curs .execute (drop_temps )
@@ -308,7 +325,7 @@ def test_costs(config):
308
325
-> Seq Scan on bar \(cost=0.00..\d+.\d+ rows=\d+ width=4\) \(Current loop: actual rows=9, loop number=1\)"""
309
326
310
327
qs = query_state (config ,acon ,query ,num_steps , {'costs' :True })
311
- assert len (qs )== 1 and re .match (expected ,qs [0 ][1 ])
328
+ assert len (qs )== 1 and re .match (expected ,qs [0 ][3 ])
312
329
assert len (notices )== 0
313
330
314
331
n_close ((acon ,))
@@ -332,7 +349,7 @@ def test_buffers(config):
332
349
set_guc (acon ,'pg_query_state.enable_buffers' ,'on' )
333
350
334
351
qs = query_state (config ,acon ,query ,num_steps , {'buffers' :True })
335
- assert len (qs )== 1 and re .match (expected ,qs [0 ][1 ])
352
+ assert len (qs )== 1 and re .match (expected ,qs [0 ][3 ])
336
353
assert len (notices )== 0
337
354
338
355
n_close ((acon ,))
@@ -354,7 +371,7 @@ def test_timing(config):
354
371
set_guc (acon ,'pg_query_state.enable_timing' ,'on' )
355
372
356
373
qs = query_state (config ,acon ,query ,num_steps , {'timing' :True })
357
- assert len (qs )== 1 and re .match (expected ,qs [0 ][1 ])
374
+ assert len (qs )== 1 and re .match (expected ,qs [0 ][3 ])
358
375
assert len (notices )== 0
359
376
360
377
n_close ((acon ,))
@@ -394,12 +411,12 @@ def test_formats(config):
394
411
-> Seq Scan on bar \(Current loop: actual rows=9, loop number=1\)"""
395
412
396
413
qs = query_state (config ,acon ,query ,num_steps , {'format' :'text' })
397
- assert len (qs )== 1 and re .match (expected ,qs [0 ][1 ])
414
+ assert len (qs )== 1 and re .match (expected ,qs [0 ][3 ])
398
415
assert len (notices )== 0
399
416
400
417
qs = query_state (config ,acon ,query ,num_steps , {'format' :'json' })
401
418
try :
402
- js_obj = json .loads (qs [0 ][1 ])
419
+ js_obj = json .loads (qs [0 ][3 ])
403
420
except ValueError :
404
421
assert False ,'Invalid json format'
405
422
assert len (qs )== 1
@@ -410,14 +427,14 @@ def test_formats(config):
410
427
assert len (qs )== 1
411
428
assert len (notices )== 0
412
429
try :
413
- xml_root = ET .fromstring (qs [0 ][1 ])
430
+ xml_root = ET .fromstring (qs [0 ][3 ])
414
431
except :
415
432
assert False ,'Invalid xml format'
416
433
check_xml (xml_root )
417
434
418
435
qs = query_state (config ,acon ,query ,num_steps , {'format' :'yaml' })
419
436
try :
420
- yaml_doc = yaml .load (qs [0 ][1 ])
437
+ yaml_doc = yaml .load (qs [0 ][3 ])
421
438
except :
422
439
assert False ,'Invalid yaml format'
423
440
assert len (qs )== 1
@@ -436,16 +453,16 @@ def test_timing_buffers_conflicts(config):
436
453
buffers_pattern = 'Buffers:'
437
454
438
455
qs = query_state (config ,acon ,query ,num_steps , {'timing' :True ,'buffers' :False })
439
- assert len (qs )== 1 and not re .search (timing_pattern ,qs [0 ][1 ])
456
+ assert len (qs )== 1 and not re .search (timing_pattern ,qs [0 ][3 ])
440
457
assert notices == ['WARNING: timing statistics disabled\n ' ]
441
458
442
459
qs = query_state (config ,acon ,query ,num_steps , {'timing' :False ,'buffers' :True })
443
- assert len (qs )== 1 and not re .search (buffers_pattern ,qs [0 ][1 ])
460
+ assert len (qs )== 1 and not re .search (buffers_pattern ,qs [0 ][3 ])
444
461
assert notices == ['WARNING: buffers statistics disabled\n ' ]
445
462
446
463
qs = query_state (config ,acon ,query ,num_steps , {'timing' :True ,'buffers' :True })
447
- assert len (qs )== 1 and not re .search (timing_pattern ,qs [0 ][1 ]) \
448
- and not re .search (buffers_pattern ,qs [0 ][1 ])
464
+ assert len (qs )== 1 and not re .search (timing_pattern ,qs [0 ][3 ]) \
465
+ and not re .search (buffers_pattern ,qs [0 ][3 ])
449
466
assert len (notices )== 2 and 'WARNING: timing statistics disabled\n ' in notices \
450
467
and 'WARNING: buffers statistics disabled\n ' in notices
451
468