Github Repo: kings-way/udf_pkg_ver_cmp
1. Intro
A MySQL UDF written in C/C++ to compare package versions, supporting both DPKG(deb) and RPM(rpm).
2. Prerequisites and Compilation
-
Some libs
1apt install libmariadbclient-dev librpm-dev libapt-pkg-dev -
Compile
1g++ ver_cmp.cpp -o ver_cmp.so -lapt-pkg -lrpm -shared -fPIC
3. Load and Run
-
Load UDF in MySQL
1CREATE FUNCTION ver_cmp RETURNS INT SONAME "ver_cmp.so"; -
Run RPM version comparsion
1select ver_cmp("rpm", "1.2", "1.3"); # shall return -1 -
Run DPKG version comparsion
1select ver_cmp("deb", "1.2", "1:1.1"); # shall return -1