Commit d89690e6 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Portability fixes

Fix for consistent 0000-00-00 date handling
Close + open binary logs on flush tables
Fix for AVG() in HAVING.
parent c9e4b2aa
......@@ -35,7 +35,7 @@ AM_MAKEFLAGS="-j 4"
# -Wshadow -Wunused -Winline (The later isn't usable in C++ as
# __attribute()__ doesn't work with gnu C++)
global_warnings="-Wimplicit -Wreturn-type -Wid-clash-51 -Wswitch -Wtrigraphs -Wcomment -W -Wchar-subscripts -Wformat -Wimplicit-function-dec -Wimplicit-int -Wparentheses -Wsign-compare -Wwrite-strings"
debug_extra_warnings="-Wuninitialized"
#debug_extra_warnings="-Wuninitialized"
c_warnings="$global_warnings -Wunused"
cxx_warnings="$global_warnings -Woverloaded-virtual -Wextern-inline -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor"
......@@ -48,7 +48,7 @@ fast_cflags="-O3 -fno-omit-frame-pointer"
# this is one is for someone who thinks 1% speedup is worth not being
# able to backtrace
reckless_cflags="-O3 -fomit-frame-pointer "
debug_cflags="-DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMALLOC -DSAFE_MUTEX -O2"
debug_cflags="-DEXTRA_DEBUG -DFORCE_INIT_OF_VARS -DSAFEMALLOC -DSAFE_MUTEX -O0"
base_cxxflags="-felide-constructors -fno-exceptions -fno-rtti"
......
......@@ -22958,7 +22958,7 @@ By default, the @code{mysql.server} script starts the MySQL
server with the @code{-l} option. If you need better performance when
you start using MySQL in a production environment, you can
remove the @code{-l} option from @code{mysql.server} or change it to
@code{--log-binary}.
@code{--log-bin}.
The entries in this log are written as @code{mysqld} receives the questions.
This may be different than the order in which the statements are executed.
......@@ -23032,8 +23032,8 @@ and the crash.
@cindex binary log
@cindex files, binary log
In the future the binary log will replace the update log, so we
recommend you to switch to this log format as soon as possible!
The intention is that the binary log should replace the update log, so
we recommend you to switch to this log format as soon as possible!
The binary log contains all information that is available in the update
log in a more efficient format. It also contains information about how long
......@@ -23048,6 +23048,14 @@ file name is given, it defaults to the name of the host machine followed
by @code{-bin}. If file name is given, but it doesn't contain a path, the
file is written in the data directory.
If you supply an extension to @code{--log-bin=filename.extension}, the
extension will be silenty removed.
To the binary log filename @code{mysqld} will append an extension that is a
number that is incremented each time you execute @code{mysqladmin
refresh}, execute @code{mysqladmin flush-logs}, execute the @code{FLUSH LOGS}
statement or restart the server.
You can use the following options to @code{mysqld} to affect what is logged
to the binary log:
......@@ -23062,11 +23070,6 @@ Tells the master that updates to the given database should not be logged
to the binary log (Example: @code{binlog-ignore-db=some_database})
@end multitable
To the binary log filename @code{mysqld} will append an extension that is a
number that is incremented each time you execute @code{mysqladmin
refresh}, execute @code{mysqladmin flush-logs}, execute the @code{FLUSH LOGS}
statement or restart the server.
To be able to know which different binary log files have been used,
@code{mysqld} will also create a binary log index file that
contains the name of all used binary log files. By default this has the
......@@ -46840,6 +46843,11 @@ not yet 100% confident in this code.
@appendixsubsec Changes in release 3.23.44
@itemize @bullet
@item
Fixed bug when using a reference to a @code{AVG()} column in @code{HAVING}.
@item
Fixed that date functions that require correct dates, like
@code{DAYOFYEAR(column)} will return @code{NULL} for @code{0000-00-00} dates.
@item
Fixed bug in const-propagation when comparing columns of different
types. (@code{SELECT * FROM date_col="2001-01-01" and date_col=time_col})
@item
......@@ -52724,15 +52732,15 @@ Make a second backup of the tables.
Remove (or move away) any old log files from the MySQL data
directory if you need more space.
@item
Start @code{mysqld} with @code{--log-binary}. @xref{Binary log}.
Start @code{mysqld} with @code{--log-bin}. @xref{Binary log}.
If you want to find a query that crashes @code{mysqld}, you should use
@code{--log --log-binary}.
@code{--log --log-bin}.
@item
When you have gotten a crashed table, stop the @code{mysqld server}.
@item
Restore the backup.
@item
Restart the @code{mysqld} server @strong{without} @code{--log-binary}
Restart the @code{mysqld} server @strong{without} @code{--log-bin}
@item
Re-execute the commands with @code{mysqlbinlog update-log-file | mysql}.
The update log is saved in the MySQL database directory with
......@@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT(sql/mysqld.cc)
AC_CANONICAL_SYSTEM
# The Docs Makefile.am parses this line!
AM_INIT_AUTOMAKE(mysql, 3.23.43)
AM_INIT_AUTOMAKE(mysql, 3.23.44)
AM_CONFIG_HEADER(config.h)
PROTOCOL_VERSION=10
......
......@@ -10,6 +10,7 @@ Created 11/5/1995 Heikki Tuuri
#ifdef UNIV_NONINL
#include "buf0lru.ic"
#include "srv0srv.h" /* Needed to getsrv_print_innodb_monitor */
#endif
#include "ut0byte.h"
......
......@@ -200,3 +200,21 @@ month(updated)
NULL
year(updated)
NULL
dayofyear("0000-00-00") dayofyear(d) dayofyear(dt) dayofyear(t) dayofyear(c)
NULL NULL NULL NULL NULL
dayofmonth("0000-00-00") dayofmonth(d) dayofmonth(dt) dayofmonth(t) dayofmonth(c)
0 0 0 0 0
month("0000-00-00") month(d) month(dt) month(t) month(c)
0 0 0 0 0
quarter("0000-00-00") quarter(d) quarter(dt) quarter(t) quarter(c)
0 0 0 0 0
week("0000-00-00") week(d) week(dt) week(t) week(c)
NULL NULL NULL NULL NULL
year("0000-00-00") year(d) year(dt) year(t) year(c)
0 0 0 0 0
yearweek("0000-00-00") yearweek(d) yearweek(dt) yearweek(t) yearweek(c)
NULL NULL NULL NULL NULL
to_days("0000-00-00") to_days(d) to_days(dt) to_days(t) to_days(c)
NULL NULL NULL NULL NULL
extract(MONTH FROM "0000-00-00") extract(MONTH FROM d) extract(MONTH FROM dt) extract(MONTH FROM t) extract(MONTH FROM c)
0 0 0 0 0
......@@ -2,3 +2,5 @@ b
b
b
0
id start end chr_strand
133197 813898 813898 -1.0000
......@@ -131,3 +131,21 @@ INSERT INTO t1 VALUES ('');
SELECT month(updated) from t1;
SELECT year(updated) from t1;
drop table t1;
#
# Check that functions work identically on 0000-00-00 as a constant and on a
# column
#
create table t1 (d date, dt datetime, t timestamp, c char(10));
insert into t1 values ("0000-00-00", "0000-00-00", "0000-00-00", "0000-00-00");
select dayofyear("0000-00-00"),dayofyear(d),dayofyear(dt),dayofyear(t),dayofyear(c) from t1;
select dayofmonth("0000-00-00"),dayofmonth(d),dayofmonth(dt),dayofmonth(t),dayofmonth(c) from t1;
select month("0000-00-00"),month(d),month(dt),month(t),month(c) from t1;
select quarter("0000-00-00"),quarter(d),quarter(dt),quarter(t),quarter(c) from t1;
select week("0000-00-00"),week(d),week(dt),week(t),week(c) from t1;
select year("0000-00-00"),year(d),year(dt),year(t),year(c) from t1;
select yearweek("0000-00-00"),yearweek(d),yearweek(dt),yearweek(t),yearweek(c) from t1;
select to_days("0000-00-00"),to_days(d),to_days(dt),to_days(t),to_days(c) from t1;
select extract(MONTH FROM "0000-00-00"),extract(MONTH FROM d),extract(MONTH FROM dt),extract(MONTH FROM t),extract(MONTH FROM c) from t1;
drop table t1;
# test of problems with having (Reported by Mark Rogers)
#
drop table if exists t1;
drop table if exists t1,t2;
create table t1 (a int);
select count(a) as b from t1 where a=0 having b > 0;
insert into t1 values (null);
select count(a) as b from t1 where a=0 having b > 0;
select count(a) as b from t1 where a=0 having b >=0;
drop table t1;
#
# Test of problem with HAVING and AVG()
#
CREATE TABLE t1 (
raw_id int(10) NOT NULL default '0',
chr_start int(10) NOT NULL default '0',
chr_end int(10) NOT NULL default '0',
raw_start int(10) NOT NULL default '0',
raw_end int(10) NOT NULL default '0',
raw_ori int(2) NOT NULL default '0'
);
INSERT INTO t1 VALUES (469713,1,164123,1,164123,1),(317330,164124,317193,101,153170,1),(469434,317194,375620,101,58527,1),(591816,375621,484273,1,108653,1),(591807,484274,534671,91,50488,1),(318885,534672,649362,101,114791,1),(318728,649363,775520,102,126259,1),(336829,775521,813997,101,38577,1),(317740,813998,953227,101,139330,1),(1,813998,953227,101,139330,1);
CREATE TABLE t2 (
id int(10) unsigned NOT NULL default '0',
contig_id int(10) unsigned NOT NULL default '0',
seq_start int(10) NOT NULL default '0',
seq_end int(10) NOT NULL default '0',
strand tinyint(2) NOT NULL default '0',
KEY id (id)
);
INSERT INTO t2 VALUES (133195,469713,61327,61384,1),(133196,469713,64113,64387,1),(133197,1,1,1,0),(133197,1,1,1,-2);
SELECT e.id,
MIN( IF(sgp.raw_ori=1,
(e.seq_start+sgp.chr_start-sgp.raw_start),
(sgp.chr_start+sgp.raw_end-e.seq_end))) as start,
MAX( IF(sgp.raw_ori=1,
(e.seq_end+sgp.chr_start-sgp.raw_start),
(sgp.chr_start+sgp.raw_end-e.seq_start))) as end,
AVG(IF (sgp.raw_ori=1,e.strand,(-e.strand))) as chr_strand
FROM t1 sgp,
t2 e
WHERE sgp.raw_id=e.contig_id
GROUP BY e.id
HAVING chr_strand= -1 and end >= 0
AND start <= 999660;
drop table t1,t2;
......@@ -25,6 +25,7 @@
#include "mysys_priv.h"
#include <m_ctype.h>
#include <m_string.h>
/* string to uppercase */
......
......@@ -25,6 +25,7 @@
*/
#include "mysys_priv.h"
#include <m_string.h>
/* Envoke the comparison function, returns either 0, < 0, or > 0. */
#ifdef QSORT_EXTRA_CMP_ARGUMENT
......
......@@ -20,6 +20,7 @@
#include <global.h>
#ifdef HAVE_COMPRESS
#include <my_sys.h>
#include <m_string.h>
#include <zlib.h>
/*
......
......@@ -15,6 +15,13 @@
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/*
This function is only used by some old ISAM code.
When we remove ISAM support from MySQL, we should also delete this file
One should instead use the functions in mf_tempfile.c
*/
#include "mysys_priv.h"
#include <m_string.h>
#include "my_static.h"
......@@ -103,13 +110,13 @@ my_string my_tempnam(const char *dir, const char *pfx,
old_env=(char**)environ;
if (dir)
{ /* Don't use TMPDIR if dir is given */
environ=(const char**)temp_env;
environ=(const char**)temp_env; /* May give warning */
temp_env[0]=0;
}
#endif
res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
#ifndef OS2
environ=(const char**)old_env;
environ=(const char**)old_env; /* May give warning */
#endif
if (!res)
DBUG_PRINT("error",("Got error: %d from tempnam",errno));
......
......@@ -2412,8 +2412,7 @@ String *Field_timestamp::val_str(String *val_buffer,
return val_buffer;
}
bool Field_timestamp::get_date(TIME *ltime,
bool fuzzydate __attribute__((unused)))
bool Field_timestamp::get_date(TIME *ltime, bool fuzzydate)
{
long temp;
#ifdef WORDS_BIGENDIAN
......@@ -2424,6 +2423,8 @@ bool Field_timestamp::get_date(TIME *ltime,
longget(temp,ptr);
if (temp == 0L)
{ /* Zero time is "000000" */
if (!fuzzydate)
return 1;
bzero((char*) ltime,sizeof(*ltime));
}
else
......@@ -2447,8 +2448,7 @@ bool Field_timestamp::get_date(TIME *ltime,
bool Field_timestamp::get_time(TIME *ltime)
{
Field_timestamp::get_date(ltime,0);
return 0;
return Field_timestamp::get_date(ltime,0);
}
int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr)
......@@ -3029,13 +3029,12 @@ bool Field_newdate::get_date(TIME *ltime,bool fuzzydate)
ltime->month= (tmp >> 5) & 15;
ltime->year= (tmp >> 9);
ltime->time_type=TIMESTAMP_DATE;
return (!fuzzydate && (!ltime->month || !ltime->day) && ltime->year) ? 1 : 0;
return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0;
}
bool Field_newdate::get_time(TIME *ltime)
{
Field_newdate::get_date(ltime,0);
return 0;
return Field_newdate::get_date(ltime,0);
}
int Field_newdate::cmp(const char *a_ptr, const char *b_ptr)
......@@ -3214,13 +3213,12 @@ bool Field_datetime::get_date(TIME *ltime,bool fuzzydate)
ltime->day= part1%100;
ltime->month= part1/100%100;
ltime->year= part1/10000;
return (!fuzzydate && (!ltime->month || !ltime->day) && ltime->year) ? 1 : 0;
return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0;
}
bool Field_datetime::get_time(TIME *ltime)
{
Field_datetime::get_date(ltime,0);
return 0;
return Field_datetime::get_date(ltime,0);
}
int Field_datetime::cmp(const char *a_ptr, const char *b_ptr)
......
......@@ -292,6 +292,7 @@ class Item_result_field :public Item /* Item with result field */
Item_result_field() :result_field(0) {}
~Item_result_field() {} /* Required with gcc 2.95 */
Field *tmp_table_field() { return result_field; }
table_map used_tables() const { return 1; }
virtual void fix_length_and_dec()=0;
};
......
......@@ -513,29 +513,37 @@ bool MYSQL_LOG::is_active(const char* log_file_name)
void MYSQL_LOG::new_file(bool inside_mutex)
{
// only rotate open logs that are marked non-rotatable
// (binlog with constant name are non-rotatable)
if (is_open() && ! no_rotate)
if (is_open())
{
char new_name[FN_REFLEN], *old_name=name;
if (!inside_mutex)
VOID(pthread_mutex_lock(&LOCK_log));
if (generate_new_name(new_name, name))
{
if (!inside_mutex)
VOID(pthread_mutex_unlock(&LOCK_log));
return; // Something went wrong
}
if (log_type == LOG_BIN)
if (!no_rotate)
{
/*
We log the whole file name for log file as the user may decide
to change base names at some point.
only rotate open logs that are marked non-rotatable
(binlog with constant name are non-rotatable)
*/
Rotate_log_event r(new_name+dirname_length(new_name));
r.write(&log_file);
VOID(pthread_cond_broadcast(&COND_binlog_update));
if (generate_new_name(new_name, name))
{
if (!inside_mutex)
VOID(pthread_mutex_unlock(&LOCK_log));
return; // Something went wrong
}
if (log_type == LOG_BIN)
{
/*
We log the whole file name for log file as the user may decide
to change base names at some point.
*/
Rotate_log_event r(new_name+dirname_length(new_name));
r.write(&log_file);
VOID(pthread_cond_broadcast(&COND_binlog_update));
}
}
else
strmov(new_name, old_name); // Reopen old file name
name=0;
close();
open(old_name, log_type, new_name);
......
......@@ -5302,6 +5302,7 @@ static bool fix_having(JOIN *join, Item **having)
JOIN_TAB *table=&join->join_tab[join->const_tables];
table_map used_tables= join->const_table_map | table->table->map;
DBUG_EXECUTE("where",print_where(*having,"having"););
Item* sort_table_cond=make_cond_for_table(*having,used_tables,used_tables);
if (sort_table_cond)
{
......
......@@ -426,7 +426,6 @@ timestamp_type
str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
{
uint field_length,year_length,digits,i,number_of_fields,date[7];
bool date_used=0;
const char *pos;
const char *end=str+length;
DBUG_ENTER("str_to_TIME");
......@@ -452,8 +451,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
tmp_value=tmp_value*10 + (uint) (uchar) (*str - '0');
str++;
}
if ((date[i]=tmp_value))
date_used=1; // Found something
date[i]=tmp_value;
if (i == 2 && str != end && *str == 'T')
str++; // ISO8601: CCYYMMDDThhmmss
else if ( i != 5 ) // Skip inter-field delimiters
......@@ -486,7 +484,7 @@ str_to_TIME(const char *str, uint length, TIME *l_time,bool fuzzy_date)
number_of_fields=i;
while (i < 6)
date[i++]=0;
if (number_of_fields < 3 || !date_used || date[1] > 12 ||
if (number_of_fields < 3 || date[1] > 12 ||
date[2] > 31 || date[3] > 23 || date[4] > 59 || date[5] > 59 ||
!fuzzy_date && (date[1] == 0 || date[2] == 0))
{
......
......@@ -16,8 +16,8 @@
MA 02111-1307, USA */
#include <global.h>
#include <m_ctype.h>
#include <m_string.h>
/* generated by make, using conf_to_src */
#include "ctype_extra_sources.c"
......
......@@ -197,7 +197,7 @@ function (const char *nptr,char **endptr,int base)
}
/* Return the result of the appropriate sign. */
return (negative ? -((longtype) i) : i);
return (negative ? -((longtype) i) : (longtype) i);
noconv:
/* There was no number to convert. */
......
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