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

squash that old bug
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Squash That Old Bug

Daniel Black IBM Daniel Black IBM

slide-2
SLIDE 2

2

Overview

Topics:

  • Choosing a bug/feature
  • Build/test environment
  • Tour of code base
  • Build/test
  • Submitting code
  • Asking for help

Topics:

  • Choosing a bug/feature
  • Build/test environment
  • Tour of code base
  • Build/test
  • Submitting code
  • Asking for help
slide-3
SLIDE 3

3

Choosing a Bug / Feature (MySQL)

Search existing bugs https://bugs.mysql.com/search.php Status: Verifjed

Note: (Efgort/Risk fjelds have fallen out of use)

Search existing bugs https://bugs.mysql.com/search.php Status: Verifjed

Note: (Efgort/Risk fjelds have fallen out of use)

slide-4
SLIDE 4

4

Choosing a Bug / Feature (MariaDB)

Search existing bugs jql: labels = beginner-friendly Search existing bugs jql: labels = beginner-friendly jql: status = Confjrmed jql: status = Confjrmed

slide-5
SLIDE 5

5

Choosing a Bug / Feature - Easy

  • Regressions
  • Wrong result
  • Portability (e.g. fix for FreeBSD)
  • Enhancement for new Linux Kernel API
  • Client tools (mysql, mysqldump/pump)
  • New SQL functions (verified / follow standard)
  • Regressions
  • Wrong result
  • Portability (e.g. fix for FreeBSD)
  • Enhancement for new Linux Kernel API
  • Client tools (mysql, mysqldump/pump)
  • New SQL functions (verified / follow standard)
slide-6
SLIDE 6

6

Choosing a Bug / Feature - Hard

  • Group / GTID replication
  • Optimizer

Or if you must: – Easy/quick to calculate (low overhead) – Always an improvement (no regressions)

  • Group / GTID replication
  • Optimizer

Or if you must: – Easy/quick to calculate (low overhead) – Always an improvement (no regressions)

slide-7
SLIDE 7

7

Build / Test environment

Few dependencies:

  • Git
  • Cmake
  • C++ compiler: gcc/ clang/ Xcode / VS17
  • Bison
  • Ncurses
  • Libevent (MariaDB) / boost (MySQL)

Ref: https://mariadb.com/kb/en/library/compiling-mariadb-from-source/ https://dev.mysql.com/doc/mysql-sourcebuild-excerpt/8.0/en/ Few dependencies:

  • Git
  • Cmake
  • C++ compiler: gcc/ clang/ Xcode / VS17
  • Bison
  • Ncurses
  • Libevent (MariaDB) / boost (MySQL)

Ref: https://mariadb.com/kb/en/library/compiling-mariadb-from-source/ https://dev.mysql.com/doc/mysql-sourcebuild-excerpt/8.0/en/

slide-8
SLIDE 8

8

Build / Test environment

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

slide-9
SLIDE 9

9

Build / Test environment

mariadb-server]$ cd ../build-mariadb-server build-mariadb-server]$ cmake -DCMAKE_BUILD_TYPE=Debug ../mariadb-server

  • - Running cmake version 3.14.3
  • - The C compiler identification is GNU 9.1.1
  • - The CXX compiler identification is GNU 9.1.1

...

  • - Configuring done
  • - Generating done
  • - Build files have been written to: /home/dan/repos/build-mariadb-server

build-mariadb-server]$ make -j8 Scanning dependencies of target abi_check Scanning dependencies of target wsrep_api_v26 mariadb-server]$ cd ../build-mariadb-server build-mariadb-server]$ cmake -DCMAKE_BUILD_TYPE=Debug ../mariadb-server

  • - Running cmake version 3.14.3
  • - The C compiler identification is GNU 9.1.1
  • - The CXX compiler identification is GNU 9.1.1

...

  • - Configuring done
  • - Generating done
  • - Build files have been written to: /home/dan/repos/build-mariadb-server

build-mariadb-server]$ make -j8 Scanning dependencies of target abi_check Scanning dependencies of target wsrep_api_v26

slide-10
SLIDE 10

1

Tour of codebase

slide-11
SLIDE 11

1 1

Example Bug 71386

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

slide-12
SLIDE 12

1 2

Create a Test Case

mysql-server]$ git grep -l STR_TO_DATE mysql-test/ mysql-test/r/date_formats.result mysql-test/r/func_time.result ... mysql-test/t/date_formats.test mysql-test/t/func_time.test mysql-test/t/ignore_strict.test mysql-test/t/parser.test mysql-test/t/strict.test mysql-test/t/type_datetime.test mysql-test/t/type_temporal_fractional.test mysql-server]$ git grep -l STR_TO_DATE mysql-test/ mysql-test/r/date_formats.result mysql-test/r/func_time.result ... mysql-test/t/date_formats.test mysql-test/t/func_time.test mysql-test/t/ignore_strict.test mysql-test/t/parser.test mysql-test/t/strict.test mysql-test/t/type_datetime.test mysql-test/t/type_temporal_fractional.test

