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

Make MOV_move know how to move blobs.

This fixes CORE-1147: Blobs are not converted to string in UDF parameters.
This commit is contained in:
asfernandes 2007-03-02 00:46:03 +00:00
parent 76f9f12d57
commit 2100a06c84
9 changed files with 69 additions and 56 deletions

View File

@ -2509,7 +2509,7 @@ static void move_to_string(thread_db* tdbb, dsc* fromDesc, dsc* toDesc)
blobAsText.dsc_address = buffer.begin();
blobAsText.dsc_length = (USHORT)len;
MOV_move(&blobAsText, toDesc);
MOV_move(tdbb, &blobAsText, toDesc);
}
@ -2574,6 +2574,8 @@ static void slice_callback(array_slice* arg, ULONG count, DSC* descriptors)
* Perform slice assignment.
*
**************************************/
thread_db* tdbb = JRD_get_thread_data();
dsc* array_desc = descriptors;
dsc* slice_desc = &arg->slice_desc;
BLOB_PTR* const next =
@ -2627,7 +2629,7 @@ static void slice_callback(array_slice* arg, ULONG count, DSC* descriptors)
}
else
{
MOV_move(slice_desc, array_desc);
MOV_move(tdbb, slice_desc, array_desc);
}
const BLOB_PTR* const end =
array_desc->dsc_address + array_desc->dsc_length;
@ -2662,10 +2664,10 @@ static void slice_callback(array_slice* arg, ULONG count, DSC* descriptors)
sizeof(USHORT));
temp_desc.dsc_address =
array_desc->dsc_address + sizeof(USHORT);
MOV_move(&temp_desc, slice_desc);
MOV_move(tdbb, &temp_desc, slice_desc);
}
else
MOV_move(array_desc, slice_desc);
MOV_move(tdbb, array_desc, slice_desc);
++arg->slice_count;
}
else {

View File

@ -1671,7 +1671,7 @@ USHORT EVL_group(thread_db* tdbb, RecordSource* rsb, jrd_nod *const node, USHORT
reinterpret_cast<ULONG**>(&data));
MOVE_CLEAR(data, ROUNDUP_LONG(asb->asb_key_desc->skd_length));
asb->asb_desc.dsc_address = data;
MOV_move(desc, &asb->asb_desc);
MOV_move(tdbb, desc, &asb->asb_desc);
break;
}
@ -1739,7 +1739,7 @@ USHORT EVL_group(thread_db* tdbb, RecordSource* rsb, jrd_nod *const node, USHORT
SET_NULL(record, id);
}
else {
MOV_move(&impure->vlu_desc, EVL_expr(tdbb, field));
MOV_move(tdbb, &impure->vlu_desc, EVL_expr(tdbb, field));
CLEAR_NULL(record, id);
}
break;
@ -1759,7 +1759,7 @@ USHORT EVL_group(thread_db* tdbb, RecordSource* rsb, jrd_nod *const node, USHORT
temp.dsc_sub_type = 0;
temp.dsc_address = (UCHAR *) & d;
d = MOV_get_double(&impure->vlu_desc) / impure->vlux_count;
MOV_move(&temp, EVL_expr(tdbb, field));
MOV_move(tdbb, &temp, EVL_expr(tdbb, field));
break;
case nod_agg_average_distinct2:
@ -1787,7 +1787,7 @@ USHORT EVL_group(thread_db* tdbb, RecordSource* rsb, jrd_nod *const node, USHORT
temp.dsc_address = (UCHAR *) & d;
d = MOV_get_double(&impure->vlu_desc) / impure->vlux_count;
}
MOV_move(&temp, EVL_expr(tdbb, field));
MOV_move(tdbb, &temp, EVL_expr(tdbb, field));
break;
default: // Shut up some compiler warnings
@ -2903,7 +2903,7 @@ static dsc* cast(thread_db* tdbb, dsc* value, const jrd_nod* node, impure_value*
if (DTYPE_IS_BLOB(value->dsc_dtype) || DTYPE_IS_BLOB(impure->vlu_desc.dsc_dtype))
BLB_move(tdbb, value, &impure->vlu_desc, NULL);
else
MOV_move(value, &impure->vlu_desc);
MOV_move(tdbb, value, &impure->vlu_desc);
if (impure->vlu_desc.dsc_dtype == dtype_text)
adjust_text_descriptor(tdbb, &impure->vlu_desc);

View File

@ -265,7 +265,7 @@ void EXE_assignment(thread_db* tdbb, jrd_nod* node)
/* Get descriptors of receiving and sending fields/parameters, variables, etc. */
const dsc* missing = NULL;
dsc* missing = NULL;
if (node->nod_arg[e_asgn_missing]) {
missing = EVL_expr(tdbb, node->nod_arg[e_asgn_missing]);
}
@ -345,7 +345,7 @@ void EXE_assignment(thread_db* tdbb, jrd_nod* node)
}
temp.dsc_address = (UCHAR *) &len;
MOV_move(&temp, indicator);
MOV_move(tdbb, &temp, indicator);
if (len) {
temp = *from_desc;
@ -388,10 +388,12 @@ void EXE_assignment(thread_db* tdbb, jrd_nod* node)
if (DTYPE_IS_BLOB_OR_QUAD(from_desc->dsc_dtype) ||
DTYPE_IS_BLOB_OR_QUAD(to_desc->dsc_dtype))
{
// ASF: Don't let MOV_move call BLB_move because MOV
// will not pass the destination field to BLB_move.
BLB_move(tdbb, from_desc, to_desc, to);
}
else if (!DSC_EQUIV(from_desc, to_desc, false))
MOV_move(from_desc, to_desc);
MOV_move(tdbb, from_desc, to_desc);
else if (from_desc->dsc_dtype == dtype_short)
{
*((SSHORT *) to_desc->dsc_address) =
@ -423,7 +425,7 @@ void EXE_assignment(thread_db* tdbb, jrd_nod* node)
else if (node->nod_arg[e_asgn_missing2] &&
(missing = EVL_expr(tdbb, node->nod_arg[e_asgn_missing2])))
{
MOV_move(missing, to_desc);
MOV_move(tdbb, missing, to_desc);
to_desc->dsc_flags |= DSC_null;
}
else
@ -499,10 +501,10 @@ void EXE_assignment(thread_db* tdbb, jrd_nod* node)
temp.dsc_scale = 0;
temp.dsc_sub_type = 0;
temp.dsc_address = (UCHAR *) & null;
MOV_move(&temp, to_desc);
MOV_move(tdbb, &temp, to_desc);
if (null && to->nod_arg[e_arg_indicator]) {
to_desc = EVL_assign_to(tdbb, to->nod_arg[e_arg_indicator]);
MOV_move(&temp, to_desc);
MOV_move(tdbb, &temp, to_desc);
}
}
@ -2631,7 +2633,7 @@ static jrd_nod* looper(thread_db* tdbb, jrd_req* request, jrd_nod* in_node)
if (value && !(request->req_flags & req_null))
{
to_desc->dsc_flags &= ~DSC_null;
MOV_move(value, to_desc);
MOV_move(tdbb, value, to_desc);
}
}
}
@ -2970,7 +2972,7 @@ static jrd_nod* modify(thread_db* tdbb, jrd_nod* node, SSHORT which_trig)
(org_rpb->rpb_relation, org_record, i,
&org_desc))
{
MOV_move(&org_desc, &new_desc);
MOV_move(tdbb, &org_desc, &new_desc);
}
else {
SET_NULL(new_record, i);

View File

@ -443,6 +443,8 @@ void EXT_store(record_param* rpb, jrd_tra* transaction)
* Update an external file.
*
**************************************/
thread_db* tdbb = JRD_get_thread_data();
jrd_rel* relation = rpb->rpb_relation;
ExternalFile* file = relation->rel_file;
Record* record = rpb->rpb_record;
@ -454,7 +456,7 @@ void EXT_store(record_param* rpb, jrd_tra* transaction)
/* check if file is read only if read only then
post error we cannot write to this file */
if (file->ext_flags & EXT_readonly) {
Database* dbb = GET_DBB();
Database* dbb = tdbb->tdbb_database;
CHECK_DBB(dbb);
/* Distinguish error message for a ReadOnly database */
if (dbb->dbb_flags & DBB_read_only)
@ -481,11 +483,11 @@ void EXT_store(record_param* rpb, jrd_tra* transaction)
TEST_NULL(record, i))
{
UCHAR* p = record->rec_data + (IPTR) desc_ptr->dsc_address;
const Literal* literal = (Literal*) field->fld_missing_value;
Literal* literal = (Literal*) field->fld_missing_value;
if (literal) {
desc = *desc_ptr;
desc.dsc_address = p;
MOV_move(&literal->lit_desc, &desc);
MOV_move(tdbb, &literal->lit_desc, &desc);
}
else {
const UCHAR pad = (desc_ptr->dsc_dtype == dtype_text) ? ' ' : 0;

View File

@ -441,7 +441,7 @@ void FUN_evaluate(UserFunction* function, jrd_nod* node, impure_value* value)
}
else
{
MOV_move(input, &temp_desc);
MOV_move(tdbb, input, &temp_desc);
}
break;
@ -458,13 +458,13 @@ void FUN_evaluate(UserFunction* function, jrd_nod* node, impure_value* value)
}
else
{
MOV_move(input, &temp_desc);
MOV_move(tdbb, input, &temp_desc);
}
break;
case dtype_quad:
case dtype_array:
MOV_move(input, &temp_desc);
MOV_move(tdbb, input, &temp_desc);
break;
case dtype_blob:
@ -516,7 +516,7 @@ void FUN_evaluate(UserFunction* function, jrd_nod* node, impure_value* value)
default:
fb_assert(FALSE);
MOV_move(input, &temp_desc);
MOV_move(tdbb, input, &temp_desc);
break;
}
@ -869,7 +869,7 @@ static SLONG get_scalar_array(fun_repeat* arg,
for (; n; --n, to.dsc_address += to.dsc_length,
from.dsc_address += array_desc->iad_element_length)
{
MOV_move(&from, &to);
MOV_move(tdbb, &from, &to);
}
}
catch (const Firebird::Exception&)
@ -1048,7 +1048,7 @@ static void invoke(UserFunction* function,
else
if (return_dsc)
{
MOV_move(return_dsc, &value->vlu_desc);
MOV_move(tdbb, return_dsc, &value->vlu_desc);
}
else
{
@ -1087,7 +1087,7 @@ static void invoke(UserFunction* function,
case dtype_text:
temp_desc = value->vlu_desc;
temp_desc.dsc_address = temp_ptr;
MOV_move(&temp_desc, &value->vlu_desc);
MOV_move(tdbb, &temp_desc, &value->vlu_desc);
break;
case dtype_cstring:
@ -1097,7 +1097,7 @@ static void invoke(UserFunction* function,
temp_desc.dsc_address = temp_ptr;
temp_desc.dsc_length =
strlen(reinterpret_cast<char*>(temp_ptr)) + 1;
MOV_move(&temp_desc, &value->vlu_desc);
MOV_move(tdbb, &temp_desc, &value->vlu_desc);
break;
case dtype_varying:
@ -1105,7 +1105,7 @@ static void invoke(UserFunction* function,
temp_desc.dsc_address = temp_ptr;
temp_desc.dsc_length =
reinterpret_cast<vary*>(temp_ptr)->vary_length + sizeof(USHORT);
MOV_move(&temp_desc, &value->vlu_desc);
MOV_move(tdbb, &temp_desc, &value->vlu_desc);
break;
case dtype_timestamp:

View File

@ -583,7 +583,7 @@ int MOV_make_string2(Jrd::thread_db* tdbb,
}
void MOV_move(const dsc* from, dsc* to)
void MOV_move(Jrd::thread_db* tdbb, /*const*/ dsc* from, dsc* to)
{
/**************************************
*
@ -596,5 +596,11 @@ void MOV_move(const dsc* from, dsc* to)
*
**************************************/
CVT_move(from, to, ERR_post);
if (DTYPE_IS_BLOB_OR_QUAD(from->dsc_dtype) ||
DTYPE_IS_BLOB_OR_QUAD(to->dsc_dtype))
{
BLB_move(tdbb, from, to, NULL);
}
else
CVT_move(from, to, ERR_post);
}

View File

@ -51,6 +51,6 @@ GDS_TIME MOV_get_sql_time(const dsc*);
GDS_TIMESTAMP MOV_get_timestamp(const dsc*);
int MOV_make_string(const dsc*, USHORT, const char**, vary*, USHORT);
int MOV_make_string2(Jrd::thread_db*, const dsc*, USHORT, UCHAR**, Jrd::MoveBuffer&);
void MOV_move(const dsc*, dsc*);
void MOV_move(Jrd::thread_db*, /*const*/ dsc*, dsc*);
#endif // JRD_MOV_PROTO_H

View File

@ -111,11 +111,11 @@ static bool get_record(thread_db*, RecordSource*, RecordSource*, RSE_GET_MODE);
static bool get_union(thread_db*, RecordSource*, IRSB);
static void invalidate_child_rpbs(thread_db*, RecordSource*);
static void join_to_nulls(thread_db*, RecordSource*, StreamStack*);
static void map_sort_data(jrd_req*, SortMap*, UCHAR *);
static void map_sort_data(thread_db*, jrd_req*, SortMap*, UCHAR *);
static void open_merge(thread_db*, RecordSource*, irsb_mrg*);
static void open_procedure(thread_db*, RecordSource*, irsb_procedure*);
static void open_sort(thread_db*, RecordSource*, irsb_sort*, UINT64);
static void proc_assignment(const dsc*, const dsc*, UCHAR*, dsc*, SSHORT, Record*);
static void proc_assignment(thread_db*, const dsc*, const dsc*, UCHAR*, dsc*, SSHORT, Record*);
static void pop_rpbs(jrd_req*, RecordSource*);
static void push_rpbs(thread_db*, jrd_req*, RecordSource*);
static ULONG read_merge_block(thread_db*, merge_file*, ULONG);
@ -1182,7 +1182,7 @@ static bool get_merge_fetch(
current record in the record parameter block */
merge_file* mfb = &tail->irsb_mrg_file;
map_sort_data(tdbb->tdbb_request, (SortMap*) sub_rsb->rsb_arg[0],
map_sort_data(tdbb, tdbb->tdbb_request, (SortMap*) sub_rsb->rsb_arg[0],
get_merge_data(tdbb, mfb, record));
return true;
@ -1221,7 +1221,7 @@ static bool get_merge_fetch(thread_db* tdbb, RecordSource* rsb, SSHORT stream)
tail->irsb_mrg_equal_current = record;
merge_file* mfb = &tail->irsb_mrg_file;
map_sort_data(tdbb->tdbb_request, (SortMap*) sub_rsb->rsb_arg[0],
map_sort_data(tdbb, tdbb->tdbb_request, (SortMap*) sub_rsb->rsb_arg[0],
get_merge_data(tdbb, mfb, record));
return true;
@ -1311,7 +1311,7 @@ static bool get_merge_join(
/* Map data into target records and do comparison */
map_sort_data(request, map, get_merge_data(tdbb, mfb, record));
map_sort_data(tdbb, request, map, get_merge_data(tdbb, mfb, record));
const int result = compare(tdbb, highest_ptr[1], ptr[1]);
if (ptr != highest_ptr)
{
@ -1356,7 +1356,7 @@ static bool get_merge_join(
get_merge_record(tdbb, sort_rsb, tail, mode);
if (record < 0)
return false;
map_sort_data(request, (SortMap*) sort_rsb->rsb_arg[0],
map_sort_data(tdbb, request, (SortMap*) sort_rsb->rsb_arg[0],
get_merge_data(tdbb, mfb, record));
}
}
@ -1517,7 +1517,7 @@ static bool get_merge_join(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
/* Map data into target records and do comparison */
map_sort_data(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)
{
@ -1551,7 +1551,7 @@ static bool get_merge_join(thread_db* tdbb, RecordSource* rsb, irsb_mrg* impure)
const SLONG record = get_merge_record(tdbb, sort_rsb, tail);
if (record < 0)
return false;
map_sort_data(request, (SortMap*) sort_rsb->rsb_arg[0],
map_sort_data(tdbb, request, (SortMap*) sort_rsb->rsb_arg[0],
get_merge_data(tdbb, mfb, record));
}
}
@ -1770,13 +1770,14 @@ static bool get_procedure(thread_db* tdbb,
eos_desc.dsc_sub_type = 0;
eos_desc.dsc_flags = 0;
eos_desc.dsc_address = (UCHAR *) & eos;
MOV_move(&desc, &eos_desc);
MOV_move(tdbb, &desc, &eos_desc);
if (!eos)
return false;
for (int i = 0; i < rec_format->fmt_count; i++)
{
proc_assignment(&msg_format->fmt_desc[2 * i],
proc_assignment(tdbb,
&msg_format->fmt_desc[2 * i],
&msg_format->fmt_desc[2 * i + 1],
om,
&rec_format->fmt_desc[i],
@ -2334,7 +2335,7 @@ static bool get_record(thread_db* tdbb,
return false;
}
map_sort_data(request, (SortMap*) rsb->rsb_arg[0], data);
map_sort_data(tdbb, request, (SortMap*) rsb->rsb_arg[0], data);
#ifdef SCROLLABLE_CURSORS
/* fix up the sort data in case we need to retrieve it again */
@ -2689,7 +2690,7 @@ static void join_to_nulls(thread_db* tdbb, RecordSource* rsb, StreamStack* strea
}
static void map_sort_data(jrd_req* request, SortMap* map, UCHAR * data)
static void map_sort_data(thread_db* tdbb, jrd_req* request, SortMap* map, UCHAR * data)
{
/**************************************
*
@ -2767,7 +2768,7 @@ static void map_sort_data(jrd_req* request, SortMap* map, UCHAR * data)
if (flag)
SET_NULL(record, id);
else {
MOV_move(&from, &to);
MOV_move(tdbb, &from, &to);
CLEAR_NULL(record, id);
}
}
@ -3015,7 +3016,7 @@ static void open_sort(thread_db* tdbb, RecordSource* rsb, irsb_sort* impure, UIN
from, &to, INTL_KEY_SORT);
}
else
MOV_move(from, &to);
MOV_move(tdbb, from, &to);
}
}
}
@ -3054,7 +3055,7 @@ static void open_sort(thread_db* tdbb, RecordSource* rsb, irsb_sort* impure, UIN
}
static void proc_assignment(
static void proc_assignment(thread_db* tdbb,
const dsc* from_desc,
const dsc* flag_desc,
UCHAR* msg, // this param is logically const
@ -3082,7 +3083,7 @@ static void proc_assignment(
dsc desc1;
desc1 = *flag_desc;
desc1.dsc_address = msg + (IPTR) flag_desc->dsc_address;
MOV_move(&desc1, &desc2);
MOV_move(tdbb, &desc1, &desc2);
if (indicator) {
SET_NULL(record, to_id);
const USHORT l = to_desc->dsc_length;
@ -3127,7 +3128,7 @@ static void proc_assignment(
desc2 = *to_desc;
desc2.dsc_address = record->rec_data + (IPTR) desc2.dsc_address;
if (!DSC_EQUIV((&desc1), (&desc2), false))
MOV_move(&desc1, &desc2);
MOV_move(tdbb, &desc1, &desc2);
else if (desc1.dsc_dtype == dtype_short)
*((SSHORT *) desc2.dsc_address) = *((SSHORT *) desc1.dsc_address);

View File

@ -121,7 +121,7 @@ static int prepare_update(thread_db*, jrd_tra*, SLONG, record_param*,
static void purge(thread_db*, record_param*);
static Record* replace_gc_record(jrd_rel*, Record**, USHORT);
static void replace_record(thread_db*, record_param*, PageStack*, const jrd_tra*);
static void set_system_flag(record_param*, USHORT, SSHORT);
static void set_system_flag(thread_db*, record_param*, USHORT, SSHORT);
static void update_in_place(thread_db*, jrd_tra*, record_param*, record_param*);
static void verb_post(thread_db*, jrd_tra*, record_param*, Record*, record_param*,
const bool, const bool);
@ -2649,7 +2649,7 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
EVL_field(0, rpb->rpb_record, f_rel_name, &desc);
DFW_post_work(transaction, dfw_create_relation, &desc, 0);
DFW_post_work(transaction, dfw_update_format, &desc, 0);
set_system_flag(rpb, f_rel_sys_flag, 0);
set_system_flag(tdbb, rpb, f_rel_sys_flag, 0);
break;
case rel_procedures:
@ -2671,7 +2671,7 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
if (check_blr)
DFW_post_work_arg(transaction, work, NULL, 0)->dfw_type = dfw_arg_check_blr;
} // scope
set_system_flag(rpb, f_prc_sys_flag, 0);
set_system_flag(tdbb, rpb, f_prc_sys_flag, 0);
break;
case rel_indices:
@ -2692,7 +2692,7 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
EVL_field(0, rpb->rpb_record, f_rfr_rname, &desc);
SCL_check_relation(&desc, SCL_control);
DFW_post_work(transaction, dfw_update_format, &desc, 0);
set_system_flag(rpb, f_rfr_sys_flag, 0);
set_system_flag(tdbb, rpb, f_rfr_sys_flag, 0);
break;
case rel_classes:
@ -2702,7 +2702,7 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
case rel_fields:
check_control(tdbb);
set_system_flag(rpb, f_fld_sys_flag, 0);
set_system_flag(tdbb, rpb, f_fld_sys_flag, 0);
break;
case rel_files:
@ -4836,7 +4836,7 @@ static void replace_record(thread_db* tdbb,
static void set_system_flag(record_param* rpb, USHORT field_id, SSHORT flag)
static void set_system_flag(thread_db* tdbb, record_param* rpb, USHORT field_id, SSHORT flag)
{
/**************************************
*
@ -4861,7 +4861,7 @@ static void set_system_flag(record_param* rpb, USHORT field_id, SSHORT flag)
desc2.dsc_scale = 0;
desc2.dsc_sub_type = 0;
desc2.dsc_address = (UCHAR *) & flag;
MOV_move(&desc2, &desc1);
MOV_move(tdbb, &desc2, &desc1);
CLEAR_NULL(record, field_id);
}