Skip to content
An UDF for MySQL/MariaDB, that does version comparsion between DPKG or RPM packages.
C++
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
readme.md
ver_cmp.cpp

readme.md

udf_pkg_ver_cmp

An UDF for MySQL/MariaDB, that does version comparsion between DPKG or RPM packages.


1. Intro

This is a MySQL UDF written in C/C++ to compare package versions, supporting both DPKG(deb) and RPM(rpm).

2. Prerequisites and Compilation

  • Some libs

      apt install libmariadb-dev librpm-dev libapt-pkg-dev
    
  • Compile

      g++ ver_cmp.cpp -o ver_cmp.so -lapt-pkg -lrpm -shared -fPIC
    

3. Load and Run

  • Load UDF in MySQL

      CREATE FUNCTION ver_cmp RETURNS INT SONAME "ver_cmp.so";
    
  • Run RPM version comparsion

      select ver_cmp("rpm", "1.2", "1.3");	# shall return -1
    
  • Run DPKG version comparsion

      select ver_cmp("deb", "1.2", "1:1.1");	# shall return -1
    

4. References

You can’t perform that action at this time.