[MDEV-10728] mysqlbinlog can't be input to mysql client Created: 2016-09-02  Updated: 2020-08-25  Resolved: 2017-11-06

Status: Closed
Project: MariaDB Server
Component/s: Character Sets
Affects Version/s: 5.5, 10.0, 10.1
Fix Version/s: 10.1.29

Type: Bug Priority: Major
Reporter: Zhoukai Lin Assignee: Vesa Pentti (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Attachments: File my.cnf     File mysql-bin.000018     File mysql-bin.000019     File mysql-bin.000020    
Sprint: 10.1.29

 Description   

I can't replay any of my binlog files even the file have no user events.
Like this:

[lzk@redhat64-26 binlog]$ mysqlbinlog mysql-bin.000018|mysql
ERROR 1064 (42000) at line 8: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ';
 
 
 
 
 
 
 
DELIMITER ;
 
ROLLBACK  ;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_T' at line 1

[lzk@redhat64-26 binlog]$ mysqlbinlog mysql-bin.000018
/*!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*/;
DELIMITER /*!*/;
# at 4
#160902 16:25:40 server id 12324  end_log_pos 248       Start: binlog v 4, server v 10.0.12-MariaDB-debug-log created 160902 16:25:40
# Warning: this binlog is either in use or was not closed properly.
BINLOG '
hDfJVw8kMAAA9AAAAPgAAAABAAQAMTAuMC4xMi1NYXJpYURCLWRlYnVnLWxvZwAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAA3AAEGggAAAAICAgCAAAACgoKAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAEEwQACr8VJg==
'/*!*/;
# at 248
#160902 16:25:40 server id 12324  end_log_pos 303       Gtid list [0-3282660265-4,
# 0-12324-354244]
# at 303
#160902 16:25:40 server id 12324  end_log_pos 342       Binlog checkpoint mysql-bin.000017
# at 342
#700101  8:00:00 server id 12324  end_log_pos 381       Binlog checkpoint mysql-bin.000018
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;



 Comments   
Comment by Elena Stepanova [ 2016-09-03 ]

Could you please run FLUSH BINARY LOGS and after that attach to this issue a couple of the empty binlogs that you cannot replay?

Please also paste or attach your cnf file(s) and paste the versions of mysqlbinlog and mysql.

Thanks.

Comment by Zhoukai Lin [ 2016-09-05 ]

MariaDB [(none)]> show binary logs;
+------------------+-----------+
| Log_name         | File_size |
+------------------+-----------+
| mysql-bin.000001 |      7221 |
| mysql-bin.000002 |      7038 |
| mysql-bin.000003 |       361 |
| mysql-bin.000004 |     24038 |
| mysql-bin.000005 |  10489037 |
| mysql-bin.000006 |   3886372 |
| mysql-bin.000007 |    491468 |
| mysql-bin.000008 |  10487573 |
| mysql-bin.000009 |  10486728 |
| mysql-bin.000010 |   8983813 |
| mysql-bin.000011 |   5235623 |
| mysql-bin.000012 |  10485818 |
| mysql-bin.000013 |  10489910 |
| mysql-bin.000014 |   1362056 |
| mysql-bin.000015 |       925 |
| mysql-bin.000016 |   6958907 |
| mysql-bin.000017 |    319640 |
| mysql-bin.000018 |      1151 |
| mysql-bin.000019 |       381 |
+------------------+-----------+
19 rows in set (0.02 sec)
 
MariaDB [(none)]> flush binary logs;
Query OK, 0 rows affected (0.13 sec)

mysql-bin.000018 mysql-bin.000019 mysql-bin.000020 my.cnf

[lzk@redhat64-26 binlog]$ mysqlbinlog mysql-bin.000020|mysql
ERROR 1064 (42000) at line 8: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ';
 
 
 
 
 
 
 
DELIMITER ;
 
ROLLBACK  ;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_T' at line 1

[lzk@redhat64-26 binlog]$ mysql --version
mysql  Ver 15.1 Distrib 10.0.12-MariaDB, for Linux (x86_64) using readline 5.1

And I tryed on 10.1.12 version,also can't replay it's own binlog.

When I replace 'DELIMITER' to 'delimiter',I can sucessfully replay all binlog files:

[lzk@redhat64-26 binlog]$ mysqlbinlog mysql-bin.000020|sed s/DELIMITER/delimiter/g|mysql
[lzk@redhat64-26 binlog]$ 

Comment by Elena Stepanova [ 2016-09-06 ]

All attached binary logs work just fine for me, without and substitution, both on 10.0.12 and 10.1.12 (and on the current 10.1, too).

As I understand, you build your server from sources. Where did you get the source code (git or source tarball)? Are you sure it wasn't modified anyhow? Could you please provide all cmake/build options?

Thanks.

Comment by Zhoukai Lin [ 2016-09-07 ]

I downloaded the source tarball from https://downloads.mariadb.org ,and haven't modified it.
cmake option like :
cmake .. \
-DCMAKE_INSTALL_PREFIX=/home/lzk \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_bin \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_NDBCLUSTER_STORAGE_ENGINE=0 \
-DENABLED_LOCAL_INFILE=1

Comment by Zhoukai Lin [ 2016-09-07 ]

When I "export LANG=C" ,binary log worked well
When I "export LANG=en_US.utf8", there is SQL syntax error, then I add "sed s/DELIMITER/delimiter/g" it's OK again.

[lzk1@redhat64-26 binlog]$ export LANG=C
[lzk1@redhat64-26 binlog]$ mysqlbinlog mysql-bin.000002 |mysql
[lzk1@redhat64-26 binlog]$ export LANG=en_US.utf8
[lzk1@redhat64-26 binlog]$ mysqlbinlog mysql-bin.000002 |mysql
ERROR 1064 (42000) at line 8: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ';
 
 
 
 
 
 
 
DELIMITER ;
 
ROLLBACK  ;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_T' at line 1
[lzk1@redhat64-26 binlog]$ mysqlbinlog mysql-bin.000002 |sed s/DELIMITER/delimiter/g|mysql
[lzk1@redhat64-26 binlog]$ 

Comment by Elena Stepanova [ 2016-09-07 ]

Thanks for this, I can reproduce the error now.
Both cmake options (for building the client) and locale are important.

  • default build options, LANG=C => OK
  • default build options, LANG=en_US.utf8 => OK
  • -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_bin, LANG=C => OK
  • -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_bin, LANG=en_US.utf8 => PROBLEM

To reproduce, It's enough to feed this to MySQL client (built with the options as above, and run in environment with LANG=en_US.utf8):

mdev10728.sql

DELIMITER /*!*/;
SELECT 1 /*!*/;
DELIMITER ;

$ export LANG=en_US.utf8
$ client/mysql -uroot --protocol=tcp < mdev10728.sql
1
1
ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ';
DELIMITER' at line 1

I'll assign it to the charset expert bar to determine whether it's a bug or expected behavior.

Comment by Julien Fritsch [ 2017-09-11 ]

bar confirmed that this is indeed a bug.

Comment by Richard Stracke [ 2017-09-11 ]

This error happened with a not self compiled 10.0.21, too.

https://downloads.mariadb.org/interstitial/mariadb-10.0.21/bintar-linux-x86_64/mariadb-10.0.21-linux-x86_64.tar.gz/from/http%3A//ftp.hosteurope.de/mirror/archive.mariadb.org/?serve

I have the impression, that some byte combination will be interpreted as escape commands even if --binary-mode=1 will be used.

Comment by Sergei Golubchik [ 2017-10-31 ]

when fixing it, make sure that ĐĒĹĩḿîţEŘ doesn't suddenly become a valid command

Comment by Vesa Pentti (Inactive) [ 2017-11-02 ]

To my understanding, in client/mysql.cc:is_delimiter_command(): "DELIMITER" from the input is compared to "delimiter" with utf8_bin collation, which makes the comparison case sensitive, failing to recognize the command.

If I understand the code correctly, other commands are parsed always using &my_charset_latin1. It would seem reasonable to do the same for "delimiter".

Comment by Alexander Barkov [ 2017-11-03 ]

Vesa, your patch https://github.com/MariaDB/server/commit/9894f9d5a517c27a2c462addbd25bc42cba1749a looks fine.

However, it seems find_command() should also be fixed to use &my_charset_latin1 instead of charset_info.

Can you also please add tests into mysql-test/t/mysql.test
to make sure that "delimiter" and some command (e.g. "use")
work in both lower and upper cases?
Thanks!

Comment by Alexander Barkov [ 2017-11-04 ]

Thanks!
Right, for my_issspace() it's not important. Ok to push.
Please make sure to do "git add mysql-test/r/delimiter_command_case_sensitivity.result".
It's not a part of the commit https://github.com/MariaDB/server/commit/ef4fe2366fc631853f07e14601c3603774f2049b

Comment by Vesa Pentti (Inactive) [ 2017-11-06 ]

Result file added. Pushed to 10.1.

Comment by Richard Stracke [ 2017-11-06 ]

Is 10.2 not affected ?
commit

https://github.com/MariaDB/server/commit/ef4fe2366fc631853f07e14601c3603774f2049b
show this change:

-   !my_strnncoll(charset_info, (uchar*) name, DELIMITER_NAME_LEN
+  !my_strnncoll(&my_charset_latin1, (uchar*) name, DELIMITER_NAME_LEN, 

Code 10.2.10

          !my_strnncoll(charset_info, (uchar*) name, DELIMITER_NAME_LEN,
                        (uchar *) DELIMITER_NAME, DELIMITER_NAME_LEN));

Richard

Comment by Vesa Pentti (Inactive) [ 2017-11-06 ]

For now it's in 10.1, not yet in 10.2. I assume 10.1 fixes will be later merged to 10.2 and 10.3.

Comment by Sergei Golubchik [ 2017-11-06 ]

Yes, they absolutely will be.

Comment by Richard Stracke [ 2017-11-07 ]

So it will be probably merged with 10.2.11 ?

Comment by Sergei Golubchik [ 2017-11-07 ]

Yes. It is currently in 10.0-galera branch.
First 10.0-galera will be merged into 10.1 in MDEV-14135, then 10.1 will be merged into 10.2 in MDEV-14289.

Generated at Thu Feb 08 07:44:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.