Message-ID: From: "joejensen (@joejensen)" To: "pgjdbc/pgjdbc" Date: Tue, 04 Feb 2025 22:04:32 +0000 Subject: [pgjdbc/pgjdbc] issue #3508: Application Name is never set for assume min server version >= 9.0 List-Id: X-GitHub-Author-Id: 1325576 X-GitHub-Author-Login: joejensen X-GitHub-Issue: 3508 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3508 Content-Type: text/plain; charset=utf-8 **Describe the issue** As of 42.7.5 the ApplicationName is never set unless the assume min server version is set to a value < 9.0. The code that set the application name for versions >= 9.0 appears to have been removed in https://github.com/pgjdbc/pgjdbc/pull/3476 The comment indicates that the removed behavior is duplicated by runInitialQueries, however, that method returns immediately if the server version is >= 9. No including this in the initial connection also has a negative impact on the connection logging as previously reported on: https://github.com/pgjdbc/pgjdbc/issues/2111 **Driver Version?** 42.7.5 **Java Version?** 17 but not relevant **OS Version?** Windows but not relevant **PostgreSQL Version?** 17.2 **To Reproduce** Create a jdbc connection with 42.7.5, using the application ApplicationName option and the assumMinServerVersion=17 option. **Expected behaviour** Expect the application name to be set to the provided ApplicationName, however, it is instead set to blank / left unset. **Logs** If possible PostgreSQL logs surrounding the occurrence of the issue Additionally logs from the driver can be obtained adding Using the following template code make sure the bug can be replicated in the driver alone. ``` import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; import java.util.Properties; public class TestNullsFirst { public static void main(String []args) throws Exception { String url = "jdbc:postgresql://localhost:5432/test"; Properties props = new Properties(); props.setProperty("user", "test"); props.setProperty("password", "test"); try ( Connection conn = DriverManager.getConnection(url, props) ){ try ( Statement statement = conn.createStatement() ) { try (ResultSet rs = statement.executeQuery( "select lastname from users order by lastname asc nulls first") ){ if (rs.next()) System.out.println( "Get String: " + rs.getString(1)); } } } } } ```