diff options
-rw-r--r-- | Docs/manual.texi | 70 | ||||
-rw-r--r-- | libmysql/Makefile.am | 1 | ||||
-rw-r--r-- | libmysqld/lib_vio.c | 2 | ||||
-rw-r--r-- | mysql-test/r/group_by.result | 22 | ||||
-rw-r--r-- | sql/ha_innodb.cc | 2 | ||||
-rw-r--r-- | sql/lex.h | 2 | ||||
-rw-r--r-- | sql/slave.cc | 4 | ||||
-rw-r--r-- | sql/sql_base.cc | 18 | ||||
-rw-r--r-- | vio/test-ssl.c | 5 |
9 files changed, 109 insertions, 17 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi index 0677c3525fe..b5bd24575ba 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -3554,10 +3554,13 @@ string) in it instead. (This behaviour can, however, be changed with the -DDONT_USE_DEFAULT_FIELDS compile option.) @item -MySQL allows you to store some wrong date values into -@code{DATE} and @code{DATETIME} columns (like 2000-02-31 or 2000-02-00). -If the date is totally wrong, MySQL Server will store the special -0000-00-00 date value in the column. +MySQL allows you to store some wrong date values into @code{DATE} and +@code{DATETIME} columns (like 2000-02-31 or 2000-02-00). The idea is +that it's not the SQL server job to vaildate date. If MySQL can store a +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 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); Note: in Version 4.0, @code{WEEK(#,0)} was changed to match the 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() @item YEAR(date) Returns the year for @code{date}, in the range @code{1000} to @code{9999}: @@ -32579,6 +32607,10 @@ mysql> SELECT YEARWEEK('1987-01-01'); -> 198653 @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() @item HOUR(time) 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; a string and performs a string comparison. It does not convert @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 -wrong date will be stored. If the date cannot be converted to any reasonable -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 -the server. +wrong date will be stored. + +Because MySQL packs dates for storage, it can't store any given date as +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 @appendixsubsec Problems with @code{NULL} Values diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index e72f73a39f9..fac544ba44d 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -52,6 +52,7 @@ link_sources: for f in $(mystringsgen); do \ rm -f $(srcdir)/$$f; \ @LN_CP_F@ ../strings/$$f $(srcdir)/$$f; \ + done; \ for f in $$qs; do \ rm -f $(srcdir)/$$f; \ @LN_CP_F@ $(srcdir)/../sql/$$f $(srcdir)/$$f; \ diff --git a/libmysqld/lib_vio.c b/libmysqld/lib_vio.c index 5460c546faa..29a70b7acbb 100644 --- a/libmysqld/lib_vio.c +++ b/libmysqld/lib_vio.c @@ -151,7 +151,7 @@ int vio_write(Vio * vio, const gptr buf, int 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); } diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 0ec1c03c467..fd0248d5ee6 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -395,3 +395,25 @@ gender dist_count percentage M 1 20.00 F 3 60.00 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; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 06931532f51..038da716abe 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2402,7 +2402,7 @@ ha_innobase::rnd_pos( int error; uint keynr = active_index; 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); diff --git a/sql/lex.h b/sql/lex.h index 1f7a121e262..c1d647c47aa 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -251,7 +251,6 @@ static SYMBOL symbols[] = { { "NEW", SYM(NEW_SYM),0,0}, { "NCHAR", SYM(NCHAR_SYM),0,0}, { "NO", SYM(NO_SYM),0,0}, - { "FOREIGN_KEY_CHECKS", SYM(FOREIGN_KEY_CHECKS), 0, 0}, { "NOT", SYM(NOT),0,0}, { "NULL", SYM(NULL_SYM),0,0}, { "NUMERIC", SYM(NUMERIC_SYM),0,0}, @@ -285,7 +284,6 @@ static SYMBOL symbols[] = { { "RELAY_LOG_POS", SYM(RELAY_LOG_POS_SYM),0,0}, { "RELOAD", SYM(RELOAD),0,0}, { "REGEXP", SYM(REGEXP),0,0}, - { "UNIQUE_CHECKS", SYM(UNIQUE_CHECKS), 0, 0}, { "RENAME", SYM(RENAME),0,0}, { "REPAIR", SYM(REPAIR),0,0}, { "REPLACE", SYM(REPLACE),0,0}, diff --git a/sql/slave.cc b/sql/slave.cc index 84e0f6dd236..2bde91f3ccd 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -23,6 +23,7 @@ #include "sql_repl.h" #include "repl_failsafe.h" #include <thr_alarm.h> +#include <my_dir.h> #include <assert.h> bool use_slave_mask = 0; @@ -1029,7 +1030,6 @@ void end_master_info(MASTER_INFO* mi) int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) { - MY_STAT stat_area; char fname[FN_REFLEN+128]; int info_fd; const char* msg = 0; @@ -1069,7 +1069,7 @@ int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname) DBUG_RETURN(1); /* 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 diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0f540a3a4fd..fddc2080764 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -108,6 +108,24 @@ static void check_unused(void) #define check_unused() #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) { int result = 0; diff --git a/vio/test-ssl.c b/vio/test-ssl.c index 9fdab86e9b9..acce201bfba 100644 --- a/vio/test-ssl.c +++ b/vio/test-ssl.c @@ -59,6 +59,7 @@ main( int argc, char* ca_file = 0, *ca_path = 0; char* cipher=0; int child_pid,sv[2]; + my_bool unused; struct st_VioSSLAcceptorFd* ssl_acceptor=0; struct st_VioSSLConnectorFd* ssl_connector=0; Vio* client_vio=0, *server_vio=0; @@ -96,11 +97,11 @@ main( int argc, client_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(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); server_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0)); server_vio->sd = sv[1]; - server_vio->vioblocking(client_vio,0); + server_vio->vioblocking(client_vio, 0, &unused); sslaccept(ssl_acceptor,server_vio,60L); printf("Socketpair: %d , %d\n", client_vio->sd, server_vio->sd); |