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

Method lookupCollation

src/jrd/intl.cpp:337–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337Collation* CharSetContainer::lookupCollation(thread_db* tdbb, USHORT tt_id)
338{
339 const USHORT id = TTYPE_TO_COLLATION(tt_id);
340
341 if (id < charset_collations.getCount() && charset_collations[id] != NULL)
342 {
343 if (!charset_collations[id]->obsolete)
344 return charset_collations[id];
345 }
346
347 CheckoutLockGuard guard(tdbb, createCollationMtx, FB_FUNCTION); // do we need it ?
348
349 Collation* to_delete = NULL;
350
351 if (id < charset_collations.getCount() && charset_collations[id] != NULL)
352 {
353 if (charset_collations[id]->obsolete)
354 {
355 // if obsolete collation is not used delete it immediately,
356 // else wait until all references are released
357 if (charset_collations[id]->useCount == 0)
358 {
359 charset_collations[id]->destroy(tdbb);
360 delete charset_collations[id];
361 }
362 else
363 to_delete = charset_collations[id];
364
365 charset_collations[id] = NULL;
366 }
367 else
368 return charset_collations[id];
369 }
370
371 SubtypeInfo info;
372 if (MET_get_char_coll_subtype_info(tdbb, tt_id, &info))
373 {
374 CharSet* charset = INTL_charset_lookup(tdbb, TTYPE_TO_CHARSET(tt_id));
375
376 if (TTYPE_TO_CHARSET(tt_id) != CS_METADATA)
377 {
378 Firebird::UCharBuffer specificAttributes;
379 ULONG size = info.specificAttributes.getCount() * charset->maxBytesPerChar();
380
381 size = INTL_convert_bytes(tdbb, TTYPE_TO_CHARSET(tt_id),
382 specificAttributes.getBuffer(size), size,
383 CS_METADATA, info.specificAttributes.begin(),
384 info.specificAttributes.getCount(), ERR_post);
385 specificAttributes.shrink(size);
386 info.specificAttributes = specificAttributes;
387 }
388
389 Attachment* const att = tdbb->getAttachment();
390 AutoPtr<texttype> tt(FB_NEW_POOL(*att->att_pool) texttype);
391 memset(tt, 0, sizeof(texttype));
392
393 lookup_texttype(tt, &info);
394

Callers 1

INTL_texttype_lookupFunction · 0.45

Calls 15

INTL_charset_lookupFunction · 0.85
INTL_convert_bytesFunction · 0.85
lookup_texttypeFunction · 0.85
LCK_lockFunction · 0.85
GdsClass · 0.85
NumClass · 0.85
isMultiByteMethod · 0.80
minBytesPerCharMethod · 0.80
ERR_postFunction · 0.70
getCountMethod · 0.45
destroyMethod · 0.45
maxBytesPerCharMethod · 0.45

Tested by

no test coverage detected