Git Product home page Git Product logo

levenshtein-mysql-udf's Introduction

Personal Website


SO badge

Main Languages

Scala Python Shell Script TypeScript React

Main Tech

Play Framework Deno AWS Docker scikit-learn PyTorch

Learning

Kubernetes


Recent open-source projects:

  • fastchecks - 🚥 Fast website monitoring - CLI & Python API
  • mkpdf - 🖨️🎨 CLI, TypeScript API, & parce.js plugin to "print" a website (URL/HTML/Markdown) into a PDF
  • stackexchange-stats-flair - 🍒 Beautiful Stack Overflow & Exchange profile flair / stats
  • CtCI - My answers for the book: Cracking the Code Interview (CtCI), 6th Edition
  • AtDSI - My coding answers for the book (Chapter 9): Ace the Data Science Interview (AtDSI), 1st Edition

levenshtein-mysql-udf's People

Contributors

juanmirocks avatar krassowski avatar lilobase avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

levenshtein-mysql-udf's Issues

README updates

Requires: sudo apt install libmysqlclient-dev
Before build.

After installing got:

$ gcc -o levenshtein.so -shared levenshtein.c mysql_config --include
/usr/bin/ld: /tmp/ccBcelTa.o: relocation R_X86_64_PC32 against symbol `levenshtein' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Tried: $ gcc -o levenshtein.so -shared -fPIC levenshtein.c mysql_config --include

Worked OK, I can see the new .so file

Can't find symbol 'levenshtein' in library

When I tried to create UDF it returns this message:

mysql> CREATE FUNCTION levenshtein RETURNS INT SONAME 'levenshtein.so';
ERROR 1127 (HY000): Can't find symbol 'levenshtein' in library

I tried with other names of function but no solution yet.
Now my machine:

  • Ubuntu 20.04
  • MySQL 8.x
    How can I fix it?
    Thanks!

compilation on macosX

Hi, just a suggestion

maybe replace :

* (mac) gcc -bundle -o levenshtein.so levenshtein.c -I/usr/local/mysql/include

with

* (mac) gcc -bundle -o levenshtein.so levenshtein.c `mysql_config --cflags --libs`

As its more generic and works with whatever source you (properly) installed mysql with : oracle, homebrew, macports,...

And thanks for this implementation :)

Wrong memory allocation with init?

From Pablo Ruano (in Spanish):

Creo que tiene el siguiente problema:

- En la función levenshtein_init pides la memoria necesaria para calcular la distancia según la longitud de las dos cadenas que se pasan como argumento:

malloc(sizeof(int) * (args->lengths[0] + 1) * (args->lengths[1] + 1))

- MySQL sólo ejecuta la función init la primera vez que va a usar la función, las siguientes veces llama directamente a la función levenshtein. Puedes leerlo aquí:

https://dev.mysql.com/doc/refman/5.6/en/adding-udf.html

- Por tanto, en sucesivas llamadas, si las cadenas de entrada son de longitud superior a las que se usaron por primera vez con la función init, la función levenshtein usará memora sin haberla reservado previamente, haciendo que la estabilidad de MySQL se vea comprometida.

He visto otras funciones UDF, y lo que suelen hacer en estos casos en los que se necesita usar memoria de forma dinámica es reservarla directamente en la función, no en el init.

Saludos

fatal error: my_global.h: No such file or directory

I encounter the following error when attempting to compile Levenshtein-MySQL-UDF:

$ gcc -fPIC -o levenshtein.so -shared levenshtein.c `mysql_config --include`
levenshtein.c:53:23: fatal error: my_global.h: No such file or directory
 #include <my_global.h>
                       ^
compilation terminated.

$ mysql --version
mysql  Ver 15.1 Distrib 10.2.8-MariaDB, for Linux (x86_64) using readline 5.1

$ uname -a
Linux sql2.___.com.au 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/centos-release
CentOS Linux release 7.3.1611 (Core)

$ git rev-parse master
e6da92e13e2c025d719436a0474d67515817150c

Unable to create function after compiling library: Error: Can't find symbol 'levenshtein' in library

I'm trying to compile and install the library for MariaDB 10.2 but the compiled .so file appears to be missing the required symbols.
Compiling the source file appears to go through fine except for some warnings:

$ gcc -o levenshtein.so -shared levenshtein.c -fPIC `mysql_config --include`
In file included from levenshtein.c:54:0:
/usr/include/mysql/my_global.h:3:2: warning: #warning This file should not be included by clients, include only <mysql.h> [-Wcpp]
 #warning This file should not be included by clients, include only <mysql.h>
  ^
In file included from levenshtein.c:55:0:
/usr/include/mysql/my_sys.h:3:2: warning: #warning This file should not be included by clients, include only <mysql.h> [-Wcpp]
 #warning This file should not be included by clients, include only <mysql.h>
  ^

However after copying the file to the mysql plugin directory and trying to create the function with:
CREATE FUNCTION levenshtein RETURNS INT SONAME 'levenshtein.so';
I get the following error: Error: Can't find symbol 'levenshtein' in library

The library is compiled fine (it seems) and mariadb can search it but there is no sign of the levenshtein symbol.
Running nm levenshtein.so also makes no mention of any of the functions:

$ nm levenshtein.so 
0000000000201028 B __bss_start
0000000000201028 b completed.6354
                 w __cxa_finalize@@GLIBC_2.2.5
0000000000000530 t deregister_tm_clones
00000000000005a0 t __do_global_dtors_aux
0000000000200e00 t __do_global_dtors_aux_fini_array_entry
0000000000200e10 d __dso_handle
0000000000200e18 d _DYNAMIC
0000000000201028 D _edata
0000000000201030 B _end
0000000000000618 T _fini
00000000000005e0 t frame_dummy
0000000000200df8 t __frame_dummy_init_array_entry
0000000000000628 r __FRAME_END__
0000000000201000 d _GLOBAL_OFFSET_TABLE_
                 w __gmon_start__
00000000000004e0 T _init
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
0000000000200e08 d __JCR_END__
0000000000200e08 d __JCR_LIST__
                 w _Jv_RegisterClasses
0000000000000560 t register_tm_clones
0000000000201028 d __TMC_END__

Thoughts and prayers?
Thanks!

Does not build (MySQL 8 issue maybe?)

This seems like a nice levenshtein plugin to have
I successfully built & installed on my local windows WSL ubuntu 18
However i cannot seem to build it on my online VPS CentOS 7 (cpanel/WHM) with MySQL 8 and mysql-community-devel-8.0.21-1.el7.x86_64

  • STANDARD is not defined
  • my_global.h and my_sys.h do not exist anymore in the mysql includes directory
  • my_bool is not defined etc. (looks like it's been removed from mysql?)

Any hope to update the header dependencies so it can still build?

Build with MariaDB 10.3+ failed

I am trying to build the function with mariadb 10.3 with libmariadb-dev. But mysql_config is not available. I tried it with mariadb_config. But it doesn't work. How can I compile the function with mariadb 10.3+.

I'm trying to install inside a Dockerfile.

Error with MYSql 8

When running GCC I get an error

levenshtein.c:11:10: fatal error: my_global.h: No such file or directory
#include <my_global.h>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.