Skip to content

Conversation

@fanyang01
Copy link
Contributor

Resolves #2701

Copy link
Contributor

@jycor jycor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!
MySQL does use the utf8mb4_0900_ai_ci collation for @@sql_mode, so we should change that, but only that variable and not all system set type

// NewSystemSetType returns a new systemSetType.
func NewSystemSetType(varName string, values ...string) sql.SystemVariableType {
return systemSetType{MustCreateSetType(values, sql.Collation_Default), varName}
return systemSetType{MustCreateSetType(values, sql.Collation_ascii_general_ci), varName}
Copy link
Contributor

@jycor jycor Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't change all our system types to use that collation, and they should still use collation_default. Also it should be utf8mb4_0900_ai_ci and not utf8mb4_ascii_general_ci.

Instead, NewSystemSetType() should take in a sql.CollationID and we should pass it sql.Collation_utf8mb4_0900_ai_ci for sql_mode in go-msql-server/sql/variables/system_variables.go.

Fortunately, NewSystemSetType() is only used in a few places, so there won't be too many changes.

Copy link
Contributor Author

@fanyang01 fanyang01 Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jycor, thanks for your review! I'm uncertain about which collation should be used for other system variables. Could you please direct me to where I can find MySQL's implementation?

mysql> set global log_output = 'table,file';
Query OK, 0 rows affected (0.00 sec)

mysql> select @@global.log_output;
+---------------------+
| @@global.log_output |
+---------------------+
| FILE,TABLE          |
+---------------------+
1 row in set (0.00 sec)

mysql> set global log_output = default;
Query OK, 0 rows affected (0.00 sec)

mysql> select @@global.log_output;
+---------------------+
| @@global.log_output |
+---------------------+
| FILE                |
+---------------------+
1 row in set (0.00 sec)

mysql> set global protocol_compression_algorithms = 'zLIB,Zstd';
Query OK, 0 rows affected (0.01 sec)

mysql> select @@global.protocol_compression_algorithms;
+------------------------------------------+
| @@global.protocol_compression_algorithms |
+------------------------------------------+
| zLIB,Zstd                                |
+------------------------------------------+
1 row in set (0.01 sec)

mysql> set global protocol_compression_algorithms = default;
Query OK, 0 rows affected (0.00 sec)

mysql> select @@global.protocol_compression_algorithms;
+------------------------------------------+
| @@global.protocol_compression_algorithms |
+------------------------------------------+
| zlib,zstd,uncompressed                   |
+------------------------------------------+
1 row in set (0.00 sec)

Copy link
Contributor Author

@fanyang01 fanyang01 Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have learned the following facts from MySQL's source code:

Copy link
Contributor

@jycor jycor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes and even digging into the MySQL source code.
LGTM!

@jycor jycor merged commit 7d0507a into dolthub:main Oct 17, 2024
8 checks passed
@fanyang01 fanyang01 deleted the lowercase-sqlmode branch October 21, 2024 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lowercase sql mode values are not supported

3 participants