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
/* Read record that is identified by table->file->ref. */
125
125
(void) table->file->rnd_pos(table->record[1], table->file->ref);
126
126
/* Copy the newly read columns into the new record. */
127
127
for (field_p= table->field; (field= *field_p); field_p++)
128
if (unique_map.test(field->field_index))
128
if (bitmap_is_set(&unique_map, field->field_index))
129
129
field->copy_from_tmp(table->s->rec_buff_length);
211
211
if (table->timestamp_field)
213
213
// Don't set timestamp column if this is modified
214
if (table->write_set->test(table->timestamp_field->field_index))
214
if (table->timestamp_field->isWriteSet())
215
215
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
218
218
if (table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE ||
219
219
table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH)
220
table->write_set->set(table->timestamp_field->field_index);
220
table->setWriteSet(table->timestamp_field->field_index);
251
251
table->timestamp_field &&
252
252
(table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE ||
253
253
table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH))
254
*(table->read_set) |= *(table->write_set);
254
bitmap_union(table->read_set, table->write_set);
255
255
// Don't count on usage of 'only index' when calculating which key to use
256
256
table->covering_keys.reset();
483
483
can_compare_record= (!(table->file->ha_table_flags() &
484
484
HA_PARTIAL_COLUMN_READ) ||
485
((*table->read_set & *table->write_set) == *table->write_set));
485
bitmap_is_subset(table->write_set, table->read_set));
487
487
while (!(error=info.read_record(&info)) && !session->killed)
848
848
Table *table= tl->table;
849
849
/* Only set timestamp column if this is not modified */
850
if (table->timestamp_field &&
851
table->write_set->test(table->timestamp_field->field_index))
850
if (table->timestamp_field && table->timestamp_field->isWriteSet())
852
851
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
854
853
/* if table will be updated then check that it is unique */
1320
1319
bool can_compare_record;
1321
1320
can_compare_record= (!(table->file->ha_table_flags() &
1322
1321
HA_PARTIAL_COLUMN_READ) ||
1323
((*table->read_set & *table->write_set) == *table->write_set));
1322
bitmap_is_subset(table->write_set,
1324
1324
table->status|= STATUS_UPDATED;
1325
1325
table->storeRecord();
1326
1326
if (fill_record(session, *fields_for_table[offset],
1523
1523
can_compare_record= (!(table->file->ha_table_flags() &
1524
1524
HA_PARTIAL_COLUMN_READ) ||
1525
((*table->read_set & *table->write_set) == *table->write_set));
1525
bitmap_is_subset(table->write_set,