6
0
mirror of https://github.com/FirebirdSQL/firebird-qa.git synced 2025-01-22 21:43:06 +01:00
firebird-qa/tests/bugs/core_2176_test.py

322 lines
11 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-21 18:49:26 +01:00
"""
ID: issue-2607
ISSUE: 2607
TITLE: Unexpected (wrong) results with COALESCE and GROUP BY
DESCRIPTION:
JIRA: CORE-2176
FBTEST: bugs.core_2176
2022-01-21 18:49:26 +01:00
"""
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
test_script = """
2021-04-26 20:07:00 +02:00
create or alter view v_rel (rid, rnm, rty) as
select r.rdb$relation_id, r.rdb$relation_name, r.rdb$relation_type
from rdb$relations r
where r.rdb$relation_id <= 30 -- ::: NB ::: added this cond because number of rows in 2.5 and 3.0 differ!
;
commit;
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
set count on ;
set list on;
select rid as c from v_rel
group by 1 ;
-- correct result
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
select * from (
select rid as c from v_rel
) group by 1 ;
-- also correct
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
select coalesce(rid, 0) as c from v_rel
group by 1 ;
-- ERROR: no zero ID is reported, the last ID is reported twice
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
select * from (
select coalesce(rid, 0) as c from v_rel
) group by 1 ;
-- ERROR: single NULL is returned
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
select * from (
select coalesce(rid, 0) as a, coalesce(rty, 0) as b from v_rel
) group by 1, 2 ;
-- ERROR: infinite result set with all zero values
2022-01-21 18:49:26 +01:00
2021-04-26 20:07:00 +02:00
select * from (
select coalesce(rid, 0) as a, coalesce(rnm, '') as b from v_rel
) group by 1, 2 ;
-- ERROR: conversion error
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 = isql_act('db', test_script)
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
C 0
C 1
C 2
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 12
C 13
C 14
C 15
C 16
C 17
C 18
C 19
C 20
C 21
C 22
C 23
C 24
C 25
C 26
C 27
C 28
C 29
C 30
Records affected: 31
C 0
C 1
C 2
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 12
C 13
C 14
C 15
C 16
C 17
C 18
C 19
C 20
C 21
C 22
C 23
C 24
C 25
C 26
C 27
C 28
C 29
C 30
Records affected: 31
C 0
C 1
C 2
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 12
C 13
C 14
C 15
C 16
C 17
C 18
C 19
C 20
C 21
C 22
C 23
C 24
C 25
C 26
C 27
C 28
C 29
C 30
Records affected: 31
C 0
C 1
C 2
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 12
C 13
C 14
C 15
C 16
C 17
C 18
C 19
C 20
C 21
C 22
C 23
C 24
C 25
C 26
C 27
C 28
C 29
C 30
Records affected: 31
A 0
B 0
A 1
B 0
A 2
B 0
A 3
B 0
A 4
B 0
A 5
B 0
A 6
B 0
A 7
B 0
A 8
B 0
A 9
B 0
A 10
B 0
A 11
B 0
A 12
B 0
A 13
B 0
A 14
B 0
A 15
B 0
A 16
B 0
A 17
B 0
A 18
B 0
A 19
B 0
A 20
B 0
A 21
B 0
A 22
B 0
A 23
B 0
A 24
B 0
A 25
B 0
A 26
B 0
A 27
B 0
A 28
B 0
A 29
B 0
A 30
B 0
Records affected: 31
A 0
2022-01-21 18:49:26 +01:00
B RDB$PAGES
2021-04-26 20:07:00 +02:00
A 1
2022-01-21 18:49:26 +01:00
B RDB$DATABASE
2021-04-26 20:07:00 +02:00
A 2
2022-01-21 18:49:26 +01:00
B RDB$FIELDS
2021-04-26 20:07:00 +02:00
A 3
2022-01-21 18:49:26 +01:00
B RDB$INDEX_SEGMENTS
2021-04-26 20:07:00 +02:00
A 4
2022-01-21 18:49:26 +01:00
B RDB$INDICES
2021-04-26 20:07:00 +02:00
A 5
2022-01-21 18:49:26 +01:00
B RDB$RELATION_FIELDS
2021-04-26 20:07:00 +02:00
A 6
2022-01-21 18:49:26 +01:00
B RDB$RELATIONS
2021-04-26 20:07:00 +02:00
A 7
2022-01-21 18:49:26 +01:00
B RDB$VIEW_RELATIONS
2021-04-26 20:07:00 +02:00
A 8
2022-01-21 18:49:26 +01:00
B RDB$FORMATS
2021-04-26 20:07:00 +02:00
A 9
2022-01-21 18:49:26 +01:00
B RDB$SECURITY_CLASSES
2021-04-26 20:07:00 +02:00
A 10
2022-01-21 18:49:26 +01:00
B RDB$FILES
2021-04-26 20:07:00 +02:00
A 11
2022-01-21 18:49:26 +01:00
B RDB$TYPES
2021-04-26 20:07:00 +02:00
A 12
2022-01-21 18:49:26 +01:00
B RDB$TRIGGERS
2021-04-26 20:07:00 +02:00
A 13
2022-01-21 18:49:26 +01:00
B RDB$DEPENDENCIES
2021-04-26 20:07:00 +02:00
A 14
2022-01-21 18:49:26 +01:00
B RDB$FUNCTIONS
2021-04-26 20:07:00 +02:00
A 15
2022-01-21 18:49:26 +01:00
B RDB$FUNCTION_ARGUMENTS
2021-04-26 20:07:00 +02:00
A 16
2022-01-21 18:49:26 +01:00
B RDB$FILTERS
2021-04-26 20:07:00 +02:00
A 17
2022-01-21 18:49:26 +01:00
B RDB$TRIGGER_MESSAGES
2021-04-26 20:07:00 +02:00
A 18
2022-01-21 18:49:26 +01:00
B RDB$USER_PRIVILEGES
2021-04-26 20:07:00 +02:00
A 19
2022-01-21 18:49:26 +01:00
B RDB$TRANSACTIONS
2021-04-26 20:07:00 +02:00
A 20
2022-01-21 18:49:26 +01:00
B RDB$GENERATORS
2021-04-26 20:07:00 +02:00
A 21
2022-01-21 18:49:26 +01:00
B RDB$FIELD_DIMENSIONS
2021-04-26 20:07:00 +02:00
A 22
2022-01-21 18:49:26 +01:00
B RDB$RELATION_CONSTRAINTS
2021-04-26 20:07:00 +02:00
A 23
2022-01-21 18:49:26 +01:00
B RDB$REF_CONSTRAINTS
2021-04-26 20:07:00 +02:00
A 24
2022-01-21 18:49:26 +01:00
B RDB$CHECK_CONSTRAINTS
2021-04-26 20:07:00 +02:00
A 25
2022-01-21 18:49:26 +01:00
B RDB$LOG_FILES
2021-04-26 20:07:00 +02:00
A 26
2022-01-21 18:49:26 +01:00
B RDB$PROCEDURES
2021-04-26 20:07:00 +02:00
A 27
2022-01-21 18:49:26 +01:00
B RDB$PROCEDURE_PARAMETERS
2021-04-26 20:07:00 +02:00
A 28
2022-01-21 18:49:26 +01:00
B RDB$CHARACTER_SETS
2021-04-26 20:07:00 +02:00
A 29
2022-01-21 18:49:26 +01:00
B RDB$COLLATIONS
2021-04-26 20:07:00 +02:00
A 30
2022-01-21 18:49:26 +01:00
B RDB$EXCEPTIONS
2021-04-26 20:07:00 +02:00
Records affected: 31
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-21 18:49:26 +01:00
@pytest.mark.version('>=3.0')
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