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

Commit bd16575

Browse files
committed
Add a regression test for pgstattuple.
This is mainly to prove that the NaN fix actually works cross-platform.
1 parent af7d181 commit bd16575

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

contrib/pgstattuple/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Generated subdirectories
2+
/log/
3+
/results/
4+
/tmp_check/

contrib/pgstattuple/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ OBJS = pgstattuple.o pgstatindex.o
66
EXTENSION = pgstattuple
77
DATA = pgstattuple--1.0.sql pgstattuple--unpackaged--1.0.sql
88

9+
REGRESS = pgstattuple
10+
911
ifdef USE_PGXS
1012
PG_CONFIG = pg_config
1113
PGXS := $(shell $(PG_CONFIG) --pgxs)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
CREATE EXTENSION pgstattuple;
2+
--
3+
-- It's difficult to come up with platform-independent test cases for
4+
-- the pgstattuple functions, but the results for empty tables and
5+
-- indexes should be that.
6+
--
7+
create table test (a int primary key);
8+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey" for table "test"
9+
select * from pgstattuple('test'::text);
10+
table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent
11+
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------
12+
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
13+
(1 row)
14+
15+
select * from pgstattuple('test'::regclass);
16+
table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent
17+
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------
18+
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0
19+
(1 row)
20+
21+
select * from pgstatindex('test_pkey');
22+
version | tree_level | index_size | root_block_no | internal_pages | leaf_pages | empty_pages | deleted_pages | avg_leaf_density | leaf_fragmentation
23+
---------+------------+------------+---------------+----------------+------------+-------------+---------------+------------------+--------------------
24+
2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | NaN | NaN
25+
(1 row)
26+
27+
select pg_relpages('test');
28+
pg_relpages
29+
-------------
30+
0
31+
(1 row)
32+
33+
select pg_relpages('test_pkey');
34+
pg_relpages
35+
-------------
36+
1
37+
(1 row)
38+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CREATE EXTENSION pgstattuple;
2+
3+
--
4+
-- It's difficult to come up with platform-independent test cases for
5+
-- the pgstattuple functions, but the results for empty tables and
6+
-- indexes should be that.
7+
--
8+
9+
create table test (a int primary key);
10+
11+
select * from pgstattuple('test'::text);
12+
select * from pgstattuple('test'::regclass);
13+
14+
select * from pgstatindex('test_pkey');
15+
16+
select pg_relpages('test');
17+
select pg_relpages('test_pkey');

0 commit comments

Comments
 (0)