After merge fixes

Added initialization of all important global variables


BUILD/SETUP.sh:
  build with readline
client/mysqltest.c:
  Added variable SERVER_VERSION
myisam/mi_key.c:
  Indentation change
myisam/mi_open.c:
  After merge fix
myisam/mi_range.c:
  After merge fix
myisam/mi_rkey.c:
  After merge fix
myisam/mi_search.c:
  After merge fix
myisam/myisamdef.h:
  After merge fix
mysql-test/include/not_embedded.inc:
  Fix test (because of wrong utf8 test)
mysql-test/r/alter_table.result:
  Updated results after merge
mysql-test/r/create.result:
  Updated results after merge
mysql-test/r/ctype_recoding.result:
  Updated results after merge
mysql-test/r/fulltext.result:
  Updated results after merge
mysql-test/r/func_group.result:
  Updated results after merge
mysql-test/r/group_by.result:
  Updated results after merge
mysql-test/r/innodb.result:
  Updated results after merge
mysql-test/r/join_outer.result:
  Updated results after merge
mysql-test/r/null_key.result:
  Updated results after merge
mysql-test/r/order_by.result:
  Updated results after merge
mysql-test/r/query_cache.result:
  Updated results after merge
mysql-test/r/repair.result:
  Updated results after merge
mysql-test/r/rpl_flush_tables.result:
  Updated results after merge
mysql-test/r/union.result:
  Updated results after merge
mysql-test/r/update.result:
  Updated results after merge
mysql-test/t/ansi.test:
  After merge fixes
mysql-test/t/create.test:
  After merge fixes
mysql-test/t/ctype_recoding.test:
  After merge fixes
mysql-test/t/ctype_ujis.test:
  After merge fixes
mysql-test/t/fulltext.test:
  After merge fixes
mysql-test/t/innodb.test:
  After merge fixes
mysql-test/t/join_outer.test:
  After merge fixes
mysql-test/t/loaddata.test:
  After merge fixes
mysql-test/t/order_by.test:
  After merge fixes
mysql-test/t/rpl_flush_tables.test:
  After merge fixes
mysql-test/t/status.test:
  After merge fixes
mysql-test/t/subselect.test:
  After merge fixes
sql/convert.cc:
  Code cleanup
sql/field.cc:
  After merge fixes
sql/filesort.cc:
  Remove compiler warning
sql/item.cc:
  More efficient set_name() (no mallocs)
sql/item_cmpfunc.cc:
  Code Code cleanup
  Item_bool_func2::fix_fields() added to get error handling right for cmp_charset
sql/item_cmpfunc.h:
  New prototypes
sql/item_func.cc:
  After merge fix
sql/item_strfunc.cc:
  Faster check for BINARY
sql/log_event.cc:
  Comment cleanup
sql/mysql_priv.h:
  New prototypes and variables
sql/mysqld.cc:
  Added initialization of all important global variables.
  Cleanup of variable declarations
  This is needed ot make the embedded version restartable
sql/opt_sum.cc:
  After merge fix
sql/set_var.cc:
  Code cleanup
sql/sql_acl.cc:
  After merge fix
  Better error message
sql/sql_db.cc:
  After merge fix
sql/sql_derived.cc:
  After merge fix
sql/sql_insert.cc:
  Indentation cleanups
sql/sql_list.h:
  Added empty() to base_ilist
sql/sql_parse.cc:
  After merge fix
sql/sql_select.cc:
  After merge fix
  Fixed derived name handling in EXPLAIN
sql/sql_show.cc:
  After merge fix
sql/sql_string.cc:
  Made copy_and_convert global
sql/sql_string.h:
  Made copy_and_convert global
sql/sql_update.cc:
  After merge fix
sql/sql_yacc.yy:
  After merge fix
sql/thr_malloc.cc:
  Added sql_strmake_with_convert()
sql/unireg.h:
  Added MAX_ALIAS_NAME
strings/ctype-ujis.c:
  Fixed bug in converting to ujis
This commit is contained in:
unknown 2003-05-21 21:39:58 +03:00
parent daac922bc3
commit f72611b4fa
64 changed files with 694 additions and 548 deletions

View File

@ -52,7 +52,7 @@ debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMA
base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti" base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
base_configs="--prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client" base_configs="--prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-readline"
static_link="--with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static" static_link="--with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static"
alpha_configs="" # Not used yet alpha_configs="" # Not used yet
pentium_configs="" pentium_configs=""

View File

@ -939,16 +939,16 @@ int do_system(struct st_query* q)
var_init(&v, 0, 0, 0, 0); var_init(&v, 0, 0, 0, 0);
eval_expr(&v, p, 0); /* NULL terminated */ eval_expr(&v, p, 0); /* NULL terminated */
if (v.str_val_len) if (v.str_val_len)
{ {
char expr_buf[512]; char expr_buf[512];
if ((uint)v.str_val_len > sizeof(expr_buf) - 1) if ((uint)v.str_val_len > sizeof(expr_buf) - 1)
v.str_val_len = sizeof(expr_buf) - 1; v.str_val_len = sizeof(expr_buf) - 1;
memcpy(expr_buf, v.str_val, v.str_val_len); memcpy(expr_buf, v.str_val, v.str_val_len);
expr_buf[v.str_val_len] = 0; expr_buf[v.str_val_len] = 0;
DBUG_PRINT("info", ("running system command '%s'", expr_buf)); DBUG_PRINT("info", ("running system command '%s'", expr_buf));
if (system(expr_buf) && q->abort_on_error) if (system(expr_buf) && q->abort_on_error)
die("system command '%s' failed", expr_buf); die("system command '%s' failed", expr_buf);
} }
var_free(&v); var_free(&v);
return 0; return 0;
} }
@ -2284,7 +2284,7 @@ void get_query_type(struct st_query* q)
q->type=(enum enum_commands) type; /* Found command */ q->type=(enum enum_commands) type; /* Found command */
} }
static byte* get_var_key(const byte* var, uint* len, static byte *get_var_key(const byte* var, uint* len,
my_bool __attribute__((unused)) t) my_bool __attribute__((unused)) t)
{ {
register char* key; register char* key;
@ -2293,11 +2293,11 @@ static byte* get_var_key(const byte* var, uint* len,
return (byte*)key; return (byte*)key;
} }
static VAR* var_init(VAR* v, const char* name, int name_len, const char* val, static VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
int val_len) int val_len)
{ {
int val_alloc_len; int val_alloc_len;
VAR* tmp_var; VAR *tmp_var;
if (!name_len && name) if (!name_len && name)
name_len = strlen(name); name_len = strlen(name);
if (!val_len && val) if (!val_len && val)
@ -2327,7 +2327,7 @@ static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
return tmp_var; return tmp_var;
} }
static void var_free(void* v) static void var_free(void *v)
{ {
my_free(((VAR*) v)->str_val, MYF(MY_WME)); my_free(((VAR*) v)->str_val, MYF(MY_WME));
if (((VAR*)v)->alloced) if (((VAR*)v)->alloced)
@ -2335,10 +2335,10 @@ static void var_free(void* v)
} }
static void var_from_env(const char* name, const char* def_val) static void var_from_env(const char *name, const char *def_val)
{ {
const char* tmp; const char *tmp;
VAR* v; VAR *v;
if (!(tmp = getenv(name))) if (!(tmp = getenv(name)))
tmp = def_val; tmp = def_val;
@ -2347,9 +2347,9 @@ static void var_from_env(const char* name, const char* def_val)
} }
static void init_var_hash() static void init_var_hash(MYSQL *mysql)
{ {
VAR* v; VAR *v;
DBUG_ENTER("init_var_hash"); DBUG_ENTER("init_var_hash");
if (hash_init(&var_hash, charset_info, if (hash_init(&var_hash, charset_info,
1024, 0, 0, get_var_key, var_free, MYF(0))) 1024, 0, 0, get_var_key, var_free, MYF(0)))
@ -2358,16 +2358,19 @@ static void init_var_hash()
var_from_env("SLAVE_MYPORT", "9307"); var_from_env("SLAVE_MYPORT", "9307");
var_from_env("MYSQL_TEST_DIR", "/tmp"); var_from_env("MYSQL_TEST_DIR", "/tmp");
var_from_env("BIG_TEST", opt_big_test ? "1" : "0"); var_from_env("BIG_TEST", opt_big_test ? "1" : "0");
v=var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "63",0); v= var_init(0,"MAX_TABLES", 0, (sizeof(ulong) == 4) ? "31" : "62",0);
hash_insert(&var_hash, (byte*)v); hash_insert(&var_hash, (byte*) v);
v= var_init(0,"SERVER_VERSION", 0, mysql_get_server_info(mysql), 0);
hash_insert(&var_hash, (byte*) v);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
int main(int argc, char** argv) int main(int argc, char **argv)
{ {
int error = 0; int error = 0;
struct st_query* q; struct st_query *q;
my_bool require_file=0, q_send_flag=0; my_bool require_file=0, q_send_flag=0;
char save_file[FN_REFLEN]; char save_file[FN_REFLEN];
MY_INIT(argv[0]); MY_INIT(argv[0]);
@ -2402,7 +2405,6 @@ int main(int argc, char** argv)
embedded_server_args, embedded_server_args,
(char**) embedded_server_groups)) (char**) embedded_server_groups))
die("Can't initialize MySQL server"); die("Can't initialize MySQL server");
init_var_hash();
if (cur_file == file_stack) if (cur_file == file_stack)
*++cur_file = stdin; *++cur_file = stdin;
*lineno=1; *lineno=1;
@ -2421,14 +2423,14 @@ int main(int argc, char** argv)
opt_ssl_capath, opt_ssl_cipher); opt_ssl_capath, opt_ssl_cipher);
#endif #endif
cur_con->name = my_strdup("default", MYF(MY_WME)); if (!(cur_con->name = my_strdup("default", MYF(MY_WME))))
if (!cur_con->name)
die("Out of memory"); die("Out of memory");
if (safe_connect(&cur_con->mysql, host, if (safe_connect(&cur_con->mysql, host, user, pass, db, port, unix_sock))
user, pass, db, port, unix_sock))
die("Failed in mysql_real_connect(): %s", mysql_error(&cur_con->mysql)); die("Failed in mysql_real_connect(): %s", mysql_error(&cur_con->mysql));
init_var_hash(&cur_con->mysql);
while (!read_query(&q)) while (!read_query(&q))
{ {
int current_line_inc = 1, processed = 0; int current_line_inc = 1, processed = 0;
@ -2596,7 +2598,7 @@ int main(int argc, char** argv)
*/ */
static int read_server_arguments(const char* name) static int read_server_arguments(const char *name)
{ {
char argument[1024],buff[FN_REFLEN], *str=0; char argument[1024],buff[FN_REFLEN], *str=0;
FILE *file; FILE *file;

View File

@ -164,7 +164,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
*/ */
uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
uint k_length, MI_KEYSEG **last_used_keyseg) uint k_length, HA_KEYSEG **last_used_keyseg)
{ {
uint length; uint length;
uchar *pos,*end,*start_key=key; uchar *pos,*end,*start_key=key;

View File

@ -186,12 +186,6 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
} }
share->state_diff_length=len-MI_STATE_INFO_SIZE; share->state_diff_length=len-MI_STATE_INFO_SIZE;
if (share->state.header.fulltext_keys)
{
/* Not supported in this version */
my_errno= HA_ERR_UNSUPPORTED;
goto err;
}
mi_state_info_read(disk_cache, &share->state); mi_state_info_read(disk_cache, &share->state);
len= mi_uint2korr(share->state.header.base_info_length); len= mi_uint2korr(share->state.header.base_info_length);
if (len != MI_BASE_INFO_SIZE) if (len != MI_BASE_INFO_SIZE)

View File

@ -59,7 +59,8 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, const byte *start_key,
if (start_key_len == 0) if (start_key_len == 0)
start_key_len=USE_WHOLE_KEY; start_key_len=USE_WHOLE_KEY;
key_buff=info->lastkey+info->s->base.max_key_length; key_buff=info->lastkey+info->s->base.max_key_length;
start_key_len=_mi_pack_key(info,inx,key_buff,(uchar*) start_key,start_key_len); start_key_len= _mi_pack_key(info,inx,key_buff,(uchar*) start_key,
start_key_len, (HA_KEYSEG**) 0);
res=rtree_estimate(info, inx, key_buff, start_key_len, myisam_read_vec[start_search_flag]); res=rtree_estimate(info, inx, key_buff, start_key_len, myisam_read_vec[start_search_flag]);
res=res?res:1; res=res?res:1;
break; break;
@ -104,7 +105,7 @@ static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, uint key_len,
key_len=USE_WHOLE_KEY; key_len=USE_WHOLE_KEY;
key_buff=info->lastkey+info->s->base.max_key_length; key_buff=info->lastkey+info->s->base.max_key_length;
key_len=_mi_pack_key(info,inx,key_buff,(uchar*) key,key_len, key_len=_mi_pack_key(info,inx,key_buff,(uchar*) key,key_len,
(MI_KEYSEG**) 0); (HA_KEYSEG**) 0);
DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg, DBUG_EXECUTE("key",_mi_print_key(DBUG_FILE,keyinfo->seg,
(uchar*) key_buff,key_len);); (uchar*) key_buff,key_len););
nextflag=myisam_read_vec[search_flag]; nextflag=myisam_read_vec[search_flag];

View File

