dolthub / dolthub/dolt

binding variable on `GROUP BY` clause fails when `sql_mode` does not include `only_full_group_by`

Open
#6,904 0 comments 0 reactions 1 assignee Claimed by @zachmu View on GitHub
bug sql
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

Repro in Dolt:
```
mysql> SELECT @@SQL_MODE;
+--------------------------------------------+
| @@SESSION.SQL_MODE |
+--------------------------------------------+
| NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES |
+--------------------------------------------+
1 row in set (0.00 sec)

mysql> PREPARE stmt FROM "SELECT pk DIV ?, SUM(c3) FROM one_pk GROUP BY ? ORDER BY ?";
ERROR 1105 (HY000): bind variable not provided: 'v3'
```

Works on MySQL:
```
mysql> SELECT @@SQL_MODE;
+----------------------------------------------------------------------------------------------------+
| @@SQL_MODE |
+----------------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+----------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

mysql> PREPARE stmt FROM "SELECT pk DIV ?, SUM(c3) FROM one_pk GROUP BY ? ORDER BY ?";
Query OK, 0 rows affected (0.00 sec)
Statement prepared

mysql> SET @a = 1;
Query OK, 0 rows affected (0.01 sec)

mysql> EXECUTE stmt USING @a, @a, @a;
+----------+---------+
| pk DIV ? | SUM(c3) |
+----------+---------+
| 0 | 2 |
+----------+---------+
1 row in set (0.00 sec)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.