From 498fd3817409d1f8b76d61efca2d5bb2681566d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= <marko.makela@mariadb.com>
Date: Wed, 9 Mar 2022 09:51:57 +0200
Subject: [PATCH] Add #ifndef NO_AUTOINC_LOCKS

---
 storage/innobase/dict/drop.cc         |  2 ++
 storage/innobase/handler/ha_innodb.cc | 10 ++++++++
 storage/innobase/handler/i_s.cc       |  9 ++++---
 storage/innobase/include/lock0lock.h  |  2 ++
 storage/innobase/include/lock0priv.h  | 12 +++++++++-
 storage/innobase/include/lock0types.h |  4 ++++
 storage/innobase/include/row0mysql.h  |  4 +++-
 storage/innobase/include/trx0trx.h    |  4 ++++
 storage/innobase/lock/lock0lock.cc    | 34 +++++++++++++++++++++++++--
 storage/innobase/row/row0mysql.cc     |  3 ++-
 storage/innobase/trx/trx0i_s.cc       |  2 ++
 storage/innobase/trx/trx0trx.cc       | 20 ++++++++++------
 12 files changed, 91 insertions(+), 15 deletions(-)

diff --git a/storage/innobase/dict/drop.cc b/storage/innobase/dict/drop.cc
index 7934f548f00..d40c5d10c7b 100644
--- a/storage/innobase/dict/drop.cc
+++ b/storage/innobase/dict/drop.cc
@@ -162,8 +162,10 @@ dberr_t trx_t::drop_table(const dict_table_t &table)
       found_x= true;
       break;
     case LOCK_TABLE | LOCK_IX:
+#ifndef NO_AUTOINC_LOCKS
     case LOCK_TABLE | LOCK_AUTO_INC:
     case LOCK_TABLE | LOCK_AUTO_INC_X:
