mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Show empty BRIN ranges in brin_page_items
Commit 3581cbdcd6
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
This commit is contained in:
@ -201,8 +201,8 @@ brin_page_items(PG_FUNCTION_ARGS)
|
||||
dtup = NULL;
|
||||
for (;;)
|
||||
{
|
||||
Datum values[7];
|
||||
bool nulls[7] = {0};
|
||||
Datum values[8];
|
||||
bool nulls[8] = {0};
|
||||
|
||||
/*
|
||||
* This loop is called once for every attribute of every tuple in the
|
||||
@ -239,6 +239,7 @@ brin_page_items(PG_FUNCTION_ARGS)
|
||||
nulls[4] = true;
|
||||
nulls[5] = true;
|
||||
nulls[6] = true;
|
||||
nulls[7] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -261,6 +262,7 @@ brin_page_items(PG_FUNCTION_ARGS)
|
||||
values[3] = BoolGetDatum(dtup->bt_columns[att].bv_allnulls);
|
||||
values[4] = BoolGetDatum(dtup->bt_columns[att].bv_hasnulls);
|
||||
values[5] = BoolGetDatum(dtup->bt_placeholder);
|
||||
values[6] = BoolGetDatum(dtup->bt_empty_range);
|
||||
if (!dtup->bt_columns[att].bv_allnulls)
|
||||
{
|
||||
BrinValues *bvalues = &dtup->bt_columns[att];
|
||||
@ -286,12 +288,12 @@ brin_page_items(PG_FUNCTION_ARGS)
|
||||
}
|
||||
appendStringInfoChar(&s, '}');
|
||||
|
||||
values[6] = CStringGetTextDatum(s.data);
|
||||
values[7] = CStringGetTextDatum(s.data);
|
||||
pfree(s.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
nulls[6] = true;
|
||||
nulls[7] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,9 @@ SELECT * FROM brin_revmap_data(get_raw_page('test1_a_idx', 1)) LIMIT 5;
|
||||
|
||||
SELECT * FROM brin_page_items(get_raw_page('test1_a_idx', 2), 'test1_a_idx')
|
||||
ORDER BY blknum, attnum LIMIT 5;
|
||||
itemoffset | blknum | attnum | allnulls | hasnulls | placeholder | value
|
||||
------------+--------+--------+----------+----------+-------------+----------
|
||||
1 | 0 | 1 | f | f | f | {1 .. 1}
|
||||
itemoffset | blknum | attnum | allnulls | hasnulls | placeholder | empty | value
|
||||
------------+--------+--------+----------+----------+-------------+-------+----------
|
||||
1 | 0 | 1 | f | f | f | f | {1 .. 1}
|
||||
(1 row)
|
||||
|
||||
-- Mask DETAIL messages as these are not portable across architectures.
|
||||
|
@ -21,3 +21,20 @@ CREATE FUNCTION bt_multi_page_stats(IN relname text, IN blkno int8, IN blk_count
|
||||
RETURNS SETOF record
|
||||
AS 'MODULE_PATHNAME', 'bt_multi_page_stats'
|
||||
LANGUAGE C STRICT PARALLEL RESTRICTED;
|
||||
|
||||
--
|
||||
-- add information about BRIN empty ranges
|
||||
--
|
||||
DROP FUNCTION brin_page_items(IN page bytea, IN index_oid regclass);
|
||||
CREATE FUNCTION brin_page_items(IN page bytea, IN index_oid regclass,
|
||||
OUT itemoffset int,
|
||||
OUT blknum int8,
|
||||
OUT attnum int,
|
||||
OUT allnulls bool,
|
||||
OUT hasnulls bool,
|
||||
OUT placeholder bool,
|
||||
OUT empty bool,
|
||||
OUT value text)
|
||||
RETURNS SETOF record
|
||||
AS 'MODULE_PATHNAME', 'brin_page_items'
|
||||
LANGUAGE C STRICT PARALLEL RESTRICTED;
|
||||
|
Reference in New Issue
Block a user