Skip to content

Commit ff37a1a

Browse files
committed
Added/Updated tests\bugs\gh_8176_test.py: Adjusted for FB 6.x: it is MANDATORY to specify schema PLG$PROFILER. when querying created profiler tables. Also, on FB 6.x one need to use: 'grant usage on schema PLG$PROFILER to role ...' See notes.
1 parent eaf25d5 commit ff37a1a

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

tests/bugs/gh_8176_test.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
https://github.com/FirebirdSQL/firebird/commit/f59905fc29f0b9288d61fc6113fd24301dce1327
4141
Frontported PR #8186 : Fixed a few issues with IPC used by remote profiler
4242
Snapshots: 6.0.0.398-f59905f, 5.0.1.1440-7b1b824
43+
44+
[03.07.2025] pzotov
45+
Adjusted for FB 6.x: it is MANDATORY to specify schema `PLG$PROFILER.` when querying created profiler tables.
46+
See doc/sql.extensions/README.schemas.md, section title: '### gbak'; see 'SQL_SCHEMA_PREFIX' variable here.
47+
Also, on FB 6.x one need to use: 'grant usage on schema "PLG$PROFILER" to role ...'
48+
Checked on 6.0.0.970; 5.0.3.1668.
49+
4350
"""
4451

4552
import pytest
@@ -111,6 +118,8 @@
111118
@pytest.mark.version('>=5.0.1')
112119
def test_1(act: Action, tmp_worker_usr: User, tmp_profiler_usr: User, tmp_profiler_role: Role, capsys):
113120

121+
PLG_SCHEMA_PREFIX = '' if act.is_version('<6') else f'PLG$PROFILER.'
122+
114123
addi_script = f"""
115124
set wng off;
116125
set bail on;
@@ -168,24 +177,25 @@ def test_1(act: Action, tmp_worker_usr: User, tmp_profiler_usr: User, tmp_profil
168177
#################################
169178
# ::: NB ::: Why this is needed ?
170179
#################################
171-
con_admin.execute_immediate(f'grant select on plg$prof_sessions to role {tmp_profiler_role.name}')
172-
con_admin.execute_immediate(f'grant select on plg$prof_psql_stats_view to role {tmp_profiler_role.name}')
180+
181+
# firebird.driver.types.DatabaseError: no permission for USAGE access to SCHEMA "PLG$PROFILER"
182+
# -Effective user is TMP_PROFILER_8176
183+
if act.is_version('<6'):
184+
pass
185+
else:
186+
con_admin.execute_immediate(f'grant usage on schema "{PLG_SCHEMA_PREFIX[:-1]}" to role {tmp_profiler_role.name}')
187+
188+
con_admin.execute_immediate(f'grant select on {PLG_SCHEMA_PREFIX}plg$prof_sessions to role {tmp_profiler_role.name}')
189+
con_admin.execute_immediate(f'grant select on {PLG_SCHEMA_PREFIX}plg$prof_psql_stats_view to role {tmp_profiler_role.name}')
173190
con_admin.commit()
174191
#------------------------------------------------------------------------------
175192

176193
tx_profiler.begin()
177-
cur_profiler.execute('select description as profiler_session_descr, attachment_id as profiled_attachment, trim(user_name) as who_was_profiled from plg$prof_sessions order by profile_id')
194+
cur_profiler.execute(f'select description as profiler_session_descr, attachment_id as profiled_attachment, trim(user_name) as who_was_profiled from {PLG_SCHEMA_PREFIX}plg$prof_sessions order by profile_id')
178195
cur_cols = cur_profiler.description
179196
for r in cur_profiler:
180197
for i in range(0,len(cur_cols)):
181198
print( cur_cols[i][0], ':', r[i] )
182-
183-
#cur_profiler.execute('select * from plg$prof_psql_stats_view')
184-
#cur_cols = cur_profiler.description
185-
#for r in cur_profiler:
186-
# for i in range(0,len(cur_cols)):
187-
# print( cur_cols[i][0], ':', r[i] )
188-
189199
tx_profiler.commit()
190200

191201
act.expected_stdout = f"""

0 commit comments

Comments
 (0)