mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 17:23:04 +01:00
DDL permission check for COMMENT ON
This commit is contained in:
parent
d58252acec
commit
b0a7e783fa
@ -489,6 +489,23 @@ static MetaName getIndexRelationName(thread_db* tdbb, jrd_tra* transaction,
|
|||||||
return ""; // silence warning
|
return ""; // silence warning
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get relation name of an trigger.
|
||||||
|
static MetaName getTriggerRelationName(thread_db* tdbb, jrd_tra* transaction,
|
||||||
|
const MetaName& triggerName)
|
||||||
|
{
|
||||||
|
AutoCacheRequest request(tdbb, drq_l_trigger_relname, DYN_REQUESTS);
|
||||||
|
|
||||||
|
FOR (REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||||
|
X IN RDB$TRIGGERS
|
||||||
|
WITH X.RDB$TRIGGER_NAME EQ triggerName.c_str()
|
||||||
|
{
|
||||||
|
return X.RDB$RELATION_NAME;
|
||||||
|
}
|
||||||
|
END_FOR
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
// Get relation type name
|
// Get relation type name
|
||||||
static const char* getRelationScopeName(const rel_t type)
|
static const char* getRelationScopeName(const rel_t type)
|
||||||
{
|
{
|
||||||
@ -1058,25 +1075,9 @@ void CommentOnNode::print(string& text) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CommentOnNode::checkPermission(thread_db* tdbb, jrd_tra* transaction)
|
bool CommentOnNode::checkPermission(thread_db* tdbb, jrd_tra* transaction)
|
||||||
{
|
|
||||||
//DDL_TODO
|
|
||||||
// Probably requires migration code from execute with caching some query results for reuse in execute later.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// select rdb$relation_name from rdb$relation_fields where rdb$field_name = 'RDB$DESCRIPTION';
|
|
||||||
// gives the list of objects that accept descriptions. At FB2 time, the only
|
|
||||||
// subobjects with descriptions are relation's fields and procedure's parameters.
|
|
||||||
// In FB3 we added function's arguments.
|
|
||||||
void CommentOnNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
|
|
||||||
jrd_tra* transaction)
|
|
||||||
{
|
{
|
||||||
Attachment* const attachment = transaction->tra_attachment;
|
Attachment* const attachment = transaction->tra_attachment;
|
||||||
|
|
||||||
const char* tableClause = NULL;
|
|
||||||
const char* columnClause = NULL;
|
|
||||||
const char* subColumnClause = NULL;
|
|
||||||
const char* addWhereClause = NULL;
|
|
||||||
Arg::StatusVector status;
|
Arg::StatusVector status;
|
||||||
string objNameStr = objName.toString();
|
string objNameStr = objName.toString();
|
||||||
|
|
||||||
@ -1127,6 +1128,109 @@ void CommentOnNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dsc dscName;
|
||||||
|
MetaName relationName;
|
||||||
|
switch (objType)
|
||||||
|
{
|
||||||
|
case obj_schema:
|
||||||
|
case obj_database:
|
||||||
|
SCL_check_database(tdbb, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_field:
|
||||||
|
SCL_check_domain(tdbb, objName.identifier, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_relation:
|
||||||
|
dscName.makeText(objNameStr.length(), CS_METADATA, (UCHAR*) objName.identifier.c_str());
|
||||||
|
SCL_check_relation(tdbb, &dscName, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_view:
|
||||||
|
dscName.makeText(objNameStr.length(), CS_METADATA, (UCHAR*) objName.identifier.c_str());
|
||||||
|
SCL_check_view(tdbb, &dscName, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_procedure:
|
||||||
|
dscName.makeText(objNameStr.length(), CS_METADATA, (UCHAR*) objName.identifier.c_str());
|
||||||
|
SCL_check_procedure(tdbb, &dscName, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_trigger:
|
||||||
|
relationName = getTriggerRelationName(tdbb, transaction, objName.identifier);
|
||||||
|
if (relationName.isEmpty())
|
||||||
|
SCL_check_database(tdbb, SCL_alter);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dscName.makeText(relationName.length(), CS_METADATA, (UCHAR*) relationName.c_str());
|
||||||
|
SCL_check_relation(tdbb, &dscName, SCL_alter);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_udf:
|
||||||
|
dscName.makeText(objName.identifier.length(), CS_METADATA, (UCHAR*) objName.identifier.c_str());
|
||||||
|
SCL_check_function(tdbb, &dscName, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_blob_filter:
|
||||||
|
SCL_check_filter(tdbb, objName.identifier, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_exception:
|
||||||
|
SCL_check_exception(tdbb, objName.identifier, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_generator:
|
||||||
|
SCL_check_generator(tdbb, objName.identifier, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_index:
|
||||||
|
relationName = getIndexRelationName(tdbb, transaction, objName.identifier);
|
||||||
|
dscName.makeText(relationName.length(), CS_METADATA, (UCHAR*) relationName.c_str());
|
||||||
|
SCL_check_relation(tdbb, &dscName, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_sql_role:
|
||||||
|
SCL_check_role(tdbb, objName.identifier, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_charset:
|
||||||
|
SCL_check_charset(tdbb, objName.identifier, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_collation:
|
||||||
|
SCL_check_collation(tdbb, objName.identifier, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case obj_package_header:
|
||||||
|
dscName.makeText(objName.identifier.length(), CS_METADATA, (UCHAR*) objName.identifier.c_str());
|
||||||
|
SCL_check_package(tdbb, &dscName, SCL_alter);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fb_assert(false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// select rdb$relation_name from rdb$relation_fields where rdb$field_name = 'RDB$DESCRIPTION';
|
||||||
|
// gives the list of objects that accept descriptions. At FB2 time, the only
|
||||||
|
// subobjects with descriptions are relation's fields and procedure's parameters.
|
||||||
|
// In FB3 we added function's arguments.
|
||||||
|
void CommentOnNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch,
|
||||||
|
jrd_tra* transaction)
|
||||||
|
{
|
||||||
|
Attachment* const attachment = transaction->tra_attachment;
|
||||||
|
|
||||||
|
const char* tableClause = NULL;
|
||||||
|
const char* columnClause = NULL;
|
||||||
|
const char* subColumnClause = NULL;
|
||||||
|
const char* addWhereClause = NULL;
|
||||||
|
Arg::StatusVector status;
|
||||||
|
string objNameStr = objName.toString();
|
||||||
|
|
||||||
|
fb_assert(objType != obj_parameter);
|
||||||
|
|
||||||
switch (objType)
|
switch (objType)
|
||||||
{
|
{
|
||||||
case obj_database:
|
case obj_database:
|
||||||
@ -3340,17 +3444,7 @@ DdlNode* DropTriggerNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
|
|||||||
|
|
||||||
bool DropTriggerNode::checkPermission(thread_db* tdbb, jrd_tra* transaction)
|
bool DropTriggerNode::checkPermission(thread_db* tdbb, jrd_tra* transaction)
|
||||||
{
|
{
|
||||||
MetaName relationName;
|
MetaName relationName = getTriggerRelationName(tdbb, transaction, name);
|
||||||
|
|
||||||
AutoCacheRequest request(tdbb, drq_l_trigger_relname, DYN_REQUESTS);
|
|
||||||
|
|
||||||
FOR (REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
|
||||||
X IN RDB$TRIGGERS
|
|
||||||
WITH X.RDB$TRIGGER_NAME EQ name.c_str()
|
|
||||||
{
|
|
||||||
relationName = X.RDB$RELATION_NAME;
|
|
||||||
}
|
|
||||||
END_FOR
|
|
||||||
|
|
||||||
if (relationName.isEmpty())
|
if (relationName.isEmpty())
|
||||||
SCL_check_database(tdbb, SCL_alter);
|
SCL_check_database(tdbb, SCL_alter);
|
||||||
|
Loading…
Reference in New Issue
Block a user