A helpful user was able to help me create a MySQL UDF for custom sorting. What’s the suggested approach for storing this UDF so that it’s always available? I’ve read that if the server restarts, the UDF is lost. Restarts are likely to be frequent, as this is on a local Windows network server that has a variety of roles and admins.
Right now I’m just going to drop and recreate it on client-side login. Logins won’t be terribly frequent – it’s used by a staff of about 11. I assume this is not the most efficient approach.
I think I read it’s possible to write it in C and store it in a .dll, but this is probably beyond my skill level.
It looks like you’re working with a stored routine, not a user-defined function. In MySQL, UDFs are always compiled extensions, while stored routines are always just SQL.
The manual pages suggest that neither will ever simply disappear. There are a variety of ways to query information about stored routines, including getting the creation date, who created it, and even the function body as defined. You could easily check if it’s missing, and add it if needed. You should also probably log this event, as it simply should not be happening.