diff options
author | Monty <monty@mariadb.org> | 2017-05-29 16:08:11 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2017-05-29 16:08:49 +0300 |
commit | 7e5bd1500f7149ed67b0593e021d3695a8f9d81a (patch) | |
tree | a9fb1e045b8965845512d0c549aa5dc524cb59e7 /sql/sql_sequence.h | |
parent | d7e3120da8be3b517b81cce160dbe53f91876ce8 (diff) | |
download | mariadb-git-7e5bd1500f7149ed67b0593e021d3695a8f9d81a.tar.gz |
Add locks for sequence's to ensure that there is only one writer or many readers
This is needed for MyISAM and other storage engines which normally
relies on THR_LOCK's to ensure that one is not writing the same block
one could be reading from.
Diffstat (limited to 'sql/sql_sequence.h')
-rw-r--r-- | sql/sql_sequence.h | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/sql/sql_sequence.h b/sql/sql_sequence.h index b9d6326fcd1..b560d03ca52 100644 --- a/sql/sql_sequence.h +++ b/sql/sql_sequence.h @@ -40,7 +40,7 @@ class sequence_definition :public Sql_alloc public: sequence_definition(): min_value(1), max_value(LONGLONG_MAX-1), start(1), increment(1), - cache(1000), round(0), cycle(0), used_fields(0) + cache(1000), round(0), restart(0), cycle(0), used_fields(0) {} longlong reserved_until; longlong min_value; @@ -49,9 +49,9 @@ public: longlong increment; longlong cache; ulonglong round; + longlong restart; // alter sequence restart value bool cycle; uint used_fields; // Which fields where used in CREATE - longlong restart; // alter sequence restart value bool check_and_adjust(bool set_reserved_until); void store_fields(TABLE *table); @@ -93,14 +93,10 @@ public: ~SEQUENCE(); int read_initial_values(TABLE *table); int read_stored_values(); - void lock() - { - mysql_mutex_lock(&mutex); - } - void unlock() - { - mysql_mutex_unlock(&mutex); - } + void write_lock(TABLE *table); + void write_unlock(TABLE *table); + void read_lock(TABLE *table); + void read_unlock(TABLE *table); void copy(sequence_definition *seq) { sequence_definition::operator= (*seq); @@ -135,7 +131,7 @@ public: private: TABLE *table; - mysql_mutex_t mutex; + mysql_rwlock_t mutex; }; |