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_3672_test.py

64 lines
2.3 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-22 21:59:15 +01:00
"""
ID: issue-4022
ISSUE: 4022
TITLE: computed index by substring function for long columns
DESCRIPTION:
JIRA: CORE-3672
FBTEST: bugs.core_3672
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()
2021-04-26 20:07:00 +02:00
2022-01-22 21:59:15 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
recreate table test(
col1 varchar(8190) character set utf8 collate unicode_ci_ai
,col2 computed by ( substring(col1 from 1 for 169) )
,col3 computed by ( substring(trim( col2 from col1 ) from 1 for 169) )
);
commit;
-- Index on UTF8-field which should be collate in CI_AI manner, will contain 6 bytes per one character (hereafter this is 'N').
2022-01-22 21:59:15 +01:00
-- This mean that maximum length of key for default page_size = 4096 is:
2021-04-26 20:07:00 +02:00
-- max_key_length = floor( (page_size / 4 - 9) / N ) = 169 characters.
-- Verify that we CAN do that w/o error:
create index test_col1_idx_a on test computed by ( substring(col1 from 1 for 169) );
create index test_col1_idx_b on test computed by ( substring(trim( col2 from col1 ) from 1 for 169) );
create index test_col2_idx_a on test computed by ( col2 );
create index test_col2_idx_b on test computed by ( substring(col2 from 1 for 169) );
create index test_col3_idx_a on test computed by ( col3 );
create index test_col3_idx_b on test computed by ( substring(col3 from 1 for 169) );
commit;
-- Confirmed for 2.5.5: "-key size exceeds implementation restriction"
show index test_col1_idx_a;
show index test_col1_idx_b;
show index test_col2_idx_a;
show index test_col2_idx_b;
show index test_col3_idx_a;
show index test_col3_idx_b;
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
TEST_COL1_IDX_A INDEX ON TEST COMPUTED BY ( substring(col1 from 1 for 169) )
TEST_COL1_IDX_B INDEX ON TEST COMPUTED BY ( substring(trim( col2 from col1 ) from 1 for 169) )
TEST_COL2_IDX_A INDEX ON TEST COMPUTED BY ( col2 )
TEST_COL2_IDX_B INDEX ON TEST COMPUTED BY ( substring(col2 from 1 for 169) )
TEST_COL3_IDX_A INDEX ON TEST COMPUTED BY ( col3 )
TEST_COL3_IDX_B INDEX ON TEST COMPUTED BY ( substring(col3 from 1 for 169) )
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