Skip to content

Commit

Permalink
Symbols renamed in PostgreSQL v17
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jcflack committed Oct 3, 2024
1 parent f9e962f commit 278e8c1
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pljava-so/src/main/c/InstallHelper.c
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,6 +14,7 @@
#include <access/xact.h>
#include <catalog/pg_language.h>
#include <catalog/pg_proc.h>
#include <commands/dbcommands.h>
#include <commands/extension.h>
#include <commands/portalcmds.h>
#include <executor/spi.h>
Expand Down Expand Up @@ -43,18 +44,21 @@
#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.
*
* One thing it's needed for is to avoid dereferencing MyProcPort in a
* background worker, where it's not set.
*/
#include <commands/dbcommands.h>
#if defined(_MSC_VER)
#include <postmaster/bgworker.h>
#define IsBackgroundWorker (MyBgworkerEntry != NULL)
#endif
#endif /* PG_VERSION_NUM < 170000 */

/*
* The name of the table the extension scripts will create to pass information
Expand Down Expand Up @@ -90,7 +94,7 @@ bool pljavaViableXact()

char *pljavaDbName()
{
if ( IsAutoVacuumWorkerProcess() || IsBackgroundWorker )
if ( AmAutoVacuumWorkerProcess() || AmBackgroundWorkerProcess() )
{
char *shortlived;
static char *longlived;
Expand All @@ -110,7 +114,7 @@ char *pljavaDbName()

static char *origUserName()
{
if ( IsAutoVacuumWorkerProcess() || IsBackgroundWorker )
if ( AmAutoVacuumWorkerProcess() || AmBackgroundWorkerProcess() )
{
char *shortlived;
static char *longlived;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 278e8c1

Please sign in to comment.