Initialize ShmemVariableCache like other shmem areas
For sake of consistency. Reviewed-by: Tristan Partin, Richard Guo Discussion: https://www.postgresql.org/message-id/6537d63d-4bb5-46f8-9b5d-73a8ba4720ab@iki.fi
This commit is contained in:
parent
049ef3398d
commit
15916ffb04
@ -34,6 +34,33 @@
|
||||
VariableCache ShmemVariableCache = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Initialization of shared memory for ShmemVariableCache.
|
||||
*/
|
||||
Size
|
||||
VarsupShmemSize(void)
|
||||
{
|
||||
return sizeof(VariableCacheData);
|
||||
}
|
||||
|
||||
void
|
||||
VarsupShmemInit(void)
|
||||
{
|
||||
bool found;
|
||||
|
||||
/* Initialize our shared state struct */
|
||||
ShmemVariableCache = ShmemInitStruct("ShmemVariableCache",
|
||||
sizeof(VariableCacheData),
|
||||
&found);
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
Assert(!found);
|
||||
memset(ShmemVariableCache, 0, sizeof(VariableCacheData));
|
||||
}
|
||||
else
|
||||
Assert(found);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate the next FullTransactionId for a new transaction or
|
||||
* subtransaction.
|
||||
|
@ -89,7 +89,6 @@
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#include "access/transam.h"
|
||||
#include "access/xlog.h"
|
||||
#include "access/xlogrecovery.h"
|
||||
#include "catalog/pg_control.h"
|
||||
@ -513,7 +512,6 @@ typedef struct
|
||||
#endif
|
||||
void *UsedShmemSegAddr;
|
||||
slock_t *ShmemLock;
|
||||
VariableCache ShmemVariableCache;
|
||||
Backend *ShmemBackendArray;
|
||||
#ifndef HAVE_SPINLOCKS
|
||||
PGSemaphore *SpinlockSemaArray;
|
||||
@ -6034,7 +6032,6 @@ save_backend_variables(BackendParameters *param, Port *port, BackgroundWorker *w
|
||||
param->UsedShmemSegAddr = UsedShmemSegAddr;
|
||||
|
||||
param->ShmemLock = ShmemLock;
|
||||
param->ShmemVariableCache = ShmemVariableCache;
|
||||
param->ShmemBackendArray = ShmemBackendArray;
|
||||
|
||||
#ifndef HAVE_SPINLOCKS
|
||||
@ -6280,7 +6277,6 @@ restore_backend_variables(BackendParameters *param, Port **port, BackgroundWorke
|
||||
UsedShmemSegAddr = param->UsedShmemSegAddr;
|
||||
|
||||
ShmemLock = param->ShmemLock;
|
||||
ShmemVariableCache = param->ShmemVariableCache;
|
||||
ShmemBackendArray = param->ShmemBackendArray;
|
||||
|
||||
#ifndef HAVE_SPINLOCKS
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "access/nbtree.h"
|
||||
#include "access/subtrans.h"
|
||||
#include "access/syncscan.h"
|
||||
#include "access/transam.h"
|
||||
#include "access/twophase.h"
|
||||
#include "access/xlogprefetcher.h"
|
||||
#include "access/xlogrecovery.h"
|
||||
@ -118,6 +119,7 @@ CalculateShmemSize(int *num_semaphores)
|
||||
size = add_size(size, PredicateLockShmemSize());
|
||||
size = add_size(size, ProcGlobalShmemSize());
|
||||
size = add_size(size, XLogPrefetchShmemSize());
|
||||
size = add_size(size, VarsupShmemSize());
|
||||
size = add_size(size, XLOGShmemSize());
|
||||
size = add_size(size, XLogRecoveryShmemSize());
|
||||
size = add_size(size, CLOGShmemSize());
|
||||
@ -289,6 +291,7 @@ CreateOrAttachShmemStructs(void)
|
||||
/*
|
||||
* Set up xlog, clog, and buffers
|
||||
*/
|
||||
VarsupShmemInit();
|
||||
XLOGShmemInit();
|
||||
XLogPrefetchShmemInit();
|
||||
XLogRecoveryShmemInit();
|
||||
|
@ -140,14 +140,6 @@ InitShmemAllocation(void)
|
||||
/* ShmemIndex can't be set up yet (need LWLocks first) */
|
||||
shmhdr->index = NULL;
|
||||
ShmemIndex = (HTAB *) NULL;
|
||||
|
||||
/*
|
||||
* Initialize ShmemVariableCache for transaction manager. (This doesn't
|
||||
* really belong here, but not worth moving.)
|
||||
*/
|
||||
ShmemVariableCache = (VariableCache)
|
||||
ShmemAlloc(sizeof(*ShmemVariableCache));
|
||||
memset(ShmemVariableCache, 0, sizeof(*ShmemVariableCache));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -285,6 +285,8 @@ extern TransactionId TransactionIdLatest(TransactionId mainxid,
|
||||
extern XLogRecPtr TransactionIdGetCommitLSN(TransactionId xid);
|
||||
|
||||
/* in transam/varsup.c */
|
||||
extern Size VarsupShmemSize(void);
|
||||
extern void VarsupShmemInit(void);
|
||||
extern FullTransactionId GetNewTransactionId(bool isSubXact);
|
||||
extern void AdvanceNextFullTransactionIdPastXid(TransactionId xid);
|
||||
extern FullTransactionId ReadNextFullTransactionId(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user