8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 07:23:03 +01:00

Comments.

This commit is contained in:
robocop 2009-11-23 08:35:42 +00:00
parent 5b447ad23b
commit 0f6aa0d9e5
2 changed files with 115 additions and 125 deletions

View File

@ -79,12 +79,12 @@ void PCMET_expression_index(thread_db* tdbb, const string& name, USHORT id, jrd_
MOVE_CLEAR(&idx, sizeof(index_desc)); MOVE_CLEAR(&idx, sizeof(index_desc));
request = CMP_find_request(tdbb, irq_c_exp_index, IRQ_REQUESTS); request = CMP_find_request(tdbb, irq_c_exp_index, IRQ_REQUESTS);
/* /*
if (request) if (request)
{ {
EXE_unwind(tdbb, request); EXE_unwind(tdbb, request);
} }
*/ */
FOR(REQUEST_HANDLE request) FOR(REQUEST_HANDLE request)
IDX IN RDB$INDICES CROSS IDX IN RDB$INDICES CROSS
REL IN RDB$RELATIONS OVER RDB$RELATION_NAME WITH REL IN RDB$RELATIONS OVER RDB$RELATION_NAME WITH
@ -131,7 +131,7 @@ void PCMET_expression_index(thread_db* tdbb, const string& name, USHORT id, jrd_
if (IDX.RDB$SEGMENT_COUNT) if (IDX.RDB$SEGMENT_COUNT)
{ {
/* Msg359: segments not allowed in expression index %s */ // Msg359: segments not allowed in expression index %s
ERR_post(Arg::Gds(isc_no_meta_update) << ERR_post(Arg::Gds(isc_no_meta_update) <<
Arg::Gds(isc_no_segments_err) << Arg::Str(name)); Arg::Gds(isc_no_segments_err) << Arg::Str(name));
} }
@ -141,10 +141,9 @@ void PCMET_expression_index(thread_db* tdbb, const string& name, USHORT id, jrd_
idx.idx_flags |= idx_descending; idx.idx_flags |= idx_descending;
CompilerScratch* csb = 0; CompilerScratch* csb = 0;
/* allocate a new pool to contain the expression tree // allocate a new pool to contain the expression tree for the expression index
for the expression index */
new_pool = dbb->createPool(); new_pool = dbb->createPool();
{ { // scope
Jrd::ContextPoolHolder context(tdbb, new_pool); Jrd::ContextPoolHolder context(tdbb, new_pool);
MET_scan_relation(tdbb, relation); MET_scan_relation(tdbb, relation);
@ -159,9 +158,9 @@ void PCMET_expression_index(thread_db* tdbb, const string& name, USHORT id, jrd_
obj_expression_index, 0, obj_expression_index, 0,
transaction); transaction);
} }
} } // end scope
/* fake a description of the index */ // fake a description of the index
idx.idx_count = 1; idx.idx_count = 1;
idx.idx_flags |= idx_expressn; idx.idx_flags |= idx_expressn;
@ -232,8 +231,7 @@ void PCMET_lookup_index(thread_db* tdbb, jrd_rel* relation, index_desc* idx)
SET_TDBB(tdbb); SET_TDBB(tdbb);
Database* dbb = tdbb->getDatabase(); Database* dbb = tdbb->getDatabase();
// Check the index blocks for the relation to see if we // Check the index blocks for the relation to see if we have a cached block
// have a cached block
IndexBlock* index_block; IndexBlock* index_block;
for (index_block = relation->rel_index_blocks; index_block; index_block = index_block->idb_next) for (index_block = relation->rel_index_blocks; index_block; index_block = index_block->idb_next)
@ -274,16 +272,16 @@ void PCMET_lookup_index(thread_db* tdbb, jrd_rel* relation, index_desc* idx)
idx->idx_expression_request = NULL; idx->idx_expression_request = NULL;
} }
/* parse the blr, making sure to create the resulting expression // parse the blr, making sure to create the resulting expression
tree and request in its own pool so that it may be cached // tree and request in its own pool so that it may be cached
with the index block in the "permanent" metadata cache */ // with the index block in the "permanent" metadata cache
{ { // scope
Jrd::ContextPoolHolder context(tdbb, dbb->createPool()); Jrd::ContextPoolHolder context(tdbb, dbb->createPool());
idx->idx_expression = idx->idx_expression =
MET_parse_blob(tdbb, relation, &IDX.RDB$EXPRESSION_BLR, &csb, MET_parse_blob(tdbb, relation, &IDX.RDB$EXPRESSION_BLR, &csb,
&idx->idx_expression_request, false); &idx->idx_expression_request, false);
} } // end scope
END_FOR; END_FOR;
@ -298,19 +296,19 @@ void PCMET_lookup_index(thread_db* tdbb, jrd_rel* relation, index_desc* idx)
} }
delete csb; delete csb;
/* if there is no existing index block for this index, create // if there is no existing index block for this index, create
one and link it in with the index blocks for this relation */ // one and link it in with the index blocks for this relation
if (!index_block) if (!index_block)
index_block = IDX_create_index_block(tdbb, relation, idx->idx_id); index_block = IDX_create_index_block(tdbb, relation, idx->idx_id);
/* if we can't get the lock, no big deal: just give up on caching the index info */ // if we can't get the lock, no big deal: just give up on caching the index info
if (!LCK_lock(tdbb, index_block->idb_lock, LCK_SR, LCK_NO_WAIT)) if (!LCK_lock(tdbb, index_block->idb_lock, LCK_SR, LCK_NO_WAIT))
return; return;
/* whether the index block already existed or was just created, // whether the index block already existed or was just created,
fill in the cached information about the index */ // fill in the cached information about the index
index_block->idb_expression = idx->idx_expression; index_block->idb_expression = idx->idx_expression;
index_block->idb_expression_request = idx->idx_expression_request; index_block->idb_expression_request = idx->idx_expression_request;

