(src []byte, dst any)
| 600 | type scanPlanBinaryNumericToNumericScanner struct{} |
| 601 | |
| 602 | func (scanPlanBinaryNumericToNumericScanner) Scan(src []byte, dst any) error { |
| 603 | scanner := (dst).(NumericScanner) |
| 604 | |
| 605 | if src == nil { |
| 606 | return scanner.ScanNumeric(Numeric{}) |
| 607 | } |
| 608 | |
| 609 | if len(src) < 8 { |
| 610 | return fmt.Errorf("numeric incomplete %v", src) |
| 611 | } |
| 612 | |
| 613 | rp := 0 |
| 614 | ndigits := binary.BigEndian.Uint16(src[rp:]) |
| 615 | rp += 2 |
| 616 | weight := int16(binary.BigEndian.Uint16(src[rp:])) |
| 617 | rp += 2 |
| 618 | sign := binary.BigEndian.Uint16(src[rp:]) |
| 619 | rp += 2 |
| 620 | dscale := int16(binary.BigEndian.Uint16(src[rp:])) |
| 621 | rp += 2 |
| 622 | |
| 623 | switch sign { |
| 624 | case pgNumericNaNSign: |
| 625 | return scanner.ScanNumeric(Numeric{NaN: true, Valid: true}) |
| 626 | case pgNumericPosInfSign: |
| 627 | return scanner.ScanNumeric(Numeric{InfinityModifier: Infinity, Valid: true}) |
| 628 | case pgNumericNegInfSign: |
| 629 | return scanner.ScanNumeric(Numeric{InfinityModifier: NegativeInfinity, Valid: true}) |
| 630 | } |
| 631 | |
| 632 | if ndigits == 0 { |
| 633 | return scanner.ScanNumeric(Numeric{Int: big.NewInt(0), Valid: true}) |
| 634 | } |
| 635 | |
| 636 | if len(src[rp:]) < int(ndigits)*2 { |
| 637 | return fmt.Errorf("numeric incomplete %v", src) |
| 638 | } |
| 639 | |
| 640 | accum := &big.Int{} |
| 641 | |
| 642 | for i := 0; i < int(ndigits+3)/4; i++ { |
| 643 | int64accum, bytesRead, digitsRead := nbaseDigitsToInt64(src[rp:]) |
| 644 | rp += bytesRead |
| 645 | |
| 646 | if i > 0 { |
| 647 | var mul *big.Int |
| 648 | switch digitsRead { |
| 649 | case 1: |
| 650 | mul = bigNBase |
| 651 | case 2: |
| 652 | mul = bigNBaseX2 |
| 653 | case 3: |
| 654 | mul = bigNBaseX3 |
| 655 | case 4: |
| 656 | mul = bigNBaseX4 |
| 657 | default: |
| 658 | return fmt.Errorf("invalid digitsRead: %d (this can't happen)", digitsRead) |
| 659 | } |
nothing calls this directly
no test coverage detected