2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
|
|
|
ID: issue-3610
|
|
|
|
ISSUE: 3610
|
|
|
|
TITLE: UTF8 UNICODE_CI collate can not be used in compound index
|
|
|
|
DESCRIPTION:
|
|
|
|
JIRA: CORE-3239
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_3239
|
2022-01-22 21:59:15 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
db = db_factory(charset='UTF8')
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
test_script = """
|
|
|
|
create collation co_utf8_ci_ai for utf8 from unicode case insensitive accent insensitive;
|
2021-04-26 20:07:00 +02:00
|
|
|
commit;
|
|
|
|
|
|
|
|
create table test (
|
|
|
|
rule_id integer not null
|
|
|
|
,ci varchar(20) character set utf8 not null collate unicode_ci
|
|
|
|
,ciai varchar(20) character set utf8 not null collate co_utf8_ci_ai
|
|
|
|
,bfield boolean
|
|
|
|
,pattern varchar(10) character set none
|
|
|
|
,constraint test_pk primary key (rule_id, ci, ciai) using index test_int_ci_ciai
|
|
|
|
,constraint test_unq unique(bfield, ciai, ci) using index test_bool_ciai_ci
|
|
|
|
);
|
|
|
|
commit;
|
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
-- áéíóúý àèìòù âêîôû ãñõ äëïöüÿ çš δθλξσψω ąęłźż
|
2021-04-26 20:07:00 +02:00
|
|
|
insert into test (rule_id, ci, ciai, bfield, pattern) values (1, 'âêîôû' , 'âÊîôû' , true , '_e_O%');
|
|
|
|
insert into test (rule_id, ci, ciai, bfield, pattern) values (2, 'äëïöüÿ', 'Äëïöüÿ', false, '_e%ioU_');
|
|
|
|
insert into test (rule_id, ci, ciai, bfield, pattern) values (3, 'áéíóúý', 'ÁéÍÓÚý', false, 'A__O_Y');
|
|
|
|
insert into test (rule_id, ci, ciai, bfield, pattern) values (4, 'àèìòù' , 'àÈÌòù' , true , '___O_');
|
|
|
|
commit;
|
|
|
|
|
|
|
|
set list on;
|
|
|
|
set plan on;
|
|
|
|
--set echo on;
|
2022-01-22 21:59:15 +01:00
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
select rule_id
|
|
|
|
from test
|
|
|
|
where bfield = false and ciai similar to pattern;
|
2022-01-22 21:59:15 +01:00
|
|
|
|
|
|
|
select rule_id
|
|
|
|
from test
|
|
|
|
where
|
|
|
|
rule_id = 1
|
2021-04-26 20:07:00 +02:00
|
|
|
and ci starting with 'ÂÊ'
|
|
|
|
and ciai similar to '%EIOU%';
|
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
select rule_id from test
|
|
|
|
where
|
2021-04-26 20:07:00 +02:00
|
|
|
bfield = false
|
|
|
|
and ciai similar to 'AEIOUY'
|
|
|
|
and ci similar to '%ÄË%ÜŸ';
|
|
|
|
|
|
|
|
select a.rule_id
|
|
|
|
from test a
|
|
|
|
join test b on a.rule_id = b.rule_id and a.ciai = b.ci
|
|
|
|
where a.bfield = true;
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
act = isql_act('db', test_script)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-22 21:59:15 +01:00
|
|
|
expected_stdout = """
|
2021-04-26 20:07:00 +02:00
|
|
|
PLAN (TEST INDEX (TEST_BOOL_CIAI_CI))
|
|
|
|
RULE_ID 2
|
|
|
|
RULE_ID 3
|
|
|
|
|
|
|
|
PLAN (TEST INDEX (TEST_INT_CI_CIAI))
|
|
|
|
RULE_ID 1
|
|
|
|
|
|
|
|
PLAN (TEST INDEX (TEST_BOOL_CIAI_CI))
|
|
|
|
RULE_ID 2
|
|
|
|
|
|
|
|
PLAN JOIN (A INDEX (TEST_BOOL_CIAI_CI), B INDEX (TEST_INT_CI_CIAI))
|
|
|
|
RULE_ID 1
|
|
|
|
RULE_ID 4
|
2021-12-22 20:23:11 +01:00
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0')
|
2022-01-22 21:59:15 +01:00
|
|
|
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
|
|
|
|