From 49122899ce9e7fb7898bb594c42cee06387e444d Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 1 Apr 2012 17:46:40 +0200 Subject: [PATCH 01/18] Use thd_killed() instead of underlaying killed field --- handlersocket/database.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/handlersocket/database.cpp b/handlersocket/database.cpp index a8746f4..8d9b93d 100644 --- a/handlersocket/database.cpp +++ b/handlersocket/database.cpp @@ -246,12 +246,12 @@ wait_server_to_start(THD *thd, volatile int& shutdown_flag) &abstime); pthread_mutex_unlock(&LOCK_server_started); pthread_mutex_lock(&thd->mysys_var->mutex); - THD::killed_state st = thd->killed; + int killed = thd_killed(thd); pthread_mutex_unlock(&thd->mysys_var->mutex); - DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d\n", (int)st)); + DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d\n", killed)); pthread_mutex_lock(&LOCK_server_started); - if (st != THD::NOT_KILLED) { - DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d break\n", (int)st)); + if (killed) { + DBG_SHUT(fprintf(stderr, "HNDSOCK wsts kst %d break\n", killed)); r = -1; break; } @@ -358,12 +358,12 @@ bool dbcontext::check_alive() { pthread_mutex_lock(&thd->mysys_var->mutex); - THD::killed_state st = thd->killed; + int killed = thd_killed(thd); pthread_mutex_unlock(&thd->mysys_var->mutex); - DBG_SHUT(fprintf(stderr, "chk HNDSOCK kst %p %p %d %zu\n", thd, &thd->killed, + DBG_SHUT(fprintf(stderr, "chk HNDSOCK kst %p %p %d %u\n", thd, killed, (int)st, sizeof(*thd))); - if (st != THD::NOT_KILLED) { - DBG_SHUT(fprintf(stderr, "chk HNDSOCK kst %d break\n", (int)st)); + if (killed) { + DBG_SHUT(fprintf(stderr, "chk HNDSOCK kst %d break\n", killed)); return false; } return true; From 8a65d2e252c043232861fee95eb13aab69616071 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 1 Apr 2012 17:56:35 +0200 Subject: [PATCH 02/18] Support MariaDB configure file in configure.ac --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4395fcf..d1e2c9a 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,7 @@ AC_DEFUN([CONFIG_OPTION_MYSQL],[ MYSQL_SOURCE_VERSION="$MYSQL_VERSION_MAJOR.$MYSQL_VERSION_MINOR.$MYSQL_VERSION_PATCH" else if test -f "$ac_mysql_source_dir/configure.in"; then - MYSQL_SOURCE_VERSION=`cat $ac_mysql_source_dir/configure.in | grep "\[[MySQL Server\]]" | sed -e "s|.*\([[0-9]]\+\.[[0-9]]\+\.[[0-9]]\+[[0-9a-zA-Z\_\-]]*\).*|\1|"` + MYSQL_SOURCE_VERSION=`cat $ac_mysql_source_dir/configure.in | grep "\[[\(MariaDB\|MySQL\) Server\]]" | sed -e "s|.*\([[0-9]]\+\.[[0-9]]\+\.[[0-9]]\+[[0-9a-zA-Z\_\-]]*\).*|\1|"` else AC_MSG_ERROR([invalid MySQL source directory: $ac_mysql_source_dir]) fi From 38c10da37ce2a80b2ec631d297479022e140aabb Mon Sep 17 00:00:00 2001 From: Akira Higuchi Date: Tue, 1 May 2012 20:58:45 +0900 Subject: [PATCH 03/18] fixed an invalid memory access (issue #78) --- docs-en/perl-client.en.txt | 1 - docs-ja/perl-client.ja.txt | 1 - handlersocket/database.cpp | 2 +- regtest/test_01_lib/run.sh | 2 +- regtest/test_01_lib/test24.expected | 2 ++ regtest/test_01_lib/test24.pl | 35 +++++++++++++++++++++++++++++ 6 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 regtest/test_01_lib/test24.expected create mode 100644 regtest/test_01_lib/test24.pl diff --git a/docs-en/perl-client.en.txt b/docs-en/perl-client.en.txt index f2b91a3..448d33b 100644 --- a/docs-en/perl-client.en.txt +++ b/docs-en/perl-client.en.txt @@ -93,7 +93,6 @@ The execute_single method can be used for inserting records also. my $res = $hs->execute_single(3, '+', [ 'foo', 'bar', 'baz' ]); die $hs->get_error() if $res->[0] != 0; - my $num_inserted_rows = $res->[1]; The 3rd argument must be an arrayref whose elements correspond to the 5th argument for the corresponding open_index call. If there diff --git a/docs-ja/perl-client.ja.txt b/docs-ja/perl-client.ja.txt index bb0cd79..90b7e4d 100644 --- a/docs-ja/perl-client.ja.txt +++ b/docs-ja/perl-client.ja.txt @@ -86,7 +86,6 @@ execute_singleメソッドは列の挿入にも使用できます。 my $res = $hs->execute_single(3, '+', [ 'foo', 'bar', 'baz' ]); die $hs->get_error() if $res->[0] != 0; - my $num_inserted_rows = $res->[1]; 第3引数は、対応するopen_index呼び出しの第5引数の列リストと同じだ けの長さの配列への参照でなければなりません。open_index呼び出しの diff --git a/handlersocket/database.cpp b/handlersocket/database.cpp index a8746f4..264174d 100644 --- a/handlersocket/database.cpp +++ b/handlersocket/database.cpp @@ -659,7 +659,7 @@ dbcontext::cmd_insert_internal(dbcallback_i& cb, const prep_stmt& pst, empty_record(table); memset(buf, 0, table->s->null_bytes); /* clear null flags */ const prep_stmt::fields_type& rf = pst.get_ret_fields(); - const size_t n = rf.size(); + const size_t n = std::min(rf.size(), fvalslen); for (size_t i = 0; i < n; ++i) { uint32_t fn = rf[i]; Field *const fld = table->field[fn]; diff --git a/regtest/test_01_lib/run.sh b/regtest/test_01_lib/run.sh index 8514612..84603d6 100755 --- a/regtest/test_01_lib/run.sh +++ b/regtest/test_01_lib/run.sh @@ -1,6 +1,6 @@ #!/bin/bash -TESTS="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23"; +TESTS="01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24"; source ../common/compat.sh diff --git a/regtest/test_01_lib/test24.expected b/regtest/test_01_lib/test24.expected new file mode 100644 index 0000000..5d07e01 --- /dev/null +++ b/regtest/test_01_lib/test24.expected @@ -0,0 +1,2 @@ +HS +0 0 diff --git a/regtest/test_01_lib/test24.pl b/regtest/test_01_lib/test24.pl new file mode 100644 index 0000000..6cd95a9 --- /dev/null +++ b/regtest/test_01_lib/test24.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +# vim:sw=2:ai + +# test for issue #78 + +BEGIN { + push @INC, "../common/"; +}; + +use strict; +use warnings; +use hstest; + +my $dbh = hstest::init_testdb(); +my $table = 'hstesttbl'; +my $tablesize = 100; +$dbh->do( + "create table $table (" . + "id bigint(20) not null auto_increment, " . + "t1 timestamp not null default current_timestamp, " . + "primary key (id)" . + ") engine = innodb"); +srand(999); + +my %valmap = (); + +my $hs = hstest::get_hs_connection(undef, 9999); +my $dbname = $hstest::conf{dbname}; +$hs->open_index(0, $dbname, $table, 'PRIMARY', 'id,t1'); +my $res = $hs->execute_single(0, '+', [ 321 ], 0, 0); +die $hs->get_error() if $res->[0] != 0; +print "HS\n"; +print join(' ', @$res) . "\n"; + From cc5299f9f7497eb0683926633614b7cd79083ad5 Mon Sep 17 00:00:00 2001 From: SvartalF Date: Mon, 4 Jun 2012 10:39:00 +0900 Subject: [PATCH 04/18] Fixing build with automake >= 1.12 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d1e2c9a..c9c53d4 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ #AC_PREREQ([2.63b]) AC_INIT([handlersocket-plugin], [1.0.6], [https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/issues]) AC_CONFIG_HEADERS([config.h]) -AM_INIT_AUTOMAKE([-Wall -Werror foreign]) +AM_INIT_AUTOMAKE([-Wall -Wno-extra-portability -Werror foreign]) AC_CONFIG_SRCDIR([libhsclient/fatal.cpp]) AC_CONFIG_MACRO_DIR([m4]) From a470bd5d8e86dfddae4c9cef1afbdfb2fa8b4f68 Mon Sep 17 00:00:00 2001 From: SvartalF Date: Mon, 4 Jun 2012 10:47:37 +0900 Subject: [PATCH 05/18] Use AM_PROG_AR instead of a -Wno-extra-portability key --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index c9c53d4..202f539 100644 --- a/configure.ac +++ b/configure.ac @@ -4,10 +4,13 @@ #AC_PREREQ([2.63b]) AC_INIT([handlersocket-plugin], [1.0.6], [https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/issues]) AC_CONFIG_HEADERS([config.h]) -AM_INIT_AUTOMAKE([-Wall -Wno-extra-portability -Werror foreign]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_CONFIG_SRCDIR([libhsclient/fatal.cpp]) AC_CONFIG_MACRO_DIR([m4]) +# For automake >= 1.12 +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) + AC_PROG_CC AC_PROG_CXX AC_PROG_CPP From 6ec33eb53d9cb94816a1d22160f09c80cbfb8a30 Mon Sep 17 00:00:00 2001 From: SvartalF Date: Mon, 4 Jun 2012 11:25:32 +0900 Subject: [PATCH 06/18] Ability to compile HandlerSocket under a gcc-4.7 --- libhsclient/fatal.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libhsclient/fatal.cpp b/libhsclient/fatal.cpp index 8f8751d..5cdd887 100644 --- a/libhsclient/fatal.cpp +++ b/libhsclient/fatal.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "fatal.hpp" From bbd00c91e92867628d9e043ebd0636ca1bbc20e8 Mon Sep 17 00:00:00 2001 From: Akira Higuchi Date: Thu, 14 Feb 2013 05:17:40 +0900 Subject: [PATCH 07/18] moved from DeNADev to DeNA --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 10717d0..104590d 100644 --- a/README +++ b/README @@ -72,7 +72,7 @@ Here is a list of client libraries for other languages: https://github.com/wuxb45/HandlerSocket-Haskell-Client The home of HandlerSocket is here: - https://github.com/DeNADev/HandlerSocket-Plugin-for-MySQL + https://github.com/DeNA/HandlerSocket-Plugin-for-MySQL More documents are available in docs-en/ and docs-ja/ directories. From 393b82d86e130bbd5e9466253ab1921f280a5fd3 Mon Sep 17 00:00:00 2001 From: Akira Higuchi Date: Tue, 19 Mar 2013 14:58:10 +0900 Subject: [PATCH 08/18] changes for mysql 5.6 --- handlersocket/database.cpp | 26 +++++++++++++++++++++++++- handlersocket/mysql_incl.hpp | 4 ++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/handlersocket/database.cpp b/handlersocket/database.cpp index c95cd89..1712b8a 100644 --- a/handlersocket/database.cpp +++ b/handlersocket/database.cpp @@ -309,8 +309,12 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag) { pthread_mutex_lock(&LOCK_thread_count); thd->thread_id = thread_id++; + #if MYSQL_VERSION_ID >= 50600 + add_global_thread(thd); + #else threads.append(thd); ++thread_count; + #endif pthread_mutex_unlock(&LOCK_thread_count); } @@ -346,9 +350,13 @@ dbcontext::term_thread() my_pthread_setspecific_ptr(THR_THD, 0); { pthread_mutex_lock(&LOCK_thread_count); + #if MYSQL_VERSION_ID >= 50600 + remove_global_thread(thd); + #else + --thread_count; + #endif delete thd; thd = 0; - --thread_count; pthread_mutex_unlock(&LOCK_thread_count); my_thread_end(); } @@ -763,7 +771,11 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst, return cb.dbcb_resp_short(2, "idxnum"); } KEY& kinfo = table->key_info[pst.get_idxnum()]; + #if MYSQL_VERSION_ID >= 50600 + if (args.kvalslen > kinfo.actual_key_parts) { + #else if (args.kvalslen > kinfo.key_parts) { + #endif return cb.dbcb_resp_short(2, "kpnum"); } uchar *const key_buf = DENA_ALLOCA_ALLOCATE(uchar, kinfo.key_length); @@ -812,11 +824,19 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst, switch (find_flag) { case HA_READ_BEFORE_KEY: case HA_READ_KEY_OR_PREV: + #if MYSQL_VERSION_ID >= 50600 + r = hnd->ha_index_prev(table->record[0]); + #else r = hnd->index_prev(table->record[0]); + #endif break; case HA_READ_AFTER_KEY: case HA_READ_KEY_OR_NEXT: + #if MYSQL_VERSION_ID >= 50600 + r = hnd->ha_index_next(table->record[0]); + #else r = hnd->index_next(table->record[0]); + #endif break; case HA_READ_KEY_EXACT: r = hnd->index_next_same(table->record[0], key_buf, kplen_sum); @@ -1015,7 +1035,11 @@ dbcontext::cmd_open(dbcallback_i& cb, const cmd_open_args& arg) tables.mdl_request.init(MDL_key::TABLE, arg.dbn, arg.tbl, for_write_flag ? MDL_SHARED_WRITE : MDL_SHARED_READ, MDL_TRANSACTION); Open_table_context ot_act(thd, 0); + #if MYSQL_VERSION_ID >= 50600 + if (!open_table(thd, &tables, &ot_act)) { + #else if (!open_table(thd, &tables, thd->mem_root, &ot_act)) { + #endif table = tables.table; } #else diff --git a/handlersocket/mysql_incl.hpp b/handlersocket/mysql_incl.hpp index d8dba70..308078f 100644 --- a/handlersocket/mysql_incl.hpp +++ b/handlersocket/mysql_incl.hpp @@ -43,6 +43,10 @@ #include "mysql_priv.h" #endif +#if MYSQL_VERSION_ID >= 50600 +#include +#endif + #undef min #undef max From 2f86eada66cc14ce764b8c56644b267fc502cc65 Mon Sep 17 00:00:00 2001 From: Akira Higuchi Date: Tue, 19 Mar 2013 19:09:01 +0900 Subject: [PATCH 09/18] add a patch against mysql 5.6 to fix that mysqld shutdown fails --- handlersocket/database.cpp | 4 ++-- misc/mysql-5.6.10-server_started.diff | 20 +++++++++++++++++++ .../perl-Net-HandlerSocket.spec.template | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 misc/mysql-5.6.10-server_started.diff diff --git a/handlersocket/database.cpp b/handlersocket/database.cpp index 1712b8a..51c6f66 100644 --- a/handlersocket/database.cpp +++ b/handlersocket/database.cpp @@ -318,9 +318,9 @@ dbcontext::init_thread(const void *stack_bottom, volatile int& shutdown_flag) pthread_mutex_unlock(&LOCK_thread_count); } - DBG_THR(fprintf(stderr, "HNDSOCK init thread wsts\n")); + DBG_THR(fprintf(stderr, "HNDSOCK %p init thread wsts\n", thd)); wait_server_to_start(thd, shutdown_flag); - DBG_THR(fprintf(stderr, "HNDSOCK init thread done\n")); + DBG_THR(fprintf(stderr, "HNDSOCK %p init thread done\n", thd)); thd_proc_info(thd, &info_message_buf[0]); set_thread_message("hs:listening"); diff --git a/misc/mysql-5.6.10-server_started.diff b/misc/mysql-5.6.10-server_started.diff new file mode 100644 index 0000000..ee916e3 --- /dev/null +++ b/misc/mysql-5.6.10-server_started.diff @@ -0,0 +1,20 @@ +--- mysql-5.6.10/sql/mysqld.cc.org 2013-03-19 18:12:44.923208944 +0900 ++++ mysql-5.6.10/sql/mysqld.cc 2013-03-19 18:14:16.638988599 +0900 +@@ -5532,7 +5532,7 @@ + /* Signal threads waiting for server to be started */ + mysql_mutex_lock(&LOCK_server_started); + mysqld_server_started= 1; +- mysql_cond_signal(&COND_server_started); ++ mysql_cond_broadcast(&COND_server_started); + mysql_mutex_unlock(&LOCK_server_started); + + bootstrap(mysql_stdin); +@@ -5560,7 +5560,7 @@ + /* Signal threads waiting for server to be started */ + mysql_mutex_lock(&LOCK_server_started); + mysqld_server_started= 1; +- mysql_cond_signal(&COND_server_started); ++ mysql_cond_broadcast(&COND_server_started); + mysql_mutex_unlock(&LOCK_server_started); + + #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE diff --git a/perl-Net-HandlerSocket/perl-Net-HandlerSocket.spec.template b/perl-Net-HandlerSocket/perl-Net-HandlerSocket.spec.template index 304baf0..2448576 100644 --- a/perl-Net-HandlerSocket/perl-Net-HandlerSocket.spec.template +++ b/perl-Net-HandlerSocket/perl-Net-HandlerSocket.spec.template @@ -22,7 +22,7 @@ group: System Environment/Libraries buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n) prefix: %(echo %{_prefix}) source: perl-Net-HandlerSocket.tar.gz -BuildRequires: libhsclient +BuildRequires: libhsclient perl-Test-Simple Requires: libhsclient Obsoletes: perl-DB-HandlerSocket From a8529273df33cb25f84b29986f55d707680367f5 Mon Sep 17 00:00:00 2001 From: Akira Higuchi Date: Tue, 19 Mar 2013 19:28:58 +0900 Subject: [PATCH 10/18] modify some tests to work with mysql 5.6 --- regtest/test_01_lib/test14.pl | 2 +- regtest/test_01_lib/test17.pl | 2 +- regtest/test_01_lib/test19.pl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/regtest/test_01_lib/test14.pl b/regtest/test_01_lib/test14.pl index 68ce87b..ff4e433 100644 --- a/regtest/test_01_lib/test14.pl +++ b/regtest/test_01_lib/test14.pl @@ -27,7 +27,7 @@ BEGIN my %valmap = (); -my $sth = $dbh->prepare("insert into $table values (?,?,?)"); +my $sth = $dbh->prepare("insert ignore into $table values (?,?,?)"); for (my $i = 0; $i < $tablesize; ++$i) { my $k = $i; my ($s1, $s2) = ("", ""); diff --git a/regtest/test_01_lib/test17.pl b/regtest/test_01_lib/test17.pl index b7861b8..1ffd7fa 100644 --- a/regtest/test_01_lib/test17.pl +++ b/regtest/test_01_lib/test17.pl @@ -60,7 +60,7 @@ sub test_one { $dbh->do( "create table $table (" . "k $typ, " . - "v1 varchar(2047), " . + "v1 varchar(1000), " . "v2 $typ, " . "primary key(k$keylen_str), " . "index i1(v1), index i2(v2$keylen_str, v1(300))) " . diff --git a/regtest/test_01_lib/test19.pl b/regtest/test_01_lib/test19.pl index 6c43267..9870199 100644 --- a/regtest/test_01_lib/test19.pl +++ b/regtest/test_01_lib/test19.pl @@ -113,7 +113,7 @@ sub test_one { "(k1 int not null, k2 int not null, " . "v1 int not null, v2 $typ default null, " . "primary key (k1, k2) ) engine = innodb"); - my $sth = $dbh->prepare("insert into $table values (?,?,?,?)"); + my $sth = $dbh->prepare("insert ignore into $table values (?,?,?,?)"); for (my $i = 0; $i < $tablesize; ++$i) { my $j = 0; for my $v (@$values) { From d01c8181789d3355ac8ac55734a16d606ba662b0 Mon Sep 17 00:00:00 2001 From: Akira Higuchi Date: Mon, 6 May 2013 05:06:37 +0900 Subject: [PATCH 11/18] fix a compilation problem with mysql 5.6.11 --- .gitignore | 1 + handlersocket/database.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/.gitignore b/.gitignore index 893cdb0..c3c70f8 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ regtest/*/*.log regtest/*/*.log2 regtest/*/DONE dist/* +ar-lib diff --git a/handlersocket/database.cpp b/handlersocket/database.cpp index 51c6f66..bd0d9b2 100644 --- a/handlersocket/database.cpp +++ b/handlersocket/database.cpp @@ -812,14 +812,22 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst, if (is_first) { is_first = false; const key_part_map kpm = (1U << args.kvalslen) - 1; + #if MYSQL_VERSION_ID >= 50611 + r = hnd->ha_index_read_map(table->record[0], key_buf, kpm, find_flag); + #else r = hnd->index_read_map(table->record[0], key_buf, kpm, find_flag); + #endif } else if (args.invalues_keypart >= 0) { if (++invalues_idx >= args.invalueslen) { break; } kplen_sum = prepare_keybuf(args, key_buf, table, kinfo, invalues_idx); const key_part_map kpm = (1U << args.kvalslen) - 1; + #if MYSQL_VERSION_ID >= 50611 + r = hnd->ha_index_read_map(table->record[0], key_buf, kpm, find_flag); + #else r = hnd->index_read_map(table->record[0], key_buf, kpm, find_flag); + #endif } else { switch (find_flag) { case HA_READ_BEFORE_KEY: @@ -839,7 +847,11 @@ dbcontext::cmd_find_internal(dbcallback_i& cb, const prep_stmt& pst, #endif break; case HA_READ_KEY_EXACT: + #if MYSQL_VERSION_ID >= 50611 + r = hnd->ha_index_next_same(table->record[0], key_buf, kplen_sum); + #else r = hnd->index_next_same(table->record[0], key_buf, kplen_sum); + #endif break; default: r = HA_ERR_END_OF_FILE; /* to finish the loop */ From a4f5436e45e25f77b1a84af545d6cf319b0dc0c1 Mon Sep 17 00:00:00 2001 From: Akira Higuchi Date: Mon, 6 May 2013 05:32:57 +0900 Subject: [PATCH 12/18] version 1.1.1 --- ChangeLog | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bc76a96..35f4176 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +1.1.1 - 2013-05-06 + * 1.1.1 + * Fixed compilation problems with mysql 5.6.11 + 1.1.0 - 2011-12-29 * 1.1.0 diff --git a/configure.ac b/configure.ac index 202f539..07c8f70 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. #AC_PREREQ([2.63b]) -AC_INIT([handlersocket-plugin], [1.0.6], [https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/issues]) +AC_INIT([handlersocket-plugin], [1.1.1], [https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL/issues]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_CONFIG_SRCDIR([libhsclient/fatal.cpp]) From 1301105ee54aaea3dc6f96d3bed00433076b3d4c Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Fri, 28 Nov 2014 15:33:31 +0300 Subject: [PATCH 13/18] move remove_global_thread() out of the lock since it locks the same mutex, causing deadlock --- handlersocket/database.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/handlersocket/database.cpp b/handlersocket/database.cpp index bd0d9b2..854cbf7 100644 --- a/handlersocket/database.cpp +++ b/handlersocket/database.cpp @@ -349,10 +349,12 @@ dbcontext::term_thread() unlock_tables_if(); my_pthread_setspecific_ptr(THR_THD, 0); { - pthread_mutex_lock(&LOCK_thread_count); #if MYSQL_VERSION_ID >= 50600 remove_global_thread(thd); - #else + #endif + + pthread_mutex_lock(&LOCK_thread_count); + #if MYSQL_VERSION_ID < 50600 --thread_count; #endif delete thd; From 802d7d53003faa9b89ffc88aa56695dee8063bc7 Mon Sep 17 00:00:00 2001 From: Akira Higuchi Date: Tue, 28 Jul 2015 15:06:23 +0900 Subject: [PATCH 14/18] fix that mysqld aborts on exit if an open handlersocket connection remains --- handlersocket/Makefile.plain.template | 2 +- handlersocket/database.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/handlersocket/Makefile.plain.template b/handlersocket/Makefile.plain.template index 4d5f8c1..0956dd6 100644 --- a/handlersocket/Makefile.plain.template +++ b/handlersocket/Makefile.plain.template @@ -4,7 +4,7 @@ MYSQL_LIB = HANDLERSOCKET_MYSQL_LIB CXX = g++ -Wall -g -fno-rtti -fno-exceptions -fPIC -DPIC LIBS = $(MYSQL_LIB) -lhsclient -lpthread -lz -CXXFLAGS = -I/usr/include/handlersocket $(MYSQL_INC) +CXXFLAGS = -I../libhsclient $(MYSQL_INC) LDFLAGS = CXXFLAGS += -O3 -DNDEBUG diff --git a/handlersocket/database.cpp b/handlersocket/database.cpp index 854cbf7..eb0d5c1 100644 --- a/handlersocket/database.cpp +++ b/handlersocket/database.cpp @@ -346,7 +346,7 @@ void dbcontext::term_thread() { DBG_THR(fprintf(stderr, "HNDSOCK thread end %p\n", thd)); - unlock_tables_if(); + close_tables_if(); my_pthread_setspecific_ptr(THR_THD, 0); { #if MYSQL_VERSION_ID >= 50600 From 43049607a39a0313dab243730c7a4069e7e7ccf5 Mon Sep 17 00:00:00 2001 From: Akira Higuchi Date: Tue, 28 Jul 2015 16:04:53 +0900 Subject: [PATCH 15/18] fix a performance bug --- handlersocket/database.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/handlersocket/database.cpp b/handlersocket/database.cpp index eb0d5c1..4ce49de 100644 --- a/handlersocket/database.cpp +++ b/handlersocket/database.cpp @@ -183,6 +183,8 @@ struct dbcontext : public dbcontext_i, private noncopyable { std::vector info_message_buf; table_vec_type table_vec; table_map_type table_map; + String val_buffer; + String val_ptr; }; database::database(const config& c) @@ -518,8 +520,6 @@ void dbcontext::resp_record(dbcallback_i& cb, TABLE *const table, const prep_stmt& pst) { - char rwpstr_buf[64]; - String rwpstr(rwpstr_buf, sizeof(rwpstr_buf), &my_charset_bin); const prep_stmt::fields_type& rf = pst.get_ret_fields(); const size_t n = rf.size(); for (size_t i = 0; i < n; ++i) { @@ -530,11 +530,11 @@ dbcontext::resp_record(dbcallback_i& cb, TABLE *const table, /* null */ cb.dbcb_resp_entry(0, 0); } else { - fld->val_str(&rwpstr, &rwpstr); - const size_t len = rwpstr.length(); + String *const val = fld->val_str(&val_buffer, &val_ptr); + const size_t len = val->length(); if (len != 0) { /* non-empty */ - cb.dbcb_resp_entry(rwpstr.ptr(), rwpstr.length()); + cb.dbcb_resp_entry(val->ptr(), val->length()); } else { /* empty */ static const char empty_str[] = ""; @@ -548,8 +548,6 @@ void dbcontext::dump_record(dbcallback_i& cb, TABLE *const table, const prep_stmt& pst) { - char rwpstr_buf[64]; - String rwpstr(rwpstr_buf, sizeof(rwpstr_buf), &my_charset_bin); const prep_stmt::fields_type& rf = pst.get_ret_fields(); const size_t n = rf.size(); for (size_t i = 0; i < n; ++i) { @@ -559,8 +557,8 @@ dbcontext::dump_record(dbcallback_i& cb, TABLE *const table, /* null */ fprintf(stderr, "NULL"); } else { - fld->val_str(&rwpstr, &rwpstr); - const std::string s(rwpstr.ptr(), rwpstr.length()); + String *const val = fld->val_str(&val_buffer, &val_ptr); + const std::string s(val->ptr(), val->length()); fprintf(stderr, "[%s]", s.c_str()); } } From 85aae57462972a710a0b03ad0b6170d5c35ee1b1 Mon Sep 17 00:00:00 2001 From: shadeware Date: Wed, 2 Mar 2016 11:24:44 +0300 Subject: [PATCH 16/18] libhsclient: fix socket read/connect: don't fail on EINTR --- libhsclient/hstcpcli.cpp | 15 +++++++++++++-- libhsclient/socket.cpp | 10 +++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/libhsclient/hstcpcli.cpp b/libhsclient/hstcpcli.cpp index c0cb5fb..616a30c 100644 --- a/libhsclient/hstcpcli.cpp +++ b/libhsclient/hstcpcli.cpp @@ -8,6 +8,8 @@ #include +#include + #include "hstcpcli.hpp" #include "auto_file.hpp" #include "string_util.hpp" @@ -125,9 +127,18 @@ hstcpcli::read_more() { const size_t block_size = 4096; // FIXME char *const wp = readbuf.make_space(block_size); - const ssize_t rlen = read(fd.get(), wp, block_size); + + ssize_t rlen; +again: + rlen = read(fd.get(), wp, block_size); if (rlen <= 0) { - if (rlen < 0) { + if (errno == EINTR) { + if (sargs.nonblocking) { + error_str = "read: interrupted"; + } else { + goto again; + } + } else if (rlen < 0) { error_str = "read: failed"; } else { error_str = "read: eof"; diff --git a/libhsclient/socket.cpp b/libhsclient/socket.cpp index d797910..4437f23 100644 --- a/libhsclient/socket.cpp +++ b/libhsclient/socket.cpp @@ -127,9 +127,17 @@ socket_connect(auto_file& fd, const socket_args& args, std::string& err_r) if ((r = socket_open(fd, args, err_r)) != 0) { return r; } + +again: if (connect(fd.get(), reinterpret_cast(&args.addr), args.addrlen) != 0) { - if (!args.nonblocking || errno != EINPROGRESS) { + if (errno == EINTR) { + if (args.nonblocking) { + return errno_string("connect", errno, err_r); + } else { + goto again; + } + } else if (!args.nonblocking || errno != EINPROGRESS) { return errno_string("connect", errno, err_r); } } From 4fe5687c566ec1f515d6c9ad7238ab727b3d61ec Mon Sep 17 00:00:00 2001 From: karupanerura Date: Wed, 28 Sep 2016 14:00:34 +0900 Subject: [PATCH 17/18] Should not use `Variable-length arrays`. clang doesn't support it. This extension is not permitted in standard C++. SEE ALSO: http://clang.llvm.org/compatibility.html#vla --- perl-Net-HandlerSocket/HandlerSocket.xs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/perl-Net-HandlerSocket/HandlerSocket.xs b/perl-Net-HandlerSocket/HandlerSocket.xs index d0aaaa3..22c0469 100644 --- a/perl-Net-HandlerSocket/HandlerSocket.xs +++ b/perl-Net-HandlerSocket/HandlerSocket.xs @@ -522,7 +522,7 @@ execute_multi(obj, cmds) CODE: DBG(fprintf(stderr, "execute_multi0\n")); const I32 cmdsmax = av_len(cmds); - execute_arg args[cmdsmax + 1]; /* GNU */ + execute_arg *args = new execute_arg[cmdsmax + 1]; for (I32 i = 0; i <= cmdsmax; ++i) { AV *const avtarget = arr_get_arrval(cmds, cmdsmax, i); if (avtarget == 0) { @@ -550,6 +550,7 @@ CODE: ag.filters, ag.invalues_keypart, ag.invalues)); } RETVAL = execute_multi_internal(obj, args, cmdsmax + 1); + delete [] args; sv_2mortal((SV *)RETVAL); OUTPUT: RETVAL From 2fccef4d81fa9cff35102eec4e4d345d12ab5511 Mon Sep 17 00:00:00 2001 From: karupanerura Date: Wed, 28 Sep 2016 14:02:33 +0900 Subject: [PATCH 18/18] Improvement compile/link options for portability --- perl-Net-HandlerSocket/HandlerSocket.xs | 2 +- perl-Net-HandlerSocket/Makefile.PL | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/perl-Net-HandlerSocket/HandlerSocket.xs b/perl-Net-HandlerSocket/HandlerSocket.xs index 22c0469..b20f177 100644 --- a/perl-Net-HandlerSocket/HandlerSocket.xs +++ b/perl-Net-HandlerSocket/HandlerSocket.xs @@ -12,7 +12,7 @@ #include "ppport.h" -#include "hstcpcli.hpp" +#include #define DBG(x) diff --git a/perl-Net-HandlerSocket/Makefile.PL b/perl-Net-HandlerSocket/Makefile.PL index 50c329d..c81f8c7 100644 --- a/perl-Net-HandlerSocket/Makefile.PL +++ b/perl-Net-HandlerSocket/Makefile.PL @@ -9,10 +9,12 @@ WriteMakefile( ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/Net/HandlerSocket.pm', # retrieve abstract from module AUTHOR => 'higuchi dot akira at dena dot jp>') : ()), - CC => 'g++ -fPIC', - LD => 'g++ -fPIC', - LIBS => ['-L../libhsclient -L../libhsclient/.libs -lhsclient'], + CC => 'g++', + CCFLAGS => '-fPIC -Werror=vla', + LD => '$(CC)', + LDFLAGS => '-fPIC', + XSOPT => '-C++', + LIBS => ['-lhsclient'], DEFINE => '', - INC => '-I. -I../libhsclient', OPTIMIZE => '-g -O3 -Wall -Wno-unused', );