PostgreSQL Source Code  git master
matview.c File Reference
#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 "access/xlog.h"
#include "catalog/catalog.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_operator.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 "parser/parse_relation.h"
#include "pgstat.h"
#include "rewrite/rewriteHandler.h"
#include "storage/lmgr.h"
#include "storage/smgr.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"
Include dependency graph for matview.c:

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)
 
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, ParamListInfo params, QueryCompletion *qc)
 
DestReceiverCreateTransientRelDestReceiver (Oid transientoid)
 
bool MatViewIncrementalMaintenanceIsEnabled (void)
 

Variables

static int matview_maintenance_depth = 0
 

Function Documentation

◆ CloseMatViewIncrementalMaintenance()

static void CloseMatViewIncrementalMaintenance ( void  )
static

Definition at line 940 of file matview.c.

941 {
944 }
Assert(fmt[strlen(fmt) - 1] !='\n')
static int matview_maintenance_depth
Definition: matview.c:61

References Assert(), and matview_maintenance_depth.

Referenced by refresh_by_match_merge().

◆ CreateTransientRelDestReceiver()

DestReceiver* CreateTransientRelDestReceiver ( Oid  transientoid)

Definition at line 443 of file matview.c.

444 {
446 
447  self->pub.receiveSlot = transientrel_receive;
448  self->pub.rStartup = transientrel_startup;
449  self->pub.rShutdown = transientrel_shutdown;
450  self->pub.rDestroy = transientrel_destroy;
451  self->pub.mydest = DestTransientRel;
452  self->transientoid = transientoid;
453 
454  return (DestReceiver *) self;
455 }
@ DestTransientRel
Definition: dest.h:99
static void transientrel_destroy(DestReceiver *self)
Definition: matview.c:532
static void transientrel_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
Definition: matview.c:461
static bool transientrel_receive(TupleTableSlot *slot, DestReceiver *self)
Definition: matview.c:487
static void transientrel_shutdown(DestReceiver *self)
Definition: matview.c:515
void * palloc0(Size size)
Definition: mcxt.c:1093

References DestTransientRel, palloc0(), transientrel_destroy(), transientrel_receive(), transientrel_shutdown(), and transientrel_startup().

Referenced by CreateDestReceiver(), and ExecRefreshMatView().

◆ ExecRefreshMatView()

ObjectAddress ExecRefreshMatView ( RefreshMatViewStmt stmt,
const char *  queryString,
ParamListInfo  params,
QueryCompletion qc 
)

Definition at line 138 of file matview.c.

