mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 06:03:02 +01:00
Cleanup: remove blr_prot_mask and blr_lock_state support
This commit is contained in:
parent
0ac7b3e9d9
commit
38ba5852ae
@ -7276,11 +7276,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
|
||||
|
||||
// I think this should be the responsability of DFW or the user will find ways to
|
||||
// circumvent DYN.
|
||||
if (!DYN_UTIL_get_prot(tdbb, transaction, PREL.RDB$RELATION_NAME, "", &priv))
|
||||
{
|
||||
// ASF: DYN_UTIL_get_prot will throw instead of return false.
|
||||
fb_assert(false);
|
||||
}
|
||||
priv = SCL_get_mask(tdbb, PREL.RDB$RELATION_NAME, "");
|
||||
|
||||
if (!(priv & SCL_read))
|
||||
{
|
||||
|
@ -127,9 +127,9 @@ static const struct
|
||||
{NULL, NULL},
|
||||
{"function", function}, // 100
|
||||
{"gen_id", gen_id},
|
||||
{"prot_mask", two},
|
||||
{NULL, NULL},
|
||||
{"upcase", one},
|
||||
{"lock_state", one},
|
||||
{NULL, NULL},
|
||||
{"value_if", three},
|
||||
{"matching2", three},
|
||||
{"index", indx},
|
||||
|
@ -198,9 +198,9 @@
|
||||
|
||||
#define blr_function (unsigned char)100
|
||||
#define blr_gen_id (unsigned char)101
|
||||
#define blr_prot_mask (unsigned char)102
|
||||
///#define blr_prot_mask (unsigned char)102
|
||||
#define blr_upcase (unsigned char)103
|
||||
#define blr_lock_state (unsigned char)104
|
||||
///#define blr_lock_state (unsigned char)104
|
||||
#define blr_value_if (unsigned char)105
|
||||
#define blr_matching2 (unsigned char)106
|
||||
#define blr_index (unsigned char)107
|
||||
|
@ -481,10 +481,8 @@ void CMP_get_desc(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node, DSC* des
|
||||
}
|
||||
break;
|
||||
|
||||
case nod_prot_mask:
|
||||
case nod_null:
|
||||
case nod_count:
|
||||
case nod_lock_state:
|
||||
desc->dsc_dtype = dtype_long;
|
||||
desc->dsc_length = sizeof(SLONG);
|
||||
desc->dsc_scale = 0;
|
||||
@ -3161,8 +3159,6 @@ jrd_nod* CMP_pass2(thread_db* tdbb, CompilerScratch* csb, jrd_nod* const node, j
|
||||
case nod_rec_version:
|
||||
case nod_substr:
|
||||
case nod_null:
|
||||
case nod_prot_mask:
|
||||
case nod_lock_state:
|
||||
case nod_scalar:
|
||||
case nod_cast:
|
||||
case nod_extract:
|
||||
|
@ -49,7 +49,6 @@
|
||||
|
||||
enum drq_type_t
|
||||
{
|
||||
drq_l_prot_mask, // lookup protection mask
|
||||
drq_s_rel_con, // store relation constraints
|
||||
drq_s_chk_con, // store check constraints
|
||||
drq_s_ref_con, // store ref constraints
|
||||
|
@ -35,8 +35,6 @@ void DYN_UTIL_store_check_constraints(Jrd::thread_db*, Jrd::jrd_tra*,
|
||||
bool DYN_UTIL_find_field_source(Jrd::thread_db* tdbb, Jrd::jrd_tra* transaction,
|
||||
const Firebird::MetaName& view_name, USHORT context, const TEXT* local_name,
|
||||
TEXT* output_field_name);
|
||||
bool DYN_UTIL_get_prot(Jrd::thread_db*, Jrd::jrd_tra*, const SCHAR*,
|
||||
const SCHAR*, Jrd::SecurityClass::flags_t*);
|
||||
void DYN_UTIL_generate_generator_name(Jrd::thread_db*, Firebird::MetaName&);
|
||||
void DYN_UTIL_generate_trigger_name(Jrd::thread_db*, Jrd::jrd_tra*, Firebird::MetaName&);
|
||||
void DYN_UTIL_generate_index_name(Jrd::thread_db*, Jrd::jrd_tra*, Firebird::MetaName&, UCHAR);
|
||||
|
@ -82,31 +82,6 @@ static const UCHAR gen_id_blr2[] =
|
||||
blr_parameter, 0, 0, 0, blr_end, blr_end, blr_end, blr_eoc
|
||||
};
|
||||
|
||||
static const UCHAR prot_blr[] =
|
||||
{
|
||||
blr_version5,
|
||||
blr_begin,
|
||||
blr_message, 1, 1, 0,
|
||||
blr_short, 0,
|
||||
blr_message, 0, 2, 0,
|
||||
blr_cstring, 32, 0,
|
||||
blr_cstring, 32, 0,
|
||||
blr_receive, 0,
|
||||
blr_begin,
|
||||
blr_send, 1,
|
||||
blr_begin,
|
||||
blr_assignment,
|
||||
blr_prot_mask,
|
||||
blr_parameter, 0, 0, 0,
|
||||
blr_parameter, 0, 1, 0,
|
||||
blr_parameter, 1, 0, 0,
|
||||
blr_end,
|
||||
blr_end,
|
||||
blr_end,
|
||||
blr_eoc
|
||||
};
|
||||
|
||||
|
||||
void DYN_UTIL_check_unique_name(thread_db* tdbb, jrd_tra* transaction,
|
||||
const Firebird::MetaName& object_name, int object_type)
|
||||
{
|
||||
@ -636,49 +611,6 @@ bool DYN_UTIL_find_field_source(thread_db* tdbb,
|
||||
}
|
||||
|
||||
|
||||
bool DYN_UTIL_get_prot(thread_db* tdbb, jrd_tra* transaction, const SCHAR* rname,
|
||||
const SCHAR* fname, SecurityClass::flags_t* prot_mask)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* D Y N _ U T I L _ g e t _ p r o t
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Get protection mask for relation or relation_field
|
||||
*
|
||||
**************************************/
|
||||
struct
|
||||
{
|
||||
SqlIdentifier relation_name;
|
||||
SqlIdentifier field_name;
|
||||
} in_msg;
|
||||
|
||||
SET_TDBB(tdbb);
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_l_prot_mask, DYN_REQUESTS);
|
||||
|
||||
try
|
||||
{
|
||||
request.compile(tdbb, prot_blr, sizeof(prot_blr));
|
||||
|
||||
gds__vtov(rname, in_msg.relation_name, sizeof(in_msg.relation_name));
|
||||
gds__vtov(fname, in_msg.field_name, sizeof(in_msg.field_name));
|
||||
EXE_start(tdbb, request, transaction);
|
||||
EXE_send(tdbb, request, 0, sizeof(in_msg), (UCHAR*) &in_msg);
|
||||
EXE_receive(tdbb, request, 1, sizeof(SecurityClass::flags_t), (UCHAR*) prot_mask);
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void DYN_UTIL_store_check_constraints(thread_db* tdbb, jrd_tra* transaction,
|
||||
const MetaName& constraint_name, const MetaName& trigger_name)
|
||||
{
|
||||
|
119
src/jrd/evl.cpp
119
src/jrd/evl.cpp
@ -122,8 +122,6 @@ static dsc* cast(thread_db*, dsc*, const jrd_nod*, impure_value*);
|
||||
static dsc* dbkey(thread_db*, const jrd_nod*, impure_value*);
|
||||
static dsc* eval_statistical(thread_db*, const jrd_nod*, impure_value*);
|
||||
static dsc* extract(thread_db*, const jrd_nod*, impure_value*);
|
||||
static dsc* get_mask(thread_db*, const jrd_nod*, impure_value*);
|
||||
static dsc* lock_state(thread_db*, const jrd_nod*, impure_value*);
|
||||
static dsc* record_version(thread_db*, const jrd_nod*, impure_value*);
|
||||
static dsc* scalar(thread_db*, const jrd_nod*, impure_value*);
|
||||
static dsc* string_length(thread_db*, const jrd_nod*, impure_value*);
|
||||
@ -471,16 +469,10 @@ dsc* EVL_expr(thread_db* tdbb, const jrd_nod* node)
|
||||
case nod_literal:
|
||||
return &((Literal*) node)->lit_desc;
|
||||
|
||||
case nod_lock_state:
|
||||
return lock_state(tdbb, node, impure);
|
||||
|
||||
case nod_null:
|
||||
request->req_flags |= req_null;
|
||||
return NULL;
|
||||
|
||||
case nod_prot_mask:
|
||||
return get_mask(tdbb, node, impure);
|
||||
|
||||
case nod_extract:
|
||||
return extract(tdbb, node, impure);
|
||||
|
||||
@ -1419,117 +1411,6 @@ static dsc* extract(thread_db* tdbb, const jrd_nod* node, impure_value* impure)
|
||||
}
|
||||
|
||||
|
||||
static dsc* get_mask(thread_db* tdbb, const jrd_nod* node, impure_value* impure)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* g e t _ m a s k
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Compute protection mask.
|
||||
*
|
||||
**************************************/
|
||||
SET_TDBB(tdbb);
|
||||
|
||||
DEV_BLKCHK(node, type_nod);
|
||||
|
||||
jrd_req* request = tdbb->getRequest();
|
||||
TEXT* p1 = NULL;
|
||||
TEXT* p2 = NULL;
|
||||
SqlIdentifier relation_name, field_name;
|
||||
|
||||
const dsc* value = EVL_expr(tdbb, node->nod_arg[0]);
|
||||
if (!(request->req_flags & req_null))
|
||||
{
|
||||
p1 = relation_name;
|
||||
MOV_get_name(value, p1);
|
||||
value = EVL_expr(tdbb, node->nod_arg[1]);
|
||||
if (!(request->req_flags & req_null))
|
||||
{
|
||||
p2 = field_name;
|
||||
MOV_get_name(value, p2);
|
||||
}
|
||||
}
|
||||
|
||||
request->req_flags &= ~req_null;
|
||||
|
||||
// SecurityClass::flags_t is USHORT for now, so it fits in vlu_long.
|
||||
impure->make_long(SCL_get_mask(tdbb, p1, p2));
|
||||
return &impure->vlu_desc;
|
||||
}
|
||||
|
||||
|
||||
static dsc* lock_state(thread_db* tdbb, const jrd_nod* node, impure_value* impure)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* l o c k _ s t a t e
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Compute state of an attachment id. The values
|
||||
* returned are:
|
||||
*
|
||||
* 0 - value is null
|
||||
* 1 - attachment is gone
|
||||
* 2 - we are that attachment
|
||||
* 3 - attachment is active
|
||||
*
|
||||
**************************************/
|
||||
SET_TDBB(tdbb);
|
||||
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
DEV_BLKCHK(node, type_nod);
|
||||
|
||||
// Initialize descriptor
|
||||
|
||||
impure->vlu_desc.dsc_address = (UCHAR *) & impure->vlu_misc.vlu_long;
|
||||
impure->vlu_desc.dsc_dtype = dtype_long;
|
||||
impure->vlu_desc.dsc_length = sizeof(SLONG);
|
||||
impure->vlu_desc.dsc_scale = 0;
|
||||
|
||||
// Evaluate attachment id
|
||||
|
||||
jrd_req* request = tdbb->getRequest();
|
||||
const dsc* desc = EVL_expr(tdbb, node->nod_arg[0]);
|
||||
|
||||
if (request->req_flags & req_null)
|
||||
impure->vlu_misc.vlu_long = 0;
|
||||
else
|
||||
{
|
||||
const SLONG id = MOV_get_long(desc, 0);
|
||||
if (id == PAG_attachment_id(tdbb))
|
||||
impure->vlu_misc.vlu_long = 2;
|
||||
else
|
||||
{
|
||||
Lock temp_lock;
|
||||
// fill out a lock block, zeroing it out first
|
||||
|
||||
temp_lock.lck_parent = dbb->dbb_lock;
|
||||
temp_lock.lck_type = LCK_attachment;
|
||||
temp_lock.lck_owner_handle = LCK_get_owner_handle(tdbb, temp_lock.lck_type);
|
||||
temp_lock.lck_length = sizeof(SLONG);
|
||||
temp_lock.lck_key.lck_long = id;
|
||||
temp_lock.lck_dbb = dbb;
|
||||
|
||||
if (LCK_lock(tdbb, &temp_lock, LCK_write, LCK_NO_WAIT))
|
||||
{
|
||||
impure->vlu_misc.vlu_long = 1;
|
||||
LCK_release(tdbb, &temp_lock);
|
||||
}
|
||||
else
|
||||
impure->vlu_misc.vlu_long = 3;
|
||||
}
|
||||
}
|
||||
|
||||
return &impure->vlu_desc;
|
||||
}
|
||||
|
||||
|
||||
static dsc* record_version(thread_db* tdbb, const jrd_nod* node, impure_value* impure)
|
||||
{
|
||||
/**************************************
|
||||
|
@ -63,8 +63,6 @@ NODE(nod_field, field, "")
|
||||
NODE(nod_from, from, "")
|
||||
NODE(nod_literal, literal, "")
|
||||
NODE(nod_scalar, scalar, "")
|
||||
NODE(nod_prot_mask, prot_mask, "")
|
||||
NODE(nod_lock_state, lock_state, "")
|
||||
NODE(nod_null, null, "NULL")
|
||||
NODE(nod_substr, substr, "")
|
||||
NODE(nod_cast, cast, "CAST")
|
||||
|
@ -2284,14 +2284,12 @@ jrd_nod* PAR_parse_node(thread_db* tdbb, CompilerScratch* csb, USHORT expected)
|
||||
*arg++ = PAR_parse_node(tdbb, csb, sub_type);
|
||||
break;
|
||||
|
||||
case blr_prot_mask:
|
||||
case blr_assignment:
|
||||
*arg++ = PAR_parse_node(tdbb, csb, sub_type);
|
||||
// Fall into ...
|
||||
|
||||
case blr_handler:
|
||||
case blr_loop:
|
||||
case blr_lock_state:
|
||||
*arg++ = PAR_parse_node(tdbb, csb, sub_type);
|
||||
break;
|
||||
|
||||
|
@ -136,9 +136,7 @@ static const VERB verbs[] =
|
||||
PAIR(nod_class_exprnode_jrd, blr_multiply, 1, 0, VALUE, VALUE),
|
||||
PAIR(nod_class_exprnode_jrd, blr_negate, 1, 0, VALUE, VALUE),
|
||||
PAIR(nod_class_exprnode_jrd, blr_gen_id, 1, 0, VALUE, VALUE),
|
||||
PAIR(nod_prot_mask, blr_prot_mask, e_pro_length, 2, VALUE, VALUE),
|
||||
PAIR(nod_class_exprnode_jrd, blr_upcase, 1, 0, VALUE, VALUE),
|
||||
PAIR(nod_lock_state, blr_lock_state, 1, 1, VALUE, VALUE),
|
||||
PAIR(nod_substr, blr_substring, 3, 3, VALUE, VALUE),
|
||||
PAIR(nod_class_exprnode_jrd, blr_subtract, 1, 0, VALUE, VALUE),
|
||||
PAIR2(nod_total, blr_total, e_stat_length, 2, VALUE, VALUE),
|
||||
|
Loading…
Reference in New Issue
Block a user