2021-04-26 20:07:00 +02:00
|
|
|
#coding:utf-8
|
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
"""
|
|
|
|
ID: issue-5464
|
|
|
|
ISSUE: 5464
|
|
|
|
TITLE: Regression: line/column numbering may be twisted if alias.name syntax is used
|
|
|
|
DESCRIPTION:
|
|
|
|
NB: it's very _poor_ idea to compare line and column values from text of failed statement
|
|
|
|
and some concrete values because they depend on position of statement whithin text ('sqltxt')
|
|
|
|
which we going to execute by ISQL.
|
|
|
|
Thus it was decided to check only that at final point we will have error log with only ONE
|
|
|
|
unique pair of values {line, column} - no matter which exactly values are stored there.
|
|
|
|
For this purpose we run script, filter its log (which contains text like: -At line NN, column MM)
|
|
|
|
and parse (split) these lines on tokens. We extract tokens with number line and column and add
|
|
|
|
each pair to the dictionary (Python; Map in java). Name of variable for this dict. = 'pairs'.
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
Key point: length of this dictionary should be 1.
|
|
|
|
JIRA: CORE-5183
|
2022-02-02 15:46:19 +01:00
|
|
|
FBTEST: bugs.core_5183
|
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
|
|
|
|
import re
|
|
|
|
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
|
|
|
act = python_act('db')
|
2021-11-29 20:54:28 +01:00
|
|
|
|
2022-01-25 22:55:48 +01:00
|
|
|
test_script = """
|
2021-11-29 20:54:28 +01:00
|
|
|
set term ^;
|
|
|
|
execute block
|
|
|
|
returns (id int)
|
|
|
|
as
|
|
|
|
begin
|
|
|
|
select y
|
|
|
|
from rdb$database x where z = 0
|
|
|
|
into id;
|
|
|
|
suspend;
|
|
|
|
end^
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-11-29 20:54:28 +01:00
|
|
|
execute block
|
|
|
|
returns (id int)
|
|
|
|
as
|
|
|
|
begin
|
|
|
|
select x.y
|
|
|
|
from rdb$database x where z = 0
|
|
|
|
into id;
|
|
|
|
suspend;
|
|
|
|
end^
|
|
|
|
"""
|
2021-04-26 20:07:00 +02:00
|
|
|
|
2021-11-29 20:54:28 +01:00
|
|
|
@pytest.mark.version('>=2.5.6')
|
2022-01-25 22:55:48 +01:00
|
|
|
def test_1(act: Action):
|
2021-11-29 20:54:28 +01:00
|
|
|
pattern = re.compile("-At line[\\s]+[0-9]+[\\s]*,[\\s]*column[\\s]+[0-9]+")
|
2022-01-25 22:55:48 +01:00
|
|
|
act.expected_stderr = "We expect errors"
|
|
|
|
act.isql(switches=[], input=test_script)
|
2021-11-29 20:54:28 +01:00
|
|
|
# stderr Output
|
|
|
|
# -At line 6, column 35
|
|
|
|
# -At line 9, column 5
|
|
|
|
# ^ ^ ^ ^ ^
|
|
|
|
# | | | | |
|
|
|
|
# 1 2 3 4 5 <<< indices for tokens
|
|
|
|
pairs = {}
|
2022-01-25 22:55:48 +01:00
|
|
|
for line in act.stderr.splitlines():
|
2021-11-29 20:54:28 +01:00
|
|
|
if pattern.match(line):
|
|
|
|
tokens = re.split('\\W+', line)
|
|
|
|
pairs[tokens[3]] = tokens[5]
|
|
|
|
print(pairs)
|
|
|
|
assert len(pairs) == 1
|