6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 05:53:06 +01:00
firebird-qa/tests/bugs/core_4125_test.py

64 lines
1.6 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-23 20:41:55 +01:00
"""
ID: issue-4453
ISSUE: 4453
TITLE: Using COLLATE UNICODE_CI_AI in WHERE clause (not indexed) is extremely slow
DESCRIPTION:
JIRA: CORE-4125
FBTEST: bugs.core_4125
2022-01-23 20:41:55 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
init_script = """
2021-04-26 20:07:00 +02:00
create or alter view test as
with recursive
r as (select 0 i from rdb$database union all select r.i+1 from r where r.i<98)
select cast(r1.i*100 + r0.i as varchar(10)) as fx
from r r1, r r0;
commit;
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
db = db_factory(charset='UTF8', init=init_script)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
-- Checked on 2.5.1: ratio = ~105, on 2.5.2: ~132, since 2.5.3: ~1.
set list on;
set term ^;
execute block returns(result varchar(50) ) as
declare t0 timestamp;
declare t1 timestamp;
declare t2 timestamp;
declare n int;
declare r numeric(18,3);
begin
t0='now';
select count(*) from test where fx collate unicode_ci like '%8%' into n;
t1='now';
select count(*) from test where fx collate unicode_ci_ai like '%8%' into n;
t2='now';
n = datediff(millisecond from t1 to t2);
r = 1.000 * n / nullif(datediff(millisecond from t0 to t1), 0);
if (r is null and n < 100 or r <= 5) then result = 'TIME RATIO IS OK.';
else result = 'BAD RATIO: '||coalesce(r,' > 100 vs 0.');
2022-01-23 20:41:55 +01:00
2021-04-26 20:07:00 +02:00
suspend;
end
^
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
RESULT TIME RATIO IS OK.
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-23 20:41:55 +01:00
@pytest.mark.version('>=3')
def test_1(act: Action):
act.expected_stdout = expected_stdout
act.execute()
assert act.clean_stdout == act.clean_expected_stdout
2021-04-26 20:07:00 +02:00