-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support expressions in SELECT...OFFSET...FETCH clauses (#2298)
In SELECT...OFFSET...FETCH, T-SQL allows expressions for the expression in OFFSET and FETCH. In Babelfish any expression involving an operator or function call requires that the expression is enclosed in brackets. This fix add those brackets as part of ANTLR rewriting. Signed-off-by: Rob Verschoor [email protected] Task: BABEL-1174
- Loading branch information
1 parent
62a34e9
commit 83f3e3d
Showing
32 changed files
with
691 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
test/JDBC/expected/order_by_offset_fetch_rows-before-15_6-or-16_2-vu-cleanup.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
DROP PROC p1_upgr_order_by_offset_fetch | ||
go | ||
DROP FUNCTION f1_upgr_order_by_offset_fetch | ||
go | ||
DROP VIEW v1_upgr_order_by_offset_fetch | ||
go | ||
DROP table t1_upgr_order_by_offset_fetch | ||
go |
8 changes: 8 additions & 0 deletions
8
test/JDBC/expected/order_by_offset_fetch_rows-before-15_6-or-16_2-vu-prepare.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
create table t1_upgr_order_by_offset_fetch(a int, b int) | ||
go | ||
CREATE PROC p1_upgr_order_by_offset_fetch @p int=1,@q int=1 AS SELECT * FROM t1_upgr_order_by_offset_fetch ORDER BY b OFFSET @p*@q ROWS FETCH NEXT square(@q)+1 ROWS ONLY | ||
go | ||
CREATE FUNCTION f1_upgr_order_by_offset_fetch(@p int, @q int) returns int as begin declare @v int SELECT @v=count(a) FROM t1_upgr_order_by_offset_fetch group by b ORDER BY b OFFSET @p*@q ROWS FETCH NEXT square(@q)+1 ROWS ONLY return @v end | ||
go | ||
CREATE VIEW v1_upgr_order_by_offset_fetch as select * FROM t1_upgr_order_by_offset_fetch ORDER BY b OFFSET 5 ROWS FETCH NEXT 3 rows only | ||
go |
73 changes: 73 additions & 0 deletions
73
test/JDBC/expected/order_by_offset_fetch_rows-before-15_6-or-16_2-vu-verify.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
insert t1_upgr_order_by_offset_fetch select generate_series, 0 from generate_series(1,100) | ||
go | ||
~~ROW COUNT: 100~~ | ||
|
||
update t1_upgr_order_by_offset_fetch set b=a | ||
go | ||
~~ROW COUNT: 100~~ | ||
|
||
exec p1_upgr_order_by_offset_fetch 1, 3 | ||
go | ||
~~START~~ | ||
int#!#int | ||
4#!#4 | ||
5#!#5 | ||
6#!#6 | ||
7#!#7 | ||
8#!#8 | ||
9#!#9 | ||
10#!#10 | ||
11#!#11 | ||
12#!#12 | ||
13#!#13 | ||
~~END~~ | ||
|
||
exec p1_upgr_order_by_offset_fetch 2, 3 | ||
go | ||
~~START~~ | ||
int#!#int | ||
7#!#7 | ||
8#!#8 | ||
9#!#9 | ||
10#!#10 | ||
11#!#11 | ||
12#!#12 | ||
13#!#13 | ||
14#!#14 | ||
15#!#15 | ||
16#!#16 | ||
~~END~~ | ||
|
||
p1_upgr_order_by_offset_fetch 3, 3 | ||
go | ||
~~START~~ | ||
int#!#int | ||
10#!#10 | ||
11#!#11 | ||
12#!#12 | ||
13#!#13 | ||
14#!#14 | ||
15#!#15 | ||
16#!#16 | ||
17#!#17 | ||
18#!#18 | ||
19#!#19 | ||
~~END~~ | ||
|
||
select dbo.f1_upgr_order_by_offset_fetch(1,1) | ||
go | ||
~~START~~ | ||
int | ||
1 | ||
~~END~~ | ||
|
||
select * from v1_upgr_order_by_offset_fetch | ||
go | ||
~~START~~ | ||
int#!#int | ||
6#!#6 | ||
7#!#7 | ||
8#!#8 | ||
~~END~~ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
DROP PROC p1_order_by_offset_fetch | ||
go | ||
DROP FUNCTION f1_order_by_offset_fetch | ||
go | ||
DROP VIEW v1_order_by_offset_fetch | ||
go | ||
DROP table t1_order_by_offset_fetch | ||
go |
16 changes: 16 additions & 0 deletions
16
test/JDBC/expected/order_by_offset_fetch_rows-vu-prepare.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
create table t1_order_by_offset_fetch(a int, b int) | ||
go | ||
insert t1_order_by_offset_fetch select generate_series, 0 from generate_series(1,100) | ||
go | ||
~~ROW COUNT: 100~~ | ||
|
||
update t1_order_by_offset_fetch set b=a | ||
go | ||
~~ROW COUNT: 100~~ | ||
|
||
CREATE PROC p1_order_by_offset_fetch @p int=1,@q int=1 AS SELECT * FROM t1_order_by_offset_fetch ORDER BY b OFFSET @p*@q ROWS FETCH NEXT square(@q)+1 ROWS ONLY | ||
go | ||
CREATE FUNCTION f1_order_by_offset_fetch(@p int, @q int) returns int as begin declare @v int SELECT @v=count(a) FROM t1_order_by_offset_fetch group by b ORDER BY b OFFSET @p*@q ROWS FETCH NEXT square(@q)+1 ROWS ONLY return @v end | ||
go | ||
CREATE VIEW v1_order_by_offset_fetch as select * FROM t1_order_by_offset_fetch ORDER BY b OFFSET 5 ROWS FETCH NEXT 3 rows only | ||
go |
Oops, something went wrong.