PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

void AtEOXact_ComboCid ( void  )

Definition at line 183 of file combocid.c.

References NULL, sizeComboCids, and usedComboCids.

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

184 {
185  /*
186  * Don't bother to pfree. These are allocated in TopTransactionContext, so
187  * they're going to go away at the end of transaction anyway.
188  */
189  comboHash = NULL;
190 
191  comboCids = NULL;
192  usedComboCids = 0;
193  sizeComboCids = 0;
194 }
static int usedComboCids
Definition: combocid.c:82
static ComboCidKey comboCids
Definition: combocid.c:81
static HTAB * comboHash
Definition: combocid.c:54
static int sizeComboCids
Definition: combocid.c:83
#define NULL
Definition: c.h:226
Size EstimateComboCIDStateSpace ( void  )

Definition at line 299 of file combocid.c.

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

Referenced by InitializeParallelDSM().

300 {
301  Size size;
302 
303  /* Add space required for saving usedComboCids */
304  size = sizeof(int);
305 
306  /* Add space required for saving the combocids key */
307  size = add_size(size, mul_size(sizeof(ComboCidKeyData), usedComboCids));
308 
309  return size;
310 }
static int usedComboCids
Definition: combocid.c:82
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:352
void RestoreComboCIDState ( char *  comboCIDstate)

Definition at line 344 of file combocid.c.

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

Referenced by ParallelWorkerMain().

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

Definition at line 318 of file combocid.c.

References elog, ERROR, and usedComboCids.

Referenced by InitializeParallelDSM().

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