@@ -100,7 +100,6 @@ TableCollection::TableCollection(const std::vector<QEP_TAB *> &tables)
100
100
m_has_blob_column(false ) {
101
101
for (QEP_TAB *qep_tab : tables) {
102
102
m_tables_bitmap |= qep_tab->table_ref ->map ();
103
- m_ref_and_null_bytes_size += qep_tab->table ()->s ->null_bytes ;
104
103
105
104
// When constructing the iterator tree, we might end up adding a
106
105
// WeedoutIterator _after_ a HashJoinIterator has been constructed.
@@ -128,6 +127,12 @@ TableCollection::TableCollection(const std::vector<QEP_TAB *> &tables)
128
127
}
129
128
}
130
129
}
130
+
131
+ if (qep_tab->used_null_fields || qep_tab->used_uneven_bit_fields ) {
132
+ m_ref_and_null_bytes_size += qep_tab->table ()->s ->null_bytes ;
133
+ table.copy_null_flags = true ;
134
+ }
135
+
131
136
m_tables.push_back (table);
132
137
}
133
138
}
@@ -216,7 +221,7 @@ size_t ComputeRowSizeUpperBound(const TableCollection &tables) {
216
221
return total_size;
217
222
}
218
223
219
- static bool keep_current_rowid (QEP_TAB *qep_tab) {
224
+ static bool KeepCurrentRowId (QEP_TAB *qep_tab) {
220
225
return qep_tab->keep_current_rowid &&
221
226
(qep_tab->copy_current_rowid == nullptr ||
222
227
qep_tab->copy_current_rowid ->buffer_is_bound ());
@@ -242,8 +247,10 @@ bool StoreFromTableBuffers(const TableCollection &tables, String *buffer) {
242
247
const TABLE *table = tbl.qep_tab ->table ();
243
248
244
249
// Store the NULL flags.
245
- memcpy (dptr, table->null_flags , table->s ->null_bytes );
246
- dptr += table->s ->null_bytes ;
250
+ if (tbl.copy_null_flags ) {
251
+ memcpy (dptr, table->null_flags , table->s ->null_bytes );
252
+ dptr += table->s ->null_bytes ;
253
+ }
247
254
248
255
if (tbl.qep_tab ->table ()->is_nullable ()) {
249
256
const size_t null_row_size = sizeof (tbl.qep_tab ->table ()->null_row );
@@ -252,7 +259,7 @@ bool StoreFromTableBuffers(const TableCollection &tables, String *buffer) {
252
259
dptr += null_row_size;
253
260
}
254
261
255
- if (keep_current_rowid (tbl.qep_tab )) {
262
+ if (KeepCurrentRowId (tbl.qep_tab )) {
256
263
// Store the row ID, since it is needed by weedout.
257
264
memcpy (dptr, table->file ->ref , table->file ->ref_length );
258
265
dptr += table->file ->ref_length ;
@@ -284,7 +291,7 @@ void LoadIntoTableBuffers(const TableCollection &tables, BufferRow row) {
284
291
for (const Table &tbl : tables.tables ()) {
285
292
TABLE *table = tbl.qep_tab ->table ();
286
293
287
- if (table-> s -> null_bytes > 0 ) {
294
+ if (tbl. copy_null_flags ) {
288
295
memcpy (table->null_flags , ptr, table->s ->null_bytes );
289
296
ptr += table->s ->null_bytes ;
290
297
}
@@ -296,7 +303,7 @@ void LoadIntoTableBuffers(const TableCollection &tables, BufferRow row) {
296
303
ptr += null_row_size;
297
304
}
298
305
299
- if (keep_current_rowid (tbl.qep_tab )) {
306
+ if (KeepCurrentRowId (tbl.qep_tab )) {
300
307
memcpy (table->file ->ref , ptr, table->file ->ref_length );
301
308
ptr += table->file ->ref_length ;
302
309
table->ref_is_set_without_position_call = true ;
0 commit comments