82
MY_BITMAP unique_map; /* Fields in offended unique. */
83
my_bitmap_map unique_map_buf[bitmap_buffer_size(MAX_FIELDS)];
85
bitset<MAX_FIELDS> unique_map; /* Fields in offended unique */
86
88
Only duplicate key errors print the key value.
100
102
/* Create unique_map with all fields used by that index. */
101
bitmap_init(&unique_map, unique_map_buf, table->s->fields, false);
102
103
table->mark_columns_used_by_index_no_reset(keynr, &unique_map);
104
105
/* Subtract read_set and write_set. */
105
bitmap_subtract(&unique_map, table->read_set);
106
bitmap_subtract(&unique_map, table->write_set);
106
unique_map &= table->read_set->flip();
107
unique_map &= table->write_set->flip();
108
table->read_set->flip();
109
table->write_set->flip();
109
112
If the unique index uses columns that are neither in read_set
110
113
nor in write_set, we must re-read the record.
111
114
Otherwise no need to do anything.
113
if (bitmap_is_clear_all(&unique_map))
116
if (unique_map.none())
116
119
/* Get identifier of last read record into table->file->ref. */
117
120
table->file->position(table->record[0]);
118
121
/* Add all fields used by unique index to read_set. */
119
bitmap_union(table->read_set, &unique_map);
122
*(table->read_set) |= unique_map;
120
123
/* Tell the engine about the new set. */
121
124
table->file->column_bitmaps_signal();
122
125
/* Read record that is identified by table->file->ref. */
123
126
(void) table->file->rnd_pos(table->record[1], table->file->ref);
124
127
/* Copy the newly read columns into the new record. */
125
128
for (field_p= table->field; (field= *field_p); field_p++)
126
if (bitmap_is_set(&unique_map, field->field_index))
129
if (unique_map.test(field->field_index))
127
130
field->copy_from_tmp(table->s->rec_buff_length);
209
212
if (table->timestamp_field)
211
214
// Don't set timestamp column if this is modified
212
if (bitmap_is_set(table->write_set,
213
table->timestamp_field->field_index))
215
if (table->write_set->test(table->timestamp_field->field_index))
214
216
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
217
219
if (table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE ||
218
220
table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH)
219
bitmap_set_bit(table->write_set,
220
table->timestamp_field->field_index);
221
table->write_set->set(table->timestamp_field->field_index);
251
252
table->timestamp_field &&
252
253
(table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE ||
253
254
table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH))
254
bitmap_union(table->read_set, table->write_set);
255
*(table->read_set) |= *(table->write_set);
255
256
// Don't count on usage of 'only index' when calculating which key to use
256
257
table->covering_keys.clear_all();
483
484
can_compare_record= (!(table->file->ha_table_flags() &
484
485
HA_PARTIAL_COLUMN_READ) ||
485
bitmap_is_subset(table->write_set, table->read_set));
486
((*table->read_set & *table->write_set) == *table->write_set));
487
488
while (!(error=info.read_record(&info)) && !session->killed)
848
849
Table *table= tl->table;
849
850
/* Only set timestamp column if this is not modified */
850
851
if (table->timestamp_field &&
851
bitmap_is_set(table->write_set,
852
table->timestamp_field->field_index))
852
table->write_set->test(table->timestamp_field->field_index))
853
853
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
855
855
/* if table will be updated then check that it is unique */
1322
1322
bool can_compare_record;
1323
1323
can_compare_record= (!(table->file->ha_table_flags() &
1324
1324
HA_PARTIAL_COLUMN_READ) ||
1325
bitmap_is_subset(table->write_set,
1325
((*table->read_set & *table->write_set) == *table->write_set));
1327
1326
table->status|= STATUS_UPDATED;
1328
1327
store_record(table,record[1]);
1329
1328
if (fill_record(session, *fields_for_table[offset],
1523
1522
can_compare_record= (!(table->file->ha_table_flags() &
1524
1523
HA_PARTIAL_COLUMN_READ) ||
1525
bitmap_is_subset(table->write_set,
1524
((*table->read_set & *table->write_set) == *table->write_set));