#8378 closed defect (fixed)
PostgreSQL environment upgrade issue
Reported by: | Emmanuel Blot | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 0.11.5 |
Component: | database backend | Version: | 0.12dev |
Severity: | major | Keywords: | posgresql |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I'm in the process of migrating from SQLite to PostgreSQL DB backend, and I have to upgrade the environment once more to upgrade Bitten.
I ran "trac-admin project" upgrade command and received the following error:
Trac [/local/var/trac/projects/tools]> upgrade KeyError: 'params'
It ends up to be an issue here:
# trac/db/postgres_backend.py def backup(self, dest_file): # line 114 if 'host' in db_prop['params']: host = db_prop['params']['host'] else: host = db_prop.get('host', 'localhost')
This part of the code does not seems to match the construction of the db_prop
dictionary, from trac/db/api.py
def _parse_db_str(db_str): # ... args = zip(('user', 'password', 'host', 'port', 'path', 'params'), (user, password, host, port, path, params)) return scheme, dict([(key, value) for key, value in args if value])
where params
may not be a dictionary entry if no value is tied to params
Here is a quick workaround to bypass the issue, although I'm not sure it's valid (no time to understand the nuts and bolts of this backend for now…)
-
trac/db/postgres_backend.py
111 111 args = [self.pg_dump_path, '-C', '-d', '-x', '-Z', '8', 112 112 '-U', db_prop['user'],] 113 113 port = db_prop.get('port', '5432') 114 if 'host' in db_prop ['params']:115 host = db_prop[' params']['host']114 if 'host' in db_prop: 115 host = db_prop['host'] 116 116 else: 117 117 host = db_prop.get('host', 'localhost') 118 118 args.append('-h') … … 121 121 args.append('-p') 122 122 args.append(str(port)) 123 123 124 if 'schema' in db_prop['params']: 125 args.extend(['-n', db_prop['params']['schema']]) 124 if 'params' in db_prop: 125 if 'schema' in db_prop['params']: 126 args.extend(['-n', db_prop['params']['schema']]) 126 127 127 128 dest_file += ".gz" 128 129 args.extend(['-f', dest_file, db_name])
Note: it might be nice to have a "DB backend" component to report issues against.
Attachments (1)
Change History (8)
comment:1 by , 15 years ago
by , 15 years ago
Attachment: | psql_backend_does_not_assume_any_properties_8378 added |
---|
comment:2 by , 15 years ago
Btw: The same problem exists in 0.11 so please fix the issue on all branches.
comment:3 by , 15 years ago
Milestone: | 0.12 → 0.11.5 |
---|
comment:4 by , 15 years ago
Milestone: | 0.11.6 → 0.11.5 |
---|
comment:6 by , 15 years ago
Component: | general → database backend |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Felix is right, db_prop['params']
can be missing, and his patch fixes the issue. Applied in [8312], thanks!
The logic for 'host'
is correct, and handles the case where the host is specified as an additional parameter, which is useful if you connect to PostgreSQL through a UNIX socket. See DatabaseBackend#Postgresql for more details.
it might be nice to have a "DB backend" component to report issues against.
Wish granted :-)
comment:7 by , 15 years ago
Owner: | changed from | to
---|
eblot: I think your patch is wrong because it there is there else clause which uses 'host' already. The real problem is that db_propparams could be missing as you already noted.
I'm attaching a preliminary patch for 0.11