[MDEV-29645] OFFSET doesn't work with view Created: 2022-09-27  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.6, 10.7, 10.8, 10.9, 10.11
Fix Version/s: 10.6, 10.11

Type: Bug Priority: Critical
Reporter: Lena Startseva Assignee: Vicențiu Ciorbaru
Resolution: Unresolved Votes: 0
Labels: view-protocol

Issue Links:
PartOf
is part of MDEV-27691 make working view-protocol Open

 Description   

Test:

create table t1 (a int);
insert into t1 values (1), (1), (2), (3), (2);
create view v1 as select * from t1 order by a offset 2 rows;
select * from v1;
drop view v1;
drop table t1;

Expected result:

a
2
2
3

Actual result:

a
1
1
2
2
3



 Comments   
Comment by Oleksandr Byelkin [ 2022-11-29 ]

It is lack of FETCH/LIMIT support in select printing for VIEWs by the author:

create table t1 (a int);
insert into t1 values (1), (1), (2), (3), (2);
select * from t1 order by a offset 2 rows;
a
2
2
3
create view v1 as select * from t1 order by a offset 2 rows;
select * from v1;
a
1
1
2
2
3
show create view v1;
View	Create View	character_set_client	collation_connection
v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` order by `t1`.`a`	latin1	latin1_swedish_ci
drop view v1;
create view v1 as select * from t1 order by a limit 2 offset 2;
select * from v1;
a
2
2
show create view v1;
View	Create View	character_set_client	collation_connection
v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` order by `t1`.`a` limit 2,2	latin1	latin1_swedish_ci
drop table t1;

Comment by Oleksandr Byelkin [ 2022-12-01 ]

after fixing the bug do not forget remove:

#enable after fix MDEV-29645
--disable_view_protocol
...
--enable_view_protocol

in mysql-test/main/fetch_first.test and run it with --view-protocol

Generated at Thu Feb 08 10:10:12 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.