@@ -953,6 +953,18 @@ fts_query_free_doc_ids(
953953 query->total_size -= SIZEOF_RBT_CREATE ;
954954}
955955
956+
957+ /* ******************************************************************/ /* *
958+ Free the query intersection */
959+ static
960+ void
961+ fts_query_free_intersection (
962+ fts_query_t * query) /* !< in: query instance */
963+ {
964+ fts_query_free_doc_ids (query, query->intersection );
965+ query->intersection = NULL ;
966+ }
967+
956968/* ******************************************************************/ /* *
957969Add the word to the documents "list" of matching words from
958970the query. We make a copy of the word from the query heap. */
@@ -1311,6 +1323,7 @@ fts_query_intersect(
13111323 /* error is passed by 'query->error' */
13121324 if (query->error != DB_SUCCESS ) {
13131325 ut_ad (query->error == DB_FTS_EXCEED_RESULT_CACHE_LIMIT );
1326+ fts_query_free_intersection (query);
13141327 return (query->error );
13151328 }
13161329
@@ -1339,7 +1352,9 @@ fts_query_intersect(
13391352
13401353 ut_a (!query->multi_exist || (query->multi_exist
13411354 && rbt_size (query->doc_ids ) <= n_doc_ids));
1342- }
1355+ } else if (query->intersection != NULL ) {
1356+ fts_query_free_intersection (query);
1357+ }
13431358 }
13441359
13451360 return (query->error );
@@ -1557,6 +1572,10 @@ fts_merge_doc_ids(
15571572 query, ranking->doc_id , ranking->rank );
15581573
15591574 if (query->error != DB_SUCCESS ) {
1575+ if (query->oper == FTS_EXIST && query->intersection != NULL )
1576+ {
1577+ fts_query_free_intersection (query);
1578+ }
15601579 DBUG_RETURN (query->error );
15611580 }
15621581
0 commit comments