+#endif
       break;
     default:
       ut_ad("unexpected lock type" == 0);
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index a7fd29a31c6..4a49ec7e7a7 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -4505,10 +4505,12 @@ innobase_commit(
 		/* We just mark the SQL statement ended and do not do a
 		transaction commit */
 
+#ifndef NO_AUTOINC_LOCKS
 		/* If we had reserved the auto-inc lock for some
 		table in this SQL statement we release it now */
 
 		lock_unlock_table_autoinc(trx);
+#endif
 
 		/* Store the current undo_no of the transaction so that we
 		know where to roll back if we have to roll back the next
@@ -4558,10 +4560,12 @@ innobase_rollback(
 
 	trx->n_autoinc_rows = 0;
 
+#ifndef NO_AUTOINC_LOCKS
 	/* If we had reserved the auto-inc lock for some table (if
 	we come here to roll back the latest SQL statement) we
 	release it now before a possibly lengthy rollback */
 	lock_unlock_table_autoinc(trx);
+#endif
 
 	/* This is a statement level variable. */
 
@@ -4605,10 +4609,12 @@ innobase_rollback_trx(
 	DBUG_ENTER("innobase_rollback_trx");
 	DBUG_PRINT("trans", ("aborting transaction"));
 
+#ifndef NO_AUTOINC_LOCKS
 	/* If we had reserved the auto-inc lock for some table (if
 	we come here to roll back the latest SQL statement) we
 	release it now before a possibly lengthy rollback */
 	lock_unlock_table_autoinc(trx);
+#endif
 	trx_deregister_from_2pc(trx);
 
 	DBUG_RETURN(convert_error_code_to_mysql(trx_rollback_for_mysql(trx),
@@ -7622,6 +7628,7 @@ ha_innobase::innobase_lock_autoinc()
   ut_ad(!srv_read_only_mode);
 
 #ifdef HAVE_REPLICATION
+# ifndef NO_AUTOINC_LOCKS
   switch (innobase_autoinc_lock_mode) {
   default:
     if (UNIV_UNLIKELY(thd_rpl_stmt_based(m_user_thd)))
@@ -7654,6 +7661,7 @@ ha_innobase::innobase_lock_autoinc()
     if (dberr_t error= row_lock_table_autoinc(m_prebuilt, false))
       DBUG_RETURN(error);
   }
+# endif
 #endif
 
   /* Acquire the AUTOINC mutex. */
@@ -16932,10 +16940,12 @@ innobase_xa_prepare(
 		/* We just mark the SQL statement ended and do not do a
 		transaction prepare */
 
+#ifndef NO_AUTOINC_LOCKS
 		/* If we had reserved the auto-inc lock for some
 		table in this SQL statement we release it now */
 
 		lock_unlock_table_autoinc(trx);
+#endif
 
 		/* Store the current undo_no of the transaction so that we
 		know where to roll back if we have to roll back the next
diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc
index 175b07551b0..5efb61beb84 100644
--- a/storage/innobase/handler/i_s.cc
+++ b/storage/innobase/handler/i_s.cc
@@ -571,11 +571,14 @@ static const LEX_CSTRING lock_mode_values[] =
 	{ STRING_WITH_LEN("IS") },
 	{ STRING_WITH_LEN("IS,GAP") },
 	{ STRING_WITH_LEN("IX") },
-	{ STRING_WITH_LEN("IX,GAP") },
-	{ STRING_WITH_LEN("AUTO_INC") }
+	{ STRING_WITH_LEN("IX,GAP") }
+#ifndef NO_AUTOINC_LOCKS
+	,{ STRING_WITH_LEN("AUTO_INC") }
+#endif
 };
 
-static TypelibBuffer<9> lock_mode_values_typelib(lock_mode_values);
+static TypelibBuffer<array_elements(lock_mode_values)>
+lock_mode_values_typelib(lock_mode_values);
 
 static const LEX_CSTRING lock_type_values[] =
 {
diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h
index 28d75517d45..4d768f7c6c8 100644
--- a/storage/innobase/include/lock0lock.h
+++ b/storage/innobase/include/lock0lock.h
@@ -512,6 +512,7 @@ bool lock_table_has_locks(dict_table_t *table);
 @retval DB_LOCK_WAIT_TIMEOUT if the lock wait timed out
 @retval DB_SUCCESS if the lock was granted */
 dberr_t lock_wait(que_thr_t *thr);
+#ifndef NO_AUTOINC_LOCKS
 /*********************************************************************//**
 Unlocks AUTO_INC type locks that were possibly reserved by a trx. This
 function should be called at the the end of an SQL statement, by the
@@ -520,6 +521,7 @@ void
 lock_unlock_table_autoinc(
 /*======================*/
 	trx_t*	trx);			/*!< in/out: transaction */
+#endif
 
 /** Handle a pending lock wait (DB_LOCK_WAIT) in a semi-consistent read
 while holding a clustered index leaf page latch.
diff --git a/storage/innobase/include/lock0priv.h b/storage/innobase/include/lock0priv.h
index e3de3076ad3..dc165432895 100644
--- a/storage/innobase/include/lock0priv.h
+++ b/storage/innobase/include/lock0priv.h
@@ -73,12 +73,22 @@ ib_lock_t::print(std::ostream& out) const
   static_assert(LOCK_IX == 1, "compatibility");
   static_assert(LOCK_S == 2, "compatibility");
   static_assert(LOCK_X == 3, "compatibility");
+#ifndef NO_AUTOINC_LOCKS
   static_assert(LOCK_AUTO_INC == 4, "compatibility");
   static_assert(LOCK_AUTO_INC_X == 5, "compatibility");
   static_assert(LOCK_NONE == 6, "compatibility");
   static_assert(LOCK_NONE_UNSET == 7, "compatibility");
+#else
+  static_assert(LOCK_NONE == 4, "compatibility");
+  static_assert(LOCK_NONE_UNSET == 5, "compatibility");
+#endif
   const char *const modes[8]=
-  { "IS", "IX", "S", "X", "AUTO_INC", "AUTO_INC_X", "NONE", "NONE_UNSET" };
+  { "IS", "IX", "S", "X",
+#ifndef NO_AUTOINC_LOCKS
+    "AUTO_INC", "AUTO_INC_X",
+#endif
+    "NONE", "NONE_UNSET"
+  };
 
   out << "[lock_t: type_mode=" << type_mode << "(" << type_string()
       << " | LOCK_" << modes[mode()];
diff --git a/storage/innobase/include/lock0types.h b/storage/innobase/include/lock0types.h
index 2f8ef8dfb58..d5809c58f1a 100644
--- a/storage/innobase/include/lock0types.h
+++ b/storage/innobase/include/lock0types.h
@@ -42,9 +42,11 @@ enum lock_mode {
 	LOCK_IX,	/* intention exclusive */
 	LOCK_S,		/* shared */
 	LOCK_X,		/* exclusive */
+#ifndef NO_AUTOINC_LOCKS
 	LOCK_AUTO_INC,	/* locks the auto-inc counter of a table
 			in an exclusive mode */
 	LOCK_AUTO_INC_X,/* exclusive lock for protecting AUTO_INCREMENT */
+#endif
 	LOCK_NONE,	/* this is used elsewhere to note consistent read */
 	LOCK_NONE_UNSET
 };
@@ -201,7 +203,9 @@ struct ib_lock_t
 
 	bool is_table() const { return type_mode & LOCK_TABLE; }
 
+#ifndef NO_AUTOINC_LOCKS
 	bool is_auto_increment() const { return type_mode & LOCK_AUTO_INC; }
+#endif
 
 	enum lock_mode mode() const
 	{
diff --git a/storage/innobase/include/row0mysql.h b/storage/innobase/include/row0mysql.h
index dd083575008..c5d8a4ccc84 100644
--- a/storage/innobase/include/row0mysql.h
+++ b/storage/innobase/include/row0mysql.h
@@ -1,7 +1,7 @@
 /*****************************************************************************
 
 Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2021, MariaDB Corporation.
+Copyright (c) 2017, 2022, MariaDB Corporation.
 
 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
@@ -194,6 +194,7 @@ row_update_prebuilt_trx(
 					in MySQL handle */
 	trx_t*		trx);		/*!< in: transaction handle */
 
+#ifndef NO_AUTOINC_LOCKS
 /** Acquire an exclusive or AUTO_INCREMENT lock on prebuilt->table.
 The lock gives exclusive access to the auto-inc counter.
 The lock is held for the duration of an SQL statement.
@@ -201,6 +202,7 @@ The lock is held for the duration of an SQL statement.
 @param auto_inc    false=exclusive lock, true=AUTO_INC lock
 @return error code or DB_SUCCESS */
 dberr_t row_lock_table_autoinc(row_prebuilt_t *prebuilt, bool exclusive);
+#endif
 
 /** Lock a table.
 @param[in,out]	prebuilt	table handle
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index 1de713ebffe..15321847f5a 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -887,12 +887,14 @@ struct trx_t : ilist_node<>
 	ulint		n_autoinc_rows;	/*!< no. of AUTO-INC rows required for
 					an SQL statement. This is useful for
 					multi-row INSERTs */
+#ifndef NO_AUTOINC_LOCKS
 	ib_vector_t*    autoinc_locks;  /* AUTOINC locks held by this
 					transaction. Note that these are
 					also in the lock list trx_locks. This
 					vector needs to be freed explicitly
 					when the trx instance is destroyed.
 					Protected by lock_sys.latch. */
+#endif
 	/*------------------------------*/
 	bool		read_only;	/*!< true if transaction is flagged
 					as a READ-ONLY transaction.
@@ -1067,7 +1069,9 @@ struct trx_t : ilist_node<>
     ut_ad(!lock.wait_lock);
     ut_ad(UT_LIST_GET_LEN(lock.trx_locks) == 0);
     ut_ad(lock.table_locks.empty());
+#ifndef NO_AUTOINC_LOCKS
     ut_ad(!autoinc_locks || ib_vector_is_empty(autoinc_locks));
+#endif
     ut_ad(UT_LIST_GET_LEN(lock.evicted_tables) == 0);
     ut_ad(!dict_operation);
   }
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index ecc6c0f62ef..3cfefdcebef 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -1654,8 +1654,10 @@ static void lock_wait_rpl_report(trx_t *trx)
   const lock_t *wait_lock= trx->lock.wait_lock;
   if (!wait_lock)
     return;
+#ifndef NO_AUTOINC_LOCKS
   static_assert(LOCK_AUTO_INC & LOCK_AUTO_INC_X, "compatibility");
   ut_ad(!(wait_lock->type_mode & LOCK_AUTO_INC));
+#endif
   /* This would likely be too large to attempt to use a memory transaction,
   even for wait_lock->is_table(). */
   if (!lock_sys.wr_lock_try())
@@ -1674,14 +1676,20 @@ static void lock_wait_rpl_report(trx_t *trx)
   }
   else if (!wait_lock->is_waiting())
     goto func_exit;
+#ifndef NO_AUTOINC_LOCKS
   ut_ad(!(wait_lock->type_mode & LOCK_AUTO_INC));
+#endif
 
   if (wait_lock->is_table())
   {
     dict_table_t *table= wait_lock->un_member.tab_lock.table;
     for (lock_t *lock= UT_LIST_GET_FIRST(table->locks); lock;
          lock= UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock))
-      if (!(lock->type_mode & LOCK_AUTO_INC) && lock->trx != trx)
+      if (
+#ifndef NO_AUTOINC_LOCKS
+          !(lock->type_mode & LOCK_AUTO_INC) &&
+#endif
+          lock->trx != trx)
         thd_rpl_deadlock_check(thd, lock->trx->mysql_thd);
   }
   else
@@ -1769,7 +1777,11 @@ dberr_t lock_wait(que_thr_t *thr)
   thd_need_wait_reports() will hold even if parallel (or any) replication
   is not being used. We want to be allow the user to skip
   lock_wait_rpl_report(). */
-  const bool rpl= !(type_mode & LOCK_AUTO_INC) && trx->mysql_thd &&
+  const bool rpl=
+# ifndef NO_AUTOINC_LOCKS
+    !(type_mode & LOCK_AUTO_INC) &&
+# endif
+    trx->mysql_thd &&
     innodb_deadlock_detect && thd_need_wait_reports(trx->mysql_thd);
 #endif
   const bool row_lock_wait= thr->lock_state == QUE_THR_LOCK_ROW;
@@ -1894,6 +1906,7 @@ static void lock_grant(lock_t *lock)
   lock_reset_lock_and_trx_wait(lock);
   trx_t *trx= lock->trx;
   trx->mutex_lock();
+#ifndef NO_AUTOINC_LOCKS
   switch (lock->mode()) {
   default:
     break;
@@ -1905,6 +1918,7 @@ static void lock_grant(lock_t *lock)
     ib_vector_push(trx->autoinc_locks, &lock);
     break;
   }
+#endif
 
   DBUG_PRINT("ib_lock", ("wait for trx " TRX_ID_FMT " ends", trx->id));
 
@@ -3160,6 +3174,7 @@ lock_t *lock_table_create(dict_table_t *table, unsigned type_mode, trx_t *trx,
 		  == table->name.m_name + strlen(table->name.m_name) + 1));
 
 	switch (LOCK_MODE_MASK & type_mode) {
+#ifndef NO_AUTOINC_LOCKS
 	case LOCK_AUTO_INC:
 	case LOCK_AUTO_INC_X:
 		++table->n_waiting_or_granted_auto_inc_locks;
@@ -3177,6 +3192,7 @@ lock_t *lock_table_create(dict_table_t *table, unsigned type_mode, trx_t *trx,
 		}
 
 		break;
+#endif
 	case LOCK_X:
 	case LOCK_S:
 		++table->n_lock_x_or_s;
@@ -3188,7 +3204,9 @@ lock_t *lock_table_create(dict_table_t *table, unsigned type_mode, trx_t *trx,
 		: static_cast<lock_t*>(
 			mem_heap_alloc(trx->lock.lock_heap, sizeof *lock));
 
+#ifndef NO_AUTOINC_LOCKS
 allocated:
+#endif
 	lock->type_mode = ib_uint32_t(type_mode | LOCK_TABLE);
 	lock->trx = trx;
 
@@ -3221,6 +3239,7 @@ lock_t *lock_table_create(dict_table_t *table, unsigned type_mode, trx_t *trx,
 	return(lock);
 }
 
+#ifndef NO_AUTOINC_LOCKS
 /*************************************************************//**
 Pops autoinc lock requests from the transaction's autoinc_locks. We
 handle the case where there are gaps in the array and they need to
@@ -3296,6 +3315,7 @@ lock_table_remove_autoinc_lock(
 		ut_error;
 	}
 }
+#endif
 
 /*************************************************************//**
 Removes a table lock request from the queue and the trx list of locks;
@@ -3321,6 +3341,7 @@ lock_table_remove_low(
 	/* Remove the table from the transaction's AUTOINC vector, if
 	the lock that is being released is an AUTOINC lock. */
 	switch (lock->mode()) {
+#ifndef NO_AUTOINC_LOCKS
 	case LOCK_AUTO_INC:
 	case LOCK_AUTO_INC_X:
 		ut_ad((table->autoinc_trx == trx) == !lock->is_waiting());
@@ -3340,6 +3361,7 @@ lock_table_remove_low(
 		ut_ad(table->n_waiting_or_granted_auto_inc_locks);
 		--table->n_waiting_or_granted_auto_inc_locks;
 		break;
+#endif
 	case LOCK_X:
 	case LOCK_S:
 		ut_ad(table->n_lock_x_or_s);
@@ -4167,10 +4189,12 @@ lock_table_print(FILE* file, const lock_t* lock)
 		ut_ad(lock->trx->id != 0);
 		fputs(" lock mode IX", file);
 		break;
+#ifndef NO_AUTOINC_LOCKS
 	case LOCK_AUTO_INC:
 	case LOCK_AUTO_INC_X:
 		fputs(" lock mode AUTO-INC", file);
 		break;
+#endif
 	default:
 		fprintf(file, " unknown lock mode %u", mode);
 	}
@@ -5579,6 +5603,7 @@ lock_clust_rec_read_check_and_lock_alt(
 	return(err);
 }
 
+#ifndef NO_AUTOINC_LOCKS
 /*******************************************************************//**
 Check if a transaction holds any autoinc locks.
 @return TRUE if the transaction holds any AUTOINC locks. */
@@ -5619,6 +5644,7 @@ static void lock_release_autoinc_locks(trx_t *trx)
   mysql_mutex_unlock(&lock_sys.wait_mutex);
   trx->mutex_unlock();
 }
+#endif
 
 /** Cancel a waiting lock request and release possibly waiting transactions */
 static void lock_cancel_waiting_and_release(lock_t *lock)
@@ -5633,11 +5659,13 @@ static void lock_cancel_waiting_and_release(lock_t *lock)
     lock_rec_dequeue_from_page(lock, true);
   else
   {
+#ifndef NO_AUTOINC_LOCKS
     if (lock->is_auto_increment())
     {
       ut_ad(trx->autoinc_locks);
       ib_vector_remove(trx->autoinc_locks, lock);
     }
+#endif
     lock_table_dequeue(lock, true);
     /* Remove the lock from table lock vector too. */
     lock_trx_table_locks_remove(lock);
@@ -5785,6 +5813,7 @@ void lock_sys_t::cancel(trx_t *trx)
   mysql_mutex_unlock(&lock_sys.wait_mutex);
 }
 
+#ifndef NO_AUTOINC_LOCKS
 /*********************************************************************//**
 Unlocks AUTO_INC type locks that were possibly reserved by a trx. This
 function should be called at the the end of an SQL statement, by the
@@ -5812,6 +5841,7 @@ lock_unlock_table_autoinc(
 		lock_release_autoinc_locks(trx);
 	}
 }
+#endif
 
 /** Handle a pending lock wait (DB_LOCK_WAIT) in a semi-consistent read
 while holding a clustered index leaf page latch.
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index 813b7ec55b1..2b5f082c830 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -1078,7 +1078,7 @@ row_get_prebuilt_insert_row(
 	return(prebuilt->ins_node->row);
 }
 
-
+#ifndef NO_AUTOINC_LOCKS
 /** Acquire an exclusive or AUTO_INCREMENT lock on prebuilt->table.
 The lock gives exclusive access to the auto-inc counter.
 The lock is held for the duration of an SQL statement.
@@ -1114,6 +1114,7 @@ dberr_t row_lock_table_autoinc(row_prebuilt_t *prebuilt, bool exclusive)
 
   return err;
 }
+#endif
 
 /** Lock a table.
 @param[in,out]	prebuilt	table handle
diff --git a/storage/innobase/trx/trx0i_s.cc b/storage/innobase/trx/trx0i_s.cc
index 623e1d4daa3..df00df02daf 100644
--- a/storage/innobase/trx/trx0i_s.cc
+++ b/storage/innobase/trx/trx0i_s.cc
@@ -728,10 +728,12 @@ static bool fill_locks_row(
 	case LOCK_IX:
 		row->lock_mode = uint8_t(7 + is_gap_lock);
 		break;
+#ifndef NO_AUTOINC_LOCKS
 	case LOCK_AUTO_INC:
 	case LOCK_AUTO_INC_X:
 		row->lock_mode = 9;
 		break;
+#endif
 	default:
 		ut_ad("unknown lock mode" == 0);
 		row->lock_mode = 0;
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index 6e8467f081d..01068676b8d 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -333,20 +333,18 @@ trx_t *trx_create()
 
 	trx->assert_freed();
 
-	mem_heap_t*	heap;
-	ib_alloc_t*	alloc;
-
 	/* We just got trx from pool, it should be non locking */
 	ut_ad(!trx->will_lock);
 	ut_ad(!trx->rw_trx_hash_pins);
 
 	DBUG_LOG("trx", "Create: " << trx);
 
-	heap = mem_heap_create(sizeof(ib_vector_t) + sizeof(void*) * 8);
-
-	alloc = ib_heap_allocator_create(heap);
-
+#ifndef NO_AUTOINC_LOCKS
+	mem_heap_t* heap
+		= mem_heap_create(sizeof(ib_vector_t) + sizeof(void*) * 8);
+	ib_alloc_t* alloc = ib_heap_allocator_create(heap);
 	trx->autoinc_locks = ib_vector_create(alloc, sizeof(void**), 4);
+#endif
 
 	ut_ad(trx->mod_tables.empty());
 	ut_ad(trx->lock.n_rec_locks == 0);
@@ -389,6 +387,7 @@ void trx_t::free()
 
   mysql_thd= nullptr;
 
+#ifndef NO_AUTOINC_LOCKS
   // FIXME: We need to avoid this heap free/alloc for each commit.
   if (autoinc_locks)
   {
@@ -397,6 +396,7 @@ void trx_t::free()
     ib_vector_free(autoinc_locks);
     autoinc_locks= NULL;
   }
+#endif
 
   MEM_NOACCESS(&n_ref, sizeof n_ref);
   /* do not poison mutex */
@@ -439,7 +439,9 @@ void trx_t::free()
   MEM_NOACCESS(&in_rollback, sizeof in_rollback);
   MEM_NOACCESS(&pages_undone, sizeof pages_undone);
   MEM_NOACCESS(&n_autoinc_rows, sizeof n_autoinc_rows);
+#ifndef NO_AUTOINC_LOCKS
   MEM_NOACCESS(&autoinc_locks, sizeof autoinc_locks);
+#endif
   MEM_NOACCESS(&read_only, sizeof read_only);
   MEM_NOACCESS(&auto_commit, sizeof auto_commit);
   MEM_NOACCESS(&will_lock, sizeof will_lock);
@@ -491,7 +493,9 @@ inline void trx_t::release_locks()
     lock_release(this);
     ut_ad(!lock.n_rec_locks);
     ut_ad(UT_LIST_GET_LEN(lock.trx_locks) == 0);
+#ifndef NO_AUTOINC_LOCKS
     ut_ad(ib_vector_is_empty(autoinc_locks));
+#endif
     mem_heap_empty(lock.lock_heap);
   }
 
@@ -918,7 +922,9 @@ trx_start_low(
 	trx->xid.null();
 #endif /* WITH_WSREP */
 
+#ifndef NO_AUTOINC_LOCKS
 	ut_a(ib_vector_is_empty(trx->autoinc_locks));
+#endif
 	ut_a(trx->lock.table_locks.empty());
 
 	/* No other thread can access this trx object through rw_trx_hash,
-- 
2.35.1

