shift.slt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Copyright 2015 - 2019 The Cockroach Authors. All rights reserved.
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. #
  11. # This file is derived from the logic test suite in CockroachDB. The
  12. # original file was retrieved on June 10, 2019 from:
  13. #
  14. # https://github.com/cockroachdb/cockroach/blob/d2f7fbf5dd1fc1a099bbad790a2e1f7c60a66cc3/pkg/sql/logictest/testdata/logic_test/shift
  15. #
  16. # The original source code is subject to the terms of the Apache
  17. # 2.0 license, a copy of which can be found in the LICENSE file at the
  18. # root of this repository.
  19. # not supported yet
  20. halt
  21. mode cockroach
  22. # Check non-constant eval
  23. statement ok
  24. CREATE TABLE t AS SELECT 1 AS i
  25. statement error shift argument out of range
  26. SELECT i << 64 FROM t
  27. statement error shift argument out of range
  28. SELECT i >> 64 FROM t
  29. statement error shift argument out of range
  30. SELECT i << -1 FROM t
  31. statement error shift argument out of range
  32. SELECT i >> -1 FROM t
  33. query II
  34. SELECT i << 63 >> 63, i << 62 >> 62 FROM t
  35. ----
  36. -1 1
  37. # Check constant folding
  38. statement error shift argument out of range
  39. SELECT 1 << 64
  40. statement error shift argument out of range
  41. SELECT 1 >> 64
  42. statement error shift argument out of range
  43. SELECT 1 << -1
  44. statement error shift argument out of range
  45. SELECT 1 >> -1
  46. query II
  47. SELECT 1 << 63 >> 63, 1 << 62 >> 62
  48. ----
  49. -1 1
  50. # Ensure that shift returns the same result as an int or a constant
  51. query II
  52. SELECT 1 << 63 >> 63, 1::INT << 63 >> 63
  53. ----
  54. -1 -1