Commit c15f970d authored by Alexander Barkov's avatar Alexander Barkov

WL#1349 Use operating system localization to send it as a default client character set

parent d850a57c
......@@ -141,7 +141,7 @@ static my_bool ignore_errors=0,wait_flag=0,quick=0,
vertical=0, line_numbers=1, column_names=1,opt_html=0,
opt_xml=0,opt_nopager=1, opt_outfile=0, named_cmds= 0,
tty_password= 0, opt_nobeep=0, opt_reconnect=1,
default_charset_used= 0, opt_secure_auth= 0,
opt_secure_auth= 0,
default_pager_set= 0, opt_sigint_ignore= 0,
show_warnings= 0, executing_query= 0, interrupted_query= 0,
ignore_spaces= 0;
......@@ -155,7 +155,7 @@ static char * opt_mysql_unix_port=0;
static int connect_flag=CLIENT_INTERACTIVE;
static char *current_host,*current_db,*current_user=0,*opt_password=0,
*current_prompt=0, *delimiter_str= 0,
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME,
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME,
*opt_init_command= 0;
static char *histfile;
static char *histfile_tmp;
......@@ -1581,9 +1581,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
strmake(mysql_charsets_dir, argument, sizeof(mysql_charsets_dir) - 1);
charsets_dir = mysql_charsets_dir;
break;
case OPT_DEFAULT_CHARSET:
default_charset_used= 1;
break;
case OPT_DELIMITER:
if (argument == disabled_my_option)
{
......@@ -1788,10 +1785,6 @@ static int get_options(int argc, char **argv)
connect_flag= 0; /* Not in interactive mode */
}
if (strcmp(default_charset, charset_info->csname) &&
!(charset_info= get_charset_by_csname(default_charset,
MY_CS_PRIMARY, MYF(MY_WME))))
exit(1);
if (argc > 1)
{
usage(0);
......@@ -2919,7 +2912,6 @@ com_charset(String *buffer __attribute__((unused)), char *line)
charset_info= new_cs;
mysql_set_character_set(&mysql, charset_info->csname);
default_charset= (char *)charset_info->csname;
default_charset_used= 1;
put_info("Charset changed", INFO_INFO);
}
else put_info("Charset is not found", INFO_INFO);
......@@ -4243,8 +4235,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
select_limit,max_join_size);
mysql_options(&mysql, MYSQL_INIT_COMMAND, init_command);
}
if (default_charset_used)
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
if (!mysql_real_connect(&mysql, host, user, password,
database, opt_mysql_port, opt_mysql_unix_port,
connect_flag | CLIENT_MULTI_STATEMENTS))
......@@ -4259,6 +4252,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
}
return -1; // Retryable
}
charset_info= mysql.charset;
connected=1;
#ifndef EMBEDDED_LIBRARY
mysql.reconnect= debug_info_flag; // We want to know if this happens
......
......@@ -30,7 +30,7 @@
#define MAX_TRUNC_LENGTH 3
char *host= NULL, *user= 0, *opt_password= 0,
*default_charset= NULL;
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
char truncated_var_names[MAX_MYSQL_VAR][MAX_TRUNC_LENGTH];
char ex_var_names[MAX_MYSQL_VAR][FN_REFLEN];
ulonglong last_values[MAX_MYSQL_VAR];
......@@ -348,8 +348,7 @@ int main(int argc,char *argv[])
if (shared_memory_base_name)
mysql_options(&mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
if (default_charset)
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset);
error_flags= (myf)(opt_nobeep ? 0 : ME_BELL);
if (sql_connect(&mysql, option_wait))
......
......@@ -369,12 +369,15 @@ static int get_options(int *argc, char ***argv)
If there's no --default-character-set option given with
--fix-table-name or --fix-db-name set the default character set to "utf8".
*/
if (!default_charset && (opt_fix_db_names || opt_fix_table_names))
if (!default_charset)
{
default_charset= (char*) "utf8";
if (opt_fix_db_names || opt_fix_table_names)
default_charset= (char*) "utf8";
else
default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
}
if (default_charset && !get_charset_by_csname(default_charset, MY_CS_PRIMARY,
MYF(MY_WME)))
if (strcmp(default_charset, MYSQL_AUTODETECT_CHARSET_NAME) &&
!get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME)))
{
printf("Unsupported character set: %s\n", default_charset);
return 1;
......@@ -787,8 +790,7 @@ static int dbConnect(char *host, char *user, char *passwd)
if (shared_memory_base_name)
mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
if (default_charset)
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset);
if (!(sock = mysql_real_connect(&mysql_connection, host, user, passwd,
NULL, opt_mysql_port, opt_mysql_unix_port, 0)))
{
......
......@@ -55,11 +55,10 @@ static char *opt_password=0, *current_user=0,
*current_host=0, *current_db=0, *fields_terminated=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0,
*escaped=0, *opt_columns=0,
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
*default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
static uint opt_mysql_port= 0, opt_protocol= 0;
static char * opt_mysql_unix_port=0;
static longlong opt_ignore_lines= -1;
static CHARSET_INFO *charset_info= &my_charset_latin1;
#include <sslopt-vars.h>
#ifdef HAVE_SMEM
......@@ -282,10 +281,6 @@ static int get_options(int *argc, char ***argv)
fprintf(stderr, "You can't use --ignore (-i) and --replace (-r) at the same time.\n");
return(1);
}
if (strcmp(default_charset, charset_info->csname) &&
!(charset_info= get_charset_by_csname(default_charset,
MY_CS_PRIMARY, MYF(MY_WME))))
exit(1);
if (*argc < 2)
{
usage();
......@@ -440,6 +435,7 @@ static MYSQL *db_connect(char *host, char *database,
if (shared_memory_base_name)
mysql_options(mysql,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name);
#endif
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset);
if (!(mysql_real_connect(mysql,host,user,passwd,
database,opt_mysql_port,opt_mysql_unix_port,
0)))
......
......@@ -32,7 +32,7 @@ static my_bool tty_password= 0, opt_table_type= 0;
static my_bool debug_info_flag= 0, debug_check_flag= 0;
static uint my_end_arg= 0;
static uint opt_verbose=0;
static char *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
static char *default_charset= (char*) MYSQL_AUTODETECT_CHARSET_NAME;
#ifdef HAVE_SMEM
static char *shared_memory_base_name=0;
......
......@@ -2031,10 +2031,11 @@ AC_SUBST(MAKE_SHELL)
AC_CHECK_HEADERS(varargs.h stdarg.h dirent.h locale.h ndir.h sys/dir.h \
sys/file.h sys/ndir.h sys/ptem.h sys/pte.h sys/select.h sys/stream.h \
sys/mman.h curses.h termcap.h termio.h termbits.h asm/termbits.h grp.h \
paths.h semaphore.h)
paths.h semaphore.h langinfo.h)
# Already-done: strcasecmp
AC_CHECK_FUNCS(lstat putenv select setenv setlocale strcoll tcgetattr)
AC_CHECK_FUNCS(nl_langinfo)
AC_STAT_MACROS_BROKEN
MYSQL_SIGNAL_CHECK
......
......@@ -27,6 +27,8 @@
#define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN)
#define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN)
#define MYSQL_AUTODETECT_CHARSET_NAME "auto"
#define SERVER_VERSION_LENGTH 60
#define SQLSTATE_LENGTH 5
......
#
# We use default-character-set=latin1 to avoid character set auto-detection
# when running tests - not to depend on the current machine localization.
#
[mysql]
default-character-set=latin1
[mysqlshow]
default-character-set=latin1
[mysqlimport]
default-character-set=latin1
[mysqlcheck]
default-character-set=latin1
[mysql_upgrade]
default-character-set=latin1
# Use default setting for mysqld processes
!include default_mysqld.cnf
!include default_client.cnf
[mysqld.1]
......
SET NAMES utf8;
DROP DATABASE IF EXISTS `ó`;
DROP DATABASE IF EXISTS `Ăł`;
DROP DATABASE IF EXISTS `цЁ`;
DROP DATABASE IF EXISTS `ó`;
ISO8859-1
@@character_set_client
latin1
Database: ó
+--------+
| Tables |
+--------+
+--------+
ISO8859-2
@@character_set_client
latin2
Database: ó
+--------+
| Tables |
+--------+
+--------+
KOI8-R
@@character_set_client
koi8r
Database: ó
+--------+
| Tables |
+--------+
+--------+
UTF-8
@@character_set_client
utf8
Database: ó
+--------+
| Tables |
+--------+
+--------+
Database: ó
+--------+
| Tables |
+--------+
+--------+
Database: Ăł
+--------+
| Tables |
+--------+
+--------+
Database: цЁ
+--------+
| Tables |
+--------+
+--------+
SHOW DATABASES LIKE 'ó';
Database (ó)
ó
SHOW DATABASES LIKE 'Ăł';
Database (Ăł)
Ăł
SHOW DATABASES LIKE 'цЁ';
Database (цЁ)
цЁ
SHOW DATABASES LIKE 'ó';
Database (ó)
ó
DROP DATABASE `ó`;
DROP DATABASE `Ăł`;
DROP DATABASE `цЁ`;
DROP DATABASE `ó`;
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
!include include/default_client.cnf
[mysqld.1]
log-bin= master-bin
......
!include include/default_mysqld.cnf
!include include/default_ndbd.cnf
!include include/default_client.cnf
[cluster_config.1]
NoOfReplicas= 2
......
# Use settings from rpl_1slave_base.cnf
# add setting to connect the slave to the master by default
!include rpl_1slave_base.cnf
!include include/default_client.cnf
[mysqld.2]
# Hardcode the host to 127.0.0.1 until running on more
......
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
!include include/default_client.cnf
[mysqld.1]
......
!include include/default_mysqld.cnf
!include include/default_ndbd.cnf
!include include/default_client.cnf
[cluster_config.1]
NoOfReplicas= 2
......
--source include/not_windows.inc
--source include/have_case_sensitive_file_system.inc
#
# Note, please keep this file UTF-8 compatible.
# After editing, make sure that
# "file mysql_locale_posix.test"
# says
# "UTF-8 Unicode text"
# or
# "UTF-8 Unicode English text"
#
#
# Check if we're running on a POSIX-locale machine
#
--disable_query_log
--exec locale -a > var/tmp/locale_a.output 2>/dev/null || true
SET @file=REPLACE(LOAD_FILE('../../tmp/locale_a.output'), '-', '');
# make it case insensitive
SET @file=CAST(@file AS CHAR CHARACTER SET latin1) COLLATE latin1_swedish_ci;
--remove_file var/tmp/locale_a.output
if (`SELECT (IFNULL(@file,'') NOT LIKE '%\nde_DE.iso88591\n%')`)
{
Skip Need POSIX locale de_DE.iso88591;
}
if (`SELECT (IFNULL(@file,'') NOT LIKE '%\nru_RU.koi8r\n%')`)
{
Skip Need POSIX locale ru_RU.koi8r;
}
if (`SELECT (IFNULL(@file,'') NOT LIKE '%\ncs_CZ.iso88592\n%')`)
{
Skip Need POSIX locale cs_CZ.iso88592;
}
if (`SELECT (IFNULL(@file,'') NOT LIKE '%\nen_US.utf8\n%')`)
{
Skip Need POSIX locale en_US.utf8;
}
--enable_query_log
SET NAMES utf8;
--disable_warnings
DROP DATABASE IF EXISTS `ó`;
DROP DATABASE IF EXISTS `Ăł`;
DROP DATABASE IF EXISTS `цЁ`;
DROP DATABASE IF EXISTS `ó`;
--enable_warnings
#
# Test some of the OS-to-MySQL character set mappings
#
# {"ANSI_X3.4-1968", "ascii", my_cs_exact},
# {"ansi1251", "cp1251", my_cs_exact},
# {"armscii8", "armscii8", my_cs_exact},
# {"ASCII", "ascii", my_cs_exact},
# {"Big5", "big5", my_cs_exact},
# {"cp1251", "cp1251", my_cs_exact},
# {"cp1255", "cp1255", my_cs_exact},
# {"CP866", "cp866", my_cs_exact},
# {"eucCN", "gb2312", my_cs_exact},
# {"eucJP", "ujis", my_cs_exact},
# {"eucKR", "euckr", my_cs_exact},
#
# {"gb18030", "gb18030", my_cs_exact},
#
# {"gb2312", "gb2312", my_cs_exact},
# {"gbk", "gbk", my_cs_exact},
# {"georgianps", "geostd8", my_cs_exact},
# {"IBM-1252", "cp1252", my_cs_exact},
#
# {"iso88591", "latin1", my_cs_approx},
# {"ISO_8859-1", "latin1", my_cs_approx},
# {"ISO8859-1", "latin1", my_cs_approx},
# {"ISO-8859-1", "latin1", my_cs_approx},
#
# _utf8 0xC3B3 = LATIN SMALL LETTER O WITH ACUTE
# _latin1 0xC3 = LATIN CAPITAL LETTER A WITH TILDE
# _latin1 0xB3 = SUPERSCRIPT THREE
#
--echo
--echo ISO8859-1
--exec LC_ALL=fi_FI.ISO8859-1 $MYSQL --default-character-set=auto test -e "SELECT @@character_set_client"
--exec LC_ALL=fi_FI.ISO8859-1 $MYSQLADMIN -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-character-set=auto create ó
--exec LC_ALL=fi_FI.ISO8859-1 $MYSQL_SHOW --default-character-set=auto ó
--exec LC_ALL=fi_FI.ISO8859-1 $MYSQL_CHECK --default-character-set=auto "ó"
# {"iso885913", "latin7", my_cs_exact},
# {"ISO_8859-13", "latin7", my_cs_exact},
# {"ISO8859-13", "latin7", my_cs_exact},
# {"ISO-8859-13", "latin7", my_cs_exact},
#
# {"iso885915", "latin9", my_cs_exact},
# {"ISO_8859-15", "latin9", my_cs_exact},
# {"ISO8859-15", "latin9", my_cs_exact},
# {"ISO-8859-15", "latin9", my_cs_exact},
#
# {"iso88592", "latin2", my_cs_exact},
# {"ISO_8859-2", "latin2", my_cs_exact},
# {"ISO8859-2", "latin2", my_cs_exact},
# {"ISO-8859-2", "latin2", my_cs_exact},
#
#
# _utf8 0xC3B3 = LATIN SMALL LETTER O WITH ACUTE
# _latin2 0xC3 = LATIN CAPITAL LETTER A WITH BREVE
# _latin2 0xB3 = LATIN SMALL LETTER L WITH STROKE
#
--echo
--echo ISO8859-2
--exec LC_ALL=cs_CZ.ISO8859-2 $MYSQL --character-sets-dir=$CHARSETSDIR --default-character-set=auto test -e "SELECT @@character_set_client"
--exec LC_ALL=cs_CZ.ISO8859-2 $MYSQLADMIN --character-sets-dir=$CHARSETSDIR -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-character-set=auto create ó
--exec LC_ALL=cs_CZ.ISO8859-2 $MYSQL_SHOW --character-sets-dir=$CHARSETSDIR --default-character-set=auto ó
--exec LC_ALL=cs_CZ.ISO8859-1 $MYSQL_CHECK --character-sets-dir=$CHARSETSDIR--default-character-set=auto "ó"
# {"iso88597", "greek", my_cs_exact},
# {"ISO_8859-7", "greek", my_cs_exact},
# {"ISO8859-7", "greek", my_cs_exact},
# {"ISO-8859-7", "greek", my_cs_exact},
#
# {"iso88598", "hebrew", my_cs_exact},
# {"ISO_8859-8", "hebrew", my_cs_exact},
# {"ISO8859-8", "hebrew", my_cs_exact},
# {"ISO-8859-8", "hebrew", my_cs_exact},
#
# {"iso88599", "latin5", my_cs_exact},
# {"ISO_8859-9", "latin5", my_cs_exact},
# {"ISO8859-9", "latin5", my_cs_exact},
# {"ISO-8859-9", "latin5", my_cs_exact},
#
# {"koi8r", "koi8r", my_cs_exact},
# {"KOI8-R", "koi8r", my_cs_exact},
# {"koi8u", "koi8u", my_cs_exact},
# {"KOI8-U", "koi8u", my_cs_exact},
#
#
# _utf8 0xC3B3 = LATIN SMALL LETTER O WITH ACUTE
# _koi8r 0xC3 = CYRILLIC SMALL LETTER TSE
# _koi8r 0xB3 = CYRILLIC CAPITAL LETTER IO
#
--echo
--echo KOI8-R
--exec LC_ALL=ru_RU.KOI8-R $MYSQL --character-sets-dir=$CHARSETSDIR --default-character-set=auto test -e "SELECT @@character_set_client"
--exec LC_ALL=ru_RU.KOI8-R $MYSQLADMIN --character-sets-dir=$CHARSETSDIR -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-character-set=auto create ó
--exec LC_ALL=ru_RU.KOI8-R $MYSQL_SHOW --character-sets-dir=$CHARSETSDIR --default-character-set=auto ó
--exec LC_ALL=ru_RU.ISO8859-1 $MYSQL_CHECK --character-sets-dir=$CHARSETSDIR --default-character-set=auto "ó"
# {"Shift_JIS", "sjis", my_cs_exact},
# {"SJIS", "sjis", my_cs_exact},
#
# {"tis620", "tis620", my_cs_exact},
#
# {"ujis", "ujis", my_cs_exact},
#
# {"US-ASCII", "ascii", my_cs_exact},
#
# {"utf8", "utf8", my_cs_exact},
# {"utf-8", "utf8", my_cs_exact},
--echo
--echo UTF-8
--exec LC_ALL=en_US.UTF-8 $MYSQL --default-character-set=auto test -e "SELECT @@character_set_client"
--exec LC_ALL=en_US.UTF-8 $MYSQLADMIN -uroot -S $MASTER_MYSOCK -P $MASTER_MYPORT --default-character-set=auto create ó
--exec LC_ALL=en_US.UTF-8 $MYSQL_SHOW --default-character-set=auto ó
--exec LC_ALL=en_US.UTF-8 $MYSQL_SHOW --default-character-set=auto "ó"
--exec LC_ALL=en_US.UTF-8 $MYSQL_SHOW --default-character-set=auto "Ăł"
--exec LC_ALL=en_US.UTF-8 $MYSQL_SHOW --default-character-set=auto "цЁ"
--exec LC_ALL=en_US.UTF-8 $MYSQL_CHECK --default-character-set=auto ó
--exec LC_ALL=en_US.UTF-8 $MYSQL_CHECK --default-character-set=auto "ó"
--exec LC_ALL=en_US.UTF-8 $MYSQL_CHECK --default-character-set=auto "Ăł"
--exec LC_ALL=en_US.UTF-8 $MYSQL_CHECK --default-character-set=auto "цЁ"
SHOW DATABASES LIKE 'ó';
SHOW DATABASES LIKE 'Ăł';
SHOW DATABASES LIKE 'цЁ';
SHOW DATABASES LIKE 'ó';
DROP DATABASE `ó`;
DROP DATABASE `Ăł`;
DROP DATABASE `цЁ`;
DROP DATABASE `ó`;
......@@ -4,7 +4,7 @@
# Test "mysqladmin ping"
#
--exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
--exec $MYSQLADMIN --no-defaults --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
#
......@@ -19,7 +19,7 @@ EOF
--replace_regex /.*mysqladmin.*: unknown/mysqladmin: unknown/
--error 7
--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf;
# When mysqladmin finds "loose-database" in .cnf file it shall print
......@@ -30,6 +30,6 @@ loose-database=db2
EOF
--replace_regex /Warning: .*mysqladmin.*: unknown/Warning: mysqladmin: unknown/
--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf --default-character-set=latin1 -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf;
......@@ -178,7 +178,7 @@ SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
WHERE TRIGGER_SCHEMA="#mysql50#a@b" ORDER BY trigger_name;
--echo mysqlcheck --fix-db-names --fix-table-names --all-databases
--exec $MYSQL_CHECK --fix-db-names --fix-table-names --all-databases
--exec $MYSQL_CHECK --default-character-set=utf8 --fix-db-names --fix-table-names --all-databases
USE `a@b`;
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment