6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_2555_test.py

133 lines
4.3 KiB
Python

#coding:utf-8
#
# id: bugs.core_2555
# title: CI column does not group correctly with a second column
# decription:
# tracker_id: CORE-2555
# min_versions: ['3.0']
# versions: 3.0
# qmid: None
import pytest
from firebird.qa import db_factory, isql_act, Action
# version: 3.0
# resources: None
substitutions_1 = []
init_script_1 = """"""
db_1 = db_factory(page_size=4096, charset='UTF8', sql_dialect=3, init=init_script_1)
test_script_1 = """
recreate table test(
rk char(1) character set none
,ca varchar(10) character set utf8 collate unicode_ci_ai
,cb varchar(10) character set utf8 collate unicode_ci
,id int generated by default as identity constraint pk_test primary key using index pk_test
);
commit;
-- Letters from latin-1 with diacritic marks: http://en.wikipedia.org/wiki/ISO/IEC_8859-1
insert into test(rk, ca, cb) values('d', 'ð', 'd');
insert into test(rk, ca, cb) values('d', 'Ð', 'd');
insert into test(rk, ca, cb) values('d', 'Ð', 'D');
insert into test(rk, ca, cb) values('d', 'd', 'd');
insert into test(rk, ca, cb) values('l', 'l', 'Ł');
insert into test(rk, ca, cb) values('l', 'ł', 'ł');
insert into test(rk, ca, cb) values('o', 'Ø', 'õ');
insert into test(rk, ca, cb) values('o', 'o', 'Õ');
insert into test(rk, ca, cb) values('o', 'Ó', 'Õ');
insert into test(rk, ca, cb) values('o', 'õ', 'Õ');
insert into test(rk, ca, cb) values('o', 'Ö', 'õ');
insert into test(rk, ca, cb) values('a', 'Ą', 'ä');
insert into test(rk, ca, cb) values('a', 'Á', 'Ä');
insert into test(rk, ca, cb) values('a', 'à', 'ä');
insert into test(rk, ca, cb) values('a', 'â', 'ä');
insert into test(rk, ca, cb) values('c', 'ç', 'Ç');
insert into test(rk, ca, cb) values('c', 'Ç', 'ç');
insert into test(rk, ca, cb) values('c', 'C', 'Ç');
insert into test(rk, ca, cb) values('u', 'Ú', 'û');
insert into test(rk, ca, cb) values('u', 'Ù', 'Û');
insert into test(rk, ca, cb) values('u', 'ü', 'û');
insert into test(rk, ca, cb) values('s', 'Š', 'Š');
insert into test(rk, ca, cb) values('s', 'ş', 'š');
insert into test(rk, ca, cb) values('s', 'š', 'Š');
insert into test(rk, ca, cb) values('n', 'Ñ', 'ñ');
insert into test(rk, ca, cb) values('n', 'ñ', 'ñ');
insert into test(rk, ca, cb) values('n', 'Ň', 'Ñ');
commit;
set list on;
set plan on;
-- First, we check result of NATURAL scans:
select rk from test group by ca,cb,rk;
commit;
-- Then, check results of GROUP BY when it can use index.
-- ::: NOTE :::
-- As of current state (WI-T3.0.0.31832 beta-2), FB cah do GROUP BY
-- WITH using of index on multi-byte or insensitive collation only
-- when this index is: 1) UNIQUE and 2) ASCENDING.
-- Index still not used in DISTINCT statement, so it's not checked.
-- See comments in CORE-4787.
create unique index test_unq1 on test(ca, cb, rk, id);
create unique index test_unq2 on test(cb, rk, ca, id);
commit;
set plan on;
select rk from test group by ca,cb,rk;
select rk from test group by cb,rk,ca;
"""
act_1 = isql_act('db_1', test_script_1, substitutions=substitutions_1)
expected_stdout_1 = """
PLAN SORT (TEST NATURAL)
RK a
RK c
RK d
RK l
RK n
RK o
RK s
RK u
PLAN (TEST ORDER TEST_UNQ1)
RK a
RK c
RK d
RK l
RK n
RK o
RK s
RK u
PLAN (TEST ORDER TEST_UNQ2)
RK a
RK c
RK d
RK l
RK n
RK o
RK s
RK u
"""
@pytest.mark.version('>=3.0')
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