From 7e13ac1242b8e9f229b76687622bc1f5de301b92 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 29 Mar 2003 20:40:03 +0300 Subject: [PATCH 01/25] ft benchmark suite: initial checkin BitKeeper/etc/ignore: Added myisam/ftbench/data myisam/ftbench/t to the ignore list --- .bzrignore | 3 ++ myisam/ftbench/Ecompare.pl | 96 +++++++++++++++++++++++++++++++++++ myisam/ftbench/Ereport.pl | 53 +++++++++++++++++++ myisam/ftbench/ft-test-run.sh | 81 +++++++++++++++++++++++++++++ 4 files changed, 233 insertions(+) create mode 100755 myisam/ftbench/Ecompare.pl create mode 100755 myisam/ftbench/Ereport.pl create mode 100755 myisam/ftbench/ft-test-run.sh diff --git a/.bzrignore b/.bzrignore index c91e2d617b1..b3db91e7c59 100644 --- a/.bzrignore +++ b/.bzrignore @@ -602,3 +602,6 @@ vio/test-ssl vio/test-sslclient vio/test-sslserver vio/viotest-ssl +myisam/ftbench/var/* +myisam/ftbench/data +myisam/ftbench/t diff --git a/myisam/ftbench/Ecompare.pl b/myisam/ftbench/Ecompare.pl new file mode 100755 index 00000000000..4bcee1fb588 --- /dev/null +++ b/myisam/ftbench/Ecompare.pl @@ -0,0 +1,96 @@ +#!/usr/bin/perl + +# compares out-files (as created by Ereport.pl) from dir1/*.out and dir2/*.out +# for each effectiveness column computes the probability of the hypothesis +# "Both files have the same effectiveness" + +# sign test is used to verify that test results are statistically +# significant to support the hypothesis. Function is computed on the fly. + +# basic formula is \sum_{r=0}^R C_N^r 2^{-N} +# As N can be big, we'll work with logarithms +$log2=log(2); +sub probab { + my $N=shift, $R=shift; + + my $r, $sum=0; + + for $r (0..$R) { + $sum+=exp(logfac($N)-logfac($r)-logfac($N-$r)-$N*$log2); + } + return $sum; +} + +# log(N!) +# for N<20 exact value from the table (below) is taken +# otherwise, Stirling approximation for N! is used +sub logfac { + my $n=shift; die "n=$n<0" if $n<0; + return $logfactab[$n] if $n<=$#logfactab; + return $n*log($n)-$n+log(2*3.14159265358*$n)/2; +} +@logfactab=( +0, 0, 0.693147180559945, 1.79175946922805, 3.17805383034795, +4.78749174278205, 6.57925121201010, 8.52516136106541, 10.6046029027453, +12.8018274800815, 15.1044125730755, 17.5023078458739, 19.9872144956619, +22.5521638531234, 25.1912211827387, 27.8992713838409, 30.6718601060807, +33.5050734501369, 36.3954452080331, 39.3398841871995, 42.3356164607535, +); + +############################# main () ############################### +#$p=shift; $m=shift; $p-=$m; +#if($p>$m) { +# print "1 > 2 [+$p-$m]: ", probab($p+$m, $m), "\n"; +#} elsif($p<$m) { +# print "1 < 2 [+$p-$m]: ", probab($p+$m, $p), "\n"; +#} else { +# print "1 = 2 [+$p-$m]: ", probab($p+$m, $m), "\n"; +#} +#exit; + +die "Use: $0 dir1 dir2\n" unless @ARGV==2 && + -d ($dir1=shift) && -d ($dir2=shift); +$_=`cd $dir1; echo *.out`; +s/\.out\b//g; +$total=""; + +for $file (split) { + open(OUT1,$out1="$dir1/$file.out") || die "Cannot open $out1: $!"; + open(OUT2,$out2="$dir2/$file.out") || die "Cannot open $out2: $!"; + + @p=@m=(); + while(!eof(OUT1) || !eof(OUT2)) { + $_=; @l1=split; shift @l1; + $_=; @l2=split; shift @l2; + + die "Number of columns differ in line $.\n" unless $#l1 == $#l2; + + for (0..$#l1) { + $p[$_]+= $l1[$_] > $l2[$_]; + $m[$_]+= $l1[$_] < $l2[$_]; + } + } + + for (0..$#l1) { + $pp[$_]+=$p[$_]; $mm[$_]+=$m[$_]; + $total.=rep($file, ($#l1 ? $_ : undef), $p[$_], $m[$_]); + } + close OUT1; + close OUT2; +} + +for (0..$#l1) { + rep($total, ($#l1 ? $_ : undef), $pp[$_], $mm[$_]); +} + +sub rep { + my ($test, $n, $p, $m, $c, $r)=@_; + + if ($p>$m) { $c=">"; $r="+"; } + elsif($p<$m) { $c="<"; $r="-"; } + else { $c="="; $r="="; } + $n=" $n: " if defined $n; + printf "%-8s $n $dir1 $c $dir2 [+%03d-%03d]: %16.15f\n", + $test, $p, $m, probab($p+$m, ($p>=$m ? $m : $p)); + $r; +} diff --git a/myisam/ftbench/Ereport.pl b/myisam/ftbench/Ereport.pl new file mode 100755 index 00000000000..aac06503849 --- /dev/null +++ b/myisam/ftbench/Ereport.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +die "Use: $0 eval_output qrels_file\n" unless @ARGV==2; + +open(EOUT,$eout=shift) || die "Cannot open $eout: $!"; +open(RELJ,$relj=shift) || die "Cannot open $relj: $!"; + +$_=; +die "$eout must start with a number!\n "unless /^[1-9][0-9]*\n/; +$ndocs=$_+0; + +$qid=0; +$relj_str=; +$eout_str=; + +while(!eof(RELJ) || !eof(EOUT)) { + ++$qid; + %dq=(); + $A=$B=$AB=0; + $Ravg=$Pavg=0; + + while($relj_str =~ /^0*$qid\s+(\d+)/) { + ++$A; + $dq{$1+0}=1; + last unless $relj_str=; + } + # Favg measure = 1/(a/Pavg+(1-a)/Ravg) +sub Favg { my $a=shift; $Pavg*$Ravg ? 1/($a/$Pavg+(1-$a)/$Ravg) : 0; } + # F0 : a=0 -- ignore precision + # F5 : a=0.5 + # F1 : a=1 -- ignore recall + while($eout_str =~ /^$qid\s+(\d+)\s+(\d+\.\d+)/) { + $B++; + $AB++ if $dq{$1+0}; + $Ravg+=$AB; + $Pavg+=$AB/$B; + last unless $eout_str=; + } + next unless $A; + + $Ravg/=$B*$A if $B; + $Pavg/=$B if $B; + + write; +format= +@##### @#.####### +$qid, Favg(0.5) +. +} + +exit 0; + + diff --git a/myisam/ftbench/ft-test-run.sh b/myisam/ftbench/ft-test-run.sh new file mode 100755 index 00000000000..4c81cac6d4f --- /dev/null +++ b/myisam/ftbench/ft-test-run.sh @@ -0,0 +1,81 @@ +#!/bin/sh -x + +if [ ! -x ./ft-test-run.sh ] ; then + echo "Usage: ./ft-test-run.sh" + exit 1 +fi + +BASE=`pwd` +DATA=$BASE/var +ROOT=`cd ../..; pwd` +MYSQLD=$ROOT/sql/mysqld +MYSQL=$ROOT/client/mysql +MYSQLADMIN=$ROOT/client/mysqladmin +SOCK=$DATA/mysql.sock +PID=$DATA/mysql.pid +H=../ftdefs.h +OPTS="--no-defaults --socket=$SOCK --character-sets-dir=$ROOT/sql/share/charsets" + +# --ft_min_word_len=# +# --ft_max_word_len=# +# --ft_max_word_len_for_sort=# +# --ft_stopword_file=name +# --key_buffer_size=# + +stop_myslqd() +{ + [ -S $SOCK ] && $MYSQLADMIN $OPTS shutdown + [ -f $PID ] && kill `cat $PID` && sleep 15 && [ -f $PID ] && kill -9 `cat $PID` +} + +if [ ! -d t/BEST ] ; then + echo "No ./t/BEST directory! Aborting..." + exit 1 +fi +rm -f t/BEST/report.txt +if [ -w $H ] ; then + echo "$H is writeable! Aborting..." + exit 1 +fi + +for batch in t/BEST t/* ; do + A=`ls $batch/*.out` + [ ! -d $batch -o -n "$A" ] && continue + rm -f $H + ln -s $BASE/$batch/ftdefs.h $H + touch $H + OPTS="--defaults-file=$BASE/$batch/my.cnf --socket=$SOCK --character-sets-dir=$ROOT/sql/share/charsets" + stop_myslqd + rm $MYSQLD + (cd $ROOT; gmake) + + for prog in $MYSQLD $MYSQL $MYSQLADMIN ; do + if [ ! -x $prog ] ; then + echo "No $prog" + exit 1 + fi + done + + rm -rf var 2>&1 >/dev/null + mkdir var + mkdir var/test + + $MYSQLD $OPTS --basedir=$BASE --skip-bdb --pid-file=$PID \ + --language=$ROOT/sql/share/english \ + --skip-grant-tables --skip-innodb \ + --skip-networking --tmpdir=$DATA & + + $MYSQLADMIN $OPTS --connect_timeout=60 ping + if [ $? != 0 ] ; then + echo "$MYSQLD refused to start" + exit 1 + fi + for test in `cd data; echo *.test|sed "s/\.test\>//g"` ; do + $MYSQL $OPTS --skip-column-names test var/$test.eval + ./Ereport.pl var/$test.eval data/$test.relj > $batch/$test.out || exit + done + stop_myslqd + rm -f $H + [ $batch -ef t/BEST ] || ./Ecompare.pl t/BEST $batch >> t/BEST/report.txt +done + From 76bd91752616f251cd7177971e30ec2e8939d356 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Mar 2003 23:14:26 +0400 Subject: [PATCH 02/25] don't increment LAST_INSERT_ID() when incremented value cannot be stored in auto_increment column (e.g. is too big) mysql-test/r/auto_increment.result: more tests mysql-test/t/auto_increment.test: more tests --- mysql-test/r/auto_increment.result | 38 ++++++++++++++++++++++++++++++ mysql-test/t/auto_increment.test | 30 +++++++++++++++++++++++ sql/handler.cc | 4 ++-- 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index e79e6aab56b..2facb504294 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -105,3 +105,41 @@ Table Op Msg_type Msg_text test.t1 check warning Found row where the auto_increment column has the value 0 test.t1 check status OK drop table t1; +create table t1 (i tinyint unsigned not null auto_increment primary key); +insert into t1 set i = 254; +insert into t1 set i = null; +select last_insert_id(); +last_insert_id() +255 +insert into t1 set i = null; +Duplicate entry '255' for key 1 +select last_insert_id(); +last_insert_id() +255 +drop table t1; +create table t1 (i tinyint unsigned not null auto_increment, key (i)); +insert into t1 set i = 254; +insert into t1 set i = null; +select last_insert_id(); +last_insert_id() +255 +insert into t1 set i = null; +select last_insert_id(); +last_insert_id() +255 +drop table t1; +create table t1 (i tinyint unsigned not null auto_increment primary key, b int, unique (b)); +insert into t1 values (NULL, 10); +select last_insert_id(); +last_insert_id() +1 +insert into t1 values (NULL, 15); +select last_insert_id(); +last_insert_id() +2 +insert into t1 values (NULL, 10); +Duplicate entry '10' for key 2 +select last_insert_id(); +last_insert_id() +3 +drop table t1; diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index d7f67fe80d4..63fdfded6d0 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -72,3 +72,33 @@ select * from t1; check table t1; drop table t1; +# +# last_insert_id() madness +# +create table t1 (i tinyint unsigned not null auto_increment primary key); +insert into t1 set i = 254; +insert into t1 set i = null; +select last_insert_id(); +--error 1062 +insert into t1 set i = null; +select last_insert_id(); +drop table t1; + +create table t1 (i tinyint unsigned not null auto_increment, key (i)); +insert into t1 set i = 254; +insert into t1 set i = null; +select last_insert_id(); +insert into t1 set i = null; +select last_insert_id(); +drop table t1; + +create table t1 (i tinyint unsigned not null auto_increment primary key, b int, unique (b)); +insert into t1 values (NULL, 10); +select last_insert_id(); +insert into t1 values (NULL, 15); +select last_insert_id(); +--error 1062 +insert into t1 values (NULL, 10); +select last_insert_id(); +drop table t1; + diff --git a/sql/handler.cc b/sql/handler.cc index 5353e78cd11..e288d590e88 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -660,8 +660,8 @@ void handler::update_auto_increment() thd->next_insert_id=0; // Clear after use else nr=get_auto_increment(); - thd->insert_id((ulonglong) nr); - table->next_number_field->store(nr); + if (!table->next_number_field->store(nr)) + thd->insert_id((ulonglong) nr); auto_increment_column_changed=1; DBUG_VOID_RETURN; } From 1f61635dcd7d4ef1d663735c34009c57f1215e5e Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 5 Apr 2003 07:59:10 +0500 Subject: [PATCH 03/25] sql_cache.cc: Cast to unsigned char sql/sql_cache.cc: Cast to unsigned char --- sql/sql_cache.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 664df11a968..912cce3ec91 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -2476,8 +2476,8 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len, tables_used->table->tmp_table != NO_TMP_TABLE || (tables_used->db_length == 5 && #ifdef FN_NO_CASE_SENCE - my_strnncoll(system_charset_info, tables_used->db, 6, - "mysql",6) == 0 + my_strnncoll(system_charset_info, (uchar*)tables_used->db, 6, + (uchar*)"mysql",6) == 0 #else tables_used->db[0]=='m' && tables_used->db[1]=='y' && From 933e16a388704a449fba42fa1eee0b139ecf27a3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 5 Apr 2003 09:29:28 +0300 Subject: [PATCH 04/25] fixed st_select_lex initialization fixed mustiupdate subselect compatibility (bug 217) mysql-test/r/subselect.result: test of multi-update & subselect mysql-test/t/subselect.test: test of multi-update & subselect sql/sql_update.cc: added subselect compatibility to query cache sql/sql_yacc.yy: right st_select_lex initialization layout fix --- mysql-test/r/subselect.result | 17 +++++++++++++++++ mysql-test/t/subselect.test | 17 +++++++++++++++++ sql/sql_update.cc | 6 ++++-- sql/sql_yacc.yy | 4 ++-- 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 795348f1897..72fc8dc2997 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1082,3 +1082,20 @@ Invalid use of group function UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i)); Invalid use of group function drop table t1; +CREATE TABLE t1 ( +id int(11) default NULL +) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES (1),(1),(2),(2),(1),(3); +CREATE TABLE t2 ( +id int(11) default NULL, +name varchar(15) default NULL +) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t2 VALUES (4,'vita'), (1,'vita'), (2,'vita'), (1,'vita'); +update t1, t2 set t2.name='lenka' where t2.id in (select id from t1); +select * from t2; +id name +4 vita +1 lenka +2 lenka +1 lenka +drop table t1,t2; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 39dfd4c72e6..e6ae86aa839 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -673,3 +673,20 @@ UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i)); -- error 1111 UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i)); drop table t1; + +# +# Multi update test +# +CREATE TABLE t1 ( + id int(11) default NULL +) TYPE=MyISAM CHARSET=latin1; +INSERT INTO t1 VALUES (1),(1),(2),(2),(1),(3); +CREATE TABLE t2 ( + id int(11) default NULL, + name varchar(15) default NULL +) TYPE=MyISAM CHARSET=latin1; + +INSERT INTO t2 VALUES (4,'vita'), (1,'vita'), (2,'vita'), (1,'vita'); +update t1, t2 set t2.name='lenka' where t2.id in (select id from t1); +select * from t2; +drop table t1,t2; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index ec1183819dc..3e72f79da62 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -400,6 +400,7 @@ int mysql_multi_update(THD *thd, table_list->grant.want_privilege=(SELECT_ACL & ~table_list->grant.privilege); if ((res=open_and_lock_tables(thd,table_list))) DBUG_RETURN(res); + fix_tables_pointers(thd->lex.all_selects_list); thd->select_limit=HA_POS_ERROR; if (setup_fields(thd, 0, table_list, *fields, 1, 0, 0)) @@ -408,7 +409,7 @@ int mysql_multi_update(THD *thd, /* Count tables and setup timestamp handling */ - for (tl= (TABLE_LIST*) table_list ; tl ; tl=tl->next) + for (tl= select_lex->get_table_list() ; tl ; tl=tl->next) { TABLE *table= tl->table; if (table->timestamp_field) @@ -426,7 +427,8 @@ int mysql_multi_update(THD *thd, List total_list; res= mysql_select(thd, &select_lex->ref_pointer_array, - table_list, select_lex->with_wild, total_list, + select_lex->get_table_list(), select_lex->with_wild, + total_list, conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, (ORDER *)NULL, options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f30bfbc594a..bbab102e0b9 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3369,8 +3369,8 @@ update: UPDATE_SYM { LEX *lex= Lex; + mysql_init_select(lex); lex->sql_command= SQLCOM_UPDATE; - lex->select_lex.init_order(); } opt_low_priority opt_ignore join_table_list SET update_list where_clause opt_order_clause delete_limit_clause @@ -3378,7 +3378,7 @@ update: LEX *lex= Lex; Select->set_lock_for_tables($3); if (lex->select_lex.table_list.elements > 1) - lex->sql_command=SQLCOM_UPDATE_MULTI; + lex->sql_command= SQLCOM_UPDATE_MULTI; } ; From a7a96235af245d7d4b32b827c6e08da898008ee8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 5 Apr 2003 15:59:29 +0500 Subject: [PATCH 05/25] sql_yacc.yy, set_var.h, set_var.cc: Optimization of SET NAMES sql/set_var.cc: Optimization of SET NAMES sql/set_var.h: Optimization of SET NAMES sql/sql_yacc.yy: Optimization of SET NAMES --- sql/set_var.cc | 28 ++++++++++++++++++++++++++++ sql/set_var.h | 15 +++++++++++++++ sql/sql_yacc.yy | 17 +++-------------- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index d0b9a2170e4..a47fdbfb63f 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1655,6 +1655,34 @@ int set_var_password::update(THD *thd) 1 : 0); } + +/***************************************************************************** + Functions to handle SET NAMES and SET CHARACTER SET +*****************************************************************************/ + +int set_var_client_collation::check(THD *thd) +{ + return 0; +} + +int set_var_client_collation::update(THD *thd) +{ +#if 0 + if (var->type == OPT_GLOBAL) + global_system_variables.thd_charset= var->save_result.charset; + else +#endif + { + thd->variables.thd_charset= client_collation; + thd->variables.convert_result_charset= convert_result_charset; + thd->protocol_simple.init(thd); + thd->protocol_prep.init(thd); + } + return 0; +} + + + /**************************************************************************** Used templates ****************************************************************************/ diff --git a/sql/set_var.h b/sql/set_var.h index d91b6796d20..54f773d40ff 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -526,6 +526,21 @@ public: }; +/* For SET NAMES and SET CHARACTER SET */ + +class set_var_client_collation: public set_var_base +{ + CHARSET_INFO *client_collation; + my_bool convert_result_charset; +public: + set_var_client_collation(CHARSET_INFO *coll_arg ,my_bool conv_arg) + :client_collation(coll_arg), convert_result_charset(conv_arg) + {} + int check(THD *thd); + int update(THD *thd); +}; + + /* Prototypes for helper functions */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d730807464f..80470e9bcb9 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4409,19 +4409,13 @@ option_value: cl->name,cs->csname); YYABORT; } - Item_string *csname= new Item_string(cl->name, - strlen(cl->name), - &my_charset_latin1); - lex->var_list.push_back(new set_var(lex->option_type, - find_sys_var("client_collation"), - csname)); + lex->var_list.push_back(new set_var_client_collation(cl,1)); } | COLLATION_SYM collation_name_or_default { THD* thd= YYTHD; LEX *lex= &thd->lex; - system_variables *vars= &thd->variables; - CHARSET_INFO *cs= vars->thd_charset; + CHARSET_INFO *cs= thd->variables->vars->thd_charset; CHARSET_INFO *cl= $2; if (!cl) @@ -4438,12 +4432,7 @@ option_value: cl->name,cs->csname); YYABORT; } - Item_string *csname= new Item_string(cl->name, - strlen(cl->name), - &my_charset_latin1); - lex->var_list.push_back(new set_var(lex->option_type, - find_sys_var("client_collation"), - csname)); + lex->var_list.push_back(new set_var_client_collation(cl,1)); } | PASSWORD equal text_or_password { From a00dbd11926b5d88e1e2b833a60274054cccd9c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 5 Apr 2003 17:02:34 +0500 Subject: [PATCH 06/25] sql_yacc.yy: I wonder how it happend that I compiled this! sql/sql_yacc.yy: I wonder how it happend that I compiled this! --- sql/sql_yacc.yy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 80470e9bcb9..d8a6595854d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4415,7 +4415,7 @@ option_value: { THD* thd= YYTHD; LEX *lex= &thd->lex; - CHARSET_INFO *cs= thd->variables->vars->thd_charset; + CHARSET_INFO *cs= thd->variables.thd_charset; CHARSET_INFO *cl= $2; if (!cl) From 0ee981674c3c8a1533b72ae0b893352144c788bb Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 5 Apr 2003 18:56:15 +0500 Subject: [PATCH 07/25] Some optimization in SET NAMES mysql-test/r/ctype_collate.result: SET NAMES charset COLLATE collation is new syntax mysql-test/r/variables.result: SET NAMES charset COLLATE collation is new syntax mysql-test/t/ctype_collate.test: SET NAMES charset COLLATE collation is new syntax mysql-test/t/variables.test: SET NAMES charset COLLATE collation is new syntax --- mysql-test/r/ctype_collate.result | 4 +- mysql-test/r/variables.result | 12 ----- mysql-test/t/ctype_collate.test | 4 +- mysql-test/t/variables.test | 8 ---- sql/set_var.cc | 25 ++++++----- sql/set_var.h | 8 +++- sql/sql_yacc.yy | 73 +++++++++++-------------------- 7 files changed, 49 insertions(+), 85 deletions(-) diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result index c0af8840e64..0be2bf5f54b 100644 --- a/mysql-test/r/ctype_collate.result +++ b/mysql-test/r/ctype_collate.result @@ -546,14 +546,14 @@ client_collation koi8r_general_ci SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' latin1 latin1_swedish_ci 3 1 -SET COLLATION koi8r_bin; +SET NAMES koi8r COLLATE koi8r_bin; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation koi8r_bin SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' latin1 latin1_swedish_ci 3 1 -SET COLLATION DEFAULT; +SET NAMES koi8r COLLATE DEFAULT; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation koi8r_general_ci diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 0693eedf55a..b709d135ee1 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -155,18 +155,10 @@ set net_buffer_length=2000000000; show variables like 'net_buffer_length'; Variable_name Value net_buffer_length 1048576 -set GLOBAL character set cp1251_koi8; -show global variables like "client_collation"; -Variable_name Value -client_collation cp1251_bulgarian_ci set character set cp1251_koi8; show variables like "client_collation"; Variable_name Value client_collation cp1251_bulgarian_ci -set global character set default, session character set default; -show variables like "client_collation"; -Variable_name Value -client_collation latin1_swedish_ci select @@timestamp>0; @@timestamp>0 1 @@ -195,10 +187,6 @@ set GLOBAL table_type=DEFAULT; Variable 'table_type' doesn't have a default value set client_collation=UNKNOWN_CHARACTER_SET; Unknown character set: 'UNKNOWN_CHARACTER_SET' -set character set unknown; -Unknown character set: 'unknown' -set character set 0; -Wrong argument type to variable 'client_collation' set global autocommit=1; Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL select @@global.timestamp; diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test index e2631a06156..2740ca24eb3 100644 --- a/mysql-test/t/ctype_collate.test +++ b/mysql-test/t/ctype_collate.test @@ -143,10 +143,10 @@ SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SET NAMES koi8r; SHOW VARIABLES LIKE 'client_collation'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; -SET COLLATION koi8r_bin; +SET NAMES koi8r COLLATE koi8r_bin; SHOW VARIABLES LIKE 'client_collation'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; -SET COLLATION DEFAULT; +SET NAMES koi8r COLLATE DEFAULT; SHOW VARIABLES LIKE 'client_collation'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; SET NAMES DEFAULT; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 7671b663738..bb94ab17b77 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -91,12 +91,8 @@ show variables like 'net_buffer_length'; set net_buffer_length=2000000000; show variables like 'net_buffer_length'; -set GLOBAL character set cp1251_koi8; -show global variables like "client_collation"; set character set cp1251_koi8; show variables like "client_collation"; -set global character set default, session character set default; -show variables like "client_collation"; select @@timestamp>0; set @@rand_seed1=10000000,@@rand_seed2=1000000; @@ -124,10 +120,6 @@ set SESSION query_cache_size=10000; set GLOBAL table_type=DEFAULT; --error 1115 set client_collation=UNKNOWN_CHARACTER_SET; ---error 1115 -set character set unknown; ---error 1232 -set character set 0; --error 1228 set global autocommit=1; --error 1228 diff --git a/sql/set_var.cc b/sql/set_var.cc index a47fdbfb63f..127988b8c4e 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1175,7 +1175,7 @@ static my_old_conv old_conv[]= { NULL , NULL } }; -static CHARSET_INFO *get_old_charset_by_name(const char *name) +CHARSET_INFO *get_old_charset_by_name(const char *name) { my_old_conv *c; @@ -1662,22 +1662,23 @@ int set_var_password::update(THD *thd) int set_var_client_collation::check(THD *thd) { + client_charset= client_charset ? client_charset : thd->db_charset; + client_collation= client_collation ? client_collation : client_charset; + if (!my_charset_same(client_charset, client_collation)) + { + my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), + client_collation->name, client_charset->csname); + return -1; + } return 0; } int set_var_client_collation::update(THD *thd) { -#if 0 - if (var->type == OPT_GLOBAL) - global_system_variables.thd_charset= var->save_result.charset; - else -#endif - { - thd->variables.thd_charset= client_collation; - thd->variables.convert_result_charset= convert_result_charset; - thd->protocol_simple.init(thd); - thd->protocol_prep.init(thd); - } + thd->variables.thd_charset= client_collation; + thd->variables.convert_result_charset= convert_result_charset; + thd->protocol_simple.init(thd); + thd->protocol_prep.init(thd); return 0; } diff --git a/sql/set_var.h b/sql/set_var.h index 54f773d40ff..7b2f9d5cb80 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -530,11 +530,14 @@ public: class set_var_client_collation: public set_var_base { + CHARSET_INFO *client_charset; CHARSET_INFO *client_collation; my_bool convert_result_charset; public: - set_var_client_collation(CHARSET_INFO *coll_arg ,my_bool conv_arg) - :client_collation(coll_arg), convert_result_charset(conv_arg) + set_var_client_collation(CHARSET_INFO *cset_arg, + CHARSET_INFO *coll_arg ,my_bool conv_arg) + :client_charset(cset_arg), client_collation(coll_arg), + convert_result_charset(conv_arg) {} int check(THD *thd); int update(THD *thd); @@ -552,3 +555,4 @@ int sql_set_variables(THD *thd, List *var_list); void fix_delay_key_write(THD *thd, enum_var_type type); extern sys_var_str sys_charset; +CHARSET_INFO *get_old_charset_by_name(const char *old_name); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index d8a6595854d..d1580332910 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -646,6 +646,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); opt_collate charset_name charset_name_or_default + old_or_new_charset_name + old_or_new_charset_name_or_default collation_name collation_name_or_default @@ -1354,6 +1356,24 @@ charset_name_or_default: charset_name { $$=$1; } | DEFAULT { $$=NULL; } ; + +old_or_new_charset_name: + ident_or_text + { + if (!($$=get_charset_by_csname($1.str,MY_CS_PRIMARY,MYF(0))) && + !($$=get_old_charset_by_name($1.str))) + { + net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,$1.str); + YYABORT; + } + } + | BINARY { $$= &my_charset_bin; } + ; + +old_or_new_charset_name_or_default: + old_or_new_charset_name { $$=$1; } + | DEFAULT { $$=NULL; } ; + collation_name: ident_or_text { @@ -1366,7 +1386,7 @@ collation_name: opt_collate: /* empty */ { $$=NULL; } - | COLLATE_SYM collation_name { $$=$2; } + | COLLATE_SYM collation_name_or_default { $$=$2; } ; collation_name_or_default: @@ -4383,56 +4403,15 @@ option_value: find_sys_var("tx_isolation"), new Item_int((int32) $4))); } - | charset set_expr_or_default + | charset old_or_new_charset_name_or_default { - THD *thd= YYTHD; - LEX *lex= &thd->lex; - if (!$2) - { - CHARSET_INFO *cl= thd->db_charset; - $2= new Item_string(cl->name, strlen(cl->name), &my_charset_latin1); - } - lex->var_list.push_back(new set_var(lex->option_type, - find_sys_var("client_collation"), - $2)); + LEX *lex= Lex; + lex->var_list.push_back(new set_var_client_collation($2,NULL,1)); } | NAMES_SYM charset_name_or_default opt_collate { - THD* thd= YYTHD; - LEX *lex= &thd->lex; - CHARSET_INFO *cs= $2 ? $2 : thd->db_charset; - CHARSET_INFO *cl= $3 ? $3 : cs; - - if (!my_charset_same(cs,cl)) - { - net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, - cl->name,cs->csname); - YYABORT; - } - lex->var_list.push_back(new set_var_client_collation(cl,1)); - } - | COLLATION_SYM collation_name_or_default - { - THD* thd= YYTHD; - LEX *lex= &thd->lex; - CHARSET_INFO *cs= thd->variables.thd_charset; - CHARSET_INFO *cl= $2; - - if (!cl) - { - if (!(cl=get_charset_by_csname(cs->csname,MY_CS_PRIMARY,MYF(0)))) - { - net_printf(YYTHD,ER_UNKNOWN_CHARACTER_SET,"DEFAULT"); - YYABORT; - } - } - else if (!my_charset_same(cs,cl)) - { - net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, - cl->name,cs->csname); - YYABORT; - } - lex->var_list.push_back(new set_var_client_collation(cl,1)); + LEX *lex= Lex; + lex->var_list.push_back(new set_var_client_collation($2,$3,1)); } | PASSWORD equal text_or_password { From 3aa5599774024a36835fcc535e8f99cdd4277950 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 6 Apr 2003 20:14:36 -0400 Subject: [PATCH 08/25] fixed bug with locales in libedit configure.in: fixed bug with external libedit --- client/mysql.cc | 7 + cmd-line-utils/libedit/map.c | 258 +++++++++++++++---------------- cmd-line-utils/libedit/refresh.c | 6 +- configure.in | 2 +- 4 files changed, 140 insertions(+), 133 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 05dfefbfec9..5367b5d7e91 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -40,6 +40,10 @@ #include #include +#if defined(USE_LIBEDIT_INTERFACE) && defined(HAVE_LOCALE_H) +#include +#endif + const char *VER= "13.5"; /* Don't try to make a nice table if the data is too big */ @@ -1111,6 +1115,9 @@ static void initialize_readline (char *name) rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion; rl_completion_entry_function= (rl_compentry_func_t*)&no_completion; #elif defined(USE_LIBEDIT_INTERFACE) +#ifdef HAVE_LOCALE_H + setlocale(LC_ALL,""); /* so as libedit use isprint */ +#endif rl_attempted_completion_function= (CPPFunction*)&new_mysql_completion; rl_completion_entry_function= (CPFunction*)&no_completion; #else diff --git a/cmd-line-utils/libedit/map.c b/cmd-line-utils/libedit/map.c index 97f8cfc5e29..144ccf1ebe0 100644 --- a/cmd-line-utils/libedit/map.c +++ b/cmd-line-utils/libedit/map.c @@ -184,135 +184,135 @@ private const el_action_t el_map_emacs[] = { /* 124 */ ED_INSERT, /* | */ /* 125 */ ED_INSERT, /* } */ /* 126 */ ED_INSERT, /* ~ */ - /* 127 */ ED_INSERT, /* ^? */ - /* 128 */ ED_INSERT, /* M-^@ */ - /* 129 */ ED_INSERT, /* M-^A */ - /* 130 */ ED_INSERT, /* M-^B */ - /* 131 */ ED_INSERT, /* M-^C */ - /* 132 */ ED_INSERT, /* M-^D */ - /* 133 */ ED_INSERT, /* M-^E */ - /* 134 */ ED_INSERT, /* M-^F */ - /* 135 */ ED_INSERT, /* M-^G */ - /* 136 */ ED_INSERT, /* M-^H */ - /* 137 */ ED_INSERT, /* M-^I */ - /* 138 */ ED_INSERT, /* M-^J */ - /* 139 */ ED_INSERT, /* M-^K */ - /* 140 */ ED_INSERT, /* M-^L */ - /* 141 */ ED_INSERT, /* M-^M */ - /* 142 */ ED_INSERT, /* M-^N */ - /* 143 */ ED_INSERT, /* M-^O */ - /* 144 */ ED_INSERT, /* M-^P */ - /* 145 */ ED_INSERT, /* M-^Q */ - /* 146 */ ED_INSERT, /* M-^R */ - /* 147 */ ED_INSERT, /* M-^S */ - /* 148 */ ED_INSERT, /* M-^T */ - /* 149 */ ED_INSERT, /* M-^U */ - /* 150 */ ED_INSERT, /* M-^V */ - /* 151 */ ED_INSERT, /* M-^W */ - /* 152 */ ED_INSERT, /* M-^X */ - /* 153 */ ED_INSERT, /* M-^Y */ - /* 154 */ ED_INSERT, /* M-^Z */ - /* 155 */ ED_INSERT, /* M-^[ */ - /* 156 */ ED_INSERT, /* M-^\ */ - /* 157 */ ED_INSERT, /* M-^] */ - /* 158 */ ED_INSERT, /* M-^^ */ - /* 159 */ ED_INSERT, /* M-^_ */ - /* 160 */ ED_INSERT, /* M-SPACE */ - /* 161 */ ED_INSERT, /* M-! */ - /* 162 */ ED_INSERT, /* M-" */ - /* 163 */ ED_INSERT, /* M-# */ - /* 164 */ ED_INSERT, /* M-$ */ - /* 165 */ ED_INSERT, /* M-% */ - /* 166 */ ED_INSERT, /* M-& */ - /* 167 */ ED_INSERT, /* M-' */ - /* 168 */ ED_INSERT, /* M-( */ - /* 169 */ ED_INSERT, /* M-) */ - /* 170 */ ED_INSERT, /* M-* */ - /* 171 */ ED_INSERT, /* M-+ */ - /* 172 */ ED_INSERT, /* M-, */ - /* 173 */ ED_INSERT, /* M-- */ - /* 174 */ ED_INSERT, /* M-. */ - /* 175 */ ED_INSERT, /* M-/ */ - /* 176 */ ED_INSERT, /* M-0 */ - /* 177 */ ED_INSERT, /* M-1 */ - /* 178 */ ED_INSERT, /* M-2 */ - /* 179 */ ED_INSERT, /* M-3 */ - /* 180 */ ED_INSERT, /* M-4 */ - /* 181 */ ED_INSERT, /* M-5 */ - /* 182 */ ED_INSERT, /* M-6 */ - /* 183 */ ED_INSERT, /* M-7 */ - /* 184 */ ED_INSERT, /* M-8 */ - /* 185 */ ED_INSERT, /* M-9 */ - /* 186 */ ED_INSERT, /* M-: */ - /* 187 */ ED_INSERT, /* M-; */ - /* 188 */ ED_INSERT, /* M-< */ - /* 189 */ ED_INSERT, /* M-= */ - /* 190 */ ED_INSERT, /* M-> */ - /* 191 */ ED_INSERT, /* M-? */ - /* 192 */ ED_INSERT, /* M-@ */ - /* 193 */ ED_INSERT, /* M-A */ - /* 194 */ ED_INSERT, /* M-B */ - /* 195 */ ED_INSERT, /* M-C */ - /* 196 */ ED_INSERT, /* M-D */ - /* 197 */ ED_INSERT, /* M-E */ - /* 198 */ ED_INSERT, /* M-F */ - /* 199 */ ED_INSERT, /* M-G */ - /* 200 */ ED_INSERT, /* M-H */ - /* 201 */ ED_INSERT, /* M-I */ - /* 202 */ ED_INSERT, /* M-J */ - /* 203 */ ED_INSERT, /* M-K */ - /* 204 */ ED_INSERT, /* M-L */ - /* 205 */ ED_INSERT, /* M-M */ - /* 206 */ ED_INSERT, /* M-N */ - /* 207 */ ED_INSERT, /* M-O */ - /* 208 */ ED_INSERT, /* M-P */ - /* 209 */ ED_INSERT, /* M-Q */ - /* 210 */ ED_INSERT, /* M-R */ - /* 211 */ ED_INSERT, /* M-S */ - /* 212 */ ED_INSERT, /* M-T */ - /* 213 */ ED_INSERT, /* M-U */ - /* 214 */ ED_INSERT, /* M-V */ - /* 215 */ ED_INSERT, /* M-W */ - /* 216 */ ED_INSERT, /* M-X */ - /* 217 */ ED_INSERT, /* M-Y */ - /* 218 */ ED_INSERT, /* M-Z */ - /* 219 */ ED_INSERT, /* M-[ */ - /* 220 */ ED_INSERT, /* M-\ */ - /* 221 */ ED_INSERT, /* M-] */ - /* 222 */ ED_INSERT, /* M-^ */ - /* 223 */ ED_INSERT, /* M-_ */ - /* 223 */ ED_INSERT, /* M-` */ - /* 224 */ ED_INSERT, /* M-a */ - /* 225 */ ED_INSERT, /* M-b */ - /* 226 */ ED_INSERT, /* M-c */ - /* 227 */ ED_INSERT, /* M-d */ - /* 228 */ ED_INSERT, /* M-e */ - /* 229 */ ED_INSERT, /* M-f */ - /* 230 */ ED_INSERT, /* M-g */ - /* 231 */ ED_INSERT, /* M-h */ - /* 232 */ ED_INSERT, /* M-i */ - /* 233 */ ED_INSERT, /* M-j */ - /* 234 */ ED_INSERT, /* M-k */ - /* 235 */ ED_INSERT, /* M-l */ - /* 236 */ ED_INSERT, /* M-m */ - /* 237 */ ED_INSERT, /* M-n */ - /* 238 */ ED_INSERT, /* M-o */ - /* 239 */ ED_INSERT, /* M-p */ - /* 240 */ ED_INSERT, /* M-q */ - /* 241 */ ED_INSERT, /* M-r */ - /* 242 */ ED_INSERT, /* M-s */ - /* 243 */ ED_INSERT, /* M-t */ - /* 244 */ ED_INSERT, /* M-u */ - /* 245 */ ED_INSERT, /* M-v */ - /* 246 */ ED_INSERT, /* M-w */ - /* 247 */ ED_INSERT, /* M-x */ - /* 248 */ ED_INSERT, /* M-y */ - /* 249 */ ED_INSERT, /* M-z */ - /* 250 */ ED_INSERT, /* M-{ */ - /* 251 */ ED_INSERT, /* M-| */ - /* 252 */ ED_INSERT, /* M-} */ - /* 253 */ ED_INSERT, /* M-~ */ - /* 254 */ ED_INSERT /* M-^? */ + /* 127 */ ED_DELETE_PREV_CHAR, /* ^? */ + /* 128 */ ED_UNASSIGNED, /* M-^@ */ + /* 129 */ ED_UNASSIGNED, /* M-^A */ + /* 130 */ ED_UNASSIGNED, /* M-^B */ + /* 131 */ ED_UNASSIGNED, /* M-^C */ + /* 132 */ ED_UNASSIGNED, /* M-^D */ + /* 133 */ ED_UNASSIGNED, /* M-^E */ + /* 134 */ ED_UNASSIGNED, /* M-^F */ + /* 135 */ ED_UNASSIGNED, /* M-^G */ + /* 136 */ ED_DELETE_PREV_WORD, /* M-^H */ + /* 137 */ ED_UNASSIGNED, /* M-^I */ + /* 138 */ ED_UNASSIGNED, /* M-^J */ + /* 139 */ ED_UNASSIGNED, /* M-^K */ + /* 140 */ ED_CLEAR_SCREEN, /* M-^L */ + /* 141 */ ED_UNASSIGNED, /* M-^M */ + /* 142 */ ED_UNASSIGNED, /* M-^N */ + /* 143 */ ED_UNASSIGNED, /* M-^O */ + /* 144 */ ED_UNASSIGNED, /* M-^P */ + /* 145 */ ED_UNASSIGNED, /* M-^Q */ + /* 146 */ ED_UNASSIGNED, /* M-^R */ + /* 147 */ ED_UNASSIGNED, /* M-^S */ + /* 148 */ ED_UNASSIGNED, /* M-^T */ + /* 149 */ ED_UNASSIGNED, /* M-^U */ + /* 150 */ ED_UNASSIGNED, /* M-^V */ + /* 151 */ ED_UNASSIGNED, /* M-^W */ + /* 152 */ ED_UNASSIGNED, /* M-^X */ + /* 153 */ ED_UNASSIGNED, /* M-^Y */ + /* 154 */ ED_UNASSIGNED, /* M-^Z */ + /* 155 */ ED_UNASSIGNED, /* M-^[ */ + /* 156 */ ED_UNASSIGNED, /* M-^\ */ + /* 157 */ ED_UNASSIGNED, /* M-^] */ + /* 158 */ ED_UNASSIGNED, /* M-^^ */ + /* 159 */ EM_COPY_PREV_WORD, /* M-^_ */ + /* 160 */ ED_UNASSIGNED, /* M-SPACE */ + /* 161 */ ED_UNASSIGNED, /* M-! */ + /* 162 */ ED_UNASSIGNED, /* M-" */ + /* 163 */ ED_UNASSIGNED, /* M-# */ + /* 164 */ ED_UNASSIGNED, /* M-$ */ + /* 165 */ ED_UNASSIGNED, /* M-% */ + /* 166 */ ED_UNASSIGNED, /* M-& */ + /* 167 */ ED_UNASSIGNED, /* M-' */ + /* 168 */ ED_UNASSIGNED, /* M-( */ + /* 169 */ ED_UNASSIGNED, /* M-) */ + /* 170 */ ED_UNASSIGNED, /* M-* */ + /* 171 */ ED_UNASSIGNED, /* M-+ */ + /* 172 */ ED_UNASSIGNED, /* M-, */ + /* 173 */ ED_UNASSIGNED, /* M-- */ + /* 174 */ ED_UNASSIGNED, /* M-. */ + /* 175 */ ED_UNASSIGNED, /* M-/ */ + /* 176 */ ED_ARGUMENT_DIGIT, /* M-0 */ + /* 177 */ ED_ARGUMENT_DIGIT, /* M-1 */ + /* 178 */ ED_ARGUMENT_DIGIT, /* M-2 */ + /* 179 */ ED_ARGUMENT_DIGIT, /* M-3 */ + /* 180 */ ED_ARGUMENT_DIGIT, /* M-4 */ + /* 181 */ ED_ARGUMENT_DIGIT, /* M-5 */ + /* 182 */ ED_ARGUMENT_DIGIT, /* M-6 */ + /* 183 */ ED_ARGUMENT_DIGIT, /* M-7 */ + /* 184 */ ED_ARGUMENT_DIGIT, /* M-8 */ + /* 185 */ ED_ARGUMENT_DIGIT, /* M-9 */ + /* 186 */ ED_UNASSIGNED, /* M-: */ + /* 187 */ ED_UNASSIGNED, /* M-; */ + /* 188 */ ED_UNASSIGNED, /* M-< */ + /* 189 */ ED_UNASSIGNED, /* M-= */ + /* 190 */ ED_UNASSIGNED, /* M-> */ + /* 191 */ ED_UNASSIGNED, /* M-? */ + /* 192 */ ED_UNASSIGNED, /* M-@ */ + /* 193 */ ED_UNASSIGNED, /* M-A */ + /* 194 */ ED_PREV_WORD, /* M-B */ + /* 195 */ EM_CAPITOL_CASE, /* M-C */ + /* 196 */ EM_DELETE_NEXT_WORD, /* M-D */ + /* 197 */ ED_UNASSIGNED, /* M-E */ + /* 198 */ EM_NEXT_WORD, /* M-F */ + /* 199 */ ED_UNASSIGNED, /* M-G */ + /* 200 */ ED_UNASSIGNED, /* M-H */ + /* 201 */ ED_UNASSIGNED, /* M-I */ + /* 202 */ ED_UNASSIGNED, /* M-J */ + /* 203 */ ED_UNASSIGNED, /* M-K */ + /* 204 */ EM_LOWER_CASE, /* M-L */ + /* 205 */ ED_UNASSIGNED, /* M-M */ + /* 206 */ ED_SEARCH_NEXT_HISTORY, /* M-N */ + /* 207 */ ED_SEQUENCE_LEAD_IN, /* M-O */ + /* 208 */ ED_SEARCH_PREV_HISTORY, /* M-P */ + /* 209 */ ED_UNASSIGNED, /* M-Q */ + /* 210 */ ED_UNASSIGNED, /* M-R */ + /* 211 */ ED_UNASSIGNED, /* M-S */ + /* 212 */ ED_UNASSIGNED, /* M-T */ + /* 213 */ EM_UPPER_CASE, /* M-U */ + /* 214 */ ED_UNASSIGNED, /* M-V */ + /* 215 */ EM_COPY_REGION, /* M-W */ + /* 216 */ ED_COMMAND, /* M-X */ + /* 217 */ ED_UNASSIGNED, /* M-Y */ + /* 218 */ ED_UNASSIGNED, /* M-Z */ + /* 219 */ ED_SEQUENCE_LEAD_IN, /* M-[ */ + /* 220 */ ED_UNASSIGNED, /* M-\ */ + /* 221 */ ED_UNASSIGNED, /* M-] */ + /* 222 */ ED_UNASSIGNED, /* M-^ */ + /* 223 */ ED_UNASSIGNED, /* M-_ */ + /* 223 */ ED_UNASSIGNED, /* M-` */ + /* 224 */ ED_UNASSIGNED, /* M-a */ + /* 225 */ ED_PREV_WORD, /* M-b */ + /* 226 */ EM_CAPITOL_CASE, /* M-c */ + /* 227 */ EM_DELETE_NEXT_WORD, /* M-d */ + /* 228 */ ED_UNASSIGNED, /* M-e */ + /* 229 */ EM_NEXT_WORD, /* M-f */ + /* 230 */ ED_UNASSIGNED, /* M-g */ + /* 231 */ ED_UNASSIGNED, /* M-h */ + /* 232 */ ED_UNASSIGNED, /* M-i */ + /* 233 */ ED_UNASSIGNED, /* M-j */ + /* 234 */ ED_UNASSIGNED, /* M-k */ + /* 235 */ EM_LOWER_CASE, /* M-l */ + /* 236 */ ED_UNASSIGNED, /* M-m */ + /* 237 */ ED_SEARCH_NEXT_HISTORY, /* M-n */ + /* 238 */ ED_UNASSIGNED, /* M-o */ + /* 239 */ ED_SEARCH_PREV_HISTORY, /* M-p */ + /* 240 */ ED_UNASSIGNED, /* M-q */ + /* 241 */ ED_UNASSIGNED, /* M-r */ + /* 242 */ ED_UNASSIGNED, /* M-s */ + /* 243 */ ED_UNASSIGNED, /* M-t */ + /* 244 */ EM_UPPER_CASE, /* M-u */ + /* 245 */ ED_UNASSIGNED, /* M-v */ + /* 246 */ EM_COPY_REGION, /* M-w */ + /* 247 */ ED_COMMAND, /* M-x */ + /* 248 */ ED_UNASSIGNED, /* M-y */ + /* 249 */ ED_UNASSIGNED, /* M-z */ + /* 250 */ ED_UNASSIGNED, /* M-{ */ + /* 251 */ ED_UNASSIGNED, /* M-| */ + /* 252 */ ED_UNASSIGNED, /* M-} */ + /* 253 */ ED_UNASSIGNED, /* M-~ */ + /* 254 */ ED_DELETE_PREV_WORD /* M-^? */ /* 255 */ }; diff --git a/cmd-line-utils/libedit/refresh.c b/cmd-line-utils/libedit/refresh.c index fdb8c13138d..534e7e12304 100644 --- a/cmd-line-utils/libedit/refresh.c +++ b/cmd-line-utils/libedit/refresh.c @@ -93,7 +93,7 @@ private void re_addc(EditLine *el, int c) { - if (isprint(c) || ((unsigned char)c)>127) { + if (isprint(c)) { re_putc(el, c, 1); return; } @@ -954,7 +954,7 @@ re_refresh_cursor(EditLine *el) h = 1; v++; } - } else if (!isprint((unsigned char) c) || ((unsigned char)c)>127) { + } else if (!isprint((unsigned char) c)) { h += 3; if (h > th) { /* if overflow, compensate */ h = h - th; @@ -1047,7 +1047,7 @@ re_fastaddc(EditLine *el) char mc = (c == '\177') ? '?' : (c | 0100); re_fastputc(el, '^'); re_fastputc(el, mc); - } else if (isprint((unsigned char) c) || ((unsigned char)c)>127) { /* normal char */ + } else if (isprint((unsigned char) c)) { /* normal char */ re_fastputc(el, c); } else { re_fastputc(el, '\\'); diff --git a/configure.in b/configure.in index 7c0505cb6ac..d9380a68267 100644 --- a/configure.in +++ b/configure.in @@ -2211,7 +2211,7 @@ then else MYSQL_CHECK_LIBEDIT_INTERFACE MYSQL_CHECK_NEW_RL_INTERFACE - if ["$mysql_cv_new_rl_interface"="yes"] || [test "$mysql_cv_libedit_interface"="no"] + if [test "$mysql_cv_new_rl_interface" = "yes"] || [test "$mysql_cv_libedit_interface" = "no"] then readline_link="-lreadline" else From 65ae25d092fe138ab0d0f9039a3ef8bc610b5031 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Apr 2003 13:52:48 +0500 Subject: [PATCH 09/25] New methods to store strings with "convert to" argimument --- sql/protocol.cc | 71 ++++++++++++++++++++++++++++++++++++++----------- sql/protocol.h | 6 +++++ sql/sql_class.h | 2 ++ 3 files changed, 64 insertions(+), 15 deletions(-) diff --git a/sql/protocol.cc b/sql/protocol.cc index 2d53d545066..f82981bd309 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -526,13 +526,16 @@ bool Protocol::send_fields(List *list, uint flag) if (thd->client_capabilities & CLIENT_PROTOCOL_41) { - if (prot.store(field.db_name, (uint) strlen(field.db_name), cs) || - prot.store(field.table_name, (uint) strlen(field.table_name), cs) || - prot.store(field.org_table_name, - (uint) strlen(field.org_table_name), cs) || - prot.store(field.col_name, (uint) strlen(field.col_name), cs) || - prot.store(field.org_col_name, - (uint) strlen(field.org_col_name), cs) || + if (prot.store(field.db_name, (uint) strlen(field.db_name), + cs, thd->charset()) || + prot.store(field.table_name, (uint) strlen(field.table_name), + cs, thd->charset()) || + prot.store(field.org_table_name, (uint) strlen(field.org_table_name), + cs, thd->charset()) || + prot.store(field.col_name, (uint) strlen(field.col_name), + cs, thd->charset()) || + prot.store(field.org_col_name, (uint) strlen(field.org_col_name), + cs, thd->charset()) || packet->realloc(packet->length()+12)) goto err; /* Store fixed length fields */ @@ -549,8 +552,10 @@ bool Protocol::send_fields(List *list, uint flag) } else { - if (prot.store(field.table_name, (uint) strlen(field.table_name), cs) || - prot.store(field.col_name, (uint) strlen(field.col_name), cs) || + if (prot.store(field.table_name, (uint) strlen(field.table_name), + cs, thd->charset()) || + prot.store(field.col_name, (uint) strlen(field.col_name), + cs, thd->charset()) || packet->realloc(packet->length()+10)) goto err; pos= (char*) packet->ptr()+packet->length(); @@ -694,7 +699,8 @@ bool Protocol_simple::store_null() #endif -bool Protocol_simple::store(const char *from, uint length, CHARSET_INFO *cs) +bool Protocol_simple::store(const char *from, uint length, + CHARSET_INFO *fromcs, CHARSET_INFO *tocs) { #ifndef DEBUG_OFF DBUG_ASSERT(field_types == 0 || @@ -703,12 +709,34 @@ bool Protocol_simple::store(const char *from, uint length, CHARSET_INFO *cs) field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); field_pos++; #endif - if (!my_charset_same(cs, this->thd->charset()) && - (cs != &my_charset_bin) && - (this->thd->charset() != &my_charset_bin) && - (this->thd->variables.convert_result_charset)) + if (!my_charset_same(fromcs, tocs) && + (fromcs != &my_charset_bin) && + (tocs != &my_charset_bin)) { - convert.copy(from, length, cs, this->thd->charset()); + convert.copy(from, length, fromcs, tocs); + return net_store_data(convert.ptr(), convert.length()); + } + else + return net_store_data(from, length); +} + + +bool Protocol_simple::store(const char *from, uint length, + CHARSET_INFO *fromcs) +{ + CHARSET_INFO *tocs= this->thd->result_charset(fromcs); +#ifndef DEBUG_OFF + DBUG_ASSERT(field_types == 0 || + field_types[field_pos] == MYSQL_TYPE_DECIMAL || + (field_types[field_pos] >= MYSQL_TYPE_ENUM && + field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); + field_pos++; +#endif + if (!my_charset_same(fromcs, tocs) && + (fromcs != &my_charset_bin) && + (tocs != &my_charset_bin)) + { + convert.copy(from, length, fromcs, tocs); return net_store_data(convert.ptr(), convert.length()); } else @@ -923,6 +951,19 @@ bool Protocol_prep::store(const char *from,uint length, CHARSET_INFO *cs) return net_store_data(from, length); } +bool Protocol_prep::store(const char *from,uint length, + CHARSET_INFO *fromcs, CHARSET_INFO *tocs) +{ +#ifndef DEBUG_OFF + DBUG_ASSERT(field_types == 0 || + field_types[field_pos] == MYSQL_TYPE_DECIMAL || + (field_types[field_pos] >= MYSQL_TYPE_ENUM && + field_types[field_pos] <= MYSQL_TYPE_GEOMETRY)); +#endif + field_pos++; + return net_store_data(from, length); +} + bool Protocol_prep::store_null() { uint offset= (field_pos+2)/8+1, bit= (1 << ((field_pos+2) & 7)); diff --git a/sql/protocol.h b/sql/protocol.h index 418814a9623..89b838ff6e4 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -74,6 +74,8 @@ public: virtual bool store_long(longlong from)=0; virtual bool store_longlong(longlong from, bool unsigned_flag)=0; virtual bool store(const char *from, uint length, CHARSET_INFO *cs)=0; + virtual bool store(const char *from, uint length, + CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0; virtual bool store(float from, uint32 decimals, String *buffer)=0; virtual bool store(double from, uint32 decimals, String *buffer)=0; virtual bool store(TIME *time)=0; @@ -97,6 +99,8 @@ public: virtual bool store_long(longlong from); virtual bool store_longlong(longlong from, bool unsigned_flag); virtual bool store(const char *from, uint length, CHARSET_INFO *cs); + virtual bool store(const char *from, uint length, + CHARSET_INFO *fromcs, CHARSET_INFO *tocs); virtual bool store(TIME *time); virtual bool store_date(TIME *time); virtual bool store_time(TIME *time); @@ -121,6 +125,8 @@ public: virtual bool store_long(longlong from); virtual bool store_longlong(longlong from, bool unsigned_flag); virtual bool store(const char *from,uint length, CHARSET_INFO *cs); + virtual bool store(const char *from, uint length, + CHARSET_INFO *fromcs, CHARSET_INFO *tocs); virtual bool store(TIME *time); virtual bool store_date(TIME *time); virtual bool store_time(TIME *time); diff --git a/sql/sql_class.h b/sql/sql_class.h index 097416985a2..9a853fc5736 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -662,6 +662,8 @@ public: DBUG_PRINT("error",("Fatal error set")); } inline CHARSET_INFO *charset() { return variables.thd_charset; } + inline CHARSET_INFO *result_charset(CHARSET_INFO *cs) + { return variables.convert_result_charset ? variables.thd_charset : cs; } }; /* From b9b15d52393f9aa33fbb6a6fdc40c8df75aadb81 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Apr 2003 16:10:27 +0500 Subject: [PATCH 10/25] sys_var_collation is now abstract class Two separate classes sys_var_client_collation and sys_var_literal_collation have been added for "literal_collation" and "client_collation" variables. --- sql/mysqld.cc | 2 + sql/protocol.cc | 4 +- sql/set_var.cc | 114 +++++++++++++++++++++++++++++---------------- sql/set_var.h | 28 ++++++++--- sql/sql_analyse.cc | 8 ++-- sql/sql_class.cc | 2 +- sql/sql_class.h | 7 +-- sql/sql_db.cc | 2 +- sql/sql_lex.cc | 5 +- sql/sql_lex.h | 1 - sql/sql_yacc.yy | 2 +- 11 files changed, 113 insertions(+), 62 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 0a3f453e4b6..a6338630568 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4567,6 +4567,8 @@ static void set_options(void) /* Set default values for some variables */ global_system_variables.convert_result_charset= TRUE; + global_system_variables.client_collation= default_charset_info; + global_system_variables.literal_collation= default_charset_info; global_system_variables.table_type= DB_TYPE_MYISAM; global_system_variables.tx_isolation= ISO_REPEATABLE_READ; global_system_variables.select_limit= (ulonglong) HA_POS_ERROR; diff --git a/sql/protocol.cc b/sql/protocol.cc index f82981bd309..195fec80ed0 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -805,7 +805,7 @@ bool Protocol_simple::store(float from, uint32 decimals, String *buffer) field_types[field_pos] == MYSQL_TYPE_FLOAT); field_pos++; #endif - buffer->set((double) from, decimals, thd->variables.thd_charset); + buffer->set((double) from, decimals, thd->charset()); return net_store_data((char*) buffer->ptr(), buffer->length()); } @@ -817,7 +817,7 @@ bool Protocol_simple::store(double from, uint32 decimals, String *buffer) field_types[field_pos] == MYSQL_TYPE_DOUBLE); field_pos++; #endif - buffer->set(from, decimals, thd->variables.thd_charset); + buffer->set(from, decimals, thd->charset()); return net_store_data((char*) buffer->ptr(), buffer->length()); } diff --git a/sql/set_var.cc b/sql/set_var.cc index 127988b8c4e..ddebf47a25d 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -133,6 +133,7 @@ sys_var_thd_ulong sys_join_buffer_size("join_buffer_size", sys_var_ulonglong_ptr sys_key_buffer_size("key_buffer_size", &keybuff_size, fix_key_buffer_size); +sys_var_literal_collation sys_literal_collation("literal_collation"); sys_var_bool_ptr sys_local_infile("local_infile", &opt_local_infile); sys_var_thd_bool sys_log_warnings("log_warnings", &SV::log_warnings); @@ -363,6 +364,7 @@ sys_var *sys_variables[]= &sys_interactive_timeout, &sys_join_buffer_size, &sys_key_buffer_size, + &sys_literal_collation, &sys_last_insert_id, &sys_local_infile, &sys_log_binlog, @@ -507,6 +509,7 @@ struct show_var_st init_vars[]= { {sys_key_buffer_size.name, (char*) &sys_key_buffer_size, SHOW_SYS}, {"language", language, SHOW_CHAR}, {"large_files_support", (char*) &opt_large_files, SHOW_BOOL}, + {sys_literal_collation.name,(char*) &sys_literal_collation, SHOW_SYS}, {sys_local_infile.name, (char*) &sys_local_infile, SHOW_SYS}, #ifdef HAVE_MLOCKALL {"locked_in_memory", (char*) &locked_in_memory, SHOW_BOOL}, @@ -1155,7 +1158,8 @@ byte *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type) } -typedef struct old_names_map_st { +typedef struct old_names_map_st +{ const char *old_name; const char *new_name; } my_old_conv; @@ -1187,20 +1191,12 @@ CHARSET_INFO *get_old_charset_by_name(const char *name) return NULL; } -bool sys_var_client_collation::check(THD *thd, set_var *var) +bool sys_var_collation::check(THD *thd, set_var *var) { CHARSET_INFO *tmp; char buff[80]; String str(buff,sizeof(buff), system_charset_info), *res; - if (!var->value) // Default value - { - var->save_result.charset= (var->type != OPT_GLOBAL ? - global_system_variables.thd_charset - : thd->db_charset); - return 0; - } - if (!(res=var->value->val_str(&str))) res= &empty_string; @@ -1217,27 +1213,90 @@ bool sys_var_client_collation::check(THD *thd, set_var *var) bool sys_var_client_collation::update(THD *thd, set_var *var) { if (var->type == OPT_GLOBAL) - global_system_variables.thd_charset= var->save_result.charset; + global_system_variables.client_collation= var->save_result.charset; else { - thd->variables.thd_charset= var->save_result.charset; + thd->variables.client_collation= var->save_result.charset; thd->protocol_simple.init(thd); thd->protocol_prep.init(thd); } return 0; } - byte *sys_var_client_collation::value_ptr(THD *thd, enum_var_type type) { CHARSET_INFO *cs= ((type == OPT_GLOBAL) ? - global_system_variables.thd_charset : - thd->variables.thd_charset); + global_system_variables.client_collation : + thd->variables.client_collation); return cs ? (byte*) cs->name : (byte*) ""; } +void sys_var_client_collation::set_default(THD *thd, enum_var_type type) +{ + if (type == OPT_GLOBAL) + global_system_variables.client_collation= default_charset_info; + else + { + thd->variables.client_collation= thd->db_charset; + } +} +bool sys_var_literal_collation::update(THD *thd, set_var *var) +{ + if (var->type == OPT_GLOBAL) + global_system_variables.literal_collation= var->save_result.charset; + else + thd->variables.literal_collation= var->save_result.charset; + return 0; +} + +byte *sys_var_literal_collation::value_ptr(THD *thd, enum_var_type type) +{ + CHARSET_INFO *cs= ((type == OPT_GLOBAL) ? + global_system_variables.literal_collation : + thd->variables.literal_collation); + return cs ? (byte*) cs->name : (byte*) ""; +} + +void sys_var_literal_collation::set_default(THD *thd, enum_var_type type) +{ + if (type == OPT_GLOBAL) + global_system_variables.literal_collation= default_charset_info; + else + thd->variables.literal_collation= thd->db_charset; +} + + +/***************************************************************************** + Functions to handle SET NAMES and SET CHARACTER SET +*****************************************************************************/ + +int set_var_client_collation::check(THD *thd) +{ + client_charset= client_charset ? client_charset : thd->db_charset; + client_collation= client_collation ? client_collation : client_charset; + if (!my_charset_same(client_charset, client_collation)) + { + my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), + client_collation->name, client_charset->csname); + return -1; + } + return 0; +} + +int set_var_client_collation::update(THD *thd) +{ + thd->variables.client_collation= client_collation; + thd->variables.literal_collation= client_collation; + thd->variables.convert_result_charset= convert_result_charset; + thd->protocol_simple.init(thd); + thd->protocol_prep.init(thd); + return 0; +} + +/****************************************************************************/ + bool sys_var_timestamp::update(THD *thd, set_var *var) { thd->set_time((time_t) var->value->val_int()); @@ -1656,31 +1715,6 @@ int set_var_password::update(THD *thd) } -/***************************************************************************** - Functions to handle SET NAMES and SET CHARACTER SET -*****************************************************************************/ - -int set_var_client_collation::check(THD *thd) -{ - client_charset= client_charset ? client_charset : thd->db_charset; - client_collation= client_collation ? client_collation : client_charset; - if (!my_charset_same(client_charset, client_collation)) - { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - client_collation->name, client_charset->csname); - return -1; - } - return 0; -} - -int set_var_client_collation::update(THD *thd) -{ - thd->variables.thd_charset= client_collation; - thd->variables.convert_result_charset= convert_result_charset; - thd->protocol_simple.init(thd); - thd->protocol_prep.init(thd); - return 0; -} diff --git a/sql/set_var.h b/sql/set_var.h index 7b2f9d5cb80..51f59981e14 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -406,20 +406,36 @@ public: }; -class sys_var_client_collation :public sys_var_thd +class sys_var_collation :public sys_var_thd { public: - sys_var_client_collation(const char *name_arg) :sys_var_thd(name_arg) - {} + sys_var_collation(const char *name_arg) :sys_var_thd(name_arg) {} bool check(THD *thd, set_var *var); - bool update(THD *thd, set_var *var); - SHOW_TYPE type() { return SHOW_CHAR; } - byte *value_ptr(THD *thd, enum_var_type type); +SHOW_TYPE type() { return SHOW_CHAR; } bool check_update_type(Item_result type) { return type != STRING_RESULT; /* Only accept strings */ } bool check_default(enum_var_type type) { return 0; } + virtual void set_default(THD *thd, enum_var_type type)= 0; +}; + +class sys_var_client_collation :public sys_var_collation +{ +public: + sys_var_client_collation(const char *name_arg) :sys_var_collation(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); +}; + +class sys_var_literal_collation :public sys_var_collation +{ +public: + sys_var_literal_collation(const char *name_arg) :sys_var_collation(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); }; diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 9bcfff62ba0..1f5462f8a3b 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -901,14 +901,14 @@ int collect_real(double *element, element_count count __attribute__((unused)), TREE_INFO *info) { char buff[MAX_FIELD_WIDTH]; - String s(buff, sizeof(buff),current_thd->variables.thd_charset); + String s(buff, sizeof(buff),current_thd->charset()); if (info->found) info->str->append(','); else info->found = 1; info->str->append('\''); - s.set(*element, info->item->decimals, current_thd->variables.thd_charset); + s.set(*element, info->item->decimals, current_thd->charset()); info->str->append(s); info->str->append('\''); return 0; @@ -927,7 +927,7 @@ int collect_longlong(longlong *element, else info->found = 1; info->str->append('\''); - s.set(*element, current_thd->variables.thd_charset); + s.set(*element, current_thd->charset()); info->str->append(s); info->str->append('\''); return 0; @@ -946,7 +946,7 @@ int collect_ulonglong(ulonglong *element, else info->found = 1; info->str->append('\''); - s.set(*element, current_thd->variables.thd_charset); + s.set(*element, current_thd->charset()); info->str->append(s); info->str->append('\''); return 0; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 8fd507c2349..31159dc259f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -207,7 +207,7 @@ void THD::init(void) { pthread_mutex_lock(&LOCK_global_system_variables); variables= global_system_variables; - variables.thd_charset=default_charset_info; + variables.client_collation= default_charset_info; pthread_mutex_unlock(&LOCK_global_system_variables); server_status= SERVER_STATUS_AUTOCOMMIT; options= thd_startup_options; diff --git a/sql/sql_class.h b/sql/sql_class.h index 9a853fc5736..1d4dafb997e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -380,7 +380,8 @@ struct system_variables my_bool new_mode; my_bool convert_result_charset; - CHARSET_INFO *thd_charset; + CHARSET_INFO *client_collation; + CHARSET_INFO *literal_collation; }; void free_tmp_table(THD *thd, TABLE *entry); @@ -661,9 +662,9 @@ public: net.report_error= 1; DBUG_PRINT("error",("Fatal error set")); } - inline CHARSET_INFO *charset() { return variables.thd_charset; } + inline CHARSET_INFO *charset() { return variables.client_collation; } inline CHARSET_INFO *result_charset(CHARSET_INFO *cs) - { return variables.convert_result_charset ? variables.thd_charset : cs; } + { return variables.convert_result_charset ? charset() : cs; } }; /* diff --git a/sql/sql_db.cc b/sql/sql_db.cc index ffa5416eaf5..903fcce6350 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -602,7 +602,7 @@ bool mysql_change_db(THD *thd, const char *name) 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; - thd->variables.thd_charset=thd->db_charset ? thd->db_charset : default_charset_info; + thd->variables.client_collation=thd->db_charset ? thd->db_charset : default_charset_info; DBUG_RETURN(0); } diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 88375b9469b..d5d438fc3a1 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -118,7 +118,6 @@ LEX *lex_start(THD *thd, uchar *buf,uint length) lex->select_lex.ftfunc_list_alloc.empty(); lex->select_lex.ftfunc_list= &lex->select_lex.ftfunc_list_alloc; lex->current_select= &lex->select_lex; - lex->thd_charset= lex->thd->variables.thd_charset; lex->yacc_yyss=lex->yacc_yyvs=0; lex->ignore_space=test(thd->variables.sql_mode & MODE_IGNORE_SPACE); lex->sql_command=SQLCOM_END; @@ -209,7 +208,7 @@ static char *get_text(LEX *lex) { reg1 uchar c,sep; uint found_escape=0; - CHARSET_INFO *cs= lex->thd->variables.thd_charset; + CHARSET_INFO *cs= lex->thd->charset(); sep= yyGetLast(); // String should end with this //lex->tok_start=lex->ptr-1; // Remember ' @@ -422,7 +421,7 @@ int yylex(void *arg, void *yythd) enum my_lex_states state,prev_state; LEX *lex= &(((THD *)yythd)->lex); YYSTYPE *yylval=(YYSTYPE*) arg; - CHARSET_INFO *cs= ((THD *) yythd)->variables.thd_charset; + CHARSET_INFO *cs= ((THD *) yythd)->charset(); uchar *state_map= cs->state_map; uchar *ident_map= cs->ident_map; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 046b67816f1..9fb0f8cfdf5 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -448,7 +448,6 @@ typedef struct st_lex TYPELIB *interval; create_field *last_field; Item *default_value, *comment; - CHARSET_INFO *thd_charset; uint uint_geom_type; LEX_USER *grant_user; gptr yacc_yyss,yacc_yyvs; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 07325d9a1b0..a8c02bf86f2 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2167,7 +2167,7 @@ simple_expr: | simple_expr COLLATE_SYM ident_or_text %prec NEG { $$= new Item_func_set_collation($1,new Item_string($3.str,$3.length, - YYTHD->variables.thd_charset)); + YYTHD->charset())); } | literal | param_marker From f390da2270e6c6ad7c7cbf8817d4be8470d6e50a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Apr 2003 18:49:56 +0500 Subject: [PATCH 11/25] All collation names are now fit into convension --- sql/share/charsets/Index.xml | 90 +++++++++------------------------ sql/share/charsets/cp1257.xml | 2 +- sql/share/charsets/greek.xml | 2 +- sql/share/charsets/hebrew.xml | 2 +- sql/share/charsets/keybcs2.xml | 2 +- sql/share/charsets/macce.xml | 2 +- sql/share/charsets/macroman.xml | 2 +- strings/ctype-big5.c | 2 +- strings/ctype-euc_kr.c | 2 +- strings/ctype-gb2312.c | 2 +- strings/ctype-gbk.c | 2 +- strings/ctype-sjis.c | 2 +- strings/ctype-tis620.c | 2 +- strings/ctype-ujis.c | 2 +- strings/ctype-utf8.c | 4 +- 15 files changed, 40 insertions(+), 80 deletions(-) diff --git a/sql/share/charsets/Index.xml b/sql/share/charsets/Index.xml index ec93d68ea8f..9b95326fe9e 100644 --- a/sql/share/charsets/Index.xml +++ b/sql/share/charsets/Index.xml @@ -17,7 +17,7 @@ To make maintaining easier please: big-five cn-big5 csbig5 - + primary compiled" @@ -169,7 +169,7 @@ To make maintaining easier please: Japanese EUC-JP Japanese euc-jp - + @@ -178,7 +178,7 @@ To make maintaining easier please: s-jis shift-jis x-sjis - + @@ -224,15 +224,15 @@ To make maintaining easier please: csisolatinhebrew iso-8859-8 iso-ir-138 - - + + Thai TIS620 Thai tis-620 - + primary compiled @@ -243,7 +243,7 @@ To make maintaining easier please: EUC-KR Korean euc_kr euc-kr - + primary compiled" @@ -283,7 +283,7 @@ To make maintaining easier please: GB2312 Simplified Chinese chinese iso-ir-58 - + primary compiled" @@ -297,8 +297,8 @@ To make maintaining easier please: greek8 iso-8859-7 iso-ir-126 - - + + @@ -323,7 +323,7 @@ To make maintaining easier please: East Asian GBK Simplified Chinese cp936 - + primary compiled @@ -336,18 +336,12 @@ To make maintaining easier please: windows-1257 - - Latvian - Lithuanian - - - Latvian - Lithuanian - - + Latvian Lithuanian + + @@ -375,14 +369,14 @@ To make maintaining easier please: Unicode UTF-8 Unicode utf-8 - - + + Unicode UCS-2 Unicode - + @@ -399,15 +393,15 @@ To make maintaining easier please: Central European DOS Kamenicky Czech-Slovak - - + + Central European Mac Central European MacCentralEurope - + Hungarian Polish Romanian @@ -418,24 +412,8 @@ To make maintaining easier please: - - Hungarian - Polish - Romanian - Croatian - Slovak - Slovenian - Sorbian - - - Hungarian - Polish - Romanian - Croatian - Slovak - Slovenian - Sorbian - + + @@ -444,7 +422,7 @@ To make maintaining easier please: Mac Macintosh csmacintosh - + Dutch English French @@ -455,27 +433,9 @@ To make maintaining easier please: Spanish - - Dutch - English - French - German Duden - Italian - Latin - Portuguese - Spanish - + - - Dutch - English - French - German Duden - Italian - Latin - Portuguese - Spanish - + diff --git a/sql/share/charsets/cp1257.xml b/sql/share/charsets/cp1257.xml index adefac80c8b..bd4489a5a79 100644 --- a/sql/share/charsets/cp1257.xml +++ b/sql/share/charsets/cp1257.xml @@ -118,7 +118,7 @@ - + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F diff --git a/sql/share/charsets/greek.xml b/sql/share/charsets/greek.xml index 6d8d0954655..defeaf049c8 100644 --- a/sql/share/charsets/greek.xml +++ b/sql/share/charsets/greek.xml @@ -97,7 +97,7 @@ - + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F diff --git a/sql/share/charsets/hebrew.xml b/sql/share/charsets/hebrew.xml index fbd4ea0c1d2..ec3fa242ced 100644 --- a/sql/share/charsets/hebrew.xml +++ b/sql/share/charsets/hebrew.xml @@ -93,7 +93,7 @@ - + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F diff --git a/sql/share/charsets/keybcs2.xml b/sql/share/charsets/keybcs2.xml index e509207c1c5..6180dd8550d 100644 --- a/sql/share/charsets/keybcs2.xml +++ b/sql/share/charsets/keybcs2.xml @@ -93,7 +93,7 @@ - + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F diff --git a/sql/share/charsets/macce.xml b/sql/share/charsets/macce.xml index 0f39cb14b31..7e955157bb7 100644 --- a/sql/share/charsets/macce.xml +++ b/sql/share/charsets/macce.xml @@ -93,7 +93,7 @@ - + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F diff --git a/sql/share/charsets/macroman.xml b/sql/share/charsets/macroman.xml index 8c8a9070084..ffedaa88274 100644 --- a/sql/share/charsets/macroman.xml +++ b/sql/share/charsets/macroman.xml @@ -90,7 +90,7 @@ - + 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 7be631bbe05..57ee2d7c6ae 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -6231,7 +6231,7 @@ CHARSET_INFO my_charset_big5 = 1,0,0, /* number */ MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM, /* state */ "big5", /* cs name */ - "big5", /* name */ + "big5_chinese_ci", /* name */ "", /* comment */ ctype_big5, to_lower_big5, diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index 0766cd40040..21f01b6509c 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -8639,7 +8639,7 @@ CHARSET_INFO my_charset_euc_kr = 19,0,0, /* number */ MY_CS_COMPILED|MY_CS_PRIMARY, /* state */ "euckr", /* cs name */ - "euckr", /* name */ + "euckr_korean_ci", /* name */ "", /* comment */ ctype_euc_kr, to_lower_euc_kr, diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index ec495be5e84..f1ec5a9f363 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -5689,7 +5689,7 @@ CHARSET_INFO my_charset_gb2312 = 24,0,0, /* number */ MY_CS_COMPILED|MY_CS_PRIMARY, /* state */ "gb2312", /* cs name */ - "gb2312", /* name */ + "gb2312_chinese_ci",/* name */ "", /* comment */ ctype_gb2312, to_lower_gb2312, diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 7673f4e6c23..b1ea209d6ad 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -9886,7 +9886,7 @@ CHARSET_INFO my_charset_gbk = 28,0,0, /* number */ MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM, /* state */ "gbk", /* cs name */ - "gbk", /* name */ + "gbk_chinese_ci", /* name */ "", /* comment */ ctype_gbk, to_lower_gbk, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index b2b1a40bdcc..fd911f1867e 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4473,7 +4473,7 @@ CHARSET_INFO my_charset_sjis = 13,0,0, /* number */ MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM, /* state */ "sjis", /* cs name */ - "sjis", /* name */ + "sjis_japanese_ci", /* name */ "", /* comment */ ctype_sjis, to_lower_sjis, diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 9da7b02ed31..21722f317a1 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -701,7 +701,7 @@ CHARSET_INFO my_charset_tis620 = 18,0,0, /* number */ MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM, /* state */ "tis620", /* cs name */ - "tis620", /* name */ + "tis620_thai_ci", /* name */ "", /* comment */ ctype_tis620, to_lower_tis620, diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index de73608293c..92214868018 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -8430,7 +8430,7 @@ CHARSET_INFO my_charset_ujis = 12,0,0, /* number */ MY_CS_COMPILED|MY_CS_PRIMARY, /* state */ "ujis", /* cs name */ - "ujis", /* name */ + "ujis_japanese_ci", /* name */ "", /* comment */ ctype_ujis, to_lower_ujis, diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 69500f6d3d6..4c908014994 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1955,7 +1955,7 @@ CHARSET_INFO my_charset_utf8 = 33,0,0, /* number */ MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM, /* state */ "utf8", /* cs name */ - "utf8", /* name */ + "utf8_general_ci", /* name */ "", /* comment */ ctype_utf8, /* ctype */ to_lower_utf8, /* to_lower */ @@ -3030,7 +3030,7 @@ CHARSET_INFO my_charset_ucs2 = 35,0,0, /* number */ MY_CS_COMPILED|MY_CS_PRIMARY|MY_CS_STRNXFRM, /* state */ "ucs2", /* cs name */ - "ucs2", /* name */ + "ucs2_general_ci", /* name */ "", /* comment */ ctype_ucs2, /* ctype */ to_lower_ucs2, /* to_lower */ From 0695239a64362d6bcf753ea30439320a742ec2fe Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Apr 2003 03:54:02 +0300 Subject: [PATCH 12/25] A better fix for UNION and slow query log. sql/sql_union.cc: A better fix for UNION and slow query log. This patch also fixes some indentation issues --- sql/sql_union.cc | 71 ++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 2be8268e432..88c461bc0f8 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000 MySQL AB +/* Copyright (C) 2000-2003 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -68,6 +68,7 @@ int select_union::prepare(List &list, SELECT_LEX_UNIT *u) return 0; } + bool select_union::send_data(List &values) { if (unit->offset_limit_cnt) @@ -91,11 +92,13 @@ bool select_union::send_data(List &values) return 0; } + bool select_union::send_eof() { return 0; } + bool select_union::flush() { int error; @@ -108,9 +111,13 @@ bool select_union::flush() return 0; } -int st_select_lex_unit::prepare(THD *thd, select_result *result, + +int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, bool tables_and_fields_initied) { + SELECT_LEX_NODE *lex_select_save= thd->lex.current_select; + SELECT_LEX *select_cursor; + TMP_TABLE_PARAM tmp_table_param; DBUG_ENTER("st_select_lex_unit::prepare"); if (prepared) @@ -118,11 +125,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result, prepared= 1; res= 0; found_rows_for_union= 0; - TMP_TABLE_PARAM tmp_table_param; - this->result= result; + result= sel_result; t_and_f= tables_and_fields_initied; - SELECT_LEX_NODE *lex_select_save= thd->lex.current_select; - SELECT_LEX *select_cursor; thd->lex.current_select= select_cursor= first_select_in_union(); /* Global option */ @@ -144,7 +148,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result, TABLE_LIST *first_table= (TABLE_LIST*) select_cursor->table_list.first; if (setup_tables(first_table) || - setup_wild(thd, first_table, select_cursor->item_list, 0, select_cursor->with_wild)) + setup_wild(thd, first_table, select_cursor->item_list, 0, + select_cursor->with_wild)) goto err; List_iterator it(select_cursor->item_list); Item *item; @@ -156,8 +161,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result, (item_list.elements + select_cursor->with_sum_func + select_cursor->order_list.elements + select_cursor->group_list.elements)) || - setup_fields(thd, select_cursor->ref_pointer_array, first_table, item_list, - 0, 0, 1)) + setup_fields(thd, select_cursor->ref_pointer_array, first_table, + item_list, 0, 0, 1)) goto err; t_and_f= 1; } @@ -183,11 +188,11 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result, union_result->not_describe=1; union_result->tmp_table_param=&tmp_table_param; -/* - the following piece of code is placed here solely for the purpose of - getting correct results with EXPLAIN when UNION is withing a sub-select - or derived table ... -*/ + /* + The following piece of code is placed here solely for the purpose of + getting correct results with EXPLAIN when UNION is withing a sub-select + or derived table ... + */ if (thd->lex.describe) { @@ -216,7 +221,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result, (ORDER*) NULL, sl, this, t_and_f); t_and_f= 0; - if (res | thd->is_fatal_error) + if (res || thd->is_fatal_error) goto err; } } @@ -235,7 +240,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *result, } } - DBUG_RETURN(res | thd->is_fatal_error); + DBUG_RETURN(res || thd->is_fatal_error ? 1 : 0); err: thd->lex.current_select= lex_select_save; DBUG_RETURN(-1); @@ -244,17 +249,18 @@ err: int st_select_lex_unit::exec() { - DBUG_ENTER("st_select_lex_unit::exec"); + int do_print_slow= 0; SELECT_LEX_NODE *lex_select_save= thd->lex.current_select; SELECT_LEX *select_cursor=first_select_in_union(), *last_select; + DBUG_ENTER("st_select_lex_unit::exec"); + LINT_INIT(last_select); - bool do_print_slow=0; if (executed && !(dependent || uncacheable)) DBUG_RETURN(0); executed= 1; - if ((dependent||uncacheable) || !item || !item->assigned()) + if ((dependent || uncacheable) || !item || !item->assigned()) { if (optimized && item && item->assigned()) { @@ -314,7 +320,7 @@ int st_select_lex_unit::exec() thd->lex.current_select= lex_select_save; DBUG_RETURN(res); } - do_print_slow = do_print_slow || (select_cursor->options & (QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED)); + do_print_slow|= select_cursor->options; } } optimized= 1; @@ -322,8 +328,8 @@ int st_select_lex_unit::exec() /* Send result to 'result' */ // to correct ORDER BY reference resolving - thd->lex.current_select = select_cursor; - res =-1; + thd->lex.current_select= select_cursor; + res= -1; { List empty_list; empty_list.empty(); @@ -332,9 +338,11 @@ int st_select_lex_unit::exec() { SELECT_LEX *fake_select = new SELECT_LEX(); fake_select->make_empty_select(last_select); - offset_limit_cnt= (select_cursor->braces) ? global_parameters->offset_limit : 0; - select_limit_cnt= (select_cursor->braces) ? global_parameters->select_limit+ - global_parameters->offset_limit : HA_POS_ERROR; + offset_limit_cnt= (select_cursor->braces ? + global_parameters->offset_limit : 0); + select_limit_cnt= (select_cursor->braces ? + global_parameters->select_limit+ + global_parameters->offset_limit : HA_POS_ERROR); if (select_limit_cnt < global_parameters->select_limit) select_limit_cnt= HA_POS_ERROR; // no limit if (select_limit_cnt == HA_POS_ERROR) @@ -351,14 +359,23 @@ int st_select_lex_unit::exec() thd->limit_found_rows = (ulonglong)table->file->records; fake_select->exclude(); delete fake_select; - if (select_cursor == &thd->lex.select_lex && !do_print_slow) - select_cursor->options &= ~(QUERY_NO_INDEX_USED | QUERY_NO_GOOD_INDEX_USED); + /* + Mark for slow query log if any of the union parts didn't use + indexes efficiently + */ + select_cursor->options= ((select_cursor->options & + ~(QUERY_NO_INDEX_USED | + QUERY_NO_GOOD_INDEX_USED)) | + do_print_slow & + (QUERY_NO_INDEX_USED | + QUERY_NO_GOOD_INDEX_USED)); } } thd->lex.current_select= lex_select_save; DBUG_RETURN(res); } + int st_select_lex_unit::cleanup() { int error= 0; From f20835c7aa678dfb043d683346bec920ce8895d9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Apr 2003 11:33:54 +0500 Subject: [PATCH 13/25] SET NAMES doesn't start recoding SET CHARACTER SET does --- mysql-test/r/ctype_many.result | 10 +++++----- mysql-test/r/ctype_recoding.result | 14 +++++++------- mysql-test/t/ctype_many.test | 10 +++++----- mysql-test/t/ctype_recoding.test | 6 +++--- sql/set_var.cc | 10 ++++++---- sql/sql_db.cc | 1 - sql/sql_yacc.yy | 2 +- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result index 4d31ab6c274..d6b6429d021 100644 --- a/mysql-test/r/ctype_many.result +++ b/mysql-test/r/ctype_many.result @@ -1,5 +1,5 @@ DROP TABLE IF EXISTS t1; -SET NAMES latin1; +SET CHARACTER SET latin1; CREATE TABLE t1 ( comment CHAR(32) ASCII NOT NULL, koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL @@ -158,7 +158,7 @@ INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r' INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ü','CYR CAPIT E'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'à','CYR CAPIT YU'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ñ','CYR CAPIT YA'); -SET NAMES utf8; +SET CHARACTER SET utf8; SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1; koi8_ru_f MIN(comment) COUNT(*) a LAT CAPIT A 2 @@ -221,7 +221,7 @@ z LAT CAPIT Z 2 Ñ CYR CAPIT YA 2 ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); -SET NAMES koi8r; +SET CHARACTER SET koi8r; SELECT * FROM t1; comment koi8_ru_f utf8_f LAT SMALL A a a @@ -1300,7 +1300,7 @@ CYR CAPIT YA CYR CAPIT YA CYR CAPIT YA CYR SMALL YA CYR SMALL YA CYR CAPIT YA CYR SMALL YA CYR SMALL YA -SET NAMES utf8; +SET CHARACTER SET utf8; ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2; ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL; INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA'); @@ -1471,7 +1471,7 @@ ARMENIAN SMALL GIM Õ£ Õ£ Õ£ ARMENIAN SMALL DA Õ¤ Õ¤ Õ¤ ARMENIAN SMALL ECH Õ¥ Õ¥ Õ¥ ARMENIAN SMALL ZA Õ¦ Õ¦ Õ¦ -SET NAMES 'binary'; +SET CHARACTER SET 'binary'; SELECT * FROM t1; comment koi8_ru_f utf8_f bin_f ucs2_f armscii8_f greek_f LAT SMALL A a a a a diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index ea4ec8d068c..99e4864bcf6 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -6,16 +6,16 @@ CREATE TABLE ); SHOW TABLES; Tables_in_test -ÔÁÂÌÉÃÁ +таблица SHOW CREATE TABLE ÔÁÂÌÉÃÁ; Table Create Table -ÔÁÂÌÉÃÁ CREATE TABLE `ÔÁÂÌÉÃÁ` ( - `ÐÏÌÅ` char(32) character set koi8r NOT NULL default '' +таблица CREATE TABLE `таблица` ( + `поле` char(32) character set koi8r NOT NULL default '' ) TYPE=MyISAM CHARSET=latin1 SHOW FIELDS FROM ÔÁÂÌÉÃÁ; Field Type Collation Null Key Default Extra -ÐÏÌÅ char(32) character set koi8r koi8r_general_ci -SET NAMES cp1251; +поле char(32) character set koi8r koi8r_general_ci +SET CHARACTER SET cp1251; SHOW TABLES; Tables_in_test òàáëèöà @@ -27,7 +27,7 @@ Table Create Table SHOW FIELDS FROM òàáëèöà; Field Type Collation Null Key Default Extra ïîëå char(32) character set koi8r koi8r_general_ci -SET NAMES utf8; +SET CHARACTER SET utf8; SHOW TABLES; Tables_in_test таблица @@ -39,5 +39,5 @@ Table Create Table SHOW FIELDS FROM таблица; Field Type Collation Null Key Default Extra поле char(32) character set koi8r koi8r_general_ci -SET NAMES koi8r; +SET CHARACTER SET koi8r; DROP TABLE ÔÁÂÌÉÃÁ; diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test index 05f3687d330..8378ef35685 100644 --- a/mysql-test/t/ctype_many.test +++ b/mysql-test/t/ctype_many.test @@ -2,7 +2,7 @@ DROP TABLE IF EXISTS t1; --enable_warnings -SET NAMES latin1; +SET CHARACTER SET latin1; CREATE TABLE t1 ( comment CHAR(32) ASCII NOT NULL, @@ -137,12 +137,12 @@ INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r' INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'à','CYR CAPIT YU'); INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ñ','CYR CAPIT YA'); -SET NAMES utf8; +SET CHARACTER SET utf8; SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1; ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL; UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8); -SET NAMES koi8r; +SET CHARACTER SET koi8r; SELECT * FROM t1; ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL; @@ -165,7 +165,7 @@ FROM t1 t11,t1 t12 WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8r) ORDER BY t12.utf8_f,t11.comment,t12.comment; -SET NAMES utf8; +SET CHARACTER SET utf8; ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2; ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL; @@ -199,7 +199,7 @@ UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE _lati UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=_utf8''; UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=_ucs2''; SELECT * FROM t1; -SET NAMES 'binary'; +SET CHARACTER SET 'binary'; SELECT * FROM t1; SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f; DROP TABLE t1; diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index c0b7139c791..cb5f4997000 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -13,16 +13,16 @@ SHOW TABLES; SHOW CREATE TABLE ÔÁÂÌÉÃÁ; SHOW FIELDS FROM ÔÁÂÌÉÃÁ; -SET NAMES cp1251; +SET CHARACTER SET cp1251; SHOW TABLES; SHOW CREATE TABLE òàáëèöà; SHOW FIELDS FROM òàáëèöà; -SET NAMES utf8; +SET CHARACTER SET utf8; SHOW TABLES; SHOW CREATE TABLE таблица; SHOW FIELDS FROM таблица; -SET NAMES koi8r; +SET CHARACTER SET koi8r; DROP TABLE ÔÁÂÌÉÃÁ; diff --git a/sql/set_var.cc b/sql/set_var.cc index ddebf47a25d..b5094e6403a 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1237,7 +1237,7 @@ void sys_var_client_collation::set_default(THD *thd, enum_var_type type) global_system_variables.client_collation= default_charset_info; else { - thd->variables.client_collation= thd->db_charset; + thd->variables.client_collation= global_system_variables.client_collation; } } @@ -1264,7 +1264,7 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type) if (type == OPT_GLOBAL) global_system_variables.literal_collation= default_charset_info; else - thd->variables.literal_collation= thd->db_charset; + thd->variables.literal_collation= global_system_variables.literal_collation; } @@ -1274,7 +1274,8 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type) int set_var_client_collation::check(THD *thd) { - client_charset= client_charset ? client_charset : thd->db_charset; + client_charset= client_charset ? + client_charset : global_system_variables.client_collation; client_collation= client_collation ? client_collation : client_charset; if (!my_charset_same(client_charset, client_collation)) { @@ -1288,7 +1289,8 @@ int set_var_client_collation::check(THD *thd) int set_var_client_collation::update(THD *thd) { thd->variables.client_collation= client_collation; - thd->variables.literal_collation= client_collation; + thd->variables.literal_collation= convert_result_charset ? + thd->db_charset: client_collation; thd->variables.convert_result_charset= convert_result_charset; thd->protocol_simple.init(thd); thd->protocol_prep.init(thd); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 903fcce6350..fe8a945bff8 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -602,7 +602,6 @@ bool mysql_change_db(THD *thd, const char *name) 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; - thd->variables.client_collation=thd->db_charset ? thd->db_charset : default_charset_info; DBUG_RETURN(0); } diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a8c02bf86f2..bb6e445bfc2 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4411,7 +4411,7 @@ option_value: | NAMES_SYM charset_name_or_default opt_collate { LEX *lex= Lex; - lex->var_list.push_back(new set_var_client_collation($2,$3,1)); + lex->var_list.push_back(new set_var_client_collation($2,$3,0)); } | PASSWORD equal text_or_password { From 8c95b516254b3af107dc8d8407f864ebcce79ee5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Apr 2003 14:38:17 +0500 Subject: [PATCH 14/25] Use of CHARSWT_INFO *result_collation instead of bool convert_result_charset SET CHARACTER SET inststead of SET NAMES in tests --- mysql-test/r/ctype_collate.result | 24 +++++++-------- mysql-test/r/ctype_recoding.result | 10 +++--- mysql-test/t/ctype_collate.test | 22 +++++++------- mysql-test/t/ctype_recoding.test | 2 +- sql/mysqld.cc | 6 +++- sql/protocol.cc | 5 ++- sql/set_var.cc | 48 ++++++++++++++++++----------- sql/set_var.h | 23 ++++++++++---- sql/sql_class.h | 6 ++-- sql/sql_yacc.yy | 49 +++++++++++++++++++----------- 10 files changed, 118 insertions(+), 77 deletions(-) diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result index 0be2bf5f54b..af231bb7930 100644 --- a/mysql-test/r/ctype_collate.result +++ b/mysql-test/r/ctype_collate.result @@ -510,11 +510,11 @@ t1 CREATE TABLE `t1` ( SHOW FIELDS FROM t1; Field Type Collation Null Key Default Extra latin1_f char(32) latin1_bin YES NULL -SET NAMES 'latin1'; +SET CHARACTER SET 'latin1'; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation latin1_swedish_ci -SET NAMES latin1; +SET CHARACTER SET latin1; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation latin1_swedish_ci @@ -524,51 +524,51 @@ client_collation latin1_swedish_ci SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' latin1 latin1_swedish_ci 3 1 -SET NAMES latin1 COLLATE latin1_bin; +SET CHARACTER SET latin1 COLLATE latin1_bin; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation latin1_bin -SET NAMES LATIN1 COLLATE Latin1_Bin; +SET CHARACTER SET LATIN1 COLLATE Latin1_Bin; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation latin1_bin -SET NAMES 'latin1' COLLATE 'latin1_bin'; +SET CHARACTER SET 'latin1' COLLATE 'latin1_bin'; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation latin1_bin SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' -latin1 latin1_bin 3 0 -SET NAMES koi8r; +latin1 latin1_swedish_ci 3 1 +SET CHARACTER SET koi8r; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation koi8r_general_ci SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' latin1 latin1_swedish_ci 3 1 -SET NAMES koi8r COLLATE koi8r_bin; +SET CHARACTER SET koi8r COLLATE koi8r_bin; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation koi8r_bin SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' latin1 latin1_swedish_ci 3 1 -SET NAMES koi8r COLLATE DEFAULT; +SET CHARACTER SET koi8r COLLATE DEFAULT; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation koi8r_general_ci SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' latin1 latin1_swedish_ci 3 1 -SET NAMES DEFAULT; +SET CHARACTER SET DEFAULT; SHOW VARIABLES LIKE 'client_collation'; Variable_name Value client_collation latin1_swedish_ci SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; charset('a') collation('a') coercibility('a') 'a'='A' latin1 latin1_swedish_ci 3 1 -SET NAMES latin1 COLLATE koi8r; +SET CHARACTER SET latin1 COLLATE koi8r; COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1' -SET NAMES 'DEFAULT'; +SET CHARACTER SET 'DEFAULT'; Unknown character set: 'DEFAULT' DROP TABLE t1; diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result index 99e4864bcf6..fb813e394f4 100644 --- a/mysql-test/r/ctype_recoding.result +++ b/mysql-test/r/ctype_recoding.result @@ -1,4 +1,4 @@ -SET NAMES koi8r; +SET CHARACTER SET koi8r; DROP TABLE IF EXISTS ÔÁÂÌÉÃÁ; CREATE TABLE ÔÁÂÌÉÃÁ ( @@ -6,15 +6,15 @@ CREATE TABLE ); SHOW TABLES; Tables_in_test -таблица +ÔÁÂÌÉÃÁ SHOW CREATE TABLE ÔÁÂÌÉÃÁ; Table Create Table -таблица CREATE TABLE `таблица` ( - `поле` char(32) character set koi8r NOT NULL default '' +ÔÁÂÌÉÃÁ CREATE TABLE `ÔÁÂÌÉÃÁ` ( + `ÐÏÌÅ` char(32) character set koi8r NOT NULL default '' ) TYPE=MyISAM CHARSET=latin1 SHOW FIELDS FROM ÔÁÂÌÉÃÁ; Field Type Collation Null Key Default Extra -поле char(32) character set koi8r koi8r_general_ci +ÐÏÌÅ char(32) character set koi8r koi8r_general_ci SET CHARACTER SET cp1251; SHOW TABLES; Tables_in_test diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test index 2740ca24eb3..431799ac65c 100644 --- a/mysql-test/t/ctype_collate.test +++ b/mysql-test/t/ctype_collate.test @@ -127,35 +127,35 @@ ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin; SHOW CREATE TABLE t1; SHOW FIELDS FROM t1; -SET NAMES 'latin1'; +SET CHARACTER SET 'latin1'; SHOW VARIABLES LIKE 'client_collation'; -SET NAMES latin1; +SET CHARACTER SET latin1; SHOW VARIABLES LIKE 'client_collation'; SHOW VARIABLES LIKE 'client_collation'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; -SET NAMES latin1 COLLATE latin1_bin; +SET CHARACTER SET latin1 COLLATE latin1_bin; SHOW VARIABLES LIKE 'client_collation'; -SET NAMES LATIN1 COLLATE Latin1_Bin; +SET CHARACTER SET LATIN1 COLLATE Latin1_Bin; SHOW VARIABLES LIKE 'client_collation'; -SET NAMES 'latin1' COLLATE 'latin1_bin'; +SET CHARACTER SET 'latin1' COLLATE 'latin1_bin'; SHOW VARIABLES LIKE 'client_collation'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; -SET NAMES koi8r; +SET CHARACTER SET koi8r; SHOW VARIABLES LIKE 'client_collation'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; -SET NAMES koi8r COLLATE koi8r_bin; +SET CHARACTER SET koi8r COLLATE koi8r_bin; SHOW VARIABLES LIKE 'client_collation'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; -SET NAMES koi8r COLLATE DEFAULT; +SET CHARACTER SET koi8r COLLATE DEFAULT; SHOW VARIABLES LIKE 'client_collation'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; -SET NAMES DEFAULT; +SET CHARACTER SET DEFAULT; SHOW VARIABLES LIKE 'client_collation'; SELECT charset('a'),collation('a'),coercibility('a'),'a'='A'; --error 1251 -SET NAMES latin1 COLLATE koi8r; +SET CHARACTER SET latin1 COLLATE koi8r; --error 1115 -SET NAMES 'DEFAULT'; +SET CHARACTER SET 'DEFAULT'; DROP TABLE t1; diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index cb5f4997000..0330bbd23b4 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -1,4 +1,4 @@ -SET NAMES koi8r; +SET CHARACTER SET koi8r; --disable_warnings DROP TABLE IF EXISTS ÔÁÂÌÉÃÁ; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a6338630568..7aa065f2177 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2087,6 +2087,10 @@ static int init_common_variables(const char *conf_file_name, int argc, #endif if (!(default_charset_info= get_charset_by_name(sys_charset.value, MYF(MY_WME)))) return 1; + global_system_variables.result_collation= default_charset_info; + global_system_variables.client_collation= default_charset_info; + global_system_variables.literal_collation= default_charset_info; + charsets_list= list_charsets(MYF(MY_CS_COMPILED | MY_CS_CONFIG)); if (use_temp_pool && bitmap_init(&temp_pool,1024,1)) @@ -4566,7 +4570,7 @@ static void set_options(void) sizeof(mysql_real_data_home)-1); /* Set default values for some variables */ - global_system_variables.convert_result_charset= TRUE; + global_system_variables.result_collation= default_charset_info; global_system_variables.client_collation= default_charset_info; global_system_variables.literal_collation= default_charset_info; global_system_variables.table_type= DB_TYPE_MYISAM; diff --git a/sql/protocol.cc b/sql/protocol.cc index 195fec80ed0..99b815a7840 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -724,7 +724,7 @@ bool Protocol_simple::store(const char *from, uint length, bool Protocol_simple::store(const char *from, uint length, CHARSET_INFO *fromcs) { - CHARSET_INFO *tocs= this->thd->result_charset(fromcs); + CHARSET_INFO *tocs= this->thd->variables.result_collation; #ifndef DEBUG_OFF DBUG_ASSERT(field_types == 0 || field_types[field_pos] == MYSQL_TYPE_DECIMAL || @@ -834,8 +834,7 @@ bool Protocol_simple::store(Field *field) field->val_str(&str,&str); if (!my_charset_same(field->charset(), this->thd->charset()) && (field->charset() != &my_charset_bin) && - (this->thd->charset() != &my_charset_bin) && - (this->thd->variables.convert_result_charset)) + (this->thd->charset() != &my_charset_bin)) { convert.copy(str.ptr(), str.length(), str.charset(), this->thd->charset()); return net_store_data(convert.ptr(), convert.length()); diff --git a/sql/set_var.cc b/sql/set_var.cc index b5094e6403a..8c224a745c6 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -110,8 +110,6 @@ sys_var_bool_ptr sys_concurrent_insert("concurrent_insert", &myisam_concurrent_insert); sys_var_long_ptr sys_connect_timeout("connect_timeout", &connect_timeout); -sys_var_thd_bool sys_convert_result_charset("convert_result_charset", - &SV::convert_result_charset); sys_var_enum sys_delay_key_write("delay_key_write", &delay_key_write_options, &delay_key_write_typelib, @@ -202,6 +200,7 @@ sys_var_thd_ulong sys_read_buff_size("read_buffer_size", &SV::read_buff_size); sys_var_thd_ulong sys_read_rnd_buff_size("read_rnd_buffer_size", &SV::read_rnd_buff_size); +sys_var_result_collation sys_result_collation("result_collation"); sys_var_long_ptr sys_rpl_recovery_rank("rpl_recovery_rank", &rpl_recovery_rank); sys_var_long_ptr sys_query_cache_size("query_cache_size", @@ -347,7 +346,6 @@ sys_var *sys_variables[]= &sys_client_collation, &sys_concurrent_insert, &sys_connect_timeout, - &sys_convert_result_charset, &sys_default_week_format, &sys_delay_key_write, &sys_delayed_insert_limit, @@ -408,6 +406,7 @@ sys_var *sys_variables[]= &sys_rand_seed2, &sys_read_buff_size, &sys_read_rnd_buff_size, + &sys_result_collation, &sys_rpl_recovery_rank, &sys_safe_updates, &sys_select_limit, @@ -459,7 +458,6 @@ struct show_var_st init_vars[]= { {sys_client_collation.name, (char*) &sys_client_collation, SHOW_SYS}, {sys_concurrent_insert.name,(char*) &sys_concurrent_insert, SHOW_SYS}, {sys_connect_timeout.name, (char*) &sys_connect_timeout, SHOW_SYS}, - {sys_convert_result_charset.name, (char*) &sys_convert_result_charset, SHOW_SYS}, {"datadir", mysql_real_data_home, SHOW_CHAR}, {"default_week_format", (char*) &sys_default_week_format, SHOW_SYS}, {sys_delay_key_write.name, (char*) &sys_delay_key_write, SHOW_SYS}, @@ -563,6 +561,7 @@ struct show_var_st init_vars[]= { {sys_pseudo_thread_id.name, (char*) &sys_pseudo_thread_id, SHOW_SYS}, {sys_read_buff_size.name, (char*) &sys_read_buff_size, SHOW_SYS}, {sys_read_rnd_buff_size.name,(char*) &sys_read_rnd_buff_size, SHOW_SYS}, + {sys_result_collation.name, (char*) &sys_result_collation, SHOW_SYS}, {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS}, #ifdef HAVE_QUERY_CACHE {sys_query_cache_limit.name,(char*) &sys_query_cache_limit, SHOW_SYS}, @@ -1267,6 +1266,31 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type) thd->variables.literal_collation= global_system_variables.literal_collation; } +bool sys_var_result_collation::update(THD *thd, set_var *var) +{ + if (var->type == OPT_GLOBAL) + global_system_variables.result_collation= var->save_result.charset; + else + thd->variables.result_collation= var->save_result.charset; + return 0; +} + +byte *sys_var_result_collation::value_ptr(THD *thd, enum_var_type type) +{ + CHARSET_INFO *cs= ((type == OPT_GLOBAL) ? + global_system_variables.result_collation : + thd->variables.result_collation); + return cs ? (byte*) cs->name : (byte*) ""; +} + +void sys_var_result_collation::set_default(THD *thd, enum_var_type type) +{ + if (type == OPT_GLOBAL) + global_system_variables.result_collation= default_charset_info; + else + thd->variables.result_collation= global_system_variables.result_collation; +} + /***************************************************************************** Functions to handle SET NAMES and SET CHARACTER SET @@ -1274,24 +1298,14 @@ void sys_var_literal_collation::set_default(THD *thd, enum_var_type type) int set_var_client_collation::check(THD *thd) { - client_charset= client_charset ? - client_charset : global_system_variables.client_collation; - client_collation= client_collation ? client_collation : client_charset; - if (!my_charset_same(client_charset, client_collation)) - { - my_error(ER_COLLATION_CHARSET_MISMATCH, MYF(0), - client_collation->name, client_charset->csname); - return -1; - } return 0; } int set_var_client_collation::update(THD *thd) { - thd->variables.client_collation= client_collation; - thd->variables.literal_collation= convert_result_charset ? - thd->db_charset: client_collation; - thd->variables.convert_result_charset= convert_result_charset; + thd->variables.client_collation= client_collation; + thd->variables.literal_collation= literal_collation; + thd->variables.result_collation= result_collation; thd->protocol_simple.init(thd); thd->protocol_prep.init(thd); return 0; diff --git a/sql/set_var.h b/sql/set_var.h index 51f59981e14..69e6bc05a67 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -438,6 +438,15 @@ public: byte *value_ptr(THD *thd, enum_var_type type); }; +class sys_var_result_collation :public sys_var_collation +{ +public: + sys_var_result_collation(const char *name_arg) :sys_var_collation(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); +}; + /* Variable that you can only read from */ @@ -546,14 +555,16 @@ public: class set_var_client_collation: public set_var_base { - CHARSET_INFO *client_charset; CHARSET_INFO *client_collation; - my_bool convert_result_charset; + CHARSET_INFO *literal_collation; + CHARSET_INFO *result_collation; public: - set_var_client_collation(CHARSET_INFO *cset_arg, - CHARSET_INFO *coll_arg ,my_bool conv_arg) - :client_charset(cset_arg), client_collation(coll_arg), - convert_result_charset(conv_arg) + set_var_client_collation(CHARSET_INFO *client_coll_arg, + CHARSET_INFO *literal_coll_arg, + CHARSET_INFO *result_coll_arg) + :client_collation(client_coll_arg), + literal_collation(literal_coll_arg), + result_collation(result_coll_arg) {} int check(THD *thd); int update(THD *thd); diff --git a/sql/sql_class.h b/sql/sql_class.h index 1d4dafb997e..5e316267e1e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -378,10 +378,10 @@ struct system_variables my_bool log_warnings; my_bool low_priority_updates; my_bool new_mode; - my_bool convert_result_charset; - + CHARSET_INFO *client_collation; CHARSET_INFO *literal_collation; + CHARSET_INFO *result_collation; }; void free_tmp_table(THD *thd, TABLE *entry); @@ -663,8 +663,6 @@ public: DBUG_PRINT("error",("Fatal error set")); } inline CHARSET_INFO *charset() { return variables.client_collation; } - inline CHARSET_INFO *result_charset(CHARSET_INFO *cs) - { return variables.convert_result_charset ? charset() : cs; } }; /* diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index bb6e445bfc2..189a28aea51 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -563,7 +563,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %type IDENT TEXT_STRING REAL_NUM FLOAT_NUM NUM LONG_NUM HEX_NUM LEX_HOSTNAME ULONGLONG_NUM field_ident select_alias ident ident_or_text - UNDERSCORE_CHARSET IDENT_sys TEXT_STRING_sys TEXT_STRING_db + UNDERSCORE_CHARSET IDENT_sys TEXT_STRING_sys TEXT_STRING_literal NCHAR_STRING %type @@ -2279,9 +2279,9 @@ simple_expr: Lex->uncacheable();; } | ENCRYPT '(' expr ',' expr ')' { $$= new Item_func_encrypt($3,$5); } - | DECODE_SYM '(' expr ',' TEXT_STRING_db ')' + | DECODE_SYM '(' expr ',' TEXT_STRING_literal ')' { $$= new Item_func_decode($3,$5.str); } - | ENCODE_SYM '(' expr ',' TEXT_STRING_db ')' + | ENCODE_SYM '(' expr ',' TEXT_STRING_literal ')' { $$= new Item_func_encode($3,$5.str); } | DES_DECRYPT_SYM '(' expr ')' { $$= new Item_func_des_decrypt($3); } @@ -2910,7 +2910,7 @@ having_clause: ; opt_escape: - ESCAPE_SYM TEXT_STRING_db { $$= $2.str; } + ESCAPE_SYM TEXT_STRING_literal { $$= $2.str; } | /* empty */ { $$= (char*) "\\"; }; @@ -3921,24 +3921,22 @@ opt_ignore_lines: /* Common definitions */ text_literal: - TEXT_STRING_db + TEXT_STRING_literal { THD *thd= YYTHD; - CHARSET_INFO *cs= my_charset_same(thd->charset(),thd->db_charset) ? - thd->charset() : thd->db_charset; - $$ = new Item_string($1.str,$1.length,cs); + $$ = new Item_string($1.str,$1.length,thd->variables.literal_collation); } | NCHAR_STRING { $$= new Item_string($1.str,$1.length,national_charset_info); } | UNDERSCORE_CHARSET TEXT_STRING { $$ = new Item_string($2.str,$2.length,Lex->charset); } - | text_literal TEXT_STRING_db + | text_literal TEXT_STRING_literal { ((Item_string*) $1)->append($2.str,$2.length); } ; text_string: - TEXT_STRING_db - { $$= new String($1.str,$1.length,YYTHD->db_charset); } + TEXT_STRING_literal + { $$= new String($1.str,$1.length,YYTHD->variables.literal_collation); } | HEX_NUM { Item *tmp = new Item_varbinary($1.str,$1.length); @@ -4104,18 +4102,18 @@ TEXT_STRING_sys: } ; -TEXT_STRING_db: +TEXT_STRING_literal: TEXT_STRING { THD *thd= YYTHD; - if (my_charset_same(thd->charset(),thd->db_charset)) + if (my_charset_same(thd->charset(),thd->variables.literal_collation)) { $$=$1; } else { String ident; - ident.copy($1.str,$1.length,thd->charset(),thd->db_charset); + ident.copy($1.str,$1.length,thd->charset(),thd->variables.literal_collation); $$.str= thd->strmake(ident.ptr(),ident.length()); $$.length= ident.length(); } @@ -4403,15 +4401,32 @@ option_value: find_sys_var("tx_isolation"), new Item_int((int32) $4))); } - | charset old_or_new_charset_name_or_default + | charset old_or_new_charset_name_or_default opt_collate { + THD *thd= YYTHD; LEX *lex= Lex; - lex->var_list.push_back(new set_var_client_collation($2,NULL,1)); + $2= $2 ? $2: global_system_variables.client_collation; + $3= $3 ? $3 : $2; + if (!my_charset_same($2,$3)) + { + net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, + $3->name,$2->csname); + YYABORT; + } + lex->var_list.push_back(new set_var_client_collation($3,thd->db_charset,$3)); } | NAMES_SYM charset_name_or_default opt_collate { LEX *lex= Lex; - lex->var_list.push_back(new set_var_client_collation($2,$3,0)); + $2= $2 ? $2 : global_system_variables.client_collation; + $3= $3 ? $3 : $2; + if (!my_charset_same($2,$3)) + { + net_printf(YYTHD,ER_COLLATION_CHARSET_MISMATCH, + $3->name,$2->csname); + YYABORT; + } + lex->var_list.push_back(new set_var_client_collation($3,$3,$3)); } | PASSWORD equal text_or_password { From 5614054b065c409ceef6d903c03259153cab4c9a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Apr 2003 17:49:16 +0200 Subject: [PATCH 15/25] - bumped up version number to 4.1.1-alpha now that 4.0.1 has been tagged - tagged ChangeSet@1.1529 as mysql-4.1.0 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index d9380a68267..77ae969b5eb 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.1.0-alpha) +AM_INIT_AUTOMAKE(mysql, 4.1.1-alpha) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 75bdeb1b21dca9266c077f9bade0e88bec716e9c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Apr 2003 20:50:30 -0400 Subject: [PATCH 16/25] added compress/uncompress function sql/mysql_priv.h: added have_compress variable sql/mysqld.cc: added have_compress variable sql/set_var.cc: added have_compress variable --- include/mysqld_error.h | 6 +- mysql-test/include/have_compress.inc | 4 ++ mysql-test/r/func_compress.result | 35 +++++++++++ mysql-test/r/have_compress.require | 2 + mysql-test/t/func_compress.test | 20 +++++++ sql/item_create.cc | 20 +++++++ sql/item_create.h | 7 +++ sql/item_func.cc | 14 ++++- sql/item_func.h | 9 +++ sql/item_strfunc.cc | 88 ++++++++++++++++++++++++++++ sql/item_strfunc.h | 23 ++++++++ sql/lex.h | 7 +++ sql/mysql_priv.h | 1 + sql/mysqld.cc | 5 ++ sql/set_var.cc | 1 + sql/share/czech/errmsg.txt | 4 ++ sql/share/danish/errmsg.txt | 4 ++ sql/share/dutch/errmsg.txt | 4 ++ sql/share/english/errmsg.txt | 4 ++ sql/share/estonian/errmsg.txt | 4 ++ sql/share/french/errmsg.txt | 4 ++ sql/share/german/errmsg.txt | 4 ++ sql/share/greek/errmsg.txt | 4 ++ sql/share/hungarian/errmsg.txt | 4 ++ sql/share/italian/errmsg.txt | 4 ++ sql/share/japanese/errmsg.txt | 4 ++ sql/share/korean/errmsg.txt | 4 ++ sql/share/norwegian-ny/errmsg.txt | 4 ++ sql/share/norwegian/errmsg.txt | 4 ++ sql/share/polish/errmsg.txt | 4 ++ sql/share/portuguese/errmsg.txt | 4 ++ sql/share/romanian/errmsg.txt | 4 ++ sql/share/russian/errmsg.txt | 4 ++ sql/share/serbian/errmsg.txt | 4 ++ sql/share/slovak/errmsg.txt | 4 ++ sql/share/spanish/errmsg.txt | 4 ++ sql/share/swedish/errmsg.txt | 4 ++ sql/share/ukrainian/errmsg.txt | 4 ++ 38 files changed, 332 insertions(+), 2 deletions(-) create mode 100644 mysql-test/include/have_compress.inc create mode 100644 mysql-test/r/func_compress.result create mode 100644 mysql-test/r/have_compress.require create mode 100644 mysql-test/t/func_compress.test diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 2f4158110cd..57625198c24 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -270,4 +270,8 @@ #define ER_COLLATION_CHARSET_MISMATCH 1251 #define ER_SLAVE_WAS_RUNNING 1252 #define ER_SLAVE_WAS_NOT_RUNNING 1253 -#define ER_ERROR_MESSAGES 254 +#define ER_TOO_BIG_FOR_UNCOMPRESS 1254 +#define ER_ZLIB_Z_MEM_ERROR 1255 +#define ER_ZLIB_Z_BUF_ERROR 1256 +#define ER_ZLIB_Z_DATA_ERROR 1257 +#define ER_ERROR_MESSAGES 258 diff --git a/mysql-test/include/have_compress.inc b/mysql-test/include/have_compress.inc new file mode 100644 index 00000000000..c042cd7452a --- /dev/null +++ b/mysql-test/include/have_compress.inc @@ -0,0 +1,4 @@ +-- require r/have_compress.require +disable_query_log; +show variables like "have_compress"; +enable_query_log; diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result new file mode 100644 index 00000000000..ac48c8b9494 --- /dev/null +++ b/mysql-test/r/func_compress.result @@ -0,0 +1,35 @@ +select @test_compress_string:='string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa '; +@test_compress_string:='string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ' +string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +select length(@test_compress_string); +length(@test_compress_string) +117 +select uncompress(compress(@test_compress_string)); +uncompress(compress(@test_compress_string)) +string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +select uncompress(@test_compress_string); +uncompress(@test_compress_string) +NULL +Warnings: +Error 1254 Too big size of uncompressed data. The maximum size is 8192. (probably, length of uncompressed data was corrupted) +select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string); +uncompressed_length(compress(@test_compress_string))=length(@test_compress_string) +1 +select uncompressed_length(compress(@test_compress_string)); +uncompressed_length(compress(@test_compress_string)) +117 +select length(compress(@test_compress_string))ptr(), res->length()); } -#endif /* HAVE_COMPRESS */ +longlong Item_func_uncompressed_length::val_int() +{ + String *res= args[0]->val_str(&value); + if (!res) + { + null_value=1; + return 0; /* purecov: inspected */ + } + null_value=0; + return uint4korr(res->c_ptr()); +} + +#endif /* HAVE_COMPRESS */ longlong Item_func_length::val_int() { diff --git a/sql/item_func.h b/sql/item_func.h index 0429e650071..e1d6156c12c 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -559,6 +559,15 @@ public: const char *func_name() const { return "crc32"; } void fix_length_and_dec() { max_length=10; } }; +class Item_func_uncompressed_length : public Item_int_func +{ + String value; +public: + Item_func_uncompressed_length(Item *a):Item_int_func(a){} + longlong val_int(); + const char *func_name() const{return "uncompressed_length";} + void fix_length_and_dec() { max_length=10; } +}; #endif class Item_func_length :public Item_int_func diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 2a0194aba28..97c9fd77fb8 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2895,3 +2895,91 @@ String *Item_func_spatial_collection::val_str(String *str) ret: return null_value ? 0 : str; } + +#ifdef HAVE_COMPRESS +#include + +String *Item_func_compress::val_str(String *str) +{ + String *res= args[0]->val_str(str); + int err= Z_OK; + int code; + + /* + citation from zlib.h (comment for compress function): + + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. + + Proportion 120/100 founded by Sinica with help of procedure + compress(compress(compress(...))) + I.e. zlib give number 'at least'.. + */ + uLongf new_size= (uLongf)((res->length()*120)/100)+12; + + buffer.realloc((uint32)new_size+sizeof(int32)+sizeof(char)); + + Byte *body= ((Byte*)buffer.c_ptr())+sizeof(int32); + err= compress(body, &new_size,(const Bytef*)res->c_ptr(), res->length()); + + if (err != Z_OK) + { + code= err==Z_MEM_ERROR ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_BUF_ERROR; + push_warning(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,code,ER(code)); + null_value= 1; + return 0; + } + + int4store(buffer.c_ptr(),res->length()); + buffer.length((uint32)new_size+sizeof(int32)); + + /* This is for the stupid char fields which trimm ' ': */ + char *last_char= ((char*)body)+new_size-1; + if (*last_char == ' ') + { + *++last_char= '.'; + new_size++; + } + + buffer.length((uint32)new_size+sizeof(int32)); + + return &buffer; +} + +String *Item_func_uncompress::val_str(String *str) +{ + String *res= args[0]->val_str(str); + uLongf new_size= uint4korr(res->c_ptr()); + int err= Z_OK; + uint code; + + if (new_size > MAX_BLOB_WIDTH) + { + push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_TOO_BIG_FOR_UNCOMPRESS, + ER(ER_TOO_BIG_FOR_UNCOMPRESS),MAX_BLOB_WIDTH); + null_value= 1; + return 0; + } + + buffer.realloc((uint32)new_size); + + err= uncompress((Byte*)buffer.c_ptr(), &new_size, + ((const Bytef*)res->c_ptr())+sizeof(int32),res->length()); + + if (err == Z_OK) + { + buffer.length((uint32)new_size); + return &buffer; + } + + code= err==Z_BUF_ERROR ? ER_ZLIB_Z_BUF_ERROR : + err==Z_MEM_ERROR ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR; + push_warning(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,code,ER(code)); + null_value= 1; + return 0; +} + +#endif diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 07b7eb2d165..3c5ab855970 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -771,6 +771,29 @@ public: const char *func_name() const { return "multipoint"; } }; +#ifdef HAVE_COMPRESS + +class Item_func_compress : public Item_str_func +{ + String buffer; +public: + Item_func_compress(Item *a):Item_str_func(a){} + String *val_str(String *); + void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;} + const char *func_name() const{return "compress";} +}; + +class Item_func_uncompress : public Item_str_func +{ + String buffer; +public: + Item_func_uncompress(Item *a):Item_str_func(a){} + String *val_str(String *); + void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;} + const char *func_name() const{return "uncompress";} +}; + +#endif /* class Item_func_multipoint :public Item_str_func diff --git a/sql/lex.h b/sql/lex.h index 3bc5820ee66..2be5bea9693 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -445,6 +445,9 @@ static SYMBOL sql_functions[] = { { "CHARACTER_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_char_length)}, { "COALESCE", SYM(COALESCE),0,0}, { "COERCIBILITY", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_coercibility)}, +#ifdef HAVE_COMPRESS + { "COMPRESS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_compress)}, +#endif { "CONCAT", SYM(CONCAT),0,0}, { "CONCAT_WS", SYM(CONCAT_WS),0,0}, { "CONNECTION_ID", SYM(FUNC_ARG0),0,CREATE_FUNC(create_func_connection_id)}, @@ -599,6 +602,10 @@ static SYMBOL sql_functions[] = { { "TOUCHES", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_touches)}, { "TRIM", SYM(TRIM),0,0}, { "UCASE", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)}, +#ifdef HAVE_COMPRESS + { "UNCOMPRESS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_uncompress)}, + { "UNCOMPRESSED_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_uncompressed_length)}, +#endif { "UNIQUE_USERS", SYM(UNIQUE_USERS),0,0}, { "UNIX_TIMESTAMP", SYM(UNIX_TIMESTAMP),0,0}, { "UPPER", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ucase)}, diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index f68de23034a..34d92836ce6 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -767,6 +767,7 @@ extern SHOW_COMP_OPTION have_isam, have_innodb, have_berkeley_db; extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink; extern SHOW_COMP_OPTION have_query_cache, have_berkeley_db, have_innodb; extern SHOW_COMP_OPTION have_crypt; +extern SHOW_COMP_OPTION have_compress; #ifndef __WIN__ extern pthread_t signal_thread; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ac3703c5a1d..687f2179193 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -257,6 +257,11 @@ SHOW_COMP_OPTION have_crypt=SHOW_OPTION_YES; #else SHOW_COMP_OPTION have_crypt=SHOW_OPTION_NO; #endif +#ifdef HAVE_COMPRESS +SHOW_COMP_OPTION have_compress= SHOW_OPTION_YES; +#else +SHOW_COMP_OPTION have_compress= SHOW_OPTION_NO; +#endif const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"}; diff --git a/sql/set_var.cc b/sql/set_var.cc index c4a4819689c..b7fcaf07f0c 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -465,6 +465,7 @@ struct show_var_st init_vars[]= { {"ft_stopword_file", (char*) &ft_stopword_file, SHOW_CHAR_PTR}, {"have_bdb", (char*) &have_berkeley_db, SHOW_HAVE}, {"have_crypt", (char*) &have_crypt, SHOW_HAVE}, + {"have_compress", (char*) &have_compress, SHOW_HAVE}, {"have_innodb", (char*) &have_innodb, SHOW_HAVE}, {"have_isam", (char*) &have_isam, SHOW_HAVE}, {"have_raid", (char*) &have_raid, SHOW_HAVE}, diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 169595c34c5..427ca169a41 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -264,3 +264,7 @@ v/* "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index ff58079f4c8..b05395b707f 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -258,3 +258,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index a0a6755c693..ef3b9ba40e7 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -266,3 +266,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 0f48416d6db..213068c7d87 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -255,3 +255,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 4503f011692..1b4207c948a 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -260,3 +260,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 9474d67f2f2..ea0d3c28f95 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -255,3 +255,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index ef4110a6b93..9b66e6f7e0c 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -265,3 +265,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 3f54e7740bd..ffe9d71ca5d 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -255,3 +255,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 7519448ef33..79451ccdb74 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -257,3 +257,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 71a02896c01..4d292d7ad09 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -255,3 +255,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index b10ddb1d1d2..c88b41dd09a 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -257,3 +257,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index be1e85ad33c..f1e9eeacf1d 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -255,3 +255,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 84c96a0540e..957ee163759 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -257,3 +257,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index b57eb19906d..776f1cc415e 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -257,3 +257,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 2d07b362257..576825f749f 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -259,3 +259,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 8db48115c49..15570be044c 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -255,3 +255,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 337cfd0963e..97be6eee3e4 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -259,3 +259,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index b5d1a0a7e07..e7dc116f337 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -257,3 +257,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index d6883efc96b..a45db002932 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -251,3 +251,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index ee7d1e9c4fb..0b00722e314 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -263,3 +263,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 2dfdc7573fa..2090c6cdee2 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -256,3 +256,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 6d34b5a93b3..be5d056e3fb 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -255,3 +255,7 @@ "COLLATION '%s' är inte tillåtet för CHARACTER SET '%s'" "Slaven har redan startat" "Slaven har redan stoppat" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index be8fe2afea5..0e550b15a55 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -260,3 +260,7 @@ "COLLATION '%s' is not valid for CHARACTER SET '%s'" "The slave was already running" "The slave was already stopped" +"Too big size of uncompressed data. The maximum size is %d. (probably, length of uncompressed data was corrupted)" +"Z_BUF_ERROR: Not enough memory available for zlib" +"Z_MEM_ERROR: Not enough room in the output buffer for zlib (probably, length of uncompressed data was corrupted)" +"Z_DATA_ERROR: Input data was corrupted for zlib" From 18cccabf1394b7cc979eee177f240862611a27c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Apr 2003 14:49:10 -0400 Subject: [PATCH 17/25] For to use the /libmysql/libmysql.def file instead BitKeeper/deleted/.del-libmysql.def~29fc6d70335f1c4c: Delete: VC++Files/libmysql/libmysql.def --- VC++Files/libmysql/libmysql.def | 117 -------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 VC++Files/libmysql/libmysql.def diff --git a/VC++Files/libmysql/libmysql.def b/VC++Files/libmysql/libmysql.def deleted file mode 100644 index e7959078390..00000000000 --- a/VC++Files/libmysql/libmysql.def +++ /dev/null @@ -1,117 +0,0 @@ -LIBRARY LIBMYSQL -DESCRIPTION 'MySQL 4.0 Client Library' -VERSION 4.0 -EXPORTS - mysql_affected_rows - mysql_close - mysql_data_seek - mysql_debug - mysql_dump_debug_info - mysql_eof - mysql_errno - mysql_error - mysql_escape_string - mysql_fetch_field - mysql_fetch_field_direct - mysql_fetch_fields - mysql_fetch_lengths - mysql_fetch_row - mysql_field_count - mysql_field_seek - mysql_field_tell - mysql_free_result - mysql_get_client_info - mysql_get_host_info - mysql_get_proto_info - mysql_get_server_info - mysql_info - mysql_init - mysql_insert_id - mysql_kill - mysql_list_dbs - mysql_list_fields - mysql_list_processes - mysql_list_tables - mysql_num_fields - mysql_num_rows - mysql_odbc_escape_string - mysql_options - mysql_ping - mysql_query - mysql_real_connect - mysql_real_query - mysql_refresh - mysql_row_seek - mysql_row_tell - mysql_select_db - mysql_shutdown - mysql_stat - mysql_store_result - mysql_thread_id - mysql_use_result - bmove_upp - delete_dynamic - _dig_vec - init_dynamic_array - insert_dynamic - int2str - is_prefix - list_add - list_delete - max_allowed_packet - my_init - my_end - my_strdup - my_malloc - my_memdup - my_no_flags_free - my_realloc - my_thread_end - my_thread_init - net_buffer_length - set_dynamic - strcend - strdup_root - strfill - strinstr - strmake - strmov - strxmov - myodbc_remove_escape - mysql_thread_safe - mysql_character_set_name - mysql_change_user - mysql_send_query - mysql_read_query_result - mysql_real_escape_string - mysql_ssl_set - mysql_real_connect - mysql_master_query - mysql_master_send_query - mysql_slave_query - mysql_slave_send_query - mysql_enable_rpl_parse - mysql_disable_rpl_parse - mysql_rpl_parse_enabled - mysql_enable_reads_from_master - mysql_disable_reads_from_master - mysql_reads_from_master_enabled - mysql_rpl_query_type - mysql_rpl_probe - mysql_set_master - mysql_add_slave - - - - - - - - - - - - - - - From aa418f0f176c0e39c48e18df67a4ba9ee19a78c6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Apr 2003 17:20:32 +0200 Subject: [PATCH 18/25] - make sure to generate the BDB tags file, otherwise s_symlink will create a lot of broken symlinks to the non-existing tags file (which magically causes the source distribution to grow about three times in size (most likely a bug in GNU tar - need to investigate if it still happens with recent versions) --- bdb/dist/s_all | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bdb/dist/s_all b/bdb/dist/s_all index ee0041032d8..132017def3c 100644 --- a/bdb/dist/s_all +++ b/bdb/dist/s_all @@ -20,4 +20,4 @@ sh s_win32_dsp # Win32 build environment. #sh s_vxworks # VxWorks include files. #sh s_java # Java support. sh s_test # Test suite support. -#sh s_tags # Tags files. +sh s_tags # Tags files. From b4d60df32d519887afb78c1c6796d665c4fff27d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Apr 2003 14:48:03 -0400 Subject: [PATCH 19/25] Exported functions claimed by MySQLCC --- libmysql/libmysql.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index e0e7ca48f48..5a333c51867 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -122,6 +122,8 @@ EXPORTS mysql_commit mysql_rollback mysql_autocommit + load_defaults + free_defaults From fc6456b5c4966af2a633c4494404e279fe617c48 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Apr 2003 04:26:55 +0600 Subject: [PATCH 20/25] correct codes of warnings in result file --- mysql-test/r/func_gconcat.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index a9a7b85f96d..ad1ba8ae3db 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -150,10 +150,10 @@ grp group_concat(c) 4 5 NULL Warnings: -Warning 1254 1 line(s) was(were) cut by group_concat() +Warning 1258 1 line(s) was(were) cut by group_concat() show warnings; Level Code Message -Warning 1254 1 line(s) was(were) cut by group_concat() +Warning 1258 1 line(s) was(were) cut by group_concat() select group_concat(sum(a)) from t1 group by grp; Invalid use of group function select grp,group_concat(c order by 2) from t1 group by grp; From b03a00ebf64b5e92a71a8f43a1c34c5c8acd6dcc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Apr 2003 00:22:43 +0600 Subject: [PATCH 21/25] replace default separator in group_concat, correct a bug mysql-test/r/func_gconcat.result: replace default separator sql/item_sum.h: add fix_length_and_dec() and copy_or_same() sql/sql_yacc.yy: replace default separator --- mysql-test/r/func_gconcat.result | 56 ++++++++++++++++---------------- sql/item_sum.h | 2 ++ sql/sql_yacc.yy | 2 +- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index ad1ba8ae3db..0136f72a817 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -14,18 +14,18 @@ insert into t1 values (3,9,"D","c"); select grp,group_concat(c) from t1 group by grp; grp group_concat(c) 1 a -2 b c -3 E C D d d D +2 b,c +3 E,C,D,d,d,D select grp,group_concat(a,c) from t1 group by grp; grp group_concat(a,c) 1 1a -2 2b 3c -3 4E 5C 6D 7d 8d 9D +2 2b,3c +3 4E,5C,6D,7d,8d,9D select grp,group_concat("(",a,":",c,")") from t1 group by grp; grp group_concat("(",a,":",c,")") 1 (1:a) -2 (2:b) (3:c) -3 (4:E) (5:C) (6:D) (7:d) (8:d) (9:D) +2 (2:b),(3:c) +3 (4:E),(5:C),(6:D),(7:d),(8:d),(9:D) select grp,group_concat(c separator ",") from t1 group by grp; grp group_concat(c separator ",") 1 a @@ -39,48 +39,48 @@ grp group_concat(c separator "---->") select grp,group_concat(c order by c) from t1 group by grp; grp group_concat(c order by c) 1 a -2 b c -3 C D d d D E +2 b,c +3 C,D,d,d,D,E select grp,group_concat(c order by c desc) from t1 group by grp; grp group_concat(c order by c desc) 1 a -2 c b -3 E D d d D C +2 c,b +3 E,D,d,d,D,C select grp,group_concat(d order by a) from t1 group by grp; grp group_concat(d order by a) 1 a -2 a b -3 a b b d d c +2 a,b +3 a,b,b,d,d,c select grp,group_concat(d order by a desc) from t1 group by grp; grp group_concat(d order by a desc) 1 a -2 b a -3 c d d b b a +2 b,a +3 c,d,d,b,b,a select grp,group_concat(a order by a,d+c) from t1 group by grp; grp group_concat(a order by a,d+c) 1 1 -2 2 3 -3 4 5 6 7 8 9 +2 2,3 +3 4,5,6,7,8,9 select grp,group_concat(c order by 1) from t1 group by grp; grp group_concat(c order by 1) 1 a -2 b c -3 C D d d D E +2 b,c +3 C,D,d,d,D,E select grp,group_concat(c order by "c") from t1 group by grp; grp group_concat(c order by "c") 1 a -2 b c -3 C D d d D E +2 b,c +3 C,D,d,d,D,E select grp,group_concat(distinct c order by c) from t1 group by grp; grp group_concat(distinct c order by c) 1 a -2 b c -3 C D E +2 b,c +3 C,D,E select grp,group_concat(distinct c order by c desc) from t1 group by grp; grp group_concat(distinct c order by c desc) 1 a -2 c b -3 E D C +2 c,b +3 E,D,C select grp,group_concat(c order by c separator ",") from t1 group by grp; grp group_concat(c order by c separator ",") 1 a @@ -104,8 +104,8 @@ grp group_concat(distinct c order by c desc separator ",") select grp,group_concat(c order by grp desc) from t1 group by grp order by grp; grp group_concat(c order by grp desc) 1 a -2 c b -3 D d d D C E +2 c,b +3 D,d,d,D,C,E select grp, group_concat(a separator "")+0 from t1 group by grp; grp group_concat(a separator "")+0 1 1 @@ -138,7 +138,7 @@ select grp,group_concat(c order by c) from t1 group by grp; grp group_concat(c order by c) 1 NULL 2 b -3 D D E +3 D,D,E 4 5 NULL set group_concat_max_len = 5; @@ -146,7 +146,7 @@ select grp,group_concat(c) from t1 group by grp; grp group_concat(c) 1 NULL 2 b -3 E D D +3 E,D,D 4 5 NULL Warnings: diff --git a/sql/item_sum.h b/sql/item_sum.h index 42d46876d27..1b3e993fffc 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -697,6 +697,7 @@ class Item_func_group_concat : public Item_sum enum Sumfunctype sum_func () const {return GROUP_CONCAT_FUNC;} const char *func_name() const { return "group_concat"; } enum Type type() const { return SUM_FUNC_ITEM; } + void fix_length_and_dec() { max_length=group_concat_max_len; } virtual Item_result result_type () const { return STRING_RESULT; } void reset(); bool add(); @@ -715,4 +716,5 @@ class Item_func_group_concat : public Item_sum return res ? strtoll(res->c_ptr(),(char**) 0,10) : (longlong) 0; } String* val_str(String* str); + Item *copy_or_same(THD* thd) { return new Item_func_group_concat(thd, *this); } }; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 189a28aea51..745d0a8e7d2 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2588,7 +2588,7 @@ opt_distinct: |DISTINCT { $$ = 1; }; opt_gconcat_separator: - /* empty */ { $$ = new String(" ",1,default_charset_info); } + /* empty */ { $$ = new String(",",1,default_charset_info); } |SEPARATOR_SYM text_string { $$ = $2; }; From ed7a26372879ef0da76c98ddc392fb8ad1604748 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Apr 2003 11:08:21 +0500 Subject: [PATCH 22/25] Fix for bug #212 sql/sql_list.h: Here we should reset item::last sometimes --- sql/sql_list.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/sql_list.h b/sql/sql_list.h index 505ea994d42..6eb4f98c011 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -201,6 +201,8 @@ public: *new_list.last=current->next; current->info=new_list.first->info; current->next=new_list.first->next; + if ((list->last == ¤t->next) && (new_list.elements > 1)) + list->last= new_list.last; list->elements+=new_list.elements-1; } return ret_value; // return old element From e5c62e32800a53910dfc96e97e80b2c965030e23 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Apr 2003 09:25:43 +0300 Subject: [PATCH 23/25] Add mysys specific error messages Make RELAY_THREAD and alias for IO_THREAD Added new interface for string -> (unsigned) long long. include/my_sys.h: Add mysys specific error messages sql/lex.h: Make RELAY_THREAD an alias for IO_THREAD sql/sql_yacc.yy: Make RELAY_THREAD an alias for IO_THREAD --- include/my_sys.h | 5 +- sql/lex.h | 3 +- sql/sql_yacc.yy | 6 +- strings/my_strtoll10-x86.s | 396 +++++++++++++++++++++++++++++++++++++ strings/my_strtoll10.c | 237 ++++++++++++++++++++++ 5 files changed, 642 insertions(+), 5 deletions(-) create mode 100644 strings/my_strtoll10-x86.s create mode 100644 strings/my_strtoll10.c diff --git a/include/my_sys.h b/include/my_sys.h index b3be3588b2f..86ca6ec6a1f 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -118,8 +118,11 @@ extern int NEAR my_errno; /* Last error in mysys */ #define MY_KEEP_PREALLOC 1 #define MY_MARK_BLOCKS_FREE 2 /* move used to free list and reuse them */ - /* defines when allocating data */ + /* Internal error numbers (for assembler functions) */ +#define MY_ERRNO_EDOM 33 +#define MY_ERRNO_ERANGE 34 + /* defines when allocating data */ #ifdef SAFEMALLOC #define my_malloc(SZ,FLAG) _mymalloc((SZ), __FILE__, __LINE__, FLAG ) #define my_malloc_ci(SZ,FLAG) _mymalloc((SZ), sFile, uLine, FLAG ) diff --git a/sql/lex.h b/sql/lex.h index 98a802f5c4a..71f56310541 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -209,7 +209,7 @@ static SYMBOL symbols[] = { { "INT4", SYM(INT_SYM),0,0}, { "INT8", SYM(BIGINT),0,0}, { "INTO", SYM(INTO),0,0}, - { "IO_THREAD", SYM(IO_THREAD),0,0}, + { "IO_THREAD", SYM(RELAY_THREAD),0,0}, { "IF", SYM(IF),0,0}, { "IS", SYM(IS),0,0}, { "ISOLATION", SYM(ISOLATION),0,0}, @@ -313,6 +313,7 @@ static SYMBOL symbols[] = { { "REFERENCES", SYM(REFERENCES),0,0}, { "RELAY_LOG_FILE", SYM(RELAY_LOG_FILE_SYM),0,0}, { "RELAY_LOG_POS", SYM(RELAY_LOG_POS_SYM),0,0}, + { "RELAY_THREAD", SYM(RELAY_THREAD),0,0}, { "RELOAD", SYM(RELOAD),0,0}, { "REGEXP", SYM(REGEXP),0,0}, { "RENAME", SYM(RENAME),0,0}, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a8c02bf86f2..9cd26b141e4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -138,7 +138,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token FLUSH_SYM %token HELP_SYM %token INSERT -%token IO_THREAD +%token RELAY_THREAD %token KILL_SYM %token LOAD %token LOCKS_SYM @@ -1688,7 +1688,7 @@ slave_thread_opt_list: slave_thread_opt: /*empty*/ {} | SQL_THREAD { Lex->slave_thd_opt|=SLAVE_SQL; } - | IO_THREAD { Lex->slave_thd_opt|=SLAVE_IO; } + | RELAY_THREAD { Lex->slave_thd_opt|=SLAVE_IO; } ; restore: @@ -4232,7 +4232,7 @@ keyword: | ISSUER_SYM {} | INNOBASE_SYM {} | INSERT_METHOD {} - | IO_THREAD {} + | RELAY_THREAD {} | LAST_SYM {} | LEVEL_SYM {} | LINESTRING {} diff --git a/strings/my_strtoll10-x86.s b/strings/my_strtoll10-x86.s new file mode 100644 index 00000000000..4d007211622 --- /dev/null +++ b/strings/my_strtoll10-x86.s @@ -0,0 +1,396 @@ +# Copyright (C) 2003 MySQL AB +# This program is free software; you can resistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Implemention of my_strtoll(): Converting a string to a 64 bit integer. + + .file "my_strtoll10-x86.s" + .version "01.01" +.data + .align 32 + .type lfactor,@object + .size lfactor,36 +lfactor: + .long 1 + .long 10 + .long 100 + .long 1000 + .long 10000 + .long 100000 + .long 1000000 + .long 10000000 + .long 100000000 +.text + .align 4 + +.globl my_strtoll10 + .type my_strtoll10,@function + + + # Used stack variables + # ebp-4 dummy for storing endptr if endptr = 0 + # ebp-8 First 9 digits of return values + # ebp-12 Pointer to first digit of second part + # ebp-16 Store lowest 2 digits + # ebp-20 != 0 if value was negative + # ebp-24 High max value + # ebp-28 Middle max value + # ebp-32 Low max value + # ebp-36 Temp value + + # esi Pointer to input string + # ebx End of string + +my_strtoll10: + pushl %ebp + movl %esp,%ebp + subl $48,%esp + pushl %esi + pushl %edi + pushl %ebx + movl 8(%ebp),%esi # esi= nptr + movl 16(%ebp),%ecx # ecx= error (Will be overwritten later) + movl 12(%ebp),%eax # eax= endptr + cld # Move forward in esi + cmpl $0,%eax # if (endptr) + je .L110 + +# Fixed length string + movl (%eax),%ebx # bx= end-of-string + .p2align 4,,7 +.L100: + cmpl %ebx,%esi + je .Lno_conv + lodsb # al= next byte + cmpb $32,%al # Skip space + je .L100 + cmpb $9,%al # Skip tab + je .L100 + jmp .L130 + +# String that ends with \0 + +.L110: + leal -4(%ebp),%edi + movl %edi,12(%ebp) # endptr= &dummy, for easier end check + .p2align 4,,7 +.L120: + lodsb # al= next byte + cmpb $32,%al + je .L120 + cmpb $9,%al + je .L120 + testb %al,%al # Test if we found end \0 + je .Lno_conv + leal 65535(%esi),%ebx # ebx = end-of-string + +.L130: + cmpb $45,%al # Test if '-' + jne .Lpositive + + # negative number + movl $-1,(%ecx) # error = -1 (mark that number is negative) + movl $1,-20(%ebp) # negative= 1 + movl $92233720,-24(%ebp) + movl $368547758,-28(%ebp) + movl $8,-32(%ebp) + jmp .L460 + + .p2align 4,,7 +.Lpositive: + movl $0,(%ecx) # error=0 + movl $0,-20(%ebp) # negative= 0 + movl $184467440,-24(%ebp) + movl $737095516,-28(%ebp) + movl $15,-32(%ebp) + cmpb $43,%al # Check if '+' + jne .L462 + +.L460: + cmpl %ebx,%esi # Check if overflow + je .Lno_conv + lodsb # al= next byte after sign + + # Remove pre zero to be able to handle a lot of pre-zero +.L462: + cmpb $48,%al + jne .L475 # Number doesn't start with 0 + movl %esi, %edi + .p2align 4,,7 +.L481: # Skip pre zeros + cmpl %ebx,%esi + je .Lms_return_zero + scasb + je .L481 + movl %edi, %esi + decl %esi # Point to last non '0' digit + leal 9(%esi),%ecx # ecx = end-of-current-part + xorl %edi,%edi # Store first 9 digits in edi + jmp .L482 + .p2align 4,,7 + + # Check if first char is a valid number +.L475: + addb $-48,%al + cmpb $9,%al + ja .Lno_conv +.L477: + movzbl %al,%edi # edi = first digit + leal 8(%esi),%ecx # ecx = end-of-current-part + + # Handle first 8/9 digits and store them in edi +.L482: + cmpl %ebx,%ecx + jbe .L522 + movl %ebx,%ecx # ecx = min(end-of-current-part, end-of-string) + jmp .L522 + + .p2align 4,,7 +.L488: + lodsb # al= next byte + addb $-48,%al + cmpb $9,%al + ja .Lend_i_dec_esi + + # Calculate edi= edi*10 + al + leal (%edi,%edi,4),%edx + movzbl %al,%eax + leal (%eax,%edx,2),%edi +.L522: + cmpl %ecx,%esi # If more digits at this level + jne .L488 + cmpl %ebx,%esi # If end of string + je .Lend_i + + movl %edi,-8(%ebp) # Store first 9 digits + movl %esi,-12(%ebp) # store pos to first digit of second part + + # Calculate next 9 digits and store them in edi + + xorl %edi,%edi + leal 9(%esi),%ecx # ecx= end-of-current-part + movl %ecx,-36(%ebp) # Store max length + cmpl %ebx,%ecx + jbe .L498 + movl %ebx,%ecx # ecx = min(end-of-current-part, end-of-string) + + .p2align 4,,7 +.L498: + lodsb # al= next byte + addb $-48,%al + cmpb $9,%al + ja .Lend_i_and_j_decl_esi + + # Calculate edi= edi*10 + al + leal (%edi,%edi,4),%edx + movzbl %al,%eax + leal (%eax,%edx,2),%edi + + cmpl %ecx,%esi # If end of current part + jne .L498 + cmpl %ebx,%esi # If end of string + jne .L500 + cmpl -36(%ebp),%esi # Test if string is less than 18 digits + jne .Lend_i_and_j + jmp .Lend3 # 18 digit string + + # Handle the possible next to last digit and store in ecx +.L500: + movb (%esi),%al + addb $-48,%al + cmpb $9,%al + ja .Lend3 + + incl %esi + movzbl %al,%ecx + cmpl %ebx,%esi # If end of string + je .Lend4 + + movb (%esi),%al # Read last digit + addb $-48,%al + cmpb $9,%al + ja .Lend4 + + # ecx= ecx*10 + al + leal (%ecx,%ecx,4),%edx + movzbl %al,%eax + leal (%eax,%edx,2),%ecx + + movl 12(%ebp),%eax # eax = endptr + incl %esi + movl %esi,(%eax) # *endptr = end-of-string + cmpl %ebx,%esi + je .L505 # At end of string + + movb (%esi),%al # check if extra digits + addb $-48,%al + cmpb $9,%al + jbe .Loverflow + + # At this point we have: + # -8(%ebp) First 9 digits + # edi Next 9 digits + # ecx Last 2 digits + # *endpos end-of-string + +.L505: # Check that we are not going to get overflow for unsigned long long + movl -8(%ebp),%eax # First 9 digits + cmpl -24(%ebp),%eax + ja .Loverflow + jne .L507 + cmpl -28(%ebp),%edi + ja .Loverflow + jne .L507 + cmpl -32(%ebp),%ecx + ja .Loverflow + +.L507: + movl %edi,-4(%ebp) # Save middle bytes + movl %ecx,%esi # esi = 2 last digits + movl $1215752192,%ecx # %ecx= lower_32_bits(100000000000) + mull %ecx + imull $23,-8(%ebp),%ecx + movl $0,-36(%ebp) + movl %eax,%ebx + imull $1215752192,-36(%ebp),%eax + movl %edx,%edi + addl %ecx,%edi + addl %eax,%edi # Temp in edi:ebx + + movl $100,%eax # j= j*100 + mull -4(%ebp) + addl %ebx,%eax # edx:eax+= edi:ebx + adcl %edi,%edx + addl %esi,%eax + adcl $0,%edx + jmp .Lms_return + +.Loverflow: + # When we come here, *endptr is already updated + + movl 16(%ebp),%edx # edx= error + movl $34,(%edx) # *error = 34 + movl $-1,%eax + movl %eax,%edx + cmpl $0,-20(%ebp) # If negative + je .Lms_return + xor %eax,%eax # edx:eax = LONGLONG_LMIN + movl $-2147483648,%edx + jmp .Lms_return + + # Return value that is in %edi as long long + .p2align 4,,7 +.Lend_i_dec_esi: + decl %esi # Fix so that it points at last digit +.Lend_i: + xorl %edx,%edx + movl %edi,%eax + cmpl $0,-20(%ebp) + je .Lreturn_save_endptr # Positive number + negl %eax + cltd # Negetive result in edx:eax + jmp .Lreturn_save_endptr + + # Return value (%ebp-8) * lfactor[(uint) (edx-start)] + edi + .p2align 4,,7 +.Lend_i_and_j_decl_esi: + decl %esi # Fix so that it points at last digit +.Lend_i_and_j: + movl %esi,%ecx + subl -12(%ebp),%ecx # ecx= number of digits in second part + movl lfactor(,%ecx,4),%eax + jmp .L523 + + # Return -8(%ebp) * $1000000000 + edi + .p2align 4,,7 +.Lend3: + movl $1000000000,%eax +.L523: + mull -8(%ebp) + addl %edi,%eax + adcl $0,%edx + cmpl $0,-20(%ebp) # if negative + je .Lreturn_save_endptr + negl %eax # Neg edx:%eax + adcl $0,%edx + negl %edx + jmp .Lreturn_save_endptr + + # Return -8(%ebp) * $10000000000 + edi*10 + ecx + .p2align 4,,7 +.Lend4: + movl %ecx,-16(%ebp) # store lowest digits + movl 12(%ebp),%ebx + movl %esi,(%ebx) # *endpos = end-of-string + movl -8(%ebp),%eax # First 9 digits + movl $1410065408,%ecx # ecx= lower_32_bits(10000000000) + mull %ecx + movl $0,-36(%ebp) + movl %eax,%ebx # Store lowest 32 byte from multiplication + imull $1410065408,-36(%ebp),%eax + movl -8(%ebp),%ecx # First 9 digits + movl %edx,%esi + addl %ecx,%ecx + addl %ecx,%esi + addl %eax,%esi # %esi:%ebx now has -8(%ebp) * $10000000000 + + movl $10,%eax # Calc edi*10 + mull %edi + addl %ebx,%eax # And add to result + adcl %esi,%edx + addl -16(%ebp),%eax # Add lowest digit + adcl $0,%edx + cmpl $0,-20(%ebp) # if negative + je .Lms_return + + cmpl $-2147483648,%edx # Test if too big signed integer + ja .Loverflow + jne .L516 + testl %eax,%eax + ja .Loverflow + +.L516: + negl %eax + adcl $0,%edx + negl %edx + jmp .Lms_return + + .p2align 4,,7 +.Lno_conv: # Not a legal number + movl 16(%ebp),%eax + movl $33,(%eax) # error= edom + +.Lms_return_zero: + xorl %eax,%eax # Return zero + xorl %edx,%edx + + .p2align 4,,7 +.Lreturn_save_endptr: + movl 12(%ebp),%ecx # endptr= end-of-string + movl %esi,(%ecx) # *endptr= end-of-string + +.Lms_return: + popl %ebx + popl %edi + popl %esi + movl %ebp,%esp + popl %ebp + ret + +my_strtoll10_end: + .size my_strtoll10,.my_strtoll10_end-my_strtoll10 + .comm res,240,32 + .comm end_ptr,120,32 + .comm error,120,32 + .ident "Monty" diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c new file mode 100644 index 00000000000..0bef961f770 --- /dev/null +++ b/strings/my_strtoll10.c @@ -0,0 +1,237 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include + +#define ULONGLONG_MAX (~(ulonglong) 0) +#define MAX_NEGATIVE_NUMBER ((ulonglong) 0x8000000000000000LL) +#define INIT_CNT 9 +#define LFACTOR LL(1000000000) +#define LFACTOR1 LL(10000000000) +#define LFACTOR2 LL(100000000000) + +static unsigned long lfactor[9]= +{ + 1L, 10L, 100L, 1000L, 10000L, 100000L, 1000000L, 10000000L, 100000000L +}; + +/* + Convert a string to an to unsigned long long integer value + + SYNOPSYS + str2ull10(char *nptr, char **enptr, *long error) + nptr in pointer to the string to be converted + endptr in/out pointer to the end of the string/ + pointer to the stop character + error out returned error code + + DESCRIPTION + This function takes the decimal representation of integer number + from string nptr and converts it to an signed or unsigned + long long integer value. + Space characters and tab are ignored. + A sign character might precede the the digit characters. The number + may have any number of pre-zero digits. + + The function stops reading the string nptr at the first character + that is not a decimal digit. If endptr is not NULL then the function + will not read characters after *endptr. + + RETURN VALUES + Value of string as a signed/unsigned longlong integer + + if no error and endptr != NULL, it will be set to point at the character + after the number + + The error parameter contains information how things went: + -1 Number was an ok negative number + 0 ok + ERANGE If the the value of the converted number exceeded the + maximum negative/unsigned long long integer. + In this case the return value is ~0 if value was + positive and LONGLONG_MIN if value was negative. + EDOM If the string didn't contain any digits. In this case + the return value is 0. + + If endptr is not NULL the function will store the end pointer to + the stop character here. +*/ + + +longlong my_strtoll10(const char *nptr, char **endptr, int *error) +{ + const char *s, *end, *start, *n_end, *true_end; + char *dummy; + unsigned char c; + unsigned long i, j, k; + ulonglong li; + int negative; + long cutoff, cutoff2, cutoff3; + + s= nptr; + /* If fixed length string */ + if (endptr) + { + end= *endptr; + while (s != end && (*s == ' ' || *s == '\t')) + s++; + if (s == end) + goto no_conv; + } + else + { + endptr= &dummy; /* Easier end test */ + while (*s == ' ' || *s == '\t') + s++; + if (!*s) + goto no_conv; + /* This number must be big to guard against a lot of pre-zeros */ + end= s+65535; /* Can't be longer than this */ + } + + /* Check for a sign. */ + negative= 0; + if (*s == '-') + { + *error= -1; /* Mark as negative number */ + negative= 1; + if (++s == end) + goto no_conv; + cutoff= MAX_NEGATIVE_NUMBER / LL(100000000000); + cutoff2= (MAX_NEGATIVE_NUMBER % LL(100000000000)) / 100; + cutoff3= MAX_NEGATIVE_NUMBER % 100; + } + else + { + *error= 0; + if (*s == '+') + { + if (++s == end) + goto no_conv; + } + cutoff= ULONGLONG_MAX / LL(100000000000); + cutoff2= ULONGLONG_MAX % LL(100000000000) / 100; + cutoff3= ULONGLONG_MAX % 100; + } + + /* Handle case where we have a lot of pre-zero */ + if (*s == '0') + { + i= 0; + do + { + if (++s == end) + goto end_i; /* Return 0 */ + } + while (*s == '0'); + n_end= s+ INIT_CNT; + } + else + { + /* Read first digit to check that it's a valid number */ + if ((c= (*s-'0')) > 9) + goto no_conv; + i= c; + n_end= ++s+ INIT_CNT-1; + } + + /* Handle first 9 digits and store them in i */ + if (n_end > end) + n_end= end; + for (; s != n_end ; s++) + { + if ((c= (*s-'0')) > 9) + goto end_i; + i= i*10+c; + } + if (s == end) + goto end_i; + + /* Handle next 9 digits and store them in j */ + j= 0; + start= s; /* Used to know how much to shift i */ + n_end= true_end= s + INIT_CNT; + if (n_end > end) + n_end= end; + do + { + if ((c= (*s-'0')) > 9) + goto end_i_and_j; + j= j*10+c; + } while (++s != n_end); + if (s == end) + { + if (s != true_end) + goto end_i_and_j; + goto end3; + } + if ((c= (*s-'0')) > 9) + goto end3; + + /* Handle the next 1 or 2 digits and store them in k */ + k=c; + if (++s == end || (c= (*s-'0')) > 9) + goto end4; + k= k*10+c; + *endptr= (char*) ++s; + + /* number string should have ended here */ + if (s != end && (c= (*s-'0')) <= 9) + goto overflow; + + /* Check that we didn't get an overflow with the last digit */ + if (i > cutoff || i == cutoff && (j > cutoff2 || j == cutoff2 && + k > cutoff3)) + goto overflow; + li=i*LFACTOR2+ (ulonglong) j*100 + k; + return (longlong) li; + +overflow: /* *endptr is set here */ + *error= MY_ERRNO_ERANGE; + return negative ? LONGLONG_MIN : ULONGLONG_MAX; + +end_i: + *endptr= (char*) s; + return (negative ? ((longlong) -(long) i) : (longlong) i); + +end_i_and_j: + li= (ulonglong) i * lfactor[(uint) (s-start)] + j; + *endptr= (char*) s; + return (negative ? -((longlong) li) : (longlong) li); + +end3: + li=(ulonglong) i*LFACTOR+ (ulonglong) j; + *endptr= (char*) s; + return (negative ? -((longlong) li) : (longlong) li); + +end4: + li=(ulonglong) i*LFACTOR1+ (ulonglong) j * 10 + k; + *endptr= (char*) s; + if (negative) + { + if (li > MAX_NEGATIVE_NUMBER) + goto overflow; + return -((longlong) li); + } + return (longlong) li; + +no_conv: + /* There was no number to convert. */ + *error= MY_ERRNO_EDOM; + *endptr= (char *) nptr; + return 0; +} From 01f85890639612136f2bd1cabd779014a226e9f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Apr 2003 14:49:46 +0500 Subject: [PATCH 24/25] Bugfix for segfault in mysql with embedded library mysys/default.c: Fix for bug in mysql with embedded library we can get NULL in *argv --- mysys/default.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mysys/default.c b/mysys/default.c index 8811efc1190..9fedfd795a5 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -174,7 +174,8 @@ void load_defaults(const char *conf_file, const char **groups, res= (char**) (ptr+sizeof(alloc)); /* copy name + found arguments + command line arguments to new array */ - res[0]=argv[0][0]; + res[0]=*argc ? argv[0][0] : ""; + memcpy((gptr) (res+1), args.buffer, args.elements*sizeof(char*)); /* Skipp --defaults-file and --defaults-extra-file */ (*argc)-= args_used; @@ -187,8 +188,9 @@ void load_defaults(const char *conf_file, const char **groups, --*argc; ++*argv; /* skipp argument */ } - memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1), - (*argc-1)*sizeof(char*)); + if (*argc) + memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1), + (*argc-1)*sizeof(char*)); res[args.elements+ *argc]=0; /* last null */ (*argc)+=args.elements; From d7edf9785b4d6b103e9067be06ec1413320ed50f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Apr 2003 00:18:29 +0200 Subject: [PATCH 25/25] Post-merge fixes. --- mysql-test/r/sp-error.result | 2 +- mysql-test/r/variables.result | 2 +- mysql-test/t/sp-error.test | 34 +++++++++++++++++----------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 3a15b748316..c754544a840 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -27,7 +27,7 @@ call foo(); PROCEDURE foo does not exist drop procedure if exists foo; Warnings: -Warning 1257 PROCEDURE foo does not exist +Warning 1261 PROCEDURE foo does not exist create procedure foo() foo: loop leave bar; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index db4de33ebe0..d5d34730c14 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -286,7 +286,7 @@ set sql_log_bin=1; set sql_log_off=1; set sql_log_update=1; Warnings: -Note 1267 The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored. +Note 1271 The update log is deprecated and replaced by the binary log. SET SQL_LOG_UPDATE has been ignored. set sql_low_priority_updates=1; set sql_max_join_size=200; select @@sql_max_join_size,@@max_join_size; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index dd3bf916260..63850f409dc 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -22,48 +22,48 @@ create function func1() returns int return 42| # Can't create recursively ---error 1255 +--error 1259 create procedure foo() create procedure bar() set @x=3| ---error 1255 +--error 1259 create procedure foo() create function bar() returns double return 2.3| # Already exists ---error 1256 +--error 1260 create procedure proc1() set @x = 42| ---error 1256 +--error 1260 create function func1() returns int return 42| # Does not exist ---error 1257 +--error 1261 alter procedure foo| ---error 1257 +--error 1261 alter function foo| ---error 1257 +--error 1261 drop procedure foo| ---error 1257 +--error 1261 drop function foo| ---error 1257 +--error 1261 call foo()| drop procedure if exists foo| # LEAVE/ITERATE with no match ---error 1260 +--error 1264 create procedure foo() foo: loop leave bar; end loop| ---error 1260 +--error 1264 create procedure foo() foo: loop iterate bar; end loop| # Redefining label ---error 1261 +--error 1265 create procedure foo() foo: loop foo: loop @@ -72,14 +72,14 @@ foo: loop end loop foo| # End label mismatch ---error 1262 +--error 1266 create procedure foo() foo: loop set @x=2; end loop bar| # Referring to undef variable ---error 1263 +--error 1267 create procedure foo(out x int) begin declare y int; @@ -87,17 +87,17 @@ begin end| # We require INTO in SELECTs (for now; this might change in the future) ---error 1264 +--error 1268 create procedure foo(x int) select * from test.t1| # RETURN in FUNCTION only ---error 1265 +--error 1269 create procedure foo() return 42| # Doesn't allow queries in FUNCTIONs (for now :-( ) ---error 1266 +--error 1270 create function foo() returns int begin declare x int;