Commit d8f416a2 authored by unknown's avatar unknown
Browse files

bug in my_strnncoll_utf8 (and friends) fixed

cleanups
better, charset-dependent, ft_max_len_for_sort value


myisam/ftdefs.h:
  better ft_max_len_for_sort value
myisam/mi_check.c:
  better, charset-dependent, ft_max_len_for_sort value
myisam/myisamchk.c:
  unused value from enum removed
myisam/sort.c:
  cleanup
sql/mysql_priv.h:
  cleanup
sql/mysqld.cc:
  cleanup
sql/sql_acl.cc:
  cleanup
sql/tztime.cc:
  cleanup
strings/ctype-utf8.c:
  bug in my_strnncoll_utf8 (and friends) fixed
parent 82257f94
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@
#define misc_word_char(X)	((X)=='\'')
#define word_char(s,X)		(true_word_char(s,X) || misc_word_char(X))

#define FT_MAX_WORD_LEN_FOR_SORT 20
#define FT_MAX_WORD_LEN_FOR_SORT 31

#define COMPILE_STOPWORDS_IN

+22 −14
Original line number Diff line number Diff line
@@ -2020,12 +2020,14 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,

    if (sort_param.keyinfo->flag & HA_FULLTEXT)
    {
      uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
                                    sort_param.keyinfo->seg->charset->mbmaxlen;
      sort_info.max_records=
        (ha_rows) (sort_info.filelength/FT_MAX_WORD_LEN_FOR_SORT+1);
        (ha_rows) (sort_info.filelength/ft_max_word_len_for_sort+1);

      sort_param.key_read=sort_ft_key_read;
      sort_param.key_write=sort_ft_key_write;
      sort_param.key_length+=FT_MAX_WORD_LEN_FOR_SORT-HA_FT_MAXBYTELEN;
      sort_param.key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
    }
    else
    {
@@ -2425,7 +2427,11 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info,
    total_key_length+=sort_param[i].key_length;

    if (sort_param[i].keyinfo->flag & HA_FULLTEXT)
      sort_param[i].key_length+=FT_MAX_WORD_LEN_FOR_SORT-HA_FT_MAXBYTELEN;
    {
      uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
                                    sort_param[i].keyinfo->seg->charset->mbmaxlen;
      sort_param[i].key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
    }
  }
  sort_info.total_keys=i;
  sort_param[0].master= 1;
@@ -2634,7 +2640,6 @@ static int sort_key_read(MI_SORT_PARAM *sort_param, void *key)
  DBUG_RETURN(sort_write_record(sort_param));
} /* sort_key_read */


static int sort_ft_key_read(MI_SORT_PARAM *sort_param, void *key)
{
  int error;
@@ -3950,25 +3955,28 @@ static ha_checksum mi_byte_checksum(const byte *buf, uint length)
  return crc;
}

/*
  Deactive all not unique index that can be recreated fast
  These include packed keys on which sorting will use more temporary
  space than the max allowed file length or for which the unpacked keys
  will take much more space than packed keys.
  Note that 'rows' may be zero for the case when we don't know how many
  rows we will put into the file.
 */

static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows)
{
  uint key_maxlength=key->maxlength;
  if (key->flag & HA_FULLTEXT)
    key_maxlength+=FT_MAX_WORD_LEN_FOR_SORT-HA_FT_MAXBYTELEN;
  {
    uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
                                  key->seg->charset->mbmaxlen;
    key_maxlength+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
  }
  return (key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) &&
	  ((ulonglong) rows * key_maxlength >
	   (ulonglong) myisam_max_temp_length));
}

/*
  Deactivate all not unique index that can be recreated fast
  These include packed keys on which sorting will use more temporary
  space than the max allowed file length or for which the unpacked keys
  will take much more space than packed keys.
  Note that 'rows' may be zero for the case when we don't know how many
  rows we will put into the file.
 */

void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows)
{
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ enum options_mc {
  OPT_KEY_CACHE_BLOCK_SIZE, OPT_MYISAM_BLOCK_SIZE,
  OPT_READ_BUFFER_SIZE, OPT_WRITE_BUFFER_SIZE, OPT_SORT_BUFFER_SIZE,
  OPT_SORT_KEY_BLOCKS, OPT_DECODE_BITS, OPT_FT_MIN_WORD_LEN,
  OPT_FT_MAX_WORD_LEN, OPT_FT_MAX_WORD_LEN_FOR_SORT, OPT_FT_STOPWORD_FILE,
  OPT_FT_MAX_WORD_LEN, OPT_FT_STOPWORD_FILE,
  OPT_MAX_RECORD_LENGTH
};

+3 −1
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
	reinit_io_cache(&tempfile,READ_CACHE,0L,0,0))
      goto err;					/* purecov: inspected */
    if (!no_messages)
      puts("  - Last merge and dumping keys\n"); /* purecov: tested */
      printf("  - Last merge and dumping keys\n"); /* purecov: tested */
    if (merge_index(info,keys,sort_keys,dynamic_element(&buffpek,0,BUFFPEK *),
                    maxbuffer,&tempfile))
      goto err;					/* purecov: inspected */
