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

Do not assume that std::int64_t is identical to long int #1488

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sql/xa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "sql/xa.h"

#include <cstdint>
#include <memory>
#include <new>
#include <string>
Expand Down Expand Up @@ -387,8 +388,8 @@ int ha_recover(xid_to_gtid_container *commit_list, Xa_state_list *xa_list,
}

fprintf(stderr,
"Opid recovery info: Smallest low watermark Opid %ld:%ld, "
"Largest max Opid %ld:%ld\n",
"Opid recovery info: Smallest low watermark Opid %" PRId64 ":%" PRId64
", Largest max Opid %" PRId64 ":%" PRId64 "\n",
info.smallest_lwm_opid.first, info.smallest_lwm_opid.second,
info.largest_max_opid.first, info.largest_max_opid.second);

Expand Down
6 changes: 4 additions & 2 deletions sql/xa/recovery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,13 @@ static void recover_binlog_pos(const char *plugin_name, handlerton *hton,
}

// Track the smallest low watermark opid and the largest max opid
if (info->smallest_lwm_opid == std::make_pair(-1L, -1L) ||
if (info->smallest_lwm_opid ==
std::make_pair<std::int64_t, std::int64_t>(-1, -1) ||
info->smallest_lwm_opid > lwm_opid) {
info->smallest_lwm_opid = lwm_opid;
}
if (info->largest_max_opid == std::make_pair(-1L, -1L) ||
if (info->largest_max_opid ==
std::make_pair<std::int64_t, std::int64_t>(-1, -1) ||
info->largest_max_opid < max_opid) {
info->largest_max_opid = max_opid;
}
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/srv/srv0srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1416,8 +1416,8 @@ void srv_printf_innodb_binlog_position(FILE *file) /*!< in: output stream */

std::string opid_info;

if (lwm_opid != std::make_pair(-1L, -1L) &&
max_opid != std::make_pair(-1L, -1L)) {
if (lwm_opid != std::make_pair<std::int64_t, std::int64_t>(-1, -1) &&
max_opid != std::make_pair<std::int64_t, std::int64_t>(-1, -1)) {
opid_info += "LWM OPID " + std::to_string(lwm_opid.first) + ":" +
std::to_string(lwm_opid.second);
opid_info += "\nMAX OPID " + std::to_string(max_opid.first) + ":" +
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/trx/trx0sys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,14 @@ static void write_binlog_position(const char *file_name, uint64_t offset,

DBUG_EXECUTE_IF("innodb_skip_binlog_opid_update", { return; };);

if (lwm_opid != std::make_pair(-1L, -1L)) {
if (lwm_opid != std::make_pair<std::int64_t, std::int64_t>(-1, -1)) {
mlog_write_ull(binlog_buf + TRX_SYS_MYSQL_LWM_OPID_TERM, lwm_opid.first,
mtr);
mlog_write_ull(binlog_buf + TRX_SYS_MYSQL_LWM_OPID_INDEX, lwm_opid.second,
mtr);
}

if (max_opid != std::make_pair(-1L, -1L)) {
if (max_opid != std::make_pair<std::int64_t, std::int64_t>(-1, -1)) {
mlog_write_ull(binlog_buf + TRX_SYS_MYSQL_MAX_OPID_TERM, max_opid.first,
mtr);
mlog_write_ull(binlog_buf + TRX_SYS_MYSQL_MAX_OPID_INDEX, max_opid.second,
Expand Down
19 changes: 11 additions & 8 deletions storage/rocksdb/ha_rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6659,15 +6659,16 @@ static void rocksdb_recover_binlog_pos_internal(
fprintf(stderr, "RocksDB: Last MySQL Gtid %s\n", marker->max_gtid);
}

if (marker->lwm_opid != std::pair(-1L, -1L)) {
if (marker->lwm_opid != std::pair<std::int64_t, std::int64_t>(-1, -1)) {
// NO_LINT_DEBUG
fprintf(stderr, "RocksDB: Low watermark binlog opid: %lu:%lu\n",
fprintf(stderr,
"RocksDB: Low watermark binlog opid: %" PRId64 ":%" PRId64 "\n",
marker->lwm_opid.first, marker->lwm_opid.second);
}

if (marker->max_opid != std::pair(-1L, -1L)) {
if (marker->max_opid != std::pair<std::int64_t, std::int64_t>(-1, -1)) {
// NO_LINT_DEBUG
fprintf(stderr, "RocksDB: Max binlog opid: %lu:%lu\n",
fprintf(stderr, "RocksDB: Max binlog opid: %" PRId64 ":%" PRId64 "\n",
marker->max_opid.first, marker->max_opid.second);
}
}
Expand Down Expand Up @@ -6727,8 +6728,10 @@ static bool rocksdb_update_binlog_pos(
strcpy(marker.file, file);
strcpy(marker.max_gtid, max_gtid_buf);
marker.offset = *offset;
if (lwm_opid != std::make_pair(-1L, -1L)) marker.lwm_opid = lwm_opid;
if (max_opid != std::make_pair(-1L, -1L)) marker.max_opid = max_opid;
if (lwm_opid != std::make_pair<std::int64_t, std::int64_t>(-1, -1))
marker.lwm_opid = lwm_opid;
if (max_opid != std::make_pair<std::int64_t, std::int64_t>(-1, -1))
marker.max_opid = max_opid;

if (binlog_manager.persist_pos(marker, sync)) return true;

Expand Down Expand Up @@ -7320,12 +7323,12 @@ static bool rocksdb_show_binlog_position(THD *const thd,
<< "BINLOG OFFSET " << marker.offset << "\n"
<< "MAX GTID " << marker.max_gtid << "\n";

if (marker.lwm_opid != std::make_pair(-1L, -1L)) {
if (marker.lwm_opid != std::make_pair<std::int64_t, std::int64_t>(-1, -1)) {
oss << "LWM OPID " << marker.lwm_opid.first << ":" << marker.lwm_opid.second
<< "\n";
}

if (marker.max_opid != std::make_pair(-1L, -1L)) {
if (marker.max_opid != std::make_pair<std::int64_t, std::int64_t>(-1, -1)) {
oss << "MAX OPID " << marker.max_opid.first << ":" << marker.max_opid.second
<< "\n";
}
Expand Down
4 changes: 2 additions & 2 deletions storage/rocksdb/rdb_datadic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5346,12 +5346,12 @@ void Rdb_binlog_manager::update(rocksdb::WriteBatchBase *const batch,
return;
};);

if (marker.lwm_opid != std::pair(-1L, -1L)) {
if (marker.lwm_opid != std::pair<std::int64_t, std::int64_t>(-1, -1)) {
value_writer.write_uint64(marker.lwm_opid.first);
value_writer.write_uint64(marker.lwm_opid.second);
}

if (marker.max_opid != std::pair(-1L, -1L)) {
if (marker.max_opid != std::pair<std::int64_t, std::int64_t>(-1, -1)) {
value_writer.write_uint64(marker.max_opid.first);
value_writer.write_uint64(marker.max_opid.second);
}
Expand Down