aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-09-13 16:56:58 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-09-13 16:57:07 -0400
commitb360e0fcd7dcffe3238187209911a6f523057b0c (patch)
tree68c1ed0cce4c6f667cf472a08f51e04623a9f5e5 /src
parentbac2fae05c7737530a6fe8276cd27d210d25c6ac (diff)
downloadpostgresql-b360e0fcd7dcffe3238187209911a6f523057b0c.tar.gz
postgresql-b360e0fcd7dcffe3238187209911a6f523057b0c.zip
Make tuplesort_set_bound() assertions more comprehensible, hopefully.
Add the comments that I griped were missing. Also re-order tests so that parallelism-related tests aren't randomly separated from each other. Discussion: https://postgr.es/m/CAAaqYe9GD__4Crm=ddz+-XXcNhfY_V5gFYdLdmkFNq=2VHO56Q@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/sort/tuplesort.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index 152daa72e1c..ab55e69975c 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -1187,20 +1187,21 @@ tuplesort_set_bound(Tuplesortstate *state, int64 bound)
{
/* Assert we're called before loading any tuples */
Assert(state->status == TSS_INITIAL && state->memtupcount == 0);
-
+ /* Can't set the bound twice, either */
Assert(!state->bounded);
+ /* Also, this shouldn't be called in a parallel worker */
Assert(!WORKER(state));
+ /* Parallel leader allows but ignores hint */
+ if (LEADER(state))
+ return;
+
#ifdef DEBUG_BOUNDED_SORT
/* Honor GUC setting that disables the feature (for easy testing) */
if (!optimize_bounded_sort)
return;
#endif
- /* Parallel leader ignores hint */
- if (LEADER(state))
- return;
-
/* We want to be able to compute bound * 2, so limit the setting */
if (bound > (int64) (INT_MAX / 2))
return;