Bug #121969 Failover add-source UDF accepts NULL channel as default channel
Description:
asynchronous_connection_failover_add_source() accepts SQL NULL for its required channel argument and stores the source under the empty/default channel.
The mysql-test/suite/rpl_gtid/t/rpl_async_conn_failover_udf_check.test contract states:
For asynchronous_connection_failover_add_source:
1. Check that the parameter count is greater than 3,
i.e. channel_name, hostname and port must be provided.
2. Check that the channel name is provided.
An empty string is valid for the default channel, but SQL NULL represents a missing required argument and should be rejected.
The observed output was:
FAIL: NULL channel accepted 0 1
The second and third values show that no exception was raised (null_channel_rejected=0) and one failover-source row was created (created_rows=1).
How to repeat:
Run as root in a fresh mysql session:
CREATE DATABASE db1;
USE db1;
DELIMITER //
CREATE PROCEDURE p1()
BEGIN
DECLARE null_channel_rejected BOOL DEFAULT FALSE;
DECLARE created_rows BIGINT DEFAULT 0;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
SET null_channel_rejected = TRUE;
SELECT asynchronous_connection_failover_add_source(
NULL, 'source.invalid', 43044, '', 50)
INTO @result;
SELECT COUNT(*) INTO created_rows
FROM performance_schema.replication_asynchronous_connection_failover
WHERE HOST = 'source.invalid' AND PORT = 43044;
SELECT IF(null_channel_rejected AND created_rows = 0,
'PASS: NULL channel rejected',
'FAIL: NULL channel accepted') AS oracle,
null_channel_rejected AS null_channel_rejected,
created_rows AS created_rows;
IF created_rows > 0 THEN
SELECT asynchronous_connection_failover_delete_source(
'', 'source.invalid', 43044, '')
INTO @cleanup_result;
END IF;
END//
DELIMITER ;
CALL p1();
-- Actual: FAIL: NULL channel accepted, 0, 1
-- Expected: PASS: NULL channel rejected, 1, 0
DROP PROCEDURE p1;
DROP DATABASE db1;
Suggested fix:
Reject args->args[0] == nullptr for the required channel argument instead of normalizing SQL NULL to the empty/default channel.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.038 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: asynchronous_connection_failover_add_source() accepts SQL NULL for its required channel argument and stores the source under the empty/default channel. The mysql-test/suite/rpl_gtid/t/rpl_async_conn_failover_udf_check.test contract states: For asynchronous_connection_failover_add_source: 1. Check that the parameter count is greater than 3, i.e. channel_name, hostname and port must be provided. 2. Check that the channel name is provided. An empty string is valid for the default channel, but SQL NULL represents a missing required argument and should be rejected. The observed output was: FAIL: NULL channel accepted 0 1 The second and third values show that no exception was raised (null_channel_rejected=0) and one failover-source row was created (created_rows=1). How to repeat: Run as root in a fresh mysql session: CREATE DATABASE db1; USE db1; DELIMITER // CREATE PROCEDURE p1() BEGIN DECLARE null_channel_rejected BOOL DEFAULT FALSE; DECLARE created_rows BIGINT DEFAULT 0; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET null_channel_rejected = TRUE; SELECT asynchronous_connection_failover_add_source( NULL, 'source.invalid', 43044, '', 50) INTO @result; SELECT COUNT(*) INTO created_rows FROM performance_schema.replication_asynchronous_connection_failover WHERE HOST = 'source.invalid' AND PORT = 43044; SELECT IF(null_channel_rejected AND created_rows = 0, 'PASS: NULL channel rejected', 'FAIL: NULL channel accepted') AS oracle, null_channel_rejected AS null_channel_rejected, created_rows AS created_rows; IF created_rows > 0 THEN SELECT asynchronous_connection_failover_delete_source( '', 'source.invalid', 43044, '') INTO @cleanup_result; END IF; END// DELIMITER ; CALL p1(); -- Actual: FAIL: NULL channel accepted, 0, 1 -- Expected: PASS: NULL channel rejected, 1, 0 DROP PROCEDURE p1; DROP DATABASE db1; Suggested fix: Reject args->args[0] == nullptr for the required channel argument instead of normalizing SQL NULL to the empty/default channel.