Commit 7b13e020 authored by unknown's avatar unknown

Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1

into sanja.is.com.ua:/home/bell/mysql/bk/work-fix_fields-4.1

parents 49c578c9 afedd9f8
......@@ -59,6 +59,7 @@ jani@rhols221.arenanet.fi
jani@ua126d19.elisa.omakaista.fi
jani@ua141d10.elisa.omakaista.fi
jani@ua167d18.elisa.omakaista.fi
jani@ua72d24.elisa.omakaista.fi
jcole@abel.spaceapes.com
jcole@main.burghcom.com
jcole@mugatu.spaceapes.com
......
......@@ -43,6 +43,7 @@
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
#include <assert.h>
#include "client_priv.h"
#include "mysql.h"
......@@ -63,7 +64,6 @@
#define SHOW_NULL 2
#define SHOW_DEFAULT 4
#define SHOW_EXTRA 5
#define QUOTE_CHAR '`'
/* Size of buffer for dump's select query */
#define QUERY_LENGTH 1536
......@@ -89,6 +89,7 @@ static char insert_pat[12 * 1024],*opt_password=0,*current_user=0,
*where=0,
*opt_compatible_mode_str= 0,
*err_ptr= 0;
static char compatible_mode_normal_str[255];
static char *default_charset= (char*) MYSQL_UNIVERSAL_CLIENT_CHARSET;
static ulong opt_compatible_mode= 0;
static uint opt_mysql_port= 0, err_len= 0;
......@@ -111,6 +112,15 @@ const char *compatible_mode_names[]=
"ANSI",
NullS
};
#define MASK_ANSI_QUOTES \
(\
(1<<2) | /* POSTGRESQL */\
(1<<3) | /* ORACLE */\
(1<<4) | /* MSSQL */\
(1<<5) | /* DB2 */\
(1<<6) | /* MAXDB */\
(1<<10) /* ANSI */\
)
TYPELIB compatible_mode_typelib= {array_elements(compatible_mode_names) - 1,
"", compatible_mode_names};
......@@ -377,10 +387,10 @@ static void write_header(FILE *sql_file, char *db_name)
");
}
fprintf(sql_file,
"/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=\"%s\" */;\n",
path?"":"NO_AUTO_VALUE_ON_ZERO");
"/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=\"%s%s%s\" */;\n",
path?"":"NO_AUTO_VALUE_ON_ZERO",compatible_mode_normal_str[0]==0?"":",",
compatible_mode_normal_str);
}
return;
} /* write_header */
......@@ -480,6 +490,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
case (int) OPT_COMPATIBLE:
{
char buff[255];
char *end= compatible_mode_normal_str;
int i;
ulong mode;
opt_quoted= 1;
opt_set_names= 1;
......@@ -493,6 +506,27 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
fprintf(stderr, "Invalid mode to --compatible: %s\n", buff);
exit(1);
}
#if !defined(DBUG_OFF)
{
int size_for_sql_mode= 0;
const char **ptr;
for (ptr= compatible_mode_names; *ptr; ptr++)
size_for_sql_mode+= strlen(*ptr);
size_for_sql_mode+= sizeof(compatible_mode_names)-1;
DBUG_ASSERT(sizeof(compatible_mode_normal_str)>=size_for_sql_mode);
}
#endif
mode= opt_compatible_mode;
for (i= 0, mode= opt_compatible_mode; mode; mode>>= 1, i++)
{
if (mode & 1)
{
end= strmov(end, compatible_mode_names[i]);
end= strmov(end, ",");
}
}
if (end!=compatible_mode_normal_str)
end[-1]= 0;
break;
}
case (int) OPT_MYSQL_PROTOCOL:
......@@ -594,6 +628,7 @@ static void safe_exit(int error)
*/
static int dbConnect(char *host, char *user,char *passwd)
{
char buff[20+FN_REFLEN];
DBUG_ENTER("dbConnect");
if (verbose)
{
......@@ -622,6 +657,16 @@ static int dbConnect(char *host, char *user,char *passwd)
DBerror(&mysql_connection, "when trying to connect");
return 1;
}
sprintf(buff, "/*!40100 SET @@SQL_MODE=\"%s\" */",
compatible_mode_normal_str);
if (mysql_query(sock, buff))
{
fprintf(stderr, "%s: Can't set the compatible mode %s (error %s)\n",
my_progname, compatible_mode_normal_str, mysql_error(sock));
mysql_close(sock);
safe_exit(EX_MYSQLERR);
return 1;
}
return 0;
} /* dbConnect */
......@@ -670,17 +715,19 @@ static my_bool test_if_special_chars(const char *str)
static char *quote_name(const char *name, char *buff, my_bool force)
{
char *to= buff;
char qtype= (opt_compatible_mode & MASK_ANSI_QUOTES) ? '\"' : '`';
if (!force && !opt_quoted && !test_if_special_chars(name))
return (char*) name;
*to++= QUOTE_CHAR;
*to++= qtype;
while (*name)
{
if (*name == QUOTE_CHAR)
*to++= QUOTE_CHAR;
if (*name == qtype)
*to++= qtype;
*to++= *name++;
}
to[0]=QUOTE_CHAR;
to[1]=0;
to[0]= qtype;
to[1]= 0;
return buff;
} /* quote_name */
......@@ -853,31 +900,6 @@ static uint getTableStructure(char *table, char* db)
/* Make an sql-file, if path was given iow. option -T was given */
char buff[20+FN_REFLEN];
if (opt_compatible_mode)
{
char *end;
uint i;
sprintf(buff, "/*!40100 SET @@sql_mode=\"");
end= strend(buff);
for (i= 0; opt_compatible_mode; opt_compatible_mode>>= 1, i++)
{
if (opt_compatible_mode & 1)
{
end= strmov(end, compatible_mode_names[i]);
end= strmov(end, ",");
}
}
end= strmov(end-1, "\" */");
if (mysql_query(sock, buff))
{
fprintf(stderr, "%s: Can't set the compatible mode '%s' (%s)\n",
my_progname, table, mysql_error(sock));
safe_exit(EX_MYSQLERR);
DBUG_RETURN(0);
}
}
sprintf(buff,"show create table %s", result_table);
if (mysql_query(sock, buff))
{
......@@ -1858,6 +1880,7 @@ int main(int argc, char **argv)
{
MYSQL_ROW row;
MYSQL_RES *master;
compatible_mode_normal_str[0]= 0;
MY_INIT(argv[0]);
if (get_options(&argc, &argv))
......
......@@ -218,6 +218,9 @@ extern int is_prefix(const char *, const char *);
/* Conversion routines */
double my_strtod(const char *str, char **end);
double my_atof(const char *nptr);
#ifndef EOVERFLOW
#define EOVERFLOW 84
#endif
#ifdef USE_MY_ITOA
extern char *my_itoa(int val,char *dst,int radix);
......
......@@ -575,7 +575,7 @@ typedef struct st_mysql_methods
MYSQL_DATA *(*read_binary_rows)(MYSQL_STMT *stmt);
int (*unbuffered_fetch)(MYSQL *mysql, char **row);
void (*free_embedded_thd)(MYSQL *mysql);
const char *(*read_statistic)(MYSQL *mysql);
const char *(*read_statistics)(MYSQL *mysql);
int (*next_result)(MYSQL *mysql);
int (*read_change_user_result)(MYSQL *mysql, char *buff, const char *passwd);
#endif
......
......@@ -307,4 +307,6 @@
#define ER_NON_UPDATABLE_TABLE 1288
#define ER_FEATURE_DISABLED 1289
#define ER_OPTION_PREVENTS_STATEMENT 1290
#define ER_ERROR_MESSAGES 291
#define ER_DUPLICATED_VALUE_IN_TYPE 1291
#define ER_TRUNCATED_WRONG_VALUE 1292
#define ER_ERROR_MESSAGES 293
......@@ -38,6 +38,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
const char *sqlstate);
void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
#ifdef __cplusplus
}
#endif
......
......@@ -34,6 +34,7 @@ CXXFLAGS="$CXXFLAGS "
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_CHECK_HEADERS(aio.h sched.h)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
......
......@@ -57,7 +57,7 @@ MYSQL_DATA * cli_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
int cli_stmt_execute(MYSQL_STMT *stmt);
MYSQL_DATA * cli_read_binary_rows(MYSQL_STMT *stmt);
int cli_unbuffered_fetch(MYSQL *mysql, char **row);
const char * cli_read_statistic(MYSQL *mysql);
const char * cli_read_statistics(MYSQL *mysql);
int cli_read_change_user_result(MYSQL *mysql, char *buff, const char *passwd);
#ifdef EMBEDDED_LIBRARY
......
......@@ -1126,7 +1126,7 @@ mysql_dump_debug_info(MYSQL *mysql)
DBUG_RETURN(simple_command(mysql,COM_DEBUG,0,0,0));
}
const char *cli_read_statistic(MYSQL *mysql)
const char *cli_read_statistics(MYSQL *mysql)
{
mysql->net.read_pos[mysql->packet_length]=0; /* End of stat string */
if (!mysql->net.read_pos[0])
......@@ -1145,7 +1145,7 @@ mysql_stat(MYSQL *mysql)
DBUG_ENTER("mysql_stat");
if (simple_command(mysql,COM_STATISTICS,0,0,0))
return mysql->net.last_error;
DBUG_RETURN((*mysql->methods->read_statistic)(mysql));
DBUG_RETURN((*mysql->methods->read_statistics)(mysql));
}
......@@ -1544,21 +1544,6 @@ void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
}
/*
Set the internal error message to mysql handler
*/
static void set_mysql_error(MYSQL * mysql, int errcode, const char *sqlstate)
{
DBUG_ENTER("set_mysql_error");
DBUG_PRINT("enter", ("error :%d '%s'", errcode, ER(errcode)));
DBUG_ASSERT(mysql != 0);
mysql->net.last_errno= errcode;
strmov(mysql->net.last_error, ER(errcode));
strmov(mysql->net.sqlstate, sqlstate);
}
/*
Reallocate the NET package to be at least of 'length' bytes
......@@ -2872,7 +2857,7 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
{
/*
Set param->is_null to point to a dummy variable if it's not set.
This is to make the excute code easier
This is to make the execute code easier
*/
if (!param->is_null)
param->is_null= &param->internal_is_null;
......@@ -3142,8 +3127,7 @@ MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt)
if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
MYF(MY_WME | MY_ZEROFILL))))
{
set_stmt_errmsg(stmt, ER(CR_OUT_OF_MEMORY), CR_OUT_OF_MEMORY,
unknown_sqlstate);
set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate);
DBUG_RETURN(0);
}
init_alloc_root(&result->alloc,8192,0); /* Assume rowlength < 8192 */
......@@ -3159,8 +3143,7 @@ MYSQL_DATA *cli_read_binary_rows(MYSQL_STMT *stmt)
!(cur->data= ((MYSQL_ROW) alloc_root(&result->alloc, pkt_len))))
{
free_rows(result);
set_stmt_errmsg(stmt, ER(CR_OUT_OF_MEMORY), CR_OUT_OF_MEMORY,
unknown_sqlstate);
set_stmt_error(stmt, CR_OUT_OF_MEMORY, unknown_sqlstate);
DBUG_RETURN(0);
}
*prev_ptr= cur;
......
......@@ -234,7 +234,7 @@ static void emb_free_embedded_thd(MYSQL *mysql)
delete thd;
}
static const char * emb_read_statistic(MYSQL *mysql)
static const char * emb_read_statistics(MYSQL *mysql)
{
THD *thd= (THD*)mysql->thd;
return thd->net.last_error;
......@@ -279,7 +279,7 @@ MYSQL_METHODS embedded_methods=
emb_read_binary_rows,
emb_unbuffered_fetch,
emb_free_embedded_thd,
emb_read_statistic,
emb_read_statistics,
emb_next_result,
emb_read_change_user_result
};
......@@ -398,23 +398,6 @@ int init_embedded_server(int argc, char **argv, char **groups)
udf_init();
#endif
if (opt_bin_log)
{
if (!opt_bin_logname)
{
char tmp[FN_REFLEN];
/* TODO: The following should be using fn_format(); We just need to
first change fn_format() to cut the file name if it's too long.
*/
strmake(tmp,glob_hostname,FN_REFLEN-5);
strmov(strcend(tmp,'.'),"-bin");
opt_bin_logname=my_strdup(tmp,MYF(MY_WME));
}
open_log(&mysql_bin_log, glob_hostname, opt_bin_logname, "-bin",
opt_binlog_index_name, LOG_BIN, 0, 0, max_binlog_size);
using_update_log=1;
}
(void) thr_setconcurrency(concurrency); // 10 by default
if (
......
......@@ -104,9 +104,9 @@ drop table t2;
create table t2 select CAST("2001-12-29" AS DATE) as d, CAST("20:45:11" AS TIME) as t, CAST("2001-12-29 20:45:11" AS DATETIME) as dt;
describe t2;
Field Type Null Key Default Extra
d date 0000-00-00
t time 00:00:00
dt datetime 0000-00-00 00:00:00
d date YES NULL
t time YES NULL
dt datetime YES NULL
drop table t1,t2;
create table t1 (a tinyint);
create table t2 (a int) select * from t1;
......@@ -396,12 +396,12 @@ Field Type Null Key Default Extra
a int(11) YES NULL
b bigint(11) 0
c bigint(10) 0
d date 0000-00-00
d date YES NULL
e char(1)
f datetime 0000-00-00 00:00:00
g time 00:00:00
f datetime YES NULL
g time YES NULL
h longblob
dd time 00:00:00
dd time YES NULL
select * from t2;
a b c d e f g h dd
1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00
......@@ -456,6 +456,20 @@ Field Type Null Key Default Extra
name varchar(10) YES NULL
age smallint(6) YES -1
drop table t1, t2;
create table t1(cenum enum('a'), cset set('b'));
create table t2(cenum enum('a','a'), cset set('b','b'));
Warnings:
Error 1291 Column 'cenum' has duplicated value 'a' in ENUM
Error 1291 Column 'cset' has duplicated value 'b' in SET
create table t3(cenum enum('a','A','a','c','c'), cset set('b','B','b','d','d'));
Warnings:
Error 1291 Column 'cenum' has duplicated value 'a' in ENUM
Error 1291 Column 'cenum' has duplicated value 'A' in ENUM
Error 1291 Column 'cenum' has duplicated value 'c' in ENUM
Error 1291 Column 'cset' has duplicated value 'b' in SET
Error 1291 Column 'cset' has duplicated value 'B' in SET
Error 1291 Column 'cset' has duplicated value 'd' in SET
drop table t1, t2, t3;
create database test_$1;
use test_$1;
select database();
......@@ -468,3 +482,44 @@ NULL
select database();
database()
NULL
use test;
create table t1 (a int, index `primary` (a));
ERROR 42000: Incorrect index name 'primary'
create table t1 (a int, index `PRIMARY` (a));
ERROR 42000: Incorrect index name 'PRIMARY'
create table t1 (`primary` int, index(`primary`));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`primary` int(11) default NULL,
KEY `primary_2` (`primary`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
create table t2 (`PRIMARY` int, index(`PRIMARY`));
show create table t2;
Table Create Table
t2 CREATE TABLE `t2` (
`PRIMARY` int(11) default NULL,
KEY `PRIMARY_2` (`PRIMARY`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
create table t3 (a int);
alter table t3 add index `primary` (a);
ERROR 42000: Incorrect index name 'primary'
alter table t3 add index `PRIMARY` (a);
ERROR 42000: Incorrect index name 'PRIMARY'
create table t4 (`primary` int);
alter table t4 add index(`primary`);
show create table t4;
Table Create Table
t4 CREATE TABLE `t4` (
`primary` int(11) default NULL,
KEY `primary_2` (`primary`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
create table t5 (`PRIMARY` int);
alter table t5 add index(`PRIMARY`);
show create table t5;
Table Create Table
t5 CREATE TABLE `t5` (
`PRIMARY` int(11) default NULL,
KEY `PRIMARY_2` (`PRIMARY`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1, t2, t3, t4, t5;
This diff is collapsed.
......@@ -159,14 +159,14 @@ time("1997-12-31 23:59:59.000001") as f9;
describe t1;
Field Type Null Key Default Extra
f1 date 0000-00-00
f2 datetime 0000-00-00 00:00:00
f3 time 00:00:00
f2 datetime YES NULL
f3 time YES NULL
f4 time 00:00:00
f5 time 00:00:00
f6 time 00:00:00
f7 datetime 0000-00-00 00:00:00
f8 date 0000-00-00
f9 time 00:00:00
f7 datetime YES NULL
f8 date YES NULL
f9 time YES NULL
select * from t1;
f1 f2 f3 f4 f5 f6 f7 f8 f9
1997-01-01 1998-01-02 01:01:00 49:01:01 46:58:57 -23:59:59 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59
......@@ -198,3 +198,18 @@ NULL NULL
NULL NULL
00:00:00 -24:00:00
drop table t1, test;
select addtime("-01:01:01.01", "-23:59:59.1") as a;
a
-25:01:00.110000
select microsecond("1997-12-31 23:59:59.01") as a;
a
10000
select microsecond(19971231235959.01) as a;
a
10000
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
a
1997-12-31 00:00:10.090000
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f");
str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f")
2003-01-02 10:11:12.001200
......@@ -624,3 +624,13 @@ Note 1003 select high_priority md5(_latin1'hello') AS `md5('hello')`,sha(_latin1
SELECT lpad(12345, 5, "#");
lpad(12345, 5, "#")
12345
create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
insert into t2 values (1,'cccccccccc'), (2,'dddddddddd');
select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2
where t2.id=t1.id order by name;
name
aaaaaaaaaaccccc
bbbbbbbbbbddddd
drop table t1, t2;
......@@ -506,17 +506,32 @@ last_day('2001-01-01 01:01:01') as f5, last_day(NULL),
last_day('2001-02-12');
f1 f2 f3 f4 f5 last_day(NULL) last_day('2001-02-12')
2000-02-29 2002-12-31 NULL 2003-04-30 2001-01-31 NULL 2001-02-28
create table t1 select last_day('2000-02-05') as a;
create table t1 select last_day('2000-02-05') as a,
from_days(to_days("960101")) as b;
describe t1;
Field Type Null Key Default Extra
a date 0000-00-00
b date YES NULL
select * from t1;
a
2000-02-29
a b
2000-02-29 1996-01-01
drop table t1;
select last_day('2000-02-05');
last_day('2000-02-05')
2000-02-29
select last_day('2000-02-05') as a,
from_days(to_days("960101")) as b;
a b
2000-02-29 1996-01-01
select date_add(last_day("1997-12-1"), INTERVAL 1 DAY);
date_add(last_day("1997-12-1"), INTERVAL 1 DAY)
1998-01-01
select length(last_day("1997-12-1"));
length(last_day("1997-12-1"))
10
select last_day("1997-12-1")+0;
last_day("1997-12-1")+0
19971231
select last_day("1997-12-1")+0.0;
last_day("1997-12-1")+0.0
19971231.0
select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0
1
......
......@@ -169,7 +169,6 @@ set @value= "1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
Warnings:
Warning 1265 Data truncated for column 'f_double ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double ' at row 1
Warning 1265 Data truncated for column 'f_float ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float ' at row 1
Warning 1265 Data truncated for column 'f_double_7_2 ' at row 1
......@@ -177,7 +176,6 @@ Warning 1264 Data truncated, out of range for column 'f_double_7_2 ' at row 1
Warning 1265 Data truncated for column 'f_float_4_3 ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_4_3 ' at row 1
Warning 1265 Data truncated for column 'f_double_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_u ' at row 1
Warning 1265 Data truncated for column 'f_float_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_u ' at row 1
Warning 1265 Data truncated for column 'f_double_15_1_u ' at row 1
......@@ -199,7 +197,6 @@ set @value= "-1e+1111111111a";
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
Warnings:
Warning 1265 Data truncated for column 'f_double ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double ' at row 1
Warning 1265 Data truncated for column 'f_float ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float ' at row 1
Warning 1265 Data truncated for column 'f_double_7_2 ' at row 1
......@@ -228,17 +225,15 @@ f_float_3_1_u 0.0
set @value= 1e+1111111111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
Warnings:
Warning 1264 Data truncated, out of range for column 'f_double ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_7_2 ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_4_3 ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_15_1_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_3_1_u ' at row 1
select * from t1 where `number `=last_insert_id();
number 6
original_value inf
original_value 1.7976931348623e+308
f_double 1.79769313486232e+308
f_float 3.40282e+38
f_double_7_2 99999.99
......@@ -250,7 +245,6 @@ f_float_3_1_u 99.9
set @value= -1e+1111111111;
insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@value,@value);
Warnings:
Warning 1264 Data truncated, out of range for column 'f_double ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float ' at row 1
Warning 1264 Data truncated, out of range for column 'f_double_7_2 ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_4_3 ' at row 1
......@@ -260,7 +254,7 @@ Warning 1264 Data truncated, out of range for column 'f_double_15_1_u ' at row 1
Warning 1264 Data truncated, out of range for column 'f_float_3_1_u ' at row 1
select * from t1 where `number `=last_insert_id();
number 7
original_value -inf
original_value -1.7976931348623e+308
f_double -1.79769313486232e+308
f_float -3.40282e+38
f_double_7_2 -99999.99
......
......@@ -46,8 +46,6 @@ UNLOCK TABLES;
DROP TABLE t1;
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES (-9e999999);
Warnings:
Warning 1264 Data truncated, out of range for column 'a' at row 1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
......@@ -144,7 +142,7 @@ CREATE TABLE t1 (a int) ENGINE=MYISAM;
INSERT INTO t1 VALUES (1), (2);
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,MYSQL40" */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL
......@@ -163,7 +161,7 @@ UNLOCK TABLES;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,MYSQL323" */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL
......@@ -205,6 +203,88 @@ UNLOCK TABLES;
drop table ```a`;
create table t1(a int);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,ANSI" */;
DROP TABLE IF EXISTS "t1";
CREATE TABLE "t1" (
"a" int(11) default NULL
);
/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
LOCK TABLES "t1" WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE "t1" ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
set global sql_mode='ANSI_QUOTES';
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO" */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE="NO_AUTO_VALUE_ON_ZERO,ANSI" */;
DROP TABLE IF EXISTS "t1";
CREATE TABLE "t1" (
"a" int(11) default NULL
);
/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
LOCK TABLES "t1" WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE "t1" ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
set global sql_mode='';
drop table t1;
create table t1(a int);
insert into t1 values (1),(2),(3);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT, CHARACTER_SET_CLIENT=utf8 */;
......
......@@ -25,9 +25,11 @@ t
36:30:31
insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a");
Warnings:
Note 1292 Truncated wrong time value: '10.22.22'
Warning 1264 Data truncated, out of range for column 't' at row 2
Warning 1264 Data truncated, out of range for column 't' at row 3
Warning 1264 Data truncated, out of range for column 't' at row 4
Note 1292 Truncated wrong time value: '12.45a'
select * from t1;
t
10:22:33
......
......@@ -346,6 +346,15 @@ create table t2(name varchar(10), age smallint default - 1);
describe t2;
drop table t1, t2;
#
# test for bug #1427 "enum allows duplicate values in the list"
#
create table t1(cenum enum('a'), cset set('b'));
create table t2(cenum enum('a','a'), cset set('b','b'));
create table t3(cenum enum('a','A','a','c','c'), cset set('b','B','b','d','d'));
drop table t1, t2, t3;
#
# Bug #1209
#
......@@ -359,3 +368,33 @@ select database();
# Connect without a database
connect (user4,localhost,mysqltest_1,,*NO-ONE*);
select database();
#
# Test for Bug 856 'Naming a key "Primary" causes trouble'
#
use test;
--error 1280
create table t1 (a int, index `primary` (a));
--error 1280
create table t1 (a int, index `PRIMARY` (a));
create table t1 (`primary` int, index(`primary`));
show create table t1;
create table t2 (`PRIMARY` int, index(`PRIMARY`));
show create table t2;
create table t3 (a int);
--error 1280
alter table t3 add index `primary` (a);
--error 1280
alter table t3 add index `PRIMARY` (a);
create table t4 (`primary` int);
alter table t4 add index(`primary`);
show create table t4;
create table t5 (`PRIMARY` int);
alter table t5 add index(`PRIMARY`);
show create table t5;
drop table t1, t2, t3, t4, t5;
......@@ -124,7 +124,7 @@ select str_to_date(concat('15-01-2001',' 2:59:58.999'),
create table t1 (date char(30), format char(30) not null);
insert into t1 values
('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S'),
('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
......@@ -209,3 +209,32 @@ create table t1 (d date);
insert into t1 values ('2004-07-14'),('2005-07-14');
select date_format(d,"%d") from t1 order by 1;
drop table t1;
select str_to_date("2003-....01ABCD-02 10:11:12.0012", "%Y-%.%m%@-%d %H:%i:%S.%f") as a;
create table t1 select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
str_to_date("10:11:12.0012", "%H:%i:%S.%f") as f2,
str_to_date("2003-01-02", "%Y-%m-%d") as f3,
str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5;
describe t1;
select * from t1;
drop table t1;
create table t1 select "02 10" as a, "%d %H" as b;
select str_to_date(a,b) from t1;
create table t2 select str_to_date(a,b) from t1;
describe t2;
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2,
str_to_date("2003-01-02", "%Y-%m-%d") as f3,
str_to_date("02 10:11:12", "%d %H:%i:%S.%f") as f4,
str_to_date("02 10:11:12", "%d %H:%i:%S") as f5,
str_to_date("02 10", "%d %f") as f6;
drop table t1, t2;
select str_to_date("2003-01-02 10:11:12.0012ABCD", "%Y-%m-%d %H:%i:%S.%f") as f1,
addtime("-01:01:01.01 GGG", "-23:59:59.1") as f2,
microsecond("1997-12-31 23:59:59.01XXXX") as f3;
select str_to_date("2003-04-05 g", "%Y-%m-%d") as f1,
str_to_date("2003-04-05 10:11:12.101010234567", "%Y-%m-%d %H:%i:%S.%f") as f2;
......@@ -97,3 +97,9 @@ SELECT ADDTIME(t1,t2) As ttt, ADDTIME(t2, t3) As qqq from test;
SELECT TIMEDIFF(t1,t4) As ttt, TIMEDIFF(t2, t3) As qqq from test;
drop table t1, test;
select addtime("-01:01:01.01", "-23:59:59.1") as a;
select microsecond("1997-12-31 23:59:59.01") as a;
select microsecond(19971231235959.01) as a;
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f");
......@@ -360,3 +360,16 @@ explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'moo
#
SELECT lpad(12345, 5, "#");
#
# Bug #3089
#
create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
insert into t2 values (1,'cccccccccc'), (2,'dddddddddd');
select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2
where t2.id=t1.id order by name;
drop table t1, t2;
......@@ -249,12 +249,18 @@ select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
last_day('2001-01-01 01:01:01') as f5, last_day(NULL),
last_day('2001-02-12');
create table t1 select last_day('2000-02-05') as a;
create table t1 select last_day('2000-02-05') as a,
from_days(to_days("960101")) as b;
describe t1;
select * from t1;
drop table t1;
select last_day('2000-02-05');
select last_day('2000-02-05') as a,
from_days(to_days("960101")) as b;
select date_add(last_day("1997-12-1"), INTERVAL 1 DAY);
select length(last_day("1997-12-1"));
select last_day("1997-12-1")+0;
select last_day("1997-12-1")+0.0;
# Test SAPDB UTC_% functions. This part is TZ dependant (It is supposed that
# TZ variable set to GMT-3
......
......@@ -72,6 +72,19 @@ create table ```a` (i int);
--exec $MYSQL_DUMP --skip-comments test
drop table ```a`;
#
# Bug #2591 "mysqldump quotes names inconsistently"
#
create table t1(a int);
--exec $MYSQL_DUMP --comments=0 test
--exec $MYSQL_DUMP --comments=0 --compatible=ansi test
set global sql_mode='ANSI_QUOTES';
--exec $MYSQL_DUMP --comments=0 test
--exec $MYSQL_DUMP --comments=0 --compatible=ansi test
set global sql_mode='';
drop table t1;
#
# Bug #2705 'mysqldump --tab extra output'
#
......
This diff is collapsed.
......@@ -4765,7 +4765,8 @@ void Field_blob::get_key_image(char *buff,uint length,
{
const char *dummy;
MBR mbr;
Geometry gobj;
Geometry_buffer buffer;
Geometry *gobj;
if (blob_length < SRID_SIZE)
{
......@@ -4773,8 +4774,9 @@ void Field_blob::get_key_image(char *buff,uint length,
return;
}
get_ptr(&blob);
gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE);
if (gobj.get_mbr(&mbr, &dummy))
gobj= Geometry::create_from_wkb(&buffer,
blob + SRID_SIZE, blob_length - SRID_SIZE);
if (gobj->get_mbr(&mbr, &dummy))
bzero(buff, SIZEOF_STORED_DOUBLE*4);
else
{
......@@ -5013,9 +5015,11 @@ void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs,
return;
}
get_ptr(&blob);
Geometry gobj;
gobj.create_from_wkb(blob + SRID_SIZE, blob_length - SRID_SIZE);
if (gobj.get_mbr(&mbr, &dummy))
Geometry_buffer buffer;
Geometry *gobj;
gobj= Geometry::create_from_wkb(&buffer,
blob + SRID_SIZE, blob_length - SRID_SIZE);
if (gobj->get_mbr(&mbr, &dummy))
bzero(buff, SIZEOF_STORED_DOUBLE*4);
else
{
......@@ -5075,7 +5079,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
if (length < SRID_SIZE + WKB_HEADER_SIZE + SIZEOF_STORED_DOUBLE*2)
goto err;
wkb_type= uint4korr(from + WKB_HEADER_SIZE);
if (wkb_type < (uint32) Geometry::wkbPoint ||
if (wkb_type < (uint32) Geometry::wkb_point ||
wkb_type > (uint32) Geometry::wkb_end)
return 1;
Field_blob::store_length(length);
......
......@@ -24,7 +24,7 @@
enum Gis_read_stream::enum_tok_types Gis_read_stream::get_next_toc_type()
{
skip_space();
if (!*m_cur)
if (m_cur >= m_limit)
return eostream;
if (my_isvar_start(&my_charset_bin, *m_cur))
return word;
......@@ -53,7 +53,7 @@ bool Gis_read_stream::get_next_word(LEX_STRING *res)
my_isvar() is a macro that would cause side effects
*/
m_cur++;
while (my_isvar(&my_charset_bin, *m_cur))
while ((m_cur < m_limit) && my_isvar(&my_charset_bin, *m_cur))
m_cur++;
res->length= (uint32) (m_cur - res->str);
......@@ -71,16 +71,21 @@ bool Gis_read_stream::get_next_word(LEX_STRING *res)
bool Gis_read_stream::get_next_number(double *d)
{
char *endptr;
int err;
skip_space();
/* The following will also test for end \0 */
if ((*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+')
if ((m_cur >= m_limit) ||
(*m_cur < '0' || *m_cur > '9') && *m_cur != '-' && *m_cur != '+')
{
set_error_msg("Numeric constant expected");
return 1;
}
*d = my_strtod(m_cur, &endptr);
*d = my_strntod(m_charset, (char *)m_cur,
m_limit-m_cur, &endptr, &err);
if (err)
return 1;
if (endptr)
m_cur = endptr;
return 0;
......@@ -90,7 +95,7 @@ bool Gis_read_stream::get_next_number(double *d)
bool Gis_read_stream::check_next_symbol(char symbol)
{
skip_space();
if (*m_cur != symbol)
if ((m_cur >= m_limit) || (*m_cur != symbol))
{
char buff[32];
strmov(buff, "'?' expected");
......
......@@ -29,8 +29,8 @@ class Gis_read_stream
comma
};
Gis_read_stream(const char *buffer, int size)
:m_cur(buffer), m_limit(buffer + size), m_err_msg(NULL)
Gis_read_stream(CHARSET_INFO *charset, const char *buffer, int size)
:m_cur(buffer), m_limit(buffer + size), m_err_msg(NULL), m_charset(charset)
{}
Gis_read_stream(): m_cur(NullS), m_limit(NullS), m_err_msg(NullS)
{}
......@@ -46,14 +46,14 @@ class Gis_read_stream
inline void skip_space()
{
while (my_isspace(&my_charset_latin1, *m_cur))
while ((m_cur < m_limit) && my_isspace(&my_charset_latin1, *m_cur))
m_cur++;
}
/* Skip next character, if match. Return 1 if no match */
inline bool skip_char(char skip)
{
skip_space();
if (*m_cur != skip)
if ((m_cur >= m_limit) || *m_cur != skip)
return 1; /* Didn't find char */
m_cur++;
return 0;
......@@ -72,4 +72,5 @@ class Gis_read_stream
const char *m_cur;
const char *m_limit;
char *m_err_msg;
CHARSET_INFO *m_charset;
};
This diff is collapsed.
......@@ -1033,7 +1033,7 @@ void Item_func_substr::fix_length_and_dec()
}
if (arg_count == 3 && args[2]->const_item())
{
int32 length= (int32) args[2]->val_int() * default_charset_info->mbmaxlen;
int32 length= (int32) args[2]->val_int() * collation.collation->mbmaxlen;
if (length <= 0)
max_length=0; /* purecov: inspected */
else
......@@ -2241,7 +2241,7 @@ String *Item_func_hex::val_str(String *str)
return &tmp_value;
}
int inline hexchar_to_int(char c)
inline int hexchar_to_int(char c)
{
if (c <= '9' && c >= '0')
return c-'0';
......@@ -2721,7 +2721,7 @@ String *Item_func_uuid::val_str(String *str)
{
ulong tmp=sql_rnd_with_mutex();
uchar mac[6];
int i;
unsigned int i;
if (my_gethwaddr(mac))
{
/*
......@@ -2754,7 +2754,14 @@ String *Item_func_uuid::val_str(String *str)
tv++;
}
else
{
if (nanoseq)
{
tv-=nanoseq;
nanoseq=0;
}
DBUG_ASSERT(tv > uuid_time);
}
uuid_time=tv;
pthread_mutex_unlock(&LOCK_uuid_generator);
......
This diff is collapsed.
......@@ -21,6 +21,11 @@
#pragma interface /* gcc class implementation */
#endif
enum date_time_format_types
{
TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND
};
class Item_func_period_add :public Item_int_func
{
public:
......@@ -318,6 +323,7 @@ class Item_date :public Item_func
enum Item_result result_type () const { return STRING_RESULT; }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
String *val_str(String *str);
longlong val_int();
double val() { return (double) val_int(); }
const char *func_name() const { return "date"; }
void fix_length_and_dec()
......@@ -407,6 +413,7 @@ class Item_func_curdate :public Item_date
Item_func_curdate() :Item_date() {}
void set_result_from_tm(struct tm *now);
longlong val_int() { return (value) ; }
String *val_str(String *str);
void fix_length_and_dec();
bool get_date(TIME *res, uint fuzzy_date);
virtual void store_now_in_tm(time_t now, struct tm *now_tm)=0;
......@@ -477,8 +484,8 @@ class Item_func_from_days :public Item_date
{
public:
Item_func_from_days(Item *a) :Item_date(a) {}
longlong val_int();
const char *func_name() const { return "from_days"; }
bool get_date(TIME *res, uint fuzzy_date);
};
......@@ -610,6 +617,19 @@ class Item_typecast :public Item_str_func
};
class Item_typecast_maybe_null :public Item_typecast
{
public:
Item_typecast_maybe_null(Item *a) :Item_typecast(a) {}
void fix_length_and_dec()
{
collation.set(&my_charset_bin);
max_length=args[0]->max_length;
maybe_null= 1;
}
};
class Item_char_typecast :public Item_typecast
{
int cast_length;
......@@ -626,10 +646,10 @@ class Item_char_typecast :public Item_typecast
};
class Item_date_typecast :public Item_typecast
class Item_date_typecast :public Item_typecast_maybe_null
{
public:
Item_date_typecast(Item *a) :Item_typecast(a) {}
Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
String *val_str(String *str);
bool get_date(TIME *ltime, uint fuzzy_date);
const char *cast_type() const { return "date"; }
......@@ -641,10 +661,10 @@ class Item_date_typecast :public Item_typecast
};
class Item_time_typecast :public Item_typecast
class Item_time_typecast :public Item_typecast_maybe_null
{
public:
Item_time_typecast(Item *a) :Item_typecast(a) {}
Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
String *val_str(String *str);
bool get_time(TIME *ltime);
const char *cast_type() const { return "time"; }
......@@ -656,10 +676,10 @@ class Item_time_typecast :public Item_typecast
};
class Item_datetime_typecast :public Item_typecast
class Item_datetime_typecast :public Item_typecast_maybe_null
{
public:
Item_datetime_typecast(Item *a) :Item_typecast(a) {}
Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {}
String *val_str(String *str);
const char *cast_type() const { return "datetime"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
......@@ -793,37 +813,29 @@ class Item_func_get_format :public Item_str_func
};
class Item_func_str_to_date :public Item_date_func
class Item_func_str_to_date :public Item_str_func
{
enum_field_types cached_field_type;
date_time_format_types cached_format_type;
timestamp_type cached_timestamp_type;
bool const_item;
public:
Item_func_str_to_date(Item *a, Item *b)
:Item_date_func(a, b)
:Item_str_func(a, b)
{}
String *val_str(String *str);
bool get_date(TIME *ltime, uint fuzzy_date);
const char *func_name() const { return "str_to_date"; }
void fix_length_and_dec()
{
maybe_null= 1;
decimals=0;
max_length=MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
}
enum_field_types field_type() const { return cached_field_type; }
void fix_length_and_dec();
Field *tmp_table_field(TABLE *t_arg);
};
class Item_func_last_day :public Item_str_func
class Item_func_last_day :public Item_date
{
public:
Item_func_last_day(Item *a) :Item_str_func(a) {}
String *val_str(String *str);
Item_func_last_day(Item *a) :Item_date(a) {}
const char *func_name() const { return "last_day"; }
enum_field_types field_type() const { return MYSQL_TYPE_DATE; }
void fix_length_and_dec()
{
decimals=0;
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
}
Field *tmp_table_field(TABLE *t_arg)
{
return (new Field_date(maybe_null, name, t_arg, &my_charset_bin));
}
bool get_date(TIME *res, uint fuzzy_date);
};
......@@ -799,6 +799,7 @@ extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
extern char pidfile_name[FN_REFLEN], time_zone[30], *opt_init_file;
extern char log_error_file[FN_REFLEN];
extern double log_10[32];
extern ulonglong log_10_int[20];
extern ulonglong keybuff_size;
extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables;
extern ulong created_tmp_tables, created_tmp_disk_tables, bytes_sent;
......@@ -958,6 +959,8 @@ timestamp_type str_to_TIME(const char *str, uint length, TIME *l_time,
void localtime_to_TIME(TIME *to, struct tm *from);
void calc_time_from_sec(TIME *to, long seconds, long microseconds);
void make_truncated_value_warning(THD *thd, const char *str_val,
uint str_length, timestamp_type time_type);
extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type,
const char *format_str,
uint format_length);
......
......@@ -305,6 +305,14 @@ ulong my_bind_addr; /* the address we bind to */
volatile ulong cached_thread_count= 0;
double log_10[32]; /* 10 potences */
ulonglong log_10_int[20]=
{
1, 10, 100, 1000, 10000UL, 100000UL, 1000000UL, 10000000UL,
100000000UL, 1000000000UL, 10000000000UL, 100000000000UL,
1000000000000UL, 10000000000000UL, 100000000000000UL,
1000000000000000UL, 10000000000000000UL, 100000000000000000UL,
1000000000000000000UL, 10000000000000000000UL
};
time_t start_time;
......
......@@ -303,3 +303,5 @@ character-set=latin2
"The target table %-.100s of the %s is not updatable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -297,3 +297,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -305,3 +305,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -294,3 +294,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updatable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -299,3 +299,5 @@ character-set=latin7
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -294,3 +294,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -306,3 +306,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -294,3 +294,5 @@ character-set=greek
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -296,3 +296,5 @@ character-set=latin2
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -294,3 +294,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -296,3 +296,5 @@ character-set=ujis
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -294,3 +294,5 @@ character-set=euckr
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -296,3 +296,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -296,3 +296,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -298,3 +298,5 @@ character-set=latin2
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -295,3 +295,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -298,3 +298,5 @@ character-set=latin2
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -296,3 +296,5 @@ character-set=koi8r
" %-.100s %s ",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -288,3 +288,5 @@ character-set=cp1250
"The target table %-.100s of the %s is not updatable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working"
"The MySQL server is running with the %s option so it cannot execute this statement"
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -302,3 +302,5 @@ character-set=latin2
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -296,3 +296,5 @@ character-set=latin1
"The target table %-.100s of the %s is not updateable",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -294,3 +294,5 @@ character-set=latin1
"'%s' är inte aktiverad; För att aktivera detta måste du bygga om MySQL med '%s' definerad",
"MySQL är started i --skip-grant-tables mod. Pga av detta kan du inte använda detta program",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
......@@ -299,3 +299,5 @@ character-set=koi8u
" %-.100s %s ",
"The '%s' feature was disabled; you need MySQL built with '%s' to have it working",
"The MySQL server is running with the %s option so it cannot execute this statement",
"Column '%-.100s' has duplicated value '%-.64s' in %s"
"Truncated wrong %-.32s value: '%-.128s'"
This diff is collapsed.
This diff is collapsed.
......@@ -1321,8 +1321,8 @@ bool st_select_lex_unit::create_total_list(THD *thd_arg, st_lex *lex,
DESCRIPTION
This is used for UNION & subselect to create a new table list of all used
tables.
The table_list->table entry in all used tables are set to point
to the entries in this list.
The table_list->table_list in all tables of global list are set to point
to the local SELECT_LEX entries.
RETURN
0 - OK
......@@ -1373,7 +1373,7 @@ create_total_list_n_last_return(THD *thd_arg,
{
TABLE_LIST *cursor;
next_table= aux->next;
/* Add not used table to the total table list */
/* Add to the total table list */
if (!(cursor= (TABLE_LIST *) thd->memdup((char*) aux,
sizeof(*aux))))
{
......
......@@ -342,6 +342,50 @@ static int sort_keys(KEY *a, KEY *b)
0);
}
/*
Check TYPELIB (set or enum) for duplicates
SYNOPSIS
check_duplicates_in_interval()
set_or_name "SET" or "ENUM" string for warning message
name name of the checked column
typelib list of values for the column
DESCRIPTION
This function prints an warning for each value in list
which has some duplicates on its right
RETURN VALUES
void
*/
void check_duplicates_in_interval(const char *set_or_name,
const char *name, TYPELIB *typelib)
{
unsigned int old_count= typelib->count;
const char **old_type_names= typelib->type_names;
if (typelib->count <= 1)
return;
old_count= typelib->count;
old_type_names= typelib->type_names;
const char **cur_value= typelib->type_names;
for ( ; typelib->count > 1; cur_value++)
{
typelib->type_names++;
typelib->count--;
if (find_type((char*)*cur_value,typelib,1))
{
push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_DUPLICATED_VALUE_IN_TYPE,
ER(ER_DUPLICATED_VALUE_IN_TYPE),
name,*cur_value,set_or_name);
}
}
typelib->count= old_count;
typelib->type_names= old_type_names;
}
/*
Create a table
......@@ -546,6 +590,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::INTERVAL_FIELD;
check_duplicates_in_interval("ENUM",sql_field->field_name,
sql_field->interval);
break;
case FIELD_TYPE_SET:
sql_field->pack_flag=pack_length_to_packflag(sql_field->pack_length) |
......@@ -553,6 +599,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
if (sql_field->charset->state & MY_CS_BINSORT)
sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->unireg_check=Field::BIT_FIELD;
check_duplicates_in_interval("SET",sql_field->field_name,
sql_field->interval);
break;
case FIELD_TYPE_DATE: // Rest of string types
case FIELD_TYPE_NEWDATE:
......@@ -639,6 +687,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_RETURN(-1);
}
key_parts+=key->columns.elements;
if (key->name && !tmp_table &&
!my_strcasecmp(system_charset_info,key->name,primary_key_name))
{
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name);
DBUG_RETURN(-1);
}
}
tmp=min(file->max_keys(), MAX_KEY);
if (key_count > tmp)
......@@ -1079,7 +1133,8 @@ make_unique_key_name(const char *field_name,KEY *start,KEY *end)
{
char buff[MAX_FIELD_NAME],*buff_end;
if (!check_if_keyname_exists(field_name,start,end))
if (!check_if_keyname_exists(field_name,start,end) &&
my_strcasecmp(system_charset_info,field_name,primary_key_name))
return (char*) field_name; // Use fieldname
buff_end=strmake(buff,field_name,MAX_FIELD_NAME-4);
for (uint i=2 ; ; i++)
......@@ -2403,6 +2458,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
if (key->type != Key::FOREIGN_KEY)
key_list.push_back(key);
if (key->name &&
!my_strcasecmp(system_charset_info,key->name,primary_key_name))
{
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key->name);
DBUG_RETURN(-1);
}
}
}
......
......@@ -2941,14 +2941,14 @@ geometry_function:
{ $$= GEOM_NEW(Item_func_geometry_from_wkb($3, $5)); }
| GEOMETRYCOLLECTION '(' expr_list ')'
{ $$= GEOM_NEW(Item_func_spatial_collection(* $3,
Geometry::wkbGeometryCollection,
Geometry::wkbPoint)); }
Geometry::wkb_geometrycollection,
Geometry::wkb_point)); }
| LINESTRING '(' expr_list ')'
{ $$= GEOM_NEW(Item_func_spatial_collection(* $3,
Geometry::wkbLineString, Geometry::wkbPoint)); }
Geometry::wkb_linestring, Geometry::wkb_point)); }
| MULTILINESTRING '(' expr_list ')'
{ $$= GEOM_NEW( Item_func_spatial_collection(* $3,
Geometry::wkbMultiLineString, Geometry::wkbLineString)); }
Geometry::wkb_multilinestring, Geometry::wkb_linestring)); }
| MLINEFROMTEXT '(' expr ')'
{ $$= GEOM_NEW(Item_func_geometry_from_text($3)); }
| MLINEFROMTEXT '(' expr ',' expr ')'
......@@ -2963,10 +2963,10 @@ geometry_function:
{ $$= GEOM_NEW(Item_func_geometry_from_text($3, $5)); }
| MULTIPOINT '(' expr_list ')'
{ $$= GEOM_NEW(Item_func_spatial_collection(* $3,
Geometry::wkbMultiPoint, Geometry::wkbPoint)); }
Geometry::wkb_multipoint, Geometry::wkb_point)); }
| MULTIPOLYGON '(' expr_list ')'
{ $$= GEOM_NEW(Item_func_spatial_collection(* $3,
Geometry::wkbMultiPolygon, Geometry::wkbPolygon)); }
Geometry::wkb_multipolygon, Geometry::wkb_polygon)); }
| POINT_SYM '(' expr ',' expr ')'
{ $$= GEOM_NEW(Item_func_point($3,$5)); }
| POINTFROMTEXT '(' expr ')'
......@@ -2979,7 +2979,7 @@ geometry_function:
{ $$= GEOM_NEW(Item_func_geometry_from_text($3, $5)); }
| POLYGON '(' expr_list ')'
{ $$= GEOM_NEW(Item_func_spatial_collection(* $3,
Geometry::wkbPolygon, Geometry::wkbLineString)); }
Geometry::wkb_polygon, Geometry::wkb_linestring)); }
| GEOMCOLLFROMTEXT '(' expr ')'
{ $$= GEOM_NEW(Item_func_geometry_from_text($3)); }
| GEOMCOLLFROMTEXT '(' expr ',' expr ')'
......
......@@ -391,9 +391,11 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
ulong not_zero_date, allow_space;
bool is_internal_format;
const char *pos, *last_field_pos;
const char *str_begin= str;
const char *end=str+length;
const uchar *format_position;
bool found_delimitier= 0, found_space= 0;
uint frac_pos, frac_len;
DBUG_ENTER("str_to_TIME");
DBUG_PRINT("ENTER",("str: %.*s",length,str));
......@@ -482,7 +484,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
tmp_value=tmp_value*10 + (ulong) (uchar) (*str - '0');
str++;
}
date_len[i]+= (uint) (str - start);
date_len[i]= (uint) (str - start);
if (tmp_value > 999999) // Impossible date part
DBUG_RETURN(TIMESTAMP_NONE);
date[i]=tmp_value;
......@@ -535,9 +537,9 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
{
if (str+2 <= end && (str[1] == 'M' || str[1] == 'm'))
{
if (str[1] == 'p' || str[1] == 'P')
if (str[0] == 'p' || str[0] == 'P')
add_hours= 12;
else if (str[1] != 'a' || str[1] != 'A')
else if (str[0] != 'a' || str[0] != 'A')
continue; // Not AM/PM
str+= 2; // Skip AM/PM
/* Skip space after AM/PM */
......@@ -569,7 +571,13 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
l_time->hour= date[(uint) format_position[3]];
l_time->minute= date[(uint) format_position[4]];
l_time->second= date[(uint) format_position[5]];
l_time->second_part= date[(uint) format_position[6]];
frac_pos= (uint) format_position[6];
frac_len= date_len[frac_pos];
if (frac_len < 6)
date[frac_pos]*= (uint) log_10_int[6 - frac_len];
l_time->second_part= date[frac_pos];
if (format_position[7] != (uchar) 255)
{
if (l_time->hour > 12)
......@@ -585,6 +593,8 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
l_time->hour= date[3];
l_time->minute= date[4];
l_time->second= date[5];
if (date_len[6] < 6)
date[6]*= (uint) log_10_int[6 - date_len[6]];
l_time->second_part=date[6];
}
l_time->neg= 0;
......@@ -614,17 +624,19 @@ str_to_TIME(const char *str, uint length, TIME *l_time, uint flags)
current_thd->cuted_fields++;
goto err;
}
if (str != end && current_thd->count_cuted_fields)
{
l_time->time_type= (number_of_fields <= 3 ?
TIMESTAMP_DATE : TIMESTAMP_DATETIME);
for (; str != end ; str++)
{
if (!my_isspace(&my_charset_latin1,*str))
{
current_thd->cuted_fields++;
make_truncated_value_warning(current_thd, str_begin, length,
l_time->time_type);
break;
}
}
}
DBUG_RETURN(l_time->time_type=
(number_of_fields <= 3 ? TIMESTAMP_DATE : TIMESTAMP_DATETIME));
......@@ -686,6 +698,7 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
{
long date[5],value;
const char *end=str+length, *end_of_days;
const char *str_begin= str;
bool found_days,found_hours;
uint state;
......@@ -784,6 +797,8 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
my_isdigit(&my_charset_latin1,str[0]) &&
field_length--)
value=value*10 + (uint) (uchar) (*str - '0');
if (field_length)
value*= (long) log_10_int[field_length];
date[4]=value;
}
else
......@@ -796,12 +811,12 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
str++;
if (str+2 <= end && (str[1] == 'M' || str[1] == 'm'))
{
if (str[1] == 'p' || str[1] == 'P')
if (str[0] == 'p' || str[0] == 'P')
{
str+= 2;
date[1]= date[1]%12 + 12;
}
else if (str[1] == 'a' || str[1] == 'A')
else if (str[0] == 'a' || str[0] == 'A')
str+=2;
}
}
......@@ -822,13 +837,14 @@ bool str_to_time(const char *str,uint length,TIME *l_time)
l_time->time_type= TIMESTAMP_TIME;
/* Check if there is garbage at end of the TIME specification */
if (str != end && current_thd->count_cuted_fields)
if (str != end)
{
do
{
if (!my_isspace(&my_charset_latin1,*str))
{
current_thd->cuted_fields++;
make_truncated_value_warning(current_thd, str_begin, length,
TIMESTAMP_TIME);
break;
}
} while (++str != end);
......@@ -1265,3 +1281,35 @@ void make_datetime(DATE_TIME_FORMAT *format, TIME *l_time, String *str)
str->length(length);
str->set_charset(&my_charset_bin);
}
void make_truncated_value_warning(THD *thd, const char *str_val,
uint str_length, timestamp_type time_type)
{
char warn_buff[MYSQL_ERRMSG_SIZE];
const char *type_str;
char buff[128];
String str(buff,(uint32) sizeof(buff), system_charset_info);
str.length(0);
str.append(str_val, str_length);
str.append('\0');
switch (time_type) {
case TIMESTAMP_DATE:
type_str= "date";
break;
case TIMESTAMP_DATETIME:
type_str= "datetime";
break;
case TIMESTAMP_TIME:
type_str= "time";
break;
default:
type_str= "string";
break;
}
sprintf(warn_buff, ER(ER_TRUNCATED_WRONG_VALUE),
type_str, str.ptr());
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
ER_TRUNCATED_WRONG_VALUE, warn_buff);
}
......@@ -2,7 +2,7 @@
An alternative implementation of "strtod()" that is both
simplier, and thread-safe.
From mit-threads as bundled with MySQL 3.22
From mit-threads as bundled with MySQL 3.23
SQL:2003 specifies a number as
......@@ -41,6 +41,7 @@ double my_strtod(const char *str, char **end)
double result= 0.0;
int negative, ndigits;
const char *old_str;
my_bool overflow=0;
while (my_isspace(&my_charset_latin1, *str))
str++;
......@@ -85,6 +86,7 @@ double my_strtod(const char *str, char **end)
double scaler= 1.0;
while (my_isdigit (&my_charset_latin1, *str))
{
if (exp < 9999) /* protection against exp overflow */
exp= exp*10 + *str - '0';
str++;
}
......@@ -93,7 +95,7 @@ double my_strtod(const char *str, char **end)
if (neg)
result= 0.0;
else
result= DBL_MAX*10;
overflow=1;
goto done;
}
while (exp >= 100)
......@@ -113,6 +115,12 @@ double my_strtod(const char *str, char **end)
if (end)
*end = (char *)str;
if (overflow || ((overflow=isinf(result))))
{
result=DBL_MAX;
errno=EOVERFLOW;
}
return negative ? -result : result;
}
......
......@@ -35,6 +35,7 @@ pkgdata_DATA = my-small.cnf \
my-large.cnf \
my-huge.cnf \
mysql-log-rotate \
mysql-@VERSION@.spec \
MySQL-shared-compat.spec
pkgdata_SCRIPTS = mysql.server
......
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