8000 [PGPRO-3690] Fix progress_bar behaviour in corner case. · postgrespro/pg_query_state@887c131 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 887c131

Browse files
author
Ekaterina Sokolova
committed
[PGPRO-3690] Fix progress_bar behaviour in corner case.
Tags: pg_query_state.
1 parent d296678 commit 887c131

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

pg_query_state.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,12 @@ progress_bar(PG_FUNCTION_ARGS)
13601360

13611361
old_progress = 0;
13621362
progress = 0;
1363+
if (SRF_IS_FIRSTCALL())
1364+
{
1365+
pg_atomic_write_u32(&counterpart_userid->n_peers, 1);
1366+
params->reqid = ++reqid;
1367+
}
1368+
13631369
bg_worker_procs = GetRemoteBackendWorkers(proc);
13641370
msgs = GetRemoteBackendQueryStates(proc,
13651371
bg_worker_procs,

tests/common.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,18 @@ def onetime_query_state(config, async_conn, query, args={}, num_workers=0):
161161
set_guc(async_conn, 'enable_mergejoin', 'on')
162162
return result, notices
163163

164-
def progress_bar(config, pid, visual):
164+
def progress_bar(config, pid):
165165
conn = psycopg2.connect(**config)
166166
curs = conn.cursor()
167167

168-
if visual:
169-
curs.callproc('progress_bar_visual', (pid, 1))
170-
else:
171-
curs.callproc('progress_bar', (pid,))
168+
curs.callproc('progress_bar', (pid,))
172169
result = curs.fetchall()
173170
notices = conn.notices[:]
174171
conn.close()
175172

176173
return result, notices
177174

178-
def onetime_progress_bar(config, async_conn, query, args={}, num_workers=0, visual=0):
175+
def onetime_progress_bar(config, async_conn, query, args={}, num_workers=0):
179176
"""
180177
Get intermediate state of 'query' on connection 'async_conn' after number of 'steps'
181178
of node executions from start of query
@@ -193,7 +190,6 @@ def onetime_progress_bar(config, async_conn, query, args={}, num_workers=0, visu
193190
pg_qs_args = {
194191
'config': config,
195192
'pid': async_conn.get_backend_pid(),
196-
'visual': visual
197193
}
198194
for k, v in args.items():
199195
pg_qs_args[k] = v

tests/pg_qs_test_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class TeardownException(Exception): pass
6969
test_timing_buffers_conflicts,
7070
test_insert_on_conflict,
7171
test_progress_bar,
72-
test_progress_bar_visual,
7372
]
7473

7574
def setup(con):

tests/test_cases.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -401,14 +401,3 @@ def test_progress_bar(config):
401401
assert qs[0][0] >= first_qs and qs[0][0] < 1
402402

403403
common.n_close((acon,))
404-
405-
def test_progress_bar_visual(config):
406-
"""test progress_bar_visual of simple query"""
407-
408-
acon, = common.n_async_connect(config)
409-
query = 'select count(*) from foo join bar on foo.c1=bar.c1'
410-
411-
qs, _ = common.onetime_progress_bar(config, acon, query, visual=1)
412-
assert qs[0][0] == 1.0
413-
414-
common.n_close((acon,))

0 commit comments

Comments
 (0)
0