MySQL 8.0 issue when deleting an item which is referenced in another table by a foreign key Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Deleting a row with a self-referencing foreign keyForeign key constraints: When to use ON UPDATE and ON DELETEhow to drop unique key on foreign key in mysql?Add Foreign Key to existing tablemysql syntax error 1064 at line 194 add foreign key for many-to-many relationshipHow to do Insert in many-to-many scenario while working with entity framework for mysql?Getting syntax error when declaring FOREIGN KEYS in MYSQL (using innoDB)#1005 - Can't create table 'morina.#sql-3e25_35102' (errno: 150)MySQL FOREIGN KEY Constraints SyntaxMySql and creating Foreign keys
All ASCII characters with a given bit count
Does a Draconic Bloodline sorcerer's doubled proficiency bonus for Charisma checks against dragons apply to all dragon types or only the chosen one?
What is the purpose of the side handle on a hand ("eggbeater") drill?
Marquee sign letters
Arriving in Atlanta (after US Preclearance in Dublin). Will I go through TSA security in Atlanta to transfer to a connecting flight?
What's parked in Mil Moscow helicopter plant?
What's the difference between using dependency injection with a container and using a service locator?
Variable does not exist: sObjectType (Task.sObjectType)
Co-worker works way more than he should
Putting Ant-Man on house arrest
Is a self contained air-bullet cartridge feasible?
How can I wire a 9-position switch so that each position turns on one more LED than the one before?
When I export an AI 300x60 art board it saves with bigger dimensions
In search of the origins of term censor, I hit a dead end stuck with the greek term, to censor, λογοκρίνω
Can gravitational waves pass through a black hole?
How to begin with a paragraph in latex
How was Lagrange appointed professor of mathematics so early?
Preserving file and folder permissions with rsync
Why aren't road bicycle wheels tiny?
/bin/ls sorts differently than just ls
Where to find documentation for `whois` command options?
"Working on a knee"
Israeli soda type drink
Why isn't everyone flabbergasted about Bran's "gift"?
MySQL 8.0 issue when deleting an item which is referenced in another table by a foreign key
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Deleting a row with a self-referencing foreign keyForeign key constraints: When to use ON UPDATE and ON DELETEhow to drop unique key on foreign key in mysql?Add Foreign Key to existing tablemysql syntax error 1064 at line 194 add foreign key for many-to-many relationshipHow to do Insert in many-to-many scenario while working with entity framework for mysql?Getting syntax error when declaring FOREIGN KEYS in MYSQL (using innoDB)#1005 - Can't create table 'morina.#sql-3e25_35102' (errno: 150)MySQL FOREIGN KEY Constraints SyntaxMySql and creating Foreign keys
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Context:
I have two tables, let's call them A and B. B has a column reference for table A and a constraint (foreign key) set so that when deleting the referenced object, the value is set to null (ON DELETE SET NULL).
CREATE TABLE `A` (
`ID` VARCHAR(32) CHARACTER SET UTF8 COLLATE UTF8_BIN NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
CREATE TABLE `B` (
`COL_B` VARCHAR(32) CHARACTER SET UTF8 COLLATE UTF8_BIN
DEFAULT NULL,
CONSTRAINT `B_FK5` FOREIGN KEY (`COL_B`) REFERENCES `A` (`ID`) ON
DELETE SET NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
INSERT INTO `A` (`ID`) VALUES (‘1’);
INSERT INTO `B` (`COL_B`) VALUES (‘1’);
DELETE FROM A;
SELECT * FROM B;
Problem:
When deleting an item from table A, the reference in table B is not set to null (the key remains although the object with that key was deleted).
Extra info:
Up until now I used MySql 5.7 and didn't have this problem. After switching to MySql 8.0.15 I started to see this behaviour. Furthermore, this problem occurs only on local and CD machines and doesn't reproduce on cloud machines. As an impact, some tests started to fail when running CD jobs.
Another strange thing is that right before deleting the item, if a modification is made in table A (switch order of columns), the issue doesn't reproduce.
I've also tried to use a MySQL run on Docker and the issue is the same.
Really, this is a blocking issue and the fact that it happens only in this case makes it more difficult to understand. From MySQL logs I couldn't get squat.
Any clue that could help with this investigation?
mysql
add a comment |
Context:
I have two tables, let's call them A and B. B has a column reference for table A and a constraint (foreign key) set so that when deleting the referenced object, the value is set to null (ON DELETE SET NULL).
CREATE TABLE `A` (
`ID` VARCHAR(32) CHARACTER SET UTF8 COLLATE UTF8_BIN NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
CREATE TABLE `B` (
`COL_B` VARCHAR(32) CHARACTER SET UTF8 COLLATE UTF8_BIN
DEFAULT NULL,
CONSTRAINT `B_FK5` FOREIGN KEY (`COL_B`) REFERENCES `A` (`ID`) ON
DELETE SET NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
INSERT INTO `A` (`ID`) VALUES (‘1’);
INSERT INTO `B` (`COL_B`) VALUES (‘1’);
DELETE FROM A;
SELECT * FROM B;
Problem:
When deleting an item from table A, the reference in table B is not set to null (the key remains although the object with that key was deleted).
Extra info:
Up until now I used MySql 5.7 and didn't have this problem. After switching to MySql 8.0.15 I started to see this behaviour. Furthermore, this problem occurs only on local and CD machines and doesn't reproduce on cloud machines. As an impact, some tests started to fail when running CD jobs.
Another strange thing is that right before deleting the item, if a modification is made in table A (switch order of columns), the issue doesn't reproduce.
I've also tried to use a MySQL run on Docker and the issue is the same.
Really, this is a blocking issue and the fact that it happens only in this case makes it more difficult to understand. From MySQL logs I couldn't get squat.
Any clue that could help with this investigation?
mysql
add a comment |
Context:
I have two tables, let's call them A and B. B has a column reference for table A and a constraint (foreign key) set so that when deleting the referenced object, the value is set to null (ON DELETE SET NULL).
CREATE TABLE `A` (
`ID` VARCHAR(32) CHARACTER SET UTF8 COLLATE UTF8_BIN NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
CREATE TABLE `B` (
`COL_B` VARCHAR(32) CHARACTER SET UTF8 COLLATE UTF8_BIN
DEFAULT NULL,
CONSTRAINT `B_FK5` FOREIGN KEY (`COL_B`) REFERENCES `A` (`ID`) ON
DELETE SET NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
INSERT INTO `A` (`ID`) VALUES (‘1’);
INSERT INTO `B` (`COL_B`) VALUES (‘1’);
DELETE FROM A;
SELECT * FROM B;
Problem:
When deleting an item from table A, the reference in table B is not set to null (the key remains although the object with that key was deleted).
Extra info:
Up until now I used MySql 5.7 and didn't have this problem. After switching to MySql 8.0.15 I started to see this behaviour. Furthermore, this problem occurs only on local and CD machines and doesn't reproduce on cloud machines. As an impact, some tests started to fail when running CD jobs.
Another strange thing is that right before deleting the item, if a modification is made in table A (switch order of columns), the issue doesn't reproduce.
I've also tried to use a MySQL run on Docker and the issue is the same.
Really, this is a blocking issue and the fact that it happens only in this case makes it more difficult to understand. From MySQL logs I couldn't get squat.
Any clue that could help with this investigation?
mysql
Context:
I have two tables, let's call them A and B. B has a column reference for table A and a constraint (foreign key) set so that when deleting the referenced object, the value is set to null (ON DELETE SET NULL).
CREATE TABLE `A` (
`ID` VARCHAR(32) CHARACTER SET UTF8 COLLATE UTF8_BIN NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
CREATE TABLE `B` (
`COL_B` VARCHAR(32) CHARACTER SET UTF8 COLLATE UTF8_BIN
DEFAULT NULL,
CONSTRAINT `B_FK5` FOREIGN KEY (`COL_B`) REFERENCES `A` (`ID`) ON
DELETE SET NULL
) ENGINE=INNODB DEFAULT CHARSET=UTF8;
INSERT INTO `A` (`ID`) VALUES (‘1’);
INSERT INTO `B` (`COL_B`) VALUES (‘1’);
DELETE FROM A;
SELECT * FROM B;
Problem:
When deleting an item from table A, the reference in table B is not set to null (the key remains although the object with that key was deleted).
Extra info:
Up until now I used MySql 5.7 and didn't have this problem. After switching to MySql 8.0.15 I started to see this behaviour. Furthermore, this problem occurs only on local and CD machines and doesn't reproduce on cloud machines. As an impact, some tests started to fail when running CD jobs.
Another strange thing is that right before deleting the item, if a modification is made in table A (switch order of columns), the issue doesn't reproduce.
I've also tried to use a MySQL run on Docker and the issue is the same.
Really, this is a blocking issue and the fact that it happens only in this case makes it more difficult to understand. From MySQL logs I couldn't get squat.
Any clue that could help with this investigation?
mysql
mysql
edited Mar 22 at 18:53
snakecharmerb
12.5k42553
12.5k42553
asked Mar 22 at 14:55
cozma.andicozma.andi
165
165
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302357%2fmysql-8-0-issue-when-deleting-an-item-which-is-referenced-in-another-table-by-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55302357%2fmysql-8-0-issue-when-deleting-an-item-which-is-referenced-in-another-table-by-a%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown