2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
"""
|
|
|
|
ID: issue-6114
|
|
|
|
ISSUE: 6114
|
|
|
|
TITLE: Very poor "similar to" performance
|
|
|
|
DESCRIPTION:
|
|
|
|
Quantifier value was increased to 1000, string 'abcd.abc' is used for pattern search.
|
|
|
|
NOTES:
|
|
|
|
doc\\sql.extensions\\README.similar_to.txt:
|
|
|
|
Since FB 4 the repeat factor low/high values could not be greater than 1000.
|
|
|
|
JIRA: CORE-5854
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
test_script = """
|
2021-04-26 20:07:00 +02:00
|
|
|
set list on;
|
|
|
|
set count on;
|
|
|
|
|
|
|
|
set term ^;
|
|
|
|
execute block as
|
|
|
|
begin
|
|
|
|
rdb$set_context( 'USER_SESSION','DTS_START', cast('now' as timestamp) );
|
|
|
|
rdb$set_context( 'USER_SESSION','MAX_THRESHOLD_MS', 100 );
|
|
|
|
-- ^
|
|
|
|
-- |
|
|
|
|
-- #############################
|
|
|
|
-- MAX ALLOWED EXECUTION TIME,MS
|
|
|
|
-- #############################
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
select iif ('abcd.abc' similar to '[[:ALPHA:].]{1,1000}.ab' ,1,0) result
|
|
|
|
from rdb$database
|
2021-04-26 20:07:00 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
set count off;
|
2022-01-26 21:10:46 +01:00
|
|
|
select
|
2021-04-26 20:07:00 +02:00
|
|
|
iif( evaluated_ms <= max_allowed_ms
|
|
|
|
,'acceptable'
|
|
|
|
,'TOO LONG: ' || evaluated_ms || ' ms - this is more then threshold = ' || max_allowed_ms || ' ms'
|
|
|
|
) as duration
|
|
|
|
from (
|
2022-01-26 21:10:46 +01:00
|
|
|
select
|
2021-04-26 20:07:00 +02:00
|
|
|
datediff( millisecond from cast(rdb$get_context( 'USER_SESSION','DTS_START') as timestamp) to current_timestamp ) evaluated_ms
|
|
|
|
,cast( rdb$get_context( 'USER_SESSION','MAX_THRESHOLD_MS' ) as int ) as max_allowed_ms
|
|
|
|
from rdb$database
|
|
|
|
);
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-26 21:10:46 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
RESULT 0
|
|
|
|
Records affected: 1
|
|
|
|
DURATION acceptable
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=4.0')
|
2022-01-26 21:10:46 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
|
|
|
act.execute()
|
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|