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

Method makeSubstr

src/jrd/DataTypeUtil.cpp:287–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285
286
287void DataTypeUtilBase::makeSubstr(dsc* result, const dsc* value, const dsc* offset, const dsc* length)
288{
289 result->clear();
290
291 if (value->isNull())
292 {
293 result->makeNullString();
294 return;
295 }
296
297 if (value->isBlob())
298 {
299 result->dsc_dtype = dtype_blob;
300 result->dsc_length = sizeof(ISC_QUAD);
301 result->setBlobSubType(value->getBlobSubType());
302 }
303 else
304 {
305 // Beware that JRD treats substring() always as returning CHAR
306 // instead of VARCHAR for historical reasons.
307 result->dsc_dtype = dtype_varying;
308 }
309
310 result->setTextType(value->isText() || value->isBlob() ? value->getTextType() : CS_ASCII);
311 result->setNullable(value->isNullable() ||
312 (offset && offset->isNullable()) ||
313 (length && length->isNullable()));
314
315 if (result->isText())
316 {
317 ULONG len = convertLength(value, result);
318
319 if (length && length->dsc_address) // constant
320 {
321 SLONG constant = CVT_get_long(length, 0, JRD_get_thread_data()->getAttachment()->att_dec_status, ERR_post);
322 fb_assert(constant >= 0);
323 len = MIN(len, MIN(MAX_STR_SIZE, ULONG(constant)) * maxBytesPerChar(result->getCharSet()));
324 }
325
326 result->dsc_length = fixLength(result, len) + static_cast<USHORT>(sizeof(USHORT));
327 }
328}
329
330
331bool DataTypeUtilBase::makeBlobOrText(dsc* result, const dsc* arg, bool force)

Callers 3

makeMethod · 0.80
getDescMethod · 0.80
performMethod · 0.80

Calls 15

CVT_get_longFunction · 0.85
JRD_get_thread_dataFunction · 0.85
ULONGEnum · 0.85
makeNullStringMethod · 0.80
isBlobMethod · 0.80
setBlobSubTypeMethod · 0.80
getBlobSubTypeMethod · 0.80
setTextTypeMethod · 0.80
isTextMethod · 0.80
getTextTypeMethod · 0.80
setNullableMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected