Oh, and to find the function you could either go into
/api-doc/ and search for it which should tell you which file
it comes from or do something like
grep -r category_synonym::search_sweeper *
in the packages directory.
I guess the real trick is knowing how to read the traceback;
in this case you look for the first function down the list
which is not in the db API (the db API might have a few bugs
but the vast majority of problems like this are in the query
itself not in the db API so that's the place to start).