Description:
I have this udf I created to pull contents out of a set depending on position. Anyway, I was noticing that the result set has an unnecessary tendency to pad with extra spaces for no obvious reason. Allow me to demonstrate:
This should be simply '' as a result, but the display makes it confusing:
mysql> select udf_pos_set('asd,asd',9) i;
+------+
| i |
+------+
| |
+------+
1 row in set (0.00 sec)
Even here it's padded with extra:
mysql> select udf_pos_set('asd,asd',0) i;
+------+
| i |
+------+
| asd |
+------+
1 row in set (0.00 sec)
This is what I normally expect:
mysql> select 0;
+---+
| 0 |
+---+
| 0 |
+---+
1 row in set (0.00 sec)
This is normal too:
mysql> select 0 i;
+---+
| i |
+---+
| 0 |
+---+
1 row in set (0.00 sec)
This shows that no spaces are passed by the function, but extra padding instead:
mysql> select concat(",",udf_pos_set('asd,asd',2),",") i;
+------+
| i |
+------+
| ,, |
+------+
1 row in set (0.00 sec)
This is normal:
mysql> select "a";
+---+
| a |
+---+
| a |
+---+
1 row in set (0.00 sec)
This is normal:
mysql> select "a" as "a";
+---+
| a |
+---+
| a |
+---+
1 row in set (0.00 sec)
This is normal:
mysql> select 'a' as 'a';
+---+
| a |
+---+
| a |
+---+
1 row in set (0.00 sec)
This is normal:
mysql> select 'ab' as 'a';
+----+
| a |
+----+
| ab |
+----+
1 row in set (0.00 sec)
This is normal:
mysql> select 'abb' as 'a';
+-----+
| a |
+-----+
| abb |
+-----+
1 row in set (0.00 sec)
This is normal too:
mysql> select @@version;
+-----------+
| @@version |
+-----------+
| 5.6.17 |
+-----------+
1 row in set (0.00 sec)
How to repeat:
See steps above.
Suggested fix:
None known.
Description: I have this udf I created to pull contents out of a set depending on position. Anyway, I was noticing that the result set has an unnecessary tendency to pad with extra spaces for no obvious reason. Allow me to demonstrate: This should be simply '' as a result, but the display makes it confusing: mysql> select udf_pos_set('asd,asd',9) i; +------+ | i | +------+ | | +------+ 1 row in set (0.00 sec) Even here it's padded with extra: mysql> select udf_pos_set('asd,asd',0) i; +------+ | i | +------+ | asd | +------+ 1 row in set (0.00 sec) This is what I normally expect: mysql> select 0; +---+ | 0 | +---+ | 0 | +---+ 1 row in set (0.00 sec) This is normal too: mysql> select 0 i; +---+ | i | +---+ | 0 | +---+ 1 row in set (0.00 sec) This shows that no spaces are passed by the function, but extra padding instead: mysql> select concat(",",udf_pos_set('asd,asd',2),",") i; +------+ | i | +------+ | ,, | +------+ 1 row in set (0.00 sec) This is normal: mysql> select "a"; +---+ | a | +---+ | a | +---+ 1 row in set (0.00 sec) This is normal: mysql> select "a" as "a"; +---+ | a | +---+ | a | +---+ 1 row in set (0.00 sec) This is normal: mysql> select 'a' as 'a'; +---+ | a | +---+ | a | +---+ 1 row in set (0.00 sec) This is normal: mysql> select 'ab' as 'a'; +----+ | a | +----+ | ab | +----+ 1 row in set (0.00 sec) This is normal: mysql> select 'abb' as 'a'; +-----+ | a | +-----+ | abb | +-----+ 1 row in set (0.00 sec) This is normal too: mysql> select @@version; +-----------+ | @@version | +-----------+ | 5.6.17 | +-----------+ 1 row in set (0.00 sec) How to repeat: See steps above. Suggested fix: None known.