| 285 | |
| 286 | |
| 287 | void 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 | |
| 331 | bool DataTypeUtilBase::makeBlobOrText(dsc* result, const dsc* arg, bool force) |
no test coverage detected