@ -28,7 +28,7 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
uchar *key_buff; uchar *key_buff;
MYISAM_SHARE *share=info->s; MYISAM_SHARE *share=info->s;
MI_KEYDEF *keyinfo; MI_KEYDEF *keyinfo;
MI_KEYSEG *last_used_keyseg; HA_KEYSEG *last_used_keyseg;
uint pack_key_length, use_key_length, nextflag; uint pack_key_length, use_key_length, nextflag;
DBUG_ENTER("mi_rkey"); DBUG_ENTER("mi_rkey");
DBUG_PRINT("enter",("base: %lx inx: %d search_flag: %d", DBUG_PRINT("enter",("base: %lx inx: %d search_flag: %d",

View File

@ -1042,9 +1042,9 @@ uint _mi_keylength(MI_KEYDEF *keyinfo, register uchar *key)
*/ */
uint _mi_keylength_part(MI_KEYDEF *keyinfo, register uchar *key, uint _mi_keylength_part(MI_KEYDEF *keyinfo, register uchar *key,
MI_KEYSEG *end) HA_KEYSEG *end)
{ {
reg1 MI_KEYSEG *keyseg; reg1 HA_KEYSEG *keyseg;
uchar *start= key; uchar *start= key;
for (keyseg=keyinfo->seg ; keyseg != end ; keyseg++) for (keyseg=keyinfo->seg ; keyseg != end ; keyseg++)

View File

@ -538,7 +538,7 @@ extern uchar *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page,
uchar *key, uchar *keypos, uint *return_key_length); uchar *key, uchar *keypos, uint *return_key_length);
extern uint _mi_keylength(MI_KEYDEF *keyinfo,uchar *key); extern uint _mi_keylength(MI_KEYDEF *keyinfo,uchar *key);
extern uint _mi_keylength_part(MI_KEYDEF *keyinfo, register uchar *key, extern uint _mi_keylength_part(MI_KEYDEF *keyinfo, register uchar *key,
MI_KEYSEG *end); HA_KEYSEG *end);
extern uchar *_mi_move_key(MI_KEYDEF *keyinfo,uchar *to,uchar *from); extern uchar *_mi_move_key(MI_KEYDEF *keyinfo,uchar *to,uchar *from);
extern int _mi_search_next(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key, extern int _mi_search_next(MI_INFO *info,MI_KEYDEF *keyinfo,uchar *key,
uint key_length,uint nextflag,my_off_t pos); uint key_length,uint nextflag,my_off_t pos);
@ -553,7 +553,7 @@ extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo);
extern uint _mi_make_key(MI_INFO *info,uint keynr,uchar *key, extern uint _mi_make_key(MI_INFO *info,uint keynr,uchar *key,
const byte *record,my_off_t filepos); const byte *record,my_off_t filepos);
extern uint _mi_pack_key(MI_INFO *info,uint keynr,uchar *key,uchar *old, extern uint _mi_pack_key(MI_INFO *info,uint keynr,uchar *key,uchar *old,
uint key_length, MI_KEYSEG **last_used_keyseg); uint key_length, HA_KEYSEG **last_used_keyseg);
extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,byte *buf); extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,byte *buf);
extern int _mi_read_cache(IO_CACHE *info,byte *buff,my_off_t pos, extern int _mi_read_cache(IO_CACHE *info,byte *buff,my_off_t pos,
uint length,int re_read_if_possibly); uint length,int re_read_if_possibly);

View File

@ -1,5 +1,5 @@
-- require r/not_embedded.require -- require r/not_embedded.require
disable_query_log; disable_query_log;
select version() like "%embedded%" as "have_embedded"; select version() like N'%embedded%' as 'have_embedded';
enable_query_log; enable_query_log;

View File

@ -183,18 +183,20 @@ show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0' `a` int(11) NOT NULL default '0'
) TYPE=HEAP ) TYPE=HEAP CHARSET=latin1
drop table t1; drop table t1;
SET SESSION table_type="gemini"; SET SESSION table_type="gemini";
SELECT @@table_type; SELECT @@table_type;
@@table_type @@table_type
GEMINI GEMINI
CREATE TABLE t1 (a int not null); CREATE TABLE t1 (a int not null);
Warnings:
Warning 1259 Using storage engine MYISAM for table 't1'
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0' `a` int(11) NOT NULL default '0'
) TYPE=MyISAM ) TYPE=MyISAM CHARSET=latin1
SET SESSION table_type=default; SET SESSION table_type=default;
drop table t1; drop table t1;
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2)); create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));

View File

@ -41,3 +41,4 @@ 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 koi8r; SET CHARACTER SET koi8r;
DROP TABLE ÔÁÂÌÉÃÁ; DROP TABLE ÔÁÂÌÉÃÁ;
SET CHARACTER SET default;

View File

@ -216,7 +216,6 @@ test.t1 repair status OK
select * from t1 where match (a) against ('aaaa'); select * from t1 where match (a) against ('aaaa');
a a
drop table t1; drop table t1;
drop table if exists t1;
create table t1 ( ref_mag text not null, fulltext (ref_mag)); create table t1 ( ref_mag text not null, fulltext (ref_mag));
insert into t1 values ('test'); insert into t1 values ('test');
select ref_mag from t1 where match ref_mag against ('+test' in boolean mode); select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);

View File

