MySQL  8.0.20
Source Code Documentation
handler0alter.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 2005, 2020, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 
27 /** @file include/handler0alter.h
28  Smart ALTER TABLE
29  *******************************************************/
30 
31 #ifndef handler0alter_h
32 #define handler0alter_h
33 
34 #define ERROR_STR_LENGTH 1024
35 
36 /** Copies an InnoDB record to table->record[0]. */
37 void innobase_rec_to_mysql(struct TABLE *table, /*!< in/out: MySQL table */
38  const rec_t *rec, /*!< in: record */
39  const dict_index_t *index, /*!< in: index */
40  const ulint *offsets); /*!< in: rec_get_offsets(
41  rec, index, ...) */
42 
43 /** Copies an InnoDB index entry to table->record[0]. */
45  struct TABLE *table, /*!< in/out: MySQL table */
46  const dict_index_t *index, /*!< in: InnoDB index */
47  const dfield_t *fields); /*!< in: InnoDB index fields */
48 
49 /** Copies an InnoDB row to table->record[0]. */
50 void innobase_row_to_mysql(struct TABLE *table, /*!< in/out: MySQL table */
51  const dict_table_t *itab, /*!< in: InnoDB table */
52  const dtuple_t *row); /*!< in: InnoDB row */
53 
54 /** Resets table->record[0]. */
55 void innobase_rec_reset(struct TABLE *table); /*!< in/out: MySQL table */
56 
57 /** Generate the next autoinc based on a snapshot of the session
58 auto_increment_increment and auto_increment_offset variables.
59 Assingnment operator would be used during the inplace_alter_table()
60 phase only **/
61 struct ib_sequence_t {
62  /**
63  @param thd the session
64  @param start_value the lower bound
65  @param max_value the upper bound (inclusive) */
66  ib_sequence_t(THD *thd, ulonglong start_value, ulonglong max_value);
67 
68  /** Postfix increment
69  @return the value to insert */
70  ulonglong operator++(int) UNIV_NOTHROW;
71 
72  /** Check if the autoinc "sequence" is exhausted.
73  @return true if the sequence is exhausted */
74  bool eof() const UNIV_NOTHROW { return (m_eof); }
75 
76  /** assignment operator to copy the sequence values
77  @param in sequence to copy from */
79  ut_ad(in.m_next_value > 0);
83  m_offset = in.m_offset;
84  m_eof = in.m_eof;
85  return (*this);
86  }
87  /**
88  @return the next value in the sequence */
89  ulonglong last() const UNIV_NOTHROW {
90  ut_ad(m_next_value > 0);
91 
92  return (m_next_value);
93  }
94 
95  /** Maximum calumn value if adding an AUTOINC column else 0. Once
96  we reach the end of the sequence it will be set to ~0. */
98 
99  /** Value of auto_increment_increment */
100  ulong m_increment;
101 
102  /** Value of auto_increment_offset */
103  ulong m_offset;
104 
105  /** Next value in the sequence */
107 
108  /** true if no more values left in the sequence */
109  bool m_eof;
110 };
111 
112 #endif /* handler0alter_h */
unsigned long long int ulonglong
Definition: my_inttypes.h:55
void innobase_row_to_mysql(struct TABLE *table, const dict_table_t *itab, const dtuple_t *row)
Copies an InnoDB row to table->record[0].
Definition: handler0alter.cc:2061
Data structure for a database table.
Definition: dict0mem.h:1520
void innobase_rec_reset(struct TABLE *table)
Resets table->record[0].
Definition: handler0alter.cc:2101
void innobase_fields_to_mysql(struct TABLE *table, const dict_index_t *index, const dfield_t *fields)
Copies an InnoDB index entry to table->record[0].
Definition: handler0alter.cc:2016
ulonglong last() const 1
Definition: handler0alter.h:89
Definition: table.h:1306
const ulonglong m_max_value
Maximum calumn value if adding an AUTOINC column else 0.
Definition: handler0alter.h:97
Generate the next autoinc based on a snapshot of the session auto_increment_increment and auto_increm...
Definition: handler0alter.h:61
byte rec_t
Definition: rem0types.h:39
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:711
void innobase_rec_to_mysql(struct TABLE *table, const rec_t *rec, const dict_index_t *index, const ulint *offsets)
Copies an InnoDB record to table->record[0].
Definition: handler0alter.cc:1973
bool eof() const 1
Check if the autoinc "sequence" is exhausted.
Definition: handler0alter.h:74
ulonglong operator++(int) 1
Postfix increment.
Definition: handler0alter.cc:10844
Structure for an SQL data field.
Definition: data0data.h:639
ib_sequence_t & operator=(const ib_sequence_t &in)
assignment operator to copy the sequence values
Definition: handler0alter.h:78
bool m_eof
true if no more values left in the sequence
Definition: handler0alter.h:109
#define ut_ad(EXPR)
Debug assertion.
Definition: ut0dbg.h:65
ulong m_increment
Value of auto_increment_increment.
Definition: handler0alter.h:100
ulonglong m_next_value
Next value in the sequence.
Definition: handler0alter.h:106
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:765
ib_sequence_t(THD *thd, ulonglong start_value, ulonglong max_value)
Definition: handler0alter.cc:10814
ulong m_offset
Value of auto_increment_offset.
Definition: handler0alter.h:103
Data structure for an index.
Definition: dict0mem.h:879