Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 428c0ca

Browse files
committed
Show empty BRIN ranges in brin_page_items
Commit 3581cbd added a flag to identify empty BRIN ranges. This adds the new flag to brin_page_items() output. This is kept as a separate commit as it should not be backpatched. Reviewed-by: Justin Pryzby, Matthias van de Meent, Alvaro Herrera Discussion: https://postgr.es/m/402430e4-7d9d-6cf1-09ef-464d80afff3b@enterprisedb.com
1 parent 3581cbd commit 428c0ca

File tree

5 files changed

+48
-29
lines changed

5 files changed

+48
-29
lines changed

contrib/pageinspect/brinfuncs.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ brin_page_items(PG_FUNCTION_ARGS)
201201
dtup = NULL;
202202
for (;;)
203203
{
204-
Datum values[7];
205-
bool nulls[7] = {0};
204+
Datum values[8];
205+
bool nulls[8] = {0};
206206

207207
/*
208208
* This loop is called once for every attribute of every tuple in the
@@ -239,6 +239,7 @@ brin_page_items(PG_FUNCTION_ARGS)
239239
nulls[4] = true;
240240
nulls[5] = true;
241241
nulls[6] = true;
242+
nulls[7] = true;
242243
}
243244
else
244245
{
@@ -261,6 +262,7 @@ brin_page_items(PG_FUNCTION_ARGS)
261262
values[3] = BoolGetDatum(dtup->bt_columns[att].bv_allnulls);
262263
values[4] = BoolGetDatum(dtup->bt_columns[att].bv_hasnulls);
263264
values[5] = BoolGetDatum(dtup->bt_placeholder);
265+
values[6] = BoolGetDatum(dtup->bt_empty_range);
264266
if (!dtup->bt_columns[att].bv_allnulls)
265267
{
266268
BrinValues *bvalues = &dtup->bt_columns[att];
@@ -286,12 +288,12 @@ brin_page_items(PG_FUNCTION_ARGS)
286288
}
287289
appendStringInfoChar(&s, '}');
288290

289-
values[6] = CStringGetTextDatum(s.data);
291+
values[7] = CStringGetTextDatum(s.data);
290292
pfree(s.data);
291293
}
292294
else
293295
{
294-
nulls[6] = true;
296+
nulls[7] = true;
295297
}
296298
}
297299

contrib/pageinspect/expected/brin.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ SELECT * FROM brin_revmap_data(get_raw_page('test1_a_idx', 1)) LIMIT 5;
4343

4444
SELECT * FROM brin_page_items(get_raw_page('test1_a_idx', 2), 'test1_a_idx')
4545
ORDER BY blknum, attnum LIMIT 5;
46-
itemoffset | blknum | attnum | allnulls | hasnulls | placeholder | value
47-
------------+--------+--------+----------+----------+-------------+----------
48-
1 | 0 | 1 | f | f | f | {1 .. 1}
46+
itemoffset | blknum | attnum | allnulls | hasnulls | placeholder | empty | value
47+
------------+--------+--------+----------+----------+-------------+-------+----------
48+
1 | 0 | 1 | f | f | f | f | {1 .. 1}
4949
(1 row)
5050

5151
-- Mask DETAIL messages as these are not portable across architectures.

contrib/pageinspect/pageinspect--1.11--1.12.sql

+17
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,20 @@ CREATE FUNCTION bt_multi_page_stats(IN relname text, IN blkno int8, IN blk_count
2121
RETURNS SETOF record
2222
AS 'MODULE_PATHNAME', 'bt_multi_page_stats'
2323
LANGUAGE C STRICT PARALLEL RESTRICTED;
24+
25+
--
26+
-- add information about BRIN empty ranges
27+
--
28+
DROP FUNCTION brin_page_items(IN page bytea, IN index_oid regclass);
29+
CREATE FUNCTION brin_page_items(IN page bytea, IN index_oid regclass,
30+
OUT itemoffset int,
31+
OUT blknum int8,
32+
OUT attnum int,
33+
OUT allnulls bool,
34+
OUT hasnulls bool,
35+
OUT placeholder bool,
36+
OUT empty bool,
37+
OUT value text)
38+
RETURNS SETOF record
39+
AS 'MODULE_PATHNAME', 'brin_page_items'
40+
LANGUAGE C STRICT PARALLEL RESTRICTED;

doc/src/sgml/pageinspect.sgml

+8-8
Original file line numberDiff line numberDiff line change
@@ -613,14 +613,14 @@ test=# SELECT * FROM brin_revmap_data(get_raw_page('brinidx', 2)) LIMIT 5;
613613
test=# SELECT * FROM brin_page_items(get_raw_page('brinidx', 5),
614614
'brinidx')
615615
ORDER BY blknum, attnum LIMIT 6;
616-
itemoffset | blknum | attnum | allnulls | hasnulls | placeholder | value
617-
------------+--------+--------+----------+----------+-------------+--------------
618-
137 | 0 | 1 | t | f | f |
619-
137 | 0 | 2 | f | f | f | {1 .. 88}
620-
138 | 4 | 1 | t | f | f |
621-
138 | 4 | 2 | f | f | f | {89 .. 176}
622-
139 | 8 | 1 | t | f | f |
623-
139 | 8 | 2 | f | f | f | {177 .. 264}
616+
itemoffset | blknum | attnum | allnulls | hasnulls | placeholder | empty | value
617+
------------+--------+--------+----------+----------+-------------+-------+--------------
618+
137 | 0 | 1 | t | f | f | f |
619+
137 | 0 | 2 | f | f | f | f | {1 .. 88}
620+
138 | 4 | 1 | t | f | f | f |
621+
138 | 4 | 2 | f | f | f | f | {89 .. 176}
622+
139 | 8 | 1 | t | f | f | f |
623+
139 | 8 | 2 | f | f | f | f | {177 .. 264}
624624
</screen>
625625
The returned columns correspond to the fields in the
626626
<structname>BrinMemTuple</structname> and <structname>BrinValues</structname> structs.

src/test/modules/brin/expected/summarization-and-inprogress-insertion.out

+14-14
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Parsed test spec with 2 sessions
22

33
starting permutation: s2check s1b s2b s1i s2summ s1c s2c s2check
44
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
5-
itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|value
6-
----------+------+------+--------+--------+-----------+--------
7-
1| 0| 1|f |t |f |{1 .. 1}
5+
itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|empty|value
6+
----------+------+------+--------+--------+-----------+-----+--------
7+
1| 0| 1|f |t |f |f |{1 .. 1}
88
(1 row)
99

1010
step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
@@ -24,28 +24,28 @@ brin_summarize_new_values
2424
step s1c: COMMIT;
2525
step s2c: COMMIT;
2626
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
27-
itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|value
28-
----------+------+------+--------+--------+-----------+-----------
29-
1| 0| 1|f |t |f |{1 .. 1}
30-
2| 1| 1|f |f |f |{1 .. 1000}
27+
itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|empty|value
28+
----------+------+------+--------+--------+-----------+-----+-----------
29+
1| 0| 1|f |t |f |f |{1 .. 1}
30+
2| 1| 1|f |f |f |f |{1 .. 1000}
3131
(2 rows)
3232

3333

3434
starting permutation: s2check s1b s1i s2vacuum s1c s2check
3535
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
36-
itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|value
37-
----------+------+------+--------+--------+-----------+--------
38-
1| 0| 1|f |t |f |{1 .. 1}
36+
itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|empty|value
37+
----------+------+------+--------+--------+-----------+-----+--------
38+
1| 0| 1|f |t |f |f |{1 .. 1}
3939
(1 row)
4040

4141
step s1b: BEGIN ISOLATION LEVEL REPEATABLE READ;
4242
step s1i: INSERT INTO brin_iso VALUES (1000);
4343
step s2vacuum: VACUUM brin_iso;
4444
step s1c: COMMIT;
4545
step s2check: SELECT * FROM brin_page_items(get_raw_page('brinidx', 2), 'brinidx'::regclass);
46-
itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|value
47-
----------+------+------+--------+--------+-----------+-----------
48-
1| 0| 1|f |t |f |{1 .. 1}
49-
2| 1| 1|f |f |f |{1 .. 1000}
46+
itemoffset|blknum|attnum|allnulls|hasnulls|placeholder|empty|value
47+
----------+------+------+--------+--------+-----------+-----+-----------
48+
1| 0| 1|f |t |f |f |{1 .. 1}
49+
2| 1| 1|f |f |f |f |{1 .. 1000}
5050
(2 rows)
5151

0 commit comments

Comments
 (0)