PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <limits.h>
#include "access/htup_details.h"
#include "commands/tablespace.h"
#include "executor/executor.h"
#include "miscadmin.h"
#include "storage/buffile.h"
#include "utils/memutils.h"
#include "utils/resowner.h"
Go to the source code of this file.
Data Structures | |
struct | TSReadPointer |
struct | Tuplestorestate |
Macros | |
#define | COPYTUP(state, tup) ((*(state)->copytup) (state, tup)) |
#define | WRITETUP(state, tup) ((*(state)->writetup) (state, tup)) |
#define | READTUP(state, len) ((*(state)->readtup) (state, len)) |
#define | LACKMEM(state) ((state)->availMem < 0) |
#define | USEMEM(state, amt) ((state)->availMem -= (amt)) |
#define | FREEMEM(state, amt) ((state)->availMem += (amt)) |
Enumerations | |
enum | TupStoreStatus { TSS_INMEM, TSS_WRITEFILE, TSS_READFILE } |
Definition at line 183 of file tuplestore.c.
Referenced by tuplestore_puttuple().
Definition at line 188 of file tuplestore.c.
Referenced by grow_memtuples(), tuplestore_clear(), tuplestore_trim(), and writetup_heap().
Definition at line 186 of file tuplestore.c.
Referenced by grow_memtuples(), and tuplestore_puttuple_common().
Definition at line 185 of file tuplestore.c.
Referenced by tuplestore_gettuple().
Definition at line 187 of file tuplestore.c.
Referenced by copytup_heap(), grow_memtuples(), readtup_heap(), tuplestore_begin_common(), tuplestore_puttupleslot(), and tuplestore_putvalues().
Definition at line 184 of file tuplestore.c.
Referenced by dumptuples(), and tuplestore_puttuple_common().
enum TupStoreStatus |
Enumerator | |
---|---|
TSS_INMEM | |
TSS_WRITEFILE | |
TSS_READFILE |
Definition at line 72 of file tuplestore.c.
|
static |
Definition at line 1494 of file tuplestore.c.
References GetMemoryChunkSpace(), minimal_tuple_from_heap_tuple(), and USEMEM.
Referenced by tuplestore_begin_heap().
|
static |
Definition at line 1206 of file tuplestore.c.
References BufFileTell(), TSReadPointer::current, TSReadPointer::eof_reached, TSReadPointer::file, i, Tuplestorestate::memtupcount, Tuplestorestate::memtupdeleted, Tuplestorestate::memtuples, Tuplestorestate::myfile, TSReadPointer::offset, Tuplestorestate::readptrcount, Tuplestorestate::readptrs, and WRITETUP.
Referenced by tuplestore_puttuple_common().
|
static |
Definition at line 1466 of file tuplestore.c.
References BufFileRead(), ereport, errcode_for_file_access(), errmsg(), ERROR, and Tuplestorestate::myfile.
Referenced by tuplestore_gettuple().
|
static |
Definition at line 578 of file tuplestore.c.
References Tuplestorestate::allowedMem, Tuplestorestate::availMem, elog, ERROR, FREEMEM, GetMemoryChunkSpace(), Tuplestorestate::growmemtuples, LACKMEM, MaxAllocHugeSize, Tuplestorestate::memtuples, Tuplestorestate::memtupsize, repalloc_huge(), and USEMEM.
Referenced by tuplestore_puttuple_common().
|
static |
Definition at line 1525 of file tuplestore.c.
References Tuplestorestate::backward, BufFileRead(), ereport, errcode_for_file_access(), errmsg(), ERROR, GetMemoryChunkSpace(), MINIMAL_TUPLE_DATA_OFFSET, Tuplestorestate::myfile, palloc(), MinimalTupleData::t_len, and USEMEM.
Referenced by tuplestore_begin_heap().
bool tuplestore_advance | ( | Tuplestorestate * | state, |
bool | forward | ||
) |
Definition at line 1110 of file tuplestore.c.
References pfree(), and tuplestore_gettuple().
Referenced by CteScanNext(), ExecMaterial(), and window_gettupleslot().
int tuplestore_alloc_read_pointer | ( | Tuplestorestate * | state, |
int | eflags | ||
) |
Definition at line 383 of file tuplestore.c.
References TSReadPointer::eflags, Tuplestorestate::eflags, elog, ERROR, Tuplestorestate::memtupcount, Tuplestorestate::readptrcount, Tuplestorestate::readptrs, Tuplestorestate::readptrsize, repalloc(), Tuplestorestate::status, and TSS_INMEM.
Referenced by begin_partition(), ExecInitCteScan(), ExecInitNamedTuplestoreScan(), and ExecMaterial().
bool tuplestore_ateof | ( | Tuplestorestate * | state | ) |
Definition at line 557 of file tuplestore.c.
References Tuplestorestate::activeptr, TSReadPointer::eof_reached, and Tuplestorestate::readptrs.
Referenced by CteScanNext(), and ExecMaterial().
|
static |
Definition at line 253 of file tuplestore.c.
References Tuplestorestate::activeptr, ALLOCSET_SEPARATE_THRESHOLD, Tuplestorestate::allowedMem, Tuplestorestate::availMem, Tuplestorestate::context, TSReadPointer::current, CurrentMemoryContext, CurrentResourceOwner, TSReadPointer::eflags, Tuplestorestate::eflags, TSReadPointer::eof_reached, GetMemoryChunkSpace(), Tuplestorestate::growmemtuples, Tuplestorestate::interXact, Max, Tuplestorestate::memtupcount, Tuplestorestate::memtupdeleted, Tuplestorestate::memtuples, Tuplestorestate::memtupsize, Tuplestorestate::myfile, palloc(), palloc0(), Tuplestorestate::readptrcount, Tuplestorestate::readptrs, Tuplestorestate::readptrsize, Tuplestorestate::resowner, Tuplestorestate::status, Tuplestorestate::truncated, TSS_INMEM, Tuplestorestate::tuples, and USEMEM.
Referenced by tuplestore_begin_heap().
Tuplestorestate* tuplestore_begin_heap | ( | bool | randomAccess, |
bool | interXact, | ||
int | maxKBytes | ||
) |
Definition at line 318 of file tuplestore.c.
References Tuplestorestate::copytup, copytup_heap(), Tuplestorestate::eflags, EXEC_FLAG_BACKWARD, EXEC_FLAG_REWIND, Tuplestorestate::readtup, readtup_heap(), tuplestore_begin_common(), Tuplestorestate::writetup, and writetup_heap().
Referenced by begin_partition(), brin_page_items(), connectby(), crosstab(), dblink_get_notify(), deflist_to_tuplestore(), each_worker(), each_worker_jsonb(), elements_worker(), elements_worker_jsonb(), exec_init_tuple_store(), ExecInitCteScan(), ExecInitRecursiveUnion(), ExecMakeTableFunctionResult(), ExecMaterial(), ExecRecursiveUnion(), fmgr_sql(), get_crosstab_tuplestore(), GetCurrentFDWTuplestore(), gist_page_items(), gist_page_items_bytea(), libpqrcv_processTuples(), MakeTransitionCaptureState(), materializeResult(), pg_available_extension_versions(), pg_available_extensions(), pg_config(), pg_cursor(), pg_event_trigger_ddl_commands(), pg_event_trigger_dropped_objects(), pg_extension_update_paths(), pg_get_backend_memory_contexts(), pg_get_replication_slots(), pg_get_shmem_allocations(), pg_hba_file_rules(), pg_logdir_ls_internal(), pg_logical_slot_get_changes_guts(), pg_ls_dir(), pg_ls_dir_files(), pg_prepared_statement(), pg_show_replication_origin_status(), pg_stat_get_activity(), pg_stat_get_prefetch_recovery(), pg_stat_get_progress_info(), pg_stat_get_replication_slots(), pg_stat_get_slru(), pg_stat_get_subscription(), pg_stat_get_wal_senders(), pg_stat_statements_internal(), pg_stop_backup_v2(), pg_tablespace_databases(), pg_timezone_names(), pgrowlocks(), plperl_return_next_internal(), pltcl_init_tuple_store(), populate_recordset_worker(), PortalCreateHoldStore(), postgres_fdw_get_connections(), show_all_file_settings(), storeRow(), text_to_table(), tfuncFetchRows(), verify_heapam(), and xpath_table().
void tuplestore_clear | ( | Tuplestorestate * | state | ) |
Definition at line 418 of file tuplestore.c.
References BufFileClose(), TSReadPointer::current, TSReadPointer::eof_reached, FREEMEM, GetMemoryChunkSpace(), i, Tuplestorestate::memtupcount, Tuplestorestate::memtupdeleted, Tuplestorestate::memtuples, Tuplestorestate::myfile, pfree(), Tuplestorestate::readptrcount, Tuplestorestate::readptrs, Tuplestorestate::status, Tuplestorestate::truncated, TSS_INMEM, and Tuplestorestate::tuples.
Referenced by ExecReScanCteScan(), ExecReScanRecursiveUnion(), and fmgr_sql().
void tuplestore_copy_read_pointer | ( | Tuplestorestate * | state, |
int | srcptr, | ||
int | destptr | ||
) |
Definition at line 1268 of file tuplestore.c.
References Tuplestorestate::activeptr, Assert, BufFileSeek(), BufFileTell(), TSReadPointer::eflags, Tuplestorestate::eflags, elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, TSReadPointer::file, i, Tuplestorestate::myfile, TSReadPointer::offset, Tuplestorestate::readptrcount, Tuplestorestate::readptrs, Tuplestorestate::status, TSS_INMEM, TSS_READFILE, TSS_WRITEFILE, Tuplestorestate::writepos_file, and Tuplestorestate::writepos_offset.
Referenced by ExecMaterialMarkPos(), and ExecMaterialRestrPos().
void tuplestore_end | ( | Tuplestorestate * | state | ) |
Definition at line 453 of file tuplestore.c.
References BufFileClose(), i, Tuplestorestate::memtupcount, Tuplestorestate::memtupdeleted, Tuplestorestate::memtuples, Tuplestorestate::myfile, pfree(), and Tuplestorestate::readptrs.
Referenced by AfterTriggerFreeQuery(), ExecEndCteScan(), ExecEndFunctionScan(), ExecEndMaterial(), ExecEndRecursiveUnion(), ExecEndTableFuncScan(), ExecMakeFunctionResultSet(), ExecRecursiveUnion(), ExecReScanFunctionScan(), ExecReScanMaterial(), ExecReScanTableFuncScan(), PortalDrop(), release_partition(), ShutdownSetExpr(), ShutdownSQLFunction(), storeRow(), and walrcv_clear_result().
|
static |
Definition at line 903 of file tuplestore.c.
References Tuplestorestate::activeptr, Assert, BufFileSeek(), BufFileTell(), TSReadPointer::current, TSReadPointer::eflags, elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, EXEC_FLAG_BACKWARD, TSReadPointer::file, getlen(), Tuplestorestate::memtupcount, Tuplestorestate::memtupdeleted, Tuplestorestate::memtuples, Tuplestorestate::myfile, TSReadPointer::offset, Tuplestorestate::readptrs, READTUP, Tuplestorestate::status, Tuplestorestate::truncated, TSS_INMEM, TSS_READFILE, TSS_WRITEFILE, Tuplestorestate::writepos_file, and Tuplestorestate::writepos_offset.
Referenced by tuplestore_advance(), tuplestore_gettupleslot(), and tuplestore_skiptuples().
bool tuplestore_gettupleslot | ( | Tuplestorestate * | state, |
bool | forward, | ||
bool | copy, | ||
TupleTableSlot * | slot | ||
) |
Definition at line 1078 of file tuplestore.c.
References ExecClearTuple(), ExecStoreMinimalTuple(), heap_copy_minimal_tuple(), and tuplestore_gettuple().
Referenced by AfterTriggerExecute(), CteScanNext(), ExecMakeFunctionResultSet(), ExecMaterial(), ExecWindowAgg(), fetch_remote_table_info(), fetch_table_list(), fmgr_sql(), FunctionNext(), NamedTuplestoreScanNext(), RunFromStore(), TableFuncNext(), update_frameheadpos(), update_frametailpos(), update_grouptailpos(), window_gettupleslot(), and WorkTableScanNext().
bool tuplestore_in_memory | ( | Tuplestorestate * | state | ) |
Definition at line 1455 of file tuplestore.c.
References Tuplestorestate::status, and TSS_INMEM.
Referenced by spool_tuples().
void tuplestore_puttuple | ( | Tuplestorestate * | state, |
HeapTuple | tuple | ||
) |
Definition at line 730 of file tuplestore.c.
References Tuplestorestate::context, COPYTUP, MemoryContextSwitchTo(), and tuplestore_puttuple_common().
Referenced by build_tuplestore_recursively(), crosstab(), each_object_field_end(), each_worker_jsonb(), elements_array_element_end(), elements_worker_jsonb(), exec_stmt_return_next(), ExecMakeTableFunctionResult(), fill_hba_line(), get_crosstab_tuplestore(), libpqrcv_processTuples(), materializeResult(), pg_config(), pg_logdir_ls_internal(), pgrowlocks(), plperl_return_next_internal(), pltcl_returnnext(), populate_recordset_record(), report_corruption_internal(), storeRow(), and xpath_table().
|
static |
Definition at line 765 of file tuplestore.c.
References Tuplestorestate::activeptr, Assert, Tuplestorestate::backward, BufFileCreateTemp(), BufFileSeek(), BufFileTell(), TSReadPointer::current, CurrentResourceOwner, dumptuples(), Tuplestorestate::eflags, elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, EXEC_FLAG_BACKWARD, TSReadPointer::file, grow_memtuples(), i, Tuplestorestate::interXact, LACKMEM, Tuplestorestate::memtupcount, Tuplestorestate::memtuples, Tuplestorestate::memtupsize, Tuplestorestate::myfile, TSReadPointer::offset, PrepareTempTablespaces(), Tuplestorestate::readptrcount, Tuplestorestate::readptrs, Tuplestorestate::resowner, Tuplestorestate::status, TSS_INMEM, TSS_READFILE, TSS_WRITEFILE, Tuplestorestate::tuples, Tuplestorestate::writepos_file, Tuplestorestate::writepos_offset, and WRITETUP.
Referenced by tuplestore_puttuple(), tuplestore_puttupleslot(), and tuplestore_putvalues().
void tuplestore_puttupleslot | ( | Tuplestorestate * | state, |
TupleTableSlot * | slot | ||
) |
Definition at line 708 of file tuplestore.c.
References Tuplestorestate::context, ExecCopySlotMinimalTuple(), GetMemoryChunkSpace(), MemoryContextSwitchTo(), tuplestore_puttuple_common(), and USEMEM.
Referenced by AfterTriggerSaveEvent(), begin_partition(), CteScanNext(), ExecMaterial(), ExecRecursiveUnion(), spool_tuples(), sqlfunction_receive(), tstoreReceiveSlot_notoast(), and tstoreReceiveSlot_tupmap().
void tuplestore_putvalues | ( | Tuplestorestate * | state, |
TupleDesc | tdesc, | ||
Datum * | values, | ||
bool * | isnull | ||
) |
Definition at line 750 of file tuplestore.c.
References Tuplestorestate::context, GetMemoryChunkSpace(), heap_form_minimal_tuple(), MemoryContextSwitchTo(), tuplestore_puttuple_common(), and USEMEM.
Referenced by brin_page_items(), dblink_get_notify(), deflist_to_tuplestore(), exec_stmt_return_next(), ExecMakeTableFunctionResult(), get_available_versions_for_extension(), gist_page_items(), gist_page_items_bytea(), LogicalOutputWrite(), pg_available_extensions(), pg_cursor(), pg_event_trigger_ddl_commands(), pg_event_trigger_dropped_objects(), pg_extension_update_paths(), pg_get_replication_slots(), pg_get_shmem_allocations(), pg_ls_dir(), pg_ls_dir_files(), pg_prepared_statement(), pg_show_replication_origin_status(), pg_stat_get_activity(), pg_stat_get_prefetch_recovery(), pg_stat_get_progress_info(), pg_stat_get_replication_slots(), pg_stat_get_slru(), pg_stat_get_subscription(), pg_stat_get_wal_senders(), pg_stat_statements_internal(), pg_stop_backup_v2(), pg_tablespace_databases(), pg_timezone_names(), plperl_return_next_internal(), pltcl_returnnext(), postgres_fdw_get_connections(), PutMemoryContextsStatsTupleStore(), show_all_file_settings(), split_text_accum_result(), tfuncLoadRows(), and tstoreReceiveSlot_detoast().
void tuplestore_rescan | ( | Tuplestorestate * | state | ) |
Definition at line 1233 of file tuplestore.c.
References Tuplestorestate::activeptr, Assert, BufFileSeek(), TSReadPointer::current, TSReadPointer::eflags, elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, EXEC_FLAG_REWIND, TSReadPointer::file, Tuplestorestate::myfile, TSReadPointer::offset, Tuplestorestate::readptrs, Tuplestorestate::status, Tuplestorestate::truncated, TSS_INMEM, TSS_READFILE, and TSS_WRITEFILE.
Referenced by DoPortalRewind(), ExecInitCteScan(), ExecInitNamedTuplestoreScan(), ExecReScanCteScan(), ExecReScanFunctionScan(), ExecReScanMaterial(), ExecReScanNamedTuplestoreScan(), ExecReScanTableFuncScan(), ExecReScanWorkTableScan(), FunctionNext(), and PersistHoldablePortal().
void tuplestore_select_read_pointer | ( | Tuplestorestate * | state, |
int | ptr | ||
) |
Definition at line 473 of file tuplestore.c.
References Tuplestorestate::activeptr, Assert, BufFileSeek(), BufFileTell(), elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, TSReadPointer::file, Tuplestorestate::myfile, TSReadPointer::offset, Tuplestorestate::readptrcount, Tuplestorestate::readptrs, Tuplestorestate::status, TSS_INMEM, TSS_READFILE, TSS_WRITEFILE, Tuplestorestate::writepos_file, and Tuplestorestate::writepos_offset.
Referenced by CteScanNext(), ExecInitCteScan(), ExecInitNamedTuplestoreScan(), ExecReScanCteScan(), ExecReScanNamedTuplestoreScan(), ExecWindowAgg(), NamedTuplestoreScanNext(), update_frameheadpos(), update_frametailpos(), update_grouptailpos(), window_gettupleslot(), and WinSetMarkPosition().
void tuplestore_set_eflags | ( | Tuplestorestate * | state, |
int | eflags | ||
) |
Definition at line 359 of file tuplestore.c.
References TSReadPointer::eflags, Tuplestorestate::eflags, elog, ERROR, i, Tuplestorestate::memtupcount, Tuplestorestate::readptrcount, Tuplestorestate::readptrs, Tuplestorestate::status, and TSS_INMEM.
Referenced by begin_partition(), ExecInitCteScan(), and ExecMaterial().
bool tuplestore_skiptuples | ( | Tuplestorestate * | state, |
int64 | ntuples, | ||
bool | forward | ||
) |
Definition at line 1135 of file tuplestore.c.
References Tuplestorestate::activeptr, Assert, CHECK_FOR_INTERRUPTS, TSReadPointer::current, TSReadPointer::eflags, TSReadPointer::eof_reached, EXEC_FLAG_BACKWARD, Tuplestorestate::memtupcount, Tuplestorestate::memtupdeleted, pfree(), Tuplestorestate::readptrs, Tuplestorestate::status, Tuplestorestate::truncated, TSS_INMEM, and tuplestore_gettuple().
Referenced by PersistHoldablePortal(), window_gettupleslot(), and WinSetMarkPosition().
void tuplestore_trim | ( | Tuplestorestate * | state | ) |
Definition at line 1360 of file tuplestore.c.
References Assert, TSReadPointer::current, Tuplestorestate::eflags, TSReadPointer::eof_reached, EXEC_FLAG_REWIND, FREEMEM, GetMemoryChunkSpace(), i, Tuplestorestate::memtupcount, Tuplestorestate::memtupdeleted, Tuplestorestate::memtuples, Min, pfree(), Tuplestorestate::readptrcount, Tuplestorestate::readptrs, Tuplestorestate::status, Tuplestorestate::truncated, and TSS_INMEM.
Referenced by ExecMaterialMarkPos(), and ExecWindowAgg().
int64 tuplestore_tuple_count | ( | Tuplestorestate * | state | ) |
Definition at line 546 of file tuplestore.c.
References Tuplestorestate::tuples.
Referenced by exec_stmt_return_query(), and SPI_register_trigger_data().
|
static |
Definition at line 1504 of file tuplestore.c.
References Tuplestorestate::backward, BufFileWrite(), FREEMEM, GetMemoryChunkSpace(), heap_free_minimal_tuple(), MINIMAL_TUPLE_DATA_OFFSET, Tuplestorestate::myfile, and MinimalTupleData::t_len.
Referenced by tuplestore_begin_heap().