@ -42,22 +42,12 @@ insert into t1 values (null,null,'');
select count(distinct a),count(distinct grp) from t1; select count(distinct a),count(distinct grp) from t1;
count(distinct a) count(distinct grp) count(distinct a) count(distinct grp)
6 3 6 3
select sum(all a),count(all a),avg(all a),std(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
sum(all a) count(all a) avg(all a) std(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c)
21 6 3.5000 1.7078 7 0 1 6 E
select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
grp sum(a) count(a) avg(a) std(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c)
NULL NULL 0 NULL NULL 0 0 NULL NULL
1 1 1 1.0000 0.0000 1 1 1 1 a a
2 5 2 2.5000 0.5000 3 2 2 3 b c
3 15 3 5.0000 0.8165 7 4 4 6 C E
select grp, sum(a)+count(a)+avg(a)+std(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1; select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
sum(all a) count(all a) avg(all a) std(all a) variance(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c) sum(all a) count(all a) avg(all a) std(all a) variance(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c)
21 6 3.5000 1.7078 2.9167 7 0 1 6 E 21 6 3.5000 1.7078 2.9167 7 0 1 6 E
select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
grp sum(a) count(a) avg(a) std(a) variance(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c) grp sum(a) count(a) avg(a) std(a) variance(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c)
NULL 0 0 NULL NULL NULL 0 0 NULL NULL NULL NULL 0 NULL NULL NULL 0 0 NULL NULL
1 1 1 1.0000 0.0000 0.0000 1 1 1 1 a a 1 1 1 1.0000 0.0000 0.0000 1 1 1 1 a a
2 5 2 2.5000 0.5000 0.2500 3 2 2 3 b c 2 5 2 2.5000 0.5000 0.2500 3 2 2 3 b c
3 15 3 5.0000 0.8165 0.6667 7 4 4 6 C E 3 15 3 5.0000 0.8165 0.6667 7 4 4 6 C E
@ -231,47 +221,6 @@ select max(t1.a2),max(t2.a1) from t1 left outer join t2 on t1.a1=10;
max(t1.a2) max(t2.a1) max(t1.a2) max(t2.a1)
zzz BBB zzz BBB
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 (a int, b int);
select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1;
count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
0 NULL NULL NULL NULL NULL -1 0
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
insert into t1 values (1,null);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL -1 0
insert into t1 values (1,null);
insert into t1 values (2,null);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 0 NULL NULL NULL NULL NULL 0 0
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL -1 0
2 0 NULL NULL NULL NULL NULL -1 0
insert into t1 values (2,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 1 1 1.0000 0.0000 1 1 0 1
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL -1 0
2 1 1 1.0000 0.0000 1 1 1 1
insert into t1 values (3,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 1 1 1.0000 0.0000 1 1 0 1
3 1 1 1.0000 0.0000 1 1 1 1
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL -1 0
2 1 1 1.0000 0.0000 1 1 1 1
3 1 1 1.0000 0.0000 1 1 1 1
drop table t1;
create table t1( create table t1(
a1 char(3) primary key, a1 char(3) primary key,
a2 smallint, a2 smallint,
@ -613,3 +562,44 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 3 NULL 14 Using index 1 SIMPLE t1 index NULL PRIMARY 3 NULL 14 Using index
1 SIMPLE t2 index NULL k2 4 NULL 6 Using where; Using index 1 SIMPLE t2 index NULL k2 4 NULL 6 Using where; Using index
drop table t1, t2; drop table t1, t2;
CREATE TABLE t1 (a int, b int);
select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1;
count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
0 NULL NULL NULL NULL NULL 18446744073709551615 0
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
insert into t1 values (1,null);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
insert into t1 values (1,null);
insert into t1 values (2,null);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 0 NULL NULL NULL NULL NULL 0 0
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 0 NULL NULL NULL NULL NULL 18446744073709551615 0
insert into t1 values (2,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 1 1 1.0000 0.0000 1 1 0 1
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 1 1 1.0000 0.0000 1 1 1 1
insert into t1 values (3,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 1 1 1.0000 0.0000 1 1 0 1
3 1 1 1.0000 0.0000 1 1 1 1
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 1 1 1.0000 0.0000 1 1 1 1
3 1 1 1.0000 0.0000 1 1 1 1
drop table t1;

View File

@ -54,9 +54,9 @@ userid MIN(t1.score+0.0)
2 2.0 2 2.0
1 1.0 1 1.0
EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL; EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary
t2 eq_ref PRIMARY PRIMARY 4 t1.userID 1 Using index 1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 t1.userID 1 Using index
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 ( CREATE TABLE t1 (
PID int(10) unsigned NOT NULL auto_increment, PID int(10) unsigned NOT NULL auto_increment,
@ -253,10 +253,10 @@ key (score)
INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3); INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3);
explain select userid,count(*) from t1 group by userid desc; explain select userid,count(*) from t1 group by userid desc;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort 1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
explain select userid,count(*) from t1 group by userid desc order by null; explain select userid,count(*) from t1 group by userid desc order by null;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary 1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary
select userid,count(*) from t1 group by userid desc; select userid,count(*) from t1 group by userid desc;
userid count(*) userid count(*)
3 5 3 5
@ -269,13 +269,13 @@ select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*));
userid count(*) userid count(*)
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc; explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index 1 SIMPLE t1 range spID spID 5 NULL 3 Using where; Using index
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid; explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index 1 SIMPLE t1 range spID spID 5 NULL 3 Using where; Using index
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null; explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range spID spID 5 NULL 2 Using where; Using index 1 SIMPLE t1 range spID spID 5 NULL 3 Using where; Using index
select spid,count(*) from t1 where spid between 1 and 2 group by spid; select spid,count(*) from t1 where spid between 1 and 2 group by spid;
spid count(*) spid count(*)
1 1 1 1

View File

@ -1209,7 +1209,8 @@ SET AUTOCOMMIT=0;
INSERT INTO t1 ( B_ID ) VALUES ( 1 ); INSERT INTO t1 ( B_ID ) VALUES ( 1 );
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 ); INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
ROLLBACK; ROLLBACK;
Warning: Some non-transactional changed tables couldn't be rolled back Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
SELECT * FROM t1; SELECT * FROM t1;
B_ID B_ID
drop table t1,t2; drop table t1,t2;
@ -1247,12 +1248,12 @@ select count(*) from t1;
count(*) count(*)
29267 29267
explain select * from t1 where c between 1 and 10000; explain select * from t1 where c between 1 and 10000;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t1 range c c 5 NULL 1 Using where 1 SIMPLE t1 range c c 5 NULL 1 Using where
update t1 set c=a; update t1 set c=a;
explain select * from t1 where c between 1 and 10000; explain select * from t1 where c between 1 and 10000;
table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
t1 ALL c NULL NULL NULL 29537 Using where 1 SIMPLE t1 ALL c NULL NULL NULL 29537 Using where
drop table t1,t2; drop table t1,t2;
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb; create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb;
insert into t1 (id) values (null),(null),(null),(null),(null); insert into t1 (id) values (null),(null),(null),(null),(null);
@ -1286,6 +1287,7 @@ a b
13 2 13 2
111 100 111 100
111 100 111 100
drop table t1;
CREATE TABLE t1 (col1 int(1))TYPE=InnoDB; CREATE TABLE t1 (col1 int(1))TYPE=InnoDB;
CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP(+0),INDEX stamp_idx CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP(+0),INDEX stamp_idx
(stamp))TYPE=InnoDB; (stamp))TYPE=InnoDB;

View File

@ -646,7 +646,6 @@ fooID barID fooID
20 2 NULL 20 2 NULL
30 3 30 30 3 30
drop table t1,t2; drop table t1,t2;
drop table if exists t3;
create table t1 (i int); create table t1 (i int);
create table t2 (i int); create table t2 (i int);
create table t3 (i int); create table t3 (i int);

View File

@ -84,7 +84,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a,b a 5 NULL 5 Using where 1 SIMPLE t1 range a,b a 5 NULL 5 Using where
explain select * from t1 where (a is null or a = 7) and b=7 and c=0; explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a,b a 5 NULL 12 Using where 1 SIMPLE t1 ALL a,b NULL NULL NULL 12 Using where
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2; explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref a,b a 5 const 3 Using where 1 SIMPLE t1 ref a,b a 5 const 3 Using where

View File

@ -549,10 +549,10 @@ KEY FieldKey (FieldKey),
KEY LongField (FieldKey,LongVal), KEY LongField (FieldKey,LongVal),
KEY StringField (FieldKey,StringVal(32)) KEY StringField (FieldKey,StringVal(32))
); );
INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3'); INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref FieldKey,LongField,StringField LongField 36 const 2 Using where 1 SIMPLE t1 ref FieldKey,LongField,StringField StringField 36 const 3 Using where; Using filesort
SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
FieldKey LongVal StringVal FieldKey LongVal StringVal
1 0 2 1 0 2

View File

@ -382,14 +382,14 @@ a
set CHARACTER SET cp1251_koi8; set CHARACTER SET cp1251_koi8;
select * from t1; select * from t1;
a a
? á
set CHARACTER SET DEFAULT; set CHARACTER SET DEFAULT;
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 1
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 4 Qcache_hits 5
drop table t1; drop table t1;
create database if not exists mysqltest; create database if not exists mysqltest;
create table mysqltest.t1 (i int not null); create table mysqltest.t1 (i int not null);
@ -415,7 +415,7 @@ Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 2
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 6 Qcache_hits 7
drop database mysqltest; drop database mysqltest;
drop table t1; drop table t1;
create table t1 (i int not null); create table t1 (i int not null);
@ -429,7 +429,7 @@ FOUND_ROWS()
4 4
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 6 Qcache_hits 7
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 1 Qcache_queries_in_cache 1
@ -441,7 +441,7 @@ FOUND_ROWS()
1 1
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 6 Qcache_hits 7
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 2
@ -454,7 +454,7 @@ FOUND_ROWS()
4 4
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 7 Qcache_hits 8
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 2
@ -466,7 +466,7 @@ FOUND_ROWS()
1 1
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 8 Qcache_hits 9
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 2
@ -535,7 +535,7 @@ a
3 3
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 11 Qcache_hits 12
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 2
@ -552,7 +552,7 @@ a
3 3
show status like "Qcache_hits"; show status like "Qcache_hits";
Variable_name Value Variable_name Value
Qcache_hits 12 Qcache_hits 13
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 2

View File

@ -7,7 +7,7 @@ test.t1 repair status OK
alter table t1 TYPE=HEAP; alter table t1 TYPE=HEAP;
repair table t1 use_frm; repair table t1 use_frm;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text
test.t1 repair error The handler for the table doesn't support repair test.t1 repair error The storage enginge for the table doesn't support repair
drop table t1; drop table t1;
repair table t1 use_frm; repair table t1 use_frm;
Table Op Msg_type Msg_text Table Op Msg_type Msg_text

View File

@ -14,7 +14,7 @@ rename table t1 to t5, t2 to t1;
flush no_write_to_binlog tables; flush no_write_to_binlog tables;
show binlog events; show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 4 Start 1 4 Server ver: 4.1.1-alpha-debug-log, Binlog ver: 3 master-bin.000001 4 Start 1 4 Server ver: SERVER_VERSION, Binlog ver: 3
master-bin.000001 79 Query 1 79 use `test`; create table t1 (a int) master-bin.000001 79 Query 1 79 use `test`; create table t1 (a int)
master-bin.000001 137 Query 1 137 use `test`; insert into t1 values (10) master-bin.000001 137 Query 1 137 use `test`; insert into t1 values (10)
master-bin.000001 198 Query 1 198 use `test`; create table t2 (a int) master-bin.000001 198 Query 1 198 use `test`; create table t2 (a int)
@ -27,7 +27,7 @@ a
flush tables; flush tables;
show binlog events; show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 4 Start 1 4 Server ver: 4.1.1-alpha-debug-log, Binlog ver: 3 master-bin.000001 4 Start 1 4 Server ver: SERVER_VERSION, Binlog ver: 3
master-bin.000001 79 Query 1 79 use `test`; create table t1 (a int) master-bin.000001 79 Query 1 79 use `test`; create table t1 (a int)
master-bin.000001 137 Query 1 137 use `test`; insert into t1 values (10) master-bin.000001 137 Query 1 137 use `test`; insert into t1 values (10)
master-bin.000001 198 Query 1 198 use `test`; create table t2 (a int) master-bin.000001 198 Query 1 198 use `test`; create table t2 (a int)

View File

@ -90,9 +90,6 @@ explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a l
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 1 PRIMARY t1 ALL NULL NULL NULL NULL 4
2 UNION t2 ALL NULL NULL NULL NULL 4 Using filesort 2 UNION t2 ALL NULL NULL NULL NULL 4 Using filesort
select found_rows();
found_rows()
0
explain select a,b from t1 union all select a,b from t2; explain select a,b from t1 union all select a,b from t2;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 4 1 PRIMARY t1 ALL NULL NULL NULL NULL 4
@ -132,6 +129,23 @@ create table t3 select a,b from t1 union all select a,b from t2;
insert into t3 select a,b from t1 union all select a,b from t2; insert into t3 select a,b from t1 union all select a,b from t2;
replace into t3 select a,b as c from t1 union all select a,b from t2; replace into t3 select a,b as c from t1 union all select a,b from t2;
drop table t1,t2,t3; drop table t1,t2,t3;
select * union select 1;
No tables used
select 1 as a,(select a union select a);
a (select a union select a)
1 1
(select 1) union (select 2) order by 0;
Unknown column '0' in 'order clause'
SELECT @a:=1 UNION SELECT @a:=@a+1;
@a:=1
1
2
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
Unknown column 'a' in 'field list'
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
1 3
1 3
2 1
CREATE TABLE t1 ( CREATE TABLE t1 (
`pseudo` char(35) NOT NULL default '', `pseudo` char(35) NOT NULL default '',
`pseudo1` char(35) NOT NULL default '', `pseudo1` char(35) NOT NULL default '',
@ -255,11 +269,6 @@ uid rl g1 cid gg
uid rl g1 cid gg uid rl g1 cid gg
1 NULL V1 NULL 1 1 NULL V1 NULL 1
drop table t1,t2,t3,t4,t5,t6; drop table t1,t2,t3,t4,t5,t6;
select * union select 1;
No tables used
select 1 as a,(select a union select a);
a (select a union select a)
1 1
CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM; CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM;
INSERT INTO t1 (id) VALUES("1"); INSERT INTO t1 (id) VALUES("1");
CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL) TYPE=MyISAM; CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL) TYPE=MyISAM;
@ -286,10 +295,6 @@ id_master id text1 text2
1 3 NULL bar3 1 3 NULL bar3
1 4 foo4 bar4 1 4 foo4 bar4
drop table if exists t1,t2; drop table if exists t1,t2;
(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
1 3
1 3
2 1
create table t1 (a int not null primary key auto_increment, b int, key(b)); create table t1 (a int not null primary key auto_increment, b int, key(b));
create table t2 (a int not null primary key auto_increment, b int); create table t2 (a int not null primary key auto_increment, b int);
insert into t1 (b) values (1),(2),(2),(3); insert into t1 (b) values (1),(2),(2),(3);
@ -323,11 +328,3 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
2 UNION t1 ref b b 5 const 1 Using where 2 UNION t1 ref b b 5 const 1 Using where
drop table t1,t2; drop table t1,t2;
(select 1) union (select 2) order by 0;
Unknown column '0' in 'order clause'
SELECT @a:=1 UNION SELECT @a:=@a+1;
@a:=1
1
2
(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
Unknown column 'a' in 'field list'

View File

@ -137,7 +137,10 @@ a b
13 2 13 2
111 100 111 100
111 100 111 100
drop table t1; create table t2 (a int not null, b int not null);
insert into t2 values (1,1),(1,2),(1,3);
update t1 set b=(select distinct 1 from (select * from t2) a);
drop table t1,t2;
CREATE TABLE t1 ( CREATE TABLE t1 (
`id_param` smallint(3) unsigned NOT NULL default '0', `id_param` smallint(3) unsigned NOT NULL default '0',
`nom_option` char(40) NOT NULL default '', `nom_option` char(40) NOT NULL default '',

View File

@ -2,7 +2,9 @@
# Test of ansi mode # Test of ansi mode
# #
--disable_warnings
drop table if exists t1; drop table if exists t1;
--enable_warnings
# Test some functions that works different in ansi mode # Test some functions that works different in ansi mode

View File

@ -145,9 +145,13 @@ drop table t1;
# #
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2)); create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
insert into t1 values ("a", 1), ("b", 2); insert into t1 values ("a", 1), ("b", 2);
!$1048 insert into t1 values ("c", NULL); --error 1048
!$1048 insert into t1 values (NULL, 3); insert into t1 values ("c", NULL);
!$1048 insert into t1 values (NULL, NULL); --error 1048
insert into t1 values (NULL, 3);
--error 1048
insert into t1 values (NULL, NULL);
drop table t1;
# #
# Test create with foreign keys # Test create with foreign keys

View File

@ -26,3 +26,4 @@ SHOW FIELDS FROM таблица;
SET CHARACTER SET koi8r; SET CHARACTER SET koi8r;
DROP TABLE ÔÁÂÌÉÃÁ; DROP TABLE ÔÁÂÌÉÃÁ;
SET CHARACTER SET default;

View File

@ -1,7 +1,9 @@
# #
# Tests with the ujis character set # Tests with the ujis character set
# #
--disable_warnings
drop table if exists t1; drop table if exists t1;
--enable_warnings
# #
# Test problem with LEFT() # Test problem with LEFT()

View File

@ -180,11 +180,9 @@ drop table t1;
# FULLTEXT index on a TEXT filed converted to a CHAR field doesn't work anymore # FULLTEXT index on a TEXT filed converted to a CHAR field doesn't work anymore
# #
drop table if exists t1;
create table t1 ( ref_mag text not null, fulltext (ref_mag)); create table t1 ( ref_mag text not null, fulltext (ref_mag));
insert into t1 values ('test'); insert into t1 values ('test');
select ref_mag from t1 where match ref_mag against ('+test' in boolean mode); select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
alter table t1 change ref_mag ref_mag char (255) not null; alter table t1 change ref_mag ref_mag char (255) not null;
select ref_mag from t1 where match ref_mag against ('+test' in boolean mode); select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
drop table t1; drop table t1;

View File

@ -807,7 +807,6 @@ CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) TYPE=InnoDB;
SET AUTOCOMMIT=0; SET AUTOCOMMIT=0;
INSERT INTO t1 ( B_ID ) VALUES ( 1 ); INSERT INTO t1 ( B_ID ) VALUES ( 1 );
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 ); INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
-- error 1196
ROLLBACK; ROLLBACK;
SELECT * FROM t1; SELECT * FROM t1;
drop table t1,t2; drop table t1,t2;

View File

@ -417,7 +417,7 @@ explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30; select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30; select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30;
drop table t1,t2; drop table t1,t2;
drop table if exists t3;
create table t1 (i int); create table t1 (i int);
create table t2 (i int); create table t2 (i int);
create table t3 (i int); create table t3 (i int);

View File

@ -2,7 +2,9 @@
# Some simple test of load data # Some simple test of load data
# #
--disable_warnings
drop table if exists t1; drop table if exists t1;
--enable_warnings
create table t1 (a date, b date, c date not null, d date); create table t1 (a date, b date, c date not null, d date);
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ','; load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',';

View File

@ -357,7 +357,7 @@ CREATE TABLE t1 (
KEY LongField (FieldKey,LongVal), KEY LongField (FieldKey,LongVal),
KEY StringField (FieldKey,StringVal(32)) KEY StringField (FieldKey,StringVal(32))
); );
INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3'); INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal; SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal; EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;

View File

@ -17,12 +17,14 @@ rename table t1 to t5, t2 to t1;
# first don't write it to the binlog, to test the NO_WRITE_TO_BINLOG keyword. # first don't write it to the binlog, to test the NO_WRITE_TO_BINLOG keyword.
flush no_write_to_binlog tables; flush no_write_to_binlog tables;
# Check that it's not in the binlog. # Check that it's not in the binlog.
--replace_result $SERVER_VERSION SERVER_VERSION
show binlog events; show binlog events;
# Check that the master is not confused. # Check that the master is not confused.
select * from t3; select * from t3;
# This FLUSH should go into the binlog to not confuse the slave. # This FLUSH should go into the binlog to not confuse the slave.
flush tables; flush tables;
# Check that it's in the binlog. # Check that it's in the binlog.
--replace_result $SERVER_VERSION SERVER_VERSION
show binlog events; show binlog events;
save_master_pos; save_master_pos;
connection slave; connection slave;

View File

@ -4,7 +4,7 @@
# This would work if mysqltest run would be threaded and handle each # This would work if mysqltest run would be threaded and handle each
# connection in a separate thread. # connection in a separate thread.
# #
-- source include/not_embedded.inc --source include/not_embedded.inc
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
connect (con2,localhost,root,,); connect (con2,localhost,root,,);

View File

@ -396,6 +396,8 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
-- error 1093 -- error 1093
INSERT INTO t2 VALUES ((SELECT * FROM t2)); INSERT INTO t2 VALUES ((SELECT * FROM t2));
-- error 1093
INSERT INTO t2 VALUES ((SELECT id FROM t2));
SELECT * FROM t2; SELECT * FROM t2;
CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
INSERT INTO t1 values (1),(1); INSERT INTO t1 values (1),(1);

