Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql 8.0 support #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# mysql_udf_http_golang
Now works for Mysql 8+ also.

[![MySQL UDF](https://img.shields.io/badge/MySQL-UDF-blue.svg)](https://dev.mysql.com/) [![MariaDB UDF](https://img.shields.io/badge/MariaDB-UDF-blue.svg)](https://mariadb.com/)

[MySQL](https://dev.mysql.com/) or [MariaDB](https://mariadb.com/) UDF(User-Defined Functions) HTTP Client Plugin
Expand All @@ -9,7 +11,8 @@ Setup
---
- **Clone Source**
```shell
git clone https://github.com/2rebi/mysql_udf_http_golang.git udf
sudo apt install libmysqlclient-dev golang-go
git clone https://github.com/parthasai/mysql_udf_http_golang.git udf
cd udf
```

Expand Down
8 changes: 4 additions & 4 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func httpRaw(method string, url string, contentType string, body string, options
}

//export http_raw_init
func http_raw_init(initid *C.UDF_INIT, args *C.UDF_ARGS, message *C.char) C.my_bool {
func http_raw_init(initid *C.UDF_INIT, args *C.UDF_ARGS, message *C.char) C.int {
if args.arg_count < 3 {
msg := `
http_raw(method string, url string, body string, option ...string) requires method, url, body argment
Expand Down Expand Up @@ -237,7 +237,7 @@ func http_raw(initid *C.UDF_INIT, args *C.UDF_ARGS, result *C.char, length *uint
}

//export http_get_init
func http_get_init(initid *C.UDF_INIT, args *C.UDF_ARGS, message *C.char) C.my_bool {
func http_get_init(initid *C.UDF_INIT, args *C.UDF_ARGS, message *C.char) C.int {
if args.arg_count == 0 {
msg := `
http_get(url string, option ...string) requires url argment
Expand Down Expand Up @@ -273,7 +273,7 @@ func http_get(initid *C.UDF_INIT, args *C.UDF_ARGS, result *C.char, length *uint
}

//export http_post_init
func http_post_init(initid *C.UDF_INIT, args *C.UDF_ARGS, message *C.char) C.my_bool {
func http_post_init(initid *C.UDF_INIT, args *C.UDF_ARGS, message *C.char) C.int {
if args.arg_count < 3 {
msg := `
http_post(url string, contentType string, body string, option ...string) requires url, contentType, body argment
Expand Down Expand Up @@ -308,7 +308,7 @@ func http_post(initid *C.UDF_INIT, args *C.UDF_ARGS, result *C.char, length *uin
}

//export http_help_init
func http_help_init(initid *C.UDF_INIT, args *C.UDF_ARGS, message *C.char) C.my_bool {
func http_help_init(initid *C.UDF_INIT, args *C.UDF_ARGS, message *C.char) C.int {
return 0
}

Expand Down
10 changes: 5 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ if [[ $# > 0 ]]; then
fi

sql_result=$(mysql --user=$1 --password=$2 -s -N -e "SHOW VARIABLES LIKE 'plugin_dir';")
plugin_dir=$(cut -d" " -f2 <<< $sql_result)
plugin_dir=$(awk '{print $2}' <<< "$sql_result")

export CGO_CFLAGS=$include_dir
go build -buildmode=c-shared -o $plugin_dir"http.so" http.go
rm $plugin_dir"http.h"

mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_help RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_raw RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_get RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE OR REPLACE FUNCTION http_post RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE FUNCTION http_help RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE FUNCTION http_raw RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE FUNCTION http_get RETURNS STRING SONAME 'http.so';"
mysql --user=$1 --password=$2 -s -N -e "CREATE FUNCTION http_post RETURNS STRING SONAME 'http.so';"

echo "Install Success"
else
Expand Down
2 changes: 1 addition & 1 deletion uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [[ $# > 0 ]]; then
mysql --user=$1 --password=$2 -s -N -e "DROP FUNCTION http_post;"

sql_result=$(mysql --user=$1 --password=$2 -s -N -e "SHOW VARIABLES LIKE 'plugin_dir';")
plugin_dir=$(cut -d" " -f2 <<< $sql_result)
plugin_dir=$(awk '{print $2}' <<< "$sql_result")
rm $plugin_dir"http.so"

echo "Uninstall Success"
Expand Down