2021-04-26 20:07:00 +02:00
|
|
|
|
#coding:utf-8
|
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
|
"""
|
|
|
|
|
ID: issue-2773
|
|
|
|
|
ISSUE: 2773
|
|
|
|
|
TITLE: Too long column name for select alias should be rejected
|
|
|
|
|
DESCRIPTION:
|
|
|
|
|
NOTES:
|
|
|
|
|
[26.01.2019]
|
|
|
|
|
code for FB 4.0: added filtering 'where rdb$system_flag is distinct from 1' for query to rdb$procedures.
|
|
|
|
|
Currently there is one system-defined package (RDB$TIME_ZONE_UTIL) and one stand-alone procedure (RDB$TRANSITIONS)
|
|
|
|
|
JIRA: CORE-2350
|
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
|
import pytest
|
|
|
|
|
from firebird.qa import *
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
|
db = db_factory()
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
|
# version: 3.0
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
|
|
test_script_1 = """
|
|
|
|
|
recreate table t1 (i integer);
|
|
|
|
|
commit;
|
|
|
|
|
|
|
|
|
|
insert into t1 values(1);
|
|
|
|
|
commit;
|
|
|
|
|
|
|
|
|
|
set list on;
|
|
|
|
|
--set echo on;
|
|
|
|
|
|
|
|
|
|
select i as i23456789012345678901234567890123456 from t1;
|
|
|
|
|
select i23456789012345678901234567890123456
|
|
|
|
|
from (
|
|
|
|
|
select i as i23456789012345678901234567890123456
|
|
|
|
|
from t1
|
|
|
|
|
);
|
2021-12-22 20:23:11 +01:00
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
|
act_1 = isql_act('db', test_script_1)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
|
|
expected_stderr_1 = """
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
|
|
|
|
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
2021-12-22 20:23:11 +01:00
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
|
|
@pytest.mark.version('>=3.0,<4.0')
|
2021-04-28 12:42:11 +02:00
|
|
|
|
def test_1(act_1: Action):
|
2021-04-26 20:07:00 +02:00
|
|
|
|
act_1.expected_stderr = expected_stderr_1
|
|
|
|
|
act_1.execute()
|
2021-12-22 20:23:11 +01:00
|
|
|
|
assert act_1.clean_stderr == act_1.clean_expected_stderr
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
|
|
# version: 4.0
|
|
|
|
|
|
|
|
|
|
test_script_2 = """
|
|
|
|
|
set list on;
|
2022-01-21 18:49:26 +01:00
|
|
|
|
select '- column title, ASCII, width = 63' as
|
2021-04-26 20:07:00 +02:00
|
|
|
|
i23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
from rdb$database;
|
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
|
select '- column title, ASCII, width = 64' as
|
2021-04-26 20:07:00 +02:00
|
|
|
|
i234567890123456789012345678901234567890123456789012345678901234
|
|
|
|
|
from rdb$database;
|
2022-01-21 18:49:26 +01:00
|
|
|
|
|
|
|
|
|
select '- column title, UTF8, width = 63' as
|
2021-04-26 20:07:00 +02:00
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
from rdb$database;
|
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
|
select '- column title, UTF8, width = 64' as
|
2021-04-26 20:07:00 +02:00
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯВ"
|
|
|
|
|
from rdb$database;
|
|
|
|
|
|
|
|
|
|
set term ^;
|
|
|
|
|
|
|
|
|
|
create or alter procedure sp_63a returns(o1 double precision) as
|
|
|
|
|
declare
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
int;
|
|
|
|
|
begin
|
|
|
|
|
select rand()*1000 as
|
|
|
|
|
a23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
from rdb$database as
|
|
|
|
|
t23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
into
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123;
|
|
|
|
|
o1 = sqrt(
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
);
|
|
|
|
|
suspend;
|
|
|
|
|
end
|
|
|
|
|
^
|
|
|
|
|
|
|
|
|
|
create or alter procedure sp_63u returns(o1 double precision) as
|
|
|
|
|
declare
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
int;
|
|
|
|
|
begin
|
|
|
|
|
select rand()*1000 as
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
from rdb$database as
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
into
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ";
|
|
|
|
|
o1 = sqrt(
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
);
|
|
|
|
|
suspend;
|
|
|
|
|
end
|
|
|
|
|
^
|
|
|
|
|
|
|
|
|
|
create or alter procedure sp_64u1 returns(o1 double precision) as
|
|
|
|
|
declare
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ1" -- 64 characters, UTF8
|
|
|
|
|
int;
|
|
|
|
|
begin
|
|
|
|
|
select rand()*1000 as
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
from rdb$database as
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
into
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ1";
|
|
|
|
|
o1 = sqrt(
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ1"
|
|
|
|
|
);
|
|
|
|
|
suspend;
|
|
|
|
|
end
|
|
|
|
|
^
|
|
|
|
|
|
|
|
|
|
create or alter procedure sp_64u2 returns(o1 double precision) as
|
|
|
|
|
declare
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
int;
|
|
|
|
|
begin
|
|
|
|
|
select rand()*1000 as
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ1" -- 64 characters, UTF8
|
|
|
|
|
from rdb$database as
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
into
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ";
|
|
|
|
|
o1 = sqrt(
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
);
|
|
|
|
|
suspend;
|
|
|
|
|
end
|
|
|
|
|
^
|
|
|
|
|
create or alter procedure sp_64u3 returns(o1 double precision) as
|
|
|
|
|
declare
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
int;
|
|
|
|
|
begin
|
|
|
|
|
select rand()*1000 as
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
from rdb$database as
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ1" -- 64 characters, UTF8
|
|
|
|
|
into
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ";
|
|
|
|
|
o1 = sqrt(
|
|
|
|
|
"ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ"
|
|
|
|
|
);
|
|
|
|
|
suspend;
|
|
|
|
|
end
|
|
|
|
|
^
|
|
|
|
|
|
|
|
|
|
create or alter procedure sp_64a1 returns(o1 double precision) as
|
|
|
|
|
declare
|
|
|
|
|
v234567890123456789012345678901234567890123456789012345678901234 -- 64 characters, ascii
|
|
|
|
|
int;
|
|
|
|
|
begin
|
|
|
|
|
select rand()*1000 as
|
|
|
|
|
a23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
from rdb$database as
|
|
|
|
|
t23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
into
|
|
|
|
|
v234567890123456789012345678901234567890123456789012345678901234;
|
|
|
|
|
o1 = sqrt(
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
);
|
|
|
|
|
suspend;
|
|
|
|
|
end
|
|
|
|
|
^
|
|
|
|
|
create or alter procedure sp_64a2 returns(o1 double precision) as
|
|
|
|
|
declare
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
int;
|
|
|
|
|
begin
|
|
|
|
|
select rand()*1000 as
|
|
|
|
|
a234567890123456789012345678901234567890123456789012345678901234 -- 64 characters, ascii
|
|
|
|
|
from rdb$database as
|
|
|
|
|
t23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
into
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123;
|
|
|
|
|
o1 = sqrt(
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
);
|
|
|
|
|
suspend;
|
|
|
|
|
end
|
|
|
|
|
^
|
|
|
|
|
create or alter procedure sp_64a3 returns(o1 double precision) as
|
|
|
|
|
declare
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
int;
|
|
|
|
|
begin
|
|
|
|
|
select rand()*1000 as
|
|
|
|
|
a23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
from rdb$database as
|
|
|
|
|
t234567890123456789012345678901234567890123456789012345678901234 -- 64 characters, ascii
|
|
|
|
|
into
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123;
|
|
|
|
|
o1 = sqrt(
|
|
|
|
|
v23456789012345678901234567890123456789012345678901234567890123
|
|
|
|
|
);
|
|
|
|
|
suspend;
|
|
|
|
|
end
|
|
|
|
|
^
|
|
|
|
|
set term ;^
|
|
|
|
|
commit;
|
|
|
|
|
set list on;
|
|
|
|
|
set count on;
|
|
|
|
|
select rdb$procedure_name from rdb$procedures where rdb$system_flag is distinct from 1;
|
2022-01-21 18:49:26 +01:00
|
|
|
|
|
2021-12-22 20:23:11 +01:00
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
2022-01-21 18:49:26 +01:00
|
|
|
|
act_2 = isql_act('db', test_script_2,
|
|
|
|
|
substitutions=[('-At line[:]{0,1}[\\s]+[\\d]+,[\\s]+column[:]{0,1}[\\s]+[\\d]+', '')])
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
|
|
expected_stdout_2 = """
|
|
|
|
|
I23456789012345678901234567890123456789012345678901234567890123 - column title, ASCII, width = 63
|
|
|
|
|
ЛевНиколаевичТолстойАннаКаренинаМнеотмщениеиазвоздамЧАСТЬПЕРВАЯ - column title, UTF8, width = 63
|
2022-01-21 18:49:26 +01:00
|
|
|
|
RDB$PROCEDURE_NAME SP_63A
|
|
|
|
|
RDB$PROCEDURE_NAME SP_63U
|
2021-04-26 20:07:00 +02:00
|
|
|
|
Records affected: 2
|
2021-12-22 20:23:11 +01:00
|
|
|
|
"""
|
2022-01-21 18:49:26 +01:00
|
|
|
|
|
2021-04-26 20:07:00 +02:00
|
|
|
|
expected_stderr_2 = """
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
|
|
|
|
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
|
|
|
|
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
|
|
|
|
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
|
|
|
|
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
|
|
|
|
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
|
|
|
|
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
|
|
|
|
|
|
|
|
|
Statement failed, SQLSTATE = 42000
|
|
|
|
|
Dynamic SQL Error
|
|
|
|
|
-SQL error code = -104
|
|
|
|
|
-Name longer than database column size
|
2021-12-22 20:23:11 +01:00
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|
|
|
|
|
@pytest.mark.version('>=4.0')
|
2021-04-28 12:42:11 +02:00
|
|
|
|
def test_2(act_2: Action):
|
2021-04-26 20:07:00 +02:00
|
|
|
|
act_2.expected_stdout = expected_stdout_2
|
|
|
|
|
act_2.expected_stderr = expected_stderr_2
|
|
|
|
|
act_2.execute()
|
2022-01-21 18:49:26 +01:00
|
|
|
|
assert (act_2.clean_stderr == act_2.clean_expected_stderr and
|
|
|
|
|
act_2.clean_stdout == act_2.clean_expected_stdout)
|
2021-04-26 20:07:00 +02:00
|
|
|
|
|