Skip to content

Commit 3b67999

Browse files
committed
Use ALLOCSET_*_SIZES macros to create contexts.
These macros became available in 9.6 (ea268cd, with a "back-patch" appearing in 9.6.0, funnily enough). It becomes /necessary/ to use them in PG 11 (9fa6f00), at least when using AllocSetContextCreate rather than the PG11-new AllocSetContextCreateExtended. Here, just define the macros locally for PG < 9.6, and use them unconditionally.
1 parent 0510ef5 commit 3b67999

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

pljava-so/src/main/c/type/JavaWrapper.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ void JavaWrapper_initialize(void)
6161

6262
JavaMemoryContext = AllocSetContextCreate(TopMemoryContext,
6363
"PL/Java",
64-
ALLOCSET_DEFAULT_MINSIZE,
65-
ALLOCSET_DEFAULT_INITSIZE,
66-
ALLOCSET_DEFAULT_MAXSIZE);
64+
ALLOCSET_DEFAULT_SIZES);
6765
}
6866

6967
/*

pljava-so/src/main/c/type/Type.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,7 @@ Datum Type_invokeSRF(Type self, jclass cls, jmethodID method, jvalue* args, PG_F
402402

403403
ctxData->rowContext = AllocSetContextCreate(context->multi_call_memory_ctx,
404404
"PL/Java row context",
405-
ALLOCSET_DEFAULT_MINSIZE,
406-
ALLOCSET_DEFAULT_INITSIZE,
407-
ALLOCSET_DEFAULT_MAXSIZE);
405+
ALLOCSET_DEFAULT_SIZES);
408406

409407
/* Register callback to be called when the function ends
410408
*/

pljava-so/src/main/include/pljava/pljava.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ extern int vsnprintf(char* buf, size_t count, const char* format, va_list arg);
5050
#define StaticAssertStmt(condition, errmessage)
5151
#endif
5252

53+
/*
54+
* AllocSetContextCreate sprouted these macros for common combinations of
55+
* size parameters in PG 9.6. It becomes /necessary/ to use them in PG 11
56+
* when using AllocSetContextCreate (which becomes a macro in that version)
57+
* and not the (new in that version) AllocSetContextCreateExtended.
58+
*/
59+
#if PG_VERSION_NUM < 90600
60+
#define ALLOCSET_DEFAULT_SIZES \
61+
ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
62+
#define ALLOCSET_SMALL_SIZES \
63+
ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_SMALL_MAXSIZE
64+
#define ALLOCSET_START_SMALL_SIZES \
65+
ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
66+
#endif
5367

5468
/*
5569
* GETSTRUCT require "access/htup_details.h" to be included in PG9.3

src/site/markdown/releasenotes.md.vm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ $h3 Updated PostgreSQL APIs tracked
167167
* `IsBinaryUpgrade`
168168
* `SPI_register_trigger_data`
169169
* `SPI` without `SPI_push`/`SPI_pop`
170+
* `AllocSetContextCreate`
170171

171172
$h2 Earlier releases
172173

0 commit comments

Comments
 (0)