1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Bug fixes, TRUNCATE, safer passwords on command line and connect timeout

Docs/manual.texi:
  Update of safe_mysqld, TRUNCATE and changes for 3.23.28
client/mysql.cc:
  Added --timeout
client/mysqladmin.c:
  Safer password handling
client/mysqldump.c:
  Safer password handling
client/mysqlimport.c:
  Safer password handling
client/mysqlshow.c:
  Safer password handling
configure.in:
  Fixes for Darwin and added test of poll
include/my_pthread.h:
  Fixes for darwin
include/violite.h:
  Added test for polling
libmysql/libmysql.c:
  connect timeout
libmysql/violite.c:
  connect timeout
mysys/hash.c:
  Fix when delting from empty table
scripts/safe_mysqld.sh:
  Added --open-files, --core-file-size and --timezone
sql-bench/bench-init.pl.sh:
  Function print_time
sql-bench/crash-me.sh:
  Added test of truncate
sql-bench/test-insert.sh:
  More "estimated" tests
sql-bench/test-select.sh:
  More "estimated" tests
sql/filesort.cc:
  Removed allocation of extra memory
sql/ha_berkeley.cc:
  Better estimation of number of rows
sql/item_create.cc:
  Truncate
sql/item_create.h:
  Truncate
sql/item_strfunc.cc:
  Removed usage of MY_FAE
sql/lex.h:
  Truncate
sql/lock.cc:
  Fixed possible loop bug
sql/log.cc:
  Removed usage of FILE:s
sql/mysqld.cc:
  Print of more server variables
sql/sql_class.h:
  Changed FILE -> File
sql/sql_insert.cc:
  Fixed bug in temptable handling
sql/sql_lex.h:
  Cleanup
sql/sql_load.cc:
  Removed usage of MY_FAE
sql/sql_parse.cc:
  Cleanup + TRUNCATE
sql/sql_select.cc:
  Cleanup + fix for INSERT ... SELECT
sql/sql_yacc.yy:
  TRUNCATE
sql/violite.c:
  Merge with client/violite.c
strings/strstr-sparc.s:
  Fixed wrong register usage
This commit is contained in:
unknown
2000-11-13 23:55:10 +02:00
parent 675d31ee9a
commit f3d2341f1f
35 changed files with 795 additions and 435 deletions

View File

@ -64,6 +64,12 @@ my_string mysql_unix_port=0;
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES | CLIENT_TRANSACTIONS)
#ifdef __WIN__
#define CONNECT_TIMEOUT 20
#else
#define CONNECT_TIMEOUT 0
#endif
#if defined(MSDOS) || defined(__WIN__)
#define ERRNO WSAGetLastError()
#define perror(A)
@ -113,7 +119,7 @@ static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to,
*****************************************************************************/
static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
uint to)
uint timeout)
{
#if defined(__WIN__)
return connect(s, (struct sockaddr*) name, namelen);
@ -128,7 +134,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
* exactly like the normal connect() call does.
*/
if (to == 0)
if (timeout == 0)
return connect(s, (struct sockaddr*) name, namelen);
flags = fcntl(s, F_GETFL, 0); /* Set socket to not block */
@ -175,13 +181,13 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
start_time = time(NULL);
for (;;)
{
tv.tv_sec = (long) to;
tv.tv_sec = (long) timeout;
tv.tv_usec = 0;
if ((res = select(s+1, NULL, &sfds, NULL, &tv)) >= 0)
break;
now_time=time(NULL);
to-= (uint) (now_time - start_time);
if (errno != EINTR || (int) to <= 0)
timeout-= (uint) (now_time - start_time);
if (errno != EINTR || (int) timeout <= 0)
return -1;
}
@ -195,7 +201,7 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen,
return(-1);
if (s_err)
{ /* getsockopt() could suceed */
{ /* getsockopt could succeed */
errno = s_err;
return(-1); /* but return an error... */
}
@ -1001,9 +1007,7 @@ mysql_init(MYSQL *mysql)
}
else
bzero((char*) (mysql),sizeof(*(mysql)));
#ifdef __WIN__
mysql->options.connect_timeout=20;
#endif
mysql->options.connect_timeout=CONNECT_TIMEOUT;
#if defined(SIGPIPE) && defined(THREAD)
if (!((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE))
(void) signal(SIGPIPE,pipe_sig_handler);
@ -1140,7 +1144,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
const char *passwd, const char *db,
uint port, const char *unix_socket,uint client_flag)
{
char buff[100],charset_name_buff[16],*end,*host_info, *charset_name;
char buff[NAME_LEN+100],charset_name_buff[16],*end,*host_info,
*charset_name;
my_socket sock;
uint32 ip_addr;
struct sockaddr_in sock_addr;
@ -1341,6 +1346,13 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
/* Get version info */
mysql->protocol_version= PROTOCOL_VERSION; /* Assume this */
if (mysql->options.connect_timeout &&
vio_poll_read(net->vio, mysql->options.connect_timeout))
{
net->last_errno= CR_SERVER_LOST;
strmov(net->last_error,ER(net->last_errno));
goto error;
}
if ((pkt_length=net_safe_read(mysql)) == packet_error)
goto error;
@ -1496,7 +1508,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
int3store(buff+2,max_allowed_packet);
if (user && user[0])
strmake(buff+5,user,32);
strmake(buff+5,user,32); /* Max user name */
else
read_user_name((char*) buff+5);
#ifdef _CUSTOMCONFIG_
@ -1507,7 +1519,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
(my_bool) (mysql->protocol_version == 9));
if (db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB))
{
end=strmov(end+1,db);
end=strmake(end+1,db,NAME_LEN);
mysql->db=my_strdup(db,MYF(MY_WME));
db=0;
}

View File

@ -32,6 +32,9 @@
#include <my_sys.h>
#include <my_net.h>
#include <m_string.h>
#ifdef HAVE_POLL
#include <sys/poll.h>
#endif
#if defined(__EMX__)
#include <sys/ioctl.h>
@ -98,7 +101,9 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost)
if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME))))
{
vio_reset(vio, type, sd, 0, localhost);
sprintf(vio->desc, "socket (%d)", vio->sd);
sprintf(vio->desc,
(vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"),
vio->sd);
#if !defined(___WIN__) && !defined(__EMX__)
#if !defined(NO_FCNTL_NONBLOCK)
vio->fcntl_mode = fcntl(sd, F_GETFL);
@ -261,7 +266,7 @@ vio_is_blocking(Vio * vio)
}
int vio_fastsend(Vio * vio, my_bool onoff)
int vio_fastsend(Vio * vio __attribute__((unused)), my_bool onoff)
{
int r=0;
DBUG_ENTER("vio_fastsend");
@ -322,7 +327,7 @@ int vio_close(Vio * vio)
if (vio->type == VIO_TYPE_NAMEDPIPE)
{
#if defined(__NT__) && defined(MYSQL_SERVER)
CancelIO(vio->hPipe);
CancelIo(vio->hPipe);
DisconnectNamedPipe(vio->hPipe);
#endif
r=CloseHandle(vio->hPipe);
@ -397,4 +402,26 @@ void vio_in_addr(Vio *vio, struct in_addr *in)
DBUG_VOID_RETURN;
}
/* Return 0 if there is data to be read */
my_bool vio_poll_read(Vio *vio,uint timeout)
{
#ifndef HAVE_POLL
return 0;
#else
struct pollfd fds;
int res;
DBUG_ENTER("vio_poll");
fds.fd=vio->sd;
fds.events=POLLIN;
fds.revents=0;
if ((res=poll(&fds,1,(int) timeout*1000)) <= 0)
{
DBUG_RETURN(res < 0 ? 0 : 1); /* Don't return 1 on errors */
}
DBUG_RETURN(fds.revents & POLLIN ? 0 : 1);
#endif
}
#endif /* HAVE_VIO */