Commit c21867da authored by unknown's avatar unknown

Merge work:/home/bk/mysql-4.0 into hundin.mysql.fi:/my/bk/mysql-4.0

acinclude.m4:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
Docs/manual.texi:
  Auto merged
parents 1a57e278 cf350ce9
......@@ -8,6 +8,6 @@ c_warnings="$c_warnings $debug_extra_warnings"
cxx_warnings="$cxx_warnings $debug_extra_warnings"
extra_configs="$pentium_configs $debug_configs"
extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-vio --with-openssl --with-embedded-server"
extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-embedded-server"
. "$path/FINISH.sh"
This diff is collapsed.
......@@ -715,6 +715,8 @@ AC_MSG_CHECKING(for OpenSSL)
[openssl="$withval"],
[openssl=no])
openssl_libs=""
openssl_includes=""
if test "$openssl" = "yes"
then
if test -n "$vio_dir"
......@@ -722,14 +724,12 @@ AC_MSG_CHECKING(for OpenSSL)
AC_MSG_RESULT(yes)
openssl_libs="-L/usr/local/ssl/lib -lssl -lcrypto"
openssl_includes="-I/usr/local/ssl/include"
AC_DEFINE(HAVE_OPENSSL)
else
AC_MSG_ERROR([OpenSSL requires Virtual IO support (--with-vio)])
AC_MSG_RESULT(disabled because --with-vio wasn not used)
fi
AC_DEFINE(HAVE_OPENSSL)
else
AC_MSG_RESULT(no)
openssl_libs=""
openssl_includes=""
fi
NON_THREADED_CLIENT_LIBS="$NON_THREADED_CLIENT_LIBS $openssl_libs"
AC_SUBST(openssl_libs)
......@@ -748,16 +748,19 @@ dnl Call MYSQL_CHECK_ORBIT even if mysqlfs == no, so that @orbit_*@
dnl get substituted.
MYSQL_CHECK_ORBIT
AC_MSG_CHECKING(if we should build MySQLFS)
fs_dirs=""
if test "$mysqlfs" = "yes"
then
if test -n "$orbit_exec_prefix"
then
fs_dirs=fs
AC_MSG_RESULT([yes])
else
AC_MSG_ERROR([mysqlfs requires ORBit, the CORBA ORB])
AC_MSG_RESULT(disabled because ORBIT, the CORBA ORB, was not found)
fi
else
fs_dirs=
AC_MSG_RESULT([no])
fi
AC_SUBST([fs_dirs])
])
......
......@@ -1758,11 +1758,15 @@ AC_ARG_WITH(extra-tools,
[with_tools=yes]
)
tools_dirs=""
if test "$with_tools" = "yes"
then
tools_dirs="tools"
else
tools_dirs=""
if test "$THREAD_SAFE_CLIENT" = "no"
then
echo "Warning: extra-tools disabled because --enable-thread-safe-client wasn't used"
else
tools_dirs="tools"
fi
fi
AC_SUBST(tools_dirs)
......
......@@ -57,6 +57,8 @@ extern CHARSET_INFO *default_charset_info;
extern CHARSET_INFO *find_compiled_charset(uint cs_number);
extern CHARSET_INFO *find_compiled_charset_by_name(const char *name);
extern CHARSET_INFO compiled_charsets[];
extern uint compiled_charset_number(const char *name);
extern const char *compiled_charset_name(uint charset_number);
#define MY_CHARSET_UNDEFINED 0
#define MY_CHARSET_CURRENT (default_charset_info->number)
......
......@@ -104,6 +104,8 @@ enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY,
struct st_vio; /* Only C */
typedef struct st_vio Vio;
#define MAX_BLOB_WIDTH 8192 // Default width for blob
typedef struct st_net {
Vio* vio;
my_socket fd; /* For Perl DBI/dbd */
......
......@@ -54,7 +54,7 @@ int myrg_create(const char *name, const char **table_names,
if (insert_method != MERGE_INSERT_DISABLED)
{
end=strxmov(buff,"#INSERT_METHOD=",
get_type(&merge_insert_method,insert_method),"\n",NullS);
get_type(&merge_insert_method,insert_method-1),"\n",NullS);
if (my_write(file,buff,(uint) (end-buff),MYF(MY_WME | MY_NABP)))
goto err;
}
......
......@@ -26,5 +26,5 @@
LIST *myrg_open_list=0;
static const char *merge_insert_methods[] =
{ "FIRST", "LAST", NullS };
TYPELIB merge_insert_method= { array_elements(merge_insert_methods),"",
TYPELIB merge_insert_method= { array_elements(merge_insert_methods)-1,"",
merge_insert_methods};
......@@ -13,3 +13,19 @@ a
18446744073709551615
a
18446744073709551614
min(big) max(big) max(big)-1
-1 9223372036854775807 9223372036854775806
min(big) max(big) max(big)-1
-1 9223372036854775807 9223372036854775806
min(big) max(big) max(big)-1
12345678901234567 18446744073709551615 18446744073709551614
min(big) max(big) max(big)-1
12345678901234567 18446744073709551615 18446744073709551614
min(big) max(big) max(big)-1
12345678901234567 18446744073709551615 18446744073709551614
min(big) max(big) max(big)-1
12345678901234567 18446744073709551615 18446744073709551614
min(big) max(big) max(big)-1
-1 9223372036854775807 9223372036854775806
min(big) max(big) max(big)-1
-1 9223372036854775807 9223372036854775806
......@@ -81,6 +81,56 @@ a
412
412
411
a b
1 Testing
1 Testing
2 table
2 table
4 Testing
4 Testing
5 table
5 table
6 t2
6 t1
7 Testing
7 Testing
8 table
8 table
9 t2
9 t2
a b
1 Testing
1 Testing
2 table
2 table
4 Testing
4 Testing
5 table
5 table
9 t2
9 t2
a b
1 Testing
1 Testing
2 table
2 table
3 t2
3 t2
4 Testing
4 Testing
5 table
5 table
a b
1 Testing
1 Testing
2 table
2 table
3 t2
3 t2
4 Testing
4 Testing
5 table
5 table
Table Create Table
t3 CREATE TABLE `t3` (
`a` int(11) NOT NULL default '0',
......@@ -130,3 +180,155 @@ a
a b
1 1
1 2
Table Create Table
t3 CREATE TABLE `t3` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MyISAM
Table Create Table
t4 CREATE TABLE `t4` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM UNION=(t1,t2)
Table Create Table
t5 CREATE TABLE `t5` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM INSERT_METHOD=FIRST UNION=(t1,t2)
Table Create Table
t6 CREATE TABLE `t6` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1,t2)
a b
a b
1 1
2 1
1 2
a b
2 2
1 3
2 3
a b
1 4
2 4
a b
1 1
1 2
1 3
1 4
5 1
5 2
a b
2 1
2 2
2 3
2 4
6 1
6 2
a b
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
5 1
5 2
6 1
6 2
a b
3 1
3 2
3 3
3 4
Table Create Table
t4 CREATE TABLE `t4` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM UNION=(t1,t2,t3)
a b
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
3 2
3 3
3 4
5 1
5 2
6 1
6 2
Table Create Table
t4 CREATE TABLE `t4` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
) TYPE=MRG_MyISAM INSERT_METHOD=FIRST UNION=(t1,t2,t3)
a b
1 1
1 2
1 3
1 4
4 1
4 2
5 1
5 2
a b
2 1
2 2
2 3
2 4
6 1
6 2
a b
3 1
3 2
3 3
3 4
a b
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
3 1
3 2
3 3
3 4
4 1
4 2
5 1
5 2
6 1
6 2
a b
1 1
1 2
1 3
1 4
2 1
2 2
2 3
2 4
4 1
4 2
5 1
5 2
6 1
6 2
......@@ -131,7 +131,7 @@ auto auto
auto auto
16 16
Field Type Null Key Default Extra Privileges
auto bigint(17) PRI 0 select,insert,update,references
auto bigint(17) unsigned PRI 0 select,insert,update,references
t1 bigint(1) 0 select,insert,update,references
t2 char(1) select,insert,update,references
t3 mediumtext select,insert,update,references
......
......@@ -14,3 +14,18 @@ select * from t1 where a='18446744073709551615';
delete from t1 where a=18446744073709551615;
select * from t1;
drop table t1;
create table t1 ( a int not null default 1, big bigint );
insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(18446744073709551615);
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
alter table t1 modify big bigint unsigned not null;
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
alter table t1 add key (big);
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
alter table t1 modify big bigint not null;
select min(big),max(big),max(big)-1 from t1;
select min(big),max(big),max(big)-1 from t1 group by a;
drop table t1;
......@@ -2,7 +2,7 @@
# test of MERGE TABLES
#
drop table if exists t1,t2,t3;
drop table if exists t1,t2,t3,t4,t5,t6;
create table t1 (a int not null primary key auto_increment, message char(20));
create table t2 (a int not null primary key auto_increment, message char(20));
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
......@@ -31,6 +31,14 @@ select * from t3 where a > 10 and a < 20;
explain select a from t3 order by a desc limit 10;
select a from t3 order by a desc limit 10;
select a from t3 order by a desc limit 300,10;
delete from t3 where a=3;
select * from t3 where a < 10;
delete from t3 where a >= 6 and a <= 8;
select * from t3 where a < 10;
update t3 set a=3 where a=9;
select * from t3 where a < 10;
update t3 set a=6 where a=7;
select * from t3 where a < 10;
show create table t3;
# The following should give errors
......@@ -114,3 +122,49 @@ insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6);
flush tables;
select * from t3 where a=1 order by b limit 2;
drop table t3,t1,t2;
#
# [phi] testing INSERT_METHOD stuff
#
drop table if exists t6, t5, t4, t3, t2, t1;
# first testing of common stuff with new parameters
create table t1 (a int not null, b int not null, key(a,b));
create table t2 (a int not null, b int not null, key(a,b));
create table t3 (a int not null, b int not null, key(a,b)) UNION=(t1,t2) INSERT_METHOD=NO;
create table t4 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=NO;
create table t5 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST;
create table t6 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST;
show create table t3;
show create table t4;
show create table t5;
show create table t6;
insert into t1 values (1,1),(1,2),(1,3),(1,4);
insert into t2 values (2,1),(2,2),(2,3),(2,4);
select * from t3 order by b,a limit 3;
select * from t4 order by b,a limit 3;
select * from t5 order by b,a limit 3,3;
select * from t6 order by b,a limit 6,3;
# now testing inserts and where the data gets written
insert into t5 values (5,1),(5,2);
insert into t6 values (6,1),(6,2);
select * from t1 order by a,b;
select * from t2 order by a,b;
select * from t4 order by a,b;
# preperation for next test
insert into t3 values (3,1),(3,2),(3,3),(3,4);
select * from t3 order by a,b;
# now testing whether options are kept by alter table
alter table t4 UNION=(t1,t2,t3);
show create table t4;
select * from t4 order by a,b;
# testing switching off insert method and inserts again
alter table t4 INSERT_METHOD=FIRST;
show create table t4;
insert into t4 values (4,1),(4,2);
select * from t1 order by a,b;
select * from t2 order by a,b;
select * from t3 order by a,b;
select * from t4 order by a,b;
select * from t5 order by a,b;
drop table if exists t6, t5, t4, t3, t2, t1;
......@@ -44,13 +44,6 @@ struct simpleconfig_buf_st {
char *p;
};
/* Defined in strings/ctype.c */
CHARSET_INFO *find_compiled_charset(uint cs_number);
uint compiled_charset_number(const char *name);
const char *compiled_charset_name(uint charset_number);
static uint num_from_csname(CS_ID **cs, const char *name)
{
CS_ID **c;
......@@ -264,22 +257,22 @@ static my_bool read_charset_file(uint cs_number, CHARSET_INFO *set,
uint get_charset_number(const char *charset_name)
{
my_bool error;
error = init_available_charsets(MYF(0)); /* If it isn't initialized */
if (error)
return compiled_charset_number(charset_name);
else
return num_from_csname(available_charsets, charset_name);
uint number=compiled_charset_number(charset_name);
if (number)
return number;
if (init_available_charsets(MYF(0))) /* If it isn't initialized */
return 0;
return num_from_csname(available_charsets, charset_name);
}
const char *get_charset_name(uint charset_number)
{
my_bool error;
error = init_available_charsets(MYF(0)); /* If it isn't initialized */
if (error)
return compiled_charset_name(charset_number);
else
return name_from_csnum(available_charsets, charset_number);
char *name=compiled_charset_name(charset_number);
if (*name != '?')
return name;
if (init_available_charsets(MYF(0))) /* If it isn't initialized */
return "?";
return name_from_csnum(available_charsets, charset_number);
}
......@@ -293,8 +286,8 @@ static CHARSET_INFO *find_charset(CHARSET_INFO **table, uint cs_number,
return NULL;
}
static CHARSET_INFO *find_charset_by_name(CHARSET_INFO **table, const char *name,
size_t tablesz)
static CHARSET_INFO *find_charset_by_name(CHARSET_INFO **table,
const char *name, size_t tablesz)
{
uint i;
for (i = 0; i < tablesz; ++i)
......
......@@ -84,7 +84,8 @@ int find_type(my_string x, TYPELIB *typelib, uint full_name)
/* Get name of type nr 'nr' */
/* Warning first type is 1, 0 = empty field */
void make_type(register my_string to, register uint nr, register TYPELIB *typelib)
void make_type(register my_string to, register uint nr,
register TYPELIB *typelib)
{
DBUG_ENTER("make_type");
if (!nr)
......
......@@ -415,10 +415,11 @@ public:
unireg_check_arg, field_name_arg, table_arg,
0, zero_arg,unsigned_arg)
{}
Field_longlong(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg)
Field_longlong(uint32 len_arg,bool maybe_null_arg,
const char *field_name_arg,
struct st_table *table_arg, bool unsigned_arg)
:Field_num((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg,0,0,0)
NONE, field_name_arg, table_arg,0,0,unsigned_arg)
{}
enum Item_result result_type () const { return INT_RESULT; }
enum_field_types type() const { return FIELD_TYPE_LONGLONG;}
......
......@@ -474,7 +474,7 @@ int main(int argc,char **argv)
MY_INIT(argv[0]);
start_value=1060872L; best_t1=7930739L; best_t2=4311642L; best_type=3; /* mode=5333 add=6 type: 0 */
start_value=1109118L; best_t1=6657025L; best_t2=6114496L; best_type=1; /* mode=4903 add=3 type: 0 */
if (get_options(argc,(char **) argv))
exit(1);
......
......@@ -90,7 +90,7 @@ const char *berkeley_lock_names[] =
{ "DEFAULT", "OLDEST","RANDOM","YOUNGEST",0 };
u_int32_t berkeley_lock_types[]=
{ DB_LOCK_DEFAULT, DB_LOCK_OLDEST, DB_LOCK_RANDOM };
TYPELIB berkeley_lock_typelib= {array_elements(berkeley_lock_names),"",
TYPELIB berkeley_lock_typelib= {array_elements(berkeley_lock_names)-1,"",
berkeley_lock_names};
static void berkeley_print_error(const char *db_errpfx, char *buffer);
......
......@@ -68,7 +68,7 @@ ulong gemini_recovery_options = GEMINI_RECOVERY_FULL;
/* bits in gemini_recovery_options */
const char *gemini_recovery_names[] =
{ "FULL", "NONE", "FORCE" };
TYPELIB gemini_recovery_typelib= {array_elements(gemini_recovery_names),"",
TYPELIB gemini_recovery_typelib= {array_elements(gemini_recovery_names)-1,"",
gemini_recovery_names};
const int start_of_name = 2; /* Name passed as ./<db>/<table-name>
......
......@@ -36,7 +36,7 @@ ulong myisam_recover_options= HA_RECOVER_NONE;
/* bits in myisam_recover_options */
const char *myisam_recover_names[] =
{ "DEFAULT", "BACKUP", "FORCE", "QUICK", NullS};
TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names),"",
TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names)-1,"",
myisam_recover_names};
......
......@@ -187,6 +187,11 @@ void ha_myisammrg::info(uint flag)
int ha_myisammrg::extra(enum ha_extra_function operation)
{
/* As this is just a mapping, we don't have to force the underlying
tables to be closed */
if (operation == HA_EXTRA_FORCE_REOPEN ||
operation == HA_EXTRA_PREPARE_FOR_DELETE)
return 0;
return myrg_extra(file,operation);
}
......@@ -285,8 +290,7 @@ void ha_myisammrg::append_create_info(String *packet)
if (file->merge_insert_method != MERGE_INSERT_DISABLED)
{
packet->append(" INSERT_METHOD=",15);
const char *tmp = get_type(&merge_insert_method,file->merge_insert_method);
packet->append(tmp);
packet->append(get_type(&merge_insert_method,file->merge_insert_method-1));
}
packet->append(" UNION=(",8);
MYRG_TABLE *table,*first;
......
......@@ -37,7 +37,7 @@ void item_init(void)
Item::Item()
{
marker=0;
binary=maybe_null=null_value=with_sum_func=0;
binary=maybe_null=null_value=with_sum_func=unsigned_flag=0;
name=0;
decimals=0; max_length=0;
next=current_thd->free_list; // Put in free list
......@@ -116,6 +116,7 @@ void Item_field::set_field(Field *field_par)
table_name=field_par->table_name;
field_name=field_par->field_name;
binary=field_par->binary();
unsigned_flag=test(field_par->flags & UNSIGNED_FLAG);
}
const char *Item_ident::full_name() const
......@@ -326,6 +327,8 @@ void Item::init_make_field(Send_field *tmp_field,
tmp_field->type=field_type;
tmp_field->length=max_length;
tmp_field->decimals=decimals;
if (unsigned_flag)
tmp_field->flags |= UNSIGNED_FLAG;
}
/* ARGSUSED */
......@@ -345,6 +348,7 @@ void Item_uint::make_field(Send_field *tmp_field)
{
init_make_field(tmp_field,FIELD_TYPE_LONGLONG);
tmp_field->flags|= UNSIGNED_FLAG;
unsigned_flag=1;
}
void Item_real::make_field(Send_field *tmp_field)
......
......@@ -43,6 +43,7 @@ public:
my_bool maybe_null; /* If item may be null */
my_bool null_value; /* if item is null */
my_bool binary;
my_bool unsigned_flag;
my_bool with_sum_func;
......
......@@ -184,8 +184,10 @@ String *Item_num_func::val_str(String *str)
longlong nr=val_int();
if (null_value)
return 0; /* purecov: inspected */
else
else if (!unsigned_flag)
str->set(nr);
else
str->set((ulonglong) nr);
}
else
{
......@@ -213,18 +215,26 @@ String *Item_int_func::val_str(String *str)
longlong nr=val_int();
if (null_value)
return 0;
else
else if (!unsigned_flag)
str->set(nr);
else
str->set((ulonglong) nr);
return str;
}
/* Change from REAL_RESULT (default) to INT_RESULT if both arguments are integers */
/*
Change from REAL_RESULT (default) to INT_RESULT if both arguments are
integers
*/
void Item_num_op::find_num_type(void)
{
if (args[0]->result_type() == INT_RESULT &&
args[1]->result_type() == INT_RESULT)
{
hybrid_type=INT_RESULT;
unsigned_flag=args[0]->unsigned_flag | args[1]->unsigned_flag;
}
}
String *Item_num_op::val_str(String *str)
......@@ -234,8 +244,10 @@ String *Item_num_op::val_str(String *str)
longlong nr=val_int();
if (null_value)
return 0; /* purecov: inspected */
else
else if (!unsigned_flag)
str->set(nr);
else
str->set((ulonglong) nr);
}
else
{
......@@ -667,8 +679,10 @@ String *Item_func_min_max::val_str(String *str)
longlong nr=val_int();
if (null_value)
return 0;
else
else if (!unsigned_flag)
str->set(nr);
else
str->set((ulonglong) nr);
return str;
}
case REAL_RESULT:
......@@ -1306,8 +1320,10 @@ String *Item_func_udf_int::val_str(String *str)
longlong nr=val_int();
if (null_value)
return 0;
else
else if (!unsigned_flag)
str->set(nr);
else
str->set((ulonglong) nr);
return str;
}
......
......@@ -17,7 +17,7 @@
/* This file defines all string functions
** Warning: Some string functions doesn't always put and end-null on a String
** (This shouldn't be neaded)
** (This shouldn't be needed)
*/
#ifdef __GNUC__
......@@ -384,7 +384,7 @@ void Item_func_reverse::fix_length_and_dec()
/*
** Replace all occurences of string2 in string1 with string3.
** Don't reallocate val_str() if not neaded
** Don't reallocate val_str() if not needed
*/
/* TODO: Fix that this works with binary strings when using USE_MB */
......
......@@ -52,6 +52,8 @@ void Item_sum::make_field(Send_field *tmp_field)
tmp_field->flags=0;
if (!maybe_null)
tmp_field->flags|= NOT_NULL_FLAG;
if (unsigned_flag)
tmp_field->flags |= UNSIGNED_FLAG;
tmp_field->length=max_length;
tmp_field->decimals=decimals;
tmp_field->type=(result_type() == INT_RESULT ? FIELD_TYPE_LONG :
......@@ -150,7 +152,7 @@ Item_sum_hybrid::fix_fields(THD *thd,TABLE_LIST *tables)
return 1;
hybrid_type=item->result_type();
if (hybrid_type == INT_RESULT)
max_length=21;
max_length=20;
else if (hybrid_type == REAL_RESULT)
max_length=float_length(decimals);
else
......@@ -158,6 +160,7 @@ Item_sum_hybrid::fix_fields(THD *thd,TABLE_LIST *tables)
decimals=item->decimals;
maybe_null=item->maybe_null;
binary=item->binary;
unsigned_flag=item->unsigned_flag;
result_field=0;
null_value=1;
fix_length_and_dec();
......@@ -323,12 +326,27 @@ double Item_sum_hybrid::val()
{
if (null_value)
return 0.0;
if (hybrid_type == STRING_RESULT)
{
switch (hybrid_type) {
case STRING_RESULT:
String *res; res=val_str(&str_value);
return res ? atof(res->c_ptr()) : 0.0;
case INT_RESULT:
if (unsigned_flag)
return ulonglong2double(sum_int);
return (double) sum_int;
case REAL_RESULT:
return sum;
}
return sum;
return 0; // Keep compiler happy
}
longlong Item_sum_hybrid::val_int()
{
if (null_value)
return 0;
if (hybrid_type == INT_RESULT)
return sum_int;
return (longlong) Item_sum_hybrid::val();
}
......@@ -337,25 +355,26 @@ Item_sum_hybrid::val_str(String *str)
{
if (null_value)
return 0;
if (hybrid_type == STRING_RESULT)
switch (hybrid_type) {
case STRING_RESULT:
return &value;
str->set(sum,decimals);
return str;
case REAL_RESULT:
str->set(sum,decimals);
break;
case INT_RESULT:
if (unsigned_flag)
str->set((ulonglong) sum_int);
else
str->set((longlong) sum_int);
break;
}
return str; // Keep compiler happy
}
bool Item_sum_min::add()
{
if (hybrid_type != STRING_RESULT)
{
double nr=args[0]->val();
if (!args[0]->null_value && (null_value || nr < sum))
{
sum=nr;
null_value=0;
}
}
else
switch (hybrid_type) {
case STRING_RESULT:
{
String *result=args[0]->val_str(&tmp_value);
if (!args[0]->null_value &&
......@@ -366,22 +385,39 @@ bool Item_sum_min::add()
null_value=0;
}
}
return 0;
}
bool Item_sum_max::add()
{
if (hybrid_type != STRING_RESULT)
break;
case INT_RESULT:
{
longlong nr=args[0]->val_int();
if (!args[0]->null_value && (null_value ||
(unsigned_flag &&
(ulonglong) nr < (ulonglong) sum_int) ||
(!unsigned_flag && nr < sum_int)))
{
sum_int=nr;
null_value=0;
}
}
break;
case REAL_RESULT:
{
double nr=args[0]->val();
if (!args[0]->null_value && (null_value || nr > sum))
if (!args[0]->null_value && (null_value || nr < sum))
{
sum=nr;
null_value=0;
}
}
else
break;
}
return 0;
}
bool Item_sum_max::add()
{
switch (hybrid_type) {
case STRING_RESULT:
{
String *result=args[0]->val_str(&tmp_value);
if (!args[0]->null_value &&
......@@ -392,6 +428,31 @@ bool Item_sum_max::add()
null_value=0;
}
}
break;
case INT_RESULT:
{
longlong nr=args[0]->val_int();
if (!args[0]->null_value && (null_value ||
(unsigned_flag &&
(ulonglong) nr > (ulonglong) sum_int) ||
(!unsigned_flag && nr > sum_int)))
{
sum_int=nr;
null_value=0;
}
}
break;
case REAL_RESULT:
{
double nr=args[0]->val();
if (!args[0]->null_value && (null_value || nr > sum))
{
sum=nr;
null_value=0;
}
}
break;
}
return 0;
}
......@@ -676,9 +737,17 @@ Item_sum_hybrid::min_max_update_int_field(int offset)
nr=args[0]->val_int();
if (!args[0]->null_value)
{
if (result_field->is_null(offset) ||
(cmp_sign > 0 ? old_nr > nr : old_nr < nr))
if (result_field->is_null(offset))
old_nr=nr;
else
{
bool res=(unsigned_flag ?
(ulonglong) old_nr > (ulonglong) nr :
old_nr > nr);
/* (cmp_sign > 0 && res) || (!(cmp_sign > 0) && !res) */
if (cmp_sign > 0 ^ !res)
old_nr=nr;
}
result_field->set_notnull();
}
else if (result_field->is_null(offset))
......@@ -1079,7 +1148,7 @@ void Item_udf_sum::reset()
bool Item_udf_sum::add()
{
DBUG_ENTER("Item_udf_sum::reset");
DBUG_ENTER("Item_udf_sum::add");
udf.add(&null_value);
DBUG_RETURN(0);
}
......
......@@ -271,6 +271,7 @@ class Item_sum_hybrid :public Item_sum
protected:
String value,tmp_value;
double sum;
longlong sum_int;
Item_result hybrid_type;
int cmp_sign;
table_map used_table_cache;
......@@ -286,12 +287,13 @@ class Item_sum_hybrid :public Item_sum
void reset()
{
sum=0.0;
sum_int=0;
value.length(0);
null_value=1;
add();
}
double val();
longlong val_int() { return (longlong) val(); } /* Real as default */
longlong val_int();
void reset_field();
String *val_str(String *);
void make_const() { used_table_cache=0; }
......
......@@ -81,7 +81,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize,
if ((my_off_t) cachesize > end_of_file-seek_offset+IO_SIZE*2-1)
{
cachesize=(uint) (end_of_file-seek_offset)+IO_SIZE*2-1;
use_async_io=0; /* No nead to use async */
use_async_io=0; /* No need to use async */
}
}
}
......
......@@ -71,7 +71,6 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#define HASH_PASSWORD_LENGTH 16
#define HOST_CACHE_SIZE 128
#define MAX_ACCEPT_RETRY 10 // Test accept this many times
#define MAX_BLOB_WIDTH 8192 // Default width for blob
#define MAX_FIELDS_BEFORE_HASH 32
#define USER_VARS_HASH_SIZE 16
#define STACK_MIN_SIZE 8192 // Abort if less stack during eval.
......
......@@ -342,7 +342,7 @@ ulong opt_sql_mode = 0L;
const char *sql_mode_names[] =
{ "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
"SERIALIZE","ONLY_FULL_GROUP_BY", NullS };
TYPELIB sql_mode_typelib= {array_elements(sql_mode_names),"",
TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"",
sql_mode_names};
MY_BITMAP temp_pool;
......@@ -1738,7 +1738,7 @@ int main(int argc, char **argv)
pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM);
#if defined( SET_RLIMIT_NOFILE) || defined( OS2)
/* connections and databases neads lots of files */
/* connections and databases needs lots of files */
{
uint wanted_files=10+(uint) max(max_connections*5,
max_connections+table_cache_size*2);
......@@ -1906,7 +1906,7 @@ The server will not act as a slave.");
(void) pthread_kill(signal_thread,MYSQL_KILL_SIGNAL);
#ifndef __WIN__
if (!opt_bootstrap)
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not neaded anymore
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
#endif
exit(1);
}
......
......@@ -607,7 +607,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables,
if (limit < records)
read_time=(double) records+scan_time+1; // Force to use index
else if (read_time <= 2.0 && !force_quick_range)
DBUG_RETURN(0); /* No nead for quick select */
DBUG_RETURN(0); /* No need for quick select */
DBUG_PRINT("info",("Time to scan table: %ld",(long) read_time));
......
......@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Basic functions neaded by many modules */
/* Basic functions needed by many modules */
#include "mysql_priv.h"
#include "sql_acl.h"
......@@ -165,14 +165,15 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild)
open_list=0; // Out of memory
break;
}
(*start_list)->table=(strmov((*start_list)->db=(char*) ((*start_list)+1),
entry->table_cache_key)+1,
entry->real_name);
strmov((*start_list)->table=
strmov(((*start_list)->db= (char*) ((*start_list)+1)),
entry->table_cache_key)+1,
entry->real_name);
(*start_list)->in_use= entry->in_use ? 1 : 0;
(*start_list)->locked= entry->locked_by_name ? 1 : 0;
start_list= &(*start_list)->next;
*start_list=0;
}
*start_list=0;
VOID(pthread_mutex_unlock(&LOCK_open));
DBUG_RETURN(open_list);
}
......
......@@ -391,7 +391,7 @@ int write_record(TABLE *table,COPY_INFO *info)
}
else
{
if (table->file->extra(HA_EXTRA_FLUSH_CACHE)) /* Not neaded with NISAM */
if (table->file->extra(HA_EXTRA_FLUSH_CACHE)) /* Not needed with NISAM */
{
error=my_errno;
goto err;
......@@ -534,7 +534,7 @@ public:
}
~delayed_insert()
{
/* The following is not really neaded, but just for safety */
/* The following is not really needed, but just for safety */
delayed_row *row;
while ((row=rows.get()))
delete row;
......
......@@ -22,7 +22,7 @@ class Table_ident;
class sql_exchange;
class LEX_COLUMN;
// The following hack is neaded because mysql_yacc.cc does not define
// The following hack is needed because mysql_yacc.cc does not define
// YYSTYPE before including this file
#ifdef MYSQL_YACC
......
......@@ -855,7 +855,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
DBUG_PRINT("info",("query ready"));
break;
}
case COM_FIELD_LIST: // This isn't actually neaded
case COM_FIELD_LIST: // This isn't actually needed
#ifdef DONT_ALLOW_SHOW_COMMANDS
send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); /* purecov: inspected */
break;
......@@ -2390,7 +2390,7 @@ bool my_yyoverflow(short **yyss, YYSTYPE **yyvs, int *yystacksize)
/****************************************************************************
Initialize global thd variables neaded for query
Initialize global thd variables needed for query
****************************************************************************/
static void
......
......@@ -3310,7 +3310,7 @@ Field *create_tmp_field(TABLE *table,Item *item, Item::Type type,
item->name,table,item_sum->decimals);
case INT_RESULT:
return new Field_longlong(item_sum->max_length,maybe_null,
item->name,table);
item->name,table,item->unsigned_flag);
case STRING_RESULT:
if (item_sum->max_length > 255)
return new Field_blob(item_sum->max_length,maybe_null,
......@@ -3361,7 +3361,7 @@ Field *create_tmp_field(TABLE *table,Item *item, Item::Type type,
break;
case INT_RESULT:
new_field=new Field_longlong(item->max_length,maybe_null,
item->name,table);
item->name,table, item->unsigned_flag);
break;
case STRING_RESULT:
if (item->max_length > 255)
......
......@@ -170,7 +170,7 @@ typedef struct st_lex_user {
/* Bits in form->status */
#define STATUS_NO_RECORD (1+2) /* Record isn't usably */
#define STATUS_GARBAGE 1
#define STATUS_NOT_FOUND 2 /* No record in database when neaded */
#define STATUS_NOT_FOUND 2 /* No record in database when needed */
#define STATUS_NO_PARENT 4 /* Parent record wasn't found */
#define STATUS_NOT_READ 8 /* Record isn't read */
#define STATUS_UPDATED 16 /* Record is updated by formula */
......
......@@ -24,7 +24,7 @@ static ulong const days_at_timestart=719528; /* daynr at 1970.01.01 */
uchar *days_in_month= (uchar*) "\037\034\037\036\037\036\037\037\036\037\036\037";
/* Init some variabels neaded when using my_local_time */
/* Init some variabels needed when using my_local_time */
/* Currently only my_time_zone is inited */
static long my_time_zone=0;
......
......@@ -20,7 +20,7 @@
struct.
In the following functions FIELD * is an ordinary field-structure with
the following exeptions:
sc_length,typepos,row,kol,dtype,regnr and field nead not to be set.
sc_length,typepos,row,kol,dtype,regnr and field need not to be set.
str is a (long) to record position where 0 is the first position.
*/
......@@ -391,8 +391,8 @@ static bool pack_header(uchar *forminfo, enum db_type table_type,
int2store(forminfo+272,int_parts);
int2store(forminfo+274,int_length);
int2store(forminfo+276,time_stamp_pos);
int2store(forminfo+278,80); /* Columns neaded */
int2store(forminfo+280,22); /* Rows neaded */
int2store(forminfo+278,80); /* Columns needed */
int2store(forminfo+280,22); /* Rows needed */
int2store(forminfo+282,null_fields);
DBUG_RETURN(0);
} /* pack_header */
......
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