mirror of
https://github.com/minio/minio.git
synced 2025-04-04 03:40:30 -04:00
fix: mysql notification target table creation (#14350)
Add a generated hash column as the primary key for the key name as MySQL does not allow indexes on long VARCHAR columns.
This commit is contained in:
parent
b23b19e5c3
commit
bc110d8055
@ -38,13 +38,16 @@ import (
|
|||||||
const (
|
const (
|
||||||
mysqlTableExists = `SELECT 1 FROM %s;`
|
mysqlTableExists = `SELECT 1 FROM %s;`
|
||||||
// Some MySQL has a 3072 byte limit on key sizes.
|
// Some MySQL has a 3072 byte limit on key sizes.
|
||||||
mysqlCreateNamespaceTable = `CREATE TABLE %s (key_name VARCHAR(3072), value JSON, PRIMARY KEY (key_name))
|
mysqlCreateNamespaceTable = `CREATE TABLE %s (
|
||||||
CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic;`
|
key_name VARCHAR(3072) NOT NULL,
|
||||||
|
key_hash CHAR(64) GENERATED ALWAYS AS (SHA2(key_name, 256)) STORED NOT NULL PRIMARY KEY,
|
||||||
|
value JSON)
|
||||||
|
CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic;`
|
||||||
mysqlCreateAccessTable = `CREATE TABLE %s (event_time DATETIME NOT NULL, event_data JSON)
|
mysqlCreateAccessTable = `CREATE TABLE %s (event_time DATETIME NOT NULL, event_data JSON)
|
||||||
ROW_FORMAT = Dynamic;`
|
ROW_FORMAT = Dynamic;`
|
||||||
|
|
||||||
mysqlUpdateRow = `INSERT INTO %s (key_name, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value=VALUES(value);`
|
mysqlUpdateRow = `INSERT INTO %s (key_name, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value=VALUES(value);`
|
||||||
mysqlDeleteRow = `DELETE FROM %s WHERE key_name = ?;`
|
mysqlDeleteRow = `DELETE FROM %s WHERE key_hash = SHA2(?, 256);`
|
||||||
mysqlInsertRow = `INSERT INTO %s (event_time, event_data) VALUES (?, ?);`
|
mysqlInsertRow = `INSERT INTO %s (event_time, event_data) VALUES (?, ?);`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user