[MXS-3299] Parse error when connecting (through binlog router) from mysql-connector-j Created: 2020-11-15  Updated: 2021-08-13  Resolved: 2021-08-06

Status: Closed
Project: MariaDB MaxScale
Component/s: binlogrouter
Affects Version/s: 2.5
Fix Version/s: 2.5.15

Type: Bug Priority: Minor
Reporter: Ben Osheroff Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None

Sprint: MXS-SPRINT-137

 Description   

(from https://groups.google.com/g/maxscale/c/ngEIt4yDJEY)

I've traced this down to a problem parsing the sql (in Pinkloki session). The sql that triggers the error:

(25) (Replication) COM_QUERY: /* mysql-connector-java-8.0.17 (Revision: 16a712ddb3f826a1933ab42b0039f7fb9eebc6ec) */SELECT  @@session.auto_increment_increment AS auto_increment_increment, @@character_set_client AS character_set_client, @@character_set_connection AS character_set_connection, @@character_set_results AS character_set_results, @@character_set_server AS character_set_server, @@collation_server AS collation_server, @@collation_connection AS collation_connection, @@init_connect AS init_connect, @@interactive_timeout AS interactive_timeout, @@license AS license, @@lower_case_table_names AS lower_case_table_names, @@max_allowed_packet AS max_allowed_packet, @@net_write_timeout AS net_write_timeout, @@performance_schema AS performance_schema, @@query_cache_size AS query_cache_size, @@query_cache_type AS query_cache_type, @@sql_mode AS sql_mode, @@system_time_zone AS system_time_zone, @@time_zone AS time_zone, @@tx_isolation AS transaction_isolation, @@wait_timeout AS wait_timeout



 Comments   
Comment by markus makela [ 2021-08-02 ]

The reason seems to be the lack of alias support in the binlogrouter.

Comment by markus makela [ 2021-08-02 ]

Adding the support for aliases in the parser isn't very complex but making it behave like MariaDB does would be more work. With minimal changes to add support for it, the query in the issue description would produce the following output:

*************************** 1. row ***************************
@@session.auto_increment_increment: @@session.auto_increment_increment
            @@character_set_client: @@character_set_client
        @@character_set_connection: @@character_set_connection
           @@character_set_results: @@character_set_results
            @@character_set_server: @@character_set_server
                @@collation_server: @@collation_server
            @@collation_connection: @@collation_connection
                    @@init_connect: @@init_connect
             @@interactive_timeout: @@interactive_timeout
                         @@license: @@license
          @@lower_case_table_names: @@lower_case_table_names
              @@max_allowed_packet: @@max_allowed_packet
               @@net_write_timeout: @@net_write_timeout
              @@performance_schema: @@performance_schema
                @@query_cache_size: @@query_cache_size
                @@query_cache_type: @@query_cache_type
                        @@sql_mode: @@sql_mode
                @@system_time_zone: @@system_time_zone
                       @@time_zone: @@time_zone
                    @@tx_isolation: @@tx_isolation
                    @@wait_timeout: @@wait_timeout

osheroff would you know if this be adequate for your purposes?

Comment by markus makela [ 2021-08-03 ]

Another way to deal with this would be to just add some code that substitutes some known variables with some constant values. The values themselves could be the defaults from some MariaDB version.

Comment by markus makela [ 2021-08-03 ]

Added in support for field aliases and constant values for the following variables:

    {"@@session.auto_increment_increment", "1"                 },
    {"@@character_set_client",             "utf8"              },
    {"@@character_set_connection",         "utf8"              },
    {"@@character_set_results",            "utf8"              },
    {"@@character_set_server",             "utf8mb4"           },
    {"@@collation_server",                 "utf8mb4_general_ci"},
    {"@@collation_connection",             "utf8_general_ci"   },
    {"@@init_connect",                     ""                  },
    {"@@interactive_timeout",              "28800"             },
    {"@@license",                          "BSL"               },
    {"@@lower_case_table_names",           "0"                 },
    {"@@max_allowed_packet",               "16777216"          },
    {"@@net_write_timeout",                "60"                },
    {"@@performance_schema",               "0"                 },
    {"@@query_cache_size",                 "1048576"           },
    {"@@query_cache_type",                 "OFF"               },
    {"@@sql_mode",                         ""                  },
    {"@@system_time_zone",                 "UTC"               },
    {"@@time_zone",                        "SYSTEM"            },
    {"@@tx_isolation",                     "REPEATABLE-READ"   },
    {"@@wait_timeout",                     "28800"             },

Generated at Thu Feb 08 04:20:24 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.