← Back to team overview

maria-developers team mailing list archive

Re: [Commits] 7801756: MDEV-13826: Floating point exception in Filesort_tracker::print_json_members(Json_writer*)

 

Hi Varun,

On Wed, Jul 12, 2017 at 12:43:02AM +0530, Varun wrote:
> revision-id: 780175646bb9312184d8a676e86b125f663b5156 (mariadb-10.2.2-591-g7801756)
> parent(s): 3904014ed37cc2b58844e8d24a5d6aaa69d80f59
> author: Varun Gupta
> committer: Varun Gupta
> timestamp: 2017-07-12 00:41:52 +0530
> message:
> 
> MDEV-13826: Floating point exception in Filesort_tracker::print_json_members(Json_writer*)
> 
> Whenever Filesort_tracker has r_loops=0, r_ouptut_rows would be 0, so we should add the value zero to the member "r_output_rows" expliciytly
> 
> ---
>  mysql-test/r/analyze_format_json.result | 60 +++++++++++++++++++++++++++++++++
>  mysql-test/t/analyze_format_json.test   | 11 ++++++
>  sql/sql_analyze_stmt.cc                 | 11 +++---
>  3 files changed, 78 insertions(+), 4 deletions(-)
> 
> diff --git a/mysql-test/r/analyze_format_json.result b/mysql-test/r/analyze_format_json.result
> index 686da92..436b13b 100644
> --- a/mysql-test/r/analyze_format_json.result
> +++ b/mysql-test/r/analyze_format_json.result
> @@ -757,3 +757,63 @@ ANALYZE
>    }
>  }
>  drop table t1,t2,t3;
> +#
> +# MDEV-13286: Floating point exception in Filesort_tracker::print_json_members(Json_writer*)
> +#
> +create table t0(a int);
> +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
> +create table t1 (a int, b int, c int);
> +insert into t1 select a,a,a from t0;
> +create table t2 as select * from t1;
> +analyze format=json select a, (select t2.b from t2 where t2.a<t1.a order by t2.c limit 1) from t1 where t1.a<0;
> +ANALYZE
> +{
> +  "query_block": {
> +    "select_id": 1,
> +    "r_loops": 1,
> +    "r_total_time_ms": 0.0324,
> +    "table": {
> +      "table_name": "t1",
> +      "access_type": "ALL",
> +      "r_loops": 1,
> +      "rows": 10,
> +      "r_rows": 10,
> +      "r_total_time_ms": 0.0098,
> +      "filtered": 100,
> +      "r_filtered": 0,
> +      "attached_condition": "t1.a < 0"
> +    },
> +    "subqueries": [
> +      {
> +        "expression_cache": {
> +          "state": "uninitialized",
> +          "r_loops": 0,
> +          "query_block": {
> +            "select_id": 2,
> +            "read_sorted_file": {
> +              "r_rows": null,
> +              "filesort": {
> +                "sort_key": "t2.c",
> +                "r_loops": 0,
> +                "r_limit": "(varied across executions)",
> +                "r_used_priority_queue": false,
Look at the "table" field below: the parameters whose values are not 
defined because of r_loop=0 had value of null (e.g. r_filtered, r_rows).

Let's follow that pattern here: r_loops:null, r_limit:null,
r_used_priority_queue: null.

Please change this.

Ok to push after this is addressed.
> +                "r_output_rows": 0,
> +                "table": {
> +                  "table_name": "t2",
> +                  "access_type": "ALL",
> +                  "r_loops": 0,
> +                  "rows": 10,
> +                  "r_rows": null,
> +                  "filtered": 100,
> +                  "r_filtered": null,
> +                  "attached_condition": "t2.a < t1.a"
> +                }
> +              }
> +            }
> +          }
> +        }
> +      }
> +    ]
> +  }
> +}
> +drop table t0,t1,t2;
> diff --git a/mysql-test/t/analyze_format_json.test b/mysql-test/t/analyze_format_json.test
> index 88a9077..02603bc 100644
> --- a/mysql-test/t/analyze_format_json.test
> +++ b/mysql-test/t/analyze_format_json.test
> @@ -212,3 +212,14 @@ GROUP BY sq ORDER BY gc;
>  
>  drop table t1,t2,t3;
>  
> +
> +--echo #
> +--echo # MDEV-13286: Floating point exception in Filesort_tracker::print_json_members(Json_writer*)
> +--echo #
> +create table t0(a int);
> +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
> +create table t1 (a int, b int, c int);
> +insert into t1 select a,a,a from t0;
> +create table t2 as select * from t1;
> +analyze format=json select a, (select t2.b from t2 where t2.a<t1.a order by t2.c limit 1) from t1 where t1.a<0;
> +drop table t0,t1,t2;
> diff --git a/sql/sql_analyze_stmt.cc b/sql/sql_analyze_stmt.cc
> index cc6e0f8..3e49af1 100644
> --- a/sql/sql_analyze_stmt.cc
> +++ b/sql/sql_analyze_stmt.cc
> @@ -43,15 +43,18 @@ void Filesort_tracker::print_json_members(Json_writer *writer)
>    }
>  
>    writer->add_member("r_used_priority_queue"); 
> -  if (r_used_pq == get_r_loops())
> -    writer->add_bool(true);
> -  else if (r_used_pq == 0)
> +  if (r_used_pq == 0)
>      writer->add_bool(false);
> +  else if (r_used_pq == get_r_loops())
> +    writer->add_bool(true);
>    else
>      writer->add_str(varied_str);
>  
> -  writer->add_member("r_output_rows").add_ll((longlong) rint(r_output_rows / 
> +  if (r_output_rows)
> +    writer->add_member("r_output_rows").add_ll((longlong) rint(r_output_rows /
>                                                               get_r_loops()));
> +  else
> +    writer->add_member("r_output_rows").add_ll((longlong)0);
>  
>    if (sort_passes)
>    {
> _______________________________________________
> commits mailing list
> commits@xxxxxxxxxxx
> https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits

-- 
BR
 Sergei
-- 
Sergei Petrunia, Software Developer
MariaDB Corporation | Skype: sergefp | Blog: http://s.petrunia.net/blog