diff options
author | Michael Widenius <monty@mariadb.org> | 2017-10-19 13:22:38 +0300 |
---|---|---|
committer | Michael Widenius <monty@mariadb.org> | 2017-10-19 13:25:02 +0300 |
commit | 211f9eea60100f05dea197ac2b55119ebb57c481 (patch) | |
tree | 4c45f3d6870c811d2ad574652814cda6bcf8dfcf /sql/sql_sequence.cc | |
parent | e156db85a75b2a15b89ebc5f65eedb07e0574420 (diff) | |
download | mariadb-git-211f9eea60100f05dea197ac2b55119ebb57c481.tar.gz |
MDEV-14092 NEXTVAL fails on slave
The problem was that the code in replication didn't distinguish between a
setval() failing because the stored sequence number was bigger than the
current (should have been ignored) and a failure from the storage engine.
Diffstat (limited to 'sql/sql_sequence.cc')
-rw-r--r-- | sql/sql_sequence.cc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index eb9dfe012f7..1d8db1a7cd9 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -758,12 +758,12 @@ void SEQUENCE_LAST_VALUE::set_version(TABLE *table) @param in table Sequence table @param in next_val Next free value - @param in next_round Round for 'next_value' (in cace of cycles) + @param in next_round Round for 'next_value' (in case of cycles) @param in is_used 1 if next_val is already used @retval 0 ok, value adjusted - 1 value was less than current value or - error when storing value + -1 value was less than current value + 1 error when storing value @comment A new value is set only if "nextval,next_round" is less than @@ -773,10 +773,10 @@ void SEQUENCE_LAST_VALUE::set_version(TABLE *table) contain the highest used value when the slave is promoted to a master. */ -bool SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round, +int SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round, bool is_used) { - bool error= 1; + int error= -1; bool needs_to_be_stored= 0; longlong org_reserved_until= reserved_until; longlong org_next_free_value= next_free_value; @@ -788,13 +788,13 @@ bool SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round, next_val= increment_value(next_val); if (round > next_round) - goto end; + goto end; // error = -1 if (round == next_round) { if (real_increment > 0 ? next_val < next_free_value : next_val > next_free_value) - goto end; + goto end; // error = -1 if (next_val == next_free_value) { error= 0; @@ -802,7 +802,13 @@ bool SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round, } } else if (cycle == 0) - goto end; // round < next_round && no cycles + { + // round < next_round && no cycles, which is impossible + my_error(ER_SEQUENCE_RUN_OUT, MYF(0), table->s->db.str, + table->s->table_name.str); + error= 1; + goto end; + } else needs_to_be_stored= 1; @@ -819,6 +825,7 @@ bool SEQUENCE::set_value(TABLE *table, longlong next_val, ulonglong next_round, reserved_until= org_reserved_until; next_free_value= org_next_free_value; round= org_round; + error= 1; goto end; } } |