github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/sem/tree/testdata/eval/overflow (about)

     1  # Overflow
     2  
     3  eval
     4  0:::int * 0:::int
     5  ----
     6  0
     7  
     8  eval
     9  0:::int * 1:::int
    10  ----
    11  0
    12  
    13  eval
    14  1:::int * 0:::int
    15  ----
    16  0
    17  
    18  eval
    19  1:::int * 1:::int
    20  ----
    21  1
    22  
    23  eval
    24  4611686018427387904:::int * 1:::int
    25  ----
    26  4611686018427387904
    27  
    28  eval
    29  -4611686018427387905:::int * 1:::int
    30  ----
    31  -4611686018427387905
    32  
    33  # Although int64 can express this value, using it like this produces an
    34  # error in Postgres.
    35  eval
    36  -9223372036854775808:::int8
    37  ----
    38  numeric constant out of int64 range
    39  
    40  eval
    41  9223372036854775808:::int8
    42  ----
    43  numeric constant out of int64 range
    44  
    45  eval
    46  -9223372036854775807:::int8
    47  ----
    48  -9223372036854775807
    49  
    50  eval
    51  9223372036854775807:::int8
    52  ----
    53  9223372036854775807
    54  
    55  # We would expect that this expression has the same result as
    56  # -9223372036854775808:::int8, but in both Postgres and Cockroach it
    57  # is valid.
    58  eval
    59  -9223372036854775807:::int8 - 1
    60  ----
    61  -9223372036854775808
    62  
    63  eval
    64  -9223372036854775807:::int8 - 2
    65  ----
    66  integer out of range
    67  
    68  eval
    69  9223372036854775807:::int8 + 1
    70  ----
    71  integer out of range