Skip to content

Commit 05d8b4e

Browse files
committed
GetOldestSnapshot -> get_toast_snapshot
When VarlenaWrapper wants to save a TOASTed value that may possibly be wanted later, it can use the least memory if it just retains the TOAST pointer and registers a current snapshot in which it is visible. In PG 9.6, a GetOldestSnapshot function appeared and made that possible. As of PG 18, with postgres/postgres@4d82750, that function has vanished, but there is a new one, get_toast_snapshot, that appears to fit the bill. It's only declared in access/toast_internals.h, though, which isn't otherwise needed. Addresses #524.
1 parent 116fd50 commit 05d8b4e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pljava-so/src/main/c/VarlenaWrapper.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018-2023 Tada AB and other contributors, as listed below.
2+
* Copyright (c) 2018-2025 Tada AB and other contributors, as listed below.
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the The BSD 3-Clause License
@@ -33,7 +33,11 @@
3333
#include "pljava/JNICalls.h"
3434

3535
#if PG_VERSION_NUM < 90600
36-
#define GetOldestSnapshot() NULL
36+
#define get_toast_snapshot() NULL
37+
#elif PG_VERSION_NUM < 180000
38+
#define get_toast_snapshot() GetOldestSnapshot()
39+
#else
40+
#include <access/toast_internals.h>
3741
#endif
3842

3943
#define _VL_TYPE struct varlena *
@@ -145,7 +149,7 @@ jobject pljava_VarlenaWrapper_Input(
145149
goto justDetoastEagerly;
146150
if ( VARATT_IS_EXTERNAL_ONDISK(vl) )
147151
{
148-
pin = GetOldestSnapshot();
152+
pin = get_toast_snapshot();
149153
if ( NULL == pin )
150154
{
151155
/*

0 commit comments

Comments
 (0)