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

Merged
merged 6 commits into from
Nov 9, 2022

Conversation

dveeden
Copy link
Contributor

@dveeden dveeden commented Nov 4, 2022

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
Copy link
Member

ti-chi-bot commented Nov 4, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • TomShawn
  • tangenta

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 missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 4, 2022
@dveeden dveeden requested review from TomShawn and qiancai November 4, 2022 07:37
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 4, 2022
@shichun-0415 shichun-0415 added translation/doing This PR's assignee is translating this PR. area/sql-infra Indicates that the Issue or PR belongs to the area of sql-infra and sql-metadata. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. needs-cherry-pick-release-6.3 and removed missing-translation-status This PR does not have translation status info. labels Nov 4, 2022
dveeden and others added 5 commits November 9, 2022 12:40
Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Copy link
Contributor

@TomShawn TomShawn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 9, 2022
@TomShawn
Copy link
Contributor

TomShawn commented Nov 9, 2022

/merge

@ti-chi-bot
Copy link
Member

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

Commit hash: ceb8da0

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Nov 9, 2022
@ti-chi-bot ti-chi-bot merged commit 59e6215 into pingcap:master Nov 9, 2022
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #11255.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #11256.

@TomShawn TomShawn added translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. and removed translation/doing This PR's assignee is translating this PR. labels Jan 4, 2023
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. needs-cherry-pick-release-6.1 Should cherry pick this PR to release-6.1 branch. 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/LGT2 Indicates that a PR has LGTM 2. translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

text/blob types' maximum lengths are wrong
5 participants