8000 Add back application name setting by joejensen · Pull Request #3509 · pgjdbc/pgjdbc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add back application name setting #3509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 1, 2025

Conversation

joejensen
Copy link
Contributor

Fixes #3508, by adding back the application_name startup parameters during the initial connection.

@davecramer
Copy link
Member

this #3491 doesn't fix it ?

@joejensen
Copy link
Contributor Author

this #3491 doesn't fix it ?

No, on line #906 it's actually returning immediately if the version >= 9.0 so it never reaches that code. Also, the postgres logging doen't include the application name in the initial connection logs if it is not included at startup.

@davecramer
Copy link
Member

OK, I think we need to add it back. I think the runInitialQueries needs to be tightened up and we need to document this better.
runInitialQueries should still set extra_float_digits=3for versions 9-12 and extra_float_digits=2` for versions less than 9

Thanks!

@joejensen joejensen force-pushed the 3508-set-application-name branch from 48630a6 to fe23843 Compare February 18, 2025 22:21
@joejensen
Copy link
Contributor Author
joejensen commented Feb 18, 2025

I believe the latest changes will run the initial queries only when necessary.
On PG 12 and later no initial queries are required assuming the assumMinServerVersion is set correctly.
On PG 9-11.x only the extra digits query is required if assumeMinServerVersion is set correctly.

I was able to add a unit test that fails for the original code, when assumeMinServerVersion was set to >= 9.0 resulting in the application name being blank. However, I don't see a straight-forward way to verify that it's being set in the startup parameters rather than via the initial queries (in the test harness at least). If you have any ideas, I would appreciate it.

I also added a note about this use-case into the documentation, not sure if it belongs anywhere else.

@joejensen joejensen force-pushed the 3508-set-application-name branch from ba257ca to 9abd197 Compare February 28, 2025 19:48
@joejensen joejensen force-pushed the 3508-set-application-name branch from 9abd197 to 9ef77ad Compare April 15, 2025 17:43
@joejensen joejensen requested a review from davecramer April 28, 2025 15:09
if (PGProperty.GROUP_STARTUP_PARAMETERS.getBoolean(info) && dbVersion >= ServerVersion.v9_0.getVersionNum()) {
SetupQueryRunner.run(queryExecutor, "BEGIN", false);
}
// Only need to send the application name if it's defined and wasn't already sent as a startup parameter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mind seeing some more explanation as to how we used the following tests to come to that conclusion.

@davecramer davecramer merged commit 71170a4 into pgjdbc:master May 1, 2025
15 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Application Name is never set for assume min server version >= 9.0
2 participants
0