MCPcopy Create free account
hub / github.com/MariaDB/server / calc_group_buffer

Function calc_group_buffer

sql/sql_select.cc:29455–29531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29453*/
29454
29455void calc_group_buffer(TMP_TABLE_PARAM *param, ORDER *group)
29456{
29457 uint key_length=0, parts=0, null_parts=0;
29458
29459 for (; group ; group=group->next)
29460 {
29461 Item *group_item= *group->item;
29462 Field *field= group_item->get_tmp_table_field();
29463 if (field)
29464 {
29465 enum_field_types type;
29466 if ((type= field->type()) == MYSQL_TYPE_BLOB)
29467 key_length+=MAX_BLOB_WIDTH; // Can't be used as a key
29468 else if (type == MYSQL_TYPE_VARCHAR || type == MYSQL_TYPE_VAR_STRING)
29469 key_length+= field->field_length + HA_KEY_BLOB_LENGTH;
29470 else if (type == MYSQL_TYPE_BIT)
29471 {
29472 /* Bit is usually stored as a longlong key for group fields */
29473 key_length+= 8; // Big enough
29474 }
29475 else
29476 key_length+= field->pack_length();
29477 }
29478 else
29479 {
29480 switch (group_item->cmp_type()) {
29481 case REAL_RESULT:
29482 key_length+= sizeof(double);
29483 break;
29484 case INT_RESULT:
29485 key_length+= sizeof(longlong);
29486 break;
29487 case DECIMAL_RESULT:
29488 key_length+= my_decimal_get_binary_size(group_item->max_length -
29489 (group_item->decimals ? 1 : 0),
29490 group_item->decimals);
29491 break;
29492 case TIME_RESULT:
29493 {
29494 /*
29495 As items represented as DATE/TIME fields in the group buffer
29496 have STRING_RESULT result type, we increase the length
29497 by 8 as maximum pack length of such fields.
29498 */
29499 key_length+= 8;
29500 break;
29501 }
29502 case STRING_RESULT:
29503 {
29504 enum enum_field_types type= group_item->field_type();
29505 if (type == MYSQL_TYPE_BLOB)
29506 key_length+= MAX_BLOB_WIDTH; // Can't be used as a key
29507 else
29508 {
29509 /*
29510 Group strings are taken as varstrings and require an length field.
29511 A field is not yet created by create_tmp_field_ex()
29512 and the sizes should match up.

Callers 4

initialize_tablesMethod · 0.85
optimize_stage2Method · 0.85
make_aggr_tables_infoMethod · 0.85
initialize_tablesMethod · 0.85

Calls 8

my_errorFunction · 0.85
get_tmp_table_fieldMethod · 0.45
typeMethod · 0.45
pack_lengthMethod · 0.45
cmp_typeMethod · 0.45
field_typeMethod · 0.45
maybe_nullMethod · 0.45

Tested by

no test coverage detected