USER is a reserved keyword in SQL92, SQL99

USER is a reserved keyword in SQL92, SQL99

Issue ID:168
Issue Category:bug
Component:core
Priority:major
Status:active
Assigned:evan
Version:0.7
Milestone:1.0

USER is a resreved keyword in the SQL standard.

Using it as the name of the table for Laconica users obviously works fine in MySQL, but definitely breaks in PostgreSQL, and could cause problems in other places down the road.

(In theory you can just always enclose the tablename in quotes, but it appears that DB_DataObject doesn't do that, and it's probably kind of a pain anyhow.)

Changing the table name to "users" (plural) or lac_user or something else would, first of all, open the door to using Postgres, and would also likely also avoid other compatibility issues down the road.

--- Gotta patch, will integrate and test after version 0.5 -- evan July 11, 2008, at 04:15 PM

---

Requires patching actions/public.php actions/publicrss.php and the {databasename}.ini file that DB_DataObject uses and the classes/User.php and the db/laconica.sql for initial setup. For active installations would require an alter database to change the name for the existing user table and resetting foreign key constraints on the user_openid table, the confirm_address_table, and the remember_me table. Diffs using laconica_user as the table name have been emailed to Evan. Still to be done is the sql script to update existing database installations.

Legacy Data

This issue was migrated from another tracking system. The legacy data at time of import is provided below as a reference.

Ticket ID: 
168
Reported by: 
mde
Owner: 
evan
Status: 
closed
Resolution: 
closed
Type: 
bug
Component: 
core
Priority: 
2
Version: 
0.7
Milestone: 
1.0

Updates

#1

['db']['quote_identifiers'] is currently used as a workaround for PostgreSQL.

#2

This is fixed.

#3

Status:fixed» active

This is broken again in 1.0.x. Running checkschema.php to upgrade from 0.8.3 to 1.0.x on PostgreSQL 9.0 errors out when it tries to modify the "user" table without quoting the name of the table:

ALTER TABLE user DROP CONSTRAINT user_design_id_fkey,
...

It looks like the 1.0.x code in lib/schema.php users $this->quoteIdentifier() for the table name in createTable(), but fails to do the same for addColumn(), dropIndex(), etc.

#4

#5

Also pushed https://gitorious.org/~dbs/statusnet/dbs-mainline/commit/32eec956f9f4124... to the same branch - caught this one while trying a clean install.

#6

This should definitely be merged. I can't see how it can go wrong, though I will try it out at my instance before I'll say anything more .)

Login or Register to modify this issue, or to receive updates by email.

You can also subscribe to the RSS feed for updates to this issue.