mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 04:43:03 +01:00
Merge pull request #155 from abzalov/master
CORE-5746: Remove the restriction on create/delete, enable/disable user indexes in the system tables
This commit is contained in:
commit
acb1c28a01
@ -89,7 +89,7 @@ static bool isItSqlRole(thread_db* tdbb, jrd_tra* transaction, const MetaName& i
|
||||
static int getGrantorOption(thread_db* tdbb, jrd_tra* transaction, const MetaName& grantor,
|
||||
int grantorType, const MetaName& roleName);
|
||||
static MetaName getIndexRelationName(thread_db* tdbb, jrd_tra* transaction,
|
||||
const MetaName& indexName);
|
||||
const MetaName& indexName, bool& systemIndex);
|
||||
static const char* getRelationScopeName(const rel_t type);
|
||||
static void makeRelationScopeName(string& to, const MetaName& name, const rel_t type);
|
||||
static void checkRelationType(const rel_t type, const MetaName& name);
|
||||
@ -538,14 +538,17 @@ static void makeRelationScopeName(string& to, const MetaName& name, const rel_t
|
||||
|
||||
// Get relation name of an index.
|
||||
static MetaName getIndexRelationName(thread_db* tdbb, jrd_tra* transaction,
|
||||
const MetaName& indexName)
|
||||
const MetaName& indexName, bool& systemIndex)
|
||||
{
|
||||
systemIndex = false;
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_l_index_relname, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
IDX IN RDB$INDICES
|
||||
WITH IDX.RDB$INDEX_NAME EQ indexName.c_str()
|
||||
{
|
||||
systemIndex = IDX.RDB$SYSTEM_FLAG == 1;
|
||||
return IDX.RDB$RELATION_NAME;
|
||||
}
|
||||
END_FOR
|
||||
@ -1286,9 +1289,10 @@ bool CommentOnNode::checkPermission(thread_db* tdbb, jrd_tra* transaction)
|
||||
break;
|
||||
|
||||
case obj_index:
|
||||
relationName = getIndexRelationName(tdbb, transaction, objName.identifier);
|
||||
bool systemIndex;
|
||||
relationName = getIndexRelationName(tdbb, transaction, objName.identifier, systemIndex);
|
||||
dscName.makeText(relationName.length(), CS_METADATA, (UCHAR*) relationName.c_str());
|
||||
SCL_check_relation(tdbb, &dscName, SCL_alter);
|
||||
SCL_check_relation(tdbb, &dscName, SCL_alter, systemIndex);
|
||||
break;
|
||||
|
||||
case obj_sql_role:
|
||||
@ -9668,12 +9672,13 @@ string AlterIndexNode::internalPrint(NodePrinter& printer) const
|
||||
|
||||
bool AlterIndexNode::checkPermission(thread_db* tdbb, jrd_tra* transaction)
|
||||
{
|
||||
MetaName relationName = getIndexRelationName(tdbb, transaction, name);
|
||||
bool systemIndex;
|
||||
MetaName relationName = getIndexRelationName(tdbb, transaction, name, systemIndex);
|
||||
|
||||
dsc dscName;
|
||||
dscName.makeText(relationName.length(), CS_METADATA, (UCHAR*) relationName.c_str());
|
||||
|
||||
SCL_check_relation(tdbb, &dscName, SCL_alter);
|
||||
SCL_check_relation(tdbb, &dscName, SCL_alter, systemIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -9730,7 +9735,8 @@ string SetStatisticsNode::internalPrint(NodePrinter& printer) const
|
||||
|
||||
bool SetStatisticsNode::checkPermission(thread_db* tdbb, jrd_tra* transaction)
|
||||
{
|
||||
MetaName relationName = getIndexRelationName(tdbb, transaction, name);
|
||||
bool systemIndex;
|
||||
MetaName relationName = getIndexRelationName(tdbb, transaction, name, systemIndex);
|
||||
|
||||
dsc dscName;
|
||||
dscName.makeText(relationName.length(), CS_METADATA, (UCHAR*) relationName.c_str());
|
||||
@ -9811,12 +9817,13 @@ string DropIndexNode::internalPrint(NodePrinter& printer) const
|
||||
|
||||
bool DropIndexNode::checkPermission(thread_db* tdbb, jrd_tra* transaction)
|
||||
{
|
||||
MetaName relationName = getIndexRelationName(tdbb, transaction, name);
|
||||
bool systemIndex;
|
||||
MetaName relationName = getIndexRelationName(tdbb, transaction, name, systemIndex);
|
||||
|
||||
dsc dscName;
|
||||
dscName.makeText(relationName.length(), CS_METADATA, (UCHAR*) relationName.c_str());
|
||||
|
||||
SCL_check_relation(tdbb, &dscName, SCL_alter);
|
||||
SCL_check_relation(tdbb, &dscName, SCL_alter, systemIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1612,7 +1612,8 @@ void VIO_erase(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
|
||||
case rel_indices:
|
||||
protect_system_table_delupd(tdbb, relation, "DELETE");
|
||||
EVL_field(0, rpb->rpb_record, f_idx_relation, &desc);
|
||||
SCL_check_relation(tdbb, &desc, SCL_control);
|
||||
EVL_field(0, rpb->rpb_record, f_idx_sys_flag, &desc2);
|
||||
SCL_check_relation(tdbb, &desc, SCL_control, MOV_get_long(tdbb, &desc2, 0) == 1);
|
||||
EVL_field(0, rpb->rpb_record, f_idx_id, &desc2);
|
||||
if ( (id = MOV_get_long(tdbb, &desc2, 0)) )
|
||||
{
|
||||
@ -3253,7 +3254,8 @@ void VIO_store(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
|
||||
case rel_indices:
|
||||
protect_system_table_insert(tdbb, request, relation);
|
||||
EVL_field(0, rpb->rpb_record, f_idx_relation, &desc);
|
||||
SCL_check_relation(tdbb, &desc, SCL_control);
|
||||
EVL_field(0, rpb->rpb_record, f_idx_sys_flag, &desc2);
|
||||
SCL_check_relation(tdbb, &desc, SCL_control, MOV_get_long(tdbb, &desc2, 0) == 1);
|
||||
EVL_field(0, rpb->rpb_record, f_idx_name, &desc);
|
||||
if (EVL_field(0, rpb->rpb_record, f_idx_exp_blr, &desc2))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user