diff options
| author | Tom Lane | 2003-05-02 20:54:36 +0000 |
|---|---|---|
| committer | Tom Lane | 2003-05-02 20:54:36 +0000 |
| commit | de28dc9a04c4df5d711815b7a518501b43535a26 (patch) | |
| tree | 1b93363ece14ded804195ff4a1c754a9b4a32306 /contrib | |
| parent | 1940434f1ef8475c8b59bb8ff03e3f3a10cac6ae (diff) | |
Portal and memory management infrastructure for extended query protocol.
Both plannable queries and utility commands are now always executed
within Portals, which have been revamped so that they can handle the
load (they used to be good only for single SELECT queries). Restructure
code to push command-completion-tag selection logic out of postgres.c,
so that it won't have to be duplicated between simple and extended queries.
initdb forced due to addition of a field to Query nodes.
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/intagg/int_aggregate.c | 52 |
1 files changed, 15 insertions, 37 deletions
diff --git a/contrib/intagg/int_aggregate.c b/contrib/intagg/int_aggregate.c index 1c14e7c2db7..9f4b5d09182 100644 --- a/contrib/intagg/int_aggregate.c +++ b/contrib/intagg/int_aggregate.c @@ -77,7 +77,9 @@ PG_FUNCTION_INFO_V1(int_enum); /* * Manage the aggregation state of the array - * You need to specify the correct memory context, or it will vanish! + * + * Need to specify a suitably long-lived memory context, or it will vanish! + * PortalContext isn't really right, but it's close enough. */ static PGARRAY * GetPGArray(int4 state, int fAdd) @@ -89,14 +91,7 @@ GetPGArray(int4 state, int fAdd) /* New array */ int cb = PGARRAY_SIZE(START_NUM); - p = (PGARRAY *) MemoryContextAlloc(TopTransactionContext, cb); - - if (!p) - { - elog(ERROR, "Integer aggregator, cant allocate TopTransactionContext memory"); - return 0; - } - + p = (PGARRAY *) MemoryContextAlloc(PortalContext, cb); p->a.size = cb; p->a.ndim = 0; p->a.flags = 0; @@ -115,18 +110,6 @@ GetPGArray(int4 state, int fAdd) int cbNew = PGARRAY_SIZE(n); pn = (PGARRAY *) repalloc(p, cbNew); - - if (!pn) - { /* Realloc failed! Reallocate new block. */ - pn = (PGARRAY *) MemoryContextAlloc(TopTransactionContext, cbNew); - if (!pn) - { - elog(ERROR, "Integer aggregator, REALLY REALLY can't alloc memory"); - return (PGARRAY *) NULL; - } - memcpy(pn, p, p->a.size); - pfree(p); - } pn->a.size = cbNew; pn->lower = n; return pn; @@ -149,24 +132,19 @@ ShrinkPGArray(PGARRAY * p) /* use current transaction context */ pnew = palloc(cb); - - if (pnew) - { - /* - * Fix up the fields in the new structure, so Postgres - * understands - */ - memcpy(pnew, p, cb); - pnew->a.size = cb; - pnew->a.ndim = 1; - pnew->a.flags = 0; + /* + * Fix up the fields in the new structure, so Postgres + * understands + */ + memcpy(pnew, p, cb); + pnew->a.size = cb; + pnew->a.ndim = 1; + pnew->a.flags = 0; #ifndef PG_7_2 - pnew->a.elemtype = INT4OID; + pnew->a.elemtype = INT4OID; #endif - pnew->lower = 0; - } - else - elog(ERROR, "Integer aggregator, can't allocate memory"); + pnew->lower = 0; + pfree(p); } return pnew; |
