Heim  >  Artikel  >  Datenbank  >  MySQL源码中的BUG

MySQL源码中的BUG

WBOY
WBOYOriginal
2016-06-07 17:18:11913Durchsuche

今天在深入学习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

  • Stellungnahme:
    Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn