mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Portability fixes for SCO and HPUX
Change TRUNCATE(number) to truncate towards zero for negative numbers Fix NULL handling for DESCRIBE table_name Docs/manual.texi: Update of TRUNCATE() information configure.in: Fix for HPUX extra/resolveip.c: Fix for SCO include/my_net.h: Fix for HPUX libmysql/libmysql.c: Removed warning on HPUX 10.20 mysql-test/r/func_math.result: Test of new TRUNCATE handling mysql-test/t/func_math.test: Test of new TRUNCATE handling mysys/my_gethostbyname.c: Portability fix sql/item_func.cc: Change TRUNCATE(number) to truncate towards zero for negative numbers sql/sql_show.cc: Fix NULL handling for DESCRIBE table_name
This commit is contained in:
@ -31150,6 +31150,17 @@ mysql> select TRUNCATE(1.999,1);
|
|||||||
-> 1.9
|
-> 1.9
|
||||||
mysql> select TRUNCATE(1.999,0);
|
mysql> select TRUNCATE(1.999,0);
|
||||||
-> 1
|
-> 1
|
||||||
|
mysql> select TRUNCATE(-1,999,1);
|
||||||
|
-> -1.9
|
||||||
|
@end example
|
||||||
|
|
||||||
|
Starting from MySQL 3.23.51 all numbers are rounded towards zero.
|
||||||
|
|
||||||
|
If @code{D} is negative, then the whole part of the number is zeroed out:
|
||||||
|
|
||||||
|
@example
|
||||||
|
mysql> select truncate(122,-2);
|
||||||
|
-> 100
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
Note that as decimal numbers are normally not stored as exact numbers in
|
Note that as decimal numbers are normally not stored as exact numbers in
|
||||||
@ -46916,6 +46927,11 @@ not yet 100% confident in this code.
|
|||||||
@appendixsubsec Changes in release 3.23.51
|
@appendixsubsec Changes in release 3.23.51
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@item
|
@item
|
||||||
|
Cleaned up @code{NULL} handling for default values in @code{DESCRIBE
|
||||||
|
table_name}.
|
||||||
|
@item
|
||||||
|
Fixed @code{truncate()} to round up negative values to the nearest integer.
|
||||||
|
@item
|
||||||
Remove end space from @code{enum} values. (This fixed a problem with
|
Remove end space from @code{enum} values. (This fixed a problem with
|
||||||
@code{SHOW CREATE TABLE}).
|
@code{SHOW CREATE TABLE}).
|
||||||
@item
|
@item
|
||||||
|
@ -1552,7 +1552,7 @@ then
|
|||||||
fi
|
fi
|
||||||
AC_TRY_COMPILE(
|
AC_TRY_COMPILE(
|
||||||
[#undef inline
|
[#undef inline
|
||||||
#if !defined(SCO) && !defined(__osf__)
|
#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
|
||||||
#define _REENTRANT
|
#define _REENTRANT
|
||||||
#endif
|
#endif
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -1585,7 +1585,7 @@ then
|
|||||||
fi
|
fi
|
||||||
AC_TRY_COMPILE(
|
AC_TRY_COMPILE(
|
||||||
[#undef inline
|
[#undef inline
|
||||||
#if !defined(SCO) && !defined(__osf__)
|
#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
|
||||||
#define _REENTRANT
|
#define _REENTRANT
|
||||||
#endif
|
#endif
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -1617,7 +1617,7 @@ then
|
|||||||
fi
|
fi
|
||||||
AC_TRY_COMPILE(
|
AC_TRY_COMPILE(
|
||||||
[#undef inline
|
[#undef inline
|
||||||
#if !defined(SCO) && !defined(__osf__)
|
#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
|
||||||
#define _REENTRANT
|
#define _REENTRANT
|
||||||
#endif
|
#endif
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@ -1643,7 +1643,7 @@ then
|
|||||||
# Check definition of pthread_getspecific
|
# Check definition of pthread_getspecific
|
||||||
AC_CACHE_CHECK("args to pthread_getspecific", mysql_cv_getspecific_args,
|
AC_CACHE_CHECK("args to pthread_getspecific", mysql_cv_getspecific_args,
|
||||||
AC_TRY_COMPILE(
|
AC_TRY_COMPILE(
|
||||||
[#if !defined(SCO) && !defined(__osf__)
|
[#if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
|
||||||
#define _REENTRANT
|
#define _REENTRANT
|
||||||
#endif
|
#endif
|
||||||
#define _POSIX_PTHREAD_SEMANTICS
|
#define _POSIX_PTHREAD_SEMANTICS
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <my_global.h>
|
#include <my_global.h>
|
||||||
#include <m_ctype.h>
|
#include <m_ctype.h>
|
||||||
#include <my_net.h>
|
|
||||||
#include <my_sys.h>
|
#include <my_sys.h>
|
||||||
#include <m_string.h>
|
#include <m_string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -30,6 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include <my_net.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
|
||||||
#if !defined(_AIX) && !defined(HAVE_UNIXWARE7_THREADS) && !defined(HAVE_UNIXWARE7_POSIX) && !defined(h_errno)
|
#if !defined(_AIX) && !defined(HAVE_UNIXWARE7_THREADS) && !defined(HAVE_UNIXWARE7_POSIX) && !defined(h_errno)
|
||||||
|
@ -53,7 +53,7 @@ struct hostent *my_gethostbyname_r(const char *name,
|
|||||||
struct hostent *result, char *buffer,
|
struct hostent *result, char *buffer,
|
||||||
int buflen, int *h_errnop);
|
int buflen, int *h_errnop);
|
||||||
#define my_gethostbyname_r_free()
|
#define my_gethostbyname_r_free()
|
||||||
#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
|
#if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX)
|
||||||
#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
|
#define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
|
||||||
#endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
|
#endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
|
||||||
|
|
||||||
|
@ -180,8 +180,13 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
|
|||||||
{
|
{
|
||||||
tv.tv_sec = (long) timeout;
|
tv.tv_sec = (long) timeout;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
#if defined(HPUX) && defined(THREAD)
|
||||||
|
if ((res = select(s+1, NULL, (int*) &sfds, NULL, &tv)) >= 0)
|
||||||
|
break;
|
||||||
|
#else
|
||||||
if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0)
|
if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0)
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
now_time=time(NULL);
|
now_time=time(NULL);
|
||||||
timeout-= (uint) (now_time - start_time);
|
timeout-= (uint) (now_time - start_time);
|
||||||
if (errno != EINTR || (int) timeout <= 0)
|
if (errno != EINTR || (int) timeout <= 0)
|
||||||
|
@ -2,8 +2,8 @@ floor(5.5) floor(-5.5)
|
|||||||
5 -6
|
5 -6
|
||||||
ceiling(5.5) ceiling(-5.5)
|
ceiling(5.5) ceiling(-5.5)
|
||||||
6 -5
|
6 -5
|
||||||
truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2)
|
truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1)
|
||||||
52.6 52.64 50 0
|
52.6 52.64 50 0 -52.6 -50
|
||||||
round(5.5) round(-5.5)
|
round(5.5) round(-5.5)
|
||||||
6 -6
|
6 -6
|
||||||
round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2)
|
round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
select floor(5.5),floor(-5.5);
|
select floor(5.5),floor(-5.5);
|
||||||
select ceiling(5.5),ceiling(-5.5);
|
select ceiling(5.5),ceiling(-5.5);
|
||||||
select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2);
|
select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
|
||||||
select round(5.5),round(-5.5);
|
select round(5.5),round(-5.5);
|
||||||
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
|
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
|
||||||
select abs(-10), sign(-5), sign(5), sign(0);
|
select abs(-10), sign(-5), sign(5), sign(0);
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
#include "mysys_priv.h"
|
#include "mysys_priv.h"
|
||||||
#include "my_pthread.h"
|
#include "my_pthread.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <my_net.h>
|
|
||||||
#if !defined(MSDOS) && !defined(__WIN__)
|
#if !defined(MSDOS) && !defined(__WIN__)
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <my_net.h>
|
||||||
|
|
||||||
/* This file is not needed if my_gethostbyname_r is a macro */
|
/* This file is not needed if my_gethostbyname_r is a macro */
|
||||||
#if !defined(my_gethostbyname_r)
|
#if !defined(my_gethostbyname_r)
|
||||||
|
@ -601,7 +601,12 @@ double Item_func_round::val()
|
|||||||
log_10[abs_dec] : pow(10.0,(double) abs_dec));
|
log_10[abs_dec] : pow(10.0,(double) abs_dec));
|
||||||
|
|
||||||
if (truncate)
|
if (truncate)
|
||||||
|
{
|
||||||
|
if (value >= 0)
|
||||||
return dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp;
|
return dec < 0 ? floor(value/tmp)*tmp : floor(value*tmp)/tmp;
|
||||||
|
else
|
||||||
|
return dec < 0 ? ceil(value/tmp)*tmp : ceil(value*tmp)/tmp;
|
||||||
|
}
|
||||||
return dec < 0 ? rint(value/tmp)*tmp : rint(value*tmp)/tmp;
|
return dec < 0 ? rint(value/tmp)*tmp : rint(value*tmp)/tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,6 +431,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
|
|||||||
TABLE *table;
|
TABLE *table;
|
||||||
handler *file;
|
handler *file;
|
||||||
char tmp[MAX_FIELD_WIDTH];
|
char tmp[MAX_FIELD_WIDTH];
|
||||||
|
Item *item;
|
||||||
DBUG_ENTER("mysqld_show_fields");
|
DBUG_ENTER("mysqld_show_fields");
|
||||||
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
|
DBUG_PRINT("enter",("db: %s table: %s",table_list->db,
|
||||||
table_list->real_name));
|
table_list->real_name));
|
||||||
@ -449,7 +450,8 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild,
|
|||||||
field_list.push_back(new Item_empty_string("Type",40));
|
field_list.push_back(new Item_empty_string("Type",40));
|
||||||
field_list.push_back(new Item_empty_string("Null",1));
|
field_list.push_back(new Item_empty_string("Null",1));
|
||||||
field_list.push_back(new Item_empty_string("Key",3));
|
field_list.push_back(new Item_empty_string("Key",3));
|
||||||
field_list.push_back(new Item_empty_string("Default",NAME_LEN));
|
field_list.push_back(item=new Item_empty_string("Default",NAME_LEN));
|
||||||
|
item->maybe_null=1;
|
||||||
field_list.push_back(new Item_empty_string("Extra",20));
|
field_list.push_back(new Item_empty_string("Extra",20));
|
||||||
if (verbose)
|
if (verbose)
|
||||||
field_list.push_back(new Item_empty_string("Privileges",80));
|
field_list.push_back(new Item_empty_string("Privileges",80));
|
||||||
|
Reference in New Issue
Block a user