diff --git i/src/backend/access/hash/hashovfl.c w/src/backend/access/hash/hashovfl.c
index 130c296..d4329fb 100644
--- i/src/backend/access/hash/hashovfl.c
+++ w/src/backend/access/hash/hashovfl.c
@@ -391,7 +391,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf,
 	uint32		ovflbitno;
 	int32		bitmappage,
 				bitmapbit;
+#ifdef USE_ASSERT_CHECKING
 	Bucket		bucket;
+#endif
 
 	/* Get information from the doomed page */
 	_hash_checkpage(rel, ovflbuf, LH_OVERFLOW_PAGE);
@@ -400,7 +402,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf,
 	ovflopaque = (HashPageOpaque) PageGetSpecialPointer(ovflpage);
 	nextblkno = ovflopaque->hasho_nextblkno;
 	prevblkno = ovflopaque->hasho_prevblkno;
+#ifdef USE_ASSERT_CHECKING
 	bucket = ovflopaque->hasho_bucket;
+#endif
 
 	/*
 	 * Zero the page for debugging's sake; then write and release it. (Note:
diff --git i/src/backend/executor/execCurrent.c w/src/backend/executor/execCurrent.c
index b07161f..41cdfcf 100644
--- i/src/backend/executor/execCurrent.c
+++ w/src/backend/executor/execCurrent.c
@@ -151,7 +151,9 @@ execCurrentOf(CurrentOfExpr *cexpr,
 	{
 		ScanState  *scanstate;
 		bool		lisnull;
+#ifdef USE_ASSERT_CHECKING
 		Oid			tuple_tableoid;
+#endif
 		ItemPointer tuple_tid;
 
 		/*
@@ -184,7 +186,9 @@ execCurrentOf(CurrentOfExpr *cexpr,
 			return false;
 
 		/* Use slot_getattr to catch any possible mistakes */
+#ifdef USE_ASSERT_CHECKING
 		tuple_tableoid =
+#endif
 			DatumGetObjectId(slot_getattr(scanstate->ss_ScanTupleSlot,
 										  TableOidAttributeNumber,
 										  &lisnull));
