105 ShmemSegHdr = shmhdr;
138 shmhdr->freeoffset = aligned - (
char *) shmhdr;
141 shmhdr->index = NULL;
142 ShmemIndex = (
HTAB *) NULL;
169 (
errcode(ERRCODE_OUT_OF_MEMORY),
170 errmsg(
"out of shared memory (%zu bytes requested)",
213 *allocated_size = size;
215 Assert(ShmemSegHdr != NULL);
221 newFree = newStart + size;
222 if (newFree <= ShmemSegHdr->totalsize)
224 newSpace = (
void *) ((
char *)
ShmemBase + newStart);
258 Assert(ShmemSegHdr != NULL);
262 newFree = newStart + size;
265 (
errcode(ERRCODE_OUT_OF_MEMORY),
266 errmsg(
"out of shared memory (%zu bytes requested)",
270 newSpace = (
void *) ((
char *)
ShmemBase + newStart);
376 return hash_create(name, init_size, infoP, hash_flags);
408 Assert(strcmp(name,
"ShmemIndex") == 0);
414 structPtr = shmemseghdr->
index;
429 shmemseghdr->
index = structPtr;
444 (
errcode(ERRCODE_OUT_OF_MEMORY),
445 errmsg(
"could not create ShmemIndex entry for data structure \"%s\"",
456 if (result->
size != size)
460 (
errmsg(
"ShmemIndex entry size is wrong for data structure" 461 " \"%s\": expected %zu, actual %zu",
462 name, size, result->
size)));
472 if (structPtr == NULL)
478 (
errcode(ERRCODE_OUT_OF_MEMORY),
479 errmsg(
"not enough shared memory for data structure" 480 " \"%s\" (%zu bytes requested)",
508 if (result < s1 || result < s2)
510 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
511 errmsg(
"requested shared memory size overflows size_t")));
523 if (s1 == 0 || s2 == 0)
527 if (result / s2 != s1)
529 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
530 errmsg(
"requested shared memory size overflows size_t")));
538 #define PG_GET_SHMEM_SIZES_COLS 4 546 Size named_allocated = 0;
553 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
554 errmsg(
"set-valued function called in context that cannot accept a set")));
557 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
558 errmsg(
"materialize mode required, but it is not allowed in this context")));
562 elog(
ERROR,
"return type must be a row type");
579 memset(nulls, 0,
sizeof(nulls));
586 named_allocated += ent->allocated_size;
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, Datum *values, bool *isnull)
VariableCacheData * VariableCache
#define IsA(nodeptr, _type_)
static PGShmemHeader * ShmemSegHdr
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
void InitShmemAccess(void *seghdr)
#define SpinLockInit(lock)
#define PG_GET_SHMEM_SIZES_COLS
#define tuplestore_donestoring(state)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
int errcode(int sqlerrcode)
void * ShmemAllocNoError(Size size)
void * ShmemAlloc(Size size)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
void LWLockRelease(LWLock *lock)
#define SpinLockAcquire(lock)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
VariableCache ShmemVariableCache
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
Datum pg_get_shmem_allocations(PG_FUNCTION_ARGS)
Datum Int64GetDatum(int64 X)
static void * ShmemAllocRaw(Size size, Size *allocated_size)
#define SpinLockRelease(lock)
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
Size mul_size(Size s1, Size s2)
void * ShmemAllocUnlocked(Size size)
Size add_size(Size s1, Size s2)
#define ereport(elevel,...)
bool ShmemAddrIsValid(const void *addr)
long hash_select_dirsize(long num_entries)
SetFunctionReturnMode returnMode
#define Assert(condition)
#define CACHELINEALIGN(LEN)
#define SHMEM_INDEX_KEYSIZE
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Size hash_get_shared_size(HASHCTL *info, int flags)
void * hash_seq_search(HASH_SEQ_STATUS *status)
MemoryContext ecxt_per_query_memory
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
Tuplestorestate * setResult
static Datum values[MAXATTR]
int errmsg(const char *fmt,...)
#define CStringGetTextDatum(s)
void InitShmemIndex(void)
HTAB * ShmemInitHash(const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags)
void InitShmemAllocation(void)