Add macros to make AllocSetContextCreate() calls simpler and safer.
authorTom Lane <[email protected]>
Sat, 27 Aug 2016 21:50:38 +0000 (17:50 -0400)
committerTom Lane <[email protected]>
Sat, 27 Aug 2016 21:50:38 +0000 (17:50 -0400)
I found that half a dozen (nearly 5%) of our AllocSetContextCreate calls
had typos in the context-sizing parameters.  While none of these led to
especially significant problems, they did create minor inefficiencies,
and it's now clear that expecting people to copy-and-paste those calls
accurately is not a great idea.  Let's reduce the risk of future errors
by introducing single macros that encapsulate the common use-cases.
Three such macros are enough to cover all but two special-purpose contexts;
those two calls can be left as-is, I think.

While this patch doesn't in itself improve matters for third-party
extensions, it doesn't break anything for them either, and they can
gradually adopt the simplified notation over time.

In passing, change TopMemoryContext to use the default allocation
parameters.  Formerly it could only be extended 8K at a time.  That was
probably reasonable when this code was written; but nowadays we create
many more contexts than we did then, so that it's not unusual to have a
couple hundred K in TopMemoryContext, even without considering various
dubious code that sticks other things there.  There seems no good reason
not to let it use growing blocks like most other contexts.

Back-patch to 9.6, mostly because that's still close enough to HEAD that
it's easy to do so, and keeping the branches in sync can be expected to
avoid some future back-patching pain.  The bugs fixed by these changes
don't seem to be significant enough to justify fixing them further back.

Discussion: <21072.1472321324@sss.pgh.pa.us>

99 files changed:
contrib/bloom/blinsert.c
contrib/dblink/dblink.c
contrib/file_fdw/file_fdw.c
contrib/pg_trgm/trgm_regexp.c
contrib/postgres_fdw/postgres_fdw.c
contrib/sepgsql/uavc.c
contrib/test_decoding/test_decoding.c
src/backend/access/brin/brin.c
src/backend/access/brin/brin_tuple.c
src/backend/access/common/printtup.c
src/backend/access/gin/ginbtree.c
src/backend/access/gin/ginfast.c
src/backend/access/gin/gininsert.c
src/backend/access/gin/ginscan.c
src/backend/access/gin/ginvacuum.c
src/backend/access/gin/ginxlog.c
src/backend/access/gist/gist.c
src/backend/access/gist/gistscan.c
src/backend/access/heap/rewriteheap.c
src/backend/access/nbtree/nbtree.c
src/backend/access/nbtree/nbtutils.c
src/backend/access/spgist/spginsert.c
src/backend/access/spgist/spgscan.c
src/backend/access/spgist/spgxlog.c
src/backend/access/transam/multixact.c
src/backend/access/transam/parallel.c
src/backend/access/transam/xact.c
src/backend/access/transam/xlog.c
src/backend/access/transam/xloginsert.c
src/backend/bootstrap/bootstrap.c
src/backend/catalog/objectaddress.c
src/backend/commands/analyze.c
src/backend/commands/cluster.c
src/backend/commands/copy.c
src/backend/commands/event_trigger.c
src/backend/commands/indexcmds.c
src/backend/commands/policy.c
src/backend/commands/trigger.c
src/backend/commands/vacuum.c
src/backend/executor/execUtils.c
src/backend/executor/functions.c
src/backend/executor/nodeFunctionscan.c
src/backend/executor/nodeHash.c
src/backend/executor/nodeRecursiveunion.c
src/backend/executor/nodeSetOp.c
src/backend/executor/nodeSubplan.c
src/backend/executor/nodeUnique.c
src/backend/executor/nodeWindowAgg.c
src/backend/executor/spi.c
src/backend/executor/tqueue.c
src/backend/libpq/be-fsstubs.c
src/backend/libpq/hba.c
src/backend/optimizer/geqo/geqo_eval.c
src/backend/optimizer/util/clauses.c
src/backend/postmaster/autovacuum.c
src/backend/postmaster/bgwriter.c
src/backend/postmaster/checkpointer.c
src/backend/postmaster/pgstat.c
src/backend/postmaster/postmaster.c
src/backend/postmaster/walwriter.c
src/backend/replication/logical/logical.c
src/backend/replication/logical/reorderbuffer.c
src/backend/replication/logical/snapbuild.c
src/backend/replication/walsender.c
src/backend/storage/buffer/localbuf.c
src/backend/storage/file/reinit.c
src/backend/storage/lmgr/lwlock.c
src/backend/storage/smgr/md.c
src/backend/tcop/postgres.c
src/backend/tsearch/spell.c
src/backend/utils/adt/array_expanded.c
src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/jsonfuncs.c
src/backend/utils/adt/xml.c
src/backend/utils/cache/catcache.c
src/backend/utils/cache/evtcache.c
src/backend/utils/cache/plancache.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/ts_cache.c
src/backend/utils/cache/typcache.c
src/backend/utils/fmgr/funcapi.c
src/backend/utils/hash/dynahash.c
src/backend/utils/init/postinit.c
src/backend/utils/misc/guc-file.l
src/backend/utils/misc/tzparser.c
src/backend/utils/mmgr/aset.c
src/backend/utils/mmgr/mcxt.c
src/backend/utils/mmgr/portalmem.c
src/backend/utils/sort/tuplesort.c
src/include/utils/memutils.h
src/pl/plperl/plperl.c
src/pl/plpgsql/src/pl_comp.c
src/pl/plpgsql/src/pl_exec.c
src/pl/plpython/plpy_cursorobject.c
src/pl/plpython/plpy_main.c
src/pl/plpython/plpy_procedure.c
src/pl/plpython/plpy_spi.c
src/pl/plpython/plpy_typeio.c
src/pl/tcl/pltcl.c

index 78eec5c67e01e688056bfd6a012cd4d36e18dde6..0946aa29ecc8ccb7194a5950df601a7887c5c10e 100644 (file)
@@ -130,9 +130,7 @@ blbuild(Relation heap, Relation index, IndexInfo *indexInfo)
        initBloomState(&buildstate.blstate, index);
        buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                                          "Bloom build temporary context",
-                                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         ALLOCSET_DEFAULT_SIZES);
        initCachedPage(&buildstate);
 
        /* Do the heap scan */
@@ -204,9 +202,7 @@ blinsert(Relation index, Datum *values, bool *isnull,
 
        insertCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                          "Bloom insert temporary context",
-                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                         ALLOCSET_DEFAULT_SIZES);
 
        oldCtx = MemoryContextSwitchTo(insertCtx);
 
index 9c8e3083584ac93ae50078d4e137f20c58942b81..d4f9090f062a06b72dfc49ccd11473f2fda21d37 100644 (file)
@@ -980,9 +980,7 @@ materializeQueryResult(FunctionCallInfo fcinfo,
                /* Create short-lived memory context for data conversions */
                sinfo.tmpcontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                                                 "dblink temporary context",
-                                                                                                ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                ALLOCSET_DEFAULT_SIZES);
 
                /* execute query, collecting any tuples into the tuplestore */
                res = storeQueryResult(&sinfo, conn, sql);
index c0491318c0b914e3e220d8cbc3e941500bfea2e6..b42de873e0f56ced19c15ed15a88431b7202ebb7 100644 (file)
@@ -1061,9 +1061,7 @@ file_acquire_sample_rows(Relation onerel, int elevel,
         */
        tupcontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                           "file_fdw temporary context",
-                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                          ALLOCSET_DEFAULT_SIZES);
 
        /* Prepare for sampling rows */
        reservoir_init_selection_state(&rstate, targrows);
index 3f09a9c718deae6f36f8401a5470f815743475cf..005701fcd92e7b892dec4676d343a882312abf98 100644 (file)
@@ -529,9 +529,7 @@ createTrgmNFA(text *text_re, Oid collation,
         */
        tmpcontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                           "createTrgmNFA temporary context",
-                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                          ALLOCSET_DEFAULT_SIZES);
        oldcontext = MemoryContextSwitchTo(tmpcontext);
 
        /*
index b92f29958f3b7cbe6343b46876ed46c6f586f2fb..daf04385321b9928c0cc5248937632a8528031f2 100644 (file)
@@ -1315,14 +1315,10 @@ postgresBeginForeignScan(ForeignScanState *node, int eflags)
        /* Create contexts for batches of tuples and per-tuple temp workspace. */
        fsstate->batch_cxt = AllocSetContextCreate(estate->es_query_cxt,
                                                                                           "postgres_fdw tuple data",
-                                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                          ALLOCSET_DEFAULT_SIZES);
        fsstate->temp_cxt = AllocSetContextCreate(estate->es_query_cxt,
                                                                                          "postgres_fdw temporary data",
-                                                                                         ALLOCSET_SMALL_MINSIZE,
-                                                                                         ALLOCSET_SMALL_INITSIZE,
-                                                                                         ALLOCSET_SMALL_MAXSIZE);
+                                                                                         ALLOCSET_SMALL_SIZES);
 
        /*
         * Get info we'll need for converting data fetched from the foreign server
@@ -1695,9 +1691,7 @@ postgresBeginForeignModify(ModifyTableState *mtstate,
        /* Create context for per-tuple temp workspace. */
        fmstate->temp_cxt = AllocSetContextCreate(estate->es_query_cxt,
                                                                                          "postgres_fdw temporary data",
-                                                                                         ALLOCSET_SMALL_MINSIZE,
-                                                                                         ALLOCSET_SMALL_INITSIZE,
-                                                                                         ALLOCSET_SMALL_MAXSIZE);
+                                                                                         ALLOCSET_SMALL_SIZES);
 
        /* Prepare for input conversion of RETURNING results. */
        if (fmstate->has_returning)
@@ -2294,9 +2288,7 @@ postgresBeginDirectModify(ForeignScanState *node, int eflags)
        /* Create context for per-tuple temp workspace. */
        dmstate->temp_cxt = AllocSetContextCreate(estate->es_query_cxt,
                                                                                          "postgres_fdw temporary data",
-                                                                                         ALLOCSET_SMALL_MINSIZE,
-                                                                                         ALLOCSET_SMALL_INITSIZE,
-                                                                                         ALLOCSET_SMALL_MAXSIZE);
+                                                                                         ALLOCSET_SMALL_SIZES);
 
        /* Prepare for input conversion of RETURNING results. */
        if (dmstate->has_returning)
@@ -3481,9 +3473,7 @@ postgresAcquireSampleRowsFunc(Relation relation, int elevel,
        astate.anl_cxt = CurrentMemoryContext;
        astate.temp_cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                        "postgres_fdw temporary data",
-                                                                                       ALLOCSET_SMALL_MINSIZE,
-                                                                                       ALLOCSET_SMALL_INITSIZE,
-                                                                                       ALLOCSET_SMALL_MAXSIZE);
+                                                                                       ALLOCSET_SMALL_SIZES);
 
        /*
         * Get the connection to use.  We do the remote access as the table's
index 10fa9a0b0bc742a45e9461049d2eee4d3f9f93d4..6e358dbef7c82ea153bfcd6577849f7e9969a7f9 100644 (file)
@@ -498,13 +498,11 @@ sepgsql_avc_init(void)
        int                     rc;
 
        /*
-        * All the avc stuff shall be allocated on avc_mem_cxt
+        * All the avc stuff shall be allocated in avc_mem_cxt
         */
        avc_mem_cxt = AllocSetContextCreate(TopMemoryContext,
                                                                                "userspace access vector cache",
-                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                               ALLOCSET_DEFAULT_SIZES);
        memset(avc_slots, 0, sizeof(avc_slots));
        avc_num_caches = 0;
        avc_lru_hint = 0;
