mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 00:03:03 +01:00
Use AutoCacheRequest for DYN requests
This commit is contained in:
parent
33ad30f559
commit
378caea05e
221
src/jrd/dyn.epp
221
src/jrd/dyn.epp
@ -290,21 +290,16 @@ bool DYN_is_it_sql_role(Global* gbl,
|
||||
|
||||
bool found = false;
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_get_role_nm, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_get_role_nm, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
X IN RDB$ROLES WITH
|
||||
X.RDB$ROLE_NAME EQ input_name.c_str()
|
||||
if (!DYN_REQUEST(drq_get_role_nm))
|
||||
DYN_REQUEST(drq_get_role_nm) = request;
|
||||
|
||||
{
|
||||
found = true;
|
||||
output_name = X.RDB$OWNER_NAME;
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_get_role_nm))
|
||||
DYN_REQUEST(drq_get_role_nm) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
return found;
|
||||
}
|
||||
@ -828,33 +823,6 @@ USHORT DYN_put_text_blob(Global* gbl, const UCHAR** ptr, bid* blob_id)
|
||||
return length;
|
||||
}
|
||||
|
||||
void DYN_rundown_request(jrd_req* handle, SSHORT id)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* D Y N _ r u n d o w n _ r e q u e s t
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Unwind a request and save it
|
||||
* in the dyn internal request list.
|
||||
*
|
||||
**************************************/
|
||||
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
if (!handle) {
|
||||
return;
|
||||
}
|
||||
|
||||
EXE_unwind(tdbb, handle);
|
||||
if (id >= 0 && !DYN_REQUEST(id)) {
|
||||
DYN_REQUEST(id) = handle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
USHORT DYN_skip_attribute(const UCHAR** ptr)
|
||||
{
|
||||
@ -1042,12 +1010,10 @@ static void grant( Global* gbl, const UCHAR** ptr)
|
||||
}
|
||||
grantor.upper7();
|
||||
|
||||
jrd_req* request = NULL;
|
||||
|
||||
try {
|
||||
|
||||
request = CMP_find_request(tdbb,
|
||||
(USHORT) (field.length() > 0 ? drq_l_grant1 : drq_l_grant2), DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, (field.length() > 0 ? drq_l_grant1 : drq_l_grant2), DYN_REQUESTS);
|
||||
|
||||
for (const TEXT* pr = privileges; *pr; pr++)
|
||||
{
|
||||
bool duplicate = false;
|
||||
@ -1065,10 +1031,7 @@ static void grant( Global* gbl, const UCHAR** ptr)
|
||||
PRIV.RDB$USER_TYPE = user_type AND
|
||||
PRIV.RDB$GRANTOR EQ grantor.c_str() AND
|
||||
PRIV.RDB$FIELD_NAME EQ field.c_str()
|
||||
if (!DYN_REQUEST(drq_l_grant1)) {
|
||||
DYN_REQUEST(drq_l_grant1) = request;
|
||||
}
|
||||
|
||||
{
|
||||
if ((PRIV.RDB$GRANT_OPTION.NULL) ||
|
||||
(PRIV.RDB$GRANT_OPTION) ||
|
||||
(PRIV.RDB$GRANT_OPTION == options))
|
||||
@ -1079,11 +1042,8 @@ static void grant( Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
ERASE PRIV; // has to be 0 and options == 1
|
||||
}
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_l_grant1))
|
||||
{
|
||||
DYN_REQUEST(drq_l_grant1) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1097,9 +1057,7 @@ static void grant( Global* gbl, const UCHAR** ptr)
|
||||
PRIV.RDB$USER_TYPE = user_type AND
|
||||
PRIV.RDB$GRANTOR EQ grantor.c_str() AND
|
||||
PRIV.RDB$FIELD_NAME MISSING
|
||||
if (!DYN_REQUEST(drq_l_grant2))
|
||||
DYN_REQUEST(drq_l_grant2) = request;
|
||||
|
||||
{
|
||||
if ((PRIV.RDB$GRANT_OPTION.NULL) ||
|
||||
(PRIV.RDB$GRANT_OPTION) ||
|
||||
(PRIV.RDB$GRANT_OPTION == options))
|
||||
@ -1110,11 +1068,8 @@ static void grant( Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
ERASE PRIV; // has to be 0 and options == 1
|
||||
}
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_l_grant2))
|
||||
{
|
||||
DYN_REQUEST(drq_l_grant2) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
|
||||
if (duplicate) {
|
||||
@ -1183,11 +1138,6 @@ static void grant( Global* gbl, const UCHAR** ptr)
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
// we need to rundown as we have to set the env.
|
||||
// But in case the error is from store_priveledge we have already
|
||||
// unwound the request so passing that as null
|
||||
jrd_req* req1 = (id == drq_s_grant || id == drq_gcg1) ? NULL : request;
|
||||
DYN_rundown_request(req1, -1);
|
||||
|
||||
switch (id)
|
||||
{
|
||||
@ -1248,8 +1198,7 @@ static bool grantor_can_grant(Global* gbl,
|
||||
|
||||
// Verify that the input relation exists.
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_gcg4, DYN_REQUESTS);
|
||||
|
||||
AutoCacheRequest request(tdbb, drq_gcg4, DYN_REQUESTS);
|
||||
|
||||
try {
|
||||
|
||||
@ -1260,14 +1209,13 @@ static bool grantor_can_grant(Global* gbl,
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
REL IN RDB$RELATIONS WITH
|
||||
REL.RDB$RELATION_NAME = relation_name.c_str()
|
||||
{
|
||||
relation_exists = true;
|
||||
if ((!REL.RDB$FLAGS.NULL) && (REL.RDB$FLAGS & REL_sql))
|
||||
sql_relation = true;
|
||||
if (!DYN_REQUEST(drq_gcg4))
|
||||
DYN_REQUEST(drq_gcg4) = request;
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_gcg4))
|
||||
DYN_REQUEST(drq_gcg4) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!relation_exists)
|
||||
{
|
||||
DYN_error(false, 175, SafeArg() << relation_name.c_str());
|
||||
@ -1283,17 +1231,17 @@ static bool grantor_can_grant(Global* gbl,
|
||||
bool field_exists = false;
|
||||
|
||||
// SELECT RDB$RELATION_FIELDS failed in grant
|
||||
request = CMP_find_request(tdbb, drq_gcg5, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_gcg5, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
G_FLD IN RDB$RELATION_FIELDS WITH
|
||||
G_FLD.RDB$RELATION_NAME = relation_name.c_str() AND
|
||||
G_FLD.RDB$FIELD_NAME = field_name.c_str()
|
||||
if (!DYN_REQUEST(drq_gcg5))
|
||||
DYN_REQUEST(drq_gcg5) = request;
|
||||
{
|
||||
field_exists = true;
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_gcg5))
|
||||
DYN_REQUEST(drq_gcg5) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!field_exists)
|
||||
{
|
||||
DYN_error(false, 176, SafeArg() << field_name.c_str() << relation_name.c_str());
|
||||
@ -1315,20 +1263,19 @@ static bool grantor_can_grant(Global* gbl,
|
||||
bool grantor_is_owner = false;
|
||||
// SELECT RDB$RELATIONS/RDB$OWNER_NAME failed in grant
|
||||
|
||||
request = CMP_find_request(tdbb, drq_gcg2, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_gcg2, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
REL IN RDB$RELATIONS WITH
|
||||
REL.RDB$RELATION_NAME = relation_name.c_str() AND
|
||||
REL.RDB$OWNER_NAME = UPPERCASE(grantor)
|
||||
if (!DYN_REQUEST(drq_gcg2))
|
||||
DYN_REQUEST(drq_gcg2) = request;
|
||||
{
|
||||
grantor_is_owner = true;
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_gcg2))
|
||||
DYN_REQUEST(drq_gcg2) = request;
|
||||
if (!sql_relation && grantor_is_owner) {
|
||||
return true;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!sql_relation && grantor_is_owner)
|
||||
return true;
|
||||
|
||||
// Remember the grant option for non field-specific user-privileges, and
|
||||
// the grant option for the user-privileges for the input field.
|
||||
@ -1338,14 +1285,14 @@ static bool grantor_can_grant(Global* gbl,
|
||||
SSHORT go_rel = -1;
|
||||
SSHORT go_fld = -1;
|
||||
|
||||
|
||||
// Verify that the grantor has the grant option for this relation/field
|
||||
// in the rdb$user_privileges. If not, then we don't need to look further.
|
||||
|
||||
err_num = 185;
|
||||
// SELECT RDB$USER_PRIVILEGES failed in grant
|
||||
|
||||
request = CMP_find_request(tdbb, drq_gcg1, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_gcg1, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
PRV IN RDB$USER_PRIVILEGES WITH
|
||||
PRV.RDB$USER = UPPERCASE(grantor) AND
|
||||
@ -1353,9 +1300,7 @@ static bool grantor_can_grant(Global* gbl,
|
||||
PRV.RDB$RELATION_NAME = relation_name.c_str() AND
|
||||
PRV.RDB$OBJECT_TYPE = obj_relation AND
|
||||
PRV.RDB$PRIVILEGE = privilege
|
||||
if (!DYN_REQUEST(drq_gcg1))
|
||||
DYN_REQUEST(drq_gcg1) = request;
|
||||
|
||||
{
|
||||
if (PRV.RDB$FIELD_NAME.NULL)
|
||||
{
|
||||
if (PRV.RDB$GRANT_OPTION.NULL || !PRV.RDB$GRANT_OPTION)
|
||||
@ -1376,11 +1321,8 @@ static bool grantor_can_grant(Global* gbl,
|
||||
go_fld = 1;
|
||||
}
|
||||
}
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_gcg1))
|
||||
{
|
||||
DYN_REQUEST(drq_gcg1) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (field_name.length())
|
||||
{
|
||||
@ -1444,7 +1386,8 @@ static bool grantor_can_grant(Global* gbl,
|
||||
err_num = 186;
|
||||
// SELECT RDB$VIEW_RELATIONS/RDB$RELATION_FIELDS/... failed in grant
|
||||
|
||||
request = CMP_find_request(tdbb, drq_gcg3, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_gcg3, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
G_FLD IN RDB$RELATION_FIELDS CROSS
|
||||
G_VIEW IN RDB$VIEW_RELATIONS WITH
|
||||
@ -1452,10 +1395,7 @@ static bool grantor_can_grant(Global* gbl,
|
||||
G_FLD.RDB$BASE_FIELD NOT MISSING AND
|
||||
G_VIEW.RDB$VIEW_NAME EQ G_FLD.RDB$RELATION_NAME AND
|
||||
G_VIEW.RDB$VIEW_CONTEXT EQ G_FLD.RDB$VIEW_CONTEXT
|
||||
if (!DYN_REQUEST(drq_gcg3)) {
|
||||
DYN_REQUEST(drq_gcg3) = request;
|
||||
}
|
||||
|
||||
{
|
||||
if (field_name.length())
|
||||
{
|
||||
if (field_name == G_FLD.RDB$FIELD_NAME)
|
||||
@ -1473,9 +1413,8 @@ static bool grantor_can_grant(Global* gbl,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_gcg3))
|
||||
DYN_REQUEST(drq_gcg3) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
// all done.
|
||||
|
||||
@ -1483,7 +1422,6 @@ static bool grantor_can_grant(Global* gbl,
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, err_num);
|
||||
// msg 77: "SELECT RDB$USER_PRIVILEGES failed in grant"
|
||||
|
||||
@ -1533,7 +1471,7 @@ static bool grantor_can_grant_role(thread_db* tdbb,
|
||||
return false;
|
||||
}
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_get_role_au, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_get_role_au, DYN_REQUESTS);
|
||||
|
||||
// The 'grantor' is not the owner of the ROLE, see if they
|
||||
// have admin privilege on the role
|
||||
@ -1544,21 +1482,13 @@ static bool grantor_can_grant_role(thread_db* tdbb,
|
||||
PRV.RDB$RELATION_NAME EQ role_name.c_str() AND
|
||||
PRV.RDB$OBJECT_TYPE = obj_sql_role AND
|
||||
PRV.RDB$PRIVILEGE EQ "M"
|
||||
if (!DYN_REQUEST(drq_get_role_au)) {
|
||||
DYN_REQUEST(drq_get_role_au) = request;
|
||||
}
|
||||
|
||||
{
|
||||
if (PRV.RDB$GRANT_OPTION == 2)
|
||||
grantable = true;
|
||||
else
|
||||
no_admin = true;
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_get_role_au))
|
||||
{
|
||||
DYN_REQUEST(drq_get_role_au) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!grantable)
|
||||
{
|
||||
@ -1775,7 +1705,7 @@ static void revoke_permission(Global* gbl, const UCHAR** ptr)
|
||||
|
||||
USHORT id = field.length() ? drq_e_grant1 : drq_e_grant2;
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, id, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, id, DYN_REQUESTS);
|
||||
|
||||
try {
|
||||
|
||||
@ -1796,9 +1726,7 @@ static void revoke_permission(Global* gbl, const UCHAR** ptr)
|
||||
PRIV.RDB$USER = user.c_str() AND
|
||||
PRIV.RDB$USER_TYPE = user_type AND
|
||||
PRIV.RDB$FIELD_NAME EQ field.c_str()
|
||||
if (!DYN_REQUEST(drq_e_grant1))
|
||||
DYN_REQUEST(drq_e_grant1) = request;
|
||||
|
||||
{
|
||||
if (revoking_as_user_name == PRIV.RDB$GRANTOR)
|
||||
{
|
||||
ERASE PRIV;
|
||||
@ -1808,10 +1736,8 @@ static void revoke_permission(Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
bad_grantor = true;
|
||||
}
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_e_grant1)) {
|
||||
DYN_REQUEST(drq_e_grant1) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1822,9 +1748,7 @@ static void revoke_permission(Global* gbl, const UCHAR** ptr)
|
||||
PRIV.RDB$OBJECT_TYPE = obj_type AND
|
||||
PRIV.RDB$USER EQ user.c_str() AND
|
||||
PRIV.RDB$USER_TYPE = user_type
|
||||
if (!DYN_REQUEST(drq_e_grant2))
|
||||
DYN_REQUEST(drq_e_grant2) = request;
|
||||
|
||||
{
|
||||
// revoking a permission at the table level implies
|
||||
// revoking the perm. on all columns. So for all fields
|
||||
// in this table which have been granted the privilege, we
|
||||
@ -1839,9 +1763,8 @@ static void revoke_permission(Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
bad_grantor = true;
|
||||
}
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_e_grant2))
|
||||
DYN_REQUEST(drq_e_grant2) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
|
||||
if (options && grant_erased)
|
||||
@ -1880,10 +1803,7 @@ static void revoke_permission(Global* gbl, const UCHAR** ptr)
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
// we need to rundown as we have to set the env.
|
||||
// But in case the error is from store_priveledge we have already
|
||||
// unwound the request so passing that as null
|
||||
DYN_rundown_request(((id == drq_s_grant) ? NULL : request), -1);
|
||||
|
||||
if (id == drq_e_grant1)
|
||||
{
|
||||
DYN_error_punt(true, 111);
|
||||
@ -1977,17 +1897,14 @@ static void revoke_all(Global* gbl, const UCHAR** ptr)
|
||||
bool grant_erased = false;
|
||||
bool bad_grantor = false;
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_e_grant3, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_e_grant3, DYN_REQUESTS);
|
||||
|
||||
try {
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
PRIV IN RDB$USER_PRIVILEGES WITH
|
||||
PRIV.RDB$USER = user.c_str() AND
|
||||
PRIV.RDB$USER_TYPE = user_type
|
||||
|
||||
if (!DYN_REQUEST(drq_e_grant1))
|
||||
DYN_REQUEST(drq_e_grant1) = request;
|
||||
|
||||
{
|
||||
if (revoking_user->locksmith() || revoking_as_user_name == PRIV.RDB$GRANTOR)
|
||||
{
|
||||
ERASE PRIV;
|
||||
@ -1997,10 +1914,8 @@ static void revoke_all(Global* gbl, const UCHAR** ptr)
|
||||
{
|
||||
bad_grantor = true;
|
||||
}
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_e_grant3)) {
|
||||
DYN_REQUEST(drq_e_grant3) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!grant_erased)
|
||||
{
|
||||
@ -2019,7 +1934,6 @@ static void revoke_all(Global* gbl, const UCHAR** ptr)
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
ex.stuff_exception(tdbb->tdbb_status_vector);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 255);
|
||||
// msg 255: "ERASE RDB$USER_PRIVILEGES failed in REVOKE ALL ON ALL"
|
||||
}
|
||||
@ -2042,8 +1956,7 @@ static void set_field_class_name(Global* gbl, const MetaName& relation, const Me
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Database* const dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_s_f_class, DYN_REQUESTS);
|
||||
jrd_req* request2 = NULL;
|
||||
AutoCacheRequest request(tdbb, drq_s_f_class, DYN_REQUESTS);
|
||||
|
||||
bool unique = false;
|
||||
|
||||
@ -2052,7 +1965,7 @@ static void set_field_class_name(Global* gbl, const MetaName& relation, const Me
|
||||
WITH RFR.RDB$FIELD_NAME = field.c_str() AND
|
||||
RFR.RDB$RELATION_NAME = relation.c_str() AND
|
||||
RFR.RDB$SECURITY_CLASS MISSING
|
||||
|
||||
{
|
||||
MODIFY RFR
|
||||
while (!unique)
|
||||
{
|
||||
@ -2060,25 +1973,21 @@ static void set_field_class_name(Global* gbl, const MetaName& relation, const Me
|
||||
DPM_gen_id(tdbb, MET_lookup_generator(tdbb, "RDB$SECURITY_CLASS"), false, 1));
|
||||
|
||||
unique = true;
|
||||
request2 = CMP_find_request(tdbb, drq_s_u_class, DYN_REQUESTS);
|
||||
|
||||
AutoCacheRequest request2(tdbb, drq_s_u_class, DYN_REQUESTS);
|
||||
FOR (REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
RFR1 IN RDB$RELATION_FIELDS
|
||||
WITH RFR1.RDB$SECURITY_CLASS = RFR.RDB$SECURITY_CLASS
|
||||
{
|
||||
unique = false;
|
||||
END_FOR;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
|
||||
RFR.RDB$SECURITY_CLASS.NULL = FALSE;
|
||||
END_MODIFY;
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_s_f_class))
|
||||
DYN_REQUEST(drq_s_f_class) = request;
|
||||
|
||||
|
||||
if (request2 && !DYN_REQUEST(drq_s_u_class))
|
||||
DYN_REQUEST(drq_s_u_class) = request2;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
|
||||
|
||||
@ -2106,7 +2015,7 @@ static void store_privilege(Global* gbl,
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Database* const dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_s_grant, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_s_grant, DYN_REQUESTS);
|
||||
|
||||
// need to unwind our own request here!! SM 27-Sep-96
|
||||
|
||||
@ -2119,6 +2028,7 @@ static void store_privilege(Global* gbl,
|
||||
strcpy(PRIV.RDB$GRANTOR, grantor.c_str());
|
||||
PRIV.RDB$USER_TYPE = user_type;
|
||||
PRIV.RDB$OBJECT_TYPE = obj_type;
|
||||
{
|
||||
if (field.length())
|
||||
{
|
||||
strcpy(PRIV.RDB$FIELD_NAME, field.c_str());
|
||||
@ -2128,17 +2038,12 @@ static void store_privilege(Global* gbl,
|
||||
PRIV.RDB$PRIVILEGE[0] = privilege[0];
|
||||
PRIV.RDB$PRIVILEGE[1] = 0;
|
||||
PRIV.RDB$GRANT_OPTION = option;
|
||||
|
||||
END_STORE;
|
||||
|
||||
if (!DYN_REQUEST(drq_s_grant)) {
|
||||
DYN_REQUEST(drq_s_grant) = request;
|
||||
}
|
||||
END_STORE
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 79);
|
||||
// msg 79: "STORE RDB$USER_PRIVILEGES failed in grant"
|
||||
}
|
||||
|
@ -112,7 +112,6 @@ bool DYN_is_it_sql_role(Jrd::Global*, const Firebird::MetaName&, Firebird::MetaN
|
||||
USHORT DYN_put_blr_blob(Jrd::Global*, const UCHAR**, Jrd::bid*);
|
||||
USHORT DYN_put_text_blob(Jrd::Global*, const UCHAR**, Jrd::bid*);
|
||||
|
||||
void DYN_rundown_request(Jrd::jrd_req*, SSHORT);
|
||||
USHORT DYN_skip_attribute(const UCHAR**);
|
||||
|
||||
void DYN_unsupported_verb();
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -118,8 +118,6 @@ void DYN_modify_database( Global* gbl, const UCHAR** ptr)
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
Jrd::Attachment* attachment = tdbb->getAttachment();
|
||||
|
||||
jrd_req* request = NULL;
|
||||
|
||||
try {
|
||||
|
||||
INF_database_info(alloc_info, sizeof(alloc_info), s, sizeof(s));
|
||||
@ -128,17 +126,14 @@ void DYN_modify_database( Global* gbl, const UCHAR** ptr)
|
||||
goto dyn_punt_84;
|
||||
}
|
||||
|
||||
request = CMP_find_request(tdbb, drq_m_database, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_m_database, DYN_REQUESTS);
|
||||
|
||||
const SSHORT length = gds__vax_integer(s + 1, 2);
|
||||
SLONG start = gds__vax_integer(s + 3, length);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
DBB IN RDB$DATABASE
|
||||
|
||||
if (!DYN_REQUEST(drq_m_database))
|
||||
DYN_REQUEST(drq_m_database) = request;
|
||||
|
||||
{
|
||||
MODIFY DBB USING
|
||||
UCHAR verb;
|
||||
while ((verb = *(*ptr)++) != isc_dyn_end)
|
||||
@ -200,17 +195,13 @@ void DYN_modify_database( Global* gbl, const UCHAR** ptr)
|
||||
DYN_execute(gbl, ptr, NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_m_database))
|
||||
DYN_REQUEST(drq_m_database) = request;
|
||||
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 84);
|
||||
// msg 84: "MODIFY DATABASE failed"
|
||||
}
|
||||
@ -238,7 +229,7 @@ void DYN_modify_exception( Global* gbl, const UCHAR** ptr)
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_m_xcp, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_m_xcp, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
MetaName t;
|
||||
@ -250,10 +241,7 @@ void DYN_modify_exception( Global* gbl, const UCHAR** ptr)
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
X IN RDB$EXCEPTIONS
|
||||
WITH X.RDB$EXCEPTION_NAME EQ t.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_m_xcp))
|
||||
DYN_REQUEST(drq_m_xcp) = request;
|
||||
|
||||
{
|
||||
found = true;
|
||||
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE,
|
||||
@ -272,17 +260,14 @@ void DYN_modify_exception( Global* gbl, const UCHAR** ptr)
|
||||
default:
|
||||
DYN_unsupported_verb();
|
||||
}
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_m_xcp))
|
||||
DYN_REQUEST(drq_m_xcp) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
|
||||
} // try
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 145);
|
||||
// msg 145: "MODIFY EXCEPTION failed"
|
||||
}
|
||||
@ -310,7 +295,7 @@ void DYN_modify_function(Global* gbl, const UCHAR** ptr)
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_m_fun, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_m_fun, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
SqlIdentifier t;
|
||||
@ -321,10 +306,7 @@ void DYN_modify_function(Global* gbl, const UCHAR** ptr)
|
||||
X IN RDB$FUNCTIONS
|
||||
WITH X.RDB$FUNCTION_NAME EQ t AND
|
||||
X.RDB$PACKAGE_NAME MISSING
|
||||
|
||||
if (!DYN_REQUEST(drq_m_fun))
|
||||
DYN_REQUEST(drq_m_fun) = request;
|
||||
|
||||
{
|
||||
if (!X.RDB$ENGINE_NAME.NULL)
|
||||
status_exception::raise(Arg::Gds(isc_dyn_newfc_oldsyntax) << t);
|
||||
|
||||
@ -352,16 +334,13 @@ void DYN_modify_function(Global* gbl, const UCHAR** ptr)
|
||||
DYN_unsupported_verb();
|
||||
}
|
||||
}
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_m_fun))
|
||||
DYN_REQUEST(drq_m_fun) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 92);
|
||||
// msg 92: "MODIFY RDB$FUNCTIONS failed"
|
||||
}
|
||||
@ -398,7 +377,7 @@ void DYN_modify_global_field(Global* gbl,
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_m_gfield, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_m_gfield, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
dyn_fld orig_dom, new_dom;
|
||||
@ -422,10 +401,7 @@ void DYN_modify_global_field(Global* gbl,
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
FLD IN RDB$FIELDS WITH FLD.RDB$FIELD_NAME EQ orig_dom.dyn_fld_name.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_m_gfield))
|
||||
DYN_REQUEST(drq_m_gfield) = request;
|
||||
|
||||
{
|
||||
found = true;
|
||||
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE,
|
||||
@ -483,8 +459,8 @@ void DYN_modify_global_field(Global* gbl,
|
||||
MODIFY DIM_DOM USING
|
||||
strcpy (DIM_DOM.RDB$FIELD_NAME, newfld.c_str());
|
||||
DIM_DOM.RDB$FIELD_NAME.NULL = FALSE;
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
END_MODIFY
|
||||
END_FOR
|
||||
CMP_release (tdbb, request);
|
||||
request = NULL;
|
||||
}
|
||||
@ -495,15 +471,15 @@ void DYN_modify_global_field(Global* gbl,
|
||||
MODIFY DOM USING
|
||||
strcpy(DOM.RDB$FIELD_SOURCE, newfld.c_str());
|
||||
DOM.RDB$FIELD_SOURCE.NULL = FALSE;
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
modify_lfield_index(tdbb, gbl,
|
||||
DOM.RDB$RELATION_NAME,
|
||||
DOM.RDB$FIELD_NAME,
|
||||
DOM.RDB$FIELD_NAME);
|
||||
END_FOR;
|
||||
END_FOR
|
||||
CMP_release(tdbb, request);
|
||||
request = old_request;
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -733,7 +709,6 @@ void DYN_modify_global_field(Global* gbl,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Now that we have all of the information needed, let's check to see if the field type can be modifed.
|
||||
// Only do this, however, if we are actually modifying the datatype of the domain.
|
||||
|
||||
@ -785,7 +760,7 @@ void DYN_modify_global_field(Global* gbl,
|
||||
DOM.RDB$RELATION_NAME,
|
||||
DOM.RDB$FIELD_NAME,
|
||||
DOM.RDB$FIELD_NAME);
|
||||
END_FOR;
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
request = old_request;
|
||||
@ -915,17 +890,14 @@ void DYN_modify_global_field(Global* gbl,
|
||||
FLD.RDB$DEFAULT_SOURCE.NULL = TRUE;
|
||||
}
|
||||
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_m_gfield))
|
||||
DYN_REQUEST(drq_m_gfield) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
|
||||
} // try
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 87);
|
||||
// msg 87: "MODIFY RDB$FIELDS failed"
|
||||
}
|
||||
@ -960,7 +932,7 @@ void DYN_modify_index( Global* gbl, const UCHAR** ptr)
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_m_index, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_m_index, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
try {
|
||||
@ -969,10 +941,7 @@ void DYN_modify_index( Global* gbl, const UCHAR** ptr)
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
IDX IN RDB$INDICES WITH IDX.RDB$INDEX_NAME EQ name.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_m_index))
|
||||
DYN_REQUEST(drq_m_index) = request;
|
||||
|
||||
{
|
||||
found = true;
|
||||
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE,
|
||||
@ -1004,17 +973,13 @@ void DYN_modify_index( Global* gbl, const UCHAR** ptr)
|
||||
DYN_unsupported_verb();
|
||||
}
|
||||
}
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_m_index))
|
||||
DYN_REQUEST(drq_m_index) = request;
|
||||
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
} // try
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 91);
|
||||
// msg 91: "MODIFY RDB$INDICES failed"
|
||||
}
|
||||
@ -1130,7 +1095,7 @@ void DYN_modify_local_field(Global* gbl, const UCHAR** ptr, const MetaName* rela
|
||||
}
|
||||
}
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_m_lfield, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_m_lfield, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
try {
|
||||
@ -1141,10 +1106,7 @@ void DYN_modify_local_field(Global* gbl, const UCHAR** ptr, const MetaName* rela
|
||||
FLD IN RDB$RELATION_FIELDS
|
||||
WITH FLD.RDB$FIELD_NAME EQ f.c_str()
|
||||
AND FLD.RDB$RELATION_NAME EQ r.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_m_lfield))
|
||||
DYN_REQUEST(drq_m_lfield) = request;
|
||||
|
||||
{
|
||||
found = true;
|
||||
|
||||
MODIFY FLD USING
|
||||
@ -1219,19 +1181,17 @@ void DYN_modify_local_field(Global* gbl, const UCHAR** ptr, const MetaName* rela
|
||||
|
||||
FLD.RDB$NULL_FLAG = (SSHORT) nullFlag.asBool();
|
||||
}
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_m_lfield))
|
||||
DYN_REQUEST(drq_m_lfield) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (npflag && found && position != existing_position)
|
||||
modify_lfield_position(tdbb, gbl, r, f, position, existing_position);
|
||||
|
||||
} // try
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 95);
|
||||
// msg 95: "MODIFY RDB$RELATION_FIELDS failed"
|
||||
}
|
||||
@ -1263,17 +1223,14 @@ void DYN_modify_relation( Global* gbl, const UCHAR** ptr)
|
||||
|
||||
GET_STRING(ptr, name);
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_m_relation, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_m_relation, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
try {
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
REL IN RDB$RELATIONS WITH REL.RDB$RELATION_NAME EQ name.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_m_relation))
|
||||
DYN_REQUEST(drq_m_relation) = request;
|
||||
|
||||
{
|
||||
if (!REL.RDB$VIEW_BLR.NULL)
|
||||
DYN_error_punt(false, 177);
|
||||
|
||||
@ -1301,13 +1258,11 @@ void DYN_modify_relation( Global* gbl, const UCHAR** ptr)
|
||||
case isc_dyn_rel_ext_file:
|
||||
if (REL.RDB$EXTERNAL_FILE.NULL)
|
||||
{
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(false, 97);
|
||||
// msg 97: "add EXTERNAL FILE not allowed"
|
||||
}
|
||||
if (!GET_STRING(ptr, REL.RDB$EXTERNAL_FILE))
|
||||
{
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(false, 98);
|
||||
// msg 98: "drop EXTERNAL FILE not allowed"
|
||||
}
|
||||
@ -1317,17 +1272,14 @@ void DYN_modify_relation( Global* gbl, const UCHAR** ptr)
|
||||
--(*ptr);
|
||||
DYN_execute(gbl, ptr, &name, &field_name, NULL, NULL, NULL);
|
||||
}
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_m_relation))
|
||||
DYN_REQUEST(drq_m_relation) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
|
||||
} // try
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 99);
|
||||
// msg 99: "MODIFY RDB$RELATIONS failed"
|
||||
}
|
||||
@ -1363,21 +1315,17 @@ void DYN_modify_view( Global* gbl, const UCHAR** ptr)
|
||||
MetaName view_name;
|
||||
GET_STRING(ptr, view_name);
|
||||
|
||||
jrd_req* request = NULL;
|
||||
bool found = false;
|
||||
|
||||
try {
|
||||
|
||||
request = CMP_find_request(tdbb, drq_m_view, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_m_view, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
REL IN RDB$RELATIONS
|
||||
WITH REL.RDB$RELATION_NAME EQ view_name.c_str()
|
||||
AND REL.RDB$VIEW_BLR NOT MISSING
|
||||
|
||||
if (!DYN_REQUEST(drq_m_view))
|
||||
DYN_REQUEST(drq_m_view) = request;
|
||||
|
||||
{
|
||||
found = true;
|
||||
|
||||
DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE,
|
||||
@ -1396,7 +1344,7 @@ void DYN_modify_view( Global* gbl, const UCHAR** ptr)
|
||||
WITH VR.RDB$VIEW_NAME EQ view_name.c_str()
|
||||
|
||||
ERASE VR;
|
||||
END_FOR;
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request2);
|
||||
|
||||
@ -1449,17 +1397,14 @@ void DYN_modify_view( Global* gbl, const UCHAR** ptr)
|
||||
}
|
||||
}
|
||||
}
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_m_view))
|
||||
DYN_REQUEST(drq_m_view) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
|
||||
} // try
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 99);
|
||||
// msg 99: "MODIFY RDB$RELATIONS failed"
|
||||
}
|
||||
@ -1500,14 +1445,14 @@ static void change_backup_mode( Global* gbl, UCHAR verb)
|
||||
ERR_post(Arg::Gds(isc_adm_task_denied));
|
||||
}
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_d_difference, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_d_difference, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
try {
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
X IN RDB$FILES
|
||||
|
||||
{
|
||||
if (X.RDB$FILE_FLAGS & FILE_difference)
|
||||
{
|
||||
found = true;
|
||||
@ -1524,7 +1469,7 @@ static void change_backup_mode( Global* gbl, UCHAR verb)
|
||||
{
|
||||
MODIFY X USING
|
||||
X.RDB$FILE_FLAGS |= FILE_backing_up;
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
}
|
||||
break;
|
||||
case isc_dyn_end_backup:
|
||||
@ -1537,7 +1482,7 @@ static void change_backup_mode( Global* gbl, UCHAR verb)
|
||||
{
|
||||
MODIFY X USING
|
||||
X.RDB$FILE_FLAGS &= ~FILE_backing_up;
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -1546,26 +1491,25 @@ static void change_backup_mode( Global* gbl, UCHAR verb)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_d_difference))
|
||||
DYN_REQUEST(drq_d_difference) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, drq_d_difference);
|
||||
DYN_error_punt(true, 63);
|
||||
// msg 63: ERASE RDB$FILE failed
|
||||
}
|
||||
|
||||
if (!found && verb == isc_dyn_begin_backup)
|
||||
{
|
||||
try {
|
||||
request = CMP_find_request(tdbb, drq_s2_difference, DYN_REQUESTS);
|
||||
try
|
||||
{
|
||||
request.reset(tdbb, drq_s2_difference, DYN_REQUESTS);
|
||||
|
||||
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
X IN RDB$FILES
|
||||
{
|
||||
X.RDB$FILE_NAME.NULL = TRUE;
|
||||
X.RDB$FILE_FLAGS.NULL = FALSE;
|
||||
X.RDB$FILE_FLAGS = FILE_difference | FILE_backing_up;
|
||||
@ -1573,19 +1517,14 @@ static void change_backup_mode( Global* gbl, UCHAR verb)
|
||||
X.RDB$FILE_START.NULL = FALSE;
|
||||
X.RDB$FILE_LENGTH.NULL = TRUE;
|
||||
X.RDB$SHADOW_NUMBER.NULL = TRUE;
|
||||
END_STORE;
|
||||
}
|
||||
END_STORE
|
||||
|
||||
found = true;
|
||||
|
||||
if (!DYN_REQUEST(drq_s2_difference))
|
||||
{
|
||||
DYN_REQUEST(drq_s2_difference) = request;
|
||||
}
|
||||
}
|
||||
catch (const Exception& ex)
|
||||
{
|
||||
stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, drq_s2_difference);
|
||||
DYN_error_punt(true, 150);
|
||||
// msg 150: STORE RDB$FILES failed
|
||||
}
|
||||
@ -1658,11 +1597,11 @@ static void modify_lfield_position(thread_db* tdbb,
|
||||
{
|
||||
MODIFY FLD USING
|
||||
FLD.RDB$FIELD_POSITION = new_pos;
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
}
|
||||
|
||||
++new_pos;
|
||||
END_FOR;
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
request = NULL;
|
||||
@ -1709,8 +1648,8 @@ static void modify_lfield_position(thread_db* tdbb,
|
||||
}
|
||||
|
||||
FLD.RDB$FIELD_POSITION.NULL = FALSE;
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
END_MODIFY
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
}
|
||||
@ -1756,7 +1695,7 @@ static bool check_view_dependency(thread_db* tdbb,
|
||||
Y.RDB$VIEW_CONTEXT EQ Z.RDB$VIEW_CONTEXT
|
||||
retval = true;
|
||||
view_name = Z.RDB$VIEW_NAME;
|
||||
END_FOR;
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
|
||||
@ -1797,7 +1736,7 @@ static bool check_sptrig_dependency(thread_db* tdbb,
|
||||
DEP.RDB$FIELD_NAME EQ field_name.c_str()
|
||||
retval = true;
|
||||
dep_name = DEP.RDB$DEPENDENT_NAME;
|
||||
END_FOR;
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
|
||||
@ -1838,15 +1777,15 @@ static void modify_lfield_index(thread_db* tdbb,
|
||||
// Change the name of the field in the index
|
||||
MODIFY IDXS USING
|
||||
memcpy(IDXS.RDB$FIELD_NAME, new_fld_name.c_str(), sizeof(IDXS.RDB$FIELD_NAME));
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
|
||||
// Set the index name to itself to tell the index to rebuild
|
||||
MODIFY IDX USING
|
||||
// This is to fool both gpre and gcc.
|
||||
char* p = IDX.RDB$INDEX_NAME;
|
||||
p[MAX_SQL_IDENTIFIER_LEN] = 0;
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
END_MODIFY
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
}
|
||||
@ -1873,7 +1812,7 @@ static bool field_exists(thread_db* tdbb,
|
||||
FLD.RDB$RELATION_NAME EQ relation_name.c_str() AND
|
||||
FLD.RDB$FIELD_NAME EQ field_name.c_str()
|
||||
retval = true;
|
||||
END_FOR;
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
return retval;
|
||||
@ -1896,7 +1835,7 @@ static bool domain_exists(thread_db* tdbb, Global* gbl, const MetaName& field_na
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
FLD IN RDB$FIELDS WITH FLD.RDB$FIELD_NAME EQ field_name.c_str()
|
||||
retval = true;
|
||||
END_FOR;
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
return retval;
|
||||
@ -2250,7 +2189,7 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
else
|
||||
DYN_UTIL_generate_field_name(tdbb, gbl, new_fld.dyn_fld_source);
|
||||
}
|
||||
END_FOR; // FLD in RDB$FIELDS
|
||||
END_FOR // FLD in RDB$FIELDS
|
||||
CMP_release(tdbb, request);
|
||||
request = NULL;
|
||||
|
||||
@ -2311,7 +2250,7 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
WITH FLD.RDB$FIELD_NAME = RFR.RDB$FIELD_SOURCE
|
||||
|
||||
ERASE FLD;
|
||||
END_FOR;
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
request = NULL;
|
||||
@ -2327,7 +2266,7 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
}
|
||||
|
||||
RFR.RDB$COLLATION_ID.NULL = TRUE; // CORE-2426
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
first_request = request;
|
||||
request = NULL;
|
||||
|
||||
@ -2338,8 +2277,8 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
|
||||
MODIFY PRM USING
|
||||
strcpy(PRM.RDB$FIELD_SOURCE, dom_fld.dyn_fld_source.c_str());
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
END_MODIFY
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
request = NULL;
|
||||
@ -2405,7 +2344,7 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
MODIFY RFR USING
|
||||
DYN_UTIL_generate_field_name(tdbb, gbl, RFR.RDB$FIELD_SOURCE);
|
||||
new_fld.dyn_fld_source = RFR.RDB$FIELD_SOURCE;
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
first_request = request;
|
||||
request = NULL;
|
||||
|
||||
@ -2496,7 +2435,7 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
|
||||
// Copy the field name into RDB$FIELDS
|
||||
strcpy(FLD.RDB$FIELD_NAME, new_fld.dyn_fld_source.c_str());
|
||||
END_STORE;
|
||||
END_STORE
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
request = NULL;
|
||||
@ -2508,8 +2447,8 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
|
||||
MODIFY PRM USING
|
||||
strcpy(PRM.RDB$FIELD_SOURCE, new_fld.dyn_fld_source.c_str());
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
END_MODIFY
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
request = NULL;
|
||||
@ -2648,8 +2587,8 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
}
|
||||
}
|
||||
|
||||
END_MODIFY;
|
||||
END_FOR; // FLD in RDB$FIELDS
|
||||
END_MODIFY
|
||||
END_FOR // FLD in RDB$FIELDS
|
||||
CMP_release(tdbb, request);
|
||||
if (domain_is_computed)
|
||||
{
|
||||
@ -2657,7 +2596,7 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
MODIFY RFR USING
|
||||
RFR.RDB$UPDATE_FLAG.NULL = FALSE;
|
||||
RFR.RDB$UPDATE_FLAG = 1;
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
first_request = request;
|
||||
}
|
||||
|
||||
@ -2679,9 +2618,9 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati
|
||||
RFR.RDB$BASE_FIELD.NULL = fld_base_field.isEmpty();
|
||||
strcpy(RFR.RDB$BASE_FIELD, fld_base_field.c_str());
|
||||
}
|
||||
END_MODIFY;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR; // RFR IN RDB$RELATION_FIELDS
|
||||
END_FOR // RFR IN RDB$RELATION_FIELDS
|
||||
CMP_release(tdbb, request);
|
||||
request = NULL;
|
||||
|
||||
@ -2715,7 +2654,7 @@ void DYN_modify_mapping(Global* gbl, const UCHAR** ptr)
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_m_map, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_m_map, DYN_REQUESTS);
|
||||
bool found = false;
|
||||
|
||||
string osName, dbName;
|
||||
@ -2738,10 +2677,7 @@ void DYN_modify_mapping(Global* gbl, const UCHAR** ptr)
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
X IN RDB$ROLES
|
||||
WITH X.RDB$ROLE_NAME EQ dbName.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_m_map))
|
||||
DYN_REQUEST(drq_m_map) = request;
|
||||
|
||||
{
|
||||
found = true;
|
||||
MODIFY X
|
||||
switch (op)
|
||||
@ -2757,11 +2693,9 @@ void DYN_modify_mapping(Global* gbl, const UCHAR** ptr)
|
||||
default:
|
||||
DYN_unsupported_verb();
|
||||
}
|
||||
END_MODIFY;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_m_map))
|
||||
DYN_REQUEST(drq_m_map) = request;
|
||||
END_MODIFY
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!found)
|
||||
{
|
||||
@ -2808,7 +2742,7 @@ void get_domain_type(thread_db* tdbb, Global* gbl, dyn_fld& dom_fld)
|
||||
if (!FLD.RDB$DIMENSIONS.NULL && FLD.RDB$DIMENSIONS > 0)
|
||||
dom_fld.dyn_dtype = blr_blob;
|
||||
|
||||
END_FOR;
|
||||
END_FOR
|
||||
CMP_release(tdbb, request);
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ void DYN_UTIL_check_unique_name(thread_db* tdbb, jrd_tra* transaction,
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
USHORT error_code = 0;
|
||||
jrd_req* request = NULL;
|
||||
AutoCacheRequest request;
|
||||
|
||||
try
|
||||
{
|
||||
@ -133,104 +133,78 @@ void DYN_UTIL_check_unique_name(thread_db* tdbb, jrd_tra* transaction,
|
||||
{
|
||||
case obj_relation:
|
||||
case obj_procedure:
|
||||
request = CMP_find_request(tdbb, drq_l_rel_name, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_l_rel_name, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
EREL IN RDB$RELATIONS WITH EREL.RDB$RELATION_NAME EQ object_name.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_l_rel_name))
|
||||
DYN_REQUEST(drq_l_rel_name) = request;
|
||||
|
||||
{
|
||||
error_code = 132;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_l_rel_name))
|
||||
DYN_REQUEST(drq_l_rel_name) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!error_code)
|
||||
{
|
||||
request = CMP_find_request(tdbb, drq_l_prc_name, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_l_prc_name, DYN_REQUESTS);
|
||||
|
||||
FOR (REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
EPRC IN RDB$PROCEDURES
|
||||
WITH EPRC.RDB$PROCEDURE_NAME EQ object_name.c_str() AND
|
||||
EPRC.RDB$PACKAGE_NAME MISSING
|
||||
|
||||
if (!DYN_REQUEST(drq_l_prc_name))
|
||||
DYN_REQUEST(drq_l_prc_name) = request;
|
||||
|
||||
{
|
||||
error_code = 135;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_l_prc_name))
|
||||
DYN_REQUEST(drq_l_prc_name) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
break;
|
||||
|
||||
case obj_index:
|
||||
request = CMP_find_request(tdbb, drq_l_idx_name, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_l_idx_name, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
EIDX IN RDB$INDICES WITH EIDX.RDB$INDEX_NAME EQ object_name.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_l_idx_name))
|
||||
DYN_REQUEST(drq_l_idx_name) = request;
|
||||
|
||||
{
|
||||
error_code = 251;
|
||||
END_FOR;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DYN_REQUEST(drq_l_idx_name))
|
||||
DYN_REQUEST(drq_l_idx_name) = request;
|
||||
break;
|
||||
|
||||
case obj_exception:
|
||||
request = CMP_find_request(tdbb, drq_l_xcp_name, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_l_xcp_name, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
EXCP IN RDB$EXCEPTIONS WITH EXCP.RDB$EXCEPTION_NAME EQ object_name.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_l_xcp_name))
|
||||
DYN_REQUEST(drq_l_xcp_name) = request;
|
||||
|
||||
{
|
||||
error_code = 253;
|
||||
END_FOR;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DYN_REQUEST(drq_l_xcp_name))
|
||||
DYN_REQUEST(drq_l_xcp_name) = request;
|
||||
break;
|
||||
|
||||
case obj_generator:
|
||||
request = CMP_find_request(tdbb, drq_l_gen_name, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_l_gen_name, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
EGEN IN RDB$GENERATORS WITH EGEN.RDB$GENERATOR_NAME EQ object_name.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_l_gen_name))
|
||||
DYN_REQUEST(drq_l_gen_name) = request;
|
||||
|
||||
{
|
||||
error_code = 254;
|
||||
END_FOR;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DYN_REQUEST(drq_l_gen_name))
|
||||
DYN_REQUEST(drq_l_gen_name) = request;
|
||||
break;
|
||||
|
||||
case obj_udf:
|
||||
request = CMP_find_request(tdbb, drq_l_fun_name, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_l_fun_name, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction)
|
||||
EFUN IN RDB$FUNCTIONS
|
||||
WITH EFUN.RDB$FUNCTION_NAME EQ object_name.c_str() AND
|
||||
EFUN.RDB$PACKAGE_NAME MISSING
|
||||
|
||||
if (!DYN_REQUEST(drq_l_fun_name))
|
||||
DYN_REQUEST(drq_l_fun_name) = request;
|
||||
|
||||
{
|
||||
error_code = 268;
|
||||
END_FOR;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DYN_REQUEST(drq_l_fun_name))
|
||||
DYN_REQUEST(drq_l_fun_name) = request;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -239,13 +213,11 @@ void DYN_UTIL_check_unique_name(thread_db* tdbb, jrd_tra* transaction,
|
||||
}
|
||||
catch (const Firebird::Exception&)
|
||||
{
|
||||
DYN_rundown_request(request, -1);
|
||||
throw;
|
||||
}
|
||||
|
||||
if (error_code) {
|
||||
if (error_code)
|
||||
DYN_error_punt(false, error_code, object_name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -265,7 +237,7 @@ SINT64 DYN_UTIL_gen_unique_id(thread_db* tdbb, SSHORT id, const char* generator_
|
||||
Jrd::Attachment* attachment = tdbb->getAttachment();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, id, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, id, DYN_REQUESTS);
|
||||
|
||||
SINT64 value = 0;
|
||||
|
||||
@ -294,18 +266,12 @@ SINT64 DYN_UTIL_gen_unique_id(thread_db* tdbb, SSHORT id, const char* generator_
|
||||
|
||||
EXE_start(tdbb, request, attachment->getSysTransaction());
|
||||
EXE_receive(tdbb, request, 0, sizeof(value), (UCHAR*) &value);
|
||||
EXE_unwind(tdbb, request);
|
||||
}
|
||||
catch (const Firebird::Exception&)
|
||||
{
|
||||
DYN_rundown_request(request, id);
|
||||
throw;
|
||||
}
|
||||
|
||||
if (!DYN_REQUEST(id)) {
|
||||
DYN_REQUEST(id) = request;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -326,7 +292,6 @@ void DYN_UTIL_generate_constraint_name( thread_db* tdbb, Global* /*gbl*/, Firebi
|
||||
Jrd::Attachment* attachment = tdbb->getAttachment();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = NULL;
|
||||
SSHORT id = -1;
|
||||
|
||||
try
|
||||
@ -337,28 +302,22 @@ void DYN_UTIL_generate_constraint_name( thread_db* tdbb, Global* /*gbl*/, Firebi
|
||||
buffer.printf("INTEG_%" SQUADFORMAT,
|
||||
DYN_UTIL_gen_unique_id(tdbb, drq_g_nxt_con, "RDB$CONSTRAINT_NAME"));
|
||||
|
||||
request = CMP_find_request(tdbb, drq_f_nxt_con, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_f_nxt_con, DYN_REQUESTS);
|
||||
id = drq_f_nxt_con;
|
||||
|
||||
found = false;
|
||||
FOR(REQUEST_HANDLE request)
|
||||
FIRST 1 X IN RDB$RELATION_CONSTRAINTS
|
||||
WITH X.RDB$CONSTRAINT_NAME EQ buffer.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_f_nxt_con))
|
||||
DYN_REQUEST(drq_f_nxt_con) = request;
|
||||
{
|
||||
found = true;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_f_nxt_con))
|
||||
DYN_REQUEST(drq_f_nxt_con) = request;
|
||||
request = NULL;
|
||||
}
|
||||
END_FOR
|
||||
} while (found);
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, id);
|
||||
DYN_error_punt(true, 131);
|
||||
// msg 131: "Generation of constraint name failed"
|
||||
}
|
||||
@ -399,7 +358,6 @@ void DYN_UTIL_generate_field_name( thread_db* tdbb, Global* /*gbl*/, Firebird::M
|
||||
Jrd::Attachment* attachment = tdbb->getAttachment();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = NULL;
|
||||
SSHORT id = -1;
|
||||
|
||||
try
|
||||
@ -410,27 +368,21 @@ void DYN_UTIL_generate_field_name( thread_db* tdbb, Global* /*gbl*/, Firebird::M
|
||||
buffer.printf("RDB$%" SQUADFORMAT,
|
||||
DYN_UTIL_gen_unique_id(tdbb, drq_g_nxt_fld, "RDB$FIELD_NAME"));
|
||||
|
||||
request = CMP_find_request(tdbb, drq_f_nxt_fld, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_f_nxt_fld, DYN_REQUESTS);
|
||||
id = drq_f_nxt_fld;
|
||||
|
||||
found = false;
|
||||
FOR(REQUEST_HANDLE request)
|
||||
FIRST 1 X IN RDB$FIELDS WITH X.RDB$FIELD_NAME EQ buffer.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_f_nxt_fld))
|
||||
DYN_REQUEST(drq_f_nxt_fld) = request;
|
||||
{
|
||||
found = true;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_f_nxt_fld))
|
||||
DYN_REQUEST(drq_f_nxt_fld) = request;
|
||||
request = NULL;
|
||||
}
|
||||
END_FOR
|
||||
} while (found);
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, id);
|
||||
DYN_error_punt(true, 81);
|
||||
// msg 81: "Generation of field name failed"
|
||||
}
|
||||
@ -458,31 +410,26 @@ void DYN_UTIL_generate_field_position(thread_db* tdbb,
|
||||
Jrd::Attachment* attachment = tdbb->getAttachment();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
request = CMP_find_request(tdbb, drq_l_fld_pos, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_l_fld_pos, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request)
|
||||
X IN RDB$RELATION_FIELDS
|
||||
WITH X.RDB$RELATION_NAME EQ relation_name.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_l_fld_pos))
|
||||
DYN_REQUEST(drq_l_fld_pos) = request;
|
||||
|
||||
{
|
||||
if (X.RDB$FIELD_POSITION.NULL)
|
||||
continue;
|
||||
|
||||
field_position = MAX(X.RDB$FIELD_POSITION, field_position);
|
||||
END_FOR;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
*field_pos = field_position;
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 162);
|
||||
// msg 162: "Looking up field position failed"
|
||||
}
|
||||
@ -506,7 +453,6 @@ void DYN_UTIL_generate_index_name(thread_db* tdbb, Global* /*gbl*/,
|
||||
Jrd::Attachment* attachment = tdbb->getAttachment();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = NULL;
|
||||
SSHORT id = -1;
|
||||
|
||||
try
|
||||
@ -530,27 +476,21 @@ void DYN_UTIL_generate_index_name(thread_db* tdbb, Global* /*gbl*/,
|
||||
buffer.printf(format,
|
||||
DYN_UTIL_gen_unique_id(tdbb, drq_g_nxt_idx, "RDB$INDEX_NAME"));
|
||||
|
||||
request = CMP_find_request(tdbb, drq_f_nxt_idx, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_f_nxt_idx, DYN_REQUESTS);
|
||||
id = drq_f_nxt_idx;
|
||||
|
||||
found = false;
|
||||
FOR(REQUEST_HANDLE request)
|
||||
FIRST 1 X IN RDB$INDICES WITH X.RDB$INDEX_NAME EQ buffer.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_f_nxt_idx))
|
||||
DYN_REQUEST(drq_f_nxt_idx) = request;
|
||||
{
|
||||
found = true;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_f_nxt_idx))
|
||||
DYN_REQUEST(drq_f_nxt_idx) = request;
|
||||
request = NULL;
|
||||
}
|
||||
END_FOR
|
||||
} while (found);
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, id);
|
||||
DYN_error_punt(true, 82);
|
||||
// msg 82: "Generation of index name failed"
|
||||
}
|
||||
@ -587,7 +527,6 @@ void DYN_UTIL_generate_generator_name(thread_db* tdbb, Firebird::MetaName& buffe
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 277); // msg 277: "Generation of generator name failed"
|
||||
}
|
||||
}
|
||||
@ -609,7 +548,6 @@ void DYN_UTIL_generate_trigger_name( thread_db* tdbb, Global* /*gbl*/, Firebird:
|
||||
Jrd::Attachment* attachment = tdbb->getAttachment();
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = NULL;
|
||||
SSHORT id = -1;
|
||||
|
||||
try
|
||||
@ -620,27 +558,21 @@ void DYN_UTIL_generate_trigger_name( thread_db* tdbb, Global* /*gbl*/, Firebird:
|
||||
buffer.printf("CHECK_%" SQUADFORMAT,
|
||||
DYN_UTIL_gen_unique_id(tdbb, drq_g_nxt_trg, "RDB$TRIGGER_NAME"));
|
||||
|
||||
request = CMP_find_request(tdbb, drq_f_nxt_trg, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_f_nxt_trg, DYN_REQUESTS);
|
||||
id = drq_f_nxt_trg;
|
||||
|
||||
found = false;
|
||||
FOR(REQUEST_HANDLE request)
|
||||
FIRST 1 X IN RDB$TRIGGERS WITH X.RDB$TRIGGER_NAME EQ buffer.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_f_nxt_trg))
|
||||
DYN_REQUEST(drq_f_nxt_trg) = request;
|
||||
{
|
||||
found = true;
|
||||
END_FOR;
|
||||
|
||||
if (!DYN_REQUEST(drq_f_nxt_trg))
|
||||
DYN_REQUEST(drq_f_nxt_trg) = request;
|
||||
request = NULL;
|
||||
}
|
||||
END_FOR
|
||||
} while (found);
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, id);
|
||||
DYN_error_punt(true, 83);
|
||||
// msg 83: "Generation of trigger name failed"
|
||||
}
|
||||
@ -668,8 +600,6 @@ bool DYN_UTIL_find_field_source(thread_db* tdbb,
|
||||
SET_TDBB(tdbb);
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = NULL;
|
||||
|
||||
/* CVC: It seems the logic of this function was changed over time. It's unlikely
|
||||
it will cause a failure that leads to call DYN_error_punt(), unless the request finds
|
||||
problems due to database corruption or unexpected ODS changes. Under normal
|
||||
@ -680,7 +610,7 @@ bool DYN_UTIL_find_field_source(thread_db* tdbb,
|
||||
bool found = false;
|
||||
|
||||
try {
|
||||
request = CMP_find_request(tdbb, drq_l_fld_src2, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_l_fld_src2, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
VRL IN RDB$VIEW_RELATIONS CROSS
|
||||
@ -690,22 +620,16 @@ bool DYN_UTIL_find_field_source(thread_db* tdbb,
|
||||
VRL.RDB$CONTEXT_TYPE BETWEEN VCT_TABLE AND VCT_VIEW AND
|
||||
VRL.RDB$PACKAGE_NAME MISSING AND
|
||||
RFR.RDB$FIELD_NAME EQ local_name
|
||||
|
||||
if (!DYN_REQUEST(drq_l_fld_src2)) {
|
||||
DYN_REQUEST(drq_l_fld_src2) = request;
|
||||
}
|
||||
|
||||
{
|
||||
found = true;
|
||||
fb_utils::exact_name_limit(RFR.RDB$FIELD_SOURCE, sizeof(RFR.RDB$FIELD_SOURCE));
|
||||
strcpy(output_field_name, RFR.RDB$FIELD_SOURCE);
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_l_fld_src2)) {
|
||||
DYN_REQUEST(drq_l_fld_src2) = request;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!found)
|
||||
{
|
||||
request = CMP_find_request(tdbb, drq_l_fld_src3, DYN_REQUESTS);
|
||||
request.reset(tdbb, drq_l_fld_src3, DYN_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
VRL IN RDB$VIEW_RELATIONS CROSS
|
||||
@ -717,24 +641,17 @@ bool DYN_UTIL_find_field_source(thread_db* tdbb,
|
||||
PPR.RDB$PACKAGE_NAME EQUIV VRL.RDB$PACKAGE_NAME AND
|
||||
PPR.RDB$PARAMETER_TYPE = 1 AND // output
|
||||
PPR.RDB$PARAMETER_NAME EQ local_name
|
||||
|
||||
if (!DYN_REQUEST(drq_l_fld_src3)) {
|
||||
DYN_REQUEST(drq_l_fld_src3) = request;
|
||||
}
|
||||
|
||||
{
|
||||
found = true;
|
||||
fb_utils::exact_name_limit(PPR.RDB$FIELD_SOURCE, sizeof(PPR.RDB$FIELD_SOURCE));
|
||||
strcpy(output_field_name, PPR.RDB$FIELD_SOURCE);
|
||||
END_FOR;
|
||||
if (!DYN_REQUEST(drq_l_fld_src3)) {
|
||||
DYN_REQUEST(drq_l_fld_src3) = request;
|
||||
}
|
||||
END_FOR
|
||||
}
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1);
|
||||
DYN_error_punt(true, 80);
|
||||
// msg 80: "Specified domain or source field does not exist"
|
||||
}
|
||||
@ -767,27 +684,22 @@ bool DYN_UTIL_get_prot(thread_db* tdbb,
|
||||
|
||||
SET_TDBB(tdbb);
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_l_prot_mask, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_l_prot_mask, DYN_REQUESTS);
|
||||
|
||||
try
|
||||
{
|
||||
if (!request)
|
||||
{
|
||||
request = CMP_compile2(tdbb, prot_blr, sizeof(prot_blr), true);
|
||||
}
|
||||
|
||||
gds__vtov(rname, in_msg.relation_name, sizeof(in_msg.relation_name));
|
||||
gds__vtov(fname, in_msg.field_name, sizeof(in_msg.field_name));
|
||||
EXE_start(tdbb, request, gbl->gbl_transaction);
|
||||
EXE_send(tdbb, request, 0, sizeof(in_msg), (UCHAR*) &in_msg);
|
||||
EXE_receive(tdbb, request, 1, sizeof(SecurityClass::flags_t), (UCHAR*) prot_mask);
|
||||
|
||||
DYN_rundown_request(request, drq_l_prot_mask);
|
||||
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, drq_l_prot_mask);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -813,25 +725,21 @@ void DYN_UTIL_store_check_constraints(thread_db* tdbb,
|
||||
SET_TDBB(tdbb);
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_s_chk_con, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_s_chk_con, DYN_REQUESTS);
|
||||
|
||||
try
|
||||
{
|
||||
STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
CHK IN RDB$CHECK_CONSTRAINTS
|
||||
{
|
||||
strcpy(CHK.RDB$CONSTRAINT_NAME, constraint_name.c_str());
|
||||
strcpy(CHK.RDB$TRIGGER_NAME, trigger_name.c_str());
|
||||
|
||||
END_STORE;
|
||||
|
||||
if (!DYN_REQUEST(drq_s_chk_con)) {
|
||||
DYN_REQUEST(drq_s_chk_con) = request;
|
||||
}
|
||||
END_STORE
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, drq_s_chk_con);
|
||||
DYN_error_punt(true, 122);
|
||||
// msg 122: "STORE RDB$CHECK_CONSTRAINTS failed"
|
||||
}
|
||||
@ -853,29 +761,23 @@ bool DYN_UTIL_is_array(thread_db* tdbb, Global* gbl, const Firebird::MetaName& d
|
||||
SET_TDBB(tdbb);
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
|
||||
jrd_req* request = CMP_find_request(tdbb, drq_dom_is_array, DYN_REQUESTS);
|
||||
AutoCacheRequest request(tdbb, drq_dom_is_array, DYN_REQUESTS);
|
||||
|
||||
try
|
||||
{
|
||||
bool rc = false;
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
X IN RDB$FIELDS WITH X.RDB$FIELD_NAME EQ domain_name.c_str()
|
||||
|
||||
if (!DYN_REQUEST(drq_dom_is_array))
|
||||
DYN_REQUEST(drq_dom_is_array) = request;
|
||||
|
||||
{
|
||||
rc = !X.RDB$DIMENSIONS.NULL && X.RDB$DIMENSIONS > 0;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
if (!DYN_REQUEST(drq_dom_is_array))
|
||||
DYN_REQUEST(drq_dom_is_array) = request;
|
||||
|
||||
return rc;
|
||||
}
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, drq_dom_is_array);
|
||||
DYN_error_punt(true, 227, domain_name.c_str());
|
||||
// msg 227: "DYN_UTIL_is_array failed for domain %s"
|
||||
return false; // Keep compiler happy.
|
||||
@ -910,7 +812,7 @@ void DYN_UTIL_copy_domain(thread_db* tdbb,
|
||||
{
|
||||
FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction)
|
||||
X IN RDB$FIELDS WITH X.RDB$FIELD_NAME EQ org_name.c_str()
|
||||
|
||||
{
|
||||
//if (!DYN_REQUEST(drq_dom_copy))
|
||||
// DYN_REQUEST(drq_dom_copy) = request;
|
||||
|
||||
@ -1013,8 +915,10 @@ void DYN_UTIL_copy_domain(thread_db* tdbb,
|
||||
X2.RDB$FIELD_PRECISION.NULL = X.RDB$FIELD_PRECISION.NULL;
|
||||
X2.RDB$FIELD_PRECISION = X.RDB$FIELD_PRECISION;
|
||||
END_STORE
|
||||
|
||||
CMP_release(tdbb, req2);
|
||||
req2 = NULL;
|
||||
}
|
||||
END_FOR
|
||||
|
||||
CMP_release(tdbb, request);
|
||||
@ -1027,7 +931,12 @@ void DYN_UTIL_copy_domain(thread_db* tdbb,
|
||||
catch (const Firebird::Exception& ex)
|
||||
{
|
||||
Firebird::stuff_exception(tdbb->tdbb_status_vector, ex);
|
||||
DYN_rundown_request(request, -1); //drq_dom_copy);
|
||||
|
||||
if (request)
|
||||
CMP_release(tdbb, request);
|
||||
if (req2)
|
||||
CMP_release(tdbb, req2);
|
||||
|
||||
DYN_error_punt(true, 228, org_name.c_str());
|
||||
// msg 228: "DYN_UTIL_copy_domain failed for domain %s"
|
||||
}
|
||||
|
@ -60,6 +60,13 @@ namespace Jrd
|
||||
{
|
||||
}
|
||||
|
||||
AutoCacheRequest()
|
||||
: id(0),
|
||||
which(0),
|
||||
request(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
~AutoCacheRequest()
|
||||
{
|
||||
release();
|
||||
@ -84,6 +91,11 @@ namespace Jrd
|
||||
return *this;
|
||||
}
|
||||
|
||||
jrd_req* operator ->()
|
||||
{
|
||||
return request;
|
||||
}
|
||||
|
||||
operator jrd_req*()
|
||||
{
|
||||
return request;
|
||||
|
Loading…
Reference in New Issue
Block a user