@@ -219,6 +219,8 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
    uint     keyno=info->key;
    uint     key_length, ref_length=index->s->rec_reflength;

    if (!no_messages)
      printf("  - Adding exceptions\n"); /* purecov: tested */
    if (flush_io_cache(&tempfile_for_exceptions) ||
	reinit_io_cache(&tempfile_for_exceptions,READ_CACHE,0L,0,0))
      goto err;
+40 −40
Original line number Diff line number Diff line
@@ -762,7 +762,7 @@ void kill_mysql(void)
    abort_loop=1;
    if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
			   (void*) 0))
      sql_print_error("Error: Can't create thread to kill server");
      sql_print_error("Can't create thread to kill server");
  }
#endif
  DBUG_VOID_RETURN;
@@ -791,7 +791,7 @@ static void __cdecl kill_server(int sig_ptr)
  abort_loop=1;					// This should be set
  signal(sig,SIG_IGN);
  if (sig == MYSQL_KILL_SIGNAL || sig == 0)
    sql_print_error(ER(ER_NORMAL_SHUTDOWN),my_progname);
    sql_print_information(ER(ER_NORMAL_SHUTDOWN),my_progname);
  else
    sql_print_error(ER(ER_GOT_SIGNAL),my_progname,sig); /* purecov: inspected */

@@ -834,7 +834,7 @@ extern "C" sig_handler print_signal_warning(int sig)
  if (!DBUG_IN_USE)
  {
    if (global_system_variables.log_warnings)
      sql_print_error("Warning: Got signal %d from thread %d",
      sql_print_warning("Got signal %d from thread %d",
		      sig,my_thread_id());
  }
#ifdef DONT_REMEMBER_SIGNAL
@@ -961,7 +961,7 @@ void clean_up(bool print_message)
#endif

  if (print_message && errmesg)
    sql_print_error(ER(ER_SHUTDOWN_COMPLETE),my_progname);
    sql_print_information(ER(ER_SHUTDOWN_COMPLETE),my_progname);
#if !defined(__WIN__) && !defined(EMBEDDED_LIBRARY)
  if (!opt_bootstrap)
    (void) my_delete(pidfile_name,MYF(0));	// This may not always exist
@@ -1062,8 +1062,8 @@ static void set_user(const char *user)
      struct passwd *user_info= getpwnam(user);
      if ((!user_info || user_id != user_info->pw_uid) &&
	  global_system_variables.log_warnings)
	fprintf(stderr,
		"Warning: One can only use the --user switch if running as root\n");
        sql_print_warning(
                    "One can only use the --user switch if running as root\n");
    }
    return;
  }
@@ -1183,7 +1183,7 @@ static void server_init(void)
    if (listen(ip_sock,(int) back_log) < 0)
    {
      sql_perror("Can't start server: listen() on TCP/IP port");
      sql_print_error("Error:  listen() on TCP/IP failed with error %d",
      sql_print_error("listen() on TCP/IP failed with error %d",
		      socket_errno);
      unireg_abort(1);
    }
@@ -1278,7 +1278,7 @@ static void server_init(void)
    (void) chmod(mysqld_unix_port,S_IFSOCK);	/* Fix solaris 2.6 bug */
#endif
    if (listen(unix_sock,(int) back_log) < 0)
      sql_print_error("Warning:  listen() on Unix socket failed with error %d",
      sql_print_warning("listen() on Unix socket failed with error %d",
		      socket_errno);
  }
#endif
@@ -1870,7 +1870,7 @@ static void init_signals(void)
    struct rlimit rl;
    rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
    if (setrlimit(RLIMIT_CORE, &rl) && global_system_variables.log_warnings)
      sql_print_error("Warning: setrlimit could not change the size of core files to 'infinity';  We may not be able to generate a core file on signals");
      sql_print_warning("setrlimit could not change the size of core files to 'infinity';  We may not be able to generate a core file on signals");
  }
#endif
  (void) sigemptyset(&set);
@@ -2024,7 +2024,7 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
    case SIGQUIT:
    case SIGKILL:
#ifdef EXTRA_DEBUG
      sql_print_error("Got signal %d to shutdown mysqld",sig);
      sql_print_information("Got signal %d to shutdown mysqld",sig);
#endif
      DBUG_PRINT("info",("Got signal: %d  abort_loop: %d",sig,abort_loop));
      if (!abort_loop)
@@ -2036,7 +2036,7 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
	  my_pthread_attr_setprio(&connection_attrib,INTERRUPT_PRIOR);
	if (pthread_create(&tmp,&connection_attrib, kill_server_thread,
			   (void*) sig))
	  sql_print_error("Error: Can't create thread to kill server");
	  sql_print_error("Can't create thread to kill server");
#else
	kill_server((void*) sig);	// MIT THREAD has a alarm thread
#endif
@@ -2060,7 +2060,7 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
#endif
    default:
#ifdef EXTRA_DEBUG
      sql_print_error("Warning: Got signal: %d  error: %d",sig,error); /* purecov: tested */
      sql_print_warning("Got signal: %d  error: %d",sig,error); /* purecov: tested */
#endif
      break;					/* purecov: tested */
    }
@@ -2339,11 +2339,11 @@ static int init_common_variables(const char *conf_file_name, int argc,
		   ("Changed limits: max_open_files: %u  max_connections: %ld  table_cache: %ld",
		    files, max_connections, table_cache_size));
	if (global_system_variables.log_warnings)
	  sql_print_error("Warning: Changed limits: max_open_files: %u  max_connections: %ld  table_cache: %ld",
	  sql_print_warning("Changed limits: max_open_files: %u  max_connections: %ld  table_cache: %ld",
			files, max_connections, table_cache_size);
      }
      else if (global_system_variables.log_warnings)
	sql_print_error("Warning: Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files);
	sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files);
    }
    open_files_limit= files;
  }
