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 297 of file combocid.c.

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

Referenced by InitializeParallelDSM().

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

◆ RestoreComboCIDState()

void RestoreComboCIDState ( char *  comboCIDstate)

Definition at line 342 of file combocid.c.

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

Referenced by ParallelWorkerMain().

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

◆ SerializeComboCIDState()

void SerializeComboCIDState ( Size  maxsize,
char *  start_address 
)

Definition at line 316 of file combocid.c.

References elog, ERROR, and usedComboCids.

Referenced by InitializeParallelDSM().

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