mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 22:03:03 +01:00
Misc.
This commit is contained in:
parent
721a168477
commit
fbba8ad798
@ -243,7 +243,7 @@ BtrPageGCLock::~BtrPageGCLock()
|
||||
LCK_release(JRD_get_thread_data(), this);
|
||||
}
|
||||
|
||||
void BtrPageGCLock::disablePageGC(thread_db* tdbb, const PageNumber &page)
|
||||
void BtrPageGCLock::disablePageGC(thread_db* tdbb, const PageNumber& page)
|
||||
{
|
||||
page.getLockStr(getKeyPtr());
|
||||
LCK_lock(tdbb, this, LCK_read, LCK_WAIT);
|
||||
|
237
src/jrd/dfw.epp
237
src/jrd/dfw.epp
@ -642,7 +642,7 @@ void Jrd::ProtectRelations::relLock::releaseLock(thread_db* tdbb, jrd_tra* trans
|
||||
if (*lock == m_lock)
|
||||
{
|
||||
LCK_release(tdbb, m_lock);
|
||||
*lock = 0;
|
||||
*lock = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2611,140 +2611,140 @@ static bool create_expression_index(thread_db* tdbb, SSHORT phase, DeferredWork*
|
||||
|
||||
case 3:
|
||||
{
|
||||
jrd_rel* relation = NULL;
|
||||
index_desc idx;
|
||||
MemoryPool* new_pool = NULL;
|
||||
jrd_rel* relation = NULL;
|
||||
index_desc idx;
|
||||
MemoryPool* new_pool = NULL;
|
||||
|
||||
SET_TDBB(tdbb);
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
Jrd::Attachment* attachment = tdbb->getAttachment();
|
||||
SET_TDBB(tdbb);
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
Jrd::Attachment* attachment = tdbb->getAttachment();
|
||||
|
||||
MOVE_CLEAR(&idx, sizeof(index_desc));
|
||||
MOVE_CLEAR(&idx, sizeof(index_desc));
|
||||
|
||||
AutoCacheRequest 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 work->dfw_name.c_str()
|
||||
{
|
||||
if (!relation)
|
||||
{
|
||||
relation = MET_relation(tdbb, REL.RDB$RELATION_ID);
|
||||
if (relation->rel_name.length() == 0) {
|
||||
relation->rel_name = REL.RDB$RELATION_NAME;
|
||||
}
|
||||
|
||||
if (IDX.RDB$INDEX_ID && IDX.RDB$STATISTICS < 0.0)
|
||||
{
|
||||
SelectivityList selectivity(*tdbb->getDefaultPool());
|
||||
const USHORT localId = IDX.RDB$INDEX_ID - 1;
|
||||
IDX_statistics(tdbb, relation, localId, selectivity);
|
||||
DFW_update_index(work->dfw_name.c_str(), localId, selectivity, transaction);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IDX.RDB$INDEX_ID)
|
||||
{
|
||||
IDX_delete_index(tdbb, relation, IDX.RDB$INDEX_ID - 1);
|
||||
MET_delete_dependencies(tdbb, work->dfw_name, obj_expression_index, transaction);
|
||||
MODIFY IDX
|
||||
IDX.RDB$INDEX_ID.NULL = TRUE;
|
||||
END_MODIFY
|
||||
}
|
||||
|
||||
if (IDX.RDB$INDEX_INACTIVE)
|
||||
return false;
|
||||
|
||||
if (IDX.RDB$SEGMENT_COUNT)
|
||||
{
|
||||
// Msg359: segments not allowed in expression index %s
|
||||
ERR_post(Arg::Gds(isc_no_meta_update) <<
|
||||
Arg::Gds(isc_no_segments_err) << Arg::Str(work->dfw_name));
|
||||
}
|
||||
if (IDX.RDB$UNIQUE_FLAG)
|
||||
idx.idx_flags |= idx_unique;
|
||||
if (IDX.RDB$INDEX_TYPE == 1)
|
||||
idx.idx_flags |= idx_descending;
|
||||
|
||||
CompilerScratch* csb = NULL;
|
||||
// allocate a new pool to contain the expression tree for the expression index
|
||||
new_pool = attachment->createPool();
|
||||
{ // scope
|
||||
Jrd::ContextPoolHolder context(tdbb, new_pool);
|
||||
MET_scan_relation(tdbb, relation);
|
||||
|
||||
if (!IDX.RDB$EXPRESSION_BLR.NULL)
|
||||
{
|
||||
idx.idx_expression = static_cast<ValueExprNode*>(MET_get_dependencies(
|
||||
tdbb, relation, NULL, 0, NULL, &IDX.RDB$EXPRESSION_BLR,
|
||||
&idx.idx_expression_statement, &csb, work->dfw_name, obj_expression_index, 0,
|
||||
transaction));
|
||||
}
|
||||
} // end scope
|
||||
|
||||
// fake a description of the index
|
||||
|
||||
idx.idx_count = 1;
|
||||
idx.idx_flags |= idx_expressn;
|
||||
idx.idx_expression->getDesc(tdbb, csb, &idx.idx_expression_desc);
|
||||
idx.idx_rpt[0].idx_itype =
|
||||
DFW_assign_index_type(tdbb, work->dfw_name,
|
||||
idx.idx_expression_desc.dsc_dtype,
|
||||
idx.idx_expression_desc.dsc_sub_type);
|
||||
idx.idx_rpt[0].idx_selectivity = 0;
|
||||
|
||||
delete csb;
|
||||
}
|
||||
}
|
||||
END_FOR
|
||||
|
||||
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 work->dfw_name.c_str()
|
||||
{
|
||||
if (!relation)
|
||||
{
|
||||
relation = MET_relation(tdbb, REL.RDB$RELATION_ID);
|
||||
if (relation->rel_name.length() == 0) {
|
||||
relation->rel_name = REL.RDB$RELATION_NAME;
|
||||
}
|
||||
if (new_pool)
|
||||
attachment->deletePool(new_pool);
|
||||
|
||||
if (IDX.RDB$INDEX_ID && IDX.RDB$STATISTICS < 0.0)
|
||||
{
|
||||
SelectivityList selectivity(*tdbb->getDefaultPool());
|
||||
const USHORT localId = IDX.RDB$INDEX_ID - 1;
|
||||
IDX_statistics(tdbb, relation, localId, selectivity);
|
||||
DFW_update_index(work->dfw_name.c_str(), localId, selectivity, transaction);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IDX.RDB$INDEX_ID)
|
||||
{
|
||||
IDX_delete_index(tdbb, relation, IDX.RDB$INDEX_ID - 1);
|
||||
MET_delete_dependencies(tdbb, work->dfw_name, obj_expression_index, transaction);
|
||||
MODIFY IDX
|
||||
IDX.RDB$INDEX_ID.NULL = TRUE;
|
||||
END_MODIFY
|
||||
}
|
||||
|
||||
if (IDX.RDB$INDEX_INACTIVE)
|
||||
return false;
|
||||
|
||||
if (IDX.RDB$SEGMENT_COUNT)
|
||||
{
|
||||
// Msg359: segments not allowed in expression index %s
|
||||
ERR_post(Arg::Gds(isc_no_meta_update) <<
|
||||
Arg::Gds(isc_no_segments_err) << Arg::Str(work->dfw_name));
|
||||
}
|
||||
if (IDX.RDB$UNIQUE_FLAG)
|
||||
idx.idx_flags |= idx_unique;
|
||||
if (IDX.RDB$INDEX_TYPE == 1)
|
||||
idx.idx_flags |= idx_descending;
|
||||
|
||||
CompilerScratch* csb = 0;
|
||||
// allocate a new pool to contain the expression tree for the expression index
|
||||
new_pool = attachment->createPool();
|
||||
{ // scope
|
||||
Jrd::ContextPoolHolder context(tdbb, new_pool);
|
||||
MET_scan_relation(tdbb, relation);
|
||||
|
||||
if (!IDX.RDB$EXPRESSION_BLR.NULL)
|
||||
{
|
||||
idx.idx_expression = static_cast<ValueExprNode*>(MET_get_dependencies(
|
||||
tdbb, relation, NULL, 0, NULL, &IDX.RDB$EXPRESSION_BLR,
|
||||
&idx.idx_expression_statement, &csb, work->dfw_name, obj_expression_index, 0,
|
||||
transaction));
|
||||
}
|
||||
} // end scope
|
||||
|
||||
// fake a description of the index
|
||||
|
||||
idx.idx_count = 1;
|
||||
idx.idx_flags |= idx_expressn;
|
||||
idx.idx_expression->getDesc(tdbb, csb, &idx.idx_expression_desc);
|
||||
idx.idx_rpt[0].idx_itype =
|
||||
DFW_assign_index_type(tdbb, work->dfw_name,
|
||||
idx.idx_expression_desc.dsc_dtype,
|
||||
idx.idx_expression_desc.dsc_sub_type);
|
||||
idx.idx_rpt[0].idx_selectivity = 0;
|
||||
|
||||
delete csb;
|
||||
// Msg308: can't create index %s
|
||||
ERR_post(Arg::Gds(isc_no_meta_update) <<
|
||||
Arg::Gds(isc_idx_create_err) << Arg::Str(work->dfw_name));
|
||||
}
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!relation)
|
||||
{
|
||||
if (new_pool)
|
||||
attachment->deletePool(new_pool);
|
||||
// Actually create the index
|
||||
|
||||
// Msg308: can't create index %s
|
||||
ERR_post(Arg::Gds(isc_no_meta_update) <<
|
||||
Arg::Gds(isc_idx_create_err) << Arg::Str(work->dfw_name));
|
||||
}
|
||||
// Protect relation from modification to create consistent index
|
||||
ProtectRelations protectRelation(tdbb, transaction, relation);
|
||||
|
||||
// Actually create the index
|
||||
SelectivityList selectivity(*tdbb->getDefaultPool());
|
||||
|
||||
// Protect relation from modification to create consistent index
|
||||
ProtectRelations protectRelation(tdbb, transaction, relation);
|
||||
jrd_tra* const current_transaction = tdbb->getTransaction();
|
||||
jrd_req* const current_request = tdbb->getRequest();
|
||||
|
||||
SelectivityList selectivity(*tdbb->getDefaultPool());
|
||||
try
|
||||
{
|
||||
fb_assert(work->dfw_id <= dbb->dbb_max_idx);
|
||||
idx.idx_id = work->dfw_id;
|
||||
IDX_create_index(tdbb, relation, &idx, work->dfw_name.c_str(), &work->dfw_id,
|
||||
transaction, selectivity);
|
||||
|
||||
jrd_tra* const current_transaction = tdbb->getTransaction();
|
||||
jrd_req* const current_request = tdbb->getRequest();
|
||||
fb_assert(work->dfw_id == idx.idx_id);
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
tdbb->setTransaction(current_transaction);
|
||||
tdbb->setRequest(current_request);
|
||||
throw;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
fb_assert(work->dfw_id <= dbb->dbb_max_idx);
|
||||
idx.idx_id = work->dfw_id;
|
||||
IDX_create_index(tdbb, relation, &idx, work->dfw_name.c_str(), &work->dfw_id,
|
||||
transaction, selectivity);
|
||||
|
||||
fb_assert(work->dfw_id == idx.idx_id);
|
||||
}
|
||||
catch (const Exception&)
|
||||
{
|
||||
tdbb->setTransaction(current_transaction);
|
||||
tdbb->setRequest(current_request);
|
||||
throw;
|
||||
}
|
||||
|
||||
tdbb->setTransaction(current_transaction);
|
||||
tdbb->setRequest(current_request);
|
||||
DFW_update_index(work->dfw_name.c_str(), idx.idx_id, selectivity, transaction);
|
||||
|
||||
DFW_update_index(work->dfw_name.c_str(), idx.idx_id, selectivity, transaction);
|
||||
// Get rid of the pool containing the expression tree
|
||||
|
||||
// Get rid of the pool containing the expression tree
|
||||
|
||||
attachment->deletePool(new_pool);
|
||||
attachment->deletePool(new_pool);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -3454,7 +3454,7 @@ static bool create_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
|
||||
Arg::Gds(isc_partner_idx_incompat_type) << Arg::Num(bad_segment + 1));
|
||||
}
|
||||
|
||||
/* hvlad: this code was never called but i preserve it for Claudio review and decision
|
||||
/*** hvlad: this code was never called but i preserve it for Claudio review and decision
|
||||
|
||||
// CVC: Currently, the server doesn't enforce FK creation more than at DYN level.
|
||||
// If DYN is bypassed, then FK creation succeeds and operation will fail at run-time.
|
||||
@ -3474,7 +3474,7 @@ static bool create_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
|
||||
SCL_check_index(tdbb, partner_relation->rel_name,
|
||||
idx.idx_id + 1, SCL_references);
|
||||
}
|
||||
*/
|
||||
***/
|
||||
}
|
||||
|
||||
protectRelations.lock();
|
||||
@ -3494,7 +3494,8 @@ static bool create_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
|
||||
LCK_lock(tdbb, relation->rel_partners_lock, LCK_EX, LCK_WAIT);
|
||||
LCK_release(tdbb, relation->rel_partners_lock);
|
||||
|
||||
if (relation != partner_relation) {
|
||||
if (relation != partner_relation)
|
||||
{
|
||||
partner_relation->rel_flags |= REL_check_partners;
|
||||
LCK_lock(tdbb, partner_relation->rel_partners_lock, LCK_EX, LCK_WAIT);
|
||||
LCK_release(tdbb, partner_relation->rel_partners_lock);
|
||||
|
@ -775,7 +775,7 @@ void Trigger::compile(thread_db* tdbb)
|
||||
if (extTrigger)
|
||||
return;
|
||||
|
||||
if (!statement /*&& !compile_in_progress*/)
|
||||
if (!statement)
|
||||
{
|
||||
compile_in_progress = true;
|
||||
// Allocate statement memory pool
|
||||
@ -1027,7 +1027,7 @@ static void rollback(thread_db*, jrd_tra*, const bool);
|
||||
static void purge_attachment(thread_db* tdbb, StableAttachmentPart* sAtt, unsigned flags = 0);
|
||||
static void getUserInfo(UserId&, const DatabaseOptions&, const char*, const char*,
|
||||
const RefPtr<Config>*, bool, ICryptKeyCallback*);
|
||||
static void makeRoleName(Database*, MetaName &, DatabaseOptions&);
|
||||
static void makeRoleName(Database*, MetaName&, DatabaseOptions&);
|
||||
|
||||
static THREAD_ENTRY_DECLARE shutdown_thread(THREAD_ENTRY_PARAM);
|
||||
|
||||
|
@ -79,7 +79,7 @@ bool JRD_verify_database_access(const Firebird::PathName&);
|
||||
void JRD_shutdown_attachment(Jrd::Attachment* attachment);
|
||||
void JRD_shutdown_attachments(Jrd::Database* dbb);
|
||||
void JRD_cancel_operation(Jrd::thread_db* tdbb, Jrd::Attachment* attachment, int option);
|
||||
void JRD_make_role_name(Firebird::MetaName &userIdRole, const int dialect);
|
||||
void JRD_make_role_name(Firebird::MetaName& userIdRole, const int dialect);
|
||||
|
||||
bool JRD_shutdown_database(Jrd::Database* dbb, const unsigned flags = 0);
|
||||
// JRD_shutdown_database() flags
|
||||
|
@ -1036,6 +1036,7 @@ bool SCL_role_granted(thread_db* tdbb, const UserId& usr, const TEXT* sql_role)
|
||||
}
|
||||
|
||||
|
||||
// TODO: Remove recursion. See dfw.epp/check_computed_dependencies as a model.
|
||||
void SCL_find_granted_roles(thread_db* tdbb, const Firebird::MetaName& object, bool isRole,
|
||||
Firebird::SortedArray<Firebird::MetaName>& grantedRoles, bool defaultOnly)
|
||||
{
|
||||
@ -1089,8 +1090,8 @@ bool SCL_admin_role(thread_db* tdbb, const Firebird::SortedArray<Firebird::MetaN
|
||||
AutoCacheRequest request(tdbb, irq_is_admin_role, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request) R IN RDB$ROLES
|
||||
WITH R.RDB$ROLE_NAME EQ roles[i].c_str()
|
||||
AND R.RDB$SYSTEM_FLAG != 0
|
||||
WITH R.RDB$ROLE_NAME EQ roles[i].c_str() AND
|
||||
R.RDB$SYSTEM_FLAG != 0
|
||||
{
|
||||
adminRole = true;
|
||||
break;
|
||||
@ -1171,6 +1172,7 @@ void SCL_init(thread_db* tdbb, bool create, const UserId& tempId)
|
||||
user->usr_granted_roles.add(user->usr_sql_role_name);
|
||||
SCL_find_granted_roles(tdbb, user->usr_sql_role_name, true, user->usr_granted_roles, false);
|
||||
}
|
||||
|
||||
// Add all default roles granted to user
|
||||
SCL_find_granted_roles(tdbb, user->usr_user_name, false, user->usr_granted_roles, true);
|
||||
|
||||
|
@ -58,8 +58,8 @@ Jrd::SecurityClass* SCL_recompute_class(Jrd::thread_db*, const TEXT*);
|
||||
void SCL_release_all(Jrd::SecurityClassList*&);
|
||||
bool SCL_role_granted(Jrd::thread_db* tdbb, const Jrd::UserId& usr, const TEXT* sql_role);
|
||||
void SCL_find_granted_roles(Jrd::thread_db* tdbb, const Firebird::MetaName& object, bool isRole,
|
||||
Firebird::SortedArray<Firebird::MetaName> &grantedRoles, bool defaultOnly);
|
||||
bool SCL_admin_role(Jrd::thread_db* tdbb, const Firebird::SortedArray<Firebird::MetaName> &roles);
|
||||
Firebird::SortedArray<Firebird::MetaName>& grantedRoles, bool defaultOnly);
|
||||
bool SCL_admin_role(Jrd::thread_db* tdbb, const Firebird::SortedArray<Firebird::MetaName>& roles);
|
||||
Jrd::SecurityClass::flags_t SCL_get_object_mask(const int object_type);
|
||||
|
||||
namespace Jrd {
|
||||
|
Loading…
Reference in New Issue
Block a user