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

52 lines
1.2 KiB
Python
Raw Normal View History

2021-04-26 20:07:00 +02:00
#coding:utf-8
2022-01-18 20:45:21 +01:00
"""
ID: issue-987
ISSUE: 987
TITLE: Token unknown in simple SELECT with GROUP BY and ORDER BY
DESCRIPTION: Getting SQL error code = -104, Token unknown count.
JIRA: CORE-625
FBTEST: bugs.core_0625
2022-01-18 20:45:21 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
import pytest
from firebird.qa import *
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
db = db_factory(page_size=4096)
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
test_script = """
2021-04-26 20:07:00 +02:00
recreate table customers(cust_id int primary key using index customers_pk, country int);
commit;
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
insert into customers
select r.rdb$relation_id, rand()*10
from rdb$relations r;
commit;
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
create index customers_country on customers(country);
commit;
2022-01-18 20:45:21 +01:00
2021-04-26 20:07:00 +02:00
set planonly;
--set explain on;
select country, count(country)
from customers
group by country
order by count(country);
-- NB: PLAN up to 2.5 contains TWO parenthesis:
-- PLAN SORT ((CUSTOMERS ORDER CUSTOMERS_COUNTRY))
-- ^^ ^^
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
act = isql_act('db', test_script, substitutions=[('\\(+', ''), ('\\)+', '')])
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +01:00
expected_stdout = """
2021-04-26 20:07:00 +02:00
PLAN SORT CUSTOMERS ORDER CUSTOMERS_COUNTRY
2021-12-22 20:23:11 +01:00
"""
2021-04-26 20:07:00 +02:00
2022-01-18 20:45:21 +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