140 {
141  Oid matviewOid;
142  Relation matviewRel;
143  RewriteRule *rule;
144  List *actions;
145  Query *dataQuery;
146  Oid tableSpace;
147  Oid relowner;
148  Oid OIDNewHeap;
150  uint64 processed = 0;
151  bool concurrent;
152  LOCKMODE lockmode;
153  char relpersistence;
154  Oid save_userid;
155  int save_sec_context;
156  int save_nestlevel;
157  ObjectAddress address;
158 
159  /* Determine strength of lock needed. */
160  concurrent = stmt->concurrent;
161  lockmode = concurrent ? ExclusiveLock : AccessExclusiveLock;
162 
163  /*
164  * Get a lock until end of transaction.
165  */
166  matviewOid = RangeVarGetRelidExtended(stmt->relation,
167  lockmode, 0,
169  matviewRel = table_open(matviewOid, NoLock);
170 
171  /* Make sure it is a materialized view. */
172  if (matviewRel->rd_rel->relkind != RELKIND_MATVIEW)
173  ereport(ERROR,
174  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
175  errmsg("\"%s\" is not a materialized view",
176  RelationGetRelationName(matviewRel))));
177 
178  /* Check that CONCURRENTLY is not specified if not populated. */
179  if (concurrent && !RelationIsPopulated(matviewRel))
180  ereport(ERROR,
181  (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
182  errmsg("CONCURRENTLY cannot be used when the materialized view is not populated")));
183 
184  /* Check that conflicting options have not been specified. */
185  if (concurrent && stmt->skipData)
186  ereport(ERROR,
187  (errcode(ERRCODE_SYNTAX_ERROR),
188  errmsg("%s and %s options cannot be used together",
189  "CONCURRENTLY", "WITH NO DATA")));
190 
191  /*
192  * Check that everything is correct for a refresh. Problems at this point
193  * are internal errors, so elog is sufficient.
194  */
195  if (matviewRel->rd_rel->relhasrules == false ||
196  matviewRel->rd_rules->numLocks < 1)
197  elog(ERROR,
198  "materialized view \"%s\" is missing rewrite information",
199  RelationGetRelationName(matviewRel));
200 
201  if (matviewRel->rd_rules->numLocks > 1)
202  elog(ERROR,
203  "materialized view \"%s\" has too many rules",
204  RelationGetRelationName(matviewRel));
205 
206  rule = matviewRel->rd_rules->rules[0];
207  if (rule->event != CMD_SELECT || !(rule->isInstead))
208  elog(ERROR,
209  "the rule for materialized view \"%s\" is not a SELECT INSTEAD OF rule",
210  RelationGetRelationName(matviewRel));
211 
212  actions = rule->actions;
213  if (list_length(actions) != 1)
214  elog(ERROR,
215  "the rule for materialized view \"%s\" is not a single action",
216  RelationGetRelationName(matviewRel));
217 
218  /*
219  * Check that there is a unique index with no WHERE clause on one or more
220  * columns of the materialized view if CONCURRENTLY is specified.
221  */
222  if (concurrent)
223  {
224  List *indexoidlist = RelationGetIndexList(matviewRel);
225  ListCell *indexoidscan;
226  bool hasUniqueIndex = false;
227 
228  foreach(indexoidscan, indexoidlist)
229  {
230  Oid indexoid = lfirst_oid(indexoidscan);
231  Relation indexRel;
232 
233  indexRel = index_open(indexoid, AccessShareLock);
234  hasUniqueIndex = is_usable_unique_index(indexRel);
235  index_close(indexRel, AccessShareLock);
236  if (hasUniqueIndex)
237  break;
238  }
239 
240  list_free(indexoidlist);
241 
242  if (!hasUniqueIndex)
243  ereport(ERROR,
244  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
245  errmsg("cannot refresh materialized view \"%s\" concurrently",
247  RelationGetRelationName(matviewRel))),
248  errhint("Create a unique index with no WHERE clause on one or more columns of the materialized view.")));
249  }
250 
251  /*
252  * The stored query was rewritten at the time of the MV definition, but
253  * has not been scribbled on by the planner.
254  */
255  dataQuery = linitial_node(Query, actions);
256 
257  /*
258  * Check for active uses of the relation in the current transaction, such
259  * as open scans.
260  *
261  * NB: We count on this to protect us against problems with refreshing the
262  * data using TABLE_INSERT_FROZEN.
263  */
264  CheckTableNotInUse(matviewRel, "REFRESH MATERIALIZED VIEW");
265 
266  /*
267  * Tentatively mark the matview as populated or not (this will roll back
268  * if we fail later).
269  */
270  SetMatViewPopulatedState(matviewRel, !stmt->skipData);
271 
272  relowner = matviewRel->rd_rel->relowner;
273 
274  /*
275  * Switch to the owner's userid, so that any functions are run as that
276  * user. Also arrange to make GUC variable changes local to this command.
277  * Don't lock it down too tight to create a temporary table just yet. We
278  * will switch modes when we are about to execute user code.
279  */
280  GetUserIdAndSecContext(&save_userid, &save_sec_context);
281  SetUserIdAndSecContext(relowner,
282  save_sec_context | SECURITY_LOCAL_USERID_CHANGE);
283  save_nestlevel = NewGUCNestLevel();
284 
285  /* Concurrent refresh builds new data in temp tablespace, and does diff. */
286  if (concurrent)
287  {
288  tableSpace = GetDefaultTablespace(RELPERSISTENCE_TEMP, false);
289  relpersistence = RELPERSISTENCE_TEMP;
290  }
291  else
292  {
293  tableSpace = matviewRel->rd_rel->reltablespace;
294  relpersistence = matviewRel->rd_rel->relpersistence;
295  }
296 
297  /*
298  * Create the transient table that will receive the regenerated data. Lock
299  * it against access by any other process until commit (by which time it
300  * will be gone).
301  */
302  OIDNewHeap = make_new_heap(matviewOid, tableSpace,
303  matviewRel->rd_rel->relam,
304  relpersistence, ExclusiveLock);
306  dest = CreateTransientRelDestReceiver(OIDNewHeap);
307 
308  /*
309  * Now lock down security-restricted operations.
310  */
311  SetUserIdAndSecContext(relowner,
312  save_sec_context | SECURITY_RESTRICTED_OPERATION);
313 
314  /* Generate the data, if wanted. */
315  if (!stmt->skipData)
316  processed = refresh_matview_datafill(dest, dataQuery, queryString);
317 
318  /* Make the matview match the newly generated data. */
319  if (concurrent)
320  {
321  int old_depth = matview_maintenance_depth;
322 
323  PG_TRY();
324  {
325  refresh_by_match_merge(matviewOid, OIDNewHeap, relowner,
326  save_sec_context);
327  }
328  PG_CATCH();
329  {
330  matview_maintenance_depth = old_depth;
331  PG_RE_THROW();
332  }
333  PG_END_TRY();
334  Assert(matview_maintenance_depth == old_depth);
335  }
336  else
337  {
338  refresh_by_heap_swap(matviewOid, OIDNewHeap, relpersistence);
339 
340  /*
341  * Inform stats collector about our activity: basically, we truncated
342  * the matview and inserted some new data. (The concurrent code path
343  * above doesn't need to worry about this because the inserts and
344  * deletes it issues get counted by lower-level code.)
345  */
346  pgstat_count_truncate(matviewRel);
347  if (!stmt->skipData)
348  pgstat_count_heap_insert(matviewRel, processed);
349  }
350 
351  table_close(matviewRel, NoLock);
352 
353  /* Roll back any GUC changes */
354  AtEOXact_GUC(false, save_nestlevel);
355 
356  /* Restore userid and security context */
357  SetUserIdAndSecContext(save_userid, save_sec_context);
358 
359  ObjectAddressSet(address, RelationRelationId, matviewOid);
360 
361  /*
362  * Save the rowcount so that pg_stat_statements can track the total number
363  * of rows processed by REFRESH MATERIALIZED VIEW command. Note that we
364  * still don't display the rowcount in the command completion tag output,
365  * i.e., the display_rowcount flag of CMDTAG_REFRESH_MATERIALIZED_VIEW
366  * command tag is left false in cmdtaglist.h. Otherwise, the change of
367  * completion tag output might break applications using it.
368  */
369  if (qc)
370  SetQueryCompletion(qc, CMDTAG_REFRESH_MATERIALIZED_VIEW, processed);
371 
372  return address;
373 }
Oid GetDefaultTablespace(char relpersistence, bool partitioned)
Definition: tablespace.c:1182
Oid make_new_heap(Oid OIDOldHeap, Oid NewTableSpace, Oid NewAccessMethod, char relpersistence, LOCKMODE lockmode)
Definition: cluster.c:631
static void SetQueryCompletion(QueryCompletion *qc, CommandTag commandTag, uint64 nprocessed)
Definition: cmdtag.h:36
int errhint(const char *fmt,...)
Definition: elog.c:1151
int errcode(int sqlerrcode)
Definition: elog.c:693
int errmsg(const char *fmt,...)
Definition: elog.c:904
#define PG_RE_THROW()
Definition: elog.h:340
#define PG_END_TRY()
Definition: elog.h:324
#define PG_TRY()
Definition: elog.h:299
#define ERROR
Definition: elog.h:33
#define elog(elevel,...)
Definition: elog.h:218
#define PG_CATCH()
Definition: elog.h:309
#define ereport(elevel,...)
Definition: elog.h:143
int NewGUCNestLevel(void)
Definition: guc.c:6259
void AtEOXact_GUC(bool isCommit, int nestLevel)
Definition: guc.c:6273
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:158
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:132
void list_free(List *list)
Definition: list.c:1505
void LockRelationOid(Oid relid, LOCKMODE lockmode)
Definition: lmgr.c:109
int LOCKMODE
Definition: lockdefs.h:26
#define NoLock
Definition: lockdefs.h:34
#define AccessExclusiveLock
Definition: lockdefs.h:43
#define AccessShareLock
Definition: lockdefs.h:36
#define ExclusiveLock
Definition: lockdefs.h:42
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3316
static uint64 refresh_matview_datafill(DestReceiver *dest, Query *query, const char *queryString)
Definition: matview.c:384
static void refresh_by_match_merge(Oid matviewOid, Oid tempOid, Oid relowner, int save_sec_context)
Definition: matview.c:592
DestReceiver * CreateTransientRelDestReceiver(Oid transientoid)
Definition: matview.c:443
static bool is_usable_unique_index(Relation indexRel)
Definition: matview.c:874
void SetMatViewPopulatedState(Relation relation, bool newstate)
Definition: matview.c:84
static void refresh_by_heap_swap(Oid matviewOid, Oid OIDNewHeap, char relpersistence)
Definition: matview.c:864
#define SECURITY_RESTRICTED_OPERATION
Definition: miscadmin.h:312
#define SECURITY_LOCAL_USERID_CHANGE
Definition: miscadmin.h:311
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
Definition: miscinit.c:600
void SetUserIdAndSecContext(Oid userid, int sec_context)
Definition: miscinit.c:607
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:237
@ CMD_SELECT
Definition: nodes.h:686
#define ObjectAddressSet(addr, class_id, object_id)
Definition: objectaddress.h:40
static int list_length(const List *l)
Definition: pg_list.h:149
#define linitial_node(type, l)
Definition: pg_list.h:177
#define lfirst_oid(lc)
Definition: pg_list.h:171
void pgstat_count_heap_insert(Relation rel, PgStat_Counter n)
Definition: pgstat.c:2358
void pgstat_count_truncate(Relation rel)
Definition: pgstat.c:2462
unsigned int Oid
Definition: postgres_ext.h:31
#define RelationGetRelationName(relation)
Definition: rel.h:512
#define RelationIsPopulated(relation)
Definition: rel.h:651
#define RelationGetNamespace(relation)
Definition: rel.h:519
List * RelationGetIndexList(Relation relation)
Definition: relcache.c:4649
char * quote_qualified_identifier(const char *qualifier, const char *ident)
Definition: ruleutils.c:11524
Definition: pg_list.h:51
RangeVar * relation
Definition: parsenodes.h:3426
RuleLock * rd_rules
Definition: rel.h:113
Form_pg_class rd_rel
Definition: rel.h:109
RewriteRule ** rules
Definition: prs2lock.h:43
int numLocks
Definition: prs2lock.h:42
Definition: localtime.c:73
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:167
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
void RangeVarCallbackOwnsTable(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
Definition: tablecmds.c:16872
void CheckTableNotInUse(Relation rel, const char *stmt)
Definition: tablecmds.c:3963

References AccessExclusiveLock, AccessShareLock, Assert(), AtEOXact_GUC(), CheckTableNotInUse(), CMD_SELECT, RefreshMatViewStmt::concurrent, 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(), LockRelationOid(), 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(), RangeVarCallbackOwnsTable(), RangeVarGetRelidExtended(), RelationData::rd_rel, RelationData::rd_rules, refresh_by_heap_swap(), refresh_by_match_merge(), refresh_matview_datafill(), RefreshMatViewStmt::relation, RelationGetIndexList(), RelationGetNamespace, RelationGetRelationName, RelationIsPopulated, RuleLock::rules, SECURITY_LOCAL_USERID_CHANGE, SECURITY_RESTRICTED_OPERATION, SetMatViewPopulatedState(), SetQueryCompletion(), SetUserIdAndSecContext(), RefreshMatViewStmt::skipData, table_close(), and table_open().

Referenced by ProcessUtilitySlow().

◆ is_usable_unique_index()

static bool is_usable_unique_index ( Relation  indexRel)
static

Definition at line 874 of file matview.c.

875 {
876  Form_pg_index indexStruct = indexRel->rd_index;
877 
878  /*
879  * Must be unique, valid, immediate, non-partial, and be defined over
880  * plain user columns (not expressions). We also require it to be a
881  * btree. Even if we had any other unique index kinds, we'd not know how
882  * to identify the corresponding equality operator, nor could we be sure
883  * that the planner could implement the required FULL JOIN with non-btree
884  * operators.
885  */
886  if (indexStruct->indisunique &&
887  indexStruct->indimmediate &&
888  indexRel->rd_rel->relam == BTREE_AM_OID &&
889  indexStruct->indisvalid &&
890  RelationGetIndexPredicate(indexRel) == NIL &&
891  indexStruct->indnatts > 0)
892  {
893  /*
894  * The point of groveling through the index columns individually is to
895  * reject both index expressions and system columns. Currently,
896  * matviews couldn't have OID columns so there's no way to create an
897  * index on a system column; but maybe someday that wouldn't be true,
898  * so let's be safe.
899  */
900  int numatts = indexStruct->indnatts;
901  int i;
902 
903  for (i = 0; i < numatts; i++)
904  {
905  int attnum = indexStruct->indkey.values[i];
906 
907  if (attnum <= 0)
908  return false;
909  }
910  return true;
911  }
912  return false;
913 }
int i
Definition: isn.c:73
int16 attnum
Definition: pg_attribute.h:83
FormData_pg_index * Form_pg_index
Definition: pg_index.h:69
#define NIL
Definition: pg_list.h:65
List * RelationGetIndexPredicate(Relation relation)
Definition: relcache.c:4996
Form_pg_index rd_index
Definition: rel.h:188

References attnum, i, NIL, RelationData::rd_index, RelationData::rd_rel, and RelationGetIndexPredicate().

Referenced by ExecRefreshMatView(), and refresh_by_match_merge().

◆ make_temptable_name_n()

static char * make_temptable_name_n ( char *  tempname,
int  n 
)
static

Definition at line 549 of file matview.c.

550 {
551  StringInfoData namebuf;
552 
553  initStringInfo(&namebuf);
554  appendStringInfoString(&namebuf, tempname);
555  appendStringInfo(&namebuf, "_%d", n);
556  return namebuf.data;
557 }
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59

References appendStringInfo(), appendStringInfoString(), StringInfoData::data, and initStringInfo().

Referenced by refresh_by_match_merge().

◆ MatViewIncrementalMaintenanceIsEnabled()

bool MatViewIncrementalMaintenanceIsEnabled ( void  )

Definition at line 928 of file matview.c.

929 {
930  return matview_maintenance_depth > 0;
931 }

References matview_maintenance_depth.

Referenced by CheckValidResultRel().

◆ OpenMatViewIncrementalMaintenance()

static void OpenMatViewIncrementalMaintenance ( void  )
static

Definition at line 934 of file matview.c.

935 {
937 }

References matview_maintenance_depth.

Referenced by refresh_by_match_merge().

◆ refresh_by_heap_swap()

static void refresh_by_heap_swap ( Oid  matviewOid,
Oid  OIDNewHeap,
char  relpersistence 
)
static

Definition at line 864 of file matview.c.

865 {
866  finish_heap_swap(matviewOid, OIDNewHeap, false, false, true, true,
867  RecentXmin, ReadNextMultiXactId(), relpersistence);
868 }
void finish_heap_swap(Oid OIDOldHeap, Oid OIDNewHeap, bool is_system_catalog, bool swap_toast_by_content, bool check_constraints, bool is_internal, TransactionId frozenXid, MultiXactId cutoffMulti, char newrelpersistence)
Definition: cluster.c:1362
MultiXactId ReadNextMultiXactId(void)
Definition: multixact.c:723
TransactionId RecentXmin
Definition: snapmgr.c:113

References finish_heap_swap(), ReadNextMultiXactId(), and RecentXmin.

Referenced by ExecRefreshMatView().

◆ refresh_by_match_merge()

static void refresh_by_match_merge ( Oid  matviewOid,
Oid  tempOid,
Oid  relowner,
int  save_sec_context 
)
static

Definition at line 592 of file matview.c.

594 {
595  StringInfoData querybuf;
596  Relation matviewRel;
597  Relation tempRel;
598  char *matviewname;
599  char *tempname;
600  char *diffname;
601  TupleDesc tupdesc;
602  bool foundUniqueIndex;
603  List *indexoidlist;
604  ListCell *indexoidscan;
605  int16 relnatts;
606  Oid *opUsedForQual;
607 
608  initStringInfo(&querybuf);
609  matviewRel = table_open(matviewOid, NoLock);
611  RelationGetRelationName(matviewRel));
612  tempRel = table_open(tempOid, NoLock);
614  RelationGetRelationName(tempRel));
615  diffname = make_temptable_name_n(tempname, 2);
616 
617  relnatts = RelationGetNumberOfAttributes(matviewRel);
618 
619  /* Open SPI context. */
620  if (SPI_connect() != SPI_OK_CONNECT)
621  elog(ERROR, "SPI_connect failed");
622 
623  /* Analyze the temp table with the new contents. */
624  appendStringInfo(&querybuf, "ANALYZE %s", tempname);
625  if (SPI_exec(querybuf.data, 0) != SPI_OK_UTILITY)
626  elog(ERROR, "SPI_exec failed: %s", querybuf.data);
627 
628  /*
629  * We need to ensure that there are not duplicate rows without NULLs in
630  * the new data set before we can count on the "diff" results. Check for
631  * that in a way that allows showing the first duplicated row found. Even
632  * after we pass this test, a unique index on the materialized view may
633  * find a duplicate key problem.
634  *
635  * Note: here and below, we use "tablename.*::tablerowtype" as a hack to
636  * keep ".*" from being expanded into multiple columns in a SELECT list.
637  * Compare ruleutils.c's get_variable().
638  */
639  resetStringInfo(&querybuf);
640  appendStringInfo(&querybuf,
641  "SELECT newdata.*::%s FROM %s newdata "
642  "WHERE newdata.* IS NOT NULL AND EXISTS "
643  "(SELECT 1 FROM %s newdata2 WHERE newdata2.* IS NOT NULL "
644  "AND newdata2.* OPERATOR(pg_catalog.*=) newdata.* "
645  "AND newdata2.ctid OPERATOR(pg_catalog.<>) "
646  "newdata.ctid)",
647  tempname, tempname, tempname);
648  if (SPI_execute(querybuf.data, false, 1) != SPI_OK_SELECT)
649  elog(ERROR, "SPI_exec failed: %s", querybuf.data);
650  if (SPI_processed > 0)
651  {
652  /*
653  * Note that this ereport() is returning data to the user. Generally,
654  * we would want to make sure that the user has been granted access to
655  * this data. However, REFRESH MAT VIEW is only able to be run by the
656  * owner of the mat view (or a superuser) and therefore there is no
657  * need to check for access to data in the mat view.
658  */
659  ereport(ERROR,
660  (errcode(ERRCODE_CARDINALITY_VIOLATION),
661  errmsg("new data for materialized view \"%s\" contains duplicate rows without any null columns",
662  RelationGetRelationName(matviewRel)),
663  errdetail("Row: %s",
665  }
666 
667  SetUserIdAndSecContext(relowner,
668  save_sec_context | SECURITY_LOCAL_USERID_CHANGE);
669 
670  /* Start building the query for creating the diff table. */
671  resetStringInfo(&querybuf);
672  appendStringInfo(&querybuf,
673  "CREATE TEMP TABLE %s AS "
674  "SELECT mv.ctid AS tid, newdata.*::%s AS newdata "
675  "FROM %s mv FULL JOIN %s newdata ON (",
676  diffname, tempname, matviewname, tempname);
677 
678  /*
679  * Get the list of index OIDs for the table from the relcache, and look up
680  * each one in the pg_index syscache. We will test for equality on all
681  * columns present in all unique indexes which only reference columns and
682  * include all rows.
683  */
684  tupdesc = matviewRel->rd_att;
685  opUsedForQual = (Oid *) palloc0(sizeof(Oid) * relnatts);
686  foundUniqueIndex = false;
687 
688  indexoidlist = RelationGetIndexList(matviewRel);
689 
690  foreach(indexoidscan, indexoidlist)
691  {
692  Oid indexoid = lfirst_oid(indexoidscan);
693  Relation indexRel;
694 
695  indexRel = index_open(indexoid, RowExclusiveLock);
696  if (is_usable_unique_index(indexRel))
697  {
698  Form_pg_index indexStruct = indexRel->rd_index;
699  int indnkeyatts = indexStruct->indnkeyatts;
700  oidvector *indclass;
701  Datum indclassDatum;
702  bool isnull;
703  int i;
704 
705  /* Must get indclass the hard way. */
706  indclassDatum = SysCacheGetAttr(INDEXRELID,
707  indexRel->rd_indextuple,
708  Anum_pg_index_indclass,
709  &isnull);
710  Assert(!isnull);
711  indclass = (oidvector *) DatumGetPointer(indclassDatum);
712 
713  /* Add quals for all columns from this index. */
714  for (i = 0; i < indnkeyatts; i++)
715  {
716  int attnum = indexStruct->indkey.values[i];
717  Oid opclass = indclass->values[i];
718  Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1);
719  Oid attrtype = attr->atttypid;
720  HeapTuple cla_ht;
721  Form_pg_opclass cla_tup;
722  Oid opfamily;
723  Oid opcintype;
724  Oid op;
725  const char *leftop;
726  const char *rightop;
727 
728  /*
729  * Identify the equality operator associated with this index
730  * column. First we need to look up the column's opclass.
731  */
732  cla_ht = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
733  if (!HeapTupleIsValid(cla_ht))
734  elog(ERROR, "cache lookup failed for opclass %u", opclass);
735  cla_tup = (Form_pg_opclass) GETSTRUCT(cla_ht);
736  Assert(cla_tup->opcmethod == BTREE_AM_OID);
737  opfamily = cla_tup->opcfamily;
738  opcintype = cla_tup->opcintype;
739  ReleaseSysCache(cla_ht);
740 
741  op = get_opfamily_member(opfamily, opcintype, opcintype,
743  if (!OidIsValid(op))
744  elog(ERROR, "missing operator %d(%u,%u) in opfamily %u",
745  BTEqualStrategyNumber, opcintype, opcintype, opfamily);
746 
747  /*
748  * If we find the same column with the same equality semantics
749  * in more than one index, we only need to emit the equality
750  * clause once.
751  *
752  * Since we only remember the last equality operator, this
753  * code could be fooled into emitting duplicate clauses given
754  * multiple indexes with several different opclasses ... but
755  * that's so unlikely it doesn't seem worth spending extra
756  * code to avoid.
757  */
758  if (opUsedForQual[attnum - 1] == op)
759  continue;
760  opUsedForQual[attnum - 1] = op;
761 
762  /*
763  * Actually add the qual, ANDed with any others.
764  */
765  if (foundUniqueIndex)
766  appendStringInfoString(&querybuf, " AND ");
767 
768  leftop = quote_qualified_identifier("newdata",
769  NameStr(attr->attname));
770  rightop = quote_qualified_identifier("mv",
771  NameStr(attr->attname));
772 
773  generate_operator_clause(&querybuf,
774  leftop, attrtype,
775  op,
776  rightop, attrtype);
777 
778  foundUniqueIndex = true;
779  }
780  }
781 
782  /* Keep the locks, since we're about to run DML which needs them. */
783  index_close(indexRel, NoLock);
784  }
785 
786  list_free(indexoidlist);
787 
788  /*
789  * There must be at least one usable unique index on the matview.
790  *
791  * ExecRefreshMatView() checks that after taking the exclusive lock on the
792  * matview. So at least one unique index is guaranteed to exist here
793  * because the lock is still being held; so an Assert seems sufficient.
794  */
795  Assert(foundUniqueIndex);
796 
797  appendStringInfoString(&querybuf,
798  " AND newdata.* OPERATOR(pg_catalog.*=) mv.*) "
799  "WHERE newdata.* IS NULL OR mv.* IS NULL "
800  "ORDER BY tid");
801 
802  /* Create the temporary "diff" table. */
803  if (SPI_exec(querybuf.data, 0) != SPI_OK_UTILITY)
804  elog(ERROR, "SPI_exec failed: %s", querybuf.data);
805 
806  SetUserIdAndSecContext(relowner,
807  save_sec_context | SECURITY_RESTRICTED_OPERATION);
808 
809  /*
810  * We have no further use for data from the "full-data" temp table, but we
811  * must keep it around because its type is referenced from the diff table.
812  */
813 
814  /* Analyze the diff table. */
815  resetStringInfo(&querybuf);
816  appendStringInfo(&querybuf, "ANALYZE %s", diffname);
817  if (SPI_exec(querybuf.data, 0) != SPI_OK_UTILITY)
818  elog(ERROR, "SPI_exec failed: %s", querybuf.data);
819 
821 
822  /* Deletes must come before inserts; do them first. */
823  resetStringInfo(&querybuf);
824  appendStringInfo(&querybuf,
825  "DELETE FROM %s mv WHERE ctid OPERATOR(pg_catalog.=) ANY "
826  "(SELECT diff.tid FROM %s diff "
827  "WHERE diff.tid IS NOT NULL "
828  "AND diff.newdata IS NULL)",
829  matviewname, diffname);
830  if (SPI_exec(querybuf.data, 0) != SPI_OK_DELETE)
831  elog(ERROR, "SPI_exec failed: %s", querybuf.data);
832 
833  /* Inserts go last. */
834  resetStringInfo(&querybuf);
835  appendStringInfo(&querybuf,
836  "INSERT INTO %s SELECT (diff.newdata).* "
837  "FROM %s diff WHERE tid IS NULL",
838  matviewname, diffname);
839  if (SPI_exec(querybuf.data, 0) != SPI_OK_INSERT)
840  elog(ERROR, "SPI_exec failed: %s", querybuf.data);
841 
842  /* We're done maintaining the materialized view. */
844  table_close(tempRel, NoLock);
845  table_close(matviewRel, NoLock);
846 
847  /* Clean up temp tables. */
848  resetStringInfo(&querybuf);
849  appendStringInfo(&querybuf, "DROP TABLE %s, %s", diffname, tempname);
850  if (SPI_exec(querybuf.data, 0) != SPI_OK_UTILITY)
851  elog(ERROR, "SPI_exec failed: %s", querybuf.data);
852 
853  /* Close SPI context. */
854  if (SPI_finish() != SPI_OK_FINISH)
855  elog(ERROR, "SPI_finish failed");
856 }
#define NameStr(name)
Definition: c.h:681
signed short int16
Definition: c.h:428
#define OidIsValid(objectId)
Definition: c.h:710
int errdetail(const char *fmt,...)
Definition: elog.c:1037
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define GETSTRUCT(TUP)
Definition: htup_details.h:649
#define RowExclusiveLock
Definition: lockdefs.h:38
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:164
static char * make_temptable_name_n(char *tempname, int n)
Definition: matview.c:549
static void CloseMatViewIncrementalMaintenance(void)
Definition: matview.c:940
static void OpenMatViewIncrementalMaintenance(void)
Definition: matview.c:934
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:207
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83
uintptr_t Datum
Definition: postgres.h:411
#define DatumGetPointer(X)
Definition: postgres.h:593
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define RelationGetNumberOfAttributes(relation)
Definition: rel.h:484
void generate_operator_clause(StringInfo buf, const char *leftop, Oid leftoptype, Oid opoid, const char *rightop, Oid rightoptype)
Definition: ruleutils.c:11848
uint64 SPI_processed
Definition: spi.c:45
SPITupleTable * SPI_tuptable
Definition: spi.c:46
int SPI_connect(void)
Definition: spi.c:95
int SPI_finish(void)
Definition: spi.c:182
int SPI_exec(const char *src, long tcount)
Definition: spi.c:535
char * SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
Definition: spi.c:1125
int SPI_execute(const char *src, bool read_only, long tcount)
Definition: spi.c:501
#define SPI_OK_UTILITY
Definition: spi.h:85
#define SPI_OK_INSERT
Definition: spi.h:88
#define SPI_OK_DELETE
Definition: spi.h:89
#define SPI_OK_CONNECT
Definition: spi.h:82
#define SPI_OK_FINISH
Definition: spi.h:83
#define SPI_OK_SELECT
Definition: spi.h:86
#define BTEqualStrategyNumber
Definition: stratnum.h:31
void resetStringInfo(StringInfo str)
Definition: stringinfo.c:75
struct HeapTupleData * rd_indextuple
Definition: rel.h:190
TupleDesc rd_att
Definition: rel.h:110
TupleDesc tupdesc
Definition: spi.h:25
HeapTuple * vals
Definition: spi.h:26
Definition: c.h:661
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:668
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1198
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1150
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1411
@ INDEXRELID
Definition: syscache.h:66
@ CLAOID
Definition: syscache.h:48
#define TupleDescAttr(tupdesc, i)
Definition: tupdesc.h:92

References appendStringInfo(), appendStringInfoString(), Assert(), attnum, BTEqualStrategyNumber, CLAOID, 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(), INDEXRELID, 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_CONNECT, SPI_OK_DELETE, SPI_OK_FINISH, SPI_OK_INSERT, SPI_OK_SELECT, SPI_OK_UTILITY, SPI_processed, SPI_tuptable, SysCacheGetAttr(), table_close(), table_open(), SPITupleTable::tupdesc, TupleDescAttr, SPITupleTable::vals, and oidvector::values.

Referenced by ExecRefreshMatView().

◆ refresh_matview_datafill()

static uint64 refresh_matview_datafill ( DestReceiver dest,
Query query,
const char *  queryString 
)
static

Definition at line 384 of file matview.c.

386 {
387  List *rewritten;
388  PlannedStmt *plan;
389  QueryDesc *queryDesc;
390  Query *copied_query;
391  uint64 processed;
392 
393  /* Lock and rewrite, using a copy to preserve the original query. */
394  copied_query = copyObject(query);
395  AcquireRewriteLocks(copied_query, true, false);
396  rewritten = QueryRewrite(copied_query);
397 
398  /* SELECT should never rewrite to more or less than one SELECT query */
399  if (list_length(rewritten) != 1)
400  elog(ERROR, "unexpected rewrite result for REFRESH MATERIALIZED VIEW");
401  query = (Query *) linitial(rewritten);
402 
403  /* Check for user-requested abort. */
405 
406  /* Plan the query which will generate data for the refresh. */
407  plan = pg_plan_query(query, queryString, CURSOR_OPT_PARALLEL_OK, NULL);
408 
409  /*
410  * Use a snapshot with an updated command ID to ensure this query sees
411  * results of any previously executed queries. (This could only matter if
412  * the planner executed an allegedly-stable function that changed the
413  * database contents, but let's do it anyway to be safe.)
414  */
417 
418  /* Create a QueryDesc, redirecting output to our tuple receiver */
419  queryDesc = CreateQueryDesc(plan, queryString,
421  dest, NULL, NULL, 0);
422 
423  /* call ExecutorStart to prepare the plan for execution */
424  ExecutorStart(queryDesc, 0);
425 
426  /* run the plan */
427  ExecutorRun(queryDesc, ForwardScanDirection, 0L, true);
428 
429  processed = queryDesc->estate->es_processed;
430 
431  /* and clean up */
432  ExecutorFinish(queryDesc);
433  ExecutorEnd(queryDesc);
434 
435  FreeQueryDesc(queryDesc);
436 
438 
439  return processed;
440 }
void ExecutorEnd(QueryDesc *queryDesc)
Definition: execMain.c:459
void ExecutorFinish(QueryDesc *queryDesc)
Definition: execMain.c:399
void ExecutorStart(QueryDesc *queryDesc, int eflags)
Definition: execMain.c:130
void ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count, bool execute_once)
Definition: execMain.c:298
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:120
#define copyObject(obj)
Definition: nodes.h:655
#define CURSOR_OPT_PARALLEL_OK
Definition: parsenodes.h:2830
#define linitial(l)
Definition: pg_list.h:174
PlannedStmt * pg_plan_query(Query *querytree, const char *query_string, int cursorOptions, ParamListInfo boundParams)
Definition: postgres.c:830
void FreeQueryDesc(QueryDesc *qdesc)
Definition: pquery.c:105
QueryDesc * CreateQueryDesc(PlannedStmt *plannedstmt, const char *sourceText, Snapshot snapshot, Snapshot crosscheck_snapshot, DestReceiver *dest, ParamListInfo params, QueryEnvironment *queryEnv, int instrument_options)
Definition: pquery.c:67
void AcquireRewriteLocks(Query *parsetree, bool forExecute, bool forUpdatePushedDown)
List * QueryRewrite(Query *parsetree)
@ ForwardScanDirection
Definition: sdir.h:26
void UpdateActiveSnapshotCommandId(void)
Definition: snapmgr.c:743
void PopActiveSnapshot(void)
Definition: snapmgr.c:774
void PushCopiedSnapshot(Snapshot snapshot)
Definition: snapmgr.c:731
Snapshot GetActiveSnapshot(void)
Definition: snapmgr.c:801
#define InvalidSnapshot
Definition: snapshot.h:123
uint64 es_processed
Definition: execnodes.h:609
EState * estate
Definition: execdesc.h:48

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(), PopActiveSnapshot(), PushCopiedSnapshot(), QueryRewrite(), and UpdateActiveSnapshotCommandId().

Referenced by ExecRefreshMatView().

◆ SetMatViewPopulatedState()

void SetMatViewPopulatedState ( Relation  relation,
bool  newstate 
)

Definition at line 84 of file matview.c.

85 {
86  Relation pgrel;
87  HeapTuple tuple;
88 
89  Assert(relation->rd_rel->relkind == RELKIND_MATVIEW);
90 
91  /*
92  * Update relation's pg_class entry. Crucial side-effect: other backends
93  * (and this one too!) are sent SI message to make them rebuild relcache
94  * entries.
95  */
96  pgrel = table_open(RelationRelationId, RowExclusiveLock);
99  if (!HeapTupleIsValid(tuple))
100  elog(ERROR, "cache lookup failed for relation %u",
101  RelationGetRelid(relation));
102 
103  ((Form_pg_class) GETSTRUCT(tuple))->relispopulated = newstate;
104 
105  CatalogTupleUpdate(pgrel, &tuple->t_self, tuple);
106 
107  heap_freetuple(tuple);
109 
110  /*
111  * Advance command counter to make the updated pg_class row locally
112  * visible.
113  */
115 }
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
Definition: indexing.c:301
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
static struct state * newstate(struct nfa *nfa)
Definition: regc_nfa.c:137
#define RelationGetRelid(relation)
Definition: rel.h:478
ItemPointerData t_self
Definition: htup.h:65
#define SearchSysCacheCopy1(cacheId, key1)
Definition: syscache.h:177
@ RELOID
Definition: syscache.h:87
void CommandCounterIncrement(void)
Definition: xact.c:1073

References Assert(), CatalogTupleUpdate(), CommandCounterIncrement(), elog, ERROR, GETSTRUCT, heap_freetuple(), HeapTupleIsValid, newstate(), ObjectIdGetDatum, RelationData::rd_rel, RelationGetRelid, RELOID, RowExclusiveLock, SearchSysCacheCopy1, HeapTupleData::t_self, table_close(), and table_open().

Referenced by ExecRefreshMatView(), and intorel_startup().

◆ transientrel_destroy()

static void transientrel_destroy ( DestReceiver self)
static

Definition at line 532 of file matview.c.

533 {
534  pfree(self);
535 }
void pfree(void *pointer)
Definition: mcxt.c:1169

References pfree().

Referenced by CreateTransientRelDestReceiver().

◆ transientrel_receive()

static bool transientrel_receive ( TupleTableSlot slot,
DestReceiver self 
)
static

Definition at line 487 of file matview.c.

488 {
489  DR_transientrel *myState = (DR_transientrel *) self;
490 
491  /*
492  * Note that the input slot might not be of the type of the target
493  * relation. That's supported by table_tuple_insert(), but slightly less
494  * efficient than inserting with the right slot - but the alternative
495  * would be to copy into a slot of the right type, which would not be
496  * cheap either. This also doesn't allow accessing per-AM data (say a
497  * tuple's xmin), but since we don't do that here...
498  */
499 
501  slot,
502  myState->output_cid,
503  myState->ti_options,
504  myState->bistate);
505 
506  /* We know this is a newly created relation, so there are no indexes */
507 
508  return true;
509 }
Relation transientrel
Definition: matview.c:55
BulkInsertState bistate
Definition: matview.c:58
CommandId output_cid
Definition: matview.c:56
int ti_options
Definition: matview.c:57
static void table_tuple_insert(Relation rel, TupleTableSlot *slot, CommandId cid, int options, struct BulkInsertStateData *bistate)
Definition: tableam.h:1373