index c3508f0e13d6d6f5292fcf99f09179de85794299..949e9a78d92857bba10c5f2d5e1dba81ffca345c 100644 (file)
@@ -102,9 +102,7 @@ pg_decode_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
        data = palloc0(sizeof(TestDecodingData));
        data->context = AllocSetContextCreate(ctx->context,
                                                                                  "text conversion context",
-                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                 ALLOCSET_DEFAULT_SIZES);
        data->include_xids = true;
        data->include_timestamp = false;
        data->skip_empty_xacts = false;
index b194d33cc5c64a29b2901b0f5dd0ef4825580c68..1b45a4c90163b95740316d553dbd128f494a7fc3 100644 (file)
@@ -165,9 +165,7 @@ brininsert(Relation idxRel, Datum *values, bool *nulls,
                        bdesc = brin_build_desc(idxRel);
                        tupcxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                   "brininsert cxt",
-                                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                  ALLOCSET_DEFAULT_SIZES);
                        oldcxt = MemoryContextSwitchTo(tupcxt);
                }
 
@@ -347,9 +345,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm)
         */
        perRangeCxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                "bringetbitmap cxt",
-                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                               ALLOCSET_DEFAULT_SIZES);
        oldcxt = MemoryContextSwitchTo(perRangeCxt);
 
        /*
@@ -856,9 +852,7 @@ brin_build_desc(Relation rel)
 
        cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                "brin desc cxt",
-                                                               ALLOCSET_SMALL_INITSIZE,
-                                                               ALLOCSET_SMALL_MINSIZE,
-                                                               ALLOCSET_SMALL_MAXSIZE);
+                                                               ALLOCSET_SMALL_SIZES);
        oldcxt = MemoryContextSwitchTo(cxt);
        tupdesc = RelationGetDescr(rel);
 
@@ -1169,9 +1163,7 @@ union_tuples(BrinDesc *bdesc, BrinMemTuple *a, BrinTuple *b)
        /* Use our own memory context to avoid retail pfree */
        cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                "brin union",
-                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                               ALLOCSET_DEFAULT_SIZES);
        oldcxt = MemoryContextSwitchTo(cxt);
        db = brin_deform_tuple(bdesc, b);
        MemoryContextSwitchTo(oldcxt);
index 64b82649596341b151109019a9f30bb9eeaca0cb..3caec14d17bdbb9c91effa4ea131c905e388392d 100644 (file)
@@ -367,9 +367,7 @@ brin_new_memtuple(BrinDesc *brdesc)
 
        dtup->bt_context = AllocSetContextCreate(CurrentMemoryContext,
                                                                                         "brin dtuple",
-                                                                                        ALLOCSET_DEFAULT_MINSIZE,
-                                                                                        ALLOCSET_DEFAULT_INITSIZE,
-                                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                        ALLOCSET_DEFAULT_SIZES);
        return dtup;
 }
 
index d9664aa6c6b918cbf3a322f37ad77784f9bd64bd..d213af90749f4dcfe704132eac5b755d6600774e 100644 (file)
@@ -135,9 +135,7 @@ printtup_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
         */
        myState->tmpcontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                                                "printtup",
-                                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                               ALLOCSET_DEFAULT_SIZES);
 
        if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
        {
index fa383719e65abce050c471d7e107ee55532266c6..a0afec4f3c0bb826f7587abbee98a3707a6ece4d 100644 (file)
@@ -348,9 +348,7 @@ ginPlaceToPage(GinBtree btree, GinBtreeStack *stack,
         */
        tmpCxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                   "ginPlaceToPage temporary context",
-                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                  ALLOCSET_DEFAULT_SIZES);
        oldCxt = MemoryContextSwitchTo(tmpCxt);
 
        if (GinPageIsData(page))
index 59a63f28d08d014ca636c2a496671444c4570d25..6b709dbdb3a1b4981cbb0a7ca6d1da8df4f5ad7b 100644 (file)
@@ -808,9 +808,7 @@ ginInsertCleanup(GinState *ginstate, bool full_clean,
         */
        opCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                  "GIN insert cleanup temporary context",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
 
        oldCtx = MemoryContextSwitchTo(opCtx);
 
index 9f784bf48d197b005ef8f1a0e4a393859060e099..4e09f76eb2a4371c3fed04d39653cfbffad79361 100644 (file)
@@ -372,9 +372,7 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo)
         */
        buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                                          "Gin build temporary context",
-                                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         ALLOCSET_DEFAULT_SIZES);
 
        /*
         * create a temporary memory context that is used for calling
@@ -382,9 +380,7 @@ ginbuild(Relation heap, Relation index, IndexInfo *indexInfo)
         */
        buildstate.funcCtx = AllocSetContextCreate(CurrentMemoryContext,
                                         "Gin build temporary context for user-defined function",
-                                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                          ALLOCSET_DEFAULT_SIZES);
 
        buildstate.accum.ginstate = &buildstate.ginstate;
        ginInitBA(&buildstate.accum);
@@ -495,9 +491,7 @@ gininsert(Relation index, Datum *values, bool *isnull,
 
        insertCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                          "Gin insert temporary context",
-                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                         ALLOCSET_DEFAULT_SIZES);
 
        oldCtx = MemoryContextSwitchTo(insertCtx);
 
index c449c1cbc0ed7dbc7e17bf5dac83523ecef12e92..bfa86b521d08a95e44e1377fb519af6bac800287 100644 (file)
@@ -38,14 +38,10 @@ ginbeginscan(Relation rel, int nkeys, int norderbys)
        so->nkeys = 0;
        so->tempCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                                "Gin scan temporary context",
-                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                               ALLOCSET_DEFAULT_SIZES);
        so->keyCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                           "Gin scan key context",
-                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                          ALLOCSET_DEFAULT_SIZES);
        initGinState(&so->ginstate, scan->indexRelation);
 
        scan->opaque = so;
index c258478f23262b593197030f35f68b5cfe3a1b92..2685a1c373196612a613e6495e895967a8bd21f7 100644 (file)
@@ -526,9 +526,7 @@ ginbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
 
        gvs.tmpCxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                           "Gin vacuum temporary context",
-                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                          ALLOCSET_DEFAULT_SIZES);
        gvs.index = index;
        gvs.callback = callback;
        gvs.callback_state = callback_state;
index b4d310f337a91d61313092b1f86103d32cad9ad2..a40f1683dd80e4620ba6ccd93ae0e178e9616cf7 100644 (file)
@@ -749,13 +749,12 @@ gin_xlog_startup(void)
 {
        opCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                  "GIN recovery temporary context",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
 }
 
 void
 gin_xlog_cleanup(void)
 {
        MemoryContextDelete(opCtx);
+       opCtx = NULL;
 }
index 9a417ca2f42199015e8f9dbe77b1c5f0d9f38ea1..f7f44b49aa30d0e2ae54b349d95ea6c2edd5f613 100644 (file)
@@ -105,9 +105,7 @@ createTempGistContext(void)
 {
        return AllocSetContextCreate(CurrentMemoryContext,
                                                                 "GiST temporary context",
-                                                                ALLOCSET_DEFAULT_MINSIZE,
-                                                                ALLOCSET_DEFAULT_INITSIZE,
-                                                                ALLOCSET_DEFAULT_MAXSIZE);
+                                                                ALLOCSET_DEFAULT_SIZES);
 }
 
 /*
@@ -1411,9 +1409,7 @@ initGISTstate(Relation index)
        /* Create the memory context that will hold the GISTSTATE */
        scanCxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                        "GiST scan context",
-                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                       ALLOCSET_DEFAULT_SIZES);
        oldCxt = MemoryContextSwitchTo(scanCxt);
 
        /* Create and fill in the GISTSTATE */
index 6f07cd8d46e54be293ff0e3526f38215a4c9a1dc..ba611ee490a93b9ee2b5346a3b40cffe07ef0c65 100644 (file)
@@ -140,9 +140,7 @@ gistrescan(IndexScanDesc scan, ScanKey key, int nkeys,
                /* second time through */
                so->queueCxt = AllocSetContextCreate(so->giststate->scanCxt,
                                                                                         "GiST queue context",
-                                                                                        ALLOCSET_DEFAULT_MINSIZE,
-                                                                                        ALLOCSET_DEFAULT_INITSIZE,
-                                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                        ALLOCSET_DEFAULT_SIZES);
                first_time = false;
        }
        else
@@ -180,9 +178,7 @@ gistrescan(IndexScanDesc scan, ScanKey key, int nkeys,
 
                so->pageDataCxt = AllocSetContextCreate(so->giststate->scanCxt,
                                                                                                "GiST page data context",
-                                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                               ALLOCSET_DEFAULT_SIZES);
        }
 
        /* create new, empty RBTree for search queue */
index f9ce9861e2cacb520c48d39892e3a176144ad7da..17584ba3ed6a69bc6d45172413bcaa433dd1b838 100644 (file)
@@ -258,9 +258,7 @@ begin_heap_rewrite(Relation old_heap, Relation new_heap, TransactionId oldest_xm
         */
        rw_cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                   "Table rewrite",
-                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                  ALLOCSET_DEFAULT_SIZES);
        old_cxt = MemoryContextSwitchTo(rw_cxt);
 
        /* Create and fill in the state struct */
index 4668c5ee59f0ccc4807831f05be4cdf376348148..128744c5b76996ec23cb7244757ceda2a990984e 100644 (file)
@@ -763,9 +763,7 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
        /* Create a temporary memory context to run _bt_pagedel in */
        vstate.pagedelcontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                                                  "_bt_pagedel",
-                                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                 ALLOCSET_DEFAULT_SIZES);
 
        /*
         * The outer loop iterates over all index pages except the metapage, in
index 5d335c7f97cd5160706778ca8a2dcef023692c1b..063c988dc1f8b53b8766b26dd4ef20c2b3d9c6a2 100644 (file)
@@ -232,10 +232,8 @@ _bt_preprocess_array_keys(IndexScanDesc scan)
         */
        if (so->arrayContext == NULL)
                so->arrayContext = AllocSetContextCreate(CurrentMemoryContext,
-                                                                                                "BTree Array Context",
-                                                                                                ALLOCSET_SMALL_MINSIZE,
-                                                                                                ALLOCSET_SMALL_INITSIZE,
-                                                                                                ALLOCSET_SMALL_MAXSIZE);
+                                                                                                "BTree array context",
+                                                                                                ALLOCSET_SMALL_SIZES);
        else
                MemoryContextReset(so->arrayContext);
 
index 44fd644e4213e5a97b2dada022cc32440456ee84..01c8d213f5ca21e957a1cddf80f6dd01af684258 100644 (file)
@@ -134,9 +134,7 @@ spgbuild(Relation heap, Relation index, IndexInfo *indexInfo)
 
        buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                                   "SP-GiST build temporary context",
-                                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         ALLOCSET_DEFAULT_SIZES);
 
        reltuples = IndexBuildHeapScan(heap, index, indexInfo, true,
                                                                   spgistBuildCallback, (void *) &buildstate);
@@ -213,9 +211,7 @@ spginsert(Relation index, Datum *values, bool *isnull,
 
        insertCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                          "SP-GiST insert temporary context",
-                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                         ALLOCSET_DEFAULT_SIZES);
        oldCtx = MemoryContextSwitchTo(insertCtx);
 
        initSpGistState(&spgstate, index);
