PostgreSQL Source Code  git master
combocid.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void AtEOXact_ComboCid (void)
 
void RestoreComboCIDState (char *comboCIDstate)
 
void SerializeComboCIDState (Size maxsize, char *start_address)
 
Size EstimateComboCIDStateSpace (void)
 

Function Documentation

◆ AtEOXact_ComboCid()

void AtEOXact_ComboCid ( void  )

Definition at line 182 of file combocid.c.

References sizeComboCids, and usedComboCids.

Referenced by AbortTransaction(), CommitTransaction(), and PrepareTransaction().

183 {
184  /*
185  * Don't bother to pfree. These are allocated in TopTransactionContext, so
186  * they're going to go away at the end of transaction anyway.
187  */
188  comboHash = NULL;
189 
190  comboCids = NULL;
191  usedComboCids = 0;
192  sizeComboCids = 0;
193 }
static int usedComboCids
Definition: combocid.c:81
static ComboCidKey comboCids
Definition: combocid.c:80
static HTAB * comboHash
Definition: combocid.c:53
static int sizeComboCids
Definition: combocid.c:82

◆ EstimateComboCIDStateSpace()

Size EstimateComboCIDStateSpace ( void  )

Definition at line 298 of file combocid.c.

References add_size(), mul_size(), and usedComboCids.

Referenced by InitializeParallelDSM().

299 {
300  Size size;
301 
302  /* Add space required for saving usedComboCids */
303  size = sizeof(int);
304 
305  /* Add space required for saving the combocids key */
306  size = add_size(size, mul_size(sizeof(ComboCidKeyData), usedComboCids));
307 
308  return size;
309 }
static int usedComboCids
Definition: combocid.c:81
Size mul_size(Size s1, Size s2)
Definition: shmem.c:492
Size add_size(Size s1, Size s2)
Definition: shmem.c:475
size_t Size
Definition: c.h:467

◆ RestoreComboCIDState()

void RestoreComboCIDState ( char *  comboCIDstate)

Definition at line 343 of file combocid.c.

References Assert, elog, ERROR, GetComboCommandId(), and i.

Referenced by ParallelWorkerMain().

344 {
345  int num_elements;
346  ComboCidKeyData *keydata;
347  int i;
348  CommandId cid;
349 
350  Assert(!comboCids && !comboHash);
351 
352  /* First, we retrieve the number of ComboCIDs that were serialized. */
353  num_elements = *(int *) comboCIDstate;
354  keydata = (ComboCidKeyData *) (comboCIDstate + sizeof(int));
355 
356  /* Use GetComboCommandId to restore each ComboCID. */
357  for (i = 0; i < num_elements; i++)
358  {
359  cid = GetComboCommandId(keydata[i].cmin, keydata[i].cmax);
360 
361  /* Verify that we got the expected answer. */
362  if (cid != i)
363  elog(ERROR, "unexpected command ID while restoring combo CIDs");
364  }
365 }
uint32 CommandId
Definition: c.h:528
static ComboCidKey comboCids
Definition: combocid.c:80
#define ERROR
Definition: elog.h:43
static CommandId GetComboCommandId(CommandId cmin, CommandId cmax)
Definition: combocid.c:204
static HTAB * comboHash
Definition: combocid.c:53
#define Assert(condition)
Definition: c.h:739
#define elog(elevel,...)
Definition: elog.h:228
int i

◆ SerializeComboCIDState()

void SerializeComboCIDState ( Size  maxsize,
char *  start_address 
)

Definition at line 317 of file combocid.c.

References elog, ERROR, and usedComboCids.

Referenced by InitializeParallelDSM().

318 {
319  char *endptr;
320 
321  /* First, we store the number of currently-existing ComboCIDs. */
322  *(int *) start_address = usedComboCids;
323 
324  /* If maxsize is too small, throw an error. */
325  endptr = start_address + sizeof(int) +
326  (sizeof(ComboCidKeyData) * usedComboCids);
327  if (endptr < start_address || endptr > start_address + maxsize)
328  elog(ERROR, "not enough space to serialize ComboCID state");
329 
330  /* Now, copy the actual cmin/cmax pairs. */
331  if (usedComboCids > 0)
332  memcpy(start_address + sizeof(int), comboCids,
333  (sizeof(ComboCidKeyData) * usedComboCids));
334 }
static int usedComboCids
Definition: combocid.c:81
static ComboCidKey comboCids
Definition: combocid.c:80
#define ERROR
Definition: elog.h:43
#define elog(elevel,...)
Definition: elog.h:228