slide-13
SLIDE 13

1 3

Create a Test Case

mysql-server]$ cat mysql-test/t/bug71386.test SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); build-mysql-8.0]$ mysql-test/mtr bug71386 …

  • ---------- MYSQLTEST OUTPUT START -----------

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

  • ---------- MYSQLTEST OUTPUT START -----------

SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); STR_TO_DATE('01:35 PM', '%h:%i %p') NULL Warnings: Warning 1411 Incorrect datetime value: '01:35 PM' for function str_to_date

slide-14
SLIDE 14

1 4

Create a Test Case

build-mysql-8.0]$ mysql-test/mtr --ddd bug71386 build-mysql-8.0]$ mysql-test/mtr --ddd bug71386

slide-15
SLIDE 15

1 5

Find the Cause

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

slide-16
SLIDE 16

1 6

Find the Cause

mysql-server]$ git grep -l ER_WRONG_VALUE_FOR_TYPE

mysql-test/include/ctype_inet.inc .. mysql-test/t/window_functions.test share/errmsg-utf8.txt sql/error_handler.cc sql/item_func.cc sql/item_geofunc.cc sql/item_inetfunc.cc sql/item_strfunc.cc sql/item_timefunc.cc

mysql-server]$ git grep -l ER_WRONG_VALUE_FOR_TYPE

mysql-test/include/ctype_inet.inc .. mysql-test/t/window_functions.test share/errmsg-utf8.txt sql/error_handler.cc sql/item_func.cc sql/item_geofunc.cc sql/item_inetfunc.cc sql/item_strfunc.cc sql/item_timefunc.cc

slide-17
SLIDE 17

1 7

Find the Cause

“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 *val…. “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 *val….

slide-18
SLIDE 18

1 8

Find the Cause

“Warning 1411 Incorrect datetime value: '01:35 PM' for function str_to_date” bool Item_func_str_to_date::val_datetime(MYSQL_TIME *ltime, my_time_flags_t fuzzy_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, my_time_flags_t fuzzy_date) {

slide-19
SLIDE 19

1 9

Find the Cause

slide-20
SLIDE 20

2

Find the Cause

slide-21
SLIDE 21

2 1

Find the Cause

slide-22
SLIDE 22

2 2

Find the Cause

slide-23
SLIDE 23

2 3

Find the Cause

slide-24
SLIDE 24

2 4

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

slide-25
SLIDE 25

2 5

A Solution

;

slide-26
SLIDE 26

2 6

Test Solution

build-mysql-8.0]$ mysql-test/mtr bug71386 …

  • ---------- MYSQLTEST OUTPUT START -----------

SELECT STR_TO_DATE('1/1/2010', '%m/%d/%Y'); STR_TO_DATE('1/1/2010', '%m/%d/%Y') 2010-01-01 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') 2010-01-01 13:35:00 SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); STR_TO_DATE('01:35 PM', '%h:%i %p') 13:35:00 build-mysql-8.0]$ mysql-test/mtr bug71386 …

  • ---------- MYSQLTEST OUTPUT START -----------

SELECT STR_TO_DATE('1/1/2010', '%m/%d/%Y'); STR_TO_DATE('1/1/2010', '%m/%d/%Y') 2010-01-01 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') 2010-01-01 13:35:00 SELECT STR_TO_DATE('01:35 PM', '%h:%i %p'); STR_TO_DATE('01:35 PM', '%h:%i %p') 13:35:00

slide-27
SLIDE 27

2 7

Test Solution

build-mysql-8.0]$ mysql-test/mtr func_time

CURRENT_TEST: main.func_time

  • -- /home/dan/repos/mysql-server/mysql-test/r/func_time.result

2019-05-03 09:08:35.340048269 +0300 +++ /home/dan/repos/build-mysql-8.0/mysql-test/var/log/func_time.reject 2019-05-14 12:50:45.124999118 +0300 @@ -1230,9 +1230,7 @@ set time_zone= @@global.time_zone; select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE

  • NULL
  • Warnings:
  • Warning 1411Incorrect datetime value: '10:00 PM' for function str_to_date

+22:10:00 create table t1 (field DATE); insert into t1 values ('2006-11-06'); select * from t1 where field < '2006-11-06 04:08:36.0'; mysqltest: Result content mismatch

build-mysql-8.0]$ mysql-test/mtr func_time

CURRENT_TEST: main.func_time

  • -- /home/dan/repos/mysql-server/mysql-test/r/func_time.result

2019-05-03 09:08:35.340048269 +0300 +++ /home/dan/repos/build-mysql-8.0/mysql-test/var/log/func_time.reject 2019-05-14 12:50:45.124999118 +0300 @@ -1230,9 +1230,7 @@ set time_zone= @@global.time_zone; select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE

  • NULL
  • Warnings:
  • Warning 1411Incorrect datetime value: '10:00 PM' for function str_to_date