View File

@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#if 0 #ifdef NOT_USED
/* /*
** Convert tables between different character sets ** Convert tables between different character sets
@ -462,4 +462,4 @@ bool CONVERT::store(String *packet,const char *from,uint length)
return 0; return 0;
} }
#endif #endif /* NOT_USED */

View File

@ -3977,23 +3977,19 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)),
int Field_string::cmp(const char *a_ptr, const char *b_ptr) int Field_string::cmp(const char *a_ptr, const char *b_ptr)
{ {
#ifdef USE_STRCOLL if (field_charset->strxfrm_multiply > 1)
if (field_charset->mbmaxlen > 1)
{ {
/* /*
We have to remove end space to be able to compare multi-byte-characters We have to remove end space to be able to compare multi-byte-characters
like in latin_de 'ae' and 0xe4 like in latin_de 'ae' and 0xe4
*/ */
uint a_length= field_length_without_space(a_ptr, field_length); return field_charset->strnncollsp(field_charset,
uint b_length= field_length_without_space(b_ptr, field_length); (const uchar*) a_ptr, field_length,
return my_strnncoll(field_charset, (const uchar*) b_ptr, field_length);
(const uchar*) a_ptr, a_length,
(const uchar*) b_ptr, b_length);
} }
#endif return field_charset->strnncoll(field_charset,
return my_strnncoll(field_charset, (const uchar*) a_ptr, field_length,
(const uchar*) a_ptr, field_length, (const uchar*) b_ptr, field_length);
(const uchar*) b_ptr, field_length);
} }
void Field_string::sort_string(char *to,uint length) void Field_string::sort_string(char *to,uint length)

View File

@ -76,7 +76,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
ulong memavl, min_sort_memory; ulong memavl, min_sort_memory;
uint maxbuffer; uint maxbuffer;
BUFFPEK *buffpek; BUFFPEK *buffpek;
ha_rows records; ha_rows records= HA_POS_ERROR;
uchar **sort_keys; uchar **sort_keys;
IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile; IO_CACHE tempfile, buffpek_pointers, *selected_records_file, *outfile;
SORTPARAM param; SORTPARAM param;

View File

@ -90,28 +90,32 @@ bool Item::check_cols(uint c)
return 0; return 0;
} }
void Item::set_name(const char *str,uint length, CHARSET_INFO *cs)
void Item::set_name(const char *str, uint length, CHARSET_INFO *cs)
{ {
if (!length) if (!length)
name= (char*) str; // Empty string, used by AS
else
{ {
while (length && !my_isgraph(cs,*str)) /* Empty string, used by AS or internal function like last_insert_id() */
{ // Fix problem with yacc name= (char*) str;
length--; return;
str++;
}
if (length && !my_charset_same(cs, system_charset_info))
{
String tmp;
tmp.copy(str, length, cs, system_charset_info);
name=sql_strmake(tmp.ptr(),min(tmp.length(),MAX_FIELD_WIDTH));
}
else
name=sql_strmake(str,min(length,MAX_FIELD_WIDTH));
} }
while (length && !my_isgraph(cs,*str))
{ // Fix problem with yacc
length--;
str++;
}
if (!my_charset_same(cs, system_charset_info))
{
uint32 res_length;
name= sql_strmake_with_convert(str, length, cs,
MAX_ALIAS_NAME, system_charset_info,
&res_length);
}
else
name=sql_strmake(str, min(length,MAX_ALIAS_NAME));
} }
/* /*
This function is only called when comparing items in the WHERE clause This function is only called when comparing items in the WHERE clause
*/ */
@ -1048,13 +1052,6 @@ inline uint char_val(char X)
X-'a'+10); X-'a'+10);
} }
/* In MySQL 4.1 this will always return STRING_RESULT */
enum Item_result Item_varbinary::result_type () const
{
return (current_thd->variables.new_mode) ? STRING_RESULT : INT_RESULT;
}
Item_varbinary::Item_varbinary(const char *str, uint str_length) Item_varbinary::Item_varbinary(const char *str, uint str_length)
{ {

View File

@ -90,7 +90,7 @@ static bool convert_constant_item(Field *field, Item **item)
bool Item_bool_func2::set_cmp_charset(CHARSET_INFO *cs1, enum coercion co1, bool Item_bool_func2::set_cmp_charset(CHARSET_INFO *cs1, enum coercion co1,
CHARSET_INFO *cs2, enum coercion co2) CHARSET_INFO *cs2, enum coercion co2)
{ {
if((cs1 == &my_charset_bin) || (cs2 == &my_charset_bin)) if ((cs1 == &my_charset_bin) || (cs2 == &my_charset_bin))
{ {
cmp_charset= &my_charset_bin; cmp_charset= &my_charset_bin;
return 0; return 0;
@ -114,29 +114,42 @@ bool Item_bool_func2::set_cmp_charset(CHARSET_INFO *cs1, enum coercion co1,
{ {
if (co1 == COER_COERCIBLE) if (co1 == COER_COERCIBLE)
{ {
CHARSET_INFO *c= get_charset_by_csname(cs1->csname,MY_CS_PRIMARY,MYF(0)); CHARSET_INFO *c;
if (c) if ((c= get_charset_by_csname(cs1->csname, MY_CS_PRIMARY, MYF(0))))
{ {
cmp_charset= c; cmp_charset= c;
return 0; return 0;
} }
else
return 1;
} }
else return 1;
return 1;
} }
} }
return 0; return 0;
} }
bool Item_bool_func2::fix_fields(THD *thd, struct st_table_list *tables,
Item ** ref)
{
if (Item_int_func::fix_fields(thd, tables, ref))
return 1;
if (!cmp_charset)
{
/* set_cmp_charset() failed */
my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name());
return 1;
}
return 0;
}
void Item_bool_func2::fix_length_and_dec() void Item_bool_func2::fix_length_and_dec()
{ {
max_length= 1; // Function returns 0 or 1 max_length= 1; // Function returns 0 or 1
/* /*
As some compare functions are generated after sql_yacc, As some compare functions are generated after sql_yacc,
we have to check for out of memory conditons here we have to check for out of memory conditions here
*/ */
if (!args[0] || !args[1]) if (!args[0] || !args[1])
return; return;
@ -149,7 +162,8 @@ void Item_bool_func2::fix_length_and_dec()
if (convert_constant_item(field,&args[1])) if (convert_constant_item(field,&args[1]))
{ {
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1, cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
INT_RESULT); // Works for all types. INT_RESULT); // Works for all types.
cmp_charset= &my_charset_bin; // For test in fix_fields
return; return;
} }
} }
@ -163,17 +177,19 @@ void Item_bool_func2::fix_length_and_dec()
{ {
cmp.set_cmp_func(this, tmp_arg, tmp_arg+1, cmp.set_cmp_func(this, tmp_arg, tmp_arg+1,
INT_RESULT); // Works for all types. INT_RESULT); // Works for all types.
cmp_charset= &my_charset_bin; // For test in fix_fields
return; return;
} }
} }
} }
if (set_cmp_charset(args[0]->charset(), args[0]->coercibility,
args[1]->charset(), args[1]->coercibility))
{
my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name());
return;
}
set_cmp_func(); set_cmp_func();
/*
We must set cmp_charset here as we may be called from for an automatic
generated item, like in natural join
*/
end:
set_cmp_charset(args[0]->charset(), args[0]->coercibility,
args[1]->charset(), args[1]->coercibility);
} }
@ -191,22 +207,22 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type)
comparators= 0; comparators= 0;
return 1; return 1;
} }
if ((comparators= (Arg_comparator *) sql_alloc(sizeof(Arg_comparator)*n))) if (!(comparators= (Arg_comparator *) sql_alloc(sizeof(Arg_comparator)*n)))
for (uint i=0; i < n; i++)
{
if ((*a)->el(i)->cols() != (*b)->el(i)->cols())
{
my_error(ER_CARDINALITY_COL, MYF(0), (*a)->el(i)->cols());
return 1;
}
comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
}
else
return 1; return 1;
for (uint i=0; i < n; i++)
{
if ((*a)->el(i)->cols() != (*b)->el(i)->cols())
{
my_error(ER_CARDINALITY_COL, MYF(0), (*a)->el(i)->cols());
return 1;
}
comparators[i].set_cmp_func(owner, (*a)->addr(i), (*b)->addr(i));
}
} }
return 0; return 0;
} }
int Arg_comparator::compare_string() int Arg_comparator::compare_string()
{ {
String *res1,*res2; String *res1,*res2;
@ -1875,13 +1891,6 @@ bool Item_func_like::fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref)
if (Item_bool_func2::fix_fields(thd, tlist, ref)) if (Item_bool_func2::fix_fields(thd, tlist, ref))
return 1; return 1;
if (set_cmp_charset(args[0]->charset(), args[0]->coercibility,
args[1]->charset(), args[1]->coercibility))
{
my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name());
return 1;
}
/* /*
We could also do boyer-more for non-const items, but as we would have to We could also do boyer-more for non-const items, but as we would have to
recompute the tables for each row it's not worth it. recompute the tables for each row it's not worth it.

View File

@ -116,7 +116,8 @@ protected:
public: public:
Item_bool_func2(Item *a,Item *b): Item_bool_func2(Item *a,Item *b):
Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1) {} Item_int_func(a,b), cmp(tmp_arg, tmp_arg+1), cmp_charset(0) {}
bool fix_fields(THD *thd, TABLE_LIST *tlist, Item ** ref);
void fix_length_and_dec(); void fix_length_and_dec();
void set_cmp_func() void set_cmp_func()
{ {

View File

@ -40,8 +40,8 @@ eval_const_cond(COND *cond)
} }
Item_func::Item_func(List<Item> &list): Item_func::Item_func(List<Item> &list)
allowed_arg_cols(1) :allowed_arg_cols(1)
{ {
arg_count=list.elements; arg_count=list.elements;
if ((args=(Item**) sql_alloc(sizeof(Item*)*arg_count))) if ((args=(Item**) sql_alloc(sizeof(Item*)*arg_count)))
@ -109,10 +109,12 @@ Item_func::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
{ // Print purify happy { // Print purify happy
for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++) for (arg=args, arg_end=args+arg_count; arg != arg_end ; arg++)
{ {
Item *item= *arg; Item *item;
if (item->fix_fields(thd, tables, arg) || /* We can't yet set item to *arg as fix_fields may change *arg */
item->check_cols(allowed_arg_cols)) if ((*arg)->fix_fields(thd, tables, arg) ||
(*arg)->check_cols(allowed_arg_cols))
return 1; /* purecov: inspected */ return 1; /* purecov: inspected */
item= *arg;
if (item->maybe_null) if (item->maybe_null)
maybe_null=1; maybe_null=1;

View File

@ -2174,7 +2174,7 @@ void Item_func_set_collation::fix_length_and_dec()
const char *colname; const char *colname;
String tmp, *str= args[1]->val_str(&tmp); String tmp, *str= args[1]->val_str(&tmp);
colname= str->c_ptr(); colname= str->c_ptr();
if (!strncmp(colname,"BINARY",6)) if (colname == binary_keyword)
set_collation= get_charset_by_csname(args[0]->charset()->csname, set_collation= get_charset_by_csname(args[0]->charset()->csname,
MY_CS_BINSORT,MYF(0)); MY_CS_BINSORT,MYF(0));
else else

View File

@ -195,9 +195,9 @@ static inline int read_str(char * &buf, char *buf_end, char * &str,
} }
/**************************************************************************/ /**************************************************************************
Log_event methods Log_event methods
***************************************************************************/ **************************************************************************/
/* /*
Log_event::get_type_str() Log_event::get_type_str()
@ -715,9 +715,9 @@ void Log_event::set_log_pos(MYSQL_LOG* log)
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
/**************************************************************************/ /**************************************************************************
Query_log_event methods Query_log_event methods
***************************************************************************/ **************************************************************************/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
@ -982,9 +982,9 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
#endif #endif
/**************************************************************************/ /**************************************************************************
Start_log_event methods Start_log_event methods
***************************************************************************/ **************************************************************************/
/* /*
Start_log_event::pack_info() Start_log_event::pack_info()
@ -1093,9 +1093,9 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli)
} }
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
/**************************************************************************/ /**************************************************************************
Load_log_event methods Load_log_event methods
***************************************************************************/ **************************************************************************/
/* /*
Load_log_event::pack_info() Load_log_event::pack_info()
@ -1651,9 +1651,9 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
#endif #endif
/****************************************************************************/ /**************************************************************************
Rotate_log_event methods Rotate_log_event methods
*****************************************************************************/ **************************************************************************/
/* /*
Rotate_log_event::pack_info() Rotate_log_event::pack_info()
@ -1788,9 +1788,9 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
#endif #endif
/***************************************************************************/ /**************************************************************************
Intvar_log_event methods Intvar_log_event methods
****************************************************************************/ **************************************************************************/
/* /*
Intvar_log_event::pack_info() Intvar_log_event::pack_info()
@ -1902,9 +1902,9 @@ int Intvar_log_event::exec_event(struct st_relay_log_info* rli)
#endif #endif
/**************************************************************************** /**************************************************************************
Rand_log_event methods Rand_log_event methods
****************************************************************************/ **************************************************************************/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void Rand_log_event::pack_info(Protocol *protocol) void Rand_log_event::pack_info(Protocol *protocol)
@ -1964,9 +1964,9 @@ int Rand_log_event::exec_event(struct st_relay_log_info* rli)
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
/*************************************************************************** /**************************************************************************
User_var_log_event methods User_var_log_event methods
***************************************************************************/ **************************************************************************/
#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) #if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT)
void User_var_log_event::pack_info(Protocol* protocol) void User_var_log_event::pack_info(Protocol* protocol)
@ -2195,9 +2195,9 @@ int User_var_log_event::exec_event(struct st_relay_log_info* rli)
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
/**************************************************************************** /**************************************************************************
Slave_log_event methods Slave_log_event methods
****************************************************************************/ **************************************************************************/
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
#ifdef MYSQL_CLIENT #ifdef MYSQL_CLIENT
@ -2342,9 +2342,9 @@ int Slave_log_event::exec_event(struct st_relay_log_info* rli)
#endif // !MYSQL_CLIENT #endif // !MYSQL_CLIENT
/***************************************************************************/ /**************************************************************************
Stop_log_event methods Stop_log_event methods
****************************************************************************/ **************************************************************************/
/* /*
Stop_log_event::print() Stop_log_event::print()
@ -2403,9 +2403,9 @@ int Stop_log_event::exec_event(struct st_relay_log_info* rli)
#endif /* HAVE_REPLICATION */ #endif /* HAVE_REPLICATION */
/***************************************************************************/ /**************************************************************************
Create_file_log_event methods Create_file_log_event methods
****************************************************************************/ **************************************************************************/
/* /*
Create_file_log_event ctor Create_file_log_event ctor
@ -2622,9 +2622,9 @@ err:
#endif #endif
/***************************************************************************/ /**************************************************************************
Append_block_log_event methods Append_block_log_event methods
****************************************************************************/ **************************************************************************/
/* /*
Append_block_log_event ctor Append_block_log_event ctor
@ -2739,9 +2739,9 @@ err:
#endif #endif
/***************************************************************************/ /**************************************************************************
Delete_file_log_event methods Delete_file_log_event methods
****************************************************************************/ **************************************************************************/
/* /*
Delete_file_log_event ctor Delete_file_log_event ctor
@ -2829,9 +2829,9 @@ int Delete_file_log_event::exec_event(struct st_relay_log_info* rli)
#endif #endif
/**************************************************************************/ /**************************************************************************
Execute_load_log_event methods Execute_load_log_event methods
***************************************************************************/ **************************************************************************/
/* /*
Execute_load_log_event ctor Execute_load_log_event ctor
@ -2971,9 +2971,9 @@ err:
#endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */ #endif /* defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) */
/**************************************************************************/ /**************************************************************************
sql_ex_info methods sql_ex_info methods
***************************************************************************/ **************************************************************************/
/* /*
sql_ex_info::write_data() sql_ex_info::write_data()

View File

@ -45,6 +45,10 @@ char *sql_strdup(const char *str);
char *sql_strmake(const char *str,uint len); char *sql_strmake(const char *str,uint len);
gptr sql_memdup(const void * ptr,unsigned size); gptr sql_memdup(const void * ptr,unsigned size);
void sql_element_free(void *ptr); void sql_element_free(void *ptr);
char *sql_strmake_with_convert(const char *str, uint32 arg_length,
CHARSET_INFO *from_cs,
uint32 max_res_length,
CHARSET_INFO *to_cs, uint32 *result_length);
void kill_one_thread(THD *thd, ulong id); void kill_one_thread(THD *thd, ulong id);
bool net_request_file(NET* net, const char* fname); bool net_request_file(NET* net, const char* fname);
char* query_table_status(THD *thd,const char *db,const char *table_name); char* query_table_status(THD *thd,const char *db,const char *table_name);
@ -687,7 +691,7 @@ extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list)) #define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
extern MY_TMPDIR mysql_tmpdir_list; extern MY_TMPDIR mysql_tmpdir_list;
extern const char *command_name[]; extern const char *command_name[];
extern const char *first_keyword, *localhost, *delayed_user; extern const char *first_keyword, *localhost, *delayed_user, *binary_keyword;
extern const char **errmesg; /* Error messages */ extern const char **errmesg; /* Error messages */
extern const char *myisam_recover_options_str; extern const char *myisam_recover_options_str;
extern uchar *days_in_month; extern uchar *days_in_month;

View File

