Commit 0ce12f70 authored by unknown's avatar unknown
Browse files

Reviewing new pushed code

- CHAR() now returns binary string as default
- CHAR(X*65536+Y*256+Z) is now equal to CHAR(X,Y,Z) independent of the character set for CHAR()
- Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
  (Some old systems returns ETIME and it's safer to test for both values
   than to try to write a wrapper for each old system)
- Fixed new introduced bug in NOT BETWEEN X and X
- Ensure we call commit_by_xid or rollback_by_xid for all engines, even if one engine has failed
- Use octet2hex() for all conversion of string to hex
- Simplify and optimize code


client/mysqldump.c:
  Simple optimizations of new code
  Indentation fixes
client/mysqltest.c:
  Removed not needed variable
include/mysql_com.h:
  Made octec2hex() more usable
mysql-test/r/ctype_utf8.result:
  CHAR() now returns binary string as default
mysql-test/r/func_str.result:
  CHAR() now returns binary string as default
mysql-test/r/range.result:
  Added test to verify new introduced bug in NOT BETWEEN X and X
mysql-test/r/user_var-binlog.result:
  CHAR() now returns binary string as default
mysql-test/r/view.result:
  More tests of view rename
mysql-test/t/ctype_utf8.test:
  CHAR() now returns binary string as default
mysql-test/t/func_str.test:
  CHAR() now returns binary string as default
mysql-test/t/range.test:
  Added test to verify new introduced bug in NOT BETWEEN X and X
mysql-test/t/view.test:
  More tests of view rename
mysys/mf_keycache.c:
  Indentation changes
  Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
mysys/my_os2cond.c:
  Fix to MySQL coding style
  Optimized functions
mysys/thr_lock.c:
  Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
mysys/thr_mutex.c:
  Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
server-tools/instance-manager/instance.cc:
  Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
server-tools/instance-manager/thread_registry.cc:
  Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/ha_federated.cc:
  Use octet2hex()
sql/ha_ndbcluster.cc:
  Removed not used variable
sql/handler.cc:
  Simplify code
  Use *NONE* instead of 'none' for not existing storage engine
  Ensure we call commit_by_xid or rollback_by_xid for all engines, even if one engine has failed
sql/item.h:
  Remove not needed test for *ref.  (If ref is set, it should never point at 0)
sql/item_func.cc:
  Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
  Simplify code
  More comments
  Require that last argument to find_and_check_access() is given
  (Made code shorter and faster)
sql/item_strfunc.cc:
  Changed CHAR() to return result in binary collation
  CHAR(X*65536+Y*256+Z) is now equal to CHAR(X,Y,Z) independent of the character set for CHAR()
  
  Bar will shortly add the following syntax:
  CHAR(.... USING character_set)
  and ensure that
  CONVERT(CHAR(....) USING utf8) cuts not legal utf8 strings
  Use ocet2hex()
sql/item_strfunc.h:
  CHAR() now returns a binary string
sql/log_event.cc:
  Use octet2hex()
  Simplify code
sql/parse_file.cc:
  Indentation fixes
  Use for() instead of while()
sql/password.c:
  Make octet2hex() more generally usable by returning pointer to end 0
sql/slave.cc:
  Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/sql_base.cc:
  Indentation fixes
sql/sql_insert.cc:
  Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/sql_manager.cc:
  Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/sql_parse.cc:
  Don't check thd->db when checking for function privileges
sql/sql_prepare.cc:
  Fixed wrong merge
sql/sql_select.cc:
  Fixed new bug for NOT BETWEEN X and X
sql/sql_show.cc:
  Removed not used variable
sql/sql_table.cc:
  Indentation fixed
  Removed DBUG_PRINT that is obvious from context
sql/sql_view.cc:
  Simplify code
sql/unireg.cc:
  Use octet2hex()
parent c2621f3d
Loading
Loading
Loading
Loading
+38 −33
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
** master/autocommit code by Brian Aker <brian@tangent.org>
** SSL by
** Andrei Errapart <andreie@no.spam.ee>
** Tõnu Samuel  <tonu@please.do.not.remove.this.spam.ee>
** Tõnu Samuel  <tonu@please.do.not.remove.this.spam.ee>
** XML by Gary Huntress <ghuntress@mediaone.net> 10/10/01, cleaned up
** and adapted to mysqldump 05/11/01 by Jani Tolonen
** Added --single-transaction option 06/06/2002 by Peter Zaitsev
@@ -1287,7 +1287,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
{
  MYSQL_RES  *tableRes;
  MYSQL_ROW  row;
  my_bool    init=0;
  my_bool    init=0, delayed, write_data, complete_insert;
  uint       num_fields;
  char	     *result_table, *opt_quoted_table;
  const char *insert_option;
@@ -1296,31 +1296,33 @@ static uint get_table_structure(char *table, char *db, char *table_type,
  char       query_buff[512];
  FILE       *sql_file = md_result_file;
  int        len;

  DBUG_ENTER("get_table_structure");
  DBUG_PRINT("enter", ("db: %s, table: %s", db, table));
  DBUG_PRINT("enter", ("db: %s  table: %s", db, table));

  *ignore_flag= check_if_ignore_table(table, table_type);

  if (opt_delayed && (*ignore_flag & IGNORE_INSERT_DELAYED))
  delayed= opt_delayed;
  if (delayed && (*ignore_flag & IGNORE_INSERT_DELAYED))
  {
    delayed= 0;
    if (verbose)
      fprintf(stderr,
	      "-- Unable to use delayed inserts for table '%s' because it's of\
 type %s\n", table, table_type);
              "-- Warning: Unable to use delayed inserts for table '%s' "
              "because it's of type %s\n", table, table_type);
  }

  if (!(*ignore_flag & IGNORE_DATA))
  complete_insert= 0;
  if ((write_data= !(*ignore_flag & IGNORE_DATA)))
  {
    complete_insert= opt_complete_insert;
    if (!insert_pat_inited)
      insert_pat_inited= init_dynamic_string(&insert_pat, "", 1024, 1024);
    else
      dynstr_set(&insert_pat, "");
  }

  insert_option= ((opt_delayed && opt_ignore &&
                   !(*ignore_flag & IGNORE_INSERT_DELAYED)) ?
                  " DELAYED IGNORE " :
                  opt_delayed && !(*ignore_flag & IGNORE_INSERT_DELAYED) ? " DELAYED " :
                  opt_ignore ? " IGNORE " : "");
  insert_option= ((delayed && opt_ignore) ? " DELAYED IGNORE " :
                  delayed ? " DELAYED " : opt_ignore ? " IGNORE " : "");

  if (verbose)
    fprintf(stderr, "-- Retrieving table structure for table %s...\n", table);
@@ -1452,17 +1454,18 @@ static uint get_table_structure(char *table, char *db, char *table_type,
    }

    /*
      if *ignore_flag & IGNORE_DATA is true, then we don't build up insert statements 
      for the table's data. Note: in subsequent lines of code, this test will 
      have to be performed each time we are appending to insert_pat.
      If write_data is true, then we build up insert statements for
      the table's data. Note: in subsequent lines of code, this test
      will have to be performed each time we are appending to
      insert_pat.
    */
    if (!(*ignore_flag & IGNORE_DATA))
    if (write_data)
    {
      dynstr_append_mem(&insert_pat, "INSERT ", 7);
      dynstr_append(&insert_pat, insert_option);
      dynstr_append_mem(&insert_pat, "INTO ", 5);
      dynstr_append(&insert_pat, opt_quoted_table);
      if (opt_complete_insert)
      if (complete_insert)
      {
        dynstr_append_mem(&insert_pat, " (", 2);
      }
@@ -1475,17 +1478,18 @@ static uint get_table_structure(char *table, char *db, char *table_type,
    }

    while ((row=mysql_fetch_row(tableRes)))
    {
      if (complete_insert)
      {
        if (init)
        {
        if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
          dynstr_append_mem(&insert_pat, ", ", 2);
        }
        init=1;
      if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
        dynstr_append(&insert_pat,
                      quote_name(row[SHOW_FIELDNAME], name_buff, 0));
      }
    }
    num_fields= (uint) mysql_num_rows(tableRes);
    mysql_free_result(tableRes);
  }
@@ -1532,7 +1536,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
      check_io(sql_file);
    }

    if (!(*ignore_flag & IGNORE_DATA))
    if (write_data)
    {
      dynstr_append_mem(&insert_pat, "INSERT ", 7);
      dynstr_append(&insert_pat, insert_option);
@@ -1558,11 +1562,11 @@ static uint get_table_structure(char *table, char *db, char *table_type,
	  fputs(",\n",sql_file);
	  check_io(sql_file);
	}
        if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
        if (complete_insert)
          dynstr_append_mem(&insert_pat, ", ", 2);
      }
      init=1;
      if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
      if (opt_complete_insert)
        dynstr_append(&insert_pat,
                      quote_name(row[SHOW_FIELDNAME], name_buff, 0));
      if (!tFlag)
@@ -1723,7 +1727,7 @@ static uint get_table_structure(char *table, char *db, char *table_type,
      check_io(sql_file);
    }
  }
  if (opt_complete_insert && !(*ignore_flag & IGNORE_DATA))
  if (opt_complete_insert)
  {
    dynstr_append_mem(&insert_pat, ") VALUES ", 9);
    if (!extended_insert)
@@ -1892,7 +1896,7 @@ static void dump_table(char *table, char *db)
    Make sure you get the create table info before the following check for
    --no-data flag below. Otherwise, the create table info won't be printed.
  */
  num_fields= get_table_structure(table, db, (char *)&table_type, &ignore_flag);
  num_fields= get_table_structure(table, db, table_type, &ignore_flag);

  /* Check --no-data flag */
  if (dFlag)
@@ -1904,7 +1908,9 @@ static void dump_table(char *table, char *db)
    DBUG_VOID_RETURN;
  }

  DBUG_PRINT("info", ("ignore_flag %x num_fields %d", ignore_flag, num_fields));
  DBUG_PRINT("info",
             ("ignore_flag: %x  num_fields: %d", (int) ignore_flag,
              num_fields));
  /*
    If the table type is a merge table or any type that has to be
     _completely_ ignored and no data dumped
@@ -1913,7 +1919,7 @@ static void dump_table(char *table, char *db)
  {
    if (verbose)
      fprintf(stderr,
	      "-- Skipping data for table '%s' because it's of type %s\n",
	      "-- Warning: Skipping data for table '%s' because it's of type %s\n",
	      table, table_type);
    DBUG_VOID_RETURN;
  }
@@ -1930,7 +1936,6 @@ static void dump_table(char *table, char *db)
  result_table= quote_name(table,table_buff, 1);
  opt_quoted_table= quote_name(table, table_buff2, 0);


  if (verbose)
    fprintf(stderr, "-- Sending SELECT query...\n");
  if (path)
+2 −6
Original line number Diff line number Diff line
@@ -737,9 +737,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname)
static int check_result(DYNAMIC_STRING* ds, const char *fname,
			my_bool require_option)
{
  int error= RESULT_OK;
  int res= dyn_string_cmp(ds, fname);

  DBUG_ENTER("check_result");

  if (res && require_option)
@@ -749,18 +747,16 @@ static int check_result(DYNAMIC_STRING* ds, const char *fname,
    break; /* ok */
  case RESULT_LENGTH_MISMATCH:
    verbose_msg("Result length mismatch");
    error= RESULT_LENGTH_MISMATCH;
    break;
  case RESULT_CONTENT_MISMATCH:
    verbose_msg("Result content mismatch");
    error= RESULT_CONTENT_MISMATCH;
    break;
  default: /* impossible */
    die("Unknown error code from dyn_string_cmp()");
  }
  if (error)
  if (res != RESULT_OK)
    reject_dump(fname, ds->str, ds->length);
  DBUG_RETURN(error);
  DBUG_RETURN(res);
}


+1 −1
Original line number Diff line number Diff line
@@ -409,7 +409,7 @@ my_bool check_scramble(const char *reply, const char *message,
                       const unsigned char *hash_stage2);
void get_salt_from_password(unsigned char *res, const char *password);
void make_password_from_salt(char *to, const unsigned char *hash_stage2);
void octet2hex(char *to, const unsigned char *str, unsigned int len);
char *octet2hex(char *to, const char *str, unsigned int len);

/* end of password.c */

+18 −16
Original line number Diff line number Diff line
@@ -1079,29 +1079,31 @@ char(53647)
select char(0xff,0x8f);
char(0xff,0x8f)

Warnings:
Warning	1300	Invalid utf8 character string: 'FF8F'
set sql_mode=traditional;
select char(0xff,0x8f);
char(0xff,0x8f)
NULL
Warnings:
Error	1300	Invalid utf8 character string: 'FF8F'

select convert(char(0xff,0x8f) using utf8);
convert(char(0xff,0x8f) using utf8)

select char(195);
char(195)
NULL
Warnings:
Error	1300	Invalid utf8 character string: 'C3'

select convert(char(195) using utf8);
convert(char(195) using utf8)

select char(196);
char(196)
NULL
Warnings:
Error	1300	Invalid utf8 character string: 'C4'
select char(2557);
char(2557)
NULL
Warnings:
Error	1300	Invalid utf8 character string: 'FD'

select convert(char(196) using utf8);
convert(char(196) using utf8)

select hex(char(2557));
hex(char(2557))
09FD
select hex(convert(char(2557) using utf8));
hex(convert(char(2557) using utf8))
09FD
set names utf8;
create table t1 (a char(1)) default character set utf8;
create table t2 (a char(1)) default character set utf8;
+5 −2
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ length(_latin1'\n\t\n\b\0\\_\\%\\')
select concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h');
concat('monty',' was here ','again')	length('hello')	char(ascii('h'))	ord('h')
monty was here again	5	h	104
select hex(char(256));
hex(char(256))
0100
select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ;
locate('he','hello')	locate('he','hello',2)	locate('lo','hello',2)
1	0	4
@@ -598,7 +601,7 @@ collation(hex(130)) coercibility(hex(130))
latin1_swedish_ci	4
select collation(char(130)), coercibility(hex(130));
collation(char(130))	coercibility(hex(130))
latin1_swedish_ci	4
binary	4
select collation(format(130,10)), coercibility(format(130,10));
collation(format(130,10))	coercibility(format(130,10))
latin1_swedish_ci	4
@@ -720,7 +723,7 @@ t1 CREATE TABLE `t1` (
  `oct(130)` varchar(64) NOT NULL default '',
  `conv(130,16,10)` varchar(64) NOT NULL default '',
  `hex(130)` varchar(6) NOT NULL default '',
  `char(130)` varchar(1) NOT NULL default '',
  `char(130)` varbinary(1) NOT NULL default '',
  `format(130,10)` varchar(4) NOT NULL default '',
  `left(_latin2'a',1)` varchar(1) character set latin2 NOT NULL default '',
  `right(_latin2'a',1)` varchar(1) character set latin2 NOT NULL default '',
Loading