Class NumericRangeRefusal

java.lang.Object
dev.frostlake.executor.NumericRangeRefusal

public final class NumericRangeRefusal extends Object
The sentence a number too wide for its destination gets. Live spells the INTERNAL type rather than the SQL one, and the three source families get three different sentences — measured, not derived:
   CAST(1000 AS NUMBER(2,0))               Number out of representable range: type FIXED[SB2](2,0){not null}, value 1000
   CAST(1 AS NUMBER(0,0))                  Number out of representable range: type FIXED[SB1]{not null}, value 1
   CAST(PARSE_JSON('1000') AS NUMBER(2,0)) Number out of representable range: type FIXED, value 1000
   CAST('1000' AS NUMBER(2,0))             Numeric value '1000' is out of range
 

★ THE WIDTH IS OMITTED AT PRECISION ZERO and printed everywhere else — NUMBER(0,0) reads FIXED[SB1]{not null} with no parentheses at all. A VARIANT source drops the class AND the width, keeping the bare family name.

★ THE NULLABILITY IS PART OF THE TYPE, and it is read from where the number was GOING or coming FROM rather than from the number: a literal is not null, a nullable column nullable.

★ THE CLASS FOLLOWS THE VALUE ON EVERY PATH BUT ONE. A cast, an INSERT … SELECT, an UPDATE and a MERGE all tag the VALUE that would not fit (SignedStorageWidth.tagOf(java.lang.Object, int)); only INSERT … VALUES tags the COLUMN's own slot (SignedStorageWidth.tagOfPrecision(int)), which is what makes the two spellings of one write disagree: a 10^11 written into a NUMBER(2,0) reads SB1 through VALUES and SB8 through SET. An approximate (FLOAT) source tags the slot too — there is no unscaled integer to measure.

The whole family is ROW-TIME: over an empty table the same conversion refuses nothing, on both engines, so none of these sentences carries a compilation prefix or a position.

  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    exceeds(BigDecimal value, int precision, int scale)
    Whether value needs more digits left of the point than a NUMBER(precision, scale) has room for.
    static String
    gText(double value)
    A double in live's overflow-value spelling: six significant digits, trailing zeros dropped, lowercase e with a signed exponent — 3e+38, 1.5e+39, 1.70141e+38.
    static boolean
    Whether a raw scaled integer is outside the signed 128-bit carrier.
    static boolean
    pastEveryNumber(BigDecimal value, int scale)
    Whether a value is past what EVERY exact number can hold, taken at scale the way exceeds(java.math.BigDecimal, int, int) takes it — so a string of decimals that merely rounds away stays readable ('0.999…9' with thirty-nine decimals is 1, not an overflow).
    static String
    typed(String storageTag, int precision, int scale, boolean nullable, BigDecimal value)
    The full sentence: storage class, declared width, nullability, value.
    static String
    typedDouble(String storageTag, int precision, int scale, boolean nullable, BigDecimal value)
    The sentence with the value printed as a DOUBLE in live's six-significant-digit scientific form — the render every raw-integer and quotient overflow uses, even when the digits would fit the carrier (live-verified: a quotient of 1.11…e38 prints 1.11111e+38, not its digits).
    static String
    typedText(String storageTag, int precision, int scale, boolean nullable, String valueText)
    The typed sentence with the value's text supplied by the caller — for the refusals whose value live prints at its own scale, trailing zeros and all, rather than stripped.
    static String
    The sentence a STRING source gets — a different family, naming the text rather than the type.
    static String
    The sentence a STRING earns when its value needs more digits than ANY number holds, which live treats as a failure to READ the text rather than a complaint about where it was going:
    static String
    The sentence a VARIANT source gets: the family alone, with neither class nor width.
    static String
    The value as live prints it: its own digits with trailing zeros dropped, so a 1000.00 that failed a NUMBER(2,0) reads 1000 while a 12.399 that failed a NUMBER(3,2) keeps all of 12.399 — the number as WRITTEN, not as the destination would have rounded it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • typed

      public static String typed(String storageTag, int precision, int scale, boolean nullable, BigDecimal value)
      The full sentence: storage class, declared width, nullability, value.
    • typedText

      public static String typedText(String storageTag, int precision, int scale, boolean nullable, String valueText)
      The typed sentence with the value's text supplied by the caller — for the refusals whose value live prints at its own scale, trailing zeros and all, rather than stripped.
      Parameters:
      storageTag - the SBn tag
      precision - the declared precision, or 0 for an untyped carrier
      scale - the declared scale
      nullable - whether the carrier is nullable
      valueText - the value exactly as the sentence prints it
      Returns:
      the sentence
    • typedDouble

      public static String typedDouble(String storageTag, int precision, int scale, boolean nullable, BigDecimal value)
      The sentence with the value printed as a DOUBLE in live's six-significant-digit scientific form — the render every raw-integer and quotient overflow uses, even when the digits would fit the carrier (live-verified: a quotient of 1.11…e38 prints 1.11111e+38, not its digits).
    • outsideSb16Window

      public static boolean outsideSb16Window(BigInteger raw)
      Whether a raw scaled integer is outside the signed 128-bit carrier. The bound is two's-complement ASYMMETRIC on purpose: -2^127 itself is representable and live answers it (live-verified), while +2^127 is the first refusal on the positive side.
    • gText

      public static String gText(double value)
      A double in live's overflow-value spelling: six significant digits, trailing zeros dropped, lowercase e with a signed exponent — 3e+38, 1.5e+39, 1.70141e+38.
    • untyped

      public static String untyped(BigDecimal value)
      The sentence a VARIANT source gets: the family alone, with neither class nor width.
    • unconvertibleText

      public static String unconvertibleText(Object text)
      The sentence a STRING source gets — a different family, naming the text rather than the type.
    • unreadableText

      public static String unreadableText(Object text)
      The sentence a STRING earns when its value needs more digits than ANY number holds, which live treats as a failure to READ the text rather than a complaint about where it was going:
         '123456789012'::NUMBER(10,0)   is out of range      fits a NUMBER, not THIS one
         '999…9'(39)::NUMBER(10,0)      is not recognized    fits no NUMBER at all
         '999…9'(39)::NUMBER(38,0)      is not recognized    …the target makes no difference
       

      The text is echoed exactly as written — live keeps its leading zeros, its sign and its fraction — and the TRY_ spellings answer NULL for both sentences.

      Parameters:
      text - the source text
      Returns:
      the sentence
    • pastEveryNumber

      public static boolean pastEveryNumber(BigDecimal value, int scale)
      Whether a value is past what EVERY exact number can hold, taken at scale the way exceeds(java.math.BigDecimal, int, int) takes it — so a string of decimals that merely rounds away stays readable ('0.999…9' with thirty-nine decimals is 1, not an overflow).
      Parameters:
      value - the parsed value
      scale - the scale it is being read at
      Returns:
      whether no NUMBER could hold it
    • exceeds

      public static boolean exceeds(BigDecimal value, int precision, int scale)
      Whether value needs more digits left of the point than a NUMBER(precision, scale) has room for. The value is taken at the TARGET's scale first, so a number that merely carries extra fractional digits rounds into range instead of overflowing.
    • valueText

      public static String valueText(BigDecimal value)
      The value as live prints it: its own digits with trailing zeros dropped, so a 1000.00 that failed a NUMBER(2,0) reads 1000 while a 12.399 that failed a NUMBER(3,2) keeps all of 12.399 — the number as WRITTEN, not as the destination would have rounded it.