index 6f9e223f43dd132242c69fdf0d814748c868e7c2..307c6a4ab57366f8e5803c8b389f96f2a1037f4b 100644 (file)
@@ -193,9 +193,7 @@ spgbeginscan(Relation rel, int keysz, int orderbysz)
        initSpGistState(&so->state, scan->indexRelation);
        so->tempCxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                "SP-GiST search temporary context",
-                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                               ALLOCSET_DEFAULT_SIZES);
 
        /* Set up indexTupDesc and xs_itupdesc in case it's an index-only scan */
        so->indexTupDesc = scan->xs_itupdesc = RelationGetDescr(rel);
index 01a4e0f2528b043ab3d210bebad2d0d103aa6d03..e016cdb4d3d6edded783bd42c43b76314f1a9f8a 100644 (file)
@@ -1014,9 +1014,7 @@ spg_xlog_startup(void)
 {
        opCtx = AllocSetContextCreate(CurrentMemoryContext,
                                                                  "SP-GiST temporary context",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
 }
 
 void
index 0c8c17af33c5b8321ccdea64367bae55923a317b..e9588a7f69d6a2994eac699ca4f1f8c4e9a852b7 100644 (file)
@@ -1570,10 +1570,8 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members)
                /* The cache only lives as long as the current transaction */
                debug_elog2(DEBUG2, "CachePut: initializing memory context");
                MXactContext = AllocSetContextCreate(TopTransactionContext,
-                                                                                        "MultiXact Cache Context",
-                                                                                        ALLOCSET_SMALL_MINSIZE,
-                                                                                        ALLOCSET_SMALL_INITSIZE,
-                                                                                        ALLOCSET_SMALL_MAXSIZE);
+                                                                                        "MultiXact cache context",
+                                                                                        ALLOCSET_SMALL_SIZES);
        }
 
        entry = (mXactCacheEnt *)
index 949bfb8b3e6e3f5fb4c702d0fcf5792bc540b5e3..cde0ed300f7130c396640d8c496519ff191be432 100644 (file)
@@ -722,10 +722,8 @@ HandleParallelMessages(void)
         */
        if (hpm_context == NULL)        /* first time through? */
                hpm_context = AllocSetContextCreate(TopMemoryContext,
-                                                                                       "HandleParallelMessages context",
-                                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                       "HandleParallelMessages",
+                                                                                       ALLOCSET_DEFAULT_SIZES);
        else
                MemoryContextReset(hpm_context);
 
@@ -962,10 +960,8 @@ ParallelWorkerMain(Datum main_arg)
        Assert(CurrentResourceOwner == NULL);
        CurrentResourceOwner = ResourceOwnerCreate(NULL, "parallel toplevel");
        CurrentMemoryContext = AllocSetContextCreate(TopMemoryContext,
-                                                                                                "parallel worker",
-                                                                                                ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                "Parallel worker",
+                                                                                                ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Now that we have a resource owner, we can attach to the dynamic shared
index 23f36ead7e54e86d0ef1e33a63aa60ade10f8b8f..e11b2297921447986000d37e2f27514d8150861d 100644 (file)
@@ -1018,9 +1018,7 @@ AtStart_Memory(void)
        TopTransactionContext =
                AllocSetContextCreate(TopMemoryContext,
                                                          "TopTransactionContext",
-                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                         ALLOCSET_DEFAULT_SIZES);
 
        /*
         * In a top-level transaction, CurTransactionContext is the same as
@@ -1078,9 +1076,7 @@ AtSubStart_Memory(void)
         */
        CurTransactionContext = AllocSetContextCreate(CurTransactionContext,
                                                                                                  "CurTransactionContext",
-                                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                 ALLOCSET_DEFAULT_SIZES);
        s->curTransactionContext = CurTransactionContext;
 
        /* Make the CurTransactionContext active. */
index f13f9c1fa5e271709a137d517533284c84253afd..acd95aa740817c0c44a5fe940a4b8bcf330c8ade 100644 (file)
@@ -4663,9 +4663,7 @@ XLOGShmemInit(void)
        {
                walDebugCxt = AllocSetContextCreate(TopMemoryContext,
                                                                                        "WAL Debug",
-                                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                       ALLOCSET_DEFAULT_SIZES);
                MemoryContextAllowInCriticalSection(walDebugCxt, true);
        }
 #endif
index c37003a24c2672deadcc72de2c5ee43ff74e601f..3cd273b19f2c26e15fc439a782cbf9110a2b3024 100644 (file)
@@ -997,9 +997,7 @@ InitXLogInsert(void)
        {
                xloginsert_cxt = AllocSetContextCreate(TopMemoryContext,
                                                                                           "WAL record construction",
-                                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                          ALLOCSET_DEFAULT_SIZES);
        }
 
        if (registered_buffers == NULL)
index e518e178bb4b43958a929aa0b998f09d92f5a1b6..8feeae05dfbe6b4d61ad2aa26939f625c894ce46 100644 (file)
@@ -1069,9 +1069,7 @@ index_register(Oid heap,
        if (nogc == NULL)
                nogc = AllocSetContextCreate(NULL,
                                                                         "BootstrapNoGC",
-                                                                        ALLOCSET_DEFAULT_MINSIZE,
-                                                                        ALLOCSET_DEFAULT_INITSIZE,
-                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                        ALLOCSET_DEFAULT_SIZES);
 
        oldcxt = MemoryContextSwitchTo(nogc);
 
index 8068b82eab892078bd3d42db778cb8d8c9d0753b..9aa81748ba7a0764ae5eeb2a8c4e831cf0de5660 100644 (file)
@@ -4747,9 +4747,7 @@ strlist_to_textarray(List *list)
 
        memcxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                   "strlist to array",
-                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                  ALLOCSET_DEFAULT_SIZES);
        oldcxt = MemoryContextSwitchTo(memcxt);
 
        datums = palloc(sizeof(text *) * list_length(list));
index 9ac71220a2ac7f7d1fad73e0e792de729f2097d7..c617abb223b07e2ee430e81861896213f6efdd36 100644 (file)
@@ -332,9 +332,7 @@ do_analyze_rel(Relation onerel, int options, VacuumParams *params,
         */
        anl_context = AllocSetContextCreate(CurrentMemoryContext,
                                                                                "Analyze",
-                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                               ALLOCSET_DEFAULT_SIZES);
        caller_context = MemoryContextSwitchTo(anl_context);
 
        /*
@@ -504,9 +502,7 @@ do_analyze_rel(Relation onerel, int options, VacuumParams *params,
 
                col_context = AllocSetContextCreate(anl_context,
                                                                                        "Analyze Column",
-                                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                       ALLOCSET_DEFAULT_SIZES);
                old_context = MemoryContextSwitchTo(col_context);
 
                for (i = 0; i < attr_cnt; i++)
@@ -688,9 +684,7 @@ compute_index_stats(Relation onerel, double totalrows,
 
        ind_context = AllocSetContextCreate(anl_context,
                                                                                "Analyze Index",
-                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                               ALLOCSET_DEFAULT_SIZES);
        old_context = MemoryContextSwitchTo(ind_context);
 
        for (ind = 0; ind < nindexes; ind++)
index 43bbd9059197379a3ba922dd516021644db5af5a..dc1f79f5948965e8ed5363daab0ee85bad286d80 100644 (file)
@@ -204,9 +204,7 @@ cluster(ClusterStmt *stmt, bool isTopLevel)
                 */
                cluster_context = AllocSetContextCreate(PortalContext,
                                                                                                "Cluster",
-                                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                               ALLOCSET_DEFAULT_SIZES);
 
                /*
                 * Build the list of relations to cluster.  Note that this lives in
index f45b3304ae9a459f3b0461ec418ec999247cb0f3..5947e7209342aa4e68e6e7802f2bf8310d058b7e 100644 (file)
@@ -1340,9 +1340,7 @@ BeginCopy(bool is_from,
         */
        cstate->copycontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                                                "COPY",
-                                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                               ALLOCSET_DEFAULT_SIZES);
 
        oldcontext = MemoryContextSwitchTo(cstate->copycontext);
 
@@ -1895,9 +1893,7 @@ CopyTo(CopyState cstate)
         */
        cstate->rowcontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                                           "COPY TO",
-                                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                          ALLOCSET_DEFAULT_SIZES);
 
        if (cstate->binary)
        {
index 50c89b827b2dc5f7d3f2be6042833dcaa0f3d06b..ac4c4ecbe77ef0be5d03c55d872a1512cea8520b 100644 (file)
@@ -1018,9 +1018,7 @@ EventTriggerInvoke(List *fn_oid_list, EventTriggerData *trigdata)
         */
        context = AllocSetContextCreate(CurrentMemoryContext,
                                                                        "event trigger context",
-                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                       ALLOCSET_DEFAULT_SIZES);
        oldcontext = MemoryContextSwitchTo(context);
 
        /* Call each event trigger. */
@@ -1226,9 +1224,7 @@ EventTriggerBeginCompleteQuery(void)
 
        cxt = AllocSetContextCreate(TopMemoryContext,
                                                                "event trigger state",
-                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                               ALLOCSET_DEFAULT_SIZES);
        state = MemoryContextAlloc(cxt, sizeof(EventTriggerQueryState));
        state->cxt = cxt;
        slist_init(&(state->SQLDropList));
index d14d540b26e0d706126da5575295aa903dcfc26c..85817c6530252dc0b2bc361a6342eb943f7e6678 100644 (file)
@@ -1903,9 +1903,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
         */
        private_context = AllocSetContextCreate(PortalContext,
                                                                                        "ReindexMultipleTables",
-                                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                       ALLOCSET_SMALL_SIZES);
 
        /*
         * Define the search keys to find the objects to reindex. For a schema, we
index bc2e4af82a35edbc22991d5a0d64727ec8861eae..d694cf80be3a1c109ecf1d48b893b19ed8d4a1d7 100644 (file)
@@ -201,9 +201,7 @@ RelationBuildRowSecurity(Relation relation)
         */
        rscxt = AllocSetContextCreate(CacheMemoryContext,
                                                                  "row security descriptor",
-                                                                 ALLOCSET_SMALL_MINSIZE,
-                                                                 ALLOCSET_SMALL_INITSIZE,
-                                                                 ALLOCSET_SMALL_MAXSIZE);
+                                                                 ALLOCSET_SMALL_SIZES);
 
        /*
         * Since rscxt lives under CacheMemoryContext, it is long-lived.  Use a
index 99a659a10270a4b448c91d6979215d33ca9c396d..9de22a13d75c05128fe39e934ca7cefec65c4ae7 100644 (file)
@@ -3339,9 +3339,7 @@ afterTriggerAddEvent(AfterTriggerEventList *events,
                        afterTriggers.event_cxt =
                                AllocSetContextCreate(TopTransactionContext,
                                                                          "AfterTriggerEvents",
-                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                         ALLOCSET_DEFAULT_SIZES);
 
                /*
                 * Chunk size starts at 1KB and is allowed to increase up to 1MB.
@@ -3780,9 +3778,7 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events,
        per_tuple_context =
                AllocSetContextCreate(CurrentMemoryContext,
                                                          "AfterTriggerTupleContext",
-                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                         ALLOCSET_DEFAULT_SIZES);
 
        for_each_chunk(chunk, *events)
        {
index 0563e6347430d43c6cd5d4be5c8456fcc3406946..58bbf5548bc9c7336392c807f22ede81d0376380 100644 (file)
@@ -209,9 +209,7 @@ vacuum(int options, RangeVar *relation, Oid relid, VacuumParams *params,
         */
        vac_context = AllocSetContextCreate(PortalContext,
                                                                                "Vacuum",
-                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                               ALLOCSET_DEFAULT_SIZES);
 
        /*
         * If caller didn't give us a buffer strategy object, make one in the
index e937cf8e7e2c4b1f6f131389ecb069e343f739be..a3bcb100daddafc6e8983a35ef83bfea316483bb 100644 (file)
@@ -80,9 +80,7 @@ CreateExecutorState(void)
         */
        qcontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                         "ExecutorState",
