Commit 028cfaba authored by unknown's avatar unknown

Fix after merge

Updated WEEK() and DATE information in the manual.


Docs/manual.texi:
  Updated WEEK() information.
  Added more information of how MySQL stores dates.
libmysql/Makefile.am:
  Fix after merge
libmysqld/lib_vio.c:
  Use new vio_blocking()
mysql-test/r/group_by.result:
  Update results after merge
sql/ha_innodb.cc:
  Fix after merge
sql/lex.h:
  Fix after merge
sql/slave.cc:
  Added missing include file
sql/sql_base.cc:
  Added function comments
vio/test-ssl.c:
  Fix after merge
parent 267b8083
...@@ -3554,10 +3554,13 @@ string) in it instead. (This behaviour can, however, be changed with the ...@@ -3554,10 +3554,13 @@ string) in it instead. (This behaviour can, however, be changed with the
-DDONT_USE_DEFAULT_FIELDS compile option.) -DDONT_USE_DEFAULT_FIELDS compile option.)
@item @item
MySQL allows you to store some wrong date values into MySQL allows you to store some wrong date values into @code{DATE} and
@code{DATE} and @code{DATETIME} columns (like 2000-02-31 or 2000-02-00). @code{DATETIME} columns (like 2000-02-31 or 2000-02-00). The idea is
If the date is totally wrong, MySQL Server will store the special that it's not the SQL server job to vaildate date. If MySQL can store a
0000-00-00 date value in the column. date and retrieve exactly the same date, then MySQL will store the
date. If the date is totally wrong (outside of MySQL abilty to store
it), MySQL Server will store the special 0000-00-00 date value in the
column.
@item @item
If you set an @code{ENUM} column to an unsupported value, it will be set to If you set an @code{ENUM} column to an unsupported value, it will be set to
...@@ -32558,6 +32561,31 @@ mysql> SELECT WEEK('1998-12-31',1); ...@@ -32558,6 +32561,31 @@ mysql> SELECT WEEK('1998-12-31',1);
Note: in Version 4.0, @code{WEEK(#,0)} was changed to match the Note: in Version 4.0, @code{WEEK(#,0)} was changed to match the
calendar in the USA. calendar in the USA.
Note that if a week is the last week of the previous year, MySQL will
return 0:
@example
mysql> SELECT YEAR('2000-01-01'), WEEK('2000-01-01',0);
-> 2000, 0
@end example
One could argue that MySQL should return @code{52} for the @code{WEEK()}
function as the given date is actually the 52 second week of 1999. We
decided to return 0 instead as we want the function to return 'the week
number in the given year'. This makes the usage of the @code{WEEK()}
function reliable when combined with other functions that extracts a
date part from a date.
If you would prefer to know the correct year-week, then you should use
the @code{YEARWEEK()} function instead:
@example
mysql> SELECT YEARWEEK('2000-01-01');
-> 199952
mysql> SELECT MID(YEARWEEK('2000-01-01'),5,2);
-> 52
@end example
@findex YEAR() @findex YEAR()
@item YEAR(date) @item YEAR(date)
Returns the year for @code{date}, in the range @code{1000} to @code{9999}: Returns the year for @code{date}, in the range @code{1000} to @code{9999}:
...@@ -32579,6 +32607,10 @@ mysql> SELECT YEARWEEK('1987-01-01'); ...@@ -32579,6 +32607,10 @@ mysql> SELECT YEARWEEK('1987-01-01');
-> 198653 -> 198653
@end example @end example
Note that the week number is different from what the @code{WEEK()} function
would return (@code{0}) as the week function returns the week in the
context of the given year.
@findex HOUR() @findex HOUR()
@item HOUR(time) @item HOUR(time)
Returns the hour for @code{time}, in the range @code{0} to @code{23}: Returns the hour for @code{time}, in the range @code{0} to @code{23}:
...@@ -48183,13 +48215,33 @@ mysql> SELECT idate FROM tbl_name WHERE STRCMP(idate,'19970505')=0; ...@@ -48183,13 +48215,33 @@ mysql> SELECT idate FROM tbl_name WHERE STRCMP(idate,'19970505')=0;
a string and performs a string comparison. It does not convert a string and performs a string comparison. It does not convert
@code{'19970505'} to a date and perform a date comparison. @code{'19970505'} to a date and perform a date comparison.
Note that MySQL does no checking whether the date is Note that MySQL does very limited checking whether the date is
correct. If you store an incorrect date, such as @code{'1998-2-31'}, the correct. If you store an incorrect date, such as @code{'1998-2-31'}, the
wrong date will be stored. If the date cannot be converted to any reasonable wrong date will be stored.
value, a @code{0} is stored in the @code{DATE} field. This is mainly a speed
issue and we think it is up to the application to check the dates, and not Because MySQL packs dates for storage, it can't store any given date as
the server. it would not fit onto the result buffer. The rules for accepting a date
are:
@itemize @bullet
@item
If MySQL can store it and retrieve a date, the wrong date is accepted
for @code{DATE} and @code{DATETIME} columns.
@item
All days values between 0-31 are accepted for any date. This makes it
very convenient for web applications where you ask year, month and day
in 3 different fields.
@item
The day or month field may be zero. This is convenient if you want
to store a birthdate in a @code{DATE} column and you only know part
of the date.
@end itemize
If the date cannot be converted to any reasonable value, a @code{0} is
stored in the @code{DATE} field, which will be retrieved as
@code{0000-00-00}. This is both a speed and convinient issue as we
belive that the databases responsiblity etrive the same date you stored
(even if the data was not logicall correct in all cases). We think it is
up to the application to check the dates, and not the server.
@node Problems with NULL, Problems with alias, Using DATE, Query Issues @node Problems with NULL, Problems with alias, Using DATE, Query Issues
@appendixsubsec Problems with @code{NULL} Values @appendixsubsec Problems with @code{NULL} Values
...@@ -52,6 +52,7 @@ link_sources: ...@@ -52,6 +52,7 @@ link_sources:
for f in $(mystringsgen); do \ for f in $(mystringsgen); do \
rm -f $(srcdir)/$$f; \ rm -f $(srcdir)/$$f; \
@LN_CP_F@ ../strings/$$f $(srcdir)/$$f; \ @LN_CP_F@ ../strings/$$f $(srcdir)/$$f; \
done; \
for f in $$qs; do \ for f in $$qs; do \
rm -f $(srcdir)/$$f; \ rm -f $(srcdir)/$$f; \
@LN_CP_F@ $(srcdir)/../sql/$$f $(srcdir)/$$f; \ @LN_CP_F@ $(srcdir)/../sql/$$f $(srcdir)/$$f; \
......
...@@ -151,7 +151,7 @@ int vio_write(Vio * vio, const gptr buf, int size) ...@@ -151,7 +151,7 @@ int vio_write(Vio * vio, const gptr buf, int size)
DBUG_RETURN(size); DBUG_RETURN(size);
} }
int vio_blocking(Vio * vio, my_bool set_blocking_mode) int vio_blocking(Vio * vio, my_bool set_blocking_mode, my_bool *old_mode)
{ {
return (0); return (0);
} }
......
...@@ -395,3 +395,25 @@ gender dist_count percentage ...@@ -395,3 +395,25 @@ gender dist_count percentage
M 1 20.00 M 1 20.00
F 3 60.00 F 3 60.00
drop table t1,t2; drop table t1,t2;
CREATE TABLE t1 (ID1 int, ID2 int, ID int NOT NULL AUTO_INCREMENT,PRIMARY KEY(ID
));
insert into t1 values (1,244,NULL),(2,243,NULL),(134,223,NULL),(185,186,NULL);
select S.ID as xID, S.ID1 as xID1 from t1 as S left join t1 as yS on S.ID1 between yS.ID1 and yS.ID2;
xID xID1
1 1
2 2
2 2
3 134
3 134
3 134
4 185
4 185
4 185
4 185
select S.ID as xID, S.ID1 as xID1, repeat('*',count(distinct yS.ID)) as Level from t1 as S left join t1 as yS on S.ID1 between yS.ID1 and yS.ID2 group by xID order by xID1;
xID xID1 Level
1 1 *
2 2 **
3 134 ***
4 185 ****
drop table t1;
...@@ -2402,7 +2402,7 @@ ha_innobase::rnd_pos( ...@@ -2402,7 +2402,7 @@ ha_innobase::rnd_pos(
int error; int error;
uint keynr = active_index; uint keynr = active_index;
DBUG_ENTER("rnd_pos"); DBUG_ENTER("rnd_pos");
DBUG_DUMP("key", (char*) pos, ref_stored_len); DBUG_DUMP("key", (char*) pos, ref_length);
statistic_increment(ha_read_rnd_count, &LOCK_status); statistic_increment(ha_read_rnd_count, &LOCK_status);
......
...@@ -251,7 +251,6 @@ static SYMBOL symbols[] = { ...@@ -251,7 +251,6 @@ static SYMBOL symbols[] = {
{ "NEW", SYM(NEW_SYM),0,0}, { "NEW", SYM(NEW_SYM),0,0},
{ "NCHAR", SYM(NCHAR_SYM),0,0}, { "NCHAR", SYM(NCHAR_SYM),0,0},
{ "NO", SYM(NO_SYM),0,0}, { "NO", SYM(NO_SYM),0,0},
{ "FOREIGN_KEY_CHECKS", SYM(FOREIGN_KEY_CHECKS), 0, 0},
{ "NOT", SYM(NOT),0,0}, { "NOT", SYM(NOT),0,0},
{ "NULL", SYM(NULL_SYM),0,0}, { "NULL", SYM(NULL_SYM),0,0},
{ "NUMERIC", SYM(NUMERIC_SYM),0,0}, { "NUMERIC", SYM(NUMERIC_SYM),0,0},
...@@ -285,7 +284,6 @@ static SYMBOL symbols[] = { ...@@ -285,7 +284,6 @@ static SYMBOL symbols[] = {
{ "RELAY_LOG_POS", SYM(RELAY_LOG_POS_SYM),0,0}, { "RELAY_LOG_POS", SYM(RELAY_LOG_POS_SYM),0,0},
{ "RELOAD", SYM(RELOAD),0,0}, { "RELOAD", SYM(RELOAD),0,0},
{ "REGEXP", SYM(REGEXP),0,0}, { "REGEXP", SYM(REGEXP),0,0},
{ "UNIQUE_CHECKS", SYM(UNIQUE_CHECKS), 0, 0},
{ "RENAME", SYM(RENAME),0,0}, { "RENAME", SYM(RENAME),0,0},
{ "REPAIR", SYM(REPAIR),0,0}, { "REPAIR", SYM(REPAIR),0,0},
{ "REPLACE", SYM(REPLACE),0,0}, { "REPLACE", SYM(REPLACE),0,0},
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "sql_repl.h" #include "sql_repl.h"
#include "repl_failsafe.h" #include "repl_failsafe.h"
#include <thr_alarm.h> #include <thr_alarm.h>
#include <my_dir.h>
#include <assert.h> #include <assert.h>
bool use_slave_mask = 0; bool use_slave_mask = 0;
...@@ -1029,7 +1030,6 @@ void end_master_info(MASTER_INFO* mi) ...@@ -1029,7 +1030,6 @@ void end_master_info(MASTER_INFO* mi)
int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
{ {
MY_STAT stat_area;
char fname[FN_REFLEN+128]; char fname[FN_REFLEN+128];
int info_fd; int info_fd;
const char* msg = 0; const char* msg = 0;
...@@ -1069,7 +1069,7 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) ...@@ -1069,7 +1069,7 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname)
DBUG_RETURN(1); DBUG_RETURN(1);
/* if file does not exist */ /* if file does not exist */
if (!my_stat(fname, &stat_area, MYF(0))) if (access(fname,F_OK))
{ {
/* /*
If someone removed the file from underneath our feet, just close If someone removed the file from underneath our feet, just close
......
...@@ -108,6 +108,24 @@ static void check_unused(void) ...@@ -108,6 +108,24 @@ static void check_unused(void)
#define check_unused() #define check_unused()
#endif #endif
/*
Create a list for all open tables matching SQL expression
SYNOPSIS
list_open_tables()
thd Thread THD
wild SQL like expression
NOTES
One gets only a list of tables for which one has any kind of privilege.
db and table names are allocated in result struct, so one doesn't need
a lock on LOCK_open when traversing the return list.
RETURN VALUES
NULL Error (Probably OOM)
# Pointer to list of names of open tables.
*/
OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild) OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild)
{ {
int result = 0; int result = 0;
......
...@@ -59,6 +59,7 @@ main( int argc, ...@@ -59,6 +59,7 @@ main( int argc,
char* ca_file = 0, *ca_path = 0; char* ca_file = 0, *ca_path = 0;
char* cipher=0; char* cipher=0;
int child_pid,sv[2]; int child_pid,sv[2];
my_bool unused;
struct st_VioSSLAcceptorFd* ssl_acceptor=0; struct st_VioSSLAcceptorFd* ssl_acceptor=0;
struct st_VioSSLConnectorFd* ssl_connector=0; struct st_VioSSLConnectorFd* ssl_connector=0;
Vio* client_vio=0, *server_vio=0; Vio* client_vio=0, *server_vio=0;
...@@ -96,11 +97,11 @@ main( int argc, ...@@ -96,11 +97,11 @@ main( int argc,
client_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0)); client_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0));
client_vio->sd = sv[0]; client_vio->sd = sv[0];
client_vio->vioblocking(client_vio,0); client_vio->vioblocking(client_vio, 0, &unused);
sslconnect(ssl_connector,client_vio,60L); sslconnect(ssl_connector,client_vio,60L);
server_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0)); server_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0));
server_vio->sd = sv[1]; server_vio->sd = sv[1];
server_vio->vioblocking(client_vio,0); server_vio->vioblocking(client_vio, 0, &unused);
sslaccept(ssl_acceptor,server_vio,60L); sslaccept(ssl_acceptor,server_vio,60L);
printf("Socketpair: %d , %d\n", client_vio->sd, server_vio->sd); printf("Socketpair: %d , %d\n", client_vio->sd, server_vio->sd);
......
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