PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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  )
extern

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
static int fb(int x)

References comboCids, comboHash, fb(), sizeComboCids, and usedComboCids.

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

◆ EstimateComboCIDStateSpace()

Size EstimateComboCIDStateSpace ( void  )
extern

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 */
305 size = add_size(size, mul_size(sizeof(ComboCidKeyData), usedComboCids));
306
307 return size;
308}
size_t Size
Definition c.h:619
Size add_size(Size s1, Size s2)
Definition shmem.c:495
Size mul_size(Size s1, Size s2)
Definition shmem.c:510

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

Referenced by InitializeParallelDSM().

◆ RestoreComboCIDState()

void RestoreComboCIDState ( char comboCIDstate)
extern

Definition at line 342 of file combocid.c.

343{
344 int num_elements;
346 int i;
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:873
uint32 CommandId
Definition c.h:680
static CommandId GetComboCommandId(CommandId cmin, CommandId cmax)
Definition combocid.c:204
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
int i
Definition isn.c:77

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

Referenced by ParallelWorkerMain().

◆ SerializeComboCIDState()

void SerializeComboCIDState ( Size  maxsize,
char start_address 
)
extern

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);
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, fb(), and usedComboCids.

Referenced by InitializeParallelDSM().