2021-12-30 19:43:52 +01:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
"""
|
|
|
|
ID: issue-6812
|
|
|
|
ISSUE: 6812
|
|
|
|
TITLE: BASE64_ENCODE and HEX_ENCODE can exceed maximum widths for VARCHAR
|
|
|
|
DESCRIPTION:
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.gh_6812
|
2023-12-14 17:20:23 +01:00
|
|
|
NOTES:
|
|
|
|
[14.12.2023] pzotov
|
|
|
|
Added 'SQLSTATE' in substitutions: runtime error must not be filtered out by '?!(...)' pattern
|
|
|
|
("negative lookahead assertion", see https://docs.python.org/3/library/re.html#regular-expression-syntax).
|
|
|
|
Added 'combine_output = True' in order to see SQLSTATE if any error occurs.
|
2022-01-27 20:08:36 +01:00
|
|
|
"""
|
2021-12-30 19:43:52 +01:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
import pytest
|
|
|
|
from firebird.qa import *
|
2021-12-30 19:43:52 +01:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
db = db_factory()
|
2021-12-30 19:43:52 +01:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
test_script = """
|
2021-12-30 19:43:52 +01:00
|
|
|
set sqlda_display on;
|
|
|
|
select hex_encode(cast('' as char(32767))) as "enc_01" from rdb$database where 1 <> 1;
|
|
|
|
select base64_encode(cast('' as char(32767))) as "enc_02" from rdb$database where 1 <> 1;
|
|
|
|
"""
|
|
|
|
|
2023-12-14 17:20:23 +01:00
|
|
|
act = isql_act('db', test_script, substitutions=[('^((?!(SQLSTATE|sqltype|enc)).)*$', ''), ('[ \t]+', ' ')])
|
2021-12-30 19:43:52 +01:00
|
|
|
|
2022-01-27 20:08:36 +01:00
|
|
|
expected_stdout = """
|
2021-12-30 19:43:52 +01:00
|
|
|
01: sqltype: 520 BLOB scale: 0 subtype: 1 len: 8 charset: 2 ASCII
|
|
|
|
: name: HEX_ENCODE alias: enc_01
|
|
|
|
01: sqltype: 520 BLOB scale: 0 subtype: 1 len: 8 charset: 2 ASCII
|
|
|
|
: name: BASE64_ENCODE alias: enc_02
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pytest.mark.version('>=4.0')
|
2022-01-27 20:08:36 +01:00
|
|
|
def test_1(act: Action):
|
|
|
|
act.expected_stdout = expected_stdout
|
2023-12-14 17:20:23 +01:00
|
|
|
act.execute(combine_output = True)
|
2022-01-27 20:08:36 +01:00
|
|
|
assert act.clean_stdout == act.clean_expected_stdout
|