summaryrefslogtreecommitdiff
path: root/sql/ha_sequence.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-05-17 12:59:07 +0400
committerAlexander Barkov <bar@mariadb.org>2017-05-17 12:59:07 +0400
commit896c2c73a02c7e82299b00e66ee3ff5f85aa3adc (patch)
treeb51a6b87f0d2488845144be585275c8cac19a1ed /sql/ha_sequence.cc
parent6378c95ee07cccc2f2187b2caddc4496e14827d9 (diff)
parentfba7fbbc5c7bb1d05488108a29b854ee8ef0066a (diff)
downloadmariadb-git-896c2c73a02c7e82299b00e66ee3ff5f85aa3adc.tar.gz
Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.310.3-MDEV-10953
Diffstat (limited to 'sql/ha_sequence.cc')
-rw-r--r--sql/ha_sequence.cc27
1 files changed, 25 insertions, 2 deletions
diff --git a/sql/ha_sequence.cc b/sql/ha_sequence.cc
index 25a1a6e71c4..a918da92be2 100644
--- a/sql/ha_sequence.cc
+++ b/sql/ha_sequence.cc
@@ -110,6 +110,8 @@ int ha_sequence::open(const char *name, int mode, uint flags)
if ((error= table->s->sequence->read_initial_values(table)))
file->ha_close();
}
+ else
+ table->m_needs_reopen= true;
}
DBUG_RETURN(error);
}
@@ -189,15 +191,17 @@ int ha_sequence::write_row(uchar *buf)
DBUG_ASSERT(table->record[0] == buf);
row_already_logged= 0;
- if (!sequence->initialized)
+ if (unlikely(sequence->initialized == SEQUENCE::SEQ_IN_PREPARE))
{
/* This calls is from ha_open() as part of create table */
DBUG_RETURN(file->write_row(buf));
}
+ if (unlikely(sequence->initialized != SEQUENCE::SEQ_READY_TO_USE))
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
/*
User tries to write a row
- - Check that row is an accurate object
+ - Check that the new row is an accurate object
- Update the first row in the table
*/
@@ -286,6 +290,25 @@ int ha_sequence::info(uint flag)
DBUG_RETURN(false);
}
+
+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;
+ }
+ return file->extra(operation);
+}
+
+bool ha_sequence::check_if_incompatible_data(HA_CREATE_INFO *create_info,
+ uint table_changes)
+{
+ /* Table definition is locked for SEQUENCE tables */
+ return(COMPATIBLE_DATA_YES);
+}
+
+
int ha_sequence::external_lock(THD *thd, int lock_type)
{
int error= file->external_lock(thd, lock_type);