Skip to content

Simple MySQL/MariaDB plugin for sending data to TCP socket and UNIX domain socket.

License

Notifications You must be signed in to change notification settings

petoc/mysql-udf-socket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MySQL UDF Socket

Simple MySQL/MariaDB plugin for sending data to TCP socket and UNIX domain socket.

Installation

To compile plugin, MySQL client library has to be available. On Debian/Ubuntu it can be installed with following command.

apt install libmysqlclient-dev

Compile and install.

make
make install

Create SQL functions.

DROP FUNCTION IF EXISTS mysql_udf_socket_info;
DROP FUNCTION IF EXISTS mysql_udf_socket_send;

CREATE FUNCTION mysql_udf_socket_info RETURNS string SONAME 'mysql_udf_socket.so';
CREATE FUNCTION mysql_udf_socket_send RETURNS string SONAME 'mysql_udf_socket.so';

Usage

-- print plugin info
SELECT mysql_udf_socket_info();
-- send data to tcp socket
SELECT mysql_udf_socket_send("tcp://127.0.0.1:8080", "hello");
-- send data to unix domain socket
SELECT mysql_udf_socket_send("unix:///tmp/test.sock", "hello");

Restrictions

  • maximum data length is 128 characters
  • request/response timeout is 2 seconds

Testing

TCP socket.

echo -ne "OK" | netcat -lp 8080 -q 1

UNIX domain socket.

socat -v UNIX-LISTEN:/tmp/test.sock,mode=777,reuseaddr EXEC:"echo -n OK"

License

Licensed under MIT License.

About

Simple MySQL/MariaDB plugin for sending data to TCP socket and UNIX domain socket.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published