Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
adfb81d9
Commit
adfb81d9
authored
Sep 29, 2016
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pageinspect: Add tests
parent
3a47c704
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
284 additions
and
0 deletions
+284
-0
contrib/pageinspect/.gitignore
contrib/pageinspect/.gitignore
+4
-0
contrib/pageinspect/Makefile
contrib/pageinspect/Makefile
+2
-0
contrib/pageinspect/expected/brin.out
contrib/pageinspect/expected/brin.out
+51
-0
contrib/pageinspect/expected/btree.out
contrib/pageinspect/expected/btree.out
+45
-0
contrib/pageinspect/expected/gin.out
contrib/pageinspect/expected/gin.out
+30
-0
contrib/pageinspect/expected/page.out
contrib/pageinspect/expected/page.out
+73
-0
contrib/pageinspect/sql/brin.sql
contrib/pageinspect/sql/brin.sql
+18
-0
contrib/pageinspect/sql/btree.sql
contrib/pageinspect/sql/btree.sql
+17
-0
contrib/pageinspect/sql/gin.sql
contrib/pageinspect/sql/gin.sql
+14
-0
contrib/pageinspect/sql/page.sql
contrib/pageinspect/sql/page.sql
+30
-0
No files found.
contrib/pageinspect/.gitignore
0 → 100644
View file @
adfb81d9
# Generated subdirectories
/log/
/results/
/tmp_check/
contrib/pageinspect/Makefile
View file @
adfb81d9
...
...
@@ -11,6 +11,8 @@ DATA = pageinspect--1.5.sql pageinspect--1.4--1.5.sql \
pageinspect--unpackaged--1.0.sql
PGFILEDESC
=
"pageinspect - functions to inspect contents of database pages"
REGRESS
=
page btree brin gin
ifdef
USE_PGXS
PG_CONFIG
=
pg_config
PGXS
:=
$(
shell
$(PG_CONFIG)
--pgxs
)
...
...
contrib/pageinspect/expected/brin.out
0 → 100644
View file @
adfb81d9
CREATE TABLE test1 (a int, b text);
INSERT INTO test1 VALUES (1, 'one');
CREATE INDEX test1_a_idx ON test1 USING brin (a);
SELECT brin_page_type(get_raw_page('test1_a_idx', 0));
brin_page_type
----------------
meta
(1 row)
SELECT brin_page_type(get_raw_page('test1_a_idx', 1));
brin_page_type
----------------
revmap
(1 row)
SELECT brin_page_type(get_raw_page('test1_a_idx', 2));
brin_page_type
----------------
regular
(1 row)
SELECT * FROM brin_metapage_info(get_raw_page('test1_a_idx', 0));
magic | version | pagesperrange | lastrevmappage
------------+---------+---------------+----------------
0xA8109CFA | 1 | 128 | 1
(1 row)
SELECT * FROM brin_metapage_info(get_raw_page('test1_a_idx', 1));
ERROR: page is not a BRIN page of type "metapage"
DETAIL: Expected special type 0000f091, got 0000f092.
SELECT * FROM brin_revmap_data(get_raw_page('test1_a_idx', 0)) LIMIT 5;
ERROR: page is not a BRIN page of type "revmap"
DETAIL: Expected special type 0000f092, got 0000f091.
SELECT * FROM brin_revmap_data(get_raw_page('test1_a_idx', 1)) LIMIT 5;
pages
-------
(2,1)
(0,0)
(0,0)
(0,0)
(0,0)
(5 rows)
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}
(1 row)
DROP TABLE test1;
contrib/pageinspect/expected/btree.out
0 → 100644
View file @
adfb81d9
CREATE TABLE test1 (a int, b text);
INSERT INTO test1 VALUES (1, 'one');
CREATE INDEX test1_a_idx ON test1 USING btree (a);
\x
SELECT * FROM bt_metap('test1_a_idx');
-[ RECORD 1 ]-----
magic | 340322
version | 2
root | 1
level | 0
fastroot | 1
fastlevel | 0
SELECT * FROM bt_page_stats('test1_a_idx', 0);
ERROR: block 0 is a meta page
SELECT * FROM bt_page_stats('test1_a_idx', 1);
-[ RECORD 1 ]-+-----
blkno | 1
type | l
live_items | 1
dead_items | 0
avg_item_size | 16
page_size | 8192
free_size | 8128
btpo_prev | 0
btpo_next | 0
btpo | 0
btpo_flags | 3
SELECT * FROM bt_page_stats('test1_a_idx', 2);
ERROR: block number out of range
SELECT * FROM bt_page_items('test1_a_idx', 0);
ERROR: block 0 is a meta page
SELECT * FROM bt_page_items('test1_a_idx', 1);
-[ RECORD 1 ]-----------------------
itemoffset | 1
ctid | (0,1)
itemlen | 16
nulls | f
vars | f
data | 01 00 00 00 00 00 00 00
SELECT * FROM bt_page_items('test1_a_idx', 2);
ERROR: block number out of range
DROP TABLE test1;
contrib/pageinspect/expected/gin.out
0 → 100644
View file @
adfb81d9
CREATE TABLE test1 (x int, y int[]);
INSERT INTO test1 VALUES (1, ARRAY[11, 111]);
CREATE INDEX test1_y_idx ON test1 USING gin (y);
\x
SELECT * FROM gin_metapage_info(get_raw_page('test1_y_idx', 0));
-[ RECORD 1 ]----+-----------
pending_head | 4294967295
pending_tail | 4294967295
tail_free_size | 0
n_pending_pages | 0
n_pending_tuples | 0
n_total_pages | 2
n_entry_pages | 1
n_data_pages | 0
n_entries | 2
version | 2
SELECT * FROM gin_metapage_info(get_raw_page('test1_y_idx', 1));
ERROR: input page is not a GIN metapage
DETAIL: Flags 0002, expected 0008
SELECT * FROM gin_page_opaque_info(get_raw_page('test1_y_idx', 1));
-[ RECORD 1 ]---------
rightlink | 4294967295
maxoff | 0
flags | {leaf}
SELECT * FROM gin_leafpage_items(get_raw_page('test1_y_idx', 1));
ERROR: input page is not a compressed GIN data leaf page
DETAIL: Flags 0002, expected 0083
DROP TABLE test1;
contrib/pageinspect/expected/page.out
0 → 100644
View file @
adfb81d9
CREATE EXTENSION pageinspect;
CREATE TABLE test1 (a int, b text);
INSERT INTO test1 VALUES (1, 'one');
VACUUM test1; -- set up FSM
-- The page contents can vary, so just test that it can be read
-- successfully, but don't keep the output.
SELECT octet_length(get_raw_page('test1', 'main', 0)) AS main_0;
main_0
--------
8192
(1 row)
SELECT octet_length(get_raw_page('test1', 'main', 1)) AS main_1;
ERROR: block number 1 is out of range for relation "test1"
SELECT octet_length(get_raw_page('test1', 'fsm', 0)) AS fsm_0;
fsm_0
-------
8192
(1 row)
SELECT octet_length(get_raw_page('test1', 'fsm', 1)) AS fsm_1;
fsm_1
-------
8192
(1 row)
SELECT octet_length(get_raw_page('test1', 'vm', 0)) AS vm_0;
vm_0
------
8192
(1 row)
SELECT octet_length(get_raw_page('test1', 'vm', 1)) AS vm_1;
ERROR: block number 1 is out of range for relation "test1"
SELECT octet_length(get_raw_page('xxx', 'main', 0));
ERROR: relation "xxx" does not exist
SELECT octet_length(get_raw_page('test1', 'xxx', 0));
ERROR: invalid fork name
HINT: Valid fork names are "main", "fsm", "vm", and "init".
SELECT get_raw_page('test1', 0) = get_raw_page('test1', 'main', 0);
?column?
----------
t
(1 row)
SELECT tuple_data_split('test1'::regclass, t_data, t_infomask, t_infomask2, t_bits)
FROM heap_page_items(get_raw_page('test1', 0));
tuple_data_split
-------------------------------
{"\\x01000000","\\x096f6e65"}
(1 row)
SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
fsm_page_contents
-------------------
0: 254 +
1: 254 +
3: 254 +
7: 254 +
15: 254 +
31: 254 +
63: 254 +
127: 254 +
255: 254 +
511: 254 +
1023: 254 +
2047: 254 +
4095: 254 +
fp_next_slot: 0 +
(1 row)
DROP TABLE test1;
contrib/pageinspect/sql/brin.sql
0 → 100644
View file @
adfb81d9
CREATE
TABLE
test1
(
a
int
,
b
text
);
INSERT
INTO
test1
VALUES
(
1
,
'one'
);
CREATE
INDEX
test1_a_idx
ON
test1
USING
brin
(
a
);
SELECT
brin_page_type
(
get_raw_page
(
'test1_a_idx'
,
0
));
SELECT
brin_page_type
(
get_raw_page
(
'test1_a_idx'
,
1
));
SELECT
brin_page_type
(
get_raw_page
(
'test1_a_idx'
,
2
));
SELECT
*
FROM
brin_metapage_info
(
get_raw_page
(
'test1_a_idx'
,
0
));
SELECT
*
FROM
brin_metapage_info
(
get_raw_page
(
'test1_a_idx'
,
1
));
SELECT
*
FROM
brin_revmap_data
(
get_raw_page
(
'test1_a_idx'
,
0
))
LIMIT
5
;
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
;
DROP
TABLE
test1
;
contrib/pageinspect/sql/btree.sql
0 → 100644
View file @
adfb81d9
CREATE
TABLE
test1
(
a
int
,
b
text
);
INSERT
INTO
test1
VALUES
(
1
,
'one'
);
CREATE
INDEX
test1_a_idx
ON
test1
USING
btree
(
a
);
\
x
SELECT
*
FROM
bt_metap
(
'test1_a_idx'
);
SELECT
*
FROM
bt_page_stats
(
'test1_a_idx'
,
0
);
SELECT
*
FROM
bt_page_stats
(
'test1_a_idx'
,
1
);
SELECT
*
FROM
bt_page_stats
(
'test1_a_idx'
,
2
);
SELECT
*
FROM
bt_page_items
(
'test1_a_idx'
,
0
);
SELECT
*
FROM
bt_page_items
(
'test1_a_idx'
,
1
);
SELECT
*
FROM
bt_page_items
(
'test1_a_idx'
,
2
);
DROP
TABLE
test1
;
contrib/pageinspect/sql/gin.sql
0 → 100644
View file @
adfb81d9
CREATE
TABLE
test1
(
x
int
,
y
int
[]);
INSERT
INTO
test1
VALUES
(
1
,
ARRAY
[
11
,
111
]);
CREATE
INDEX
test1_y_idx
ON
test1
USING
gin
(
y
);
\
x
SELECT
*
FROM
gin_metapage_info
(
get_raw_page
(
'test1_y_idx'
,
0
));
SELECT
*
FROM
gin_metapage_info
(
get_raw_page
(
'test1_y_idx'
,
1
));
SELECT
*
FROM
gin_page_opaque_info
(
get_raw_page
(
'test1_y_idx'
,
1
));
SELECT
*
FROM
gin_leafpage_items
(
get_raw_page
(
'test1_y_idx'
,
1
));
DROP
TABLE
test1
;
contrib/pageinspect/sql/page.sql
0 → 100644
View file @
adfb81d9
CREATE
EXTENSION
pageinspect
;
CREATE
TABLE
test1
(
a
int
,
b
text
);
INSERT
INTO
test1
VALUES
(
1
,
'one'
);
VACUUM
test1
;
-- set up FSM
-- The page contents can vary, so just test that it can be read
-- successfully, but don't keep the output.
SELECT
octet_length
(
get_raw_page
(
'test1'
,
'main'
,
0
))
AS
main_0
;
SELECT
octet_length
(
get_raw_page
(
'test1'
,
'main'
,
1
))
AS
main_1
;
SELECT
octet_length
(
get_raw_page
(
'test1'
,
'fsm'
,
0
))
AS
fsm_0
;
SELECT
octet_length
(
get_raw_page
(
'test1'
,
'fsm'
,
1
))
AS
fsm_1
;
SELECT
octet_length
(
get_raw_page
(
'test1'
,
'vm'
,
0
))
AS
vm_0
;
SELECT
octet_length
(
get_raw_page
(
'test1'
,
'vm'
,
1
))
AS
vm_1
;
SELECT
octet_length
(
get_raw_page
(
'xxx'
,
'main'
,
0
));
SELECT
octet_length
(
get_raw_page
(
'test1'
,
'xxx'
,
0
));
SELECT
get_raw_page
(
'test1'
,
0
)
=
get_raw_page
(
'test1'
,
'main'
,
0
);
SELECT
tuple_data_split
(
'test1'
::
regclass
,
t_data
,
t_infomask
,
t_infomask2
,
t_bits
)
FROM
heap_page_items
(
get_raw_page
(
'test1'
,
0
));
SELECT
*
FROM
fsm_page_contents
(
get_raw_page
(
'test1'
,
'fsm'
,
0
));
DROP
TABLE
test1
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment