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

Added --sql-mode=NO_UNSIGNED_SUBTRACTION

parent 2c24b6fb
...@@ -8133,15 +8133,17 @@ than it had in 3.23. ...@@ -8133,15 +8133,17 @@ than it had in 3.23.
@item @item
The result of all bitwise operators @code{|}, @code{&}, @code{<<}, The result of all bitwise operators @code{|}, @code{&}, @code{<<},
@code{>>} and @code{~} is now unsigned. This may cause problems if your @code{>>} and @code{~} is now unsigned. This may cause problems if your
are using them in a context where you want an signed result. @xref{Cast are using them in a context where you want an signed result.
Functions}. @xref{Cast Functions}.
@item @item
@strong{NOTE:} When you use subtraction between integers values where @strong{NOTE:} When you use subtraction between integers values where
one is of type @code{UNSIGNED}, the result will be unsigned! In other one is of type @code{UNSIGNED}, the result will be unsigned! In other
words, before upgrading to MySQL 4.0, you should check your application words, before upgrading to MySQL 4.0, you should check your application
for cases where you are subtracting a value from an unsigned entity for cases where you are subtracting a value from an unsigned entity and
and want a negative answer or subtracting an unsigned value from a an want a negative answer or subtracting an unsigned value from a an
integer column. @xref{Cast Functions}. integer column. You can disable this behaviour by using the
@code{--sql-mode=NO_UNSIGNED_SUBTRACTION} option when starting
@code{mysqld}. @xref{Cast Functions}.
@item @item
To use @code{MATCH ... AGAINST (... IN BOOLEAN MODE)} with your tables, To use @code{MATCH ... AGAINST (... IN BOOLEAN MODE)} with your tables,
you need to rebuild them with @code{ALTER TABLE table_name TYPE=MyISAM}, you need to rebuild them with @code{ALTER TABLE table_name TYPE=MyISAM},
...@@ -19873,6 +19875,8 @@ Means that the thread is flushing the changed table data to disk and ...@@ -19873,6 +19875,8 @@ Means that the thread is flushing the changed table data to disk and
closing the used tables. This should be a fast operation. If not, then closing the used tables. This should be a fast operation. If not, then
you should check that you don't have a full disk or that the disk is not you should check that you don't have a full disk or that the disk is not
in very heavy use. in very heavy use.
@item @code{Connect Out}
Slave connecting to master.
@item @code{Copying to tmp table on disk} @item @code{Copying to tmp table on disk}
The temporary result set was larger than @code{tmp_table_size} and the The temporary result set was larger than @code{tmp_table_size} and the
thread is now changing the in memory based temporary table to a disk thread is now changing the in memory based temporary table to a disk
...@@ -32000,6 +32004,12 @@ SELECT (unsigned_column_1+0.0)-(unsigned_column_2+0.0); ...@@ -32000,6 +32004,12 @@ SELECT (unsigned_column_1+0.0)-(unsigned_column_2+0.0);
The idea is that the columns are converted to floating point before doing The idea is that the columns are converted to floating point before doing
the subtraction. the subtraction.
If you get a problem with @code{UNSIGNED} columns in your old MySQL
application when porting to MySQL 4.0, you can use the
@code{--sql-mode=NO_UNSIGNED_SUBTRACTION} option when starting
@code{mysqld}. Note however that as long as you use this, you will not
be able to efficiently use the @code{UNSIGNED BIGINT} column type.
@node Other Functions, Group by functions, Cast Functions, Functions @node Other Functions, Group by functions, Cast Functions, Functions
@subsection Other Functions @subsection Other Functions
...@@ -48361,6 +48371,10 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. ...@@ -48361,6 +48371,10 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet @itemize @bullet
@item @item
Added sql-mode flag @code{NO_UNSIGNED_SUBTRACTION} to disable unsigned
arithmetic rules when it comes to subtraction. (This will make MySQL 4.0
behave more closely to 3.23 with @code{UNSIGNED} columns).
@item
Added @code{WITH MAX_QUERIES_PER_HOUR=#} to @code{GRANT} command. Added @code{WITH MAX_QUERIES_PER_HOUR=#} to @code{GRANT} command.
@item @item
The type returned for all bit functions (@code{|}, @code{<<} ...) are now of The type returned for all bit functions (@code{|}, @code{<<} ...) are now of
...@@ -48473,7 +48487,7 @@ Added support for @code{MATCH ... AGAINST(... IN BOOLEAN MODE)}. ...@@ -48473,7 +48487,7 @@ Added support for @code{MATCH ... AGAINST(... IN BOOLEAN MODE)}.
@code{ALTER TABLE tablename TYPE=MyISAM} to be @code{ALTER TABLE tablename TYPE=MyISAM} to be
able to use boolean fulltext search}. able to use boolean fulltext search}.
@item @item
@code{LOCATE()} and @code{INSTR()} are case sensitive if neither @code{LOCATE()} and @code{INSTR()} are now case sensitive if either
argument is a binary string. argument is a binary string.
@item @item
Changed @code{RAND()} initialization so that @code{RAND(N)} and Changed @code{RAND()} initialization so that @code{RAND(N)} and
...@@ -280,6 +280,21 @@ longlong Item_func_plus::val_int() ...@@ -280,6 +280,21 @@ longlong Item_func_plus::val_int()
return (longlong) Item_func_plus::val(); return (longlong) Item_func_plus::val();
} }
/*
The following function is here to allow the user to force
subtraction of UNSIGNED BIGINT to return negative values.
*/
void Item_func_minus::fix_length_and_dec()
{
Item_num_op::fix_length_and_dec();
if (unsigned_flag &&
(current_thd->sql_mode & MODE_NO_UNSIGNED_SUBTRACTION))
unsigned_flag=0;
}
double Item_func_minus::val() double Item_func_minus::val()
{ {
double value=args[0]->val() - args[1]->val(); double value=args[0]->val() - args[1]->val();
......
...@@ -233,8 +233,10 @@ public: ...@@ -233,8 +233,10 @@ public:
const char *func_name() const { return "-"; } const char *func_name() const { return "-"; }
double val(); double val();
longlong val_int(); longlong val_int();
void fix_length_and_dec();
}; };
class Item_func_mul :public Item_num_op class Item_func_mul :public Item_num_op
{ {
public: public:
......
...@@ -187,6 +187,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); ...@@ -187,6 +187,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name);
#define MODE_IGNORE_SPACE 8 #define MODE_IGNORE_SPACE 8
#define MODE_SERIALIZABLE 16 #define MODE_SERIALIZABLE 16
#define MODE_ONLY_FULL_GROUP_BY 32 #define MODE_ONLY_FULL_GROUP_BY 32
#define MODE_NO_UNSIGNED_SUBTRACTION 64
#define RAID_BLOCK_SIZE 1024 #define RAID_BLOCK_SIZE 1024
......
...@@ -351,7 +351,7 @@ time_t start_time; ...@@ -351,7 +351,7 @@ time_t start_time;
ulong opt_sql_mode = 0L; ulong opt_sql_mode = 0L;
const char *sql_mode_names[] = const char *sql_mode_names[] =
{ "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE", { "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE",
"SERIALIZE","ONLY_FULL_GROUP_BY", NullS }; "SERIALIZE","ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",NullS };
TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"", TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"",
sql_mode_names}; sql_mode_names};
...@@ -486,7 +486,6 @@ static void close_connections(void) ...@@ -486,7 +486,6 @@ static void close_connections(void)
HANDLE hTempPipe = &hPipe; HANDLE hTempPipe = &hPipe;
DBUG_PRINT( "quit", ("Closing named pipes") ); DBUG_PRINT( "quit", ("Closing named pipes") );
hPipe = INVALID_HANDLE_VALUE; hPipe = INVALID_HANDLE_VALUE;
CancelIo( hTempPipe );
DisconnectNamedPipe( hTempPipe ); DisconnectNamedPipe( hTempPipe );
CloseHandle( hTempPipe ); CloseHandle( hTempPipe );
} }
...@@ -3411,7 +3410,8 @@ static void usage(void) ...@@ -3411,7 +3410,8 @@ static void usage(void)
-t, --tmpdir=path Path for temporary files\n\ -t, --tmpdir=path Path for temporary files\n\
--sql-mode=option[,option[,option...]] where option can be one of:\n\ --sql-mode=option[,option[,option...]] where option can be one of:\n\
REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES,\n\ REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES,\n\
IGNORE_SPACE, SERIALIZE, ONLY_FULL_GROUP_BY.\n\ IGNORE_SPACE, SERIALIZE, ONLY_FULL_GROUP_BY,\n\
NO_UNSIGNED_SUBTRACTION.\n\
--transaction-isolation\n\ --transaction-isolation\n\
Default transaction isolation level\n\ Default transaction isolation level\n\
--temp-pool Use a pool of temporary files\n\ --temp-pool Use a pool of temporary files\n\
......
...@@ -1541,7 +1541,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) ...@@ -1541,7 +1541,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
*/ */
/* TODO: I/O thread should not even log events with the same server id */ /* TODO: I/O thread should not even log events with the same server id */
rli->inc_pos(ev->get_event_len(), rli->inc_pos(ev->get_event_len(),
type_code != STOP_EVENT ? ev->log_pos : 0, type_code != STOP_EVENT ? ev->log_pos : LL(0),
1/* skip lock*/); 1/* skip lock*/);
flush_relay_log_info(rli); flush_relay_log_info(rli);
if (rli->slave_skip_counter && /* protect against common user error of if (rli->slave_skip_counter && /* protect against common user error of
...@@ -2297,7 +2297,6 @@ Log_event* next_event(RELAY_LOG_INFO* rli) ...@@ -2297,7 +2297,6 @@ Log_event* next_event(RELAY_LOG_INFO* rli)
DBUG_ASSERT(rli->cur_log_fd >= 0); DBUG_ASSERT(rli->cur_log_fd >= 0);
my_close(rli->cur_log_fd, MYF(MY_WME)); my_close(rli->cur_log_fd, MYF(MY_WME));
rli->cur_log_fd = -1; rli->cur_log_fd = -1;
int error;
// purge_first_log will properly set up relay log coordinates in rli // purge_first_log will properly set up relay log coordinates in rli
if (rli->relay_log.purge_first_log(rli)) if (rli->relay_log.purge_first_log(rli))
......
...@@ -176,7 +176,7 @@ typedef struct st_relay_log_info ...@@ -176,7 +176,7 @@ typedef struct st_relay_log_info
pending += val; pending += val;
} }
// TODO: this probably needs to be fixed // TODO: this probably needs to be fixed
inline void inc_pos(ulonglong val, uint32 log_pos, bool skip_lock=0) inline void inc_pos(ulonglong val, ulonglong log_pos, bool skip_lock=0)
{ {
if (!skip_lock) if (!skip_lock)
pthread_mutex_lock(&data_lock); pthread_mutex_lock(&data_lock);
......
...@@ -35,8 +35,10 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) ...@@ -35,8 +35,10 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
TABLE_LIST *lock_table,*ren_table=0; TABLE_LIST *lock_table,*ren_table=0;
DBUG_ENTER("mysql_rename_tables"); DBUG_ENTER("mysql_rename_tables");
/* Avoid problems with a rename on a table that we have locked or /*
if the user is trying to to do this in a transcation context */ Avoid problems with a rename on a table that we have locked or
if the user is trying to to do this in a transcation context
*/
if (thd->locked_tables || thd->active_transaction()) if (thd->locked_tables || thd->active_transaction())
{ {
......
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