86
bitset<MAX_FIELDS> unique_map; /* Fields in offended unique */
86
MY_BITMAP unique_map; /* Fields in offended unique. */
87
my_bitmap_map unique_map_buf[bitmap_buffer_size(MAX_FIELDS)];
89
90
Only duplicate key errors print the key value.
103
104
/* Create unique_map with all fields used by that index. */
105
bitmap_init(&unique_map, unique_map_buf, table->s->fields, false);
104
106
table->mark_columns_used_by_index_no_reset(keynr, &unique_map);
106
108
/* Subtract read_set and write_set. */
107
unique_map &= table->read_set->flip();
108
unique_map &= table->write_set->flip();
109
table->read_set->flip();
110
table->write_set->flip();
109
bitmap_subtract(&unique_map, table->read_set);
110
bitmap_subtract(&unique_map, table->write_set);
113
113
If the unique index uses columns that are neither in read_set
114
114
nor in write_set, we must re-read the record.
115
115
Otherwise no need to do anything.
117
if (unique_map.none())
117
if (bitmap_is_clear_all(&unique_map))
120
120
/* Get identifier of last read record into table->file->ref. */
121
121
table->file->position(table->record[0]);
122
122
/* Add all fields used by unique index to read_set. */
123
*(table->read_set) |= unique_map;
123
bitmap_union(table->read_set, &unique_map);
124
124
/* Tell the engine about the new set. */
125
125
table->file->column_bitmaps_signal();
126
126
/* Read record that is identified by table->file->ref. */
127
127
(void) table->file->rnd_pos(table->record[1], table->file->ref);
128
128
/* Copy the newly read columns into the new record. */
129
129
for (field_p= table->field; (field= *field_p); field_p++)
130
if (unique_map.test(field->field_index))
130
if (bitmap_is_set(&unique_map, field->field_index))
131
131
field->copy_from_tmp(table->s->rec_buff_length);
213
213
if (table->timestamp_field)
215
215
// Don't set timestamp column if this is modified
216
if (table->write_set->test(table->timestamp_field->field_index))
216
if (bitmap_is_set(table->write_set,
217
table->timestamp_field->field_index))
217
218
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
220
221
if (table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE ||
221
222
table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH)
222
table->write_set->set(table->timestamp_field->field_index);
223
bitmap_set_bit(table->write_set,
224
table->timestamp_field->field_index);
253
255
table->timestamp_field &&
254
256
(table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE ||
255
257
table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH))
256
*(table->read_set) |= *(table->write_set);
258
bitmap_union(table->read_set, table->write_set);
257
259
// Don't count on usage of 'only index' when calculating which key to use
258
260
table->covering_keys.clear_all();
485
487
can_compare_record= (!(table->file->ha_table_flags() &
486
488
HA_PARTIAL_COLUMN_READ) ||
487
isBitmapSubset(table->write_set, table->read_set));
489
bitmap_is_subset(table->write_set, table->read_set));
489
491
while (!(error=info.read_record(&info)) && !session->killed)
850
852
Table *table= tl->table;
851
853
/* Only set timestamp column if this is not modified */
852
854
if (table->timestamp_field &&
853
table->write_set->test(table->timestamp_field->field_index))
855
bitmap_is_set(table->write_set,
856
table->timestamp_field->field_index))
854
857
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
856
859
/* if table will be updated then check that it is unique */
1322
1325
bool can_compare_record;
1323
1326
can_compare_record= (!(table->file->ha_table_flags() &
1324
1327
HA_PARTIAL_COLUMN_READ) ||
1325
isBitmapSubset(table->write_set,
1328
bitmap_is_subset(table->write_set,
1327
1330
table->status|= STATUS_UPDATED;
1328
1331
table->storeRecord();
1329
1332
if (fill_record(session, *fields_for_table[offset],
1526
1529
can_compare_record= (!(table->file->ha_table_flags() &
1527
1530
HA_PARTIAL_COLUMN_READ) ||
1528
isBitmapSubset(table->write_set,
1531
bitmap_is_subset(table->write_set,