From 4af43c999a30d8b534c930c898effe8f876b8590 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Fri, 20 Jan 2017 11:47:30 -0200 Subject: [PATCH] Cleanup. --- src/dsql/metd.epp | 206 ------------------------------------------ src/dsql/metd_proto.h | 2 - src/jrd/irq.h | 2 - 3 files changed, 210 deletions(-) diff --git a/src/dsql/metd.epp b/src/dsql/metd.epp index a81fbc59bb..9ac7200e4e 100644 --- a/src/dsql/metd.epp +++ b/src/dsql/metd.epp @@ -343,118 +343,6 @@ dsql_intlsym* METD_get_collation(jrd_tra* transaction, const MetaName& name, USH } -USHORT METD_get_col_default(jrd_tra* transaction, const char* for_rel_name, - const char* for_col_name, bool* has_default, UCHAR* buffer, USHORT buff_length) -{ -/************************************************************* - * - * M E T D _ g e t _ c o l _ d e f a u l t - * - ************************************************************** - * - * Function: - * Gets the default value for a column of an existing table. - * Will check the default for the column of the table, if that is - * not present, will check for the default of the relevant domain - * - * The default blr is returned in buffer. The blr is of the form - * blr_version4 blr_literal ..... blr_eoc - * - * Reads the system tables RDB$FIELDS and RDB$RELATION_FIELDS. - * - **************************************************************/ - thread_db* tdbb = JRD_get_thread_data(); - - validateTransaction(transaction); - - dsql_dbb* dbb = transaction->getDsqlAttachment(); - bid* blob_id; - - USHORT result = 0; - blb* blob_handle = 0; - - *has_default = false; - - AutoCacheRequest handle(tdbb, irq_col_default, IRQ_REQUESTS); - - FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction) - RFL IN RDB$RELATION_FIELDS CROSS - FLD IN RDB$FIELDS WITH - RFL.RDB$RELATION_NAME EQ for_rel_name AND - RFL.RDB$FIELD_SOURCE EQ FLD.RDB$FIELD_NAME AND - RFL.RDB$FIELD_NAME EQ for_col_name - { - if (!RFL.RDB$DEFAULT_VALUE.NULL) - { - blob_id = &RFL.RDB$DEFAULT_VALUE; - *has_default = true; - } - else if (!FLD.RDB$DEFAULT_VALUE.NULL) - { - blob_id = &FLD.RDB$DEFAULT_VALUE; - *has_default = true; - } - else - *has_default = false; - - if (*has_default) - { - blob_handle = blb::open2(tdbb, transaction, blob_id, sizeof(blr_bpb), blr_bpb, true); - - // fetch segments. Assuming here that the buffer is big enough. - UCHAR* ptr_in_buffer = buffer; - while (true) - { - const USHORT length = blob_handle->BLB_get_segment(tdbb, ptr_in_buffer, buff_length); - - ptr_in_buffer += length; - buff_length -= length; - result += length; - - if (blob_handle->blb_flags & BLB_eof) - { - // null terminate the buffer - *ptr_in_buffer = 0; - break; - } - if (blob_handle->getFragmentSize()) - status_exception::raise(Arg::Gds(isc_segment)); - else - continue; - } - - try - { - ThreadStatusGuard status_vector(tdbb); - - blob_handle->BLB_close(tdbb); - blob_handle = NULL; - } - catch (Exception&) - { - } - - // the default string must be of the form: - // blr_version4 blr_literal ..... blr_eoc - fb_assert((buffer[0] == blr_version4) || (buffer[0] == blr_version5)); - fb_assert(buffer[1] == blr_literal); - } - else - { - if (dbb->dbb_db_SQL_dialect > SQL_DIALECT_V5) - buffer[0] = blr_version5; - else - buffer[0] = blr_version4; - buffer[1] = blr_eoc; - result = 2; - } - } - END_FOR - - return result; -} - - dsql_intlsym* METD_get_charset(jrd_tra* transaction, USHORT length, const char* name) // UTF-8 { /************************************** @@ -711,100 +599,6 @@ bool METD_get_domain(jrd_tra* transaction, TypeClause* field, const MetaName& na } -USHORT METD_get_domain_default(jrd_tra* transaction, const MetaName& domain_name, bool* has_default, - UCHAR* buffer, USHORT buff_length) -{ -/************************************************************* - * - * M E T D _ g e t _ d o m a i n _ d e f a u l t - * - ************************************************************** - * - * Function: - * Gets the default value for a domain of an existing table. - * - **************************************************************/ - thread_db* tdbb = JRD_get_thread_data(); - - validateTransaction(transaction); - - *has_default = false; - - dsql_dbb* dbb = transaction->getDsqlAttachment(); - USHORT result = 0; - - AutoCacheRequest handle(tdbb, irq_domain_2, IRQ_REQUESTS); - - FOR(REQUEST_HANDLE handle TRANSACTION_HANDLE transaction) - FLD IN RDB$FIELDS WITH FLD.RDB$FIELD_NAME EQ domain_name.c_str() - { - bid* blob_id; - if (!FLD.RDB$DEFAULT_VALUE.NULL) - { - blob_id = &FLD.RDB$DEFAULT_VALUE; - *has_default = true; - } - else - *has_default = false; - - if (*has_default) - { - blb* blob_handle = blb::open2(tdbb, transaction, blob_id, sizeof(blr_bpb), blr_bpb, true); - - // fetch segments. Assume buffer is big enough. - UCHAR* ptr_in_buffer = buffer; - while (true) - { - const USHORT length = blob_handle->BLB_get_segment(tdbb, ptr_in_buffer, buff_length); - - ptr_in_buffer += length; - buff_length -= length; - result += length; - - if (blob_handle->blb_flags & BLB_eof) - { - // null terminate the buffer - *ptr_in_buffer = 0; - break; - } - if (blob_handle->getFragmentSize()) - status_exception::raise(Arg::Gds(isc_segment)); - else - continue; - } - - try - { - ThreadStatusGuard status_vector(tdbb); - - blob_handle->BLB_close(tdbb); - blob_handle = NULL; - } - catch (Exception&) - { - } - - // the default string must be of the form: - // blr_version4 blr_literal ..... blr_eoc - fb_assert((buffer[0] == blr_version4) || (buffer[0] == blr_version5)); - fb_assert(buffer[1] == blr_literal); - } - else - { - if (dbb->dbb_db_SQL_dialect > SQL_DIALECT_V5) - buffer[0] = blr_version5; - else - buffer[0] = blr_version4; - buffer[1] = blr_eoc; - result = 2; - } - } - END_FOR - - return result; -} - - 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 bef7985b1f..64a921bc13 100644 --- a/src/dsql/metd_proto.h +++ b/src/dsql/metd_proto.h @@ -55,10 +55,8 @@ Jrd::dsql_intlsym* METD_get_charset(Jrd::jrd_tra*, USHORT, const char* name); USHORT METD_get_charset_bpc(Jrd::jrd_tra*, SSHORT); Firebird::MetaName METD_get_charset_name(Jrd::jrd_tra*, SSHORT); Jrd::dsql_intlsym* METD_get_collation(Jrd::jrd_tra*, const Firebird::MetaName&, USHORT charset_id); -USHORT METD_get_col_default(Jrd::jrd_tra*, const char*, const char*, bool*, UCHAR*, USHORT); Firebird::MetaName METD_get_default_charset(Jrd::jrd_tra*); bool METD_get_domain(Jrd::jrd_tra*, class Jrd::TypeClause*, const Firebird::MetaName& name); -USHORT METD_get_domain_default(Jrd::jrd_tra*, const Firebird::MetaName&, bool*, UCHAR*, USHORT); 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 a02f92578b..652b210731 100644 --- a/src/jrd/irq.h +++ b/src/jrd/irq.h @@ -145,8 +145,6 @@ enum irq_type_t irq_charset, // DSQL/METD: lookup a character set irq_domain, // DSQL/METD: lookup a domain 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_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