select IF ( 1 = 0 , '<--- 17 CHAR --->', '<### 17 CHAR ###>aaaaaaaaaaaaaaaaaaaaaaaa') as "my_column" union select 'here is the union line'; # Here I get wrong output. The server must return: # '<### 17 CHAR ###>aaaaaaaaaaaaaaaaaaaaaaaa' # The bug seems to depend on the length of expr1 and the line caused by UNION select IF ( 1 = 0 , '<------- 26 CHAR -------->', '<####### 26 CHAR ########>aaaaaaaaaaaaaaa') as "my_column" union select 'here is the union line'; # Here I get wrong output. The server must return: # '<## 16 CHAR ###>aaaaaaaaaaaaaaaaaaaaaaaaa' # The bug disappears, when UNION is omitted select IF ( 1 = 0 , '<--- 17 CHAR --->', '<### 17 CHAR ###>aaaaaaaaaaaaaaaaaaaaaaaa') as "my_column"; # Here I get the expected output: # '<### 17 CHAR ###>aaaaaaaaaaaaaaaaaaaaaaaa' # The control flow function CASE + UNION give the expected output SELECT CASE 2 WHEN 1 THEN '<--- 17 CHAR --->' WHEN 2 THEN '<### 17 CHAR ###>aaaaaaaaaaaaaaaaaaaaaaaa' END as "my_column" union select 'here is the union line'; ############################################################################### # My original test case slightly modified set sql_mode='PIPES_AS_CONCAT'; let $my_errno= 1; let $exp_val= 0; eval select IF ( $my_errno = $exp_val , 'TEST-INFO: passed', 'TEST-INFO: failed, wrong return code got:' || $my_errno || ' expected: ' || CAST($exp_val as CHAR)) as "" union select ''; # Must return: # 'TEST-INFO: failed, wrong return code got:1 expected: 0'