This is important to remember when you're using db_foreach, because it looks as if you're code is executing in the calling context, but it is using the "re-parenting" trick, so any return in your loop will only terminate the loop. If you want to terminate the calling context, you need to use "return -code return", and I think there are some places where even that won't work (inside the -if_no_rows clause, IIRC).