Effects of the Environment
I already discussed some effects of environments such as concurrent threads, the operating system, hardware, concurrently running software, and the MySQL server and client options in this book. But a query, even if it is running in a single client connected to a dedicated MySQL server, can also be affected by the context in which it is run.
When you call a query from a stored procedure, function,
trigger, or event, these contexts
can override current session options with their own defaults. Therefore,
if you encounter a problem you can’t explain, try the same query outside
of the routine. If the results are different, check the routine’s
character set and SQL mode. Examine the body of the routine to check
whether all necessary objects exist and whether a variable that can affect
the query was set. Another environment variable that matters is time_zone, which affects the results of time
functions such as NOW() and CURDATE().
If a query does not work properly, check the environment in which it was called.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access