From 378caea05e8bd9945cad66e64ad4cd1cd8b0fcf3 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Sun, 18 Apr 2010 01:10:05 +0000 Subject: [PATCH] Use AutoCacheRequest for DYN requests --- src/jrd/dyn.epp | 221 +++++----------- src/jrd/dyn.h | 1 - src/jrd/dyn_def.epp | 581 ++++++++++++++----------------------------- src/jrd/dyn_del.epp | 505 +++++++++++-------------------------- src/jrd/dyn_mod.epp | 250 +++++++------------ src/jrd/dyn_util.epp | 231 ++++++----------- src/jrd/exe_proto.h | 12 + 7 files changed, 565 insertions(+), 1236 deletions(-) diff --git a/src/jrd/dyn.epp b/src/jrd/dyn.epp index 1a19e7c6cb..d141018fb8 100644 --- a/src/jrd/dyn.epp +++ b/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" } diff --git a/src/jrd/dyn.h b/src/jrd/dyn.h index 8572fbaafb..ab1e4c038c 100644 --- a/src/jrd/dyn.h +++ b/src/jrd/dyn.h @@ -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(); diff --git a/src/jrd/dyn_def.epp b/src/jrd/dyn_def.epp index e93d2e9346..93c3009317 100644 --- a/src/jrd/dyn_def.epp +++ b/src/jrd/dyn_def.epp @@ -132,7 +132,7 @@ void DYN_define_collation( Global* gbl, const UCHAR** ptr) DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, DDL_TRIGGER_CREATE_COLLATION, collation_name, gbl->sqlText); - jrd_req* request = CMP_find_request(tdbb, drq_s_colls, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_colls, DYN_REQUESTS); bool b_ending_store = false; @@ -140,7 +140,7 @@ void DYN_define_collation( Global* gbl, const UCHAR** ptr) { STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$COLLATIONS - + { CharSet* cs = NULL; SubtypeInfo info; USHORT attributes_on = 0; @@ -164,23 +164,17 @@ void DYN_define_collation( Global* gbl, const UCHAR** ptr) cs = INTL_charset_lookup(tdbb, X.RDB$CHARACTER_SET_ID); - jrd_req* request2 = CMP_find_request(tdbb, drq_l_charset, DYN_REQUESTS); + AutoCacheRequest request2(tdbb, drq_l_charset, DYN_REQUESTS); FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) CS IN RDB$CHARACTER_SETS WITH CS.RDB$CHARACTER_SET_ID EQ X.RDB$CHARACTER_SET_ID - - if (!DYN_REQUEST(drq_l_charset)) - DYN_REQUEST(drq_l_charset) = request2; - + { charsetName = CS.RDB$CHARACTER_SET_NAME; - + } END_FOR - if (!DYN_REQUEST(drq_l_charset)) - DYN_REQUEST(drq_l_charset) = request2; - break; } @@ -345,18 +339,14 @@ void DYN_define_collation( Global* gbl, const UCHAR** ptr) } b_ending_store = true; - - END_STORE; - - if (!DYN_REQUEST(drq_s_colls)) - DYN_REQUEST(drq_s_colls) = request; + } + END_STORE } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (b_ending_store) { - DYN_rundown_request(request, drq_s_colls); DYN_error_punt(true, 219); // msg 219: "DEFINE COLLATION failed" } @@ -399,16 +389,16 @@ void DYN_define_constraint(Global* gbl, if (constraint_name.isEmpty()) DYN_UTIL_generate_constraint_name(tdbb, gbl, constraint_name); - jrd_req* request = NULL; SSHORT id = -1; try { - request = CMP_find_request(tdbb, drq_s_rel_con, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_rel_con, DYN_REQUESTS); id = drq_s_rel_con; STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) CRT IN RDB$RELATION_CONSTRAINTS + { strcpy(CRT.RDB$CONSTRAINT_NAME, constraint_name.c_str()); strcpy(CRT.RDB$RELATION_NAME, relation_name->c_str()); @@ -461,12 +451,8 @@ void DYN_define_constraint(Global* gbl, SCL_check_index(tdbb, referred_index_name, 0, SCL_sql_references); } - END_STORE; - - if (!DYN_REQUEST(drq_s_rel_con)) - { - DYN_REQUEST(drq_s_rel_con) = request; } + END_STORE } // try catch (const Firebird::Exception& ex) @@ -506,8 +492,6 @@ void DYN_define_constraint(Global* gbl, break; } - DYN_rundown_request(request, local_id); - DYN_error_punt(true, number, number == 124 ? constraint_name.c_str() : NULL); } @@ -540,7 +524,7 @@ void DYN_define_constraint(Global* gbl, // Make sure unique field names were specified for UNIQUE/PRIMARY/FOREIGN // All fields must have the NOT NULL attribute specified for UNIQUE/PRIMARY. - request = CMP_find_request(tdbb, drq_c_unq_nam, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_c_unq_nam, DYN_REQUESTS); id = drq_c_unq_nam; bool not_null = true; @@ -556,25 +540,20 @@ void DYN_define_constraint(Global* gbl, REDUCED TO IDS.RDB$FIELD_NAME, IDS.RDB$INDEX_NAME, FLX.RDB$NULL_FLAG SORTED BY ASCENDING IDS.RDB$FIELD_NAME - if (!DYN_REQUEST(drq_c_unq_nam)) - DYN_REQUEST(drq_c_unq_nam) = request; - + { if ((FLX.RDB$NULL_FLAG.NULL || !FLX.RDB$NULL_FLAG) && (RFR.RDB$NULL_FLAG.NULL || !RFR.RDB$NULL_FLAG) && primary_flag) { not_null = false; null_field_name = RFR.RDB$FIELD_NAME; - EXE_unwind(tdbb, request); break; } unique_count++; field_list.add() = IDS.RDB$FIELD_NAME; - END_FOR; - if (!DYN_REQUEST(drq_c_unq_nam)) { - DYN_REQUEST(drq_c_unq_nam) = request; } + END_FOR if (!not_null) { @@ -582,31 +561,25 @@ void DYN_define_constraint(Global* gbl, // msg 123: "Field: %s not defined as NOT NULL - can't be used in PRIMARY KEY constraint definition" } - request = CMP_find_request(tdbb, drq_n_idx_seg, DYN_REQUESTS); + request.reset(tdbb, drq_n_idx_seg, DYN_REQUESTS); id = drq_n_idx_seg; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) IDS IN RDB$INDEX_SEGMENTS WITH IDS.RDB$INDEX_NAME EQ index_name.c_str() - if (!DYN_REQUEST(drq_n_idx_seg)) { - DYN_REQUEST(drq_n_idx_seg) = request; - } - + { all_count++; - END_FOR; - if (!DYN_REQUEST(drq_n_idx_seg)) { - DYN_REQUEST(drq_n_idx_seg) = request; } + END_FOR - if (unique_count != all_count) { + if (unique_count != all_count) goto dyn_punt_false_124; - } // For PRIMARY KEY/UNIQUE constraints, make sure same set of columns // is not used in another constraint of either type if (!foreign_flag) { - request = CMP_find_request(tdbb, drq_c_dup_con, DYN_REQUESTS); + request.reset(tdbb, drq_c_dup_con, DYN_REQUESTS); id = drq_c_dup_con; index_name = ""; @@ -620,19 +593,14 @@ void DYN_define_constraint(Global* gbl, CRT.RDB$CONSTRAINT_TYPE EQ UNIQUE_CNSTRT) AND CRT.RDB$CONSTRAINT_NAME NE constraint_name.c_str() SORTED BY CRT.RDB$INDEX_NAME, DESCENDING IDS.RDB$FIELD_NAME - if (!DYN_REQUEST(drq_c_dup_con)) - DYN_REQUEST(drq_c_dup_con) = request; - + { if (index_name != CRT.RDB$INDEX_NAME) { if (list_index >= 0) { found = false; } if (found) - { - EXE_unwind(tdbb, request); break; - } list_index = field_list.getCount() - 1; index_name = CRT.RDB$INDEX_NAME; found = true; @@ -648,44 +616,35 @@ void DYN_define_constraint(Global* gbl, else { found = false; } - END_FOR; - if (!DYN_REQUEST(drq_c_dup_con)) { - DYN_REQUEST(drq_c_dup_con) = request; } + END_FOR - if (list_index >= 0) { + if (list_index >= 0) found = false; - } - if (found) { + if (found) goto dyn_punt_false_126; - } } else { // Foreign key being defined - request = CMP_find_request(tdbb, drq_s_ref_con, DYN_REQUESTS); + request.reset(tdbb, drq_s_ref_con, DYN_REQUESTS); id = drq_s_ref_con; - jrd_req* old_request = NULL; - STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) REF IN RDB$REF_CONSTRAINTS - old_request = request; + { const SSHORT old_id = id; - request = CMP_find_request(tdbb, drq_l_intg_con, DYN_REQUESTS); + AutoCacheRequest request2(tdbb, drq_l_intg_con, DYN_REQUESTS); id = drq_l_intg_con; - FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) + FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) CRT IN RDB$RELATION_CONSTRAINTS WITH CRT.RDB$INDEX_NAME EQ referred_index_name.c_str() AND (CRT.RDB$CONSTRAINT_TYPE = PRIMARY_KEY OR CRT.RDB$CONSTRAINT_TYPE = UNIQUE_CNSTRT) - - if (!DYN_REQUEST(drq_l_intg_con)) - DYN_REQUEST(drq_l_intg_con) = request; - + { fb_utils::exact_name_limit(CRT.RDB$CONSTRAINT_NAME, sizeof(CRT.RDB$CONSTRAINT_NAME)); strcpy(REF.RDB$CONST_NAME_UQ, CRT.RDB$CONSTRAINT_NAME); strcpy(REF.RDB$CONSTRAINT_NAME, constraint_name.c_str()); @@ -703,7 +662,6 @@ void DYN_define_constraint(Global* gbl, // RESTRICT is the default value for this column strcpy(REF.RDB$UPDATE_RULE, RI_RESTRICT); - REF.RDB$DELETE_RULE.NULL = FALSE; if (ri_action & FOR_KEY_DEL_CASCADE) strcpy(REF.RDB$DELETE_RULE, RI_ACTION_CASCADE); @@ -716,16 +674,12 @@ void DYN_define_constraint(Global* gbl, else // RESTRICT is the default value for this column strcpy(REF.RDB$DELETE_RULE, RI_RESTRICT); + } + END_FOR - END_FOR; - if (!DYN_REQUEST(drq_l_intg_con)) - DYN_REQUEST(drq_l_intg_con) = request; - request = old_request; id = old_id; - END_STORE; - - if (!DYN_REQUEST(drq_s_ref_con)) - DYN_REQUEST(drq_s_ref_con) = request; + } + END_STORE } } // try @@ -762,8 +716,6 @@ void DYN_define_constraint(Global* gbl, break; } - DYN_rundown_request(request, local_id); - DYN_error_punt(true, number, number == 124 ? constraint_name.c_str() : NULL); } @@ -799,17 +751,18 @@ void DYN_define_dimension(Global* gbl, thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_s_dims, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_dims, DYN_REQUESTS); bool b_ending_store = false; - try { - + try + { STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) DIM IN RDB$FIELD_DIMENSIONS DIM.RDB$UPPER_BOUND.NULL = TRUE; DIM.RDB$LOWER_BOUND.NULL = TRUE; DIM.RDB$DIMENSION = (SSHORT)DYN_get_number(ptr); + { if (field_name) { strcpy(DIM.RDB$FIELD_NAME, field_name->c_str()); } @@ -840,24 +793,20 @@ void DYN_define_dimension(Global* gbl, } b_ending_store = true; - - END_STORE; + } + END_STORE } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - if (b_ending_store) { - DYN_rundown_request(request, drq_s_dims); + if (b_ending_store) + { DYN_error_punt(true, 3); // msg 3: "STORE RDB$FIELD_DIMENSIONS failed" } throw; } - - if (!DYN_REQUEST(drq_s_dims)) { - DYN_REQUEST(drq_s_dims) = request; - } } @@ -889,7 +838,7 @@ void DYN_define_exception( Global* gbl, const UCHAR** ptr) DYN_UTIL_check_unique_name(tdbb, gbl->gbl_transaction, exception_name, obj_exception); - jrd_req* request = CMP_find_request(tdbb, drq_s_xcp, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_xcp, DYN_REQUESTS); const UCHAR* message_ptr = NULL; @@ -923,7 +872,7 @@ void DYN_define_exception( Global* gbl, const UCHAR** ptr) STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$EXCEPTIONS - + { X.RDB$EXCEPTION_NUMBER = xcp_id; strcpy(X.RDB$EXCEPTION_NAME, exception_name.c_str()); @@ -939,16 +888,13 @@ void DYN_define_exception( Global* gbl, const UCHAR** ptr) } b_ending_store = true; - - END_STORE; + } + END_STORE break; } catch (const Firebird::status_exception& ex) { - if (b_ending_store) - DYN_rundown_request(request, drq_s_xcp); - if (ex.value()[1] != isc_no_dup) throw; @@ -959,20 +905,10 @@ void DYN_define_exception( Global* gbl, const UCHAR** ptr) fb_utils::init_status(tdbb->tdbb_status_vector); } } - - if (!DYN_REQUEST(drq_s_xcp)) { - DYN_REQUEST(drq_s_xcp) = request; - } - } // try catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - if (b_ending_store) - { - DYN_error_punt(true, 142); - // msg 142: "DEFINE EXCEPTION failed" - } throw; } @@ -1010,8 +946,6 @@ void DYN_define_file(Global* gbl, ERR_post(Arg::Gds(isc_adm_task_denied)); } - jrd_req* request = NULL; - try { id = -1; @@ -1020,30 +954,23 @@ void DYN_define_file(Global* gbl, if (!ISC_expand_filename(temp_f, false)) DYN_error_punt(false, 231); // File name is invalid. - request = CMP_find_request(tdbb, id = drq_l_files, DYN_REQUESTS); - - if (dbb->dbb_filename == temp_f) { + if (dbb->dbb_filename == temp_f) DYN_error_punt(false, 166); - } + + AutoCacheRequest request(tdbb, id = drq_l_files, DYN_REQUESTS); FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) FIRST 1 X IN RDB$FILES WITH X.RDB$FILE_NAME EQ temp_f.c_str() - if (!DYN_REQUEST(drq_l_files)) - DYN_REQUEST(drq_l_files) = request; - + { DYN_error_punt(false, 166); - END_FOR; + } + END_FOR - if (!DYN_REQUEST(drq_l_files)) - DYN_REQUEST(drq_l_files) = request; - - request = CMP_find_request(tdbb, id = drq_s_files, DYN_REQUESTS); + request.reset(tdbb, id = drq_s_files, DYN_REQUESTS); STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$FILES - if (!DYN_REQUEST(drq_s_files)) - DYN_REQUEST(drq_s_files) = request; - + { temp_f.copyTo(X.RDB$FILE_NAME, sizeof(X.RDB$FILE_NAME)); X.RDB$SHADOW_NUMBER = (SSHORT)shadow_number; X.RDB$FILE_FLAGS = 0; @@ -1082,27 +1009,17 @@ void DYN_define_file(Global* gbl, } } *start += X.RDB$FILE_LENGTH; - END_STORE; - - if (!DYN_REQUEST(drq_s_files)) - DYN_REQUEST(drq_s_files) = request; + } + END_STORE } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (id == drq_l_files) - { - DYN_rundown_request(request, drq_l_files); DYN_error_punt(false, 166); - } else - { - if (id != -1) - DYN_rundown_request(request, drq_s_files); - DYN_error_punt(true, msg); - } } } @@ -1124,7 +1041,6 @@ void DYN_define_difference(Global* gbl, const UCHAR** ptr) thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = NULL; if (!tdbb->getAttachment()->locksmith()) { @@ -1135,25 +1051,24 @@ void DYN_define_difference(Global* gbl, const UCHAR** ptr) { bool found = false; id = drq_l_difference; - request = CMP_find_request(tdbb, drq_l_difference, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_l_difference, DYN_REQUESTS); FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) FIL IN RDB$FILES + { if (FIL.RDB$FILE_FLAGS & FILE_difference) found = true; - END_FOR; - - if (!DYN_REQUEST(drq_l_difference)) { - DYN_REQUEST(drq_l_difference) = request; } + END_FOR - if (found) { + if (found) goto dyn_punt_216; - } - request = CMP_find_request(tdbb, drq_s_difference, DYN_REQUESTS); + request.reset(tdbb, drq_s_difference, DYN_REQUESTS); id = drq_s_difference; + STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$FILES + { GET_STRING(ptr, X.RDB$FILE_NAME); X.RDB$FILE_FLAGS = FILE_difference; X.RDB$FILE_FLAGS.NULL = FALSE; @@ -1161,23 +1076,19 @@ void DYN_define_difference(Global* gbl, const UCHAR** ptr) X.RDB$FILE_START.NULL = FALSE; X.RDB$FILE_LENGTH.NULL = TRUE; X.RDB$SHADOW_NUMBER.NULL = TRUE; - END_STORE; - - if (!DYN_REQUEST(drq_s_difference)) - DYN_REQUEST(drq_s_difference) = request; + } + END_STORE } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (id == drq_s_difference) { - DYN_rundown_request(request, drq_s_difference); DYN_error_punt(true, 150); // msg 150: STORE RDB$FILES failed } else { - DYN_rundown_request(request, drq_l_difference); DYN_error_punt(true, 156); // msg 156: Difference file lookup failed } @@ -1210,7 +1121,7 @@ void DYN_define_filter( Global* gbl, const UCHAR** ptr) Firebird::MetaName filter_name; GET_STRING(ptr, filter_name); - jrd_req* request = CMP_find_request(tdbb, drq_s_filters, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_filters, DYN_REQUESTS); bool b_ending_store = false; @@ -1225,7 +1136,7 @@ void DYN_define_filter( Global* gbl, const UCHAR** ptr) X.RDB$ENTRYPOINT.NULL = TRUE; X.RDB$SYSTEM_FLAG = 0; X.RDB$SYSTEM_FLAG.NULL = FALSE; - + { UCHAR verb; while ((verb = *(*ptr)++) != isc_dyn_end) { @@ -1255,19 +1166,14 @@ void DYN_define_filter( Global* gbl, const UCHAR** ptr) DYN_unsupported_verb(); } } - - END_STORE; - - if (!DYN_REQUEST(drq_s_filters)) { - DYN_REQUEST(drq_s_filters) = request; } + END_STORE } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (b_ending_store) { - DYN_rundown_request(request, drq_s_filters); DYN_error_punt(true, 7); // msg 7: "DEFINE BLOB FILTER failed" } @@ -1298,7 +1204,7 @@ void DYN_define_function( Global* gbl, const UCHAR** ptr) DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, DDL_TRIGGER_CREATE_FUNCTION, function_name, gbl->sqlText); - jrd_req* request = CMP_find_request(tdbb, drq_s_funcs, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_funcs, DYN_REQUESTS); bool b_ending_store = false; @@ -1306,6 +1212,7 @@ void DYN_define_function( Global* gbl, const UCHAR** ptr) STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$FUNCTIONS USING + { strcpy(X.RDB$FUNCTION_NAME, function_name.c_str()); X.RDB$RETURN_ARGUMENT.NULL = TRUE; X.RDB$QUERY_NAME.NULL = TRUE; @@ -1356,18 +1263,14 @@ void DYN_define_function( Global* gbl, const UCHAR** ptr) } b_ending_store = true; - END_STORE; - - if (!DYN_REQUEST(drq_s_funcs)) { - DYN_REQUEST(drq_s_funcs) = request; } + END_STORE } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (b_ending_store) { - DYN_rundown_request(request, drq_s_funcs); DYN_error_punt(true, 10); // msg 10: "DEFINE FUNCTION failed" } @@ -1392,17 +1295,16 @@ void DYN_define_function_arg(Global* gbl, const UCHAR** ptr, Firebird::MetaName* * **************************************/ - jrd_req* request = NULL; - thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); try { - request = CMP_find_request(tdbb, drq_s_func_args, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_func_args, DYN_REQUESTS); STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$FUNCTION_ARGUMENTS + { X.RDB$ARGUMENT_POSITION = (SSHORT)DYN_get_number(ptr); if (X.RDB$ARGUMENT_POSITION > MAX_UDF_ARGUMENTS) @@ -1479,20 +1381,12 @@ void DYN_define_function_arg(Global* gbl, const UCHAR** ptr, Firebird::MetaName* default: DYN_unsupported_verb(); } - - END_STORE; - - if (!DYN_REQUEST(drq_s_func_args)) { - DYN_REQUEST(drq_s_func_args) = request; } - + END_STORE } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - if (request) { - DYN_rundown_request(request, drq_s_func_args); - } DYN_error_punt(true, 12); // msg 12: "DEFINE FUNCTION ARGUMENT failed" } @@ -1530,7 +1424,7 @@ void DYN_define_global_field(Global* gbl, DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, DDL_TRIGGER_CREATE_DOMAIN, global_field_name, gbl->sqlText); - jrd_req* request = CMP_find_request(tdbb, drq_s_gfields, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_gfields, DYN_REQUESTS); bool b_ending_store = false; @@ -1538,7 +1432,7 @@ void DYN_define_global_field(Global* gbl, STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) FLD IN RDB$FIELDS USING - + { strcpy(FLD.RDB$FIELD_NAME, global_field_name.c_str()); FLD.RDB$SYSTEM_FLAG = 0; @@ -1738,12 +1632,8 @@ void DYN_define_global_field(Global* gbl, } b_ending_store = true; - - END_STORE; - - if (!DYN_REQUEST(drq_s_gfields)) { - DYN_REQUEST(drq_s_gfields) = request; } + END_STORE } // try catch (const Firebird::Exception& ex) @@ -1751,7 +1641,6 @@ void DYN_define_global_field(Global* gbl, Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (b_ending_store) { - DYN_rundown_request(request, drq_s_gfields); DYN_error_punt(true, 13); // msg 13: "STORE RDB$FIELDS failed" } @@ -1806,7 +1695,6 @@ void DYN_define_index(Global* gbl, DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, DDL_TRIGGER_CREATE_INDEX, index_name, gbl->sqlText); - jrd_req* request = NULL; SSHORT id = -1; try { @@ -1814,14 +1702,14 @@ void DYN_define_index(Global* gbl, id = drq_l_idx_name; DYN_UTIL_check_unique_name(tdbb, gbl->gbl_transaction, index_name, obj_index); - request = CMP_find_request(tdbb, drq_s_indices, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_indices, DYN_REQUESTS); id = drq_s_indices; ULONG key_length = 0; - jrd_req* old_request = NULL; STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) IDX IN RDB$INDICES + { IDX.RDB$UNIQUE_FLAG.NULL = TRUE; IDX.RDB$INDEX_INACTIVE.NULL = TRUE; IDX.RDB$INDEX_TYPE.NULL = TRUE; @@ -1845,39 +1733,32 @@ void DYN_define_index(Global* gbl, // Check if the table is actually a view - old_request = request; SSHORT old_id = id; - request = CMP_find_request(tdbb, drq_l_view_idx, DYN_REQUESTS); + AutoCacheRequest request2(tdbb, drq_l_view_idx, DYN_REQUESTS); id = drq_l_view_idx; - FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) + FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) VREL IN RDB$RELATIONS WITH VREL.RDB$RELATION_NAME EQ IDX.RDB$RELATION_NAME - - if (!DYN_REQUEST(drq_l_view_idx)) - DYN_REQUEST(drq_l_view_idx) = request; - + { if (!VREL.RDB$VIEW_BLR.NULL) DYN_error_punt(false, 181); // msg 181: "attempt to index a view" + } + END_FOR - END_FOR; - if (!DYN_REQUEST(drq_l_view_idx)) - DYN_REQUEST(drq_l_view_idx) = request; - - request = old_request; id = old_id; // The previous 2 lines and the next two lines can be // deleted as long as no code is added in the middle. - old_request = request; old_id = id; - request = CMP_find_request(tdbb, drq_l_lfield, DYN_REQUESTS); + request2.reset(tdbb, drq_l_lfield, DYN_REQUESTS); id = drq_l_lfield; ULONG referred_cols = 0; while ((verb = *(*ptr)++) != isc_dyn_end) + { switch (verb) { case isc_dyn_idx_unique: @@ -1911,17 +1792,13 @@ void DYN_define_index(Global* gbl, seg_count++; - FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) + FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) F IN RDB$RELATION_FIELDS CROSS GF IN RDB$FIELDS WITH GF.RDB$FIELD_NAME EQ F.RDB$FIELD_SOURCE AND F.RDB$FIELD_NAME EQ str.c_str() AND IDX.RDB$RELATION_NAME EQ F.RDB$RELATION_NAME - + { ULONG length = 0; - if (!DYN_REQUEST(drq_l_lfield)) - { - DYN_REQUEST(drq_l_lfield) = request; - } fld_count++; if (GF.RDB$FIELD_TYPE == blr_blob) @@ -1975,9 +1852,9 @@ void DYN_define_index(Global* gbl, { key_length = length; } - END_FOR; - if (!DYN_REQUEST(drq_l_lfield)) - DYN_REQUEST(drq_l_lfield) = request; + } + END_FOR + break; } @@ -2101,7 +1978,8 @@ void DYN_define_index(Global* gbl, default: DYN_unsupported_verb(); } - request = old_request; + } + id = old_id; key_length = ROUNDUP(key_length, sizeof(SLONG)); @@ -2113,23 +1991,23 @@ void DYN_define_index(Global* gbl, if (seg_count != fld_count) DYN_error_punt(false, 120, IDX.RDB$INDEX_NAME); // msg 118 "Unknown fields in index %s" - old_request = request; old_id = id; - request = CMP_find_request(tdbb, drq_s_idx_segs, DYN_REQUESTS); + request2.reset(tdbb, drq_s_idx_segs, DYN_REQUESTS); id = drq_s_idx_segs; + while (seg_list.getCount()) { - STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) + STORE(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$INDEX_SEGMENTS + { strcpy(X.RDB$INDEX_NAME, IDX.RDB$INDEX_NAME); Firebird::MetaName str = seg_list.pop(); strcpy(X.RDB$FIELD_NAME, str.c_str()); X.RDB$FIELD_POSITION = --fld_count; - END_STORE; + } + END_STORE } - if (!DYN_REQUEST(drq_s_idx_segs)) - DYN_REQUEST(drq_s_idx_segs) = request; - request = old_request; + id = old_id; } else if (IDX.RDB$EXPRESSION_BLR.NULL) @@ -2149,15 +2027,14 @@ void DYN_define_index(Global* gbl, // lookup a unique index in the referenced relation with the // referenced fields mentioned - old_request = request; old_id = id; - request = CMP_find_request(tdbb, drq_l_unq_idx, DYN_REQUESTS); + request2.reset(tdbb, drq_l_unq_idx, DYN_REQUESTS); id = drq_l_unq_idx; index_name = ""; int list_index = -1; bool found = false; - FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) + FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) RC IN RDB$RELATION_CONSTRAINTS CROSS IND IN RDB$INDICES OVER RDB$INDEX_NAME CROSS ISEG IN RDB$INDEX_SEGMENTS OVER RDB$INDEX_NAME WITH @@ -2167,19 +2044,13 @@ void DYN_define_index(Global* gbl, RC.RDB$CONSTRAINT_TYPE = UNIQUE_CNSTRT) SORTED BY IND.RDB$INDEX_NAME, DESCENDING ISEG.RDB$FIELD_POSITION - - if (!DYN_REQUEST(drq_l_unq_idx)) - DYN_REQUEST(drq_l_unq_idx) = request; - + { if (index_name != IND.RDB$INDEX_NAME) { if (list_index >= 0) found = false; if (found) - { - EXE_unwind(tdbb, request); break; - } list_index = field_list.getCount() - 1; index_name = IND.RDB$INDEX_NAME; found = true; @@ -2198,11 +2069,9 @@ void DYN_define_index(Global* gbl, } else found = false; + } + END_FOR - END_FOR; - if (!DYN_REQUEST(drq_l_unq_idx)) - DYN_REQUEST(drq_l_unq_idx) = request; - request = old_request; id = old_id; if (list_index >= 0) @@ -2218,18 +2087,20 @@ void DYN_define_index(Global* gbl, } else { - jrd_req* request2 = NULL; + jrd_req* request3 = NULL; found = false; bool isView = false; - FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) + FOR(REQUEST_HANDLE request3 TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$RELATIONS WITH X.RDB$RELATION_NAME EQ referenced_relation.c_str() + { found = true; isView = !X.RDB$VIEW_BLR.NULL; + } END_FOR - CMP_release(tdbb, request2); + CMP_release(tdbb, request3); if (isView) { @@ -2251,20 +2122,17 @@ void DYN_define_index(Global* gbl, } else if (referenced_relation.length()) { - old_request = request; old_id = id; - request = CMP_find_request(tdbb, drq_l_primary, DYN_REQUESTS); + request2.reset(tdbb, drq_l_primary, DYN_REQUESTS); id = drq_l_primary; - FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) + FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) IND IN RDB$INDICES CROSS RC IN RDB$RELATION_CONSTRAINTS OVER RDB$INDEX_NAME WITH IND.RDB$RELATION_NAME EQ referenced_relation.c_str() AND RC.RDB$CONSTRAINT_TYPE EQ PRIMARY_KEY - if (!DYN_REQUEST(drq_l_primary)) - DYN_REQUEST(drq_l_primary) = request; - + { // Number of columns in referred index should be same as number // of columns in referring index @@ -2278,11 +2146,9 @@ void DYN_define_index(Global* gbl, IDX.RDB$FOREIGN_KEY.NULL = FALSE; if (referred_index_name) *referred_index_name = IND.RDB$INDEX_NAME; + } + END_FOR - END_FOR; - if (!DYN_REQUEST(drq_l_primary)) - DYN_REQUEST(drq_l_primary) = request; - request = old_request; id = old_id; if (IDX.RDB$FOREIGN_KEY.NULL) @@ -2293,11 +2159,8 @@ void DYN_define_index(Global* gbl, } IDX.RDB$SEGMENT_COUNT = seg_count; - END_STORE; - - if (!DYN_REQUEST(drq_s_indices)) { - DYN_REQUEST(drq_s_indices) = request; } + END_STORE } // try catch (const Firebird::Exception& ex) @@ -2305,19 +2168,15 @@ void DYN_define_index(Global* gbl, Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (id == drq_s_indices) { - DYN_rundown_request(request, id); DYN_error_punt(true, 21); // msg 21: "STORE RDB$INDICES failed" } else if (id == drq_s_idx_segs) { - DYN_rundown_request(request, id); DYN_error_punt(true, 15); // msg 15: "STORE RDB$INDEX_SEGMENTS failed" } - DYN_rundown_request(request, -1); - switch (id) { case drq_l_idx_name: @@ -2377,12 +2236,11 @@ void DYN_define_local_field(Global* gbl, Firebird::MetaName local_field_name; GET_STRING(ptr, local_field_name); - jrd_req* request = NULL; SSHORT id = -1; try { - request = CMP_find_request(tdbb, drq_s_lfields, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_lfields, DYN_REQUESTS); id = drq_s_lfields; bool lflag, sflag, slflag, scflag, clflag, prflag; @@ -2394,6 +2252,7 @@ void DYN_define_local_field(Global* gbl, STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) RFR IN RDB$RELATION_FIELDS + { strcpy(RFR.RDB$FIELD_NAME, local_field_name.c_str()); strcpy(RFR.RDB$FIELD_SOURCE, RFR.RDB$FIELD_NAME); if (field_name) { @@ -2615,13 +2474,13 @@ void DYN_define_local_field(Global* gbl, if (blr) { - jrd_req* old_request = request; const SSHORT old_id = id; - request = CMP_find_request(tdbb, drq_s_gfields2, DYN_REQUESTS); + AutoCacheRequest request2(tdbb, drq_s_gfields2, DYN_REQUESTS); + id = drq_s_gfields2; - STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) + STORE(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) FLD IN RDB$FIELDS - + { FLD.RDB$SYSTEM_FLAG = 0; FLD.RDB$SYSTEM_FLAG.NULL = FALSE; strcpy(FLD.RDB$FIELD_NAME, RFR.RDB$FIELD_SOURCE); @@ -2680,12 +2539,9 @@ void DYN_define_local_field(Global* gbl, } else FLD.RDB$CHARACTER_SET_ID.NULL = TRUE; + } + END_STORE - END_STORE; - - if (!DYN_REQUEST(drq_s_gfields2)) - DYN_REQUEST(drq_s_gfields2) = request; - request = old_request; id = old_id; } @@ -2695,11 +2551,8 @@ void DYN_define_local_field(Global* gbl, DYN_UTIL_find_field_source(tdbb, gbl, *relation_name, RFR.RDB$VIEW_CONTEXT, RFR.RDB$BASE_FIELD, RFR.RDB$FIELD_SOURCE); } - END_STORE; - - if (!DYN_REQUEST(drq_s_lfields)) { - DYN_REQUEST(drq_s_lfields) = request; } + END_STORE } // try catch (const Firebird::Exception& ex) @@ -2707,13 +2560,11 @@ void DYN_define_local_field(Global* gbl, Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (id == drq_s_lfields) { - DYN_rundown_request(request, id); DYN_error_punt(true, 23); // msg 23: "STORE RDB$RELATION_FIELDS failed" } else { - DYN_rundown_request(request, id); DYN_error_punt(true, 22); // msg 22: "STORE RDB$FIELDS failed" } @@ -2745,7 +2596,6 @@ void DYN_define_relation(Global* gbl, const UCHAR** ptr, bool view) DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, (view ? DDL_TRIGGER_CREATE_VIEW : DDL_TRIGGER_CREATE_TABLE), relation_name, gbl->sqlText); - jrd_req* request = NULL; SSHORT id = -1; Firebird::PathName Path, Name; @@ -2757,11 +2607,12 @@ void DYN_define_relation(Global* gbl, const UCHAR** ptr, bool view) bool sql_prot = false; rel_t rel_type = rel_persistent; - request = CMP_find_request(tdbb, drq_s_rels, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_rels, DYN_REQUESTS); id = drq_s_rels; STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) REL IN RDB$RELATIONS + { strcpy(REL.RDB$RELATION_NAME, relation_name.c_str()); REL.RDB$SYSTEM_FLAG = 0; REL.RDB$SYSTEM_FLAG.NULL = FALSE; @@ -2869,19 +2720,16 @@ void DYN_define_relation(Global* gbl, const UCHAR** ptr, bool view) if (rel_type == rel_view) { - jrd_req* old_request = request; const SSHORT old_id2 = id; - request = CMP_find_request(tdbb, drq_l_view_rels, DYN_REQUESTS); + AutoCacheRequest request2(tdbb, drq_l_view_rels, DYN_REQUESTS); id = drq_l_view_rels; - FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) + FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) VRL IN RDB$VIEW_RELATIONS CROSS PREL IN RDB$RELATIONS OVER RDB$RELATION_NAME WITH VRL.RDB$PACKAGE_NAME MISSING AND VRL.RDB$VIEW_NAME EQ relation_name.c_str() - if (!DYN_REQUEST(drq_l_view_rels)) - DYN_REQUEST(drq_l_view_rels) = request; - + { // CVC: This never matches so it causes unnecessary calls to verify, // so I included a call to strip trailing blanks. fb_utils::exact_name_limit(PREL.RDB$OWNER_NAME, sizeof(PREL.RDB$OWNER_NAME)); @@ -2908,27 +2756,25 @@ void DYN_define_relation(Global* gbl, const UCHAR** ptr, bool view) // msg 115: "CREATE VIEW failed" } } - END_FOR; - if (!DYN_REQUEST(drq_l_view_rels)) - DYN_REQUEST(drq_l_view_rels) = request; - request = old_request; + } + END_FOR + id = old_id2; } } - END_STORE; - - if (!DYN_REQUEST(drq_s_rels)) - DYN_REQUEST(drq_s_rels) = request; + } + END_STORE if (sql_prot) { for (const TEXT* p = ALL_PRIVILEGES; *p; p++) { - request = CMP_find_request(tdbb, drq_s_usr_prvs, DYN_REQUESTS); + request.reset(tdbb, drq_s_usr_prvs, DYN_REQUESTS); id = drq_s_usr_prvs; STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$USER_PRIVILEGES + { strcpy(X.RDB$RELATION_NAME, relation_name.c_str()); strcpy(X.RDB$USER, owner_name.c_str()); X.RDB$USER_TYPE = obj_user; @@ -2936,10 +2782,8 @@ void DYN_define_relation(Global* gbl, const UCHAR** ptr, bool view) X.RDB$PRIVILEGE[0] = *p; X.RDB$PRIVILEGE[1] = 0; X.RDB$GRANT_OPTION = 1; - END_STORE; - - if (!DYN_REQUEST(drq_s_usr_prvs)) - DYN_REQUEST(drq_s_usr_prvs) = request; + } + END_STORE } } @@ -2949,19 +2793,15 @@ void DYN_define_relation(Global* gbl, const UCHAR** ptr, bool view) Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (id == drq_s_rels) { - DYN_rundown_request(request, id); DYN_error_punt(true, 24); // msg 24: "STORE RDB$RELATIONS failed" } else if (id == drq_s_usr_prvs) { - DYN_rundown_request(request, id); DYN_error_punt(true, 25); // msg 25: "STORE RDB$USER_PRIVILEGES failed defining a relation" } - DYN_rundown_request(request, -1); - switch (id) { case drq_l_rel_name: @@ -3000,8 +2840,6 @@ void DYN_define_role( Global* gbl, const UCHAR** ptr) * ROLES cannot be named the same as any existing user name * **************************************/ - jrd_req* request = NULL; - thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); @@ -3045,30 +2883,24 @@ void DYN_define_role( Global* gbl, const UCHAR** ptr) goto do_err_punt; } - request = CMP_find_request(tdbb, drq_role_gens, DYN_REQUESTS); + 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 (!DYN_REQUEST(drq_role_gens)) { - DYN_REQUEST(drq_role_gens) = request; } + END_STORE - if (*(*ptr)++ != isc_dyn_end) { + if (*(*ptr)++ != isc_dyn_end) goto do_error_punt_9; - } } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - if (request) { - DYN_rundown_request(request, drq_role_gens); - } DYN_error_punt(true, 8); // msg 8: "DEFINE ROLE failed" } @@ -3114,17 +2946,16 @@ void DYN_define_sql_field(Global* gbl, Firebird::MetaName sql_field_name; GET_STRING(ptr, sql_field_name); - jrd_req* request = NULL; SSHORT id = -1; try { - request = CMP_find_request(tdbb, drq_s_sql_lfld, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_sql_lfld, DYN_REQUESTS); id = drq_s_sql_lfld; - jrd_req* old_request = NULL; STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) RFR IN RDB$RELATION_FIELDS + { strcpy(RFR.RDB$FIELD_NAME, sql_field_name.c_str()); if (field_name) *field_name = RFR.RDB$FIELD_NAME; @@ -3146,13 +2977,13 @@ void DYN_define_sql_field(Global* gbl, RFR.RDB$GENERATOR_NAME.NULL = TRUE; RFR.RDB$IDENTITY_TYPE.NULL = TRUE; - old_request = request; const SSHORT old_id = id; - request = CMP_find_request(tdbb, drq_s_sql_gfld, DYN_REQUESTS); + AutoCacheRequest request2(tdbb, drq_s_sql_gfld, DYN_REQUESTS); id = drq_s_sql_gfld; - STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) + STORE(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) FLD IN RDB$FIELDS + { FLD.RDB$SYSTEM_FLAG = 0; FLD.RDB$SYSTEM_FLAG.NULL = FALSE; FLD.RDB$FIELD_SCALE.NULL = TRUE; @@ -3397,17 +3228,12 @@ void DYN_define_sql_field(Global* gbl, RFR.RDB$FIELD_POSITION.NULL = FALSE; } } + } + END_STORE - END_STORE; - - if (!DYN_REQUEST(drq_s_sql_gfld)) - DYN_REQUEST(drq_s_sql_gfld) = request; - request = old_request; id = old_id; - END_STORE; - - if (!DYN_REQUEST(drq_s_sql_lfld)) - DYN_REQUEST(drq_s_sql_lfld) = request; + } + END_STORE } catch (const Firebird::Exception& ex) @@ -3415,13 +3241,11 @@ void DYN_define_sql_field(Global* gbl, Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (id == drq_s_sql_lfld) { - DYN_rundown_request(request, id); DYN_error_punt(true, 29); // msg 29: "STORE RDB$RELATION_FIELDS failed" } else { - DYN_rundown_request(request, id); DYN_error_punt(true, 28); // msg 28: "STORE RDB$FIELDS failed" } @@ -3451,23 +3275,20 @@ void DYN_define_shadow( Global* gbl, const UCHAR** ptr) // If a shadow set identified by the shadow number already exists return error. - jrd_req* request = CMP_find_request(tdbb, drq_l_shadow, DYN_REQUESTS); - - try { + AutoCacheRequest request(tdbb, drq_l_shadow, DYN_REQUESTS); + try + { FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) FIRST 1 X IN RDB$FILES WITH X.RDB$SHADOW_NUMBER EQ shadow_number - found = true; - END_FOR; - - if (!DYN_REQUEST(drq_l_shadow)) { - DYN_REQUEST(drq_l_shadow) = request; + { + found = true; } + END_FOR } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - DYN_rundown_request(request, drq_l_shadow); DYN_error_punt(true, 164); // msg 164: "Shadow lookup failed" } @@ -3532,7 +3353,7 @@ void DYN_define_trigger(Global* gbl, if (trigger_name) *trigger_name = t; - jrd_req* request = CMP_find_request(tdbb, drq_s_triggers, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_triggers, DYN_REQUESTS); bool b_ending_store = false; const UCHAR* debug_info_ptr = NULL; @@ -3541,6 +3362,7 @@ void DYN_define_trigger(Global* gbl, STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$TRIGGERS + { X.RDB$TRIGGER_TYPE.NULL = TRUE; X.RDB$TRIGGER_SEQUENCE = 0; X.RDB$TRIGGER_SEQUENCE.NULL = FALSE; @@ -3675,23 +3497,18 @@ void DYN_define_trigger(Global* gbl, // after the request is compiled and before the request is sent. // It makes the current request (to define the trigger) go through // without checking any permissions lower in the engine - - END_STORE_SPECIAL; + } + END_STORE_SPECIAL if (ignore_perm) request->req_flags &= ~req_ignore_perm; - if (!DYN_REQUEST(drq_s_triggers)) { - DYN_REQUEST(drq_s_triggers) = request; - } - } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (b_ending_store) { - DYN_rundown_request(request, drq_s_triggers); DYN_error_punt(true, 31); // msg 31: "DEFINE TRIGGER failed" } @@ -3718,7 +3535,7 @@ void DYN_define_view_relation( Global* gbl, const UCHAR** ptr, const Firebird::M fb_assert(view); - jrd_req* request = CMP_find_request(tdbb, drq_s_view_rels, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_s_view_rels, DYN_REQUESTS); SSHORT id = drq_s_view_rels; bool b_ending_store = false; @@ -3727,6 +3544,7 @@ void DYN_define_view_relation( Global* gbl, const UCHAR** ptr, const Firebird::M { STORE(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) VRL IN RDB$VIEW_RELATIONS + { strcpy(VRL.RDB$VIEW_NAME, view->c_str()); GET_STRING(ptr, VRL.RDB$RELATION_NAME); VRL.RDB$CONTEXT_NAME.NULL = TRUE; @@ -3769,18 +3587,14 @@ void DYN_define_view_relation( Global* gbl, const UCHAR** ptr, const Firebird::M } b_ending_store = true; - END_STORE; - - if (!DYN_REQUEST(drq_s_view_rels)) { - DYN_REQUEST(drq_s_view_rels) = request; } + END_STORE } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); if (b_ending_store) { - DYN_rundown_request(request, id); if (id == drq_s_view_rels) { DYN_error_punt(true, 34); @@ -3806,7 +3620,6 @@ bool is_it_user_name(Global* gbl, const Firebird::MetaName& role_name, thread_db * **************************************/ - jrd_req* request; USHORT request_id; SET_TDBB(tdbb); @@ -3819,48 +3632,40 @@ bool is_it_user_name(Global* gbl, const Firebird::MetaName& role_name, thread_db // can infer there is a user with this name request_id = drq_get_user_priv; - request = CMP_find_request(tdbb, request_id, DYN_REQUESTS); + 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 (!DYN_REQUEST(drq_get_user_priv)) - DYN_REQUEST(drq_get_user_priv) = request; - - if (found) { - return found; } + 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 = CMP_find_request(tdbb, request_id, DYN_REQUESTS); + 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; - - if (!DYN_REQUEST(drq_get_rel_owner)) { - DYN_REQUEST(drq_get_rel_owner) = request; } + END_FOR } catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - if (request) { - DYN_rundown_request(request, request_id); - } ERR_punt(); } @@ -3874,22 +3679,16 @@ static rel_t get_relation_type(thread_db* tdbb, Global* gbl, const Firebird::Met rel_t rel_type = rel_persistent; - jrd_req* request = CMP_find_request(tdbb, drq_l_rel_type, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_l_rel_type, DYN_REQUESTS); FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) REL IN RDB$RELATIONS WITH REL.RDB$RELATION_NAME EQ rel_name.c_str() AND REL.RDB$RELATION_TYPE NOT MISSING - - if (!DYN_REQUEST(drq_l_rel_type)) - DYN_REQUEST(drq_l_rel_type) = request; - + { rel_type = (rel_t) REL.RDB$RELATION_TYPE; - - END_FOR; - - if (!DYN_REQUEST(drq_l_rel_type)) - DYN_REQUEST(drq_l_rel_type) = request; + } + END_FOR return rel_type; } @@ -3911,7 +3710,7 @@ static void check_foreign_key_temp_scope(thread_db* tdbb, Global* gbl, **********************************************************/ Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_l_rel_info, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_l_rel_info, DYN_REQUESTS); bool bErr = false; Firebird::string sMaster, sChild; @@ -3924,10 +3723,7 @@ static void check_foreign_key_temp_scope(thread_db* tdbb, Global* gbl, AND RLC_M.RDB$INDEX_NAME EQ master_index_name AND REL_C.RDB$RELATION_NAME EQ child_rel_name AND REL_M.RDB$RELATION_NAME EQ RLC_M.RDB$RELATION_NAME - - if (!DYN_REQUEST(drq_l_rel_info)) - DYN_REQUEST(drq_l_rel_info) = request; - + { const rel_t master_type = get_relation_type(tdbb, gbl, REL_M.RDB$RELATION_NAME); fb_assert(master_type == rel_persistent || master_type == rel_global_temp_preserve || @@ -3950,10 +3746,8 @@ static void check_foreign_key_temp_scope(thread_db* tdbb, Global* gbl, make_relation_scope_name(REL_M.RDB$RELATION_NAME, master_type, sMaster); make_relation_scope_name(REL_C.RDB$RELATION_NAME, child_type, sChild); } - END_FOR; - - if (!DYN_REQUEST(drq_l_rel_info)) - DYN_REQUEST(drq_l_rel_info) = request; + } + END_FOR if (bErr) { @@ -3986,7 +3780,7 @@ static void check_relation_temp_scope(thread_db* tdbb, Global* gbl, return; } - jrd_req* request = CMP_find_request(tdbb, drq_l_rel_info2, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_l_rel_info2, DYN_REQUESTS); bool bErr = false; Firebird::string sMaster, sChild; @@ -4000,10 +3794,7 @@ static void check_relation_temp_scope(thread_db* tdbb, Global* gbl, AND IND_C.RDB$INDEX_NAME EQ RLC_C.RDB$INDEX_NAME AND IND_M.RDB$INDEX_NAME EQ IND_C.RDB$FOREIGN_KEY AND IND_M.RDB$RELATION_NAME EQ REL_M.RDB$RELATION_NAME - - if (!DYN_REQUEST(drq_l_rel_info2)) - DYN_REQUEST(drq_l_rel_info2) = request; - + { const rel_t master_type = get_relation_type(tdbb, gbl, REL_M.RDB$RELATION_NAME); fb_assert(master_type == rel_persistent || master_type == rel_global_temp_preserve || @@ -4020,10 +3811,8 @@ static void check_relation_temp_scope(thread_db* tdbb, Global* gbl, make_relation_scope_name(REL_M.RDB$RELATION_NAME, master_type, sMaster); make_relation_scope_name(child_rel_name, child_type, sChild); } - END_FOR; - - if (!DYN_REQUEST(drq_l_rel_info2)) - DYN_REQUEST(drq_l_rel_info2) = request; + } + END_FOR if (bErr) { diff --git a/src/jrd/dyn_del.epp b/src/jrd/dyn_del.epp index d7752125fd..e50d92a29c 100644 --- a/src/jrd/dyn_del.epp +++ b/src/jrd/dyn_del.epp @@ -95,8 +95,6 @@ void DYN_delete_collation(Global* gbl, const UCHAR** ptr) thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = NULL; - bool found = false; Firebird::MetaName collName; @@ -104,23 +102,19 @@ void DYN_delete_collation(Global* gbl, const UCHAR** ptr) { GET_STRING(ptr, collName); - request = CMP_find_request(tdbb, drq_e_colls, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_colls, DYN_REQUESTS); FOR (REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) COLL IN RDB$COLLATIONS CROSS CS IN RDB$CHARACTER_SETS WITH COLL.RDB$COLLATION_NAME EQ collName.c_str() AND CS.RDB$CHARACTER_SET_ID EQ COLL.RDB$CHARACTER_SET_ID - - if (!DYN_REQUEST(drq_e_colls)) - DYN_REQUEST(drq_e_colls) = request; - + { DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, DDL_TRIGGER_DROP_COLLATION, collName, gbl->sqlText); if (COLL.RDB$SYSTEM_FLAG == 1) { - DYN_rundown_request(request, -1); DYN_error_punt(false, 237); // msg 237: "Cannot delete system collation" } @@ -132,7 +126,6 @@ void DYN_delete_collation(Global* gbl, const UCHAR** ptr) fb_utils::exact_name_limit(CS.RDB$CHARACTER_SET_NAME, sizeof(CS.RDB$CHARACTER_SET_NAME)); - DYN_rundown_request(request, -1); DYN_error_punt(false, 238, CS.RDB$CHARACTER_SET_NAME); // msg 238: "Cannot delete default collation of CHARACTER SET %s" } @@ -141,84 +134,63 @@ void DYN_delete_collation(Global* gbl, const UCHAR** ptr) fb_utils::exact_name_limit(COLL.RDB$COLLATION_NAME, sizeof(COLL.RDB$COLLATION_NAME)); - jrd_req* request2 = CMP_find_request(tdbb, drq_l_rfld_coll, DYN_REQUESTS); + AutoCacheRequest request2(tdbb, drq_l_rfld_coll, DYN_REQUESTS); FOR (REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) RF IN RDB$RELATION_FIELDS CROSS F IN RDB$FIELDS WITH RF.RDB$FIELD_SOURCE EQ F.RDB$FIELD_NAME AND F.RDB$CHARACTER_SET_ID EQ COLL.RDB$CHARACTER_SET_ID AND RF.RDB$COLLATION_ID EQ COLL.RDB$COLLATION_ID - - if (!DYN_REQUEST(drq_l_rfld_coll)) - DYN_REQUEST(drq_l_rfld_coll) = request2; - + { fb_utils::exact_name_limit(RF.RDB$RELATION_NAME, sizeof(RF.RDB$RELATION_NAME)); fb_utils::exact_name_limit(RF.RDB$FIELD_NAME, sizeof(RF.RDB$FIELD_NAME)); - DYN_rundown_request(request2, -1); DYN_error_punt(false, 235, SafeArg() << COLL.RDB$COLLATION_NAME << RF.RDB$RELATION_NAME << RF.RDB$FIELD_NAME); // msg 235: "Collation %s is used in table %s (field name %s) and cannot be dropped" - END_FOR; + } + END_FOR - if (!DYN_REQUEST(drq_l_rfld_coll)) - DYN_REQUEST(drq_l_rfld_coll) = request2; - - request2 = CMP_find_request(tdbb, drq_l_prm_coll, DYN_REQUESTS); + request2.reset(tdbb, drq_l_prm_coll, DYN_REQUESTS); FOR (REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) PRM IN RDB$PROCEDURE_PARAMETERS CROSS F IN RDB$FIELDS WITH PRM.RDB$FIELD_SOURCE EQ F.RDB$FIELD_NAME AND F.RDB$CHARACTER_SET_ID EQ COLL.RDB$CHARACTER_SET_ID AND PRM.RDB$COLLATION_ID EQ COLL.RDB$COLLATION_ID - - if (!DYN_REQUEST(drq_l_prm_coll)) - DYN_REQUEST(drq_l_prm_coll) = request2; - + { fb_utils::exact_name_limit(PRM.RDB$PARAMETER_NAME, sizeof(PRM.RDB$PARAMETER_NAME)); - DYN_rundown_request(request2, -1); DYN_error_punt(false, 243, SafeArg() << COLL.RDB$COLLATION_NAME << QualifiedName(PRM.RDB$PROCEDURE_NAME, (PRM.RDB$PACKAGE_NAME.NULL ? NULL : PRM.RDB$PACKAGE_NAME)).toString().c_str() << PRM.RDB$PARAMETER_NAME); // msg 243: "Collation %s is used in procedure %s (parameter name %s) and cannot be dropped" - END_FOR; + } + END_FOR - if (!DYN_REQUEST(drq_l_prm_coll)) - DYN_REQUEST(drq_l_prm_coll) = request2; - - request2 = CMP_find_request(tdbb, drq_l_fld_coll, DYN_REQUESTS); + request2.reset(tdbb, drq_l_fld_coll, DYN_REQUESTS); FOR (REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) F IN RDB$FIELDS WITH F.RDB$CHARACTER_SET_ID EQ COLL.RDB$CHARACTER_SET_ID AND F.RDB$COLLATION_ID EQ COLL.RDB$COLLATION_ID - - if (!DYN_REQUEST(drq_l_fld_coll)) - DYN_REQUEST(drq_l_fld_coll) = request2; - + { fb_utils::exact_name_limit(F.RDB$FIELD_NAME, sizeof(F.RDB$FIELD_NAME)); - DYN_rundown_request(request2, -1); DYN_error_punt(false, 236, SafeArg() << COLL.RDB$COLLATION_NAME << F.RDB$FIELD_NAME); // msg 236: "Collation %s is used in domain %s and cannot be dropped" - END_FOR; - - if (!DYN_REQUEST(drq_l_fld_coll)) - DYN_REQUEST(drq_l_fld_coll) = request2; + } + END_FOR ERASE COLL; - END_FOR; - - if (!DYN_REQUEST(drq_e_colls)) - DYN_REQUEST(drq_e_colls) = 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, 233); // msg 234: "ERASE RDB$COLLATIONS failed" } @@ -321,7 +293,7 @@ void DYN_delete_exception( Global* gbl, const UCHAR** ptr) GET_STRING(ptr, t); - jrd_req* request = CMP_find_request(tdbb, drq_e_xcp, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_xcp, DYN_REQUESTS); bool found = false; @@ -331,24 +303,19 @@ void DYN_delete_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_e_xcp)) - DYN_REQUEST(drq_e_xcp) = request; - + { found = true; DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, DDL_TRIGGER_DROP_EXCEPTION, t, gbl->sqlText); ERASE X; - END_FOR; - if (!DYN_REQUEST(drq_e_xcp)) - DYN_REQUEST(drq_e_xcp) = request; - + } + END_FOR } // try catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - DYN_rundown_request(request, -1); DYN_error_punt(true, 143); // msg 143: "ERASE EXCEPTION failed" } @@ -386,7 +353,7 @@ void DYN_delete_filter( Global* gbl, const UCHAR** ptr) thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_e_filters, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_filters, DYN_REQUESTS); bool found = false; @@ -398,19 +365,15 @@ void DYN_delete_filter( Global* gbl, const UCHAR** ptr) found = false; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$FILTERS WITH X.RDB$FUNCTION_NAME = f.c_str() - if (!DYN_REQUEST(drq_e_filters)) - DYN_REQUEST(drq_e_filters) = request; - + { ERASE X; found = true; - END_FOR; - if (!DYN_REQUEST(drq_e_filters)) - DYN_REQUEST(drq_e_filters) = 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, 36); // msg 36: "ERASE BLOB FILTER failed" } @@ -444,29 +407,21 @@ void DYN_delete_generator(Global* gbl, const UCHAR**ptr) thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = NULL; - bool found = false; Firebird::MetaName t; GET_STRING(ptr, t); try { - request = CMP_find_request(tdbb, drq_e_gens, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_gens, DYN_REQUESTS); found = false; FOR (REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$GENERATORS WITH X.RDB$GENERATOR_NAME EQ t.c_str() - - if (!DYN_REQUEST(drq_e_gens)) - DYN_REQUEST(drq_e_gens) = request; - + { if (X.RDB$SYSTEM_FLAG != 0) - { - DYN_rundown_request(request, -1); DYN_error_punt(false, 272); // msg 272: "Cannot delete system generator" - } found = true; @@ -474,15 +429,12 @@ void DYN_delete_generator(Global* gbl, const UCHAR**ptr) DDL_TRIGGER_DROP_SEQUENCE, t, gbl->sqlText); ERASE X; - END_FOR; - - if (!DYN_REQUEST(drq_e_gens)) - DYN_REQUEST(drq_e_gens) = 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, 213); // msg 213: "ERASE GENERATOR failed" } @@ -518,7 +470,7 @@ void DYN_delete_global_field( Global* gbl, const UCHAR** ptr) thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_e_gfields, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_gfields, DYN_REQUESTS); bool found = false; @@ -528,64 +480,51 @@ void DYN_delete_global_field( Global* gbl, const UCHAR** ptr) FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$FIELDS WITH X.RDB$FIELD_NAME EQ f.c_str() - if (!DYN_REQUEST(drq_e_gfields)) - DYN_REQUEST(drq_e_gfields) = request; - + { DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, DDL_TRIGGER_DROP_DOMAIN, f, gbl->sqlText); delete_dimension_records(gbl, f); ERASE X; found = true; + } END_FOR - if (!DYN_REQUEST(drq_e_gfields)) - DYN_REQUEST(drq_e_gfields) = request; - request = CMP_find_request(tdbb, drq_l_fld_src, DYN_REQUESTS); + request.reset(tdbb, drq_l_fld_src, DYN_REQUESTS); FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) Y IN RDB$RELATION_FIELDS WITH Y.RDB$FIELD_SOURCE EQ f.c_str() - if (!DYN_REQUEST(drq_l_fld_src)) - DYN_REQUEST(drq_l_fld_src) = request; - + { fb_utils::exact_name_limit(Y.RDB$FIELD_SOURCE, sizeof(Y.RDB$FIELD_SOURCE)); fb_utils::exact_name_limit(Y.RDB$RELATION_NAME, sizeof(Y.RDB$RELATION_NAME)); fb_utils::exact_name_limit(Y.RDB$FIELD_NAME, sizeof(Y.RDB$FIELD_NAME)); - DYN_rundown_request(request, -1); DYN_error_punt(false, 43, SafeArg() << Y.RDB$FIELD_SOURCE << Y.RDB$RELATION_NAME << Y.RDB$FIELD_NAME); // msg 43: "Domain %s is used in table %s (local name %s) and can not be dropped" - END_FOR; - if (!DYN_REQUEST(drq_l_fld_src)) - DYN_REQUEST(drq_l_fld_src) = request; + } + END_FOR - request = CMP_find_request(tdbb, drq_l_prp_src, DYN_REQUESTS); + request.reset(tdbb, drq_l_prp_src, DYN_REQUESTS); FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$PROCEDURE_PARAMETERS WITH X.RDB$FIELD_SOURCE EQ f.c_str() - if (!DYN_REQUEST(drq_l_prp_src)) - DYN_REQUEST(drq_l_prp_src) = request; - + { fb_utils::exact_name_limit(X.RDB$FIELD_SOURCE, sizeof(X.RDB$FIELD_SOURCE)); fb_utils::exact_name_limit(X.RDB$PROCEDURE_NAME, sizeof(X.RDB$PROCEDURE_NAME)); fb_utils::exact_name_limit(X.RDB$PARAMETER_NAME, sizeof(X.RDB$PARAMETER_NAME)); - DYN_rundown_request(request, -1); DYN_error_punt(false, 239, SafeArg() << X.RDB$FIELD_SOURCE << QualifiedName(X.RDB$PROCEDURE_NAME, (X.RDB$PACKAGE_NAME.NULL ? NULL : X.RDB$PACKAGE_NAME)).toString().c_str() << X.RDB$PARAMETER_NAME); // msg 239: "Domain %s is used in procedure %s (parameter name %s) and cannot be dropped" - + } END_FOR - if (!DYN_REQUEST(drq_l_prp_src)) - DYN_REQUEST(drq_l_prp_src) = request; } // try catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - DYN_rundown_request(request, -1); DYN_error_punt(true, 44); // msg 44: "ERASE RDB$FIELDS failed" } @@ -627,7 +566,7 @@ void DYN_delete_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_e_indices, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_indices, DYN_REQUESTS); bool found = false; bool is_expression = false; @@ -639,9 +578,7 @@ void DYN_delete_index( Global* gbl, const UCHAR** ptr) 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() - if (!DYN_REQUEST(drq_e_indices)) - DYN_REQUEST(drq_e_indices) = request; - + { rel_name = IDX.RDB$RELATION_NAME; found = true; @@ -650,14 +587,12 @@ void DYN_delete_index( Global* gbl, const UCHAR** ptr) is_expression = !IDX.RDB$EXPRESSION_BLR.NULL; ERASE IDX; - END_FOR; - if (!DYN_REQUEST(drq_e_indices)) - DYN_REQUEST(drq_e_indices) = request; + } + END_FOR } //try catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - DYN_rundown_request(request, -1); DYN_error_punt(true, 47); // msg 47: "ERASE RDB$INDICES failed" } @@ -743,7 +678,7 @@ void DYN_delete_local_field(Global* gbl, const UCHAR** ptr, const Firebird::Meta else GET_STRING(ptr, tbl_nm); - jrd_req* request = CMP_find_request(tdbb, drq_l_dep_flds, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_l_dep_flds, DYN_REQUESTS); USHORT id = drq_l_dep_flds; bool found; @@ -762,23 +697,18 @@ void DYN_delete_local_field(Global* gbl, const UCHAR** ptr, const Firebird::Meta Y.RDB$RELATION_NAME EQ Z.RDB$VIEW_NAME AND X.RDB$RELATION_NAME EQ Z.RDB$RELATION_NAME AND Y.RDB$VIEW_CONTEXT EQ Z.RDB$VIEW_CONTEXT - if (!DYN_REQUEST(drq_l_dep_flds)) - DYN_REQUEST(drq_l_dep_flds) = request; - - DYN_rundown_request(request, -1); + { DYN_error_punt(false, 52, SafeArg() << col_nm.c_str() << tbl_nm.c_str() << Y.RDB$RELATION_NAME); // msg 52: "field %s from relation %s is referenced in view %s" - END_FOR; - if (!DYN_REQUEST(drq_l_dep_flds)) - DYN_REQUEST(drq_l_dep_flds) = request; - + } + END_FOR // If the column to be dropped is being used as a foreign key // and the column was not part of any compound foreign key, // then we can drop the column. But we have to drop the foreign key // constraint first. - request = CMP_find_request(tdbb, drq_g_rel_constr_nm, DYN_REQUESTS); + request.reset(tdbb, drq_g_rel_constr_nm, DYN_REQUESTS); id = drq_g_rel_constr_nm; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) @@ -791,9 +721,7 @@ void DYN_delete_local_field(Global* gbl, const UCHAR** ptr, const Firebird::Meta AND IDX.RDB$INDEX_NAME EQ IDX_SEG.RDB$INDEX_NAME AND IDX.RDB$INDEX_NAME EQ REL_CONST.RDB$INDEX_NAME AND REL_CONST.RDB$CONSTRAINT_TYPE EQ FOREIGN_KEY - if (!DYN_REQUEST(drq_g_rel_constr_nm)) - DYN_REQUEST(drq_g_rel_constr_nm) = request; - + { if (IDX.RDB$SEGMENT_COUNT == 1) { constraint = REL_CONST.RDB$CONSTRAINT_NAME; @@ -803,16 +731,12 @@ void DYN_delete_local_field(Global* gbl, const UCHAR** ptr, const Firebird::Meta } else { - DYN_rundown_request(request, -1); DYN_error_punt(false, 187, SafeArg() << col_nm.c_str() << tbl_nm.c_str() << IDX.RDB$INDEX_NAME); // msg 187: "field %s from relation %s is referenced in index %s" } - - END_FOR; - - if (!DYN_REQUEST(drq_g_rel_constr_nm)) - DYN_REQUEST(drq_g_rel_constr_nm) = request; + } + END_FOR // make sure that column is not referenced in any user-defined indexes @@ -820,7 +744,7 @@ void DYN_delete_local_field(Global* gbl, const UCHAR** ptr, const Firebird::Meta // they were already been deleted when dropping column that was // used as foreign key before "commit". - request = CMP_find_request(tdbb, drq_e_l_idx, DYN_REQUESTS); + request.reset(tdbb, drq_e_l_idx, DYN_REQUESTS); id = drq_e_l_idx; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) @@ -833,18 +757,14 @@ void DYN_delete_local_field(Global* gbl, const UCHAR** ptr, const Firebird::Meta REL_CONST IN RDB$RELATION_CONSTRAINTS WITH REL_CONST.RDB$RELATION_NAME EQ IDX.RDB$RELATION_NAME AND REL_CONST.RDB$INDEX_NAME EQ IDX.RDB$INDEX_NAME - if (!DYN_REQUEST(drq_e_l_idx)) - DYN_REQUEST(drq_e_l_idx) = request; - - DYN_rundown_request(request, -1); + { DYN_error_punt(false, 187, SafeArg() << col_nm.c_str() << tbl_nm.c_str() << fb_utils::exact_name_limit(IDX.RDB$INDEX_NAME, sizeof(IDX.RDB$INDEX_NAME))); // msg 187: "field %s from relation %s is referenced in index %s" - END_FOR; - if (!DYN_REQUEST(drq_e_l_idx)) - DYN_REQUEST(drq_e_l_idx) = request; + } + END_FOR - request = CMP_find_request(tdbb, drq_e_lfield, DYN_REQUESTS); + request.reset(tdbb, drq_e_lfield, DYN_REQUESTS); id = drq_e_lfield; found = false; @@ -852,9 +772,7 @@ void DYN_delete_local_field(Global* gbl, const UCHAR** ptr, const Firebird::Meta RFR IN RDB$RELATION_FIELDS WITH RFR.RDB$FIELD_NAME EQ col_nm.c_str() AND RFR.RDB$RELATION_NAME EQ tbl_nm.c_str() - if (!DYN_REQUEST(drq_e_lfield)) - DYN_REQUEST(drq_e_lfield) = request; - + { if (!RFR.RDB$GENERATOR_NAME.NULL) delete_identity_generator(tdbb, gbl->gbl_transaction, RFR.RDB$GENERATOR_NAME); @@ -877,12 +795,10 @@ void DYN_delete_local_field(Global* gbl, const UCHAR** ptr, const Firebird::Meta DYN_execute(gbl, ptr, &rel_name, &tmp, NULL, NULL, NULL); } } - END_FOR; - if (!DYN_REQUEST(drq_e_lfield)) { - DYN_REQUEST(drq_e_lfield) = request; } + END_FOR - request = CMP_find_request(tdbb, drq_e_fld_prvs, DYN_REQUESTS); + request.reset(tdbb, drq_e_fld_prvs, DYN_REQUESTS); id = drq_e_fld_prvs; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) @@ -890,22 +806,15 @@ void DYN_delete_local_field(Global* gbl, const UCHAR** ptr, const Firebird::Meta PRIV.RDB$RELATION_NAME EQ tbl_nm.c_str() AND PRIV.RDB$FIELD_NAME EQ col_nm.c_str() AND PRIV.RDB$OBJECT_TYPE = obj_relation - - if (!DYN_REQUEST(drq_e_fld_prvs)) - DYN_REQUEST(drq_e_fld_prvs) = request; - + { ERASE PRIV; - END_FOR; - - if (!DYN_REQUEST(drq_e_fld_prvs)) { - DYN_REQUEST(drq_e_fld_prvs) = request; } + END_FOR } // try catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - DYN_rundown_request(request, -1); switch (id) { @@ -953,8 +862,7 @@ void DYN_delete_relation( Global* gbl, const UCHAR** ptr, const Firebird::MetaNa else GET_STRING(ptr, relation_name); - jrd_req* req2 = NULL; - jrd_req* request = CMP_find_request(tdbb, drq_l_relation, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_l_relation, DYN_REQUESTS); USHORT id = drq_l_relation; bool found = false; @@ -964,19 +872,15 @@ void DYN_delete_relation( Global* gbl, const UCHAR** ptr, const Firebird::MetaNa FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) R IN RDB$RELATIONS WITH R.RDB$RELATION_NAME EQ relation_name.c_str() - if (!DYN_REQUEST(drq_l_relation)) - DYN_REQUEST(drq_l_relation) = request; - + { view = !R.RDB$VIEW_BLR.NULL; DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, (view ? DDL_TRIGGER_DROP_VIEW : DDL_TRIGGER_DROP_TABLE), relation_name, gbl->sqlText); - END_FOR; + } + END_FOR - if (!DYN_REQUEST(drq_l_relation)) - DYN_REQUEST(drq_l_relation) = request; - - request = CMP_find_request(tdbb, drq_e_rel_con2, DYN_REQUESTS); + request.reset(tdbb, drq_e_rel_con2, DYN_REQUESTS); id = drq_e_rel_con2; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) @@ -986,51 +890,36 @@ void DYN_delete_relation( Global* gbl, const UCHAR** ptr, const Firebird::MetaNa CRT.RDB$CONSTRAINT_TYPE EQ UNIQUE_CNSTRT OR CRT.RDB$CONSTRAINT_TYPE EQ FOREIGN_KEY) SORTED BY ASCENDING CRT.RDB$CONSTRAINT_TYPE - - if (!DYN_REQUEST(drq_e_rel_con2)) - DYN_REQUEST(drq_e_rel_con2) = request; - + { ERASE CRT; - END_FOR; + } + END_FOR - if (!DYN_REQUEST(drq_e_rel_con2)) - DYN_REQUEST(drq_e_rel_con2) = request; - - request = CMP_find_request(tdbb, drq_e_rel_idxs, DYN_REQUESTS); + request.reset(tdbb, drq_e_rel_idxs, DYN_REQUESTS); id = drq_e_rel_idxs; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) IDX IN RDB$INDICES WITH IDX.RDB$RELATION_NAME EQ relation_name.c_str() - - if (!DYN_REQUEST(drq_e_rel_idxs)) - DYN_REQUEST(drq_e_rel_idxs) = request; - + { delete_index_segment_records(gbl, IDX.RDB$INDEX_NAME); ERASE IDX; - END_FOR; + } + END_FOR - if (!DYN_REQUEST(drq_e_rel_idxs)) - DYN_REQUEST(drq_e_rel_idxs) = request; - - request = CMP_find_request(tdbb, drq_e_trg_msgs2, DYN_REQUESTS); + request.reset(tdbb, drq_e_trg_msgs2, DYN_REQUESTS); id = drq_e_trg_msgs2; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) TM IN RDB$TRIGGER_MESSAGES CROSS T IN RDB$TRIGGERS WITH T.RDB$RELATION_NAME EQ relation_name.c_str() AND TM.RDB$TRIGGER_NAME EQ T.RDB$TRIGGER_NAME - - if (!DYN_REQUEST(drq_e_trg_msgs2)) - DYN_REQUEST(drq_e_trg_msgs2) = request; - + { ERASE TM; - END_FOR; - - if (!DYN_REQUEST(drq_e_trg_msgs2)) - DYN_REQUEST(drq_e_trg_msgs2) = request; + } + END_FOR // CVC: Moved this block here to avoid SF Bug #1111570. - request = CMP_find_request(tdbb, drq_e_rel_con3, DYN_REQUESTS); + request.reset(tdbb, drq_e_rel_con3, DYN_REQUESTS); id = drq_e_rel_con3; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) @@ -1038,25 +927,17 @@ void DYN_delete_relation( Global* gbl, const UCHAR** ptr, const Firebird::MetaNa CRT.RDB$RELATION_NAME EQ relation_name.c_str() AND (CRT.RDB$CONSTRAINT_TYPE EQ CHECK_CNSTRT OR CRT.RDB$CONSTRAINT_TYPE EQ NOT_NULL_CNSTRT) - - if (!DYN_REQUEST(drq_e_rel_con3)) - DYN_REQUEST(drq_e_rel_con3) = request; - + { ERASE CRT; - END_FOR; + } + END_FOR - if (!DYN_REQUEST(drq_e_rel_con3)) - DYN_REQUEST(drq_e_rel_con3) = request; - - request = CMP_find_request(tdbb, drq_e_rel_flds, DYN_REQUESTS); + request.reset(tdbb, drq_e_rel_flds, DYN_REQUESTS); id = drq_e_rel_flds; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) RFR IN RDB$RELATION_FIELDS WITH RFR.RDB$RELATION_NAME EQ relation_name.c_str() - - if (!DYN_REQUEST(drq_e_rel_flds)) - DYN_REQUEST(drq_e_rel_flds) = request; - + { if (!RFR.RDB$GENERATOR_NAME.NULL) delete_identity_generator(tdbb, gbl->gbl_transaction, RFR.RDB$GENERATOR_NAME); @@ -1069,34 +950,25 @@ void DYN_delete_relation( Global* gbl, const UCHAR** ptr, const Firebird::MetaNa } delete_gfield_for_lfield(gbl, RFR.RDB$FIELD_SOURCE); + } + END_FOR - END_FOR; - - if (!DYN_REQUEST(drq_e_rel_flds)) - DYN_REQUEST(drq_e_rel_flds) = request; - - request = CMP_find_request(tdbb, drq_e_view_rels, DYN_REQUESTS); + request.reset(tdbb, drq_e_view_rels, DYN_REQUESTS); id = drq_e_view_rels; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) VR IN RDB$VIEW_RELATIONS WITH VR.RDB$VIEW_NAME EQ relation_name.c_str() - if (!DYN_REQUEST(drq_e_view_rels)) - DYN_REQUEST(drq_e_view_rels) = request; - + { ERASE VR; - END_FOR; + } + END_FOR - if (!DYN_REQUEST(drq_e_view_rels)) - DYN_REQUEST(drq_e_view_rels) = request; - - request = CMP_find_request(tdbb, drq_e_relation, DYN_REQUESTS); + request.reset(tdbb, drq_e_relation, DYN_REQUESTS); id = drq_e_relation; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) R IN RDB$RELATIONS WITH R.RDB$RELATION_NAME EQ relation_name.c_str() - if (!DYN_REQUEST(drq_e_relation)) - DYN_REQUEST(drq_e_relation) = request; - + { ERASE R; if (!R.RDB$SECURITY_CLASS.NULL && @@ -1106,96 +978,68 @@ void DYN_delete_relation( Global* gbl, const UCHAR** ptr, const Firebird::MetaNa } found = true; - END_FOR; - - if (!DYN_REQUEST(drq_e_relation)) - DYN_REQUEST(drq_e_relation) = request; - - if (!found) { - goto dyn_punt_61; } + END_FOR + + if (!found) + goto dyn_punt_61; // Triggers must be deleted after check constraints Firebird::MetaName trigger_name; - request = CMP_find_request(tdbb, drq_e_trigger2, DYN_REQUESTS); + request.reset(tdbb, drq_e_trigger2, DYN_REQUESTS); id = drq_e_trigger2; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$TRIGGERS WITH X.RDB$RELATION_NAME EQ relation_name.c_str() - - if (!DYN_REQUEST(drq_e_trigger2)) - DYN_REQUEST(drq_e_trigger2) = request; - + { trigger_name = X.RDB$TRIGGER_NAME; ERASE X; - req2 = CMP_find_request(tdbb, drq_e_trg_prv, DYN_REQUESTS); + AutoCacheRequest request2(tdbb, drq_e_trg_prv, DYN_REQUESTS); id = drq_e_trg_prv; - FOR(REQUEST_HANDLE req2 TRANSACTION_HANDLE gbl->gbl_transaction) + FOR(REQUEST_HANDLE request2 TRANSACTION_HANDLE gbl->gbl_transaction) PRIV IN RDB$USER_PRIVILEGES WITH PRIV.RDB$USER EQ trigger_name.c_str() AND PRIV.RDB$USER_TYPE = obj_trigger - - if (!DYN_REQUEST(drq_e_trg_prv)) - DYN_REQUEST(drq_e_trg_prv) = req2; - + { ERASE PRIV; - END_FOR; - - if (!DYN_REQUEST(drq_e_trg_prv)) - DYN_REQUEST(drq_e_trg_prv) = req2; + } + END_FOR id = drq_e_trigger2; + } + END_FOR - END_FOR; - - if (!DYN_REQUEST(drq_e_trigger2)) - DYN_REQUEST(drq_e_trigger2) = request; - - request = CMP_find_request(tdbb, drq_e_usr_prvs, DYN_REQUESTS); + request.reset(tdbb, drq_e_usr_prvs, DYN_REQUESTS); id = drq_e_usr_prvs; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) PRIV IN RDB$USER_PRIVILEGES WITH PRIV.RDB$RELATION_NAME EQ relation_name.c_str() AND PRIV.RDB$OBJECT_TYPE = obj_relation - - if (!DYN_REQUEST(drq_e_usr_prvs)) - DYN_REQUEST(drq_e_usr_prvs) = request; - + { ERASE PRIV; - END_FOR; - - if (!DYN_REQUEST(drq_e_usr_prvs)) { - DYN_REQUEST(drq_e_usr_prvs) = request; } + END_FOR - request = CMP_find_request(tdbb, drq_e_view_prv, DYN_REQUESTS); + request.reset(tdbb, drq_e_view_prv, DYN_REQUESTS); id = drq_e_view_prv; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) PRIV IN RDB$USER_PRIVILEGES WITH PRIV.RDB$USER EQ relation_name.c_str() AND PRIV.RDB$USER_TYPE = obj_view - - if (!DYN_REQUEST(drq_e_view_prv)) - DYN_REQUEST(drq_e_view_prv) = request; - + { ERASE PRIV; - END_FOR; - - if (!DYN_REQUEST(drq_e_view_prv)) { - DYN_REQUEST(drq_e_view_prv) = request; } + END_FOR } // try catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - DYN_rundown_request(request, -1); - DYN_rundown_request(req2, -1); // lookup error # from id // msg 57: "ERASE RDB$INDICES failed" @@ -1283,7 +1127,6 @@ void DYN_delete_role( Global* gbl, const UCHAR** ptr) thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = NULL; bool found = false; try @@ -1293,7 +1136,7 @@ void DYN_delete_role( Global* gbl, const UCHAR** ptr) GET_STRING(ptr, role_name); - request = CMP_find_request(tdbb, drq_drop_role, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_drop_role, DYN_REQUESTS); id = drq_drop_role; bool del_role_ok = true; @@ -1301,10 +1144,7 @@ void DYN_delete_role( Global* gbl, const UCHAR** ptr) FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) XX IN RDB$ROLES WITH XX.RDB$ROLE_NAME EQ role_name.c_str() - - if (!DYN_REQUEST(drq_drop_role)) - DYN_REQUEST(drq_drop_role) = request; - + { found = true; DdlNode::executeDdlTrigger(tdbb, gbl->gbl_transaction, DdlNode::DTW_BEFORE, @@ -1320,19 +1160,14 @@ void DYN_delete_role( Global* gbl, const UCHAR** ptr) { del_role_ok = false; } - - END_FOR; - - if (!DYN_REQUEST(drq_drop_role)) { - DYN_REQUEST(drq_drop_role) = request; } + END_FOR if (del_role_ok) { - request = CMP_find_request(tdbb, drq_del_role_1, DYN_REQUESTS); + 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) @@ -1341,17 +1176,10 @@ void DYN_delete_role( Global* gbl, const UCHAR** ptr) PRIV.RDB$OBJECT_TYPE = obj_sql_role) OR (PRIV.RDB$USER EQ role_name.c_str() AND PRIV.RDB$USER_TYPE = obj_sql_role) - - if (!DYN_REQUEST(drq_del_role_1)) { - DYN_REQUEST(drq_del_role_1) = request; - } - + { ERASE PRIV; - - END_FOR; - - if (!DYN_REQUEST(drq_del_role_1)) - DYN_REQUEST(drq_del_role_1) = request; + } + END_FOR } else { @@ -1363,7 +1191,6 @@ void DYN_delete_role( Global* gbl, const UCHAR** ptr) catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - DYN_rundown_request(request, -1); const USHORT number = (id == drq_drop_role ? 191 : 62); // msg 191: "ERASE RDB$ROLES failed" // msg 62: "ERASE RDB$USER_PRIVILEGES failed" @@ -1408,28 +1235,21 @@ void DYN_delete_shadow( Global* gbl, const UCHAR** ptr) ERR_post(Arg::Gds(isc_adm_task_denied)); } - jrd_req* request = CMP_find_request(tdbb, drq_e_shadow, DYN_REQUESTS); + 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 - - if (!DYN_REQUEST(drq_e_shadow)) - DYN_REQUEST(drq_e_shadow) = request; - + { ERASE FIL; - END_FOR; - - if (!DYN_REQUEST(drq_e_shadow)) - DYN_REQUEST(drq_e_shadow) = 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, 63); // msg 63: "ERASE RDB$FILES failed" } @@ -1458,7 +1278,7 @@ static bool delete_constraint_records(Global* gbl, thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_e_rel_con, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_rel_con, DYN_REQUESTS); bool found = false; @@ -1469,21 +1289,15 @@ static bool delete_constraint_records(Global* gbl, RC IN RDB$RELATION_CONSTRAINTS WITH RC.RDB$CONSTRAINT_NAME EQ constraint_name.c_str() AND RC.RDB$RELATION_NAME EQ relation_name.c_str() - - if (!DYN_REQUEST(drq_e_rel_con)) - DYN_REQUEST(drq_e_rel_con) = request; - + { found = true; ERASE RC; - END_FOR; - - if (!DYN_REQUEST(drq_e_rel_con)) - DYN_REQUEST(drq_e_rel_con) = 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, 129); // msg 129: "ERASE RDB$RELATION_CONSTRAINTS failed" } @@ -1508,7 +1322,7 @@ static bool delete_dimension_records(Global* gbl, const Firebird::MetaName& fiel thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_e_dims, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_dims, DYN_REQUESTS); bool found = false; @@ -1517,22 +1331,15 @@ static bool delete_dimension_records(Global* gbl, const Firebird::MetaName& fiel found = false; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) X IN RDB$FIELD_DIMENSIONS WITH X.RDB$FIELD_NAME EQ field_name.c_str() - - if (!DYN_REQUEST(drq_e_dims)) - DYN_REQUEST(drq_e_dims) = request; - + { found = true; ERASE X; - END_FOR; - - if (!DYN_REQUEST(drq_e_dims)) - DYN_REQUEST(drq_e_dims) = 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, 35); // msg 35: "ERASE RDB$FIELDS failed" } @@ -1580,7 +1387,7 @@ static void delete_f_key_constraint(thread_db* tdbb, SET_TDBB(tdbb); Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_e_rel_const, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_rel_const, DYN_REQUESTS); try { @@ -1591,16 +1398,11 @@ static void delete_f_key_constraint(thread_db* tdbb, AND RC.RDB$CONSTRAINT_TYPE EQ FOREIGN_KEY AND RC.RDB$RELATION_NAME EQ tbl_nm.c_str() AND RC.RDB$INDEX_NAME EQ index_name.c_str() - - if (!DYN_REQUEST(drq_e_rel_const)) - DYN_REQUEST(drq_e_rel_const) = request; - + { found = true; ERASE RC; - END_FOR; - - if (!DYN_REQUEST(drq_e_rel_const)) - DYN_REQUEST(drq_e_rel_const) = request; + } + END_FOR if (!found) { @@ -1611,7 +1413,6 @@ static void delete_f_key_constraint(thread_db* tdbb, catch (const Firebird::Exception& ex) { Firebird::stuff_exception(tdbb->tdbb_status_vector, ex); - DYN_rundown_request(request, -1); DYN_error_punt(true, 129); // msg 49: "ERASE RDB$RELATION_CONSTRAINTS failed" } @@ -1633,7 +1434,7 @@ static void delete_gfield_for_lfield( Global* gbl, const Firebird::MetaName& lfi **************************************/ thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_e_l_gfld, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_l_gfld, DYN_REQUESTS); FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) FLD IN RDB$FIELDS @@ -1646,17 +1447,11 @@ static void delete_gfield_for_lfield( Global* gbl, const Firebird::MetaName& lfi RFR.RDB$FIELD_SOURCE EQ FLD.RDB$FIELD_NAME) AND (NOT ANY PRC IN RDB$PROCEDURE_PARAMETERS WITH PRC.RDB$FIELD_SOURCE EQ FLD.RDB$FIELD_NAME) - - if (!DYN_REQUEST(drq_e_l_gfld)) - DYN_REQUEST(drq_e_l_gfld) = request; - + { delete_dimension_records(gbl, FLD.RDB$FIELD_NAME); ERASE FLD; - END_FOR; - - - if (!DYN_REQUEST(drq_e_l_gfld)) - DYN_REQUEST(drq_e_l_gfld) = request; + } + END_FOR } @@ -1691,7 +1486,7 @@ static bool delete_index_segment_records(Global* gbl, const Firebird::MetaName& thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_e_idx_segs, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_idx_segs, DYN_REQUESTS); bool found = false; @@ -1700,21 +1495,15 @@ static bool delete_index_segment_records(Global* gbl, const Firebird::MetaName& found = false; FOR(REQUEST_HANDLE request TRANSACTION_HANDLE gbl->gbl_transaction) I_S IN RDB$INDEX_SEGMENTS WITH I_S.RDB$INDEX_NAME EQ index_name.c_str() - - if (!DYN_REQUEST(drq_e_idx_segs)) - DYN_REQUEST(drq_e_idx_segs) = request; - + { found = true; ERASE I_S; - END_FOR; - - if (!DYN_REQUEST(drq_e_idx_segs)) - DYN_REQUEST(drq_e_idx_segs) = 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, 49); // msg 49: "ERASE RDB$INDEX_SEGMENTS failed" } @@ -1740,7 +1529,7 @@ bool DYN_delete_security_class2(jrd_tra* transaction, const Firebird::MetaName& thread_db* tdbb = JRD_get_thread_data(); Database* dbb = tdbb->getDatabase(); - jrd_req* request = CMP_find_request(tdbb, drq_e_class, DYN_REQUESTS); + AutoCacheRequest request(tdbb, drq_e_class, DYN_REQUESTS); bool found = false; @@ -1749,23 +1538,15 @@ bool DYN_delete_security_class2(jrd_tra* transaction, const Firebird::MetaName& FOR(REQUEST_HANDLE request TRANSACTION_HANDLE transaction) SC IN RDB$SECURITY_CLASSES WITH SC.RDB$SECURITY_CLASS EQ security_class.c_str() - - if (!DYN_REQUEST(drq_e_class)) - DYN_REQUEST(drq_e_class) = request; - + { found = true; ERASE SC; - - END_FOR; - - if (!DYN_REQUEST(drq_e_class)) { - DYN_REQUEST(drq_e_class) = 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, 74); // msg 74: "ERASE RDB$SECURITY_CLASSES failed" } diff --git a/src/jrd/dyn_mod.epp b/src/jrd/dyn_mod.epp index cd2d2aef3f..1b5dab0d0c 100644 --- a/src/jrd/dyn_mod.epp +++ b/src/jrd/dyn_mod.epp @@ -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); } diff --git a/src/jrd/dyn_util.epp b/src/jrd/dyn_util.epp index a2b9e12e9a..1e1a4ab37a 100644 --- a/src/jrd/dyn_util.epp +++ b/src/jrd/dyn_util.epp @@ -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" } diff --git a/src/jrd/exe_proto.h b/src/jrd/exe_proto.h index 865fd3b1af..5e980e7ce2 100644 --- a/src/jrd/exe_proto.h +++ b/src/jrd/exe_proto.h @@ -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;