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