6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-23 05:53:06 +01:00
firebird-qa/tests/bugs/core_4604_test.py

100 lines
3.1 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-24 20:27:02 +01:00
"""
ID: issue-4919
ISSUE: 4919
TITLE: EXECUTE STATEMENT rise varchar char_length() size
DESCRIPTION:
JIRA: CORE-4604
FBTEST: bugs.core_4604
2022-01-24 20:27:02 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set list on;
set term ^;
execute block returns (str_size integer)
as
declare variable tmp_guid varchar(38);
declare variable tmp_sqltext varchar(300);
declare v_dbname type of column mon$database.mon$database_name;
declare v_usr varchar(31) = 'SYSDBA';
declare v_pwd varchar(31) = 'masterkey';
begin
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
v_dbname = 'localhost:' || rdb$get_context('SYSTEM', 'DB_NAME');
---------------------------------------------------------------
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
tmp_guid = uuid_to_char(gen_uuid());
str_size = char_length(tmp_guid);
suspend;
---------------------------------------------------------------
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
tmp_sqltext = 'select ''' || tmp_guid || ''' from rdb$database';
2022-01-24 20:27:02 +01:00
execute statement (:TMP_SQLTEXT)
2021-04-26 20:07:00 +02:00
into :tmp_guid;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
str_size = char_length(tmp_guid);
suspend;
---------------------------------------------------------------
2022-01-24 20:27:02 +01:00
execute statement (:TMP_SQLTEXT)
2021-04-26 20:07:00 +02:00
on external v_dbname as user v_usr password v_pwd
into :tmp_guid;
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
str_size = char_length(tmp_guid);
2022-01-24 20:27:02 +01:00
2021-04-26 20:07:00 +02:00
-- Confirmed on WI-T3.0.0.31374 Firebird 3.0 Beta 1/tcp (csprog)/P13
-- STR_SIZE 36
-- STR_SIZE 36
2022-01-24 20:27:02 +01:00
-- STR_SIZE 144
2021-04-26 20:07:00 +02:00
suspend;
end
^
set term ;^
commit;
-- ||||||||||||||||||||||||||||
-- ###################################||| FB 4.0+, SS and SC |||##############################
-- ||||||||||||||||||||||||||||
-- If we check SS or SC and ExtConnPoolLifeTime > 0 (config parameter FB 4.0+) then current
-- DB (bugs.core_NNNN.fdb) will be 'captured' by firebird.exe process and fbt_run utility
-- will not able to drop this database at the final point of test.
-- Moreover, DB file will be hold until all activity in firebird.exe completed and AFTER this
-- we have to wait for <ExtConnPoolLifeTime> seconds after it (discussion and small test see
-- in the letter to hvlad and dimitr 13.10.2019 11:10).
-- This means that one need to kill all connections to prevent from exception on cleanup phase:
-- SQLCODE: -901 / lock time-out on wait transaction / object <this_test_DB> is in use
-- #############################################################################################
delete from mon$attachments where mon$attachment_id != current_connection;
2022-01-24 20:27:02 +01:00
commit;
2021-04-26 20:07:00 +02:00
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
act = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
STR_SIZE 36
STR_SIZE 36
STR_SIZE 36
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-24 20:27:02 +01:00
@pytest.mark.version('>=3')
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