diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 106b2e075f8f4efaf555144dcdd6f41f6f79d4d4..cad53ff98361316f2561af06e0f3a18e2802f2ad 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -7827,7 +7827,7 @@ ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, const
 retry:
     if(report_error)
     {
-      if (file)
+      if (file && pTrans)
       {
         reterr= file->ndb_err(pTrans);
       }