From d334575818ad7f0f09144ed3c96fe28d8760b0c8 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes Date: Mon, 29 May 2017 16:39:12 +0000 Subject: [PATCH] Fixed CORE-5550 - Computed decimal field in a view has wrong RDB$FIELD_PRECISION. --- src/dsql/DdlNodes.epp | 24 ++++-------------------- src/dsql/dsql.h | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index 4162835f0a..bd707ad8bd 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -393,26 +393,8 @@ void defineComputed(DsqlCompilerScratch* dsqlScratch, RelationSourceNode* relati field->subType = desc.dsc_sub_type; } - if (field && field->precision == 0 && field->scale != 0) - { - switch (field->dtype) - { - case dtype_short: - field->precision = 4; - break; - - case dtype_long: - field->precision = 9; - break; - - case dtype_int64: - field->precision = 18; - break; - - default: - fb_assert(!DTYPE_IS_EXACT(field->dtype)); - } - } + if (field) + field->setExactPrecision(); dsqlScratch->resetContextStack(); @@ -8872,6 +8854,8 @@ void CreateAlterViewNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra else newField.subType = desc.dsc_sub_type; + newField.setExactPrecision(); + if (relField) // modifying a view { AutoRequest request2; diff --git a/src/dsql/dsql.h b/src/dsql/dsql.h index 8d8033a8ce..e568dfc5ac 100644 --- a/src/dsql/dsql.h +++ b/src/dsql/dsql.h @@ -237,6 +237,31 @@ public: { } +public: + void setExactPrecision() + { + if (precision != 0) + return; + + switch (dtype) + { + case dtype_short: + precision = 4; + break; + + case dtype_long: + precision = 9; + break; + + case dtype_int64: + precision = 18; + break; + + default: + fb_assert(!DTYPE_IS_EXACT(dtype)); + } + } + public: USHORT dtype; FLD_LENGTH length;