首頁  >  文章  >  資料庫  >  MySQL源码中的BUG

MySQL源码中的BUG

WBOY
WBOY原創
2016-06-07 17:18:11913瀏覽

今天在深入学习MySQL查询优化器的过程中,发现一个低级的错误,应该是开发人员出于笔误导致的,当然这个错误不会出现问题,仅仅会

今天在深入学习MySQL查询优化器的过程中,发现一个低级的错误,应该是开发人员出于笔误导致的,当然这个错误不会出现问题,仅仅会在debug环境下,输出trace信息的时候会误导开发人员。

现公布如下:

本文基于mysql-5.5.20源代码进行调试开发。

sql_select.cc文件的5439行,代码如下:

  • print_planidxrecord_count

    其中通过查看print_plan函数可以发现,,输入参数:read_time和record_count的顺序是错误的。print_plan函数在sql_test.cc的266行定义如下:

  • /*
  •  print_plan()
  •     the structure providing all context info for
  •                  the query
  •     read_time the cost of the best partial plan
  •     record_count estimatethe number of records returned by the best
  •                  partial plan
  •     idx length of the partial QEPpositions';
  •                  also an indexthebest_ref';
  •     info commentappear above the printout
  • */
  • void
  • print_planuint idxdouble read_time,
  •            double current_read_timechar *info)
  • 因此,sql_select.cc文件的5439行的代码应该讲read_time和record_count的顺序颠倒。修改后的代码如下:

  • print_planidxread_time

    由于这个错误,会在打印输出的debug trace信息中感到困惑。 

    linux

  • 陳述:
    本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn