From 81609a77d7fef0479a8488da5345324d4804f5b3 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Tue, 18 Sep 2012 16:01:58 +0000 Subject: [PATCH] Cleanup. --- src/dsql/DdlNodes.epp | 20 ++++++++-------- src/dsql/DsqlCompilerScratch.h | 12 ++++++++++ src/dsql/ddl.cpp | 43 ++-------------------------------- src/dsql/ddl_proto.h | 5 ++-- src/dsql/metd.epp | 32 ------------------------- src/dsql/metd_proto.h | 1 - src/jrd/irq.h | 1 - src/msgs/messages2.sql | 2 +- 8 files changed, 27 insertions(+), 89 deletions(-) diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index f1334e0f90..4f9310412d 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -294,7 +294,7 @@ void defineComputed(DsqlCompilerScratch* dsqlScratch, RelationSourceNode* relati ValueSourceClause* clause, string& source, BlrWriter::BlrData& value) { // Get the table node and set up correct context. - DDL_reset_context_stack(dsqlScratch); + dsqlScratch->resetContextStack(); // Save the size of the field if it is specified. dsc saveDesc; @@ -364,7 +364,7 @@ void defineComputed(DsqlCompilerScratch* dsqlScratch, RelationSourceNode* relati field->fld_sub_type = desc.dsc_sub_type; } - DDL_reset_context_stack(dsqlScratch); + dsqlScratch->resetContextStack(); // Generate the source text. source = clause->source; @@ -935,7 +935,7 @@ TypeClause::TypeClause(MemoryPool& pool, dsql_fld* aLegacyField, const MetaName& void TypeClause::resolve(DsqlCompilerScratch* dsqlScratch, bool modifying) { - DDL_resolve_intl_type2(dsqlScratch, legacyField, + DDL_resolve_intl_type(dsqlScratch, legacyField, (collate.isEmpty() ? NULL : collate), modifying); setup(dsqlScratch); @@ -3194,7 +3194,7 @@ void CreateAlterTriggerNode::compile(thread_db* /*tdbb*/, DsqlCompilerScratch* d // fields to that context but prevent relations referenced in // the trigger actions from referencing the predefined "1" context. if (dsqlScratch->contextNumber) - dsqlScratch->resetContextStack(); + dsqlScratch->resetTriggerContextStack(); if (relationName.hasData()) { @@ -5995,7 +5995,7 @@ void RelationNode::defineCheckConstraintTrigger(DsqlCompilerScratch* dsqlScratch // place holder to avoid resolving fields to that context but prevent relations referenced // in the trigger actions from referencing the predefined "1" context. - DDL_reset_context_stack(dsqlScratch); + dsqlScratch->resetContextStack(); // CVC: I thought I could disable the OLD context here to avoid "ambiguous field name" // errors in pre_store and pre_modify triggers. Also, what sense can I make from NEW in @@ -6026,7 +6026,7 @@ void RelationNode::defineCheckConstraintTrigger(DsqlCompilerScratch* dsqlScratch dsqlScratch->appendUChar(blr_eoc); // end of the blr - DDL_reset_context_stack(dsqlScratch); + dsqlScratch->resetContextStack(); // Move the blr to the constraint blrWriter. blrWriter.getBlrData().join(dsqlScratch->getBlrData()); @@ -7454,7 +7454,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra // context number since view contexts start at 1 (except for computed fields) -- note that // calling PASS1_rse directly rather than PASS1_statement saves the context stack. - DDL_reset_context_stack(dsqlScratch); + dsqlScratch->resetContextStack(); ++dsqlScratch->contextNumber; RseNode* rse = PASS1_rse(dsqlScratch, selectExpr, NULL); @@ -7972,7 +7972,7 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra createCheckTrigger(tdbb, dsqlScratch, items); } - DDL_reset_context_stack(dsqlScratch); + dsqlScratch->resetContextStack(); executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_AFTER, ddlTriggerAction, name); @@ -8008,7 +8008,7 @@ void CreateAlterViewNode::createCheckTrigger(thread_db* tdbb, DsqlCompilerScratc dsqlScratch->appendUChar(blr_begin); - DDL_reset_context_stack(dsqlScratch); + dsqlScratch->resetContextStack(); ++dsqlScratch->contextNumber; // OLD context @@ -8089,7 +8089,7 @@ void CreateAlterViewNode::createCheckTrigger(thread_db* tdbb, DsqlCompilerScratc dsqlScratch->appendUChar(blr_end); // of begin dsqlScratch->appendUChar(blr_eoc); - DDL_reset_context_stack(dsqlScratch); + dsqlScratch->resetContextStack(); TriggerDefinition trigger(pool); trigger.systemFlag = fb_sysflag_view_check; diff --git a/src/dsql/DsqlCompilerScratch.h b/src/dsql/DsqlCompilerScratch.h index b385c371c4..2b825e081c 100644 --- a/src/dsql/DsqlCompilerScratch.h +++ b/src/dsql/DsqlCompilerScratch.h @@ -171,7 +171,19 @@ public: void genParameters(Firebird::Array& parameters, Firebird::Array& returns); + // Get rid of any predefined contexts created for a view or trigger definition. + // Also reset hidden variables. void resetContextStack() + { + context->clear(); + contextNumber = 0; + derivedContextNumber = 0; + + hiddenVarsNumber = 0; + hiddenVariables.clear(); + } + + void resetTriggerContextStack() { context->clear(); contextNumber = 0; diff --git a/src/dsql/ddl.cpp b/src/dsql/ddl.cpp index 53d799f1a8..142be2b7a9 100644 --- a/src/dsql/ddl.cpp +++ b/src/dsql/ddl.cpp @@ -125,24 +125,12 @@ bool DDL_ids(const DsqlCompilerScratch* scratch) } -// -// See the next function for description. This is only a -// wrapper that sets the last parameter to false to indicate -// we are creating a field, not modifying one. -// void DDL_resolve_intl_type(DsqlCompilerScratch* dsqlScratch, dsql_fld* field, - const MetaName& collation_name) -{ - DDL_resolve_intl_type2(dsqlScratch, field, collation_name, false); -} - - -void DDL_resolve_intl_type2(DsqlCompilerScratch* dsqlScratch, dsql_fld* field, const MetaName& collation_name, bool modifying) { /************************************** * - * D D L _ r e s o l v e _ i n t l _ t y p e 2 + * D D L _ r e s o l v e _ i n t l _ t y p e * ************************************** * @@ -286,9 +274,6 @@ void DDL_resolve_intl_type2(DsqlCompilerScratch* dsqlScratch, dsql_fld* field, if (modifying) { -#ifdef DEV_BUILD - const dsql_rel* relation = dsqlScratch->relation; -#endif const dsql_fld* afield = field->fld_next; USHORT bpc = 0; @@ -297,7 +282,7 @@ void DDL_resolve_intl_type2(DsqlCompilerScratch* dsqlScratch, dsql_fld* field, // The first test is redundant. if (afield != field && afield->fld_relation && afield->fld_name == field->fld_name) { - fb_assert(afield->fld_relation == relation || !relation); + fb_assert(afield->fld_relation == dsqlScratch->relation || !dsqlScratch->relation); break; } @@ -467,30 +452,6 @@ static void assign_field_length(dsql_fld* field, USHORT bytes_per_char) } -void DDL_reset_context_stack(DsqlCompilerScratch* dsqlScratch) -{ -/************************************** - * - * D D L _ r e s e t _ c o n t e x t _ s t a c k - * - ************************************** - * - * Function - * Get rid of any predefined contexts created - * for a view or trigger definition. - * Also reset hidden variables. - * - **************************************/ - - dsqlScratch->context->clear(); - dsqlScratch->contextNumber = 0; - dsqlScratch->derivedContextNumber = 0; - - dsqlScratch->hiddenVarsNumber = 0; - dsqlScratch->hiddenVariables.clear(); -} - - // post very often used error - avoid code duplication static void post_607(const Arg::StatusVector& v) { diff --git a/src/dsql/ddl_proto.h b/src/dsql/ddl_proto.h index 86f4baf9c9..5f93c1e934 100644 --- a/src/dsql/ddl_proto.h +++ b/src/dsql/ddl_proto.h @@ -61,8 +61,7 @@ const USHORT blr_dtypes[] = { }; bool DDL_ids(const Jrd::DsqlCompilerScratch*); -void DDL_reset_context_stack(Jrd::DsqlCompilerScratch*); -void DDL_resolve_intl_type(Jrd::DsqlCompilerScratch*, Jrd::dsql_fld*, const Firebird::MetaName&); -void DDL_resolve_intl_type2(Jrd::DsqlCompilerScratch*, Jrd::dsql_fld*, const Firebird::MetaName&, bool); +void DDL_resolve_intl_type(Jrd::DsqlCompilerScratch*, Jrd::dsql_fld*, const Firebird::MetaName&, + bool = false); #endif // DSQL_DDL_PROTO_H diff --git a/src/dsql/metd.epp b/src/dsql/metd.epp index b730e2387e..2acb9522c9 100644 --- a/src/dsql/metd.epp +++ b/src/dsql/metd.epp @@ -775,38 +775,6 @@ USHORT METD_get_domain_default(jrd_tra* transaction, const MetaName& domain_name } -bool METD_get_exception(jrd_tra* transaction, const dsql_str* name) -{ -/************************************** - * - * M E T D _ g e t _ e x c e p t i o n - * - ************************************** - * - * Functional description - * Look up an exception. - * - **************************************/ - thread_db* tdbb = JRD_get_thread_data(); - - validateTransaction(transaction); - - bool found = false; - - AutoCacheRequest handle(tdbb, irq_exception, IRQ_REQUESTS); - - FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction) - X IN RDB$EXCEPTIONS WITH - X.RDB$EXCEPTION_NAME EQ name->str_data; - { - found = true; - } - END_FOR - - return found; -} - - dsql_udf* METD_get_function(jrd_tra* transaction, DsqlCompilerScratch* dsqlScratch, const QualifiedName& name) { diff --git a/src/dsql/metd_proto.h b/src/dsql/metd_proto.h index fda364c778..15c176be74 100644 --- a/src/dsql/metd_proto.h +++ b/src/dsql/metd_proto.h @@ -60,7 +60,6 @@ USHORT METD_get_col_default(Jrd::jrd_tra*, const char*, const char*, bool*, UCHA Jrd::dsql_str* METD_get_default_charset(Jrd::jrd_tra*); bool METD_get_domain(Jrd::jrd_tra*, class Jrd::dsql_fld*, const Firebird::MetaName& name); USHORT METD_get_domain_default(Jrd::jrd_tra*, const Firebird::MetaName&, bool*, UCHAR*, USHORT); -bool METD_get_exception(Jrd::jrd_tra*, const Jrd::dsql_str*); Jrd::dsql_udf* METD_get_function(Jrd::jrd_tra*, Jrd::DsqlCompilerScratch*, const Firebird::QualifiedName&); void METD_get_primary_key(Jrd::jrd_tra*, const Firebird::MetaName&, diff --git a/src/jrd/irq.h b/src/jrd/irq.h index a790374dde..ecb8c76b80 100644 --- a/src/jrd/irq.h +++ b/src/jrd/irq.h @@ -139,7 +139,6 @@ enum irq_type_t irq_type, // DSQL/METD: lookup a symbolic name in RDB$TYPES irq_col_default, // DSQL/METD: lookup default for a column irq_domain_2, // DSQL/METD: lookup a domain - irq_exception, // DSQL/METD: lookup an exception irq_cs_name, // DSQL/METD: lookup a charset name irq_default_cs, // DSQL/METD: lookup the default charset irq_rel_ids, // DSQL/METD: check relation/field ids diff --git a/src/msgs/messages2.sql b/src/msgs/messages2.sql index 3bc841f923..a6f7a62a30 100644 --- a/src/msgs/messages2.sql +++ b/src/msgs/messages2.sql @@ -643,7 +643,7 @@ without specifying a character set.', NULL); ('tra_num_exc', 'bump_transaction_id', 'tra.cpp', NULL, 0, 544, NULL, 'Transactions count exceeded. Perform backup and restore to make database operable again', NULL, NULL); ('field_disappeared', 'EVL_assign_to', 'evl.cpp', NULL, 0, 545, NULL, 'Column has been unexpectedly deleted', NULL, NULL); ('met_wrong_gtt_scope', 'store_dependencies', 'met.e', NULL, 0, 546, NULL, '@1 cannot depend on @2', NULL, NULL); -('subtype_for_internal_use', 'DDL_resolve_intl_type2', 'DSQL/ddl.cpp', NULL, 0, 547, NULL, 'Blob sub_types bigger than 1 (text) are for internal use only', NULL, NULL); +('subtype_for_internal_use', 'DDL_resolve_intl_type', 'DSQL/ddl.cpp', NULL, 0, 547, NULL, 'Blob sub_types bigger than 1 (text) are for internal use only', NULL, NULL); ('illegal_prc_type', 'par_procedure', 'par.cpp', NULL, 0, 548, NULL, 'Procedure @1 is not selectable (it does not contain a SUSPEND statement)', NULL, NULL); ('invalid_sort_datatype', 'gen_sort', 'opt.cpp', NULL, 0, 549, NULL, 'Datatype @1 is not supported for sorting operation', NULL, NULL); ('collation_name', 'check_dependencies', 'dfw.e', NULL, 0, 550, NULL, 'COLLATION @1', NULL, NULL);