From 9611d7e08a9f69cd91dfa3b313c5ed1c324121d5 Mon Sep 17 00:00:00 2001 From: Caribe 1999 Date: Wed, 3 Jan 2018 11:27:20 +0100 Subject: Fix There's an annoying bug that prevents a Sphinx table to connect to a searchd using a host name. So the example table in the documentation https://mariadb.com/kb/en/library/about-sphinxse/#basic-usage that point's to "localhost" actually doesn't work. After some investigation I found two errors. The first one is a wrong check after the getaddrinfo call. The second is a wrong usage of the returned struct. --- storage/sphinx/ha_sphinx.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'storage/sphinx') diff --git a/storage/sphinx/ha_sphinx.cc b/storage/sphinx/ha_sphinx.cc index 65ad286f5d9..67bf0744c78 100644 --- a/storage/sphinx/ha_sphinx.cc +++ b/storage/sphinx/ha_sphinx.cc @@ -2162,7 +2162,7 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort ) #if MYSQL_VERSION_ID>=50515 struct addrinfo *hp = NULL; tmp_errno = getaddrinfo ( sHost, NULL, NULL, &hp ); - if ( !tmp_errno || !hp || !hp->ai_addr ) + if ( tmp_errno || !hp || !hp->ai_addr ) { bError = true; if ( hp ) @@ -2189,8 +2189,9 @@ int ha_sphinx::Connect ( const char * sHost, ushort uPort ) } #if MYSQL_VERSION_ID>=50515 - memcpy ( &sin.sin_addr, hp->ai_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->ai_addrlen ) ); - freeaddrinfo ( hp ); + struct sockaddr_in *in = (sockaddr_in *)hp->ai_addr; + memcpy ( &sin.sin_addr, &in->sin_addr, Min ( sizeof(sin.sin_addr), sizeof(in->sin_addr) ) ); + freeaddrinfo ( hp ); #else memcpy ( &sin.sin_addr, hp->h_addr, Min ( sizeof(sin.sin_addr), (size_t)hp->h_length ) ); my_gethostbyname_r_free(); -- cgit v1.2.1 From fd5cd073cc5a65a1f713eaf830b21b1fb962834e Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Wed, 8 May 2019 06:40:37 -0700 Subject: MDEV 19205 Sphinx unable to connect using a host name - Enable the test `sphinx.sphinx` which was disabled by MDEV 10986, comit ee0094d2fd48dac0c - Add test case to `sphinx.sphinx` to cover host as localhost instead of `127.0.0.1` - Add result file for single test --- storage/sphinx/mysql-test/sphinx/sphinx.result | 20 ++++++++++++++++++++ storage/sphinx/mysql-test/sphinx/sphinx.test | 13 +++++++++++++ 2 files changed, 33 insertions(+) (limited to 'storage/sphinx') diff --git a/storage/sphinx/mysql-test/sphinx/sphinx.result b/storage/sphinx/mysql-test/sphinx/sphinx.result index 3536ba42af8..c462d0cc883 100644 --- a/storage/sphinx/mysql-test/sphinx/sphinx.result +++ b/storage/sphinx/mysql-test/sphinx/sphinx.result @@ -75,3 +75,23 @@ id w q 1 2 test;range=meta.foo_count,100,500 5 1 test;range=meta.foo_count,100,500 drop table ts; +# +# MDEV-19205: Sphinx unable to connect using a host name +# +create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://localhost:SPHINXSEARCH_PORT/*"; +select * from ts where q=';filter=meta.foo_count,100'; +id w q +1 1 ;filter=meta.foo_count,100 +select * from ts where q='test;filter=meta.sub.int,7'; +id w q +5 1 test;filter=meta.sub.int,7 +select * from ts where q=';filter=meta.sub.list[0],4'; +id w q +select * from ts where q=';filter=meta.sub.list[1],4'; +id w q +5 1 ;filter=meta.sub.list[1],4 +select * from ts where q='test;range=meta.foo_count,100,500'; +id w q +1 2 test;range=meta.foo_count,100,500 +5 1 test;range=meta.foo_count,100,500 +drop table ts; diff --git a/storage/sphinx/mysql-test/sphinx/sphinx.test b/storage/sphinx/mysql-test/sphinx/sphinx.test index fe388f7ddd2..b733a3fc5ff 100644 --- a/storage/sphinx/mysql-test/sphinx/sphinx.test +++ b/storage/sphinx/mysql-test/sphinx/sphinx.test @@ -41,3 +41,16 @@ select * from ts where q=';filter=meta.sub.list[0],4'; select * from ts where q=';filter=meta.sub.list[1],4'; select * from ts where q='test;range=meta.foo_count,100,500'; drop table ts; + +--echo # +--echo # MDEV-19205: Sphinx unable to connect using a host name +--echo # + +--replace_result $SPHINXSEARCH_PORT SPHINXSEARCH_PORT +eval create table ts ( id bigint unsigned not null, w int not null, q varchar(255) not null, index(q) ) engine=sphinx connection="sphinx://localhost:$SPHINXSEARCH_PORT/*"; +select * from ts where q=';filter=meta.foo_count,100'; +select * from ts where q='test;filter=meta.sub.int,7'; +select * from ts where q=';filter=meta.sub.list[0],4'; +select * from ts where q=';filter=meta.sub.list[1],4'; +select * from ts where q='test;range=meta.foo_count,100,500'; +drop table ts; -- cgit v1.2.1