summaryrefslogtreecommitdiff
path: root/sql/mini_client.cc
diff options
context:
space:
mode:
authorunknown <monty@work.mysql.com>2001-09-02 18:38:33 +0200
committerunknown <monty@work.mysql.com>2001-09-02 18:38:33 +0200
commit2edb76f0f7b0832daf0c0038c752564704fa05a1 (patch)
tree4689ffbe50e97ce9a47deb58fa2b9e7decdfc6a8 /sql/mini_client.cc
parent50a0734f1b4d56752c11341faca047e1a6f56740 (diff)
parentf3e3aa4820661738d1f5401ea11e7749378333ad (diff)
downloadmariadb-git-2edb76f0f7b0832daf0c0038c752564704fa05a1.tar.gz
merge with 3.23.42
config.guess: Auto merged config.sub: Auto merged ltconfig: Auto merged BitKeeper/deleted/.del-violite.c~d7b85be615595ace: Auto merged BitKeeper/deleted/.del-violite.c~984c09cffe14a11b: Auto merged client/Makefile.am: Auto merged include/errmsg.h: Auto merged include/global.h: Auto merged include/heap.h: Auto merged include/my_sys.h: Auto merged include/mysql_com.h: Auto merged isam/isamlog.c: Auto merged libmysql/libmysql.c: Auto merged merge/open.c: Auto merged myisam/ft_search.c: Auto merged myisam/ftdefs.h: Auto merged myisam/mi_test_all.sh: Auto merged myisam/myisamchk.c: Auto merged myisam/myisamlog.c: Auto merged myisam/myisampack.c: Auto merged myisam/sort.c: Auto merged myisammrg/myrg_open.c: Auto merged mysys/hash.c: Auto merged mysys/mf_casecnv.c: Auto merged mysys/mf_format.c: Auto merged mysys/my_lib.c: Auto merged mysys/tree.c: Auto merged sql-bench/bench-init.pl.sh: Auto merged sql/filesort.cc: Auto merged sql/ha_myisam.cc: Auto merged sql/ha_myisammrg.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/item_func.cc: Auto merged sql/item_strfunc.cc: Auto merged sql/lex.h: Auto merged sql/log.cc: Auto merged sql/log_event.cc: Auto merged sql/mysql_priv.h: Auto merged sql/mysqld.cc: Auto merged sql/net_serv.cc: Auto merged sql/slave.cc: Auto merged sql/sql_acl.cc: Auto merged sql/sql_base.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_db.cc: Auto merged sql/sql_delete.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_show.cc: Auto merged mysql-test/r/func_time.result: Auto merged mysql-test/r/innodb.result: Auto merged mysql-test/t/bdb.test: Auto merged mysql-test/t/err000001.test: Auto merged mysql-test/t/func_time.test: Auto merged mysql-test/t/innodb.test: Auto merged mysql-test/t/overflow.test: Auto merged mysql-test/t/show_check.test: Auto merged sql/sql_table.cc: Auto merged sql/sql_test.cc: Auto merged sql/sql_update.cc: Auto merged sql/sql_yacc.yy: Auto merged strings/ctype.c: Auto merged Docs/manual.texi: Change to 3.23 manual. (I will later add the changes for 4.0 to this copy) client/mysql.cc: merge client/mysqlbinlog.cc: merge client/mysqldump.c: merge client/mysqltest.c: merge client/thread_test.c: merge configure.in: merge include/my_pthread.h: merge include/mysqld_error.h: merge libmysql/net.c: merge myisam/mi_cache.c: merge myisam/mi_check.c: merge mysql-test/t/fulltext.test: merge mysys/mf_qsort.c: merge sql/lock.cc: merge sql/md5.c: merge sql/mini_client.cc: merge sql/share/czech/errmsg.txt: merge sql/share/danish/errmsg.txt: merge sql/share/dutch/errmsg.txt: merge sql/share/english/errmsg.txt: merge sql/share/estonian/errmsg.txt: merge sql/share/french/errmsg.txt: merge sql/share/german/errmsg.txt: merge sql/share/greek/errmsg.txt: merge sql/share/hungarian/errmsg.txt: merge sql/share/italian/errmsg.txt: merge sql/share/japanese/errmsg.txt: merge sql/share/korean/errmsg.txt: merge sql/share/norwegian-ny/errmsg.txt: merge sql/share/norwegian/errmsg.txt: merge sql/share/polish/errmsg.txt: merge sql/share/portuguese/errmsg.txt: merge sql/share/romanian/errmsg.txt: merge sql/share/russian/errmsg.txt: merge sql/share/slovak/errmsg.txt: merge sql/share/spanish/errmsg.txt: merge sql/share/swedish/errmsg.txt: merge sql/sql_load.cc: merge sql/sql_repl.cc: merge
Diffstat (limited to 'sql/mini_client.cc')
-rw-r--r--sql/mini_client.cc66
1 files changed, 43 insertions, 23 deletions
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index 31181ee2580..994f788f423 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -23,10 +23,23 @@
*/
#define DONT_USE_RAID
-#if defined(__WIN__) || defined(WIN32)
+#if defined(__WIN__)
#include <winsock.h>
#include <odbcinst.h>
+/* Disable alarms */
+typedef my_bool ALARM;
+#define thr_alarm_init(A) (*(A))=0
+#define thr_alarm_in_use(A) (*(A))
+#define thr_end_alarm(A)
+#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C))
+inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
+{
+ *A=1;
+ return 0;
+}
+#define thr_got_alarm(A) 0
#endif
+
#include <global.h>
#include <mysql_com.h>
#include <violite.h>
@@ -45,6 +58,11 @@
#define net_write_timeout net_write_timeout1
#endif
+#if defined( OS2) && defined( MYSQL_SERVER)
+#undef ER
+#define ER CER
+#endif
+
extern ulong net_read_timeout;
extern "C" { // Because of SCO 3.2V4.2
@@ -68,7 +86,7 @@ extern "C" { // Because of SCO 3.2V4.2
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
-#if defined(THREAD) && !defined(__WIN__)
+#if defined(THREAD)
#include <my_pthread.h> /* because of signal() */
#include <thr_alarm.h>
#endif
@@ -101,6 +119,9 @@ static MYSQL_DATA *mc_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
#if defined(MSDOS) || defined(__WIN__)
#define ERRNO WSAGetLastError()
#define perror(A)
+#elif defined(OS2)
+#define ERRNO sock_errno()
+#define SOCKET_ERROR -1
#else
#include <sys/errno.h>
#define ERRNO errno
@@ -254,7 +275,7 @@ static void mc_free_old_query(MYSQL *mysql)
static int mc_sock_connect(my_socket s, const struct sockaddr *name,
uint namelen, uint to)
{
-#if defined(__WIN__)
+#if defined(__WIN__) || defined(OS2)
return connect(s, (struct sockaddr*) name, namelen);
#else
int flags, res, s_err;
@@ -349,18 +370,18 @@ mc_net_safe_read(MYSQL *mysql)
{
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d",
vio_description(net->vio),len));
- if(errno != EINTR)
+ if (socket_errno != EINTR)
+ {
+ mc_end_server(mysql);
+ if(net->last_errno != ER_NET_PACKET_TOO_LARGE)
{
- mc_end_server(mysql);
- if(net->last_errno != ER_NET_PACKET_TOO_LARGE)
- {
- net->last_errno=CR_SERVER_LOST;
- strmov(net->last_error,ER(net->last_errno));
- }
- else
- strmov(net->last_error, "Packet too large - increase \
+ net->last_errno=CR_SERVER_LOST;
+ strmov(net->last_error,ER(net->last_errno));
+ }
+ else
+ strmov(net->last_error, "Packet too large - increase \
max_allowed_packet on this server");
- }
+ }
return(packet_error);
}
if (net->read_pos[0] == 255)
@@ -470,7 +491,7 @@ mc_simple_command(MYSQL *mysql,enum enum_server_command command,
if (net_write_command(net,(uchar) command,arg,
length ? length :(uint) strlen(arg)))
{
- DBUG_PRINT("error",("Can't send command to server. Error: %d",errno));
+ DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno));
mc_end_server(mysql);
if (mc_mysql_reconnect(mysql) ||
net_write_command(net,(uchar) command,arg,
@@ -502,9 +523,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
uint pkt_length;
NET *net= &mysql->net;
thr_alarm_t alarmed;
-#if !defined(__WIN__)
ALARM alarm_buff;
-#endif
#ifdef __WIN__
HANDLE hPipe=INVALID_HANDLE_VALUE;
@@ -554,9 +573,9 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if (mc_sock_connect(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
mysql->options.connect_timeout) <0)
{
- DBUG_PRINT("error",("Got error %d on connect to local server",ERRNO));
+ DBUG_PRINT("error",("Got error %d on connect to local server",socket_errno));
net->last_errno=CR_CONNECTION_ERROR;
- sprintf(net->last_error,ER(net->last_errno),unix_socket,ERRNO);
+ sprintf(net->last_error,ER(net->last_errno),unix_socket,socket_errno);
goto error;
}
}
@@ -604,7 +623,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if ((sock = socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
{
net->last_errno=CR_IPSOCK_ERROR;
- sprintf(net->last_error,ER(net->last_errno),ERRNO);
+ sprintf(net->last_error,ER(net->last_errno),socket_errno);
goto error;
}
net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE);
@@ -641,7 +660,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if (!(hp=gethostbyname(host)))
{
net->last_errno=CR_UNKNOWN_HOST;
- sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, errno);
+ sprintf(net->last_error, ER(CR_UNKNOWN_HOST), host, socket_errno);
goto error;
}
memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
@@ -649,11 +668,12 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
#endif
sock_addr.sin_port = (ushort) htons((ushort) port);
if (mc_sock_connect(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr),
- mysql->options.connect_timeout) <0)
+ mysql->options.connect_timeout) <0)
{
- DBUG_PRINT("error",("Got error %d on connect to '%s'",ERRNO,host));
+ DBUG_PRINT("error",("Got error %d on connect to '%s'",
+ socket_errno,host));
net->last_errno= CR_CONN_HOST_ERROR;
- sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, ERRNO);
+ sprintf(net->last_error ,ER(CR_CONN_HOST_ERROR), host, socket_errno);
if (thr_alarm_in_use(&alarmed))
thr_end_alarm(&alarmed);
goto error;