PostgreSQL Source Code git master
|
#include "postgres.h"
#include "access/genam.h"
#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/multixact.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_opclass.h"
#include "commands/cluster.h"
#include "commands/matview.h"
#include "commands/tablecmds.h"
#include "commands/tablespace.h"
#include "executor/executor.h"
#include "executor/spi.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "rewrite/rewriteHandler.h"
#include "storage/lmgr.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | DR_transientrel |
Functions | |
static void | transientrel_startup (DestReceiver *self, int operation, TupleDesc typeinfo) |
static bool | transientrel_receive (TupleTableSlot *slot, DestReceiver *self) |
static void | transientrel_shutdown (DestReceiver *self) |
static void | transientrel_destroy (DestReceiver *self) |
static uint64 | refresh_matview_datafill (DestReceiver *dest, Query *query, const char *queryString, bool is_create) |
static char * | make_temptable_name_n (char *tempname, int n) |
static void | refresh_by_match_merge (Oid matviewOid, Oid tempOid, Oid relowner, int save_sec_context) |
static void | refresh_by_heap_swap (Oid matviewOid, Oid OIDNewHeap, char relpersistence) |
static bool | is_usable_unique_index (Relation indexRel) |
static void | OpenMatViewIncrementalMaintenance (void) |
static void | CloseMatViewIncrementalMaintenance (void) |
void | SetMatViewPopulatedState (Relation relation, bool newstate) |
ObjectAddress | ExecRefreshMatView (RefreshMatViewStmt *stmt, const char *queryString, QueryCompletion *qc) |
ObjectAddress | RefreshMatViewByOid (Oid matviewOid, bool is_create, bool skipData, bool concurrent, const char *queryString, QueryCompletion *qc) |
DestReceiver * | CreateTransientRelDestReceiver (Oid transientoid) |
bool | MatViewIncrementalMaintenanceIsEnabled (void) |
Variables | |
static int | matview_maintenance_depth = 0 |
|
static |
Definition at line 982 of file matview.c.
References Assert, and matview_maintenance_depth.
Referenced by refresh_by_match_merge().
DestReceiver * CreateTransientRelDestReceiver | ( | Oid | transientoid | ) |
Definition at line 465 of file matview.c.
References DestTransientRel, _DestReceiver::mydest, palloc0(), DR_transientrel::pub, _DestReceiver::rDestroy, _DestReceiver::receiveSlot, _DestReceiver::rShutdown, _DestReceiver::rStartup, DR_transientrel::transientoid, transientrel_destroy(), transientrel_receive(), transientrel_shutdown(), and transientrel_startup().
Referenced by CreateDestReceiver(), and RefreshMatViewByOid().
ObjectAddress ExecRefreshMatView | ( | RefreshMatViewStmt * | stmt, |
const char * | queryString, | ||
QueryCompletion * | qc | ||
) |
Definition at line 121 of file matview.c.
References AccessExclusiveLock, ExclusiveLock, RangeVarCallbackMaintainsTable(), RangeVarGetRelidExtended(), RefreshMatViewByOid(), and stmt.
Referenced by ProcessUtilitySlow().
|
static |
Definition at line 916 of file matview.c.
References attnum, i, NIL, RelationData::rd_index, RelationData::rd_rel, and RelationGetIndexPredicate().
Referenced by refresh_by_match_merge(), and RefreshMatViewByOid().
|
static |
Definition at line 571 of file matview.c.
References appendStringInfo(), appendStringInfoString(), StringInfoData::data, and initStringInfo().
Referenced by refresh_by_match_merge().
bool MatViewIncrementalMaintenanceIsEnabled | ( | void | ) |
Definition at line 970 of file matview.c.
References matview_maintenance_depth.
Referenced by CheckValidResultRel().
|
static |
Definition at line 976 of file matview.c.
References matview_maintenance_depth.
Referenced by refresh_by_match_merge().
Definition at line 906 of file matview.c.
References finish_heap_swap(), ReadNextMultiXactId(), and RecentXmin.
Referenced by RefreshMatViewByOid().
|
static |
Definition at line 614 of file matview.c.
References appendStringInfo(), appendStringInfoString(), Assert, attnum, BTEqualStrategyNumber, CloseMatViewIncrementalMaintenance(), StringInfoData::data, DatumGetPointer(), elog, ereport, errcode(), errdetail(), errmsg(), ERROR, generate_operator_clause(), get_namespace_name(), get_opfamily_member(), GETSTRUCT(), HeapTupleIsValid, i, index_close(), index_open(), initStringInfo(), is_usable_unique_index(), lfirst_oid, list_free(), make_temptable_name_n(), NameStr, NoLock, ObjectIdGetDatum(), OidIsValid, OpenMatViewIncrementalMaintenance(), palloc0(), quote_qualified_identifier(), RelationData::rd_att, RelationData::rd_index, RelationData::rd_indextuple, RelationGetIndexList(), RelationGetNamespace, RelationGetNumberOfAttributes, RelationGetRelationName, ReleaseSysCache(), resetStringInfo(), RowExclusiveLock, SearchSysCache1(), SECURITY_LOCAL_USERID_CHANGE, SECURITY_RESTRICTED_OPERATION, SetUserIdAndSecContext(), SPI_connect(), SPI_exec(), SPI_execute(), SPI_finish(), SPI_getvalue(), SPI_OK_DELETE, SPI_OK_FINISH, SPI_OK_INSERT, SPI_OK_SELECT, SPI_OK_UTILITY, SPI_processed, SPI_tuptable, SysCacheGetAttrNotNull(), table_close(), table_open(), SPITupleTable::tupdesc, TupleDescAttr(), SPITupleTable::vals, and oidvector::values.
Referenced by RefreshMatViewByOid().
|
static |
Definition at line 405 of file matview.c.
References AcquireRewriteLocks(), CHECK_FOR_INTERRUPTS, copyObject, CreateQueryDesc(), CURSOR_OPT_PARALLEL_OK, generate_unaccent_rules::dest, elog, ERROR, EState::es_processed, QueryDesc::estate, ExecutorEnd(), ExecutorFinish(), ExecutorRun(), ExecutorStart(), ForwardScanDirection, FreeQueryDesc(), GetActiveSnapshot(), InvalidSnapshot, linitial, list_length(), pg_plan_query(), plan, PopActiveSnapshot(), PushCopiedSnapshot(), QueryRewrite(), and UpdateActiveSnapshotCommandId().
Referenced by RefreshMatViewByOid().
ObjectAddress RefreshMatViewByOid | ( | Oid | matviewOid, |
bool | is_create, | ||
bool | skipData, | ||
bool | concurrent, | ||
const char * | queryString, | ||
QueryCompletion * | qc | ||
) |
Definition at line 165 of file matview.c.
References AccessExclusiveLock, AccessShareLock, Assert, AtEOXact_GUC(), CheckRelationOidLockedByMe(), CheckTableNotInUse(), CMD_SELECT, CreateTransientRelDestReceiver(), generate_unaccent_rules::dest, elog, ereport, errcode(), errhint(), errmsg(), ERROR, ExclusiveLock, get_namespace_name(), GetDefaultTablespace(), GetUserIdAndSecContext(), index_close(), index_open(), is_usable_unique_index(), lfirst_oid, linitial_node, list_free(), list_length(), make_new_heap(), matview_maintenance_depth, NewGUCNestLevel(), NoLock, RuleLock::numLocks, ObjectAddressSet, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pgstat_count_heap_insert(), pgstat_count_truncate(), quote_qualified_identifier(), RelationData::rd_rel, RelationData::rd_rules, refresh_by_heap_swap(), refresh_by_match_merge(), refresh_matview_datafill(), RelationGetIndexList(), RelationGetNamespace, RelationGetRelationName, RelationIsPopulated, RestrictSearchPath(), RuleLock::rules, SECURITY_RESTRICTED_OPERATION, SetMatViewPopulatedState(), SetQueryCompletion(), SetUserIdAndSecContext(), table_close(), and table_open().
Referenced by ExecCreateTableAs(), and ExecRefreshMatView().
void SetMatViewPopulatedState | ( | Relation | relation, |
bool | newstate | ||
) |
Definition at line 79 of file matview.c.
References Assert, CatalogTupleUpdate(), CommandCounterIncrement(), elog, ERROR, GETSTRUCT(), heap_freetuple(), HeapTupleIsValid, newstate(), ObjectIdGetDatum(), RelationData::rd_rel, RelationGetRelid, RowExclusiveLock, SearchSysCacheCopy1, HeapTupleData::t_self, table_close(), and table_open().
Referenced by intorel_startup(), and RefreshMatViewByOid().
|
static |
Definition at line 554 of file matview.c.
References pfree().
Referenced by CreateTransientRelDestReceiver().
|
static |
Definition at line 509 of file matview.c.
References DR_transientrel::bistate, DR_transientrel::output_cid, table_tuple_insert(), DR_transientrel::ti_options, and DR_transientrel::transientrel.
Referenced by CreateTransientRelDestReceiver().
|
static |
Definition at line 537 of file matview.c.
References DR_transientrel::bistate, FreeBulkInsertState(), NoLock, table_close(), table_finish_bulk_insert(), DR_transientrel::ti_options, and DR_transientrel::transientrel.
Referenced by CreateTransientRelDestReceiver().
|
static |
Definition at line 483 of file matview.c.
References Assert, DR_transientrel::bistate, GetBulkInsertState(), GetCurrentCommandId(), InvalidBlockNumber, NoLock, DR_transientrel::output_cid, RelationGetTargetBlock, TABLE_INSERT_FROZEN, TABLE_INSERT_SKIP_FSM, table_open(), DR_transientrel::ti_options, DR_transientrel::transientoid, and DR_transientrel::transientrel.
Referenced by CreateTransientRelDestReceiver().
|
static |
Definition at line 56 of file matview.c.
Referenced by CloseMatViewIncrementalMaintenance(), MatViewIncrementalMaintenanceIsEnabled(), OpenMatViewIncrementalMaintenance(), and RefreshMatViewByOid().