#coding:utf-8 # # id: functional.tabloid.eqc_200762 # title: Check results of CONTAINING when search pattern can span on one or several blob segments # decription: # tracker_id: # 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; create sequence g; recreate table test ( id int primary key, pattern varchar(32765), memotext blob sub_type 1 segment size 1024 character set none ); 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 select mon$page_size from mon$database into v_db_page; delete from test; v_pattern = 'qwertyuioplkjhgfdsa1234567890zxcvbnm'; -- short pattern (len < 50 bytes), start on 1st segment and spans to 2nd: insert into test(id, pattern, memotext) values( gen_id(g,1), :v_pattern, rpad( '', 1000, uuid_to_char(gen_uuid()) ) || :v_pattern ); -- middle length pattern (len > 1024 and <= db_page_size) insert into test(id, pattern) 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; 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; 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; -- large length pattern ( > db_page_size): 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; 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; 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; 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 do 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 ID 2 PTRN_LEN 4915 BLOB_LEN 5916 PTRN_POS 1002 ID 3 PTRN_LEN 5734 BLOB_LEN 6736 PTRN_POS 1003 ID 4 PTRN_LEN 8192 BLOB_LEN 9195 PTRN_POS 1004 ID 5 PTRN_LEN 9830 BLOB_LEN 10834 PTRN_POS 1005 ID 6 PTRN_LEN 10650 BLOB_LEN 11655 PTRN_POS 1006 ID 7 PTRN_LEN 31724 BLOB_LEN 32730 PTRN_POS 1007 """ @pytest.mark.version('>=2.5') def test_1(act_1: Action): act_1.expected_stdout = expected_stdout_1 act_1.execute() assert act_1.clean_expected_stdout == act_1.clean_stdout