misplaced GUC in pqcomm.h -- where to put actual common variable though...?

From: Greg Stark <stark(at)mit(dot)edu>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: misplaced GUC in pqcomm.h -- where to put actual common variable though...?
Date: 2023-03-22 02:43:05
Message-ID: CAM-w4HMmBmMxPisbMOb_JTEHbYL5VvG0f-0U9wUbZ=1XFBKJ1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

So back in 2002 in 7.3 there was a commit 2c6b34d9598 which added a
GUC db_user_namespace which is stored in a variable Db_user_namespace.
All that seems fine except...

The variable this GUC is stored in is Db_user_namespace which... is
actually declared in pqcomm.h which is intended to be "Definitions
common to frontends and backends".

Afaics it's never actually defined in any FE code, neither libpq nor
any clients. I was a bit surprised this isn't producing a warning
about an extern declaration that's never defined but I guess that's
not actually that unusual.

The actual variable is defined in the backend in postmaster.c. I'm
guessing this declaration can just move to libpq/libpq.h which
(counterintuitively) is for the backend iiuc.

I don't think this causes any actual problems aside from namespace
pollution but it confused me. I found this because I was looking for
where to put the ALPN protocol version which (at least at the moment)
would be the same for the server and client. But as far as I can tell
it would be the only variable (other than the above) declared in both
and that means there's no particularly handy place to put the
definition.

--
greg

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2023-03-22 02:58:54 Re: Initial Schema Sync for Logical Replication
Previous Message Kyotaro Horiguchi 2023-03-22 02:37:03 Re: Reconcile stats in find_tabstat_entry() and get rid of PgStat_BackendFunctionEntry