Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: schemadiff to calculate "Row size too large" and index size #15955

Open
shlomi-noach opened this issue May 16, 2024 · 2 comments

Comments

@shlomi-noach
Copy link
Contributor

Feature Description

MySQL/InnoDB limit the total size of char and binary columns:

  • 8126 for COMPACT
  • 65535 for DYNAMIC, COMPRESSED

Key length is limited to:

  • 767 bytes for COMPACT,
  • 3072 bytes for DYNAMIC, COMPRESSED

These lengths depend on the character set used for char columns. schemadiff's validate() function should be able to compute these.

Use Case(s)

Better schema validation by schemadiff.

@shlomi-noach
Copy link
Contributor Author

Simple table structure to test with:

CREATE TABLE `t` (
	`id` int NOT NULL AUTO_INCREMENT,
	`v1` varchar(1000) NOT NULL,
	`v2` varchar(1000) NOT NULL,
	`v3` varchar(1000) NOT NULL,
	`v4` varchar(1000) NOT NULL,
	`v5` varchar(1000) NOT NULL,
	`v6` varchar(1000) NOT NULL,
	`v7` varchar(1000) NOT NULL,
	PRIMARY KEY (`id`),
	KEY `v1_idx` (`v1`)
) ENGINE InnoDB,
  CHARSET utf8mb3,
  ROW_FORMAT COMPACT;

@shlomi-noach
Copy link
Contributor Author

InnoDB snippet:

uint ha_innobase::max_supported_key_part_length(
    HA_CREATE_INFO *create_info) const {
  /* A table format specific index column length check will be performed
  at ha_innobase::add_index() and row_create_index_for_mysql() */
  switch (create_info->row_type) {
    case ROW_TYPE_REDUNDANT:
    case ROW_TYPE_COMPACT:
      return (REC_ANTELOPE_MAX_INDEX_COL_LEN - 1);
      break;
    default:
      return (REC_VERSION_56_MAX_INDEX_COL_LEN);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant