aboutsummaryrefslogtreecommitdiff
path: root/src/test/modules/test_tidstore/expected/test_tidstore.out
blob: cbcacfd26e178d0ced36cc94d460271571c49fdb (plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
CREATE EXTENSION test_tidstore;
-- To hide the output of do_set_block_offsets()
CREATE TEMP TABLE hideblocks(blockno bigint);
-- Constant values used in the tests.
\set maxblkno 4294967295
-- The maximum number of heap tuples (MaxHeapTuplesPerPage) in 8kB block is 291.
-- We use a higher number to test tidstore.
\set maxoffset 512
SELECT test_create(false);
 test_create 
-------------
 
(1 row)

-- Test on empty tidstore.
SELECT test_is_full();
 test_is_full 
--------------
 f
(1 row)

SELECT check_set_block_offsets();
 check_set_block_offsets 
-------------------------
 
(1 row)

-- Add TIDs.
INSERT INTO hideblocks (blockno)
SELECT do_set_block_offsets(blk, array_agg(off)::int2[])
  FROM
    (VALUES (0), (1), (:maxblkno / 2), (:maxblkno - 1), (:maxblkno)) AS blocks(blk),
    (VALUES (1), (2), (:maxoffset / 2), (:maxoffset - 1), (:maxoffset)) AS offsets(off)
  GROUP BY blk;
-- Test offsets embedded in the bitmap header.
SELECT do_set_block_offsets(501, array[greatest((random() * :maxoffset)::int, 1)]::int2[]);
 do_set_block_offsets 
----------------------
                  501
(1 row)

SELECT do_set_block_offsets(502, array_agg(DISTINCT greatest((random() * :maxoffset)::int, 1))::int2[])
  FROM generate_series(1, 3);
 do_set_block_offsets 
----------------------
                  502
(1 row)

-- Add enough TIDs to cause the store to appear "full", compared
-- to the allocated memory it started out with. This is easier
-- with memory contexts in local memory.
INSERT INTO hideblocks (blockno)
SELECT do_set_block_offsets(blk, ARRAY[1,31,32,63,64,200]::int2[])
  FROM generate_series(1000, 2000, 1) blk;
-- Zero offset not allowed
SELECT do_set_block_offsets(1, ARRAY[0]::int2[]);
ERROR:  tuple offset out of range: 0
-- Check TIDs we've added to the store.
SELECT check_set_block_offsets();
 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT test_is_full();
 test_is_full 
--------------
 t
(1 row)

-- Re-create the TID store for randommized tests.
SELECT test_destroy();
 test_destroy 
--------------
 
(1 row)

-- Test replacements crossing RT_CHILDPTR_IS_VALUE in both directions
SELECT test_create(false);
 test_create 
-------------
 
(1 row)

SELECT do_set_block_offsets(1, array[1]::int2[]); SELECT check_set_block_offsets();
 do_set_block_offsets 
----------------------
                    1
(1 row)

 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT do_set_block_offsets(1, array[1,2]::int2[]); SELECT check_set_block_offsets();
 do_set_block_offsets 
----------------------
                    1
(1 row)

 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT do_set_block_offsets(1, array[1,2,3]::int2[]); SELECT check_set_block_offsets();
 do_set_block_offsets 
----------------------
                    1
(1 row)

 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT do_set_block_offsets(1, array[1,2,3,4]::int2[]); SELECT check_set_block_offsets();
 do_set_block_offsets 
----------------------
                    1
(1 row)

 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT do_set_block_offsets(1, array[1,2,3,4,100]::int2[]); SELECT check_set_block_offsets();
 do_set_block_offsets 
----------------------
                    1
(1 row)

 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT do_set_block_offsets(1, array[1,2,3,4]::int2[]); SELECT check_set_block_offsets();
 do_set_block_offsets 
----------------------
                    1
(1 row)

 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT do_set_block_offsets(1, array[1,2,3]::int2[]); SELECT check_set_block_offsets();
 do_set_block_offsets 
----------------------
                    1
(1 row)

 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT do_set_block_offsets(1, array[1,2]::int2[]); SELECT check_set_block_offsets();
 do_set_block_offsets 
----------------------
                    1
(1 row)

 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT do_set_block_offsets(1, array[1]::int2[]); SELECT check_set_block_offsets();
 do_set_block_offsets 
----------------------
                    1
(1 row)

 check_set_block_offsets 
-------------------------
 
(1 row)

SELECT test_destroy();
 test_destroy 
--------------
 
(1 row)

-- Use shared memory this time. We can't do that in test_radixtree.sql,
-- because unused static functions would raise warnings there.
SELECT test_create(true);
 test_create 
-------------
 
(1 row)

-- Test offsets embedded in the bitmap header.
SELECT do_set_block_offsets(501, array[greatest((random() * :maxoffset)::int, 1)]::int2[]);
 do_set_block_offsets 
----------------------
                  501
(1 row)

SELECT do_set_block_offsets(502, array_agg(DISTINCT greatest((random() * :maxoffset)::int, 1))::int2[])
  FROM generate_series(1, 3);
 do_set_block_offsets 
----------------------
                  502
(1 row)

-- Random TIDs test. The offset numbers are randomized and must be
-- unique and ordered.
INSERT INTO hideblocks (blockno)
SELECT do_set_block_offsets(blkno, array_agg(DISTINCT greatest((random() * :maxoffset)::int, 1))::int2[])
  FROM generate_series(1, 100) num_offsets,
  generate_series(1000, 1100, 1) blkno
GROUP BY blkno;
-- Check TIDs we've added to the store.
SELECT check_set_block_offsets();
 check_set_block_offsets 
-------------------------
 
(1 row)

-- cleanup
SELECT test_destroy();
 test_destroy 
--------------
 
(1 row)

DROP TABLE hideblocks;