I would like to use the hamming distance in my MySQL database (used over phpMyAdmin) but did not succeed in creating the function with the code given here.
I'm refering to this code:
CREATE FUNCTION HAMMINGDISTANCE(
A0 BIGINT, A1 BIGINT, A2 BIGINT, A3 BIGINT,
B0 BIGINT, B1 BIGINT, B2 BIGINT, B3 BIGINT
)
RETURNS INT DETERMINISTIC
RETURN
BIT_COUNT(A0 ^ B0) +
BIT_COUNT(A1 ^ B1) +
BIT_COUNT(A2 ^ B2) +
BIT_COUNT(A3 ^ B3);
The problem is that I don't have the "super privilege". I also tried putting this code between DELIMITER //
(which worked for the Levenshtein distance function, see below), but also that did not solve the problem - I get a time out:
Maximum execution time of 300 seconds exceeded in
/usr/share/phpmyadmin/libraries/import/sql.php
on line 132
I'm quite new to MySQL anyway, so I'm wondering if anybody can help me with creating the hamming function in MySQL some other way.
Btw, I'm also using the Levenshtein distance function and the creation of this function worked fine. Yet, I saw that the Levenshtein distance should rather be used for calculating the distance between two strings and the hamming distance for numerical data.
Thanks.