Edgewall Software
Modify

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#7600 closed defect (fixed)

[PATCH] Trac does not send object names in quotes to PostgreSQL

Reported by: devrim@… Owned by: Jonas Borgström
Priority: normal Milestone: 0.11.4
Component: general Version: 0.11.3
Severity: critical Keywords: postgresql
Cc: felix.schwarz@… Branch:
Release Notes:
API Changes:

Description

Hello,

If we create an environment with a dash sign in it, Trac fails to authenticate from PostgreSQL. The reason is that within PostgreSQL, object names cannot have - in it:

test=# CREATE TEMP TABLE t-1 (c1 int);
ERROR:  syntax error at or near "-"
LINE 1: CREATE TEMP TABLE t-1 (c1 int);

If you want to use dash, you need to double quote object name:

test=# CREATE TEMP TABLE "t-1" (c1 int);
CREATE TABLE

This is not a bug — this is a feature. So trac needs to send all object names in double quotes to PostgreSQL.

Regards, Devrim

Attachments (4)

postgres_quoting.patch (2.2 KB ) - added by felix.schwarz@… 11 years ago.
patch against 0.11
postgres_quoting.2.patch (4.7 KB ) - added by felix.schwarz@… 11 years ago.
re-did my patch, this time with unit tests
trac-postgres-sql.patch (809 bytes ) - added by shanec@… 11 years ago.
fix for index column quoting
testcase_quoting_multiple_indexes.patch (1020 bytes ) - added by Felix Schwarz <felix.schwarz@…> 11 years ago.
a test case to ensure that the bug does not creep in again

Download all attachments as: .zip

Change History (15)

comment:1 by felix.schwarz@…, 11 years ago

Version: 0.10.50.12dev

This problem is present even in 0.11 and trunk. I attach a patch which solves the problem for me. As I did not find any unit tests in trac for testing SQL generation for specific databases, I don't attach a test case.

by felix.schwarz@…, 11 years ago

Attachment: postgres_quoting.patch added

patch against 0.11

by felix.schwarz@…, 11 years ago

Attachment: postgres_quoting.2.patch added

re-did my patch, this time with unit tests

comment:2 by felix.schwarz@…, 11 years ago

Milestone: 0.11.2
Summary: Trac does not send object names in quotes to PostgreSQL[PATCH] Trac does not send object names in quotes to PostgreSQL

modifying subject to make my patch more visible

comment:3 by Christian Boos, 11 years ago

Keywords: postgresql added
Milestone: 0.11.20.11.3

Patch looks OK, would need some double checking before applying.

Postponing to 0.11.3 but if someone feels like testing and applying it before, please do.

comment:4 by felix.schwarz@…, 11 years ago

Cc: felix.schwarz@… added

comment:5 by Jonas Borgström, 11 years ago

Resolution: fixed
Status: newclosed

Patch applied in [7784] and [7785]. Thanks Felix!

comment:6 by Christian Boos, 11 years ago

Owner: set to Jonas Borgström

comment:7 by shanec@…, 11 years ago

Resolution: fixed
Severity: normalblocker
Status: closedreopened
Version: 0.12dev0.11.3

This patch broke index creation with postgres 8.3 on both osx and linux. You cannot do quoting as follows:

CREATE INDEX "tags_tagspace_name_idx" ON "tags" ("tagspace,name")

It needs to be:

CREATE INDEX "tags_tagspace_name_idx" ON "tags" ("tagspace", "name")

at this point, 11.3 is busted for creating projects using postgres.

Patch to follow.

by shanec@…, 11 years ago

Attachment: trac-postgres-sql.patch added

fix for index column quoting

comment:8 by Christian Boos, 11 years ago

Jonas, looks like a candidate for 0.11.3.1, as it fixes a defect introduced in 0.11.3?

by Felix Schwarz <felix.schwarz@…>, 11 years ago

a test case to ensure that the bug does not creep in again

comment:9 by Christian Boos, 11 years ago

Milestone: 0.11.30.11.4
Severity: blockercritical

Thanks for the patches.

comment:10 by Eli Carter, 11 years ago

Based on a bug report on IRC, a fix for this is in r7923 and r7924 (done before I knew about this bugreport), but does not include testcases.

comment:11 by Jonas Borgström, 11 years ago

Resolution: fixed
Status: reopenedclosed

Test case patch applied in [7938].

This changeset also includes the postgresql test cases in the main test suite. As far as I can tell this should be safe and work even if no postgresql module is available.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Jonas Borgström 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.