+22:10:00 create table t1 (field DATE); insert into t1 values ('2006-11-06'); select * from t1 where field < '2006-11-06 04:08:36.0'; mysqltest: Result content mismatch

slide-28
SLIDE 28

2 8

Record New Test Result

build-mysql-8.0]$ mysql-test/mtr --record func_time

mysql-server]$ git diff -U1

diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index b99d37eeb31..4f78a52a9be 100644

  • -- a/mysql-test/r/func_time.result

+++ b/mysql-test/r/func_time.result @@ -1233,3 +1233 @@ str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE

  • NULL
  • Warnings:
  • Warning 1411 Incorrect datetime value: '10:00 PM' for function str_to_date

+22:10:00 diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 16e0b53636d..30c9526cfd6 100644

  • -- a/sql/item_timefunc.cc

+++ b/sql/item_timefunc.cc @@ -3076,0 +3077 @@ bool Item_func_str_to_date::val_datetime(MYSQL_TIME *ltime, + (data_type() != MYSQL_TYPE_TIME) &&

build-mysql-8.0]$ mysql-test/mtr --record func_time

mysql-server]$ git diff -U1

diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index b99d37eeb31..4f78a52a9be 100644

  • -- a/mysql-test/r/func_time.result

+++ b/mysql-test/r/func_time.result @@ -1233,3 +1233 @@ str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE

  • NULL
  • Warnings:
  • Warning 1411 Incorrect datetime value: '10:00 PM' for function str_to_date

+22:10:00 diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 16e0b53636d..30c9526cfd6 100644

  • -- a/sql/item_timefunc.cc

+++ b/sql/item_timefunc.cc @@ -3076,0 +3077 @@ bool Item_func_str_to_date::val_datetime(MYSQL_TIME *ltime, + (data_type() != MYSQL_TYPE_TIME) &&

slide-29
SLIDE 29

2 9

Submit Changes

mysql-server]$ git checkout -b 8.0-bug-71386 M mysql-test/r/func_time.result M sql/item_timefunc.cc Switched to a new branch '8.0-bug-71386' mysql-server]$ git checkout -b 8.0-bug-71386 M mysql-test/r/func_time.result M sql/item_timefunc.cc Switched to a new branch '8.0-bug-71386'

slide-30
SLIDE 30

3

Submit Changes

mysql-server]$ git commit -m 'bug#71386: STR_TO_DATE parse time only in sql_mode=NO_ZERO_IN_DATE' -a 2 files changed, 2 insertions(+), 3 deletions(-) mysql-server]$ git commit -m 'bug#71386: STR_TO_DATE parse time only in sql_mode=NO_ZERO_IN_DATE' -a 2 files changed, 2 insertions(+), 3 deletions(-)

slide-31
SLIDE 31

3 1

Submit Changes

mysql-server]$ git push .. remote: Create a pull request for '8.0-bug-71386' on GitHub by visiting: remote: https://github.com/grooverdan/mysql-server/pull/new/8.0-bug- 71386 remote: To github.com:grooverdan/mysql-server.git * [new branch] 8.0-bug-71386 -> 8.0-bug-71386 Branch '8.0-bug-71386' set up to track remote branch '8.0-bug-71386' from 'submit'. mysql-server]$ git push .. remote: Create a pull request for '8.0-bug-71386' on GitHub by visiting: remote: https://github.com/grooverdan/mysql-server/pull/new/8.0-bug- 71386 remote: To github.com:grooverdan/mysql-server.git * [new branch] 8.0-bug-71386 -> 8.0-bug-71386 Branch '8.0-bug-71386' set up to track remote branch '8.0-bug-71386' from 'submit'.

slide-32
SLIDE 32

3 2

Submit Changes

slide-33
SLIDE 33

3 3

Getting Help - MariaDB

Mailing list

  • https://lists.launchpad.net/maria-developers/

Chat

  • https://mariadb.zulipchat.com / irc://freenode.net/#maria

From 8:00 to 10:00 UTC on Mondays, and 10:00 to 12:00 UTC on Thursdays Mailing list

  • https://lists.launchpad.net/maria-developers/

Chat

  • https://mariadb.zulipchat.com / irc://freenode.net/#maria

From 8:00 to 10:00 UTC on Mondays, and 10:00 to 12:00 UTC on Thursdays

slide-34
SLIDE 34

3 4

Getting Help - MySQL

  • https://mysqlcommunity.slack.com #contributions
  • https://forums.mysql.com/list.php?117 (Source, Builds, Binaries )
  • https://mysqlcommunity.slack.com #contributions
  • https://forums.mysql.com/list.php?117 (Source, Builds, Binaries )
slide-35
SLIDE 35

35

Rate My Session