MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:ingo Date:April 22 2005 10:30am
Subject:bk commit into 4.1 tree (ingo:1.2203) BUG#7806
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of mydev. When mydev does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2203 05/04/22 12:30:09 ingo@stripped +2 -0
  Bug#7806 - insert on duplicate key and auto-update of timestamp
  A fix of the original patch.
  Correctly clear a bit from an enum value.

  sql/table.h
    1.72 05/04/22 12:27:09 ingo@stripped +10 -6
    Bug#7806 - insert on duplicate key and auto-update of timestamp
    A fix of the original patch.
    Correctly clear a bit from an enum value.

  sql/sql_insert.cc
    1.158 05/04/22 12:27:09 ingo@stripped +6 -3
    Bug#7806 - insert on duplicate key and auto-update of timestamp
    A fix of the original patch.
    Correctly clear a bit from an enum value.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ingo
# Host:	chilla.local
# Root:	/home/mydev/mysql-4.1-4100

--- 1.157/sql/sql_insert.cc	Thu Apr 21 21:47:56 2005
+++ 1.158/sql/sql_insert.cc	Fri Apr 22 12:27:09 2005
@@ -80,7 +80,8 @@
 	check_grant_all_columns(thd,INSERT_ACL,table))
       return -1;
 #endif
-    *(int*)&table->timestamp_field_type&= ~ (int) TIMESTAMP_AUTO_SET_ON_INSERT;
+    clear_timestamp_auto_bits(table->timestamp_field_type,
+                              TIMESTAMP_AUTO_SET_ON_INSERT);
   }
   else
   {						// Part field list
@@ -110,7 +111,8 @@
     }
     if (table->timestamp_field &&	// Don't set timestamp if used
 	table->timestamp_field->query_id == thd->query_id)
-      *(int*)&table->timestamp_field_type&= ~ (int) TIMESTAMP_AUTO_SET_ON_INSERT;
+      clear_timestamp_auto_bits(table->timestamp_field_type,
+                                TIMESTAMP_AUTO_SET_ON_INSERT);
   }
   // For the values we need select_priv
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
@@ -167,7 +169,8 @@
   {
     /* Don't set timestamp column if this is modified. */
     if (table->timestamp_field->query_id == thd->query_id)
-    *(int*)&table->timestamp_field_type&= ~ (int) TIMESTAMP_AUTO_SET_ON_UPDATE;
+      clear_timestamp_auto_bits(table->timestamp_field_type,
+                                TIMESTAMP_AUTO_SET_ON_UPDATE);
     else
       table->timestamp_field->query_id= timestamp_query_id;
   }

--- 1.71/sql/table.h	Tue Apr 19 15:12:29 2005
+++ 1.72/sql/table.h	Fri Apr 22 12:27:09 2005
@@ -58,18 +58,22 @@
 
 
 /*
-  Values in this enum are used to indicate during which operations value
-  of TIMESTAMP field should be set to current timestamp.
-  WARNING: The values are used for bit operations. If you change the enum,
-  you must keep the bitwise relation of the values. For example:
-  (int) TIMESTAMP_AUTO_SET_ON_BOTH ==
-    (int) TIMESTAMP_AUTO_SET_ON_INSERT | (int) TIMESTAMP_AUTO_SET_ON_UPDATE.
+  Values in this enum are used to indicate how a tables TIMESTAMP field
+  should be treated. It can be set to the current timestamp on insert or
+  update or both.
+  WARNING: The values are used for bit operations. If you change the
+  enum, you must keep the bitwise relation of the values. For example:
+  (int) TIMESTAMP_AUTO_SET_ON_BOTH must be equal to
+  (int) TIMESTAMP_AUTO_SET_ON_INSERT | (int) TIMESTAMP_AUTO_SET_ON_UPDATE.
+  We use an enum here so that the debugger can display the value names.
 */
 enum timestamp_auto_set_type
 {
   TIMESTAMP_NO_AUTO_SET= 0, TIMESTAMP_AUTO_SET_ON_INSERT= 1,
   TIMESTAMP_AUTO_SET_ON_UPDATE= 2, TIMESTAMP_AUTO_SET_ON_BOTH= 3
 };
+#define clear_timestamp_auto_bits(_target_, _bits_) \
+  (_target_)= (enum timestamp_auto_set_type)((int)(_target_) & ~(int)(_bits_))
 
 /* Table cache entry struct */
 
Thread
bk commit into 4.1 tree (ingo:1.2203) BUG#7806ingo22 Apr