"Your Database is Your Prison" also extols stored procedures:
Start with stored procedures.
“Ask yourself: ‘How bad would it be if a hacker rooted my webserver?’
If the answer is ‘real bad’, then move your authentication logic to a
stored procedure inside the database. It’s more secure, maintains better
layering, and higher performance for the end user.”
So I tried a FUNCTION I used in a database:
$ mysql -h 127.0.0.1 bedrock
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: bedrock 6f25a8097802c2d2d7a4b45e7f6a312bcccfb952
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [bedrock]> DELIMITER |
MySQL [bedrock]> CREATE FUNCTION GeoDistKM( lat1 FLOAT, lon1 FLOAT, lat2 FLOAT, lon2 FLOAT ) RETURNS float
-> BEGIN
-> DECLARE pi, q1, q2, q3 FLOAT;
-> DECLARE rads FLOAT DEFAULT 0;
-> SET pi = PI();
-> SET lat1 = lat1 * pi / 180;
-> SET lon1 = lon1 * pi / 180;
-> SET lat2 = lat2 * pi / 180;
-> SET lon2 = lon2 * pi / 180;
-> SET q1 = COS(lon1-lon2);
-> SET q2 = COS(lat1-lat2);
-> SET q3 = COS(lat1+lat2);
-> SET rads = ACOS( 0.5*((1.0+q1)*q2 - (1.0-q1)*q3) );
-> RETURN 6378.388 * rads;
-> END;
-> |
ERROR 502 (HY000): near "FUNCTION": syntax error
MySQL [bedrock]> DELIMITER ;
MySQL [bedrock]>
No? How do you get them into your database where you get all that "secure high performance"?