Commit 1388c164 authored by monty@mysql.com's avatar monty@mysql.com

After merge fixes

Return NULL if a time argument is given to date_add(). (Warning will be shown after Dimitri's timezone patch is pushed)
parent b11d2588
......@@ -60,6 +60,7 @@
#include <violite.h>
#define MAX_QUERY 131072
#define MAX_VAR_NAME 256
#define MAX_COLUMNS 256
#define PAD_SIZE 128
#define MAX_CONS 128
......@@ -386,6 +387,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
register char c;
register int escaped = 0;
VAR* v;
DBUG_ENTER("do_eval");
for (p= query; (c = *p); ++p)
{
......@@ -417,6 +419,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
break;
}
}
DBUG_VOID_RETURN;
}
......@@ -1739,6 +1742,7 @@ int read_line(char* buf, int size)
enum {R_NORMAL, R_Q1, R_ESC_Q_Q1, R_ESC_Q_Q2,
R_ESC_SLASH_Q1, R_ESC_SLASH_Q2,
R_Q2, R_COMMENT, R_LINE_START} state= R_LINE_START;
DBUG_ENTER("read_line");
start_lineno= *lineno;
for (; p < buf_end ;)
......@@ -1752,7 +1756,7 @@ int read_line(char* buf, int size)
cur_file--;
lineno--;
if (cur_file == file_stack)
return 1;
DBUG_RETURN(1);
continue;
}
......@@ -1762,7 +1766,7 @@ int read_line(char* buf, int size)
if (end_of_query(c))
{
*p= 0;
return 0;
DBUG_RETURN(0);
}
else if (c == '\'')
state = R_Q1;
......@@ -1779,7 +1783,7 @@ int read_line(char* buf, int size)
{
*p= 0;
(*lineno)++;
return 0;
DBUG_RETURN(0);
}
break;
case R_LINE_START:
......@@ -1797,12 +1801,12 @@ int read_line(char* buf, int size)
{
*buf++= '}';
*buf= 0;
return 0;
DBUG_RETURN(0);
}
else if (end_of_query(c) || c == '{')
{
*p= 0;
return 0;
DBUG_RETURN(0);
}
else if (c == '\'')
state= R_Q1;
......@@ -1822,7 +1826,7 @@ int read_line(char* buf, int size)
if (end_of_query(c))
{
*p= 0;
return 0;
DBUG_RETURN(0);
}
if (c != '\'')
state= R_NORMAL;
......@@ -1843,7 +1847,7 @@ int read_line(char* buf, int size)
if (end_of_query(c))
{
*p= 0;
return 0;
DBUG_RETURN(0);
}
if (c != '"')
state= R_NORMAL;
......@@ -1859,7 +1863,7 @@ int read_line(char* buf, int size)
*p++= c;
}
*p= 0; /* Always end with \0 */
return feof(*cur_file);
DBUG_RETURN(feof(*cur_file));
}
......@@ -1894,8 +1898,11 @@ int read_query(struct st_query** q_ptr)
q->type = Q_UNKNOWN;
q->query_buf= q->query= 0;
if (read_line(read_query_buf, sizeof(read_query_buf)))
{
DBUG_PRINT("warning",("too long query"));
DBUG_RETURN(1);
}
DBUG_PRINT("info", ("query: %s", read_query_buf));
if (*p == '#')
{
q->type = Q_COMMENT;
......@@ -2261,6 +2268,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
char* query;
int query_len, got_error_on_send= 0;
DBUG_ENTER("run_query");
DBUG_PRINT("enter",("flags: %d", flags));
if (q->type != Q_EVAL)
{
......@@ -2728,7 +2736,10 @@ int main(int argc, char **argv)
case Q_EVAL_RESULT: eval_result = 1; break;
case Q_EVAL:
if (q->query == q->query_buf)
{
q->query= q->first_argument;
q->first_word_len= 0;
}
/* fall through */
case Q_QUERY_VERTICAL:
case Q_QUERY_HORIZONTAL:
......@@ -2738,13 +2749,16 @@ int main(int argc, char **argv)
{
/* This happens when we use 'query_..' on it's own line */
q_send_flag=1;
DBUG_PRINT("info",
("query: '%s' first_word_len: %d send_flag=1",
q->query, q->first_word_len));
break;
}
/* fix up query pointer if this is * first iteration for this line */
if (q->query == q->query_buf)
q->query += q->first_word_len + 1;
display_result_vertically= (q->type==Q_QUERY_VERTICAL);
error |= run_query(&cur_con->mysql, q, QUERY_REAP|QUERY_SEND);
error|= run_query(&cur_con->mysql, q, QUERY_REAP|QUERY_SEND);
display_result_vertically= old_display_result_vertically;
break;
}
......
......@@ -104,7 +104,6 @@ dtype_form_prtype(
return(old_prtype + (charset_coll << 16));
}
#ifdef UNIV_DEBUG
/*************************************************************************
Validates a data type structure. */
......
......@@ -2825,8 +2825,7 @@ fil_load_single_table_tablespaces(void)
if (!dbpath) {
dbpath = mem_alloc(dbpath_len);
} else {
dbpath = mem_realloc(dbpath, dbpath_len,
__FILE__, __LINE__);
dbpath = ut_realloc(dbpath, dbpath_len);
}
}
sprintf(dbpath, "%s/%s", fil_path_to_mysql_datadir,
......
......@@ -1513,7 +1513,6 @@ recv_apply_log_recs_for_backup(void)
recv_sys_empty_hash();
}
#endif /* UNIV_HOTBACKUP */
#ifdef notdefined
/***********************************************************************
......
......@@ -70,7 +70,7 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record)
{
const byte *pos, *end;
ha_checksum crc= 0;
ulong seed= 4;
ulong seed1=0, seed2= 4;
HA_KEYSEG *keyseg;
for (keyseg=def->seg ; keyseg < def->end ; keyseg++)
......@@ -109,11 +109,10 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record)
end= pos+length;
if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT)
{
ulong tmp= 0;
keyseg->charset->coll->hash_sort(keyseg->charset,
(const uchar*) pos, length, &tmp,
&seed);
crc^= tmp;
(const uchar*) pos, length, &seed1,
&seed2);
crc^= seed1;
}
else
while (pos != end)
......
......@@ -528,7 +528,7 @@ date_add(date,INTERVAL "1 1:1:1" DAY_SECOND)
2003-01-03 01:01:01
select date_add(time,INTERVAL 1 SECOND) from t1;
date_add(time,INTERVAL 1 SECOND)
2006-07-08 00:00:01
NULL
drop table t1;
select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
last_day('2003-03-32') as f3, last_day('2003-04-01') as f4,
......
slave stop;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start;
start slave;
create table t1 (a int);
create table t2 (a int);
drop table t1;
......
......@@ -18,9 +18,9 @@ get_lock("lock",3)
select * from t1;
n
1
select is_free_lock("lock"), is_used_lock("lock");
is_free_lock("lock") is_used_lock("lock")
0 6
select is_free_lock("lock"), is_used_lock("lock") = connection_id();
is_free_lock("lock") is_used_lock("lock") = connection_id()
0 1
explain extended select is_free_lock("lock"), is_used_lock("lock");
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
......
......@@ -73,7 +73,7 @@ SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.
DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT))
Wed, 06 March 2002 10:11:12 GMT-0800 Wed, 06 March 2002 10:11:12 GMT-0800
drop table t1,t2;
CREATE TABLE t1 (f1 time default NULL, f2 time default NULL) TYPE=MyISAM;
CREATE TABLE t1 (f1 time default NULL, f2 time default NULL);
INSERT INTO t1 (f1, f2) VALUES ('09:00', '12:00');
SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1;
DATE_FORMAT(f1, "%l.%i %p") DATE_FORMAT(f2, "%l.%i %p")
......
......@@ -449,7 +449,7 @@ SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a_dec` decimal(12,11) default NULL
) TYPE=MyISAM
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
create table t1(a decimal(7,3));
insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000000001'),('10'),('+10'),('-10'),('0000000010'),('+0000000010'),('-0000000010'),('100'),('+100'),('-100'),('0000000100'),('+0000000100'),('-0000000100'),('1000'),('+1000'),('-1000'),('0000001000'),('+0000001000'),('-0000001000'),('10000'),('+10000'),('-10000'),('0000010000'),('+0000010000'),('-0000010000'),('100000'),('+100000'),('-100000'),('0000100000'),('+0000100000'),('-0000100000'),('1000000'),('+1000000'),('-1000000'),('0001000000'),('+0001000000'),('-0001000000'),('10000000'),('+10000000'),('-10000000'),('0010000000'),('+0010000000'),('-0010000000'),('100000000'),('+100000000'),('-100000000'),('0100000000'),('+0100000000'),('-0100000000'),('1000000000'),('+1000000000'),('-1000000000'),('1000000000'),('+1000000000'),('-1000000000');
......
......@@ -255,8 +255,6 @@ select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1;
select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1;
select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1;
select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
# The following is not as one would expect...
select date_add(time,INTERVAL 1 SECOND) from t1;
drop table t1;
......
......@@ -22,7 +22,7 @@ connection slave;
sync_with_master;
select get_lock("lock",3);
select * from t1;
select is_free_lock("lock"), is_used_lock("lock");
select is_free_lock("lock"), is_used_lock("lock") = connection_id();
explain extended select is_free_lock("lock"), is_used_lock("lock");
# Check lock functions
select is_free_lock("lock2");
......
......@@ -81,9 +81,10 @@ SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.
drop table t1,t2;
#
# Bug 4036
# Multiple SELECT DATE_FORMAT gave incorrect results (Bug #4036)
#
CREATE TABLE t1 (f1 time default NULL, f2 time default NULL) TYPE=MyISAM;
CREATE TABLE t1 (f1 time default NULL, f2 time default NULL);
INSERT INTO t1 (f1, f2) VALUES ('09:00', '12:00');
SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1;
DROP TABLE t1;
This diff is collapsed.
......@@ -1732,7 +1732,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, tmp_errno);
goto error;
}
memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
memcpy(&sock_addr.sin_addr, hp->h_addr,
min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
my_gethostbyname_r_free();
}
sock_addr.sin_port = (ushort) htons((ushort) port);
......
......@@ -3395,10 +3395,21 @@ String *Field_time::val_str(String *val_buffer,
}
bool Field_time::get_date(TIME *ltime,
bool fuzzydate __attribute__((unused)))
/*
Normally we would not consider 'time' as a vaild date, but we allow
get_date() here to be able to do things like
DATE_FORMAT(time, "%l.%i %p")
*/
bool Field_time::get_date(TIME *ltime, uint fuzzydate)
{
long tmp=(long) sint3korr(ptr);
long tmp;
if (!fuzzydate)
{
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE);
return 1;
}
tmp=(long) sint3korr(ptr);
ltime->neg=0;
if (tmp < 0)
{
......
......@@ -800,7 +800,7 @@ class Field_time :public Field_str {
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
bool get_date(TIME *ltime,bool fuzzydate);
bool get_date(TIME *ltime, uint fuzzydate);
bool send_binary(Protocol *protocol);
bool get_time(TIME *ltime);
int cmp(const char *,const char*);
......
......@@ -284,7 +284,9 @@ my_net_write(NET *net,const char *packet,ulong len)
buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
return 1;
#ifndef DEBUG_DATA_PACKETS
DBUG_DUMP("packet_header",(char*) buff,NET_HEADER_SIZE);
#endif
return test(net_write_buff(net,packet,len));
}
......@@ -394,6 +396,9 @@ net_write_buff(NET *net,const char *packet,ulong len)
else
left_length= (ulong) (net->buff_end - net->write_pos);
#ifdef DEBUG_DATA_PACKETS
DBUG_DUMP("data", packet, len);
#endif
if (len > left_length)
{
if (net->write_pos != net->buff)
......@@ -776,6 +781,8 @@ my_real_read(NET *net, ulong *complen)
if (i == 0)
{ /* First parts is packet length */
ulong helping;
DBUG_DUMP("packet_header",(char*) net->buff+net->where_b,
NET_HEADER_SIZE);
if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr)
{
if (net->buff[net->where_b] != (uchar) 255)
......@@ -784,7 +791,6 @@ my_real_read(NET *net, ulong *complen)
("Packets out of order (Found: %d, expected %u)",
(int) net->buff[net->where_b + 3],
net->pkt_nr));
DBUG_DUMP("packet_header",(char*) net->buff+net->where_b, 4);
#ifdef EXTRA_DEBUG
fprintf(stderr,"Packets out of order (Found: %d, expected %d)\n",
(int) net->buff[net->where_b + 3],
......@@ -841,6 +847,10 @@ my_real_read(NET *net, ulong *complen)
vio_blocking(net->vio, net_blocking, &old_mode);
}
net->reading_or_writing=0;
#ifdef DEBUG_DATA_PACKETS
if (len != packet_error)
DBUG_DUMP("data",(char*) net->buff+net->where_b, len);
#endif
return(len);
}
......
......@@ -162,7 +162,8 @@ THD::THD():user_time(0), current_statement(0), is_fatal_error(0),
{
host= user= priv_user= db= ip=0;
host_or_ip= "connecting host";
locked=killed=some_tables_deleted=no_errors=password= 0;
locked=some_tables_deleted=no_errors=password= 0;
killed=0;
query_start_used= 0;
count_cuted_fields= CHECK_FIELD_IGNORE;
db_length= col_access= 0;
......
......@@ -1134,7 +1134,7 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo,
char fill[IO_SIZE];
#if SIZEOF_OFF_T > 4
/* Fix this in MySQL 4.0; The current limit is 4G rows (QQ) */
/* Fix this when we have new .frm files; Current limit is 4G rows (QQ) */
if (create_info->max_rows > ~(ulong) 0)
create_info->max_rows= ~(ulong) 0;
if (create_info->min_rows > ~(ulong) 0)
......
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