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.

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 ComboCidKey comboCids
Definition: combocid.c:80
static HTAB * comboHash
Definition: combocid.c:53
static int usedComboCids
Definition: combocid.c:81
static int sizeComboCids
Definition: combocid.c:82

References comboCids, comboHash, sizeComboCids, and usedComboCids.

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

◆ EstimateComboCIDStateSpace()

Size EstimateComboCIDStateSpace ( void  )

Definition at line 297 of file combocid.c.

298{
299 Size size;
300
301 /* Add space required for saving usedComboCids */
302 size = sizeof(int);
303
304 /* Add space required for saving ComboCidKeyData */
306
307 return size;
308}
size_t Size
Definition: c.h:562
Size add_size(Size s1, Size s2)
Definition: shmem.c:488
Size mul_size(Size s1, Size s2)
Definition: shmem.c:505
static pg_noinline void Size size
Definition: slab.c:607

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

Referenced by InitializeParallelDSM().

◆ RestoreComboCIDState()

void RestoreComboCIDState ( char *  comboCIDstate)

Definition at line 342 of file combocid.c.

343{
344 int num_elements;
345 ComboCidKeyData *keydata;
346 int i;
347 CommandId cid;
348
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}
#define Assert(condition)
Definition: c.h:815
uint32 CommandId
Definition: c.h:623
static CommandId GetComboCommandId(CommandId cmin, CommandId cmax)
Definition: combocid.c:204
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:225
int i
Definition: isn.c:72

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

Referenced by ParallelWorkerMain().

◆ SerializeComboCIDState()

void SerializeComboCIDState ( Size  maxsize,
char *  start_address 
)

Definition at line 316 of file combocid.c.

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}

References comboCids, elog, ERROR, and usedComboCids.

Referenced by InitializeParallelDSM().