dolthub / dolt

Dolt – Git for Data
Apache License 2.0
17.73k stars 503 forks source link

Dolt differs from MySQL on allowing query global only system variable with session scope #6722

Open jennifersp opened 11 months ago

jennifersp commented 11 months ago

Dolt display incorrect header for querying global only variable without specifying the scope. It also should error on querying global only variable with SESSION scope. Dolt:

mysql> SELECT @@system_time_zone;
+----------------------------+
| @@SESSION.system_time_zone |
+----------------------------+
| PDT                        |
+----------------------------+
1 row in set (0.00 sec)

mysql> SELECT @@SESSION.system_time_zone;
+----------------------------+
| @@SESSION.system_time_zone |
+----------------------------+
| PDT                        |
+----------------------------+
1 row in set (0.00 sec)

MySQL:

mysql> SELECT @@system_time_zone;
+--------------------+
| @@system_time_zone |
+--------------------+
| PDT                |
+--------------------+
1 row in set (0.00 sec)

mysql> SELECT @@SESSION.system_time_zone;
ERROR 1238 (HY000): Variable 'system_time_zone' is a GLOBAL variable
fulghum commented 8 months ago

This is partially fixed in Dolt 1.32.0...

We no longer add the SESSION prefix, and now match the exact form that was requested in the query:

SELECT @@system_time_zone;
+--------------------+
| @@system_time_zone |
+--------------------+
| PST                |
+--------------------+

However, you can still incorrectly query a global variable using SESSION syntax:

SELECT @@SESSION.system_time_zone;
+----------------------------+
| @@SESSION.system_time_zone |
+----------------------------+
| PST                        |
+----------------------------+