From 9d2550a89e4db38465fe5f21982ee284c2816862 Mon Sep 17 00:00:00 2001 From: Partha Sai Date: Wed, 21 Jun 2023 20:58:37 +0530 Subject: [PATCH 1/5] In Mysql 8 my_bool variable is depricated Replaced my_bool with int --- http.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/http.go b/http.go index 83533d6..71182df 100644 --- a/http.go +++ b/http.go @@ -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 @@ -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 @@ -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 @@ -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 } From f9a056b00718518466f55a48652a80099aca56d0 Mon Sep 17 00:00:00 2001 From: parthasai Date: Wed, 21 Jun 2023 21:01:12 +0530 Subject: [PATCH 2/5] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b869577..264beb4 100644 --- a/README.md +++ b/README.md @@ -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 @@ -9,7 +11,7 @@ Setup --- - **Clone Source** ```shell -git clone https://github.com/2rebi/mysql_udf_http_golang.git udf +git clone https://github.com/parthasai/mysql_udf_http_golang.git udf cd udf ``` From e1fc6f8d7895c9b28295ffbd215cea41891b2aa0 Mon Sep 17 00:00:00 2001 From: parthasai Date: Wed, 21 Jun 2023 21:41:26 +0530 Subject: [PATCH 3/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 264beb4..99dc326 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ Setup --- - **Clone Source** ```shell +sudo apt install libmysqlclient-dev git clone https://github.com/parthasai/mysql_udf_http_golang.git udf cd udf ``` From d7ccecf69a1fe256f89b4949f968051e72a04604 Mon Sep 17 00:00:00 2001 From: parthasai Date: Wed, 21 Jun 2023 21:48:02 +0530 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99dc326..8a56f37 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Setup --- - **Clone Source** ```shell -sudo apt install libmysqlclient-dev +sudo apt install libmysqlclient-dev golang-go git clone https://github.com/parthasai/mysql_udf_http_golang.git udf cd udf ``` From eaaeae057b811adbd41deeddc8372b5e9548580d Mon Sep 17 00:00:00 2001 From: Partha Sai Date: Wed, 21 Jun 2023 21:56:25 +0530 Subject: [PATCH 5/5] edited plugin_dir extraction to avoid junk string --- install.sh | 10 +++++----- uninstall.sh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 46c1999..56e90de 100644 --- a/install.sh +++ b/install.sh @@ -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 diff --git a/uninstall.sh b/uninstall.sh index fe53dcd..aa5ff15 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -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"