I’m trying to rewrite my code for searching of keywords in text from PHP to MySQL stored procedure because PHP has too low memory_limit and I’m on a shared hosting so I can’t change the memory limit.
What I need to code is this (aho-corasick algorithm):
for every char ch in text do
do some transitions
if there is a result for a given state add it to the output (output is position of word in text and keyword)
I don’t want anybody to write the procedure but I would like to know if it is possible to append results as I wrote in pseudocode above.
Note: I read the document: http://www.peregrinesalon.com/wp-content/uploads/2009/03/mysql-stored-procedures.pdf and for cycle is easy to program, conditions are easy too, transitions between states may be slow but it seems still possible.
Thanks for an answer!
In a SP you can build your result set in a temp table and manipulate it however you want before you exit. Then the calling procedure can select out what it wants from there. Once the MySQL session closes the temp table will be cleared as well.
(EDIT)
http://dev.mysql.com/tech-resources/articles/mysql-storedprocedures.html