Avoid using "tapeset" in XL-specific tuplesort code.
authorPavan Deolasee <[email protected]>
Thu, 15 Jun 2017 05:21:13 +0000 (10:51 +0530)
committerPavan Deolasee <[email protected]>
Thu, 15 Jun 2017 05:21:13 +0000 (10:51 +0530)
"tapeset" may not be setup when we are using tuplesort to merge tuples from
remote connections. So avoid referencing tapeset members.

src/backend/utils/sort/tuplesort.c

index 015e4ea93b7dd8e2b9000a78222670ee226ea9eb..02cd1d7fe27e9b652c711936b673f02c6c1c0911 100644 (file)
@@ -2216,8 +2216,14 @@ tuplesort_gettuple_common(Tuplesortstate *state, bool forward,
                                         * Rewind to free the read buffer.  It'd go away at the
                                         * end of the sort anyway, but better to release the
                                         * memory early.
+                                        *
+                                        * XXX PG10MERGE: In XL, we use tuplesort_begin_merge() to
+                                        * merge tuples from datanode connections. We don't use
+                                        * tapeset in that code path. The following fix helps that
+                                        * case.
                                         */
-                                       LogicalTapeRewindForWrite(state->tapeset, srcTape);
+                                       if (state->tapeset)
+                                               LogicalTapeRewindForWrite(state->tapeset, srcTape);
                                        return true;
                                }
                                newtup.tupindex = srcTape;