Commit 35459cb7 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-4.0

into mashka.mysql.fi:/home/my/mysql-4.0

parents 592c30bd 3ac05ea4
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
#ifndef _global_h #ifndef _global_h
#define _global_h #define _global_h
#ifndef EMBEDDED_LIBRARY
#define HAVE_REPLICATION
#define HAVE_EXTERNAL_CLIENT
#endif
#if defined( __EMX__) && !defined( MYSQL_SERVER) #if defined( __EMX__) && !defined( MYSQL_SERVER)
/* moved here to use below VOID macro redefinition */ /* moved here to use below VOID macro redefinition */
#define INCL_BASE #define INCL_BASE
......
...@@ -47,7 +47,7 @@ sum(all a) count(all a) avg(all a) std(all a) bit_or(all a) bit_and(all a) min(a ...@@ -47,7 +47,7 @@ sum(all a) count(all a) avg(all a) std(all a) bit_or(all a) bit_and(all a) min(a
21 6 3.5000 1.7078 7 0 1 6 E 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; 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) grp sum(a) count(a) avg(a) std(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c)
NULL 0 0 NULL NULL 0 0 NULL NULL NULL NULL 0 NULL NULL 0 0 NULL NULL
1 1 1 1.0000 0.0000 1 1 1 1 a a 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 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 3 15 3 5.0000 0.8165 7 4 4 6 C E
...@@ -204,3 +204,44 @@ select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1= ...@@ -204,3 +204,44 @@ select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1=
max(t2.a1) max(t2.a1)
NULL NULL
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;
...@@ -126,3 +126,24 @@ select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=20; ...@@ -126,3 +126,24 @@ select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=20;
select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=10; select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=10;
select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1='AAA'; select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1='AAA';
drop table t1,t2; drop table t1,t2;
#
# Test of group function and NULL values
#
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;
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;
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;
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;
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;
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;
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;
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;
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;
drop table t1;
...@@ -175,12 +175,14 @@ Item_sum_hybrid::fix_fields(THD *thd,TABLE_LIST *tables) ...@@ -175,12 +175,14 @@ Item_sum_hybrid::fix_fields(THD *thd,TABLE_LIST *tables)
void Item_sum_sum::reset() void Item_sum_sum::reset()
{ {
null_value=0; sum=0.0; Item_sum_sum::add(); null_value=1; sum=0.0; Item_sum_sum::add();
} }
bool Item_sum_sum::add() bool Item_sum_sum::add()
{ {
sum+=args[0]->val(); sum+=args[0]->val();
if (!args[0]->null_value)
null_value= 0;
return 0; return 0;
} }
...@@ -566,7 +568,9 @@ void Item_sum_sum::reset_field() ...@@ -566,7 +568,9 @@ void Item_sum_sum::reset_field()
{ {
double nr=args[0]->val(); // Nulls also return 0 double nr=args[0]->val(); // Nulls also return 0
float8store(result_field->ptr,nr); float8store(result_field->ptr,nr);
null_value=0; if (args[0]->null_value)
result_field->set_null();
else
result_field->set_notnull(); result_field->set_notnull();
} }
...@@ -623,7 +627,10 @@ void Item_sum_sum::update_field(int offset) ...@@ -623,7 +627,10 @@ void Item_sum_sum::update_field(int offset)
float8get(old_nr,res+offset); float8get(old_nr,res+offset);
nr=args[0]->val(); nr=args[0]->val();
if (!args[0]->null_value) if (!args[0]->null_value)
{
old_nr+=nr; old_nr+=nr;
result_field->set_notnull();
}
float8store(res,old_nr); float8store(res,old_nr);
} }
......
...@@ -92,9 +92,6 @@ public: ...@@ -92,9 +92,6 @@ public:
class Item_sum_int :public Item_sum_num class Item_sum_int :public Item_sum_num
{ {
void fix_length_and_dec()
{ decimals=0; max_length=21; maybe_null=null_value=0; }
public: public:
Item_sum_int(Item *item_par) :Item_sum_num(item_par) {} Item_sum_int(Item *item_par) :Item_sum_num(item_par) {}
Item_sum_int(List<Item> &list) :Item_sum_num(list) {} Item_sum_int(List<Item> &list) :Item_sum_num(list) {}
...@@ -102,6 +99,8 @@ public: ...@@ -102,6 +99,8 @@ public:
String *val_str(String*str); String *val_str(String*str);
enum Item_result result_type () const { return INT_RESULT; } enum Item_result result_type () const { return INT_RESULT; }
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
void fix_length_and_dec()
{ decimals=0; max_length=21; maybe_null=null_value=0; }
}; };
...@@ -118,6 +117,7 @@ class Item_sum_sum :public Item_sum_num ...@@ -118,6 +117,7 @@ class Item_sum_sum :public Item_sum_num
double val(); double val();
void reset_field(); void reset_field();
void update_field(int offset); void update_field(int offset);
void no_rows_in_result() {}
const char *func_name() const { return "sum"; } const char *func_name() const { return "sum"; }
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
}; };
...@@ -361,6 +361,8 @@ class Item_sum_bit :public Item_sum_int ...@@ -361,6 +361,8 @@ class Item_sum_bit :public Item_sum_int
longlong val_int(); longlong val_int();
void reset_field(); void reset_field();
unsigned int size_of() { return sizeof(*this);} unsigned int size_of() { return sizeof(*this);}
void fix_length_and_dec()
{ decimals=0; max_length=21; unsigned_flag=1; maybe_null=null_value=0; }
}; };
......
...@@ -3562,7 +3562,7 @@ relay logs", ...@@ -3562,7 +3562,7 @@ relay logs",
{"skip-stack-trace", OPT_SKIP_STACK_TRACE, {"skip-stack-trace", OPT_SKIP_STACK_TRACE,
"Don't print a stack trace on failure", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, "Don't print a stack trace on failure", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0,
0, 0, 0, 0}, 0, 0, 0, 0},
{"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables", {"skip-symlink", OPT_SKIP_SYMLINKS, "Don't allow symlinking of tables. Depricated option. Use --skip-symbolic-links instead",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"skip-thread-priority", OPT_SKIP_PRIOR, {"skip-thread-priority", OPT_SKIP_PRIOR,
"Don't give threads different priorities.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, "Don't give threads different priorities.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
...@@ -3606,11 +3606,12 @@ replicating a LOAD DATA INFILE command", ...@@ -3606,11 +3606,12 @@ replicating a LOAD DATA INFILE command",
{"external-locking", OPT_USE_LOCKING, "Use system (external) locking. With this option enabled you can run myisamchk to test (not repair) tables while the MySQL server is running", {"external-locking", OPT_USE_LOCKING, "Use system (external) locking. With this option enabled you can run myisamchk to test (not repair) tables while the MySQL server is running",
(gptr*) &opt_external_locking, (gptr*) &opt_external_locking, (gptr*) &opt_external_locking, (gptr*) &opt_external_locking,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
#ifdef USE_SYMDIR {"use-symbolic-links", 's', "Enable symbolic link support. Depricated option; Use --symbolic-links instead",
{"use-symbolic-links", 's', "Enable symbolic link support", (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
IF_PURIFY(0,1), 0, 0, 0, 0, 0},
{"--symbolic-links", 's', "Enable symbolic link support",
(gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG, (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG,
IF_PURIFY(0,1), 0, 0, 0, 0, 0}, IF_PURIFY(0,1), 0, 0, 0, 0, 0},
#endif
{"user", 'u', "Run mysqld daemon as user", 0, 0, 0, GET_STR, REQUIRED_ARG, {"user", 'u', "Run mysqld daemon as user", 0, 0, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0}, 0, 0, 0, 0, 0, 0},
{"version", 'V', "Output version information and exit", 0, 0, 0, GET_NO_ARG, {"version", 'V', "Output version information and exit", 0, 0, 0, GET_NO_ARG,
...@@ -4424,9 +4425,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -4424,9 +4425,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE; delay_key_write_options= (uint) DELAY_KEY_WRITE_NONE;
myisam_concurrent_insert=0; myisam_concurrent_insert=0;
myisam_recover_options= HA_RECOVER_NONE; myisam_recover_options= HA_RECOVER_NONE;
my_disable_symlinks=1;
my_use_symdir=0; my_use_symdir=0;
have_symlink=SHOW_OPTION_DISABLED;
ha_open_options&= ~(HA_OPEN_ABORT_IF_CRASHED | HA_OPEN_DELAY_KEY_WRITE); ha_open_options&= ~(HA_OPEN_ABORT_IF_CRASHED | HA_OPEN_DELAY_KEY_WRITE);
#ifdef HAVE_QUERY_CACHE #ifdef HAVE_QUERY_CACHE
query_cache_size=0; query_cache_size=0;
...@@ -4473,9 +4472,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), ...@@ -4473,9 +4472,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
test_flags|=TEST_NO_STACKTRACE; test_flags|=TEST_NO_STACKTRACE;
break; break;
case (int) OPT_SKIP_SYMLINKS: case (int) OPT_SKIP_SYMLINKS:
my_disable_symlinks=1;
my_use_symdir=0; my_use_symdir=0;
have_symlink=SHOW_OPTION_DISABLED;
break; break;
case (int) OPT_BIND_ADDRESS: case (int) OPT_BIND_ADDRESS:
if (argument && isdigit(argument[0])) if (argument && isdigit(argument[0]))
......
...@@ -47,13 +47,6 @@ ...@@ -47,13 +47,6 @@
can't normally do this the client should have a bigger max_allowed_packet. can't normally do this the client should have a bigger max_allowed_packet.
*/ */
#ifdef MYSQL_SERVER
#define USE_QUERY_CACHE
extern uint test_flags;
extern void query_cache_insert(NET *net, const char *packet, ulong length);
#else
#endif
#if defined(__WIN__) || !defined(MYSQL_SERVER) #if defined(__WIN__) || !defined(MYSQL_SERVER)
/* The following is because alarms doesn't work on windows. */ /* The following is because alarms doesn't work on windows. */
#define NO_ALARM #define NO_ALARM
...@@ -62,16 +55,23 @@ extern void query_cache_insert(NET *net, const char *packet, ulong length); ...@@ -62,16 +55,23 @@ extern void query_cache_insert(NET *net, const char *packet, ulong length);
#ifndef NO_ALARM #ifndef NO_ALARM
#include "my_pthread.h" #include "my_pthread.h"
void sql_print_error(const char *format,...); void sql_print_error(const char *format,...);
extern ulong bytes_sent, bytes_received;
extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
#else #else
#undef statistic_add
#define statistic_add(A,B,C)
#define DONT_USE_THR_ALARM #define DONT_USE_THR_ALARM
#endif /* NO_ALARM */ #endif /* NO_ALARM */
#include "thr_alarm.h" #include "thr_alarm.h"
#ifdef MYSQL_SERVER
#define USE_QUERY_CACHE
extern uint test_flags;
extern void query_cache_insert(NET *net, const char *packet, ulong length);
extern ulong bytes_sent, bytes_received;
extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
#else
#undef statistic_add
#define statistic_add(A,B,C)
#endif
#define TEST_BLOCKING 8 #define TEST_BLOCKING 8
#define MAX_PACKET_LENGTH (256L*256L*256L-1) #define MAX_PACKET_LENGTH (256L*256L*256L-1)
......
...@@ -564,6 +564,10 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, ...@@ -564,6 +564,10 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user,
user_access=acl_user->access; user_access=acl_user->access;
else else
{ {
if (global_system_variables.log_warnings)
sql_print_error("X509 ciphers mismatch: should be '%s' but is '%s'",
acl_user->ssl_cipher,
SSL_get_cipher(vio->ssl_));
user_access=NO_ACCESS; user_access=NO_ACCESS;
break; break;
} }
...@@ -581,6 +585,9 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, ...@@ -581,6 +585,9 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user,
acl_user->x509_issuer, ptr)); acl_user->x509_issuer, ptr));
if (strcmp(acl_user->x509_issuer, ptr)) if (strcmp(acl_user->x509_issuer, ptr))
{ {
if (global_system_variables.log_warnings)
sql_print_error("X509 issuer mismatch: should be '%s' but is '%s'",
acl_user->x509_issuer, ptr);
user_access=NO_ACCESS; user_access=NO_ACCESS;
free(ptr); free(ptr);
break; break;
...@@ -596,7 +603,12 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, ...@@ -596,7 +603,12 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user,
DBUG_PRINT("info",("comparing subjects: '%s' and '%s'", DBUG_PRINT("info",("comparing subjects: '%s' and '%s'",
acl_user->x509_subject, ptr)); acl_user->x509_subject, ptr));
if (strcmp(acl_user->x509_subject,ptr)) if (strcmp(acl_user->x509_subject,ptr))
{
if (global_system_variables.log_warnings)
sql_print_error("X509 subject mismatch: '%s' vs '%s'",
acl_user->x509_subject, ptr);
user_access=NO_ACCESS; user_access=NO_ACCESS;
}
else else
user_access=acl_user->access; user_access=acl_user->access;
free(ptr); free(ptr);
......
...@@ -1225,7 +1225,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, ...@@ -1225,7 +1225,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables,
case SHOW_RPL_STATUS: case SHOW_RPL_STATUS:
net_store_data(&packet2, rpl_status_type[(int)rpl_status]); net_store_data(&packet2, rpl_status_type[(int)rpl_status]);
break; break;
#ifndef EMBEDDED_LIBRARY #ifdef HAVE_REPLICATION
case SHOW_SLAVE_RUNNING: case SHOW_SLAVE_RUNNING:
{ {
LOCK_ACTIVE_MI; LOCK_ACTIVE_MI;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment