Skip to content

Commit

Permalink
Clean up ib_sequence::m_max_value
Browse files Browse the repository at this point in the history
Correctly document the usage of m_max_value. Remove the const
qualifier, so that the implicit assignment operator can be used.
Make all members of ib_sequence private, and add an accessor
member function max_value().
  • Loading branch information
dr-m committed Apr 25, 2019
1 parent ac97ad4 commit 9e7bcb0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion storage/innobase/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2721,7 +2721,7 @@ prepare_inplace_alter_table_dict(
(ha_alter_info->handler_ctx);

DBUG_ASSERT((ctx->add_autoinc != ULINT_UNDEFINED)
== (ctx->sequence.m_max_value > 0));
== (ctx->sequence.max_value() > 0));
DBUG_ASSERT(!ctx->num_to_drop_index == !ctx->drop_index);
DBUG_ASSERT(!ctx->num_to_drop_fk == !ctx->drop_fk);
DBUG_ASSERT(!add_fts_doc_id || add_fts_doc_id_idx);
Expand Down
11 changes: 8 additions & 3 deletions storage/innobase/include/handler0alter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -96,9 +97,13 @@ struct ib_sequence_t {
return(m_next_value);
}

/** Maximum calumn value if adding an AUTOINC column else 0. Once
we reach the end of the sequence it will be set to ~0. */
const ulonglong m_max_value;
/** @return maximum column value
@retval 0 if not adding AUTO_INCREMENT column */
ulonglong max_value() const { return m_max_value; }

private:
/** Maximum value if adding an AUTO_INCREMENT column, else 0 */
ulonglong m_max_value;

/** Value of auto_increment_increment */
ulong m_increment;
Expand Down
2 changes: 1 addition & 1 deletion storage/xtradb/handler/handler0alter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2727,7 +2727,7 @@ prepare_inplace_alter_table_dict(
(ha_alter_info->handler_ctx);

DBUG_ASSERT((ctx->add_autoinc != ULINT_UNDEFINED)
== (ctx->sequence.m_max_value > 0));
== (ctx->sequence.max_value() > 0));
DBUG_ASSERT(!ctx->num_to_drop_index == !ctx->drop_index);
DBUG_ASSERT(!ctx->num_to_drop_fk == !ctx->drop_fk);
DBUG_ASSERT(!add_fts_doc_id || add_fts_doc_id_idx);
Expand Down
11 changes: 8 additions & 3 deletions storage/xtradb/include/handler0alter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Expand Down Expand Up @@ -96,9 +97,13 @@ struct ib_sequence_t {
return(m_next_value);
}

/** Maximum calumn value if adding an AUTOINC column else 0. Once
we reach the end of the sequence it will be set to ~0. */
const ulonglong m_max_value;
/** @return maximum column value
@retval 0 if not adding AUTO_INCREMENT column */
ulonglong max_value() const { return m_max_value; }

private:
/** Maximum value if adding an AUTO_INCREMENT column, else 0 */
ulonglong m_max_value;

/** Value of auto_increment_increment */
ulong m_increment;
Expand Down

0 comments on commit 9e7bcb0

Please sign in to comment.