Skip to content

Commit 6fa40b8

Browse files
committed
MDEV-23554 Wrong default value for foreign_key_checks variable
Sys_var_bit::session_save_default() ignored reverse_semantics property.
1 parent 4a90bb8 commit 6fa40b8

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

mysql-test/suite/innodb/r/foreign_key.result

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ PRIMARY KEY (store_id),
167167
UNIQUE KEY idx_unique_manager (manager_staff_id),
168168
CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ON DELETE RESTRICT ON UPDATE CASCADE
169169
) ENGINE=InnoDB;
170-
SET FOREIGN_KEY_CHECKS=DEFAULT;
171170
LOCK TABLE staff WRITE;
172171
UNLOCK TABLES;
173172
DROP TABLES staff, store;

mysql-test/suite/innodb/t/foreign_key.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ CREATE TABLE store (
136136
UNIQUE KEY idx_unique_manager (manager_staff_id),
137137
CONSTRAINT fk_store_staff FOREIGN KEY (manager_staff_id) REFERENCES staff (staff_id) ON DELETE RESTRICT ON UPDATE CASCADE
138138
) ENGINE=InnoDB;
139-
SET FOREIGN_KEY_CHECKS=DEFAULT;
140139

141140
LOCK TABLE staff WRITE;
142141
UNLOCK TABLES;

mysql-test/suite/sys_vars/r/foreign_key_checks_basic.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SET @@session.foreign_key_checks = 1;
77
SET @@session.foreign_key_checks = DEFAULT;
88
SELECT @@session.foreign_key_checks;
99
@@session.foreign_key_checks
10-
0
10+
1
1111
'#---------------------FN_DYNVARS_032_02-------------------------#'
1212
SET foreign_key_checks = 1;
1313
SELECT @@foreign_key_checks;

mysql-test/suite/sys_vars/r/unique_checks_basic.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SET @@session.unique_checks= 1;
77
SET @@session.unique_checks= DEFAULT;
88
SELECT @@session.unique_checks;
99
@@session.unique_checks
10-
0
10+
1
1111
'#--------------------FN_DYNVARS_005_04-------------------------#'
1212
SET @@session.unique_checks =1;
1313
SELECT @@session.unique_checks;

sql/sys_vars.ic

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,13 +1704,16 @@ public:
17041704
return false;
17051705
}
17061706
void session_save_default(THD *thd, set_var *var)
1707-
{ var->save_result.ulonglong_value= global_var(ulonglong) & bitmask; }
1707+
{
1708+
var->save_result.ulonglong_value=
1709+
(reverse_semantics == !(global_var(ulonglong) & bitmask));
1710+
}
17081711
void global_save_default(THD *thd, set_var *var)
17091712
{ var->save_result.ulonglong_value= option.def_value; }
17101713

17111714
uchar *valptr(THD *thd, ulonglong val)
17121715
{
1713-
thd->sys_var_tmp.my_bool_value= reverse_semantics ^ ((val & bitmask) != 0);
1716+
thd->sys_var_tmp.my_bool_value= (reverse_semantics == !(val & bitmask));
17141717
return (uchar*) &thd->sys_var_tmp.my_bool_value;
17151718
}
17161719
uchar *session_value_ptr(THD *thd, const LEX_STRING *base)

0 commit comments

Comments
 (0)