mysql icon indicating copy to clipboard operation
mysql copied to clipboard

UNKNOWN_CODE_PLEASE_REPORT: ERROR 3730 (HY000): drop table / foreign key constraint

Open jcward opened this issue 4 years ago • 1 comments

MySQL server version 8 mysqljs 2.18.1

CREATE TABLE IF NOT EXISTS users (
  id INTEGER NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
);

CREATE TABLE IF NOT EXISTS foo (
  user_id INTEGER NOT NULL,
  FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

DROP TABLE users;

ERROR 3730 (HY000): Cannot drop table 'users' referenced by a foreign key constraint 'foo_ibfk_1' on table 'foo'.

Error: UNKNOWN_CODE_PLEASE_REPORT: Cannot drop table 'a' referenced by a foreign key constraint 'b_ibfk_1' on table 'b'.
      >     at Query.Sequence._packetToError (...node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
      >     at Query.ErrorPacket (...node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
      >     at Protocol._parsePacket (...node_modules/mysql/lib/protocol/Protocol.js:291:23)
      >     at Parser._parsePacket (...node_modules/mysql/lib/protocol/Parser.js:433:10)
      >     at Parser.write (...node_modules/mysql/lib/protocol/Parser.js:43:10)
      >     at Protocol.write (...node_modules/mysql/lib/protocol/Protocol.js:38:16)
      >     at Socket.<anonymous> (...node_modules/mysql/lib/Connection.js:88:28)
      >     at Socket.<anonymous> (...node_modules/mysql/lib/Connection.js:526:10)
      >     at Socket.emit (events.js:315:20)
      >     at addChunk (_stream_readable.js:295:12)

jcward avatar Sep 05 '20 22:09 jcward

I've created a pr that deals with this, #2386. It works well, though we'll have to see if it'll ever be merged

ARitz-Cracker avatar Oct 12 '20 18:10 ARitz-Cracker