-                                                                        ALLOCSET_DEFAULT_MINSIZE,
-                                                                        ALLOCSET_DEFAULT_INITSIZE,
-                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                        ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Make the EState node within the per-query context.  This way, we don't
@@ -229,9 +227,7 @@ CreateExprContext(EState *estate)
        econtext->ecxt_per_tuple_memory =
                AllocSetContextCreate(estate->es_query_cxt,
                                                          "ExprContext",
-                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                         ALLOCSET_DEFAULT_SIZES);
 
        econtext->ecxt_param_exec_vals = estate->es_param_exec_vals;
        econtext->ecxt_param_list_info = estate->es_param_list_info;
@@ -300,9 +296,7 @@ CreateStandaloneExprContext(void)
        econtext->ecxt_per_tuple_memory =
                AllocSetContextCreate(CurrentMemoryContext,
                                                          "ExprContext",
-                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                         ALLOCSET_DEFAULT_SIZES);
 
        econtext->ecxt_param_exec_vals = NULL;
        econtext->ecxt_param_list_info = NULL;
index e02fba52329101f3b360fc3453b99b56e7924d4a..470db5bb4aa6ba5a1a5c965a47b5ec91a1c32627 100644 (file)
@@ -600,9 +600,7 @@ init_sql_fcache(FmgrInfo *finfo, Oid collation, bool lazyEvalOK)
         */
        fcontext = AllocSetContextCreate(finfo->fn_mcxt,
                                                                         "SQL function data",
-                                                                        ALLOCSET_DEFAULT_MINSIZE,
-                                                                        ALLOCSET_DEFAULT_INITSIZE,
-                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                        ALLOCSET_DEFAULT_SIZES);
 
        oldcontext = MemoryContextSwitchTo(fcontext);
 
index a03f6e73fd28c941624635c664b60b0f72d300ca..5a0f324de0aaa824fc76f33fcb27dc8c2db41574 100644 (file)
@@ -508,9 +508,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, int eflags)
         */
        scanstate->argcontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                                                  "Table function arguments",
-                                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                 ALLOCSET_DEFAULT_SIZES);
 
        return scanstate;
 }
index 9ed09a7b0ca206d5bb54b79b9270ea09f2eadc25..6375d9bfda7ee2818fe59540d1c24be21e49be40 100644 (file)
@@ -344,15 +344,11 @@ ExecHashTableCreate(Hash *node, List *hashOperators, bool keepNulls)
         */
        hashtable->hashCxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                           "HashTableContext",
-                                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                          ALLOCSET_DEFAULT_SIZES);
 
        hashtable->batchCxt = AllocSetContextCreate(hashtable->hashCxt,
                                                                                                "HashBatchContext",
-                                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                               ALLOCSET_DEFAULT_SIZES);
 
        /* Allocate data that will live for the life of the hashjoin */
 
index e76405a56e1fc8eadf602037ed0d651d905086fe..39be191c45b0459b0f7ddb3e2360fb0f32804a67 100644 (file)
@@ -200,15 +200,11 @@ ExecInitRecursiveUnion(RecursiveUnion *node, EState *estate, int eflags)
                rustate->tempContext =
                        AllocSetContextCreate(CurrentMemoryContext,
                                                                  "RecursiveUnion",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
                rustate->tableContext =
                        AllocSetContextCreate(CurrentMemoryContext,
                                                                  "RecursiveUnion hash table",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
        }
 
        /*
index 2d81d46927f5b974fcefbd57062adb8361ea7db0..633580b4362af9b9dd9efd01510b2cc1f94dbca2 100644 (file)
@@ -507,9 +507,7 @@ ExecInitSetOp(SetOp *node, EState *estate, int eflags)
        setopstate->tempContext =
                AllocSetContextCreate(CurrentMemoryContext,
                                                          "SetOp",
-                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                         ALLOCSET_DEFAULT_SIZES);
 
        /*
         * If hashing, we also need a longer-lived context to store the hash
@@ -520,9 +518,7 @@ ExecInitSetOp(SetOp *node, EState *estate, int eflags)
                setopstate->tableContext =
                        AllocSetContextCreate(CurrentMemoryContext,
                                                                  "SetOp hash table",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Tuple table initialization
index e503494edd146c20b8d4404207b7a6c18112eb73..2cf169f956620c5720c8d0a29c6f1f7b205b309e 100644 (file)
@@ -776,16 +776,12 @@ ExecInitSubPlan(SubPlan *subplan, PlanState *parent)
                sstate->hashtablecxt =
                        AllocSetContextCreate(CurrentMemoryContext,
                                                                  "Subplan HashTable Context",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
                /* and a small one for the hash tables to use as temp storage */
                sstate->hashtempcxt =
                        AllocSetContextCreate(CurrentMemoryContext,
                                                                  "Subplan HashTable Temp Context",
-                                                                 ALLOCSET_SMALL_MINSIZE,
-                                                                 ALLOCSET_SMALL_INITSIZE,
-                                                                 ALLOCSET_SMALL_MAXSIZE);
+                                                                 ALLOCSET_SMALL_SIZES);
                /* and a short-lived exprcontext for function evaluation */
                sstate->innerecontext = CreateExprContext(estate);
                /* Silly little array of column numbers 1..n */
index 4caae34b9743ce8722396f990c4212f42fa8b59d..f45c79232dfa6f15a02ad68ff0a00bceac85ea85 100644 (file)
@@ -133,9 +133,7 @@ ExecInitUnique(Unique *node, EState *estate, int eflags)
        uniquestate->tempContext =
                AllocSetContextCreate(CurrentMemoryContext,
                                                          "Unique",
-                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                         ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Tuple table initialization
index d4c88a1f0efdcda2fda12d06f1eee2bd87433706..371548ceb39079af2a082b78bd33fa8b6b6edea3 100644 (file)
@@ -1801,10 +1801,8 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
        /* Create long-lived context for storage of partition-local memory etc */
        winstate->partcontext =
                AllocSetContextCreate(CurrentMemoryContext,
-                                                         "WindowAgg_Partition",
-                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                         "WindowAgg Partition",
+                                                         ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Create mid-lived context for aggregate trans values etc.
@@ -1814,10 +1812,8 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
         */
        winstate->aggcontext =
                AllocSetContextCreate(CurrentMemoryContext,
-                                                         "WindowAgg_Aggregates",
-                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                         "WindowAgg Aggregates",
+                                                         ALLOCSET_DEFAULT_SIZES);
 
        /*
         * tuple table initialization
@@ -2321,10 +2317,8 @@ initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc,
        if (OidIsValid(invtransfn_oid))
                peraggstate->aggcontext =
                        AllocSetContextCreate(CurrentMemoryContext,
-                                                                 "WindowAgg_AggregatePrivate",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 "WindowAgg Per Aggregate",
+                                                                 ALLOCSET_DEFAULT_SIZES);
        else
                peraggstate->aggcontext = winstate->aggcontext;
 
index 38de18006de49affdb79e63b5506a593e84b4088..38767ae4cedc7dabc80cd08f3f49e8620d1ba65d 100644 (file)
@@ -142,14 +142,10 @@ SPI_connect(void)
         */
        _SPI_current->procCxt = AllocSetContextCreate(TopTransactionContext,
                                                                                                  "SPI Proc",
-                                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                 ALLOCSET_DEFAULT_SIZES);
        _SPI_current->execCxt = AllocSetContextCreate(TopTransactionContext,
                                                                                                  "SPI Exec",
-                                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                 ALLOCSET_DEFAULT_SIZES);
        /* ... and switch to procedure's context */
        _SPI_current->savedcxt = MemoryContextSwitchTo(_SPI_current->procCxt);
 
@@ -1744,9 +1740,7 @@ spi_dest_startup(DestReceiver *self, int operation, TupleDesc typeinfo)
 
        tuptabcxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                          "SPI TupTable",
-                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                         ALLOCSET_DEFAULT_SIZES);
        MemoryContextSwitchTo(tuptabcxt);
 
        _SPI_current->tuptable = tuptable = (SPITupleTable *)
@@ -2615,14 +2609,11 @@ _SPI_make_plan_non_temp(SPIPlanPtr plan)
 
        /*
         * Create a memory context for the plan, underneath the procedure context.
-        * We don't expect the plan to be very large, so use smaller-than-default
-        * alloc parameters.
+        * We don't expect the plan to be very large.
         */
        plancxt = AllocSetContextCreate(parentcxt,
                                                                        "SPI Plan",
-                                                                       ALLOCSET_SMALL_MINSIZE,
-                                                                       ALLOCSET_SMALL_INITSIZE,
-                                                                       ALLOCSET_SMALL_MAXSIZE);
+                                                                       ALLOCSET_SMALL_SIZES);
        oldcxt = MemoryContextSwitchTo(plancxt);
 
        /* Copy the SPI_plan struct and subsidiary data into the new context */
@@ -2689,9 +2680,7 @@ _SPI_save_plan(SPIPlanPtr plan)
         */
        plancxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                        "SPI Plan",
-                                                                       ALLOCSET_SMALL_MINSIZE,
-                                                                       ALLOCSET_SMALL_INITSIZE,
-                                                                       ALLOCSET_SMALL_MAXSIZE);
+                                                                       ALLOCSET_SMALL_SIZES);
        oldcxt = MemoryContextSwitchTo(plancxt);
 
        /* Copy the SPI plan into its own context */
index 58d0eeaf0ba85d09139d11128e27f53dcbacc35d..344e623c94261de4f3f1eb1518fe45760e47c347 100644 (file)
@@ -281,9 +281,7 @@ tqueueReceiveSlot(TupleTableSlot *slot, DestReceiver *self)
                                        tqueue->tmpcontext =
                                                AllocSetContextCreate(tqueue->mycontext,
                                                                                          "tqueue sender temp context",
-                                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         ALLOCSET_DEFAULT_SIZES);
                                oldcontext = MemoryContextSwitchTo(tqueue->tmpcontext);
                        }
 
index b64ef8b5c4c2139c5b3d0bbba323ff3108f73048..764f602aaa23f53b0e833f5cc33823c3e2e19f9b 100644 (file)
@@ -79,9 +79,7 @@ static MemoryContext fscxt = NULL;
                if (fscxt == NULL) \
                        fscxt = AllocSetContextCreate(TopMemoryContext, \
                                                                                  "Filesystem", \
-                                                                                 ALLOCSET_DEFAULT_MINSIZE, \
-                                                                                 ALLOCSET_DEFAULT_INITSIZE, \
-                                                                                 ALLOCSET_DEFAULT_MAXSIZE); \
+                                                                                 ALLOCSET_DEFAULT_SIZES); \
        } while (0)
 
 
index 1b4bbce42dd0849868b22a34fa5ddc226c7047e0..d612c11159ee966bcd16f6bd59dba21e589aecb4 100644 (file)
@@ -387,10 +387,8 @@ tokenize_file(const char *filename, FILE *file,
        MemoryContext oldcxt;
 
        linecxt = AllocSetContextCreate(CurrentMemoryContext,
-                                                                       "tokenize file cxt",
-                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                       "tokenize_file",
+                                                                       ALLOCSET_SMALL_SIZES);
        oldcxt = MemoryContextSwitchTo(linecxt);
 
        *lines = *line_nums = NIL;
@@ -1817,9 +1815,7 @@ load_hba(void)
        Assert(PostmasterContext);
        hbacxt = AllocSetContextCreate(PostmasterContext,
                                                                   "hba parser context",
-                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                  ALLOCSET_SMALL_SIZES);
        oldcxt = MemoryContextSwitchTo(hbacxt);
        forthree(line, hba_lines, line_num, hba_line_nums, raw_line, hba_raw_lines)
        {
@@ -2195,9 +2191,7 @@ load_ident(void)
        Assert(PostmasterContext);
        ident_context = AllocSetContextCreate(PostmasterContext,
                                                                                  "ident parser context",
-                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                 ALLOCSET_SMALL_SIZES);
        oldcxt = MemoryContextSwitchTo(ident_context);
        forboth(line_cell, ident_lines, num_cell, ident_line_nums)
        {
index 88acebc1f2d28b403f6c13deca913467d56b4202..fb2ab77422d90fdc7bf479bdd1c0809c386de653 100644 (file)
@@ -74,9 +74,7 @@ geqo_eval(PlannerInfo *root, Gene *tour, int num_gene)
         */
        mycontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                          "GEQO",
-                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                         ALLOCSET_DEFAULT_SIZES);
        oldcxt = MemoryContextSwitchTo(mycontext);
 
        /*
index 4496fde056d580ae27266149d395111652cd605e..e1baf71e383dfaa96977d4602c5c0ba98d31baf7 100644 (file)
@@ -4378,9 +4378,7 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid,
         */
        mycxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                  "inline_function",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
        oldcxt = MemoryContextSwitchTo(mycxt);
 
        /* Fetch the function body */
@@ -4896,9 +4894,7 @@ inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte)
         */
        mycxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                  "inline_set_returning_function",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
        oldcxt = MemoryContextSwitchTo(mycxt);
 
        /*
index 3768f50bcf3aa2b2700c2e586e117d1ff3465399..1a92ca1deb7916273684828dcad4aafafcb2a1fd 100644 (file)
@@ -462,9 +462,7 @@ AutoVacLauncherMain(int argc, char *argv[])
         */
        AutovacMemCxt = AllocSetContextCreate(TopMemoryContext,
                                                                                  "Autovacuum Launcher",
-                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                 ALLOCSET_DEFAULT_SIZES);
        MemoryContextSwitchTo(AutovacMemCxt);
 
        /*
@@ -894,14 +892,10 @@ rebuild_database_list(Oid newdb)
 
        newcxt = AllocSetContextCreate(AutovacMemCxt,
                                                                   "AV dblist",
-                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                  ALLOCSET_DEFAULT_SIZES);
        tmpcxt = AllocSetContextCreate(newcxt,
                                                                   "tmp AV dblist",
-                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                  ALLOCSET_DEFAULT_SIZES);
        oldcxt = MemoryContextSwitchTo(tmpcxt);
 
        /*
@@ -1111,9 +1105,7 @@ do_start_worker(void)
         */
        tmpcxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                   "Start worker tmp cxt",
-                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                  ALLOCSET_DEFAULT_SIZES);
        oldcxt = MemoryContextSwitchTo(tmpcxt);
 
        /* use fresh stats */