diff --git i/src/backend/executor/nodeMaterial.c w/src/backend/executor/nodeMaterial.c
index b320b54..6dbfe55 100644
--- i/src/backend/executor/nodeMaterial.c
+++ w/src/backend/executor/nodeMaterial.c
@@ -62,13 +62,16 @@ ExecMaterial(MaterialState *node)
 		tuplestore_set_eflags(tuplestorestate, node->eflags);
 		if (node->eflags & EXEC_FLAG_MARK)
 		{
+#ifdef USE_ASSERT_CHECKING
 			/*
 			 * Allocate a second read pointer to serve as the mark. We know it
 			 * must have index 1, so needn't store that.
 			 */
 			int			ptrno;
 
-			ptrno = tuplestore_alloc_read_pointer(tuplestorestate,
+			ptrno =
+#endif
+				tuplestore_alloc_read_pointer(tuplestorestate,
 												  node->eflags);
 			Assert(ptrno == 1);
 		}
diff --git i/src/backend/executor/nodeSetOp.c w/src/backend/executor/nodeSetOp.c
index 7fa5730..ee92125 100644
--- i/src/backend/executor/nodeSetOp.c
+++ w/src/backend/executor/nodeSetOp.c
@@ -344,7 +344,9 @@ setop_fill_hash_table(SetOpState *setopstate)
 	SetOp	   *node = (SetOp *) setopstate->ps.plan;
 	PlanState  *outerPlan;
 	int			firstFlag;
+#ifdef USE_ASSERT_CHECKING
 	bool		in_first_rel;
+#endif
 
 	/*
 	 * get state info from node
@@ -361,7 +363,9 @@ setop_fill_hash_table(SetOpState *setopstate)
 	 * Process each outer-plan tuple, and then fetch the next one, until we
 	 * exhaust the outer plan.
 	 */
+#ifdef USE_ASSERT_CHECKING
 	in_first_rel = true;
+#endif
 	for (;;)
 	{
 		TupleTableSlot *outerslot;
@@ -395,7 +399,9 @@ setop_fill_hash_table(SetOpState *setopstate)
 		else
 		{
 			/* reached second relation */
+#ifdef USE_ASSERT_CHECKING
 			in_first_rel = false;
+#endif
 
 			/* For tuples not seen previously, do not make hashtable entry */
 			entry = (SetOpHashEntry)
diff --git i/src/backend/executor/nodeWorktablescan.c w/src/backend/executor/nodeWorktablescan.c
index e2f3dd4..203fa6c 100644
--- i/src/backend/executor/nodeWorktablescan.c
+++ w/src/backend/executor/nodeWorktablescan.c
@@ -30,7 +30,9 @@ static TupleTableSlot *
 WorkTableScanNext(WorkTableScanState *node)
 {
 	TupleTableSlot *slot;
+#ifdef USE_ASSERT_CHECKING
 	EState	   *estate;
+#endif
 	Tuplestorestate *tuplestorestate;
 
 	/*
@@ -48,7 +50,9 @@ WorkTableScanNext(WorkTableScanState *node)
 	 * worktable.  Therefore, we don't need a private read pointer for the
 	 * tuplestore, nor do we need to tell tuplestore_gettupleslot to copy.
 	 */
+#ifdef USE_ASSERT_CHECKING
 	estate = node->ss.ps.state;
+#endif
 	Assert(ScanDirectionIsForward(estate->es_direction));
 
 	tuplestorestate = node->rustate->working_table;
diff --git i/src/backend/libpq/be-fsstubs.c w/src/backend/libpq/be-fsstubs.c
index b864c86..a3c8ad4 100644
--- i/src/backend/libpq/be-fsstubs.c
+++ w/src/backend/libpq/be-fsstubs.c
@@ -377,8 +377,10 @@ static Oid
 lo_import_internal(text *filename, Oid lobjOid)
 {
 	File		fd;
-	int			nbytes,
-				tmp;
+	int			nbytes;
+#ifdef USE_ASSERT_CHECKING
+	int			tmp;
+#endif
 	char		buf[BUFSIZE];
 	char		fnamebuf[MAXPGPATH];
 	LargeObjectDesc *lobj;
@@ -417,7 +419,10 @@ lo_import_internal(text *filename, Oid lobjOid)
 
 	while ((nbytes = FileRead(fd, buf, BUFSIZE)) > 0)
 	{
-		tmp = inv_write(lobj, buf, nbytes);
+#ifdef USE_ASSERT_CHECKING
+		tmp =
+#endif
+			inv_write(lobj, buf, nbytes);
 		Assert(tmp == nbytes);
 	}
 
diff --git i/src/backend/libpq/pqcomm.c w/src/backend/libpq/pqcomm.c
index 35812f4..0c256b8 100644
--- i/src/backend/libpq/pqcomm.c
+++ w/src/backend/libpq/pqcomm.c
@@ -1373,7 +1373,9 @@ fail:
 void
 pq_putmessage_noblock(char msgtype, const char *s, size_t len)
 {
+#ifdef USE_ASSERT_CHECKING
 	int			res;
+#endif
 	int			required;
 
 	/*
@@ -1386,7 +1388,10 @@ pq_putmessage_noblock(char msgtype, const char *s, size_t len)
 		PqSendBuffer = repalloc(PqSendBuffer, required);
 		PqSendBufferSize = required;
 	}
-	res = pq_putmessage(msgtype, s, len);
+#ifdef USE_ASSERT_CHECKING
+	res =
+#endif
+		pq_putmessage(msgtype, s, len);
 	Assert(res == 0);			/* should not fail when the message fits in
 								 * buffer */
 }
diff --git i/src/backend/optimizer/path/costsize.c w/src/backend/optimizer/path/costsize.c
index e1c070e..2b9c82a 100644
--- i/src/backend/optimizer/path/costsize.c
+++ w/src/backend/optimizer/path/costsize.c
@@ -3245,12 +3245,16 @@ void
 set_subquery_size_estimates(PlannerInfo *root, RelOptInfo *rel)
 {
 	PlannerInfo *subroot = rel->subroot;
+#ifdef USE_ASSERT_CHECKING
 	RangeTblEntry *rte;
+#endif
 	ListCell   *lc;
 
 	/* Should only be applied to base relations that are subqueries */
 	Assert(rel->relid > 0);
+#ifdef USE_ASSERT_CHECKING
 	rte = planner_rt_fetch(rel->relid, root);
+#endif
 	Assert(rte->rtekind == RTE_SUBQUERY);
 
 	/* Copy raw number of output rows from subplan */
diff --git i/src/backend/optimizer/plan/createplan.c w/src/backend/optimizer/plan/createplan.c
index e41d2a6..369490d 100644
--- i/src/backend/optimizer/plan/createplan.c
+++ w/src/backend/optimizer/plan/createplan.c
@@ -1820,14 +1820,18 @@ create_foreignscan_plan(PlannerInfo *root, ForeignPath *best_path,
 	ForeignScan *scan_plan;
 	RelOptInfo *rel = best_path->path.parent;
 	Index		scan_relid = rel->relid;
+#ifdef USE_ASSERT_CHECKING
 	RangeTblEntry *rte;
+#endif
 	bool		fsSystemCol;
 	int			i;
 
 	/* it should be a base rel... */
 	Assert(scan_relid > 0);
 	Assert(rel->rtekind == RTE_RELATION);
+#ifdef USE_ASSERT_CHECKING
 	rte = planner_rt_fetch(scan_relid, root);
+#endif
 	Assert(rte->rtekind == RTE_RELATION);
 
 	/* Sort clauses into best execution order */
diff --git i/src/backend/parser/analyze.c w/src/backend/parser/analyze.c
index be6e93e..b6cf8c2 100644
--- i/src/backend/parser/analyze.c
+++ w/src/backend/parser/analyze.c
@@ -1530,7 +1530,9 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
 		/* Process leaf SELECT */
 		Query	   *selectQuery;
 		char		selectName[32];
+#ifdef USE_ASSERT_CHECKING
 		RangeTblEntry *rte;
+#endif
 		RangeTblRef *rtr;
 		ListCell   *tl;
 
@@ -1579,7 +1581,10 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt,
 		 */
 		snprintf(selectName, sizeof(selectName), "*SELECT* %d",
 				 list_length(pstate->p_rtable) + 1);
-		rte = addRangeTableEntryForSubquery(pstate,
+#ifdef USE_ASSERT_CHECKING
+		rte =
+#endif
+			addRangeTableEntryForSubquery(pstate,
 											selectQuery,
 											makeAlias(selectName, NIL),
 											false);
diff --git i/src/backend/storage/file/fd.c w/src/backend/storage/file/fd.c
index 43bc43a..915511e 100644
--- i/src/backend/storage/file/fd.c
+++ w/src/backend/storage/file/fd.c
@@ -684,9 +684,12 @@ LruInsert(File file)
 		/* seek to the right position */
 		if (vfdP->seekPos != (off_t) 0)
 		{
+#ifdef USE_ASSERT_CHECKING
 			off_t		returnValue;
 
-			returnValue = lseek(vfdP->fd, vfdP->seekPos, SEEK_SET);
+			returnValue =
+#endif
+				lseek(vfdP->fd, vfdP->seekPos, SEEK_SET);
 			Assert(returnValue != (off_t) -1);
 		}
 	}
diff --git i/src/backend/storage/lmgr/predicate.c w/src/backend/storage/lmgr/predicate.c
index 9e927f8..9134d3e 100644
--- i/src/backend/storage/lmgr/predicate.c
+++ w/src/backend/storage/lmgr/predicate.c
@@ -2013,7 +2013,9 @@ RestoreScratchTarget(bool lockheld)
 static void
 RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target, uint32 targettaghash)
 {
+#ifdef USE_ASSERT_CHECKING
 	PREDICATELOCKTARGET *rmtarget;
+#endif
 
 	Assert(LWLockHeldByMe(SerializablePredicateLockListLock));
 
@@ -2022,7 +2024,10 @@ RemoveTargetIfNoLongerUsed(PREDICATELOCKTARGET *target, uint32 targettaghash)
 		return;
 
 	/* Actually remove the target. */
-	rmtarget = hash_search_with_hash_value(PredicateLockTargetHash,
+#ifdef USE_ASSERT_CHECKING
+	rmtarget =
+#endif
+		hash_search_with_hash_value(PredicateLockTargetHash,
 										   &target->tag,
 										   targettaghash,
 										   HASH_REMOVE, NULL);
@@ -2074,7 +2079,9 @@ DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag)
 		{
 			uint32		oldtargettaghash;
 			LWLockId	partitionLock;
+#ifdef USE_ASSERT_CHECKING
 			PREDICATELOCK *rmpredlock;
+#endif
 
 			oldtargettaghash = PredicateLockTargetTagHashCode(&oldtargettag);
 			partitionLock = PredicateLockHashPartitionLock(oldtargettaghash);
@@ -2083,7 +2090,10 @@ DeleteChildTargetLocks(const PREDICATELOCKTARGETTAG *newtargettag)
 
 			SHMQueueDelete(predlocksxactlink);
 			SHMQueueDelete(&(predlock->targetLink));
-			rmpredlock = hash_search_with_hash_value
+#ifdef USE_ASSERT_CHECKING
+			rmpredlock =
+#endif
+				hash_search_with_hash_value
 				(PredicateLockHash,
 				 &oldlocktag,
 				 PredicateLockHashCodeFromTargetHashCode(&oldlocktag,
@@ -2226,8 +2236,10 @@ DecrementParentLocks(const PREDICATELOCKTARGETTAG *targettag)
 	while (GetParentPredicateLockTag(&parenttag, &nexttag))
 	{
 		uint32		targettaghash;
-		LOCALPREDICATELOCK *parentlock,
-				   *rmlock;
+		LOCALPREDICATELOCK *parentlock;
+#ifdef USE_ASSERT_CHECKING
+		LOCALPREDICATELOCK *rmlock;
+#endif
 
 		parenttag = nexttag;
 		targettaghash = PredicateLockTargetTagHashCode(&parenttag);
@@ -2259,7 +2271,9 @@ DecrementParentLocks(const PREDICATELOCKTARGETTAG *targettag)
 
 		if ((parentlock->childLocks == 0) && (!parentlock->held))
 		{
+#ifdef USE_ASSERT_CHECKING
 			rmlock = (LOCALPREDICATELOCK *)
+#endif
 				hash_search_with_hash_value(LocalPredicateLockHash,
 											&parenttag, targettaghash,
 											HASH_REMOVE, NULL);
diff --git i/src/backend/storage/lmgr/proc.c w/src/backend/storage/lmgr/proc.c
index dcf1928..2c3a72b 100644
--- i/src/backend/storage/lmgr/proc.c
+++ w/src/backend/storage/lmgr/proc.c
@@ -806,12 +806,16 @@ ProcKill(int code, Datum arg)
 static void
 AuxiliaryProcKill(int code, Datum arg)
 {
+#ifdef USE_ASSERT_CHECKING
 	int			proctype = DatumGetInt32(arg);
 	PGPROC	   *auxproc;
+#endif
 
 	Assert(proctype >= 0 && proctype < NUM_AUXILIARY_PROCS);
 
+#ifdef USE_ASSERT_CHECKING
 	auxproc = &AuxiliaryProcs[proctype];
+#endif
 
 	Assert(MyProc == auxproc);
 
diff --git i/src/backend/utils/adt/selfuncs.c w/src/backend/utils/adt/selfuncs.c
index da638f8..a133856 100644
--- i/src/backend/utils/adt/selfuncs.c
+++ w/src/backend/utils/adt/selfuncs.c
@@ -3771,7 +3771,9 @@ convert_string_datum(Datum value, Oid typid)
 	{
 		char	   *xfrmstr;
 		size_t		xfrmlen;
+#ifdef USE_ASSERT_CHECKING
 		size_t		xfrmlen2;
+#endif
 
 		/*
 		 * Note: originally we guessed at a suitable output buffer size, and
@@ -3815,7 +3817,10 @@ convert_string_datum(Datum value, Oid typid)
 			return val;
 #endif
 		xfrmstr = (char *) palloc(xfrmlen + 1);
-		xfrmlen2 = strxfrm(xfrmstr, val, xfrmlen + 1);
+#ifdef USE_ASSERT_CHECKING
+		xfrmlen2 =
+#endif
+			strxfrm(xfrmstr, val, xfrmlen + 1);
 		Assert(xfrmlen2 <= xfrmlen);
 		pfree(val);
 		val = xfrmstr;
@@ -6280,8 +6285,10 @@ btcostestimate(PG_FUNCTION_ARGS)
 	{
 		RestrictInfo *rinfo = (RestrictInfo *) lfirst(lcc);
 		Expr	   *clause;
-		Node	   *leftop,
-				   *rightop;
+		Node	   *leftop;
+#ifdef USE_ASSERT_CHECKING
+		Node	   *rightop;
+#endif
 		Oid			clause_op;
 		int			op_strategy;
 		bool		is_null_op = false;
@@ -6303,7 +6310,9 @@ btcostestimate(PG_FUNCTION_ARGS)
 		if (IsA(clause, OpExpr))
 		{
 			leftop = get_leftop(clause);
+#ifdef USE_ASSERT_CHECKING
 			rightop = get_rightop(clause);
+#endif
 			clause_op = ((OpExpr *) clause)->opno;
 		}
 		else if (IsA(clause, RowCompareExpr))
@@ -6311,7 +6320,9 @@ btcostestimate(PG_FUNCTION_ARGS)
 			RowCompareExpr *rc = (RowCompareExpr *) clause;
 
 			leftop = (Node *) linitial(rc->largs);
+#ifdef USE_ASSERT_CHECKING
 			rightop = (Node *) linitial(rc->rargs);
+#endif
 			clause_op = linitial_oid(rc->opnos);
 		}
 		else if (IsA(clause, ScalarArrayOpExpr))
@@ -6319,7 +6330,9 @@ btcostestimate(PG_FUNCTION_ARGS)
 			ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) clause;
 
 			leftop = (Node *) linitial(saop->args);
+#ifdef USE_ASSERT_CHECKING
 			rightop = (Node *) lsecond(saop->args);
+#endif
 			clause_op = saop->opno;
 			found_saop = true;
 		}
@@ -6328,7 +6341,9 @@ btcostestimate(PG_FUNCTION_ARGS)
 			NullTest   *nt = (NullTest *) clause;
 
 			leftop = (Node *) nt->arg;
+#ifdef USE_ASSERT_CHECKING
 			rightop = NULL;
+#endif
 			clause_op = InvalidOid;
 			if (nt->nulltesttype == IS_NULL)
 			{
diff --git i/src/bin/psql/psqlscan.l w/src/bin/psql/psqlscan.l
index a27bcd1..545ab02 100644
--- i/src/bin/psql/psqlscan.l
+++ w/src/bin/psql/psqlscan.l
@@ -1474,7 +1474,9 @@ psql_scan_slash_option(PsqlScanState state,
 					   bool semicolon)
 {
 	PQExpBufferData mybuf;
+#ifdef USE_ASSERT_CHECKING
 	int			lexresult;
+#endif
 	char		local_quote;
 
 	/* Must be scanning already */
@@ -1505,7 +1507,10 @@ psql_scan_slash_option(PsqlScanState state,
 		BEGIN(xslashargstart);
 
 	/* And lex. */
-	lexresult = yylex();
+#ifdef USE_ASSERT_CHECKING
+	lexresult =
+#endif
+		yylex();
 
 	/*
 	 * Check the lex result: we should have gotten back either LEXRES_OK
