/* Otherwise, prepare to set one up. */
old_context = MemoryContextSwitchTo(TopMemoryContext);
shm_toc_initialize_estimator(&estimator);
/* Estimate space for the per-session DSA area. */
shm_toc_estimate_keys(&estimator, 1);
shm_toc_estimate_chunk(&estimator, SESSION_DSA_SIZE);
/* Estimate space for the per-session record typmod registry. */
typmod_registry_size = SharedRecordTypmodRegistryEstimate();
shm_toc_estimate_keys(&estimator, 1);
shm_toc_estimate_chunk(&estimator, typmod_registry_size);
/* Set up segment and TOC. */
size = shm_toc_estimate(&estimator);
seg = dsm_create(size, DSM_CREATE_NULL_IF_MAXSEGMENTS); if (seg == NULL)
{
MemoryContextSwitchTo(old_context);
/* Attach to the DSM segment. */
seg = dsm_attach(handle); if (seg == NULL)
elog(ERROR, "could not attach to per-session DSM segment");
toc = shm_toc_attach(SESSION_MAGIC, dsm_segment_address(seg));
/* Attach to the DSA area. */
dsa_space = shm_toc_lookup(toc, SESSION_KEY_DSA, false);
dsa = dsa_attach_in_place(dsa_space, seg);
/* Make them available via the current session. */
CurrentSession->segment = seg;
CurrentSession->area = dsa;
/* Attach to the shared record typmod registry. */
typmod_registry_space =
shm_toc_lookup(toc, SESSION_KEY_RECORD_TYPMOD_REGISTRY, false);
SharedRecordTypmodRegistryAttach((SharedRecordTypmodRegistry *)
typmod_registry_space);
/* Remain attached until end of backend or DetachSession(). */
dsm_pin_mapping(seg);
dsa_pin_mapping(dsa);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.