Merge pull request #441 from mozilla/issue-438, r=@philbooth
This commit is contained in:
Коммит
5d3d89f280
|
@ -554,8 +554,8 @@ module.exports = function (log, error) {
|
|||
// Select : accounts
|
||||
// Fields : uid, email, normalizedEmail, emailVerified, emailCode, kA, wrapWrapKb, verifierVersion, authSalt,
|
||||
// verifierSetAt, createdAt, locale, lockedAt, profileChangedAt
|
||||
// Where : accounts.uid = LOWER($1)
|
||||
var ACCOUNT = 'CALL account_5(?)'
|
||||
// Where : accounts.uid = $1
|
||||
var ACCOUNT = 'CALL account_6(?)'
|
||||
|
||||
MySql.prototype.account = function (uid) {
|
||||
return this.readFirstResult(ACCOUNT, [uid])
|
||||
|
@ -897,20 +897,9 @@ module.exports = function (log, error) {
|
|||
// verifierSetAt, createdAt, lockedAt, primaryEmail, profileChangedAt
|
||||
// Where : emails.normalizedEmail = LOWER($1)
|
||||
//
|
||||
// There's a newer version of this query named `accountRecord_4`
|
||||
// which coalesces the `profileChangedAt` column from values in the db.
|
||||
// We're experiencing unexpectedly bad query performance for reasons
|
||||
// that we don't yet understand, so we've reverted to using an older
|
||||
// version of the query while we're figuring that out, and doing the
|
||||
// coalesce here in code.
|
||||
// Ref: https://github.com/mozilla/fxa-content-server/issues/6655
|
||||
var GET_ACCOUNT_RECORD = 'CALL accountRecord_2(?)'
|
||||
var GET_ACCOUNT_RECORD = 'CALL accountRecord_5(?)'
|
||||
MySql.prototype.accountRecord = function (email) {
|
||||
return this.readFirstResult(GET_ACCOUNT_RECORD, [email])
|
||||
.then(record => {
|
||||
record.profileChangedAt = record.verifierSetAt || record.createdAt
|
||||
return record
|
||||
})
|
||||
}
|
||||
|
||||
// Select : emails
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
// The expected patch level of the database. Update if you add a new
|
||||
// patch in the ./schema/ directory.
|
||||
module.exports.level = 91
|
||||
module.exports.level = 92
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
SET NAMES utf8mb4 COLLATE utf8mb4_bin;
|
||||
|
||||
CALL assertPatchLevel('91');
|
||||
|
||||
-- Removes the LOWER(inUid) requirement on the WHERE clause
|
||||
CREATE PROCEDURE `account_6` (
|
||||
IN `inUid` BINARY(16)
|
||||
)
|
||||
BEGIN
|
||||
SELECT
|
||||
a.uid,
|
||||
a.email,
|
||||
a.normalizedEmail,
|
||||
a.emailVerified,
|
||||
a.emailCode,
|
||||
a.kA,
|
||||
a.wrapWrapKb,
|
||||
a.verifierVersion,
|
||||
a.authSalt,
|
||||
a.verifierSetAt,
|
||||
a.createdAt,
|
||||
a.locale,
|
||||
a.lockedAt,
|
||||
COALESCE(a.verifierSetAt, a.createdAt) AS profileChangedAt
|
||||
FROM
|
||||
accounts a
|
||||
WHERE
|
||||
a.uid = inUid
|
||||
;
|
||||
END;
|
||||
|
||||
-- Specify the email string encoding for `inEmail`. MySQL fails to use the
|
||||
-- correct index in subquery if this is not set.
|
||||
-- Ref: https://github.com/mozilla/fxa-auth-db-mysql/issues/440
|
||||
CREATE PROCEDURE `accountRecord_5` (
|
||||
IN `inEmail` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin
|
||||
)
|
||||
BEGIN
|
||||
SELECT
|
||||
a.uid,
|
||||
a.email,
|
||||
a.normalizedEmail,
|
||||
a.emailVerified,
|
||||
a.emailCode,
|
||||
a.kA,
|
||||
a.wrapWrapKb,
|
||||
a.verifierVersion,
|
||||
a.authSalt,
|
||||
a.verifierSetAt,
|
||||
a.createdAt,
|
||||
a.locale,
|
||||
a.lockedAt,
|
||||
COALESCE(a.verifierSetAt, a.createdAt) AS profileChangedAt,
|
||||
e.normalizedEmail AS primaryEmail
|
||||
FROM
|
||||
accounts a,
|
||||
emails e
|
||||
WHERE
|
||||
a.uid = (SELECT uid FROM emails WHERE normalizedEmail = LOWER(inEmail))
|
||||
AND
|
||||
a.uid = e.uid
|
||||
AND
|
||||
e.isPrimary = true;
|
||||
END;
|
||||
|
||||
UPDATE dbMetadata SET value = '92' WHERE name = 'schema-patch-level';
|
|
@ -0,0 +1,6 @@
|
|||
-- SET NAMES utf8mb4 COLLATE utf8mb4_bin;
|
||||
|
||||
-- DROP PROCEDURE account_6;
|
||||
-- DROP PROCEDURE accountRecord_5;
|
||||
|
||||
-- UPDATE dbMetadata SET value = '91' WHERE name = 'schema-patch-level';
|
Загрузка…
Ссылка в новой задаче