Commit b5dfd056 authored by unknown's avatar unknown

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)


client/mysqltest.c:
  Added MAX_VAR_NAME which was lost in merge
  Added more debugging
  Fixed bug in 'eval'
innobase/data/data0type.c:
  After merge fix
innobase/fil/fil0fil.c:
  After merge fix
innobase/log/log0recv.c:
  After merge fix
myisam/mi_unique.c:
  Better checksum handling
mysql-test/r/func_time.result:
  Return NULL if a time argument is given to date_add()
mysql-test/r/rpl_free_items.result:
  After merge fix
mysql-test/r/rpl_get_lock.result:
  Test was depending on when server was restarted.
mysql-test/r/type_date.result:
  After merge fix
mysql-test/r/type_decimal.result:
  After merge fix
mysql-test/t/func_time.test:
  Removed comment that is not needed anymore
  (After Dimitri's timezone patch is pushed, we should get a warning for the date_add(time...) entry)
mysql-test/t/rpl_get_lock.test:
  Test was depending on when server was restarted.
mysql-test/t/type_date.test:
  Addded missing explanation for bug
netware/mysqld_safe.c:
  Removed end \r
  Run program through indent-ex to get MySQL indentation
sql-common/client.c:
  After merge fix
sql/field.cc:
  Fixed that get_date(time) gives a warning
sql/field.h:
  After merge fix
sql/net_serv.cc:
  More debugging (if DEBUG_DATA_PACKETS is set)
sql/sql_class.cc:
  Removed compiler warning
sql/table.cc:
  Better comment
parent 2b9a8afa
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include <violite.h> #include <violite.h>
#define MAX_QUERY 131072 #define MAX_QUERY 131072
#define MAX_VAR_NAME 256
#define MAX_COLUMNS 256 #define MAX_COLUMNS 256
#define PAD_SIZE 128 #define PAD_SIZE 128
#define MAX_CONS 128 #define MAX_CONS 128
...@@ -386,6 +387,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query) ...@@ -386,6 +387,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
register char c; register char c;
register int escaped = 0; register int escaped = 0;
VAR* v; VAR* v;
DBUG_ENTER("do_eval");
for (p= query; (c = *p); ++p) for (p= query; (c = *p); ++p)
{ {
...@@ -417,6 +419,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query) ...@@ -417,6 +419,7 @@ static void do_eval(DYNAMIC_STRING* query_eval, const char* query)
break; break;
} }
} }
DBUG_VOID_RETURN;
} }
...@@ -1739,6 +1742,7 @@ int read_line(char* buf, int size) ...@@ -1739,6 +1742,7 @@ int read_line(char* buf, int size)
enum {R_NORMAL, R_Q1, R_ESC_Q_Q1, R_ESC_Q_Q2, enum {R_NORMAL, R_Q1, R_ESC_Q_Q1, R_ESC_Q_Q2,
R_ESC_SLASH_Q1, R_ESC_SLASH_Q2, R_ESC_SLASH_Q1, R_ESC_SLASH_Q2,
R_Q2, R_COMMENT, R_LINE_START} state= R_LINE_START; R_Q2, R_COMMENT, R_LINE_START} state= R_LINE_START;
DBUG_ENTER("read_line");
start_lineno= *lineno; start_lineno= *lineno;
for (; p < buf_end ;) for (; p < buf_end ;)
...@@ -1752,7 +1756,7 @@ int read_line(char* buf, int size) ...@@ -1752,7 +1756,7 @@ int read_line(char* buf, int size)
cur_file--; cur_file--;
lineno--; lineno--;
if (cur_file == file_stack) if (cur_file == file_stack)
return 1; DBUG_RETURN(1);
continue; continue;
} }
...@@ -1762,7 +1766,7 @@ int read_line(char* buf, int size) ...@@ -1762,7 +1766,7 @@ int read_line(char* buf, int size)
if (end_of_query(c)) if (end_of_query(c))
{ {
*p= 0; *p= 0;
return 0; DBUG_RETURN(0);
} }
else if (c == '\'') else if (c == '\'')
state = R_Q1; state = R_Q1;
...@@ -1779,7 +1783,7 @@ int read_line(char* buf, int size) ...@@ -1779,7 +1783,7 @@ int read_line(char* buf, int size)
{ {
*p= 0; *p= 0;
(*lineno)++; (*lineno)++;
return 0; DBUG_RETURN(0);
} }
break; break;
case R_LINE_START: case R_LINE_START:
...@@ -1797,12 +1801,12 @@ int read_line(char* buf, int size) ...@@ -1797,12 +1801,12 @@ int read_line(char* buf, int size)
{ {
*buf++= '}'; *buf++= '}';
*buf= 0; *buf= 0;
return 0; DBUG_RETURN(0);
} }
else if (end_of_query(c) || c == '{') else if (end_of_query(c) || c == '{')
{ {
*p= 0; *p= 0;
return 0; DBUG_RETURN(0);
} }
else if (c == '\'') else if (c == '\'')
state= R_Q1; state= R_Q1;
...@@ -1822,7 +1826,7 @@ int read_line(char* buf, int size) ...@@ -1822,7 +1826,7 @@ int read_line(char* buf, int size)
if (end_of_query(c)) if (end_of_query(c))
{ {
*p= 0; *p= 0;
return 0; DBUG_RETURN(0);
} }
if (c != '\'') if (c != '\'')
state= R_NORMAL; state= R_NORMAL;
...@@ -1843,7 +1847,7 @@ int read_line(char* buf, int size) ...@@ -1843,7 +1847,7 @@ int read_line(char* buf, int size)
if (end_of_query(c)) if (end_of_query(c))
{ {
*p= 0; *p= 0;
return 0; DBUG_RETURN(0);
} }
if (c != '"') if (c != '"')
state= R_NORMAL; state= R_NORMAL;
...@@ -1859,7 +1863,7 @@ int read_line(char* buf, int size) ...@@ -1859,7 +1863,7 @@ int read_line(char* buf, int size)
*p++= c; *p++= c;
} }
*p= 0; /* Always end with \0 */ *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) ...@@ -1894,8 +1898,11 @@ int read_query(struct st_query** q_ptr)
q->type = Q_UNKNOWN; q->type = Q_UNKNOWN;
q->query_buf= q->query= 0; q->query_buf= q->query= 0;
if (read_line(read_query_buf, sizeof(read_query_buf))) if (read_line(read_query_buf, sizeof(read_query_buf)))
{
DBUG_PRINT("warning",("too long query"));
DBUG_RETURN(1); DBUG_RETURN(1);
}
DBUG_PRINT("info", ("query: %s", read_query_buf));
if (*p == '#') if (*p == '#')
{ {
q->type = Q_COMMENT; q->type = Q_COMMENT;
...@@ -2261,6 +2268,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) ...@@ -2261,6 +2268,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags)
char* query; char* query;
int query_len, got_error_on_send= 0; int query_len, got_error_on_send= 0;
DBUG_ENTER("run_query"); DBUG_ENTER("run_query");
DBUG_PRINT("enter",("flags: %d", flags));
if (q->type != Q_EVAL) if (q->type != Q_EVAL)
{ {
...@@ -2728,7 +2736,10 @@ int main(int argc, char **argv) ...@@ -2728,7 +2736,10 @@ int main(int argc, char **argv)
case Q_EVAL_RESULT: eval_result = 1; break; case Q_EVAL_RESULT: eval_result = 1; break;
case Q_EVAL: case Q_EVAL:
if (q->query == q->query_buf) if (q->query == q->query_buf)
{
q->query= q->first_argument; q->query= q->first_argument;
q->first_word_len= 0;
}
/* fall through */ /* fall through */
case Q_QUERY_VERTICAL: case Q_QUERY_VERTICAL:
case Q_QUERY_HORIZONTAL: case Q_QUERY_HORIZONTAL:
...@@ -2738,13 +2749,16 @@ int main(int argc, char **argv) ...@@ -2738,13 +2749,16 @@ int main(int argc, char **argv)
{ {
/* This happens when we use 'query_..' on it's own line */ /* This happens when we use 'query_..' on it's own line */
q_send_flag=1; q_send_flag=1;
DBUG_PRINT("info",
("query: '%s' first_word_len: %d send_flag=1",
q->query, q->first_word_len));
break; break;
} }
/* fix up query pointer if this is * first iteration for this line */ /* fix up query pointer if this is * first iteration for this line */
if (q->query == q->query_buf) if (q->query == q->query_buf)
q->query += q->first_word_len + 1; q->query += q->first_word_len + 1;
display_result_vertically= (q->type==Q_QUERY_VERTICAL); 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; display_result_vertically= old_display_result_vertically;
break; break;
} }
......
...@@ -104,7 +104,6 @@ dtype_form_prtype( ...@@ -104,7 +104,6 @@ dtype_form_prtype(
return(old_prtype + (charset_coll << 16)); return(old_prtype + (charset_coll << 16));
} }
#ifdef UNIV_DEBUG
/************************************************************************* /*************************************************************************
Validates a data type structure. */ Validates a data type structure. */
......
...@@ -2825,8 +2825,7 @@ fil_load_single_table_tablespaces(void) ...@@ -2825,8 +2825,7 @@ fil_load_single_table_tablespaces(void)
if (!dbpath) { if (!dbpath) {
dbpath = mem_alloc(dbpath_len); dbpath = mem_alloc(dbpath_len);
} else { } else {
dbpath = mem_realloc(dbpath, dbpath_len, dbpath = ut_realloc(dbpath, dbpath_len);
__FILE__, __LINE__);
} }
} }
sprintf(dbpath, "%s/%s", fil_path_to_mysql_datadir, sprintf(dbpath, "%s/%s", fil_path_to_mysql_datadir,
......
...@@ -1513,7 +1513,6 @@ skip_this_recv_addr: ...@@ -1513,7 +1513,6 @@ skip_this_recv_addr:
recv_sys_empty_hash(); recv_sys_empty_hash();
} }
#endif /* UNIV_HOTBACKUP */
#ifdef notdefined #ifdef notdefined
/*********************************************************************** /***********************************************************************
......
...@@ -70,7 +70,7 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) ...@@ -70,7 +70,7 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record)
{ {
const byte *pos, *end; const byte *pos, *end;
ha_checksum crc= 0; ha_checksum crc= 0;
ulong seed= 4; ulong seed1=0, seed2= 4;
HA_KEYSEG *keyseg; HA_KEYSEG *keyseg;
for (keyseg=def->seg ; keyseg < def->end ; keyseg++) for (keyseg=def->seg ; keyseg < def->end ; keyseg++)
...@@ -109,11 +109,10 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) ...@@ -109,11 +109,10 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record)
end= pos+length; end= pos+length;
if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT) if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT)
{ {
ulong tmp= 0;
keyseg->charset->coll->hash_sort(keyseg->charset, keyseg->charset->coll->hash_sort(keyseg->charset,
(const uchar*) pos, length, &tmp, (const uchar*) pos, length, &seed1,
&seed); &seed2);
crc^= tmp; crc^= seed1;
} }
else else
while (pos != end) while (pos != end)
......
...@@ -528,7 +528,7 @@ date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) ...@@ -528,7 +528,7 @@ date_add(date,INTERVAL "1 1:1:1" DAY_SECOND)
2003-01-03 01:01:01 2003-01-03 01:01:01
select date_add(time,INTERVAL 1 SECOND) from t1; select date_add(time,INTERVAL 1 SECOND) from t1;
date_add(time,INTERVAL 1 SECOND) date_add(time,INTERVAL 1 SECOND)
2006-07-08 00:00:01 NULL
drop table t1; drop table t1;
select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2, 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, 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; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master; reset master;
reset slave; reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
slave start; start slave;
create table t1 (a int); create table t1 (a int);
create table t2 (a int); create table t2 (a int);
drop table t1; drop table t1;
......
...@@ -18,9 +18,9 @@ get_lock("lock",3) ...@@ -18,9 +18,9 @@ get_lock("lock",3)
select * from t1; select * from t1;
n n
1 1
select is_free_lock("lock"), is_used_lock("lock"); select is_free_lock("lock"), is_used_lock("lock") = connection_id();
is_free_lock("lock") is_used_lock("lock") is_free_lock("lock") is_used_lock("lock") = connection_id()
0 6 0 1
explain extended select is_free_lock("lock"), is_used_lock("lock"); explain extended select is_free_lock("lock"), is_used_lock("lock");
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used 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. ...@@ -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)) 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 Wed, 06 March 2002 10:11:12 GMT-0800 Wed, 06 March 2002 10:11:12 GMT-0800
drop table t1,t2; 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'); 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; 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") DATE_FORMAT(f1, "%l.%i %p") DATE_FORMAT(f2, "%l.%i %p")
......
...@@ -449,7 +449,7 @@ SHOW CREATE TABLE t1; ...@@ -449,7 +449,7 @@ SHOW CREATE TABLE t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
`a_dec` decimal(12,11) default NULL `a_dec` decimal(12,11) default NULL
) TYPE=MyISAM ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
create table t1(a decimal(7,3)); 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'); 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; ...@@ -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" HOUR_SECOND) from t1;
select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) 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; 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; select date_add(time,INTERVAL 1 SECOND) from t1;
drop table t1; drop table t1;
......
...@@ -22,7 +22,7 @@ connection slave; ...@@ -22,7 +22,7 @@ connection slave;
sync_with_master; sync_with_master;
select get_lock("lock",3); select get_lock("lock",3);
select * from t1; 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"); explain extended select is_free_lock("lock"), is_used_lock("lock");
# Check lock functions # Check lock functions
select is_free_lock("lock2"); 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. ...@@ -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; 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'); 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; SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1;
DROP TABLE t1; DROP TABLE t1;
/* /*
Copyright (c) 2003 Novell, Inc. All Rights Reserved. Copyright (c) 2003 Novell, Inc. All Rights Reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
/****************************************************************************** /******************************************************************************
global variables global variables
******************************************************************************/ ******************************************************************************/
char autoclose; char autoclose;
char basedir[PATH_MAX]; char basedir[PATH_MAX];
...@@ -47,38 +47,38 @@ char mysqld[PATH_MAX]; ...@@ -47,38 +47,38 @@ char mysqld[PATH_MAX];
char hostname[PATH_MAX]; char hostname[PATH_MAX];
char default_option[PATH_MAX]; char default_option[PATH_MAX];
FILE *log_fd = NULL; FILE *log_fd= NULL;
/****************************************************************************** /******************************************************************************
prototypes prototypes
******************************************************************************/ ******************************************************************************/
void usage(void); void usage(void);
void vlog(char *, va_list); void vlog(char *, va_list);
void log(char *, ...); void log(char *, ...);
void start_defaults(int, char*[]); void start_defaults(int, char *[]);
void finish_defaults(); void finish_defaults();
void read_defaults(arg_list_t *); void read_defaults(arg_list_t *);
void parse_args(int, char*[]); void parse_args(int, char *[]);
void get_options(int, char*[]); void get_options(int, char *[]);
void check_data_vol(); void check_data_vol();
void check_setup(); void check_setup();
void check_tables(); void check_tables();
void mysql_start(int, char*[]); void mysql_start(int, char *[]);
void parse_setvar(char *arg); void parse_setvar(char *arg);
/****************************************************************************** /******************************************************************************
functions functions
******************************************************************************/ ******************************************************************************/
/****************************************************************************** /******************************************************************************
usage() usage()
Show usage. Show usage.
******************************************************************************/ ******************************************************************************/
...@@ -86,7 +86,7 @@ void usage(void) ...@@ -86,7 +86,7 @@ void usage(void)
{ {
// keep the screen up // keep the screen up
setscreenmode(SCR_NO_MODE); setscreenmode(SCR_NO_MODE);
puts("\ puts("\
\n\ \n\
usage: mysqld_safe [options]\n\ usage: mysqld_safe [options]\n\
...@@ -107,14 +107,14 @@ options:\n\ ...@@ -107,14 +107,14 @@ options:\n\
--mysqld=<file> Use the <file> MySQL daemon.\n\ --mysqld=<file> Use the <file> MySQL daemon.\n\
\n\ \n\
"); ");
exit(-1); exit(-1);
} }
/****************************************************************************** /******************************************************************************
vlog() vlog()
Log the message. Log the message.
******************************************************************************/ ******************************************************************************/
...@@ -122,7 +122,7 @@ void vlog(char *format, va_list ap) ...@@ -122,7 +122,7 @@ void vlog(char *format, va_list ap)
{ {
vfprintf(stdout, format, ap); vfprintf(stdout, format, ap);
fflush(stdout); fflush(stdout);
if (log_fd) if (log_fd)
{ {
vfprintf(log_fd, format, ap); vfprintf(log_fd, format, ap);
...@@ -133,25 +133,25 @@ void vlog(char *format, va_list ap) ...@@ -133,25 +133,25 @@ void vlog(char *format, va_list ap)
/****************************************************************************** /******************************************************************************
log() log()
Log the message. Log the message.
******************************************************************************/ ******************************************************************************/
void log(char *format, ...) void log(char *format, ...)
{ {
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
vlog(format, ap); vlog(format, ap);
va_end(ap); va_end(ap);
} }
/****************************************************************************** /******************************************************************************
start_defaults() start_defaults()
Start setting the defaults. Start setting the defaults.
******************************************************************************/ ******************************************************************************/
...@@ -159,30 +159,30 @@ void start_defaults(int argc, char *argv[]) ...@@ -159,30 +159,30 @@ void start_defaults(int argc, char *argv[])
{ {
struct stat buf; struct stat buf;
int i; int i;
// default options // default options
static char *default_options[] = static char *default_options[]=
{ {
"--no-defaults", "--no-defaults",
"--defaults-file=", "--defaults-file=",
"--defaults-extra-file=", "--defaults-extra-file=",
NULL NULL
}; };
// autoclose // autoclose
autoclose = FALSE; autoclose= FALSE;
// basedir // basedir
get_basedir(argv[0], basedir); get_basedir(argv[0], basedir);
// check-tables // check-tables
checktables = FALSE; checktables= FALSE;
// hostname // hostname
if (gethostname(hostname,PATH_MAX) < 0) if (gethostname(hostname, PATH_MAX) < 0)
{ {
// default // default
strcpy(hostname,"mysql"); strcpy(hostname, "mysql");
} }
// address // address
...@@ -190,30 +190,30 @@ void start_defaults(int argc, char *argv[]) ...@@ -190,30 +190,30 @@ void start_defaults(int argc, char *argv[])
// port // port
snprintf(port, PATH_MAX, "3306"); snprintf(port, PATH_MAX, "3306");
// default option // default option
default_option[0] = NULL; default_option[0]= NULL;
for (i=0; (argc > 1) && default_options[i]; i++) for (i= 0; (argc > 1) && default_options[i]; i++)
{ {
if(!strnicmp(argv[1], default_options[i], strlen(default_options[i]))) if (!strnicmp(argv[1], default_options[i], strlen(default_options[i])))
{ {
strncpy(default_option, argv[1], PATH_MAX); strncpy(default_option, argv[1], PATH_MAX);
break; break;
} }
} }
// set after basedir is established // set after basedir is established
datadir[0] = NULL; datadir[0]= NULL;
pid_file[0] = NULL; pid_file[0]= NULL;
err_log[0] = NULL; err_log[0]= NULL;
safe_log[0] = NULL; safe_log[0]= NULL;
mysqld[0] = NULL; mysqld[0]= NULL;
} }
/****************************************************************************** /******************************************************************************
finish_defaults() finish_defaults()
Finish settig the defaults. Finish settig the defaults.
******************************************************************************/ ******************************************************************************/
...@@ -221,22 +221,27 @@ void finish_defaults() ...@@ -221,22 +221,27 @@ void finish_defaults()
{ {
struct stat buf; struct stat buf;
int i; int i;
// datadir // datadir
if (!datadir[0]) snprintf(datadir, PATH_MAX, "%s/data", basedir); if (!datadir[0])
snprintf(datadir, PATH_MAX, "%s/data", basedir);
// pid-file // pid-file
if (!pid_file[0]) snprintf(pid_file, PATH_MAX, "%s/%s.pid", datadir, hostname); if (!pid_file[0])
snprintf(pid_file, PATH_MAX, "%s/%s.pid", datadir, hostname);
// err-log // err-log
if (!err_log[0]) snprintf(err_log, PATH_MAX, "%s/%s.err", datadir, hostname); if (!err_log[0])
snprintf(err_log, PATH_MAX, "%s/%s.err", datadir, hostname);
// safe-log // safe-log
if (!safe_log[0]) snprintf(safe_log, PATH_MAX, "%s/%s.safe", datadir, hostname); if (!safe_log[0])
snprintf(safe_log, PATH_MAX, "%s/%s.safe", datadir, hostname);
// mysqld // mysqld
if (!mysqld[0]) snprintf(mysqld, PATH_MAX, "%s/bin/mysqld-max", basedir); if (!mysqld[0])
snprintf(mysqld, PATH_MAX, "%s/bin/mysqld-max", basedir);
if (stat(mysqld, &buf)) if (stat(mysqld, &buf))
{ {
snprintf(mysqld, PATH_MAX, "%s/bin/mysqld", basedir); snprintf(mysqld, PATH_MAX, "%s/bin/mysqld", basedir);
...@@ -246,7 +251,7 @@ void finish_defaults() ...@@ -246,7 +251,7 @@ void finish_defaults()
/****************************************************************************** /******************************************************************************
read_defaults() read_defaults()
Read the defaults. Read the defaults.
******************************************************************************/ ******************************************************************************/
...@@ -257,64 +262,66 @@ void read_defaults(arg_list_t *pal) ...@@ -257,64 +262,66 @@ void read_defaults(arg_list_t *pal)
char mydefaults[PATH_MAX]; char mydefaults[PATH_MAX];
char line[PATH_MAX]; char line[PATH_MAX];
FILE *fp; FILE *fp;
// defaults output file
snprintf(defaults_file, PATH_MAX, "%s/bin/defaults.out", basedir);
remove(defaults_file);
// mysqladmin file // defaults output file
snprintf(defaults_file, PATH_MAX, "%s/bin/defaults.out", basedir);
remove(defaults_file);
// mysqladmin file
snprintf(mydefaults, PATH_MAX, "%s/bin/my_print_defaults", basedir); snprintf(mydefaults, PATH_MAX, "%s/bin/my_print_defaults", basedir);
// args // args
init_args(&al); init_args(&al);
add_arg(&al, mydefaults); add_arg(&al, mydefaults);
if (default_option[0]) add_arg(&al, default_option); if (default_option[0])
add_arg(&al, default_option);
add_arg(&al, "mysqld"); add_arg(&al, "mysqld");
add_arg(&al, "server"); add_arg(&al, "server");
add_arg(&al, "mysqld_safe"); add_arg(&al, "mysqld_safe");
add_arg(&al, "safe_mysqld"); add_arg(&al, "safe_mysqld");
spawn(mydefaults, &al, TRUE, NULL, defaults_file, NULL); spawn(mydefaults, &al, TRUE, NULL, defaults_file, NULL);
free_args(&al); free_args(&al);
// gather defaults // gather defaults
if((fp = fopen(defaults_file, "r")) != NULL) if ((fp= fopen(defaults_file, "r")) != NULL)
{ {
while(fgets(line, PATH_MAX, fp)) while (fgets(line, PATH_MAX, fp))
{ {
char *p; char *p;
// remove end-of-line character // remove end-of-line character
if ((p = strrchr(line, '\n')) != NULL) *p = '\0'; if ((p= strrchr(line, '\n')) != NULL)
*p= '\0';
// add the option as an argument // add the option as an argument
add_arg(pal, line); add_arg(pal, line);
} }
fclose(fp); fclose(fp);
} }
// remove file // remove file
remove(defaults_file); remove(defaults_file);
} }
/****************************************************************************** /******************************************************************************
parse_args() parse_args()
Get the options. Get the options.
******************************************************************************/ ******************************************************************************/
void parse_args(int argc, char *argv[]) void parse_args(int argc, char *argv[])
{ {
int index = 0; int index= 0;
int c; int c;
// parse options // parse options
enum opts enum opts
{ {
OPT_BASEDIR = 0xFF, OPT_BASEDIR= 0xFF,
OPT_DATADIR, OPT_DATADIR,
OPT_PID_FILE, OPT_PID_FILE,
OPT_BIND_ADDRESS, OPT_BIND_ADDRESS,
...@@ -325,65 +332,64 @@ void parse_args(int argc, char *argv[]) ...@@ -325,65 +332,64 @@ void parse_args(int argc, char *argv[])
OPT_HELP, OPT_HELP,
OPT_SETVAR OPT_SETVAR
}; };
static struct option options[] = static struct option options[]=
{ {
{"autoclose", no_argument, &autoclose, TRUE}, {"autoclose", no_argument, &autoclose, TRUE},
{"basedir", required_argument, 0, OPT_BASEDIR}, {"basedir", required_argument, 0, OPT_BASEDIR},
{"check-tables", no_argument, &checktables, TRUE}, {"check-tables", no_argument, &checktables, TRUE},
{"datadir", required_argument, 0, OPT_DATADIR}, {"datadir", required_argument, 0, OPT_DATADIR},
{"pid-file", required_argument, 0, OPT_PID_FILE}, {"pid-file", required_argument, 0, OPT_PID_FILE},
{"bind-address", required_argument, 0, OPT_BIND_ADDRESS}, {"bind-address", required_argument, 0, OPT_BIND_ADDRESS},
{"port", required_argument, 0, OPT_PORT}, {"port", required_argument, 0, OPT_PORT},
{"err-log", required_argument, 0, OPT_ERR_LOG}, {"err-log", required_argument, 0, OPT_ERR_LOG},
{"safe-log", required_argument, 0, OPT_SAFE_LOG}, {"safe-log", required_argument, 0, OPT_SAFE_LOG},
{"mysqld", required_argument, 0, OPT_MYSQLD}, {"mysqld", required_argument, 0, OPT_MYSQLD},
{"help", no_argument, 0, OPT_HELP}, {"help", no_argument, 0, OPT_HELP},
{"set-variable", required_argument, 0, OPT_SETVAR}, {"set-variable", required_argument, 0, OPT_SETVAR},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
// we have to reset getopt_long because we use it multiple times // we have to reset getopt_long because we use it multiple times
optind = 1; optind= 1;
// turn off error reporting // turn off error reporting
opterr = 0; opterr= 0;
while ((c = getopt_long(argc, argv, "b:h:P:", options, &index)) >= 0) while ((c= getopt_long(argc, argv, "b:h:P:", options, &index)) >= 0)
{ {
switch (c) switch (c) {
{
case OPT_BASEDIR: case OPT_BASEDIR:
case 'b': case 'b':
strcpy(basedir, optarg); strcpy(basedir, optarg);
break; break;
case OPT_DATADIR: case OPT_DATADIR:
case 'h': case 'h':
strcpy(datadir, optarg); strcpy(datadir, optarg);
break; break;
case OPT_PID_FILE: case OPT_PID_FILE:
strcpy(pid_file, optarg); strcpy(pid_file, optarg);
break; break;
case OPT_BIND_ADDRESS: case OPT_BIND_ADDRESS:
strcpy(address, optarg); strcpy(address, optarg);
break; break;
case OPT_PORT: case OPT_PORT:
case 'P': case 'P':
strcpy(port, optarg); strcpy(port, optarg);
break; break;
case OPT_ERR_LOG: case OPT_ERR_LOG:
strcpy(err_log, optarg); strcpy(err_log, optarg);
break; break;
case OPT_SAFE_LOG: case OPT_SAFE_LOG:
strcpy(safe_log, optarg); strcpy(safe_log, optarg);
break; break;
case OPT_MYSQLD: case OPT_MYSQLD:
strcpy(mysqld, optarg); strcpy(mysqld, optarg);
break; break;
...@@ -391,11 +397,11 @@ void parse_args(int argc, char *argv[]) ...@@ -391,11 +397,11 @@ void parse_args(int argc, char *argv[])
case OPT_SETVAR: case OPT_SETVAR:
parse_setvar(optarg); parse_setvar(optarg);
break; break;
case OPT_HELP: case OPT_HELP:
usage(); usage();
break; break;
default: default:
// ignore // ignore
break; break;
...@@ -410,14 +416,15 @@ void parse_args(int argc, char *argv[]) ...@@ -410,14 +416,15 @@ void parse_args(int argc, char *argv[])
void parse_setvar(char *arg) void parse_setvar(char *arg)
{ {
char *pos; char *pos;
if ((pos= strindex(arg, "port"))) if ((pos= strindex(arg, "port")))
{ {
for (; *pos && *pos != '='; pos++) ; for (; *pos && *pos != '='; pos++);
if (*pos) if (*pos)
strcpy(port, pos + 1); strcpy(port, pos + 1);
} }
} }
/****************************************************************************** /******************************************************************************
...@@ -425,14 +432,14 @@ void parse_setvar(char *arg) ...@@ -425,14 +432,14 @@ void parse_setvar(char *arg)
/****************************************************************************** /******************************************************************************
get_options() get_options()
Get the options. Get the options.
******************************************************************************/ ******************************************************************************/
void get_options(int argc, char *argv[]) void get_options(int argc, char *argv[])
{ {
arg_list_t al; arg_list_t al;
// start defaults // start defaults
start_defaults(argc, argv); start_defaults(argc, argv);
...@@ -442,10 +449,10 @@ void get_options(int argc, char *argv[]) ...@@ -442,10 +449,10 @@ void get_options(int argc, char *argv[])
read_defaults(&al); read_defaults(&al);
parse_args(al.argc, al.argv); parse_args(al.argc, al.argv);
free_args(&al); free_args(&al);
// command-line arguments // command-line arguments
parse_args(argc, argv); parse_args(argc, argv);
// finish defaults // finish defaults
finish_defaults(); finish_defaults();
} }
...@@ -453,7 +460,7 @@ void get_options(int argc, char *argv[]) ...@@ -453,7 +460,7 @@ void get_options(int argc, char *argv[])
/****************************************************************************** /******************************************************************************
check_data_vol() check_data_vol()
Check the database volume. Check the database volume.
******************************************************************************/ ******************************************************************************/
...@@ -463,23 +470,23 @@ void check_data_vol() ...@@ -463,23 +470,23 @@ void check_data_vol()
struct volume_info vol; struct volume_info vol;
char buff[PATH_MAX]; char buff[PATH_MAX];
char *p; char *p;
// clear struct // clear struct
memset(&vol, 0, sizeof(vol)); memset(&vol, 0, sizeof(vol));
// find volume name // find volume name
strcpy(buff, datadir); strcpy(buff, datadir);
if (p = strchr(buff, ':')) if (p= strchr(buff, ':'))
{ {
// terminate after volume name // terminate after volume name
*p = 0; *p= 0;
} }
else else
{ {
// assume SYS volume // assume SYS volume
strcpy(buff, "SYS"); strcpy(buff, "SYS");
} }
// retrieve information // retrieve information
netware_vol_info_from_name(&vol, buff); netware_vol_info_from_name(&vol, buff);
...@@ -493,25 +500,25 @@ void check_data_vol() ...@@ -493,25 +500,25 @@ void check_data_vol()
/****************************************************************************** /******************************************************************************
check_setup() check_setup()
Check the current setup. Check the current setup.
******************************************************************************/ ******************************************************************************/
void check_setup() void check_setup()
{ {
struct stat info; struct stat info;
char temp[PATH_MAX]; char temp[PATH_MAX];
// remove any current pid_file // remove any current pid_file
if (!stat(pid_file, &info) && (remove(pid_file) < 0)) if (!stat(pid_file, &info) && (remove(pid_file) < 0))
{ {
log("ERROR: Unable to remove current pid file!\n\n"); log("ERROR: Unable to remove current pid file!\n\n");
exit(-1); exit(-1);
} }
// check the data volume // check the data volume
check_data_vol(); check_data_vol();
// check for a database // check for a database
snprintf(temp, PATH_MAX, "%s/mysql/host.frm", datadir); snprintf(temp, PATH_MAX, "%s/mysql/host.frm", datadir);
if (stat(temp, &info)) if (stat(temp, &info))
...@@ -524,7 +531,7 @@ void check_setup() ...@@ -524,7 +531,7 @@ void check_setup()
/****************************************************************************** /******************************************************************************
check_tables() check_tables()
Check the database tables. Check the database tables.
******************************************************************************/ ******************************************************************************/
...@@ -532,21 +539,21 @@ void check_tables() ...@@ -532,21 +539,21 @@ void check_tables()
{ {
arg_list_t al; arg_list_t al;
char mycheck[PATH_MAX]; char mycheck[PATH_MAX];
char table[PATH_MAX]; char table[PATH_MAX];
char db[PATH_MAX]; char db[PATH_MAX];
DIR *datadir_entry, *db_entry, *table_entry; DIR *datadir_entry, *db_entry, *table_entry;
// status // status
log("checking tables...\n"); log("checking tables...\n");
// list databases // list databases
if ((datadir_entry = opendir(datadir)) == NULL) if ((datadir_entry= opendir(datadir)) == NULL)
{ {
return; return;
} }
while((db_entry = readdir(datadir_entry)) != NULL) while ((db_entry= readdir(datadir_entry)) != NULL)
{ {
if (db_entry->d_name[0] == '.') if (db_entry->d_name[0] == '.')
{ {
// Skip // Skip
...@@ -555,71 +562,71 @@ void check_tables() ...@@ -555,71 +562,71 @@ void check_tables()
{ {
// create long db name // create long db name
snprintf(db, PATH_MAX, "%s/%s", datadir, db_entry->d_name); snprintf(db, PATH_MAX, "%s/%s", datadir, db_entry->d_name);
// list tables // list tables
if ((db_entry = opendir(db)) == NULL) if ((db_entry= opendir(db)) == NULL)
{ {
continue; continue;
} }
while((table_entry = readdir(db_entry)) != NULL) while ((table_entry= readdir(db_entry)) != NULL)
{ {
// create long table name // create long table name
snprintf(table, PATH_MAX, "%s/%s", db, strlwr(table_entry->d_name)); snprintf(table, PATH_MAX, "%s/%s", db, strlwr(table_entry->d_name));
if (strindex(table, ".myi")) if (strindex(table, ".myi"))
{ {
// ** myisamchk // ** myisamchk
// mysqladmin file // mysqladmin file
snprintf(mycheck, PATH_MAX, "%s/bin/myisamchk", basedir); snprintf(mycheck, PATH_MAX, "%s/bin/myisamchk", basedir);
// args // args
init_args(&al); init_args(&al);
add_arg(&al, mycheck); add_arg(&al, mycheck);
add_arg(&al, "--silent"); add_arg(&al, "--silent");
add_arg(&al, "--force"); add_arg(&al, "--force");
add_arg(&al, "--fast"); add_arg(&al, "--fast");
add_arg(&al, "--medium-check"); add_arg(&al, "--medium-check");
add_arg(&al, "-O"); add_arg(&al, "-O");
add_arg(&al, "key_buffer=64M"); add_arg(&al, "key_buffer=64M");
add_arg(&al, "-O"); add_arg(&al, "-O");
add_arg(&al, "sort_buffer=64M"); add_arg(&al, "sort_buffer=64M");
add_arg(&al, table); add_arg(&al, table);
spawn(mycheck, &al, TRUE, NULL, NULL, NULL); spawn(mycheck, &al, TRUE, NULL, NULL, NULL);
free_args(&al); free_args(&al);
} }
else if (strindex(table, ".ism")) else if (strindex(table, ".ism"))
{ {
// ** isamchk // ** isamchk
// mysqladmin file // mysqladmin file
snprintf(mycheck, PATH_MAX, "%s/bin/isamchk", basedir); snprintf(mycheck, PATH_MAX, "%s/bin/isamchk", basedir);
// args // args
init_args(&al); init_args(&al);
add_arg(&al, mycheck); add_arg(&al, mycheck);
add_arg(&al, "--silent"); add_arg(&al, "--silent");
add_arg(&al, "--force"); add_arg(&al, "--force");
add_arg(&al, "-O"); add_arg(&al, "-O");
add_arg(&al, "sort_buffer=64M"); add_arg(&al, "sort_buffer=64M");
add_arg(&al, table); add_arg(&al, table);
spawn(mycheck, &al, TRUE, NULL, NULL, NULL); spawn(mycheck, &al, TRUE, NULL, NULL, NULL);
free_args(&al); free_args(&al);
} }
} }
} }
} }
} }
/****************************************************************************** /******************************************************************************
mysql_start() mysql_start()
Start the mysql server. Start the mysql server.
******************************************************************************/ ******************************************************************************/
...@@ -632,9 +639,9 @@ void mysql_start(int argc, char *argv[]) ...@@ -632,9 +639,9 @@ void mysql_start(int argc, char *argv[])
struct tm lt; struct tm lt;
char stamp[PATH_MAX]; char stamp[PATH_MAX];
char skip; char skip;
// private options // private options
static char *private_options[] = static char *private_options[]=
{ {
"--autoclose", "--autoclose",
"--check-tables", "--check-tables",
...@@ -643,56 +650,57 @@ void mysql_start(int argc, char *argv[]) ...@@ -643,56 +650,57 @@ void mysql_start(int argc, char *argv[])
"--mysqld=", "--mysqld=",
NULL NULL
}; };
// args // args
init_args(&al); init_args(&al);
add_arg(&al, "%s", mysqld); add_arg(&al, "%s", mysqld);
// parent args // parent args
for(i = 1; i < argc; i++) for (i= 1; i < argc; i++)
{ {
skip = FALSE; skip= FALSE;
// skip private arguments // skip private arguments
for (j=0; private_options[j]; j++) for (j= 0; private_options[j]; j++)
{ {
if(!strnicmp(argv[i], private_options[j], strlen(private_options[j]))) if (!strnicmp(argv[i], private_options[j], strlen(private_options[j])))
{ {
skip = TRUE; skip= TRUE;
consoleprintf("The argument skipped is %s\n",argv[i]); consoleprintf("The argument skipped is %s\n", argv[i]);
break; break;
} }
} }
if (!skip) if (!skip)
{ {
add_arg(&al, "%s", argv[i]); add_arg(&al, "%s", argv[i]);
consoleprintf("The final argument is %s\n",argv[i]); consoleprintf("The final argument is %s\n", argv[i]);
} }
} }
// spawn // spawn
do do
{ {
// check the database tables // check the database tables
if (checktables) check_tables(); if (checktables)
check_tables();
// status // status
time(&cal); time(&cal);
localtime_r(&cal, &lt); localtime_r(&cal, &lt);
strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", &lt); strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", &lt);
log("mysql started : %s\n", stamp); log("mysql started : %s\n", stamp);
// spawn mysqld // spawn mysqld
spawn(mysqld, &al, TRUE, NULL, NULL, err_log); spawn(mysqld, &al, TRUE, NULL, NULL, err_log);
} }
while (!stat(pid_file, &info)); while (!stat(pid_file, &info));
// status // status
time(&cal); time(&cal);
localtime_r(&cal, &lt); localtime_r(&cal, &lt);
strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", &lt); strftime(stamp, PATH_MAX, "%d %b %Y %H:%M:%S", &lt);
log("mysql stopped : %s\n\n", stamp); log("mysql stopped : %s\n\n", stamp);
// free args // free args
free_args(&al); free_args(&al);
} }
...@@ -700,43 +708,45 @@ void mysql_start(int argc, char *argv[]) ...@@ -700,43 +708,45 @@ void mysql_start(int argc, char *argv[])
/****************************************************************************** /******************************************************************************
main() main()
******************************************************************************/ ******************************************************************************/
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
char temp[PATH_MAX]; char temp[PATH_MAX];
// get the options // get the options
get_options(argc, argv); get_options(argc, argv);
// keep the screen up // keep the screen up
if (!autoclose) setscreenmode(SCR_NO_MODE); if (!autoclose)
setscreenmode(SCR_NO_MODE);
// create log file // create log file
log_fd = fopen(safe_log, "w+"); log_fd= fopen(safe_log, "w+");
// header // header
log("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE); log("MySQL Server %s, for %s (%s)\n\n", VERSION, SYSTEM_TYPE, MACHINE_TYPE);
// status // status
log("address : %s\n", address); log("address : %s\n", address);
log("port : %s\n", port); log("port : %s\n", port);
log("daemon : %s\n", mysqld); log("daemon : %s\n", mysqld);
log("base directory : %s\n", basedir); log("base directory : %s\n", basedir);
log("data directory : %s\n", datadir); log("data directory : %s\n", datadir);
log("pid file : %s\n", pid_file); log("pid file : %s\n", pid_file);
log("error file : %s\n", err_log); log("error file : %s\n", err_log);
log("log file : %s\n", safe_log); log("log file : %s\n", safe_log);
log("\n"); log("\n");
// check setup // check setup
check_setup(); check_setup();
// start the MySQL server // start the MySQL server
mysql_start(argc, argv); mysql_start(argc, argv);
// close log file // close log file
if (log_fd) fclose(log_fd); if (log_fd)
fclose(log_fd);
return 0; return 0;
} }
...@@ -1732,7 +1732,8 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, ...@@ -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); sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, tmp_errno);
goto error; 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(); my_gethostbyname_r_free();
} }
sock_addr.sin_port = (ushort) htons((ushort) port); sock_addr.sin_port = (ushort) htons((ushort) port);
......
...@@ -3395,10 +3395,21 @@ String *Field_time::val_str(String *val_buffer, ...@@ -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; ltime->neg=0;
if (tmp < 0) if (tmp < 0)
{ {
......
...@@ -800,7 +800,7 @@ public: ...@@ -800,7 +800,7 @@ public:
double val_real(void); double val_real(void);
longlong val_int(void); longlong val_int(void);
String *val_str(String*,String *); 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 send_binary(Protocol *protocol);
bool get_time(TIME *ltime); bool get_time(TIME *ltime);
int cmp(const char *,const char*); int cmp(const char *,const char*);
......
...@@ -284,7 +284,9 @@ my_net_write(NET *net,const char *packet,ulong len) ...@@ -284,7 +284,9 @@ my_net_write(NET *net,const char *packet,ulong len)
buff[3]= (uchar) net->pkt_nr++; buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE)) if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
return 1; return 1;
#ifndef DEBUG_DATA_PACKETS
DBUG_DUMP("packet_header",(char*) buff,NET_HEADER_SIZE); DBUG_DUMP("packet_header",(char*) buff,NET_HEADER_SIZE);
#endif
return test(net_write_buff(net,packet,len)); return test(net_write_buff(net,packet,len));
} }
...@@ -394,6 +396,9 @@ net_write_buff(NET *net,const char *packet,ulong len) ...@@ -394,6 +396,9 @@ net_write_buff(NET *net,const char *packet,ulong len)
else else
left_length= (ulong) (net->buff_end - net->write_pos); left_length= (ulong) (net->buff_end - net->write_pos);
#ifdef DEBUG_DATA_PACKETS
DBUG_DUMP("data", packet, len);
#endif
if (len > left_length) if (len > left_length)
{ {
if (net->write_pos != net->buff) if (net->write_pos != net->buff)
...@@ -776,6 +781,8 @@ my_real_read(NET *net, ulong *complen) ...@@ -776,6 +781,8 @@ my_real_read(NET *net, ulong *complen)
if (i == 0) if (i == 0)
{ /* First parts is packet length */ { /* First parts is packet length */
ulong helping; 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 + 3] != (uchar) net->pkt_nr)
{ {
if (net->buff[net->where_b] != (uchar) 255) if (net->buff[net->where_b] != (uchar) 255)
...@@ -784,7 +791,6 @@ my_real_read(NET *net, ulong *complen) ...@@ -784,7 +791,6 @@ my_real_read(NET *net, ulong *complen)
("Packets out of order (Found: %d, expected %u)", ("Packets out of order (Found: %d, expected %u)",
(int) net->buff[net->where_b + 3], (int) net->buff[net->where_b + 3],
net->pkt_nr)); net->pkt_nr));
DBUG_DUMP("packet_header",(char*) net->buff+net->where_b, 4);
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
fprintf(stderr,"Packets out of order (Found: %d, expected %d)\n", fprintf(stderr,"Packets out of order (Found: %d, expected %d)\n",
(int) net->buff[net->where_b + 3], (int) net->buff[net->where_b + 3],
...@@ -841,6 +847,10 @@ end: ...@@ -841,6 +847,10 @@ end:
vio_blocking(net->vio, net_blocking, &old_mode); vio_blocking(net->vio, net_blocking, &old_mode);
} }
net->reading_or_writing=0; 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); return(len);
} }
......
...@@ -162,7 +162,8 @@ THD::THD():user_time(0), current_statement(0), is_fatal_error(0), ...@@ -162,7 +162,8 @@ THD::THD():user_time(0), current_statement(0), is_fatal_error(0),
{ {
host= user= priv_user= db= ip=0; host= user= priv_user= db= ip=0;
host_or_ip= "connecting host"; 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; query_start_used= 0;
count_cuted_fields= CHECK_FIELD_IGNORE; count_cuted_fields= CHECK_FIELD_IGNORE;
db_length= col_access= 0; db_length= col_access= 0;
......
...@@ -1134,7 +1134,7 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo, ...@@ -1134,7 +1134,7 @@ File create_frm(register my_string name, uint reclength, uchar *fileinfo,
char fill[IO_SIZE]; char fill[IO_SIZE];
#if SIZEOF_OFF_T > 4 #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) if (create_info->max_rows > ~(ulong) 0)
create_info->max_rows= ~(ulong) 0; create_info->max_rows= ~(ulong) 0;
if (create_info->min_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