1 /* 2 Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 #ifndef NDB_EVENT_DATA_H 26 #define NDB_EVENT_DATA_H 27 28 #include "my_alloc.h" // MEM_ROOT 29 #include "storage/ndb/plugin/ndb_bitmap.h" 30 31 namespace dd { 32 class Table; 33 } 34 35 struct NDB_SHARE; 36 struct TABLE; 37 union NdbValue; 38 39 /* 40 Ndb_event_data holds information related to 41 receiving events from NDB. It's created when 42 the table is setup for binlogging or schema 43 distribution. 44 */ 45 46 class Ndb_event_data { 47 Ndb_event_data() = delete; 48 Ndb_event_data(const Ndb_event_data &) = delete; 49 50 Ndb_event_data(NDB_SHARE *the_share, size_t num_columns); 51 ~Ndb_event_data(); 52 53 void init_stored_columns(); 54 void init_pk_bitmap(); 55 TABLE *open_shadow_table(class THD *thd, const char *db, 56 const char *table_name, const char *key, 57 const dd::Table *table_def, class THD *owner_thd); 58 59 public: 60 MEM_ROOT mem_root; 61 TABLE *shadow_table; 62 NDB_SHARE *share; 63 NdbValue *ndb_value[2]; 64 65 // Bitmap with all stored columns 66 MY_BITMAP stored_columns; 67 /* Bitmap with all primary key columns. */ 68 MY_BITMAP pk_bitmap; 69 // The NDB table have blobs 70 bool have_blobs; 71 72 void generate_minimal_bitmap(MY_BITMAP *before, MY_BITMAP *after) const; 73 74 // Factory function to create Ndb_event_data, open the shadow_table and 75 // initialize bitmaps. 76 static Ndb_event_data *create_event_data( 77 class THD *thd, NDB_SHARE *share, const char *db, const char *table_name, 78 const char *key, class THD *owner_thd, const dd::Table *table_def); 79 static void destroy(const Ndb_event_data *); 80 81 // Read uint32 value directly from NdbRecAttr in received event 82 uint32 unpack_uint32(unsigned attr_id) const; 83 // Read string value directly from NdbRecAttr in received event 84 const char *unpack_string(unsigned attr_id) const; 85 }; 86 87 #endif 88