Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 35cb574

Browse files
committed
Suppress -Wimplicit-fallthrough warning in new LIMIT WITH TIES code.
The placement of the fall-through comment in this code appears not to work to suppress the warning in recent gcc. Move it to the bottom of the case group, and add an assertion that we didn't get there through some other code path. Also improve wording of nearby comments. Julien Rouhaud, comment hacking by me Discussion: https://postgr.es/m/CAOBaU_aLdPGU5wCpaowNLF-Q8328iR7mj1yJAhMOVsdLwY+sdg@mail.gmail.com
1 parent 328c709 commit 35cb574

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/backend/executor/nodeLimit.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -138,17 +138,18 @@ ExecLimit(PlanState *pstate)
138138
/*
139139
* Forwards scan, so check for stepping off end of window. At
140140
* the end of the window, the behavior depends on whether WITH
141-
* TIES was specified: in that case, we need to change the
142-
* state machine to LIMIT_WINDOWTIES. If not (nothing was
143-
* specified, or ONLY was) return NULL without advancing the
144-
* subplan or the position variable but change the state
145-
* machine to record having done so
141+
* TIES was specified: if so, we need to change the state
142+
* machine to WINDOWEND_TIES, and fall through to the code for
143+
* that case. If not (nothing was specified, or ONLY was)
144+
* return NULL without advancing the subplan or the position
145+
* variable, but change the state machine to record having
146+
* done so.
146147
*
147-
* Once at the end, ideally, we can shut down parallel
148-
* resources but that would destroy the parallel context which
149-
* would be required for rescans. To do that, we need to find
150-
* a way to pass down more information about whether rescans
151-
* are possible.
148+
* Once at the end, ideally, we would shut down parallel
149+
* resources; but that would destroy the parallel context
150+
* which might be required for rescans. To do that, we'll
151+
* need to find a way to pass down more information about
152+
* whether rescans are possible.
152153
*/
153154
if (!node->noCount &&
154155
node->position - node->offset >= node->count)
@@ -161,7 +162,7 @@ ExecLimit(PlanState *pstate)
161162
else
162163
{
163164
node->lstate = LIMIT_WINDOWEND_TIES;
164-
/* fall-through */
165+
/* we'll fall through to the next case */
165166
}
166167
}
167168
else
@@ -177,8 +178,9 @@ ExecLimit(PlanState *pstate)
177178
}
178179

179180
/*
180-
* Tuple at limit is needed for comparation in subsequent
181-
* execution to detect ties.
181+
* If WITH TIES is active, and this is the last in-window
182+
* tuple, save it to be used in subsequent WINDOWEND_TIES
183+
* processing.
182184
*/
183185
if (node->limitOption == LIMIT_OPTION_WITH_TIES &&
184186
node->position - node->offset == node->count - 1)
@@ -194,7 +196,7 @@ ExecLimit(PlanState *pstate)
194196
{
195197
/*
196198
* Backwards scan, so check for stepping off start of window.
197-
* As above, change only state-machine status if so.
199+
* As above, only change state-machine status if so.
198200
*/
199201
if (node->position <= node->offset + 1)
200202
{
@@ -213,6 +215,9 @@ ExecLimit(PlanState *pstate)
213215
break;
214216
}
215217

218+
Assert(node->lstate == LIMIT_WINDOWEND_TIES);
219+
/* FALL THRU */
220+
216221
case LIMIT_WINDOWEND_TIES:
217222
if (ScanDirectionIsForward(direction))
218223
{

0 commit comments

Comments
 (0)