|
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"#include "utils/tuplestore.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 186 of file tuplestore.c.
Definition at line 191 of file tuplestore.c.
Definition at line 189 of file tuplestore.c.
Definition at line 188 of file tuplestore.c.
Definition at line 190 of file tuplestore.c.
Definition at line 187 of file tuplestore.c.
| Enumerator | |
|---|---|
| TSS_INMEM | |
| TSS_WRITEFILE | |
| TSS_READFILE | |
Definition at line 73 of file tuplestore.c.
|
static |
Definition at line 1622 of file tuplestore.c.
References fb(), GetMemoryChunkSpace(), minimal_tuple_from_heap_tuple(), and USEMEM.
Referenced by tuplestore_begin_heap().
|
static |
Definition at line 1291 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 1598 of file tuplestore.c.
References BufFileReadMaybeEOF(), fb(), and len.
Referenced by tuplestore_gettuple().
|
static |
Definition at line 613 of file tuplestore.c.
References elog, ERROR, fb(), FREEMEM, GetMemoryChunkSpace(), LACKMEM, MaxAllocHugeSize, repalloc_huge(), and USEMEM.
Referenced by tuplestore_puttuple_common().
|
static |
Definition at line 1653 of file tuplestore.c.
References BufFileReadExact(), fb(), 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 1195 of file tuplestore.c.
References fb(), pfree(), and tuplestore_gettuple().
Referenced by CteScanNext(), ExecMaterial(), and window_gettupleslot().
| int tuplestore_alloc_read_pointer | ( | Tuplestorestate * | state, |
| int | eflags | ||
| ) |
Definition at line 396 of file tuplestore.c.
References elog, ERROR, fb(), repalloc(), and TSS_INMEM.
Referenced by ExecInitCteScan(), ExecInitNamedTuplestoreScan(), ExecMaterial(), and prepare_tuplestore().
| bool tuplestore_ateof | ( | Tuplestorestate * | state | ) |
Definition at line 592 of file tuplestore.c.
Referenced by CteScanNext(), and ExecMaterial().
|
static |
Definition at line 257 of file tuplestore.c.
References ALLOCSET_DEFAULT_SIZES, ALLOCSET_SEPARATE_THRESHOLD, CurrentMemoryContext, CurrentResourceOwner, fb(), GenerationContextCreate(), GetMemoryChunkSpace(), Max, palloc(), palloc0_object, TSS_INMEM, and USEMEM.
Referenced by tuplestore_begin_heap().
| Tuplestorestate * tuplestore_begin_heap | ( | bool | randomAccess, |
| bool | interXact, | ||
| int | maxKBytes | ||
| ) |
Definition at line 331 of file tuplestore.c.
References copytup_heap(), EXEC_FLAG_BACKWARD, EXEC_FLAG_REWIND, fb(), readtup_heap(), tuplestore_begin_common(), and writetup_heap().
Referenced by connectby(), crosstab(), exec_init_tuple_store(), ExecHashBuildNullTupleStore(), ExecInitCteScan(), ExecInitRecursiveUnion(), ExecMakeTableFunctionResult(), ExecMaterial(), get_crosstab_tuplestore(), GetCurrentFDWTuplestore(), InitMaterializedSRF(), libpqrcv_processTuples(), MakeTransitionCaptureState(), materializeQueryResult(), materializeResult(), plperl_return_next_internal(), pltcl_init_tuple_store(), populate_recordset_worker(), PortalCreateHoldStore(), postquel_start(), prepare_tuplestore(), storeRow(), and tfuncFetchRows().
| void tuplestore_clear | ( | Tuplestorestate * | state | ) |
Definition at line 431 of file tuplestore.c.
References Assert, BufFileClose(), TSReadPointer::current, TSReadPointer::eof_reached, fb(), GetMemoryChunkSpace(), i, MemoryContextReset(), TSS_INMEM, tuplestore_updatemax(), and USEMEM.
Referenced by ExecRecursiveUnion(), ExecReScanCteScan(), ExecReScanRecursiveUnion(), and release_partition().
| void tuplestore_copy_read_pointer | ( | Tuplestorestate * | state, |
| int | srcptr, | ||
| int | destptr | ||
| ) |
Definition at line 1353 of file tuplestore.c.
References Assert, BufFileSeek(), BufFileTell(), elog, ereport, errcode_for_file_access(), errmsg, ERROR, fb(), i, TSS_INMEM, TSS_READFILE, and TSS_WRITEFILE.
Referenced by ExecMaterialMarkPos(), and ExecMaterialRestrPos().
| void tuplestore_end | ( | Tuplestorestate * | state | ) |
Definition at line 493 of file tuplestore.c.
References BufFileClose(), MemoryContextDelete(), and pfree().
Referenced by AfterTriggerFreeQuery(), ExecEndCteScan(), ExecEndFunctionScan(), ExecEndHashJoin(), ExecEndMaterial(), ExecEndRecursiveUnion(), ExecEndTableFuncScan(), ExecEndWindowAgg(), ExecHashJoinImpl(), ExecHashJoinReInitializeDSM(), ExecMakeFunctionResultSet(), ExecReScanFunctionScan(), ExecReScanHashJoin(), 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 1566 of file tuplestore.c.
References fb(), and tuplestore_updatemax().
Referenced by show_ctescan_info(), show_material_info(), show_recursive_union_info(), show_table_func_scan_info(), and show_windowagg_info().
|
static |
Definition at line 956 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, fb(), TSReadPointer::file, getlen(), TSReadPointer::offset, pg_fallthrough, READTUP, TSS_INMEM, TSS_READFILE, and TSS_WRITEFILE.
Referenced by tuplestore_advance(), tuplestore_gettupleslot(), tuplestore_gettupleslot_force(), and tuplestore_skiptuples().
| bool tuplestore_gettupleslot | ( | Tuplestorestate * | state, |
| bool | forward, | ||
| bool | copy, | ||
| TupleTableSlot * | slot | ||
| ) |
Definition at line 1131 of file tuplestore.c.
References ExecClearTuple(), ExecStoreMinimalTuple(), fb(), heap_copy_minimal_tuple(), and tuplestore_gettuple().
Referenced by AfterTriggerExecute(), check_pub_dead_tuple_retention(), check_publications(), check_publications_origin_sequences(), check_publications_origin_tables(), copy_sequences(), CteScanNext(), ExecHashJoinImpl(), ExecMakeFunctionResultSet(), ExecMaterial(), ExecWindowAgg(), fetch_relation_list(), fetch_remote_slots(), fetch_remote_table_info(), FunctionNext(), NamedTuplestoreScanNext(), RunFromStore(), TableFuncNext(), update_frameheadpos(), update_frametailpos(), update_grouptailpos(), validate_remote_info(), window_gettupleslot(), and WorkTableScanNext().
| bool tuplestore_gettupleslot_force | ( | Tuplestorestate * | state, |
| bool | forward, | ||
| bool | copy, | ||
| TupleTableSlot * | slot | ||
| ) |
Definition at line 1163 of file tuplestore.c.
References ExecClearTuple(), ExecForceStoreMinimalTuple(), fb(), heap_copy_minimal_tuple(), and tuplestore_gettuple().
Referenced by ExecHashJoinImpl().
| bool tuplestore_in_memory | ( | Tuplestorestate * | state | ) |
| void tuplestore_puttuple | ( | Tuplestorestate * | state, |
| HeapTuple | tuple | ||
| ) |
Definition at line 765 of file tuplestore.c.
References COPYTUP, fb(), 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(), materializeQueryResult(), 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 800 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, fb(), 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 743 of file tuplestore.c.
References ExecCopySlotMinimalTuple(), fb(), GetMemoryChunkSpace(), MemoryContextSwitchTo(), tuplestore_puttuple_common(), and USEMEM.
Referenced by AfterTriggerSaveEvent(), begin_partition(), CteScanNext(), ExecHashJoinOuterGetTuple(), ExecMaterial(), ExecParallelHashJoinOuterGetTuple(), ExecParallelHashJoinPartitionOuter(), ExecRecursiveUnion(), MultiExecParallelHash(), MultiExecPrivateHash(), 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 785 of file tuplestore.c.
References fb(), 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(), injection_points_list(), LogicalOutputWrite(), pg_available_extensions(), pg_buffercache_usage_counts(), pg_config(), pg_cursor(), pg_event_trigger_ddl_commands(), pg_event_trigger_dropped_objects(), pg_extension_update_paths(), pg_get_aios(), pg_get_dsm_registry_allocations(), pg_get_loaded_modules(), pg_get_replication_slots(), pg_get_shmem_allocations(), pg_get_shmem_allocations_numa(), pg_get_wait_events(), pg_get_wal_resource_managers(), pg_ls_dir(), pg_ls_dir_files(), pg_options_to_table(), pg_prepared_statement(), pg_show_replication_origin_status(), pg_stat_get_activity(), 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_io_build_tuples(), pg_stat_statements_internal(), pg_tablespace_databases(), pg_timezone_names(), 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 1318 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, fb(), TSReadPointer::file, TSReadPointer::offset, TSS_INMEM, TSS_READFILE, and TSS_WRITEFILE.
Referenced by DoPortalRewind(), ExecInitCteScan(), ExecInitNamedTuplestoreScan(), ExecReScanCteScan(), ExecReScanFunctionScan(), ExecReScanHashJoin(), ExecReScanMaterial(), ExecReScanNamedTuplestoreScan(), ExecReScanTableFuncScan(), ExecReScanWorkTableScan(), FunctionNext(), and PersistHoldablePortal().
| void tuplestore_select_read_pointer | ( | Tuplestorestate * | state, |
| int | ptr | ||
| ) |
Definition at line 508 of file tuplestore.c.
References Assert, BufFileSeek(), BufFileTell(), elog, TSReadPointer::eof_reached, ereport, errcode_for_file_access(), errmsg, ERROR, fb(), 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 372 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 1220 of file tuplestore.c.
References Assert, CHECK_FOR_INTERRUPTS, TSReadPointer::current, TSReadPointer::eflags, TSReadPointer::eof_reached, EXEC_FLAG_BACKWARD, fb(), pfree(), TSS_INMEM, and tuplestore_gettuple().
Referenced by PersistHoldablePortal(), window_gettupleslot(), and WinSetMarkPosition().
| void tuplestore_trim | ( | Tuplestorestate * | state | ) |
Definition at line 1445 of file tuplestore.c.
References Assert, EXEC_FLAG_REWIND, fb(), FREEMEM, GetMemoryChunkSpace(), i, Min, pfree(), TSS_INMEM, and tuplestore_updatemax().
Referenced by ExecMaterialMarkPos(), and ExecWindowAgg().
| int64 tuplestore_tuple_count | ( | Tuplestorestate * | state | ) |
Definition at line 581 of file tuplestore.c.
Referenced by exec_stmt_return_query(), fetch_remote_table_info(), and SPI_register_trigger_data().
|
static |
Definition at line 1541 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 1632 of file tuplestore.c.
References BufFileWrite(), fb(), FREEMEM, GetMemoryChunkSpace(), heap_free_minimal_tuple(), MINIMAL_TUPLE_DATA_OFFSET, and MinimalTupleData::t_len.
Referenced by tuplestore_begin_heap().