Skip to content

Commit

Permalink
Move all sidecar tables explicitly to utf8mb4
Browse files Browse the repository at this point in the history
And then ignore charset/collation when either is empty

Signed-off-by: Matt Lord <[email protected]>
  • Loading branch information
mattlord committed Aug 28, 2024
1 parent 403b474 commit ebad904
Show file tree
Hide file tree
Showing 20 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/misc/heartbeat.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ CREATE TABLE IF NOT EXISTS heartbeat
tabletUid INT UNSIGNED NOT NULL,
ts BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (`keyspaceShard`)
) engine = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/misc/reparent_journal.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ CREATE TABLE IF NOT EXISTS reparent_journal
`replication_position` varbinary(64000) DEFAULT NULL,

PRIMARY KEY (`time_created_ns`)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/onlineddl/schema_migrations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ CREATE TABLE IF NOT EXISTS schema_migrations
KEY `table_complete_idx` (`migration_status`, `keyspace`(64), `mysql_table`(64), `completed_timestamp`),
KEY `migration_context_idx` (`migration_context`(64)),
KEY `reverted_uuid_idx` (`reverted_uuid`)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/schemaengine/tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ CREATE TABLE IF NOT EXISTS tables
CREATE_STATEMENT longtext,
CREATE_TIME BIGINT,
PRIMARY KEY (TABLE_SCHEMA, TABLE_NAME)
) engine = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/schemaengine/udfs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ CREATE TABLE IF NOT EXISTS udfs
FUNCTION_RETURN_TYPE varchar(20) CHARACTER SET `utf8mb3` COLLATE `utf8mb3_bin` NOT NULL,
FUNCTION_TYPE varchar(20) CHARACTER SET `utf8mb3` COLLATE `utf8mb3_bin` NOT NULL,
PRIMARY KEY (FUNCTION_NAME)
) engine = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/schemaengine/views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ CREATE TABLE IF NOT EXISTS views
CREATE_STATEMENT longtext,
VIEW_DEFINITION longtext NOT NULL,
PRIMARY KEY (TABLE_SCHEMA, TABLE_NAME)
) engine = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/twopc/dt_participant.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ CREATE TABLE IF NOT EXISTS dt_participant
keyspace varchar(256) NOT NULL,
shard varchar(256) NOT NULL,
primary key(dtid, id)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/twopc/dt_state.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ CREATE TABLE IF NOT EXISTS dt_state
time_created bigint NOT NULL,
primary key(dtid),
key (time_created)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/twopc/redo_state.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ CREATE TABLE IF NOT EXISTS redo_state(
state bigint NOT NULL,
time_created bigint NOT NULL,
primary key(dtid)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/twopc/redo_statement.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ CREATE TABLE IF NOT EXISTS redo_statement(
id bigint NOT NULL,
statement mediumblob NOT NULL,
primary key(dtid, id)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/vdiff/vdiff.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ CREATE TABLE IF NOT EXISTS vdiff
UNIQUE KEY `uuid_idx` (`vdiff_uuid`),
KEY `state` (`state`),
KEY `ks_wf_idx` (`keyspace`(64), `workflow`(64))
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/vdiff/vdiff_log.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ CREATE TABLE IF NOT EXISTS vdiff_log
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`message` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/vdiff/vdiff_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ CREATE TABLE IF NOT EXISTS vdiff_table
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`vdiff_id`, `table_name`)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/vreplication/copy_state.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ CREATE TABLE IF NOT EXISTS copy_state
`lastpk` varbinary(2000) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `vrepl_id` (`vrepl_id`,`table_name`)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/vreplication/post_copy_action.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ CREATE TABLE IF NOT EXISTS post_copy_action(
action JSON NOT NULL,
UNIQUE KEY (vrepl_id, table_name),
PRIMARY KEY(id)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/vreplication/resharding_journal.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ CREATE TABLE IF NOT EXISTS resharding_journal
`db_name` varbinary(255) DEFAULT NULL,
`val` blob,
PRIMARY KEY (`id`)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/vreplication/schema_version.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ CREATE TABLE IF NOT EXISTS schema_version
ddl BLOB DEFAULT NULL,
schemax LONGBLOB NOT NULL,
PRIMARY KEY (id)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/vreplication/vreplication.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ CREATE TABLE IF NOT EXISTS vreplication
`options` json NOT NULL,
PRIMARY KEY (`id`),
KEY `workflow_idx` (`workflow`(64))
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
2 changes: 1 addition & 1 deletion go/vt/sidecardb/schema/vreplication/vreplication_log.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ CREATE TABLE IF NOT EXISTS vreplication_log
`count` bigint NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
KEY `vrepl_id_idx` (`vrepl_id`)
) ENGINE = InnoDB
) ENGINE = InnoDB CHARSET = utf8mb4
1 change: 1 addition & 0 deletions go/vt/sidecardb/sidecardb.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ func (si *schemaInit) getCurrentSchema(tableName string) (string, error) {
// or an ALTER if the table exists but has a different schema.
func (si *schemaInit) findTableSchemaDiff(tableName, current, desired string) (string, error) {
hints := &schemadiff.DiffHints{
TableCharsetCollateStrategy: schemadiff.TableCharsetCollateIgnoreEmpty,
AlterTableAlgorithmStrategy: schemadiff.AlterTableAlgorithmStrategyCopy,
}
env := schemadiff.NewEnv(si.env, si.coll)
Expand Down

0 comments on commit ebad904

Please sign in to comment.