]> granicus.if.org Git - postgresql/commitdiff
Add a regression test for pgstattuple.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Aug 2011 04:06:16 +0000 (00:06 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 25 Aug 2011 04:06:16 +0000 (00:06 -0400)
This is mainly to prove that the NaN fix actually works cross-platform.

contrib/pgstattuple/.gitignore [new file with mode: 0644]
contrib/pgstattuple/Makefile
contrib/pgstattuple/expected/pgstattuple.out [new file with mode: 0644]
contrib/pgstattuple/sql/pgstattuple.sql [new file with mode: 0644]

diff --git a/contrib/pgstattuple/.gitignore b/contrib/pgstattuple/.gitignore
new file mode 100644 (file)
index 0000000..5dcb3ff
--- /dev/null
@@ -0,0 +1,4 @@
+# Generated subdirectories
+/log/
+/results/
+/tmp_check/
index 13b87090eec946e8156eb80a443959813bee30fe..6ac277598c85c0a19345bb3e0f80d32ff2e68207 100644 (file)
@@ -6,6 +6,8 @@ OBJS            = pgstattuple.o pgstatindex.o
 EXTENSION = pgstattuple
 DATA = pgstattuple--1.0.sql pgstattuple--unpackaged--1.0.sql
 
+REGRESS = pgstattuple
+
 ifdef USE_PGXS
 PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/pgstattuple/expected/pgstattuple.out b/contrib/pgstattuple/expected/pgstattuple.out
new file mode 100644 (file)
index 0000000..7f28177
--- /dev/null
@@ -0,0 +1,38 @@
+CREATE EXTENSION pgstattuple;
+--
+-- It's difficult to come up with platform-independent test cases for
+-- the pgstattuple functions, but the results for empty tables and
+-- indexes should be that.
+--
+create table test (a int primary key);
+NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey" for table "test"
+select * from pgstattuple('test'::text);
+ table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent 
+-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------
+         0 |           0 |         0 |             0 |                0 |              0 |                  0 |          0 |            0
+(1 row)
+
+select * from pgstattuple('test'::regclass);
+ table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent 
+-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------
+         0 |           0 |         0 |             0 |                0 |              0 |                  0 |          0 |            0
+(1 row)
+
+select * from pgstatindex('test_pkey');
+ version | tree_level | index_size | root_block_no | internal_pages | leaf_pages | empty_pages | deleted_pages | avg_leaf_density | leaf_fragmentation 
+---------+------------+------------+---------------+----------------+------------+-------------+---------------+------------------+--------------------
+       2 |          0 |          0 |             0 |              0 |          0 |           0 |             0 |              NaN |                NaN
+(1 row)
+
+select pg_relpages('test');
+ pg_relpages 
+-------------
+           0
+(1 row)
+
+select pg_relpages('test_pkey');
+ pg_relpages 
+-------------
+           1
+(1 row)
+
diff --git a/contrib/pgstattuple/sql/pgstattuple.sql b/contrib/pgstattuple/sql/pgstattuple.sql
new file mode 100644 (file)
index 0000000..2fd1152
--- /dev/null
@@ -0,0 +1,17 @@
+CREATE EXTENSION pgstattuple;
+
+--
+-- It's difficult to come up with platform-independent test cases for
+-- the pgstattuple functions, but the results for empty tables and
+-- indexes should be that.
+--
+
+create table test (a int primary key);
+
+select * from pgstattuple('test'::text);
+select * from pgstattuple('test'::regclass);
+
+select * from pgstatindex('test_pkey');
+
+select pg_relpages('test');
+select pg_relpages('test_pkey');