Skip to content

Commit

Permalink
Define MYSQL_PROXY_PORT
Browse files Browse the repository at this point in the history
  • Loading branch information
justing-bq committed Apr 25, 2023
1 parent 4974e59 commit ab93160
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions driver/failover_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const std::regex IPV6_COMPRESSED_PATTERN(
R"#(^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$)#");

const char* MYSQL_READONLY_QUERY = "SELECT @@innodb_read_only AS is_reader";

const unsigned int MYSQL_PROXY_PORT = 8666;
} // namespace

FAILOVER_HANDLER::FAILOVER_HANDLER(DBC* dbc, DataSource* ds)
Expand Down Expand Up @@ -362,9 +364,9 @@ bool FAILOVER_HANDLER::should_connect_to_new_writer(const char* host) {
ds_set_wstrnattr(&ds->server, (SQLWCHAR*)writer_host_wstr.c_str(), writer_host_wstr.size());
ds_set_strnattr(&ds->server8, (SQLCHAR*)writer_host.c_str(), writer_host.size());

std::string suffix = ".proxied";
if (writer_host.compare(writer_host.length() - suffix.length(), suffix.length(), suffix) == 0) {
ds->port = 8666;
// If we are updating to a proxied server, we need to also update the port to the proxy port.
if (writer_host.compare(writer_host.length() - 8, 8, ".proxied") == 0) {
ds->port = MYSQL_PROXY_PORT;
}

return true;
Expand Down

0 comments on commit ab93160

Please sign in to comment.