| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 2005, 2016, 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 as published by the Free Software |
| 7 | Foundation; version 2 of the License. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License along with |
| 14 | this program; if not, write to the Free Software Foundation, Inc., |
| 15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
| 16 | |
| 17 | *****************************************************************************/ |
| 18 | |
| 19 | /**************************************************//** |
| 20 | @file include/handler0alter.h |
| 21 | Smart ALTER TABLE |
| 22 | *******************************************************/ |
| 23 | |
| 24 | /*************************************************************//** |
| 25 | Copies an InnoDB record to table->record[0]. */ |
| 26 | void |
| 27 | innobase_rec_to_mysql( |
| 28 | /*==================*/ |
| 29 | struct TABLE* table, /*!< in/out: MySQL table */ |
| 30 | const rec_t* rec, /*!< in: record */ |
| 31 | const dict_index_t* index, /*!< in: index */ |
| 32 | const ulint* offsets)/*!< in: rec_get_offsets( |
| 33 | rec, index, ...) */ |
| 34 | MY_ATTRIBUTE((nonnull)); |
| 35 | |
| 36 | /*************************************************************//** |
| 37 | Copies an InnoDB index entry to table->record[0]. */ |
| 38 | void |
| 39 | innobase_fields_to_mysql( |
| 40 | /*=====================*/ |
| 41 | struct TABLE* table, /*!< in/out: MySQL table */ |
| 42 | const dict_index_t* index, /*!< in: InnoDB index */ |
| 43 | const dfield_t* fields) /*!< in: InnoDB index fields */ |
| 44 | MY_ATTRIBUTE((nonnull)); |
| 45 | |
| 46 | /*************************************************************//** |
| 47 | Copies an InnoDB row to table->record[0]. */ |
| 48 | void |
| 49 | innobase_row_to_mysql( |
| 50 | /*==================*/ |
| 51 | struct TABLE* table, /*!< in/out: MySQL table */ |
| 52 | const dict_table_t* itab, /*!< in: InnoDB table */ |
| 53 | const dtuple_t* row) /*!< in: InnoDB row */ |
| 54 | MY_ATTRIBUTE((nonnull)); |
| 55 | |
| 56 | /** Generate the next autoinc based on a snapshot of the session |
| 57 | auto_increment_increment and auto_increment_offset variables. */ |
| 58 | struct ib_sequence_t { |
| 59 | |
| 60 | /** |
| 61 | @param thd the session |
| 62 | @param start_value the lower bound |
| 63 | @param max_value the upper bound (inclusive) */ |
| 64 | ib_sequence_t(THD* thd, ulonglong start_value, ulonglong max_value); |
| 65 | |
| 66 | /** Postfix increment |
| 67 | @return the value to insert */ |
| 68 | ulonglong operator++(int) UNIV_NOTHROW; |
| 69 | |
| 70 | /** Check if the autoinc "sequence" is exhausted. |
| 71 | @return true if the sequence is exhausted */ |
| 72 | bool eof() const UNIV_NOTHROW |
| 73 | { |
| 74 | return(m_eof); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | @return the next value in the sequence */ |
| 79 | ulonglong last() const UNIV_NOTHROW |
| 80 | { |
| 81 | ut_ad(m_next_value > 0); |
| 82 | |
| 83 | return(m_next_value); |
| 84 | } |
| 85 | |
| 86 | /** Maximum calumn value if adding an AUTOINC column else 0. Once |
| 87 | we reach the end of the sequence it will be set to ~0. */ |
| 88 | const ulonglong m_max_value; |
| 89 | |
| 90 | /** Value of auto_increment_increment */ |
| 91 | ulong m_increment; |
| 92 | |
| 93 | /** Value of auto_increment_offset */ |
| 94 | ulong m_offset; |
| 95 | |
| 96 | /** Next value in the sequence */ |
| 97 | ulonglong m_next_value; |
| 98 | |
| 99 | /** true if no more values left in the sequence */ |
| 100 | bool m_eof; |
| 101 | }; |
| 102 | |