8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 21:23:03 +01:00
This commit is contained in:
asfernandes 2008-11-30 02:23:01 +00:00
parent 64ea14c87c
commit 3dcddd6ed5
3 changed files with 42 additions and 49 deletions

View File

@ -235,10 +235,8 @@ dsc* EVL_assign_to(thread_db* tdbb, jrd_nod* node)
return &impure->vlu_desc;
case nod_field:
record =
request->req_rpb[(int) (IPTR) node->nod_arg[e_fld_stream]].rpb_record;
if (!EVL_field(0, record, (USHORT)(IPTR) node->nod_arg[e_fld_id],
&impure->vlu_desc))
record = request->req_rpb[(int) (IPTR) node->nod_arg[e_fld_stream]].rpb_record;
if (!EVL_field(0, record, (USHORT)(IPTR) node->nod_arg[e_fld_id], &impure->vlu_desc))
{
// The below condition means that EVL_field() returned
// a read-only dummy value which cannot be assigned to.
@ -365,7 +363,7 @@ bool EVL_boolean(thread_db* tdbb, jrd_nod* node)
* Evaluate a boolean.
*
**************************************/
dsc* desc[2];
dsc* desc[2];
bool value;
SSHORT comparison;
impure_value* impure;
@ -412,7 +410,8 @@ bool EVL_boolean(thread_db* tdbb, jrd_nod* node)
force_equal |= request->req_flags & req_same_tx_upd;
// Currently only nod_like, nod_contains, nod_starts and nod_similar may be marked invariant
if (node->nod_flags & nod_invariant) {
if (node->nod_flags & nod_invariant)
{
impure = reinterpret_cast<impure_value*>((SCHAR *)request + node->nod_impure);
// Check that data type of operand is still the same.
@ -430,29 +429,35 @@ bool EVL_boolean(thread_db* tdbb, jrd_nod* node)
impure->vlu_flags &= ~VLU_computed;
}
if (impure->vlu_flags & VLU_computed) {
if (impure->vlu_flags & VLU_computed)
{
if (impure->vlu_flags & VLU_null)
request->req_flags |= req_null;
else
computed_invariant = true;
}
else {
else
{
desc[1] = EVL_expr(tdbb, *ptr++);
if (request->req_flags & req_null) {
if (request->req_flags & req_null)
{
impure->vlu_flags |= VLU_computed;
impure->vlu_flags |= VLU_null;
}
else {
else
{
impure->vlu_flags &= ~VLU_null;
// Search object depends on operand data type.
// Thus save data type which we use to compute invariant
if (desc[0]) {
if (desc[0])
{
impure->vlu_desc.dsc_dtype = desc[0]->dsc_dtype;
impure->vlu_desc.dsc_sub_type = desc[0]->dsc_sub_type;
impure->vlu_desc.dsc_scale = desc[0]->dsc_scale;
}
else {
else
{
// Indicate we do not know type of expression.
// This code will force pattern recompile for the next non-null value
impure->vlu_desc.dsc_dtype = 0;
@ -495,18 +500,16 @@ bool EVL_boolean(thread_db* tdbb, jrd_nod* node)
force_equal |= request->req_flags & req_same_tx_upd;
if (node->nod_flags & nod_comparison) {
if (node->nod_flags & nod_comparison)
comparison = MOV_compare(desc[0], desc[1]);
}
/* If we are checking equality of record_version
* and same transaction updated the record,
* force equality.
*/
if ((rec_version->nod_type == nod_rec_version) && (force_equal)) {
if (rec_version->nod_type == nod_rec_version && force_equal)
comparison = 0;
}
request->req_flags &= ~(req_null | req_same_tx_upd);
}
@ -891,8 +894,7 @@ dsc* EVL_expr(thread_db* tdbb, jrd_nod* const node)
case nod_field:
{
Record* record =
request->req_rpb[(int) (IPTR)node->nod_arg[e_fld_stream]].rpb_record;
Record* record = request->req_rpb[(int) (IPTR)node->nod_arg[e_fld_stream]].rpb_record;
jrd_rel* relation = request->req_rpb[(USHORT)(IPTR) node->nod_arg[e_fld_stream]].rpb_relation;
/* In order to "map a null to a default" value (in EVL_field()),
* the relation block is referenced.
@ -1214,7 +1216,7 @@ bool EVL_field(jrd_rel* relation, Record* record, USHORT id, dsc* desc)
*/
if (!format || id >= format->fmt_count || !desc->dsc_dtype)
{
/* Map a non-existent field to a default value, if available.
/* Map a non-existent field to a default value, if available.
* This enables automatic format upgrade for data rows.
* Handle Outer Joins and such specially!
* Reference: Bug 10424, 10116
@ -1558,8 +1560,7 @@ USHORT EVL_group(thread_db* tdbb, RecordSource* rsb, jrd_nod *const node, USHORT
}
else {
EVL_make_value(tdbb, desc, impure);
if (!vtemp.vlu_desc.dsc_address
|| MOV_compare(&vtemp.vlu_desc, desc))
if (!vtemp.vlu_desc.dsc_address || MOV_compare(&vtemp.vlu_desc, desc))
{
goto break_out;
}
@ -1608,8 +1609,7 @@ USHORT EVL_group(thread_db* tdbb, RecordSource* rsb, jrd_nod *const node, USHORT
// when this reasoning has been validated, please.
break;
}
const SLONG result =
MOV_compare(desc, reinterpret_cast<dsc*>(impure));
const SLONG result = MOV_compare(desc, reinterpret_cast<dsc*>(impure));
if ((result > 0 &&
(from->nod_type == nod_agg_max ||
@ -1771,8 +1771,7 @@ USHORT EVL_group(thread_db* tdbb, RecordSource* rsb, jrd_nod *const node, USHORT
jrd_nod* from = (*ptr)->nod_arg[e_asgn_from];
jrd_nod* field = (*ptr)->nod_arg[e_asgn_to];
const USHORT id = (USHORT)(IPTR) field->nod_arg[e_fld_id];
Record* record =
request->req_rpb[(int) (IPTR) field->nod_arg[e_fld_stream]].rpb_record;
Record* record = request->req_rpb[(int) (IPTR) field->nod_arg[e_fld_stream]].rpb_record;
impure_value_ex* impure = (impure_value_ex*) ((SCHAR *) request + from->nod_impure);
switch (from->nod_type)

View File

@ -507,8 +507,7 @@ void EXE_assignment(thread_db* tdbb, jrd_nod* to, dsc* from_desc, bool from_null
if (to->nod_type == nod_field)
{
const SSHORT id = (USHORT)(IPTR) to->nod_arg[e_fld_id];
Record* record =
request->req_rpb[(int) (IPTR) to->nod_arg[e_fld_stream]].rpb_record;
Record* record = request->req_rpb[(int) (IPTR) to->nod_arg[e_fld_stream]].rpb_record;
if (null) {
SET_NULL(record, id);
}
@ -3147,9 +3146,9 @@ static jrd_nod* modify(thread_db* tdbb, jrd_nod* node, SSHORT which_trig)
const Format* org_format;
Record* org_record = org_rpb->rpb_record;
if (!org_record) {
org_record =
VIO_record(tdbb, org_rpb, new_format, tdbb->getDefaultPool());
if (!org_record)
{
org_record = VIO_record(tdbb, org_rpb, new_format, tdbb->getDefaultPool());
org_format = org_record->rec_format;
org_rpb->rpb_address = org_record->rec_data;
org_rpb->rpb_length = org_format->fmt_length;

View File

@ -1707,9 +1707,7 @@ Record* VIO_gc_record(thread_db* tdbb, jrd_rel* relation)
/* Allocate a garbage collect record block if all are active. */
record_param rpb;
rpb.rpb_record = 0;
Record* record =
VIO_record(tdbb, &rpb, MET_current(tdbb, relation),
dbb->dbb_permanent);
Record* record = VIO_record(tdbb, &rpb, MET_current(tdbb, relation), dbb->dbb_permanent);
record->rec_flags |= REC_gc_active;
/* Insert the new record block into the last slot of the vector. */
@ -2473,8 +2471,7 @@ bool VIO_next_record(thread_db* tdbb,
}
Record* VIO_record(thread_db* tdbb, record_param* rpb, const Format* format,
MemoryPool *pool)
Record* VIO_record(thread_db* tdbb, record_param* rpb, const Format* format, MemoryPool* pool)
{
/**************************************
*
@ -2491,7 +2488,8 @@ Record* VIO_record(thread_db* tdbb, record_param* rpb, const Format* format,
CHECK_DBB(dbb);
#ifdef VIO_DEBUG
if (debug_flag > DEBUG_TRACE) {
if (debug_flag > DEBUG_TRACE)
{
printf("VIO_record (record_param %"QUADFORMAT"d, format %d, pool %p)\n",
rpb->rpb_number.getValue(), format ? format->fmt_version : 0,
(void*) pool);
@ -2500,30 +2498,27 @@ Record* VIO_record(thread_db* tdbb, record_param* rpb, const Format* format,
/* If format wasn't given, look one up */
if (!format) {
if (!format)
format = MET_format(tdbb, rpb->rpb_relation, rpb->rpb_format_number);
}
Record* record = rpb->rpb_record;
if (!record) {
if (!pool) {
if (!record)
{
if (!pool)
pool = dbb->dbb_permanent;
}
record = rpb->rpb_record = FB_NEW_RPT(*pool, format->fmt_length) Record(*pool);
}
else if (record->rec_length < format->fmt_length) {
else if (record->rec_length < format->fmt_length)
{
Record* const old = record;
if (record->rec_flags & REC_gc_active) {
record =
replace_gc_record(rpb->rpb_relation, &rpb->rpb_record,
format->fmt_length);
}
if (record->rec_flags & REC_gc_active)
record = replace_gc_record(rpb->rpb_relation, &rpb->rpb_record, format->fmt_length);
else
record = realloc_record(rpb->rpb_record, format->fmt_length);
if (rpb->rpb_prior == old) {
if (rpb->rpb_prior == old)
rpb->rpb_prior = record;
}
}
record->rec_format = format;