@ -116,7 +116,7 @@ int deny_severity = LOG_WARNING;
#define my_fromhost(A) fromhost() #define my_fromhost(A) fromhost()
#define my_hosts_access(A) hosts_access() #define my_hosts_access(A) hosts_access()
#define my_eval_client(A) eval_client() #define my_eval_client(A) eval_client()
#endif #endif /* __STDC__ */
#endif /* HAVE_LIBWRAP */ #endif /* HAVE_LIBWRAP */
#ifdef HAVE_SYS_MMAN_H #ifdef HAVE_SYS_MMAN_H
@ -128,8 +128,8 @@ int deny_severity = LOG_WARNING;
#include <library.h> #include <library.h>
#include <monitor.h> #include <monitor.h>
event_handle_t eh; static event_handle_t eh;
Report_t ref; static Report_t ref;
#endif /* __NETWARE__ */ #endif /* __NETWARE__ */
#ifdef _AIX41 #ifdef _AIX41
@ -169,6 +169,7 @@ inline void reset_floating_point_exceptions()
#else #else
#define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads #define THR_KILL_SIGNAL SIGUSR2 // Can't use this with LinuxThreads
#endif #endif
#define MYSQL_KILL_SIGNAL SIGTERM
#ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R #ifdef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R
#include <sys/types.h> #include <sys/types.h>
@ -183,26 +184,6 @@ inline void reset_floating_point_exceptions()
extern "C" int gethostname(char *name, int namelen); extern "C" int gethostname(char *name, int namelen);
#endif #endif
#define MYSQL_KILL_SIGNAL SIGTERM
#ifndef DBUG_OFF
static const char* default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
"d:t:i:o,/tmp/mysqld.trace");
#endif
#ifdef __NT__
static char szPipeName [ 257 ];
static SECURITY_ATTRIBUTES saPipeSecurity;
static SECURITY_DESCRIPTOR sdPipeDescriptor;
static HANDLE hPipe = INVALID_HANDLE_VALUE;
#endif
#ifdef __WIN__
static pthread_cond_t COND_handler_count;
static uint handler_count;
static bool start_mode=0, use_opt_args;
static int opt_argc;
static char **opt_argv;
#endif
/* Set prefix for windows binary */ /* Set prefix for windows binary */
#ifdef __WIN__ #ifdef __WIN__
@ -220,192 +201,78 @@ static char **opt_argv;
#endif /* __NT__ */ #endif /* __NT__ */
#endif /* __WIN__ */ #endif /* __WIN__ */
#ifdef HAVE_BERKELEY_DB
SHOW_COMP_OPTION have_berkeley_db=SHOW_OPTION_YES; /* Constants */
#else
SHOW_COMP_OPTION have_berkeley_db=SHOW_OPTION_NO;
#endif
#ifdef HAVE_INNOBASE_DB
SHOW_COMP_OPTION have_innodb=SHOW_OPTION_YES;
#else
SHOW_COMP_OPTION have_innodb=SHOW_OPTION_NO;
#endif
#ifdef HAVE_ISAM
SHOW_COMP_OPTION have_isam=SHOW_OPTION_YES;
#else
SHOW_COMP_OPTION have_isam=SHOW_OPTION_NO;
#endif
#ifdef USE_RAID
SHOW_COMP_OPTION have_raid=SHOW_OPTION_YES;
#else
SHOW_COMP_OPTION have_raid=SHOW_OPTION_NO;
#endif
#ifdef HAVE_OPENSSL
SHOW_COMP_OPTION have_openssl=SHOW_OPTION_YES;
#else
SHOW_COMP_OPTION have_openssl=SHOW_OPTION_NO;
#endif
#ifdef HAVE_BROKEN_REALPATH
SHOW_COMP_OPTION have_symlink=SHOW_OPTION_NO;
#else
SHOW_COMP_OPTION have_symlink=SHOW_OPTION_YES;
#endif
#ifdef HAVE_QUERY_CACHE
SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_YES;
#else
SHOW_COMP_OPTION have_query_cache=SHOW_OPTION_NO;
#endif
#ifdef HAVE_CRYPT
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"}; const char *show_comp_option_name[]= {"YES", "NO", "DISABLED"};
const char *sql_mode_names[] =
bool opt_large_files= sizeof(my_off_t) > 4; {
"REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
"SERIALIZE", "ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",
"POSTGRESQL", "ORACLE", "MSSQL", "DB2", "SAPDB", "NO_KEY_OPTIONS",
"NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS", "MYSQL323", "MYSQL40",
NullS
};
TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"",
sql_mode_names };
const char *first_keyword= "first", *binary_keyword= "BINARY";
const char *localhost= "localhost", *delayed_user= "DELAYED";
#if SIZEOF_OFF_T > 4 && defined(BIG_TABLES) #if SIZEOF_OFF_T > 4 && defined(BIG_TABLES)
#define GET_HA_ROWS GET_ULL #define GET_HA_ROWS GET_ULL
#else #else
#define GET_HA_ROWS GET_ULONG #define GET_HA_ROWS GET_ULONG
#endif #endif
#ifdef HAVE_LIBWRAP bool opt_large_files= sizeof(my_off_t) > 4;
char *libwrapName= NULL;
#endif
/*
Variables to store startup options
*/
my_bool opt_skip_slave_start = 0; // If set, slave is not autostarted
/*
If set, some standard measures to enforce slave data integrity will not
be performed
*/
my_bool opt_reckless_slave = 0;
ulong back_log, connect_timeout, concurrency;
char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], time_zone[30];
char log_error_file[FN_REFLEN];
bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
bool opt_error_log= IF_WIN(1,0);
bool opt_disable_networking=0, opt_skip_show_db=0;
my_bool opt_enable_named_pipe= 0;
my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol;
uint delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
static my_bool opt_do_pstack = 0;
static ulong opt_specialflag=SPECIAL_ENGLISH;
static ulong opt_myisam_block_size;
static my_socket unix_sock= INVALID_SOCKET,ip_sock= INVALID_SOCKET;
static my_string opt_logname=0,opt_update_logname=0,
opt_binlog_index_name = 0,opt_slow_logname=0;
static char* mysql_home_ptr= mysql_home;
static char* pidfile_name_ptr= pidfile_name;
char* log_error_file_ptr= log_error_file;
static pthread_t select_thread;
static my_bool opt_noacl=0, opt_bootstrap=0, opt_myisam_log=0;
my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
my_bool lower_case_table_names, opt_old_rpl_compat;
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
my_bool opt_log_slave_updates= 0, opt_old_passwords=0, use_old_passwords=0;
my_bool opt_console= 0, opt_bdb, opt_innodb, opt_isam;
volatile bool mqh_used = 0;
FILE *bootstrap_file=0;
static bool kill_in_progress=0, segfaulted= 0;
struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
static int cleanup_done;
static char **defaults_argv;
char glob_hostname[FN_REFLEN];
#include "sslopt-vars.h"
#ifdef HAVE_OPENSSL
char *des_key_file = 0;
struct st_VioSSLAcceptorFd *ssl_acceptor_fd= 0;
#endif /* HAVE_OPENSSL */
I_List <i_string_pair> replicate_rewrite_db;
I_List<i_string> replicate_do_db, replicate_ignore_db;
// allow the user to tell us which db to replicate and which to ignore
I_List<i_string> binlog_do_db, binlog_ignore_db;
/* if we guessed server_id , we need to know about it */
ulong server_id= 0; // Must be long becasue of set_var.cc
bool server_id_supplied = 0;
uint mysql_port;
uint test_flags = 0, select_errors=0, dropping_tables=0,ha_open_options=0;
uint volatile thread_count=0, thread_running=0, kill_cached_threads=0,
wake_thread=0;
ulong thd_startup_options=(OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL |
OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE );
uint protocol_version=PROTOCOL_VERSION;
struct system_variables global_system_variables;
struct system_variables max_system_variables;
ulonglong keybuff_size;
ulong table_cache_size,
thread_stack,
thread_stack_min,what_to_log= ~ (1L << (uint) COM_TIME),
query_buff_size,
slow_launch_time = 2L,
slave_open_temp_tables=0,
open_files_limit=0, max_binlog_size;
ulong com_stat[(uint) SQLCOM_END], com_other;
ulong slave_net_timeout;
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
ulong query_cache_size=0;
#ifdef HAVE_QUERY_CACHE
ulong query_cache_limit= 0;
ulong query_cache_min_res_unit= QUERY_CACHE_MIN_RESULT_DATA_SIZE;
Query_cache query_cache;
#endif
arg_cmp_func Arg_comparator::comparator_matrix[4][2] = arg_cmp_func Arg_comparator::comparator_matrix[4][2] =
{{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string}, {{&Arg_comparator::compare_string, &Arg_comparator::compare_e_string},
{&Arg_comparator::compare_real, &Arg_comparator::compare_e_real}, {&Arg_comparator::compare_real, &Arg_comparator::compare_e_real},
{&Arg_comparator::compare_int, &Arg_comparator::compare_e_int}, {&Arg_comparator::compare_int, &Arg_comparator::compare_e_int},
{&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}}; {&Arg_comparator::compare_row, &Arg_comparator::compare_e_row}};
#ifdef HAVE_SMEM
char *shared_memory_base_name=default_shared_memory_base_name;
my_bool opt_enable_shared_memory = 0;
#endif
volatile ulong cached_thread_count=0;
// replication parameters, if master_host is not NULL, we are a slave /* Global variables */
my_string master_user = (char*) "test", master_password = 0, master_host=0,
master_info_file = (char*) "master.info",
relay_log_info_file = (char*) "relay-log.info",
master_ssl_key=0, master_ssl_cert=0, master_ssl_capath=0, master_ssl_cipher=0;
my_string report_user = 0, report_password = 0, report_host=0;
const char *localhost=LOCAL_HOST;
const char *delayed_user="DELAYED";
uint master_port = MYSQL_PORT, master_connect_retry = 60;
uint report_port = MYSQL_PORT;
my_bool master_ssl = 0;
ulong master_retry_count=0;
ulong bytes_sent = 0L, bytes_received = 0L;
bool opt_log, opt_update_log, opt_bin_log, opt_slow_log;
bool opt_error_log= IF_WIN(1,0);
bool opt_disable_networking=0, opt_skip_show_db=0;
bool server_id_supplied = 0;
bool opt_endinfo,using_udf_functions, locked_in_memory; bool opt_endinfo,using_udf_functions, locked_in_memory;
bool opt_using_transactions, using_update_log; bool opt_using_transactions, using_update_log;
bool volatile abort_loop, select_thread_in_use, signal_thread_in_use; bool volatile abort_loop, select_thread_in_use, signal_thread_in_use;
bool volatile ready_to_exit, shutdown_in_progress, grant_option; bool volatile ready_to_exit, shutdown_in_progress, grant_option;
my_bool opt_skip_slave_start = 0; // If set, slave is not autostarted
my_bool opt_reckless_slave = 0;
my_bool opt_enable_named_pipe= 0;
my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol;
my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
my_bool lower_case_table_names, opt_old_rpl_compat;
my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
my_bool opt_log_slave_updates= 0, opt_old_passwords=0, use_old_passwords=0;
my_bool opt_console= 0, opt_bdb, opt_innodb, opt_isam;
my_bool opt_readonly, use_temp_pool, relay_log_purge;
volatile bool mqh_used = 0;
uint mysql_port, test_flags, select_errors, dropping_tables, ha_open_options;
uint delay_key_write_options, protocol_version;
uint volatile thread_count, thread_running, kill_cached_threads, wake_thread;
ulong back_log, connect_timeout, concurrency;
ulong server_id, thd_startup_options;
ulong table_cache_size, thread_stack, thread_stack_min, what_to_log;
ulong query_buff_size, slow_launch_time, slave_open_temp_tables;
ulong open_files_limit, max_binlog_size;
ulong slave_net_timeout;
ulong thread_cache_size=0, binlog_cache_size=0, max_binlog_cache_size=0;
ulong query_cache_size=0;
ulong com_stat[(uint) SQLCOM_END], com_other;
ulong bytes_sent, bytes_received;
ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */ ulong refresh_version=1L,flush_version=1L; /* Increments on each reload */
ulong query_id=1L,long_query_count,aborted_threads, ulong query_id, long_query_count, aborted_threads, aborted_connects;
aborted_connects,delayed_insert_timeout,delayed_insert_limit, ulong delayed_insert_timeout, delayed_insert_limit, delayed_queue_size;
delayed_queue_size,delayed_insert_threads,delayed_insert_writes, ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use;
delayed_rows_in_use,delayed_insert_errors,flush_time, thread_created; ulong delayed_insert_errors,flush_time, thread_created;
ulong filesort_rows, filesort_range_count, filesort_scan_count; ulong filesort_rows, filesort_range_count, filesort_scan_count;
ulong filesort_merge_passes; ulong filesort_merge_passes;
ulong select_range_check_count, select_range_count, select_scan_count; ulong select_range_check_count, select_range_count, select_scan_count;
@ -417,51 +284,52 @@ ulong max_connections,max_insert_delayed_threads,max_used_connections,
ulong thread_id=1L,current_pid; ulong thread_id=1L,current_pid;
ulong slow_launch_threads = 0; ulong slow_launch_threads = 0;
ulong expire_logs_days = 0; ulong expire_logs_days = 0;
ulong rpl_recovery_rank=0;
ulong my_bind_addr; /* the address we bind to */
volatile ulong cached_thread_count= 0;
ulonglong keybuff_size;
double log_10[32]; /* 10 potences */
time_t start_time;
char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN], time_zone[30];
char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN];
char* log_error_file_ptr= log_error_file;
char mysql_real_data_home[FN_REFLEN], char mysql_real_data_home[FN_REFLEN],
language[LIBLEN],reg_ext[FN_EXTLEN], language[LIBLEN],reg_ext[FN_EXTLEN],
mysql_charsets_dir[FN_REFLEN], *charsets_list, mysql_charsets_dir[FN_REFLEN], *charsets_list,
max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file; max_sort_char,*mysqld_user,*mysqld_chroot, *opt_init_file;
char *language_ptr= language; char *language_ptr= language;
char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home; char mysql_data_home_buff[2], *mysql_data_home=mysql_real_data_home;
#ifndef EMBEDDED_LIBRARY
bool mysql_embedded=0;
#else
bool mysql_embedded=1;
#endif
static char *opt_bin_logname = 0;
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION; char server_version[SERVER_VERSION_LENGTH]=MYSQL_SERVER_VERSION;
const char *first_keyword="first"; char *mysql_unix_port, *opt_mysql_tmpdir;
char *my_bind_addr_str;
const char **errmesg; /* Error messages */ const char **errmesg; /* Error messages */
const char *myisam_recover_options_str="OFF"; const char *myisam_recover_options_str="OFF";
const char *sql_mode_str="OFF"; const char *sql_mode_str="OFF";
ulong rpl_recovery_rank=0;
my_bool relay_log_purge=1;
my_string mysql_unix_port=NULL, opt_mysql_tmpdir=NULL; FILE *bootstrap_file;
MY_TMPDIR mysql_tmpdir_list;
ulong my_bind_addr; /* the address we bind to */ I_List <i_string_pair> replicate_rewrite_db;
char *my_bind_addr_str; I_List<i_string> replicate_do_db, replicate_ignore_db;
DATE_FORMAT dayord; // allow the user to tell us which db to replicate and which to ignore
double log_10[32]; /* 10 potences */ I_List<i_string> binlog_do_db, binlog_ignore_db;
I_List<THD> threads,thread_cache; I_List<THD> threads,thread_cache;
time_t start_time;
const char *sql_mode_names[] = struct system_variables global_system_variables;
{ struct system_variables max_system_variables;
"REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
"SERIALIZE", "ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",
"POSTGRESQL", "ORACLE", "MSSQL", "DB2", "SAPDB", "NO_KEY_OPTIONS",
"NO_TABLE_OPTIONS", "NO_FIELD_OPTIONS", "MYSQL323", "MYSQL40",
NullS
};
TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"",
sql_mode_names};
MY_TMPDIR mysql_tmpdir_list;
DATE_FORMAT dayord;
MY_BITMAP temp_pool; MY_BITMAP temp_pool;
my_bool use_temp_pool=0;
SHOW_COMP_OPTION have_berkeley_db, have_innodb, have_isam;
SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_query_cache;
SHOW_COMP_OPTION have_crypt, have_compress;
/* Thread specific variables */
pthread_key(MEM_ROOT*,THR_MALLOC); pthread_key(MEM_ROOT*,THR_MALLOC);
pthread_key(THD*, THR_THD); pthread_key(THD*, THR_THD);
@ -479,24 +347,98 @@ pthread_cond_t COND_thread_cache,COND_flush_thread_cache;
pthread_t signal_thread; pthread_t signal_thread;
pthread_attr_t connection_attrib; pthread_attr_t connection_attrib;
/* replication parameters, if master_host is not NULL, we are a slave */
my_bool master_ssl;
uint master_port= MYSQL_PORT, master_connect_retry = 60;
uint report_port= MYSQL_PORT;
ulong master_retry_count=0;
char *master_user, *master_password, *master_host, *master_info_file;
char *relay_log_info_file, *master_ssl_key, *master_ssl_cert;
char *master_ssl_capath, *master_ssl_cipher, *report_user;
char *report_password, *report_host;
char *opt_relay_logname = 0, *opt_relaylog_index_name=0;
/* Static variables */
static bool kill_in_progress, segfaulted;
static my_bool opt_do_pstack, opt_noacl, opt_bootstrap, opt_myisam_log;
static int cleanup_done;
static ulong opt_specialflag, opt_myisam_block_size;
static char *opt_logname, *opt_update_logname, *opt_binlog_index_name;
static char *opt_slow_logname;
static char *mysql_home_ptr, *pidfile_name_ptr;
static char **defaults_argv;
static char *opt_bin_logname;
static my_socket unix_sock,ip_sock;
static pthread_t select_thread;
struct rand_struct sql_rand; // used by sql_class.cc:THD::THD()
/* OS specific variables */
#ifdef __WIN__ #ifdef __WIN__
#undef getpid #undef getpid
#include <process.h> #include <process.h>
static pthread_cond_t COND_handler_count;
static uint handler_count;
static bool start_mode=0, use_opt_args;
static int opt_argc;
static char **opt_argv;
#if !defined(EMBEDDED_LIBRARY) #if !defined(EMBEDDED_LIBRARY)
HANDLE hEventShutdown; static HANDLE hEventShutdown;
static char shutdown_event_name[40]; static char shutdown_event_name[40];
#include "nt_servc.h" #include "nt_servc.h"
static NTService Service; // Service object for WinNT static NTService Service; // Service object for WinNT
#endif #endif /* EMBEDDED_LIBRARY */
#endif /* __WIN__ */
#ifdef __NT__
static char szPipeName [ 257 ];
static SECURITY_ATTRIBUTES saPipeSecurity;
static SECURITY_DESCRIPTOR sdPipeDescriptor;
static HANDLE hPipe = INVALID_HANDLE_VALUE;
#endif #endif
#ifdef OS2 #ifdef OS2
pthread_cond_t eventShutdown; pthread_cond_t eventShutdown;
#endif #endif
#ifndef EMBEDDED_LIBRARY
bool mysql_embedded=0;
#else
bool mysql_embedded=1;
#endif
#ifndef DBUG_OFF
static const char* default_dbug_option;
#endif
#ifdef HAVE_LIBWRAP
char *libwrapName= NULL;
#endif
#ifdef HAVE_QUERY_CACHE
ulong query_cache_limit= 0;
ulong query_cache_min_res_unit= QUERY_CACHE_MIN_RESULT_DATA_SIZE;
Query_cache query_cache;
#endif
#ifdef HAVE_SMEM
char *shared_memory_base_name= default_shared_memory_base_name;
my_bool opt_enable_shared_memory;
#endif
#include "sslopt-vars.h"
#ifdef HAVE_OPENSSL
char *des_key_file;
struct st_VioSSLAcceptorFd *ssl_acceptor_fd;
#endif /* HAVE_OPENSSL */
/* Function declarations */
static void start_signal_handler(void); static void start_signal_handler(void);
extern "C" pthread_handler_decl(signal_hand, arg); extern "C" pthread_handler_decl(signal_hand, arg);
static void set_options(void); static void mysql_init_variables(void);
static void get_options(int argc,char **argv); static void get_options(int argc,char **argv);
static int init_thread_environment(); static int init_thread_environment();
static char *get_relative_path(const char *path); static char *get_relative_path(const char *path);
@ -1998,6 +1940,7 @@ static int init_common_variables(const char *conf_file_name, int argc,
max_system_variables.pseudo_thread_id= (ulong)~0; max_system_variables.pseudo_thread_id= (ulong)~0;
start_time=time((time_t*) 0); start_time=time((time_t*) 0);
mysql_init_variables();
#ifdef OS2 #ifdef OS2
{ {
@ -2036,7 +1979,6 @@ static int init_common_variables(const char *conf_file_name, int argc,
load_defaults(conf_file_name, groups, &argc, &argv); load_defaults(conf_file_name, groups, &argc, &argv);
defaults_argv=argv; defaults_argv=argv;
set_options();
get_options(argc,argv); get_options(argc,argv);
if (init_thread_environment()) if (init_thread_environment())
return 1; return 1;
@ -4610,18 +4552,110 @@ To see what values a running MySQL server is using, type\n\
} }
static void set_options(void) /*
Initialize all MySQL global variables to default values
SYNOPSIS
mysql_init_variables()
NOTES
The reason to set a lot of global variables to zero is to allow one to
restart the embedded server with a clean environment
It's also needed on some exotic platforms where global variables are
not set to 0 when a program starts.
We don't need to set numeric variables refered to in my_long_options
as these are initialized by my_getopt.
*/
static void mysql_init_variables(void)
{ {
#if !defined( my_pthread_setprio ) && !defined( HAVE_PTHREAD_SETSCHEDPARAM ) /* Things reset to zero */
opt_specialflag |= SPECIAL_NO_PRIOR; opt_skip_slave_start= opt_reckless_slave = 0;
#endif mysql_home[0]= pidfile_name[0]= log_error_file[0]= 0;
opt_log= opt_update_log= opt_bin_log= opt_slow_log= 0;
opt_disable_networking= opt_skip_show_db=0;
opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname=0;
opt_bootstrap= opt_myisam_log= use_old_passwords= 0;
mqh_used= 0;
segfaulted= kill_in_progress= 0;
cleanup_done= 0;
defaults_argv= 0;
server_id_supplied= 0;
test_flags= select_errors= dropping_tables= ha_open_options=0;
thread_count= thread_running= kill_cached_threads= wake_thread=0;
slave_open_temp_tables= 0;
com_other= 0;
cached_thread_count= 0;
bytes_sent= bytes_received= 0;
opt_endinfo= using_udf_functions= 0;
opt_using_transactions= using_update_log= 0;
abort_loop= select_thread_in_use= signal_thread_in_use= 0;
ready_to_exit= shutdown_in_progress= grant_option= 0;
long_query_count= aborted_threads= aborted_connects= 0;
delayed_insert_threads= delayed_insert_writes= delayed_rows_in_use= 0;
delayed_insert_errors= thread_created= 0;
filesort_rows= filesort_range_count= filesort_scan_count= 0;
filesort_merge_passes= select_range_check_count= select_range_count= 0;
select_scan_count= select_full_range_join_count= select_full_join_count= 0;
specialflag= opened_tables= created_tmp_tables= created_tmp_disk_tables= 0;
max_used_connections= slow_launch_threads = 0;
max_sort_char= 0;
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
errmesg= 0;
mysql_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS;
bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list));
bzero((gptr) &com_stat, sizeof(com_stat));
/* Things with default values that are not zero */
delay_key_write_options= (uint) DELAY_KEY_WRITE_ON;
opt_specialflag= SPECIAL_ENGLISH;
unix_sock= ip_sock= INVALID_SOCKET;
mysql_home_ptr= mysql_home;
pidfile_name_ptr= pidfile_name;
log_error_file_ptr= log_error_file;
language_ptr= language;
mysql_data_home= mysql_real_data_home;
thd_startup_options= (OPTION_UPDATE_LOG | OPTION_AUTO_IS_NULL |
OPTION_BIN_LOG | OPTION_QUOTE_SHOW_CREATE);
protocol_version= PROTOCOL_VERSION;
what_to_log= ~ (1L << (uint) COM_TIME);
refresh_version= flush_version= 1L; /* Increments on each reload */
thread_id= 1L;
strmov(server_version, MYSQL_SERVER_VERSION);
myisam_recover_options_str= sql_mode_str= "OFF";
my_bind_addr = htonl(INADDR_ANY);
threads.empty();
thread_cache.empty();
/* Initialize structures that is used when processing options */
replicate_rewrite_db.empty();
replicate_do_db.empty();
replicate_ignore_db.empty();
binlog_do_db.empty();
binlog_ignore_db.empty();
/* Set directory paths */
strmake(language, LANGUAGE, sizeof(language)-1);
strmake(mysql_real_data_home, get_relative_path(DATADIR),
sizeof(mysql_real_data_home)-1);
mysql_data_home_buff[0]=FN_CURLIB; // all paths are relative from here
mysql_data_home_buff[1]=0;
/* Replication parameters */
master_user= (char*) "test";
master_password= master_host= 0;
master_info_file= (char*) "master.info",
relay_log_info_file= (char*) "relay-log.info",
master_ssl_key= master_ssl_cert= master_ssl_capath= master_ssl_cipher= 0;
report_user= report_password = report_host= 0; /* TO BE DELETED */
opt_relay_logname= opt_relaylog_index_name= 0;
/* Variables in libraries */
charsets_dir= 0;
sys_charset.value= (char*) MYSQL_CHARSET; sys_charset.value= (char*) MYSQL_CHARSET;
(void) strmake(language, LANGUAGE, sizeof(language)-1);
(void) strmake(mysql_real_data_home, get_relative_path(DATADIR),
sizeof(mysql_real_data_home)-1);
/* Set default values for some variables */ /* Set default values for some option variables */
global_system_variables.collation_results= default_charset_info; global_system_variables.collation_results= default_charset_info;
global_system_variables.collation_client= default_charset_info; global_system_variables.collation_client= default_charset_info;
global_system_variables.collation_connection= default_charset_info; global_system_variables.collation_connection= default_charset_info;
@ -4632,6 +4666,71 @@ static void set_options(void)
global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR; global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR; max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR;
/* Variables that depends on compile options */
#ifndef DBUG_OFF
default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
"d:t:i:o,/tmp/mysqld.trace");
#endif
opt_error_log= IF_WIN(1,0);
#ifdef HAVE_BERKELEY_DB
have_berkeley_db= SHOW_OPTION_YES;
#else
have_berkeley_db= SHOW_OPTION_NO;
#endif
#ifdef HAVE_INNOBASE_DB
have_innodb=SHOW_OPTION_YES;
#else
have_innodb=SHOW_OPTION_NO;
#endif
#ifdef HAVE_ISAM
have_isam=SHOW_OPTION_YES;
#else
have_isam=SHOW_OPTION_NO;
#endif
#ifdef USE_RAID
have_raid=SHOW_OPTION_YES;
#else
have_raid=SHOW_OPTION_NO;
#endif
#ifdef HAVE_OPENSSL
have_openssl=SHOW_OPTION_YES;
#else
have_openssl=SHOW_OPTION_NO;
#endif
#ifdef HAVE_BROKEN_REALPATH
have_symlink=SHOW_OPTION_NO;
#else
have_symlink=SHOW_OPTION_YES;
#endif
#ifdef HAVE_QUERY_CACHE
have_query_cache=SHOW_OPTION_YES;
#else
have_query_cache=SHOW_OPTION_NO;
#endif
#ifdef HAVE_CRYPT
have_crypt=SHOW_OPTION_YES;
#else
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
#ifdef HAVE_LIBWRAP
libwrapName= NullS;
#endif
#ifdef HAVE_OPENSSL
des_key_file = 0;
ssl_acceptor_fd= 0;
#endif
#ifdef HAVE_SMEM
shared_memory_base_name= default_shared_memory_base_name;
#endif
#if !defined(my_pthread_setprio) && !defined(HAVE_PTHREAD_SETSCHEDPARAM)
opt_specialflag |= SPECIAL_NO_PRIOR;
#endif
#if defined(__WIN__) || defined(__NETWARE__) #if defined(__WIN__) || defined(__NETWARE__)
/* Allow Win32 and NetWare users to move MySQL anywhere */ /* Allow Win32 and NetWare users to move MySQL anywhere */
{ {
@ -4646,10 +4745,6 @@ static void set_options(void)
tmpenv = DEFAULT_MYSQL_HOME; tmpenv = DEFAULT_MYSQL_HOME;
(void) strmake(mysql_home, tmpenv, sizeof(mysql_home)-1); (void) strmake(mysql_home, tmpenv, sizeof(mysql_home)-1);
#endif #endif
my_disable_locking=myisam_single_user= 1;
opt_external_locking=0;
my_bind_addr = htonl( INADDR_ANY );
} }

View File

@ -280,6 +280,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
if (!error && reckey_in_range(1, &ref, item_field->field, if (!error && reckey_in_range(1, &ref, item_field->field,
conds, range_fl, prefix_len)) conds, range_fl, prefix_len))
error= HA_ERR_KEY_NOT_FOUND; error= HA_ERR_KEY_NOT_FOUND;
}
if (table->key_read) if (table->key_read)
{ {
table->key_read=0; table->key_read=0;

View File

@ -232,8 +232,7 @@ sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol",
sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout", sys_var_long_ptr sys_slave_net_timeout("slave_net_timeout",
&slave_net_timeout); &slave_net_timeout);
#endif #endif
sys_var_bool_ptr sys_readonly("read_only", sys_var_bool_ptr sys_readonly("read_only", &opt_readonly);
&opt_readonly);
sys_var_long_ptr sys_slow_launch_time("slow_launch_time", sys_var_long_ptr sys_slow_launch_time("slow_launch_time",
&slow_launch_time); &slow_launch_time);
sys_var_thd_ulong sys_sort_buffer("sort_buffer_size", sys_var_thd_ulong sys_sort_buffer("sort_buffer_size",

View File

@ -2672,9 +2672,12 @@ bool check_grant_all_columns(THD *thd, ulong want_access, TABLE *table)
want_access &= ~table->grant.privilege; want_access &= ~table->grant.privilege;
if (!want_access) if (!want_access)
return 0; // Already checked return 0; // Already checked
if (!grant_option) if (!grant_option)
{
field= table->field[0]; // To give a meaningful error message
goto err2; goto err2;
}
rw_rdlock(&LOCK_grant); rw_rdlock(&LOCK_grant);
@ -3134,7 +3137,7 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
} }
global.append(" ON `",5); global.append(" ON `",5);
global.append(grant_table->db); global.append(grant_table->db);
global.append("`.`,3); global.append("`.`",3);
global.append(grant_table->tname); global.append(grant_table->tname);
global.append("` TO '",6); global.append("` TO '",6);
global.append(lex_user->user.str,lex_user->user.length); global.append(lex_user->user.str,lex_user->user.length);

View File

@ -434,7 +434,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
my_dirend(dirp); my_dirend(dirp);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
raid_dirs.push_back(dir=new String(newpath)); raid_dirs.push_back(dir=new String(newpath, &my_charset_latin1));
dir->copy(); dir->copy();
continue; continue;
} }

View File

@ -116,7 +116,8 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
TABLE_LIST *first_table= (TABLE_LIST*) select_cursor->table_list.first; TABLE_LIST *first_table= (TABLE_LIST*) select_cursor->table_list.first;
/* Setting up. A must if a join or IGNORE, USE or similar are utilised */ /* Setting up. A must if a join or IGNORE, USE or similar are utilised */
if (setup_tables(first_table) || 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))
{ {
res= -1; res= -1;
goto exit; goto exit;
@ -128,16 +129,18 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
(item_list.elements + select_cursor->with_sum_func + (item_list.elements + select_cursor->with_sum_func +
select_cursor->order_list.elements + select_cursor->order_list.elements +
select_cursor->group_list.elements)) || select_cursor->group_list.elements)) ||
setup_fields(thd, select_cursor->ref_pointer_array, first_table, item_list, setup_fields(thd, select_cursor->ref_pointer_array, first_table,
0, 0, 1)) item_list, 0, 0, 1))
{ {
res= -1; res= -1;
goto exit; goto exit;
} }
bzero((char*) &tmp_table_param,sizeof(tmp_table_param)); bzero((char*) &tmp_table_param,sizeof(tmp_table_param));
tmp_table_param.field_count= item_list.elements; tmp_table_param.field_count= item_list.elements;
/* temp table is created so that it hounours if UNION without ALL is to be /*
processed */ Temp table is created so that it hounours if UNION without ALL is to be
processed
*/
if (!(table= create_tmp_table(thd, &tmp_table_param, item_list, if (!(table= create_tmp_table(thd, &tmp_table_param, item_list,
(ORDER*) 0, (ORDER*) 0,
is_union && !unit->union_option, 1, is_union && !unit->union_option, 1,
@ -190,6 +193,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
org_table_list->table=table; org_table_list->table=table;
table->derived_select_number= select_cursor->select_number; table->derived_select_number= select_cursor->select_number;
table->tmp_table= TMP_TABLE; table->tmp_table= TMP_TABLE;
org_table_list->grant.privilege= SELECT_ACL;
if (lex->describe) if (lex->describe)
{ {
// to fix a problem in EXPLAIN // to fix a problem in EXPLAIN
@ -206,7 +210,7 @@ int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit,
/* Try to catch errors if this is accessed */ /* Try to catch errors if this is accessed */
org_table_list->derived=(SELECT_LEX_UNIT *) 1; org_table_list->derived=(SELECT_LEX_UNIT *) 1;
#endif #endif
// This line is required to force read of table stats in the optimizer // Force read of table stats in the optimizer
table->file->info(HA_STATUS_VARIABLE); table->file->info(HA_STATUS_VARIABLE);
} }
} }

View File

@ -483,7 +483,8 @@ int write_record(TABLE *table,COPY_INFO *info)
key_copy((byte*) key,table,key_nr,0); key_copy((byte*) key,table,key_nr,0);
if ((error=(table->file->index_read_idx(table->record[1],key_nr, if ((error=(table->file->index_read_idx(table->record[1],key_nr,
(byte*) key, (byte*) key,
table->key_info[key_nr].key_length, table->key_info[key_nr].
key_length,
HA_READ_KEY_EXACT)))) HA_READ_KEY_EXACT))))
goto err; goto err;
} }
@ -495,7 +496,7 @@ int write_record(TABLE *table,COPY_INFO *info)
*/ */
store_record(table,insert_values); store_record(table,insert_values);
restore_record(table,record[1]); restore_record(table,record[1]);
if (fill_record(*info->update_fields,*info->update_values)) if (fill_record(*info->update_fields, *info->update_values, 0))
goto err; goto err;
if ((error=table->file->update_row(table->record[1],table->record[0]))) if ((error=table->file->update_row(table->record[1],table->record[0])))
goto err; goto err;
@ -506,10 +507,11 @@ int write_record(TABLE *table,COPY_INFO *info)
{ {
if (last_uniq_key(table,key_nr)) if (last_uniq_key(table,key_nr))
{ {
if ((error=table->file->update_row(table->record[1],table->record[0]))) if ((error=table->file->update_row(table->record[1],
table->record[0])))
goto err; goto err;
info->deleted++; info->deleted++;
break; /* Update logfile and count */ break; /* Update logfile and count */
} }
else if ((error=table->file->delete_row(table->record[1]))) else if ((error=table->file->delete_row(table->record[1])))
goto err; goto err;

View File

@ -368,6 +368,7 @@ template <class T>
class I_List :private base_ilist { class I_List :private base_ilist {
public: public:
I_List() :base_ilist() {} I_List() :base_ilist() {}
inline void empty() { base_ilist::empty(); }
inline bool is_empty() { return base_ilist::is_empty(); } inline bool is_empty() { return base_ilist::is_empty(); }
inline void append(T* a) { base_ilist::append(a); } inline void append(T* a) { base_ilist::append(a); }
inline void push_back(T* a) { base_ilist::push_back(a); } inline void push_back(T* a) { base_ilist::push_back(a); }

View File

@ -213,7 +213,7 @@ static int check_user(THD *thd,enum_server_command command, const char *user,
thd->db=0; thd->db=0;
thd->db_length=0; thd->db_length=0;
USER_RESOURCES ur; USER_RESOURCES ur;
char tmp_passwd[SCRAMBL41_LENGTH]; char tmp_passwd[SCRAMBLE41_LENGTH];
DBUG_ENTER("check_user"); DBUG_ENTER("check_user");
/* /*
@ -231,7 +231,7 @@ static int check_user(THD *thd,enum_server_command command, const char *user,
} }
thd->master_access=acl_getroot(thd, thd->host, thd->ip, thd->user, thd->master_access=acl_getroot(thd, thd->host, thd->ip, thd->user,
passwd, thd->scramble, passwd, thd->scramble,
&thd->priv_user, &thd->priv_host, &thd->priv_user, thd->priv_host,
(protocol_version == 9 || (protocol_version == 9 ||
!(thd->client_capabilities & !(thd->client_capabilities &
CLIENT_LONG_PASSWORD)), CLIENT_LONG_PASSWORD)),
@ -1666,7 +1666,7 @@ mysql_execute_command(THD *thd)
!(thd->slave_thread || (thd->master_access & SUPER_ACL)) && !(thd->slave_thread || (thd->master_access & SUPER_ACL)) &&
(uc_update_queries[lex->sql_command] > 0)) (uc_update_queries[lex->sql_command] > 0))
{ {
send_error(&thd->net,ER_CANT_UPDATE_WITH_READLOCK); send_error(thd, ER_CANT_UPDATE_WITH_READLOCK);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }

View File

@ -626,7 +626,7 @@ JOIN::optimize()
Force MySQL to read the table in sorted order to get result in Force MySQL to read the table in sorted order to get result in
ORDER BY order. ORDER BY order.
*/ */
join.tmp_table_param.quick_group=0; tmp_table_param.quick_group=0;
} }
order=0; order=0;
} }
@ -4264,7 +4264,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
table->blob_ptr_size=mi_portable_sizeof_char_ptr; table->blob_ptr_size=mi_portable_sizeof_char_ptr;
table->map=1; table->map=1;
table->tmp_table= TMP_TABLE; table->tmp_table= TMP_TABLE;
table->derived_select_number= 0;
table->db_low_byte_first=1; // True for HEAP and MyISAM table->db_low_byte_first=1; // True for HEAP and MyISAM
table->temp_pool_slot = temp_pool_slot; table->temp_pool_slot = temp_pool_slot;
table->copy_blobs= 1; table->copy_blobs= 1;
@ -7983,6 +7982,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
TABLE *table=tab->table; TABLE *table=tab->table;
char buff[512],*buff_ptr=buff; char buff[512],*buff_ptr=buff;
char buff1[512], buff2[512]; char buff1[512], buff2[512];
char derived_name[64];
String tmp1(buff1,sizeof(buff1),cs); String tmp1(buff1,sizeof(buff1),cs);
String tmp2(buff2,sizeof(buff2),cs); String tmp2(buff2,sizeof(buff2),cs);
tmp1.length(0); tmp1.length(0);
@ -7996,13 +7996,13 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
cs)); cs));
if (tab->type == JT_ALL && tab->select && tab->select->quick) if (tab->type == JT_ALL && tab->select && tab->select->quick)
tab->type= JT_RANGE; tab->type= JT_RANGE;
if (table->tmp_table == TMP_TABLE && table->derived_select_number != 0) if (table->derived_select_number)
{ {
// Derived table name generation /* Derived table name generation */
char buff[512]; int len= my_snprintf(derived_name, sizeof(derived_name)-1,
int len= my_snprintf(buff, 512, "<derived%u>", "<derived%u>",
table->derived_select_number); table->derived_select_number);
item_list.push_back(new Item_string(buff, len, cs)); item_list.push_back(new Item_string(derived_name, len, cs));
} }
else else
item_list.push_back(new Item_string(table->table_name, item_list.push_back(new Item_string(table->table_name,
@ -8196,5 +8196,3 @@ void free_underlaid_joins(THD *thd, SELECT_LEX *select)
unit= unit->next_unit()) unit= unit->next_unit())
unit->cleanup(); unit->cleanup();
} }

