decimal-overflow.td 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. #
  10. # Test that check that various overflow and carry-over conditions are handled
  11. #
  12. # Value becomes greater than 1
  13. > SELECT '0.999999999999999999999999999999999999999'::decimal + '0.000000000000000000000000000000000000001'::decimal
  14. 1
  15. # Division creates a number that is too small
  16. ! SELECT '0.000000000000000000000000000000000000001'::decimal / 10::decimal;
  17. contains:value out of range: underflow
  18. # Division creates a number that is too large
  19. ! SELECT '999999999999999999999999999999999999999'::decimal / 0.1::decimal;
  20. contains:value out of range: overflow
  21. # Multilication creates a number that is too small
  22. ! SELECT '0.000000000000000000000000000000000000001'::decimal * 0.1::decimal;
  23. contains:value out of range: underflow
  24. # Multiplication creates a number that is too large
  25. ! SELECT '999999999999999999999999999999999999999'::decimal * 10::decimal;
  26. contains:value out of range: overflow
  27. # ROUND creates a value that is too large
  28. ! SELECT ROUND('999999999999999999999999999999999999999'::decimal,1);
  29. contains:value out of range: overflow
  30. # POW
  31. ! SELECT POW(99999::decimal,9);
  32. contains:value out of range: overflow
  33. # Conversion from double
  34. ! SELECT 999999999999999999999999999999999999999::double::decimal;
  35. contains:numeric field overflow