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

Method execute

src/dsql/ExprNodes.cpp:1971–2052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1969}
1970
1971dsc* ArithmeticNode::execute(thread_db* tdbb, Request* request) const
1972{
1973 impure_value* const impure = request->getImpure<impure_value>(impureOffset);
1974
1975 request->req_flags &= ~req_null;
1976
1977 // Evaluate arguments. If either is null, result is null, but in
1978 // any case, evaluate both, since some expressions may later depend
1979 // on mappings which are developed here
1980
1981 const dsc* desc1 = EVL_expr(tdbb, request, arg1);
1982 const ULONG flags = request->req_flags;
1983 request->req_flags &= ~req_null;
1984
1985 const dsc* desc2 = EVL_expr(tdbb, request, arg2);
1986
1987 // restore saved NULL state
1988
1989 if (flags & req_null)
1990 request->req_flags |= req_null;
1991
1992 if (request->req_flags & req_null)
1993 return NULL;
1994
1995 EVL_make_value(tdbb, desc1, impure);
1996
1997 if (dialect1) // dialect-1 semantics
1998 {
1999 switch (blrOp)
2000 {
2001 case blr_add:
2002 case blr_subtract:
2003 return add(tdbb, desc2, impure, this, blrOp);
2004
2005 case blr_divide:
2006 {
2007 const double divisor = MOV_get_double(tdbb, desc2);
2008
2009 if (divisor == 0)
2010 {
2011 ERR_post(Arg::Gds(isc_arith_except) <<
2012 Arg::Gds(isc_exception_float_divide_by_zero));
2013 }
2014
2015 impure->vlu_misc.vlu_double = MOV_get_double(tdbb, desc1) / divisor;
2016
2017 if (std::isinf(impure->vlu_misc.vlu_double))
2018 {
2019 ERR_post(Arg::Gds(isc_arith_except) <<
2020 Arg::Gds(isc_exception_float_overflow));
2021 }
2022
2023 impure->vlu_desc.dsc_dtype = DEFAULT_DOUBLE;
2024 impure->vlu_desc.dsc_length = sizeof(double);
2025 impure->vlu_desc.dsc_address = (UCHAR*) &impure->vlu_misc;
2026
2027 return &impure->vlu_desc;
2028 }

Callers

nothing calls this directly

Calls 15

EVL_exprFunction · 0.85
EVL_make_valueFunction · 0.85
MOV_get_doubleFunction · 0.85
GdsClass · 0.85
isinfFunction · 0.85
MOV_make_string2Function · 0.85
MOV_moveFunction · 0.85
DSC_EQUIVFunction · 0.85
DTYPE_IS_TEXTFunction · 0.85
DSC_string_lengthFunction · 0.85
EVL_validateFunction · 0.85

Tested by

no test coverage detected