Skip to content

Commit eaf25d5

Browse files
committed
Added/Updated tests\bugs\gh_7752_test.py: Re-implemented. See notes.
1 parent 828ac10 commit eaf25d5

File tree

1 file changed

+50
-55
lines changed

1 file changed

+50
-55
lines changed

tests/bugs/gh_7752_test.py

Lines changed: 50 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -8,66 +8,24 @@
88
[02.10.2023] pzotov
99
Confirmed problem (truncating of profiler data) on 5.0.0.1219, date of build: 17-sep-2023.
1010
Checked on 5.0.0.1235, 6.0.0.65 -- all fine.
11+
[14.07.2025] pzotov
12+
Re-implemented: use non-ascii names for table and its alias.
13+
Using non-ascii SCHEMA name with maximal allowed length (56 characters) - it is needed on FB 6.x.
14+
Adjusted for FB 6.x: it is MANDATORY to specify schema `PLG$PROFILER.` when querying created profiler tables.
15+
See doc/sql.extensions/README.schemas.md, section title: '### gbak'; see 'SQL_SCHEMA_PREFIX' variable here.
16+
Separated expected output for FB major versions prior/since 6.x.
17+
No substitutions are used to suppress schema and quotes. Discussed with dimitr, 24.06.2025 12:39.
18+
Checked on 6.0.0.970; 5.0.3.1668.
1119
"""
1220

1321
import os
1422
import pytest
1523
from firebird.qa import *
1624

17-
db = db_factory()
25+
db = db_factory(charset = 'utf8')
1826

1927
act = python_act('db')
2028

21-
test_sql = """
22-
select count(*)
23-
from (
24-
select 1 i from
25-
rdb$relations r
26-
where
27-
(r.rdb$relation_name = 'RDB$RELATIONS') OR
28-
(r.rdb$relation_name = 'RDB$DATABASE') OR
29-
(r.rdb$relation_name = 'RDB$COLLATIONS') OR
30-
(r.rdb$relation_name = 'RDB$CONFIG') OR
31-
(r.rdb$relation_name = 'RDB$EXCEPTIONS') OR
32-
(r.rdb$relation_name = 'RDB$FIELDS') OR
33-
(r.rdb$relation_name = 'RDB$FUNCTIONS') OR
34-
(r.rdb$relation_name = 'RDB$PROCEDURES')
35-
rows 1
36-
)
37-
"""
38-
39-
profiler_sql = """
40-
select p.access_path
41-
from plg$prof_record_sources p
42-
order by p.record_source_id desc rows 1
43-
"""
44-
45-
expected_stdout = """
46-
-> Table "RDB$RELATIONS" as "R" Access By ID
47-
....-> Bitmap Or
48-
........-> Bitmap Or
49-
............-> Bitmap Or
50-
................-> Bitmap Or
51-
....................-> Bitmap Or
52-
........................-> Bitmap Or
53-
............................-> Bitmap Or
54-
................................-> Bitmap
55-
....................................-> Index "RDB$INDEX_0" Unique Scan
56-
................................-> Bitmap
57-
....................................-> Index "RDB$INDEX_0" Unique Scan
58-
............................-> Bitmap
59-
................................-> Index "RDB$INDEX_0" Unique Scan
60-
........................-> Bitmap
61-
............................-> Index "RDB$INDEX_0" Unique Scan
62-
....................-> Bitmap
63-
........................-> Index "RDB$INDEX_0" Unique Scan
64-
................-> Bitmap
65-
....................-> Index "RDB$INDEX_0" Unique Scan
66-
............-> Bitmap
67-
................-> Index "RDB$INDEX_0" Unique Scan
68-
........-> Bitmap
69-
............-> Index "RDB$INDEX_0" Unique Scan
70-
"""
7129

7230
#---------------------------------------------------------
7331

@@ -79,22 +37,59 @@ def replace_leading(source, char="#"):
7937

8038
@pytest.mark.version('>=5.0')
8139
def test_1(act: Action, capsys):
82-
83-
with act.db.connect() as con:
40+
41+
PLG_SCHEMA_PREFIX = '' if act.is_version('<6') else 'PLG$PROFILER.'
42+
43+
CUSTOM_SCHEMA = '' if act.is_version('<6') else '"БьТЦууКенгШщзХъЭждЛорПавЫфЯчсмиТьбЮЪхЗщШШГнЕкУцЙФывААпрО"'
44+
CREATE_SCHEMA_SQL = '' if act.is_version('<6') else f'create schema {CUSTOM_SCHEMA};'
45+
SQL_SCHEMA_PREFIX = '' if act.is_version('<6') else f'{CUSTOM_SCHEMA}.'
46+
TEST_TABLE_NAME = '"БьТЦууКенгШщзХъЭждЛорПавЫфЯчсмиТьбЮЪхЗщШШГнЕкУцЙФывААпрО"'
47+
TEST_ALIAS_NAME = '"ЦууКенгШщзХъЭждЛорПавЫфЯчсмиТьбЮЪхЗщШШГнЕкУцЙФывААпрОБьТ"'
48+
49+
init_sql = f"""
50+
{CREATE_SCHEMA_SQL}
51+
create table {SQL_SCHEMA_PREFIX}{TEST_TABLE_NAME}(id int);
52+
"""
53+
54+
profiler_sql = f"""
55+
select p.access_path
56+
from {PLG_SCHEMA_PREFIX}plg$prof_record_sources p
57+
order by octet_length(p.access_path) desc
58+
rows 1
59+
"""
60+
61+
with act.db.connect(charset = 'utf8') as con:
62+
8463
cur = con.cursor()
64+
for x in init_sql.splitlines():
65+
if (s := x.strip()):
66+
cur.execute(s)
67+
con.commit()
68+
8569
cur.execute("select rdb$profiler.start_session('profile session 1') from rdb$database")
8670
for r in cur:
8771
pass
8872

89-
cur.execute(test_sql)
73+
cur.execute( f'select count(*) from {SQL_SCHEMA_PREFIX}{TEST_TABLE_NAME} as {TEST_ALIAS_NAME}')
74+
for r in cur:
75+
pass
76+
9077
cur.callproc('rdb$profiler.finish_session', (True,))
9178
con.commit()
9279

9380
cur.execute(profiler_sql)
9481
for r in cur:
9582
print( '\n'.join([replace_leading(s, char='.') for s in r[0].split('\n')]) )
9683

97-
act.expected_stdout = expected_stdout
84+
expected_stdout_5x = f"""
85+
-> Table {TEST_TABLE_NAME} as {TEST_ALIAS_NAME} Full Scan
86+
"""
87+
88+
expected_stdout_6x = f"""
89+
-> Table {CUSTOM_SCHEMA}.{TEST_TABLE_NAME} as {TEST_ALIAS_NAME} Full Scan
90+
"""
91+
92+
act.expected_stdout = expected_stdout_5x if act.is_version('<6') else expected_stdout_6x
9893
act.stdout = capsys.readouterr().out
9994
assert act.clean_stdout == act.clean_expected_stdout
10095
act.reset()

0 commit comments

Comments
 (0)