@@ -1911,9 +1903,7 @@ do_autovacuum(void)
         */
        AutovacMemCxt = AllocSetContextCreate(TopMemoryContext,
                                                                                  "AV worker",
-                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                 ALLOCSET_DEFAULT_SIZES);
        MemoryContextSwitchTo(AutovacMemCxt);
 
        /*
@@ -2183,9 +2173,7 @@ do_autovacuum(void)
         */
        PortalContext = AllocSetContextCreate(AutovacMemCxt,
                                                                                  "Autovacuum Portal",
-                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                 ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Perform operations on collected tables.
index 00f03d8acbe7ba54b4fc91aa28c80f2c508850fb..10020349a2c0dccc3c183617d44b387c5a8cc8fb 100644 (file)
@@ -160,9 +160,7 @@ BackgroundWriterMain(void)
         */
        bgwriter_context = AllocSetContextCreate(TopMemoryContext,
                                                                                         "Background Writer",
-                                                                                        ALLOCSET_DEFAULT_MINSIZE,
-                                                                                        ALLOCSET_DEFAULT_INITSIZE,
-                                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                        ALLOCSET_DEFAULT_SIZES);
        MemoryContextSwitchTo(bgwriter_context);
 
        WritebackContextInit(&wb_context, &bgwriter_flush_after);
index 8d4b3539b1ec8f5d901f8fa4d8d05bf92c4aff67..d702a4864d6b3ac2895cbf08c812ddf3c1a9014a 100644 (file)
@@ -245,9 +245,7 @@ CheckpointerMain(void)
         */
        checkpointer_context = AllocSetContextCreate(TopMemoryContext,
                                                                                                 "Checkpointer",
-                                                                                                ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                ALLOCSET_DEFAULT_SIZES);
        MemoryContextSwitchTo(checkpointer_context);
 
        /*
index 8fa9edbf7293799c67be691950a3bc99a03dbe67..2f99aea7912a6865ee0fd06f60b4add851ad07d2 100644 (file)
@@ -4792,9 +4792,7 @@ pgstat_setup_memcxt(void)
        if (!pgStatLocalContext)
                pgStatLocalContext = AllocSetContextCreate(TopMemoryContext,
                                                                                                   "Statistics snapshot",
-                                                                                                  ALLOCSET_SMALL_MINSIZE,
-                                                                                                  ALLOCSET_SMALL_INITSIZE,
-                                                                                                  ALLOCSET_SMALL_MAXSIZE);
+                                                                                                  ALLOCSET_SMALL_SIZES);
 }
 
 
index 05f3f14e35bb11e60bbbcc4b13e613c36782aee9..a28e215e2d71f0cf65e06c21cf6fe2977c2ab020 100644 (file)
@@ -583,9 +583,7 @@ PostmasterMain(int argc, char *argv[])
         */
        PostmasterContext = AllocSetContextCreate(TopMemoryContext,
                                                                                          "Postmaster",
-                                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         ALLOCSET_DEFAULT_SIZES);
        MemoryContextSwitchTo(PostmasterContext);
 
        /* Initialize paths to installation files */
index 228190a836d52e59ed0f9aef0a578d4c0f906c29..11ec56aebbef9f85cb74f67b74341011fdd55491 100644 (file)
@@ -142,9 +142,7 @@ WalWriterMain(void)
         */
        walwriter_context = AllocSetContextCreate(TopMemoryContext,
                                                                                          "Wal Writer",
-                                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         ALLOCSET_DEFAULT_SIZES);
        MemoryContextSwitchTo(walwriter_context);
 
        /*
index ecf9a03318044a438b6549a7555faf1b0c723603..1512be5322c254b7913815eab81fd0256ba1f838 100644 (file)
@@ -127,10 +127,8 @@ StartupDecodingContext(List *output_plugin_options,
        slot = MyReplicationSlot;
 
        context = AllocSetContextCreate(CurrentMemoryContext,
-                                                                       "Logical Decoding Context",
-                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                       "Logical decoding context",
+                                                                       ALLOCSET_DEFAULT_SIZES);
        old_context = MemoryContextSwitchTo(context);
        ctx = palloc0(sizeof(LogicalDecodingContext));
 
index 213ce34674ced87e1c010ed617e4458cee975668..43b584cf7e2d771dc697590de0438d22e926c795 100644 (file)
@@ -232,9 +232,7 @@ ReorderBufferAllocate(void)
        /* allocate memory in own context, to have better accountability */
        new_ctx = AllocSetContextCreate(CurrentMemoryContext,
                                                                        "ReorderBuffer",
-                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                       ALLOCSET_DEFAULT_SIZES);
 
        buffer =
                (ReorderBuffer *) MemoryContextAlloc(new_ctx, sizeof(ReorderBuffer));
@@ -2317,7 +2315,7 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn,
 
        if (write(fd, rb->outbuf, ondisk->size) != ondisk->size)
        {
-               int save_errno = errno;
+               int                     save_errno = errno;
 
                CloseTransientFile(fd);
                errno = save_errno;
index b5fa3dbbc0bb7a4be872087933fb386348a88477..8b59fc5a16a15cabac8816edb44215824dd92bf2 100644 (file)
@@ -289,9 +289,7 @@ AllocateSnapshotBuilder(ReorderBuffer *reorder,
        /* allocate memory in own context, to have better accountability */
        context = AllocSetContextCreate(CurrentMemoryContext,
                                                                        "snapshot builder context",
-                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                       ALLOCSET_DEFAULT_SIZES);
        oldcontext = MemoryContextSwitchTo(context);
 
        builder = palloc0(sizeof(SnapBuild));
index a0dba194a615b38bac046d66e76b800a244808c7..1ea2a5cfdf1225d1ab781a227a713c8f96ad6f62 100644 (file)
@@ -1309,9 +1309,7 @@ exec_replication_command(const char *cmd_string)
 
        cmd_context = AllocSetContextCreate(CurrentMemoryContext,
                                                                                "Replication command context",
-                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                               ALLOCSET_DEFAULT_SIZES);
        old_context = MemoryContextSwitchTo(cmd_context);
 
        replication_scanner_init(cmd_string);
index 53981794b98c7b803a5cbe8c8ad39d9b90008f8c..ca2388789d72fe08ecef846d37ed348fca08a005 100644 (file)
@@ -511,9 +511,7 @@ GetLocalBufferStorage(void)
                        LocalBufferContext =
                                AllocSetContextCreate(TopMemoryContext,
                                                                          "LocalBufferContext",
-                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                         ALLOCSET_DEFAULT_SIZES);
 
                /* Start with a 16-buffer request; subsequent ones double each time */
                num_bufs = Max(num_bufs_in_block * 2, 16);
index 7e8138b42adac156ac1811c57e7873a9f20f3248..6b98131e5433341272055b15b09d5ecd013cd112 100644 (file)
@@ -65,9 +65,7 @@ ResetUnloggedRelations(int op)
         */
        tmpctx = AllocSetContextCreate(CurrentMemoryContext,
                                                                   "ResetUnloggedRelations",
-                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                  ALLOCSET_DEFAULT_SIZES);
        oldctx = MemoryContextSwitchTo(tmpctx);
 
        /*
index 303e99c65b2b770b153e4c9fc6250cdbcf8f1643..53b45d72fe0ed14806c44871b936680bae34b766 100644 (file)
@@ -285,9 +285,7 @@ init_lwlock_stats(void)
         */
        lwlock_stats_cxt = AllocSetContextCreate(TopMemoryContext,
                                                                                         "LWLock stats",
-                                                                                        ALLOCSET_DEFAULT_MINSIZE,
-                                                                                        ALLOCSET_DEFAULT_INITSIZE,
-                                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                        ALLOCSET_DEFAULT_SIZES);
        MemoryContextAllowInCriticalSection(lwlock_stats_cxt, true);
 
        MemSet(&ctl, 0, sizeof(ctl));
index f329d1538c38297dfe6fd07a4c33b4812f6ea2b1..12871429182f4e4def28c9457e90aebd45fe020c 100644 (file)
@@ -208,9 +208,7 @@ mdinit(void)
 {
        MdCxt = AllocSetContextCreate(TopMemoryContext,
                                                                  "MdSmgr",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Create pending-operations hashtable if we need it.  Currently, we need
@@ -231,10 +229,8 @@ mdinit(void)
                 * practice.
                 */
                pendingOpsCxt = AllocSetContextCreate(MdCxt,
-                                                                                         "Pending Ops Context",
-                                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         "Pending ops context",
+                                                                                         ALLOCSET_DEFAULT_SIZES);
                MemoryContextAllowInCriticalSection(pendingOpsCxt, true);
 
                MemSet(&hash_ctl, 0, sizeof(hash_ctl));
index b185c1b5eb69fba2654b65a8b80bfe74f03ff600..98ccbbb4d1acf77d646732f2b067fd08b141c78a 100644 (file)
@@ -1253,9 +1253,7 @@ exec_parse_message(const char *query_string,      /* string to execute */
                unnamed_stmt_context =
                        AllocSetContextCreate(MessageContext,
                                                                  "unnamed prepared statement",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
                oldcontext = MemoryContextSwitchTo(unnamed_stmt_context);
        }
 
@@ -3794,9 +3792,7 @@ PostgresMain(int argc, char *argv[],
         */
        MessageContext = AllocSetContextCreate(TopMemoryContext,
                                                                                   "MessageContext",
-                                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                  ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Remember stand-alone backend startup time
index 821f611e4f8ee8f719c2c2e5db6667d56674dff0..9c7ba85eb559b35a156bf3a969da35e9b71de9bb 100644 (file)
@@ -92,9 +92,7 @@ NIStartBuild(IspellDict *Conf)
         */
        Conf->buildCxt = AllocSetContextCreate(CurTransactionContext,
                                                                                   "Ispell dictionary init context",
-                                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                  ALLOCSET_DEFAULT_SIZES);
 }
 
 /*
index 7dd7e3fbcbe56b6381cb20a1191e8f7ee3f08ba0..94eb19d45df990693f4928640e533b1f459e47ee 100644 (file)
@@ -63,9 +63,7 @@ expand_array(Datum arraydatum, MemoryContext parentcontext,
         */
        objcxt = AllocSetContextCreate(parentcontext,
                                                                   "expanded array",
-                                                                  ALLOCSET_SMALL_MINSIZE,
-                                                                  ALLOCSET_SMALL_INITSIZE,
-                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                  ALLOCSET_START_SMALL_SIZES);
 
        /* Set up expanded array header */
        eah = (ExpandedArrayHeader *)
index 8fbd85014694c82cd2dbdc48ef4b59380bcf1355..1db7bf0a35b0749f68399ede2a943ded3540d0df 100644 (file)
@@ -4957,9 +4957,7 @@ initArrayResult(Oid element_type, MemoryContext rcontext, bool subcontext)
        if (subcontext)
                arr_context = AllocSetContextCreate(rcontext,
                                                                                        "accumArrayResult",
-                                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                       ALLOCSET_DEFAULT_SIZES);
 
        astate = (ArrayBuildState *)
                MemoryContextAlloc(arr_context, sizeof(ArrayBuildState));
@@ -5161,9 +5159,7 @@ initArrayResultArr(Oid array_type, Oid element_type, MemoryContext rcontext,
        if (subcontext)
                arr_context = AllocSetContextCreate(rcontext,
                                                                                        "accumArrayResultArr",
-                                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                       ALLOCSET_DEFAULT_SIZES);
 
        /* Note we initialize all fields to zero */
        astate = (ArrayBuildStateArr *)
index a80a20eceead937737379546d07f0c43538f30d1..996007d4837d93aaae23d7b2970822c5800d4546 100644 (file)
@@ -1503,9 +1503,7 @@ each_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
 
        tmp_cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                        "jsonb_each temporary cxt",
-                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                       ALLOCSET_DEFAULT_SIZES);
 
        it = JsonbIteratorInit(&jb->root);
 
@@ -1641,9 +1639,7 @@ each_worker(FunctionCallInfo fcinfo, bool as_text)
        state->lex = lex;
        state->tmp_cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                   "json_each temporary cxt",
-                                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                  ALLOCSET_DEFAULT_SIZES);
 
        pg_parse_json(lex, sem);
 
@@ -1822,9 +1818,7 @@ elements_worker_jsonb(FunctionCallInfo fcinfo, const char *funcname,
 
        tmp_cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                        "jsonb_array_elements temporary cxt",
-                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                       ALLOCSET_DEFAULT_SIZES);
 
        it = JsonbIteratorInit(&jb->root);
 
@@ -1962,9 +1956,7 @@ elements_worker(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
        state->lex = lex;
        state->tmp_cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                 "json_array_elements temporary cxt",
-                                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                  ALLOCSET_DEFAULT_SIZES);
 
        pg_parse_json(lex, sem);
 
index 7ed5bcb93dd45bbb3c282913bc55110192371a1e..b144920ec65d02d00312b5e2621b6f1d7b6013e3 100644 (file)
@@ -1455,10 +1455,8 @@ xml_memory_init(void)
        /* Create memory context if not there already */
        if (LibxmlContext == NULL)
                LibxmlContext = AllocSetContextCreate(TopMemoryContext,
-                                                                                         "LibxmlContext",
-                                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         "Libxml context",
+                                                                                         ALLOCSET_DEFAULT_SIZES);
 
        /* Re-establish the callbacks even if already set */
        xmlMemSetup(xml_pfree, xml_palloc, xml_repalloc, xml_pstrdup);
index e929616c97e6ee79de41be79d7059d6b992d73a0..db7099fc0e9efdaad4e27a497552495ae725667f 100644 (file)
@@ -536,9 +536,7 @@ CreateCacheMemoryContext(void)
        if (!CacheMemoryContext)
                CacheMemoryContext = AllocSetContextCreate(TopMemoryContext,
                                                                                                   "CacheMemoryContext",
-                                                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                  ALLOCSET_DEFAULT_SIZES);
 }
 
 
index 6fc1df880b3bc75c675a56078cc257464cab91e6..8a620a51c8c83f2d6c08f832fc618a9c9fddc3b6 100644 (file)
@@ -105,9 +105,7 @@ BuildEventTriggerCache(void)
                EventTriggerCacheContext =
                        AllocSetContextCreate(CacheMemoryContext,
                                                                  "EventTriggerCache",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
                CacheRegisterSyscacheCallback(EVENTTRIGGEROID,
                                                                          InvalidateEventCacheCallback,
                                                                          (Datum) 0);
index f42a62d5000c0e2c6de311d9bd53496b468fa823..c96a86500adc46920c07470f8eef15016c6cee7c 100644 (file)
@@ -159,15 +159,13 @@ CreateCachedPlan(Node *raw_parse_tree,
        /*
         * Make a dedicated memory context for the CachedPlanSource and its
         * permanent subsidiary data.  It's probably not going to be large, but
-        * just in case, use the default maxsize parameter.  Initially it's a
-        * child of the caller's context (which we assume to be transient), so
-        * that it will be cleaned up on error.
+        * just in case, allow it to grow large.  Initially it's a child of the
+        * caller's context (which we assume to be transient), so that it will be
+        * cleaned up on error.
         */
        source_context = AllocSetContextCreate(CurrentMemoryContext,
                                                                                   "CachedPlanSource",
-                                                                                  ALLOCSET_SMALL_MINSIZE,
-                                                                                  ALLOCSET_SMALL_INITSIZE,
-                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                  ALLOCSET_START_SMALL_SIZES);
 
        /*
         * Create and fill the CachedPlanSource struct within the new context.
@@ -359,9 +357,7 @@ CompleteCachedPlan(CachedPlanSource *plansource,
                /* Again, it's a good bet the querytree_context can be small */
                querytree_context = AllocSetContextCreate(source_context,
                                                                                                  "CachedPlanQuery",
-                                                                                                 ALLOCSET_SMALL_MINSIZE,
-                                                                                                 ALLOCSET_SMALL_INITSIZE,
-                                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                 ALLOCSET_START_SMALL_SIZES);
                MemoryContextSwitchTo(querytree_context);
                querytree_list = (List *) copyObject(querytree_list);
        }
@@ -733,9 +729,7 @@ RevalidateCachedQuery(CachedPlanSource *plansource)
         */
        querytree_context = AllocSetContextCreate(CurrentMemoryContext,
                                                                                          "CachedPlanQuery",
-                                                                                         ALLOCSET_SMALL_MINSIZE,
-                                                                                         ALLOCSET_SMALL_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         ALLOCSET_START_SMALL_SIZES);
        oldcxt = MemoryContextSwitchTo(querytree_context);
 
        qlist = (List *) copyObject(tlist);
@@ -955,17 +949,14 @@ BuildCachedPlan(CachedPlanSource *plansource, List *qlist,
        /*
         * Normally we make a dedicated memory context for the CachedPlan and its
         * subsidiary data.  (It's probably not going to be large, but just in
-        * case, use the default maxsize parameter.  It's transient for the
-        * moment.)  But for a one-shot plan, we just leave it in the caller's
-        * memory context.
+        * case, allow it to grow large.  It's transient for the moment.)  But for
+        * a one-shot plan, we just leave it in the caller's memory context.
         */
        if (!plansource->is_oneshot)
        {
                plan_context = AllocSetContextCreate(CurrentMemoryContext,
                                                                                         "CachedPlan",
-                                                                                        ALLOCSET_SMALL_MINSIZE,
-                                                                                        ALLOCSET_SMALL_INITSIZE,
-                                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                        ALLOCSET_START_SMALL_SIZES);
 
                /*
                 * Copy plan into the new context.
@@ -1351,9 +1342,7 @@ CopyCachedPlan(CachedPlanSource *plansource)
 
        source_context = AllocSetContextCreate(CurrentMemoryContext,
                                                                                   "CachedPlanSource",
-                                                                                  ALLOCSET_SMALL_MINSIZE,
-                                                                                  ALLOCSET_SMALL_INITSIZE,
-                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                  ALLOCSET_START_SMALL_SIZES);
 
        oldcxt = MemoryContextSwitchTo(source_context);
 
@@ -1384,9 +1373,7 @@ CopyCachedPlan(CachedPlanSource *plansource)
 
        querytree_context = AllocSetContextCreate(source_context,
                                                                                          "CachedPlanQuery",
-                                                                                         ALLOCSET_SMALL_MINSIZE,
-                                                                                         ALLOCSET_SMALL_INITSIZE,
-                                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                         ALLOCSET_START_SMALL_SIZES);
        MemoryContextSwitchTo(querytree_context);
        newsource->query_list = (List *) copyObject(plansource->query_list);
        newsource->relationOids = (List *) copyObject(plansource->relationOids);
index 8d2ad018bbfb261277816dece6506b5a89785822..79e0b1ff483008a5dd7a9f302feb4af461b4ee93 100644 (file)
@@ -659,14 +659,11 @@ RelationBuildRuleLock(Relation relation)
        int                     maxlocks;
 
        /*
-        * Make the private context.  Parameters are set on the assumption that
-        * it'll probably not contain much data.
+        * Make the private context.  Assume it'll not contain much data.
         */
        rulescxt = AllocSetContextCreate(CacheMemoryContext,
                                                                         RelationGetRelationName(relation),
-                                                                        ALLOCSET_SMALL_MINSIZE,
-                                                                        ALLOCSET_SMALL_INITSIZE,
-                                                                        ALLOCSET_SMALL_MAXSIZE);
+                                                                        ALLOCSET_SMALL_SIZES);
        relation->rd_rulescxt = rulescxt;
 
        /*
@@ -1248,15 +1245,10 @@ RelationInitIndexAccessInfo(Relation relation)
         * Make the private context to hold index access info.  The reason we need
         * a context, and not just a couple of pallocs, is so that we won't leak
         * any subsidiary info attached to fmgr lookup records.
-        *
-        * Context parameters are set on the assumption that it'll probably not
-        * contain much data.
         */
        indexcxt = AllocSetContextCreate(CacheMemoryContext,
                                                                         RelationGetRelationName(relation),
-                                                                        ALLOCSET_SMALL_MINSIZE,
-                                                                        ALLOCSET_SMALL_INITSIZE,
-                                                                        ALLOCSET_SMALL_MAXSIZE);
+                                                                        ALLOCSET_SMALL_SIZES);
        relation->rd_indexcxt = indexcxt;
 
        /*
@@ -4948,9 +4940,7 @@ load_relcache_init_file(bool shared)
                         */
                        indexcxt = AllocSetContextCreate(CacheMemoryContext,
                                                                                         RelationGetRelationName(rel),
-                                                                                        ALLOCSET_SMALL_MINSIZE,
-                                                                                        ALLOCSET_SMALL_INITSIZE,
-                                                                                        ALLOCSET_SMALL_MAXSIZE);
+                                                                                        ALLOCSET_SMALL_SIZES);
                        rel->rd_indexcxt = indexcxt;
 
                        /*
index 5e4de431dd3de63e96df19e6c74c3feb4e970ae6..50f17438fb83fb7c8481e51b3ef2712c850e8d55 100644 (file)
@@ -295,9 +295,7 @@ lookup_ts_dictionary_cache(Oid dictId)
                        /* Create private memory context the first time through */
                        saveCtx = AllocSetContextCreate(CacheMemoryContext,
                                                                                        NameStr(dict->dictname),
-                                                                                       ALLOCSET_SMALL_MINSIZE,
-                                                                                       ALLOCSET_SMALL_INITSIZE,
-                                                                                       ALLOCSET_SMALL_MAXSIZE);
+                                                                                       ALLOCSET_SMALL_SIZES);
                }
                else
                {
index ea6f787a527489d188cf88ebcc1d46429b2c196c..9150fe832f59235fc4f35e738a00884de431ddd8 100644 (file)
@@ -756,9 +756,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
 
                                cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                        "Domain constraints",
-                                                                                       ALLOCSET_SMALL_INITSIZE,
-                                                                                       ALLOCSET_SMALL_MINSIZE,
-                                                                                       ALLOCSET_SMALL_MAXSIZE);
+                                                                                       ALLOCSET_SMALL_SIZES);
                                dcc = (DomainConstraintCache *)
                                        MemoryContextAlloc(cxt, sizeof(DomainConstraintCache));
                                dcc->constraints = NIL;
@@ -841,9 +839,7 @@ load_domaintype_info(TypeCacheEntry *typentry)
 
                        cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                "Domain constraints",
-                                                                               ALLOCSET_SMALL_INITSIZE,
-                                                                               ALLOCSET_SMALL_MINSIZE,
-                                                                               ALLOCSET_SMALL_MAXSIZE);
+                                                                               ALLOCSET_SMALL_SIZES);
                        dcc = (DomainConstraintCache *)
                                MemoryContextAlloc(cxt, sizeof(DomainConstraintCache));
                        dcc->constraints = NIL;
