MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / validateLength

Method validateLength

src/jrd/cvt.cpp:505–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503
504
505ULONG EngineCallbacks::validateLength(CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start,
506 const USHORT size)
507{
508 fb_assert(charSet);
509
510 if (charSet && (charSet->isMultiByte() || length > size))
511 {
512 const ULONG srcCharLength = charSet->length(length, start, true);
513 const ULONG destCharLength = (ULONG) size / charSet->maxBytesPerChar();
514
515 if (srcCharLength > destCharLength)
516 {
517 const ULONG spaceByteLength = charSet->getSpaceLength();
518 const ULONG trimmedByteLength = charSet->removeTrailingSpaces(length, start);
519 const ULONG trimmedCharLength = srcCharLength - (length - trimmedByteLength) / spaceByteLength;
520
521 if (trimmedCharLength <= destCharLength)
522 return trimmedByteLength + (destCharLength - trimmedCharLength) * spaceByteLength;
523 else
524 {
525 err(Arg::Gds(isc_arith_except) << Arg::Gds(isc_string_truncation) <<
526 Arg::Gds(isc_trunc_limits) << Arg::Num(destCharLength) << Arg::Num(srcCharLength));
527 }
528 }
529 }
530
531 return length;
532}
533
534
535ULONG TruncateCallbacks::validateLength(CharSet* charSet, CHARSET_ID charSetId, ULONG length, const UCHAR* start,

Callers 2

executeMethod · 0.45
INTL_convert_stringFunction · 0.45

Calls 12

GdsClass · 0.85
NumClass · 0.85
ERR_post_warningFunction · 0.85
WarningClass · 0.85
isMultiByteMethod · 0.80
getSpaceLengthMethod · 0.80
removeTrailingSpacesMethod · 0.80
substringMethod · 0.80
lengthMethod · 0.45
maxBytesPerCharMethod · 0.45
getCapacityMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected