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

data-type-string: Corrections (#11155) #11256

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #11155

What is changed, added or deleted? (Required)

  • Add remark about default row/column sizes for types that are over the default 6 MiB.
  • Correct the text for TEXT(M)

From the mysql docs on string data types:

An optional length M can be given for this type. If this is done, MySQL creates the column as the smallest TEXT type large enough to hold values M characters long.

sql> CREATE TABLE t1 (id int primary key, c1 TEXT(60), c2 TEXT(70), c3 TEXT(70) CHARSET ASCII);
Query OK, 0 rows affected (0.1513 sec)

sql> SHOW CREATE TABLE t1\G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `id` int(11) NOT NULL,
  `c1` tinytext DEFAULT NULL,
  `c2` text DEFAULT NULL,
  `c3` tinytext CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
1 row in set (0.0003 sec)

sql> CREATE TABLE t1 (id int primary key, c1 TEXT(0));
ERROR: 1050 (42S01): Table 'test.t1' already exists

So:

  • TEXT(60) results in TINYTEXT (60×4=240, which is less than 255)
  • TEXT(70) results in TEXT (70×4=280, which is more than 255)
  • TEXT(70) CHARACTER SET ASCII results in TINYTEXT (70×1=70, which is less than 255)
sql> CREATE TABLE t2 (id int primary key, c1 TEXT(0));
Query OK, 0 rows affected (0.1293 sec)

sql> INSERT INTO t2 VALUES (1, 'some text');
Query OK, 1 row affected (0.0112 sec)

sql> TABLE t2;
+----+-----------+
| id | c1        |
+----+-----------+
|  1 | some text |
+----+-----------+
1 row in set (0.0011 sec)

sql> SHOW CREATE TABLE t2\G
*************************** 1. row ***************************
       Table: t2
Create Table: CREATE TABLE `t2` (
  `id` int(11) NOT NULL,
  `c1` tinytext DEFAULT NULL,
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
1 row in set (0.0003 sec)

This is to show that a TEXT(0) can actually hold a string of 9 characters (and 9 bytes).

sql> CREATE TABLE t3 (id int primary key, c1 TEXT(4294967296));
ERROR: 1439 (42000): Display width out of range for column 'c1' (max = 4294967295)

sql> CREATE TABLE t3 (id int primary key, c1 TEXT(4294967295));
Query OK, 0 rows affected (0.1685 sec)

This error says this is the display width, but I don't think that's really true as that is only used for integer types.

Closes #4014

Which TiDB version(s) do your changes apply to? (Required)

  • master (the latest development version)
  • v6.4 (TiDB 6.4 versions)
  • v6.3 (TiDB 6.3 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)
  • v5.3 (TiDB 5.3 versions)
  • v5.2 (TiDB 5.2 versions)
  • v5.1 (TiDB 5.1 versions)
  • v5.0 (TiDB 5.0 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@ti-chi-bot ti-chi-bot mentioned this pull request Nov 9, 2022
13 tasks
@ti-chi-bot
Copy link
Member Author

ti-chi-bot commented Nov 9, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • TomShawn

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added area/sql-infra Indicates that the Issue or PR belongs to the area of sql-infra and sql-metadata. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-6.3 This PR is cherry-picked to release-6.3 from a source PR. labels Nov 9, 2022
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 10, 2022
@TomShawn
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member Author

This pull request has been accepted and is ready to merge.

Commit hash: 2846fb2

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 10, 2022
@ti-chi-bot ti-chi-bot merged commit 75c77f5 into pingcap:release-6.3 Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sql-infra Indicates that the Issue or PR belongs to the area of sql-infra and sql-metadata. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/cherry-pick-for-release-6.3 This PR is cherry-picked to release-6.3 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants