#10641 closed defect (duplicate)
Unable to create new project using PostgreSQL schema
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | database backend | Version: | 0.12.2 |
| Severity: | major | Keywords: | PostgreSQL, initenv, postgresql |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
I've tried to create a new project:
ilias@localhost:/srv/trac/projects$ sudo -u trac trac-admin ./the-project initenv
Creating a new Trac environment at /srv/trac/projects/the-project
Trac will first ask a few questions about your environment
in order to initialize and prepare the project database.
Please enter the name of your project.
This name will be used in page titles and descriptions.
Project Name [My Project]> The Project
Please specify the connection string for the database to use.
By default, a local SQLite database is created in the environment
directory. It is also possible to use an already existing
PostgreSQL database (check the Trac documentation for the exact
connection string syntax).
Database connection string [sqlite:db/trac.db]> postgres://trac@/trac?schema=the_project
Creating and Initializing Project
Initenv for '/srv/trac/projects/the-project' failed.
Failed to create environment.
invalid value for parameter "search_path": "the_project"
DETAIL: schema "the_project" does not exist
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/trac/admin/console.py", line 422, in do_initenv
options=options)
File "/usr/lib/python2.7/dist-packages/trac/env.py", line 213, in __init__
self.create(options)
File "/usr/lib/python2.7/dist-packages/trac/env.py", line 401, in create
DatabaseManager(self).init_db()
File "/usr/lib/python2.7/dist-packages/trac/db/api.py", line 146, in init_db
connector.init_db(**args)
File "/usr/lib/python2.7/dist-packages/trac/db/postgres_backend.py", line 98, in init_db
params)
File "/usr/lib/python2.7/dist-packages/trac/db/postgres_backend.py", line 87, in get_connection
params)
File "/usr/lib/python2.7/dist-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": "the_project"
DETAIL: schema "the_project" does not exist
Of course, the database 'trac' exists and user 'trac' has necessary permissions to operate on the database.
The problem is in function PostgreSQLConnector.init_db(). The function obtains new connection. Eventually PostgreSQLConnection's constructor checks if 'schema' is among params and updates the 'search_path'. The problem is that the schema does not exist before project creation, and it's impossible to update the 'search_path'.
This error is in the version 0.12-stable as well as in the trunk. Patches with the little hack are applied. The hack removes 'schema' from 'params' and updates 'cnx.schema' as 'cnx' has been created.
Attachments (2)
Change History (7)
by , 14 years ago
| Attachment: | postgres_backend.py-0.12.patch added |
|---|
comment:1 by , 14 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
comment:5 by , 11 years ago
| Keywords: | postgresql added |
|---|



Fix for 0.12-stable