-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-39240 10.6-11.4 Replication Allows Full Range for 32-bit Unsigned Timestamps #4933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 10.11
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the discussion on Zoom, this should error even with |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume we only need to cover Row-based Replication here, since changing Statement-based Replication requires a mode (be it |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,11 +100,15 @@ pack_row(TABLE *table, MY_BITMAP const* cols, | |
| length is stored in little-endian format, since this is the | ||
| format used for the binlog. | ||
| */ | ||
| #if !defined DBUG_OFF && defined DBUG_TRACE | ||
| const uchar *old_pack_ptr= pack_ptr; | ||
| #ifndef DBUG_OFF | ||
| uchar *old_pack_ptr= pack_ptr; | ||
| #endif | ||
| pack_ptr= field->pack(pack_ptr, field->ptr + offset, | ||
| field->max_data_length()); | ||
| DBUG_EXECUTE_IF("rpl_pack_simulate_negation", | ||
| for (uchar *byte= old_pack_ptr; byte < pack_ptr; ++byte) | ||
| *byte= ~*byte; | ||
| ); | ||
|
Comment on lines
+108
to
+111
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered sneaking over-max timestamps into the primary server, but I’m concerned that it’s too UB from reading the relevant entry code, and so decided not to fix any tangential problems this hack surfaces. |
||
| DBUG_PRINT("debug", ("field: %s; real_type: %d, pack_ptr: %p;" | ||
| " pack_ptr':%p; bytes: %d", | ||
| field->field_name.str, field->real_type(), | ||
|
|
@@ -187,6 +191,8 @@ pack_row(TABLE *table, MY_BITMAP const* cols, | |
| A generic, internal, error caused the unpacking to fail. | ||
| @retval HA_ERR_CORRUPT_EVENT | ||
| Found error when trying to unpack fields. | ||
| @retval HA_ERR_ROWS_EVENT_APPLY | ||
| Found error when validating field values. | ||
| */ | ||
| #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) | ||
| int | ||
|
|
@@ -338,6 +344,38 @@ unpack_row(rpl_group_info *rgi, | |
| table->s->table_name.str); | ||
| DBUG_RETURN(HA_ERR_CORRUPT_EVENT); | ||
| } | ||
|
|
||
| // Validate this external data | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could use |
||
| switch (f->type()) { | ||
| case MYSQL_TYPE_TIMESTAMP: | ||
| { | ||
| ulong microseconds; | ||
| my_time_t seconds= f->get_timestamp(µseconds); | ||
| if (likely(microseconds <= TIME_MAX_SECOND_PART)) | ||
| { | ||
| if (likely(seconds >= 0 && seconds <= TIMESTAMP_MAX_VALUE)) | ||
| break; | ||
| else if (likely(seconds == UINT_MAX32)) // They are both signed. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| { | ||
| // Normalize MariaDB 11.5.1+ Epochalypse | ||
| f->store_timestamp(TIMESTAMP_MAX_VALUE, microseconds); | ||
| break; | ||
| } | ||
| } | ||
| static const char unixtime_format[]= | ||
| "FROM_UNIXTIME(%ld + %lu/1""000""000)"; | ||
| // + strlen("2147483648""16777215") - strlen("%ld""%lu") | ||
| char unixtime[sizeof(unixtime_format) + 12]; | ||
| snprintf(unixtime, sizeof(unixtime), unixtime_format, | ||
| seconds, microseconds); | ||
| rgi->rli->report(ERROR_LEVEL, ER_TRUNCATED_WRONG_VALUE_FOR_FIELD, | ||
| rgi->gtid_info(), ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD), | ||
| f->type_handler()->name().ptr(), unixtime, table->s->db.str, | ||
| table->s->table_name.str, f->field_name.str, 0lu); | ||
| DBUG_RETURN(HA_ERR_ROWS_EVENT_APPLY); | ||
| } | ||
| default:; | ||
| } | ||
| } | ||
|
|
||
| /* | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…
However, variable substitution for SQL commands can’t work with strings containing both
'and", which affectssuite/rpl/include/check_type.inc(and others, such asinclude/write_var_to_file.inc), so I switched toLast_SQL_Errnoinstead.(Help thread: Escaping quotes for
--evalin MTR)