Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc301c2e

Browse files
committed
WITH TIES: number of rows is optional and defaults to one
FETCH FIRST .. ONLY implements this correctly, but we missed to includeit for FETCH FIRST .. WITH TIES in commit357889e.Author: Vik FearingDiscussion:https://postgr.es/m/6aa690ef-551d-e24f-2690-c38c2442947c@postgresfriends.org
1 parent7966b79 commitc301c2e

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

‎src/backend/parser/gram.y

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11816,6 +11816,14 @@ limit_clause:
1181611816
n->limitOption = LIMIT_OPTION_COUNT;
1181711817
$$ = n;
1181811818
}
11819+
|FETCHfirst_or_nextrow_or_rowsWITHTIES
11820+
{
11821+
SelectLimit *n = (SelectLimit *) palloc(sizeof(SelectLimit));
11822+
n->limitOffset =NULL;
11823+
n->limitCount = makeIntConst(1, -1);
11824+
n->limitOption = LIMIT_OPTION_WITH_TIES;
11825+
$$ = n;
11826+
}
1181911827
;
1182011828

1182111829
offset_clause:

‎src/test/regress/expected/limit.out

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,23 @@ SELECT thousand
576576
0
577577
(10 rows)
578578

579+
SELECT thousand
580+
FROM onek WHERE thousand < 5
581+
ORDER BY thousand FETCH FIRST ROWS WITH TIES;
582+
thousand
583+
----------
584+
0
585+
0
586+
0
587+
0
588+
0
589+
0
590+
0
591+
0
592+
0
593+
0
594+
(10 rows)
595+
579596
SELECT thousand
580597
FROM onek WHERE thousand < 5
581598
ORDER BY thousand FETCH FIRST 1 ROW WITH TIES;

‎src/test/regress/sql/limit.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,18 @@ SELECT thousand
161161
FROM onekWHERE thousand<5
162162
ORDER BY thousand FETCH FIRST2 ROW WITH TIES;
163163

164+
SELECT thousand
165+
FROM onekWHERE thousand<5
166+
ORDER BY thousand FETCH FIRST ROWS WITH TIES;
167+
164168
SELECT thousand
165169
FROM onekWHERE thousand<5
166170
ORDER BY thousand FETCH FIRST1 ROW WITH TIES;
167171

168172
SELECT thousand
169173
FROM onekWHERE thousand<5
170174
ORDER BY thousand FETCH FIRST2 ROW ONLY;
175+
171176
-- should fail
172177
SELECT''::textAS two, unique1, unique2, stringu1
173178
FROM onekWHERE unique1>50

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp