access control in mysql stored routines by example definer invoker sql security
Read this post on kedar.nitty-witty.com/blog