References DR_transientrel::bistate, DR_transientrel::output_cid, table_tuple_insert(), DR_transientrel::ti_options, and DR_transientrel::transientrel.

Referenced by CreateTransientRelDestReceiver().

◆ transientrel_shutdown()

static void transientrel_shutdown ( DestReceiver self)
static

Definition at line 515 of file matview.c.

516 {
517  DR_transientrel *myState = (DR_transientrel *) self;
518 
519  FreeBulkInsertState(myState->bistate);
520 
522 
523  /* close transientrel, but keep lock until commit */
524  table_close(myState->transientrel, NoLock);
525  myState->transientrel = NULL;
526 }
void FreeBulkInsertState(BulkInsertState bistate)
Definition: heapam.c:2021
static void table_finish_bulk_insert(Relation rel, int options)
Definition: tableam.h:1566

References DR_transientrel::bistate, FreeBulkInsertState(), NoLock, table_close(), table_finish_bulk_insert(), DR_transientrel::ti_options, and DR_transientrel::transientrel.

Referenced by CreateTransientRelDestReceiver().

◆ transientrel_startup()

static void transientrel_startup ( DestReceiver self,
int  operation,
TupleDesc  typeinfo 
)
static

Definition at line 461 of file matview.c.

462 {
463  DR_transientrel *myState = (DR_transientrel *) self;
464  Relation transientrel;
465 
466  transientrel = table_open(myState->transientoid, NoLock);
467 
468  /*
469  * Fill private fields of myState for use by later routines
470  */
471  myState->transientrel = transientrel;
472  myState->output_cid = GetCurrentCommandId(true);
474  myState->bistate = GetBulkInsertState();
475 
476  /*
477  * Valid smgr_targblock implies something already wrote to the relation.
478  * This may be harmless, but this function hasn't planned for it.
479  */
481 }
#define InvalidBlockNumber
Definition: block.h:33
BulkInsertState GetBulkInsertState(void)
Definition: heapam.c:2007
#define RelationGetTargetBlock(relation)
Definition: rel.h:575
Oid transientoid
Definition: matview.c:53
#define TABLE_INSERT_FROZEN
Definition: tableam.h:237
#define TABLE_INSERT_SKIP_FSM
Definition: tableam.h:236
CommandId GetCurrentCommandId(bool used)
Definition: xact.c:813

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().

Variable Documentation

◆ matview_maintenance_depth

int matview_maintenance_depth = 0
static