Commit 598f7ec5 authored by unknown's avatar unknown

Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1

into deer.(none):/home/hf/work/mysql-4.1.emb_bind

parents 002b1f86 4e6acef8
......@@ -617,3 +617,4 @@ vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
include/readline/*.h
scripts/mysql_create_system_tables
......@@ -19,7 +19,10 @@
#undef CRAY_STACKSEG_END
/* Define the default charset name */
#undef DEFAULT_CHARSET_NAME
#undef MYSQL_DEFAULT_CHARSET_NAME
/* Define the default charset name */
#undef MYSQL_DEFAULT_COLLATION_NAME
/* Version of .frm files */
#undef DOT_FRM_VERSION
......
......@@ -139,7 +139,7 @@ static my_string 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_CHARSET;
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
static char *histfile;
static String glob_buffer,old_buffer;
static String processed_prompt;
......@@ -1457,6 +1457,16 @@ int mysql_store_result_for_lazy(MYSQL_RES **result)
return 0;
}
static void print_help_item(MYSQL_ROW *cur, int num_name, int num_cat, char *last_char)
{
char ccat= (*cur)[num_cat][0];
if (*last_char != ccat)
{
put_info(ccat == 'Y' ? "categories :" : "topics :", INFO_INFO);
*last_char= ccat;
}
tee_fprintf(PAGER, " %s\n", (*cur)[num_name]);
}
static int com_server_help(String *buffer __attribute__((unused)),
char *line __attribute__((unused)), char *help_arg)
......@@ -1465,14 +1475,15 @@ static int com_server_help(String *buffer __attribute__((unused)),
const char *server_cmd= buffer->ptr();
char cmd_buf[100];
MYSQL_RES *result;
MYSQL_FIELD *fields;
int error;
if (help_arg[0] != '\'')
{
(void) strxnmov(cmd_buf, sizeof(cmd_buf), "help '", help_arg, "'", NullS);
server_cmd= cmd_buf;
}
if (!status.batch)
{
old_buffer= *buffer;
......@@ -1482,15 +1493,16 @@ static int com_server_help(String *buffer __attribute__((unused)),
if (!connected && reconnect())
return 1;
if ((error= mysql_real_query_for_lazy(server_cmd,strlen(server_cmd))))
return error;
if ((error= mysql_store_result_for_lazy(&result)))
if ((error= mysql_real_query_for_lazy(server_cmd,strlen(server_cmd))) ||
(error= mysql_store_result_for_lazy(&result)))
return error;
if (result)
{
ulonglong num_rows= mysql_num_rows(result);
if (num_rows == 1)
unsigned int num_fields= mysql_num_fields(result);
my_ulonglong num_rows= mysql_num_rows(result);
fields= mysql_fetch_fields(result);
if (num_fields==3 && num_rows==1)
{
if (!(cur= mysql_fetch_row(result)))
{
......@@ -1499,46 +1511,45 @@ static int com_server_help(String *buffer __attribute__((unused)),
}
init_pager();
if (cur[1][0] == 'Y')
{
tee_fprintf(PAGER, "Help topic \'%s\'\n", cur[0]);
tee_fprintf(PAGER, "%s\n", cur[2]);
tee_fprintf(PAGER, "For help on specific function please type 'help <function>'\nwhere function is one of next:\n%s\n", cur[3]);
}
else
{
tee_fprintf(PAGER, "Name: \'%s\'\n\n", cur[0]);
tee_fprintf(PAGER, "Description:\n%s\n\n", cur[2]);
if (cur[3])
tee_fprintf(PAGER, "Examples:\n%s\n", cur[3]);
}
tee_fprintf(PAGER, "Name: \'%s\'\n", cur[0]);
tee_fprintf(PAGER, "Description:\n%s", cur[1]);
if (cur[2] && *((char*)cur[2]))
tee_fprintf(PAGER, "Examples:\n%s", cur[2]);
tee_fprintf(PAGER, "\n");
end_pager();
}
else if (num_rows > 1)
else if (num_fields >= 2 && num_rows)
{
put_info("Many help items for your request exist", INFO_INFO);
put_info("For more specific request please type 'help <item>' where item is one of next:", INFO_INFO);
init_pager();
char last_char= '_';
while ((cur= mysql_fetch_row(result)))
char last_char;
int num_name, num_cat;
if (num_fields == 2)
{
if (cur[1][0]!=last_char)
{
put_info("-------------------------------------------", INFO_INFO);
put_info(cur[1][0] == 'Y' ?
"categories:" : "functions:", INFO_INFO);
put_info("-------------------------------------------", INFO_INFO);
}
last_char= cur[1][0];
tee_fprintf(PAGER, "%s\n", cur[0]);
put_info("Many help items for your request exist", INFO_INFO);
put_info("For more specific request please type 'help <item>' where item is one of next", INFO_INFO);
num_name= 0;
num_cat= 1;
last_char= '_';
}
else if ((cur= mysql_fetch_row(result)))
{
tee_fprintf(PAGER, "You asked help about help category: \"%s\"\n", cur[0]);
put_info("For a more information type 'help <item>' where item is one of the following", INFO_INFO);
num_name= 1;
num_cat= 2;
print_help_item(&cur,1,2,&last_char);
}
while ((cur= mysql_fetch_row(result)))
print_help_item(&cur,num_name,num_cat,&last_char);
tee_fprintf(PAGER, "\n");
end_pager();
}
else
{
put_info("\nNothing found\n", INFO_INFO);
put_info("\nNothing found", INFO_INFO);
put_info("Please try to run 'help contents' for list of all accessible topics\n", INFO_INFO);
}
}
......
......@@ -38,7 +38,8 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0,
static uint verbose = 0, opt_mysql_port=0;
static my_string opt_mysql_unix_port = 0;
static char *opt_password = 0, *current_user = 0,
*default_charset = (char *)MYSQL_CHARSET, *current_host = 0;
*default_charset = (char *)MYSQL_DEFAULT_CHARSET_NAME,
*current_host = 0;
static int first_error = 0;
DYNAMIC_ARRAY tables4repair;
#ifdef HAVE_SMEM
......
......@@ -85,7 +85,7 @@ static MYSQL mysql_connection,*sock=0;
static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*current_host=0,*path=0,*fields_terminated=0,
*lines_terminated=0, *enclosed=0, *opt_enclosed=0, *escaped=0,
*where=0, *default_charset= (char *)MYSQL_CHARSET,
*where=0, *default_charset= (char *)MYSQL_DEFAULT_CHARSET_NAME,
*opt_compatible_mode_str= 0,
*err_ptr= 0;
static ulong opt_compatible_mode= 0;
......
......@@ -44,7 +44,7 @@ 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_CHARSET;
*default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME;
static uint opt_mysql_port=0;
static my_string opt_mysql_unix_port=0;
static my_string opt_ignore_lines=0;
......
......@@ -2255,6 +2255,12 @@ AC_ARG_WITH(charset,
[default_charset="$withval"],
[default_charset="$DEFAULT_CHARSET"])
AC_ARG_WITH(collation,
[ --with-collation=COLLATION
Default collation],
[default_collation="$withval"],
[default_collation="default"])
AC_ARG_WITH(extra-charsets,
[ --with-extra-charsets=CHARSET[,CHARSET,...]
......@@ -2281,7 +2287,6 @@ else
CHARSETS="$CHARSETS $EXTRA_CHARSETS"
fi
for cs in $CHARSETS
do
case $cs in
......@@ -2404,11 +2409,169 @@ do
done
AC_SUBST(default_charset)
AC_DEFINE_UNQUOTED(DEFAULT_CHARSET_NAME,"$default_charset")
default_charset_collations=""
AC_MSG_RESULT([default: $default_charset; compiled in: $CHARSETS])
case $default_charset in
armscii8)
default_charset_default_collation="armscii8_general_ci"
default_charset_collations="armscii8_general_ci armscii_bin"
;;
ascii)
default_charset_default_collation="ascii_general_ci"
default_charset_collations="ascii_general_ci ascii_bin"
;;
big5)
default_charset_default_collation="big5_chinese_ci"
default_charset_collations="big5_chinese_ci big5_bin"
;;
cp1250)
default_charset_default_collation="cp1250_general_ci"
default_charset_collations="cp1250_general_ci cp1250_czech_ci cp1250_bin"
;;
cp1251)
default_charset_default_collation="cp1251_general_ci"
default_charset_collations="cp1251_general_ci cp1251_general_cs cp1251_bin cp1251_bulgarian_ci cp1251_ukrainian_ci"
;;
cp1256)
default_charset_default_collation="cp1256_general_ci"
default_charset_collations="cp1256_general_ci cp1256_bin"
;;
cp1257)
default_charset_default_collation="cp1257_general_ci"
default_charset_collations="cp1257_general_ci cp1257_lithuanian_ci cp1257_bin"
;;
cp850)
default_charset_default_collation="cp850_general_ci"
default_charset_collations="cp850_general_ci cp850_bin"
;;
cp852)
default_charset_default_collation="cp852_general_ci"
default_charset_collations="cp852_general_ci cp852_bin"
;;
cp866)
default_charset_default_collation="cp866_general_ci"
default_charset_collations="cp866_general_ci cp866_bin"
;;
dec8)
default_charset_default_collation="dec8_swedish_ci"
default_charset_collations="dec8_swedish_ci dec8_bin"
;;
euckr)
default_charset_default_collation="euckr_korean_ci"
default_charset_collations="euckr_korean_ci euckr_bin"
;;
gb2312)
default_charset_default_collation="gb2312_chinese_ci"
default_charset_collations="gb2312_chinese_ci gb2312_bin"
;;
gbk)
default_charset_default_collation="gbk_chinese_ci"
default_charset_collations="gbk_chinese_ci gbk_bin"
;;
greek)
default_charset_default_collation="greek_general_ci"
default_charset_collations="greek_general_ci greek_bin"
;;
hebrew)
default_charset_default_collation="hebrew_general_ci"
default_charset_collations="hebrew_general_ci hebrew_bin"
;;
hp8)
default_charset_default_collation="hp8_english_ci"
default_charset_collations="hp8_english_ci hp8_bin"
;;
keybcs2)
default_charset_default_collation="keybcs2_general_ci"
default_charset_collations="keybcs2_general_ci keybcs2_bin"
;;
koi8r)
default_charset_default_collation="koi8r_general_ci"
default_charset_collations="koi8r_general_ci koi8r_bin"
;;
koi8u)
default_charset_default_collation="koi8u_general_ci"
default_charset_collations="koi8u_general_ci koi8u_bin"
;;
latin1)
default_charset_default_collation="latin1_swedish_ci"
default_charset_collations="latin1_general_ci latin1_general_cs latin1_bin latin1_german1_ci latin1_german2_ci latin1_danish_ci latin1_swedish_ci"
;;
latin2)
default_charset_default_collation="latin2_general_ci"
default_charset_collations="latin2_general_ci latin2_bin latin2_czech_ci latin2_hungarian_ci latin2_croatian_ci"
;;
latin5)
default_charset_default_collation="latin5_turkish_ci"
default_charset_collations="latin5_turkish_ci latin5_bin"
;;
latin7)
default_charset_default_collation="latin7_general_ci"
default_charset_collations="latin7_general_ci latin7_general_cs latin7_bin latin7_estonian_cs"
;;
macce)
default_charset_default_collation="macce_general_ci"
default_charset_collations="macce_general_ci macce_bin"
;;
macroman)
default_charset_default_collation="macroman_general_ci"
default_charset_collations="macroman_general_ci macroman_bin"
;;
sjis)
default_charset_default_collation="sjis_japanese_ci"
default_charset_collations="sjis_japanese_ci sjis_bin"
;;
swe7)
default_charset_default_collation="swe7_swedish_ci"
default_charset_collations="swe7_swedish_ci swe7_bin"
;;
tis620)
default_charset_default_collation="tis620_thai_ci"
default_charset_collations="tis620_thai_ci tis620_bin"
;;
ucs2)
default_charset_default_collation="ucs2_general_ci"
default_charset_collations="ucs2_general_ci ucs2_bin"
;;
ujis)
default_charset_default_collation="ujis_japanese_ci"
default_charset_collations="ujis_japanese_ci ujis_bin"
;;
utf8)
default_charset_default_collation="utf8_general_ci"
default_charset_collations="utf8_general_ci utf8_bin"
;;
*)
AC_MSG_ERROR([Charset $cs not available. (Available are: $CHARSETS_AVAILABLE).
See the Installation chapter in the Reference Manual.]);
esac
if test "$default_collation" = default; then
default_collation=$default_charset_default_collation
fi
valid_default_collation=no
for cl in $default_charset_collations
do
if test x"$cl" = x"$default_collation"
then
valid_default_collation=yes
break
fi
done
if test x$valid_default_collation = xyes
then
AC_MSG_RESULT([default: $default_charset, collation: $default_collation; compiled in: $CHARSETS])
else
AC_MSG_ERROR([
Collation $default_collation is not valid for character set $default_charset.
Valid collations are: $default_charset_collations.
See the Installation chapter in the Reference Manual.
]);
fi
AC_DEFINE_UNQUOTED(MYSQL_DEFAULT_CHARSET_NAME,"$default_charset")
AC_DEFINE_UNQUOTED(MYSQL_DEFAULT_COLLATION_NAME,"$default_collation")
MYSQL_CHECK_ISAM
MYSQL_CHECK_BDB
......
......@@ -20,8 +20,5 @@
#define MYSQL_CONFIG_NAME "my"
/* mysqld compile time options */
#ifndef MYSQL_CHARSET
#define MYSQL_CHARSET "@default_charset@"
#endif /* MYSQL_CHARSET */
#endif /* _CUSTOMCONFIG_ */
#endif /* _mysql_version_h */
......@@ -11,10 +11,12 @@ if [ x$1 = x"-bin" ]; then
bindir=../bin
BINARY_DIST=1
fix_bin=mysql-test
scriptdir=../bin
else
execdir=../sql
bindir=../client
fix_bin=.
scriptdir=../scripts
fi
vardir=var
......@@ -60,217 +62,11 @@ basedir=.
EXTRA_ARG="--language=../sql/share/english/"
fi
# Initialize variables
c_d="" i_d=""
c_h="" i_h=""
c_u="" i_u=""
c_f="" i_f=""
c_t="" c_c=""
c_hl="" c_hl=""
c_hc="" c_hc=""
c_clr="" c_clr=""
# Check for old tables
if test ! -f $mdata/db.frm
then
# mysqld --bootstrap wants one command/line
c_d="$c_d CREATE TABLE db ("
c_d="$c_d Host char(60) DEFAULT '' NOT NULL,"
c_d="$c_d Db char(64) DEFAULT '' NOT NULL,"
c_d="$c_d User char(16) DEFAULT '' NOT NULL,"
c_d="$c_d Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d PRIMARY KEY Host (Host,Db,User),"
c_d="$c_d KEY User (User)"
c_d="$c_d )"
c_d="$c_d comment='Database privileges';"
i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');"
fi
if test ! -f $mdata/host.frm
then
c_h="$c_h CREATE TABLE host ("
c_h="$c_h Host char(60) DEFAULT '' NOT NULL,"
c_h="$c_h Db char(64) DEFAULT '' NOT NULL,"
c_h="$c_h Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h PRIMARY KEY Host (Host,Db)"
c_h="$c_h )"
c_h="$c_h comment='Host privileges; Merged with database privileges';"
fi
if test ! -f $mdata/user.frm
then
c_u="$c_u CREATE TABLE user ("
c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL,"
c_u="$c_u User char(16) binary DEFAULT '' NOT NULL,"
c_u="$c_u Password char(45) binary DEFAULT '' NOT NULL,"
c_u="$c_u Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Process_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u File_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Super_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL,"
c_u="$c_u ssl_cipher BLOB NOT NULL,"
c_u="$c_u x509_issuer BLOB NOT NULL,"
c_u="$c_u x509_subject BLOB NOT NULL,"
c_u="$c_u max_questions int(11) unsigned DEFAULT 0 NOT NULL,"
c_u="$c_u max_updates int(11) unsigned DEFAULT 0 NOT NULL,"
c_u="$c_u max_connections int(11) unsigned DEFAULT 0 NOT NULL,"
c_u="$c_u PRIMARY KEY Host (Host,User)"
c_u="$c_u )"
c_u="$c_u comment='Users and global privileges';"
i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
INSERT INTO user (host,user) values ('localhost','');
INSERT INTO user (host,user) values ('$hostname','');"
fi
if test ! -f $mdata/func.frm
then
c_f="$c_f CREATE TABLE func ("
c_f="$c_f name char(64) DEFAULT '' NOT NULL,"
c_f="$c_f ret tinyint(1) DEFAULT '0' NOT NULL,"
c_f="$c_f dl char(128) DEFAULT '' NOT NULL,"
c_f="$c_f type enum ('function','aggregate') NOT NULL,"
c_f="$c_f PRIMARY KEY (name)"
c_f="$c_f )"
c_f="$c_f comment='User defined functions';"
fi
if test ! -f $mdata/tables_priv.frm
then
c_t="$c_t CREATE TABLE tables_priv ("
c_t="$c_t Host char(60) DEFAULT '' NOT NULL,"
c_t="$c_t Db char(64) DEFAULT '' NOT NULL,"
c_t="$c_t User char(16) DEFAULT '' NOT NULL,"
c_t="$c_t Table_name char(60) DEFAULT '' NOT NULL,"
c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
c_t="$c_t Timestamp timestamp(14),"
c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,"
c_t="$c_t Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name),"
c_t="$c_t KEY Grantor (Grantor)"
c_t="$c_t )"
c_t="$c_t comment='Table privileges';"
fi
if test ! -f $mdata/columns_priv.frm
then
c_c="$c_c CREATE TABLE columns_priv ("
c_c="$c_c Host char(60) DEFAULT '' NOT NULL,"
c_c="$c_c Db char(64) DEFAULT '' NOT NULL,"
c_c="$c_c User char(16) DEFAULT '' NOT NULL,"
c_c="$c_c Table_name char(64) DEFAULT '' NOT NULL,"
c_c="$c_c Column_name char(64) DEFAULT '' NOT NULL,"
c_c="$c_c Timestamp timestamp(14),"
c_c="$c_c Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)"
c_c="$c_c )"
c_c="$c_c comment='Column privileges';"
fi
if test ! -f $mdata/help_topic.frm
then
c_hl="$c_hl CREATE TABLE help_topic ("
c_hl="$c_hl help_topic_id int unsigned not null auto_increment,"
c_hl="$c_hl name varchar(64) not null,"
c_hl="$c_hl description text not null,"
c_hl="$c_hl example text not null,"
c_hl="$c_hl url varchar(128) not null,"
c_hl="$c_hl primary key (help_topic_id),"
c_hl="$c_hl unique index (name)"
c_hl="$c_hl )"
c_hl="$c_hl comment='help topics';"
fi
if test ! -f $mdata/help_category.frm
then
c_clr="$c_clr CREATE TABLE help_category ("
c_clr="$c_clr help_category_id smallint unsigned not null auto_increment,"
c_clr="$c_clr name varchar(64) not null,"
c_clr="$c_clr url varchar(128) not null,"
c_clr="$c_clr primary key (help_category_id),"
c_clr="$c_clr unique index (name)"
c_clr="$c_clr )"
c_clr="$c_clr comment='help topics-categories relation';"
fi
if test ! -f $mdata/help_relation.frm
then
c_hc="$c_hc CREATE TABLE help_relation ("
c_hc="$c_hc help_topic_id int unsigned not null references help_topic,"
c_hc="$c_hc help_category_id smallint unsigned not null references help_category,"
c_hc="$c_hc primary key (help_category_id, help_topic_id),"
c_hc="$c_hc )"
c_hc="$c_hc comment='categories of help topics';"
fi
mysqld_boot=" $execdir/mysqld --no-defaults --bootstrap --skip-grant-tables \
--basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb $EXTRA_ARG"
echo "running $mysqld_boot"
if $mysqld_boot << END_OF_DATA
use mysql;
$c_d
$i_d
$c_h
$i_h
$c_u
$i_u
$c_f
$i_f
$c_t
$c_c
$c_hl
$c_hc
$c_clr
END_OF_DATA
if $scriptdir/mysql_create_system_tables test $mdata $hostname | $mysqld_boot
then
exit 0
else
......
......@@ -28,6 +28,19 @@ cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME)
select cast("1:2:3" as TIME);
cast("1:2:3" as TIME)
01:02:03
select cast(_latin1'test' as char character set latin2);
cast(_latin1'test' as char character set latin2)
test
select cast(_koi8r'' as char character set cp1251);
cast(_koi8r'' as char character set cp1251)
create table t1 select cast(_koi8r'' as char character set cp1251) as t;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`t` char(4) character set cp1251 NOT NULL default ''
) TYPE=MyISAM CHARSET=latin1
drop table t1;
select cast("2001-1-1" as date) = "2001-01-01";
cast("2001-1-1" as date) = "2001-01-01"
0
......
......@@ -4,6 +4,7 @@ columns_priv
db
func
help_category
help_keyword
help_relation
help_topic
host
......@@ -19,6 +20,7 @@ columns_priv
db
func
help_category
help_keyword
help_relation
help_topic
host
......@@ -34,6 +36,7 @@ columns_priv
db
func
help_category
help_keyword
help_relation
help_topic
host
......
This diff is collapsed.
......@@ -13,6 +13,15 @@ select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
select cast("1:2:3" as TIME);
#
# Character set convertion
#
select cast(_latin1'test' as char character set latin2);
select cast(_koi8r'' as char character set cp1251);
create table t1 select cast(_koi8r'' as char character set cp1251) as t;
show create table t1;
drop table t1;
#
# The following should be fixed in 4.1
#
......
-- source include/have_innodb.inc
truncate mysql.help_topic;
truncate mysql.help_category;
truncate mysql.help_relation;
insert into mysql.help_topic(name,description,example)values('impossible_function_1','description of \n impossible_function1','example of \n impossible_function1');
SELECT @topic1_id:=LAST_INSERT_ID();
insert into mysql.help_topic(name,description,example)values('impossible_function_2','description of \n impossible_function2','example of \n impossible_function2');
SELECT @topic2_id:=LAST_INSERT_ID();
insert into mysql.help_topic(name,description,example)values('impossible_function_3','description of \n impossible_function3','example of \n impossible_function3');
SELECT @topic3_id:=LAST_INSERT_ID();
insert into mysql.help_category(name)values('impossible_category_1');
SELECT @category1_id:=LAST_INSERT_ID();
insert into mysql.help_category(name)values('impossible_category_2');
SELECT @category2_id:=LAST_INSERT_ID();
insert into mysql.help_relation(help_category_id,help_topic_id)values(@category1_id,@topic1_id);
insert into mysql.help_relation(help_category_id,help_topic_id)values(@category1_id,@topic2_id);
insert into mysql.help_relation(help_category_id,help_topic_id)values(@category2_id,@topic2_id);
insert into mysql.help_relation(help_category_id,help_topic_id)values(@category2_id,@topic3_id);
# category: topic: keyword:
#
# impossible_category_1
# impossible_function_1
# impossible_function_5
# impossible_function_2
# impossible_function_1
# impossible_category_2
# impossible_function_3
# impossible_function_6
# impossible_function_4
# impossible_function_6
# impossible_category_3
# impossible_function_7
insert into mysql.help_category(help_category_id,name)values(1,'impossible_category_1');
select @category1_id:= 1;
insert into mysql.help_category(help_category_id,name)values(2,'impossible_category_2');
select @category2_id:= 2;
insert into mysql.help_category(help_category_id,name,parent_category_id)values(3,'impossible_category_3',@category2_id);
select @category3_id:= 3;
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(1,'impossible_function_1',@category1_id,'description of \n impossible_function1\n','example of \n impossible_function1');
select @topic1_id:= 1;
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(2,'impossible_function_2',@category1_id,'description of \n impossible_function2\n','example of \n impossible_function2');
select @topic2_id:= 2;
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(3,'impossible_function_3',@category2_id,'description of \n impossible_function3\n','example of \n impossible_function3');
select @topic3_id:= 3;
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(4,'impossible_function_4',@category2_id,'description of \n impossible_function4\n','example of \n impossible_function4');
select @topic4_id:= 4;
insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(5,'impossible_function_7',@category3_id,'description of \n impossible_function5\n','example of \n impossible_function7');
select @topic5_id:= 5;
insert into mysql.help_keyword(help_keyword_id,name)values(1,'impossible_function_1');
select @keyword1_id:= 1;
insert into mysql.help_keyword(help_keyword_id,name)values(2,'impossible_function_5');
select @keyword2_id:= 2;
insert into mysql.help_keyword(help_keyword_id,name)values(3,'impossible_function_6');
select @keyword3_id:= 3;
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword1_id,@topic2_id);
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword2_id,@topic1_id);
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic3_id);
insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic4_id);
##############
help 'function_of_my_dream';
help '%possible_f%';
help 'impossible_func%';
help 'impossible_category%';
help 'impossible_%';
help '%function_1';
help '%function_2';
help '%function_3';
help '%function_4';
help '%function_5';
help '%function_6';
help '%function_7';
help '%category_2';
help 'impossible_function_1';
help 'impossible_category_1';
##############
alter table mysql.help_relation type=innodb;
alter table mysql.help_keyword type=innodb;
alter table mysql.help_topic type=innodb;
alter table mysql.help_category type=innodb;
alter table mysql.help_relation type=innodb;
##############
help 'function_of_my_dream';
help '%ble_f%';
help '%possible_f%';
help 'impossible_func%';
help 'impossible_category%';
help 'impossible_%';
help '%function_1';
help '%function_2';
help '%function_3';
help '%function_4';
help '%function_5';
help '%function_6';
help '%function_7';
help '%category_2';
help 'impossible_function_1';
help 'impossible_category_1';
##############
alter table mysql.help_relation type=myisam;
alter table mysql.help_keyword type=myisam;
alter table mysql.help_topic type=myisam;
alter table mysql.help_category type=myisam;
alter table mysql.help_relation type=myisam;
delete from mysql.help_topic where help_topic_id=@topic1_id;
delete from mysql.help_topic where help_topic_id=@topic2_id;
delete from mysql.help_topic where help_topic_id=@topic3_id;
delete from mysql.help_topic where help_topic_id=@topic4_id;
delete from mysql.help_topic where help_topic_id=@topic5_id;
delete from mysql.help_category where help_category_id=@category3_id;
delete from mysql.help_category where help_category_id=@category2_id;
delete from mysql.help_category where help_category_id=@category1_id;
delete from mysql.help_keyword where help_keyword_id=@keyword1_id;
delete from mysql.help_keyword where help_keyword_id=@keyword2_id;
delete from mysql.help_keyword where help_keyword_id=@keyword3_id;
delete from mysql.help_relation where help_keyword_id=@keyword1_id and help_topic_id=@topic2_id;
delete from mysql.help_relation where help_keyword_id=@keyword2_id and help_topic_id=@topic1_id;
delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic3_id;
delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic4_id;
......@@ -32,7 +32,9 @@ bin_SCRIPTS = @server_scripts@ \
mysqldumpslow \
mysql_explain_log \
mysql_tableinfo \
mysqld_multi
mysqld_multi \
fill_help_tables \
mysql_create_system_tables
EXTRA_SCRIPTS = make_binary_distribution.sh \
make_win_src_distribution.sh \
......@@ -54,14 +56,13 @@ EXTRA_SCRIPTS = make_binary_distribution.sh \
mysqld_multi.sh \
mysql_tableinfo.sh \
mysqld_safe.sh \
fill_help_tables.sh
fill_help_tables.sh \
mysql_create_system_tables.sh
EXTRA_DIST = $(EXTRA_SCRIPTS) \
mysqlaccess.conf \
mysqlbug
pkgdata_DATA = fill_help_tables.sql
# mysqlbug should be distributed built so that people can report build
# failures with it.
CLEANFILES = @server_scripts@ \
......@@ -81,7 +82,7 @@ CLEANFILES = @server_scripts@ \
mysqldumpslow \
mysqld_multi \
fill_help_tables \
fill_help_tables.sql
mysql_create_system_tables
SUPERCLEANFILES = mysqlbug
......@@ -137,12 +138,5 @@ SUFFIXES = .sh
# Don't update the files from bitkeeper
%::SCCS/s.%
all: fill_help_tables.sql make_win_src_distribution make_binary_distribution
# The following rule is here to ensure that build will continue
# even if we don't have perl installed. In this case the help tables
# will be empty
all: make_win_src_distribution make_binary_distribution
fill_help_tables.sql: fill_help_tables ../Docs/manual.texi
-./fill_help_tables < ../Docs/manual.texi > fill_help_tables.sql
echo "" >> fill_help_tables.sql
This diff is collapsed.
This diff is collapsed.
......@@ -87,7 +87,7 @@ if test -z "$basedir"
then
basedir=@prefix@
bindir=@bindir@
execdir=@libexecdir@
execdir=@libexecdir@
pkgdatadir=@pkgdatadir@
else
bindir="$basedir/bin"
......@@ -100,24 +100,24 @@ else
else
execdir="$basedir/bin"
fi
# find fill_help_tables.sh
for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts @pkgdatadir@
do
if test -f $i/fill_help_tables.sql
then
pkgdatadir=$i
fi
done
fi
# find fill_help_tables.sh
for i in $basedir/support-files $basedir/share $basedir/share/mysql $basedir/scripts `pwd` @pkgdatadir@
do
if test -f $i/fill_help_tables.sql
then
pkgdatadir=$i
fi
done
if test -f $pkgdatadir/fill_help_tables.sql
then
fill_help_tables=$pkgdatadir/fill_help_tables.sql
else
if test $verbose -eq 1
then
echo "Could not find help file 'fill_help_tables.sql'".
echo "Could not find help file 'fill_help_tables.sql' ;$pkgdatadir; ;$basedir;".
fi
fi
......@@ -172,205 +172,21 @@ fi
chown $user $ldata $ldata/mysql $ldata/test;
fi
# Initialize variables
c_d="" i_d=""
c_h="" i_h=""
c_u="" i_u=""
c_f="" i_f=""
c_t="" c_c=""
# Check for old tables
if test ! -f $mdata/db.frm
then
if test $verbose -eq 1 ; then
echo "Preparing db table"
fi
# mysqld --bootstrap wants one command/line
c_d="$c_d CREATE TABLE db ("
c_d="$c_d Host char(60) binary DEFAULT '' NOT NULL,"
c_d="$c_d Db char(64) binary DEFAULT '' NOT NULL,"
c_d="$c_d User char(16) binary DEFAULT '' NOT NULL,"
c_d="$c_d Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_d="$c_d PRIMARY KEY Host (Host,Db,User),"
c_d="$c_d KEY User (User)"
c_d="$c_d )"
c_d="$c_d comment='Database privileges';"
i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');"
fi
if test ! -f $mdata/host.frm
then
if test $verbose -eq 1 ; then
echo "Preparing host table"
fi
c_h="$c_h CREATE TABLE host ("
c_h="$c_h Host char(60) binary DEFAULT '' NOT NULL,"
c_h="$c_h Db char(64) binary DEFAULT '' NOT NULL,"
c_h="$c_h Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_h="$c_h PRIMARY KEY Host (Host,Db)"
c_h="$c_h )"
c_h="$c_h comment='Host privileges; Merged with database privileges';"
c_d="yes"
fi
if test ! -f $mdata/user.frm
if test $verbose -eq 1
then
if test $verbose -eq 1 ; then
echo "Preparing user table"
fi
c_u="$c_u CREATE TABLE user ("
c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL,"
c_u="$c_u User char(16) binary DEFAULT '' NOT NULL,"
c_u="$c_u Password char(45) binary DEFAULT '' NOT NULL,"
c_u="$c_u Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Process_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u File_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Super_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL,"
c_u="$c_u ssl_cipher BLOB NOT NULL,"
c_u="$c_u x509_issuer BLOB NOT NULL,"
c_u="$c_u x509_subject BLOB NOT NULL,"
c_u="$c_u max_questions int(11) unsigned DEFAULT 0 NOT NULL,"
c_u="$c_u max_updates int(11) unsigned DEFAULT 0 NOT NULL,"
c_u="$c_u max_connections int(11) unsigned DEFAULT 0 NOT NULL,"
c_u="$c_u PRIMARY KEY Host (Host,User)"
c_u="$c_u )"
c_u="$c_u comment='Users and global privileges';"
i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
REPLACE INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
INSERT INTO user (host,user) values ('localhost','');
"
if test "$windows" -eq 0
then
i_u="$i_u INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
REPLACE INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
INSERT INTO user (host,user) values ('$hostname','');"
fi
fi
if test ! -f $mdata/func.frm
then
if test $verbose -eq 1 ; then
echo "Preparing func table"
fi
c_f="$c_f CREATE TABLE func ("
c_f="$c_f name char(64) binary DEFAULT '' NOT NULL,"
c_f="$c_f ret tinyint(1) DEFAULT '0' NOT NULL,"
c_f="$c_f dl char(128) DEFAULT '' NOT NULL,"
c_f="$c_f type enum ('function','aggregate') NOT NULL,"
c_f="$c_f PRIMARY KEY (name)"
c_f="$c_f )"
c_f="$c_f comment='User defined functions';"
fi
if test ! -f $mdata/tables_priv.frm
then
if test $verbose -eq 1 ; then
echo "Preparing tables_priv table"
fi
c_t="$c_t CREATE TABLE tables_priv ("
c_t="$c_t Host char(60) binary DEFAULT '' NOT NULL,"
c_t="$c_t Db char(64) binary DEFAULT '' NOT NULL,"
c_t="$c_t User char(16) binary DEFAULT '' NOT NULL,"
c_t="$c_t Table_name char(60) binary DEFAULT '' NOT NULL,"
c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
c_t="$c_t Timestamp timestamp(14),"
c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,"
c_t="$c_t Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name),"
c_t="$c_t KEY Grantor (Grantor)"
c_t="$c_t )"
c_t="$c_t comment='Table privileges';"
fi
if test ! -f $mdata/columns_priv.frm
then
if test $verbose -eq 1 ; then
echo "Preparing columns_priv table"
fi
c_c="$c_c CREATE TABLE columns_priv ("
c_c="$c_c Host char(60) binary DEFAULT '' NOT NULL,"
c_c="$c_c Db char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c User char(16) binary DEFAULT '' NOT NULL,"
c_c="$c_c Table_name char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c Column_name char(64) binary DEFAULT '' NOT NULL,"
c_c="$c_c Timestamp timestamp(14),"
c_c="$c_c Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)"
c_c="$c_c )"
c_c="$c_c comment='Column privileges';"
create_option="verbose"
else
create_option="real"
fi
echo "Installing privilege tables"
echo "Installing all prepared tables"
if (
cat << END_OF_DATA
use mysql;
$c_d
$i_d
$c_h
$i_h
$c_u
$i_u
$c_f
$i_f
$c_t
$c_c
END_OF_DATA
mysql_create_system_tables $create_option $mdata $hostname $windows
if test -n "$fill_help_tables"
then
cat $fill_help_tables
......
......@@ -457,13 +457,16 @@ Item *create_load_file(Item* a)
}
Item *create_func_cast(Item *a, Item_cast cast_type)
Item *create_func_cast(Item *a, Item_cast cast_type, CHARSET_INFO *cs)
{
Item *res;
LINT_INIT(res);
switch (cast_type) {
case ITEM_CAST_BINARY: res= new Item_func_binary(a); break;
case ITEM_CAST_CHAR: res= new Item_char_typecast(a); break;
case ITEM_CAST_CHAR:
res= (cs == NULL) ? (Item*) new Item_char_typecast(a) :
(Item*) new Item_func_conv_charset(a,cs);
break;
case ITEM_CAST_SIGNED_INT: res= new Item_func_signed(a); break;
case ITEM_CAST_UNSIGNED_INT: res= new Item_func_unsigned(a); break;
case ITEM_CAST_DATE: res= new Item_date_typecast(a); break;
......
......@@ -28,7 +28,7 @@ Item *create_func_bit_length(Item* a);
Item *create_func_coercibility(Item* a);
Item *create_func_ceiling(Item* a);
Item *create_func_char_length(Item* a);
Item *create_func_cast(Item *a, Item_cast cast_type);
Item *create_func_cast(Item *a, Item_cast cast_type, CHARSET_INFO *cs);
Item *create_func_connection_id(void);
Item *create_func_conv(Item* a, Item *b, Item *c);
Item *create_func_cos(Item* a);
......
......@@ -877,6 +877,7 @@ bool check_db_name(char *db);
bool check_column_name(const char *name);
bool check_table_name(const char *name, uint length);
char *get_field(MEM_ROOT *mem, Field *field);
bool get_field(MEM_ROOT *mem, Field *field, class String *res);
int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr);
/* from hostname.cc */
......
......@@ -300,7 +300,7 @@ char* log_error_file_ptr= log_error_file;
char mysql_real_data_home[FN_REFLEN],
language[LIBLEN],reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file;
char *language_ptr, *default_collation_name;
char *language_ptr, *default_collation_name, *default_character_set_name;
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION;
char *mysql_unix_port, *opt_mysql_tmpdir;
......@@ -2028,7 +2028,7 @@ static int init_common_variables(const char *conf_file_name, int argc,
#ifdef USE_REGEX
regex_init(&my_charset_latin1);
#endif
if (!(default_charset_info= get_charset_by_csname(sys_charset.value,
if (!(default_charset_info= get_charset_by_csname(default_character_set_name,
MY_CS_PRIMARY,
MYF(MY_WME))))
return 1;
......@@ -2046,6 +2046,8 @@ static int init_common_variables(const char *conf_file_name, int argc,
}
default_charset_info= default_collation;
}
global_system_variables.character_set_server= default_charset_info;
global_system_variables.character_set_database= default_charset_info;
global_system_variables.character_set_results= NULL;
global_system_variables.character_set_client= default_charset_info;
global_system_variables.collation_connection= default_charset_info;
......@@ -3542,8 +3544,8 @@ Disable with --skip-bdb (will save memory)",
0, 0, 0, 0, 0, 0},
#endif /* HAVE_OPENSSL */
{"default-character-set", 'C', "Set the default character set",
(gptr*) &sys_charset.value, (gptr*) &sys_charset.value, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
(gptr*) &default_character_set_name, (gptr*) &default_character_set_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation",
(gptr*) &default_collation_name, (gptr*) &default_collation_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
......@@ -4538,7 +4540,7 @@ static void use_help(void)
static void usage(void)
{
if (!(default_charset_info= get_charset_by_csname(sys_charset.value,
if (!(default_charset_info= get_charset_by_csname(default_character_set_name,
MY_CS_PRIMARY,
MYF(MY_WME))))
exit(1);
......@@ -4642,7 +4644,6 @@ static void mysql_init_variables(void)
pidfile_name_ptr= pidfile_name;
log_error_file_ptr= log_error_file;
language_ptr= language;
default_collation_name= 0;
mysql_data_home= mysql_real_data_home;
thd_startup_options= (OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL |
OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE);
......@@ -4681,10 +4682,13 @@ static void mysql_init_variables(void)
/* Variables in libraries */
charsets_dir= 0;
sys_charset.value= (char*) MYSQL_CHARSET;
default_character_set_name= (char*) MYSQL_DEFAULT_CHARSET_NAME;
default_collation_name= (char*) MYSQL_DEFAULT_COLLATION_NAME;
sys_charset_system.value= (char*) system_charset_info->csname;
/* Set default values for some option variables */
global_system_variables.character_set_server= default_charset_info;
global_system_variables.character_set_database= default_charset_info;
global_system_variables.character_set_results= NULL;
global_system_variables.character_set_client= default_charset_info;
global_system_variables.collation_connection= default_charset_info;
......
......@@ -60,6 +60,8 @@ class Protocol
{ return store_longlong((longlong) from, 0); }
inline bool store(ulonglong from)
{ return store_longlong((longlong) from, 1); }
inline bool store(String *str)
{ return store(str->c_ptr(),str->length(),str->charset()); }
virtual bool prepare_for_send(List<Item> *item_list)
{
......
......@@ -103,15 +103,14 @@ sys_var_long_ptr sys_binlog_cache_size("binlog_cache_size",
&binlog_cache_size);
sys_var_thd_ulong sys_bulk_insert_buff_size("bulk_insert_buffer_size",
&SV::bulk_insert_buff_size);
sys_var_str sys_charset("character_set_server",
sys_check_charset,
sys_update_charset,
sys_set_default_charset);
sys_var_str sys_charset_system("character_set_system",
sys_var_character_set_server sys_character_set_server("character_set_server");
sys_var_str sys_charset_system("character_set_system",
sys_check_charset,
sys_update_charset,
sys_set_default_charset);
sys_var_character_set_database sys_character_set_database("character_set_database");
sys_var_character_set_client sys_character_set_client("character_set_client");
sys_var_character_set_connection sys_character_set_connection("character_set_connection");
sys_var_character_set_results sys_character_set_results("character_set_results");
sys_var_collation_connection sys_collation_connection("collation_connection");
sys_var_bool_ptr sys_concurrent_insert("concurrent_insert",
......@@ -362,7 +361,10 @@ sys_var *sys_variables[]=
&sys_binlog_cache_size,
&sys_buffer_results,
&sys_bulk_insert_buff_size,
&sys_character_set_server,
&sys_character_set_database,
&sys_character_set_client,
&sys_character_set_connection,
&sys_character_set_results,
&sys_collation_connection,
&sys_concurrent_insert,
......@@ -481,9 +483,11 @@ struct show_var_st init_vars[]= {
#endif
{sys_binlog_cache_size.name,(char*) &sys_binlog_cache_size, SHOW_SYS},
{sys_bulk_insert_buff_size.name,(char*) &sys_bulk_insert_buff_size,SHOW_SYS},
{sys_charset.name, (char*) &sys_charset, SHOW_SYS},
{sys_character_set_server.name, (char*) &sys_character_set_server,SHOW_SYS},
{sys_charset_system.name, (char*) &sys_charset_system, SHOW_SYS},
{sys_character_set_database.name, (char*) &sys_character_set_database,SHOW_SYS},
{sys_character_set_client.name,(char*) &sys_character_set_client,SHOW_SYS},
{sys_character_set_connection.name,(char*) &sys_character_set_connection,SHOW_SYS},
{sys_character_set_results.name,(char*) &sys_character_set_results, SHOW_SYS},
{sys_collation_connection.name,(char*) &sys_collation_connection, SHOW_SYS},
{sys_concurrent_insert.name,(char*) &sys_concurrent_insert, SHOW_SYS},
......@@ -1276,9 +1280,15 @@ bool sys_var_character_set::check(THD *thd, set_var *var)
String str(buff,sizeof(buff), system_charset_info), *res;
if (!(res=var->value->val_str(&str)))
res= &empty_string;
if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) &&
{
if (!nullable)
{
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), "NULL");
return 1;
}
tmp= NULL;
}
else if (!(tmp=get_charset_by_csname(res->c_ptr(),MY_CS_PRIMARY,MYF(0))) &&
!(tmp=get_old_charset_by_name(res->c_ptr())))
{
my_error(ER_UNKNOWN_CHARACTER_SET, MYF(0), res->c_ptr());
......@@ -1288,23 +1298,44 @@ bool sys_var_character_set::check(THD *thd, set_var *var)
return 0;
}
bool sys_var_character_set_client::update(THD *thd, set_var *var)
bool sys_var_character_set::update(THD *thd, set_var *var)
{
if (var->type == OPT_GLOBAL)
global_system_variables.character_set_client= var->save_result.charset;
else
thd->variables.character_set_client= var->save_result.charset;
ci_ptr(thd,var->type)[0]= var->save_result.charset;
return 0;
}
byte *sys_var_character_set_client::value_ptr(THD *thd, enum_var_type type)
byte *sys_var_character_set::value_ptr(THD *thd, enum_var_type type)
{
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
global_system_variables.character_set_client :
thd->variables.character_set_client);
CHARSET_INFO *cs= ci_ptr(thd,type)[0];
return cs ? (byte*) cs->csname : (byte*) "NULL";
}
CHARSET_INFO ** sys_var_character_set_connection::ci_ptr(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
return &global_system_variables.collation_connection;
else
return &thd->variables.collation_connection;
}
void sys_var_character_set_connection::set_default(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
global_system_variables.collation_connection= default_charset_info;
else
thd->variables.collation_connection= global_system_variables.collation_connection;
}
CHARSET_INFO ** sys_var_character_set_client::ci_ptr(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
return &global_system_variables.character_set_client;
else
return &thd->variables.character_set_client;
}
void sys_var_character_set_client::set_default(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
......@@ -1313,58 +1344,81 @@ void sys_var_character_set_client::set_default(THD *thd, enum_var_type type)
thd->variables.character_set_client= global_system_variables.character_set_client;
}
bool sys_var_collation_connection::update(THD *thd, set_var *var)
CHARSET_INFO ** sys_var_character_set_results::ci_ptr(THD *thd, enum_var_type type)
{
if (var->type == OPT_GLOBAL)
global_system_variables.collation_connection= var->save_result.charset;
if (type == OPT_GLOBAL)
return &global_system_variables.character_set_results;
else
thd->variables.collation_connection= var->save_result.charset;
return 0;
return &thd->variables.character_set_results;
}
byte *sys_var_collation_connection::value_ptr(THD *thd, enum_var_type type)
void sys_var_character_set_results::set_default(THD *thd, enum_var_type type)
{
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
global_system_variables.collation_connection :
thd->variables.collation_connection);
return cs ? (byte*) cs->name : (byte*) "NULL";
if (type == OPT_GLOBAL)
global_system_variables.character_set_results= NULL;
else
thd->variables.character_set_results= global_system_variables.character_set_results;
}
void sys_var_collation_connection::set_default(THD *thd, enum_var_type type)
CHARSET_INFO ** sys_var_character_set_server::ci_ptr(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
return &global_system_variables.character_set_server;
else
return &thd->variables.character_set_server;
}
void sys_var_character_set_server::set_default(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
global_system_variables.collation_connection= default_charset_info;
global_system_variables.character_set_server= default_charset_info;
else
thd->variables.collation_connection= global_system_variables.collation_connection;
thd->variables.character_set_server= global_system_variables.character_set_server;
}
CHARSET_INFO ** sys_var_character_set_database::ci_ptr(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
return &global_system_variables.character_set_database;
else
return &thd->variables.character_set_database;
}
bool sys_var_character_set_results::update(THD *thd, set_var *var)
void sys_var_character_set_database::set_default(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
global_system_variables.character_set_database= default_charset_info;
else
thd->variables.character_set_database= thd->db_charset;
}
bool sys_var_collation_connection::update(THD *thd, set_var *var)
{
if (var->type == OPT_GLOBAL)
global_system_variables.character_set_results= var->save_result.charset;
global_system_variables.collation_connection= var->save_result.charset;
else
thd->variables.character_set_results= var->save_result.charset;
thd->variables.collation_connection= var->save_result.charset;
return 0;
}
byte *sys_var_character_set_results::value_ptr(THD *thd, enum_var_type type)
byte *sys_var_collation_connection::value_ptr(THD *thd, enum_var_type type)
{
CHARSET_INFO *cs= ((type == OPT_GLOBAL) ?
global_system_variables.character_set_results :
thd->variables.character_set_results);
return cs ? (byte*) cs->csname : (byte*) "NULL";
global_system_variables.collation_connection :
thd->variables.collation_connection);
return cs ? (byte*) cs->name : (byte*) "NULL";
}
void sys_var_character_set_results::set_default(THD *thd, enum_var_type type)
void sys_var_collation_connection::set_default(THD *thd, enum_var_type type)
{
if (type == OPT_GLOBAL)
global_system_variables.character_set_results= NULL;
global_system_variables.collation_connection= default_charset_info;
else
thd->variables.character_set_results= global_system_variables.character_set_results;
thd->variables.collation_connection= global_system_variables.collation_connection;
}
/*****************************************************************************
Functions to handle SET NAMES and SET CHARACTER SET
*****************************************************************************/
......
......@@ -433,7 +433,9 @@ SHOW_TYPE type() { return SHOW_CHAR; }
class sys_var_character_set :public sys_var_thd
{
public:
sys_var_character_set(const char *name_arg) :sys_var_thd(name_arg) {}
bool nullable;
sys_var_character_set(const char *name_arg) :sys_var_thd(name_arg)
{ nullable= 0; }
bool check(THD *thd, set_var *var);
SHOW_TYPE type() { return SHOW_CHAR; }
bool check_update_type(Item_result type)
......@@ -441,7 +443,10 @@ SHOW_TYPE type() { return SHOW_CHAR; }
return type != STRING_RESULT; /* Only accept strings */
}
bool check_default(enum_var_type type) { return 0; }
bool update(THD *thd, set_var *var);
byte *value_ptr(THD *thd, enum_var_type type);
virtual void set_default(THD *thd, enum_var_type type)= 0;
virtual CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0;
};
class sys_var_character_set_client :public sys_var_character_set
......@@ -449,19 +454,45 @@ class sys_var_character_set_client :public sys_var_character_set
public:
sys_var_character_set_client(const char *name_arg) :
sys_var_character_set(name_arg) {}
bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type);
byte *value_ptr(THD *thd, enum_var_type type);
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
};
class sys_var_character_set_results :public sys_var_character_set
{
public:
sys_var_character_set_results(const char *name_arg) :
sys_var_character_set(name_arg)
{ nullable= 1; }
void set_default(THD *thd, enum_var_type type);
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
};
class sys_var_character_set_server :public sys_var_character_set
{
public:
sys_var_character_set_server(const char *name_arg) :
sys_var_character_set(name_arg) {}
bool update(THD *thd, set_var *var);
void set_default(THD *thd, enum_var_type type);
byte *value_ptr(THD *thd, enum_var_type type);
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
};
class sys_var_character_set_database :public sys_var_character_set
{
public:
sys_var_character_set_database(const char *name_arg) :
sys_var_character_set(name_arg) {}
void set_default(THD *thd, enum_var_type type);
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
};
class sys_var_character_set_connection :public sys_var_character_set
{
public:
sys_var_character_set_connection(const char *name_arg) :
sys_var_character_set(name_arg) {}
void set_default(THD *thd, enum_var_type type);
CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type);
};
class sys_var_collation_connection :public sys_var_collation
......@@ -606,6 +637,5 @@ sys_var *find_sys_var(const char *str, uint length=0);
int sql_set_variables(THD *thd, List<set_var_base> *var_list);
void fix_delay_key_write(THD *thd, enum_var_type type);
extern sys_var_str sys_charset;
extern sys_var_str sys_charset_system;
CHARSET_INFO *get_old_charset_by_name(const char *old_name);
......@@ -2311,7 +2311,7 @@ int mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
DBUG_ENTER("mysql_create_index");
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type=DB_TYPE_DEFAULT;
create_info.table_charset= thd->db_charset;
create_info.table_charset= thd->variables.character_set_database;
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
&create_info, table_list,
fields, keys, drop, alter, 0, (ORDER*)0, FALSE,
......@@ -2328,7 +2328,7 @@ int mysql_drop_index(THD *thd, TABLE_LIST *table_list, List<Alter_drop> &drop)
DBUG_ENTER("mysql_drop_index");
bzero((char*) &create_info,sizeof(create_info));
create_info.db_type=DB_TYPE_DEFAULT;
create_info.table_charset= thd->db_charset;
create_info.table_charset= thd->variables.character_set_database;
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->real_name,
&create_info, table_list,
fields, keys, drop, alter, 0, (ORDER*)0, FALSE,
......
......@@ -109,7 +109,7 @@ THD::THD():user_time(0), is_fatal_error(0),
file_id = 0;
cond_count=0;
warn_id= 0;
db_charset=default_charset_info;
db_charset= global_system_variables.character_set_database;
mysys_var=0;
#ifndef DBUG_OFF
dbug_sentry=THD_SENTRY_MAGIC;
......
......@@ -386,6 +386,8 @@ struct system_variables
my_bool low_priority_updates;
my_bool new_mode;
CHARSET_INFO *character_set_server;
CHARSET_INFO *character_set_database;
CHARSET_INFO *character_set_client;
CHARSET_INFO *character_set_results;
CHARSET_INFO *collation_connection;
......
......@@ -51,7 +51,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
1 Could not create file or write to it. Error sent through my_error()
*/
static bool write_db_opt(const char *path, HA_CREATE_INFO *create)
static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
{
register File file;
char buf[256]; // Should be enough for one option
......@@ -61,8 +61,9 @@ static bool write_db_opt(const char *path, HA_CREATE_INFO *create)
{
ulong length;
CHARSET_INFO *cs= (create && create->table_charset) ?
create->table_charset : default_charset_info;
length= my_sprintf(buf,(buf, "default-character-set=%s\n", cs->name));
create->table_charset :
thd->variables.character_set_database;
length= my_sprintf(buf,(buf, "default-character-set=%s\ndefault-collation=%s\n", cs->csname,cs->name));
/* Error is written by my_write */
if (!my_write(file,(byte*) buf, length, MYF(MY_NABP+MY_WME)))
......@@ -89,7 +90,7 @@ static bool write_db_opt(const char *path, HA_CREATE_INFO *create)
*/
static bool load_db_opt(const char *path, HA_CREATE_INFO *create)
static bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create)
{
File file;
char buf[256];
......@@ -98,7 +99,7 @@ static bool load_db_opt(const char *path, HA_CREATE_INFO *create)
uint nbytes;
bzero((char*) create,sizeof(*create));
create->table_charset= default_charset_info;
create->table_charset= global_system_variables.character_set_database;
if ((file=my_open(path, O_RDONLY | O_SHARE, MYF(0))) >= 0)
{
IO_CACHE cache;
......@@ -115,12 +116,18 @@ static bool load_db_opt(const char *path, HA_CREATE_INFO *create)
{
if (!strncmp(buf,"default-character-set", (pos-buf)))
{
if (strcmp(pos+1,"DEFAULT"))
if (!(create->table_charset=get_charset_by_csname(pos+1,
MY_CS_PRIMARY,
MYF(0))))
{
if (!(create->table_charset=get_charset_by_name(pos+1, MYF(0))))
{
sql_print_error(ER(ER_UNKNOWN_CHARACTER_SET),pos+1);
}
sql_print_error(ER(ER_UNKNOWN_CHARACTER_SET),pos+1);
}
}
else if (!strncmp(buf,"default-collation", (pos-buf)))
{
if (!(create->table_charset=get_charset_by_name(pos+1, MYF(0))))
{
sql_print_error(ER(ER_UNKNOWN_CHARACTER_SET),pos+1);
}
}
}
......@@ -197,7 +204,7 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
unpack_dirname(path, path);
strcat(path,MY_DB_OPT_FILE);
if (write_db_opt(path, create_info))
if (write_db_opt(thd, path, create_info))
{
/*
Could not create options file.
......@@ -270,7 +277,7 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
/* Check directory */
(void)sprintf(path,"%s/%s/%s", mysql_data_home, db, MY_DB_OPT_FILE);
fn_format(path, path, "", "", MYF(MY_UNPACK_FILENAME));
if ((error=write_db_opt(path, create_info)))
if ((error=write_db_opt(thd, path, create_info)))
goto exit;
/*
......@@ -280,7 +287,9 @@ int mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
if (thd->db && !strcmp(thd->db,db))
{
thd->db_charset= (create_info && create_info->table_charset) ?
create_info->table_charset : default_charset_info;
create_info->table_charset :
global_system_variables.character_set_database;
thd->variables.character_set_database= thd->db_charset;
}
mysql_update_log.write(thd,thd->query, thd->query_length);
......@@ -615,8 +624,11 @@ bool mysql_change_db(THD *thd, const char *name)
thd->db_access=db_access;
strmov(path+unpack_dirname(path,path), MY_DB_OPT_FILE);
load_db_opt(path, &create);
thd->db_charset= create.table_charset ? create.table_charset : default_charset_info;
load_db_opt(thd, path, &create);
thd->db_charset= create.table_charset ?
create.table_charset :
global_system_variables.character_set_database;
thd->variables.character_set_database= thd->db_charset;
DBUG_RETURN(0);
}
......@@ -674,7 +686,7 @@ int mysqld_show_create_db(THD *thd, char *dbname,
if (found_libchar)
path[length-1]= FN_LIBCHAR;
strmov(path+length, MY_DB_OPT_FILE);
load_db_opt(path, &create);
load_db_opt(thd, path, &create);
List<Item> field_list;
field_list.push_back(new Item_empty_string("Database",NAME_LEN));
......
This diff is collapsed.
......@@ -215,7 +215,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
info.handle_duplicates=handle_duplicates;
info.escape_char=escaped->length() ? (*escaped)[0] : INT_MAX;
READ_INFO read_info(file,tot_length,thd->db_charset,
READ_INFO read_info(file,tot_length,thd->variables.character_set_database,
*field_term,*ex->line_start, *ex->line_term, *enclosed,
info.escape_char, read_file_from_client, is_fifo);
if (read_info.error)
......
......@@ -481,7 +481,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
{
if (!sql_field->charset)
sql_field->charset = create_info->table_charset ?
create_info->table_charset : thd->db_charset;
create_info->table_charset :
thd->variables.character_set_database;
switch (sql_field->sql_type) {
case FIELD_TYPE_BLOB:
......
......@@ -848,7 +848,7 @@ create:
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.options=$2 | $4;
lex->create_info.db_type= (enum db_type) lex->thd->variables.table_type;
lex->create_info.table_charset= thd->db_charset;
lex->create_info.table_charset= thd->variables.character_set_database;
lex->name=0;
}
create2
......@@ -1536,7 +1536,7 @@ alter:
lex->select_lex.db=lex->name=0;
bzero((char*) &lex->create_info,sizeof(lex->create_info));
lex->create_info.db_type= DB_TYPE_DEFAULT;
lex->create_info.table_charset= thd->db_charset;
lex->create_info.table_charset= thd->variables.character_set_database;
lex->create_info.row_type= ROW_TYPE_NOT_USED;
lex->alter_keys_onoff=LEAVE_AS_IS;
lex->simple_alter=1;
......@@ -2233,10 +2233,12 @@ simple_expr:
$$= new Item_func_set_collation($2,new Item_string(binary_keyword,
6, &my_charset_latin1));
}
| CAST_SYM '(' expr AS cast_type ')' { $$= create_func_cast($3, $5); }
| CAST_SYM '(' expr AS cast_type ')'
{ $$= create_func_cast($3, $5, Lex->charset); }
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
{ $$= new Item_func_case(* $4, $2, $5 ); }
| CONVERT_SYM '(' expr ',' cast_type ')' { $$= create_func_cast($3, $5); }
| CONVERT_SYM '(' expr ',' cast_type ')'
{ $$= create_func_cast($3, $5, Lex->charset); }
| CONVERT_SYM '(' expr USING charset_name ')'
{ $$= new Item_func_conv_charset($3,$5); }
| CONVERT_SYM '(' expr ',' expr ',' expr ')'
......@@ -2645,15 +2647,15 @@ in_sum_expr:
};
cast_type:
BINARY { $$=ITEM_CAST_BINARY; }
| CHAR_SYM { $$=ITEM_CAST_CHAR; }
| SIGNED_SYM { $$=ITEM_CAST_SIGNED_INT; }
| SIGNED_SYM INT_SYM { $$=ITEM_CAST_SIGNED_INT; }
| UNSIGNED { $$=ITEM_CAST_UNSIGNED_INT; }
| UNSIGNED INT_SYM { $$=ITEM_CAST_UNSIGNED_INT; }
| DATE_SYM { $$=ITEM_CAST_DATE; }
| TIME_SYM { $$=ITEM_CAST_TIME; }
| DATETIME { $$=ITEM_CAST_DATETIME; }
BINARY { $$=ITEM_CAST_BINARY; Lex->charset= NULL; }
| CHAR_SYM opt_binary { $$=ITEM_CAST_CHAR; }
| SIGNED_SYM { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; }
| SIGNED_SYM INT_SYM { $$=ITEM_CAST_SIGNED_INT; Lex->charset= NULL; }
| UNSIGNED { $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; }
| UNSIGNED INT_SYM { $$=ITEM_CAST_UNSIGNED_INT; Lex->charset= NULL; }
| DATE_SYM { $$=ITEM_CAST_DATE; Lex->charset= NULL; }
| TIME_SYM { $$=ITEM_CAST_TIME; Lex->charset= NULL; }
| DATETIME { $$=ITEM_CAST_DATETIME; Lex->charset= NULL; }
;
expr_list:
......@@ -4437,7 +4439,7 @@ option_value:
THD *thd= YYTHD;
LEX *lex= Lex;
$2= $2 ? $2: global_system_variables.character_set_client;
lex->var_list.push_back(new set_var_collation_client($2,thd->db_charset,$2));
lex->var_list.push_back(new set_var_collation_client($2,thd->variables.character_set_database,$2));
}
| NAMES_SYM charset_name_or_default opt_collate
{
......
......@@ -1160,6 +1160,33 @@ rename_file_ext(const char * from,const char * to,const char * ext)
}
/*
Allocate string field in MEM_ROOT and return it as String
SYNOPSIS
get_field()
mem MEM_ROOT for allocating
field Field for retrieving of string
res result String
RETURN VALUES
true string is empty
false all ok
*/
bool get_field(MEM_ROOT *mem, Field *field, String *res)
{
char buff[MAX_FIELD_WIDTH];
String str(buff,sizeof(buff),&my_charset_bin);
field->val_str(&str,&str);
uint length=str.length();
if (!length)
return true;
char *to= strmake_root(mem, str.ptr(), length);
res->set(to,length,((Field_str*)field)->charset());
return false;
}
/*
Allocate string field in MEM_ROOT and return it as NULL-terminated string
......
......@@ -45,6 +45,13 @@
#include "m_string.h"
#include "m_ctype.h"
#else
#include <stdio.h>
#define uchar unsigned char
#endif
#ifdef HAVE_CHARSET_cp1250
......@@ -253,12 +260,6 @@ static uchar NEAR to_upper_win1250ch[] = {
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xff
};
#else
#include <stdio.h>
#define uchar unsigned char
#endif
static uchar NEAR sort_order_win1250ch[] = {
......@@ -289,7 +290,7 @@ static uchar NEAR _sort_order_win1250ch1[] = {
0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91,
/* 0 ord 48 0x30 */
0x92, 0x93, 0x94, 0x95, 0x95, 0x97, 0x98, 0x99,
0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
0x9a, 0x9b,
/* colon ord 58 0x3a */
0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1,
......
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