squash that old bug
play

Squash That Old Bug Daniel Black Daniel Black IBM IBM Overview - PowerPoint PPT Presentation

Squash That Old Bug Daniel Black Daniel Black IBM IBM Overview Topics: Topics: Choosing a bug/feature Choosing a bug/feature Build/test environment Build/test environment Tour of code base Tour of code base


  1. Squash That Old Bug Daniel Black Daniel Black IBM IBM

  2. Overview Topics: Topics: • Choosing a bug/feature • Choosing a bug/feature • Build/test environment • Build/test environment • Tour of code base • Tour of code base • Build/test • Build/test • Submitting code • Submitting code • Asking for help • Asking for help 2

  3. Choosing a Bug / Feature (MySQL) Search existing bugs Search existing bugs https://bugs.mysql.com/search.php https://bugs.mysql.com/search.php Status: Verifjed Status: Verifjed Note: (Efgort/Risk fjelds have fallen out of use) Note: (Efgort/Risk fjelds have fallen out of use) 3

  4. Choosing a Bug / Feature (MariaDB) Search existing bugs Search existing bugs jql: status = Confjrmed jql: status = Confjrmed jql: labels = beginner-friendly jql: labels = beginner-friendly 4

  5. Choosing a Bug / Feature - Easy ● Regressions ● Regressions ● Wrong result ● Wrong result ● Portability (e.g. fix for FreeBSD) ● Portability (e.g. fix for FreeBSD) ● Enhancement for new Linux Kernel API ● Enhancement for new Linux Kernel API ● Client tools (mysql, mysqldump/pump) ● Client tools (mysql, mysqldump/pump) ● New SQL functions (verified / follow standard) ● New SQL functions (verified / follow standard) 5

  6. Choosing a Bug / Feature - Hard ● Group / GTID replication ● Group / GTID replication ● Optimizer ● Optimizer Or if you must: Or if you must: – Easy/quick to calculate (low overhead) – Easy/quick to calculate (low overhead) – Always an improvement (no regressions) – Always an improvement (no regressions) 6

  7. Build / Test environment Few dependencies: Few dependencies: ● Git ● Git ● Cmake ● Cmake ● C++ compiler: gcc/ clang/ Xcode / VS17 ● C++ compiler: gcc/ clang/ Xcode / VS17 ● Bison ● Bison ● Ncurses ● Ncurses ● Libevent (MariaDB) / boost (MySQL) ● Libevent (MariaDB) / boost (MySQL) Ref: https://mariadb.com/kb/en/library/compiling-mariadb-from-source/ Ref: https://mariadb.com/kb/en/library/compiling-mariadb-from-source/ https://dev.mysql.com/doc/mysql-sourcebuild-excerpt/8.0/en/ https://dev.mysql.com/doc/mysql-sourcebuild-excerpt/8.0/en/ 7

  8. Build / Test environment Github: https://github.com/MariaDB/server/ Github: https://github.com/MariaDB/server/ repos]$ git clone git@github.com:grooverdan/mariadb-server.git repos]$ git clone git@github.com:grooverdan/mariadb-server.git 8

  9. Build / Test environment mariadb-server]$ cd ../build-mariadb-server mariadb-server]$ cd ../build-mariadb-server build-mariadb-server]$ cmake -DCMAKE_BUILD_TYPE=Debug ../mariadb-server build-mariadb-server]$ cmake -DCMAKE_BUILD_TYPE=Debug ../mariadb-server -- Running cmake version 3.14.3 -- Running cmake version 3.14.3 -- The C compiler identification is GNU 9.1.1 -- The C compiler identification is GNU 9.1.1 -- The CXX compiler identification is GNU 9.1.1 -- The CXX compiler identification is GNU 9.1.1 ... ... -- Configuring done -- Configuring done -- Generating done -- Generating done -- Build files have been written to: /home/dan/repos/build-mariadb-server -- Build files have been written to: /home/dan/repos/build-mariadb-server build-mariadb-server]$ make -j8 build-mariadb-server]$ make -j8 Scanning dependencies of target abi_check Scanning dependencies of target abi_check 9 Scanning dependencies of target wsrep_api_v26 Scanning dependencies of target wsrep_api_v26

  10. Tour of codebase 1 0

  11. Example Bug 71386 SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); null null SHOW WARNINGS SHOW WARNINGS Warning | 1411 | Incorrect datetime value: '01:35 PM' for function Warning | 1411 | Incorrect datetime value: '01:35 PM' for function str_to_date str_to_date 1 1

  12. Create a Test Case mysql-server]$ git grep -l STR_TO_DATE mysql-test/ mysql-server]$ git grep -l STR_TO_DATE mysql-test/ mysql-test/r/date_formats.result mysql-test/r/date_formats.result mysql-test/r/func_time.result mysql-test/r/func_time.result ... ... mysql-test/t/date_formats.test mysql-test/t/date_formats.test mysql-test/t/func_time.test mysql-test/t/func_time.test mysql-test/t/ignore_strict.test mysql-test/t/ignore_strict.test mysql-test/t/parser.test mysql-test/t/parser.test mysql-test/t/strict.test mysql-test/t/strict.test mysql-test/t/type_datetime.test mysql-test/t/type_datetime.test mysql-test/t/type_temporal_fractional.test mysql-test/t/type_temporal_fractional.test 1 2

  13. Create a Test Case mysql-server]$ cat mysql-test/t/bug71386.test mysql-server]$ cat mysql-test/t/bug71386.test SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); build-mysql-8.0]$ mysql-test/mtr bug71386 build-mysql-8.0]$ mysql-test/mtr bug71386 … … ----------- MYSQLTEST OUTPUT START ----------- ----------- MYSQLTEST OUTPUT START ----------- SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); STR_TO_DATE('01:35 PM', '%h:%i %p') STR_TO_DATE('01:35 PM', '%h:%i %p') NULL NULL Warnings: Warnings: Warning 1411 Incorrect datetime value: '01:35 PM' for function str_to_date Warning 1411 Incorrect datetime value: '01:35 PM' for function str_to_date 1 3

  14. Create a Test Case build-mysql-8.0]$ mysql-test/mtr --ddd bug71386 build-mysql-8.0]$ mysql-test/mtr --ddd bug71386 1 4

  15. Find the Cause mysql-server] $ git grep -B 1 "' for function " mysql-server] $ git grep -B 1 "' for function " share/errmsg-utf8.txt-ER_WRONG_VALUE_FOR_TYPE share/errmsg-utf8.txt-ER_WRONG_VALUE_FOR_TYPE share/errmsg-utf8.txt: eng "Incorrect %-.32s value: '%-.128s' for function share/errmsg-utf8.txt: eng "Incorrect %-.32s value: '%-.128s' for function %-.32s" %-.32s" 1 5

  16. Find the Cause mysql-server]$ git grep -l ER_WRONG_VALUE_FOR_TYPE mysql-server]$ git grep -l ER_WRONG_VALUE_FOR_TYPE mysql-test/include/ctype_inet.inc mysql-test/include/ctype_inet.inc .. .. mysql-test/t/window_functions.test mysql-test/t/window_functions.test share/errmsg-utf8.txt share/errmsg-utf8.txt sql/error_handler.cc sql/error_handler.cc sql/item_func.cc sql/item_func.cc sql/item_geofunc.cc sql/item_geofunc.cc sql/item_inetfunc.cc sql/item_inetfunc.cc sql/item_strfunc.cc sql/item_strfunc.cc sql/item_timefunc.cc sql/item_timefunc.cc 1 6

  17. Find the Cause “Warning 1411 Incorrect datetime value: '01:35 PM' for function str_to_date” “Warning 1411 Incorrect datetime value: '01:35 PM' for function str_to_date” static bool extract_date_time(const Date_time_format *format, const char static bool extract_date_time(const Date_time_format *format, const char *val…. *val…. 1 7

  18. Find the Cause “Warning 1411 Incorrect datetime value: '01:35 PM' for function str_to_date” “Warning 1411 Incorrect datetime value: '01:35 PM' for function str_to_date” bool Item_func_str_to_date::val_datetime(MYSQL_TIME *ltime, bool Item_func_str_to_date::val_datetime(MYSQL_TIME *ltime, my_time_flags_t fuzzy_date) { my_time_flags_t fuzzy_date) { 1 8

  19. Find the Cause 1 9

  20. Find the Cause 2 0

  21. Find the Cause 2 1

  22. Find the Cause 2 2

  23. Find the Cause 2 3

  24. Find the Cause mysql-server]$ cat ./mysql-test/t/bug71386.test SELECT STR_TO_DATE('1/1/2010', '%m/%d/%Y'); SELECT STR_TO_DATE('1/1/2010 01:35 PM', '%m/%d/%Y %h:%i %p'); SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); ; Thread 42 "mysqld" hit Breakpoint 2, Item_func_str_to_date::val_datetime (this=0x7fff941064e8, ltime=0x7fffec06d510, fuzzy_date=1) at /home/dan/repos/mysql- server/sql/item_timefunc.cc:3059 (gdb) p data_type() $1 = MYSQL_TYPE_DATE (gdb) cont Continuing. (gdb) p data_type() $2 = MYSQL_TYPE_DATETIME (gdb) cont Continuing. (gdb) p data_type() $3 = MYSQL_TYPE_TIME 2 4

  25. A Solution ; 2 5

  26. Test Solution build-mysql-8.0]$ mysql-test/mtr bug71386 build-mysql-8.0]$ mysql-test/mtr bug71386 … … ----------- MYSQLTEST OUTPUT START ----------- ----------- MYSQLTEST OUTPUT START ----------- SELECT STR_TO_DATE('1/1/2010', '%m/%d/%Y'); SELECT STR_TO_DATE('1/1/2010', '%m/%d/%Y'); STR_TO_DATE('1/1/2010', '%m/%d/%Y') STR_TO_DATE('1/1/2010', '%m/%d/%Y') 2010-01-01 2010-01-01 SELECT STR_TO_DATE('1/1/2010 01:35 PM', '%m/%d/%Y %h:%i %p'); SELECT STR_TO_DATE('1/1/2010 01:35 PM', '%m/%d/%Y %h:%i %p'); STR_TO_DATE('1/1/2010 01:35 PM', '%m/%d/%Y %h:%i %p') STR_TO_DATE('1/1/2010 01:35 PM', '%m/%d/%Y %h:%i %p') 2010-01-01 13:35:00 2010-01-01 13:35:00 SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); STR_TO_DATE('01:35 PM', '%h:%i %p') STR_TO_DATE('01:35 PM', '%h:%i %p') 2 6 13:35:00 13:35:00

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend