List:Commits« Previous MessageNext Message »
From:Ignacio Galarza Date:August 16 2006 7:27pm
Subject:bk commit into 5.0 tree (iggy:1.2249)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of iggy. When iggy 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@stripped, 2006-08-16 15:27:15-04:00, iggy@stripped +7 -0
  Merge rolltop.ignatz42.dyndns.org:/mnt/storeage/mysql-4.1-maint_20328
  into  rolltop.ignatz42.dyndns.org:/mnt/storeage/mysql-5.0-maint_20328
  MERGE: 1.1616.2691.11

  BitKeeper/deleted/.del-mysql_client.result@stripped, 2006-08-16 15:27:12-04:00, iggy@stripped +0 -3
    manual merge
    MERGE: 1.2.1.2

  BitKeeper/deleted/.del-mysql_client.result@stripped, 2006-08-16 15:05:58-04:00, iggy@stripped +0 -0
    Merge rename: mysql-test/r/mysql_client.result -> BitKeeper/deleted/.del-mysql_client.result

  BitKeeper/deleted/.del-mysql_client.test@stripped, 2006-08-16 15:27:12-04:00, iggy@stripped +3 -6
    manual merge
    MERGE: 1.2.1.2

  BitKeeper/deleted/.del-mysql_client.test@stripped, 2006-08-16 15:05:58-04:00, iggy@stripped +0 -0
    Merge rename: mysql-test/t/mysql_client.test -> BitKeeper/deleted/.del-mysql_client.test

  mysql-test/r/func_time.result@stripped, 2006-08-16 15:27:12-04:00, iggy@stripped +207 -0
    manual merge
    MERGE: 1.23.1.18

  mysql-test/t/func_time.test@stripped, 2006-08-16 15:27:13-04:00, iggy@stripped +0 -0
    manual merge
    MERGE: 1.21.1.15

  sql/item_timefunc.cc@stripped, 2006-08-16 15:05:58-04:00, iggy@stripped +0 -0
    Auto merged
    MERGE: 1.51.1.55

  sql/slave.cc@stripped, 2006-08-16 15:05:58-04:00, iggy@stripped +0 -0
    Auto merged
    MERGE: 1.188.1.92

  sql/sql_acl.cc@stripped, 2006-08-16 15:27:13-04:00, iggy@stripped +27 -298
    manual merge
    MERGE: 1.74.1.103

# 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:	iggy
# Host:	rolltop.ignatz42.dyndns.org
# Root:	/mnt/storeage/mysql-5.0-maint_20328/RESYNC

--- 1.121/sql/item_timefunc.cc	2006-08-16 15:27:20 -04:00
+++ 1.122/sql/item_timefunc.cc	2006-08-16 15:27:20 -04:00
@@ -1704,14 +1704,12 @@
       case 'u': /* week (00..52), where week starts with Monday */
       case 'V': /* week 1..53 used with 'x' */
       case 'v': /* week 1..53 used with 'x', where week starts with Monday */
-      case 'H': /* hour (00..23) */
       case 'y': /* year, numeric, 2 digits */
       case 'm': /* month, numeric */
       case 'd': /* day (of the month), numeric */
       case 'h': /* hour (01..12) */
       case 'I': /* --||-- */
       case 'i': /* minutes, numeric */
-      case 'k': /* hour ( 0..23) */
       case 'l': /* hour ( 1..12) */
       case 'p': /* locale's AM or PM */
       case 'S': /* second (00..61) */
@@ -1719,6 +1717,10 @@
       case 'c': /* month (0..12) */
       case 'e': /* day (0..31) */
 	size += 2;
+	break;
+      case 'k': /* hour ( 0..23) */
+      case 'H': /* hour (00..23; value > 23 OK, padding always 2-digit) */
+	size += 7; /* docs allow > 23, range depends on sizeof(unsigned int) */
 	break;
       case 'r': /* time, 12-hour (hh:mm:ss [AP]M) */
 	size += 11;

--- 1.275/sql/slave.cc	2006-08-16 15:27:20 -04:00
+++ 1.276/sql/slave.cc	2006-08-16 15:27:20 -04:00
@@ -3226,7 +3226,7 @@
       rli->is_until_satisfied())
   {
     char buf[22];
-    sql_print_error("Slave SQL thread stopped because it reached its"
+    sql_print_information("Slave SQL thread stopped because it reached its"
                     " UNTIL position %s", llstr(rli->until_pos(), buf));
     /*
       Setting abort_slave flag because we do not want additional message about

--- 1.200/sql/sql_acl.cc	2006-08-16 15:27:20 -04:00
+++ 1.201/sql/sql_acl.cc	2006-08-16 15:27:20 -04:00
@@ -4678,6 +4678,33 @@
   DBUG_RETURN(0);
 }
 
+ACL_USER *check_acl_user(LEX_USER *user_name,
+			 uint *acl_acl_userdx)
+{
+  ACL_USER *acl_user= 0;
+  uint counter;
+
+  safe_mutex_assert_owner(&acl_cache->lock);
+
+  for (counter= 0 ; counter < acl_users.elements ; counter++)
+  {
+    const char *user,*host;
+    acl_user= dynamic_element(&acl_users, counter, ACL_USER*);
+    if (!(user=acl_user->user))
+      user= "";
+    if (!(host=acl_user->host.hostname))
+      host= "";
+    if (!strcmp(user_name->user.str,user) &&
+	!my_strcasecmp(system_charset_info, user_name->host.str, host))
+      break;
+  }
+  if (counter == acl_users.elements)
+    return 0;
+
+  *acl_acl_userdx= counter;
+  return acl_user;
+}
+
 
 /*
   Modify a privilege table.
@@ -5026,137 +5053,6 @@
         acl_db->user= strdup_root(&mem, user_to->user.str);
         acl_db->host.hostname= strdup_root(&mem, user_to->host.str);
         break;
-
-      case 2:
-      case 3:
-        grant_name->user= strdup_root(&mem, user_to->user.str);
-        update_hostname(&grant_name->host,
-                        strdup_root(&mem, user_to->host.str));
-	break;
-      }
-    }
-    else
-    {
-      /* If search is requested, we do not need to search further. */
-      break;
-    }
-  }
-#ifdef EXTRA_DEBUG
-  DBUG_PRINT("loop",("scan struct: %u  result %d", struct_no, result));
-#endif
-
-  DBUG_RETURN(result);
-}
-
-
-/*
-  Handle all privilege tables and in-memory privilege structures.
-
-  SYNOPSIS
-    handle_grant_data()
-    tables                      The array with the four open tables.
-    drop                        If user_from is to be dropped.
-    user_from                   The the user to be searched/dropped/renamed.
-    user_to                     The new name for the user if to be renamed,
-                                NULL otherwise.
-
-  DESCRIPTION
-    Go through all grant tables and in-memory grant structures and apply
-    the requested operation.
-    Delete from grant data if drop is true.
-    Update in grant data if drop is false and user_to is not NULL.
-    Search in grant data if drop is false and user_to is NULL.
-
-  RETURN
-    > 0         At least one element matched.
-    0           OK, but no element matched.
-    < 0         Error.
-*/
-
-static int handle_grant_data(TABLE_LIST *tables, bool drop,
-                             LEX_USER *user_from, LEX_USER *user_to)
-{
-  int result= 0;
-  int found;
-  DBUG_ENTER("handle_grant_data");
-
-  /* Handle user table. */
-  if ((found= handle_grant_table(tables, 0, drop, user_from, user_to)) < 0)
-  {
-    /* Handle of table failed, don't touch the in-memory array. */
-    result= -1;
-  }
-  else
-  {
-    /* Handle user array. */
-    if ((handle_grant_struct(0, drop, user_from, user_to) && ! result) ||
-        found)
-    {
-      result= 1; /* At least one record/element found. */
-      /* If search is requested, we do not need to search further. */
-      if (! drop && ! user_to)
-        goto end;
-    }
-  }
-
-  /* Handle db table. */
-  if ((found= handle_grant_table(tables, 1, drop, user_from, user_to)) < 0)
-  {
-    /* Handle of table failed, don't touch the in-memory array. */
-    result= -1;
-  }
-  else
-  {
-    /* Handle db array. */
-    if (((handle_grant_struct(1, drop, user_from, user_to) && ! result) ||
-         found) && ! result)
-    {
-      result= 1; /* At least one record/element found. */
-      /* If search is requested, we do not need to search further. */
-      if (! drop && ! user_to)
-        goto end;
-    }
-  }
-
-  /* Handle procedures table. */
-  if ((found= handle_grant_table(tables, 4, drop, user_from, user_to)) < 0)
-  {
-    /* Handle of table failed, don't touch in-memory array. */
-    result= -1;
-  }
-  else
-  {
-    /* Handle procs array. */
-    if (((handle_grant_struct(3, drop, user_from, user_to) && ! result) ||
-         found) && ! result)
-    {
-      result= 1; /* At least one record/element found. */
-      /* If search is requested, we do not need to search further. */
-      if (! drop && ! user_to)
-        goto end;
-    }
-  }
-
-  /* Handle tables table. */
-  if ((found= handle_grant_table(tables, 2, drop, user_from, user_to)) < 0)
-  {
-    /* Handle of table failed, don't touch columns and in-memory array. */
-    result= -1;
-  }
-  else
-  {
-    if (found && ! result)
-    {
-      result= 1; /* At least one record found. */
-      /* If search is requested, we do not need to search further. */
-      if (! drop && ! user_to)
-        goto end;
-    }
-
-    /* Handle columns table. */
-    if ((found= handle_grant_table(tables, 3, drop, user_from, user_to)) < 0)
-    {
-      /* Handle of table failed, don't touch the in-memory array. */
       result= -1;
     }
     else
@@ -5206,173 +5102,6 @@
   List_iterator <LEX_USER> user_list(list);
   TABLE_LIST tables[GRANT_TABLES];
   DBUG_ENTER("mysql_create_user");
-
-  /* CREATE USER may be skipped on replication client. */
-  if ((result= open_grant_tables(thd, tables)))
-    DBUG_RETURN(result != 1);
-
-  rw_wrlock(&LOCK_grant);
-  VOID(pthread_mutex_lock(&acl_cache->lock));
-
-  while ((tmp_user_name= user_list++))
-  {
-    if (!(user_name= get_current_user(thd, tmp_user_name)))
-    {
-      result= TRUE;
-      continue;
-    }
-
-    if (user_name->host.length > HOSTNAME_LENGTH ||
-	user_name->user.length > USERNAME_LENGTH)
-    {
-      append_user(&wrong_users, user_name);
-      result= TRUE;
-      continue;
-    }
-
-    /*
-      Search all in-memory structures and grant tables
-      for a mention of the new user name.
-    */
-    if (handle_grant_data(tables, 0, user_name, NULL))
-    {
-      append_user(&wrong_users, user_name);
-      result= TRUE;
-      continue;
-    }
-
-    sql_mode= thd->variables.sql_mode;
-    if (replace_user_table(thd, tables[0].table, *user_name, 0, 0, 1, 0))
-    {
-      append_user(&wrong_users, user_name);
-      result= TRUE;
-    }
-  }
-
-  VOID(pthread_mutex_unlock(&acl_cache->lock));
-  rw_unlock(&LOCK_grant);
-  close_thread_tables(thd);
-  if (result)
-    my_error(ER_CANNOT_USER, MYF(0), "CREATE USER", wrong_users.c_ptr_safe());
-  DBUG_RETURN(result);
-}
-
-
-/*
-  Drop a list of users and all their privileges.
-
-  SYNOPSIS
-    mysql_drop_user()
-    thd                         The current thread.
-    list                        The users to drop.
-
-  RETURN
-    FALSE       OK.
-    TRUE        Error.
-*/
-
-bool mysql_drop_user(THD *thd, List <LEX_USER> &list)
-{
-  int result;
-  String wrong_users;
-  LEX_USER *user_name, *tmp_user_name;
-  List_iterator <LEX_USER> user_list(list);
-  TABLE_LIST tables[GRANT_TABLES];
-  DBUG_ENTER("mysql_drop_user");
-
-  /* DROP USER may be skipped on replication client. */
-  if ((result= open_grant_tables(thd, tables)))
-    DBUG_RETURN(result != 1);
-
-  rw_wrlock(&LOCK_grant);
-  VOID(pthread_mutex_lock(&acl_cache->lock));
-
-  while ((tmp_user_name= user_list++))
-  {
-    user_name= get_current_user(thd, tmp_user_name);
-    if (!(user_name= get_current_user(thd, tmp_user_name)))
-    {
-      result= TRUE;
-      continue;
-    }  
-    if (handle_grant_data(tables, 1, user_name, NULL) <= 0)
-    {
-      append_user(&wrong_users, user_name);
-      result= TRUE;
-    }
-  }
-
-  /* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
-  rebuild_check_host();
-
-  VOID(pthread_mutex_unlock(&acl_cache->lock));
-  rw_unlock(&LOCK_grant);
-  close_thread_tables(thd);
-  if (result)
-    my_error(ER_CANNOT_USER, MYF(0), "DROP USER", wrong_users.c_ptr_safe());
-  DBUG_RETURN(result);
-}
-
-
-/*
-  Rename a user.
-
-  SYNOPSIS
-    mysql_rename_user()
-    thd                         The current thread.
-    list                        The user name pairs: (from, to).
-
-  RETURN
-    FALSE       OK.
-    TRUE        Error.
-*/
-
-bool mysql_rename_user(THD *thd, List <LEX_USER> &list)
-{
-  int result;
-  String wrong_users;
-  LEX_USER *user_from, *tmp_user_from;
-  LEX_USER *user_to, *tmp_user_to;
-  List_iterator <LEX_USER> user_list(list);
-  TABLE_LIST tables[GRANT_TABLES];
-  DBUG_ENTER("mysql_rename_user");
-
-  /* RENAME USER may be skipped on replication client. */
-  if ((result= open_grant_tables(thd, tables)))
-    DBUG_RETURN(result != 1);
-
-  rw_wrlock(&LOCK_grant);
-  VOID(pthread_mutex_lock(&acl_cache->lock));
-
-  while ((tmp_user_from= user_list++))
-  {
-    if (!(user_from= get_current_user(thd, tmp_user_from)))
-    {
-      result= TRUE;
-      continue;
-    }  
-    tmp_user_to= user_list++;
-    if (!(user_to= get_current_user(thd, tmp_user_to)))
-    {
-      result= TRUE;
-      continue;
-    }  
-    DBUG_ASSERT(user_to != 0); /* Syntax enforces pairs of users. */
-
-    /*
-      Search all in-memory structures and grant tables
-      for a mention of the new user name.
-    */
-    if (handle_grant_data(tables, 0, user_to, NULL) ||
-        handle_grant_data(tables, 0, user_from, user_to) <= 0)
-    {
-      append_user(&wrong_users, user_from);
-      result= TRUE;
-    }
-  }
-
-  /* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */
-  rebuild_check_host();
 
   VOID(pthread_mutex_unlock(&acl_cache->lock));
   rw_unlock(&LOCK_grant);

--- 1.63/mysql-test/r/func_time.result	2006-08-16 15:27:20 -04:00
+++ 1.64/mysql-test/r/func_time.result	2006-08-16 15:27:20 -04:00
@@ -1,5 +1,6 @@
 drop table if exists t1,t2,t3;
 set time_zone="+03:00";
+set time_zone="+03:00";
 select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
 from_days(to_days("960101"))	to_days(960201)-to_days("19960101")	to_days(date_add(curdate(), interval 1 day))-to_days(curdate())	weekday("1997-11-29")
 1996-01-01	31	1	5
@@ -250,11 +251,15 @@
 NULL
 Warnings:
 Warning	1441	Datetime function: datetime field overflow
+Warnings:
+Warning	1441	Datetime function: datetime field overflow
 select date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR);
 date_add("1997-12-31 23:59:59",INTERVAL -100000 YEAR)
 NULL
 Warnings:
 Warning	1441	Datetime function: datetime field overflow
+Warnings:
+Warning	1441	Datetime function: datetime field overflow
 select date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND);
 date_add("1997-12-31 23:59:59",INTERVAL "10000:1" MINUTE_SECOND)
 1998-01-07 22:40:00
@@ -308,11 +313,15 @@
 NULL
 Warnings:
 Warning	1441	Datetime function: datetime field overflow
+Warnings:
+Warning	1441	Datetime function: datetime field overflow
 select date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND);
 date_sub("0000-00-00 00:00:00",INTERVAL 1 SECOND)
 NULL
 Warnings:
 Warning	1292	Truncated incorrect datetime value: '0000-00-00 00:00:00'
+Warnings:
+Warning	1292	Truncated incorrect datetime value: '0000-00-00 00:00:00'
 select date_add('1998-01-30',Interval 1 month);
 date_add('1998-01-30',Interval 1 month)
 1998-02-28
@@ -403,6 +412,54 @@
 SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
 DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
 9999-12-31 00:00:00
+SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
+DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
+9999-12-31 00:00:00
+SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
+DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
+9999-12-31 00:00:00
+SELECT EXTRACT(QUARTER FROM '2004-01-15') AS quarter;
+quarter
+1
+SELECT EXTRACT(QUARTER FROM '2004-02-15') AS quarter;
+quarter
+1
+SELECT EXTRACT(QUARTER FROM '2004-03-15') AS quarter;
+quarter
+1
+SELECT EXTRACT(QUARTER FROM '2004-04-15') AS quarter;
+quarter
+2
+SELECT EXTRACT(QUARTER FROM '2004-05-15') AS quarter;
+quarter
+2
+SELECT EXTRACT(QUARTER FROM '2004-06-15') AS quarter;
+quarter
+2
+SELECT EXTRACT(QUARTER FROM '2004-07-15') AS quarter;
+quarter
+3
+SELECT EXTRACT(QUARTER FROM '2004-08-15') AS quarter;
+quarter
+3
+SELECT EXTRACT(QUARTER FROM '2004-09-15') AS quarter;
+quarter
+3
+SELECT EXTRACT(QUARTER FROM '2004-10-15') AS quarter;
+quarter
+4
+SELECT EXTRACT(QUARTER FROM '2004-11-15') AS quarter;
+quarter
+4
+SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter;
+quarter
+4
+SELECT DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
+DATE_SUB(str_to_date('9999-12-31 00:01:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
+9999-12-31 00:00:00
+SELECT DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE);
+DATE_ADD(str_to_date('9999-12-30 23:59:00','%Y-%m-%d %H:%i:%s'), INTERVAL 1 MINUTE)
+9999-12-31 00:00:00
 SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
 "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND
 1968-01-20 03:14:08
@@ -426,21 +483,29 @@
 NULL
 Warnings:
 Warning	1441	Datetime function: datetime field overflow
+Warnings:
+Warning	1441	Datetime function: datetime field overflow
 SELECT "1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE;
 "1900-01-01 00:00:00" + INTERVAL 1<<33 MINUTE
 NULL
 Warnings:
 Warning	1441	Datetime function: datetime field overflow
+Warnings:
+Warning	1441	Datetime function: datetime field overflow
 SELECT "1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR;
 "1900-01-01 00:00:00" + INTERVAL 1<<30 HOUR
 NULL
 Warnings:
 Warning	1441	Datetime function: datetime field overflow
+Warnings:
+Warning	1441	Datetime function: datetime field overflow
 SELECT "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND;
 "1900-01-01 00:00:00" + INTERVAL "1000000000:214748364700" MINUTE_SECOND
 NULL
 Warnings:
 Warning	1441	Datetime function: datetime field overflow
+Warnings:
+Warning	1441	Datetime function: datetime field overflow
 create table t1 (ctime varchar(20));
 insert into t1 values ('2001-01-12 12:23:40');
 select ctime, hour(ctime) from t1;
@@ -486,6 +551,9 @@
 Warnings:
 Warning	1292	Truncated incorrect datetime value: '0000-00-00'
 Warning	1292	Truncated incorrect datetime value: '0000-00-00'
+Warnings:
+Warning	1292	Truncated incorrect datetime value: '0000-00-00'
+Warning	1292	Truncated incorrect datetime value: '0000-00-00'
 select dayofmonth("0000-00-00"),dayofmonth(d),dayofmonth(dt),dayofmonth(t),dayofmonth(c) from t1;
 dayofmonth("0000-00-00")	dayofmonth(d)	dayofmonth(dt)	dayofmonth(t)	dayofmonth(c)
 0	0	0	0	0
@@ -501,6 +569,9 @@
 Warnings:
 Warning	1292	Truncated incorrect datetime value: '0000-00-00'
 Warning	1292	Truncated incorrect datetime value: '0000-00-00'
+Warnings:
+Warning	1292	Truncated incorrect datetime value: '0000-00-00'
+Warning	1292	Truncated incorrect datetime value: '0000-00-00'
 select year("0000-00-00"),year(d),year(dt),year(t),year(c) from t1;
 year("0000-00-00")	year(d)	year(dt)	year(t)	year(c)
 0	0	0	0	0
@@ -510,12 +581,18 @@
 Warnings:
 Warning	1292	Truncated incorrect datetime value: '0000-00-00'
 Warning	1292	Truncated incorrect datetime value: '0000-00-00'
+Warnings:
+Warning	1292	Truncated incorrect datetime value: '0000-00-00'
+Warning	1292	Truncated incorrect datetime value: '0000-00-00'
 select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(t),to_days(c) from t1;
 to_days("0000-00-00")	to_days(d)	to_days(dt)	to_days(t)	to_days(c)
 NULL	NULL	NULL	NULL	NULL
 Warnings:
 Warning	1292	Truncated incorrect datetime value: '0000-00-00'
 Warning	1292	Truncated incorrect datetime value: '0000-00-00'
+Warnings:
+Warning	1292	Truncated incorrect datetime value: '0000-00-00'
+Warning	1292	Truncated incorrect datetime value: '0000-00-00'
 select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM dt),extract(MONTH FROM t),extract(MONTH FROM c) from t1;
 extract(MONTH FROM "0000-00-00")	extract(MONTH FROM d)	extract(MONTH FROM dt)	extract(MONTH FROM t)	extract(MONTH FROM c)
 0	0	0	0	0
@@ -523,6 +600,7 @@
 CREATE TABLE t1 ( start datetime default NULL);
 INSERT INTO t1 VALUES ('2002-10-21 00:00:00'),('2002-10-28 00:00:00'),('2002-11-04 00:00:00');
 CREATE TABLE t2 ( ctime1 timestamp NOT NULL, ctime2 timestamp NOT NULL);
+CREATE TABLE t2 ( ctime1 timestamp NOT NULL, ctime2 timestamp NOT NULL);
 INSERT INTO t2 VALUES (20021029165106,20021105164731);
 CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL);
 INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31");
@@ -739,6 +817,135 @@
 SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29');
 TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29')
 2
+select date_add(date,INTERVAL "1" WEEK) from t1;
+date_add(date,INTERVAL "1" WEEK)
+2003-01-09 00:00:00
+select date_add(date,INTERVAL "1" QUARTER) from t1;
+date_add(date,INTERVAL "1" QUARTER)
+2003-04-02
+select timestampadd(MINUTE, 1, date) from t1;
+timestampadd(MINUTE, 1, date)
+2003-01-02 00:01:00
+select timestampadd(WEEK, 1, date) from t1;
+timestampadd(WEEK, 1, date)
+2003-01-09 00:00:00
+select timestampadd(SQL_TSI_SECOND, 1, date) from t1;
+timestampadd(SQL_TSI_SECOND, 1, date)
+2003-01-02 00:00:01
+select timestampadd(SQL_TSI_FRAC_SECOND, 1, date) from t1;
+timestampadd(SQL_TSI_FRAC_SECOND, 1, date)
+2003-01-02 00:00:00.000001
+select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a;
+a
+3
+select timestampdiff(YEAR, '2002-05-01', '2001-01-01') as a;
+a
+-1
+select timestampdiff(QUARTER, '2002-05-01', '2001-01-01') as a;
+a
+-5
+select timestampdiff(MONTH, '2000-03-28', '2000-02-29') as a;
+a
+0
+select timestampdiff(MONTH, '1991-03-28', '2000-02-29') as a;
+a
+107
+select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a;
+a
+12
+select timestampdiff(SQL_TSI_HOUR, '2001-02-01', '2001-05-01') as a;
+a
+2136
+select timestampdiff(SQL_TSI_DAY, '2001-02-01', '2001-05-01') as a;
+a
+89
+select timestampdiff(SQL_TSI_MINUTE, '2001-02-01 12:59:59', '2001-05-01 12:58:59') as a;
+a
+128159
+select timestampdiff(SQL_TSI_SECOND, '2001-02-01 12:59:59', '2001-05-01 12:58:58') as a;
+a
+7689539
+select timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a;
+a
+7689538999999
+select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1,
+timestampdiff(SQL_TSI_DAY, '1900-02-01', '1900-03-01') as a2,
+timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3,
+timestampdiff(SQL_TSI_DAY, '2000-02-01', '2000-03-01') as a4;
+a1	a2	a3	a4
+28	28	29	29
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27')
+0
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28')
+1
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29')
+1
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27')
+1
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28')
+2
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29')
+2
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27')
+0
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28')
+1
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29')
+1
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27')
+1
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28')
+2
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29')
+2
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27')
+0
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28')
+1
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29')
+1
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27')
+1
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28')
+2
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29')
+2
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27')
+0
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28')
+1
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29')
+1
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27')
+1
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28')
+2
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29')
+2
 select date_add(time,INTERVAL 1 SECOND) from t1;
 date_add(time,INTERVAL 1 SECOND)
 NULL
@@ -891,6 +1098,27 @@
   `from_unixtime(1) + 0` double(23,6) default NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
+H
+120
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
+H
+120
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
+H
+05
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
+H
+5
+End of 4.1 tests
 explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
 timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
 id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra

--- 1.51/mysql-test/t/func_time.test	2006-08-16 15:27:20 -04:00
+++ 1.52/mysql-test/t/func_time.test	2006-08-16 15:27:20 -04:00
@@ -446,7 +446,25 @@
 show create table t1;
 drop table t1;
 
-# End of 4.1 tests
+#
+# Bug #19844 time_format in Union truncates values
+#
+
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
+
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
+
+--echo End of 4.1 tests
 
 explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
 			timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;

--- 1.2.1.1/mysql-test/r/mysql_client.result	2006-08-16 15:27:20 -04:00
+++ 1.6/BitKeeper/deleted/.del-mysql_client.result	2006-08-16 15:27:20 -04:00
@@ -2,3 +2,7 @@
 1
 ERROR 1064 (42000) at line 3: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
 ERROR at line 1: USE must be followed by a database name
+\
+\\
+';
+';

--- 1.2.1.1/mysql-test/t/mysql_client.test	2006-08-16 15:27:20 -04:00
+++ 1.5/BitKeeper/deleted/.del-mysql_client.test	2006-08-16 15:27:20 -04:00
@@ -33,3 +33,14 @@
 #
 --exec echo 'help' | $MYSQL   >  $MYSQLTEST_VARDIR/tmp/bug20328.tmp
 --exec echo 'help ' | $MYSQL  >  $MYSQLTEST_VARDIR/tmp/bug20328.tmp
+
+#
+# Bug #20103: Escaping with backslash does not work
+#
+--exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';"  > $MYSQLTEST_VARDIR/tmp/bug20103.sql
+--exec echo "SELECT '\';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
+
+--exec echo "SET SQL_MODE = '';"  > $MYSQLTEST_VARDIR/tmp/bug20103.sql
+--exec echo "SELECT '\';';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
+--exec $MYSQL              < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
Thread
bk commit into 5.0 tree (iggy:1.2249)Ignacio Galarza16 Aug