Skip to content

Commit

Permalink
MDEV-22330: mysqlbinlog stops with an error Don't know how to handle …
Browse files Browse the repository at this point in the history
…column type: 255 meta: 4 (0004)

Analysis:
========
"mysqlbinlog -v" option will reconstruct row events and display them as
commented SQL statements. If this option is given twice, the output includes
comments to indicate column data types and some metadata.
`log_event_print_value` is the function reponsible for printing values and
their types. This function doesn't handle GEOMETRY type. Hence the above error
gets printed.

Fix:
===
Add support for GEOMETRY datatype.
  • Loading branch information
sujatha-s committed Sep 28, 2020
1 parent e0f5e7b commit 15cd919
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 7 deletions.
56 changes: 55 additions & 1 deletion mysql-test/suite/binlog/r/binlog_mysqlbinlog_row.result
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,11 @@ a
123.47
999.99
DROP TABLE t1dec102;
flush logs;
CREATE TABLE t1 (a GEOMETRY DEFAULT NULL);
INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (POINT(10,10));
DROP TABLE t1;
FLUSH LOGS;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
Expand Down Expand Up @@ -4623,6 +4627,56 @@ SET TIMESTAMP=1000000000/*!*/;
DROP TABLE `t1dec102` /* generated by server */
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-321 ddl
/*!100001 SET @@session.gtid_seq_no=321*//*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
CREATE TABLE t1 (a GEOMETRY DEFAULT NULL)
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-322
/*!100001 SET @@session.gtid_seq_no=322*//*!*/;
BEGIN
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# at #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=NULL /* GEOMETRY meta=4 nullable=1 is_null=1 */
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
COMMIT
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-323
/*!100001 SET @@session.gtid_seq_no=323*//*!*/;
BEGIN
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Table_map: `test`.`t1` mapped to number #
# at #
#010909 4:46:40 server id 1 end_log_pos # Write_rows: table id # flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1='\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00$@\x00\x00\x00\x00\x00\x00$@' /* GEOMETRY meta=4 nullable=1 is_null=0 */
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
COMMIT
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # GTID 0-1-324 ddl
/*!100001 SET @@session.gtid_seq_no=324*//*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Query thread_id=# exec_time=# error_code=0
SET TIMESTAMP=1000000000/*!*/;
DROP TABLE `t1` /* generated by server */
/*!*/;
# at #
#010909 4:46:40 server id 1 end_log_pos # Rotate to master-bin.000002 pos: 4
DELIMITER ;
# End of log file
Expand Down
14 changes: 13 additions & 1 deletion mysql-test/suite/binlog/t/binlog_mysqlbinlog_row.test
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,19 @@ INSERT INTO t1dec102 VALUES (999.99);
SELECT * FROM t1dec102 ORDER BY a;
DROP TABLE t1dec102;

flush logs;

#
# MDEV-22330: mysqlbinlog stops with an error Don't know how to handle column
# type: 255 meta: 4 (0004)
# Check support for GEOMETRY type with verbose mode.
#
CREATE TABLE t1 (a GEOMETRY DEFAULT NULL);

INSERT INTO t1 VALUES (NULL);
INSERT INTO t1 VALUES (POINT(10,10));
DROP TABLE t1;

FLUSH LOGS;

--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_regex /SQL_LOAD_MB-[0-9]-[0-9]/SQL_LOAD_MB-#-#/ /exec_time=[0-9]*/exec_time=#/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /server v [^ ]*/server v #.##.##/ /(@[0-9]*=[0-9]*[.][0-9]{1,3})[0-9e+-]*[^ ]*(.*(FLOAT|DOUBLE).*[*].)/\1...\2/
Expand Down
17 changes: 12 additions & 5 deletions sql/log_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2575,13 +2575,20 @@ log_event_print_value(IO_CACHE *file, const uchar *ptr,
"Not enough metadata to display the value. ");
break;

case MYSQL_TYPE_GEOMETRY:
strmake(typestr, "GEOMETRY", typestr_length);
if (!ptr)
goto return_null;

length= uint4korr(ptr);
my_b_write_quoted(file, ptr + meta, length);
return length + meta;

default:
{
char tmp[5];
my_snprintf(tmp, sizeof(tmp), "%04x", meta);
my_b_printf(file,
"!! Don't know how to handle column type=%d meta=%d (%s)",
type, meta, tmp);
fprintf(stderr,
"\nError: Don't know how to handle column type: %d meta: %d (%04x)\n",
type, meta, meta);
}
break;
}
Expand Down

0 comments on commit 15cd919

Please sign in to comment.