Bug #5364 SUBSTRING(str,pos) and SUBSTRING(str FROM pos) returns blank if charset is UCS2
Submitted: 2 Sep 2004 7:50 Modified: 7 Sep 2004 11:33
Reporter: Shuichi Tamagawa Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.4-gamma OS:Linux (SuSE Linux 9.0)
Assigned to: Alexey Botchkov CPU Architecture:Any

[2 Sep 2004 7:50] Shuichi Tamagawa
Description:
SELECT SUBSTRING(str,pos) and SELECT SUBSTRING(str FROM pos) returns blank if the table's character set is UCS2. 

SUBSTRING(str,pos,len) and SUBSTRING(str FROM pos FOR len) work fine. 

How to repeat:
Use the attached file.

mysql> source substring.test
[2 Sep 2004 7:51] Shuichi Tamagawa
Test case file to reproduce the problem

Attachment: substring.test (application/octet-stream, text), 1.61 KiB.

[2 Sep 2004 11:53] Alexander Keremidarski
Only some of SUBSTRING forms expose the problem. Others work well:

SELECT `c1`, SUBSTRING(`c1`,4) FROM `t1`; 
  -> emty strings
SELECT `c1`, SUBSTRING(`c1` FROM 4) FROM `t1`; 
  -> empty strings
SELECT `c1`, SUBSTRING(`c1`,1,4) FROM `t1`;
  -> correct result
SELECT `c1`, SUBSTRING(`c1` FROM 1 FOR 4) FROM `t1`;
  -> correct result
[7 Sep 2004 11:33] Alexey Botchkov
I completed compile-pentium-debug-max, then ran attached test.
Everything went fine.
Maybe there's something else to do to repeat this bug.