Skip to content

Commit

Permalink
Backported fix for CORE-1997 - Broken foreign key handling for multi-…
Browse files Browse the repository at this point in the history
…segmented index using multi-level collations.
  • Loading branch information
asfernandes committed Feb 27, 2012
1 parent 850683a commit d16fad4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/jrd/btr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ void BTR_insert(thread_db* tdbb, WIN* root_window, index_insertion* insertion)


idx_e BTR_key(thread_db* tdbb, jrd_rel* relation, Record* record, index_desc* idx,
temporary_key* key, idx_null_state* null_state, const bool fuzzy)
temporary_key* key, idx_null_state* null_state, const bool fuzzy, USHORT count)
{
/**************************************
*
Expand Down Expand Up @@ -1249,7 +1249,7 @@ idx_e BTR_key(thread_db* tdbb, jrd_rel* relation, Record* record, index_desc* id
UCHAR* p = key->key_data;
SSHORT stuff_count = 0;
temp.key_flags |= key_empty;
for (USHORT n = 0; n < idx->idx_count; n++, tail++)
for (USHORT n = 0; n < count; n++, tail++)
{
for (; stuff_count; --stuff_count) {
*p++ = 0;
Expand Down Expand Up @@ -1334,6 +1334,12 @@ idx_e BTR_key(thread_db* tdbb, jrd_rel* relation, Record* record, index_desc* id
}
}

idx_e BTR_key(thread_db* tdbb, jrd_rel* relation, Record* record, index_desc* idx,
temporary_key* key, idx_null_state* null_state, const bool fuzzy)
{
return BTR_key(tdbb, relation, record, idx, key, null_state, fuzzy, idx->idx_count);
}


USHORT BTR_key_length(thread_db* tdbb, jrd_rel* relation, index_desc* idx)
{
Expand Down
2 changes: 2 additions & 0 deletions src/jrd/btr_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Ods::btree_page* BTR_find_page(Jrd::thread_db*, Jrd::IndexRetrieval*, Jrd::win*,
Jrd::temporary_key*, Jrd::temporary_key*);
#endif
void BTR_insert(Jrd::thread_db*, Jrd::win*, Jrd::index_insertion*);
Jrd::idx_e BTR_key(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::Record*, Jrd::index_desc*, Jrd::temporary_key*,
Jrd::idx_null_state*, const bool, USHORT);
Jrd::idx_e BTR_key(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::Record*, Jrd::index_desc*, Jrd::temporary_key*,
Jrd::idx_null_state*, const bool);
USHORT BTR_key_length(Jrd::thread_db*, Jrd::jrd_rel*, Jrd::index_desc*);
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/idx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ static idx_e check_partner_index(thread_db* tdbb,
// tmpIndex.idx_flags |= idx_unique;
tmpIndex.idx_flags = (tmpIndex.idx_flags & ~idx_unique) | (partner_idx.idx_flags & idx_unique);
temporary_key key;
result = BTR_key(tdbb, relation, record, &tmpIndex, &key, 0, starting);
result = BTR_key(tdbb, relation, record, &tmpIndex, &key, 0, starting, segment);
CCH_RELEASE(tdbb, &window);

// now check for current duplicates
Expand Down

0 comments on commit d16fad4

Please sign in to comment.