@@ -139,7 +139,8 @@ def test_simple_query(config):
139139 -> Seq Scan on bar \(Current loop: actual rows=9, loop number=1\)"""
140140
141141 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
143144 assert len (notices ) == 0
144145
145146 n_close ((acon ,))
@@ -161,8 +162,11 @@ def test_concurrent_access(config):
161162
162163 qs1 , qs2 = acurs1 .fetchall (), acurs2 .fetchall ()
163164 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
166170 assert len (notices ) == 0
167171
168172 n_close ((acon1 , acon2 , acon3 ))
@@ -199,11 +203,13 @@ def test_nested_call(config):
199203
200204 qs = query_state (config , acon , call_function , num_steps )
201205 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
204211 assert len (notices ) == 0
205212
206-
207213 util_curs .execute (drop_function )
208214
209215 util_conn .close ()
@@ -228,7 +234,10 @@ def test_insert_on_conflict(config):
228234 util_conn .commit ()
229235
230236 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
232241 assert len (notices ) == 0
233242
234243 util_curs .execute (drop_field_uniqueness )
@@ -278,14 +287,22 @@ def test_trigger(config):
278287
279288 qs = query_state (config , acon , query , num_steps , {'triggers' : True })
280289 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
283296 assert len (notices ) == 0
284297
285298 qs = query_state (config , acon , query , num_steps , {'triggers' : False })
286299 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
289306 assert len (notices ) == 0
290307
291308 util_curs .execute (drop_temps )
@@ -308,7 +325,7 @@ def test_costs(config):
308325 -> Seq Scan on bar \(cost=0.00..\d+.\d+ rows=\d+ width=4\) \(Current loop: actual rows=9, loop number=1\)"""
309326
310327 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 ])
312329 assert len (notices ) == 0
313330
314331 n_close ((acon ,))
@@ -332,7 +349,7 @@ def test_buffers(config):
332349 set_guc (acon , 'pg_query_state.enable_buffers' , 'on' )
333350
334351 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 ])
336353 assert len (notices ) == 0
337354
338355 n_close ((acon ,))
@@ -354,7 +371,7 @@ def test_timing(config):
354371 set_guc (acon , 'pg_query_state.enable_timing' , 'on' )
355372
356373 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 ])
358375 assert len (notices ) == 0
359376
360377 n_close ((acon ,))
@@ -394,12 +411,12 @@ def test_formats(config):
394411 -> Seq Scan on bar \(Current loop: actual rows=9, loop number=1\)"""
395412
396413 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 ])
398415 assert len (notices ) == 0
399416
400417 qs = query_state (config , acon , query , num_steps , {'format' : 'json' })
401418 try :
402- js_obj = json .loads (qs [0 ][1 ])
419+ js_obj = json .loads (qs [0 ][3 ])
403420 except ValueError :
404421 assert False , 'Invalid json format'
405422 assert len (qs ) == 1
@@ -410,14 +427,14 @@ def test_formats(config):
410427 assert len (qs ) == 1
411428 assert len (notices ) == 0
412429 try :
413- xml_root = ET .fromstring (qs [0 ][1 ])
430+ xml_root = ET .fromstring (qs [0 ][3 ])
414431 except :
415432 assert False , 'Invalid xml format'
416433 check_xml (xml_root )
417434
418435 qs = query_state (config , acon , query , num_steps , {'format' : 'yaml' })
419436 try :
420- yaml_doc = yaml .load (qs [0 ][1 ])
437+ yaml_doc = yaml .load (qs [0 ][3 ])
421438 except :
422439 assert False , 'Invalid yaml format'
423440 assert len (qs ) == 1
@@ -436,16 +453,16 @@ def test_timing_buffers_conflicts(config):
436453 buffers_pattern = 'Buffers:'
437454
438455 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 ])
440457 assert notices == ['WARNING: timing statistics disabled\n ' ]
441458
442459 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 ])
444461 assert notices == ['WARNING: buffers statistics disabled\n ' ]
445462
446463 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 ])
449466 assert len (notices ) == 2 and 'WARNING: timing statistics disabled\n ' in notices \
450467 and 'WARNING: buffers statistics disabled\n ' in notices
451468
0 commit comments