From 6b586265845e71ea3cf16d12338b68c2d43f4a8c Mon Sep 17 00:00:00 2001 From: robocop Date: Fri, 27 Nov 2009 06:57:17 +0000 Subject: [PATCH] Cleanup. --- src/dsql/PackageNodes.epp | 8 +++---- src/dsql/metd.epp | 39 ++++++--------------------------- src/jrd/cch.cpp | 6 ++--- src/jrd/dfw.epp | 2 +- src/jrd/dyn.epp | 4 +--- src/jrd/dyn_def.epp | 46 ++++++++++++++------------------------- src/jrd/dyn_mod.epp | 2 +- src/jrd/evl.cpp | 2 +- src/jrd/ini.epp | 2 +- 9 files changed, 34 insertions(+), 77 deletions(-) diff --git a/src/dsql/PackageNodes.epp b/src/dsql/PackageNodes.epp index 4715e17216..816ea250c6 100644 --- a/src/dsql/PackageNodes.epp +++ b/src/dsql/PackageNodes.epp @@ -425,7 +425,7 @@ void CreateAlterPackageNode::execute(thread_db* tdbb, jrd_tra* transaction) { fb_assert(create || alter); - Database* dbb = tdbb->getDatabase(); + //Database* dbb = tdbb->getDatabase(); //dbb->checkOdsForDsql(ODS_12_0); @@ -597,7 +597,7 @@ void DropPackageNode::print(string& text, Array& /*nodes*/) const void DropPackageNode::execute(thread_db* tdbb, jrd_tra* transaction) { - Database* dbb = tdbb->getDatabase(); + //Database* dbb = tdbb->getDatabase(); MetaName metaName(nameInMetaCharSet(tdbb, name)); //dbb->checkOdsForDsql(ODS_12_0); @@ -833,7 +833,7 @@ Node* CreatePackageBodyNode::internalDsqlPass() void CreatePackageBodyNode::execute(thread_db* tdbb, jrd_tra* transaction) { - Database* dbb = tdbb->getDatabase(); + //Database* dbb = tdbb->getDatabase(); const MetaName metaName(nameInMetaCharSet(tdbb, name)); //dbb->checkOdsForDsql(ODS_12_0); @@ -1014,7 +1014,7 @@ void DropPackageBodyNode::print(string& text, Array& /*nodes*/) const void DropPackageBodyNode::execute(thread_db* tdbb, jrd_tra* transaction) { - Database* dbb = tdbb->getDatabase(); + //Database* dbb = tdbb->getDatabase(); const MetaName metaName(nameInMetaCharSet(tdbb, name)); //dbb->checkOdsForDsql(ODS_12_0); diff --git a/src/dsql/metd.epp b/src/dsql/metd.epp index c05187b86c..8bf0a49bba 100644 --- a/src/dsql/metd.epp +++ b/src/dsql/metd.epp @@ -1255,41 +1255,16 @@ dsql_prc* METD_get_procedure(CompiledStatement* statement, const dsql_str* name, if (!DSQL_REQUEST(irq_parameters)) DSQL_REQUEST(irq_parameters) = handle2; - SSHORT pr_collation_id_null = TRUE; - SSHORT pr_collation_id; - SSHORT pr_default_value_null = TRUE; - SSHORT pr_null_flag_null = TRUE; - SSHORT pr_null_flag; - bool pr_type_of = false; + const SSHORT pr_collation_id_null = PR.RDB$COLLATION_ID.NULL; + const SSHORT pr_collation_id = PR.RDB$COLLATION_ID; - jrd_req* handle3 = CMP_find_request(tdbb, irq_parameters2, IRQ_REQUESTS); + const SSHORT pr_default_value_null = PR.RDB$DEFAULT_VALUE.NULL; - const MetaName packageName(PR.RDB$PACKAGE_NAME.NULL ? NULL : PR.RDB$PACKAGE_NAME); + const SSHORT pr_null_flag_null = PR.RDB$NULL_FLAG.NULL; + const SSHORT pr_null_flag = PR.RDB$NULL_FLAG; - FOR(REQUEST_HANDLE handle3 TRANSACTION_HANDLE statement->req_transaction) - PR2 IN RDB$PROCEDURE_PARAMETERS - WITH PR2.RDB$PROCEDURE_NAME EQ PR.RDB$PROCEDURE_NAME AND - PR2.RDB$PACKAGE_NAME EQUIV NULLIF(packageName.c_str(), '') AND - PR2.RDB$PARAMETER_NAME EQ PR.RDB$PARAMETER_NAME - - if (!DSQL_REQUEST(irq_parameters2)) - DSQL_REQUEST(irq_parameters2) = handle3; - - pr_collation_id_null = PR2.RDB$COLLATION_ID.NULL; - pr_collation_id = PR2.RDB$COLLATION_ID; - - pr_default_value_null = PR2.RDB$DEFAULT_VALUE.NULL; - - pr_null_flag_null = PR2.RDB$NULL_FLAG.NULL; - pr_null_flag = PR2.RDB$NULL_FLAG; - - if (!PR2.RDB$PARAMETER_MECHANISM.NULL && PR2.RDB$PARAMETER_MECHANISM == prm_mech_type_of) - pr_type_of = true; - - END_FOR - - if (!DSQL_REQUEST(irq_parameters2)) - DSQL_REQUEST(irq_parameters2) = handle3; + const bool pr_type_of = + (!PR.RDB$PARAMETER_MECHANISM.NULL && PR.RDB$PARAMETER_MECHANISM == prm_mech_type_of); count++; // allocate the field block diff --git a/src/jrd/cch.cpp b/src/jrd/cch.cpp index af47543569..2080c8c7d0 100644 --- a/src/jrd/cch.cpp +++ b/src/jrd/cch.cpp @@ -301,9 +301,7 @@ USHORT CCH_checksum(BufferDesc* bdb) **************************************/ #ifdef NO_CHECKSUM return DUMMY_CHECKSUM; -#else - Database* dbb = bdb->bdb_dbb; -#ifdef WIN_NT +#elif defined(WIN_NT) // ODS_VERSION8 for NT was shipped before page checksums // were disabled on other platforms. Continue to compute // checksums for ODS_VERSION8 databases but eliminate them @@ -313,6 +311,7 @@ USHORT CCH_checksum(BufferDesc* bdb) return DUMMY_CHECKSUM; #else + Database* dbb = bdb->bdb_dbb; pag* page = bdb->bdb_buffer; const ULONG* const end = (ULONG *) ((SCHAR *) page + dbb->dbb_page_size); @@ -350,7 +349,6 @@ USHORT CCH_checksum(BufferDesc* bdb) return DUMMY_CHECKSUM; #endif -#endif } diff --git a/src/jrd/dfw.epp b/src/jrd/dfw.epp index abfd479c4c..12e531288b 100644 --- a/src/jrd/dfw.epp +++ b/src/jrd/dfw.epp @@ -4718,7 +4718,7 @@ static Format* make_format(thread_db* tdbb, jrd_rel* relation, USHORT* version, } if (desc2->dsc_dtype) { - offset = MET_align(dbb, &(*desc2), offset); + offset = MET_align(&(*desc2), offset); desc2->dsc_address = (UCHAR *) (IPTR) offset; offset += desc2->dsc_length; } diff --git a/src/jrd/dyn.epp b/src/jrd/dyn.epp index a1cbd397e0..be3edc0600 100644 --- a/src/jrd/dyn.epp +++ b/src/jrd/dyn.epp @@ -892,8 +892,6 @@ USHORT DYN_put_text_blob(Global* gbl, const UCHAR** ptr, bid* blob_id) const UCHAR* const end = p + length; try { - Database* dbb = tdbb->getDatabase(); - UCharBuffer bpb; const size_t convSize = 15; bpb.resize(convSize); @@ -957,7 +955,7 @@ void DYN_rundown_request(jrd_req* handle, SSHORT id) **************************************/ thread_db* tdbb = JRD_get_thread_data(); - Database* dbb = tdbb->getDatabase(); + Database* dbb = tdbb->getDatabase(); if (!handle) { return; diff --git a/src/jrd/dyn_def.epp b/src/jrd/dyn_def.epp index 50ce820e87..eaefbe9230 100644 --- a/src/jrd/dyn_def.epp +++ b/src/jrd/dyn_def.epp @@ -2939,6 +2939,8 @@ void DYN_define_relation(Global* gbl, const UCHAR** ptr, bool view) REL.RDB$EXTERNAL_FILE.NULL = TRUE; REL.RDB$FLAGS = 0; REL.RDB$FLAGS.NULL = FALSE; + REL.RDB$RELATION_TYPE.NULL = FALSE; + UCHAR verb; while ((verb = *(*ptr)++) != isc_dyn_end) @@ -3024,6 +3026,9 @@ void DYN_define_relation(Global* gbl, const UCHAR** ptr, bool view) } } // while + // The relation type cannot be determined definitely inside the above loop, + // because there are many DYN codes that affect it. + REL.RDB$RELATION_TYPE = rel_type; SSHORT old_id = id; id = drq_l_rel_info2; @@ -3087,19 +3092,6 @@ void DYN_define_relation(Global* gbl, const UCHAR** ptr, bool view) if (!DYN_REQUEST(drq_s_rels)) DYN_REQUEST(drq_s_rels) = request; - jrd_req* sub_request = NULL; - - FOR(REQUEST_HANDLE sub_request TRANSACTION_HANDLE gbl->gbl_transaction) - REL IN RDB$RELATIONS WITH REL.RDB$RELATION_NAME EQ relation_name.c_str() - - MODIFY REL USING - REL.RDB$RELATION_TYPE = rel_type; - REL.RDB$RELATION_TYPE.NULL = FALSE; - END_MODIFY; - END_FOR; - - CMP_release(tdbb, sub_request); - if (sql_prot) { for (const TEXT* p = ALL_PRIVILEGES; *p; p++) @@ -3888,6 +3880,17 @@ void DYN_define_trigger(Global* gbl, if (X.RDB$RELATION_NAME.NULL && !tdbb->getAttachment()->locksmith()) ERR_post(Arg::Gds(isc_adm_task_denied)); + X.RDB$VALID_BLR = TRUE; + X.RDB$VALID_BLR.NULL = FALSE; + + if (debug_info_ptr) + { + X.RDB$DEBUG_INFO.NULL = FALSE; + DYN_put_blr_blob(gbl, &debug_info_ptr, &X.RDB$DEBUG_INFO); + } + else + X.RDB$DEBUG_INFO.NULL = TRUE; + b_ending_store = true; // the END_STORE_SPECIAL adds the foll. lines of code to the END_STORE @@ -3906,23 +3909,6 @@ void DYN_define_trigger(Global* gbl, DYN_REQUEST(drq_s_triggers) = request; } - jrd_req* sub_request = NULL; - - FOR(REQUEST_HANDLE sub_request TRANSACTION_HANDLE gbl->gbl_transaction) - TRG IN RDB$TRIGGERS WITH TRG.RDB$TRIGGER_NAME EQ t.c_str() - - MODIFY TRG USING - TRG.RDB$VALID_BLR = TRUE; - TRG.RDB$VALID_BLR.NULL = FALSE; - - TRG.RDB$DEBUG_INFO.NULL = (debug_info_ptr == NULL) ? TRUE : FALSE; - if (debug_info_ptr) - DYN_put_blr_blob(gbl, &debug_info_ptr, &TRG.RDB$DEBUG_INFO); - END_MODIFY; - END_FOR; - - CMP_release(tdbb, sub_request); - } catch (const Firebird::Exception& ex) { diff --git a/src/jrd/dyn_mod.epp b/src/jrd/dyn_mod.epp index 1fa8ef4c28..b363c39996 100644 --- a/src/jrd/dyn_mod.epp +++ b/src/jrd/dyn_mod.epp @@ -2432,7 +2432,7 @@ void DYN_modify_sql_field(Global* gbl, const UCHAR** ptr, const MetaName* relati * **************************************/ thread_db* tdbb = JRD_get_thread_data(); - Database* dbb = tdbb->getDatabase(); + //Database* dbb = tdbb->getDatabase(); dyn_fld orig_fld, new_fld, dom_fld; diff --git a/src/jrd/evl.cpp b/src/jrd/evl.cpp index 4f8846d47b..fd9cdfd6e7 100644 --- a/src/jrd/evl.cpp +++ b/src/jrd/evl.cpp @@ -1250,7 +1250,7 @@ bool EVL_field(jrd_rel* relation, Record* record, USHORT id, dsc* desc) if (record && record->rec_format && relation) { thread_db* tdbb = JRD_get_thread_data(); - Database* dbb = tdbb->getDatabase(); + //Database* dbb = tdbb->getDatabase(); while (format && (id >= format->fmt_defaults.getCount() || diff --git a/src/jrd/ini.epp b/src/jrd/ini.epp index 7082a934d7..eba88297df 100644 --- a/src/jrd/ini.epp +++ b/src/jrd/ini.epp @@ -652,7 +652,7 @@ void INI_init2(thread_db* tdbb) { if (n-- > 0) { - format->fmt_length = (USHORT) MET_align(dbb, &(*desc), format->fmt_length); + format->fmt_length = (USHORT) MET_align(&(*desc), format->fmt_length); desc->dsc_address = (UCHAR*) (IPTR) format->fmt_length; format->fmt_length += desc->dsc_length; }