Bug #13069 CONCAT( int1, int2 ) returns empty string if int1 < 10000
Submitted: 8 Sep 2005 17:07 Modified: 9 Sep 2005 17:01
Reporter: philip antoniades Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.0.13-beta (custom) OS:Linux (RHES 3.0)
Assigned to: Assigned Account CPU Architecture:Any

[8 Sep 2005 17:07] philip antoniades
Description:
When using CONCAT with numbers, having the first number be less than 5 digits makes the string null (inside a Stored Procedure). 

How to repeat:
drop procedure if exists concat_bug;

DELIMITER //

CREATE PROCEDURE concat_bug()

BEGIN

	DECLARE p_var	varchar( 1000 );

	DROP TABLE IF EXISTS tmp_concat;

	CREATE TEMPORARY TABLE tmp_concat
	( 
		pk integer primary key auto_increment, 
		val varchar(1000)
	) ENGINE=INNODB;

	SET p_var = 123456;
	SET p_var = CONCAT( p_var,",", 123 );

	INSERT INTO tmp_concat VALUES ( NULL, p_var);

	SET p_var = 12345;
	SET p_var = CONCAT( p_var,",", 123 );

	INSERT INTO tmp_concat VALUES ( NULL, p_var);

	SET p_var = 1234;
	SET p_var = CONCAT( p_var,",", 123 );

	INSERT INTO tmp_concat VALUES ( NULL, p_var);

	SET p_var = 123;
	SET p_var = CONCAT( p_var,",", 123 );

	INSERT INTO tmp_concat VALUES ( NULL, p_var);

	SELECT * FROM tmp_concat;
END;
// 
DELIMITER ;

CALL concat_bug(); // will return:

+----+------------+
| pk | val        |
+----+------------+
|  1 | 123456,123 |
|  2 | 12345,123  |
|  3 |            |
|  4 |            |
+----+------------+
4 rows in set (0.23 sec)
 
Query OK, 0 rows affected (0.23 sec)
[8 Sep 2005 17:28] philip antoniades
Note, this was done in a custom build based on the source tree as of Sept 2.
[9 Sep 2005 17:01] Petr Chardin
This is a duplicate of Bug #12849 Stored Procedure: Crash on procedure call with CHAR type 'INOUT' parameter (one more duplicate is Bug#12939). The patch for the bug was pushed recently.