diff --git a/src/jrd/evl.cpp b/src/jrd/evl.cpp index b22a32c9c9..01e8719463 100644 --- a/src/jrd/evl.cpp +++ b/src/jrd/evl.cpp @@ -3933,7 +3933,7 @@ static void init_agg_distinct(thread_db* tdbb, const jrd_nod* node) SORT_fini(asb_impure->iasb_sort_handle); asb_impure->iasb_sort_handle = - SORT_init(tdbb->getDatabase(), &request->req_sorts, ROUNDUP_LONG(asb->asb_length), + SORT_init(tdbb->getDatabase(), &request->req_sorts, asb->asb_length, (asb->asb_intl ? 2 : 1), 1, sort_key, reject_duplicate, 0); } diff --git a/src/jrd/opt.cpp b/src/jrd/opt.cpp index 5373b5df85..28057eac3f 100644 --- a/src/jrd/opt.cpp +++ b/src/jrd/opt.cpp @@ -4151,6 +4151,8 @@ static RecordSource* gen_aggregate(thread_db* tdbb, OptimizerBlk* opt, jrd_nod* else asb->asb_length += sort_key->skd_length; + asb->asb_length = ROUNDUP(asb->asb_length, sizeof(SLONG)); + sort_key->skd_flags = SKD_ascending; asb->nod_impure = CMP_impure(csb, sizeof(impure_agg_sort)); asb->asb_desc = *desc;