From 36ae8846ca86bc82900f8c1b2bbad2666a3e9945 Mon Sep 17 00:00:00 2001 From: Monty Date: Sat, 3 Jun 2017 16:08:23 +0300 Subject: Fixed sequences based on comments from Peter Gulutzan and Andrii Nikitin - Changed names of SEQUENCE table columns to be more close to ANSI - Fixed error message for SHOW SEQUENCE non_existing_sequence - Allow syntax CACHE +1 - Fixed ALTER TABLE for TEMPORARY sequences. --- sql/ha_sequence.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'sql/ha_sequence.cc') diff --git a/sql/ha_sequence.cc b/sql/ha_sequence.cc index e0e9e2a42e7..7f2248bf3cb 100644 --- a/sql/ha_sequence.cc +++ b/sql/ha_sequence.cc @@ -198,6 +198,18 @@ int ha_sequence::write_row(uchar *buf) /* This calls is from ha_open() as part of create table */ DBUG_RETURN(file->write_row(buf)); } + if (unlikely(sequence->initialized == SEQUENCE::SEQ_IN_ALTER)) + { + int error= 0; + /* This is called from alter table */ + tmp_seq.read_fields(table); + if (tmp_seq.check_and_adjust(0)) + DBUG_RETURN(HA_ERR_SEQUENCE_INVALID_DATA); + sequence->copy(&tmp_seq); + if (!(error= file->write_row(buf))) + sequence->initialized= SEQUENCE::SEQ_READY_TO_USE; + DBUG_RETURN(error); + } if (unlikely(sequence->initialized != SEQUENCE::SEQ_READY_TO_USE)) DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -280,7 +292,7 @@ int ha_sequence::extra(enum ha_extra_function operation) if (operation == HA_EXTRA_PREPARE_FOR_ALTER_TABLE) { /* In case of ALTER TABLE allow ::write_row() to copy rows */ - sequence->initialized= SEQUENCE::SEQ_IN_PREPARE; + sequence->initialized= SEQUENCE::SEQ_IN_ALTER; } return file->extra(operation); } -- cgit v1.2.1