From d41092796332f1a9de32c56eeff16dc8e49b69b1 Mon Sep 17 00:00:00 2001
From: unknown <pem@mysql.comhem.se>
Date: Fri, 27 Aug 2004 16:41:34 +0200
Subject: [PATCH] Fixed BUG#5251: mysql changes creation time of a
 procedure/function when altering.

mysql-test/r/sp.result:
  New test case for BUG#5251.
mysql-test/t/sp.test:
  New test case for BUG#5251.
sql/sp.cc:
  Don't update the created timestamp when doing alter procedure/function.
---
 mysql-test/r/sp.result | 11 +++++++++++
 mysql-test/t/sp.test   | 16 ++++++++++++++++
 sql/sp.cc              |  1 +
 3 files changed, 28 insertions(+)

diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index e5f80b7a25..3e1114b2fd 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -1744,6 +1744,17 @@ select @n|
 2
 delete from t1|
 drop procedure bug3157|
+create procedure bug5251()
+begin
+end|
+select created into @c1 from mysql.proc
+where db='test' and name='bug5251'|
+alter procedure bug5251 comment 'foobar'|
+select count(*) from mysql.proc
+where  db='test' and name='bug5251' and created = @c1|
+count(*)
+1
+drop procedure bug5251|
 drop table if exists fac|
 create table fac (n int unsigned not null primary key, f bigint unsigned)|
 create procedure ifac(n int unsigned)
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 560130963f..577fa13b26 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -1898,6 +1898,22 @@ select @n|
 delete from t1|
 drop procedure bug3157|
 
+#
+# BUG#5251: mysql changes creation time of a procedure/function when altering
+#
+create procedure bug5251()
+begin
+end|
+
+select created into @c1 from mysql.proc
+  where db='test' and name='bug5251'|
+--sleep 2
+alter procedure bug5251 comment 'foobar'|
+select count(*) from mysql.proc
+  where  db='test' and name='bug5251' and created = @c1|
+
+drop procedure bug5251|
+
 
 #
 # Some "real" examples
diff --git a/sql/sp.cc b/sql/sp.cc
index b881eeb78d..dda6e0fad6 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -425,6 +425,7 @@ db_update_routine(THD *thd, int type, sp_name *name,
   if (ret == SP_OK)
   {
     store_record(table,record[1]);
+    table->timestamp_on_update_now = 0;	// Don't update create time now.
     ((Field_timestamp *)table->field[MYSQL_PROC_FIELD_MODIFIED])->set_time();
     if (chistics->suid != IS_DEFAULT_SUID)
       table->field[MYSQL_PROC_FIELD_SECURITY_TYPE]->store((longlong)chistics->suid);
-- 
2.30.9