MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / setDecDesc

Function setDecDesc

src/dsql/ExprNodes.cpp:700–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

698enum Scaling { SCALE_MIN, SCALE_SUM };
699
700USHORT setDecDesc(dsc* desc, const dsc& desc1, const dsc& desc2, Scaling sc, SCHAR* nodScale = nullptr)
701{
702 UCHAR zipType = decimalDescTable[getFType(desc1)][getFType(desc2)];
703 fb_assert(zipType <= DSC_ZTYPE_FIXED);
704 if (zipType > DSC_ZTYPE_FIXED)
705 zipType = DSC_ZTYPE_FLT128; // In production case fallback to Decimal128
706
707 desc->dsc_dtype = zipType == DSC_ZTYPE_FLT64 ? dtype_dec64 :
708 zipType == DSC_ZTYPE_FLT128 ? dtype_dec128 : dtype_int128;
709 if (!setFixedSubType(desc, desc1, desc2))
710 desc->dsc_sub_type = 0;
711 desc->dsc_flags = (desc1.dsc_flags | desc2.dsc_flags) & DSC_nullable;
712 desc->dsc_scale = 0;
713
714 if (zipType == DSC_ZTYPE_FIXED)
715 {
716 switch (sc)
717 {
718 case SCALE_MIN:
719 desc->dsc_scale = MIN(NUMERIC_SCALE(desc1), NUMERIC_SCALE(desc2));
720 break;
721 case SCALE_SUM:
722 desc->dsc_scale = NUMERIC_SCALE(desc1) + NUMERIC_SCALE(desc2);
723 break;
724 }
725 }
726
727 if (nodScale)
728 *nodScale = desc->dsc_scale;
729
730 desc->dsc_length = zipType == DSC_ZTYPE_FLT64 ? sizeof(Decimal64) :
731 zipType == DSC_ZTYPE_FLT128 ? sizeof(Decimal128) : sizeof(Int128);
732
733 return zipType == DSC_ZTYPE_FIXED ? ExprNode::FLAG_INT128 : ExprNode::FLAG_DECFLOAT;
734}
735
736} // anon namespace
737

Callers 4

makeDialect1Method · 0.85
makeDialect3Method · 0.85
getDescDialect1Method · 0.85
getDescDialect3Method · 0.85

Calls 3

getFTypeFunction · 0.85
setFixedSubTypeFunction · 0.85
NUMERIC_SCALEFunction · 0.85

Tested by

no test coverage detected