=== Applying patches on top of PostgreSQL commit ID d66997dfe8fe5a2fc6e25a64e78309ca2094f396 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Thu Mar 27 15:25:21 UTC 2025 On branch cf/5609 nothing to commit, working tree clean === using 'git am' to apply patch ./0005-Introduce-log_connection_messages.patch === Applying: Introduce log_connection_messages Using index info to reconstruct a base tree... M doc/src/sgml/config.sgml M src/backend/commands/variable.c M src/backend/libpq/auth.c M src/backend/postmaster/postmaster.c M src/backend/tcop/backend_startup.c M src/backend/tcop/postgres.c M src/backend/utils/init/postinit.c M src/backend/utils/misc/guc_tables.c M src/backend/utils/misc/postgresql.conf.sample M src/include/postmaster/postmaster.h M src/include/tcop/tcopprot.h M src/include/utils/guc_hooks.h M src/interfaces/libpq/t/005_negotiate_encryption.pl M src/test/authentication/t/001_password.pl M src/test/modules/oauth_validator/t/001_server.pl M src/test/postmaster/t/002_connection_limits.pl M src/test/postmaster/t/003_start_stop.pl M src/test/recovery/t/013_crash_restart.pl M src/test/recovery/t/022_crash_temp_files.pl M src/test/recovery/t/032_relfilenode_reuse.pl M src/test/ssl/t/SSL/Server.pm Falling back to patching base and 3-way merge... Auto-merging src/test/ssl/t/SSL/Server.pm Auto-merging src/test/recovery/t/032_relfilenode_reuse.pl Auto-merging src/test/recovery/t/022_crash_temp_files.pl Auto-merging src/test/recovery/t/013_crash_restart.pl Auto-merging src/test/postmaster/t/003_start_stop.pl Auto-merging src/test/postmaster/t/002_connection_limits.pl CONFLICT (content): Merge conflict in src/test/postmaster/t/002_connection_limits.pl Auto-merging src/test/modules/oauth_validator/t/001_server.pl Auto-merging src/test/authentication/t/001_password.pl Auto-merging src/interfaces/libpq/t/005_negotiate_encryption.pl Auto-merging src/include/utils/guc_hooks.h Auto-merging src/include/tcop/tcopprot.h Auto-merging src/include/postmaster/postmaster.h Auto-merging src/backend/utils/misc/postgresql.conf.sample CONFLICT (content): Merge conflict in src/backend/utils/misc/postgresql.conf.sample Auto-merging src/backend/utils/misc/guc_tables.c Auto-merging src/backend/utils/init/postinit.c CONFLICT (content): Merge conflict in src/backend/utils/init/postinit.c Auto-merging src/backend/tcop/postgres.c Auto-merging src/backend/tcop/backend_startup.c CONFLICT (content): Merge conflict in src/backend/tcop/backend_startup.c Auto-merging src/backend/postmaster/postmaster.c Auto-merging src/backend/libpq/auth.c CONFLICT (content): Merge conflict in src/backend/libpq/auth.c Auto-merging src/backend/commands/variable.c Auto-merging doc/src/sgml/config.sgml CONFLICT (content): Merge conflict in doc/src/sgml/config.sgml error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Introduce log_connection_messages When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". Unstaged changes after reset: M doc/src/sgml/config.sgml M src/backend/commands/variable.c M src/backend/libpq/auth.c M src/backend/tcop/backend_startup.c M src/backend/tcop/postgres.c M src/backend/utils/init/postinit.c M src/backend/utils/misc/guc_tables.c M src/backend/utils/misc/postgresql.conf.sample M src/include/postgres.h M src/include/tcop/tcopprot.h M src/include/utils/guc_hooks.h M src/interfaces/libpq/t/005_negotiate_encryption.pl M src/test/authentication/t/001_password.pl M src/test/authentication/t/003_peer.pl M src/test/authentication/t/005_sspi.pl M src/test/kerberos/t/001_auth.pl M src/test/ldap/t/001_auth.pl M src/test/ldap/t/002_bindpasswd.pl M src/test/modules/ldap_password_func/t/001_mutated_bindpasswd.pl M src/test/modules/oauth_validator/t/001_server.pl M src/test/modules/oauth_validator/t/002_client.pl M src/test/postmaster/t/002_connection_limits.pl M src/test/postmaster/t/003_start_stop.pl M src/test/recovery/t/013_crash_restart.pl M src/test/recovery/t/022_crash_temp_files.pl M src/test/recovery/t/032_relfilenode_reuse.pl M src/test/recovery/t/037_invalid_database.pl M src/test/ssl/t/SSL/Server.pm M src/tools/ci/pg_ci_base.conf === using patch(1) to apply patch ./0005-Introduce-log_connection_messages.patch === patch: unrecognized option `--no-backup-if-mismatch' usage: patch [-bCcEeflNnRstuv] [-B backup-prefix] [-D symbol] [-d directory] [-F max-fuzz] [-i patchfile] [-o out-file] [-p strip-count] [-r rej-name] [-V t | nil | never | none] [-x number] [-z backup-ext] [--posix] [origfile [patchfile]] patch ++<<<<<<< ours + + log_connections (string) ++======= + + log_connection_messages (string) ++>>>>>>> theirs - log_connections configuration parameter + log_connection_messages configuration parameter ++<<<<<<< ours + Causes aspects of each connection to the server to be logged. + The default is the empty string, '', which + disables all connection logging. The following options may be + specified alone or in a comma-separated list: + + + + Log Connection Options + + + + + + Name + Description + + + + + receipt + Logs receipt of a connection. + + + + authentication + + Logs the original identity used by an authentication method + to identify a user. In most cases, the identity string + matches the PostgreSQL username, + but some third-party authentication methods may alter the + original user identifier before the server stores it. Failed + authentication is always logged regardless of the value of + this setting. + + + + + authorization + + Logs successful completion of authorization. At this point + the connection has been established but the backend is not + yet fully set up. The log message includes the authorized + username as well as the database name and application name, + if applicable. + + + + + setup_durations + + Logs the time spent establishing the connection and setting up the + backend at the time the connection is ready to execute its first + query. The log message includes the total setup duration, starting + from the postmaster accepting the incoming connection and ending + when the connection is ready for query. It also includes the time + it took to fork the new backend and the time it took to + authenticate the user. + + + + + all + + A convenience alias equivalent to specifying all options. If + all is specified in a list of other + options, all connection aspects will be logged. + + + + + +
+ + + Disconnection logging is separately controlled by . + + + + For the purposes of backwards compatibility, on, + off, true, + false, yes, + no, 1, and 0 + are still supported. The positive values are equivalent to specifying + the receipt, authentication, and + authorization options. + + + ++======= + Causes the specified stages of each connection attempt to be logged. + Example: authorized,disconnected. + The default is the empty string, which means that nothing is logged. ++>>>>>>> theirs Only superusers and users with the appropriate SET privilege can change this parameter at session start, and it cannot be changed at all within a session. diff --cc src/backend/libpq/auth.c index e18683c47e7,afe64d20a09..00000000000 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@@ -318,8 -317,8 +318,13 @@@ auth_failed(Port *port, int status, con /* * Sets the authenticated identity for the current user. The provided string * will be stored into MyClientConnectionInfo, alongside the current HBA ++<<<<<<< ours + * method in use. The ID will be logged if log_connections has the + * 'authentication' option specified. ++======= + * method in use. The ID will be logged if + * log_connection_messages contains the 'authenticated' value. ++>>>>>>> theirs * * Auth methods should call this routine exactly once, as soon as the user is * successfully authenticated, even if they have reasons to know that @@@ -351,7 -350,7 +356,11 @@@ set_authn_id(Port *port, const char *id MyClientConnectionInfo.authn_id = MemoryContextStrdup(TopMemoryContext, id); MyClientConnectionInfo.auth_method = port->hba->auth_method; ++<<<<<<< ours + if (log_connections & LOG_CONNECTION_AUTHENTICATION) ++======= + if (Log_connection_messages & LOG_CONNECTION_AUTHENTICATED) ++>>>>>>> theirs { ereport(LOG, errmsg("connection authenticated: identity=\"%s\" method=%s " @@@ -635,8 -634,7 +644,12 @@@ ClientAuthentication(Port *port #endif } ++<<<<<<< ours + if ((log_connections & LOG_CONNECTION_AUTHENTICATION) && + status == STATUS_OK && ++======= + if (Log_connection_messages && LOG_CONNECTION_AUTHENTICATED && status == STATUS_OK && ++>>>>>>> theirs !MyClientConnectionInfo.authn_id) { /* diff --cc src/backend/tcop/backend_startup.c index 27c0b3c2b04,10b20cdce3a..00000000000 --- a/src/backend/tcop/backend_startup.c +++ b/src/backend/tcop/backend_startup.c @@@ -216,8 -201,8 +216,13 @@@ BackendInitialize(ClientSocket *client_ port->remote_host = MemoryContextStrdup(TopMemoryContext, remote_host); port->remote_port = MemoryContextStrdup(TopMemoryContext, remote_port); ++<<<<<<< ours + /* And now we can log that the connection was received, if enabled */ + if (log_connections & LOG_CONNECTION_RECEIPT) ++======= + /* And now we can issue the "connection received" message, if wanted */ + if (Log_connection_messages & LOG_CONNECTION_RECEIVED) ++>>>>>>> theirs { if (remote_port[0]) ereport(LOG, diff --cc src/backend/utils/init/postinit.c index 7958ea11b73,14637b69112..00000000000 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@@ -257,10 -251,7 +257,14 @@@ PerformAuthentication(Port *port */ disable_timeout(STATEMENT_TIMEOUT, false); ++<<<<<<< ours + /* Capture authentication end time for logging */ + conn_timing.auth_end = GetCurrentTimestamp(); + + if (log_connections & LOG_CONNECTION_AUTHORIZATION) ++======= + if (Log_connection_messages & LOG_CONNECTION_AUTHORIZED) ++>>>>>>> theirs { StringInfoData logmsg; diff --cc src/backend/utils/misc/postgresql.conf.sample index 7c12434efa2,2ee7a6fd197..00000000000 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@@ -21,7 -21,7 +21,11 @@@ # require a server shutdown and restart to take effect. # # Any parameter can also be given as a command-line option to the server, e.g., ++<<<<<<< ours +# "postgres -c log_connections=all". Some parameters can be changed at run time ++======= + # "postgres -c log_connection_messages=all". Some parameters can be changed at run time ++>>>>>>> theirs # with the "SET" SQL command. # # Memory units: B = bytes Time units: us = microseconds @@@ -590,11 -578,8 +594,16 @@@ # actions running at least this number # of milliseconds. #log_checkpoints = on ++<<<<<<< ours +#log_connections = '' # log aspects of connection setup + # options include receipt, authentication, authorization, + # setup_durations, and all to log all of these aspects +#log_disconnections = off +#log_duration = off # log statement duration ++======= + #log_connection_messages = '' + #log_duration = off ++>>>>>>> theirs #log_error_verbosity = default # terse, default, or verbose messages #log_hostname = off #log_line_prefix = '%m [%p] ' # special values: diff --cc src/test/postmaster/t/002_connection_limits.pl index 325a00efd47,d22efe38253..00000000000 --- a/src/test/postmaster/t/002_connection_limits.pl +++ b/src/test/postmaster/t/002_connection_limits.pl @@@ -20,8 -19,7 +20,12 @@@ $node->init $node->append_conf('postgresql.conf', "max_connections = 6"); $node->append_conf('postgresql.conf', "reserved_connections = 2"); $node->append_conf('postgresql.conf', "superuser_reserved_connections = 1"); ++<<<<<<< ours +$node->append_conf('postgresql.conf', "log_connections = on"); +$node->append_conf('postgresql.conf', "log_min_messages=debug2"); ++======= + $node->append_conf('postgresql.conf', "log_connection_messages = all"); ++>>>>>>> theirs $node->start; $node->safe_psql(