Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
-
2021-9
Description
install_mcs_mysql.sh.in currently uses direct INSERTs to populate mysql.func, e.g.:
...
|
INSERT INTO mysql.func VALUES ('mcssystemready',2,'ha_columnstore.so','function'); |
INSERT INTO mysql.func VALUES ('mcssystemreadonly',2,'ha_columnstore.so','function'); |
INSERT INTO mysql.func VALUES ('mcssystemprimary',2,'ha_columnstore.so','function'); |
INSERT INTO mysql.func VALUES ('regr_avgx',1,'libregr_mysql.so','aggregate'); |
INSERT INTO mysql.func VALUES ('regr_avgy',1,'libregr_mysql.so','aggregate'); |
INSERT INTO mysql.func VALUES ('regr_count',2,'libregr_mysql.so','aggregate'); |
...
|
This is a not good way to install UDFs and UDAFs:
- There is no a guaratee that the structure of mysql.func will always be the same.
- This approach needs to restart the MariaDB server to make the functions actually available. This makes ColumnStore post-installation step unnecessarily more complex.
The correct way to install UDFs and UDAFs it to use CREATE FUNCTION and CREATE AGGREGATE FUNCTION statements.
...
|
CREATE OR REPLACE FUNCTION mcssystemready RETURNS INTEGER SONAME 'ha_columnstore.so'; |
CREATE OR REPLACE FUNCTION mcssystemreadonly RETURNS INTEGER SONAME 'ha_columnstore.so'; |
CREATE OR REPLACE FUNCTION mcssystemprimary RETURNS INTEGER SONAME 'ha_columnstore.so'; |
CREATE OR REPLACE AGGREGATE FUNCTION regr_avgx RETURNS REAL SONAME 'libregr_mysql.so'; |
CREATE OR REPLACE AGGREGATE FUNCTION regr_avgy RETURNS REAL SONAME 'libregr_mysql.so'; |
CREATE OR REPLACE AGGREGATE FUNCTION regr_count RETURNS INTEGER SONAME 'libregr_mysql.so'; |
...
|
- It's safe about mysql.func structure changes
- It does not need the server restart. Functions become immediately available.