"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/jrd/btr.cpp" between
Firebird-3.0.2.32703-0.tar.bz2 and Firebird-3.0.4.33054-0.tar.bz2

About: Firebird is a relational database offering many ANSI SQL standard features.

btr.cpp  (Firebird-3.0.2.32703-0.tar.bz2):btr.cpp  (Firebird-3.0.4.33054-0.tar.bz2)
skipping to change at line 1990 skipping to change at line 1990
if (!root) { if (!root) {
return; return;
} }
ULONG page; ULONG page;
if (id >= root->irt_count || !(page = root->irt_rpt[id].getRoot())) if (id >= root->irt_count || !(page = root->irt_rpt[id].getRoot()))
{ {
CCH_RELEASE(tdbb, &window); CCH_RELEASE(tdbb, &window);
return; return;
} }
const bool descending = (root->irt_rpt[id].irt_flags & irt_descending);
const ULONG segments = root->irt_rpt[id].irt_keys;
window.win_flags = WIN_large_scan; window.win_flags = WIN_large_scan;
window.win_scans = 1; window.win_scans = 1;
btree_page* bucket = (btree_page*) CCH_HANDOFF(tdbb, &window, page, LCK_r ead, pag_index); btree_page* bucket = (btree_page*) CCH_HANDOFF(tdbb, &window, page, LCK_r ead, pag_index);
// go down the left side of the index to leaf level // go down the left side of the index to leaf level
UCHAR* pointer = bucket->btr_nodes + bucket->btr_jump_size; UCHAR* pointer = bucket->btr_nodes + bucket->btr_jump_size;
while (bucket->btr_level) while (bucket->btr_level)
{ {
IndexNode pageNode; IndexNode pageNode;
pageNode.readNode(pointer, false); pageNode.readNode(pointer, false);
skipping to change at line 2012 skipping to change at line 2016
page = pageNode.pageNumber; page = pageNode.pageNumber;
} }
FB_UINT64 nodes = 0; FB_UINT64 nodes = 0;
FB_UINT64 duplicates = 0; FB_UINT64 duplicates = 0;
temporary_key key; temporary_key key;
key.key_flags = 0; key.key_flags = 0;
key.key_length = 0; key.key_length = 0;
SSHORT l; SSHORT l;
bool firstNode = true; bool firstNode = true;
const bool descending = (root->irt_rpt[id].irt_flags & irt_descending);
const ULONG segments = root->irt_rpt[id].irt_keys;
// SSHORT count, stuff_count, pos, i; // SSHORT count, stuff_count, pos, i;
Firebird::HalfStaticArray<FB_UINT64, 4> duplicatesList; Firebird::HalfStaticArray<FB_UINT64, 4> duplicatesList;
duplicatesList.grow(segments); duplicatesList.grow(segments);
memset(duplicatesList.begin(), 0, segments * sizeof(FB_UINT64)); memset(duplicatesList.begin(), 0, segments * sizeof(FB_UINT64));
//const Database* dbb = tdbb->getDatabase(); //const Database* dbb = tdbb->getDatabase();
// go through all the leaf nodes and count them; // go through all the leaf nodes and count them;
// also count how many of them are duplicates // also count how many of them are duplicates
skipping to change at line 5927 skipping to change at line 5929
* *
**************************************/ **************************************/
fb_assert(relation && idx && record); fb_assert(relation && idx && record);
if (!(relation->rel_flags & REL_scanned) || if (!(relation->rel_flags & REL_scanned) ||
(relation->rel_flags & REL_being_scanned)) (relation->rel_flags & REL_being_scanned))
{ {
MET_scan_relation(tdbb, relation); MET_scan_relation(tdbb, relation);
} }
class Printer const int MAX_KEY_STRING_LEN = 250;
{
public:
explicit Printer(thread_db* tdbb, const dsc* desc)
{
const int MAX_KEY_STRING_LEN = 250;
const char* const NULL_KEY_STRING = "NULL";
if (!desc)
{
value = NULL_KEY_STRING;
return;
}
fb_assert(!desc->isBlob());
value = MOV_make_string2(tdbb, desc, ttype_dynamic);
const int len = (int) value.length();
const char* const str = value.c_str();
if (desc->isText() || desc->isDateTime())
{
if (desc->dsc_dtype == dtype_text)
{
const char* const pad = (desc->dsc_sub_ty
pe == ttype_binary) ? "\0": " ";
value.rtrim(pad);
}
if (desc->isText() && desc->getTextType() == ttyp
e_binary)
{
string hex;
char* s = hex.getBuffer(2 * len);
for (int i = 0; i < len; i++)
{
sprintf(s, "%02X", (int) (unsigne
d char) str[i]);
s += 2;
}
value = "x'" + hex + "'";
}
else
{
value = "'" + value + "'";
}
}
if (value.length() > MAX_KEY_STRING_LEN)
{
fb_assert(desc->isText());
value.resize(MAX_KEY_STRING_LEN);
const CharSet* const cs = INTL_charset_lookup(tdb
b, desc->getCharSet());
while (value.hasData() && !cs->wellFormed(value.l
ength(), (const UCHAR*) value.c_str()))
value.resize(value.length() - 1);
value += "...";
}
}
const string& get() const
{
return value;
}
private:
string value;
};
string key, value; string key, value;
try try
{ {
if (idx->idx_flags & idx_expressn) if (idx->idx_flags & idx_expressn)
{ {
bool notNull = false; bool notNull = false;
const dsc* const desc = BTR_eval_expression(tdbb, idx, re cord, notNull); const dsc* const desc = BTR_eval_expression(tdbb, idx, re cord, notNull);
value = Printer(tdbb, notNull ? desc : NULL).get(); value = DescPrinter(tdbb, notNull ? desc : NULL, MAX_KEY_ STRING_LEN).get();
key += "<expression> = " + value; key += "<expression> = " + value;
} }
else else
{ {
for (USHORT i = 0; i < idx->idx_count; i++) for (USHORT i = 0; i < idx->idx_count; i++)
{ {
const USHORT field_id = idx->idx_rpt[i].idx_field ; const USHORT field_id = idx->idx_rpt[i].idx_field ;
const jrd_fld* const field = MET_get_field(relati on, field_id); const jrd_fld* const field = MET_get_field(relati on, field_id);
if (field) if (field)
value.printf("\"%s\"", field->fld_name.c_ str()); value.printf("\"%s\"", field->fld_name.c_ str());
else else
value.printf("<field #%d>", field_id); value.printf("<field #%d>", field_id);
key += value; key += value;
dsc desc; dsc desc;
const bool notNull = EVL_field(relation, record, field_id, &desc); const bool notNull = EVL_field(relation, record, field_id, &desc);
value = Printer(tdbb, notNull ? &desc : NULL).get (); value = DescPrinter(tdbb, notNull ? &desc : NULL, MAX_KEY_STRING_LEN).get();
key += " = " + value; key += " = " + value;
if (i < idx->idx_count - 1) if (i < idx->idx_count - 1)
key += ", "; key += ", ";
} }
} }
} }
catch (const Exception&) catch (const Exception&)
{ {
return ""; return "";
 End of changes. 5 change blocks. 
79 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)