View File

@ -1590,11 +1590,10 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
case SHOW_QUESTION: case SHOW_QUESTION:
end= int10_to_str((long) thd->query_id, buff, 10); end= int10_to_str((long) thd->query_id, buff, 10);
break; break;
#ifndef EMBEDDED_LIBRARY #ifdef HAVE_REPLICATION
case SHOW_RPL_STATUS: case SHOW_RPL_STATUS:
end= strmov(buff, rpl_status_type[(int)rpl_status]); end= strmov(buff, rpl_status_type[(int)rpl_status]);
break; break;
#ifdef HAVE_REPLICATION
case SHOW_SLAVE_RUNNING: case SHOW_SLAVE_RUNNING:
{ {
LOCK_ACTIVE_MI; LOCK_ACTIVE_MI;

View File

@ -34,9 +34,6 @@ CHARSET_INFO *national_charset_info= &my_charset_utf8;
extern gptr sql_alloc(unsigned size); extern gptr sql_alloc(unsigned size);
extern void sql_element_free(void *ptr); extern void sql_element_free(void *ptr);
static uint32
copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
const char *from, uint32 from_length, CHARSET_INFO *from_cs);
#include "sql_string.h" #include "sql_string.h"
@ -630,7 +627,7 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
*/ */
static uint32 uint32
copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs, copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
const char *from, uint32 from_length, CHARSET_INFO *from_cs) const char *from, uint32 from_length, CHARSET_INFO *from_cs)
{ {

View File

@ -27,6 +27,9 @@
class String; class String;
int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); int sortcmp(const String *a,const String *b, CHARSET_INFO *cs);
String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
uint32 copy_and_convert(char *to, uint32 to_length, CHARSET_INFO *to_cs,
const char *from, uint32 from_length,
CHARSET_INFO *from_cs);
class String class String
{ {

View File

@ -97,7 +97,7 @@ int mysql_update(THD *thd,
setup_ref_array(thd, &thd->lex.select_lex.ref_pointer_array, setup_ref_array(thd, &thd->lex.select_lex.ref_pointer_array,
order_num) || order_num) ||
setup_order(thd, thd->lex.select_lex.ref_pointer_array, setup_order(thd, thd->lex.select_lex.ref_pointer_array,
&tables, fields, all_fields, order) || &tables, all_fields, all_fields, order) ||
setup_ftfuncs(&thd->lex.select_lex)) setup_ftfuncs(&thd->lex.select_lex))
DBUG_RETURN(-1); /* purecov: inspected */ DBUG_RETURN(-1); /* purecov: inspected */
@ -207,7 +207,7 @@ int mysql_update(THD *thd,
MYF(MY_FAE | MY_ZEROFILL)); MYF(MY_FAE | MY_ZEROFILL));
if (!(sortorder=make_unireg_sortorder(order, &length)) || if (!(sortorder=make_unireg_sortorder(order, &length)) ||
(table->sort.found_records = filesort(thd, table, sortorder, length, (table->sort.found_records = filesort(thd, table, sortorder, length,
select, 0L, limit, select, limit,
&examined_rows)) &examined_rows))
== HA_POS_ERROR) == HA_POS_ERROR)
{ {
@ -755,7 +755,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
{ {
table->status|= STATUS_UPDATED; table->status|= STATUS_UPDATED;
store_record(table,record[1]); store_record(table,record[1]);
if (fill_record(*fields_for_table[offset], *values_for_table[offset]), 0) if (fill_record(*fields_for_table[offset], *values_for_table[offset], 0))
DBUG_RETURN(1); DBUG_RETURN(1);
found++; found++;
if (compare_record(table, thd->query_id)) if (compare_record(table, thd->query_id))
@ -793,7 +793,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
(error != HA_ERR_FOUND_DUPP_KEY && (error != HA_ERR_FOUND_DUPP_KEY &&
error != HA_ERR_FOUND_DUPP_UNIQUE)) error != HA_ERR_FOUND_DUPP_UNIQUE))
{ {
if (create_myisam_from_heap(thd, table, tmp_table_param + offset, if (create_myisam_from_heap(thd, tmp_table, tmp_table_param + offset,
error, 1)) error, 1))
{ {
do_update=0; do_update=0;

View File

@ -2180,8 +2180,10 @@ simple_expr:
simple_ident simple_ident
| simple_expr COLLATE_SYM ident_or_text %prec NEG | simple_expr COLLATE_SYM ident_or_text %prec NEG
{ {
$$= new Item_func_set_collation($1,new Item_string($3.str,$3.length, $$= new Item_func_set_collation($1,
YYTHD->charset())); new Item_string($3.str,
$3.length,
YYTHD->charset()));
} }
| literal | literal
| param_marker | param_marker
@ -2228,8 +2230,8 @@ simple_expr:
| ASCII_SYM '(' expr ')' { $$= new Item_func_ascii($3); } | ASCII_SYM '(' expr ')' { $$= new Item_func_ascii($3); }
| BINARY expr %prec NEG | BINARY expr %prec NEG
{ {
$$= new Item_func_set_collation($2,new Item_string("BINARY",6, $$= new Item_func_set_collation($2,new Item_string(binary_keyword,
&my_charset_latin1)); 6, &my_charset_latin1));
} }
| CAST_SYM '(' expr AS cast_type ')' { $$= create_func_cast($3, $5); } | CAST_SYM '(' expr AS cast_type ')' { $$= create_func_cast($3, $5); }
| CASE_SYM opt_expr WHEN_SYM when_list opt_else END | CASE_SYM opt_expr WHEN_SYM when_list opt_else END
@ -2580,9 +2582,9 @@ sum_expr:
| COUNT_SYM '(' in_sum_expr ')' | COUNT_SYM '(' in_sum_expr ')'
{ $$=new Item_sum_count($3); } { $$=new Item_sum_count($3); }
| COUNT_SYM '(' DISTINCT | COUNT_SYM '(' DISTINCT
{ Select->in_sum_expr++; } { Select->select_lex()->in_sum_expr++; }
expr_list expr_list
{ Select->in_sum_expr--; } { Select->select_lex()->in_sum_expr--; }
')' ')'
{ $$=new Item_sum_count_distinct(* $5); } { $$=new Item_sum_count_distinct(* $5); }
| GROUP_UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' in_sum_expr ')' | GROUP_UNIQUE_USERS '(' text_literal ',' NUM ',' NUM ',' in_sum_expr ')'

View File

@ -85,3 +85,33 @@ gptr sql_memdup(const void *ptr,uint len)
void sql_element_free(void *ptr __attribute__((unused))) void sql_element_free(void *ptr __attribute__((unused)))
{} /* purecov: deadcode */ {} /* purecov: deadcode */
char *sql_strmake_with_convert(const char *str, uint32 arg_length,
CHARSET_INFO *from_cs,
uint32 max_res_length,
CHARSET_INFO *to_cs, uint32 *result_length)
{
char *pos;
uint32 new_length= to_cs->mbmaxlen*arg_length;
max_res_length--; // Reserve place for end null
set_if_smaller(new_length, max_res_length);
if (!(pos= sql_alloc(new_length+1)))
return pos; // Error
if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
{
// Safety if to_cs->mbmaxlen > 0
new_length= min(arg_length, max_res_length);
memcpy(pos, str, new_length);
}
else
new_length= copy_and_convert((char*) pos, new_length, to_cs, str,
arg_length, from_cs);
pos[new_length]= 0;
*result_length= new_length;
return pos;
}

View File

@ -45,6 +45,7 @@
#define LIBLEN FN_REFLEN-FN_LEN /* Max l{ngd p} dev */ #define LIBLEN FN_REFLEN-FN_LEN /* Max l{ngd p} dev */
#define MAX_DBKEY_LENGTH (FN_LEN*2+6) /* extra 4 bytes for slave tmp #define MAX_DBKEY_LENGTH (FN_LEN*2+6) /* extra 4 bytes for slave tmp
* tables */ * tables */
#define MAX_ALIAS_NAME 256
#define MAX_FIELD_NAME 34 /* Max colum name length +2 */ #define MAX_FIELD_NAME 34 /* Max colum name length +2 */
#define MAX_SYS_VAR_LENGTH 32 #define MAX_SYS_VAR_LENGTH 32
#define MAX_KEY 32 /* Max used keys */ #define MAX_KEY 32 /* Max used keys */

View File

@ -8257,7 +8257,7 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e)
{ {
int c1,c2,c3; int c1,c2,c3;
if (s>e) if (s >= e)
return MY_CS_TOOFEW(0); return MY_CS_TOOFEW(0);
c1=s[0]; c1=s[0];