Skip to content

Commit

Permalink
SHOW REPLICA STATUS: mark columns as unsigned
Browse files Browse the repository at this point in the history
Update all integer columns of SHOW REPLICA STATUS (technically
INFORMATION_SCHEMA.SLAVE_STATUS) to unsigned because, well, they are (:.

Some `uint32` ones were accidentally using the `Field::store(double nr)`
overload because they forgot the `, true` for
`Field::store(longlong nr, bool unsigned_val)`.
The mistake’s harmless, fortunately, as `double` supports over 15
significant decimal digits, well over `uint32`’s 9-and-a-half.
  • Loading branch information
ParadoxV5 committed Jan 31, 2025
1 parent 630afcb commit 2b36777
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
8 changes: 4 additions & 4 deletions mysql-test/suite/funcs_1/r/is_columns_is.result
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def information_schema SESSION_STATUS VARIABLE_VALUE 2 NULL NO varchar 4096 1228
def information_schema SESSION_VARIABLES VARIABLE_NAME 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL NO NO
def information_schema SESSION_VARIABLES VARIABLE_VALUE 2 NULL NO varchar 4096 12288 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(4096) select NEVER NULL NO NO
def information_schema SLAVE_STATUS Connection_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(64) select NEVER NULL NO NO
def information_schema SLAVE_STATUS Connect_Retry 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) select NEVER NULL NO NO
def information_schema SLAVE_STATUS Connect_Retry 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select NEVER NULL NO NO
def information_schema SLAVE_STATUS Executed_log_entries 59 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select NEVER NULL NO NO
def information_schema SLAVE_STATUS Exec_Master_Log_Pos 24 NULL NO bigint NULL NULL 20 0 NULL NULL NULL bigint(20) unsigned select NEVER NULL NO NO
def information_schema SLAVE_STATUS Gtid_IO_Pos 46 NULL NO varchar 21844 65532 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(21844) select NEVER NULL NO NO
Expand All @@ -406,7 +406,7 @@ def information_schema SLAVE_STATUS Master_last_event_time 63 NULL YES datetime
def information_schema SLAVE_STATUS Master_Log_File 8 NULL NO varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) select NEVER NULL NO NO
def information_schema SLAVE_STATUS Master_Port 6 NULL NO smallint NULL NULL 5 0 NULL NULL NULL smallint(5) unsigned select NEVER NULL NO NO
def information_schema SLAVE_STATUS Master_Server_Id 42 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select NEVER NULL NO NO
def information_schema SLAVE_STATUS Master_Slave_time_diff 65 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) select NEVER NULL NO NO
def information_schema SLAVE_STATUS Master_Slave_time_diff 65 NULL YES int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select NEVER NULL NO NO
def information_schema SLAVE_STATUS Master_SSL_Allowed 29 NULL YES varchar 7 21 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(7) select NEVER NULL NO NO
def information_schema SLAVE_STATUS Master_SSL_CA_File 30 NULL YES varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) select NEVER NULL NO NO
def information_schema SLAVE_STATUS Master_SSL_CA_Path 31 NULL YES varchar 512 1536 NULL NULL NULL utf8mb3 utf8mb3_general_ci varchar(512) select NEVER NULL NO NO
Expand Down Expand Up @@ -1070,7 +1070,7 @@ NULL information_schema SEQUENCES INCREMENT bigint NULL NULL NULL NULL bigint(21
3.0000 information_schema SLAVE_STATUS Master_Host varchar 255 765 utf8mb3 utf8mb3_general_ci varchar(255)
3.0000 information_schema SLAVE_STATUS Master_User varchar 384 1152 utf8mb3 utf8mb3_general_ci varchar(384)
NULL information_schema SLAVE_STATUS Master_Port smallint NULL NULL NULL NULL smallint(5) unsigned
NULL information_schema SLAVE_STATUS Connect_Retry int NULL NULL NULL NULL int(10)
NULL information_schema SLAVE_STATUS Connect_Retry int NULL NULL NULL NULL int(10) unsigned
3.0000 information_schema SLAVE_STATUS Master_Log_File varchar 512 1536 utf8mb3 utf8mb3_general_ci varchar(512)
NULL information_schema SLAVE_STATUS Read_Master_Log_Pos bigint NULL NULL NULL NULL bigint(20) unsigned
3.0000 information_schema SLAVE_STATUS Relay_Log_File varchar 512 1536 utf8mb3 utf8mb3_general_ci varchar(512)
Expand Down Expand Up @@ -1128,7 +1128,7 @@ NULL information_schema SLAVE_STATUS Slave_heartbeat_period float NULL NULL NULL
3.0000 information_schema SLAVE_STATUS Gtid_Slave_Pos varchar 21844 65532 utf8mb3 utf8mb3_general_ci varchar(21844)
NULL information_schema SLAVE_STATUS Master_last_event_time datetime NULL NULL NULL NULL datetime
NULL information_schema SLAVE_STATUS Slave_last_event_time datetime NULL NULL NULL NULL datetime
NULL information_schema SLAVE_STATUS Master_Slave_time_diff int NULL NULL NULL NULL int(10)
NULL information_schema SLAVE_STATUS Master_Slave_time_diff int NULL NULL NULL NULL int(10) unsigned
NULL information_schema SPATIAL_REF_SYS SRID smallint NULL NULL NULL NULL smallint(5)
3.0000 information_schema SPATIAL_REF_SYS AUTH_NAME varchar 512 1536 utf8mb3 utf8mb3_general_ci varchar(512)
NULL information_schema SPATIAL_REF_SYS AUTH_SRID int NULL NULL NULL NULL int(5)
Expand Down
21 changes: 12 additions & 9 deletions sql/slave.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2955,8 +2955,8 @@ void store_master_info(THD *thd, Master_info *mi, TABLE *table,

store_string_or_null(field++, mi->host);
store_string_or_null(field++, mi->user);
(*field++)->store((uint32) mi->port);
(*field++)->store((uint32) mi->connect_retry);
(*field++)->store((uint32) mi->port, true);
(*field++)->store((uint32) mi->connect_retry, true);
(*field++)->store(mi->master_log_name, strlen(mi->master_log_name),
&my_charset_bin);
(*field++)->store((ulonglong) mi->master_log_pos, true);
Expand All @@ -2979,9 +2979,9 @@ void store_master_info(THD *thd, Master_info *mi, TABLE *table,
rpl_filter->get_wild_ignore_table(&tmp);
(*field++)->store(tmp.ptr(), tmp.length(), &my_charset_bin);

(*field++)->store(mi->rli.last_error().number);
(*field++)->store(mi->rli.last_error().number, true);
store_string_or_null(field++, mi->rli.last_error().message);
(*field++)->store((uint32) mi->rli.slave_skip_counter);
(*field++)->store((uint32) mi->rli.slave_skip_counter, true);
(*field++)->store((ulonglong) mi->rli.group_master_log_pos, true);
(*field++)->store((ulonglong) mi->rli.log_space_total, true);

Expand Down Expand Up @@ -3069,17 +3069,17 @@ void store_master_info(THD *thd, Master_info *mi, TABLE *table,
&my_charset_bin);

// Last_IO_Errno
(*field++)->store(mi->last_error().number);
(*field++)->store(mi->last_error().number, true);
// Last_IO_Error
store_string_or_null(field++, mi->last_error().message);
// Last_SQL_Errno
(*field++)->store(mi->rli.last_error().number);
(*field++)->store(mi->rli.last_error().number, true);
// Last_SQL_Error
store_string_or_null(field++, mi->rli.last_error().message);
// Replicate_Ignore_Server_Ids
field_store_ids((*field++), &mi->ignore_server_ids);
// Master_Server_id
(*field++)->store((uint32) mi->master_id);
(*field++)->store((uint32) mi->master_id, true);
// SQL_Delay
// Master_Ssl_Crl
store_string_or_null(field++, mi->ssl_crl);
Expand All @@ -3103,7 +3103,8 @@ void store_master_info(THD *thd, Master_info *mi, TABLE *table,
(*field++)->store(mode_name, strlen(mode_name), &my_charset_bin);
}

(*field++)->store((uint32) mi->rli.get_sql_delay());
// int32 on paper, unsigned in practice
(*field++)->store((uint32) mi->rli.get_sql_delay(), true);
// SQL_Remaining_Delay
// THD::proc_info is not protected by any lock, so we read it once
// to ensure that we use the same value throughout this function.
Expand All @@ -3112,7 +3113,7 @@ void store_master_info(THD *thd, Master_info *mi, TABLE *table,
if (slave_sql_running_state == stage_sql_thd_waiting_until_delay.m_name)
{
time_t t= my_time(0), sql_delay_end= mi->rli.get_sql_delay_end();
(*field++)->store((uint32)(t < sql_delay_end ? sql_delay_end - t : 0));
(*field++)->store((uint32)(t < sql_delay_end ? sql_delay_end - t : 0), true);
}
else
(*field++)->set_null();
Expand Down Expand Up @@ -3146,6 +3147,8 @@ void store_master_info(THD *thd, Master_info *mi, TABLE *table,
if ((slave_timestamp= mi->rli.slave_timestamp))
{
(*field++)->store_timestamp((my_time_t) slave_timestamp, 0);
// primary's binlog timestamp should be >= replica's replication timestamp
DBUG_ASSERT(master_timestamp >= slave_timestamp);
(*field++)->store((uint) (master_timestamp - slave_timestamp), true);
}
else
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10628,7 +10628,7 @@ ST_FIELD_INFO slave_status_info[]=
Column("Master_Host", Varchar(HOSTNAME_LENGTH), NULLABLE),
Column("Master_User", Varchar(USERNAME_LENGTH), NULLABLE),
Column("Master_Port", UShort(5), NOT_NULL),
Column("Connect_Retry", SLong(10), NOT_NULL),
Column("Connect_Retry", ULong(10), NOT_NULL),
Column("Master_Log_File", Varchar(FN_REFLEN), NOT_NULL),
Column("Read_Master_Log_Pos", ULonglong(20), NOT_NULL),
Column("Relay_Log_File", Varchar(FN_REFLEN), NOT_NULL),
Expand Down Expand Up @@ -10686,7 +10686,7 @@ ST_FIELD_INFO slave_status_info[]=
Column("Gtid_Slave_Pos", Varchar(), NOT_NULL),
Column("Master_last_event_time", Datetime(0), NULLABLE),
Column("Slave_last_event_time", Datetime(0), NULLABLE),
Column("Master_Slave_time_diff", SLong(10), NULLABLE),
Column("Master_Slave_time_diff", ULong(10), NULLABLE),
CEnd()
};
#endif
Expand Down

0 comments on commit 2b36777

Please sign in to comment.