index 5d179ae8a8d93ff122b8376b08b96aa23cdd887b..5d49fe5b50636bf99cf1546877b346c39e1a9296 100644 (file)
@@ -73,9 +73,7 @@ init_MultiFuncCall(PG_FUNCTION_ARGS)
                 */
                multi_call_ctx = AllocSetContextCreate(fcinfo->flinfo->fn_mcxt,
                                                                                           "SRF multi-call context",
-                                                                                          ALLOCSET_SMALL_MINSIZE,
-                                                                                          ALLOCSET_SMALL_INITSIZE,
-                                                                                          ALLOCSET_SMALL_MAXSIZE);
+                                                                                          ALLOCSET_SMALL_SIZES);
 
                /*
                 * Allocate suitably long-lived space and zero it
index d35052aea6cf0a1f8b4fe965bef0b573d1b5ff34..bb835ba9467d7e2826c56d2f72348439dc629397 100644 (file)
@@ -327,9 +327,7 @@ hash_create(const char *tabname, long nelem, HASHCTL *info, int flags)
                        CurrentDynaHashCxt = TopMemoryContext;
                CurrentDynaHashCxt = AllocSetContextCreate(CurrentDynaHashCxt,
                                                                                                   tabname,
-                                                                                                  ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                  ALLOCSET_DEFAULT_SIZES);
        }
 
        /* Initialize the hash header, plus a copy of the table name */
index d17197267ef76e2c82745280e097057c77b16751..824d5abf11fefb0f51a49423fbcbc3ad5893cfcc 100644 (file)
@@ -201,9 +201,7 @@ PerformAuthentication(Port *port)
        if (PostmasterContext == NULL)
                PostmasterContext = AllocSetContextCreate(TopMemoryContext,
                                                                                                  "Postmaster",
-                                                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                 ALLOCSET_DEFAULT_SIZES);
 
        if (!load_hba())
        {
index 48052f9320c008de6e3afadaf20da73d308c331c..dae5015a32e9b7455ae83d04f76818dba2c26812 100644 (file)
@@ -145,9 +145,7 @@ ProcessConfigFile(GucContext context)
         */
        config_cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                           "config file processing",
-                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                          ALLOCSET_DEFAULT_SIZES);
        caller_cxt = MemoryContextSwitchTo(config_cxt);
 
        /*
index a960343baa71d58cb794b823a9bc3ceeb8d606e5..a053e22439b3d0e5d02b07a12d9c7d8479c3c25d 100644 (file)
@@ -450,9 +450,7 @@ load_tzoffsets(const char *filename)
         */
        tmpContext = AllocSetContextCreate(CurrentMemoryContext,
                                                                           "TZParserMemory",
-                                                                          ALLOCSET_SMALL_MINSIZE,
-                                                                          ALLOCSET_SMALL_INITSIZE,
-                                                                          ALLOCSET_SMALL_MAXSIZE);
+                                                                          ALLOCSET_SMALL_SIZES);
        oldContext = MemoryContextSwitchTo(tmpContext);
 
        /* Initialize array at a reasonable size */
index d26991ed23f6d42e5539b2de36d6c6b1bb41af45..43c85234ce187c3e8e398c1682062ab51c3a298f 100644 (file)
@@ -427,10 +427,14 @@ randomize_mem(char *ptr, size_t size)
  *             Create a new AllocSet context.
  *
  * parent: parent context, or NULL if top-level context
- * name: name of context (for debugging --- string will be copied)
+ * name: name of context (for debugging only, need not be unique)
  * minContextSize: minimum context size
  * initBlockSize: initial allocation block size
  * maxBlockSize: maximum allocation block size
+ *
+ * Notes: the name string will be copied into context-lifespan storage.
+ * Most callers should abstract the context size parameters using a macro
+ * such as ALLOCSET_DEFAULT_SIZES.
  */
 MemoryContext
 AllocSetContextCreate(MemoryContext parent,
index 6b7894213c10daa5968fd54f5605189172609749..5cf388f9d600f5160e37c7f9d3873859ae2d9ca0 100644 (file)
@@ -91,16 +91,13 @@ MemoryContextInit(void)
        AssertState(TopMemoryContext == NULL);
 
        /*
-        * Initialize TopMemoryContext as an AllocSetContext with slow growth rate
-        * --- we don't really expect much to be allocated in it.
-        *
-        * (There is special-case code in MemoryContextCreate() for this call.)
+        * First, initialize TopMemoryContext, which will hold the MemoryContext
+        * nodes for all other contexts.  (There is special-case code in
+        * MemoryContextCreate() to handle this call.)
         */
        TopMemoryContext = AllocSetContextCreate((MemoryContext) NULL,
                                                                                         "TopMemoryContext",
-                                                                                        0,
-                                                                                        8 * 1024,
-                                                                                        8 * 1024);
+                                                                                        ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Not having any other place to point CurrentMemoryContext, make it point
index 425cae12ea1725d6829a7ac83812e0a00d1e9390..8286800380de9fab77bae389aed321d3f5af2f4b 100644 (file)
@@ -108,9 +108,7 @@ EnablePortalManager(void)
 
        PortalMemory = AllocSetContextCreate(TopMemoryContext,
                                                                                 "PortalMemory",
-                                                                                ALLOCSET_DEFAULT_MINSIZE,
-                                                                                ALLOCSET_DEFAULT_INITSIZE,
-                                                                                ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                ALLOCSET_DEFAULT_SIZES);
 
        ctl.keysize = MAX_PORTALNAME_LEN;
        ctl.entrysize = sizeof(PortalHashEnt);
@@ -221,9 +219,7 @@ CreatePortal(const char *name, bool allowDup, bool dupSilent)
        /* initialize portal heap context; typically it won't store much */
        portal->heap = AllocSetContextCreate(PortalMemory,
                                                                                 "PortalHeapMemory",
-                                                                                ALLOCSET_SMALL_MINSIZE,
-                                                                                ALLOCSET_SMALL_INITSIZE,
-                                                                                ALLOCSET_SMALL_MAXSIZE);
+                                                                                ALLOCSET_SMALL_SIZES);
 
        /* create a resource owner for the portal */
        portal->resowner = ResourceOwnerCreate(CurTransactionResourceOwner,
@@ -361,9 +357,7 @@ PortalCreateHoldStore(Portal portal)
        portal->holdContext =
                AllocSetContextCreate(PortalMemory,
                                                          "PortalHoldContext",
-                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                         ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Create the tuple store, selecting cross-transaction temp files, and
index ae384a8546ac450018b63e04154a40afa6c97f29..c8fbcf8fcc944ec06d8d745eced4ec4468e9f604 100644 (file)
@@ -654,9 +654,7 @@ tuplesort_begin_common(int workMem, bool randomAccess)
         */
        sortcontext = AllocSetContextCreate(CurrentMemoryContext,
                                                                                "TupleSort main",
-                                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                                               ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Caller tuple (e.g. IndexTuple) memory context.
@@ -669,9 +667,7 @@ tuplesort_begin_common(int workMem, bool randomAccess)
         */
        tuplecontext = AllocSetContextCreate(sortcontext,
                                                                                 "Caller tuples",
-                                                                                ALLOCSET_DEFAULT_MINSIZE,
-                                                                                ALLOCSET_DEFAULT_INITSIZE,
-                                                                                ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                ALLOCSET_DEFAULT_SIZES);
 
        /*
         * Make the Tuplesortstate within the per-sort context.  This way, we
index ae07705b6be76574dfc65a403a70aa5f8c7c3826..e6334a203851499acf5c9e9c67f670f2cf08473c 100644 (file)
@@ -142,14 +142,26 @@ extern MemoryContext AllocSetContextCreate(MemoryContext parent,
 #define ALLOCSET_DEFAULT_MINSIZE   0
 #define ALLOCSET_DEFAULT_INITSIZE  (8 * 1024)
 #define ALLOCSET_DEFAULT_MAXSIZE   (8 * 1024 * 1024)
+#define ALLOCSET_DEFAULT_SIZES \
+       ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
 
 /*
- * Recommended alloc parameters for "small" contexts that are not expected
+ * Recommended alloc parameters for "small" contexts that are never expected
  * to contain much data (for example, a context to contain a query plan).
  */
 #define ALLOCSET_SMALL_MINSIZE  0
 #define ALLOCSET_SMALL_INITSIZE  (1 * 1024)
 #define ALLOCSET_SMALL_MAXSIZE  (8 * 1024)
+#define ALLOCSET_SMALL_SIZES \
+       ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_SMALL_MAXSIZE
+
+/*
+ * Recommended alloc parameters for contexts that should start out small,
+ * but might sometimes grow big.
+ */
+#define ALLOCSET_START_SMALL_SIZES \
+       ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
+
 
 /*
  * Threshold above which a request in an AllocSet context is certain to be
index 82bde6e4424a7d5a555f582513d7c1456656630c..2cd761496d0066ef29c7d5a2eeadc92bddc7182f 100644 (file)
@@ -3205,9 +3205,7 @@ plperl_return_next(SV *sv)
                current_call_data->tmp_cxt =
                        AllocSetContextCreate(CurrentMemoryContext,
                                                                  "PL/Perl return_next temporary cxt",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
        }
 
        old_cxt = MemoryContextSwitchTo(current_call_data->tmp_cxt);
@@ -3460,9 +3458,7 @@ plperl_spi_prepare(char *query, int argc, SV **argv)
                 ************************************************************/
                plan_cxt = AllocSetContextCreate(TopMemoryContext,
                                                                                 "PL/Perl spi_prepare query",
-                                                                                ALLOCSET_SMALL_MINSIZE,
-                                                                                ALLOCSET_SMALL_INITSIZE,
-                                                                                ALLOCSET_SMALL_MAXSIZE);
+                                                                                ALLOCSET_SMALL_SIZES);
                MemoryContextSwitchTo(plan_cxt);
                qdesc = (plperl_query_desc *) palloc0(sizeof(plperl_query_desc));
                snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc);
@@ -3479,9 +3475,7 @@ plperl_spi_prepare(char *query, int argc, SV **argv)
                 ************************************************************/
                work_cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                                 "PL/Perl spi_prepare workspace",
-                                                                                ALLOCSET_DEFAULT_MINSIZE,
-                                                                                ALLOCSET_DEFAULT_INITSIZE,
-                                                                                ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                ALLOCSET_DEFAULT_SIZES);
                MemoryContextSwitchTo(work_cxt);
 
                /************************************************************
index 38aa030303a3765ca6a3095673b91e87c9d6aa64..4ceb402c929c861460fdea40d57a110c8933c14f 100644 (file)
@@ -340,9 +340,7 @@ do_compile(FunctionCallInfo fcinfo,
         */
        func_cxt = AllocSetContextCreate(TopMemoryContext,
                                                                         "PL/pgSQL function context",
-                                                                        ALLOCSET_DEFAULT_MINSIZE,
-                                                                        ALLOCSET_DEFAULT_INITSIZE,
-                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                        ALLOCSET_DEFAULT_SIZES);
        plpgsql_compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
 
        function->fn_signature = format_procedure(fcinfo->flinfo->fn_oid);
