Fix to expose a GUC variable, Log_disconnections, to outside of postgres.c

Started by Satoshi Nagayasuover 10 years ago5 messages
#1Satoshi Nagayasu
snaga@uptime.jp
1 attachment(s)

Hi,

I just found that Log_disconnections value has not been
exposed to outside of postgres.c.
Despite that, Log_connections has already been exposed.

So, I'd like to add attached fix to touch the Log_disconnections
value in other modules.

Any comments?

Regards,
--
NAGAYASU Satoshi <snaga@uptime.jp>

Attachments:

Log_disconnections.difftext/plain; charset=Shift_JIS; name=Log_disconnections.diffDownload
commit afffca193b69ea5eb42f5e7273d48a6a82eb7e37
Author: Satoshi Nagayasu <snaga@uptime.jp>
Date:   Thu Jul 9 03:42:31 2015 +0000

    Fix to expose "Log_disconnections" GUC variable to the outside postgres.c.

diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h
index d160304..4c76f30 100644
--- a/src/include/postmaster/postmaster.h
+++ b/src/include/postmaster/postmaster.h
@@ -25,6 +25,7 @@ extern bool ClientAuthInProgress;
 extern int	PreAuthDelay;
 extern int	AuthenticationTimeout;
 extern bool Log_connections;
+extern bool Log_disconnections;
 extern bool log_hostname;
 extern bool enable_bonjour;
 extern char *bonjour_name;
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Satoshi Nagayasu (#1)
Re: Fix to expose a GUC variable, Log_disconnections, to outside of postgres.c

Satoshi Nagayasu <snaga@uptime.jp> writes:

I just found that Log_disconnections value has not been
exposed to outside of postgres.c.
Despite that, Log_connections has already been exposed.

Why would an external module need to touch either one?

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Satoshi Nagayasu
snaga@uptime.jp
In reply to: Tom Lane (#2)
Re: Fix to expose a GUC variable, Log_disconnections, to outside of postgres.c

On 2015/07/09 13:06, Tom Lane wrote:

Satoshi Nagayasu <snaga@uptime.jp> writes:

I just found that Log_disconnections value has not been
exposed to outside of postgres.c.
Despite that, Log_connections has already been exposed.

Why would an external module need to touch either one?

To check settings of GUC variables from a shared preload
library.

For example, I'd like to print "WARNING ...." in _PG_init()
when some GUC variable is disabled on postmaster startup.

Regards,
--
NAGAYASU Satoshi <snaga@uptime.jp>

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Satoshi Nagayasu (#3)
Re: Fix to expose a GUC variable, Log_disconnections, to outside of postgres.c

On 07/09/2015 07:19 AM, Satoshi Nagayasu wrote:

On 2015/07/09 13:06, Tom Lane wrote:

Satoshi Nagayasu <snaga@uptime.jp> writes:

I just found that Log_disconnections value has not been
exposed to outside of postgres.c.
Despite that, Log_connections has already been exposed.

Why would an external module need to touch either one?

To check settings of GUC variables from a shared preload
library.

For example, I'd like to print "WARNING ...." in _PG_init()
when some GUC variable is disabled on postmaster startup.

I still have a hard time seeing why an extension would be interested in
Log_disconnections. But hey, extensions do strange things..

You could use GetConfigOption(). I'm not necessarily opposed to exposing
Log_disconnections, but with GetConfigOption() it will work with earlier
versions too.

- Heikki

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Satoshi Nagayasu
snaga@uptime.jp
In reply to: Heikki Linnakangas (#4)
Re: Fix to expose a GUC variable, Log_disconnections, to outside of postgres.c

On 2015/07/09 15:30, Heikki Linnakangas wrote:

On 07/09/2015 07:19 AM, Satoshi Nagayasu wrote:

On 2015/07/09 13:06, Tom Lane wrote:

Satoshi Nagayasu <snaga@uptime.jp> writes:

I just found that Log_disconnections value has not been
exposed to outside of postgres.c.
Despite that, Log_connections has already been exposed.

Why would an external module need to touch either one?

To check settings of GUC variables from a shared preload
library.

For example, I'd like to print "WARNING ...." in _PG_init()
when some GUC variable is disabled on postmaster startup.

I still have a hard time seeing why an extension would be interested in
Log_disconnections. But hey, extensions do strange things..

Definitely. :)

You could use GetConfigOption(). I'm not necessarily opposed to exposing
Log_disconnections, but with GetConfigOption() it will work with earlier
versions too.

That's it! This is what I'm looking for. Thanks a lot. :)

Regards,
--
NAGAYASU Satoshi <snaga@uptime.jp>

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers