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 185 of file tuplestore.c.
Definition at line 190 of file tuplestore.c.
Definition at line 188 of file tuplestore.c.
Definition at line 187 of file tuplestore.c.
Definition at line 189 of file tuplestore.c.
Definition at line 186 of file tuplestore.c.
enum TupStoreStatus |
|
static |
Definition at line 1589 of file tuplestore.c.
References GetMemoryChunkSpace(), minimal_tuple_from_heap_tuple(), and USEMEM.
Referenced by tuplestore_begin_heap().
|
static |
Definition at line 1258 of file tuplestore.c.
References BufFileTell(), TSReadPointer::current, TSReadPointer::eof_reached, TSReadPointer::file, i, j, TSReadPointer::offset, and WRITETUP.
Referenced by tuplestore_puttuple_common().
|
static |
Definition at line 1565 of file tuplestore.c.
References BufFileReadMaybeEOF(), and len.
Referenced by tuplestore_gettuple().
|
static |
Definition at line 612 of file tuplestore.c.
References elog, ERROR, FREEMEM, GetMemoryChunkSpace(), LACKMEM, MaxAllocHugeSize, repalloc_huge(), and USEMEM.
Referenced by tuplestore_puttuple_common().
|
static |
Definition at line 1620 of file tuplestore.c.
References BufFileReadExact(), len, MINIMAL_TUPLE_DATA_OFFSET, palloc(), and MinimalTupleData::t_len.
Referenced by tuplestore_begin_heap().
bool tuplestore_advance | ( | Tuplestorestate * | state, |
bool | forward | ||
) |
Definition at line 1162 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 395 of file tuplestore.c.
References elog, ERROR, repalloc(), and TSS_INMEM.
Referenced by ExecInitCteScan(), ExecInitNamedTuplestoreScan(), ExecMaterial(), and prepare_tuplestore().
bool tuplestore_ateof | ( | Tuplestorestate * | state | ) |
Definition at line 591 of file tuplestore.c.
Referenced by CteScanNext(), and ExecMaterial().
|
static |
Definition at line 256 of file tuplestore.c.
References ALLOCSET_DEFAULT_SIZES, ALLOCSET_SEPARATE_THRESHOLD, CurrentMemoryContext, CurrentResourceOwner, GenerationContextCreate(), GetMemoryChunkSpace(), Max, palloc(), palloc0(), TSS_INMEM, and USEMEM.
Referenced by tuplestore_begin_heap().
Tuplestorestate* tuplestore_begin_heap | ( | bool | randomAccess, |
bool | interXact, | ||
int | maxKBytes | ||
) |
Definition at line 330 of file tuplestore.c.
References copytup_heap(), EXEC_FLAG_BACKWARD, EXEC_FLAG_REWIND, readtup_heap(), tuplestore_begin_common(), and writetup_heap().
Referenced by connectby(), crosstab(), exec_init_tuple_store(), ExecInitCteScan(), ExecInitRecursiveUnion(), ExecMakeTableFunctionResult(), ExecMaterial(), fmgr_sql(), get_crosstab_tuplestore(), GetCurrentFDWTuplestore(), InitMaterializedSRF(), libpqrcv_processTuples(), MakeTransitionCaptureState(), materializeResult(), plperl_return_next_internal(), pltcl_init_tuple_store(), populate_recordset_worker(), PortalCreateHoldStore(), prepare_tuplestore(), storeRow(), and tfuncFetchRows().
void tuplestore_clear | ( | Tuplestorestate * | state | ) |
Definition at line 430 of file tuplestore.c.
References Assert, BufFileClose(), TSReadPointer::current, TSReadPointer::eof_reached, GetMemoryChunkSpace(), i, MemoryContextReset(), TSS_INMEM, tuplestore_updatemax(), and USEMEM.
Referenced by ExecRecursiveUnion(), ExecReScanCteScan(), ExecReScanRecursiveUnion(), fmgr_sql(), and release_partition().
void tuplestore_copy_read_pointer | ( | Tuplestorestate * | state, |
int | srcptr, | ||
int | destptr | ||
) |
Definition at line 1320 of file tuplestore.c.
References Assert, BufFileSeek(), BufFileTell(), TSReadPointer::eflags, elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, TSReadPointer::file, i, TSReadPointer::offset, TSS_INMEM, TSS_READFILE, and TSS_WRITEFILE.
Referenced by ExecMaterialMarkPos(), and ExecMaterialRestrPos().
void tuplestore_end | ( | Tuplestorestate * | state | ) |
Definition at line 492 of file tuplestore.c.
References BufFileClose(), MemoryContextDelete(), and pfree().
Referenced by AfterTriggerFreeQuery(), ExecEndCteScan(), ExecEndFunctionScan(), ExecEndMaterial(), ExecEndRecursiveUnion(), ExecEndTableFuncScan(), ExecEndWindowAgg(), ExecMakeFunctionResultSet(), ExecReScanFunctionScan(), ExecReScanMaterial(), ExecReScanTableFuncScan(), PortalDrop(), ShutdownSetExpr(), ShutdownSQLFunction(), storeRow(), and walrcv_clear_result().
void tuplestore_get_stats | ( | Tuplestorestate * | state, |
char ** | max_storage_type, | ||
int64 * | max_space | ||
) |
Definition at line 1533 of file tuplestore.c.
References tuplestore_updatemax().
Referenced by show_storage_info().
|
static |
Definition at line 955 of file tuplestore.c.
References Assert, BufFileSeek(), BufFileTell(), TSReadPointer::current, TSReadPointer::eflags, elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, EXEC_FLAG_BACKWARD, TSReadPointer::file, getlen(), TSReadPointer::offset, READTUP, TSS_INMEM, TSS_READFILE, and TSS_WRITEFILE.
Referenced by tuplestore_advance(), tuplestore_gettupleslot(), and tuplestore_skiptuples().
bool tuplestore_gettupleslot | ( | Tuplestorestate * | state, |
bool | forward, | ||
bool | copy, | ||
TupleTableSlot * | slot | ||
) |
Definition at line 1130 of file tuplestore.c.
References ExecClearTuple(), ExecStoreMinimalTuple(), heap_copy_minimal_tuple(), and tuplestore_gettuple().
Referenced by AfterTriggerExecute(), check_publications(), check_publications_origin(), CteScanNext(), ExecMakeFunctionResultSet(), ExecMaterial(), ExecWindowAgg(), fetch_remote_table_info(), fetch_table_list(), fmgr_sql(), FunctionNext(), NamedTuplestoreScanNext(), RunFromStore(), synchronize_slots(), TableFuncNext(), update_frameheadpos(), update_frametailpos(), update_grouptailpos(), validate_remote_info(), window_gettupleslot(), and WorkTableScanNext().
bool tuplestore_in_memory | ( | Tuplestorestate * | state | ) |
void tuplestore_puttuple | ( | Tuplestorestate * | state, |
HeapTuple | tuple | ||
) |
Definition at line 764 of file tuplestore.c.
References COPYTUP, MemoryContextSwitchTo(), and tuplestore_puttuple_common().
Referenced by build_tuplestore_recursively(), crosstab(), each_object_field_end(), elements_array_element_end(), exec_stmt_return_next(), ExecMakeTableFunctionResult(), fill_hba_line(), fill_ident_line(), get_crosstab_tuplestore(), libpqrcv_processTuples(), materializeResult(), pg_available_wal_summaries(), pg_wal_summary_contents(), pgrowlocks(), plperl_return_next_internal(), pltcl_returnnext(), populate_recordset_record(), report_corruption_internal(), storeRow(), and xpath_table().
|
static |
Definition at line 799 of file tuplestore.c.
References Assert, BufFileCreateTemp(), BufFileSeek(), BufFileTell(), TSReadPointer::current, CurrentResourceOwner, dumptuples(), elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, EXEC_FLAG_BACKWARD, TSReadPointer::file, grow_memtuples(), i, LACKMEM, MemoryContextSwitchTo(), TSReadPointer::offset, PrepareTempTablespaces(), TSS_INMEM, TSS_READFILE, TSS_WRITEFILE, tuplestore_updatemax(), and WRITETUP.
Referenced by tuplestore_puttuple(), tuplestore_puttupleslot(), and tuplestore_putvalues().
void tuplestore_puttupleslot | ( | Tuplestorestate * | state, |
TupleTableSlot * | slot | ||
) |
Definition at line 742 of file tuplestore.c.
References ExecCopySlotMinimalTuple(), GetMemoryChunkSpace(), MemoryContextSwitchTo(), tuplestore_puttuple_common(), and USEMEM.
Referenced by AfterTriggerSaveEvent(), begin_partition(), CteScanNext(), ExecMaterial(), ExecRecursiveUnion(), spool_tuples(), sqlfunction_receive(), TransitionTableAddTuple(), tstoreReceiveSlot_notoast(), and tstoreReceiveSlot_tupmap().
void tuplestore_putvalues | ( | Tuplestorestate * | state, |
TupleDesc | tdesc, | ||
const Datum * | values, | ||
const bool * | isnull | ||
) |
Definition at line 784 of file tuplestore.c.
References GetMemoryChunkSpace(), heap_form_minimal_tuple(), MemoryContextSwitchTo(), tuplestore_puttuple_common(), USEMEM, and values.
Referenced by brin_page_items(), dblink_get_notify(), each_worker_jsonb(), elements_worker_jsonb(), exec_stmt_return_next(), ExecMakeTableFunctionResult(), get_altertable_subcmdinfo(), get_available_versions_for_extension(), GetWALBlockInfo(), GetWALRecordsInfo(), GetXLogSummaryStats(), gist_page_items(), gist_page_items_bytea(), LogicalOutputWrite(), pg_available_extensions(), pg_config(), 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_get_wait_events(), pg_ls_dir(), pg_ls_dir_files(), pg_prepared_statement(), pg_show_replication_origin_status(), pg_stat_get_activity(), pg_stat_get_io(), pg_stat_get_progress_info(), pg_stat_get_recovery_prefetch(), pg_stat_get_slru(), pg_stat_get_subscription(), pg_stat_get_wal_senders(), pg_stat_statements_internal(), pg_tablespace_databases(), plperl_return_next_internal(), pltcl_returnnext(), postgres_fdw_get_connections_internal(), PutMemoryContextsStatsTupleStore(), show_all_file_settings(), split_text_accum_result(), tfuncLoadRows(), and tstoreReceiveSlot_detoast().
void tuplestore_rescan | ( | Tuplestorestate * | state | ) |
Definition at line 1285 of file tuplestore.c.
References Assert, BufFileSeek(), TSReadPointer::current, TSReadPointer::eflags, elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, EXEC_FLAG_REWIND, TSReadPointer::file, TSReadPointer::offset, 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 507 of file tuplestore.c.
References Assert, BufFileSeek(), BufFileTell(), elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg(), ERROR, TSReadPointer::file, TSReadPointer::offset, TSS_INMEM, TSS_READFILE, and TSS_WRITEFILE.
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 371 of file tuplestore.c.
References elog, ERROR, i, and TSS_INMEM.
Referenced by ExecInitCteScan(), ExecMaterial(), and prepare_tuplestore().
bool tuplestore_skiptuples | ( | Tuplestorestate * | state, |
int64 | ntuples, | ||
bool | forward | ||
) |
Definition at line 1187 of file tuplestore.c.
References Assert, CHECK_FOR_INTERRUPTS, TSReadPointer::current, TSReadPointer::eflags, TSReadPointer::eof_reached, EXEC_FLAG_BACKWARD, pfree(), TSS_INMEM, and tuplestore_gettuple().
Referenced by PersistHoldablePortal(), window_gettupleslot(), and WinSetMarkPosition().
void tuplestore_trim | ( | Tuplestorestate * | state | ) |
Definition at line 1412 of file tuplestore.c.
References Assert, EXEC_FLAG_REWIND, FREEMEM, GetMemoryChunkSpace(), i, Min, pfree(), TSS_INMEM, and tuplestore_updatemax().
Referenced by ExecMaterialMarkPos(), and ExecWindowAgg().
int64 tuplestore_tuple_count | ( | Tuplestorestate * | state | ) |
Definition at line 580 of file tuplestore.c.
Referenced by exec_stmt_return_query(), fetch_remote_table_info(), and SPI_register_trigger_data().
|
static |
Definition at line 1508 of file tuplestore.c.
References BufFileSize(), Max, and TSS_INMEM.
Referenced by tuplestore_clear(), tuplestore_get_stats(), tuplestore_puttuple_common(), and tuplestore_trim().
|
static |
Definition at line 1599 of file tuplestore.c.
References BufFileWrite(), FREEMEM, GetMemoryChunkSpace(), heap_free_minimal_tuple(), MINIMAL_TUPLE_DATA_OFFSET, and MinimalTupleData::t_len.
Referenced by tuplestore_begin_heap().