From: Tatsuo Ishii Date: Fri, 7 Nov 2025 09:17:54 +0000 (+0900) Subject: Remove unnecessary application_name treatment. X-Git-Tag: V4_6_4~7 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=4fabca331b48e6b0d26d24267b9d63577ce06e13;p=pgpool2.git Remove unnecessary application_name treatment. Commit c20858797eafe377b30166b467d2a36de89768e1 added an treatment to send "set application_name" command to backend when reusing existing connection. The reason were: (1) to set application_name parameter to proper value, which is the value specified in the startup packet when the connection was created. (2) to return application_name parameter status message to frontend. However, (1) is not necessary, because when the previous connection is closed, queries in reset_query_list are executed and the list usually includes "DISCARD ALL", which reset the application_name value to the previous one which was set when the connection was established. Also (2) is not necessary either, because send_params() sends all necessary parameter status messages to frontend including application_name. For these reasons, I think the treatment added in c20858797eafe377b30166b467d2a36de89768e1 is not necessary. This commit just removes the treatment. Also this will enhance the performance when some of backend nodes are in geographically distant location, by eliminating the time to send application_name to such a node and wait for the response. Author: Tatsuo Ishii Discussion: https://github.com/pgpool/pgpool2/issues/130 Backpatch-through: v4.2. --- diff --git a/src/protocol/child.c b/src/protocol/child.c index 5ccc1b074..591d520ad 100644 --- a/src/protocol/child.c +++ b/src/protocol/child.c @@ -847,49 +847,7 @@ connect_using_existing_connection(POOL_CONNECTION * frontend, if (MAJOR(backend) == 3) { - char command_buf[1024]; - - /* - * If we have received application_name in the start up packet, we - * send SET command to backend. Also we add or replace existing - * application_name data. - */ - if (sp->application_name) - { - snprintf(command_buf, sizeof(command_buf), "SET application_name TO '%s'", sp->application_name); - - for (i = 0; i < NUM_BACKENDS; i++) - { - if (VALID_BACKEND(i)) - { - /* - * We want to catch and ignore errors in do_command if a - * backend is just going down right now. Otherwise - * do_command raises an error and disconnects the - * connection to frontend. We can safely ignore error from - * "SET application_name" command if the backend goes - * down. - */ - PG_TRY(); - { - do_command(frontend, CONNECTION(backend, i), - command_buf, MAJOR(backend), - MAIN_CONNECTION(backend)->pid, - MAIN_CONNECTION(backend)->key, 0); - } - PG_CATCH(); - { - /* ignore the error message */ - MemoryContextSwitchTo(oldContext); - FlushErrorState(); - } - PG_END_TRY(); - } - } - pool_add_param(&MAIN(backend)->params, "application_name", sp->application_name); - set_application_name_with_string(sp->application_name); - } - + /* Send parameter status message to frontend. */ send_params(frontend, backend); }