#10406 closed defect (fixed)
ERROR: invalid value for parameter "search_path"
Reported by: | winix | Owned by: | Remy Blank |
---|---|---|---|
Priority: | highest | Milestone: | 0.12.3 |
Component: | database backend | Version: | 0.12.2 |
Severity: | critical | Keywords: | postgresql, schema |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
System Information:
- OS: Archlinux
- Python: 2.7.2
- python2-psycopg2 2.4.2
- Database: postgresql 9.1.1
I run this command to create trac environment:
sudo trac-admin test initenv test 'postgres://user:pass@localhost/trac?schema=test' 'svn' /home/subversion/repos/test
Initenv filed, and python traceback:
Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/trac/admin/console.py", line 422, in do_initenv options=options) File "/usr/lib/python2.7/site-packages/trac/env.py", line 213, in __init__ self.create(options) File "/usr/lib/python2.7/site-packages/trac/env.py", line 401, in create DatabaseManager(self).init_db() File "/usr/lib/python2.7/site-packages/trac/db/api.py", line 146, in init_db connector.init_db(**args) File "/usr/lib/python2.7/site-packages/trac/db/postgres_backend.py", line 98, in init_db params) File "/usr/lib/python2.7/site-packages/trac/db/postgres_backend.py", line 87, in get_connection params) File "/usr/lib/python2.7/site-packages/trac/db/postgres_backend.py", line 212, in __init__ cnx.cursor().execute('SET search_path TO %s', (self.schema,)) DataError: invalid value for parameter "search_path": "test" DETAIL: schema "test" does not exist
With postgresql 9.1, if schema does not exist, 'SET search_path' will raise DataError, not ProgrammingError (/db/postgres_backend.py)
Attachments (1)
Change History (7)
comment:1 by , 13 years ago
Milestone: | → 0.12.3 |
---|---|
Owner: | set to |
Priority: | normal → highest |
Severity: | normal → critical |
by , 13 years ago
Attachment: | 10406-search-path-r10830.patch added |
---|
Catch the right exception for PostgreSQL 9.1.
comment:2 by , 13 years ago
Can you please test 10406-search-path-r10830.patch?
To be honest, I don't really understand why we even catch this error. Currently, if SET search_path
fails, we leave the search path unchanged, which means that we are going to access the public
schema. I think it would be better to abort than to access the wrong schema.
Oh, now I see. It's only to allow a connection to be created for the initial CREATE SCHEMA
. This could be done better. Let's see…
comment:3 by , 13 years ago
Mmh… The EnvironmentStub
has some weird initialization sequence that actually requires catching the "missing schema" error, so I would rather leave it as-is. So yes, please test the patch above.
comment:4 by , 13 years ago
The patch works for me.
I think, before init_db call get_connection function, should remove schema value from params temporary, after get_connection, if schema exists, then create schema and set search_path.
comment:5 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Thanks for testing. Patch applied in [10831].
About the weird initialization of the connector, we have never had a defect report, so I'd rather leave it as-is at this point. Maybe I'll refactor it on trunk.
comment:6 by , 10 years ago
Keywords: | postgresql schema → postgresql, schema |
---|
Thanks for the report. I don't have a 9.1 server readily available (I should take the time to upgrade my 8.2), but I'll post a patch.