mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-10139 Support for SEQUENCE objects
- SETVAL(sequence_name, next_value, is_used, round) - ALTER SEQUENCE, including RESTART WITH Other things: - Added handler::extra() option HA_EXTRA_PREPARE_FOR_ALTER_TABLE to signal ha_sequence() that it should allow write_row statments. - ALTER ONLINE TABLE now works with SEQUENCE:s
This commit is contained in:
@@ -20,6 +20,11 @@
|
||||
#define seq_field_used_min_value 1
|
||||
#define seq_field_used_max_value 2
|
||||
#define seq_field_used_start 4
|
||||
#define seq_field_used_increment 8
|
||||
#define seq_field_used_cache 16
|
||||
#define seq_field_used_cycle 32
|
||||
#define seq_field_used_restart 64
|
||||
#define seq_field_used_restart_value 128
|
||||
|
||||
/**
|
||||
sequence_definition is used when defining a sequence as part of create
|
||||
@@ -41,11 +46,14 @@ public:
|
||||
ulonglong round;
|
||||
bool cycle;
|
||||
uint used_fields; // Which fields where used in CREATE
|
||||
longlong restart; // alter sequence restart value
|
||||
|
||||
bool check_and_adjust();
|
||||
void store_fields(TABLE *table);
|
||||
void read_fields(TABLE *table);
|
||||
void print_dbug()
|
||||
int write_initial_sequence(TABLE *table);
|
||||
int write(TABLE *table);
|
||||
inline void print_dbug()
|
||||
{
|
||||
DBUG_PRINT("sequence", ("reserved: %lld start: %lld increment: %lld min_value: %lld max_value: %lld cache: %lld round: %lld",
|
||||
reserved_until, start, increment, min_value,
|
||||
@@ -80,13 +88,35 @@ public:
|
||||
mysql_mutex_unlock(&mutex);
|
||||
}
|
||||
/* This must be called after sequence data has been updated */
|
||||
void adjust_values();
|
||||
void adjust_values(longlong next_value);
|
||||
void copy(sequence_definition *seq)
|
||||
{
|
||||
sequence_definition::operator= (*seq);
|
||||
adjust_values();
|
||||
adjust_values(reserved_until);
|
||||
}
|
||||
longlong next_value(TABLE *table, bool second_round, int *error);
|
||||
bool set_value(TABLE *table, longlong next_value, ulonglong round_arg,
|
||||
bool is_used);
|
||||
longlong increment_value(longlong value)
|
||||
{
|
||||
if (real_increment > 0)
|
||||
{
|
||||
if (value + real_increment > max_value ||
|
||||
value > max_value - real_increment)
|
||||
value= max_value + 1;
|
||||
else
|
||||
value+= real_increment;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value + real_increment < min_value ||
|
||||
value < min_value - real_increment)
|
||||
value= min_value - 1;
|
||||
else
|
||||
value+= real_increment;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
bool all_values_used;
|
||||
seq_init initialized;
|
||||
@@ -100,7 +130,6 @@ private:
|
||||
merged with global auto_increment_offset and auto_increment_increment
|
||||
*/
|
||||
longlong real_increment;
|
||||
longlong offset;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user