mirror of
https://github.com/MariaDB/server.git
synced 2025-05-10 02:01:19 +03:00
InnoDB does not attempt to handle lower_case_table_names == 2 when looking up foreign table names and referenced table name. It turned that server variable into a boolean and ignored the possibility of it being '2'. The setting lower_case_table_names == 2 means that it should be stored and displayed in mixed case as given, but compared internally in lower case. Normally the server deals with this since it stores table names. But InnoDB stores referential constraints for the server, so it needs to keep track of both lower case and given names. This solution creates two table name pointers for each foreign and referenced table name. One to display the name, and one to look it up. Both pointers point to the same allocated string unless this setting is 2. So the overhead added is not too much. Two functions are created in dict0mem.c to populate the ..._lookup versions of these pointers. Both dict_mem_foreign_table_name_lookup_set() and dict_mem_referenced_table_name_lookup_set() are called 5 times each.
42 lines
1.3 KiB
Plaintext
Executable File
42 lines
1.3 KiB
Plaintext
Executable File
CREATE TABLE product (category INT NOT NULL, id INT NOT NULL,
|
|
price DECIMAL, PRIMARY KEY(category, id)) ENGINE=INNODB;
|
|
CREATE TABLE customer (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
|
|
CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT,
|
|
product_category INT NOT NULL,
|
|
product_id INT NOT NULL,
|
|
customer_id INT NOT NULL,
|
|
PRIMARY KEY(no),
|
|
INDEX (product_category, product_id),
|
|
FOREIGN KEY (product_category, product_id)
|
|
REFERENCES product(category, id) ON UPDATE CASCADE ON DELETE RESTRICT,
|
|
INDEX (customer_id),
|
|
FOREIGN KEY (customer_id)
|
|
REFERENCES customer(id)
|
|
) ENGINE=INNODB;
|
|
SELECT * FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS;
|
|
CONSTRAINT_CATALOG def
|
|
CONSTRAINT_SCHEMA test
|
|
CONSTRAINT_NAME product_order_ibfk_1
|
|
UNIQUE_CONSTRAINT_CATALOG def
|
|
UNIQUE_CONSTRAINT_SCHEMA test
|
|
UNIQUE_CONSTRAINT_NAME PRIMARY
|
|
MATCH_OPTION NONE
|
|
UPDATE_RULE CASCADE
|
|
DELETE_RULE RESTRICT
|
|
TABLE_NAME product_order
|
|
REFERENCED_TABLE_NAME product
|
|
CONSTRAINT_CATALOG def
|
|
CONSTRAINT_SCHEMA test
|
|
CONSTRAINT_NAME product_order_ibfk_2
|
|
UNIQUE_CONSTRAINT_CATALOG def
|
|
UNIQUE_CONSTRAINT_SCHEMA test
|
|
UNIQUE_CONSTRAINT_NAME PRIMARY
|
|
MATCH_OPTION NONE
|
|
UPDATE_RULE RESTRICT
|
|
DELETE_RULE RESTRICT
|
|
TABLE_NAME product_order
|
|
REFERENCED_TABLE_NAME customer
|
|
DROP TABLE product_order;
|
|
DROP TABLE product;
|
|
DROP TABLE customer;
|