Skip to content
Permalink
Browse files

fixed #1101 crash on IN filter to JSON attribute; added regression to…

… test 361
  • Loading branch information
tomatolog committed Nov 19, 2019
1 parent 795520a commit 2284da5e3ff77bf7be4038a4d950c0580e4159c8
Showing with 8 additions and 2 deletions.
  1. +3 −1 src/sphinxfilter.cpp
  2. +1 −1 test/test_361/model.bin
  3. +4 −0 test/test_361/test.xml
@@ -1250,7 +1250,7 @@ static ISphFilter * CreateFilterExpr ( ISphExpr * _pExpr, const CSphFilterSettin
bool bAutoConvert = false;
bool bJsonExpr = false;
if ( pExpr && tSettings.m_eType!=SPH_FILTER_NULL )
bJsonExpr = pExpr->IsJson ( bAutoConvert );
bJsonExpr = pExpr->IsJson ( bAutoConvert );
if ( bJsonExpr && !bAutoConvert )
pExpr = sphJsonFieldConv ( pExpr );

@@ -1342,6 +1342,8 @@ static ISphFilter * CreateFilter ( const CSphFilterSettings & tSettings, const C
{
pExpr = pAttr->m_pExpr;
eAttrType = pAttr->m_eAttrType;
if ( pAttr->m_eAttrType==SPH_ATTR_JSON && !pExpr && tSettings.m_eType!=SPH_FILTER_NULL )
pExpr = sphExprParse ( sAttrName.cstr(), tSchema, &eAttrType, nullptr, sError, nullptr, eCollation );
pFilter = CreateFilterExpr ( pExpr, tSettings, sError, eCollation, pAttr->m_eAttrType );

} else
@@ -1 +1 @@
a:1:{i:0;a:25:{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:3:{s:2:"id";s:1:"1";s:3:"gid";s:1:"1";s:1:"j";s:15:"{"a":5,"b":123}";}i:1;a:3:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";}}}i:1;a:3:{s:8:"sphinxql";s:39:"select * from test where j.a IN (5,100)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:1:"1";s:1:"j";s:15:"{"a":5,"b":123}";}}}i:2;a:3:{s:8:"sphinxql";s:57:"select *, IN(j.b, 100, 134) as cnd from test where cnd<>0";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";s:3:"cnd";s:1:"1";}}}i:3;a:3:{s:8:"sphinxql";s:56:"select *, j.b IN(100, 134) as cnd from test where cnd<>0";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";s:3:"cnd";s:1:"1";}}}i:4;a:3:{s:8:"sphinxql";s:39:"select * from dist where j.a IN (5,100)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:1:"1";s:1:"j";s:15:"{"a":5,"b":123}";}}}i:5;a:3:{s:8:"sphinxql";s:57:"select *, IN(j.b, 100, 134) as cnd from dist where cnd<>0";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";s:3:"cnd";s:1:"1";}}}i:6;a:3:{s:8:"sphinxql";s:56:"select *, j.b IN(100, 134) as cnd from dist where cnd<>0";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";s:3:"cnd";s:1:"1";}}}i:7;a:2:{s:8:"sphinxql";s:62:"INSERT INTO pq (query, filters) VALUES ('', 'j.a IN (5, 100)')";s:14:"total_affected";i:1;}i:8;a:2:{s:8:"sphinxql";s:63:"INSERT INTO pq (query, filters) VALUES ('', 'IN (j.a, 5, 100)')";s:14:"total_affected";i:1;}i:9;a:2:{s:8:"sphinxql";s:82:"INSERT INTO pq (query, filters) VALUES ('', 'j.a IN (5, 100) and CRC32(\'test\')')";s:14:"total_affected";i:1;}i:10;a:2:{s:8:"sphinxql";s:83:"INSERT INTO pq (query, filters) VALUES ('', 'IN (j.a, 5, 100) and CRC32(\'test\')')";s:14:"total_affected";i:1;}i:11;a:2:{s:8:"sphinxql";s:84:"INSERT INTO pq (query, filters) VALUES ('', 'j.a IN (5, 100) or IN (j.b, 134, 200)')";s:14:"total_affected";i:1;}i:12;a:2:{s:8:"sphinxql";s:84:"INSERT INTO pq (query, filters) VALUES ('', 'IN (j.a, 5, 100) or j.b IN (134, 200)')";s:14:"total_affected";i:1;}i:13;a:3:{s:8:"sphinxql";s:93:"CALL PQ ('pq', ('{"j":{"a":5, "b":123}}', '{"j":{"a":101, "b":134}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:6;s:4:"rows";a:6:{i:0;a:5:{s:2:"id";s:13:"1677721600001";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:14:"j.a IN (5,100)";}i:1;a:5:{s:2:"id";s:13:"1677721600002";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:16:"IN (j.a, 5, 100)";}i:2;a:5:{s:2:"id";s:13:"1677721600003";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:33:"j.a IN (5, 100) and CRC32('test')";}i:3;a:5:{s:2:"id";s:13:"1677721600004";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:34:"IN (j.a, 5, 100) and CRC32('test')";}i:4;a:5:{s:2:"id";s:13:"1677721600005";s:9:"documents";s:3:"1,2";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:37:"j.a IN (5, 100) or IN (j.b, 134, 200)";}i:5;a:5:{s:2:"id";s:13:"1677721600006";s:9:"documents";s:3:"1,2";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:37:"IN (j.a, 5, 100) or j.b IN (134, 200)";}}}i:14;a:3:{s:8:"sphinxql";s:39:"select *, IN (missed.a,5,100) from test";s:5:"error";s:47:"index test: parse error: unknown column: missed";s:5:"errno";i:1064;}i:15;a:2:{s:8:"sphinxql";s:107:"INSERT INTO pq_in (query, filters) VALUES ('', '(j.a=5 OR (j.a=6 AND NOT IN(j.b, 1220431865,6663093570)))')";s:14:"total_affected";i:1;}i:16;a:3:{s:8:"sphinxql";s:94:"CALL PQ ('pq_in', ('{"j":{"a":5, "b":123}}', '{"j":{"a":6, "b":134}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:2:"id";s:13:"1677721600007";s:9:"documents";s:3:"1,2";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:57:"(j.a=5 OR (j.a=6 AND NOT IN(j.b, 1220431865,6663093570)))";}}}i:17;a:3:{s:8:"sphinxql";s:56:"select *, in(j.a,1220431865,6663093570) as p from arrays";s:10:"total_rows";i:4;s:4:"rows";a:4:{i:0;a:3:{s:2:"id";s:3:"123";s:1:"j";s:36:"{"a":[1,2,3,4],"t":["t1","t2","t3"]}";s:1:"p";s:1:"0";}i:1;a:3:{s:2:"id";s:3:"234";s:1:"j";s:36:"{"a":[2,3,4,5],"t":["t2","t3","t4"]}";s:1:"p";s:1:"0";}i:2;a:3:{s:2:"id";s:3:"345";s:1:"j";s:36:"{"a":[3,4,5,1],"t":["t3","t4","t5"]}";s:1:"p";s:1:"0";}i:3;a:3:{s:2:"id";s:3:"456";s:1:"j";s:44:"{"a":["4","5","6","2"],"t":["t4","t5","t6"]}";s:1:"p";s:1:"0";}}}i:18;a:2:{s:8:"sphinxql";s:63:"INSERT INTO pq_expr (query, filters) VALUES ('', 'abs(j.a)=22')";s:14:"total_affected";i:1;}i:19;a:2:{s:8:"sphinxql";s:63:"INSERT INTO pq_expr (query, filters) VALUES ('', 'abs(j.a)=12')";s:14:"total_affected";i:1;}i:20;a:3:{s:8:"sphinxql";s:99:"CALL PQ ('pq_expr', ('{"j":{"a":-12, "b":123}}', '{"j":{"a":22, "b":134}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:2;s:4:"rows";a:2:{i:0;a:5:{s:2:"id";s:13:"1677721600008";s:9:"documents";s:1:"2";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:11:"abs(j.a)=22";}i:1;a:5:{s:2:"id";s:13:"1677721600009";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:11:"abs(j.a)=12";}}}i:21;a:2:{s:8:"sphinxql";s:122:"INSERT INTO pq_expr (query, filters) VALUES ('', 'GEODIST(j.lat, j.lon,0.937717,-0.0798578, {in=radians, out=m} )<100000')";s:14:"total_affected";i:1;}i:22;a:3:{s:8:"sphinxql";s:202:"CALL PQ ('pq_expr', ('{"j":{"lon":-0.0798578, "lat":0.937717}}', '{"j":{"lon":-0.0799989, "lat":0.891975}}', '{"j":{"some":"thing"}}', '{"j":{"lon":-0.0721455, "lat":0.926761}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:2:"id";s:13:"1677721600010";s:9:"documents";s:3:"1,4";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:70:"GEODIST(j.lat, j.lon,0.937717,-0.0798578, {in=radians, out=m} )<100000";}}}i:23;a:2:{s:8:"sphinxql";s:82:"INSERT INTO pq_expr (query, filters) VALUES ('', 'CONTAINS(POLY2D(j.poly), 2, 3)')";s:14:"total_affected";i:1;}i:24;a:3:{s:8:"sphinxql";s:146:"CALL PQ ('pq_expr', ('{"j":{"poly":"1,2,3,4,5,6.0"}}', '{"j":{"poly":"1,-2,1,2,-5,6"}}', '{"j":{"poly":"-1,2,12,4,5,6"}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:2:"id";s:13:"1677721600011";s:9:"documents";s:3:"1,3";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:30:"CONTAINS(POLY2D(j.poly), 2, 3)";}}}}}
a:1:{i:0;a:26:{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:3:{s:2:"id";s:1:"1";s:3:"gid";s:1:"1";s:1:"j";s:15:"{"a":5,"b":123}";}i:1;a:3:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";}}}i:1;a:3:{s:8:"sphinxql";s:39:"select * from test where j.a IN (5,100)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:1:"1";s:1:"j";s:15:"{"a":5,"b":123}";}}}i:2;a:3:{s:8:"sphinxql";s:57:"select *, IN(j.b, 100, 134) as cnd from test where cnd<>0";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";s:3:"cnd";s:1:"1";}}}i:3;a:3:{s:8:"sphinxql";s:56:"select *, j.b IN(100, 134) as cnd from test where cnd<>0";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";s:3:"cnd";s:1:"1";}}}i:4;a:3:{s:8:"sphinxql";s:39:"select * from dist where j.a IN (5,100)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:3:{s:2:"id";s:1:"1";s:3:"gid";s:1:"1";s:1:"j";s:15:"{"a":5,"b":123}";}}}i:5;a:3:{s:8:"sphinxql";s:57:"select *, IN(j.b, 100, 134) as cnd from dist where cnd<>0";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";s:3:"cnd";s:1:"1";}}}i:6;a:3:{s:8:"sphinxql";s:56:"select *, j.b IN(100, 134) as cnd from dist where cnd<>0";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:4:{s:2:"id";s:1:"2";s:3:"gid";s:1:"1";s:1:"j";s:17:"{"a":101,"b":134}";s:3:"cnd";s:1:"1";}}}i:7;a:2:{s:8:"sphinxql";s:62:"INSERT INTO pq (query, filters) VALUES ('', 'j.a IN (5, 100)')";s:14:"total_affected";i:1;}i:8;a:2:{s:8:"sphinxql";s:63:"INSERT INTO pq (query, filters) VALUES ('', 'IN (j.a, 5, 100)')";s:14:"total_affected";i:1;}i:9;a:2:{s:8:"sphinxql";s:82:"INSERT INTO pq (query, filters) VALUES ('', 'j.a IN (5, 100) and CRC32(\'test\')')";s:14:"total_affected";i:1;}i:10;a:2:{s:8:"sphinxql";s:83:"INSERT INTO pq (query, filters) VALUES ('', 'IN (j.a, 5, 100) and CRC32(\'test\')')";s:14:"total_affected";i:1;}i:11;a:2:{s:8:"sphinxql";s:84:"INSERT INTO pq (query, filters) VALUES ('', 'j.a IN (5, 100) or IN (j.b, 134, 200)')";s:14:"total_affected";i:1;}i:12;a:2:{s:8:"sphinxql";s:84:"INSERT INTO pq (query, filters) VALUES ('', 'IN (j.a, 5, 100) or j.b IN (134, 200)')";s:14:"total_affected";i:1;}i:13;a:3:{s:8:"sphinxql";s:93:"CALL PQ ('pq', ('{"j":{"a":5, "b":123}}', '{"j":{"a":101, "b":134}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:6;s:4:"rows";a:6:{i:0;a:5:{s:2:"id";s:13:"1677721600001";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:14:"j.a IN (5,100)";}i:1;a:5:{s:2:"id";s:13:"1677721600002";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:16:"IN (j.a, 5, 100)";}i:2;a:5:{s:2:"id";s:13:"1677721600003";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:33:"j.a IN (5, 100) and CRC32('test')";}i:3;a:5:{s:2:"id";s:13:"1677721600004";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:34:"IN (j.a, 5, 100) and CRC32('test')";}i:4;a:5:{s:2:"id";s:13:"1677721600005";s:9:"documents";s:3:"1,2";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:37:"j.a IN (5, 100) or IN (j.b, 134, 200)";}i:5;a:5:{s:2:"id";s:13:"1677721600006";s:9:"documents";s:3:"1,2";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:37:"IN (j.a, 5, 100) or j.b IN (134, 200)";}}}i:14;a:3:{s:8:"sphinxql";s:39:"select *, IN (missed.a,5,100) from test";s:5:"error";s:47:"index test: parse error: unknown column: missed";s:5:"errno";i:1064;}i:15;a:2:{s:8:"sphinxql";s:107:"INSERT INTO pq_in (query, filters) VALUES ('', '(j.a=5 OR (j.a=6 AND NOT IN(j.b, 1220431865,6663093570)))')";s:14:"total_affected";i:1;}i:16;a:3:{s:8:"sphinxql";s:94:"CALL PQ ('pq_in', ('{"j":{"a":5, "b":123}}', '{"j":{"a":6, "b":134}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:2:"id";s:13:"1677721600007";s:9:"documents";s:3:"1,2";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:57:"(j.a=5 OR (j.a=6 AND NOT IN(j.b, 1220431865,6663093570)))";}}}i:17;a:3:{s:8:"sphinxql";s:56:"select *, in(j.a,1220431865,6663093570) as p from arrays";s:10:"total_rows";i:4;s:4:"rows";a:4:{i:0;a:3:{s:2:"id";s:3:"123";s:1:"j";s:36:"{"a":[1,2,3,4],"t":["t1","t2","t3"]}";s:1:"p";s:1:"0";}i:1;a:3:{s:2:"id";s:3:"234";s:1:"j";s:36:"{"a":[2,3,4,5],"t":["t2","t3","t4"]}";s:1:"p";s:1:"0";}i:2;a:3:{s:2:"id";s:3:"345";s:1:"j";s:36:"{"a":[3,4,5,1],"t":["t3","t4","t5"]}";s:1:"p";s:1:"0";}i:3;a:3:{s:2:"id";s:3:"456";s:1:"j";s:44:"{"a":["4","5","6","2"],"t":["t4","t5","t6"]}";s:1:"p";s:1:"0";}}}i:18;a:2:{s:8:"sphinxql";s:63:"INSERT INTO pq_expr (query, filters) VALUES ('', 'abs(j.a)=22')";s:14:"total_affected";i:1;}i:19;a:2:{s:8:"sphinxql";s:63:"INSERT INTO pq_expr (query, filters) VALUES ('', 'abs(j.a)=12')";s:14:"total_affected";i:1;}i:20;a:3:{s:8:"sphinxql";s:99:"CALL PQ ('pq_expr', ('{"j":{"a":-12, "b":123}}', '{"j":{"a":22, "b":134}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:2;s:4:"rows";a:2:{i:0;a:5:{s:2:"id";s:13:"1677721600008";s:9:"documents";s:1:"2";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:11:"abs(j.a)=22";}i:1;a:5:{s:2:"id";s:13:"1677721600009";s:9:"documents";s:1:"1";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:11:"abs(j.a)=12";}}}i:21;a:2:{s:8:"sphinxql";s:122:"INSERT INTO pq_expr (query, filters) VALUES ('', 'GEODIST(j.lat, j.lon,0.937717,-0.0798578, {in=radians, out=m} )<100000')";s:14:"total_affected";i:1;}i:22;a:3:{s:8:"sphinxql";s:202:"CALL PQ ('pq_expr', ('{"j":{"lon":-0.0798578, "lat":0.937717}}', '{"j":{"lon":-0.0799989, "lat":0.891975}}', '{"j":{"some":"thing"}}', '{"j":{"lon":-0.0721455, "lat":0.926761}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:2:"id";s:13:"1677721600010";s:9:"documents";s:3:"1,4";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:70:"GEODIST(j.lat, j.lon,0.937717,-0.0798578, {in=radians, out=m} )<100000";}}}i:23;a:2:{s:8:"sphinxql";s:82:"INSERT INTO pq_expr (query, filters) VALUES ('', 'CONTAINS(POLY2D(j.poly), 2, 3)')";s:14:"total_affected";i:1;}i:24;a:3:{s:8:"sphinxql";s:146:"CALL PQ ('pq_expr', ('{"j":{"poly":"1,2,3,4,5,6.0"}}', '{"j":{"poly":"1,-2,1,2,-5,6"}}', '{"j":{"poly":"-1,2,12,4,5,6"}}'), 1 as docs, 1 as query)";s:10:"total_rows";i:1;s:4:"rows";a:1:{i:0;a:5:{s:2:"id";s:13:"1677721600011";s:9:"documents";s:3:"1,3";s:5:"query";s:0:"";s:4:"tags";s:0:"";s:7:"filters";s:30:"CONTAINS(POLY2D(j.poly), 2, 3)";}}}i:25;a:2:{s:8:"sphinxql";s:37:"select * from test where j IN (5,100)";s:10:"total_rows";i:0;}}}
@@ -142,5 +142,9 @@ INSERT INTO j_arrays ( id, gid, j ) VALUES
<sphinxql>INSERT INTO pq_expr (query, filters) VALUES ('', 'CONTAINS(POLY2D(j.poly), 2, 3)')</sphinxql>
<sphinxql>CALL PQ ('pq_expr', ('{"j":{"poly":"1,2,3,4,5,6.0"}}', '{"j":{"poly":"1,-2,1,2,-5,6"}}', '{"j":{"poly":"-1,2,12,4,5,6"}}'), 1 as docs, 1 as query)</sphinxql>

<!-- regression crash at IN to JSON attribute -->
<sphinxql>select * from test where j IN (5,100)</sphinxql>


</sphqueries>
</test>

0 comments on commit 2284da5

Please sign in to comment.
You can’t perform that action at this time.