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

Added LINEAR HASH/KEY mysql compatibility #11085

Merged
merged 16 commits into from
Nov 16, 2022
1 change: 1 addition & 0 deletions mysql-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ In TiDB, all supported DDL changes are performed online. Compared with DDL opera
* Table Partitioning supports `HASH`, `RANGE`, and `LIST` partitioning types. For the unsupported partition type, the `Warning: Unsupported partition type %s, treat as normal table` error might be output, where `%s` is a specific partition type.
* Table Partitioning also supports `ADD`, `DROP`, and `TRUNCATE` operations. Other partition operations are ignored. The following Table Partition syntaxes are not supported:
- `PARTITION BY KEY`
- `PARTITION BY LINEAR KEY`
- `SUBPARTITION`
- `{CHECK|TRUNCATE|OPTIMIZE|REPAIR|IMPORT|DISCARD|REBUILD|REORGANIZE|COALESCE} PARTITION`

Expand Down
9 changes: 9 additions & 0 deletions partitioned-table.md
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,15 @@ MOD(YEAR('2005-09-01'),4)
= 1
```

#### LINEAR HASH handling
qiancai marked this conversation as resolved.
Show resolved Hide resolved

Before v6.4, if you execute DDL statements of MySQL Linear Hash partitions in TiDB, TiDB can only create non-partitioned tables. In this case, if you still want to use partitioned tables in TiDB, you need to update your DDL statements.
qiancai marked this conversation as resolved.
Show resolved Hide resolved

Since v6.4.0, TiDB supports parsing the MySQL `PARTITION BY LINEAR HASH` syntax but ignores the `LINEAR` keyword in it. If you have some existing DDL and DML statements of MySQL Linear Hash partitions, you can execute them in TiDB without modification:

- For DDL statements of MySQL Linear Hash partitions, TiDB will create non-linear Hash partitioned tables correspondingly (note that Linear Hash partitioned tables are not provided in TiDB).
- DML statements of MySQL Linear Hash partitions are not affected unless you use explicit partition selection, in which case TiDB will return the query results of the corresponding TiDB Hash partitioned normally.
mjonss marked this conversation as resolved.
Show resolved Hide resolved

### How TiDB partitioning handles NULL

It is allowed in TiDB to use `NULL` as the calculation result of a partitioning expression.
Expand Down