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

Incorrect type inference for COALESCE of system variables #8448

Closed
fanyang01 opened this issue Oct 14, 2024 · 1 comment · Fixed by dolthub/go-mysql-server#2700
Closed

Incorrect type inference for COALESCE of system variables #8448

fanyang01 opened this issue Oct 14, 2024 · 1 comment · Fixed by dolthub/go-mysql-server#2700
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue good repro Easily reproducible bugs

Comments

@fanyang01
Copy link

Hi Dolt creators,

I have observed that the type inference for the COALESCE function does not work as expected when used with system variables. For instance, COALESCE(@@admin_port, @@port) is inferred to be a longtext field. This issue can be reproduced using the _example implementation:

$ cd _example
$ go run .
mysql -h127.0.0.1 -uroot -P3306;
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 8.0.33 Dolt

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database db01;
Query OK, 1 row affected (0.00 sec)

mysql> use db01;
Database changed
mysql> select @@admin_port, @@port;
+--------------+--------+
| @@admin_port | @@port |
+--------------+--------+
|        33062 |   3306 |
+--------------+--------+
1 row in set (0.00 sec)

mysql> create table t as select @@admin_port as port1, @@port as port2, COALESCE(@@admin_port, @@port) as
 port3;
Query OK, 1 row affected (0.00 sec)

mysql> desc t;
+-------+------------+------+-----+---------+-------+
| Field | Type       | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| port1 | system_int | NO   |     | NULL    |       |
| port2 | system_int | NO   |     | NULL    |       |
| port3 | longtext   | NO   |     | NULL    |       |
+-------+------------+------+-----+---------+-------+
3 rows in set (0.01 sec)

mysql> select * from t;
+-------+-------+-------+
| port1 | port2 | port3 |
+-------+-------+-------+
| 33062 |  3306 | 33062 |
+-------+-------+-------+
1 row in set (0.00 sec)
@timsehn
Copy link
Contributor

timsehn commented Oct 14, 2024

I'm going to move this one to the actual Dolt repo for visibility.

@timsehn timsehn transferred this issue from dolthub/go-mysql-server Oct 14, 2024
@timsehn timsehn added bug Something isn't working good repro Easily reproducible bugs correctness We don't return the same result as MySQL labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue good repro Easily reproducible bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants