bytes.slt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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/bytes
  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. mode cockroach
  20. # query T
  21. # SHOW bytea_output
  22. # ----
  23. # hex
  24. query T
  25. SELECT 'non-escaped-string'::bytea::text
  26. ----
  27. \x6e6f6e2d657363617065642d737472696e67
  28. # TODO(benesch): support escape string literals.
  29. #
  30. # query T
  31. # SELECT e'\x5c\x78'::text
  32. # ----
  33. # \x
  34. #
  35. # query T
  36. # SELECT e'a\\134b\nc\'e'::text::bytea::text
  37. # ----
  38. # \x615c620a632765
  39. query T
  40. SELECT '日本語'::text::bytea::text
  41. ----
  42. \xe697a5e69cace8aa9e
  43. query error invalid input syntax for type bytea: invalid escape sequence
  44. SELECT '\400'::bytea
  45. # TODO(benesch): support bytea_output.
  46. #
  47. # statement ok
  48. # SET bytea_output = escape
  49. #
  50. # query T
  51. # SELECT 'non-escaped-text'::bytea::text
  52. # ----
  53. # non-escaped-text
  54. #
  55. # query T
  56. # SELECT '\Xabcd'::bytea::text
  57. # ----
  58. # \253\315
  59. #
  60. # query T
  61. # SELECT b'\x5c\x78'::bytea
  62. # ----
  63. # \x
  64. #
  65. # query T
  66. # SELECT b'\x5c\x78'::bytea::text
  67. # ----
  68. # \\x
  69. #
  70. # query T
  71. # SELECT b'\x5c\x58'::bytea::text
  72. # ----
  73. # \\X
  74. #
  75. # query T
  76. # SELECT e'\x5c\x78'::text
  77. # ----
  78. # \x
  79. #
  80. # query T
  81. # SELECT '\X'::bytea::text
  82. # ----
  83. # ·
  84. #
  85. # query T
  86. # SELECT e'a\\134b\nc\'e'::text::bytea::text
  87. # ----
  88. # a\\b\012c'e
  89. #
  90. # query T
  91. # SELECT '日本語'::text::bytea::text
  92. # ----
  93. # \346\227\245\346\234\254\350\252\236
  94. subtest Regression_25841
  95. # statement ok
  96. # set bytea_output = hex
  97. query T
  98. SELECT 'a\\b'::text::bytea
  99. ----
  100. a\b
  101. query I
  102. SELECT length('a\\b'::text::bytea)
  103. ----
  104. 3
  105. query error invalid input syntax for type bytea: invalid escape sequence
  106. SELECT 'a\bcde'::text::bytea
  107. query error invalid input syntax for type bytea: invalid escape sequence
  108. SELECT 'a\01'::text::bytea
  109. query error invalid input syntax for type bytea: ends with escape character
  110. SELECT 'a\'::text::bytea
  111. subtest Regression_27950
  112. # statement ok
  113. # set bytea_output = hex
  114. statement ok
  115. CREATE TABLE t(b bytea)
  116. statement ok
  117. INSERT INTO t(b) VALUES ('\xe697a5e69cace8aa9e'::bytea)
  118. query TT
  119. SELECT b, b::text FROM t
  120. ----
  121. 日本語 \xe697a5e69cace8aa9e
  122. # statement ok
  123. # set bytea_output = escape
  124. #
  125. # query TT
  126. # SELECT b, b::text FROM t
  127. # ----
  128. # 日本語 \346\227\245\346\234\254\350\252\236
  129. statement ok
  130. DROP TABLE t