MCPcopy Create free account
hub / github.com/MariaDB/server / GetCalcValue

Method GetCalcValue

storage/connect/bsonudf.cpp:626–703  ·  view source on GitHub ↗

/ Get the value used for calculating the array. */ /

Source from the content-addressed store, hash-verified

624/* Get the value used for calculating the array. */
625/*********************************************************************************/
626PVAL BJNX::GetCalcValue(PGLOBAL g, PBVAL bap, int n)
627{
628 // For calculated arrays, a local Value must be used
629 int lng = 0;
630 short type = 0, prec = 0;
631 bool b = n < Nod - 1;
632 PVAL valp;
633 PBVAL vlp, vp;
634 OPVAL op = Nodes[n].Op;
635
636 switch (op) {
637 case OP_NUM:
638 type = TYPE_INT;
639 break;
640 case OP_ADD:
641 case OP_MULT:
642 if (!IsTypeNum(Buf_Type)) {
643 type = TYPE_INT;
644 prec = 0;
645
646 for (vlp = GetArray(bap); vlp; vlp = GetNext(vlp)) {
647 vp = (b && IsJson(vlp)) ? GetRowValue(g, vlp, n + 1) : vlp;
648
649 switch (vp->Type) {
650 case TYPE_BINT:
651 if (type == TYPE_INT)
652 type = TYPE_BIGINT;
653
654 break;
655 case TYPE_DBL:
656 case TYPE_FLOAT:
657 type = TYPE_DOUBLE;
658 prec = MY_MAX(prec, vp->Nd);
659 break;
660 default:
661 break;
662 } // endswitch Type
663
664 } // endfor vlp
665
666 } else {
667 type = Buf_Type;
668 prec = GetPrecision();
669 } // endif Buf_Type
670
671 break;
672 case OP_SEP:
673 if (IsTypeChar(Buf_Type)) {
674 type = TYPE_DOUBLE;
675 prec = 2;
676 } else {
677 type = Buf_Type;
678 prec = GetPrecision();
679 } // endif Buf_Type
680
681 break;
682 case OP_MIN:
683 case OP_MAX:

Callers

nothing calls this directly

Calls 6

IsJsonFunction · 0.85
IsTypeCharFunction · 0.85
AllocateValueFunction · 0.85
IsTypeNumFunction · 0.70
GetNextFunction · 0.70
GetPrecisionFunction · 0.70

Tested by

no test coverage detected