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

Function print_key

src/jrd/btr.cpp:6460–6521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6458
6459
6460string print_key(thread_db* tdbb, jrd_rel* relation, index_desc* idx, Record* record)
6461{
6462/**************************************
6463 *
6464 * p r i n t _ k e y
6465 *
6466 **************************************
6467 *
6468 * Functional description
6469 * Convert index key into textual representation.
6470 *
6471 **************************************/
6472 fb_assert(relation && idx && record);
6473
6474 if (!(relation->rel_flags & REL_scanned) ||
6475 (relation->rel_flags & REL_being_scanned))
6476 {
6477 MET_scan_relation(tdbb, relation);
6478 }
6479
6480 const FB_SIZE_T MAX_KEY_STRING_LEN = 250;
6481 string key, value;
6482
6483 try
6484 {
6485 if (idx->idx_flags & idx_expression)
6486 {
6487 const auto desc = BTR_eval_expression(tdbb, idx, record);
6488 value = DescPrinter(tdbb, desc, MAX_KEY_STRING_LEN, CS_METADATA).get();
6489 key += "<expression> = " + value;
6490 }
6491 else
6492 {
6493 for (USHORT i = 0; i < idx->idx_count; i++)
6494 {
6495 const USHORT field_id = idx->idx_rpt[i].idx_field;
6496 const jrd_fld* const field = MET_get_field(relation, field_id);
6497
6498 if (field)
6499 value.printf("\"%s\"", field->fld_name.c_str());
6500 else
6501 value.printf("<field #%d>", field_id);
6502
6503 key += value;
6504
6505 dsc desc;
6506 const bool notNull = EVL_field(relation, record, field_id, &desc);
6507 value = DescPrinter(tdbb, notNull ? &desc : NULL, MAX_KEY_STRING_LEN, CS_METADATA).get();
6508 key += " = " + value;
6509
6510 if (i < idx->idx_count - 1)
6511 key += ", ";
6512 }
6513 }
6514 }
6515 catch (const Exception&)
6516 {
6517 return "";

Callers 1

raiseMethod · 0.85

Calls 6

BTR_eval_expressionFunction · 0.85
DescPrinterClass · 0.85
EVL_fieldFunction · 0.85
getMethod · 0.45
printfMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected