diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 1016cf27c18b436bcb2ad58d56d51c71d3330c5f..4ddc7e2ab87cda6546e08d37bd84e351e6d17915 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -429,6 +429,16 @@ set session insert_id=20;
 select @@session.insert_id;
 @@session.insert_id
 20
+set session last_insert_id=100;
+select @@session.insert_id;
+@@session.insert_id
+20
+select @@session.last_insert_id;
+@@session.last_insert_id
+100
+select @@session.insert_id;
+@@session.insert_id
+20
 set @@session.insert_id=@save_insert_id;
 select @@session.insert_id;
 @@session.insert_id
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index d0def5af8d01c20bb2c0f3fcaba2665db5d71ce8..68efcafd1e09f5ee3521cfa464bd97967173b521 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -308,6 +308,12 @@ select @@session.insert_id;
 set @save_insert_id=@@session.insert_id;
 set session insert_id=20;
 select @@session.insert_id;
+
+set session last_insert_id=100;
+select @@session.insert_id;
+select @@session.last_insert_id;
+select @@session.insert_id;
+
 set @@session.insert_id=@save_insert_id;
 select @@session.insert_id;