#7600 closed defect (fixed)
[PATCH] Trac does not send object names in quotes to PostgreSQL
Reported by: | 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: | |||
Internal 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)
Change History (15)
comment:1 by , 16 years ago
Version: | 0.10.5 → 0.12dev |
---|
by , 16 years ago
Attachment: | postgres_quoting.2.patch added |
---|
re-did my patch, this time with unit tests
comment:2 by , 16 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 , 16 years ago
Keywords: | postgresql added |
---|---|
Milestone: | 0.11.2 → 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 by , 16 years ago
Cc: | added |
---|
comment:5 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 by , 16 years ago
Owner: | set to |
---|
comment:7 by , 16 years ago
Resolution: | fixed |
---|---|
Severity: | normal → blocker |
Status: | closed → reopened |
Version: | 0.12dev → 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.
comment:8 by , 16 years ago
Jonas, looks like a candidate for 0.11.3.1, as it fixes a defect introduced in 0.11.3?
by , 16 years ago
Attachment: | testcase_quoting_multiple_indexes.patch added |
---|
a test case to ensure that the bug does not creep in again
comment:9 by , 16 years ago
Milestone: | 0.11.3 → 0.11.4 |
---|---|
Severity: | blocker → critical |
Thanks for the patches.
comment:10 by , 16 years ago
comment:11 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → 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.
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.