@@ -2523,8 +2523,8 @@ static int init_server_components()
  }
  else if (opt_log_slave_updates)
  {
      sql_print_error("\
Warning: you need to use --log-bin to make --log-slave-updates work. \
      sql_print_warning("\
you need to use --log-bin to make --log-slave-updates work. \
Now disabling --log-slave-updates.");
  }

@@ -2532,7 +2532,7 @@ Now disabling --log-slave-updates.");
  if (opt_log_slave_updates && replicate_same_server_id)
  {
    sql_print_error("\
Error: using --replicate-same-server-id in conjunction with \
using --replicate-same-server-id in conjunction with \
--log-slave-updates is impossible, it would lead to infinite loops in this \
server.");
    unireg_abort(1);
@@ -2561,12 +2561,12 @@ server.");
  if (opt_innodb_safe_binlog)
  {
    if (have_innodb != SHOW_OPTION_YES)
      sql_print_error("Warning: --innodb-safe-binlog is meaningful only if "
      sql_print_warning("--innodb-safe-binlog is meaningful only if "
                      "the InnoDB storage engine is enabled in the server.");
#ifdef HAVE_INNOBASE_DB
    if (innobase_flush_log_at_trx_commit != 1)
    {
      sql_print_error("Warning: --innodb-safe-binlog is meaningful only if "
      sql_print_warning("--innodb-safe-binlog is meaningful only if "
                      "innodb_flush_log_at_trx_commit is 1; now setting it "
                      "to 1.");
      innobase_flush_log_at_trx_commit= 1;
@@ -2578,14 +2578,14 @@ server.");
        good (especially "littlesync", and on Windows... see
        srv/srv0start.c).
      */
      sql_print_error("Warning: --innodb-safe-binlog requires that "
      sql_print_warning("--innodb-safe-binlog requires that "
                      "the innodb_flush_method actually synchronizes the "
                      "InnoDB log to disk; it is your responsibility "
                      "to verify that the method you chose does it.");
    }
    if (sync_binlog_period != 1)
    {
      sql_print_error("Warning: --innodb-safe-binlog is meaningful only if "
      sql_print_warning("--innodb-safe-binlog is meaningful only if "
                      "the global sync_binlog variable is 1; now setting it "
                      "to 1.");
      sync_binlog_period= 1;
@@ -2624,7 +2624,7 @@ server.");
    if (mlockall(MCL_CURRENT))
    {
      if (global_system_variables.log_warnings)
	sql_print_error("Warning: Failed to lock memory. Errno: %d\n",errno);
	sql_print_warning("Failed to lock memory. Errno: %d\n",errno);
      locked_in_memory= 0;
    }
  }
@@ -2650,7 +2650,7 @@ static void create_maintenance_thread()
  {
    pthread_t hThread;
    if (pthread_create(&hThread,&connection_attrib,handle_manager,0))
      sql_print_error("Warning: Can't create thread to manage maintenance");
      sql_print_warning("Can't create thread to manage maintenance");
  }
}

@@ -2662,7 +2662,7 @@ static void create_shutdown_thread()
  hEventShutdown=CreateEvent(0, FALSE, FALSE, shutdown_event_name);
  pthread_t hThread;
  if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
    sql_print_error("Warning: Can't create thread to handle shutdown requests");
    sql_print_warning("Can't create thread to handle shutdown requests");

  // On "Stop Service" we have to do regular shutdown
  Service.SetShutdownEvent(hEventShutdown);
@@ -2671,7 +2671,7 @@ static void create_shutdown_thread()
  pthread_cond_init(&eventShutdown, NULL);
  pthread_t hThread;
  if (pthread_create(&hThread,&connection_attrib,handle_shutdown,0))
    sql_print_error("Warning: Can't create thread to handle shutdown requests");
    sql_print_warning("Can't create thread to handle shutdown requests");
#endif
#endif // EMBEDDED_LIBRARY 
}
@@ -2702,7 +2702,7 @@ static void handle_connections_methods()
    if (pthread_create(&hThread,&connection_attrib,
		       handle_connections_namedpipes, 0))
    {
      sql_print_error("Warning: Can't create thread to handle named pipes");
      sql_print_warning("Can't create thread to handle named pipes");
      handler_count--;
    }
  }
@@ -2713,7 +2713,7 @@ static void handle_connections_methods()
    if (pthread_create(&hThread,&connection_attrib,
		       handle_connections_sockets, 0))
    {
      sql_print_error("Warning: Can't create thread to handle TCP/IP");
      sql_print_warning("Can't create thread to handle TCP/IP");
      handler_count--;
    }
  }
@@ -2724,7 +2724,7 @@ static void handle_connections_methods()
    if (pthread_create(&hThread,&connection_attrib,
		       handle_connections_shared_memory, 0))
    {
      sql_print_error("Warning: Can't create thread to handle shared memory");
      sql_print_warning("Can't create thread to handle shared memory");
      handler_count--;
    }
  }
@@ -2784,7 +2784,7 @@ int main(int argc, char **argv)
    if (stack_size && stack_size < thread_stack)
    {
      if (global_system_variables.log_warnings)
	sql_print_error("Warning: Asked for %ld thread stack, but got %ld",
	sql_print_warning("Asked for %ld thread stack, but got %ld",
			thread_stack, stack_size);
      thread_stack= stack_size;
    }
@@ -2807,8 +2807,8 @@ int main(int argc, char **argv)
    if (lower_case_table_names_used)
    {
      if (global_system_variables.log_warnings)
	sql_print_error("\
Warning: You have forced lower_case_table_names to 0 through a command-line \
	sql_print_warning("\
You have forced lower_case_table_names to 0 through a command-line \
option, even though your file system '%s' is case insensitive.  This means \
that you can corrupt a MyISAM table by accessing it with different cases. \
You should consider changing lower_case_table_names to 1 or 2",
@@ -2817,7 +2817,7 @@ You should consider changing lower_case_table_names to 1 or 2",
    else
    {
      if (global_system_variables.log_warnings)
	sql_print_error("Warning: Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home);
	sql_print_warning("Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home);
      lower_case_table_names= 2;
    }
  }
@@ -2850,14 +2850,14 @@ You should consider changing lower_case_table_names to 1 or 2",
#ifdef EXTRA_DEBUG
    switch (server_id) {
    case 1:
      sql_print_error("\
Warning: You have enabled the binary log, but you haven't set server-id to \
      sql_print_warning("\
You have enabled the binary log, but you haven't set server-id to \
a non-zero value: we force server id to 1; updates will be logged to the \
binary log, but connections from slaves will not be accepted.");
      break;
    case 2:
      sql_print_error("\
Warning: You should set server-id to a non-0 value if master_host is set; \
      sql_print_warning("\
You should set server-id to a non-0 value if master_host is set; \
we force server id to 2, but this MySQL server will not act as a slave.");
      break;
    }
@@ -3197,7 +3197,7 @@ static int bootstrap(FILE *file)
  if (pthread_create(&thd->real_id,&connection_attrib,handle_bootstrap,
		     (void*) thd))
  {
    sql_print_error("Warning: Can't create thread to handle bootstrap");
    sql_print_warning("Can't create thread to handle bootstrap");
    DBUG_RETURN(-1);
  }
  /* Wait for thread to die */
@@ -5606,7 +5606,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
    if (!mysqld_user || !strcmp(mysqld_user, argument))
      mysqld_user= argument;
    else
      fprintf(stderr, "Warning: Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user);
      sql_print_warning("Ignoring user change to '%s' because the user was set to '%s' earlier on the command line\n", argument, mysqld_user);
    break;
  case 'L':
    strmake(language, argument, sizeof(language)-1);
@@ -6391,7 +6391,7 @@ static int test_if_case_insensitive(const char *dir_name)
  (void) my_delete(buff2, MYF(0));
  if ((file= my_create(buff, 0666, O_RDWR, MYF(0))) < 0)
  {
    sql_print_error("Warning: Can't create test file %s", buff);
    sql_print_warning("Can't create test file %s", buff);
    DBUG_RETURN(-1);
  }
  my_close(file, MYF(0));
Loading