View File

@ -250,7 +250,7 @@ void RSE_close(thread_db* tdbb, RecordSource* rsb)
return; return;
default: default:
BUGCHECK(166); /* msg 166 invalid rsb type */ BUGCHECK(166); // msg 166 invalid rsb type
} }
} }
} }
@ -276,8 +276,7 @@ bool RSE_get_record(thread_db* tdbb, RecordSource* rsb)
impure->irsb_flags |= irsb_eof; impure->irsb_flags |= irsb_eof;
/* Turn off the flag so that records at a // Turn off the flag so that records at a lower level will not be counted.
lower level will not be counted. */
const bool count = (request->req_flags & req_count_records) != 0; const bool count = (request->req_flags & req_count_records) != 0;
request->req_flags &= ~req_count_records; request->req_flags &= ~req_count_records;
@ -335,7 +334,7 @@ bool RSE_get_record(thread_db* tdbb, RecordSource* rsb)
break; break;
} }
/* reset the flag to whatever it was */ // reset the flag to whatever it was
if (count) if (count)
request->req_flags |= req_count_records; request->req_flags |= req_count_records;
@ -396,9 +395,9 @@ void RSE_open(thread_db* tdbb, RecordSource* rsb)
Database* dbb = tdbb->getDatabase(); Database* dbb = tdbb->getDatabase();
BufferControl* bcb = dbb->dbb_bcb; BufferControl* bcb = dbb->dbb_bcb;
/* Unless this is the only attachment, limit the cache flushing // Unless this is the only attachment, limit the cache flushing
effect of large sequential scans on the page working sets of // effect of large sequential scans on the page working sets of
other attachments. */ // other attachments.
Jrd::Attachment* attachment = tdbb->getAttachment(); Jrd::Attachment* attachment = tdbb->getAttachment();
if (attachment && (attachment != dbb->dbb_attachments || attachment->att_next)) if (attachment && (attachment != dbb->dbb_attachments || attachment->att_next))
@ -482,7 +481,7 @@ void RSE_open(thread_db* tdbb, RecordSource* rsb)
((IRSB) impure)->irsb_count = 0; ((IRSB) impure)->irsb_count = 0;
VIO_record(tdbb, rpb, rsb->rsb_format, tdbb->getDefaultPool()); VIO_record(tdbb, rpb, rsb->rsb_format, tdbb->getDefaultPool());
/* Initialize the record number of each stream in the union */ // Initialize the record number of each stream in the union
RecordSource** ptr = &rsb->rsb_arg[rsb->rsb_count]; RecordSource** ptr = &rsb->rsb_arg[rsb->rsb_count];
for (const RecordSource* const* const end = ptr + (USHORT)(IPTR) *ptr; for (const RecordSource* const* const end = ptr + (USHORT)(IPTR) *ptr;
@ -519,9 +518,9 @@ void RSE_open(thread_db* tdbb, RecordSource* rsb)
impure->irsb_flags &= ~(irsb_first | irsb_in_opened | irsb_join_full); impure->irsb_flags &= ~(irsb_first | irsb_in_opened | irsb_join_full);
impure->irsb_flags |= irsb_mustread; impure->irsb_flags |= irsb_mustread;
/* Allocate a record block for each union/aggregate/procedure // Allocate a record block for each union/aggregate/procedure
stream in the right sub-stream. The block will be needed // stream in the right sub-stream. The block will be needed
if we join to nulls before opening the rsbs */ // if we join to nulls before opening the rsbs
for (RsbStack::iterator stack(*(rsb->rsb_left_rsbs)); stack.hasData(); ++stack) for (RsbStack::iterator stack(*(rsb->rsb_left_rsbs)); stack.hasData(); ++stack)
{ {
@ -532,7 +531,7 @@ void RSE_open(thread_db* tdbb, RecordSource* rsb)
} }
default: default:
BUGCHECK(166); /* msg 166 invalid rsb type */ BUGCHECK(166); // msg 166 invalid rsb type
} }
} }
} }
@ -553,18 +552,18 @@ static void close_merge(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
**************************************/ **************************************/
SET_TDBB(tdbb); SET_TDBB(tdbb);
/* do two simultaneous but unrelated things in one loop */ // do two simultaneous but unrelated things in one loop
irsb_mrg::irsb_mrg_repeat* tail = impure->irsb_mrg_rpt; irsb_mrg::irsb_mrg_repeat* tail = impure->irsb_mrg_rpt;
RecordSource** ptr = rsb->rsb_arg; RecordSource** ptr = rsb->rsb_arg;
for (const RecordSource* const* const end = ptr + rsb->rsb_count * 2; ptr < end; ptr += 2, tail++) for (const RecordSource* const* const end = ptr + rsb->rsb_count * 2; ptr < end; ptr += 2, tail++)
{ {
/* close all the substreams for the sort-merge */ // close all the substreams for the sort-merge
RSE_close(tdbb, *ptr); RSE_close(tdbb, *ptr);
/* Release memory associated with the merge file block // Release memory associated with the merge file block
and the sort file block. Also delete the merge file // and the sort file block. Also delete the merge file
if one exists. */ // if one exists.
merge_file* mfb = &tail->irsb_mrg_file; merge_file* mfb = &tail->irsb_mrg_file;
delete mfb->mfb_space; delete mfb->mfb_space;
@ -767,8 +766,7 @@ static bool fetch_left(thread_db* tdbb, RecordSource* rsb, IRSB impure)
if (rsb->rsb_left_inner_streams->isEmpty()) if (rsb->rsb_left_inner_streams->isEmpty())
return false; return false;
/* We have a full outer join. Open up the inner stream // We have a full outer join. Open up the inner stream one more time.
one more time. */
RSE_close(tdbb, rsb->rsb_arg[RSB_LEFT_outer]); RSE_close(tdbb, rsb->rsb_arg[RSB_LEFT_outer]);
impure->irsb_flags |= irsb_join_full; impure->irsb_flags |= irsb_join_full;
@ -778,8 +776,8 @@ static bool fetch_left(thread_db* tdbb, RecordSource* rsb, IRSB impure)
if (rsb->rsb_arg[RSB_LEFT_boolean] && if (rsb->rsb_arg[RSB_LEFT_boolean] &&
!EVL_boolean(tdbb, (jrd_nod*) rsb->rsb_arg[RSB_LEFT_boolean])) !EVL_boolean(tdbb, (jrd_nod*) rsb->rsb_arg[RSB_LEFT_boolean]))
{ {
/* The boolean pertaining to the left sub-stream is false // The boolean pertaining to the left sub-stream is false
so just join sub-stream to a null valued right sub-stream */ // so just join sub-stream to a null valued right sub-stream
join_to_nulls(tdbb, rsb->rsb_left_streams); join_to_nulls(tdbb, rsb->rsb_left_streams);
return true; return true;
} }
@ -802,24 +800,24 @@ static bool fetch_left(thread_db* tdbb, RecordSource* rsb, IRSB impure)
impure->irsb_flags |= irsb_mustread; impure->irsb_flags |= irsb_mustread;
if (!(impure->irsb_flags & irsb_joined)) if (!(impure->irsb_flags & irsb_joined))
{ {
/* The current left sub-stream record has not been joined // The current left sub-stream record has not been joined
to anything. Join it to a null valued right sub-stream */ // to anything. Join it to a null valued right sub-stream
join_to_nulls(tdbb, rsb->rsb_left_streams); join_to_nulls(tdbb, rsb->rsb_left_streams);
return true; return true;
} }
} }
} }
/* Continue with a full outer join. */ // Continue with a full outer join.
RecordSource* full = rsb->rsb_arg[RSB_LEFT_inner]; RecordSource* full = rsb->rsb_arg[RSB_LEFT_inner];
full = (full->rsb_type == rsb_boolean) ? full->rsb_next : full; full = (full->rsb_type == rsb_boolean) ? full->rsb_next : full;
if (impure->irsb_flags & irsb_in_opened) if (impure->irsb_flags & irsb_in_opened)
{ {
/* The inner stream was opened at some point. If it doesn't have a // The inner stream was opened at some point. If it doesn't have a
boolean, then all of its records have been returned. Otherwise, // boolean, then all of its records have been returned. Otherwise,
find the records that haven't been. */ // find the records that haven't been.
bool found; bool found;
do { do {
if (!RSE_internal_get_record(tdbb, full, NULL)) if (!RSE_internal_get_record(tdbb, full, NULL))
@ -931,7 +929,7 @@ static bool get_merge_join(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
jrd_req* request = tdbb->getRequest(); jrd_req* request = tdbb->getRequest();
const RecordSource* const* const end = rsb->rsb_arg + rsb->rsb_count * 2; const RecordSource* const* const end = rsb->rsb_arg + rsb->rsb_count * 2;
/* If there is a record group already formed, fetch the next combination */ // If there is a record group already formed, fetch the next combination
if (get_merge_fetch(tdbb, rsb, rsb->rsb_count - 1)) if (get_merge_fetch(tdbb, rsb, rsb->rsb_count - 1))
return true; return true;
@ -939,8 +937,8 @@ static bool get_merge_join(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
RecordSource** ptr; RecordSource** ptr;
irsb_mrg::irsb_mrg_repeat* tail; irsb_mrg::irsb_mrg_repeat* tail;
/* Assuming we are done with the current value group, advance each // Assuming we are done with the current value group, advance each
stream one record. If any comes up dry, we're done. */ // stream one record. If any comes up dry, we're done.
RecordSource** highest_ptr = rsb->rsb_arg; RecordSource** highest_ptr = rsb->rsb_arg;
for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt; ptr < end; ptr += 2, tail++) for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt; ptr < end; ptr += 2, tail++)
@ -949,13 +947,13 @@ static bool get_merge_join(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
SortMap* map = (SortMap*) sort_rsb->rsb_arg[0]; SortMap* map = (SortMap*) sort_rsb->rsb_arg[0];
merge_file* mfb = &tail->irsb_mrg_file; merge_file* mfb = &tail->irsb_mrg_file;
/* reset equality group record positions */ // reset equality group record positions
tail->irsb_mrg_equal = 0; tail->irsb_mrg_equal = 0;
tail->irsb_mrg_equal_current = 0; tail->irsb_mrg_equal_current = 0;
tail->irsb_mrg_equal_end = 0; tail->irsb_mrg_equal_end = 0;
/* If there is a record waiting, use it. Otherwise get another */ // If there is a record waiting, use it. Otherwise get another
SLONG record = tail->irsb_mrg_last_fetched; SLONG record = tail->irsb_mrg_last_fetched;
if (record >= 0) if (record >= 0)
@ -977,7 +975,7 @@ static bool get_merge_join(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
return false; return false;
} }
/* Map data into target records and do comparison */ // Map data into target records and do comparison
map_sort_data(tdbb, request, map, get_merge_data(tdbb, mfb, record)); map_sort_data(tdbb, request, map, get_merge_data(tdbb, mfb, record));
if (ptr != highest_ptr && compare(tdbb, (jrd_nod*) highest_ptr[1], (jrd_nod*) ptr[1]) < 0) if (ptr != highest_ptr && compare(tdbb, (jrd_nod*) highest_ptr[1], (jrd_nod*) ptr[1]) < 0)
@ -986,8 +984,8 @@ static bool get_merge_join(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
} }
} }
/* Loop thru the streams advancing each up to the target value. If any // Loop thru the streams advancing each up to the target value. If any
exceeds the target value, start over */ // exceeds the target value, start over
for (;;) for (;;)
{ {
@ -1019,7 +1017,7 @@ static bool get_merge_join(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
recycle:; recycle:;
} }
/* Finally compute equality group for each stream in sort/merge */ // Finally compute equality group for each stream in sort/merge
for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt; ptr < end; ptr += 2, tail++) for (ptr = rsb->rsb_arg, tail = impure->irsb_mrg_rpt; ptr < end; ptr += 2, tail++)
{ {
@ -1049,10 +1047,10 @@ static bool get_merge_join(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
write_merge_block(tdbb, mfb, mfb->mfb_current_block); write_merge_block(tdbb, mfb, mfb->mfb_current_block);
} }
/* Optimize cross product of equivalence groups by ordering the streams // Optimize cross product of equivalence groups by ordering the streams
from left (outermost) to right (innermost) by descending cardinality // from left (outermost) to right (innermost) by descending cardinality
of merge blocks. This ordering will vary for each set of equivalence // of merge blocks. This ordering will vary for each set of equivalence
groups and cannot be statically assigned by the optimizer. */ // groups and cannot be statically assigned by the optimizer.
typedef Firebird::Stack<irsb_mrg::irsb_mrg_repeat*> ImrStack; typedef Firebird::Stack<irsb_mrg::irsb_mrg_repeat*> ImrStack;
ImrStack best_tails; ImrStack best_tails;
@ -1247,7 +1245,7 @@ bool RSE_internal_get_record(thread_db* tdbb,
if (--tdbb->tdbb_quantum < 0) if (--tdbb->tdbb_quantum < 0)
JRD_reschedule(tdbb, 0, true); JRD_reschedule(tdbb, 0, true);
/* check request flags for special processing */ // check request flags for special processing
jrd_req* request = tdbb->getRequest(); jrd_req* request = tdbb->getRequest();
if (request->req_flags & req_abort) if (request->req_flags & req_abort)
@ -1296,7 +1294,7 @@ bool RSE_internal_get_record(thread_db* tdbb,
{ {
rpb->rpb_number.setValue(bitmap->current()); rpb->rpb_number.setValue(bitmap->current());
#ifdef SUPERSERVER_V2 #ifdef SUPERSERVER_V2
/* Prefetch next set of data pages from bitmap. */ // Prefetch next set of data pages from bitmap.
if (rpb->rpb_number > ((irsb_index*) impure)->irsb_prefetch_number) if (rpb->rpb_number > ((irsb_index*) impure)->irsb_prefetch_number)
{ {
@ -1354,7 +1352,7 @@ bool RSE_internal_get_record(thread_db* tdbb,
jrd_nod* column_node = (jrd_nod*) rsb->rsb_any_boolean; jrd_nod* column_node = (jrd_nod*) rsb->rsb_any_boolean;
if (column_node && (request->req_flags & (req_ansi_all | req_ansi_any))) if (column_node && (request->req_flags & (req_ansi_all | req_ansi_any)))
{ {
/* see if there's a select node to work with */ // see if there's a select node to work with
if (column_node->nod_type == nod_and) if (column_node->nod_type == nod_and)
{ {
@ -1376,7 +1374,7 @@ bool RSE_internal_get_record(thread_db* tdbb,
{ {
request->req_flags &= ~req_ansi_not; request->req_flags &= ~req_ansi_not;
/* do NOT ANY */ // do NOT ANY
/* if the subquery was the empty set /* if the subquery was the empty set
(numTrue + numFalse + numUnknown = 0) (numTrue + numFalse + numUnknown = 0)
or if all were false or if all were false
@ -1389,13 +1387,13 @@ bool RSE_internal_get_record(thread_db* tdbb,
{ {
if (EVL_boolean(tdbb, (jrd_nod*) rsb->rsb_arg[0])) if (EVL_boolean(tdbb, (jrd_nod*) rsb->rsb_arg[0]))
{ {
/* found a TRUE value */ // found a TRUE value
any_true = true; any_true = true;
break; break;
} }
/* check for select stream and nulls */ // check for select stream and nulls
if (!select_node) if (!select_node)
{ {
@ -1411,16 +1409,16 @@ bool RSE_internal_get_record(thread_db* tdbb,
// select for ANY/ALL processing // select for ANY/ALL processing
const bool select_value = EVL_boolean(tdbb, select_node); const bool select_value = EVL_boolean(tdbb, select_node);
/* see if any record in select stream */ // see if any record in select stream
if (select_value) if (select_value)
{ {
/* see if any nulls */ // see if any nulls
request->req_flags &= ~req_null; request->req_flags &= ~req_null;
EVL_boolean(tdbb, column_node); EVL_boolean(tdbb, column_node);
/* see if any record is null */ // see if any record is null
if (request->req_flags & req_null) { if (request->req_flags & req_null) {
any_null = true; any_null = true;
@ -1442,9 +1440,8 @@ bool RSE_internal_get_record(thread_db* tdbb,
else else
{ {
/* do ANY */ // do ANY
/* if the subquery was true for any comparison, // if the subquery was true for any comparison, ANY is true
ANY is true */
result = false; result = false;
while (RSE_internal_get_record(tdbb, rsb->rsb_next, rsb)) while (RSE_internal_get_record(tdbb, rsb->rsb_next, rsb))
@ -1471,23 +1468,22 @@ bool RSE_internal_get_record(thread_db* tdbb,
{ {
request->req_flags &= ~req_ansi_not; request->req_flags &= ~req_ansi_not;
/* do NOT ALL */ // do NOT ALL
/* if the subquery was false for any comparison, // if the subquery was false for any comparison, NOT ALL is true
NOT ALL is true */
any_false = false; any_false = false;
while (RSE_internal_get_record(tdbb, rsb->rsb_next, rsb)) while (RSE_internal_get_record(tdbb, rsb->rsb_next, rsb))
{ {
request->req_flags &= ~req_null; request->req_flags &= ~req_null;
/* look for a FALSE (and not null either) */ // look for a FALSE (and not null either)
if (!EVL_boolean(tdbb, (jrd_nod*) rsb->rsb_arg[0]) && if (!EVL_boolean(tdbb, (jrd_nod*) rsb->rsb_arg[0]) &&
!(request->req_flags & req_null)) !(request->req_flags & req_null))
{ {
/* make sure it wasn't FALSE because there's // make sure it wasn't FALSE because there's
no select stream record */ // no select stream record
if (select_node) { if (select_node) {
request->req_flags &= ~req_null; request->req_flags &= ~req_null;
@ -1517,7 +1513,7 @@ bool RSE_internal_get_record(thread_db* tdbb,
else else
{ {
/* do ALL */ // do ALL
/* if the subquery was the empty set /* if the subquery was the empty set
(numTrue + numFalse + numUnknown = 0) (numTrue + numFalse + numUnknown = 0)
or if all were true or if all were true
@ -1529,12 +1525,12 @@ bool RSE_internal_get_record(thread_db* tdbb,
{ {
request->req_flags &= ~req_null; request->req_flags &= ~req_null;
/* look for a FALSE or null */ // look for a FALSE or null
if (!EVL_boolean(tdbb, (jrd_nod*) rsb->rsb_arg[0])) if (!EVL_boolean(tdbb, (jrd_nod*) rsb->rsb_arg[0]))
{ {
/* make sure it wasn't FALSE because there's // make sure it wasn't FALSE because there's
no select stream record */ // no select stream record
if (select_node) { if (select_node) {
request->req_flags &= ~req_null; request->req_flags &= ~req_null;
@ -1670,9 +1666,9 @@ bool RSE_internal_get_record(thread_db* tdbb,
break; break;
} }
/* in the case of a project which has been mapped to an index, // in the case of a project which has been mapped to an index,
we need to make sure that we only return a single record for // we need to make sure that we only return a single record for
each of the leftmost records in the join */ // each of the leftmost records in the join
if (rsb->rsb_flags & rsb_project) if (rsb->rsb_flags & rsb_project)
{ {
@ -1732,14 +1728,14 @@ bool RSE_internal_get_record(thread_db* tdbb,
break; break;
default: default:
BUGCHECK(166); /* msg 166 invalid rsb type */ BUGCHECK(166); // msg 166 invalid rsb type
} }
/* Check to see if we need to update the record_count. This record // Check to see if we need to update the record_count. This record
count is used in NAV_get_record and needs to be updated before // count is used in NAV_get_record and needs to be updated before
checking for singularity. Note that in our check for singularity // checking for singularity. Note that in our check for singularity
we call get_record which calls NAV_get_record where this count // we call get_record which calls NAV_get_record where this count
is used. Bug # 8415, 8416 */ // is used. Bug # 8415, 8416
if (rsb->rsb_type == rsb_boolean) if (rsb->rsb_type == rsb_boolean)
rsb->rsb_next->rsb_record_count++; rsb->rsb_next->rsb_record_count++;
@ -1781,8 +1777,8 @@ static UCHAR *get_sort(thread_db* tdbb, RecordSource* rsb)
jrd_req* request = tdbb->getRequest(); jrd_req* request = tdbb->getRequest();
irsb_sort* impure = (irsb_sort*) ((UCHAR *) request + rsb->rsb_impure); irsb_sort* impure = (irsb_sort*) ((UCHAR *) request + rsb->rsb_impure);
/* Get address of record from sort. If the address if null, we // Get address of record from sort. If the address if null, we
ran out of records. This is known in the trade as "end of file." */ // ran out of records. This is known in the trade as "end of file."
ULONG* data = 0; ULONG* data = 0;
SORT_get(tdbb, impure->irsb_sort_handle, &data); SORT_get(tdbb, impure->irsb_sort_handle, &data);
@ -1806,7 +1802,7 @@ static bool get_union(thread_db* tdbb, RecordSource* rsb, IRSB impure)
SET_TDBB(tdbb); SET_TDBB(tdbb);
RecordSource** rsb_ptr = rsb->rsb_arg + impure->irsb_count; RecordSource** rsb_ptr = rsb->rsb_arg + impure->irsb_count;
/* March thru the sub-streams (tributaries?) looking for a record */ // March thru the sub-streams (tributaries?) looking for a record
while (!RSE_internal_get_record(tdbb, *rsb_ptr, NULL)) while (!RSE_internal_get_record(tdbb, *rsb_ptr, NULL))
{ {
@ -1818,7 +1814,7 @@ static bool get_union(thread_db* tdbb, RecordSource* rsb, IRSB impure)
RSE_open(tdbb, *rsb_ptr); RSE_open(tdbb, *rsb_ptr);
} }
/* We've got a record, map it into the target record */ // We've got a record, map it into the target record
jrd_nod* map = (jrd_nod*) rsb_ptr[1]; jrd_nod* map = (jrd_nod*) rsb_ptr[1];
@ -1919,7 +1915,7 @@ void RSE_invalidate_child_rpbs(thread_db* tdbb, RecordSource* rsb)
return; return;
default: default:
BUGCHECK(166); /* msg 166 invalid rsb type */ BUGCHECK(166); // msg 166 invalid rsb type
} }
} }
} }
@ -1947,8 +1943,8 @@ static void join_to_nulls(thread_db* tdbb, StreamStack* stream)
rpb->rpb_number.setValid(false); rpb->rpb_number.setValid(false);
/* Make sure a record block has been allocated. If there isn't // Make sure a record block has been allocated. If there isn't
one, first find the format, then allocate the record block */ // one, first find the format, then allocate the record block
Record* record = rpb->rpb_record; Record* record = rpb->rpb_record;
if (!record) { if (!record) {
@ -1993,14 +1989,13 @@ static void map_sort_data(thread_db* tdbb, jrd_req* request, SortMap* map, UCHAR
if (node && node->nod_type != nod_field) if (node && node->nod_type != nod_field)
continue; continue;
/* if moving a TEXT item into the key portion of // if moving a TEXT item into the key portion of
the sort record, then want to sort by // the sort record, then want to sort by
language dependant order */ // language dependant order
/* in the case below a nod_field is being converted to // in the case below a nod_field is being converted to
a sort key, there is a later nod_field in the item // a sort key, there is a later nod_field in the item
list that contains the data to send back // list that contains the data to send back
*/
if (IS_INTL_DATA(&item->smb_desc) && if (IS_INTL_DATA(&item->smb_desc) &&
(USHORT)(IPTR) item->smb_desc.dsc_address < map->smb_key_length * sizeof(ULONG)) (USHORT)(IPTR) item->smb_desc.dsc_address < map->smb_key_length * sizeof(ULONG))
{ {
@ -2063,20 +2058,20 @@ static void open_merge(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
SET_TDBB(tdbb); SET_TDBB(tdbb);
/* do two simultaneous but unrelated things in one loop */ // do two simultaneous but unrelated things in one loop
RecordSource** ptr = rsb->rsb_arg; RecordSource** ptr = rsb->rsb_arg;
const RecordSource* const* end = ptr + rsb->rsb_count * 2; const RecordSource* const* end = ptr + rsb->rsb_count * 2;
for (irsb_mrg::irsb_mrg_repeat* tail = impure->irsb_mrg_rpt; ptr < end; ptr += 2, tail++) for (irsb_mrg::irsb_mrg_repeat* tail = impure->irsb_mrg_rpt; ptr < end; ptr += 2, tail++)
{ {
/* open all the substreams for the sort-merge */ // open all the substreams for the sort-merge
RSE_open(tdbb, *ptr); RSE_open(tdbb, *ptr);
RecordSource* sort_rsb = *ptr; RecordSource* sort_rsb = *ptr;
SortMap* map = (SortMap*) sort_rsb->rsb_arg[0]; SortMap* map = (SortMap*) sort_rsb->rsb_arg[0];
/* Reset equality group record positions */ // Reset equality group record positions
tail->irsb_mrg_equal = -1; tail->irsb_mrg_equal = -1;
tail->irsb_mrg_equal_end = -1; tail->irsb_mrg_equal_end = -1;
@ -2116,7 +2111,7 @@ static void open_procedure(thread_db* tdbb, RecordSource* rsb, irsb_procedure* i
jrd_prc* procedure = rsb->rsb_procedure; jrd_prc* procedure = rsb->rsb_procedure;
jrd_req* request = tdbb->getRequest(); jrd_req* request = tdbb->getRequest();
/* get rid of any lingering record */ // get rid of any lingering record
record_param* rpb = &request->req_rpb[rsb->rsb_stream]; record_param* rpb = &request->req_rpb[rsb->rsb_stream];
delete rpb->rpb_record; delete rpb->rpb_record;
@ -2148,8 +2143,7 @@ static void open_procedure(thread_db* tdbb, RecordSource* rsb, irsb_procedure* i
im = NULL; im = NULL;
} }
/* req_proc_fetch flag used only when fetching rows, so // req_proc_fetch flag used only when fetching rows, so is set at end of open_procedure ().
is set at end of open_procedure (). */
proc_request->req_flags &= ~req_proc_fetch; proc_request->req_flags &= ~req_proc_fetch;
@ -2359,8 +2353,8 @@ static void proc_assignment(thread_db* tdbb,
switch (to_desc->dsc_dtype) switch (to_desc->dsc_dtype)
{ {
case dtype_text: case dtype_text:
/* YYY - not necessarily the right thing to do */ // YYY - not necessarily the right thing to do
/* YYY for text formats that don't have trailing spaces */ // YYY for text formats that don't have trailing spaces
if (l) { if (l) {
const CHARSET_ID chid = DSC_GET_CHARSET(to_desc); const CHARSET_ID chid = DSC_GET_CHARSET(to_desc);
/* /*
@ -2509,10 +2503,9 @@ static void pop_rpbs(jrd_req* request, RecordSource* rsb)
case rsb_cross: case rsb_cross:
{ {
/* Bug # 72369: singleton-SELECT in Stored Procedure gives wrong // Bug # 72369: singleton-SELECT in Stored Procedure gives wrong
* results when there are more than 2 streams in the cross. // results when there are more than 2 streams in the cross.
* rsb_cross can have more than 2 rsb_arg's. Go through each one // rsb_cross can have more than 2 rsb_arg's. Go through each one
*/
RecordSource** ptr = rsb->rsb_arg; RecordSource** ptr = rsb->rsb_arg;
for (const RecordSource* const* const end = ptr + rsb->rsb_count; ptr < end; ptr++) for (const RecordSource* const* const end = ptr + rsb->rsb_count; ptr < end; ptr++)
{ {
@ -2527,7 +2520,7 @@ static void pop_rpbs(jrd_req* request, RecordSource* rsb)
break; break;
default: default:
BUGCHECK(166); /* msg 166 invalid rsb type */ BUGCHECK(166); // msg 166 invalid rsb type
} }
} }
@ -2623,10 +2616,9 @@ static void push_rpbs(thread_db* tdbb, jrd_req* request, RecordSource* rsb)
case rsb_cross: case rsb_cross:
{ {
/* Bug # 72369: singleton-SELECT in Stored Procedure gives wrong // Bug # 72369: singleton-SELECT in Stored Procedure gives wrong
* results when there are more than 2 streams in the cross. // results when there are more than 2 streams in the cross.
* rsb_cross can have more than 2 rsb_arg's. Go through each one // rsb_cross can have more than 2 rsb_arg's. Go through each one
*/
RecordSource** ptr = rsb->rsb_arg; RecordSource** ptr = rsb->rsb_arg;
for (const RecordSource* const* const end = ptr + rsb->rsb_count; ptr < end; ptr++) for (const RecordSource* const* const end = ptr + rsb->rsb_count; ptr < end; ptr++)
{ {
@ -2635,15 +2627,15 @@ static void push_rpbs(thread_db* tdbb, jrd_req* request, RecordSource* rsb)
} }
break; break;
/* BUG #8637: left outer join gives internal gds software consistency // BUG #8637: left outer join gives internal gds software consistency
check. Added case for rsb_left_cross. */ // check. Added case for rsb_left_cross.
case rsb_left_cross: case rsb_left_cross:
push_rpbs(tdbb, request, rsb->rsb_arg[RSB_LEFT_outer]); push_rpbs(tdbb, request, rsb->rsb_arg[RSB_LEFT_outer]);
push_rpbs(tdbb, request, rsb->rsb_arg[RSB_LEFT_inner]); push_rpbs(tdbb, request, rsb->rsb_arg[RSB_LEFT_inner]);
break; break;
default: default:
BUGCHECK(166); /* msg 166 invalid rsb type */ BUGCHECK(166); // msg 166 invalid rsb type
} }
} }