Gary Pendergast wrote:
Hi folks,
I'm trying to to move CONCAT() and CONCAT_WS() to a plugin, but I'm
encountering a weird problem in testing. CONCAT_WS seems to work
correctly, except for when it's being used as part of a WHERE clause.
It's a bit hard to explain, if someone has some time to review, could
you pull
https://code.launchpad.net/~pento/drizzle/drizzle-string-functions , and
run the main.str_func test case?
I've been staring at the code for ages, but I'm not quite sure where I
should be looking to figure this one out.
Thanks!
Hi! I pulled your branch and indeed saw the failures you describe. So,
I fired up a debugger and a client session and found out some interested
things.
First, the failure only happens on a WHERE clause. If you change to use
a HAVING clause, everything works fine:
drizzle> SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
-> FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
-> LEFT JOIN t1 AS t3 ON t2.pc=t3.id;
+----+-------------+
| id | col1 |
+----+-------------+
| 1 | Main |
| 2 | Main->Toys |
| 3 | Main->Games |
+----+-------------+
3 rows in set (1 min 0.92 sec)
drizzle> SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
-> FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
-> LEFT JOIN t1 AS t3 ON t2.pc=t3.id
-> WHERE CONCAT_WS('->', t3.title, t2.title, t1.title) LIKE
'%Toys%';
Empty set (0 sec)
drizzle> SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as
col1 FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id LEFT JOIN t1
AS t3 ON t2.pc=t3.id HAVING col1 LIKE '%Toys%';
+----+------------+
| id | col1 |
+----+------------+
| 2 | Main->Toys |
+----+------------+
1 row in set (47 sec)
So, the above tells me that the ConcatwsFunction::val_str() is actually
correct -- it's returning the correct string. However, it seems that by
moving the ConcatwsFunction from a Create_native_func factory class to a
plugin::Create_function<ConcatwsFunction> factory, something is getting
messed up in the creation of the ConcatwsFunction objects.
I will take a look and see how we're calling those factory classes
differently in the parser and see if I can get some more information for
you.
Cheers,
Jay
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp