Skip to content

Conversation

hfxsd
Copy link
Collaborator

@hfxsd hfxsd commented Jun 12, 2024

First-time contributors' checklist

What is changed, added or deleted? (Required)

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

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v8.2 (TiDB 8.2 versions)
  • v8.1 (TiDB 8.1 versions)
  • v8.0 (TiDB 8.0 versions)
  • v7.6 (TiDB 7.6 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 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)

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

  • This PR is translated from:
  • Other reference 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

@hfxsd hfxsd self-assigned this Jun 12, 2024
@ti-chi-bot ti-chi-bot bot added contribution This PR is from a community contributor. missing-translation-status This PR does not have translation status info. labels Jun 12, 2024
@hfxsd hfxsd added needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. and removed contribution This PR is from a community contributor. missing-translation-status This PR does not have translation status info. labels Jun 12, 2024
@ti-chi-bot ti-chi-bot bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 12, 2024
@hfxsd hfxsd added translation/doing This PR's assignee is translating this PR. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 12, 2024
@hfxsd hfxsd requested a review from dveeden June 12, 2024 09:53
@hfxsd hfxsd changed the title sql: add a note about FULLTEXT sql: add a note about FULLTEXT Jun 12, 2024
@ti-chi-bot ti-chi-bot bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 12, 2024
@hfxsd hfxsd requested a review from 0xPoe June 12, 2024 09:54
@hfxsd hfxsd 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 Jun 12, 2024
@dveeden
Copy link
Contributor

dveeden commented Jun 12, 2024

mysql> CREATE TABLE t1 (id INT PRIMARY KEY, v VARCHAR(255), INDEX (v) USING BTREE);
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE t2 (id INT PRIMARY KEY, v VARCHAR(255), INDEX (v) USING HASH);
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW CREATE TABLE t1\G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `id` int(11) NOT NULL,
  `v` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
  KEY `v` (`v`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
1 row in set (0.00 sec)

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

mysql> SHOW INDEX FROM t1;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | Clustered |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| t1    |          0 | PRIMARY  |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | YES     | NULL       | YES       |
| t1    |          1 | v        |            1 | v           | A         |           0 |     NULL | NULL   | YES  | BTREE      |         |               | YES     | NULL       | NO        |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
2 rows in set (0.00 sec)

mysql> SHOW INDEX FROM t2;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | Clustered |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| t2    |          0 | PRIMARY  |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | YES     | NULL       | YES       |
| t2    |          1 | v        |            1 | v           | A         |           0 |     NULL | NULL   | YES  | HASH       |         |               | YES     | NULL       | NO        |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
2 rows in set (0.00 sec)

So we support FULLTEXT and HASH syntax wise. Where FULLTEXT results in a warning, this isn't the case for HASH. Note that the index type for hash persists in the output of SHOW INDEX, but not in the output of SHOW CREATE TABLE.

@dveeden
Copy link
Contributor

dveeden commented Jun 12, 2024

Note that these pages should have a note about FULLTEXT:

  • sql-statements/sql-statement-add-index.md
  • sql-statements/sql-statement-create-index.md
  • sql-statements/sql-statement-create-table.md

Note that the "CREATE INDEX" page already has a complete note about this: "TiDB supports parsing the FULLTEXT and SPATIAL syntax but does not support using the FULLTEXT, HASH, and SPATIAL indexes."

Note that mysql-compatibility.md has a note about HASH being supported, but ignored.

@dveeden
Copy link
Contributor

dveeden commented Jun 12, 2024

@kennytm looks like "USING" for index type is missing from the EBNF for "CREATE TABLE"?

@dveeden
Copy link
Contributor

dveeden commented Jun 12, 2024

mysql> CREATE TABLE t3 (id INT PRIMARY KEY, v VARCHAR(255), INDEX (v) USING RTREE);
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW INDEX FROM t3;
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | Clustered |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
| t3    |          0 | PRIMARY  |            1 | id          | A         |           0 |     NULL | NULL   |      | BTREE      |         |               | YES     | NULL       | YES       |
| t3    |          1 | v        |            1 | v           | A         |           0 |     NULL | NULL   | YES  | RTREE      |         |               | YES     | NULL       | NO        |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+-----------+
2 rows in set (0.00 sec)

Note that RTREE is also accepted as index type (and ignored).

@dveeden
Copy link
Contributor

dveeden commented Jun 12, 2024

Not that TiDB supports parsing the `FULLTEXT` and `SPATIAL` syntax from sql-statements/sql-statement-create-index.md is incorrect as far as I know. I don't think we support ...SPATIAL INDEX... syntax.

@dveeden
Copy link
Contributor

dveeden commented Jun 12, 2024

Maybe we should also add a note about the (meaningless) Index_type in the output to this page? https://docs.pingcap.com/tidb/stable/sql-statement-show-indexes

hfxsd and others added 2 commits June 12, 2024 19:04
Co-authored-by: Daniël van Eeden <github@myname.nl>
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 12, 2024
@hfxsd
Copy link
Collaborator Author

hfxsd commented Jun 12, 2024

Maybe we should also add a note about the (meaningless) Index_type in the output to this page? docs.pingcap.com/tidb/stable/sql-statement-show-indexes

OK, updated.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 12, 2024
@dveeden
Copy link
Contributor

dveeden commented Jun 12, 2024

I think the IndexOption of the create table statement page should be changed to:

IndexOption ::=
    'COMMENT' String
|   ( 'VISIBLE' | 'INVISIBLE' )
|   ('USING' | 'TYPE') ('BTREE' | 'RTREE' | 'HASH')

@dveeden
Copy link
Contributor

dveeden commented Jun 12, 2024

Looks like these pages reference IndexInvisible but that's never defined. cc @kennytm

@kennytm
Copy link
Contributor

kennytm commented Jun 12, 2024

@dveeden If any EBNF references IndexInvisible the node should be replaced with ("VISIBLE" | "INVISIBLE").

If you want a hyperlink it should go to https://docs.pingcap.com/tidb/stable/sql-statement-alter-index.

Co-authored-by: Lilian Lee <lilin@pingcap.com>
Copy link
Member

@lilin90 lilin90 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 bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 13, 2024
Copy link

ti-chi-bot bot commented Jun 13, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-12 13:38:47.51751235 +0000 UTC m=+558281.570824274: ☑️ agreed by dveeden.
  • 2024-06-13 10:30:20.252086716 +0000 UTC m=+633374.305398635: ☑️ agreed by lilin90.

sql: Update EBNF related to indexing
@hfxsd
Copy link
Collaborator Author

hfxsd commented Jun 13, 2024

/approve

Copy link

ti-chi-bot bot commented Jun 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hfxsd

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Jun 13, 2024
@ti-chi-bot ti-chi-bot bot merged commit f6b5857 into pingcap:master Jun 13, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #17891.

ti-chi-bot bot pushed a commit that referenced this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. 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.

5 participants