From 278e8c16b16f3c8369e1830b25e06c897bcb9d30 Mon Sep 17 00:00:00 2001 From: Chapman Flack Date: Wed, 2 Oct 2024 20:45:52 -0400 Subject: [PATCH] Symbols renamed in PostgreSQL v17 Credit to Francisco Miguel Biete Banon in PR #501. Simplified so the code now simply uses the new names (introduced in postgres/postgres@393b559), and defines them in older PG versions for compatibility. --- pljava-so/src/main/c/InstallHelper.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pljava-so/src/main/c/InstallHelper.c b/pljava-so/src/main/c/InstallHelper.c index 2cb5a9cb3..488ee0a66 100644 --- a/pljava-so/src/main/c/InstallHelper.c +++ b/pljava-so/src/main/c/InstallHelper.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2023 Tada AB and other contributors, as listed below. + * Copyright (c) 2015-2024 Tada AB and other contributors, as listed below. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the The BSD 3-Clause License @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,9 @@ #include "pljava/PgObject.h" #include "pljava/type/String.h" +#if PG_VERSION_NUM < 170000 +#define AmAutoVacuumWorkerProcess() IsAutoVacuumWorkerProcess() +#define AmBackgroundWorkerProcess() IsBackgroundWorker /* * As of 9.6.1, IsBackgroundWorker still does not * have PGDLLIMPORT, but MyBgworkerEntry != NULL can be used in MSVC instead. @@ -50,11 +54,11 @@ * One thing it's needed for is to avoid dereferencing MyProcPort in a * background worker, where it's not set. */ -#include #if defined(_MSC_VER) #include #define IsBackgroundWorker (MyBgworkerEntry != NULL) #endif +#endif /* PG_VERSION_NUM < 170000 */ /* * The name of the table the extension scripts will create to pass information @@ -90,7 +94,7 @@ bool pljavaViableXact() char *pljavaDbName() { - if ( IsAutoVacuumWorkerProcess() || IsBackgroundWorker ) + if ( AmAutoVacuumWorkerProcess() || AmBackgroundWorkerProcess() ) { char *shortlived; static char *longlived; @@ -110,7 +114,7 @@ char *pljavaDbName() static char *origUserName() { - if ( IsAutoVacuumWorkerProcess() || IsBackgroundWorker ) + if ( AmAutoVacuumWorkerProcess() || AmBackgroundWorkerProcess() ) { char *shortlived; static char *longlived; @@ -354,8 +358,8 @@ char *pljavaFnOidToLibPath(Oid fnOid, char **langName, bool *trusted) bool InstallHelper_shouldDeferInit() { - if ( IsBackgroundWorker || IsAutoVacuumWorkerProcess() ) - return true; + if ( AmAutoVacuumWorkerProcess() || AmBackgroundWorkerProcess() ) + return true; if ( ! IsBinaryUpgrade ) return false;