PostgreSQL Source Code git master
|
#include "postgres.h"
#include "access/xact.h"
#include "commands/portalcmds.h"
#include "funcapi.h"
#include "miscadmin.h"
#include "storage/ipc.h"
#include "utils/builtins.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | portalhashent |
Macros | |
#define | PORTALS_PER_USER 16 |
#define | MAX_PORTALNAME_LEN NAMEDATALEN |
#define | PortalHashTableLookup(NAME, PORTAL) |
#define | PortalHashTableInsert(PORTAL, NAME) |
#define | PortalHashTableDelete(PORTAL) |
Typedefs | |
typedef struct portalhashent | PortalHashEnt |
Variables | |
static HTAB * | PortalHashTable = NULL |
static MemoryContext | TopPortalContext = NULL |
#define MAX_PORTALNAME_LEN NAMEDATALEN |
Definition at line 46 of file portalmem.c.
#define PortalHashTableDelete | ( | PORTAL | ) |
Definition at line 81 of file portalmem.c.
#define PortalHashTableInsert | ( | PORTAL, | |
NAME | |||
) |
Definition at line 68 of file portalmem.c.
#define PortalHashTableLookup | ( | NAME, | |
PORTAL | |||
) |
Definition at line 56 of file portalmem.c.
#define PORTALS_PER_USER 16 |
Definition at line 38 of file portalmem.c.
typedef struct portalhashent PortalHashEnt |
void AtAbort_Portals | ( | void | ) |
Definition at line 781 of file portalmem.c.
References PortalData::autoHeld, PortalData::cleanup, PortalData::createSubid, hash_seq_init(), hash_seq_search(), InvalidSubTransactionId, MarkPortalFailed(), MemoryContextDeleteChildren(), PointerIsValid, portalhashent::portal, PORTAL_ACTIVE, PORTAL_READY, PortalData::portalContext, PortalHashTable, PortalReleaseCachedPlan(), PortalData::resowner, shmem_exit_inprogress, and PortalData::status.
Referenced by AbortOutOfAnyTransaction(), and AbortTransaction().
void AtCleanup_Portals | ( | void | ) |
Definition at line 858 of file portalmem.c.
References Assert, PortalData::autoHeld, PortalData::cleanup, PortalData::createSubid, elog, hash_seq_init(), hash_seq_search(), InvalidSubTransactionId, PortalData::name, PointerIsValid, portalhashent::portal, PORTAL_ACTIVE, PortalDrop(), PortalHashTable, PortalData::portalPinned, PortalData::resowner, PortalData::status, and WARNING.
Referenced by CleanupTransaction().
void AtSubAbort_Portals | ( | SubTransactionId | mySubid, |
SubTransactionId | parentSubid, | ||
ResourceOwner | myXactOwner, | ||
ResourceOwner | parentXactOwner | ||
) |
Definition at line 979 of file portalmem.c.
References PortalData::activeSubid, PortalData::cleanup, PortalData::createSubid, hash_seq_init(), hash_seq_search(), MarkPortalFailed(), MemoryContextDeleteChildren(), PointerIsValid, portalhashent::portal, PORTAL_ACTIVE, PORTAL_FAILED, PORTAL_READY, PortalData::portalContext, PortalHashTable, PortalReleaseCachedPlan(), ResourceOwnerNewParent(), PortalData::resowner, and PortalData::status.
Referenced by AbortOutOfAnyTransaction(), and AbortSubTransaction().
void AtSubCleanup_Portals | ( | SubTransactionId | mySubid | ) |
Definition at line 1092 of file portalmem.c.
References PortalData::cleanup, PortalData::createSubid, elog, hash_seq_init(), hash_seq_search(), PortalData::name, PointerIsValid, portalhashent::portal, PortalDrop(), PortalHashTable, PortalData::portalPinned, and WARNING.
Referenced by CleanupSubTransaction().
void AtSubCommit_Portals | ( | SubTransactionId | mySubid, |
SubTransactionId | parentSubid, | ||
int | parentLevel, | ||
ResourceOwner | parentXactOwner | ||
) |
Definition at line 943 of file portalmem.c.
References PortalData::activeSubid, PortalData::createLevel, PortalData::createSubid, hash_seq_init(), hash_seq_search(), portalhashent::portal, PortalHashTable, ResourceOwnerNewParent(), and PortalData::resowner.
Referenced by CommitSubTransaction().
Portal CreateNewPortal | ( | void | ) |
Definition at line 235 of file portalmem.c.
References CreatePortal(), GetPortalByName(), MAX_PORTALNAME_LEN, and sprintf.
Referenced by ExecuteQuery(), and SPI_cursor_open_internal().
Portal CreatePortal | ( | const char * | name, |
bool | allowDup, | ||
bool | dupSilent | ||
) |
Definition at line 175 of file portalmem.c.
References PortalData::activeSubid, ALLOCSET_SMALL_SIZES, AllocSetContextCreate, Assert, PortalData::atEnd, PortalData::atStart, PortalData::cleanup, PortalData::createLevel, PortalData::createSubid, PortalData::creation_time, CURSOR_OPT_NO_SCROLL, PortalData::cursorOptions, CurTransactionResourceOwner, ereport, errcode(), errmsg(), ERROR, GetCurrentStatementStartTimestamp(), GetCurrentSubTransactionId(), GetCurrentTransactionNestLevel(), GetPortalByName(), MemoryContextAllocZero(), MemoryContextSetIdentifier(), name, PortalData::name, PointerIsValid, PORTAL_MULTI_QUERY, PORTAL_NEW, PortalCleanup(), PortalData::portalContext, PortalDrop(), PortalHashTableInsert, PortalIsValid, ResourceOwnerCreate(), PortalData::resowner, PortalData::status, PortalData::strategy, TopPortalContext, PortalData::visible, and WARNING.
Referenced by CreateNewPortal(), exec_bind_message(), exec_simple_query(), PerformCursorOpen(), and SPI_cursor_open_internal().
void EnablePortalManager | ( | void | ) |
Definition at line 104 of file portalmem.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, ctl, hash_create(), HASH_ELEM, HASH_STRINGS, MAX_PORTALNAME_LEN, PortalHashTable, PORTALS_PER_USER, TopMemoryContext, and TopPortalContext.
Referenced by InitPostgres().
void ForgetPortalSnapshots | ( | void | ) |
Definition at line 1256 of file portalmem.c.
References ActiveSnapshotSet(), elog, ERROR, hash_seq_init(), hash_seq_search(), PopActiveSnapshot(), portalhashent::portal, PortalHashTable, and PortalData::portalSnapshot.
Referenced by _SPI_commit(), and _SPI_rollback().
Portal GetPortalByName | ( | const char * | name | ) |
Definition at line 130 of file portalmem.c.
References name, PointerIsValid, and PortalHashTableLookup.
Referenced by CreateNewPortal(), CreatePortal(), exec_describe_portal_message(), exec_execute_message(), exec_simple_query(), execCurrentOf(), FetchStatementTargetList(), PerformPortalClose(), PerformPortalFetch(), PLy_cursor_close(), PLy_cursor_dealloc(), PLy_cursor_fetch(), PLy_cursor_iternext(), PostgresMain(), SPI_cursor_find(), UtilityReturnsTuples(), and UtilityTupleDescriptor().
void HoldPinnedPortals | ( | void | ) |
Definition at line 1207 of file portalmem.c.
References PortalData::autoHeld, elog, ereport, errcode(), errmsg(), ERROR, hash_seq_init(), hash_seq_search(), HoldPortal(), portalhashent::portal, PORTAL_ONE_SELECT, PORTAL_READY, PortalHashTable, PortalData::portalPinned, PortalData::status, and PortalData::strategy.
Referenced by _SPI_commit(), and _SPI_rollback().
|
static |
Definition at line 636 of file portalmem.c.
References PortalData::activeSubid, PortalData::createLevel, PortalData::createSubid, InvalidSubTransactionId, PersistHoldablePortal(), PortalCreateHoldStore(), PortalReleaseCachedPlan(), and PortalData::resowner.
Referenced by HoldPinnedPortals(), and PreCommit_Portals().
void MarkPortalActive | ( | Portal | portal | ) |
Definition at line 395 of file portalmem.c.
References PortalData::activeSubid, ereport, errcode(), errmsg(), ERROR, GetCurrentSubTransactionId(), PortalData::name, PORTAL_ACTIVE, PORTAL_READY, and PortalData::status.
Referenced by PersistHoldablePortal(), PortalRun(), and PortalRunFetch().
void MarkPortalDone | ( | Portal | portal | ) |
Definition at line 414 of file portalmem.c.
References Assert, PortalData::cleanup, PointerIsValid, PORTAL_ACTIVE, PORTAL_DONE, and PortalData::status.
Referenced by PortalRun().
void MarkPortalFailed | ( | Portal | portal | ) |
Definition at line 442 of file portalmem.c.
References Assert, PortalData::cleanup, PointerIsValid, PORTAL_DONE, PORTAL_FAILED, and PortalData::status.
Referenced by AtAbort_Portals(), AtSubAbort_Portals(), PersistHoldablePortal(), PortalRun(), PortalRunFetch(), and PortalStart().
Datum pg_cursor | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1131 of file portalmem.c.
References BoolGetDatum(), PortalData::creation_time, CStringGetTextDatum, CURSOR_OPT_BINARY, CURSOR_OPT_HOLD, CURSOR_OPT_SCROLL, PortalData::cursorOptions, hash_seq_init(), hash_seq_search(), InitMaterializedSRF(), PortalData::name, PortalHashTable, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, PortalData::sourceText, TimestampTzGetDatum(), tuplestore_putvalues(), values, and PortalData::visible.
void PinPortal | ( | Portal | portal | ) |
Definition at line 371 of file portalmem.c.
References elog, ERROR, and PortalData::portalPinned.
Referenced by exec_for_query(), plperl_spi_query(), plperl_spi_query_prepared(), PLy_cursor_plan(), and PLy_cursor_query().
void PortalCreateHoldStore | ( | Portal | portal | ) |
Definition at line 331 of file portalmem.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, CURSOR_OPT_SCROLL, PortalData::cursorOptions, PortalData::holdContext, PortalData::holdSnapshot, PortalData::holdStore, MemoryContextSwitchTo(), TopPortalContext, tuplestore_begin_heap(), and work_mem.
Referenced by FillPortalStore(), and HoldPortal().
void PortalDefineQuery | ( | Portal | portal, |
const char * | prepStmtName, | ||
const char * | sourceText, | ||
CommandTag | commandTag, | ||
List * | stmts, | ||
CachedPlan * | cplan | ||
) |
Definition at line 282 of file portalmem.c.
References Assert, QueryCompletion::commandTag, PortalData::commandTag, PortalData::cplan, NIL, QueryCompletion::nprocessed, PORTAL_DEFINED, PORTAL_NEW, PortalIsValid, PortalData::prepStmtName, PortalData::qc, PortalData::sourceText, PortalData::status, and PortalData::stmts.
Referenced by exec_bind_message(), exec_simple_query(), ExecuteQuery(), PerformCursorOpen(), and SPI_cursor_open_internal().
void PortalDrop | ( | Portal | portal, |
bool | isTopCommit | ||
) |
Definition at line 468 of file portalmem.c.
References Assert, PortalData::cleanup, ereport, errcode(), errmsg(), ERROR, PortalData::holdContext, PortalData::holdSnapshot, PortalData::holdStore, MemoryContextDelete(), MemoryContextSwitchTo(), PortalData::name, pfree(), PointerIsValid, PORTAL_ACTIVE, PORTAL_FAILED, PortalData::portalContext, PortalHashTableDelete, PortalIsValid, PortalData::portalPinned, PortalReleaseCachedPlan(), PortalData::portalSnapshot, RESOURCE_RELEASE_AFTER_LOCKS, RESOURCE_RELEASE_BEFORE_LOCKS, RESOURCE_RELEASE_LOCKS, ResourceOwnerDelete(), ResourceOwnerRelease(), PortalData::resowner, PortalData::status, tuplestore_end(), and UnregisterSnapshotFromOwner().
Referenced by AtCleanup_Portals(), AtSubCleanup_Portals(), CreatePortal(), exec_simple_query(), ExecuteQuery(), PerformPortalClose(), PortalErrorCleanup(), PortalHashTableDeleteAll(), PostgresMain(), PreCommit_Portals(), and SPI_cursor_close().
void PortalErrorCleanup | ( | void | ) |
Definition at line 917 of file portalmem.c.
References PortalData::autoHeld, hash_seq_init(), hash_seq_search(), portalhashent::portal, PortalDrop(), PortalHashTable, and PortalData::portalPinned.
Referenced by PostgresMain().
PlannedStmt * PortalGetPrimaryStmt | ( | Portal | portal | ) |
Definition at line 151 of file portalmem.c.
References lfirst_node, stmt, and PortalData::stmts.
Referenced by FetchPortalTargetList(), and PortalStart().
void PortalHashTableDeleteAll | ( | void | ) |
Definition at line 607 of file portalmem.c.
References hash_seq_init(), hash_seq_search(), hash_seq_term(), portalhashent::portal, PORTAL_ACTIVE, PortalDrop(), PortalHashTable, and PortalData::status.
Referenced by DiscardAll(), and PerformPortalClose().
|
static |
Definition at line 310 of file portalmem.c.
References PortalData::cplan, NIL, ReleaseCachedPlan(), and PortalData::stmts.
Referenced by AtAbort_Portals(), AtSubAbort_Portals(), HoldPortal(), and PortalDrop().
bool PreCommit_Portals | ( | bool | isPrepare | ) |
Definition at line 677 of file portalmem.c.
References PortalData::autoHeld, PortalData::createSubid, CURSOR_OPT_HOLD, PortalData::cursorOptions, elog, ereport, errcode(), errmsg(), ERROR, hash_seq_init(), hash_seq_search(), hash_seq_term(), HoldPortal(), PortalData::holdSnapshot, InvalidSubTransactionId, portalhashent::portal, PORTAL_ACTIVE, PORTAL_READY, PortalDrop(), PortalHashTable, PortalData::portalPinned, PortalData::portalSnapshot, PortalData::resowner, PortalData::status, and UnregisterSnapshotFromOwner().
Referenced by CommitTransaction(), and PrepareTransaction().
bool ThereAreNoReadyPortals | ( | void | ) |
Definition at line 1171 of file portalmem.c.
References hash_seq_init(), hash_seq_search(), portalhashent::portal, PORTAL_READY, PortalHashTable, and PortalData::status.
Referenced by CopyFrom().
void UnpinPortal | ( | Portal | portal | ) |
Definition at line 380 of file portalmem.c.
References elog, ERROR, and PortalData::portalPinned.
Referenced by exec_for_query(), plperl_spi_cursor_close(), plperl_spi_fetchrow(), PLy_cursor_close(), and PLy_cursor_dealloc().
|
static |
Definition at line 54 of file portalmem.c.
Referenced by AtAbort_Portals(), AtCleanup_Portals(), AtSubAbort_Portals(), AtSubCleanup_Portals(), AtSubCommit_Portals(), EnablePortalManager(), ForgetPortalSnapshots(), HoldPinnedPortals(), pg_cursor(), PortalErrorCleanup(), PortalHashTableDeleteAll(), PreCommit_Portals(), and ThereAreNoReadyPortals().
|
static |
Definition at line 91 of file portalmem.c.
Referenced by CreatePortal(), EnablePortalManager(), and PortalCreateHoldStore().