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
Change History
comment:1 Changed 3 years ago by felix.schwarz@…
- Version changed from 0.10.5 to 0.12dev
Changed 3 years ago by felix.schwarz@…
- Attachment postgres_quoting.2.patch added
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
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@…
- Attachment trac-postgres-sql.patch added
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@…>
- Attachment testcase_quoting_multiple_indexes.patch added
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
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.



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.