mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 00:03:03 +01:00
Use AutoCacheRequest in all cacheable system requests. Fixes some request leakages.
This commit is contained in:
parent
0fc47599d4
commit
39498cb65b
@ -74,8 +74,6 @@ static const UCHAR blr_bpb[] =
|
||||
static void convert_dtype(dsql_fld*, SSHORT);
|
||||
static void free_relation(dsql_rel*);
|
||||
|
||||
#define DSQL_REQUEST(id) dbb->dbb_database->dbb_internal[id]
|
||||
|
||||
namespace
|
||||
{
|
||||
inline void validateTransaction(const jrd_tra* transaction)
|
||||
@ -286,17 +284,14 @@ dsql_intlsym* METD_get_collation(jrd_tra* transaction, const dsql_str* name, USH
|
||||
|
||||
symbol = NULL;
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_collation, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_collation, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$COLLATIONS
|
||||
CROSS Y IN RDB$CHARACTER_SETS OVER RDB$CHARACTER_SET_ID
|
||||
WITH X.RDB$COLLATION_NAME EQ name->str_data AND
|
||||
X.RDB$CHARACTER_SET_ID EQ charset_id;
|
||||
|
||||
if (!DSQL_REQUEST(irq_collation))
|
||||
DSQL_REQUEST(irq_collation) = handle;
|
||||
|
||||
{
|
||||
symbol = FB_NEW(dbb->dbb_pool) dsql_intlsym(dbb->dbb_pool);
|
||||
symbol->intlsym_name = metaName;
|
||||
symbol->intlsym_flags = 0;
|
||||
@ -306,12 +301,9 @@ dsql_intlsym* METD_get_collation(jrd_tra* transaction, const dsql_str* name, USH
|
||||
INTL_CS_COLL_TO_TTYPE(symbol->intlsym_charset_id, symbol->intlsym_collate_id);
|
||||
symbol->intlsym_bytes_per_char =
|
||||
(Y.RDB$BYTES_PER_CHARACTER.NULL) ? 1 : (Y.RDB$BYTES_PER_CHARACTER);
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_collation))
|
||||
DSQL_REQUEST(irq_collation) = handle;
|
||||
|
||||
if (!symbol)
|
||||
return NULL;
|
||||
|
||||
@ -354,7 +346,7 @@ USHORT METD_get_col_default(jrd_tra* transaction, const char* for_rel_name,
|
||||
|
||||
*has_default = false;
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_col_default, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_col_default, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
RFL IN RDB$RELATION_FIELDS CROSS
|
||||
@ -362,10 +354,7 @@ USHORT METD_get_col_default(jrd_tra* transaction, const char* for_rel_name,
|
||||
RFL.RDB$RELATION_NAME EQ for_rel_name AND
|
||||
RFL.RDB$FIELD_SOURCE EQ FLD.RDB$FIELD_NAME AND
|
||||
RFL.RDB$FIELD_NAME EQ for_col_name
|
||||
|
||||
if (!DSQL_REQUEST(irq_col_default))
|
||||
DSQL_REQUEST(irq_col_default) = handle;
|
||||
|
||||
{
|
||||
if (!RFL.RDB$DEFAULT_VALUE.NULL)
|
||||
{
|
||||
blob_id = &RFL.RDB$DEFAULT_VALUE;
|
||||
@ -430,12 +419,9 @@ USHORT METD_get_col_default(jrd_tra* transaction, const char* for_rel_name,
|
||||
buffer[1] = blr_eoc;
|
||||
result = 2;
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_col_default))
|
||||
DSQL_REQUEST(irq_col_default) = handle;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -475,7 +461,7 @@ dsql_intlsym* METD_get_charset(jrd_tra* transaction, USHORT length, const char*
|
||||
|
||||
symbol = NULL;
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_charset, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_charset, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$COLLATIONS
|
||||
@ -485,10 +471,7 @@ dsql_intlsym* METD_get_charset(jrd_tra* transaction, USHORT length, const char*
|
||||
AND Z.RDB$TYPE_NAME EQ name
|
||||
AND Z.RDB$FIELD_NAME EQ "RDB$CHARACTER_SET_NAME"
|
||||
AND Y.RDB$DEFAULT_COLLATE_NAME EQ X.RDB$COLLATION_NAME;
|
||||
|
||||
if (!DSQL_REQUEST(irq_charset))
|
||||
DSQL_REQUEST(irq_charset) = handle;
|
||||
|
||||
{
|
||||
symbol = FB_NEW(dbb->dbb_pool) dsql_intlsym(dbb->dbb_pool);
|
||||
symbol->intlsym_name = metaName;
|
||||
symbol->intlsym_flags = 0;
|
||||
@ -498,12 +481,9 @@ dsql_intlsym* METD_get_charset(jrd_tra* transaction, USHORT length, const char*
|
||||
INTL_CS_COLL_TO_TTYPE(symbol->intlsym_charset_id, symbol->intlsym_collate_id);
|
||||
symbol->intlsym_bytes_per_char =
|
||||
(Y.RDB$BYTES_PER_CHARACTER.NULL) ? 1 : (Y.RDB$BYTES_PER_CHARACTER);
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_charset))
|
||||
DSQL_REQUEST(irq_charset) = handle;
|
||||
|
||||
if (!symbol)
|
||||
return NULL;
|
||||
|
||||
@ -581,22 +561,16 @@ MetaName METD_get_charset_name(jrd_tra* transaction, SSHORT charset_id)
|
||||
|
||||
MetaName name;
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_cs_name, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_cs_name, IRQ_REQUESTS);
|
||||
|
||||
FOR (REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
Y IN RDB$CHARACTER_SETS
|
||||
WITH Y.RDB$CHARACTER_SET_ID EQ charset_id
|
||||
|
||||
if (!DSQL_REQUEST(irq_cs_name))
|
||||
DSQL_REQUEST(irq_cs_name) = handle;
|
||||
|
||||
{
|
||||
name = Y.RDB$CHARACTER_SET_NAME;
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_cs_name))
|
||||
DSQL_REQUEST(irq_cs_name) = handle;
|
||||
|
||||
// put new charset into hash table if needed
|
||||
METD_get_charset(transaction, name.length(), name.c_str());
|
||||
|
||||
@ -629,15 +603,12 @@ dsql_str* METD_get_default_charset(jrd_tra* transaction)
|
||||
|
||||
// Now see if it is in the database
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_default_cs, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_default_cs, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
FIRST 1 DBB IN RDB$DATABASE
|
||||
WITH DBB.RDB$CHARACTER_SET_NAME NOT MISSING;
|
||||
|
||||
if (!DSQL_REQUEST(irq_default_cs))
|
||||
DSQL_REQUEST(irq_default_cs) = handle;
|
||||
|
||||
{
|
||||
// Terminate ASCIIZ string on first trailing blank
|
||||
fb_utils::exact_name(DBB.RDB$CHARACTER_SET_NAME);
|
||||
const USHORT length = strlen(DBB.RDB$CHARACTER_SET_NAME);
|
||||
@ -645,12 +616,9 @@ dsql_str* METD_get_default_charset(jrd_tra* transaction)
|
||||
dbb->dbb_dfl_charset->str_length = length;
|
||||
dbb->dbb_dfl_charset->str_charset = NULL;
|
||||
memcpy(dbb->dbb_dfl_charset->str_data, DBB.RDB$CHARACTER_SET_NAME, length);
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_default_cs))
|
||||
DSQL_REQUEST(irq_default_cs) = handle;
|
||||
|
||||
if (!dbb->dbb_dfl_charset)
|
||||
dbb->dbb_no_charset = true;
|
||||
|
||||
@ -678,14 +646,11 @@ bool METD_get_domain(jrd_tra* transaction, dsql_fld* field, const char* name) //
|
||||
|
||||
dsql_dbb* dbb = transaction->getDsqlAttachment();
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_domain, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_domain, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
FLX IN RDB$FIELDS WITH FLX.RDB$FIELD_NAME EQ name
|
||||
|
||||
if (!DSQL_REQUEST(irq_domain))
|
||||
DSQL_REQUEST(irq_domain) = handle;
|
||||
|
||||
{
|
||||
found = true;
|
||||
field->fld_length = FLX.RDB$FIELD_LENGTH;
|
||||
field->fld_scale = FLX.RDB$FIELD_SCALE;
|
||||
@ -713,12 +678,9 @@ bool METD_get_domain(jrd_tra* transaction, dsql_fld* field, const char* name) //
|
||||
if (FLX.RDB$FIELD_TYPE == blr_blob) {
|
||||
field->fld_seg_length = FLX.RDB$SEGMENT_LENGTH;
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_domain))
|
||||
DSQL_REQUEST(irq_domain) = handle;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@ -745,14 +707,11 @@ USHORT METD_get_domain_default(jrd_tra* transaction, const TEXT* domain_name, bo
|
||||
dsql_dbb* dbb = transaction->getDsqlAttachment();
|
||||
USHORT result = 0;
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_domain_2, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_domain_2, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
FLD IN RDB$FIELDS WITH FLD.RDB$FIELD_NAME EQ domain_name
|
||||
|
||||
if (!DSQL_REQUEST(irq_domain_2))
|
||||
DSQL_REQUEST(irq_domain_2) = handle;
|
||||
|
||||
{
|
||||
bid* blob_id;
|
||||
if (!FLD.RDB$DEFAULT_VALUE.NULL)
|
||||
{
|
||||
@ -813,12 +772,9 @@ USHORT METD_get_domain_default(jrd_tra* transaction, const TEXT* domain_name, bo
|
||||
buffer[1] = blr_eoc;
|
||||
result = 2;
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_domain_2))
|
||||
DSQL_REQUEST(irq_domain_2) = handle;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -842,22 +798,16 @@ bool METD_get_exception(jrd_tra* transaction, const dsql_str* name)
|
||||
dsql_dbb* dbb = transaction->getDsqlAttachment();
|
||||
bool found = false;
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_exception, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_exception, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$EXCEPTIONS WITH
|
||||
X.RDB$EXCEPTION_NAME EQ name->str_data;
|
||||
|
||||
if (!DSQL_REQUEST(irq_exception))
|
||||
DSQL_REQUEST(irq_exception) = handle;
|
||||
|
||||
{
|
||||
found = true;
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_exception))
|
||||
DSQL_REQUEST(irq_exception) = handle;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@ -910,27 +860,21 @@ dsql_udf* METD_get_function(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
|
||||
|
||||
while (!userFunc)
|
||||
{
|
||||
jrd_req* handle1 = CMP_find_request(tdbb, irq_function, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle1(tdbb, irq_function, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle1 TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$FUNCTIONS WITH
|
||||
X.RDB$FUNCTION_NAME EQ metaName.identifier.c_str() AND
|
||||
X.RDB$PACKAGE_NAME EQUIV NULLIF(metaName.package.c_str(), '')
|
||||
|
||||
if (!DSQL_REQUEST(irq_function))
|
||||
DSQL_REQUEST(irq_function) = handle1;
|
||||
|
||||
{
|
||||
userFunc = FB_NEW(dbb->dbb_pool) dsql_udf(dbb->dbb_pool);
|
||||
userFunc->udf_name = metaName;
|
||||
userFunc->udf_private = !X.RDB$PRIVATE_FLAG.NULL && X.RDB$PRIVATE_FLAG != 0;
|
||||
|
||||
return_arg = X.RDB$RETURN_ARGUMENT;
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_function))
|
||||
DSQL_REQUEST(irq_function) = handle1;
|
||||
|
||||
if (!userFunc)
|
||||
{
|
||||
if (maybeUnqualified)
|
||||
@ -943,28 +887,22 @@ dsql_udf* METD_get_function(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
|
||||
}
|
||||
}
|
||||
|
||||
jrd_req* handle2 = CMP_find_request(tdbb, irq_func_return, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle2(tdbb, irq_func_return, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle2 TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$FUNCTION_ARGUMENTS WITH
|
||||
X.RDB$FUNCTION_NAME EQ metaName.identifier.c_str() AND
|
||||
X.RDB$PACKAGE_NAME EQUIV NULLIF(metaName.package.c_str(), '')
|
||||
SORTED BY X.RDB$ARGUMENT_POSITION
|
||||
|
||||
if (!DSQL_REQUEST(irq_func_return))
|
||||
DSQL_REQUEST(irq_func_return) = handle2;
|
||||
|
||||
{
|
||||
if (!X.RDB$FIELD_SOURCE.NULL)
|
||||
{
|
||||
jrd_req* handle3 = CMP_find_request(tdbb, irq_func_ret_fld, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle3(tdbb, irq_func_ret_fld, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle3 TRANSACTION_HANDLE transaction)
|
||||
F IN RDB$FIELDS WITH
|
||||
F.RDB$FIELD_NAME EQ X.RDB$FIELD_SOURCE
|
||||
|
||||
if (!DSQL_REQUEST(irq_func_ret_fld))
|
||||
DSQL_REQUEST(irq_func_ret_fld) = handle3;
|
||||
|
||||
{
|
||||
if (X.RDB$ARGUMENT_POSITION == return_arg)
|
||||
{
|
||||
userFunc->udf_dtype = (F.RDB$FIELD_TYPE != blr_blob) ?
|
||||
@ -1027,10 +965,8 @@ dsql_udf* METD_get_function(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
|
||||
|
||||
userFunc->udf_arguments.add(d);
|
||||
}
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_func_ret_fld))
|
||||
DSQL_REQUEST(irq_func_ret_fld) = handle3;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1097,12 +1033,9 @@ dsql_udf* METD_get_function(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
|
||||
userFunc->udf_arguments.add(d);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_func_return))
|
||||
DSQL_REQUEST(irq_func_return) = handle2;
|
||||
|
||||
// Adjust the return type & length of the UDF to account for
|
||||
// cstring & varying. While a UDF can return CSTRING, we convert it
|
||||
// to VARCHAR for manipulation as CSTRING is not a SQL type.
|
||||
@ -1153,7 +1086,7 @@ dsql_nod* METD_get_primary_key(jrd_tra* transaction, const dsql_str* relation_na
|
||||
|
||||
DsqlNodStack stack;
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_primary_key, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_primary_key, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$INDICES CROSS
|
||||
@ -1164,17 +1097,11 @@ dsql_nod* METD_get_primary_key(jrd_tra* transaction, const dsql_str* relation_na
|
||||
WITH Z.RDB$RELATION_NAME EQ relation_name->str_data
|
||||
AND Z.RDB$CONSTRAINT_TYPE EQ "PRIMARY KEY"
|
||||
SORTED BY Y.RDB$FIELD_POSITION
|
||||
|
||||
if (!DSQL_REQUEST(irq_primary_key))
|
||||
DSQL_REQUEST(irq_primary_key) = handle;
|
||||
|
||||
{
|
||||
stack.push(MAKE_field_name(Y.RDB$FIELD_NAME));
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_primary_key))
|
||||
DSQL_REQUEST(irq_primary_key) = handle;
|
||||
|
||||
return (stack.getCount() ? MAKE_list(stack) : NULL);
|
||||
}
|
||||
|
||||
@ -1261,16 +1188,13 @@ dsql_prc* METD_get_procedure(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
|
||||
|
||||
while (!procedure)
|
||||
{
|
||||
jrd_req* handle1 = CMP_find_request(tdbb, irq_procedure, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle1(tdbb, irq_procedure, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle1 TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$PROCEDURES
|
||||
WITH X.RDB$PROCEDURE_NAME EQ name->str_data AND
|
||||
X.RDB$PACKAGE_NAME EQUIV NULLIF(metaName.package.c_str(), '')
|
||||
|
||||
if (!DSQL_REQUEST(irq_procedure))
|
||||
DSQL_REQUEST(irq_procedure) = handle1;
|
||||
|
||||
{
|
||||
fb_utils::exact_name(X.RDB$OWNER_NAME);
|
||||
|
||||
procedure = FB_NEW(dbb->dbb_pool) dsql_prc(dbb->dbb_pool);
|
||||
@ -1278,12 +1202,9 @@ dsql_prc* METD_get_procedure(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
|
||||
procedure->prc_name = metaName;
|
||||
procedure->prc_owner = X.RDB$OWNER_NAME;
|
||||
procedure->prc_private = !X.RDB$PRIVATE_FLAG.NULL && X.RDB$PRIVATE_FLAG != 0;
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_procedure))
|
||||
DSQL_REQUEST(irq_procedure) = handle1;
|
||||
|
||||
if (!procedure)
|
||||
{
|
||||
if (maybeUnqualified)
|
||||
@ -1304,7 +1225,7 @@ dsql_prc* METD_get_procedure(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
|
||||
|
||||
SSHORT count = 0, defaults = 0;
|
||||
|
||||
jrd_req* handle2 = CMP_find_request(tdbb, irq_parameters, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle2(tdbb, irq_parameters, IRQ_REQUESTS);
|
||||
|
||||
FOR (REQUEST_HANDLE handle2 TRANSACTION_HANDLE transaction)
|
||||
PR IN RDB$PROCEDURE_PARAMETERS
|
||||
@ -1314,10 +1235,7 @@ dsql_prc* METD_get_procedure(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
|
||||
PR.RDB$PARAMETER_TYPE = type AND
|
||||
PR.RDB$PACKAGE_NAME EQUIV NULLIF(metaName.package.c_str(), '')
|
||||
SORTED BY DESCENDING PR.RDB$PARAMETER_NUMBER
|
||||
|
||||
if (!DSQL_REQUEST(irq_parameters))
|
||||
DSQL_REQUEST(irq_parameters) = handle2;
|
||||
|
||||
{
|
||||
const SSHORT pr_collation_id_null = PR.RDB$COLLATION_ID.NULL;
|
||||
const SSHORT pr_collation_id = PR.RDB$COLLATION_ID;
|
||||
|
||||
@ -1377,12 +1295,9 @@ dsql_prc* METD_get_procedure(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
|
||||
{
|
||||
defaults++;
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_parameters))
|
||||
DSQL_REQUEST(irq_parameters) = handle2;
|
||||
|
||||
if (type)
|
||||
procedure->prc_out_count = count;
|
||||
else
|
||||
@ -1451,38 +1366,29 @@ dsql_rel* METD_get_relation(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
|
||||
|
||||
bool permanent = true;
|
||||
|
||||
jrd_req* handle1 = CMP_find_request(tdbb, irq_rel_ids, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle1(tdbb, irq_rel_ids, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle1 TRANSACTION_HANDLE transaction)
|
||||
REL IN RDB$RELATIONS
|
||||
CROSS RFR IN RDB$RELATION_FIELDS OVER RDB$RELATION_NAME
|
||||
WITH REL.RDB$RELATION_NAME EQ name->str_data
|
||||
AND (REL.RDB$RELATION_ID MISSING OR RFR.RDB$FIELD_ID MISSING)
|
||||
|
||||
if (!DSQL_REQUEST(irq_rel_ids))
|
||||
DSQL_REQUEST(irq_rel_ids) = handle1;
|
||||
|
||||
{
|
||||
permanent = false;
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_rel_ids))
|
||||
DSQL_REQUEST(irq_rel_ids) = handle1;
|
||||
|
||||
// Now see if it is in the database
|
||||
|
||||
MemoryPool& pool = permanent ? dbb->dbb_pool : *tdbb->getDefaultPool();
|
||||
|
||||
dsql_rel* relation = NULL;
|
||||
|
||||
jrd_req* handle2 = CMP_find_request(tdbb, irq_relation, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle2(tdbb, irq_relation, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle2 TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$RELATIONS WITH X.RDB$RELATION_NAME EQ name->str_data
|
||||
|
||||
if (!DSQL_REQUEST(irq_relation))
|
||||
DSQL_REQUEST(irq_relation) = handle2;
|
||||
|
||||
{
|
||||
fb_utils::exact_name(X.RDB$OWNER_NAME);
|
||||
|
||||
// Allocate from default or permanent pool as appropriate
|
||||
@ -1492,9 +1398,8 @@ dsql_rel* METD_get_relation(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
|
||||
relation = FB_NEW(pool) dsql_rel(pool);
|
||||
relation->rel_id = X.RDB$RELATION_ID;
|
||||
}
|
||||
else if (!DDL_ids(dsqlScratch)) {
|
||||
else if (!DDL_ids(dsqlScratch))
|
||||
relation = FB_NEW(pool) dsql_rel(pool);
|
||||
}
|
||||
|
||||
// fill out the relation information
|
||||
|
||||
@ -1505,28 +1410,22 @@ dsql_rel* METD_get_relation(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
|
||||
if (!(relation->rel_dbkey_length = X.RDB$DBKEY_LENGTH))
|
||||
relation->rel_dbkey_length = 8;
|
||||
// CVC: let's see if this is a table or a view.
|
||||
if (!X.RDB$VIEW_BLR.NULL) {
|
||||
if (!X.RDB$VIEW_BLR.NULL)
|
||||
relation->rel_flags |= REL_view;
|
||||
}
|
||||
if (!X.RDB$EXTERNAL_FILE.NULL) {
|
||||
if (!X.RDB$EXTERNAL_FILE.NULL)
|
||||
relation->rel_flags |= REL_external;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_relation))
|
||||
DSQL_REQUEST(irq_relation) = handle2;
|
||||
|
||||
if (!relation) {
|
||||
if (!relation)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Lookup field stuff
|
||||
|
||||
dsql_fld** ptr = &relation->rel_fields;
|
||||
|
||||
jrd_req* handle3 = CMP_find_request(tdbb, irq_fields, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle3(tdbb, irq_fields, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle3 TRANSACTION_HANDLE transaction)
|
||||
FLX IN RDB$FIELDS CROSS
|
||||
@ -1534,10 +1433,7 @@ dsql_rel* METD_get_relation(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
|
||||
WITH FLX.RDB$FIELD_NAME EQ RFR.RDB$FIELD_SOURCE
|
||||
AND RFR.RDB$RELATION_NAME EQ name->str_data
|
||||
SORTED BY RFR.RDB$FIELD_POSITION
|
||||
|
||||
if (!DSQL_REQUEST(irq_fields))
|
||||
DSQL_REQUEST(irq_fields) = handle3;
|
||||
|
||||
{
|
||||
// allocate the field block
|
||||
|
||||
fb_utils::exact_name(RFR.RDB$FIELD_NAME);
|
||||
@ -1603,12 +1499,9 @@ dsql_rel* METD_get_relation(jrd_tra* transaction, DsqlCompilerScratch* dsqlScrat
|
||||
if (RFR.RDB$SYSTEM_FLAG == 1 || FLX.RDB$SYSTEM_FLAG == 1)
|
||||
field->fld_flags |= FLD_system;
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_fields))
|
||||
DSQL_REQUEST(irq_fields) = handle3;
|
||||
|
||||
if (dbb->dbb_relations.get(metaName, temp) && !(temp->rel_flags & REL_dropped))
|
||||
{
|
||||
free_relation(relation);
|
||||
@ -1652,14 +1545,11 @@ bool METD_get_trigger(jrd_tra* transaction, const dsql_str* name, dsql_str** rel
|
||||
if (relation)
|
||||
*relation = NULL;
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_trigger, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_trigger, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$TRIGGERS WITH X.RDB$TRIGGER_NAME EQ name->str_data
|
||||
|
||||
if (!DSQL_REQUEST(irq_trigger))
|
||||
DSQL_REQUEST(irq_trigger) = handle;
|
||||
|
||||
{
|
||||
found = true;
|
||||
*trig_type = X.RDB$TRIGGER_TYPE;
|
||||
|
||||
@ -1671,12 +1561,9 @@ bool METD_get_trigger(jrd_tra* transaction, const dsql_str* name, dsql_str** rel
|
||||
*relation = MAKE_string(X.RDB$RELATION_NAME, strlen(X.RDB$RELATION_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_trigger))
|
||||
DSQL_REQUEST(irq_trigger) = handle;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@ -1700,23 +1587,17 @@ bool METD_get_type(jrd_tra* transaction, const dsql_str* name, const char* field
|
||||
dsql_dbb* dbb = transaction->getDsqlAttachment();
|
||||
bool found = false;
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_type, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_type, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$TYPES WITH
|
||||
X.RDB$FIELD_NAME EQ field AND X.RDB$TYPE_NAME EQ name->str_data;
|
||||
|
||||
if (!DSQL_REQUEST(irq_type))
|
||||
DSQL_REQUEST(irq_type) = handle;
|
||||
|
||||
{
|
||||
found = true;
|
||||
*value = X.RDB$TYPE;
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_type))
|
||||
DSQL_REQUEST(irq_type) = handle;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
@ -1754,15 +1635,12 @@ dsql_rel* METD_get_view_base(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
|
||||
|
||||
while (cont)
|
||||
{
|
||||
jrd_req* handle1 = CMP_find_request(tdbb, irq_view_base, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle1(tdbb, irq_view_base, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle1 TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$VIEW_RELATIONS
|
||||
WITH X.RDB$VIEW_NAME EQ view_name
|
||||
|
||||
if (!DSQL_REQUEST(irq_view_base))
|
||||
DSQL_REQUEST(irq_view_base) = handle1;
|
||||
|
||||
{
|
||||
// return NULL if there is more than one context
|
||||
if (X.RDB$VIEW_CONTEXT != 1 || X.RDB$CONTEXT_TYPE == VCT_PROCEDURE)
|
||||
{
|
||||
@ -1787,15 +1665,12 @@ dsql_rel* METD_get_view_base(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
|
||||
break;
|
||||
}
|
||||
|
||||
jrd_req* handle2 = CMP_find_request(tdbb, irq_view_base_flds, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle2(tdbb, irq_view_base_flds, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle2 TRANSACTION_HANDLE transaction)
|
||||
RFL IN RDB$RELATION_FIELDS
|
||||
WITH RFL.RDB$RELATION_NAME EQ X.RDB$VIEW_NAME
|
||||
|
||||
if (!DSQL_REQUEST(irq_view_base_flds))
|
||||
DSQL_REQUEST(irq_view_base_flds) = handle2;
|
||||
|
||||
{
|
||||
if (RFL.RDB$BASE_FIELD.NULL || RFL.RDB$FIELD_NAME.NULL)
|
||||
continue;
|
||||
|
||||
@ -1821,12 +1696,9 @@ dsql_rel* METD_get_view_base(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_view_base_flds))
|
||||
DSQL_REQUEST(irq_view_base_flds) = handle2;
|
||||
|
||||
for (const MetaName* i = ambiguities.begin(); i != ambiguities.end(); ++i)
|
||||
{
|
||||
MetaName field;
|
||||
@ -1849,11 +1721,8 @@ dsql_rel* METD_get_view_base(jrd_tra* transaction, DsqlCompilerScratch* dsqlScra
|
||||
}
|
||||
|
||||
first = false;
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_view_base))
|
||||
DSQL_REQUEST(irq_view_base) = handle1;
|
||||
}
|
||||
|
||||
if (!relation)
|
||||
@ -1886,14 +1755,11 @@ dsql_rel* METD_get_view_relation(jrd_tra* transaction, DsqlCompilerScratch* dsql
|
||||
|
||||
dsql_dbb* dbb = transaction->getDsqlAttachment();
|
||||
|
||||
jrd_req* handle = CMP_find_request(tdbb, irq_view, IRQ_REQUESTS);
|
||||
AutoCacheRequest handle(tdbb, irq_view, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$VIEW_RELATIONS WITH X.RDB$VIEW_NAME EQ view_name
|
||||
|
||||
if (!DSQL_REQUEST(irq_view))
|
||||
DSQL_REQUEST(irq_view) = handle;
|
||||
|
||||
{
|
||||
fb_utils::exact_name(X.RDB$CONTEXT_NAME);
|
||||
fb_utils::exact_name(X.RDB$RELATION_NAME);
|
||||
|
||||
@ -1911,12 +1777,9 @@ dsql_rel* METD_get_view_relation(jrd_tra* transaction, DsqlCompilerScratch* dsql
|
||||
|
||||
if (relation)
|
||||
return relation;
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DSQL_REQUEST(irq_view))
|
||||
DSQL_REQUEST(irq_view) = handle;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -85,20 +85,14 @@ Function* Function::lookup(thread_db* tdbb, USHORT id, bool return_deleted, bool
|
||||
|
||||
function = NULL;
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_l_fun_id, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_l_fun_id, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
X IN RDB$FUNCTIONS WITH X.RDB$FUNCTION_ID EQ id
|
||||
|
||||
if (!REQUEST(irq_l_fun_id))
|
||||
REQUEST(irq_l_fun_id) = request;
|
||||
|
||||
{
|
||||
function = loadMetadata(tdbb, X.RDB$FUNCTION_ID, noscan, flags);
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_l_fun_id))
|
||||
REQUEST(irq_l_fun_id) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (check_function)
|
||||
{
|
||||
@ -149,22 +143,16 @@ Function* Function::lookup(thread_db* tdbb, const QualifiedName& name, bool nosc
|
||||
|
||||
Function* function = NULL;
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_l_fun_name, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_l_fun_name, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
X IN RDB$FUNCTIONS
|
||||
WITH X.RDB$FUNCTION_NAME EQ name.identifier.c_str() AND
|
||||
X.RDB$PACKAGE_NAME EQUIV NULLIF(name.package.c_str(), '')
|
||||
|
||||
if (!REQUEST(irq_l_fun_name))
|
||||
REQUEST(irq_l_fun_name) = request;
|
||||
|
||||
{
|
||||
function = loadMetadata(tdbb, X.RDB$FUNCTION_ID, noscan, 0);
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_l_fun_name))
|
||||
REQUEST(irq_l_fun_name) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (check_function)
|
||||
{
|
||||
@ -238,17 +226,14 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
|
||||
{
|
||||
bool valid_blr = true;
|
||||
|
||||
jrd_req* request_fun = CMP_find_request(tdbb, irq_l_functions, IRQ_REQUESTS);
|
||||
AutoCacheRequest request_fun(tdbb, irq_l_functions, IRQ_REQUESTS);
|
||||
|
||||
fun_repeat temp[MAX_UDF_ARGUMENTS + 1];
|
||||
|
||||
FOR(REQUEST_HANDLE request_fun)
|
||||
X IN RDB$FUNCTIONS
|
||||
WITH X.RDB$FUNCTION_ID EQ id
|
||||
|
||||
if (!REQUEST(irq_l_functions))
|
||||
REQUEST(irq_l_functions) = request_fun;
|
||||
|
||||
{
|
||||
function->setName(QualifiedName(X.RDB$FUNCTION_NAME,
|
||||
(X.RDB$PACKAGE_NAME.NULL ? NULL : X.RDB$PACKAGE_NAME)));
|
||||
|
||||
@ -280,17 +265,14 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
|
||||
function->fun_inputs = 0;
|
||||
function->fun_defaults = 0;
|
||||
|
||||
jrd_req* request_arg = CMP_find_request(tdbb, irq_l_args, IRQ_REQUESTS);
|
||||
AutoCacheRequest request_arg(tdbb, irq_l_args, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request_arg)
|
||||
Y IN RDB$FUNCTION_ARGUMENTS
|
||||
WITH Y.RDB$FUNCTION_NAME EQ function->getName().identifier.c_str() AND
|
||||
Y.RDB$PACKAGE_NAME EQUIV NULLIF(function->getName().package.c_str(), '')
|
||||
SORTED BY Y.RDB$ARGUMENT_POSITION
|
||||
|
||||
if (!REQUEST(irq_l_args))
|
||||
REQUEST(irq_l_args) = request_arg;
|
||||
|
||||
{
|
||||
if (Y.RDB$ARGUMENT_POSITION != X.RDB$RETURN_ARGUMENT)
|
||||
function->fun_inputs++;
|
||||
|
||||
@ -315,15 +297,12 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
|
||||
{
|
||||
parameter->prm_field_source = Y.RDB$FIELD_SOURCE;
|
||||
|
||||
jrd_req* request_arg_fld = CMP_find_request(tdbb, irq_l_arg_fld, IRQ_REQUESTS);
|
||||
AutoCacheRequest request_arg_fld(tdbb, irq_l_arg_fld, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request_arg_fld)
|
||||
F IN RDB$FIELDS
|
||||
WITH F.RDB$FIELD_NAME = Y.RDB$FIELD_SOURCE
|
||||
|
||||
if (!REQUEST(irq_l_arg_fld))
|
||||
REQUEST(irq_l_arg_fld) = request_arg_fld;
|
||||
|
||||
{
|
||||
DSC_make_descriptor(¶meter->prm_desc, F.RDB$FIELD_TYPE,
|
||||
F.RDB$FIELD_SCALE, F.RDB$FIELD_LENGTH,
|
||||
F.RDB$FIELD_SUB_TYPE, F.RDB$CHARACTER_SET_ID,
|
||||
@ -334,11 +313,8 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
|
||||
default_value_null = F.RDB$DEFAULT_VALUE.NULL;
|
||||
default_value = F.RDB$DEFAULT_VALUE;
|
||||
}
|
||||
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!REQUEST(irq_l_arg_fld))
|
||||
REQUEST(irq_l_arg_fld) = request_arg_fld;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -374,10 +350,8 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
|
||||
sizeof(udf_blob) : FB_ALIGN(tail->fun_parameter->prm_desc.dsc_length, FB_DOUBLE_ALIGN);
|
||||
|
||||
count = MAX(count, size_t(Y.RDB$ARGUMENT_POSITION));
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_l_args))
|
||||
REQUEST(irq_l_args) = request_arg;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
function->fun_return_arg = X.RDB$RETURN_ARGUMENT;
|
||||
function->fun_temp_length = length;
|
||||
@ -495,11 +469,8 @@ Function* Function::loadMetadata(thread_db* tdbb, USHORT id, bool noscan, USHORT
|
||||
}
|
||||
|
||||
function->fun_flags |= FUN_scanned;
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_l_functions))
|
||||
REQUEST(irq_l_functions) = request_fun;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!(dbb->dbb_flags & DBB_read_only) && !valid_blr)
|
||||
{
|
||||
|
@ -845,8 +845,8 @@ jrd_req* CMP_find_request(thread_db* tdbb, USHORT id, USHORT which)
|
||||
Database::CheckoutLockGuard guard(dbb, dbb->dbb_cmp_clone_mutex);
|
||||
|
||||
jrd_req* request;
|
||||
if ((which == IRQ_REQUESTS && !(request = REQUEST(id))) ||
|
||||
(which == DYN_REQUESTS && !(request = DYN_REQUEST(id))) ||
|
||||
if ((which == IRQ_REQUESTS && !(request = dbb->dbb_internal[id])) ||
|
||||
(which == DYN_REQUESTS && !(request = dbb->dbb_dyn_req[id])) ||
|
||||
!(request->req_flags & (req_active | req_reserved)))
|
||||
{
|
||||
if (request) {
|
||||
|
431
src/jrd/dfw.epp
431
src/jrd/dfw.epp
File diff suppressed because it is too large
Load Diff
@ -1715,18 +1715,17 @@ void DPM_pages(thread_db* tdbb, SSHORT rel_id, int type, ULONG sequence, SLONG p
|
||||
}
|
||||
#endif
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_s_pages, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_s_pages, IRQ_REQUESTS);
|
||||
|
||||
STORE(REQUEST_HANDLE request)
|
||||
X IN RDB$PAGES
|
||||
{
|
||||
X.RDB$RELATION_ID = rel_id;
|
||||
X.RDB$PAGE_TYPE = type;
|
||||
X.RDB$PAGE_SEQUENCE = sequence;
|
||||
X.RDB$PAGE_NUMBER = page;
|
||||
}
|
||||
END_STORE
|
||||
|
||||
if (!REQUEST(irq_s_pages))
|
||||
REQUEST(irq_s_pages) = request;
|
||||
}
|
||||
|
||||
|
||||
@ -1839,12 +1838,10 @@ void DPM_scan_pages( thread_db* tdbb)
|
||||
|
||||
CCH_RELEASE(tdbb, &window);
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_r_pages, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_r_pages, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request) X IN RDB$PAGES
|
||||
|
||||
if (!REQUEST(irq_r_pages))
|
||||
REQUEST(irq_r_pages) = request;
|
||||
{
|
||||
relation = MET_relation(tdbb, X.RDB$RELATION_ID);
|
||||
relPages = relation->getBasePages();
|
||||
sequence = X.RDB$PAGE_SEQUENCE;
|
||||
@ -1871,10 +1868,8 @@ void DPM_scan_pages( thread_db* tdbb)
|
||||
}
|
||||
vector = *address = vcl::newVector(*dbb->dbb_permanent, *address, sequence + 1);
|
||||
(*vector)[sequence] = X.RDB$PAGE_NUMBER;
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_r_pages))
|
||||
REQUEST(irq_r_pages) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,8 +47,6 @@
|
||||
#ifndef JRD_DRQ_H
|
||||
#define JRD_DRQ_H
|
||||
|
||||
#define DYN_REQUEST(drt) dbb->dbb_dyn_req[drt]
|
||||
|
||||
enum drq_type_t
|
||||
{
|
||||
drq_l_prot_mask, // lookup protection mask
|
||||
|
@ -504,7 +504,6 @@ void DYN_modify_global_field(Global* gbl,
|
||||
new_dom.dyn_dsc.dsc_length = DYN_get_number(ptr);
|
||||
if (++field_adjusted_count > 2)
|
||||
{
|
||||
EXE_unwind(tdbb, request);
|
||||
DYN_error_punt(false, 148, orig_dom.dyn_fld_name.c_str());
|
||||
// msg 148: "Only one data type change to the domain %s allowed at a time"
|
||||
}
|
||||
@ -530,7 +529,6 @@ void DYN_modify_global_field(Global* gbl,
|
||||
new_dom.dyn_dtype = DYN_get_number(ptr);
|
||||
if (++field_adjusted_count > 2)
|
||||
{
|
||||
EXE_unwind(tdbb, request);
|
||||
DYN_error_punt(false, 148, orig_dom.dyn_fld_name.c_str());
|
||||
// msg 148: "Only one data type change to the domain %s allowed at a time"
|
||||
}
|
||||
@ -632,7 +630,6 @@ void DYN_modify_global_field(Global* gbl,
|
||||
case isc_dyn_single_validation:
|
||||
if (single_validate)
|
||||
{
|
||||
EXE_unwind(tdbb, request);
|
||||
DYN_error_punt(false, 160);
|
||||
// msg 160: "Only one constraint allowed for a domain"
|
||||
break;
|
||||
@ -644,7 +641,6 @@ void DYN_modify_global_field(Global* gbl,
|
||||
case isc_dyn_fld_validation_blr:
|
||||
if (single_validate && (!FLD.RDB$VALIDATION_BLR.NULL))
|
||||
{
|
||||
EXE_unwind(tdbb, request);
|
||||
DYN_error_punt(false, 160);
|
||||
// msg 160: "Only one constraint allowed for a domain"
|
||||
break;
|
||||
|
@ -121,9 +121,9 @@ namespace Jrd
|
||||
Database* dbb = JRD_get_thread_data()->getDatabase();
|
||||
|
||||
if (which == IRQ_REQUESTS)
|
||||
REQUEST(id) = request;
|
||||
dbb->dbb_internal[id] = request;
|
||||
else if (which == DYN_REQUESTS)
|
||||
DYN_REQUEST(id) = request;
|
||||
dbb->dbb_dyn_req[id] = request;
|
||||
else
|
||||
{
|
||||
fb_assert(false);
|
||||
|
@ -219,25 +219,19 @@ static void define_default_class(thread_db* tdbb,
|
||||
default_class.printf("%s%" SQUADFORMAT, DEFAULT_CLASS,
|
||||
DPM_gen_id(tdbb, MET_lookup_generator(tdbb, DEFAULT_CLASS), false, 1));
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant7, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant7, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
REL IN RDB$RELATIONS
|
||||
WITH REL.RDB$RELATION_NAME EQ relation_name
|
||||
|
||||
if (!REQUEST(irq_grant7))
|
||||
REQUEST(irq_grant7) = request;
|
||||
|
||||
{
|
||||
MODIFY REL USING
|
||||
REL.RDB$DEFAULT_CLASS.NULL = FALSE;
|
||||
jrd_vtof(default_class.c_str(), REL.RDB$DEFAULT_CLASS,
|
||||
sizeof(REL.RDB$DEFAULT_CLASS));
|
||||
END_MODIFY;
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant7))
|
||||
REQUEST(irq_grant7) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
|
||||
save_security_class(tdbb, default_class, acl, transaction);
|
||||
@ -296,7 +290,7 @@ static SecurityClass::flags_t get_public_privs(thread_db* tdbb,
|
||||
|
||||
SecurityClass::flags_t public_priv = 0;
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant5, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant5, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
PRV IN RDB$USER_PRIVILEGES
|
||||
@ -305,13 +299,10 @@ static SecurityClass::flags_t get_public_privs(thread_db* tdbb,
|
||||
PRV.RDB$USER EQ "PUBLIC" AND
|
||||
PRV.RDB$USER_TYPE EQ obj_user AND
|
||||
PRV.RDB$FIELD_NAME MISSING
|
||||
if (!REQUEST(irq_grant5))
|
||||
REQUEST(irq_grant5) = request;
|
||||
{
|
||||
public_priv |= trans_sql_priv(PRV.RDB$PRIVILEGE);
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant5))
|
||||
REQUEST(irq_grant5) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
return public_priv;
|
||||
}
|
||||
@ -346,85 +337,65 @@ static void get_object_info(thread_db* tdbb,
|
||||
|
||||
if (obj_type == obj_relation)
|
||||
{
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant1, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant1, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
REL IN RDB$RELATIONS WITH
|
||||
REL.RDB$RELATION_NAME EQ object_name
|
||||
|
||||
if (!REQUEST(irq_grant1))
|
||||
REQUEST(irq_grant1) = request;
|
||||
|
||||
{
|
||||
s_class = REL.RDB$SECURITY_CLASS;
|
||||
default_class = REL.RDB$DEFAULT_CLASS;
|
||||
owner = REL.RDB$OWNER_NAME;
|
||||
view = !REL.RDB$VIEW_BLR.isEmpty();
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant1))
|
||||
REQUEST(irq_grant1) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
else if (obj_type == obj_package_header)
|
||||
{
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant10, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant10, IRQ_REQUESTS);
|
||||
|
||||
FOR (REQUEST_HANDLE request)
|
||||
PKG IN RDB$PACKAGES
|
||||
WITH PKG.RDB$PACKAGE_NAME EQ object_name
|
||||
|
||||
if (!REQUEST(irq_grant10))
|
||||
REQUEST(irq_grant10) = request;
|
||||
|
||||
{
|
||||
s_class = PKG.RDB$SECURITY_CLASS;
|
||||
default_class = "";
|
||||
owner = PKG.RDB$OWNER_NAME;
|
||||
view = false;
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant10))
|
||||
REQUEST(irq_grant10) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
else if (obj_type == obj_procedure)
|
||||
{
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant9, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant9, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
PRC IN RDB$PROCEDURES WITH
|
||||
PRC.RDB$PROCEDURE_NAME EQ object_name AND
|
||||
PRC.RDB$PACKAGE_NAME MISSING
|
||||
|
||||
if (!REQUEST(irq_grant9))
|
||||
REQUEST(irq_grant9) = request;
|
||||
|
||||
{
|
||||
s_class = PRC.RDB$SECURITY_CLASS;
|
||||
default_class = "";
|
||||
owner = PRC.RDB$OWNER_NAME;
|
||||
view = false;
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant9))
|
||||
REQUEST(irq_grant9) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
else if (obj_type == obj_udf)
|
||||
{
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant11, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant11, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
FUN IN RDB$FUNCTIONS WITH
|
||||
FUN.RDB$FUNCTION_NAME EQ object_name AND
|
||||
FUN.RDB$PACKAGE_NAME MISSING
|
||||
|
||||
if (!REQUEST(irq_grant11))
|
||||
REQUEST(irq_grant11) = request;
|
||||
|
||||
{
|
||||
s_class = FUN.RDB$SECURITY_CLASS;
|
||||
default_class = "";
|
||||
owner = FUN.RDB$OWNER_NAME;
|
||||
view = false;
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant11))
|
||||
REQUEST(irq_grant11) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -458,7 +429,7 @@ static void get_user_privs(thread_db* tdbb,
|
||||
SSHORT user_type = -2;
|
||||
SecurityClass::flags_t priv = 0;
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant2, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant2, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
PRV IN RDB$USER_PRIVILEGES
|
||||
@ -468,10 +439,7 @@ static void get_user_privs(thread_db* tdbb,
|
||||
(PRV.RDB$USER NE owner.c_str() OR PRV.RDB$USER_TYPE NE obj_user) AND
|
||||
PRV.RDB$FIELD_NAME MISSING
|
||||
SORTED BY PRV.RDB$USER, PRV.RDB$USER_TYPE
|
||||
|
||||
if (!REQUEST(irq_grant2))
|
||||
REQUEST(irq_grant2) = request;
|
||||
|
||||
{
|
||||
fb_utils::exact_name_limit(PRV.RDB$USER, sizeof(PRV.RDB$USER));
|
||||
if (user != PRV.RDB$USER || user_type != PRV.RDB$USER_TYPE)
|
||||
{
|
||||
@ -491,10 +459,8 @@ static void get_user_privs(thread_db* tdbb,
|
||||
user = PRV.RDB$USER;
|
||||
}
|
||||
priv |= trans_sql_priv(PRV.RDB$PRIVILEGE);
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant2))
|
||||
REQUEST(irq_grant2) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (user.length())
|
||||
grant_user(acl, user, user_type, priv);
|
||||
@ -629,27 +595,21 @@ static void purge_default_class( TEXT* object_name, SSHORT obj_type)
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant8, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant8, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
REL IN RDB$RELATIONS
|
||||
WITH REL.RDB$RELATION_NAME EQ object_name
|
||||
AND REL.RDB$DEFAULT_CLASS NOT MISSING
|
||||
|
||||
if (!REQUEST(irq_grant8))
|
||||
REQUEST(irq_grant8) = request;
|
||||
|
||||
{
|
||||
fb_utils::exact_name_limit(REL.RDB$DEFAULT_CLASS, sizeof(REL.RDB$DEFAULT_CLASS));
|
||||
delete_security_class(tdbb, REL.RDB$DEFAULT_CLASS);
|
||||
|
||||
MODIFY REL USING
|
||||
REL.RDB$DEFAULT_CLASS.NULL = TRUE;
|
||||
END_MODIFY;
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant8))
|
||||
REQUEST(irq_grant8) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
|
||||
dsc desc;
|
||||
desc.dsc_dtype = dtype_text;
|
||||
@ -696,7 +656,7 @@ static SecurityClass::flags_t save_field_privileges(thread_db* tdbb,
|
||||
SecurityClass::flags_t field_public = 0;
|
||||
SSHORT user_type = -1;
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant6, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant6, IRQ_REQUESTS);
|
||||
jrd_req* request2 = NULL;
|
||||
jrd_req* request3 = NULL;
|
||||
|
||||
@ -709,10 +669,7 @@ static SecurityClass::flags_t save_field_privileges(thread_db* tdbb,
|
||||
PRV.RDB$FIELD_NAME NOT MISSING AND
|
||||
(PRV.RDB$USER NE owner.c_str() OR PRV.RDB$USER_TYPE NE obj_user)
|
||||
SORTED BY PRV.RDB$FIELD_NAME, PRV.RDB$USER
|
||||
|
||||
if (!REQUEST(irq_grant6))
|
||||
REQUEST(irq_grant6) = request;
|
||||
|
||||
{
|
||||
fb_utils::exact_name_limit(PRV.RDB$USER, sizeof(PRV.RDB$USER));
|
||||
fb_utils::exact_name_limit(PRV.RDB$FIELD_NAME, sizeof(PRV.RDB$FIELD_NAME));
|
||||
|
||||
@ -766,6 +723,7 @@ static SecurityClass::flags_t save_field_privileges(thread_db* tdbb,
|
||||
|
||||
field_name = PRV.RDB$FIELD_NAME;
|
||||
s_class = FLD.RDB$SECURITY_CLASS;
|
||||
|
||||
if (FLD.RDB$SECURITY_CLASS.NULL || s_class.length() == 0)
|
||||
{
|
||||
bool unique = false;
|
||||
@ -774,6 +732,7 @@ static SecurityClass::flags_t save_field_privileges(thread_db* tdbb,
|
||||
RFR IN RDB$RELATION_FIELDS WITH
|
||||
RFR.RDB$RELATION_NAME EQ FLD.RDB$RELATION_NAME
|
||||
AND RFR.RDB$FIELD_NAME EQ FLD.RDB$FIELD_NAME
|
||||
{
|
||||
MODIFY RFR
|
||||
while (!unique)
|
||||
{
|
||||
@ -785,16 +744,19 @@ static SecurityClass::flags_t save_field_privileges(thread_db* tdbb,
|
||||
FOR (REQUEST_HANDLE request3)
|
||||
RFR2 IN RDB$RELATION_FIELDS
|
||||
WITH RFR2.RDB$SECURITY_CLASS = RFR.RDB$SECURITY_CLASS
|
||||
{
|
||||
unique = false;
|
||||
END_FOR;
|
||||
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
|
||||
RFR.RDB$SECURITY_CLASS.NULL = FALSE;
|
||||
s_class = RFR.RDB$SECURITY_CLASS;
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
|
||||
field_public = 0;
|
||||
|
||||
// restart a security class at the end of the relation-level privs
|
||||
@ -802,10 +764,8 @@ static SecurityClass::flags_t save_field_privileges(thread_db* tdbb,
|
||||
}
|
||||
|
||||
priv |= trans_sql_priv(PRV.RDB$PRIVILEGE);
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant6))
|
||||
REQUEST(irq_grant6) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (request2)
|
||||
CMP_release(tdbb, request2);
|
||||
@ -886,35 +846,31 @@ static void save_security_class(thread_db* tdbb,
|
||||
}
|
||||
BLB_close(tdbb, blob);
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_grant3, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_grant3, IRQ_REQUESTS);
|
||||
|
||||
bool found = false;
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
CLS IN RDB$SECURITY_CLASSES
|
||||
WITH CLS.RDB$SECURITY_CLASS EQ s_class.c_str()
|
||||
if (!REQUEST(irq_grant3))
|
||||
REQUEST(irq_grant3) = request;
|
||||
{
|
||||
found = true;
|
||||
MODIFY CLS
|
||||
CLS.RDB$ACL = blob_id;
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_grant3))
|
||||
REQUEST(irq_grant3) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!found)
|
||||
{
|
||||
request = CMP_find_request(tdbb, irq_grant4, IRQ_REQUESTS);
|
||||
request.reset(tdbb, irq_grant4, IRQ_REQUESTS);
|
||||
|
||||
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
CLS IN RDB$SECURITY_CLASSES
|
||||
{
|
||||
jrd_vtof(s_class.c_str(), CLS.RDB$SECURITY_CLASS, sizeof(CLS.RDB$SECURITY_CLASS));
|
||||
CLS.RDB$ACL = blob_id;
|
||||
END_STORE;
|
||||
|
||||
if (!REQUEST(irq_grant4))
|
||||
REQUEST(irq_grant4) = request;
|
||||
}
|
||||
END_STORE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
#ifndef JRD_IRQ_H
|
||||
#define JRD_IRQ_H
|
||||
|
||||
#define REQUEST(irt) dbb->dbb_internal[irt]
|
||||
|
||||
enum irq_type_t
|
||||
{
|
||||
irq_s_pages, // store PAGES
|
||||
|
690
src/jrd/met.epp
690
src/jrd/met.epp
File diff suppressed because it is too large
Load Diff
@ -76,19 +76,14 @@ void PCMET_expression_index(thread_db* tdbb, const MetaName& name, USHORT id, jr
|
||||
|
||||
MOVE_CLEAR(&idx, sizeof(index_desc));
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_c_exp_index, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_c_exp_index, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
IDX IN RDB$INDICES CROSS
|
||||
REL IN RDB$RELATIONS OVER RDB$RELATION_NAME WITH
|
||||
IDX.RDB$EXPRESSION_BLR NOT MISSING AND
|
||||
IDX.RDB$INDEX_NAME EQ name.c_str()
|
||||
|
||||
if (!REQUEST(irq_c_exp_index))
|
||||
{
|
||||
REQUEST(irq_c_exp_index) = request;
|
||||
}
|
||||
|
||||
{
|
||||
if (!relation)
|
||||
{
|
||||
relation = MET_relation(tdbb, REL.RDB$RELATION_ID);
|
||||
@ -103,7 +98,6 @@ void PCMET_expression_index(thread_db* tdbb, const MetaName& name, USHORT id, jr
|
||||
IDX_statistics(tdbb, relation, id, selectivity);
|
||||
DFW_update_index(name.c_str(), id, selectivity, transaction);
|
||||
|
||||
EXE_unwind(tdbb, request);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -113,14 +107,11 @@ void PCMET_expression_index(thread_db* tdbb, const MetaName& name, USHORT id, jr
|
||||
MET_delete_dependencies(tdbb, name, obj_expression_index, transaction);
|
||||
MODIFY IDX
|
||||
IDX.RDB$INDEX_ID.NULL = TRUE;
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
}
|
||||
|
||||
if (IDX.RDB$INDEX_INACTIVE)
|
||||
{
|
||||
EXE_unwind(tdbb, request);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IDX.RDB$SEGMENT_COUNT)
|
||||
{
|
||||
@ -165,13 +156,8 @@ void PCMET_expression_index(thread_db* tdbb, const MetaName& name, USHORT id, jr
|
||||
|
||||
delete csb;
|
||||
}
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_c_exp_index))
|
||||
{
|
||||
REQUEST(irq_c_exp_index) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!relation)
|
||||
{
|
||||
@ -242,18 +228,13 @@ void PCMET_lookup_index(thread_db* tdbb, jrd_rel* relation, index_desc* idx)
|
||||
}
|
||||
|
||||
CompilerScratch* csb = NULL;
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_l_exp_index, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_l_exp_index, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
IDX IN RDB$INDICES WITH
|
||||
IDX.RDB$RELATION_NAME EQ relation->rel_name.c_str() AND
|
||||
IDX.RDB$INDEX_ID EQ idx->idx_id + 1
|
||||
|
||||
if (!REQUEST(irq_l_exp_index))
|
||||
{
|
||||
REQUEST(irq_l_exp_index) = request;
|
||||
}
|
||||
|
||||
{
|
||||
if (idx->idx_expression_request)
|
||||
{
|
||||
CMP_release(tdbb, idx->idx_expression_request);
|
||||
@ -270,18 +251,12 @@ void PCMET_lookup_index(thread_db* tdbb, jrd_rel* relation, index_desc* idx)
|
||||
MET_parse_blob(tdbb, relation, &IDX.RDB$EXPRESSION_BLR, &csb,
|
||||
&idx->idx_expression_request, false);
|
||||
} // end scope
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_l_exp_index))
|
||||
{
|
||||
REQUEST(irq_l_exp_index) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (csb)
|
||||
{
|
||||
CMP_get_desc(tdbb, csb, idx->idx_expression, &idx->idx_expression_desc);
|
||||
}
|
||||
|
||||
delete csb;
|
||||
|
||||
// if there is no existing index block for this index, create
|
||||
|
131
src/jrd/scl.epp
131
src/jrd/scl.epp
@ -451,21 +451,16 @@ void SCL_check_package(thread_db* tdbb, const dsc* dsc_name, SecurityClass::flag
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
const SecurityClass* s_class = NULL;
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_pkg_security, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_pkg_security, IRQ_REQUESTS);
|
||||
|
||||
FOR (REQUEST_HANDLE request)
|
||||
PKG IN RDB$PACKAGES
|
||||
WITH PKG.RDB$PACKAGE_NAME EQ name.c_str()
|
||||
|
||||
if (!REQUEST(irq_pkg_security))
|
||||
REQUEST(irq_pkg_security) = request;
|
||||
|
||||
{
|
||||
if (!PKG.RDB$SECURITY_CLASS.NULL)
|
||||
s_class = SCL_get_class(tdbb, PKG.RDB$SECURITY_CLASS);
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_pkg_security))
|
||||
REQUEST(irq_pkg_security) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
SCL_check_access(tdbb, s_class, 0, id_package, name, mask, SCL_object_package, name);
|
||||
}
|
||||
@ -496,22 +491,17 @@ void SCL_check_procedure(thread_db* tdbb, const dsc* dsc_name, SecurityClass::fl
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
const SecurityClass* s_class = NULL;
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_p_security, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_p_security, IRQ_REQUESTS);
|
||||
|
||||
FOR (REQUEST_HANDLE request)
|
||||
SPROC IN RDB$PROCEDURES
|
||||
WITH SPROC.RDB$PROCEDURE_NAME EQ name.c_str() AND
|
||||
SPROC.RDB$PACKAGE_NAME MISSING
|
||||
|
||||
if (!REQUEST(irq_p_security))
|
||||
REQUEST(irq_p_security) = request;
|
||||
|
||||
{
|
||||
if (!SPROC.RDB$SECURITY_CLASS.NULL)
|
||||
s_class = SCL_get_class(tdbb, SPROC.RDB$SECURITY_CLASS);
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_p_security))
|
||||
REQUEST(irq_p_security) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
SCL_check_access(tdbb, s_class, 0, id_procedure, name, mask, SCL_object_procedure, name);
|
||||
}
|
||||
@ -542,22 +532,17 @@ void SCL_check_function(thread_db* tdbb, const dsc* dsc_name, SecurityClass::fla
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
const SecurityClass* s_class = NULL;
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_f_security, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_f_security, IRQ_REQUESTS);
|
||||
|
||||
FOR (REQUEST_HANDLE request)
|
||||
SFUN IN RDB$FUNCTIONS
|
||||
WITH SFUN.RDB$FUNCTION_NAME EQ name.c_str() AND
|
||||
SFUN.RDB$PACKAGE_NAME MISSING
|
||||
|
||||
if (!REQUEST(irq_f_security))
|
||||
REQUEST(irq_f_security) = request;
|
||||
|
||||
{
|
||||
if (!SFUN.RDB$SECURITY_CLASS.NULL)
|
||||
s_class = SCL_get_class(tdbb, SFUN.RDB$SECURITY_CLASS);
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_f_security))
|
||||
REQUEST(irq_f_security) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
SCL_check_access(tdbb, s_class, 0, id_function, name, mask, SCL_object_function, name);
|
||||
}
|
||||
@ -588,20 +573,15 @@ void SCL_check_relation(thread_db* tdbb, const dsc* dsc_name, SecurityClass::fla
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
const SecurityClass* s_class = NULL;
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_v_security, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_v_security, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request) REL IN RDB$RELATIONS
|
||||
WITH REL.RDB$RELATION_NAME EQ name.c_str()
|
||||
|
||||
if (!REQUEST(irq_v_security))
|
||||
REQUEST(irq_v_security) = request;
|
||||
|
||||
{
|
||||
if (!REL.RDB$SECURITY_CLASS.NULL)
|
||||
s_class = SCL_get_class(tdbb, REL.RDB$SECURITY_CLASS);
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_v_security))
|
||||
REQUEST(irq_v_security) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
SCL_check_access(tdbb, s_class, 0, 0, NULL, mask, SCL_object_table, name);
|
||||
}
|
||||
@ -753,21 +733,14 @@ void SCL_init(thread_db* tdbb, bool create, const UserId& tempId)
|
||||
{
|
||||
if (!create)
|
||||
{
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_get_role_name, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_get_role_name, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request) X IN RDB$ROLES
|
||||
WITH X.RDB$ROLE_NAME EQ login_name
|
||||
|
||||
if (!REQUEST(irq_get_role_name))
|
||||
REQUEST(irq_get_role_name) = request;
|
||||
|
||||
EXE_unwind(tdbb, request);
|
||||
{
|
||||
ERR_post(Arg::Gds(isc_login_same_as_role_name) << Arg::Str(login_name));
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_get_role_name))
|
||||
REQUEST(irq_get_role_name) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
}
|
||||
|
||||
@ -778,7 +751,7 @@ void SCL_init(thread_db* tdbb, bool create, const UserId& tempId)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
jrd_req* request = CMP_find_request (tdbb, irq_verify_role_name, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_verify_role_name, IRQ_REQUESTS);
|
||||
|
||||
// CVC: The caller has hopefully uppercased the role or stripped quotes. Of course,
|
||||
// uppercase-UPPER7 should only happen if the role wasn't enclosed in quotes.
|
||||
@ -796,53 +769,37 @@ void SCL_init(thread_db* tdbb, bool create, const UserId& tempId)
|
||||
OR UU.RDB$USER EQ "PUBLIC")
|
||||
AND UU.RDB$USER_TYPE EQ obj_user
|
||||
AND UU.RDB$PRIVILEGE EQ "M"
|
||||
|
||||
if (!REQUEST (irq_verify_role_name))
|
||||
REQUEST (irq_verify_role_name) = request;
|
||||
|
||||
{
|
||||
if (!UU.RDB$USER.NULL)
|
||||
found = true;
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST (irq_verify_role_name))
|
||||
REQUEST (irq_verify_role_name) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!found && (tempId.usr_flags & USR_trole))
|
||||
{
|
||||
jrd_req* request = CMP_find_request (tdbb, irq_verify_trusted_role, IRQ_REQUESTS);
|
||||
request.reset(tdbb, irq_verify_trusted_role, IRQ_REQUESTS);
|
||||
|
||||
FOR (REQUEST_HANDLE request) FIRST 1 RR IN RDB$ROLES
|
||||
WITH RR.RDB$ROLE_NAME EQ sql_role
|
||||
AND RR.RDB$SYSTEM_FLAG > 0
|
||||
|
||||
if (!REQUEST (irq_verify_trusted_role))
|
||||
REQUEST (irq_verify_trusted_role) = request;
|
||||
|
||||
{
|
||||
if (RR.RDB$SYSTEM_FLAG & ROLE_FLAG_MAY_TRUST)
|
||||
found = true;
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST (irq_verify_trusted_role))
|
||||
REQUEST (irq_verify_trusted_role) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
role_name = NULL_ROLE;
|
||||
}
|
||||
}
|
||||
|
||||
if (sql_role)
|
||||
{
|
||||
if (role_name != NULL_ROLE) {
|
||||
if (role_name != NULL_ROLE)
|
||||
role_name = sql_role;
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
role_name = NULL_ROLE;
|
||||
}
|
||||
|
||||
MemoryPool& pool = *attachment->att_pool;
|
||||
UserId* const user = FB_NEW(pool) UserId(pool, tempId);
|
||||
@ -1122,14 +1079,11 @@ static SecurityClass::flags_t compute_access(thread_db* tdbb,
|
||||
|
||||
SecurityClass::flags_t privileges = SCL_scanned;
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_l_security, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_l_security, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request) X IN RDB$SECURITY_CLASSES
|
||||
WITH X.RDB$SECURITY_CLASS EQ s_class->scl_name.c_str()
|
||||
|
||||
if (!REQUEST(irq_l_security))
|
||||
REQUEST(irq_l_security) = request;
|
||||
|
||||
{
|
||||
privileges |= SCL_exists;
|
||||
blb* blob = BLB_open(tdbb, sysTransaction, &X.RDB$ACL);
|
||||
UCHAR* buffer = acl.getBuffer(ACL_BLOB_BUFFER_SIZE);
|
||||
@ -1154,13 +1108,9 @@ static SecurityClass::flags_t compute_access(thread_db* tdbb,
|
||||
acl.shrink(end - buffer);
|
||||
|
||||
if (acl.getCount() > 0)
|
||||
{
|
||||
privileges |= walk_acl(tdbb, acl, view, obj_type, obj_name);
|
||||
}
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_l_security))
|
||||
REQUEST(irq_l_security) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
return privileges;
|
||||
}
|
||||
@ -1265,7 +1215,7 @@ static SecurityClass::flags_t walk_acl(thread_db* tdbb,
|
||||
++q;
|
||||
}
|
||||
hit = false;
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_get_role_mem, IRQ_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, irq_get_role_mem, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request) U IN RDB$USER_PRIVILEGES WITH
|
||||
(U.RDB$USER EQ login_name OR
|
||||
@ -1274,16 +1224,11 @@ static SecurityClass::flags_t walk_acl(thread_db* tdbb,
|
||||
U.RDB$RELATION_NAME EQ user.usr_sql_role_name.c_str() AND
|
||||
U.RDB$OBJECT_TYPE EQ obj_sql_role AND
|
||||
U.RDB$PRIVILEGE EQ "M"
|
||||
|
||||
if (!REQUEST(irq_get_role_mem))
|
||||
REQUEST(irq_get_role_mem) = request;
|
||||
|
||||
{
|
||||
if (!U.RDB$USER.NULL)
|
||||
hit = true;
|
||||
END_FOR;
|
||||
|
||||
if (!REQUEST(irq_get_role_mem))
|
||||
REQUEST(irq_get_role_mem) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user