Commit 7202c21b authored by Michael Widenius's avatar Michael Widenius

Merge of patch lp:~ahiguti100/maria/handlersocket-fix-78 by Akira Higuchi

A bugfix of HandlerSocket is not applied to mariadb yet
parent 53d44ad1
......@@ -66,7 +66,7 @@ Here is a list of other language bindings:
https://github.com/koichik/node-handlersocket
The home of HandlerSocket is here:
https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL
https://github.com/DeNADev/HandlerSocket-Plugin-for-MySQL
More documents are available in docs-en/ and docs-ja/ directories.
......@@ -17,10 +17,11 @@ crash, etc).
$ ./autogen.sh
$ ./configure --with-mysql-source=/work/mysql-5.1.50 --with-mysql-bindir=/work/mysql-5.1.50-linux-x86_64-glibc23/bin --with-mysql-plugindir=/work/mysql-5.1.50-linux-x86_64-glibc23/lib/plugin
--with-mysql-source refers to the top of MySQL source directory,
--with-mysql-bindir refers to where MySQL binary executables (i.e.
mysql_config) are located, and --with-mysql-plugindir refers to a plugin
directory where plugin libraries (*.so) are installed.
--with-mysql-source refers to the top of MySQL source directory (which
contains the VERSION file or the configure.in file), --with-mysql-bindir
refers to where MySQL binary executables (i.e. mysql_config) are located,
and --with-mysql-plugindir refers to a plugin directory where plugin
libraries (*.so) are installed.
$ make
$ sudo make install
......
......@@ -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
......@@ -116,6 +115,15 @@ executing them separatedly.
# ...
}
-----------------------------------------------------------------
If handlersocket is configured to authenticate client connections
(ie., handlersocket_plain_secret or handlersocket_plain_secret_wr
is set), a client must call 'auth' method before any other
methods.
my $res = $hs->auth('password');
die $hs->get_error() if $res->[0] != 0;
-----------------------------------------------------------------
When an error is occured, the first element of the returned
arrayref becomes a non-zero value. A negative value indicates
......
......@@ -29,7 +29,7 @@ Request and Response
lines) at one time, and receive responses for them at one time.
----------------------------------------------------------------------------
'open_index' request
Opening index
The 'open_index' request has the following syntax.
......@@ -74,23 +74,21 @@ FILETER is a sequence of the following parameters.
HandlerSocket supports '=', '>', '>=', '<', and '<='.
- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
must be smaller than or equal to the number of index columns specified by
the <columns> parameter of the corresponding 'open_index' request.
the <indexname> parameter of the corresponding 'open_index' request.
- <v1> ... <vn> specify the index column values to fetch.
- LIM is optional. <limit> and <offset> are numbers. When omitted, it works
as if 1 and 0 are specified. These parameter works like LIMIT of SQL.
These values don't include the number of records skipped by a filter.
- IN is optional. It works like WHERE ... IN syntax of SQL. <icol> must be
smaller than or equal to the number of index columns specified by the
<columns> parameter of the corresponding 'open_index' request. If IN is
specified in a find request, the <icol>-th parameter value of <v1> ...
<vn> is ignored.
smaller than or equal to the number of index columns specified by the
smaller than the number of index columns specified by the <indexname>
parameter of the corresponding 'open_index' request. If IN is specified in
a find request, the <icol>-th parameter value of <v1> ... <vn> is ignored.
- FILTERs are optional. A FILTER specifies a filter. <ftyp> is either 'F'
(filter) or 'W' (while). <fop> specifies the comparison operation to use.
<fcol> must be smaller than or equal to the number of columns specified by
the <fcolumns> parameter of the corresponding 'open_index' request.
Multiple filters can be specified, and work as the logical AND of them.
The difference of 'F' and 'W' is that, when a record does not meet the
<fcol> must be smaller than the number of columns specified by the
<fcolumns> parameter of the corresponding 'open_index' request. Multiple
filters can be specified, and work as the logical AND of them. The
difference of 'F' and 'W' is that, when a record does not meet the
specified condition, 'F' simply skips the record, and 'W' stops the loop.
----------------------------------------------------------------------------
......@@ -112,8 +110,8 @@ MOD is a sequence of the following parameters.
<mk> must be smaller than or equal to the length of <columns> specified by
the corresponding 'open_index' request. If <mop> is 'D', these parameters
are ignored. If <mop> is '+' or '-', values must be numeric. If <mop> is
'-' and it attempts to change column values from negative to positive or
positive to negative, it is not modified.
'-' and it attempts to change a column value from negative to positive or
positive to negative, the column value is not modified.
----------------------------------------------------------------------------
Inserting data
......@@ -187,6 +185,8 @@ syntax.
0 1 <nummod>
- <nummod> is the number of modified rows.
- As an exception, if the '?' suffix is specified in <mop>, a response has
the syntax of a response for 'find' instead.
----------------------------------------------------------------------------
Response for 'insert'
......@@ -196,3 +196,10 @@ syntax.
0 1
----------------------------------------------------------------------------
Response for 'auth'
If 'auth' is succeeded, HanderSocket returns a line of the following syntax.
0 1
......@@ -8,7 +8,8 @@ HandlerSocketプラグインのビルド方法(RPMを使わない方法)
$ ./configure --with-mysql-source=/work/mysql-5.1.50 --with-mysql-bindir=/work/mysql-5.1.50-linux-x86_64-glibc23/bin --with-mysql-plugindir=/work/mysql-5.1.50-linux-x86_64-glibc23/lib/plugin
ここで--with-mysql-sourceにはMySQLのソースコードのトップディレク
トリを指定します。--with-mysql-bindirにはインストール済みのMySQL
トリを指定します(そこにVERSIONファイルかconfigure.inファイルがなく
てはなりません)。--with-mysql-bindirにはインストール済みのMySQL
のmysql_configコマンドが有るディレクトリを指定します。
その後以下のようにビルド・インストールします。
......
......@@ -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呼び出しの
......@@ -109,6 +108,15 @@ execute_multiメソッドを使えば、複数のリクエストを一つの呼
# ...
}
-----------------------------------------------------------------
もしhandlersocketが接続を認証するように設定されている
(handlersocket_plain_secret又はhandlersocket_plain_secret_wrがセッ
トされている)ならば、クライアントは他のメソッド呼び出しの前にauth
メソッドを呼び出す必要があります。
my $res = $hs->auth('password');
die $hs->get_error() if $res->[0] != 0;
-----------------------------------------------------------------
エラーが起こると返値の配列参照の最初の要素が0以外になります。負の
数の場合はI/Oエラーが起こったことを示し、その場合はその
......
......@@ -658,7 +658,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];
......
......@@ -151,7 +151,7 @@ sv_get_string_ref(SV *sv)
static IV
sv_get_iv(SV *sv)
{
if (sv == 0 || !SvIOK(sv)) {
if (sv == 0 || ( !SvIOK(sv) && !SvPOK(sv) ) ) {
return 0;
}
return SvIV(sv);
......
#!/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
......
......@@ -27,7 +27,7 @@ srand(999);
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) = ("", "");
......
......@@ -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))) " .
......
......@@ -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) {
......
#!/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";
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment