Subject: | Cant queue multiple queries on the same statement handle |
If you queue multiple events that all execute the same handle, you will
only be able to do a fetch on the last execution.
Scenario:
#1) You have a prepared statement already in existence.
#2) you post an execute event that will use that statement handle
#3) You immediately post a second execite event that will also use the
same statement handle
#4) LaDBI receives the first event and performs the execute
#5) LaDBI gets the response and posts the SuccessEvent handler
#6) The next item on the stack is post from #2 so LaDBI processes it
#7) LaDBI gets the response and posts the SuccessEvent handler
#8) The SuccessEvent from #5 gets handled and sends a fetchrow
-- now here is the problem, the statement handle got reused, so when the
fetchrow is performed, it'll be fetching the results from #7, not #5 as
it should
I see a few possible solutions
1) call() the SuccessEvent handler instead of posting so that it can
then call() the fetchrow event before the second execute is performed.
2) duplicate the statement handle if it hasnt been explicitly finished
and another execute comes along wanting it. this would be ugly as it
would slow down the query when it has to prepare another handle. it
would also make the handle id that execute was called with invalid as a
new one was just generated
3) when it gets a execute for a handle which hasnt been explicitly
finished, hold the execute until a finish comes along
4) add additional request events like 'execute_fetchrow' that
immediately perform the fetchrow upon a completed execute
5) add an argument like SuccessEvent_sync that will call a specified
event handler via call() if present