Skip to content

Commit ad8cdef

Browse files
committed
Updated autocommit
1 parent c614cfd commit ad8cdef

File tree

1 file changed

+33
-14
lines changed

1 file changed

+33
-14
lines changed

openidconnect.sql

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -459,36 +459,55 @@ CREATE TABLE `whitelisted_site_scope` (
459459
--
460460
-- Turn off autocommit and start a transaction so that we can use the temp tables
461461
--
462+
-- From https://github.com/mitreid-connect/OpenID-Connect-Java-Spring-Server/blob/master/openid-connect-server-webapp/src/main/resources/db/scopes.sql
463+
--
464+
465+
--
466+
-- Turn off autocommit and start a transaction so that we can use the temp tables
467+
-- Info from: http://stackoverflow.com/questions/2280465/how-do-i-turn-off-autocommit-for-a-mysql-client
468+
-- http://dev.mysql.com/doc/refman/5.7/en/commit.html
469+
--
462470

463-
SET AUTOCOMMIT FALSE;
471+
SET autocommit=0;
464472

465473
START TRANSACTION;
466474

467475
--
468476
-- Insert scope information into the temporary tables.
469477
--
470478

471-
INSERT INTO system_scope_TEMP (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES
472-
('openid', 'log in using your identity', 'user', false, true, false, null),
473-
('profile', 'basic profile information', 'list-alt', false, true, false, null),
474-
('email', 'email address', 'envelope', false, true, false, null),
475-
('address', 'physical address', 'home', false, true, false, null),
476-
('phone', 'telephone number', 'bell', false, true, false, null),
477-
('offline_access', 'offline access', 'time', false, false, false, null);
479+
INSERT INTO system_scope_TEMP (scope, description, icon, allow_dyn_reg, default_scope, structured, structured_param_description) VALUES
480+
('openid', 'log in using your identity', 'user', true, true, false, null),
481+
('profile', 'basic profile information', 'list-alt', true, true, false, null),
482+
('email', 'email address', 'envelope', true, true, false, null),
483+
('address', 'physical address', 'home', true, true, false, null),
484+
('phone', 'telephone number', 'bell', true, true, false, null),
485+
('offline_access', 'offline access', 'time', true, false, false, null);
478486

479487
--
480488
-- Merge the temporary scopes safely into the database. This is a two-step process to keep scopes from being created on every startup with a persistent store.
481489
--
482490

483-
MERGE INTO system_scope
484-
USING (SELECT scope, description, icon, restricted, default_scope, structured, structured_param_description FROM system_scope_TEMP) AS vals(scope, description, icon, restricted, default_scope, structured, structured_param_description)
485-
ON vals.scope = system_scope.scope
486-
WHEN NOT MATCHED THEN
487-
INSERT (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES(vals.scope, vals.description, vals.icon, vals.restricted, vals.default_scope, vals.structured, vals.structured_param_description);
491+
INSERT INTO system_scope (scope, description, icon, allow_dyn_reg, default_scope, structured, structured_param_description)
492+
SELECT scope, description, icon, allow_dyn_reg, default_scope, structured, structured_param_description FROM system_scope_TEMP
493+
ON DUPLICATE KEY UPDATE
494+
scope = values(scope),
495+
description = values(description),
496+
icon = values(icon),
497+
allow_dyn_reg = values(allow_dyn_reg),
498+
default_scope = values(default_scope),
499+
structured = values(structured),
500+
structured_param_description = values(structured_param_description);
501+
502+
-- MERGE INTO system_scope
503+
-- USING (SELECT scope, description, icon, restricted, default_scope, structured, structured_param_description FROM system_scope_TEMP) AS vals(scope, description, icon, restricted, default_scope, structured, structured_param_description)
504+
-- ON vals.scope = system_scope.scope
505+
-- WHEN NOT MATCHED THEN
506+
-- INSERT (scope, description, icon, restricted, default_scope, structured, structured_param_description) VALUES(vals.scope, vals.description, vals.icon, vals.restricted, vals.default_scope, vals.structured, vals.structured_param_description);
488507

489508
COMMIT;
490509

491-
SET AUTOCOMMIT TRUE;
510+
SET autocommit=1;
492511

493512
--
494513
-- Dumping events for database 'OpenIDConnect'

0 commit comments

Comments
 (0)