Closed Bug 1196092 Opened 9 years ago Closed 9 years ago

Switch logincookies primary key to auto_incremented id, make cookie a secondary UNIQUE key

Categories

(bugzilla.mozilla.org :: General, defect)

Production
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dylan, Assigned: dylan)

References

Details

Attachments

(1 file, 1 obsolete file)

This is a required change for bug 1192687, as natural primary keys (such as "cookie") are very difficult to work with, especially when they are secrets.
Attached patch 1196092_5.patch (obsolete) — Splinter Review
This was remarkably hard to get right. bz_column_info_real() is used because bz_column_info() returns our fake, shadow schema...
Attachment #8650840 - Flags: review?(glob)
Comment on attachment 8650840 [details] [diff] [review]
1196092_5.patch

Review of attachment 8650840 [details] [diff] [review]:
-----------------------------------------------------------------

Updating column cookie in table logincookies ...
Old: varchar(22) PRIMARY KEY NOT NULL
New: varchar(22) NOT NULL
DBD::mysql::db do failed: Can't DROP 'PRIMARY'; check that column/key exists [for Statement "ALTER TABLE logincookies DROP PRIMARY KEY"] at Bugzilla/DB.pm line 760.
Attachment #8650840 - Flags: review?(glob) → review-
Attached patch 1196092_6.patchSplinter Review
It would appear I underestimated our DB schema layer. It can actually drop the primary key itself.
Attachment #8650840 - Attachment is obsolete: true
Attachment #8651196 - Flags: review?(glob)
Comment on attachment 8651196 [details] [diff] [review]
1196092_6.patch

Review of attachment 8651196 [details] [diff] [review]:
-----------------------------------------------------------------

this generates the same sql, which fails:

Updating column cookie in table logincookies ...
Old: varchar(22) PRIMARY KEY NOT NULL
New: varchar(22) NOT NULL
DBD::mysql::db do failed: Can't DROP 'PRIMARY'; check that column/key exists [for Statement "ALTER TABLE logincookies DROP PRIMARY KEY"] at Bugzilla/DB.pm line 760.
Attachment #8651196 - Flags: review?(glob) → review-
Comment on attachment 8651196 [details] [diff] [review]
1196092_6.patch

Review of attachment 8651196 [details] [diff] [review]:
-----------------------------------------------------------------

ah, my bad.  for reasons that are unknown logincookies.cookie isn't a PK in the db i'm using, and a mysql quirk had it reporting it incorrectly ("A UNIQUE index may be displayed as PRI if it cannot contain NULL values and there is no PRIMARY KEY in the table").

r=glob

::: Bugzilla/Install/DB.pm
@@ +738,4 @@
>      $dbh->bz_alter_column('logincookies', 'cookie',
> +                            {TYPE => 'varchar(22)', NOTNULL => 1});
> +    $dbh->bz_add_index('logincookies', 'logincookies_cookie_idx',
> +                        {TYPE => 'UNIQUE', FIELDS => ['cookie']});

nit: this line and the previous {TYPE should line up with the '
Attachment #8651196 - Flags: review- → review+
To ssh://gitolite3@git.mozilla.org/webtools/bmo/bugzilla.git
   0b05719..57f911c  master -> master
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: