Edgewall Software
Modify

Ticket #7600 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

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

Reported by: devrim@… Owned by: jonas
Priority: normal Milestone: 0.11.4
Component: general Version: 0.11.3
Severity: critical Keywords: postgresql
Cc: felix.schwarz@…
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

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

Download all attachments as: .zip

Change History

comment:1 Changed 3 years ago by felix.schwarz@…

  • Version changed from 0.10.5 to 0.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.

Changed 3 years ago by felix.schwarz@…

patch against 0.11

Changed 3 years ago by felix.schwarz@…

re-did my patch, this time with unit tests

comment:2 Changed 3 years ago by felix.schwarz@…

  • Milestone set to 0.11.2
  • Summary changed from Trac does not send object names in quotes to PostgreSQL to [PATCH] Trac does not send object names in quotes to PostgreSQL

modifying subject to make my patch more visible

comment:3 Changed 3 years ago by cboos

  • Keywords postgresql added
  • Milestone changed from 0.11.2 to 0.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 Changed 3 years ago by felix.schwarz@…

  • Cc felix.schwarz@… added

comment:5 Changed 3 years ago by jonas

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:6 Changed 3 years ago by cboos

  • Owner set to jonas

comment:7 Changed 3 years ago by shanec@…

  • Resolution fixed deleted
  • Severity changed from normal to blocker
  • Status changed from closed to reopened
  • Version changed from 0.12dev to 0.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.

Changed 3 years ago by shanec@…

fix for index column quoting

comment:8 Changed 3 years ago by cboos

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

Changed 3 years ago by Felix Schwarz <felix.schwarz@…>

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

comment:9 Changed 3 years ago by cboos

  • Milestone changed from 0.11.3 to 0.11.4
  • Severity changed from blocker to critical

Thanks for the patches.

comment:10 Changed 3 years ago by ecarter

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 Changed 3 years ago by jonas

  • Resolution set to fixed
  • Status changed from reopened to closed

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.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
to The owner will be changed from jonas. Next status will be 'closed'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.