forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bytea.slt
103 lines (84 loc) · 1.66 KB
/
bytea.slt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
# Tests for the bytea type.
mode cockroach
statement ok
CREATE TABLE test (ord int, b bytea)
statement ok
INSERT INTO test VALUES (0, 'hello'), (1, '你好'), (2, NULL), (3, ''), (4, 'nonprintablechar:')
query II rowsort
SELECT ord, length(b) FROM test
----
0 5
1 6
2 NULL
3 0
4 18
query II rowsort
SELECT ord, length(b, 'utf-8') FROM test
----
0 5
1 2
2 NULL
3 0
4 18
query I
SELECT length('\xDEADBEEF'::bytea)
----
4
query I
SELECT octet_length('\xDEADBEEF'::bytea)
----
4
query I
SELECT bit_length('\xDEADBEEF'::bytea)
----
32
query I
SELECT length('DEADBEEF'::bytea)
----
8
query I
SELECT octet_length('DEADBEEF'::bytea)
----
8
query I
SELECT octet_length('DEADBEEF'::text);
----
8
query I
SELECT bit_length('DEADBEEF'::bytea)
----
64
query I
SELECT bit_length('DEADBEEF'::text);
----
64
statement error
SELECT length('deadbeef'::text, 'utf-8')
query IT rowsort
SELECT ord, b::text FROM test
----
0 \x68656c6c6f
1 \xe4bda0e5a5bd
2 NULL
3 \x
4 \x6e6f6e7072696e7461626c65636861723a06
query IT rowsort
SELECT ord, convert_from(b, 'utf-8') FROM test
----
0 hello
1 你好
2 NULL
3 (empty)
4 nonprintablechar:
query error invalid encoding name 'invalid encoding'
SELECT convert_from(b, 'invalid encoding') FROM test
query error invalid utf-8 sequence of 1 bytes
SELECT convert_from('\x00ff', 'utf-8')