pingcap/tidb

select var_pop(distinct xxx) could successfully execute in TiDB but failed in MySQL

Open

#19.499 aperta il 26 ago 2020

Vedi su GitHub
 (9 commenti) (0 reazioni) (0 assegnatari)Go (6186 fork)batch import
challenge-programgood first issuesig/executiontype/compatibility

Metriche repository

Star
 (40.090 star)
Metriche merge PR
 (Merge medio 14g 4h) (346 PR mergiate in 30 g)

Descrizione

Description

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  • TiDB
mysql> create table t1 (grp int, a bigint unsigned, c char(10) not null);
Query OK, 0 rows affected (0.00 sec)

mysql> insert into t1 values (1,1,"a");
Query OK, 1 row affected (0.01 sec)

mysql> select var_pop(distinct grp) from t1;
+-----------------------+
| var_pop(distinct grp) |
+-----------------------+
|                     0 |
+-----------------------+
1 row in set (0.00 sec)
  • MySQL -8.0.19
root@127.0.0.1 : gangshen 02:25:53> create table t1 (grp int, a bigint unsigned, c char(10) not null);
Query OK, 0 rows affected (0.02 sec)

root@127.0.0.1 : gangshen 02:25:57>  insert into t1 values (1,1,"a");
Query OK, 1 row affected (0.00 sec)

root@127.0.0.1 : gangshen 02:26:01> select var_pop(distinct grp) from t1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distinct grp) from t1' at line 1
  • MySQL 5.7.31:
mysql [localhost:5731] {msandbox} ((none)) > select var_pop(distinct grp) from t1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distinct grp) from t1' at line 1

2. What did you expect to see? (Required)

select var_pop(distinct xxx) failed. I‘ve refered MySQL docs: link It seems var_pop/stdev func couldn't contains distinct in it.

3. What did you see instead (Required)

It could execute successfully.

4. What is your TiDB version? (Required)

  • nightly

SIG slack channel

#sig-exec

Score

  • 300

Mentor

  • @qw4990

Guida contributor