Unused macros in contrib code

Started by Daniel Gustafssonover 9 years ago2 messages
#1Daniel Gustafsson
daniel@yesql.se
1 attachment(s)

While doing some archaeology I came across a couple of macros in pgstattuple
and pageinspect contrib code which seems to have been unused for some time.
CHECK_PAGE_OFFSET_RANGE is unused in both modules and commit 6405842 which
introduced contrib/pageinspect moved the code making CHECK_RELATION_BLOCK_RANGE
in pgstattuple unused.

For cleanliness sake it seems reasonable to remove these, patch attached which
passes make check (regular and in contrib).

cheers ./daniel

Attachments:

contrib_macros.diffapplication/octet-stream; name=contrib_macros.diffDownload
diff --git a/contrib/pageinspect/btreefuncs.c b/contrib/pageinspect/btreefuncs.c
index d088ce5..4983bbb 100644
--- a/contrib/pageinspect/btreefuncs.c
+++ b/contrib/pageinspect/btreefuncs.c
@@ -43,11 +43,6 @@ PG_FUNCTION_INFO_V1(bt_page_stats);
 #define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX)
 #define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
 
-#define CHECK_PAGE_OFFSET_RANGE(pg, offnum) { \
-		if ( !(FirstOffsetNumber <= (offnum) && \
-						(offnum) <= PageGetMaxOffsetNumber(pg)) ) \
-			 elog(ERROR, "page offset number out of range"); }
-
 /* note: BlockNumber is unsigned, hence can't be negative */
 #define CHECK_RELATION_BLOCK_RANGE(rel, blkno) { \
 		if ( RelationGetNumberOfBlocks(rel) <= (BlockNumber) (blkno) ) \
diff --git a/contrib/pgstattuple/pgstatindex.c b/contrib/pgstattuple/pgstatindex.c
index 9f1377c..6084589 100644
--- a/contrib/pgstattuple/pgstatindex.c
+++ b/contrib/pgstattuple/pgstatindex.c
@@ -58,16 +58,6 @@ PG_FUNCTION_INFO_V1(pgstatginindex);
 #define IS_BTREE(r) ((r)->rd_rel->relam == BTREE_AM_OID)
 #define IS_GIN(r) ((r)->rd_rel->relam == GIN_AM_OID)
 
-#define CHECK_PAGE_OFFSET_RANGE(pg, offnum) { \
-		if ( !(FirstOffsetNumber <= (offnum) && \
-						(offnum) <= PageGetMaxOffsetNumber(pg)) ) \
-			 elog(ERROR, "page offset number out of range"); }
-
-/* note: BlockNumber is unsigned, hence can't be negative */
-#define CHECK_RELATION_BLOCK_RANGE(rel, blkno) { \
-		if ( RelationGetNumberOfBlocks(rel) <= (BlockNumber) (blkno) ) \
-			 elog(ERROR, "block number out of range"); }
-
 /* ------------------------------------------------
  * A structure for a whole btree index statistics
  * used by pgstatindex().
#2Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Daniel Gustafsson (#1)
Re: Unused macros in contrib code

On 28/04/16 16:06, Daniel Gustafsson wrote:

While doing some archaeology I came across a couple of macros in pgstattuple
and pageinspect contrib code which seems to have been unused for some time.
CHECK_PAGE_OFFSET_RANGE is unused in both modules and commit 6405842 which
introduced contrib/pageinspect moved the code making CHECK_RELATION_BLOCK_RANGE
in pgstattuple unused.

For cleanliness sake it seems reasonable to remove these, patch attached which
passes make check (regular and in contrib).

Committed, thanks!

- Heikki

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers