2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
#
|
|
|
|
# id: functional.tabloid.eqc_200762
|
|
|
|
# title: Check results of CONTAINING when search pattern can span on one or several blob segments
|
2021-10-21 19:29:23 +02:00
|
|
|
# decription:
|
|
|
|
# tracker_id:
|
2021-04-26 20:07:00 +02:00
|
|
|
# min_versions: ['2.5.0']
|
|
|
|
# versions: 2.5
|
|
|
|
# qmid: None
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
from firebird.qa import db_factory, isql_act, Action
|
|
|
|
|
|
|
|
# version: 2.5
|
|
|
|
# resources: None
|
|
|
|
|
|
|
|
substitutions_1 = []
|
|
|
|
|
|
|
|
init_script_1 = """"""
|
|
|
|
|
|
|
|
db_1 = db_factory(page_size=8192, sql_dialect=3, init=init_script_1)
|
|
|
|
|
|
|
|
test_script_1 = """
|
|
|
|
set list on;
|
|
|
|
set term ^;
|
|
|
|
execute block as
|
|
|
|
begin
|
|
|
|
execute statement 'drop sequence g'; when any do begin end
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
|
|
|
commit;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
create sequence g;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
recreate table test (
|
|
|
|
id int primary key,
|
|
|
|
pattern varchar(32765),
|
|
|
|
memotext blob sub_type 1 segment size 1024 character set none
|
|
|
|
);
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
set term ^;
|
|
|
|
execute block returns(id int, ptrn_len int, blob_len int, ptrn_pos int) as
|
|
|
|
declare v_pattern varchar(32765);
|
|
|
|
declare v_db_page smallint;
|
|
|
|
declare v_id int;
|
|
|
|
begin
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
select mon$page_size from mon$database into v_db_page;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
delete from test;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
v_pattern = 'qwertyuioplkjhgfdsa1234567890zxcvbnm';
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
-- short pattern (len < 50 bytes), start on 1st segment and spans to 2nd:
|
2021-10-21 19:29:23 +02:00
|
|
|
insert into test(id, pattern, memotext)
|
2021-04-26 20:07:00 +02:00
|
|
|
values( gen_id(g,1), :v_pattern, rpad( '', 1000, uuid_to_char(gen_uuid()) ) || :v_pattern );
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
-- middle length pattern (len > 1024 and <= db_page_size)
|
2021-10-21 19:29:23 +02:00
|
|
|
|
|
|
|
insert into test(id, pattern)
|
2021-04-26 20:07:00 +02:00
|
|
|
values(gen_id(g,1), rpad( '', 2.0/3 * :v_db_page, uuid_to_char(gen_uuid()) ) )
|
|
|
|
returning id, pattern into v_id, v_pattern;
|
|
|
|
update test set memotext = rpad( '', 1001, uuid_to_char(gen_uuid()) ) || :v_pattern
|
|
|
|
where id = :v_id;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
insert into test(id, pattern) values(gen_id(g,1), rpad( '', 3.0/4 * :v_db_page, uuid_to_char(gen_uuid()) ) )
|
|
|
|
returning id, pattern into v_id, v_pattern;
|
|
|
|
update test set memotext = rpad( '', 1002, uuid_to_char(gen_uuid()) ) || :v_pattern
|
|
|
|
where id = :v_id;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
insert into test(id, pattern) values(gen_id(g,1), rpad( '', :v_db_page, uuid_to_char(gen_uuid()) ) )
|
|
|
|
returning id, pattern into v_id, v_pattern;
|
|
|
|
update test set memotext = rpad( '', 1003, uuid_to_char(gen_uuid()) ) || :v_pattern
|
|
|
|
where id = :v_id;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
-- large length pattern ( > db_page_size):
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
insert into test(id, pattern) values(gen_id(g,1), rpad( '', 5.0/4 * :v_db_page, uuid_to_char(gen_uuid()) ) )
|
|
|
|
returning id, pattern into v_id, v_pattern;
|
|
|
|
update test set memotext = rpad( '', 1004, uuid_to_char(gen_uuid()) ) || :v_pattern
|
|
|
|
where id = :v_id;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
insert into test(id, pattern) values(gen_id(g,1), rpad( '', 4.0/3 * :v_db_page, uuid_to_char(gen_uuid()) ) )
|
|
|
|
returning id, pattern into v_id, v_pattern;
|
|
|
|
update test set memotext = rpad( '', 1005, uuid_to_char(gen_uuid()) ) || :v_pattern
|
|
|
|
where id = :v_id;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
insert into test(id, pattern) values(gen_id(g,1), rpad( '', 31724, uuid_to_char(gen_uuid()) ) )
|
|
|
|
returning id, pattern into v_id, v_pattern;
|
|
|
|
update test set memotext = rpad( '', 1006, uuid_to_char(gen_uuid()) ) || :v_pattern
|
|
|
|
where id = :v_id;
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
for
|
|
|
|
select id, char_length(pattern), char_length(memotext), position(pattern in memotext)
|
|
|
|
from test
|
|
|
|
where memotext containing pattern
|
|
|
|
order by id
|
|
|
|
into id, ptrn_len, blob_len, ptrn_pos
|
2021-10-21 19:29:23 +02:00
|
|
|
do
|
2021-04-26 20:07:00 +02:00
|
|
|
suspend;
|
|
|
|
end
|
|
|
|
^
|
|
|
|
set term ;^
|
|
|
|
commit;
|
|
|
|
"""
|
|
|
|
|
|
|
|
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
|
|
|
|
|
|
|
|
expected_stdout_1 = """
|
|
|
|
ID 1
|
|
|
|
PTRN_LEN 36
|
|
|
|
BLOB_LEN 1036
|
|
|
|
PTRN_POS 1001
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
ID 2
|
|
|
|
PTRN_LEN 4915
|
|
|
|
BLOB_LEN 5916
|
|
|
|
PTRN_POS 1002
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
ID 3
|
|
|
|
PTRN_LEN 5734
|
|
|
|
BLOB_LEN 6736
|
|
|
|
PTRN_POS 1003
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
ID 4
|
|
|
|
PTRN_LEN 8192
|
|
|
|
BLOB_LEN 9195
|
|
|
|
PTRN_POS 1004
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
ID 5
|
|
|
|
PTRN_LEN 9830
|
|
|
|
BLOB_LEN 10834
|
|
|
|
PTRN_POS 1005
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
ID 6
|
|
|
|
PTRN_LEN 10650
|
|
|
|
BLOB_LEN 11655
|
|
|
|
PTRN_POS 1006
|
2021-10-21 19:29:23 +02:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
ID 7
|
|
|
|
PTRN_LEN 31724
|
|
|
|
BLOB_LEN 32730
|
|
|
|
PTRN_POS 1007
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pytest.mark.version('>=2.5')
|
2021-04-28 12:42:11 +02:00
|
|
|
def test_1(act_1: Action):
|
2021-10-21 19:29:23 +02:00
|
|
|
act_1.charset = 'NONE'
|
2021-04-26 20:07:00 +02:00
|
|
|
act_1.expected_stdout = expected_stdout_1
|
|
|
|
act_1.execute()
|
|
|
|
assert act_1.clean_expected_stdout == act_1.clean_stdout
|
|
|
|
|