mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 22:43:03 +01:00
Refactor DDL commands: DROP INDEX, DROP FILTER, DROP SHADOW, CREATE/DROP ROLE and DROP USER.
This commit is contained in:
parent
33fd17708a
commit
193f9379b9
@ -26,7 +26,6 @@
|
||||
<ClCompile Include="..\..\..\gen\jrd\dpm.cpp" />
|
||||
<ClCompile Include="..\..\..\gen\jrd\dyn.cpp" />
|
||||
<ClCompile Include="..\..\..\gen\jrd\dyn_def.cpp" />
|
||||
<ClCompile Include="..\..\..\gen\jrd\dyn_del.cpp" />
|
||||
<ClCompile Include="..\..\..\gen\jrd\dyn_mod.cpp" />
|
||||
<ClCompile Include="..\..\..\gen\jrd\dyn_util.cpp" />
|
||||
<ClCompile Include="..\..\..\gen\jrd\fun.cpp" />
|
||||
@ -220,7 +219,6 @@
|
||||
<ClInclude Include="..\..\..\src\jrd\drq.h" />
|
||||
<ClInclude Include="..\..\..\src\jrd\dyn.h" />
|
||||
<ClInclude Include="..\..\..\src\jrd\dyn_df_proto.h" />
|
||||
<ClInclude Include="..\..\..\src\jrd\dyn_dl_proto.h" />
|
||||
<ClInclude Include="..\..\..\src\jrd\dyn_md_proto.h" />
|
||||
<ClInclude Include="..\..\..\src\jrd\dyn_proto.h" />
|
||||
<ClInclude Include="..\..\..\src\jrd\dyn_ut_proto.h" />
|
||||
@ -353,7 +351,6 @@
|
||||
<None Include="..\..\..\src\jrd\dpm.epp" />
|
||||
<None Include="..\..\..\src\jrd\dyn.epp" />
|
||||
<None Include="..\..\..\src\jrd\dyn_def.epp" />
|
||||
<None Include="..\..\..\src\jrd\dyn_del.epp" />
|
||||
<None Include="..\..\..\src\jrd\dyn_mod.epp" />
|
||||
<None Include="..\..\..\src\jrd\dyn_util.epp" />
|
||||
<None Include="..\..\..\src\jrd\fun.epp" />
|
||||
|
@ -417,9 +417,6 @@
|
||||
<ClCompile Include="..\..\..\gen\jrd\dyn_def.cpp">
|
||||
<Filter>JRD files\GPRE cpp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gen\jrd\dyn_del.cpp">
|
||||
<Filter>JRD files\GPRE cpp</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\gen\jrd\dyn_mod.cpp">
|
||||
<Filter>JRD files\GPRE cpp</Filter>
|
||||
</ClCompile>
|
||||
@ -686,9 +683,6 @@
|
||||
<ClInclude Include="..\..\..\src\jrd\dyn_df_proto.h">
|
||||
<Filter>Header files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\jrd\dyn_dl_proto.h">
|
||||
<Filter>Header files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\src\jrd\dyn_md_proto.h">
|
||||
<Filter>Header files</Filter>
|
||||
</ClInclude>
|
||||
@ -1027,9 +1021,6 @@
|
||||
<None Include="..\..\..\src\jrd\dyn_def.epp">
|
||||
<Filter>JRD files\GPRE files</Filter>
|
||||
</None>
|
||||
<None Include="..\..\..\src\jrd\dyn_del.epp">
|
||||
<Filter>JRD files\GPRE files</Filter>
|
||||
</None>
|
||||
<None Include="..\..\..\src\jrd\dyn_mod.epp">
|
||||
<Filter>JRD files\GPRE files</Filter>
|
||||
</None>
|
||||
|
@ -730,10 +730,6 @@
|
||||
RelativePath="..\..\..\gen\jrd\dyn_def.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\gen\jrd\dyn_del.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\gen\jrd\dyn_mod.cpp"
|
||||
>
|
||||
@ -790,10 +786,6 @@
|
||||
RelativePath="..\..\..\src\jrd\dyn_def.epp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\jrd\dyn_del.epp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\jrd\dyn_mod.epp"
|
||||
>
|
||||
@ -1043,10 +1035,6 @@
|
||||
RelativePath="..\..\..\src\jrd\dyn_df_proto.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\jrd\dyn_dl_proto.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\src\jrd\dyn_md_proto.h"
|
||||
>
|
||||
|
@ -67,7 +67,7 @@ goto :EOF
|
||||
@for %%i in (array, blob) do @call :PREPROCESS yvalve %%i
|
||||
@for %%i in (metd, DdlNodes, PackageNodes) do @call :PREPROCESS dsql %%i -gds_cxx
|
||||
@for %%i in (gpre_meta) do @call :PREPROCESS gpre/std %%i
|
||||
@for %%i in (dfw, dpm, dyn, dyn_def, dyn_del, dyn_mod, dyn_util, fun, grant, ini, met, pcmet, scl, Function) do @call :PREPROCESS jrd %%i -gds_cxx
|
||||
@for %%i in (dfw, dpm, dyn, dyn_def, dyn_mod, dyn_util, fun, grant, ini, met, pcmet, scl, Function) do @call :PREPROCESS jrd %%i -gds_cxx
|
||||
@for %%i in (stats) do @call :PREPROCESS utilities %%i
|
||||
@goto :EOF
|
||||
|
||||
@ -81,7 +81,7 @@ goto :EOF
|
||||
@for %%i in (metd) do @call :PREPROCESS dsql %%i -gds_cxx
|
||||
@for %%i in (DdlNodes, PackageNodes) do @call :PREPROCESS dsql %%i -gds_cxx
|
||||
@for %%i in (gpre_meta) do @call :PREPROCESS gpre/std %%i
|
||||
@for %%i in (dfw, dpm, dyn, dyn_def, dyn_del, dyn_mod, dyn_util, fun, grant, ini, met, pcmet, scl, Function) do @call :PREPROCESS jrd %%i -gds_cxx
|
||||
@for %%i in (dfw, dpm, dyn, dyn_def, dyn_mod, dyn_util, fun, grant, ini, met, pcmet, scl, Function) do @call :PREPROCESS jrd %%i -gds_cxx
|
||||
@for %%i in (codes) do @call :PREPROCESS misc %%i
|
||||
@for %%i in (build_file) do @call :PREPROCESS msgs %%i
|
||||
@for %%i in (help, meta, proc, show) do @call :PREPROCESS qli %%i
|
||||
|
@ -2118,6 +2118,18 @@ C --
|
||||
PARAMETER (GDS__dsql_drop_sequence_failed = 336397303)
|
||||
INTEGER*4 GDS__dsql_recreate_sequence_failed
|
||||
PARAMETER (GDS__dsql_recreate_sequence_failed = 336397304)
|
||||
INTEGER*4 GDS__dsql_drop_index_failed
|
||||
PARAMETER (GDS__dsql_drop_index_failed = 336397305)
|
||||
INTEGER*4 GDS__dsql_drop_filter_failed
|
||||
PARAMETER (GDS__dsql_drop_filter_failed = 336397306)
|
||||
INTEGER*4 GDS__dsql_drop_shadow_failed
|
||||
PARAMETER (GDS__dsql_drop_shadow_failed = 336397307)
|
||||
INTEGER*4 GDS__dsql_drop_role_failed
|
||||
PARAMETER (GDS__dsql_drop_role_failed = 336397308)
|
||||
INTEGER*4 GDS__dsql_drop_user_failed
|
||||
PARAMETER (GDS__dsql_drop_user_failed = 336397309)
|
||||
INTEGER*4 GDS__dsql_create_role_failed
|
||||
PARAMETER (GDS__dsql_create_role_failed = 336397310)
|
||||
INTEGER*4 GDS__gsec_cant_open_db
|
||||
PARAMETER (GDS__gsec_cant_open_db = 336723983)
|
||||
INTEGER*4 GDS__gsec_switches_error
|
||||
|
@ -1066,6 +1066,12 @@ const
|
||||
gds_dsql_drop_view_failed = 336397302;
|
||||
gds_dsql_drop_sequence_failed = 336397303;
|
||||
gds_dsql_recreate_sequence_failed = 336397304;
|
||||
gds_dsql_drop_index_failed = 336397305;
|
||||
gds_dsql_drop_filter_failed = 336397306;
|
||||
gds_dsql_drop_shadow_failed = 336397307;
|
||||
gds_dsql_drop_role_failed = 336397308;
|
||||
gds_dsql_drop_user_failed = 336397309;
|
||||
gds_dsql_create_role_failed = 336397310;
|
||||
gds_gsec_cant_open_db = 336723983;
|
||||
gds_gsec_switches_error = 336723984;
|
||||
gds_gsec_no_op_spec = 336723985;
|
||||
|
@ -39,9 +39,10 @@
|
||||
#include "../jrd/IntlManager.h"
|
||||
#include "../jrd/PreparedStatement.h"
|
||||
#include "../jrd/ResultSet.h"
|
||||
#include "../jrd/UserManagement.h"
|
||||
#include "../jrd/blb_proto.h"
|
||||
#include "../jrd/cmp_proto.h"
|
||||
#include "../common/dsc_proto.h"
|
||||
#include "../jrd/dfw_proto.h"
|
||||
#include "../jrd/dyn_dl_proto.h"
|
||||
#include "../jrd/dyn_ut_proto.h"
|
||||
#include "../jrd/exe_proto.h"
|
||||
@ -56,8 +57,30 @@
|
||||
#include "../dsql/make_proto.h"
|
||||
#include "../dsql/metd_proto.h"
|
||||
#include "../dsql/pass1_proto.h"
|
||||
#include "../utilities/gsec/gsec.h"
|
||||
#include "../common/dsc_proto.h"
|
||||
#include "../common/StatusArg.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
class DynamicUserData : public Firebird::VersionedIface<Auth::UserData, FB_AUTH_USER_VERSION>
|
||||
{
|
||||
public:
|
||||
|
||||
#ifdef DEBUG_GDS_ALLOC
|
||||
void* operator new(size_t size, Firebird::MemoryPool& pool, const char* fileName, int line)
|
||||
{
|
||||
return pool.allocate(size, fileName, line);
|
||||
}
|
||||
#else // DEBUG_GDS_ALLOC
|
||||
void* operator new(size_t size, Firebird::MemoryPool& pool)
|
||||
{
|
||||
return pool.allocate(size);
|
||||
}
|
||||
#endif // DEBUG_GDS_ALLOC
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace Jrd {
|
||||
|
||||
using namespace Firebird;
|
||||
@ -8734,5 +8757,336 @@ bool DropIndexNode::deleteSegmentRecords(thread_db* tdbb, jrd_tra* transaction,
|
||||
return found;
|
||||
}
|
||||
|
||||
void DropIndexNode::print(string& text, Array<dsql_nod*>& /*nodes*/) const
|
||||
{
|
||||
text.printf(
|
||||
"DropIndexNode\n"
|
||||
" name: '%s'\n",
|
||||
name.c_str());
|
||||
}
|
||||
|
||||
void DropIndexNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
|
||||
{
|
||||
// run all statements under savepoint control
|
||||
AutoSavePoint savePoint(tdbb, transaction);
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_e_indices, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
IDX IN RDB$INDICES
|
||||
WITH IDX.RDB$INDEX_NAME EQ name.c_str()
|
||||
{
|
||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE,
|
||||
DDL_TRIGGER_DROP_INDEX, name);
|
||||
|
||||
ERASE IDX;
|
||||
|
||||
if (IDX.RDB$EXPRESSION_BLR.NULL && !deleteSegmentRecords(tdbb, transaction, name))
|
||||
{
|
||||
// msg 50: "No segments found for index"
|
||||
status_exception::raise(Arg::Gds(ENCODE_ISC_MSG(50, DYN_MSG_FAC)));
|
||||
}
|
||||
|
||||
found = true;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (found)
|
||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_AFTER, DDL_TRIGGER_DROP_INDEX, name);
|
||||
else
|
||||
{
|
||||
// msg 48: "Index not found"
|
||||
status_exception::raise(Arg::Gds(ENCODE_ISC_MSG(48, DYN_MSG_FAC)));
|
||||
}
|
||||
|
||||
savePoint.release(); // everything is ok
|
||||
}
|
||||
|
||||
|
||||
//----------------------
|
||||
|
||||
|
||||
void DropFilterNode::print(string& text, Array<dsql_nod*>& /*nodes*/) const
|
||||
{
|
||||
text.printf(
|
||||
"DropFilterNode\n"
|
||||
" name: '%s'\n",
|
||||
name.c_str());
|
||||
}
|
||||
|
||||
void DropFilterNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
|
||||
{
|
||||
// run all statements under savepoint control
|
||||
AutoSavePoint savePoint(tdbb, transaction);
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_e_filters, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$FILTERS
|
||||
WITH X.RDB$FUNCTION_NAME EQ name.c_str()
|
||||
{
|
||||
ERASE X;
|
||||
found = true;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!found)
|
||||
{
|
||||
// msg 37: "Blob Filter %s not found"
|
||||
status_exception::raise(Arg::Gds(ENCODE_ISC_MSG(37, DYN_MSG_FAC)) << name);
|
||||
}
|
||||
|
||||
savePoint.release(); // everything is ok
|
||||
}
|
||||
|
||||
|
||||
//----------------------
|
||||
|
||||
|
||||
void DropShadowNode::print(string& text, Array<dsql_nod*>& /*nodes*/) const
|
||||
{
|
||||
text.printf(
|
||||
"DropShadowNode\n"
|
||||
" number: '%d'\n",
|
||||
number);
|
||||
}
|
||||
|
||||
void DropShadowNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
|
||||
{
|
||||
if (!tdbb->getAttachment()->locksmith())
|
||||
status_exception::raise(Arg::Gds(isc_adm_task_denied));
|
||||
|
||||
// run all statements under savepoint control
|
||||
AutoSavePoint savePoint(tdbb, transaction);
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_e_shadow, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
FIL IN RDB$FILES
|
||||
WITH FIL.RDB$SHADOW_NUMBER EQ number
|
||||
{
|
||||
ERASE FIL;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
// ASF: No error is raised if the shadow is not found.
|
||||
|
||||
savePoint.release(); // everything is ok
|
||||
}
|
||||
|
||||
|
||||
//----------------------
|
||||
|
||||
|
||||
void CreateRoleNode::print(string& text, Array<dsql_nod*>& /*nodes*/) const
|
||||
{
|
||||
text.printf(
|
||||
"CreateRoleNode\n"
|
||||
" name: '%s'\n",
|
||||
name.c_str());
|
||||
}
|
||||
|
||||
void CreateRoleNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
|
||||
{
|
||||
MetaName ownerName(tdbb->getAttachment()->att_user->usr_user_name);
|
||||
ownerName.upper7();
|
||||
|
||||
// run all statements under savepoint control
|
||||
AutoSavePoint savePoint(tdbb, transaction);
|
||||
|
||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE,
|
||||
DDL_TRIGGER_CREATE_ROLE, name);
|
||||
|
||||
if (name == ownerName)
|
||||
{
|
||||
// msg 193: "user name could not be used for SQL role"
|
||||
status_exception::raise(Arg::Gds(ENCODE_ISC_MSG(193, DYN_MSG_FAC)) << ownerName);
|
||||
}
|
||||
|
||||
if (name == NULL_ROLE)
|
||||
{
|
||||
// msg 195: "keyword NONE could not be used as SQL role name"
|
||||
status_exception::raise(Arg::Gds(ENCODE_ISC_MSG(195, DYN_MSG_FAC)) << name);
|
||||
}
|
||||
|
||||
if (isItUserName(tdbb, transaction))
|
||||
{
|
||||
// msg 193: "user name could not be used for SQL role"
|
||||
status_exception::raise(Arg::Gds(ENCODE_ISC_MSG(193, DYN_MSG_FAC)) << name);
|
||||
}
|
||||
|
||||
MetaName dummyName;
|
||||
if (DYN_is_it_sql_role(transaction, name, dummyName, tdbb))
|
||||
{
|
||||
// msg 194: "SQL role @1 already exists"
|
||||
status_exception::raise(Arg::Gds(ENCODE_ISC_MSG(194, DYN_MSG_FAC)) << name);
|
||||
}
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_role_gens, DYN_REQUESTS);
|
||||
|
||||
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$ROLES
|
||||
{
|
||||
strcpy(X.RDB$ROLE_NAME, name.c_str());
|
||||
strcpy(X.RDB$OWNER_NAME, ownerName.c_str());
|
||||
X.RDB$SYSTEM_FLAG = 0;
|
||||
}
|
||||
END_STORE
|
||||
|
||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_AFTER,
|
||||
DDL_TRIGGER_CREATE_ROLE, name);
|
||||
|
||||
savePoint.release(); // everything is ok
|
||||
}
|
||||
|
||||
// If role name is user name returns true. Otherwise returns false.
|
||||
bool CreateRoleNode::isItUserName(thread_db* tdbb, jrd_tra* transaction)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
// If there is a user with privilege or a grantor on a relation we
|
||||
// can infer there is a user with this name
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_get_user_priv, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
PRIV IN RDB$USER_PRIVILEGES
|
||||
WITH (PRIV.RDB$USER EQ name.c_str() AND PRIV.RDB$USER_TYPE = obj_user) OR
|
||||
(PRIV.RDB$GRANTOR EQ name.c_str() AND PRIV.RDB$OBJECT_TYPE = obj_relation)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (found)
|
||||
return found;
|
||||
|
||||
// We can infer that 'role name' is a user name if it owns any relations
|
||||
// Note we can only get here if a user creates a table and revokes all
|
||||
// his privileges on the table
|
||||
|
||||
request.reset(tdbb, drq_get_rel_owner, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
REL IN RDB$RELATIONS
|
||||
WITH REL.RDB$OWNER_NAME EQ name.c_str()
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
//----------------------
|
||||
|
||||
|
||||
void DropRoleNode::print(string& text, Array<dsql_nod*>& /*nodes*/) const
|
||||
{
|
||||
text.printf(
|
||||
"DropRoleNode\n"
|
||||
" name: '%s'\n",
|
||||
name.c_str());
|
||||
}
|
||||
|
||||
void DropRoleNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
|
||||
{
|
||||
MetaName user(tdbb->getAttachment()->att_user->usr_user_name);
|
||||
user.upper7();
|
||||
|
||||
// run all statements under savepoint control
|
||||
AutoSavePoint savePoint(tdbb, transaction);
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_drop_role, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
ROL IN RDB$ROLES
|
||||
WITH ROL.RDB$ROLE_NAME EQ name.c_str()
|
||||
{
|
||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE,
|
||||
DDL_TRIGGER_DROP_ROLE, name);
|
||||
|
||||
const MetaName roleOwner(ROL.RDB$OWNER_NAME);
|
||||
|
||||
if (tdbb->getAttachment()->locksmith() || roleOwner == user)
|
||||
{
|
||||
AutoCacheRequest request2(tdbb, drq_del_role_1, DYN_REQUESTS);
|
||||
|
||||
// The first OR clause finds all members of the role.
|
||||
// The 2nd OR clause finds all privileges granted to the role
|
||||
FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE transaction)
|
||||
PRIV IN RDB$USER_PRIVILEGES
|
||||
WITH (PRIV.RDB$RELATION_NAME EQ name.c_str() AND PRIV.RDB$OBJECT_TYPE = obj_sql_role) OR
|
||||
(PRIV.RDB$USER EQ name.c_str() AND PRIV.RDB$USER_TYPE = obj_sql_role)
|
||||
{
|
||||
ERASE PRIV;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
ERASE ROL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// msg 191: "only owner of SQL role or USR_locksmith could drop SQL role"
|
||||
status_exception::raise(Arg::Gds(ENCODE_ISC_MSG(191, DYN_MSG_FAC)));
|
||||
}
|
||||
|
||||
found = true;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (found)
|
||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_AFTER, DDL_TRIGGER_DROP_ROLE, name);
|
||||
else
|
||||
{
|
||||
// msg 155: "Role %s not found"
|
||||
status_exception::raise(Arg::Gds(ENCODE_ISC_MSG(155, DYN_MSG_FAC)) << name);
|
||||
}
|
||||
|
||||
savePoint.release(); // everything is ok
|
||||
}
|
||||
|
||||
|
||||
//----------------------
|
||||
|
||||
|
||||
void DropUserNode::print(string& text, Array<dsql_nod*>& /*nodes*/) const
|
||||
{
|
||||
text.printf(
|
||||
"DropUserNode\n"
|
||||
" name: '%s'\n",
|
||||
name.c_str());
|
||||
}
|
||||
|
||||
void DropUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
|
||||
{
|
||||
// run all statements under savepoint control
|
||||
AutoSavePoint savePoint(tdbb, transaction);
|
||||
|
||||
DynamicUserData* userData = FB_NEW(*transaction->tra_pool) DynamicUserData;
|
||||
|
||||
string text = name.c_str();
|
||||
text.upper();
|
||||
|
||||
userData->op = DEL_OPER;
|
||||
userData->user.set(text.c_str());
|
||||
userData->user.setEntered(1);
|
||||
|
||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE, DDL_TRIGGER_DROP_USER,
|
||||
userData->user.get());
|
||||
|
||||
USHORT id = transaction->getUserManagement()->put(userData);
|
||||
DFW_post_work(transaction, dfw_user_management, NULL, id);
|
||||
|
||||
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_AFTER, DDL_TRIGGER_DROP_USER,
|
||||
userData->user.get());
|
||||
|
||||
savePoint.release(); // everything is ok
|
||||
}
|
||||
|
||||
|
||||
} // namespace Jrd
|
||||
|
@ -1245,11 +1245,153 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class DropIndexNode
|
||||
class DropIndexNode : public DdlNode
|
||||
{
|
||||
public:
|
||||
DropIndexNode(MemoryPool& p, const Firebird::MetaName& aName)
|
||||
: DdlNode(p),
|
||||
name(p, aName)
|
||||
{
|
||||
}
|
||||
|
||||
static bool deleteSegmentRecords(thread_db* tdbb, jrd_tra* transaction,
|
||||
const Firebird::MetaName& name);
|
||||
|
||||
public:
|
||||
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
||||
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
||||
|
||||
protected:
|
||||
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
||||
{
|
||||
statusVector << Firebird::Arg::Gds(isc_dsql_drop_index_failed) << name;
|
||||
}
|
||||
|
||||
public:
|
||||
Firebird::MetaName name;
|
||||
};
|
||||
|
||||
|
||||
class DropFilterNode : public DdlNode
|
||||
{
|
||||
public:
|
||||
DropFilterNode(MemoryPool& p, const Firebird::MetaName& aName)
|
||||
: DdlNode(p),
|
||||
name(p, aName)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
||||
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
||||
|
||||
protected:
|
||||
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
||||
{
|
||||
statusVector << Firebird::Arg::Gds(isc_dsql_drop_filter_failed) << name;
|
||||
}
|
||||
|
||||
public:
|
||||
Firebird::MetaName name;
|
||||
};
|
||||
|
||||
|
||||
class DropShadowNode : public DdlNode
|
||||
{
|
||||
public:
|
||||
DropShadowNode(MemoryPool& p, const SSHORT aNumber)
|
||||
: DdlNode(p),
|
||||
number(aNumber)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
||||
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
||||
|
||||
protected:
|
||||
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
||||
{
|
||||
statusVector << Firebird::Arg::Gds(isc_dsql_drop_shadow_failed) << Firebird::Arg::Num(number);
|
||||
}
|
||||
|
||||
public:
|
||||
SSHORT number;
|
||||
};
|
||||
|
||||
|
||||
class CreateRoleNode : public DdlNode
|
||||
{
|
||||
public:
|
||||
CreateRoleNode(MemoryPool& p, const Firebird::MetaName& aName)
|
||||
: DdlNode(p),
|
||||
name(p, aName)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
||||
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
||||
|
||||
protected:
|
||||
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
||||
{
|
||||
statusVector << Firebird::Arg::Gds(isc_dsql_create_role_failed) << name;
|
||||
}
|
||||
|
||||
private:
|
||||
bool isItUserName(thread_db* tdbb, jrd_tra* transaction);
|
||||
|
||||
public:
|
||||
Firebird::MetaName name;
|
||||
};
|
||||
|
||||
|
||||
class DropRoleNode : public DdlNode
|
||||
{
|
||||
public:
|
||||
DropRoleNode(MemoryPool& p, const Firebird::MetaName& aName)
|
||||
: DdlNode(p),
|
||||
name(p, aName)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
||||
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
||||
|
||||
protected:
|
||||
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
||||
{
|
||||
statusVector << Firebird::Arg::Gds(isc_dsql_drop_role_failed) << name;
|
||||
}
|
||||
|
||||
public:
|
||||
Firebird::MetaName name;
|
||||
};
|
||||
|
||||
|
||||
class DropUserNode : public DdlNode
|
||||
{
|
||||
public:
|
||||
DropUserNode(MemoryPool& p, const Firebird::MetaName& aName)
|
||||
: DdlNode(p),
|
||||
name(p, aName)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void print(Firebird::string& text, Firebird::Array<dsql_nod*>& nodes) const;
|
||||
virtual void execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction);
|
||||
|
||||
protected:
|
||||
virtual void putErrorPrefix(Firebird::Arg::StatusVector& statusVector)
|
||||
{
|
||||
statusVector << Firebird::Arg::Gds(isc_dsql_drop_user_failed) << name;
|
||||
}
|
||||
|
||||
public:
|
||||
Firebird::MetaName name;
|
||||
};
|
||||
|
||||
|
||||
|
@ -119,7 +119,6 @@ static void define_computed(DsqlCompilerScratch*, dsql_nod*, dsql_fld*, dsql_nod
|
||||
static void define_database(DsqlCompilerScratch*);
|
||||
static void define_filter(DsqlCompilerScratch*);
|
||||
static SSHORT getBlobFilterSubType(DsqlCompilerScratch* dsqlScratch, const dsql_nod* node);
|
||||
static void define_role(DsqlCompilerScratch*);
|
||||
static void define_index(DsqlCompilerScratch*);
|
||||
static void define_shadow(DsqlCompilerScratch*);
|
||||
static void generate_dyn(DsqlCompilerScratch*, dsql_nod*);
|
||||
@ -925,21 +924,6 @@ static void define_index(DsqlCompilerScratch* dsqlScratch)
|
||||
}
|
||||
|
||||
|
||||
// ******************************
|
||||
// d e f i n e _ r o l e
|
||||
// ******************************
|
||||
// Create a SQL role.
|
||||
//
|
||||
static void define_role(DsqlCompilerScratch* dsqlScratch)
|
||||
{
|
||||
DsqlCompiledStatement* statement = dsqlScratch->getStatement();
|
||||
const dsql_str* role_name = (dsql_str*) statement->getDdlNode()->nod_arg[0];
|
||||
|
||||
dsqlScratch->appendNullString(isc_dyn_def_sql_role, role_name->str_data);
|
||||
dsqlScratch->appendUChar(isc_dyn_end);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// create a shadow for the database
|
||||
//
|
||||
@ -1016,37 +1000,15 @@ static void generate_dyn(DsqlCompilerScratch* dsqlScratch, dsql_nod* node)
|
||||
define_index(dsqlScratch);
|
||||
break;
|
||||
|
||||
case nod_del_index:
|
||||
string = (dsql_str*) node->nod_arg[0];
|
||||
dsqlScratch->appendNullString(isc_dyn_delete_idx, string->str_data);
|
||||
dsqlScratch->appendUChar(isc_dyn_end);
|
||||
break;
|
||||
|
||||
case nod_del_role:
|
||||
string = (dsql_str*) node->nod_arg[0];
|
||||
dsqlScratch->appendNullString(isc_dyn_del_sql_role, string->str_data);
|
||||
dsqlScratch->appendUChar(isc_dyn_end);
|
||||
break;
|
||||
|
||||
case nod_grant:
|
||||
case nod_revoke:
|
||||
grant_revoke(dsqlScratch);
|
||||
break;
|
||||
|
||||
case nod_def_role:
|
||||
define_role(dsqlScratch);
|
||||
break;
|
||||
|
||||
case nod_def_filter:
|
||||
define_filter(dsqlScratch);
|
||||
break;
|
||||
|
||||
case nod_del_filter:
|
||||
string = (dsql_str*) node->nod_arg[0];
|
||||
dsqlScratch->appendNullString(isc_dyn_delete_filter, string->str_data);
|
||||
dsqlScratch->appendUChar(isc_dyn_end);
|
||||
break;
|
||||
|
||||
case nod_del_udf:
|
||||
string = (dsql_str*) node->nod_arg[0];
|
||||
dsqlScratch->appendNullString(isc_dyn_delete_function, string->str_data);
|
||||
@ -1057,11 +1019,6 @@ static void generate_dyn(DsqlCompilerScratch* dsqlScratch, dsql_nod* node)
|
||||
define_shadow(dsqlScratch);
|
||||
break;
|
||||
|
||||
case nod_del_shadow:
|
||||
dsqlScratch->appendNumber(isc_dyn_delete_shadow, (SSHORT) (IPTR) node->nod_arg[0]);
|
||||
dsqlScratch->appendUChar(isc_dyn_end);
|
||||
break;
|
||||
|
||||
case nod_mod_database:
|
||||
modify_database(dsqlScratch);
|
||||
break;
|
||||
@ -1094,10 +1051,6 @@ static void generate_dyn(DsqlCompilerScratch* dsqlScratch, dsql_nod* node)
|
||||
define_user(dsqlScratch, isc_dyn_user_mod);
|
||||
break;
|
||||
|
||||
case nod_del_user:
|
||||
define_user(dsqlScratch, isc_dyn_user_del);
|
||||
break;
|
||||
|
||||
default: // CVC: Shouldn't we complain here?
|
||||
break;
|
||||
}
|
||||
@ -1640,7 +1593,7 @@ static void define_user(DsqlCompilerScratch* dsqlScratch, UCHAR op)
|
||||
}
|
||||
}
|
||||
|
||||
if (argCount < 2 && op != isc_dyn_user_del)
|
||||
if (argCount < 2)
|
||||
{
|
||||
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
|
||||
// Unexpected end of command
|
||||
|
@ -67,12 +67,9 @@ enum nod_t
|
||||
nod_mod_field,
|
||||
nod_del_field,
|
||||
nod_def_index,
|
||||
nod_del_index,
|
||||
nod_def_constraint,
|
||||
nod_def_filter,
|
||||
nod_del_filter,
|
||||
nod_def_shadow,
|
||||
nod_del_shadow,
|
||||
nod_del_udf,
|
||||
nod_grant,
|
||||
nod_revoke,
|
||||
@ -134,10 +131,8 @@ enum nod_t
|
||||
nod_set_statistics, // set statistics
|
||||
nod_ref_upd_del, // referential integrity actions
|
||||
nod_ref_trig_action,
|
||||
nod_def_role, // SQL role support
|
||||
nod_role_name,
|
||||
nod_grant_admin,
|
||||
nod_del_role,
|
||||
nod_mod_field_name,
|
||||
nod_mod_field_type,
|
||||
nod_mod_field_pos,
|
||||
@ -156,7 +151,6 @@ enum nod_t
|
||||
nod_mod_role,
|
||||
nod_add_user,
|
||||
nod_mod_user,
|
||||
nod_del_user,
|
||||
nod_dfl_collate,
|
||||
nod_trg_act,
|
||||
nod_trg_ext,
|
||||
|
@ -714,8 +714,8 @@ inline void check_copy_incr(char*& to, const char ch, const char* const string)
|
||||
%type <legacyNode> delete_rule delimiter_opt derived_column_list derived_table
|
||||
%type <legacyNode> deterministic_opt distinct_clause
|
||||
%type <legacyNode> domain_default domain_default_opt domain_or_non_array_type
|
||||
%type <legacyNode> domain_or_non_array_type_name domain_type drop drop_behaviour
|
||||
%type <legacyNode> drop_clause drop_user_clause
|
||||
%type <legacyNode> domain_or_non_array_type_name domain_type drop_behaviour
|
||||
%type <ddlNode> drop drop_clause
|
||||
%type <legacyStr> db_name ddl_desc
|
||||
|
||||
%type <legacyNode> event_argument_opt exception_clause
|
||||
@ -972,6 +972,7 @@ statement
|
||||
| delete
|
||||
{ $$ = makeClassNode($1); }
|
||||
| drop
|
||||
{ $$ = makeClassNode($1); }
|
||||
| grant
|
||||
| insert
|
||||
{ $$ = makeClassNode($1); }
|
||||
@ -1532,7 +1533,7 @@ generator_clause
|
||||
// CREATE ROLE
|
||||
|
||||
role_clause
|
||||
: symbol_role_name { $$ = make_node (nod_def_role, (int) 1, $1); }
|
||||
: symbol_role_name { $$ = makeClassNode(newNode<CreateRoleNode>(toName($1))); }
|
||||
;
|
||||
|
||||
|
||||
@ -3509,47 +3510,48 @@ trigger_type_opt // we do not allow alter database triggers, hence we do not use
|
||||
|
||||
// DROP metadata operations
|
||||
|
||||
drop : DROP drop_clause
|
||||
{ $$ = $2; }
|
||||
;
|
||||
drop
|
||||
: DROP drop_clause
|
||||
{ $$ = $2; }
|
||||
;
|
||||
|
||||
drop_clause
|
||||
: EXCEPTION symbol_exception_name
|
||||
{ $$ = makeClassNode(newNode<DropExceptionNode>(toName($2))); }
|
||||
{ $$ = newNode<DropExceptionNode>(toName($2)); }
|
||||
| INDEX symbol_index_name
|
||||
{ $$ = make_node (nod_del_index, (int) 1, $2); }
|
||||
{ $$ = newNode<DropIndexNode>(toName($2)); }
|
||||
| PROCEDURE symbol_procedure_name
|
||||
{ $$ = makeClassNode(newNode<DropProcedureNode>(toName($2))); }
|
||||
{ $$ = newNode<DropProcedureNode>(toName($2)); }
|
||||
| TABLE symbol_table_name
|
||||
{ $$ = makeClassNode(newNode<DropRelationNode>(toName($2), false)); }
|
||||
{ $$ = newNode<DropRelationNode>(toName($2), false); }
|
||||
| TRIGGER symbol_trigger_name
|
||||
{ $$ = makeClassNode(newNode<DropTriggerNode>(toName($2))); }
|
||||
{ $$ = newNode<DropTriggerNode>(toName($2)); }
|
||||
| VIEW symbol_view_name
|
||||
{ $$ = makeClassNode(newNode<DropRelationNode>(toName($2), true)); }
|
||||
{ $$ = newNode<DropRelationNode>(toName($2), true); }
|
||||
| FILTER symbol_filter_name
|
||||
{ $$ = make_node (nod_del_filter, (int) 1, $2); }
|
||||
{ $$ = newNode<DropFilterNode>(toName($2)); }
|
||||
| DOMAIN symbol_domain_name
|
||||
{ $$ = makeClassNode(newNode<DropDomainNode>(toName($2))); }
|
||||
{ $$ = newNode<DropDomainNode>(toName($2)); }
|
||||
| EXTERNAL FUNCTION symbol_UDF_name
|
||||
{ $$ = makeClassNode(newNode<DropFunctionNode>(toName($3))); }
|
||||
{ $$ = newNode<DropFunctionNode>(toName($3)); }
|
||||
| FUNCTION symbol_UDF_name
|
||||
{ $$ = makeClassNode(newNode<DropFunctionNode>(toName($2))); }
|
||||
{ $$ = newNode<DropFunctionNode>(toName($2)); }
|
||||
| SHADOW pos_short_integer
|
||||
{ $$ = make_node (nod_del_shadow, (int) 1, (dsql_nod*)(IPTR) $2); }
|
||||
{ $$ = newNode<DropShadowNode>($2); }
|
||||
| ROLE symbol_role_name
|
||||
{ $$ = make_node (nod_del_role, (int) 1, $2); }
|
||||
{ $$ = newNode<DropRoleNode>(toName($2)); }
|
||||
| GENERATOR symbol_generator_name
|
||||
{ $$ = makeClassNode(FB_NEW(getPool()) DropSequenceNode(getPool(), toName($2))); }
|
||||
{ $$ = newNode<DropSequenceNode>(toName($2)); }
|
||||
| SEQUENCE symbol_generator_name
|
||||
{ $$ = makeClassNode(FB_NEW(getPool()) DropSequenceNode(getPool(), toName($2))); }
|
||||
{ $$ = newNode<DropSequenceNode>(toName($2)); }
|
||||
| COLLATION symbol_collation_name
|
||||
{ $$ = makeClassNode(newNode<DropCollationNode>(toName($2))); }
|
||||
| USER drop_user_clause
|
||||
{ $$ = $2; }
|
||||
{ $$ = newNode<DropCollationNode>(toName($2)); }
|
||||
| USER symbol_user_name
|
||||
{ $$ = newNode<DropUserNode>(toName($2)); }
|
||||
| PACKAGE symbol_package_name
|
||||
{ $$ = makeClassNode(newNode<DropPackageNode>(toName($2))); }
|
||||
{ $$ = newNode<DropPackageNode>(toName($2)); }
|
||||
| PACKAGE BODY symbol_package_name
|
||||
{ $$ = makeClassNode(newNode<DropPackageBodyNode>(toName($3))); }
|
||||
{ $$ = newNode<DropPackageBodyNode>(toName($3)); }
|
||||
;
|
||||
|
||||
|
||||
@ -5329,10 +5331,6 @@ alter_user_clause
|
||||
{ $$ = make_node(nod_mod_user, (int) e_user_count, $1, $3, $4, $5, $6, $7); }
|
||||
;
|
||||
|
||||
drop_user_clause
|
||||
: symbol_user_name { $$ = make_node(nod_del_user, (int) e_del_user_count, $1); }
|
||||
;
|
||||
|
||||
passwd_clause
|
||||
: PASSWORD sql_string { $$ = $2; }
|
||||
;
|
||||
|
@ -897,25 +897,19 @@ dsql_nod* PASS1_statement(DsqlCompilerScratch* dsqlScratch, dsql_nod* input)
|
||||
|
||||
case nod_def_index:
|
||||
case nod_mod_index:
|
||||
case nod_del_index:
|
||||
case nod_def_constraint:
|
||||
case nod_grant:
|
||||
case nod_revoke:
|
||||
case nod_mod_database:
|
||||
case nod_def_role:
|
||||
case nod_del_role:
|
||||
case nod_def_filter:
|
||||
case nod_del_filter:
|
||||
case nod_def_domain:
|
||||
case nod_del_udf:
|
||||
case nod_def_shadow:
|
||||
case nod_del_shadow:
|
||||
case nod_set_statistics:
|
||||
case nod_mod_udf:
|
||||
case nod_mod_role:
|
||||
case nod_add_user:
|
||||
case nod_mod_user:
|
||||
case nod_del_user:
|
||||
dsqlScratch->getStatement()->setType(DsqlCompiledStatement::TYPE_DDL);
|
||||
return input;
|
||||
|
||||
@ -4773,12 +4767,6 @@ void DSQL_pretty(const dsql_nod* node, int column)
|
||||
case nod_del_field:
|
||||
verb = "delete field";
|
||||
break;
|
||||
case nod_del_filter:
|
||||
verb = "delete filter";
|
||||
break;
|
||||
case nod_del_index:
|
||||
verb = "delete index";
|
||||
break;
|
||||
case nod_execute:
|
||||
verb = "execute";
|
||||
break;
|
||||
@ -4884,9 +4872,6 @@ void DSQL_pretty(const dsql_nod* node, int column)
|
||||
case nod_def_shadow:
|
||||
verb = "def_shadow";
|
||||
break;
|
||||
case nod_del_shadow:
|
||||
verb = "del_shadow";
|
||||
break;
|
||||
case nod_del_udf:
|
||||
verb = "del_udf";
|
||||
break;
|
||||
@ -4986,18 +4971,12 @@ void DSQL_pretty(const dsql_nod* node, int column)
|
||||
case nod_ref_trig_action:
|
||||
verb = "ref_trig_action";
|
||||
break;
|
||||
case nod_def_role:
|
||||
verb = "def_role";
|
||||
break;
|
||||
case nod_role_name:
|
||||
verb = "role_name";
|
||||
break;
|
||||
case nod_grant_admin:
|
||||
verb = "grant_admin";
|
||||
break;
|
||||
case nod_del_role:
|
||||
verb = "del_role";
|
||||
break;
|
||||
case nod_mod_field_name:
|
||||
verb = "mod_field_name";
|
||||
break;
|
||||
@ -5081,10 +5060,6 @@ void DSQL_pretty(const dsql_nod* node, int column)
|
||||
verb = "mod_user";
|
||||
break;
|
||||
|
||||
case nod_del_user:
|
||||
verb = "del_user";
|
||||
break;
|
||||
|
||||
case nod_class_exprnode:
|
||||
case nod_class_stmtnode:
|
||||
reinterpret_cast<Node*>(node->nod_arg[0])->print(verb, subNodes);
|
||||
|
@ -1055,6 +1055,12 @@ static const struct {
|
||||
{"dsql_drop_view_failed", 336397302},
|
||||
{"dsql_drop_sequence_failed", 336397303},
|
||||
{"dsql_recreate_sequence_failed", 336397304},
|
||||
{"dsql_drop_index_failed", 336397305},
|
||||
{"dsql_drop_filter_failed", 336397306},
|
||||
{"dsql_drop_shadow_failed", 336397307},
|
||||
{"dsql_drop_role_failed", 336397308},
|
||||
{"dsql_drop_user_failed", 336397309},
|
||||
{"dsql_create_role_failed", 336397310},
|
||||
{"gsec_cant_open_db", 336723983},
|
||||
{"gsec_switches_error", 336723984},
|
||||
{"gsec_no_op_spec", 336723985},
|
||||
|
@ -1089,6 +1089,12 @@ const ISC_STATUS isc_dsql_recreate_view_failed = 336397301L;
|
||||
const ISC_STATUS isc_dsql_drop_view_failed = 336397302L;
|
||||
const ISC_STATUS isc_dsql_drop_sequence_failed = 336397303L;
|
||||
const ISC_STATUS isc_dsql_recreate_sequence_failed = 336397304L;
|
||||
const ISC_STATUS isc_dsql_drop_index_failed = 336397305L;
|
||||
const ISC_STATUS isc_dsql_drop_filter_failed = 336397306L;
|
||||
const ISC_STATUS isc_dsql_drop_shadow_failed = 336397307L;
|
||||
const ISC_STATUS isc_dsql_drop_role_failed = 336397308L;
|
||||
const ISC_STATUS isc_dsql_drop_user_failed = 336397309L;
|
||||
const ISC_STATUS isc_dsql_create_role_failed = 336397310L;
|
||||
const ISC_STATUS isc_gsec_cant_open_db = 336723983L;
|
||||
const ISC_STATUS isc_gsec_switches_error = 336723984L;
|
||||
const ISC_STATUS isc_gsec_no_op_spec = 336723985L;
|
||||
@ -1190,7 +1196,7 @@ const ISC_STATUS isc_trace_switch_user_only = 337182757L;
|
||||
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
|
||||
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
|
||||
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
|
||||
const ISC_STATUS isc_err_max = 1134;
|
||||
const ISC_STATUS isc_err_max = 1140;
|
||||
|
||||
#else /* c definitions */
|
||||
|
||||
@ -2249,6 +2255,12 @@ const ISC_STATUS isc_err_max = 1134;
|
||||
#define isc_dsql_drop_view_failed 336397302L
|
||||
#define isc_dsql_drop_sequence_failed 336397303L
|
||||
#define isc_dsql_recreate_sequence_failed 336397304L
|
||||
#define isc_dsql_drop_index_failed 336397305L
|
||||
#define isc_dsql_drop_filter_failed 336397306L
|
||||
#define isc_dsql_drop_shadow_failed 336397307L
|
||||
#define isc_dsql_drop_role_failed 336397308L
|
||||
#define isc_dsql_drop_user_failed 336397309L
|
||||
#define isc_dsql_create_role_failed 336397310L
|
||||
#define isc_gsec_cant_open_db 336723983L
|
||||
#define isc_gsec_switches_error 336723984L
|
||||
#define isc_gsec_no_op_spec 336723985L
|
||||
@ -2350,7 +2362,7 @@ const ISC_STATUS isc_err_max = 1134;
|
||||
#define isc_trace_switch_param_miss 337182758L
|
||||
#define isc_trace_param_act_notcompat 337182759L
|
||||
#define isc_trace_mandatory_switch_miss 337182760L
|
||||
#define isc_err_max 1134
|
||||
#define isc_err_max 1140
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1058,6 +1058,12 @@ Data source : @4"}, /* eds_statement */
|
||||
{336397302, "DROP VIEW @1 failed"}, /* dsql_drop_view_failed */
|
||||
{336397303, "DROP SEQUENCE @1 failed"}, /* dsql_drop_sequence_failed */
|
||||
{336397304, "RECREATE SEQUENCE @1 failed"}, /* dsql_recreate_sequence_failed */
|
||||
{336397305, "DROP INDEX @1 failed"}, /* dsql_drop_index_failed */
|
||||
{336397306, "DROP FILTER @1 failed"}, /* dsql_drop_filter_failed */
|
||||
{336397307, "DROP SHADOW @1 failed"}, /* dsql_drop_shadow_failed */
|
||||
{336397308, "DROP ROLE @1 failed"}, /* dsql_drop_role_failed */
|
||||
{336397309, "DROP USER @1 failed"}, /* dsql_drop_user_failed */
|
||||
{336397310, "CREATE ROLE @1 failed"}, /* dsql_create_role_failed */
|
||||
{336723983, "unable to open database"}, /* gsec_cant_open_db */
|
||||
{336723984, "error in switch specifications"}, /* gsec_switches_error */
|
||||
{336723985, "no operation specified"}, /* gsec_no_op_spec */
|
||||
|
@ -1054,6 +1054,12 @@ static const struct {
|
||||
{336397302, -901}, /* 1014 dsql_drop_view_failed */
|
||||
{336397303, -901}, /* 1015 dsql_drop_sequence_failed */
|
||||
{336397304, -901}, /* 1016 dsql_recreate_sequence_failed */
|
||||
{336397305, -901}, /* 1017 dsql_drop_index_failed */
|
||||
{336397306, -901}, /* 1018 dsql_drop_filter_failed */
|
||||
{336397307, -901}, /* 1019 dsql_drop_shadow_failed */
|
||||
{336397308, -901}, /* 1020 dsql_drop_role_failed */
|
||||
{336397309, -901}, /* 1021 dsql_drop_user_failed */
|
||||
{336397310, -901}, /* 1022 dsql_create_role_failed */
|
||||
{336723983, -901}, /* 15 gsec_cant_open_db */
|
||||
{336723984, -901}, /* 16 gsec_switches_error */
|
||||
{336723985, -901}, /* 17 gsec_no_op_spec */
|
||||
|
@ -1054,6 +1054,12 @@ static const struct {
|
||||
{336397302, "42000"}, // 1014 dsql_drop_view_failed
|
||||
{336397303, "42000"}, // 1015 dsql_drop_sequence_failed
|
||||
{336397304, "42000"}, // 1016 dsql_recreate_sequence_failed
|
||||
{336397305, "42000"}, // 1017 dsql_drop_index_failed
|
||||
{336397306, "42000"}, // 1018 dsql_drop_filter_failed
|
||||
{336397307, "42000"}, // 1019 dsql_drop_shadow_failed
|
||||
{336397308, "42000"}, // 1020 dsql_drop_role_failed
|
||||
{336397309, "42000"}, // 1021 dsql_drop_user_failed
|
||||
{336397310, "42000"}, // 1022 dsql_create_role_failed
|
||||
{336723983, "00000"}, // 15 gsec_cant_open_db
|
||||
{336723984, "00000"}, // 16 gsec_switches_error
|
||||
{336723985, "00000"}, // 17 gsec_no_op_spec
|
||||
|
@ -270,7 +270,7 @@ void DYN_error_punt(bool status_flag, USHORT number)
|
||||
}
|
||||
|
||||
|
||||
bool DYN_is_it_sql_role(Global* gbl,
|
||||
bool DYN_is_it_sql_role(jrd_tra* transaction,
|
||||
const MetaName& input_name,
|
||||
MetaName& output_name,
|
||||
thread_db* tdbb)
|
||||
@ -293,7 +293,7 @@ bool DYN_is_it_sql_role(Global* gbl,
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_get_role_nm, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
X IN RDB$ROLES WITH
|
||||
X.RDB$ROLE_NAME EQ input_name.c_str()
|
||||
{
|
||||
@ -384,30 +384,14 @@ void DYN_execute(Global* gbl,
|
||||
DYN_define_filter(gbl, ptr);
|
||||
break;
|
||||
|
||||
case isc_dyn_delete_filter:
|
||||
DYN_delete_filter(gbl, ptr);
|
||||
break;
|
||||
|
||||
case isc_dyn_mod_function:
|
||||
DYN_modify_function(gbl, ptr);
|
||||
break;
|
||||
|
||||
case isc_dyn_def_sql_role:
|
||||
DYN_define_role(gbl, ptr);
|
||||
break;
|
||||
|
||||
case isc_dyn_del_sql_role:
|
||||
DYN_delete_role(gbl, ptr);
|
||||
break;
|
||||
|
||||
case isc_dyn_def_shadow:
|
||||
DYN_define_shadow(gbl, ptr);
|
||||
break;
|
||||
|
||||
case isc_dyn_delete_shadow:
|
||||
DYN_delete_shadow(gbl, ptr);
|
||||
break;
|
||||
|
||||
case isc_dyn_def_idx:
|
||||
DYN_define_index(gbl, ptr, relation_name);
|
||||
break;
|
||||
@ -416,10 +400,6 @@ void DYN_execute(Global* gbl,
|
||||
DYN_modify_index(gbl, ptr);
|
||||
break;
|
||||
|
||||
case isc_dyn_delete_idx:
|
||||
DYN_delete_index(gbl, ptr);
|
||||
break;
|
||||
|
||||
case isc_dyn_mapping:
|
||||
DYN_modify_mapping(gbl, ptr);
|
||||
break;
|
||||
@ -720,28 +700,6 @@ USHORT DYN_put_text_blob(Global* gbl, const UCHAR** ptr, bid* blob_id)
|
||||
}
|
||||
|
||||
|
||||
USHORT DYN_skip_attribute(const UCHAR** ptr)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* D Y N _ s k i p _ a t t r i b u t e
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Skip over attribute returning length (excluding
|
||||
* size of count bytes).
|
||||
*
|
||||
**************************************/
|
||||
const UCHAR* p = *ptr;
|
||||
USHORT length = *p++;
|
||||
length |= (*p++) << 8;
|
||||
*ptr = p + length;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
|
||||
static void grant( Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
/**************************************
|
||||
@ -813,7 +771,7 @@ static void grant( Global* gbl, const UCHAR** ptr)
|
||||
case isc_dyn_grant_user:
|
||||
GET_STRING(ptr, user);
|
||||
// This test may become obsolete as we now allow explicit ROLE keyword.
|
||||
if (DYN_is_it_sql_role(gbl, user, dummy_name, tdbb))
|
||||
if (DYN_is_it_sql_role(gbl->gbl_transaction, user, dummy_name, tdbb))
|
||||
{
|
||||
user_type = obj_sql_role;
|
||||
if (user == NULL_ROLE)
|
||||
@ -838,7 +796,7 @@ static void grant( Global* gbl, const UCHAR** ptr)
|
||||
case isc_dyn_grant_role:
|
||||
user_type = obj_sql_role;
|
||||
GET_STRING(ptr, user);
|
||||
if (!DYN_is_it_sql_role(gbl, user, dummy_name, tdbb))
|
||||
if (!DYN_is_it_sql_role(gbl->gbl_transaction, user, dummy_name, tdbb))
|
||||
{
|
||||
DYN_error_punt(false, 188, user.c_str());
|
||||
// msg 188: Role doesn't exist.
|
||||
@ -1351,7 +1309,7 @@ static bool grantor_can_grant_role(thread_db* tdbb,
|
||||
|
||||
// Fetch the name of the owner of the ROLE
|
||||
MetaName owner;
|
||||
if (DYN_is_it_sql_role(gbl, role_name, owner, tdbb))
|
||||
if (DYN_is_it_sql_role(gbl->gbl_transaction, role_name, owner, tdbb))
|
||||
{
|
||||
// Both SYSDBA and the owner of this ROLE can grant membership
|
||||
if (tdbb->getAttachment()->locksmith() || owner == grantor)
|
||||
@ -1502,7 +1460,7 @@ static void revoke_permission(Global* gbl, const UCHAR** ptr)
|
||||
case isc_dyn_grant_user:
|
||||
GET_STRING(ptr, user);
|
||||
// This test may become obsolete as we now allow explicit ROLE keyword.
|
||||
if (DYN_is_it_sql_role(gbl, user, dummy_name, tdbb))
|
||||
if (DYN_is_it_sql_role(gbl->gbl_transaction, user, dummy_name, tdbb))
|
||||
{
|
||||
user_type = obj_sql_role;
|
||||
if (user == NULL_ROLE)
|
||||
@ -1527,7 +1485,7 @@ static void revoke_permission(Global* gbl, const UCHAR** ptr)
|
||||
case isc_dyn_grant_role:
|
||||
user_type = obj_sql_role;
|
||||
GET_STRING(ptr, user);
|
||||
if (!DYN_is_it_sql_role(gbl, user, dummy_name, tdbb))
|
||||
if (!DYN_is_it_sql_role(gbl->gbl_transaction, user, dummy_name, tdbb))
|
||||
{
|
||||
DYN_error_punt(false, 188, user.c_str());
|
||||
// msg 188: Role doesn't exist.
|
||||
@ -1741,7 +1699,7 @@ static void revoke_all(Global* gbl, const UCHAR** ptr)
|
||||
case isc_dyn_grant_user:
|
||||
GET_STRING(ptr, user);
|
||||
// This test may become obsolete as we now allow explicit ROLE keyword.
|
||||
if (DYN_is_it_sql_role(gbl, user, dummy_name, tdbb))
|
||||
if (DYN_is_it_sql_role(gbl->gbl_transaction, user, dummy_name, tdbb))
|
||||
{
|
||||
user_type = obj_sql_role;
|
||||
if (user == NULL_ROLE)
|
||||
@ -1766,7 +1724,7 @@ static void revoke_all(Global* gbl, const UCHAR** ptr)
|
||||
case isc_dyn_grant_role:
|
||||
GET_STRING(ptr, user);
|
||||
user_type = obj_sql_role;
|
||||
if (!DYN_is_it_sql_role(gbl, user, dummy_name, tdbb)) {
|
||||
if (!DYN_is_it_sql_role(gbl->gbl_transaction, user, dummy_name, tdbb)) {
|
||||
DYN_error_punt(false, 188, user.c_str()); // msg 188: Role doesn't exist.
|
||||
}
|
||||
if (user == NULL_ROLE)
|
||||
@ -1948,7 +1906,7 @@ static void dyn_user(Global* gbl, const UCHAR** ptr)
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Implements CREATE/ALTER/DROP USER
|
||||
* Implements CREATE/ALTER USER
|
||||
*
|
||||
**************************************/
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
@ -1997,13 +1955,6 @@ static void dyn_user(Global* gbl, const UCHAR** ptr)
|
||||
userData->user.setEntered(1);
|
||||
break;
|
||||
|
||||
case isc_dyn_user_del:
|
||||
text.upper();
|
||||
userData->op = DEL_OPER;
|
||||
userData->user.set(text.c_str());
|
||||
userData->user.setEntered(1);
|
||||
break;
|
||||
|
||||
case isc_dyn_user_passwd:
|
||||
if (text.isEmpty())
|
||||
{
|
||||
@ -2072,10 +2023,6 @@ static void dyn_user(Global* gbl, const UCHAR** ptr)
|
||||
case MOD_OPER:
|
||||
ddlAction = DDL_TRIGGER_ALTER_USER;
|
||||
break;
|
||||
|
||||
case DEL_OPER:
|
||||
ddlAction = DDL_TRIGGER_DROP_USER;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ddlAction != 0)
|
||||
|
@ -113,12 +113,10 @@ USHORT DYN_get_string(const UCHAR**, Firebird::string&, size_t);
|
||||
USHORT DYN_get_string(const UCHAR**, Firebird::UCharBuffer&, size_t);
|
||||
USHORT DYN_get_string(const UCHAR**, TEXT*, size_t);
|
||||
|
||||
bool DYN_is_it_sql_role(Jrd::Global*, const Firebird::MetaName&, Firebird::MetaName&, Jrd::thread_db*);
|
||||
bool DYN_is_it_sql_role(Jrd::jrd_tra*, const Firebird::MetaName&, Firebird::MetaName&, Jrd::thread_db*);
|
||||
USHORT DYN_put_blr_blob(Jrd::Global*, const UCHAR**, Jrd::bid*);
|
||||
USHORT DYN_put_text_blob(Jrd::Global*, const UCHAR**, Jrd::bid*);
|
||||
|
||||
USHORT DYN_skip_attribute(const UCHAR**);
|
||||
|
||||
void DYN_unsupported_verb();
|
||||
|
||||
#endif // JRD_DYN_H
|
||||
|
@ -100,8 +100,6 @@ const int FOR_KEY_DEL_NONE = 0x80;
|
||||
|
||||
DATABASE DB = STATIC "ODS.RDB";
|
||||
|
||||
static bool is_it_user_name(Global*, const Firebird::MetaName&, thread_db*);
|
||||
|
||||
|
||||
void DYN_define_file(Global* gbl,
|
||||
const UCHAR** ptr,
|
||||
@ -463,99 +461,6 @@ void DYN_define_index(Global* gbl, const UCHAR** ptr, const Firebird::MetaName*
|
||||
}
|
||||
|
||||
|
||||
void DYN_define_role( Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* D Y N _ d e f i n e _ r o l e
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
*
|
||||
* Define a SQL role.
|
||||
* ROLES cannot be named the same as any existing user name
|
||||
*
|
||||
**************************************/
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
|
||||
Firebird::MetaName owner_name(tdbb->getAttachment()->att_user->usr_user_name);
|
||||
owner_name.upper7();
|
||||
|
||||
Firebird::MetaName role_name;
|
||||
GET_STRING(ptr, role_name);
|
||||
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE,
|
||||
DDL_TRIGGER_CREATE_ROLE, role_name, gbl->sqlText);
|
||||
|
||||
if (role_name == owner_name)
|
||||
{
|
||||
// user name could not be used for SQL role
|
||||
DYN_error(false, 193, SafeArg() << owner_name.c_str());
|
||||
ERR_punt();
|
||||
}
|
||||
|
||||
if (role_name == NULL_ROLE)
|
||||
{
|
||||
// keyword NONE could not be used as SQL role name
|
||||
DYN_error(false, 195, SafeArg() << role_name.c_str());
|
||||
ERR_punt();
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if (is_it_user_name(gbl, role_name, tdbb))
|
||||
{
|
||||
// user name could not be used for SQL role
|
||||
DYN_error(false, 193, SafeArg() << role_name.c_str());
|
||||
goto do_err_punt;
|
||||
}
|
||||
|
||||
Firebird::MetaName dummy_name;
|
||||
if (DYN_is_it_sql_role(gbl, role_name, dummy_name, tdbb))
|
||||
{
|
||||
// SQL role @1 already exists
|
||||
DYN_error(false, 194, SafeArg() << role_name.c_str());
|
||||
goto do_err_punt;
|
||||
}
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_role_gens, DYN_REQUESTS);
|
||||
|
||||
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
X IN RDB$ROLES
|
||||
{
|
||||
strcpy(X.RDB$ROLE_NAME, role_name.c_str());
|
||||
strcpy(X.RDB$OWNER_NAME, owner_name.c_str());
|
||||
X.RDB$SYSTEM_FLAG = 0;
|
||||
X.RDB$SYSTEM_FLAG.NULL = FALSE;
|
||||
}
|
||||
END_STORE
|
||||
|
||||
if (*(*ptr)++ != isc_dyn_end)
|
||||
goto do_error_punt_9;
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_error_punt(true, 8);
|
||||
// msg 8: "DEFINE ROLE failed"
|
||||
}
|
||||
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_AFTER,
|
||||
DDL_TRIGGER_CREATE_ROLE, role_name, gbl->sqlText);
|
||||
|
||||
return;
|
||||
|
||||
do_err_punt:
|
||||
ERR_punt();
|
||||
return;
|
||||
|
||||
do_error_punt_9:
|
||||
DYN_error_punt(true, 9);
|
||||
// msg 9: "DEFINE ROLE unexpected dyn verb"
|
||||
}
|
||||
|
||||
|
||||
void DYN_define_shadow( Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
/**************************************
|
||||
@ -616,69 +521,3 @@ void DYN_define_shadow( Global* gbl, const UCHAR** ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool is_it_user_name(Global* gbl, const Firebird::MetaName& role_name, thread_db* tdbb)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* i s _ i t _ u s e r _ n a m e
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
*
|
||||
* if role_name is user name returns true. Otherwise returns false.
|
||||
*
|
||||
**************************************/
|
||||
|
||||
USHORT request_id;
|
||||
|
||||
SET_TDBB(tdbb);
|
||||
bool found = false;
|
||||
|
||||
try {
|
||||
|
||||
// If there is a user with privilege or a grantor on a relation we
|
||||
// can infer there is a user with this name
|
||||
|
||||
request_id = drq_get_user_priv;
|
||||
AutoCacheRequest request(tdbb, request_id, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
PRIV IN RDB$USER_PRIVILEGES WITH
|
||||
(PRIV.RDB$USER EQ role_name.c_str() AND
|
||||
PRIV.RDB$USER_TYPE = obj_user) OR
|
||||
(PRIV.RDB$GRANTOR EQ role_name.c_str() AND
|
||||
PRIV.RDB$OBJECT_TYPE = obj_relation)
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (found)
|
||||
return found;
|
||||
|
||||
// We can infer that 'role_name' is a user name if it owns any relations
|
||||
// Note we can only get here if a user creates a table and revokes all
|
||||
// his privileges on the table
|
||||
|
||||
request_id = drq_get_rel_owner;
|
||||
request.reset(tdbb, request_id, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
REL IN RDB$RELATIONS WITH
|
||||
REL.RDB$OWNER_NAME EQ role_name.c_str()
|
||||
{
|
||||
found = true;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
ERR_punt();
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
@ -1,346 +0,0 @@
|
||||
/*
|
||||
* PROGRAM: JRD Data Definition Utility
|
||||
* MODULE: dyn_delete.epp
|
||||
* DESCRIPTION: Dynamic data definition - DYN_delete_<x>
|
||||
*
|
||||
* The contents of this file are subject to the Interbase Public
|
||||
* License Version 1.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy
|
||||
* of the License at http://www.Inprise.com/IPL.html
|
||||
*
|
||||
* Software distributed under the License is distributed on an
|
||||
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code was created by Inprise Corporation
|
||||
* and its predecessors. Portions created by Inprise Corporation are
|
||||
* Copyright (C) Inprise Corporation.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*
|
||||
* 24-May-2001 Claudio Valderrama - Forbid zero length identifiers,
|
||||
* they are not ANSI SQL compliant.
|
||||
* 23-May-2001 Claudio Valderrama - Move here DYN_delete_role.
|
||||
* 20-Jun-2001 Claudio Valderrama - Make available DYN_delete_generator.
|
||||
*/
|
||||
|
||||
#include "firebird.h"
|
||||
#include "dyn_consts.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../common/common.h"
|
||||
#include "../dsql/DdlNodes.h"
|
||||
#include "../jrd/jrd.h"
|
||||
#include "../jrd/ods.h"
|
||||
#include "../jrd/tra.h"
|
||||
#include "../jrd/scl.h"
|
||||
#include "../jrd/drq.h"
|
||||
#include "../jrd/flags.h"
|
||||
#include "../jrd/ibase.h"
|
||||
#include "../jrd/lls.h"
|
||||
#include "../jrd/met.h"
|
||||
#include "../jrd/btr.h"
|
||||
#include "../jrd/intl.h"
|
||||
#include "../jrd/dyn.h"
|
||||
#include "../jrd/blb_proto.h"
|
||||
#include "../jrd/cmp_proto.h"
|
||||
#include "../jrd/dyn_proto.h"
|
||||
#include "../jrd/dyn_proto.h"
|
||||
#include "../jrd/dyn_dl_proto.h"
|
||||
#include "../jrd/err_proto.h"
|
||||
#include "../jrd/exe_proto.h"
|
||||
#include "../yvalve/gds_proto.h"
|
||||
#include "../jrd/inf_proto.h"
|
||||
#include "../jrd/intl_proto.h"
|
||||
#include "../common/isc_f_proto.h"
|
||||
#include "../jrd/met_proto.h"
|
||||
#include "../jrd/vio_proto.h"
|
||||
#include "../common/utils_proto.h"
|
||||
|
||||
using MsgFormat::SafeArg;
|
||||
|
||||
using namespace Jrd;
|
||||
using namespace Firebird;
|
||||
|
||||
|
||||
DATABASE DB = STATIC "ODS.RDB";
|
||||
|
||||
|
||||
void DYN_delete_filter( Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* D Y N _ d e l e t e _ f i l t e r
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Execute a dynamic ddl statement that
|
||||
* deletes a blob filter.
|
||||
*
|
||||
**************************************/
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_e_filters, DYN_REQUESTS);
|
||||
|
||||
bool found = false;
|
||||
|
||||
Firebird::MetaName f;
|
||||
GET_STRING(ptr, f);
|
||||
|
||||
try
|
||||
{
|
||||
found = false;
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
X IN RDB$FILTERS WITH X.RDB$FUNCTION_NAME = f.c_str()
|
||||
{
|
||||
ERASE X;
|
||||
found = true;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_error_punt(true, 36);
|
||||
// msg 36: "ERASE BLOB FILTER failed"
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
DYN_error_punt(false, 37, f.c_str());
|
||||
// msg 37: "Blob Filter %s not found"
|
||||
}
|
||||
|
||||
if (*(*ptr)++ != isc_dyn_end) {
|
||||
DYN_unsupported_verb();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DYN_delete_index( Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* D Y N _ d e l e t e _ i n d e x
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Execute a dynamic ddl statement that
|
||||
* deletes an index.
|
||||
*
|
||||
**************************************/
|
||||
Firebird::MetaName idx_name, rel_name;
|
||||
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_e_indices, DYN_REQUESTS);
|
||||
|
||||
bool found = false;
|
||||
bool is_expression = false;
|
||||
|
||||
try
|
||||
{
|
||||
GET_STRING(ptr, idx_name);
|
||||
|
||||
found = false;
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
IDX IN RDB$INDICES WITH IDX.RDB$INDEX_NAME EQ idx_name.c_str()
|
||||
{
|
||||
rel_name = IDX.RDB$RELATION_NAME;
|
||||
found = true;
|
||||
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE,
|
||||
DDL_TRIGGER_DROP_INDEX, idx_name, gbl->sqlText);
|
||||
|
||||
is_expression = !IDX.RDB$EXPRESSION_BLR.NULL;
|
||||
ERASE IDX;
|
||||
}
|
||||
END_FOR
|
||||
} //try
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_error_punt(true, 47);
|
||||
// msg 47: "ERASE RDB$INDICES failed"
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_AFTER,
|
||||
DDL_TRIGGER_DROP_INDEX, idx_name, gbl->sqlText);
|
||||
}
|
||||
else
|
||||
{
|
||||
DYN_error_punt(false, 48);
|
||||
// msg 48: "Index not found"
|
||||
}
|
||||
|
||||
if (!is_expression)
|
||||
if (!DropIndexNode::deleteSegmentRecords(tdbb, gbl->gbl_transaction, idx_name))
|
||||
{
|
||||
DYN_error_punt(false, 50);
|
||||
// msg 50: "No segments found for index"
|
||||
}
|
||||
|
||||
while (*(*ptr)++ != isc_dyn_end)
|
||||
{
|
||||
--(*ptr);
|
||||
DYN_execute(gbl, ptr, &rel_name, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DYN_delete_role( Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* D Y N _ d e l e t e _ r o l e
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
*
|
||||
* Execute a dynamic ddl statement that deletes a role with all its
|
||||
* members of the role.
|
||||
*
|
||||
**************************************/
|
||||
int id = -1;
|
||||
Firebird::MetaName role_name;
|
||||
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
|
||||
bool found = false;
|
||||
|
||||
try
|
||||
{
|
||||
Firebird::MetaName user(tdbb->getAttachment()->att_user->usr_user_name);
|
||||
user.upper7();
|
||||
|
||||
GET_STRING(ptr, role_name);
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_drop_role, DYN_REQUESTS);
|
||||
id = drq_drop_role;
|
||||
|
||||
bool del_role_ok = true;
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
XX IN RDB$ROLES WITH
|
||||
XX.RDB$ROLE_NAME EQ role_name.c_str()
|
||||
{
|
||||
found = true;
|
||||
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE,
|
||||
DDL_TRIGGER_DROP_ROLE, role_name, gbl->sqlText);
|
||||
|
||||
const Firebird::MetaName role_owner(XX.RDB$OWNER_NAME);
|
||||
|
||||
if (tdbb->getAttachment()->locksmith() || role_owner == user)
|
||||
{
|
||||
ERASE XX;
|
||||
}
|
||||
else
|
||||
{
|
||||
del_role_ok = false;
|
||||
}
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (del_role_ok)
|
||||
{
|
||||
request.reset(tdbb, drq_del_role_1, DYN_REQUESTS);
|
||||
id = drq_del_role_1;
|
||||
|
||||
// The first OR clause finds all members of the role.
|
||||
// The 2nd OR clause finds all privileges granted to the role
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
PRIV IN RDB$USER_PRIVILEGES WITH
|
||||
(PRIV.RDB$RELATION_NAME EQ role_name.c_str() AND
|
||||
PRIV.RDB$OBJECT_TYPE = obj_sql_role)
|
||||
OR (PRIV.RDB$USER EQ role_name.c_str() AND
|
||||
PRIV.RDB$USER_TYPE = obj_sql_role)
|
||||
{
|
||||
ERASE PRIV;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
else
|
||||
{
|
||||
DYN_error(false, 191, SafeArg() << user.c_str() << role_name.c_str());
|
||||
// only owner of SQL role or USR_locksmith could drop SQL role
|
||||
goto do_punt;
|
||||
}
|
||||
} // try
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
const USHORT number = (id == drq_drop_role ? 191 : 62);
|
||||
// msg 191: "ERASE RDB$ROLES failed"
|
||||
// msg 62: "ERASE RDB$USER_PRIVILEGES failed"
|
||||
DYN_error_punt(true, number);
|
||||
}
|
||||
|
||||
if (found)
|
||||
{
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_AFTER,
|
||||
DDL_TRIGGER_DROP_ROLE, role_name, gbl->sqlText);
|
||||
}
|
||||
else
|
||||
{
|
||||
DYN_error_punt(false, 155, role_name.c_str());
|
||||
// msg 155: "Role %s not found"
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
do_punt: // ugly, rethink logic of this function
|
||||
ERR_punt();
|
||||
}
|
||||
|
||||
|
||||
void DYN_delete_shadow( Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* D Y N _ d e l e t e _ s h a d o w
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Delete a shadow.
|
||||
*
|
||||
**************************************/
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
|
||||
if (!tdbb->getAttachment()->locksmith())
|
||||
{
|
||||
ERR_post(Arg::Gds(isc_adm_task_denied));
|
||||
}
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_e_shadow, DYN_REQUESTS);
|
||||
|
||||
try
|
||||
{
|
||||
const int shadow_number = DYN_get_number(ptr);
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
FIL IN RDB$FILES WITH FIL.RDB$SHADOW_NUMBER EQ shadow_number
|
||||
{
|
||||
ERASE FIL;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_error_punt(true, 63);
|
||||
// msg 63: "ERASE RDB$FILES failed"
|
||||
}
|
||||
|
||||
if (*(*ptr)++ != isc_dyn_end) {
|
||||
DYN_unsupported_verb();
|
||||
}
|
||||
}
|
@ -27,7 +27,6 @@
|
||||
void DYN_define_file(Jrd::Global*, const UCHAR**, SLONG, SLONG*, USHORT);
|
||||
void DYN_define_filter(Jrd::Global*, const UCHAR**);
|
||||
void DYN_define_index(Jrd::Global*, const UCHAR**, const Firebird::MetaName*);
|
||||
void DYN_define_role(Jrd::Global*, const UCHAR**);
|
||||
void DYN_define_shadow(Jrd::Global*, const UCHAR**);
|
||||
void DYN_define_difference(Jrd::Global*, const UCHAR**);
|
||||
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* PROGRAM: JRD Access method
|
||||
* MODULE: dyn_dl_proto.h
|
||||
* DESCRIPTION: Prototype Header file for dyn_del.epp
|
||||
*
|
||||
* The contents of this file are subject to the Interbase Public
|
||||
* License Version 1.0 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy
|
||||
* of the License at http://www.Inprise.com/IPL.html
|
||||
*
|
||||
* Software distributed under the License is distributed on an
|
||||
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code was created by Inprise Corporation
|
||||
* and its predecessors. Portions created by Inprise Corporation are
|
||||
* Copyright (C) Inprise Corporation.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*/
|
||||
|
||||
#ifndef JRD_DYN_DL_PROTO_H
|
||||
#define JRD_DYN_DL_PROTO_H
|
||||
|
||||
void DYN_delete_filter(Jrd::Global*, const UCHAR**);
|
||||
void DYN_delete_index(Jrd::Global*, const UCHAR**);
|
||||
void DYN_delete_role(Jrd::Global*, const UCHAR**);
|
||||
void DYN_delete_shadow(Jrd::Global*, const UCHAR**);
|
||||
|
||||
#endif // JRD_DYN_DL_PROTO_H
|
@ -20,7 +20,7 @@ set bulk_insert INSERT INTO FACILITIES (LAST_CHANGE, FACILITY, FAC_CODE, MAX_NUM
|
||||
('1996-11-07 13:39:40', 'INSTALL', 10, 1)
|
||||
('1996-11-07 13:38:41', 'TEST', 11, 4)
|
||||
('2011-06-01 12:57:44', 'GBAK', 12, 351)
|
||||
('2010-11-10 12:40:00', 'SQLERR', 13, 1017)
|
||||
('2010-11-13 19:06:00', 'SQLERR', 13, 1023)
|
||||
('1996-11-07 13:38:42', 'SQLWARN', 14, 613)
|
||||
('2006-09-10 03:04:31', 'JRD_BUGCHK', 15, 307)
|
||||
--
|
||||
|
@ -2484,6 +2484,12 @@ ERROR: Backup incomplete', NULL, NULL);
|
||||
('dsql_drop_view_failed', 'getMainErrorCode', 'DdlNodes.h', NULL, 13, 1014, NULL, 'DROP VIEW @1 failed', NULL, NULL);
|
||||
('dsql_drop_sequence_failed', 'getMainErrorCode', 'DdlNodes.h', NULL, 13, 1015, NULL, 'DROP SEQUENCE @1 failed', NULL, NULL);
|
||||
('dsql_recreate_sequence_failed', 'getMainErrorCode', 'DdlNodes.h', NULL, 13, 1016, NULL, 'RECREATE SEQUENCE @1 failed', NULL, NULL);
|
||||
('dsql_drop_index_failed', 'getMainErrorCode', 'DdlNodes.h', NULL, 13, 1017, NULL, 'DROP INDEX @1 failed', NULL, NULL);
|
||||
('dsql_drop_filter_failed', 'getMainErrorCode', 'DdlNodes.h', NULL, 13, 1018, NULL, 'DROP FILTER @1 failed', NULL, NULL);
|
||||
('dsql_drop_shadow_failed', 'getMainErrorCode', 'DdlNodes.h', NULL, 13, 1019, NULL, 'DROP SHADOW @1 failed', NULL, NULL);
|
||||
('dsql_drop_role_failed', 'getMainErrorCode', 'DdlNodes.h', NULL, 13, 1020, NULL, 'DROP ROLE @1 failed', NULL, NULL);
|
||||
('dsql_drop_user_failed', 'getMainErrorCode', 'DdlNodes.h', NULL, 13, 1021, NULL, 'DROP USER @1 failed', NULL, NULL);
|
||||
('dsql_create_role_failed', 'getMainErrorCode', 'DdlNodes.h', NULL, 13, 1022, NULL, 'CREATE ROLE @1 failed', NULL, NULL);
|
||||
-- SQLWARN
|
||||
(NULL, NULL, NULL, NULL, 14, 100, NULL, 'Row not found for fetch, update or delete, or the result of a query is an empty table.', NULL, NULL);
|
||||
(NULL, NULL, NULL, NULL, 14, 101, NULL, 'segment buffer length shorter than expected', NULL, NULL);
|
||||
|
@ -1047,6 +1047,12 @@ COMMIT WORK;
|
||||
(-901, '42', '000', 13, 1014, 'dsql_drop_view_failed', NULL, NULL);
|
||||
(-901, '42', '000', 13, 1015, 'dsql_drop_sequence_failed', NULL, NULL);
|
||||
(-901, '42', '000', 13, 1016, 'dsql_recreate_sequence_failed', NULL, NULL);
|
||||
(-901, '42', '000', 13, 1017, 'dsql_drop_index_failed', NULL, NULL);
|
||||
(-901, '42', '000', 13, 1018, 'dsql_drop_filter_failed', NULL, NULL);
|
||||
(-901, '42', '000', 13, 1019, 'dsql_drop_shadow_failed', NULL, NULL);
|
||||
(-901, '42', '000', 13, 1020, 'dsql_drop_role_failed', NULL, NULL);
|
||||
(-901, '42', '000', 13, 1021, 'dsql_drop_user_failed', NULL, NULL);
|
||||
(-901, '42', '000', 13, 1022, 'dsql_create_role_failed', NULL, NULL);
|
||||
-- GSEC
|
||||
(-901, '00', '000', 18, 15, 'gsec_cant_open_db', NULL, NULL)
|
||||
(-901, '00', '000', 18, 16, 'gsec_switches_error', NULL, NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user