Re: [multithreading] extension compatibility

From: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, hlinnaka <hlinnaka(at)iki(dot)fi>
Subject: Re: [multithreading] extension compatibility
Date: 2024-06-05 20:45:23
Message-ID: CAGECzQQni+MBig-27FwJoPQAhLpg=b=JpTHNX0VnLN-uCWmh=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 5 Jun 2024 at 22:05, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> The attached patch is a sketch of one possible approach: PostgreSQL
> signals whether it is multithreaded by defining or not defining
> PG_MULTITHREADING in pg_config_manual.h, and an extension signals
> thread-readiness by defining PG_THREADSAFE_EXTENSION before including
> any PostgreSQL headers other than postgres.h.

My first gut-reaction: It seems kinda annoying to have to do this for
every c that you use to build your extension, e.g. citus or postgis
have a ton of those.

PG_MODULE_MAGIC seems like a better fit imho.

If we really want a compile time failure, then I think I'd prefer to
have a new postgres.h file (e.g. postgres-thread.h) that you would
include instead of plain postgres.h. Basically this file could then
contain the below two lines:

#include "postgres.h"
#define PG_THREADSAFE_EXTENSION 1

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-06-05 20:48:43 Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs
Previous Message Nathan Bossart 2024-06-05 20:39:17 Re: problems with "Shared Memory and Semaphores" section of docs