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

Commit 9e596b6

Browse files
Add "LP_DEAD item?" column to GiST pageinspect functions
This brings gist_page_items() and gist_page_items_bytea() in line with nbtree's bt_page_items() function. Minor follow-up to commit 756ab29, which added the GiST functions. Author: Andrey Borodin <x4mmm@yandex-team.ru> Discussion: https://postgr.es/m/E0794687-7315-4C29-A9C7-EC54D448596D@yandex-team.ru
1 parent fa41cf8 commit 9e596b6

File tree

4 files changed

+46
-42
lines changed

4 files changed

+46
-42
lines changed

contrib/pageinspect/expected/gist.out

+16-16
Original file line numberDiff line numberDiff line change
@@ -31,25 +31,25 @@ SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 2));
3131

3232
COMMIT;
3333
SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 0), 'test_gist_idx');
34-
itemoffset | ctid | itemlen | keys
35-
------------+-----------+---------+-------------------
36-
1 | (1,65535) | 40 | (p)=((166,166))
37-
2 | (2,65535) | 40 | (p)=((332,332))
38-
3 | (3,65535) | 40 | (p)=((498,498))
39-
4 | (4,65535) | 40 | (p)=((664,664))
40-
5 | (5,65535) | 40 | (p)=((830,830))
41-
6 | (6,65535) | 40 | (p)=((996,996))
42-
7 | (7,65535) | 40 | (p)=((1000,1000))
34+
itemoffset | ctid | itemlen | dead | keys
35+
------------+-----------+---------+------+-------------------
36+
1 | (1,65535) | 40 | f | (p)=((166,166))
37+
2 | (2,65535) | 40 | f | (p)=((332,332))
38+
3 | (3,65535) | 40 | f | (p)=((498,498))
39+
4 | (4,65535) | 40 | f | (p)=((664,664))
40+
5 | (5,65535) | 40 | f | (p)=((830,830))
41+
6 | (6,65535) | 40 | f | (p)=((996,996))
42+
7 | (7,65535) | 40 | f | (p)=((1000,1000))
4343
(7 rows)
4444

4545
SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 1), 'test_gist_idx') LIMIT 5;
46-
itemoffset | ctid | itemlen | keys
47-
------------+-------+---------+-------------
48-
1 | (0,1) | 40 | (p)=((1,1))
49-
2 | (0,2) | 40 | (p)=((2,2))
50-
3 | (0,3) | 40 | (p)=((3,3))
51-
4 | (0,4) | 40 | (p)=((4,4))
52-
5 | (0,5) | 40 | (p)=((5,5))
46+
itemoffset | ctid | itemlen | dead | keys
47+
------------+-------+---------+------+-------------
48+
1 | (0,1) | 40 | f | (p)=((1,1))
49+
2 | (0,2) | 40 | f | (p)=((2,2))
50+
3 | (0,3) | 40 | f | (p)=((3,3))
51+
4 | (0,4) | 40 | f | (p)=((4,4))
52+
5 | (0,5) | 40 | f | (p)=((5,5))
5353
(5 rows)
5454

5555
-- gist_page_items_bytea prints the raw key data as a bytea. The output of that is

contrib/pageinspect/gistfuncs.c

