Mysql select for update according to the secondary index, how to lock when the record can not be queried?

Table structure

CREATE TABLE `table1` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT "id",
  `account_name` varchar(65) NOT NULL COMMENT ,
  PRIMARY KEY (`id`),
  KEY `idx_an` (`account_name`,`already_login`),
) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8;
select * from table1 where name="1"  for update;

how is it locked when there is no such data in the table?

Mar.13,2021
Menu