Permalink
Browse files

fixed #285 empty string at result set and filter; added regression to…

… test 357
  • Loading branch information...
tomatolog committed May 24, 2018
1 parent afa942d commit 6dbeaf2389d2af6a9dfccb56bfc986685b9f203e
Showing with 76 additions and 2 deletions.
  1. +7 −2 src/searchd.cpp
  2. +1 −0 test/test_357/model.bin
  3. +68 −0 test/test_357/test.xml
@@ -15898,8 +15898,13 @@ void SendMysqlSelectResult ( SqlRowBuffer_c & dRows, const AggrResult_t & tRes,
iLen = sphUnpackPtrAttr ( pString, &pString );
else
{
// stringptr is NULL - send NULL value
dRows.PutNULL();
// JSON is NULL - send NULL value
// string - empty string have no support for NULL of value types
if ( eAttrType==SPH_ATTR_JSON_PTR )
dRows.PutNULL();
else
dRows.PutString ( "" );
break;
}
@@ -0,0 +1 @@
a:1:{i:0;a:7:{i:0;a:3:{s:8:"sphinxql";s:18:"select * from test";s:10:"total_rows";i:2;s:4:"rows";a:2:{i:0;a:4:{s:2:"id";s:1:"1";s:3:"idd";s:1:"1";s:4:"str1";s:0:"";s:4:"str2";s:0:"";}i:1;a:4:{s:2:"id";s:2:"11";s:3:"idd";s:2:"11";s:4:"str1";s:0:"";s:4:"str2";s:1:"a";}}}i:1;a:3:{s:8:"sphinxql";s:37:"select * from test where str1 is NULL";s:10:"total_rows";i:2;s:4:"rows";a:2:{i:0;a:4:{s:2:"id";s:1:"1";s:3:"idd";s:1:"1";s:4:"str1";s:0:"";s:4:"str2";s:0:"";}i:1;a:4:{s:2:"id";s:2:"11";s:3:"idd";s:2:"11";s:4:"str1";s:0:"";s:4:"str2";s:1:"a";}}}i:2;a:3:{s:8:"sphinxql";s:41:"select * from test where str1 is not NULL";s:10:"total_rows";i:2;s:4:"rows";a:2:{i:0;a:4:{s:2:"id";s:1:"1";s:3:"idd";s:1:"1";s:4:"str1";s:0:"";s:4:"str2";s:0:"";}i:1;a:4:{s:2:"id";s:2:"11";s:3:"idd";s:2:"11";s:4:"str1";s:0:"";s:4:"str2";s:1:"a";}}}i:3;a:3:{s:8:"sphinxql";s:32:"select * from test where str1=''";s:10:"total_rows";i:2;s:4:"rows";a:2:{i:0;a:4:{s:2:"id";s:1:"1";s:3:"idd";s:1:"1";s:4:"str1";s:0:"";s:4:"str2";s:0:"";}i:1;a:4:{s:2:"id";s:2:"11";s:3:"idd";s:2:"11";s:4:"str1";s:0:"";s:4:"str2";s:1:"a";}}}i:4;a:2:{s:8:"sphinxql";s:33:"select * from test where str1!=''";s:10:"total_rows";i:0;}i:5;a:3:{s:8:"sphinxql";s:32:"select * from test where str2=''";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"1";s:3:"idd";s:1:"1";s:4:"str1";s:0:"";s:4:"str2";s:0:"";}}}i:6;a:3:{s:8:"sphinxql";s:33:"select * from test where str2!=''";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:2:"11";s:3:"idd";s:2:"11";s:4:"str1";s:0:"";s:4:"str2";s:1:"a";}}}}}
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<test>
<name>empty string at result set; string filter</name>
<config>
indexer
{
mem_limit = 16M
}
searchd
{
<searchd_settings/>
}
source test
{
type = mysql
<sql_settings/>
sql_query_pre = SET NAMES utf8
sql_query = SELECT * FROM test_table
sql_attr_uint = idd
sql_attr_string = str1
sql_attr_string = str2
}
index test
{
source = test
path = <data_path/>/test
docinfo = extern
dict = keywords
charset_table = a..z, _, A..Z->a..z, russian
}
</config>
<db_create>
CREATE TABLE test_table
(
id INTEGER PRIMARY KEY NOT NULL,
idd INTEGER NOT NULL,
body VARCHAR(255) NOT NULL,
str1 VARCHAR(255) NOT NULL,
str2 VARCHAR(255) NOT NULL
) CHARACTER SET utf8;
</db_create>
<db_drop>DROP TABLE IF EXISTS test_table</db_drop>
<db_insert>INSERT INTO test_table VALUES
( 1, 1, 'test', '', '' ), (11, 11, 'test', '', 'a')
</db_insert>
<sphqueries>
<!-- regression: empty string was NULL at result set but empty at filter -->
<sphinxql>select * from test</sphinxql>
<sphinxql>select * from test where str1 is NULL</sphinxql>
<sphinxql>select * from test where str1 is not NULL</sphinxql>
<sphinxql>select * from test where str1=''</sphinxql>
<sphinxql>select * from test where str1!=''</sphinxql>
<sphinxql>select * from test where str2=''</sphinxql>
<sphinxql>select * from test where str2!=''</sphinxql>
</sphqueries>
</test>

0 comments on commit 6dbeaf2

Please sign in to comment.