Edgewall Software
Modify

Opened 9 years ago

Closed 9 years ago

Last modified 6 years ago

#10641 closed defect (duplicate)

Unable to create new project using PostgreSQL schema

Reported by: ilias@… 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)

postgres_backend.py-0.12.patch (587 bytes ) - added by ilias@… 9 years ago.
Fix for 0.12-stable
postgres_backend.py-trunk.patch (602 bytes ) - added by ilias@… 9 years ago.
Fix for the trunk

Download all attachments as: .zip

Change History (7)

by ilias@…, 9 years ago

Fix for 0.12-stable

by ilias@…, 9 years ago

Fix for the trunk

comment:1 by Remy Blank, 9 years ago

Resolution: duplicate
Status: newclosed

You're using PostgreSQL 9.1 or later, aren't you? You should update your Trac installation, this has been fixed in [10831].

Duplicate of #10406.

comment:2 by ilias@…, 9 years ago

Yes, I'm using PgSQL 9.1.

What version of Trac should I install?

comment:3 by ilias@…, 9 years ago

Now I'm using Trac 0.12.2-1 from Debian Testing.

comment:4 by Remy Blank, 9 years ago

Version: 0.12-stable0.12.2

At least 0.12.3.

comment:5 by Ryan J Ollos, 6 years ago

Keywords: postgresql added

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.