diff options
author | monty@hundin.mysql.fi <> | 2002-08-08 15:24:47 +0300 |
---|---|---|
committer | monty@hundin.mysql.fi <> | 2002-08-08 15:24:47 +0300 |
commit | 087261482a9bbdaa3bc0e26052a719ebdb73644b (patch) | |
tree | e7f4a2013ed3d66e640f6574e62cb7e534a5d77f /innobase/dict | |
parent | 8be1cdeb89ca59be790d58dc0d43993cdc4f4191 (diff) | |
parent | 3f48e0369b2e49026e9ddd4fddcee68ebe17db1e (diff) | |
download | mariadb-git-087261482a9bbdaa3bc0e26052a719ebdb73644b.tar.gz |
merge with 3.23.52
Diffstat (limited to 'innobase/dict')
-rw-r--r-- | innobase/dict/dict0dict.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 5abec8dbb1e..85199b90a5a 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -261,7 +261,7 @@ dict_table_get_index_noninline( { return(dict_table_get_index(table, name)); } - + /************************************************************************ Initializes the autoinc counter. It is not an error to initialize an already initialized counter. */ @@ -270,7 +270,7 @@ void dict_table_autoinc_initialize( /*==========================*/ dict_table_t* table, /* in: table */ - ib_longlong value) /* in: value which was assigned to a row */ + ib_longlong value) /* in: next value to assign to a row */ { mutex_enter(&(table->autoinc_mutex)); @@ -281,8 +281,8 @@ dict_table_autoinc_initialize( } /************************************************************************ -Gets the next autoinc value, 0 if not yet initialized. If initialized, -increments the counter by 1. */ +Gets the next autoinc value (== autoinc counter value), 0 if not yet +initialized. If initialized, increments the counter by 1. */ ib_longlong dict_table_autoinc_get( @@ -298,8 +298,8 @@ dict_table_autoinc_get( value = 0; } else { - table->autoinc = table->autoinc + 1; value = table->autoinc; + table->autoinc = table->autoinc + 1; } mutex_exit(&(table->autoinc_mutex)); @@ -334,20 +334,43 @@ dict_table_autoinc_read( } /************************************************************************ -Updates the autoinc counter if the value supplied is bigger than the +Peeks the autoinc counter value, 0 if not yet initialized. Does not +increment the counter. The read not protected by any mutex! */ + +ib_longlong +dict_table_autoinc_peek( +/*====================*/ + /* out: value of the counter */ + dict_table_t* table) /* in: table */ +{ + ib_longlong value; + + if (!table->autoinc_inited) { + + value = 0; + } else { + value = table->autoinc; + } + + return(value); +} + +/************************************************************************ +Updates the autoinc counter if the value supplied is equal or bigger than the current value. If not inited, does nothing. */ void dict_table_autoinc_update( /*======================*/ + dict_table_t* table, /* in: table */ ib_longlong value) /* in: value which was assigned to a row */ { mutex_enter(&(table->autoinc_mutex)); if (table->autoinc_inited) { - if (value > table->autoinc) { - table->autoinc = value; + if (value >= table->autoinc) { + table->autoinc = value + 1; } } |