diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 4d0d295..8472de2 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -852,7 +852,7 @@ def fill_table_cache(opts, select, tables, where, old_prefix, cache_tables_seen,
     """
 
     # If we've got a max_depth set and we've exceeded that depth, bail now.
-    if max_depth and cur_depth > max_depth:
+    if max_depth and cur_depth >= max_depth:
         return None
 
     qn = connection.ops.quote_name
diff --git a/tests/modeltests/select_related/models.py b/tests/modeltests/select_related/models.py
index 43efab3..60e66b5 100644
--- a/tests/modeltests/select_related/models.py
+++ b/tests/modeltests/select_related/models.py
@@ -147,6 +147,13 @@ __test__ = {'API_TESTS':"""
 >>> len(db.connection.queries)
 5
 
+# Test the bug with select_related and extra combination
+>>> s = Species.objects.all().select_related(depth=1).extra(select={'a': 'select_related_species.id + 10'})[0]
+
+# With the correct code the result should be True
+>>> s.id + 10 == s.a
+True
+
 # Reset DEBUG to where we found it.
 >>> settings.DEBUG = False
 """}
