Let’s say I want to create a MySQL function called “funcCalculateSalesCommission(parameter list)”.
If I create a Stored Procedure, or Trigger, or a View in MySQL, then they all persist. Whether I shut down the MySQL database server or not, this database objects will always be there - just like my tables and data - as long as things do not become corrupt.
Logically, one would expect a Custom Function to persist in the same way.
It sounds like you are saying that is not the case, which if true, would be a really stupid design.
Hey, not sure if you saw my edit yet ( post-brainfart ).
The functions that you create using the CREATE FUNCTION command are indeed persistent. All active functions get reloaded when the server starts up. They are removed only with DROP FUNCTION
Here found a link for you so that you can read it for yourself:
An active function is one that has been loaded with CREATE FUNCTION and not removed with DROP FUNCTION. All active functions are reloaded each time the server starts, unless you start mysqld with the --skip-grant-tables option.
Yes, I saw that, but the wording is throwing me some…
When I hear “get reloaded” it makes it sound like they disappear from the database.
(The webpage I was reading last night - but lost - said something like, “Every time you shut down MySQL, you have to manually reload all of your functions…”
To me, that implied that I would have to recreate every function in MySQL which would be insanity!)
Nope, they don’t disappear…since they are not native extensions, the sql server has to keep track of them and load them up when the server starts.
Think of it kind of like the database tables themselves…they will always exist once you create them, but you have to explicitly call them to use them. It’s the same with functions; you have to call them to use them, but they will always exist. The sql server just makes them accessible automatically once the server starts up…that’s what I meant by “reloading” them