258
/* Adjust number to next larger disk buffer */
260
ulong next_io_size(register ulong pos)
262
register ulong offset;
263
if ((offset= pos & (IO_SIZE-1)))
264
return pos-offset+IO_SIZE;
252
270
Store an SQL quoted string.
336
354
bool check_db_name(Session *session, SchemaIdentifier &schema_identifier)
338
if (not plugin::Authorization::isAuthorized(session->user(), schema_identifier))
356
if (not plugin::Authorization::isAuthorized(session->getSecurityContext(), schema_identifier))
521
539
We must set bit in read set as update_auto_increment() is using the
522
540
store() to check overflow of auto_increment values
524
setReadSet(found_next_number_field->position());
525
setWriteSet(found_next_number_field->position());
542
setReadSet(found_next_number_field->field_index);
543
setWriteSet(found_next_number_field->field_index);
526
544
if (getShare()->next_number_keypart)
527
545
mark_columns_used_by_index_no_reset(getShare()->next_number_index);
621
639
/* Merge keys is all keys that had a column refered to in the query */
622
640
if (is_overlapping(merge_keys, (*reg_field)->part_of_key))
623
setReadSet((*reg_field)->position());
641
setReadSet((*reg_field)->field_index);
773
791
create_tmp_table(Session *session,Tmp_Table_Param *param,List<Item> &fields,
774
Order *group, bool distinct, bool save_sum_fields,
792
order_st *group, bool distinct, bool save_sum_fields,
775
793
uint64_t select_options, ha_rows rows_limit,
776
794
const char *table_alias)
1012
1030
group_null_items++;
1013
1031
new_field->flags|= GROUP_FLAG;
1015
new_field->setPosition(fieldnr++);
1033
new_field->field_index= fieldnr++;
1016
1034
*(reg_field++)= new_field;
1018
1036
if (!--hidden_field_count)
1238
1256
keyinfo->rec_per_key= 0;
1239
1257
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
1240
1258
keyinfo->name= (char*) "group_key";
1241
Order *cur_group= group;
1259
order_st *cur_group= group;
1242
1260
for (; cur_group ; cur_group= cur_group->next, key_part_info++)
1244
1262
Field *field=(*cur_group->item)->get_tmp_table_field();
1476
True if the table's input and output record buffers are comparable using
1477
compare_records(TABLE*).
1479
bool Table::records_are_comparable()
1481
return ((getEngine()->check_flag(HTON_BIT_PARTIAL_COLUMN_READ) == 0) ||
1482
write_set->is_subset_of(*read_set));
1486
Compares the input and outbut record buffers of the table to see if a row
1487
has changed. The algorithm iterates over updated columns and if they are
1488
nullable compares NULL bits in the buffer before comparing actual
1489
data. Special care must be taken to compare only the relevant NULL bits and
1490
mask out all others as they may be undefined. The storage engine will not
1491
and should not touch them.
1493
@param table The table to evaluate.
1495
@return true if row has changed.
1496
@return false otherwise.
1498
bool Table::compare_records()
1500
if (getEngine()->check_flag(HTON_BIT_PARTIAL_COLUMN_READ) != 0)
1503
Storage engine may not have read all columns of the record. Fields
1504
(including NULL bits) not in the write_set may not have been read and
1505
can therefore not be compared.
1507
for (Field **ptr= this->field ; *ptr != NULL; ptr++)
1510
if (write_set->test(f->position()))
1512
if (f->real_maybe_null())
1514
unsigned char null_byte_index= f->null_ptr - record[0];
1516
if (((record[0][null_byte_index]) & f->null_bit) !=
1517
((record[1][null_byte_index]) & f->null_bit))
1520
if (f->cmp_binary_offset(getShare()->rec_buff_length))
1528
The storage engine has read all columns, so it's safe to compare all bits
1529
including those not in the write_set. This is cheaper than the
1530
field-by-field comparison done above.
1493
/* Return false if row hasn't changed */
1495
bool Table::compare_record()
1532
1497
if (not getShare()->blob_fields + getShare()->hasVariableWidth())
1533
// Fixed-size record: do bitwise comparison of the records
1534
1498
return memcmp(this->getInsertRecord(), this->getUpdateRecord(), (size_t) getShare()->getRecordLength());
1536
1500
/* Compare null bits */
1537
1501
if (memcmp(null_flags, null_flags + getShare()->rec_buff_length, getShare()->null_bytes))
1538
1502
return true; /* Diff in NULL value */
1540
1504
/* Compare updated fields */
1541
1505
for (Field **ptr= field ; *ptr ; ptr++)
1543
if (isWriteSet((*ptr)->position()) &&
1507
if (isWriteSet((*ptr)->field_index) &&
1544
1508
(*ptr)->cmp_binary_offset(getShare()->rec_buff_length))
1735
void Table::filesort_free_buffers(bool full)
1737
if (sort.record_pointers)
1739
free((unsigned char*) sort.record_pointers);
1740
sort.record_pointers=0;
1744
if (sort.sort_keys )
1746
if ((unsigned char*) sort.sort_keys)
1747
free((unsigned char*) sort.sort_keys);
1752
if ((unsigned char*) sort.buffpek)
1753
free((unsigned char*) sort.buffpek);
1755
sort.buffpek_len= 0;
1761
free((char *) sort.addon_buf);
1762
free((char *) sort.addon_field);
1768
1698
} /* namespace drizzled */