pingcap / pingcap/tidb

sql_mode = 'ANSI_QUOTES' does not use ANSI_QUOTES for columns within functions in partitioning expression

Open
#35,389 1 comment 0 reactions 1 assignee Claimed by @djshow832 View on GitHub
severity/minor sig/sql-infra type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```
set sql_mode='ANSI_QUOTES';
CREATE TABLE "t2" (
"created_at" timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (UNIX_TIMESTAMP(`created_at`))
(PARTITION "p0" VALUES LESS THAN (1638313200),
PARTITION "p1" VALUES LESS THAN (1640991600));
SHOW CREATE TABLE t2;
```

### 2. What did you expect to see? (Required)
```
mysql> show create table t2;
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t2 | CREATE TABLE "t2" (
"created_at" timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
/*!50100 PARTITION BY RANGE (unix_timestamp("created_at"))
(PARTITION p0 VALUES LESS THAN (1638313200) ENGINE = InnoDB,
PARTITION p1 VALUES LESS THAN (1640991600) ENGINE = InnoDB) */ |
+-------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0,01 sec)
```

### 3. What did you see instead (Required)
```
tidb> show create table t2;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t2 | CREATE TABLE "t2" (
"created_at" timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin
PARTITION BY RANGE (UNIX_TIMESTAMP(`created_at`))
(PARTITION "p0" VALUES LESS THAN (1638313200),
PARTITION "p1" VALUES LESS THAN (1640991600)) |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0,01 sec)
```
where ``UNIX_TIMESTAMP(`created_at`)`` does not use `"` quoting.

### 4. What is your TiDB version? (Required)

```
tidb_version(): Release Version: v6.2.0-alpha-112-g2ba2a9ef56
Edition: Community
Git Commit Hash: 2ba2a9ef56c3a5cb339ebc0dfee8cb173e8686f3
Git Branch: master
UTC Build Time: 2022-06-14 20:14:29
GoVersion: go1.18
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
Store: unistore
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.