@@ -829,10 +827,8 @@ plpgsql_compile_inline(char *proc_source)
         * its own memory context, so it can be reclaimed easily.
         */
        func_cxt = AllocSetContextCreate(CurrentMemoryContext,
-                                                                        "PL/pgSQL function context",
-                                                                        ALLOCSET_DEFAULT_MINSIZE,
-                                                                        ALLOCSET_DEFAULT_INITSIZE,
-                                                                        ALLOCSET_DEFAULT_MAXSIZE);
+                                                                        "PL/pgSQL inline code context",
+                                                                        ALLOCSET_DEFAULT_SIZES);
        plpgsql_compile_tmp_cxt = MemoryContextSwitchTo(func_cxt);
 
        function->fn_signature = pstrdup(func_name);
index f9b3b22d0811c6fe853f486e1a4dc8831d4276ee..2f8b6ff2f2befd350723cffea44cd0316b24fa3e 100644 (file)
@@ -1092,9 +1092,7 @@ get_stmt_mcontext(PLpgSQL_execstate *estate)
                estate->stmt_mcontext =
                        AllocSetContextCreate(estate->stmt_mcontext_parent,
                                                                  "PLpgSQL per-statement data",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
        }
        return estate->stmt_mcontext;
 }
@@ -3479,9 +3477,7 @@ plpgsql_estate_setup(PLpgSQL_execstate *estate,
                {
                        shared_cast_context = AllocSetContextCreate(TopMemoryContext,
                                                                                                                "PLpgSQL cast info",
-                                                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                                                  ALLOCSET_DEFAULT_INITSIZE,
-                                                                                                  ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                                        ALLOCSET_DEFAULT_SIZES);
                        memset(&ctl, 0, sizeof(ctl));
                        ctl.keysize = sizeof(plpgsql_CastHashKey);
                        ctl.entrysize = sizeof(plpgsql_CastHashEntry);
index 44ba76e765e2cdcd1f253b1799b9c7fd6926e74a..0e17a03ce7b196e1a4f03eec2f33014606a95351 100644 (file)
@@ -116,9 +116,7 @@ PLy_cursor_query(const char *query)
        cursor->closed = false;
        cursor->mcxt = AllocSetContextCreate(TopMemoryContext,
                                                                                 "PL/Python cursor context",
-                                                                                ALLOCSET_DEFAULT_MINSIZE,
-                                                                                ALLOCSET_DEFAULT_INITSIZE,
-                                                                                ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                ALLOCSET_DEFAULT_SIZES);
        PLy_typeinfo_init(&cursor->result, cursor->mcxt);
 
        oldcontext = CurrentMemoryContext;
@@ -210,9 +208,7 @@ PLy_cursor_plan(PyObject *ob, PyObject *args)
        cursor->closed = false;
        cursor->mcxt = AllocSetContextCreate(TopMemoryContext,
                                                                                 "PL/Python cursor context",
-                                                                                ALLOCSET_DEFAULT_MINSIZE,
-                                                                                ALLOCSET_DEFAULT_INITSIZE,
-                                                                                ALLOCSET_DEFAULT_MAXSIZE);
+                                                                                ALLOCSET_DEFAULT_SIZES);
        PLy_typeinfo_init(&cursor->result, cursor->mcxt);
 
        oldcontext = CurrentMemoryContext;
index f95039406a33a1ced1e0f3b8469dbdcfefff7cdd..860b804e5455d432ba861e7fb9fef4278b0d2cfa 100644 (file)
@@ -315,9 +315,7 @@ plpython_inline_handler(PG_FUNCTION_ARGS)
        MemSet(&proc, 0, sizeof(PLyProcedure));
        proc.mcxt = AllocSetContextCreate(TopMemoryContext,
                                                                          "__plpython_inline_block",
-                                                                         ALLOCSET_DEFAULT_MINSIZE,
-                                                                         ALLOCSET_DEFAULT_INITSIZE,
-                                                                         ALLOCSET_DEFAULT_MAXSIZE);
+                                                                         ALLOCSET_DEFAULT_SIZES);
        proc.pyname = MemoryContextStrdup(proc.mcxt, "__plpython_inline_block");
        proc.langid = codeblock->langOid;
        proc.result.out.d.typoid = VOIDOID;
@@ -416,9 +414,7 @@ PLy_get_scratch_context(PLyExecutionContext *context)
                context->scratch_ctx =
                        AllocSetContextCreate(TopTransactionContext,
                                                                  "PL/Python scratch context",
-                                                                 ALLOCSET_DEFAULT_MINSIZE,
-                                                                 ALLOCSET_DEFAULT_INITSIZE,
-                                                                 ALLOCSET_DEFAULT_MAXSIZE);
+                                                                 ALLOCSET_DEFAULT_SIZES);
        return context->scratch_ctx;
 }
 
index 70b75f5d95ea33c1d71e5d2495084aaea8cb12d6..2b249b029d2d69ecad98b36314c53893799b18a2 100644 (file)
@@ -167,9 +167,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
 
        cxt = AllocSetContextCreate(TopMemoryContext,
                                                                procName,
-                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                               ALLOCSET_DEFAULT_SIZES);
 
        oldcxt = MemoryContextSwitchTo(cxt);
 
index 1e965cf85f02762ea038468719aae96dfd8dd519..09ee06d9e861e32741f371c69aaf2261eb2beeeb 100644 (file)
@@ -66,9 +66,7 @@ PLy_spi_prepare(PyObject *self, PyObject *args)
 
        plan->mcxt = AllocSetContextCreate(TopMemoryContext,
                                                                           "PL/Python plan context",
-                                                                          ALLOCSET_DEFAULT_MINSIZE,
-                                                                          ALLOCSET_DEFAULT_INITSIZE,
-                                                                          ALLOCSET_DEFAULT_MAXSIZE);
+                                                                          ALLOCSET_DEFAULT_SIZES);
        oldcontext = MemoryContextSwitchTo(plan->mcxt);
 
        nargs = list ? PySequence_Length(list) : 0;
@@ -413,9 +411,7 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, uint64 rows, int status)
 
                cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                        "PL/Python temp context",
-                                                                       ALLOCSET_DEFAULT_MINSIZE,
-                                                                       ALLOCSET_DEFAULT_INITSIZE,
-                                                                       ALLOCSET_DEFAULT_MAXSIZE);
+                                                                       ALLOCSET_DEFAULT_SIZES);
                PLy_typeinfo_init(&args, cxt);
 
                oldcontext = CurrentMemoryContext;
index 7ad7a4400a53fdbc4eab28a1c99720fe4608ea1c..70f2e6d20f19ae3516d43e5df98e9dec7b42c61f 100644 (file)
@@ -756,9 +756,7 @@ PLyObject_ToComposite(PLyObToDatum *arg, int32 typmod, PyObject *plrv)
        /* Create a dummy PLyTypeInfo */
        cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                "PL/Python temp context",
-                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                               ALLOCSET_DEFAULT_SIZES);
        MemSet(&info, 0, sizeof(PLyTypeInfo));
        PLy_typeinfo_init(&info, cxt);
        /* Mark it as needing output routines lookup */
@@ -923,9 +921,7 @@ PLyString_ToComposite(PLyTypeInfo *info, TupleDesc desc, PyObject *string)
        /* Create a dummy PLyTypeInfo */
        cxt = AllocSetContextCreate(CurrentMemoryContext,
                                                                "PL/Python temp context",
-                                                               ALLOCSET_DEFAULT_MINSIZE,
-                                                               ALLOCSET_DEFAULT_INITSIZE,
-                                                               ALLOCSET_DEFAULT_MAXSIZE);
+                                                               ALLOCSET_DEFAULT_SIZES);
        MemSet(&locinfo, 0, sizeof(PLyTypeInfo));
        PLy_typeinfo_init(&locinfo, cxt);
 
index 6ee4153ae62eafe0db3f9d5764ff78f6899d8e96..2a335aa2196c8dab2f3fdc8ac8258430fd8b51a4 100644 (file)
@@ -2331,9 +2331,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
         ************************************************************/
        plan_cxt = AllocSetContextCreate(TopMemoryContext,
                                                                         "PL/TCL spi_prepare query",
-                                                                        ALLOCSET_SMALL_MINSIZE,
-                                                                        ALLOCSET_SMALL_INITSIZE,
-                                                                        ALLOCSET_SMALL_MAXSIZE);
+                                                                        ALLOCSET_SMALL_SIZES);
        MemoryContextSwitchTo(plan_cxt);
        qdesc = (pltcl_query_desc *) palloc0(sizeof(pltcl_query_desc));
        snprintf(qdesc->qname, sizeof(qdesc->qname), "%p", qdesc);