PostgreSQL Source Code git master
|
#include "postgres.h"
#include <limits.h>
#include "commands/tablespace.h"
#include "miscadmin.h"
#include "pg_trace.h"
#include "storage/shmem.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/pg_rusage.h"
#include "utils/tuplesort.h"
#include "lib/sort_template.h"
Go to the source code of this file.
Data Structures | |
union | SlabSlot |
struct | Tuplesortstate |
struct | Sharedsort |
Macros | |
#define | INITIAL_MEMTUPSIZE |
#define | SLAB_SLOT_SIZE 1024 |
#define | MINORDER 6 /* minimum merge order */ |
#define | MAXORDER 500 /* maximum merge order */ |
#define | TAPE_BUFFER_OVERHEAD BLCKSZ |
#define | MERGE_BUFFER_SIZE (BLCKSZ * 32) |
#define | IS_SLAB_SLOT(state, tuple) |
#define | RELEASE_SLAB_SLOT(state, tuple) |
#define | REMOVEABBREV(state, stup, count) ((*(state)->base.removeabbrev) (state, stup, count)) |
#define | COMPARETUP(state, a, b) ((*(state)->base.comparetup) (a, b, state)) |
#define | WRITETUP(state, tape, stup) ((*(state)->base.writetup) (state, tape, stup)) |
#define | READTUP(state, stup, tape, len) ((*(state)->base.readtup) (state, stup, tape, len)) |
#define | FREESTATE(state) ((state)->base.freestate ? (*(state)->base.freestate) (state) : (void) 0) |
#define | LACKMEM(state) ((state)->availMem < 0 && !(state)->slabAllocatorUsed) |
#define | USEMEM(state, amt) ((state)->availMem -= (amt)) |
#define | FREEMEM(state, amt) ((state)->availMem += (amt)) |
#define | SERIAL(state) ((state)->shared == NULL) |
#define | WORKER(state) ((state)->shared && (state)->worker != -1) |
#define | LEADER(state) ((state)->shared && (state)->worker == -1) |
#define | ST_SORT qsort_tuple_unsigned |
#define | ST_ELEMENT_TYPE SortTuple |
#define | ST_COMPARE(a, b, state) qsort_tuple_unsigned_compare(a, b, state) |
#define | ST_COMPARE_ARG_TYPE Tuplesortstate |
#define | ST_CHECK_FOR_INTERRUPTS |
#define | ST_SCOPE static |
#define | ST_DEFINE |
#define | ST_SORT qsort_tuple_signed |
#define | ST_ELEMENT_TYPE SortTuple |
#define | ST_COMPARE(a, b, state) qsort_tuple_signed_compare(a, b, state) |
#define | ST_COMPARE_ARG_TYPE Tuplesortstate |
#define | ST_CHECK_FOR_INTERRUPTS |
#define | ST_SCOPE static |
#define | ST_DEFINE |
#define | ST_SORT qsort_tuple_int32 |
#define | ST_ELEMENT_TYPE SortTuple |
#define | ST_COMPARE(a, b, state) qsort_tuple_int32_compare(a, b, state) |
#define | ST_COMPARE_ARG_TYPE Tuplesortstate |
#define | ST_CHECK_FOR_INTERRUPTS |
#define | ST_SCOPE static |
#define | ST_DEFINE |
#define | ST_SORT qsort_tuple |
#define | ST_ELEMENT_TYPE SortTuple |
#define | ST_COMPARE_RUNTIME_POINTER |
#define | ST_COMPARE_ARG_TYPE Tuplesortstate |
#define | ST_CHECK_FOR_INTERRUPTS |
#define | ST_SCOPE static |
#define | ST_DECLARE |
#define | ST_DEFINE |
#define | ST_SORT qsort_ssup |
#define | ST_ELEMENT_TYPE SortTuple |
#define | ST_COMPARE(a, b, ssup) |
#define | ST_COMPARE_ARG_TYPE SortSupportData |
#define | ST_CHECK_FOR_INTERRUPTS |
#define | ST_SCOPE static |
#define | ST_DEFINE |
Typedefs | |
typedef union SlabSlot | SlabSlot |
Enumerations | |
enum | TupSortStatus { TSS_INITIAL , TSS_BOUNDED , TSS_BUILDRUNS , TSS_SORTEDINMEM , TSS_SORTEDONTAPE , TSS_FINALMERGE } |
Variables | |
bool | trace_sort = false |
Definition at line 396 of file tuplesort.c.
Definition at line 402 of file tuplesort.c.
#define FREESTATE | ( | state | ) | ((state)->base.freestate ? (*(state)->base.freestate) (state) : (void) 0) |
Definition at line 399 of file tuplesort.c.
#define INITIAL_MEMTUPSIZE |
Definition at line 120 of file tuplesort.c.
#define IS_SLAB_SLOT | ( | state, | |
tuple | |||
) |
Definition at line 375 of file tuplesort.c.
Definition at line 400 of file tuplesort.c.
Definition at line 405 of file tuplesort.c.
#define MAXORDER 500 /* maximum merge order */ |
Definition at line 177 of file tuplesort.c.
#define MERGE_BUFFER_SIZE (BLCKSZ * 32) |
Definition at line 179 of file tuplesort.c.
#define MINORDER 6 /* minimum merge order */ |
Definition at line 176 of file tuplesort.c.
Definition at line 398 of file tuplesort.c.
#define RELEASE_SLAB_SLOT | ( | state, | |
tuple | |||
) |
Definition at line 383 of file tuplesort.c.
Definition at line 395 of file tuplesort.c.
Definition at line 403 of file tuplesort.c.
#define SLAB_SLOT_SIZE 1024 |
Definition at line 142 of file tuplesort.c.
#define ST_CHECK_FOR_INTERRUPTS |
Definition at line 613 of file tuplesort.c.
#define ST_CHECK_FOR_INTERRUPTS |
Definition at line 613 of file tuplesort.c.
#define ST_CHECK_FOR_INTERRUPTS |
Definition at line 613 of file tuplesort.c.
#define ST_CHECK_FOR_INTERRUPTS |
Definition at line 613 of file tuplesort.c.
#define ST_CHECK_FOR_INTERRUPTS |
Definition at line 613 of file tuplesort.c.
Definition at line 609 of file tuplesort.c.
Definition at line 609 of file tuplesort.c.
Definition at line 609 of file tuplesort.c.
Definition at line 609 of file tuplesort.c.
#define ST_COMPARE_ARG_TYPE Tuplesortstate |
Definition at line 612 of file tuplesort.c.
#define ST_COMPARE_ARG_TYPE Tuplesortstate |
Definition at line 612 of file tuplesort.c.
#define ST_COMPARE_ARG_TYPE Tuplesortstate |
Definition at line 612 of file tuplesort.c.
#define ST_COMPARE_ARG_TYPE Tuplesortstate |
Definition at line 612 of file tuplesort.c.
#define ST_COMPARE_ARG_TYPE SortSupportData |
Definition at line 612 of file tuplesort.c.
#define ST_COMPARE_RUNTIME_POINTER |
Definition at line 599 of file tuplesort.c.
#define ST_DECLARE |
Definition at line 603 of file tuplesort.c.
#define ST_DEFINE |
Definition at line 615 of file tuplesort.c.
#define ST_DEFINE |
Definition at line 615 of file tuplesort.c.
#define ST_DEFINE |
Definition at line 615 of file tuplesort.c.
#define ST_DEFINE |
Definition at line 615 of file tuplesort.c.
#define ST_DEFINE |
Definition at line 615 of file tuplesort.c.
#define ST_ELEMENT_TYPE SortTuple |
Definition at line 608 of file tuplesort.c.
#define ST_ELEMENT_TYPE SortTuple |
Definition at line 608 of file tuplesort.c.
#define ST_ELEMENT_TYPE SortTuple |
Definition at line 608 of file tuplesort.c.
#define ST_ELEMENT_TYPE SortTuple |
Definition at line 608 of file tuplesort.c.
#define ST_ELEMENT_TYPE SortTuple |
Definition at line 608 of file tuplesort.c.
#define ST_SCOPE static |
Definition at line 614 of file tuplesort.c.
#define ST_SCOPE static |
Definition at line 614 of file tuplesort.c.
#define ST_SCOPE static |
Definition at line 614 of file tuplesort.c.
#define ST_SCOPE static |
Definition at line 614 of file tuplesort.c.
#define ST_SCOPE static |
Definition at line 614 of file tuplesort.c.
#define ST_SORT qsort_tuple_unsigned |
Definition at line 607 of file tuplesort.c.
#define ST_SORT qsort_tuple_signed |
Definition at line 607 of file tuplesort.c.
#define ST_SORT qsort_tuple_int32 |
Definition at line 607 of file tuplesort.c.
#define ST_SORT qsort_tuple |
Definition at line 607 of file tuplesort.c.
#define ST_SORT qsort_ssup |
Definition at line 607 of file tuplesort.c.
#define TAPE_BUFFER_OVERHEAD BLCKSZ |
Definition at line 178 of file tuplesort.c.
Definition at line 401 of file tuplesort.c.
Definition at line 404 of file tuplesort.c.
Definition at line 397 of file tuplesort.c.
enum TupSortStatus |
Enumerator | |
---|---|
TSS_INITIAL | |
TSS_BOUNDED | |
TSS_BUILDRUNS | |
TSS_SORTEDINMEM | |
TSS_SORTEDONTAPE | |
TSS_FINALMERGE |
Definition at line 154 of file tuplesort.c.
|
static |
Definition at line 2256 of file tuplesort.c.
References Assert(), mergereadnext(), Min, SortTuple::srctape, and tuplesort_heap_insert().
Referenced by mergeonerun(), and mergeruns().
|
static |
Definition at line 1315 of file tuplesort.c.
References Assert(), and TSS_INITIAL.
Referenced by tuplesort_puttuple_common().
|
static |
Definition at line 2303 of file tuplesort.c.
References Assert(), elog, ereport, errcode(), errmsg(), ERROR, FREEMEM, i, LACKMEM, LOG, markrunend(), MemoryContextReset(), pg_rusage_show(), selectnewtape(), trace_sort, TSS_BUILDRUNS, tuplesort_sort_memtuples(), and WRITETUP.
Referenced by tuplesort_performsort(), and tuplesort_puttuple_common().
|
static |
Definition at line 3122 of file tuplesort.c.
References FREEMEM, GetMemoryChunkSpace(), pfree(), and SortTuple::tuple.
Referenced by make_bounded_heap(), and tuplesort_puttuple_common().
|
static |
Definition at line 2850 of file tuplesort.c.
References elog, ERROR, len, and LogicalTapeRead().
Referenced by mergereadnext(), and tuplesort_gettuple_common().
|
static |
Definition at line 1048 of file tuplesort.c.
References elog, ERROR, FREEMEM, GetMemoryChunkSpace(), LACKMEM, MaxAllocHugeSize, repalloc_huge(), and USEMEM.
Referenced by tuplesort_puttuple_common().
|
static |
Definition at line 1977 of file tuplesort.c.
References i, palloc(), SLAB_SLOT_SIZE, and USEMEM.
Referenced by mergeruns().
|
static |
Definition at line 1861 of file tuplesort.c.
References Assert(), elog, inittapestate(), LEADER, LOG, LogicalTapeSetCreate(), mergeruns(), MINORDER, palloc0(), pg_rusage_show(), selectnewtape(), trace_sort, TSS_BUILDRUNS, tuplesort_merge_order(), and WORKER.
Referenced by tuplesort_performsort(), and tuplesort_puttuple_common().
|
static |
Definition at line 1910 of file tuplesort.c.
References GetMemoryChunkSpace(), PrepareTempTablespaces(), TAPE_BUFFER_OVERHEAD, and USEMEM.
Referenced by inittapes(), and leader_takeover_tapes().
|
static |
Definition at line 3063 of file tuplesort.c.
References Assert(), elog, ERROR, Sharedsort::fileset, inittapestate(), j, LEADER, LogicalTapeImport(), LogicalTapeSetCreate(), Sharedsort::mutex, palloc0(), SpinLockAcquire, SpinLockRelease, Sharedsort::tapes, TSS_BUILDRUNS, and Sharedsort::workersFinished.
Referenced by tuplesort_performsort().
|
static |
Definition at line 2583 of file tuplesort.c.
References Assert(), CHECK_FOR_INTERRUPTS, COMPARETUP, free_sort_tuple(), i, reversedirection(), SERIAL, TSS_BOUNDED, TSS_INITIAL, tuplesort_heap_insert(), and tuplesort_heap_replace_top().
Referenced by tuplesort_puttuple_common().
|
static |
Definition at line 2863 of file tuplesort.c.
References len, and LogicalTapeWrite().
Referenced by dumptuples(), and mergeonerun().
|
static |
Definition at line 1829 of file tuplesort.c.
References Max, Min, and TAPE_BUFFER_OVERHEAD.
Referenced by mergeruns().
|
static |
Definition at line 2196 of file tuplesort.c.
References Assert(), beginmerge(), markrunend(), mergereadnext(), RELEASE_SLAB_SLOT, SortTuple::srctape, tuplesort_heap_delete_top(), tuplesort_heap_replace_top(), and WRITETUP.
Referenced by mergeruns().
|
static |
Definition at line 2284 of file tuplesort.c.
References getlen(), and READTUP.
Referenced by beginmerge(), mergeonerun(), and tuplesort_gettuple_common().
|
static |
Definition at line 2013 of file tuplesort.c.
References Assert(), beginmerge(), elog, FREEMEM, GetMemoryChunkSpace(), init_slab_allocator(), INT64_FORMAT, LOG, LogicalTapeClose(), LogicalTapeFreeze(), LogicalTapeRewindForRead(), LogicalTapeSetForgetFreeSpace(), MemoryContextAlloc(), MemoryContextResetOnly(), merge_read_buffer_size(), mergeonerun(), palloc0(), pfree(), pg_rusage_show(), selectnewtape(), trace_sort, TSS_BUILDRUNS, TSS_FINALMERGE, TSS_SORTEDONTAPE, TUPLESORT_RANDOMACCESS, USEMEM, WORKER, and worker_freeze_result_tape().
Referenced by inittapes(), and tuplesort_performsort().
|
static |
Definition at line 540 of file tuplesort.c.
References a, ApplyInt32SortComparator(), b, and compare().
|
static |
Definition at line 517 of file tuplesort.c.
References a, ApplySignedSortComparator(), b, and compare().
|
static |
Definition at line 495 of file tuplesort.c.
References a, ApplyUnsignedSortComparator(), b, and compare().
|
static |
Definition at line 2832 of file tuplesort.c.
References SortSupportData::ssup_nulls_first, and SortSupportData::ssup_reverse.
Referenced by make_bounded_heap(), and sort_bounded_heap().
|
static |
Definition at line 1944 of file tuplesort.c.
References Assert(), and LogicalTapeCreate().
Referenced by dumptuples(), inittapes(), and mergeruns().
|
static |
Definition at line 2632 of file tuplesort.c.
References Assert(), reversedirection(), SERIAL, TSS_BOUNDED, TSS_SORTEDINMEM, and tuplesort_heap_delete_top().
Referenced by tuplesort_performsort().
int ssup_datum_int32_cmp | ( | Datum | x, |
Datum | y, | ||
SortSupport | ssup | ||
) |
Definition at line 3158 of file tuplesort.c.
References DatumGetInt32(), x, and y.
Referenced by btint4sortsupport(), date_sortsupport(), and tuplesort_sort_memtuples().
int ssup_datum_signed_cmp | ( | Datum | x, |
Datum | y, | ||
SortSupport | ssup | ||
) |
Definition at line 3144 of file tuplesort.c.
References DatumGetInt64(), x, and y.
Referenced by btint8sortsupport(), timestamp_sortsupport(), and tuplesort_sort_memtuples().
int ssup_datum_unsigned_cmp | ( | Datum | x, |
Datum | y, | ||
SortSupport | ssup | ||
) |
Definition at line 3133 of file tuplesort.c.
Referenced by gist_point_sortsupport(), macaddr_sortsupport(), network_sortsupport(), tuplesort_sort_memtuples(), uuid_sortsupport(), and varstr_sortsupport().
void tuplesort_attach_shared | ( | Sharedsort * | shared, |
dsm_segment * | seg | ||
) |
Definition at line 2955 of file tuplesort.c.
References Sharedsort::fileset, and SharedFileSetAttach().
Referenced by _brin_parallel_build_main(), _bt_parallel_build_main(), and _gin_parallel_build_main().
|
static |
Definition at line 748 of file tuplesort.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, BumpContextCreate(), elog, ERROR, GetMemoryChunkSpace(), INITIAL_MEMTUPSIZE, LACKMEM, MemoryContextSwitchTo(), palloc(), pfree(), TSS_INITIAL, TupleSortUseBumpTupleCxt, and USEMEM.
Referenced by tuplesort_begin_common(), and tuplesort_reset().
Tuplesortstate * tuplesort_begin_common | ( | int | workMem, |
SortCoordinate | coordinate, | ||
int | sortopt | ||
) |
Definition at line 638 of file tuplesort.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), CurrentMemoryContext, elog, ERROR, INITIAL_MEMTUPSIZE, SortCoordinateData::isWorker, Max, MemoryContextSwitchTo(), SortCoordinateData::nParticipants, palloc0(), pg_rusage_init(), SortCoordinateData::sharedsort, trace_sort, tuplesort_begin_batch(), TUPLESORT_RANDOMACCESS, and worker_get_identifier().
Referenced by tuplesort_begin_cluster(), tuplesort_begin_datum(), tuplesort_begin_heap(), tuplesort_begin_index_brin(), tuplesort_begin_index_btree(), tuplesort_begin_index_gin(), tuplesort_begin_index_gist(), and tuplesort_begin_index_hash().
void tuplesort_end | ( | Tuplesortstate * | state | ) |
Definition at line 947 of file tuplesort.c.
References MemoryContextDelete(), and tuplesort_free().
Referenced by _brin_parallel_merge(), _brin_parallel_scan_and_build(), _bt_parallel_scan_and_sort(), _bt_spooldestroy(), _gin_parallel_merge(), _gin_parallel_scan_and_build(), _gin_process_worker_data(), _h_spooldestroy(), array_sort_internal(), ExecEndAgg(), ExecEndIncrementalSort(), ExecEndSort(), ExecReScanAgg(), ExecReScanSort(), gistbuild(), heapam_relation_copy_for_cluster(), initialize_aggregate(), initialize_phase(), ordered_set_shutdown(), process_ordered_aggregate_multi(), process_ordered_aggregate_single(), and validate_index().
Size tuplesort_estimate_shared | ( | int | nWorkers | ) |
Definition at line 2911 of file tuplesort.c.
References add_size(), Assert(), MAXALIGN, and mul_size().
Referenced by _brin_begin_parallel(), _bt_begin_parallel(), and _gin_begin_parallel().
|
static |
Definition at line 893 of file tuplesort.c.
References elog, FREESTATE, LOG, LogicalTapeSetBlocks(), LogicalTapeSetClose(), MemoryContextReset(), MemoryContextSwitchTo(), pg_rusage_show(), SERIAL, and trace_sort.
Referenced by tuplesort_end(), and tuplesort_reset().
void tuplesort_get_stats | ( | Tuplesortstate * | state, |
TuplesortInstrumentation * | stats | ||
) |
Definition at line 2495 of file tuplesort.c.
References SORT_SPACE_TYPE_DISK, SORT_SPACE_TYPE_MEMORY, SORT_TYPE_EXTERNAL_MERGE, SORT_TYPE_EXTERNAL_SORT, SORT_TYPE_QUICKSORT, SORT_TYPE_STILL_IN_PROGRESS, SORT_TYPE_TOP_N_HEAPSORT, TuplesortInstrumentation::sortMethod, TuplesortInstrumentation::spaceType, TuplesortInstrumentation::spaceUsed, TSS_FINALMERGE, TSS_SORTEDINMEM, TSS_SORTEDONTAPE, and tuplesort_updatemax().
Referenced by ExecSort(), instrumentSortedGroup(), and show_sort_info().
bool tuplesort_gettuple_common | ( | Tuplesortstate * | state, |
bool | forward, | ||
SortTuple * | stup | ||
) |
Definition at line 1466 of file tuplesort.c.
References Assert(), elog, ERROR, getlen(), LogicalTapeBackspace(), LogicalTapeClose(), mergereadnext(), READTUP, RELEASE_SLAB_SLOT, SortTuple::srctape, TSS_FINALMERGE, TSS_SORTEDINMEM, TSS_SORTEDONTAPE, SortTuple::tuple, tuplesort_heap_delete_top(), tuplesort_heap_replace_top(), TUPLESORT_RANDOMACCESS, and WORKER.
Referenced by tuplesort_getbrintuple(), tuplesort_getdatum(), tuplesort_getgintuple(), tuplesort_getheaptuple(), tuplesort_getindextuple(), tuplesort_gettupleslot(), and tuplesort_skiptuples().
|
static |
Definition at line 2768 of file tuplesort.c.
References tuplesort_heap_replace_top().
Referenced by mergeonerun(), sort_bounded_heap(), and tuplesort_gettuple_common().
|
static |
Definition at line 2733 of file tuplesort.c.
References Assert(), CHECK_FOR_INTERRUPTS, COMPARETUP, i, and j.
Referenced by beginmerge(), and make_bounded_heap().
|
static |
Definition at line 2792 of file tuplesort.c.
References Assert(), CHECK_FOR_INTERRUPTS, COMPARETUP, i, and j.
Referenced by make_bounded_heap(), mergeonerun(), tuplesort_gettuple_common(), tuplesort_heap_delete_top(), and tuplesort_puttuple_common().
void tuplesort_initialize_shared | ( | Sharedsort * | shared, |
int | nWorkers, | ||
dsm_segment * | seg | ||
) |
Definition at line 2932 of file tuplesort.c.
References Assert(), Sharedsort::currentWorker, Sharedsort::fileset, TapeShare::firstblocknumber, i, Sharedsort::mutex, Sharedsort::nTapes, SharedFileSetInit(), SpinLockInit, Sharedsort::tapes, and Sharedsort::workersFinished.
Referenced by _brin_begin_parallel(), _bt_begin_parallel(), and _gin_begin_parallel().
void tuplesort_markpos | ( | Tuplesortstate * | state | ) |
Definition at line 2431 of file tuplesort.c.
References Assert(), elog, ERROR, LogicalTapeTell(), MemoryContextSwitchTo(), TSS_SORTEDINMEM, TSS_SORTEDONTAPE, and TUPLESORT_RANDOMACCESS.
Referenced by ExecSortMarkPos().
int tuplesort_merge_order | ( | int64 | allowedMem | ) |
Definition at line 1774 of file tuplesort.c.
References Max, MAXORDER, MERGE_BUFFER_SIZE, Min, MINORDER, and TAPE_BUFFER_OVERHEAD.
Referenced by cost_tuplesort(), and inittapes().
const char * tuplesort_method_name | ( | TuplesortMethod | m | ) |
Definition at line 2539 of file tuplesort.c.
References SORT_TYPE_EXTERNAL_MERGE, SORT_TYPE_EXTERNAL_SORT, SORT_TYPE_QUICKSORT, SORT_TYPE_STILL_IN_PROGRESS, and SORT_TYPE_TOP_N_HEAPSORT.
Referenced by show_incremental_sort_group_info(), and show_sort_info().
void tuplesort_performsort | ( | Tuplesortstate * | state | ) |
Definition at line 1359 of file tuplesort.c.
References dumptuples(), elog, ERROR, inittapes(), leader_takeover_tapes(), LOG, MemoryContextSwitchTo(), mergeruns(), pg_rusage_show(), SERIAL, sort_bounded_heap(), trace_sort, TSS_BOUNDED, TSS_BUILDRUNS, TSS_FINALMERGE, TSS_INITIAL, TSS_SORTEDINMEM, TSS_SORTEDONTAPE, tuplesort_sort_memtuples(), WORKER, and worker_nomergeruns().
Referenced by _brin_parallel_merge(), _brin_parallel_scan_and_build(), _bt_leafbuild(), _bt_parallel_scan_and_sort(), _gin_parallel_merge(), _gin_parallel_scan_and_build(), _gin_process_worker_data(), _h_indexbuild(), array_sort_internal(), ExecIncrementalSort(), ExecSort(), gistbuild(), heapam_relation_copy_for_cluster(), hypothetical_dense_rank_final(), hypothetical_rank_common(), initialize_phase(), mode_final(), percentile_cont_final_common(), percentile_cont_multi_final_common(), percentile_disc_final(), percentile_disc_multi_final(), process_ordered_aggregate_multi(), process_ordered_aggregate_single(), switchToPresortedPrefixMode(), and validate_index().
void tuplesort_puttuple_common | ( | Tuplesortstate * | state, |
SortTuple * | tuple, | ||
bool | useAbbrev, | ||
Size | tuplen | ||
) |
Definition at line 1165 of file tuplesort.c.
References Assert(), CHECK_FOR_INTERRUPTS, COMPARETUP, consider_abort_common(), SortTuple::datum1, dumptuples(), elog, ERROR, free_sort_tuple(), grow_memtuples(), inittapes(), LACKMEM, LEADER, LOG, make_bounded_heap(), MemoryContextSwitchTo(), pg_rusage_show(), REMOVEABBREV, trace_sort, TSS_BOUNDED, TSS_BUILDRUNS, TSS_INITIAL, tuplesort_heap_replace_top(), and USEMEM.
Referenced by tuplesort_putbrintuple(), tuplesort_putdatum(), tuplesort_putgintuple(), tuplesort_putheaptuple(), tuplesort_putindextuplevalues(), and tuplesort_puttupleslot().
void * tuplesort_readtup_alloc | ( | Tuplesortstate * | state, |
Size | tuplen | ||
) |
Definition at line 2877 of file tuplesort.c.
References Assert(), buf, MemoryContextAlloc(), and SLAB_SLOT_SIZE.
Referenced by readtup_cluster(), readtup_datum(), readtup_heap(), readtup_index(), readtup_index_brin(), and readtup_index_gin().
void tuplesort_rescan | ( | Tuplesortstate * | state | ) |
Definition at line 2398 of file tuplesort.c.
References Assert(), elog, ERROR, LogicalTapeRewindForRead(), MemoryContextSwitchTo(), TSS_SORTEDINMEM, TSS_SORTEDONTAPE, and TUPLESORT_RANDOMACCESS.
Referenced by ExecReScanSort(), mode_final(), percentile_cont_final_common(), percentile_cont_multi_final_common(), percentile_disc_final(), and percentile_disc_multi_final().
void tuplesort_reset | ( | Tuplesortstate * | state | ) |
Definition at line 1015 of file tuplesort.c.
References tuplesort_begin_batch(), tuplesort_free(), and tuplesort_updatemax().
Referenced by ExecIncrementalSort(), ExecReScanIncrementalSort(), and switchToPresortedPrefixMode().
void tuplesort_restorepos | ( | Tuplesortstate * | state | ) |
Definition at line 2462 of file tuplesort.c.
References Assert(), elog, ERROR, LogicalTapeSeek(), MemoryContextSwitchTo(), TSS_SORTEDINMEM, TSS_SORTEDONTAPE, and TUPLESORT_RANDOMACCESS.
Referenced by ExecSortRestrPos().
void tuplesort_set_bound | ( | Tuplesortstate * | state, |
int64 | bound | ||
) |
Definition at line 834 of file tuplesort.c.
References Assert(), LEADER, TSS_INITIAL, TUPLESORT_ALLOWBOUNDED, and WORKER.
Referenced by ExecIncrementalSort(), ExecSort(), and switchToPresortedPrefixMode().
bool tuplesort_skiptuples | ( | Tuplesortstate * | state, |
int64 | ntuples, | ||
bool | forward | ||
) |
Definition at line 1706 of file tuplesort.c.
References Assert(), CHECK_FOR_INTERRUPTS, elog, ERROR, MemoryContextSwitchTo(), TSS_FINALMERGE, TSS_SORTEDINMEM, TSS_SORTEDONTAPE, tuplesort_gettuple_common(), and WORKER.
Referenced by percentile_cont_final_common(), percentile_cont_multi_final_common(), percentile_disc_final(), and percentile_disc_multi_final().
|
static |
Definition at line 2672 of file tuplesort.c.
References Assert(), LEADER, ssup_datum_int32_cmp(), ssup_datum_signed_cmp(), and ssup_datum_unsigned_cmp().
Referenced by dumptuples(), and tuplesort_performsort().
const char * tuplesort_space_type_name | ( | TuplesortSpaceType | t | ) |
Definition at line 2562 of file tuplesort.c.
References Assert(), SORT_SPACE_TYPE_DISK, and SORT_SPACE_TYPE_MEMORY.
Referenced by show_incremental_sort_group_info(), and show_sort_info().
|
static |
Definition at line 964 of file tuplesort.c.
References LogicalTapeSetBlocks().
Referenced by tuplesort_get_stats(), and tuplesort_reset().
bool tuplesort_used_bound | ( | Tuplesortstate * | state | ) |
Definition at line 882 of file tuplesort.c.
Referenced by ExecIncrementalSort().
|
static |
Definition at line 3003 of file tuplesort.c.
References Assert(), LogicalTapeFreeze(), Sharedsort::mutex, output, pfree(), SpinLockAcquire, SpinLockRelease, Sharedsort::tapes, WORKER, and Sharedsort::workersFinished.
Referenced by mergeruns(), and worker_nomergeruns().
|
static |
Definition at line 2975 of file tuplesort.c.
References Assert(), Sharedsort::currentWorker, Sharedsort::mutex, SpinLockAcquire, SpinLockRelease, and WORKER.
Referenced by tuplesort_begin_common().
|
static |
Definition at line 3041 of file tuplesort.c.
References Assert(), WORKER, and worker_freeze_result_tape().
Referenced by tuplesort_performsort().
bool trace_sort = false |
Definition at line 124 of file tuplesort.c.
Referenced by dumptuples(), inittapes(), macaddr_abbrev_abort(), mergeruns(), network_abbrev_abort(), numeric_abbrev_abort(), tuplesort_begin_cluster(), tuplesort_begin_common(), tuplesort_begin_datum(), tuplesort_begin_heap(), tuplesort_begin_index_brin(), tuplesort_begin_index_btree(), tuplesort_begin_index_gin(), tuplesort_begin_index_gist(), tuplesort_begin_index_hash(), tuplesort_free(), tuplesort_performsort(), tuplesort_puttuple_common(), uuid_abbrev_abort(), and varstr_abbrev_abort().