+10-8
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
146146
offset <= maxoff;
147147
offset++)
148148
{
149-
Datum values[4];
150-
bool nulls[4];
149+
Datum values[5];
150+
bool nulls[5];
151151
ItemId id;
152152
IndexTuple itup;
153153
bytea *tuple_bytea;
@@ -170,7 +170,8 @@ gist_page_items_bytea(PG_FUNCTION_ARGS)
170170
tuple_bytea = (bytea *) palloc(tuple_len + VARHDRSZ);
171171
SET_VARSIZE(tuple_bytea, tuple_len + VARHDRSZ);
172172
memcpy(VARDATA(tuple_bytea), itup, tuple_len);
173-
values[3] = PointerGetDatum(tuple_bytea);
173+
values[3] = BoolGetDatum(ItemIdIsDead(id));
174+
values[4] = PointerGetDatum(tuple_bytea);
174175

175176
tuplestore_putvalues(tupstore, tupdesc, values, nulls);
176177
}
@@ -237,8 +238,8 @@ gist_page_items(PG_FUNCTION_ARGS)
237238
offset <= maxoff;
238239
offset++)
239240
{
240-
Datum values[4];
241-
bool nulls[4];
241+
Datum values[5];
242+
bool nulls[5];
242243
ItemId id;
243244
IndexTuple itup;
244245
Datum itup_values[INDEX_MAX_KEYS];
@@ -260,14 +261,15 @@ gist_page_items(PG_FUNCTION_ARGS)
260261
values[0] = DatumGetInt16(offset);
261262
values[1] = ItemPointerGetDatum(&itup->t_tid);
262263
values[2] = Int32GetDatum((int) IndexTupleSize(itup));
264+
values[3] = BoolGetDatum(ItemIdIsDead(id));
263265

264266
key_desc = BuildIndexValueDescription(indexRel, itup_values, itup_isnull);
265267
if (key_desc)
266-
values[3] = CStringGetTextDatum(key_desc);
268+
values[4] = CStringGetTextDatum(key_desc);
267269
else
268270
{
269-
values[3] = (Datum) 0;
270-
nulls[3] = true;
271+
values[4] = (Datum) 0;
272+
nulls[4] = true;
271273
}
272274

273275
tuplestore_putvalues(tupstore, tupdesc, values, nulls);

contrib/pageinspect/pageinspect--1.8--1.9.sql

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ CREATE FUNCTION gist_page_items_bytea(IN page bytea,
2222
OUT itemoffset smallint,
2323
OUT ctid tid,
2424
OUT itemlen smallint,
25+
OUT dead boolean,
2526
OUT key_data bytea)
2627
RETURNS SETOF record
2728
AS 'MODULE_PATHNAME', 'gist_page_items_bytea'
@@ -35,6 +36,7 @@ CREATE FUNCTION gist_page_items(IN page bytea,
3536
OUT itemoffset smallint,
3637
OUT ctid tid,
3738
OUT itemlen smallint,
39+
OUT dead boolean,
3840
OUT keys text)
3941
RETURNS SETOF record
4042
AS 'MODULE_PATHNAME', 'gist_page_items'

doc/src/sgml/pageinspect.sgml

+18-18
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,15 @@ test=# SELECT * FROM gist_page_opaque_info(get_raw_page('test_gist_idx', 2));
714714
the data stored in a page of a <acronym>GiST</acronym> index. For example:
715715
<screen>
716716
test=# SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 0), 'test_gist_idx');
717-
itemoffset | ctid | itemlen | keys
718-
------------+-----------+---------+-------------------
719-
1 | (1,65535) | 40 | (p)=((166,166))
720-
2 | (2,65535) | 40 | (p)=((332,332))
721-
3 | (3,65535) | 40 | (p)=((498,498))
722-
4 | (4,65535) | 40 | (p)=((664,664))
723-
5 | (5,65535) | 40 | (p)=((830,830))
724-
6 | (6,65535) | 40 | (p)=((996,996))
725-
7 | (7,65535) | 40 | (p)=((1000,1000))
717+
itemoffset | ctid | itemlen | dead | keys
718+
------------+-----------+---------+------+-------------------
719+
1 | (1,65535) | 40 | f | (p)=((166,166))
720+
2 | (2,65535) | 40 | f | (p)=((332,332))
721+
3 | (3,65535) | 40 | f | (p)=((498,498))
722+
4 | (4,65535) | 40 | f | (p)=((664,664))
723+
5 | (5,65535) | 40 | f | (p)=((830,830))
724+
6 | (6,65535) | 40 | f | (p)=((996,996))
725+
7 | (7,65535) | 40 | f | (p)=((1000,1000))
726726
(7 rows)
727727
</screen>
728728
</para>
@@ -745,15 +745,15 @@ test=# SELECT * FROM gist_page_items(get_raw_page('test_gist_idx', 0), 'test_gis
745745
example:
746746
<screen>
747747
test=# SELECT * FROM gist_page_items_bytea(get_raw_page('test_gist_idx', 0));
748-
itemoffset | ctid | itemlen | key_data
749-
------------+-----------+---------+-------------------------------------------&zwsp;-----------------------------------------
750-
1 | (1,65535) | 40 | \x00000100ffff28000000000000c0644000000000&zwsp;00c06440000000000000f03f000000000000f03f
751-
2 | (2,65535) | 40 | \x00000200ffff28000000000000c0744000000000&zwsp;00c074400000000000e064400000000000e06440
752-
3 | (3,65535) | 40 | \x00000300ffff28000000000000207f4000000000&zwsp;00207f400000000000d074400000000000d07440
753-
4 | (4,65535) | 40 | \x00000400ffff28000000000000c0844000000000&zwsp;00c084400000000000307f400000000000307f40
754-
5 | (5,65535) | 40 | \x00000500ffff28000000000000f0894000000000&zwsp;00f089400000000000c884400000000000c88440
755-
6 | (6,65535) | 40 | \x00000600ffff28000000000000208f4000000000&zwsp;00208f400000000000f889400000000000f88940
756-
7 | (7,65535) | 40 | \x00000700ffff28000000000000408f4000000000&zwsp;00408f400000000000288f400000000000288f40
748+
itemoffset | ctid | itemlen | dead | key_data
749+
------------+-----------+---------+------+-----------------------------------------&zwsp;-------------------------------------------
750+
1 | (1,65535) | 40 | f | \x00000100ffff28000000000000c0644000000000&zwsp;00c06440000000000000f03f000000000000f03f
751+
2 | (2,65535) | 40 | f | \x00000200ffff28000000000000c0744000000000&zwsp;00c074400000000000e064400000000000e06440
752+
3 | (3,65535) | 40 | f | \x00000300ffff28000000000000207f4000000000&zwsp;00207f400000000000d074400000000000d07440
753+
4 | (4,65535) | 40 | f | \x00000400ffff28000000000000c0844000000000&zwsp;00c084400000000000307f400000000000307f40
754+
5 | (5,65535) | 40 | f | \x00000500ffff28000000000000f0894000000000&zwsp;00f089400000000000c884400000000000c88440
755+
6 | (6,65535) | 40 | f | \x00000600ffff28000000000000208f4000000000&zwsp;00208f400000000000f889400000000000f88940
756+
7 | (7,65535) | 40 | f | \x00000700ffff28000000000000408f4000000000&zwsp;00408f400000000000288f400000000000288f40
757757
(7 rows)
758758
</screen>
759759
</para>

0 commit comments

Comments
 (0)