#12496 closed enhancement (fixed)
Include PostgreSQL version in environment_info table
Reported by: | Ryan J Ollos | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.3.1 |
Component: | database backend | Version: | |
Severity: | normal | Keywords: | postgres |
Cc: | Branch: | ||
Release Notes: |
|
||
API Changes: |
|
||
Internal Changes: |
Attachments (2)
Change History (23)
by , 9 years ago
Attachment: | Screen Shot 2016-05-31 at 11.52.09.png added |
---|
by , 9 years ago
Attachment: | Screen Shot 2016-05-31 at 11.52.26.png added |
---|
comment:1 by , 8 years ago
Milestone: | next-stable-1.0.x → 1.2 |
---|---|
Owner: | set to |
Status: | new → assigned |
follow-up: 3 comment:2 by , 8 years ago
comment:3 by , 8 years ago
Replying to Ryan J Ollos:
I'm not sure if that makes sense. Possible changes in log:rjollos.git:t12496_postgresql_version_in_environment_info.
I don't think versions of libpq and pg_dump would be same. It is possible that a user installs multiple versions of postgresql client, install to directory which isn't in PATH
(e.g. /usr/local/postgresql-9.x
, using only LD_LIBRARY_PATH
).
I consider we should use psycopg2.libpq_version
(since psycopg 2.7) or PQlibVersion()
in libpq via ctypes
: [94d79aa7d/jomae.git] (untested with Windows)
follow-up: 6 comment:4 by , 8 years ago
Sounds good. Do you have any concerns about [93313f31/rjollos.git#file0]? Maybe my solution is just a hack.
comment:5 by , 8 years ago
Milestone: | 1.2 → 1.3.1 |
---|
comment:6 by , 8 years ago
Replying to Ryan J Ollos:
Do you have any concerns about [93313f31/rjollos.git#file0]? Maybe my solution is just a hack.
I consider that is not a good idea.
- If database connection string is incorrect,
get_systeminfo()
always would fail. - Database connection retrieved from
connector.get_connection(**args)
would be leaked. Must close it.
comment:7 by , 8 years ago
Milestone: | 1.3.1 → next-dev-1.3.x |
---|---|
Owner: | removed |
Status: | assigned → new |
I don't have any better ideas to resolve this. Feel free to take over the ticket if you'd like.
comment:8 by , 8 years ago
Another idea: [f85b868eb/jomae.git] (jomae.git@t12496.2_trunk)
- Add
get_system_info()
toIDatabaseConnector
. - Name and version of the database are returned by
Environment.get_system_info()
withDatabaseManager(env).get_connector()
. - The name and version are returned even if database isn't connected yet (
(not-connected)
would be shown as database version).
comment:9 by , 8 years ago
That looks good. It would probably make sense to have DatabaseManager
implement ISystemInfoProvider
, but that appears to result in a circular import.
comment:10 by , 8 years ago
With the changes introduced, system_info
should probably not be lazily-evaluated: trunk/trac/env.py@15058:312#L304. We could modify the test case to test Environment.system_info
rather than Environment.get_system_info
. The former would be more like a functional test. I tried to make the to the test case, but ran into an issue that get_system_info
from Environment
is not returned from Environment.system_info
. It seems to be most directly due to EnvironmentStub
not being found in cmpmgr
: trunk/trac/core.py@14978:82#L63.
follow-up: 12 comment:11 by , 8 years ago
Milestone: | next-dev-1.3.x → 1.3.1 |
---|
Additional changes in log:rjollos.git:t12496.3_trunk.
I consider the changes after and including [1ca2ba02/rjollos.git] to be experimental. While moving the interfaces from trac.env
to trac.api
resolves the circular import, I'm not sure yet that it's the right change to make.
comment:12 by , 8 years ago
Replying to Ryan J Ollos:
While moving the interfaces from
trac.env
totrac.api
resolves the circular import, I'm not sure yet that it's the right change to make.
More generally, it looks like we'd avoid circular import problems by:
- Putting interfaces and abstract base classes in
api.py
, but don't put implementations inapi.py
, such as DatabaseManager. - Don't import
api
in__init__
. This is done, for example, in trac.admin.__init__.
comment:13 by , 8 years ago
Looks good to me except two things.
[a0df6a00a/jomae.git]: I think server_version
and _client_version
in trac.db.postgres_backend
should be a tuple of the version to be consistent. Thoughts?
[380e93192/jomae.git]: I believe a connection retrieved from connector.get_connection()
in trac.db.api is leaked. The statement should be removed, otherwise call close()
of the connection.
comment:14 by , 8 years ago
Those changes look good. I also had concerns about the string vs tuple inconsistency and I like the solution of having helper functions. I'll review the changes again at end of the week and push them.
comment:15 by , 8 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
Rebased changes in log:rjollos.git:t12496.5. I squashed and reordered the resulting changesets into an order suitable for pushing to the main repository.
comment:16 by , 8 years ago
Committed to trunk in [15148:15151].
It looks like builds on AppVeyor were failing even when I pushed to my GitHub fork, but I didn't notice because I'm apparently not getting notifications. I'll investigate.
comment:17 by , 8 years ago
Sorry, my mistake. It's needed to use libpq
instead of pq
on Windows. Also, UnboundLocalError
occurs if missing libpq library.
comment:18 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Thanks for the fix. Committed in r15152.
comment:19 by , 8 years ago
Owner: | changed from | to
---|
comment:21 by , 5 years ago
Release Notes: | modified (diff) |
---|
I had an unexpected finding. The first database interaction in a test case is through the
TransactionContextManager
: branches/1.2-stable/trac/test.py@15048:389,405#L388. It seemsIDatabaseConnector.get_connection
isn't called when aTransactionContextManager
is put in the pool.I'm not sure if that makes sense. Possible changes in log:rjollos.git:t12496_postgresql_version_in_environment_info.
Note:
assertRegexpMatches
is only available in Python 2.7 and the test is only intended to be committed to the trunk. Also, I haven't run tests on all platforms.