diff --git a/src/hnsw.c b/src/hnsw.c
index 5bfc6193e..606466c82 100644
--- a/src/hnsw.c
+++ b/src/hnsw.c
@@ -130,7 +130,7 @@ hnswcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
 	Relation	index;
 
 	/* Never use index without order */
-	if (path->indexorderbys == NULL)
+	if (path->indexorderbys == NIL)
 	{
 		*indexStartupCost = get_float8_infinity();
 		*indexTotalCost = get_float8_infinity();
diff --git a/src/ivfflat.c b/src/ivfflat.c
index 9e8370ffe..c4cd1bbdf 100644
--- a/src/ivfflat.c
+++ b/src/ivfflat.c
@@ -92,7 +92,7 @@ ivfflatcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
 	Relation	index;
 
 	/* Never use index without order */
-	if (path->indexorderbys == NULL)
+	if (path->indexorderbys == NIL)
 	{
 		*indexStartupCost = get_float8_infinity();
 		*indexTotalCost = get_float8_infinity();
