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

Function do_cut_string_complex

sql/field_conv.cc:502–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500*/
501
502static void do_cut_string_complex(const Copy_field *copy)
503{ // Shorter string field
504 CHARSET_INFO *cs= copy->from_field->charset();
505 const uchar *from_end= copy->from_ptr + copy->from_length;
506 Well_formed_prefix prefix(cs,
507 (char*) copy->from_ptr,
508 (char*) from_end,
509 copy->to_length / cs->mbmaxlen);
510 size_t copy_length= prefix.length();
511 if (copy->to_length < copy_length)
512 copy_length= copy->to_length;
513 memcpy(copy->to_ptr, copy->from_ptr, copy_length);
514
515 /* Check if we lost any important characters */
516 if (unlikely(prefix.well_formed_error_pos() ||
517 cs->scan((char*) copy->from_ptr + copy_length,
518 (char*) from_end,
519 MY_SEQ_SPACES) <
520 (copy->from_length - copy_length)))
521 {
522 copy->to_field->set_warning(Sql_condition::WARN_LEVEL_WARN,
523 WARN_DATA_TRUNCATED, 1);
524 }
525
526 if (copy_length < copy->to_length)
527 cs->fill((char*) copy->to_ptr + copy_length,
528 copy->to_length - copy_length, ' ');
529}
530
531
532

Callers

nothing calls this directly

Calls 6

well_formed_error_posMethod · 0.80
charsetMethod · 0.45
lengthMethod · 0.45
scanMethod · 0.45
set_warningMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected