Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.3(EOL), 10.4(EOL)
-
None
Description
--source include/master-slave.inc
|
--source include/have_binlog_format_row.inc
|
|
SET SQL_MODE= 'EMPTY_STRING_IS_NULL'; |
|
CREATE TABLE t1 AS SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE 1 = 0; |
|
--sync_slave_with_master
|
|
SHOW CREATE TABLE t1; |
|
# Cleanup
|
--connection master
|
DROP TABLE t1; |
--source include/rpl_end.inc |
10.3 f010c908 |
Last_Errno 1067
|
Last_Error Error 'Invalid default value for 'TABLE_NAME'' on query. Default database: 'test'. Query: 'CREATE TABLE `t1` (
|
`TABLE_NAME` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT ''
|
)'
|
Technically the error isn't wrong, so I have no idea what should be done about it; but I guess it shouldn't just be allowed to fail.
Attachments
Issue Links
- is duplicated by
-
MDEV-20254 Problems with EMPTY_STRING_IS_NULL and I_S tables
-
- Closed
-
- relates to
-
MDEV-20254 Problems with EMPTY_STRING_IS_NULL and I_S tables
-
- Closed
-
-
MDEV-20253 DEFAULT is erroneously copied in `CREATE..SELECT column`
-
- Confirmed
-
Background:
===========
In Row based replication statements such as CREATE TABLE ... SELECT, a CREATE
statement is generated from the table definition and replicated using
statement-based format, while the row insertions are replicated using row-based
format
For example: Query: create table t1 (a int) select b from t;
============
1) binlog-format= STATEMENT
MariaDB [test]> create table t1 (a int) select b from t;
#190719 13:07:55 server id 1 end_log_pos 502 CRC32 0x5c74db35 GTID 0-1-2 ddl
/*!100001 SET @@session.gtid_seq_no=2*//*!*/;
# at 502
#190719 13:07:55 server id 1 end_log_pos 608 CRC32 0xa14ceae2 Query thread_id=4 exec_time=0 error_code=0
SET TIMESTAMP=1563521875/*!*/;
create table t1 (a int) select b from t
/*!*/;
2) binlog-format= ROW
MariaDB [test]> create table t1 (a int) select b from t;
#190719 13:06:01 server id 1 end_log_pos 502 CRC32 0x12f5a142 GTID 0-1-2 ddl
/*!100001 SET @@session.gtid_seq_no=2*//*!*/;
BEGIN
/*!*/;
# at 502
#190719 13:06:01 server id 1 end_log_pos 645 CRC32 0xf3a1ca57 Query thread_id=4 exec_time=0 error_code=0
SET TIMESTAMP=1563521761/*!*/;
CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL
)
Reported Bug:
=============
Query is "CREATE TABLE t1 AS SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE 1 = 0;"
The "TABLE_NAME" field in "INFORMATION_SCHEMA.TABLES" is defined as shown below.
`TABLE_NAME` varchar(64) NOT NULL DEFAULT ''
On master the above query gets executed successfully and it gets rewritten in the
binarylog as per the resulting table definition as shown below.
CREATE TABLE `t1` (`TABLE_NAME` varchar(64) CHARACTER SET utf8 NOT NULL DEFAULT '')
On Slave: The rewritten query arrives for execution. The
SQL_MODE='EMPTY_STRING_IS_NULL' is set. The above DDL is sent to parser for
validation. Parser invokes "Column_definition::check" for "TABLE_NAME" column.
The DEFAULT is '' (Empty String) and it gets mapped to NULL due to the
"SQL_MODE" which contradicts with field definition being "NOT NULL".
Hence it results in "ER_INVALID_DEFAULT", 1067, "Invalid default value for \'%-.192s\'"
error.
Replication behaves as expected.