diff --git a/contrib/amcheck/expected/check_btree.out b/contrib/amcheck/expected/check_btree.out
index 6f5b91754d..2a06cce9a0 100644
--- a/contrib/amcheck/expected/check_btree.out
+++ b/contrib/amcheck/expected/check_btree.out
@@ -1,10 +1,14 @@
 -- minimal test, basically just verifying that amcheck
 CREATE TABLE bttest_a(id int8);
 CREATE TABLE bttest_b(id int8);
+CREATE TABLE bttest_multi(id int8, data int8);
 INSERT INTO bttest_a SELECT * FROM generate_series(1, 100000);
 INSERT INTO bttest_b SELECT * FROM generate_series(100000, 1, -1);
+INSERT INTO bttest_multi SELECT i, i%2  FROM generate_series(1, 100000) as i;
 CREATE INDEX bttest_a_idx ON bttest_a USING btree (id);
 CREATE INDEX bttest_b_idx ON bttest_b USING btree (id);
+CREATE UNIQUE INDEX bttest_multi_idx ON bttest_multi
+USING btree (id) INCLUDE (data);
 CREATE ROLE bttest_role;
 -- verify permissions are checked (error due to function not callable)
 SET ROLE bttest_role;
@@ -93,8 +97,50 @@ WHERE relation = ANY(ARRAY['bttest_a', 'bttest_a_idx', 'bttest_b', 'bttest_b_idx
 (0 rows)
 
 COMMIT;
+-- normal check outside of xact for index with included columns
+SELECT bt_index_check('bttest_multi_idx');
+ bt_index_check 
+----------------
+ 
+(1 row)
+
+-- more expansive test for index with included columns
+SELECT bt_index_parent_check('bttest_multi_idx', true);
+ bt_index_parent_check 
+-----------------------
+ 
+(1 row)
+
+SELECT bt_index_parent_check('bttest_multi_idx', true);
+ bt_index_parent_check 
+-----------------------
+ 
+(1 row)
+
+-- repeat same checks with index made by insertions
+TRUNCATE bttest_multi;
+INSERT INTO bttest_multi SELECT i, i%2  FROM generate_series(1, 100000) as i;
+SELECT bt_index_check('bttest_multi_idx');
+ bt_index_check 
+----------------
+ 
+(1 row)
+
+SELECT bt_index_parent_check('bttest_multi_idx', true);
+ bt_index_parent_check 
+-----------------------
+ 
+(1 row)
+
+SELECT bt_index_parent_check('bttest_multi_idx', true);
+ bt_index_parent_check 
+-----------------------
+ 
+(1 row)
+
 -- cleanup
 DROP TABLE bttest_a;
 DROP TABLE bttest_b;
+DROP TABLE bttest_multi;
 DROP OWNED BY bttest_role; -- permissions
 DROP ROLE bttest_role;
diff --git a/contrib/amcheck/sql/check_btree.sql b/contrib/amcheck/sql/check_btree.sql
index 03f4c96b9e..da2f1314e5 100644
--- a/contrib/amcheck/sql/check_btree.sql
+++ b/contrib/amcheck/sql/check_btree.sql
@@ -1,12 +1,16 @@
 -- minimal test, basically just verifying that amcheck
 CREATE TABLE bttest_a(id int8);
 CREATE TABLE bttest_b(id int8);
+CREATE TABLE bttest_multi(id int8, data int8);
 
 INSERT INTO bttest_a SELECT * FROM generate_series(1, 100000);
 INSERT INTO bttest_b SELECT * FROM generate_series(100000, 1, -1);
+INSERT INTO bttest_multi SELECT i, i%2  FROM generate_series(1, 100000) as i;
 
 CREATE INDEX bttest_a_idx ON bttest_a USING btree (id);
 CREATE INDEX bttest_b_idx ON bttest_b USING btree (id);
+CREATE UNIQUE INDEX bttest_multi_idx ON bttest_multi
+USING btree (id) INCLUDE (data);
 
 CREATE ROLE bttest_role;
 
@@ -57,8 +61,23 @@ WHERE relation = ANY(ARRAY['bttest_a', 'bttest_a_idx', 'bttest_b', 'bttest_b_idx
     AND pid = pg_backend_pid();
 COMMIT;
 
+-- normal check outside of xact for index with included columns
+SELECT bt_index_check('bttest_multi_idx');
+-- more expansive test for index with included columns
+SELECT bt_index_parent_check('bttest_multi_idx', true);
+SELECT bt_index_parent_check('bttest_multi_idx', true);
+
+-- repeat same checks with index made by insertions
+TRUNCATE bttest_multi;
+INSERT INTO bttest_multi SELECT i, i%2  FROM generate_series(1, 100000) as i;
+SELECT bt_index_check('bttest_multi_idx');
+SELECT bt_index_parent_check('bttest_multi_idx', true);
+SELECT bt_index_parent_check('bttest_multi_idx', true);
+
+
 -- cleanup
 DROP TABLE bttest_a;
 DROP TABLE bttest_b;
+DROP TABLE bttest_multi;
 DROP OWNED BY bttest_role; -- permissions
 DROP ROLE bttest_role;
diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c
index 52aa633056..28ea2f211b 100644
--- a/contrib/amcheck/verify_nbtree.c
+++ b/contrib/amcheck/verify_nbtree.c
@@ -1391,10 +1391,10 @@ static inline bool
 invariant_leq_offset(BtreeCheckState *state, ScanKey key,
 					 OffsetNumber upperbound)
 {
-	int16		natts = state->rel->rd_rel->relnatts;
+	int16		nkeyatts = IndexRelationGetNumberOfKeyAttributes(state->rel);
 	int32		cmp;
 
-	cmp = _bt_compare(state->rel, natts, key, state->target, upperbound);
+	cmp = _bt_compare(state->rel, nkeyatts, key, state->target, upperbound);
 
 	return cmp <= 0;
 }
@@ -1410,10 +1410,10 @@ static inline bool
 invariant_geq_offset(BtreeCheckState *state, ScanKey key,
 					 OffsetNumber lowerbound)
 {
-	int16		natts = state->rel->rd_rel->relnatts;
+	int16		nkeyatts = IndexRelationGetNumberOfKeyAttributes(state->rel);
 	int32		cmp;
 
-	cmp = _bt_compare(state->rel, natts, key, state->target, lowerbound);
+	cmp = _bt_compare(state->rel, nkeyatts, key, state->target, lowerbound);
 
 	return cmp >= 0;
 }
@@ -1433,10 +1433,10 @@ invariant_leq_nontarget_offset(BtreeCheckState *state,
 							   Page nontarget, ScanKey key,
 							   OffsetNumber upperbound)
 {
-	int16		natts = state->rel->rd_rel->relnatts;
+	int16		nkeyatts = IndexRelationGetNumberOfKeyAttributes(state->rel);
 	int32		cmp;
 
-	cmp = _bt_compare(state->rel, natts, key, nontarget, upperbound);
+	cmp = _bt_compare(state->rel, nkeyatts, key, nontarget, upperbound);
 
 	return cmp <= 0;
 }
