6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 13:33:07 +01:00
firebird-qa/tests/bugs/core_5404_test.py

119 lines
2.8 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-25 22:55:48 +01:00
"""
ID: issue-5677
ISSUE: 5677
TITLE: Inconsistent column/line references when PSQL definitions return errors
DESCRIPTION:
### WARNING ###
Following code is intentionaly aborted in the middle point because some cases are not
covered by fix of this ticket (see also issue in the ticket, 22/Nov/16 06:10 PM).
JIRA: CORE-5404
FBTEST: bugs.core_5404
2022-01-25 22:55:48 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
db = db_factory()
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
set term ^;
create or alter procedure dsql_field_err1 as
declare i int;
begin
select "" from rdb$database into i; -- Column unknown.
2022-01-25 22:55:48 +01:00
end
2021-04-26 20:07:00 +02:00
^
create or alter procedure dsql_field_err2 as
declare i int;
begin
select foo from rdb$database into i;
end
^
set term ;^
quit; --------------------------------------- Q U I T ------------------- (TEMPLY)
set term ^;
create or alter procedure dsql_count_mismatch as
declare i int;
declare k int;
begin
select 1 from rdb$database into i, k; -- Count of column list and variable list do not match.
2022-01-25 22:55:48 +01:00
end
2021-04-26 20:07:00 +02:00
^
create or alter procedure dsql_invalid_expr as
declare i int;
declare j varchar(64);
declare k int;
begin
2022-01-25 22:55:48 +01:00
select RDB$RELATION_ID,RDB$CHARACTER_SET_NAME, count(*)
from rdb$database
2021-04-26 20:07:00 +02:00
group by 1
into i, j, k;
2022-01-25 22:55:48 +01:00
end
2021-04-26 20:07:00 +02:00
^
create or alter procedure dsql_agg_where_err as
declare i int;
begin
2022-01-25 22:55:48 +01:00
select count(*)
from rdb$database
2021-04-26 20:07:00 +02:00
group by count(*) -- Cannot use an aggregate function in a GROUP BY clause.
into i;
2022-01-25 22:55:48 +01:00
end
2021-04-26 20:07:00 +02:00
^
create or alter procedure dsql_agg_nested_err as
declare i int;
begin
select count( max(1) ) -- Nested aggregate functions are not allowed.
2022-01-25 22:55:48 +01:00
from rdb$database
2021-04-26 20:07:00 +02:00
into i;
2022-01-25 22:55:48 +01:00
end
2021-04-26 20:07:00 +02:00
^
create or alter procedure dsql_column_pos_err as
declare i int;
begin
select 1
2022-01-25 22:55:48 +01:00
from rdb$database
2021-04-26 20:07:00 +02:00
order by 1, 2 -- Invalid column position used in the @1 clause
into i;
2022-01-25 22:55:48 +01:00
end
2021-04-26 20:07:00 +02:00
^
2022-01-25 22:55:48 +01:00
set term ;^
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-25 22:55:48 +01:00
act = isql_act('db', test_script,
substitutions=[('-At line[:]{0,1}[\\s]+[\\d]+,[\\s]+column[:]{0,1}[\\s]+[\\d]+',
'-At line: column:')])
2021-04-26 20:07:00 +02:00
2022-01-25 22:55:48 +01:00
expected_stderr = """
2021-04-26 20:07:00 +02:00
Statement failed, SQLSTATE = 42000
Dynamic SQL Error
-SQL error code = -104
-Zero length identifiers are not allowed
-At line 4, column 10
Statement failed, SQLSTATE = 42S22
unsuccessful metadata update
-CREATE OR ALTER PROCEDURE DSQL_FIELD_ERR2 failed
-Dynamic SQL Error
-SQL error code = -206
-Column unknown
-FOO
-At line 4, column 10
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
@pytest.mark.version('>=4.0')
2022-01-25 22:55:48 +01:00
def test_1(act: Action):
act.expected_stderr = expected_stderr
act.execute()
assert act.clean_stderr == act.clean_expected_stderr
2021-04-26 20:07:00 +02:00