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

Merge work:/home/bk/mysql into hundin.mysql.fi:/my/bk/mysql

parents e42eca1e 7a199878
This diff is collapsed.
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
INCLUDES = -I$(srcdir)/../include \ INCLUDES = -I$(srcdir)/../include \
-I../include -I$(srcdir)/.. -I$(top_srcdir) \ -I../include -I$(srcdir)/.. -I$(top_srcdir) \
-I.. -I..
noinst_HEADERS = client_priv.h
LIBS = @CLIENT_LIBS@ LIBS = @CLIENT_LIBS@
LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la
bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \ bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \
......
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Common defines for all clients */
#include <global.h>
#include <my_sys.h>
#include <m_string.h>
#include <mysql.h>
#include <errmsg.h>
#include <getopt.h>
/* We have to define 'enum options' identical in all files to keep OS2 happy */
enum options { OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
OPT_PAGER, OPT_NOPAGER, OPT_TEE, OPT_NOTEE,
OPT_LOW_PRIORITY, OPT_AUTO_REPAIR, OPT_COMPRESS,
OPT_FTB, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC, OPT_TABLES};
...@@ -25,17 +25,12 @@ ...@@ -25,17 +25,12 @@
* *
**/ **/
#include <global.h> #include "client_priv.h"
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h> #include <m_ctype.h>
#include "mysql.h"
#include "errmsg.h"
#include <my_dir.h> #include <my_dir.h>
#ifndef __GNU_LIBRARY__ #ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h #define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif #endif
#include <getopt.h>
#include "my_readline.h" #include "my_readline.h"
#include <signal.h> #include <signal.h>
...@@ -380,10 +375,6 @@ sig_handler mysql_end(int sig) ...@@ -380,10 +375,6 @@ sig_handler mysql_end(int sig)
exit(status.exit_status); exit(status.exit_status);
} }
enum options {OPT_CHARSETS_DIR=256, OPT_DEFAULT_CHARSET,
OPT_PAGER, OPT_NOPAGER, OPT_TEE, OPT_NOTEE} ;
static struct option long_options[] = static struct option long_options[] =
{ {
{"i-am-a-dummy", optional_argument, 0, 'U'}, {"i-am-a-dummy", optional_argument, 0, 'U'},
......
...@@ -17,13 +17,8 @@ ...@@ -17,13 +17,8 @@
/* maintaince of mysql databases */ /* maintaince of mysql databases */
#include <global.h> #include "client_priv.h"
#include <my_sys.h>
#include <m_string.h>
#include <signal.h> #include <signal.h>
#include "mysql.h"
#include "errmsg.h"
#include <getopt.h>
#ifdef THREAD #ifdef THREAD
#include <my_pthread.h> /* because of signal() */ #include <my_pthread.h> /* because of signal() */
#endif #endif
...@@ -102,8 +97,6 @@ static const char *command_names[]= { ...@@ -102,8 +97,6 @@ static const char *command_names[]= {
static TYPELIB command_typelib= static TYPELIB command_typelib=
{ array_elements(command_names)-1,"commands", command_names}; { array_elements(command_names)-1,"commands", command_names};
enum options { OPT_CHARSETS_DIR=256 };
static struct option long_options[] = { static struct option long_options[] = {
{"compress", no_argument, 0, 'C'}, {"compress", no_argument, 0, 'C'},
{"character-sets-dir", required_argument, 0, OPT_CHARSETS_DIR}, {"character-sets-dir", required_argument, 0, OPT_CHARSETS_DIR},
......
...@@ -17,23 +17,20 @@ ...@@ -17,23 +17,20 @@
#define MYSQL_CLIENT #define MYSQL_CLIENT
#undef MYSQL_SERVER #undef MYSQL_SERVER
#include <global.h> #include "client_priv.h"
#include <m_string.h>
#include <my_sys.h>
#include <getopt.h>
#include <mysql.h>
#include <time.h> #include <time.h>
#include "log_event.h" #include "log_event.h"
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES) #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
#ifndef OS2
extern "C" extern "C"
{ {
int simple_command(MYSQL *mysql,enum enum_server_command command, int simple_command(MYSQL *mysql,enum enum_server_command command,
const char *arg, const char *arg, uint length, my_bool skipp_check);
uint length, my_bool skipp_check); uint net_safe_read(MYSQL* mysql);
int net_safe_read(MYSQL* mysql);
} }
#endif
char server_version[SERVER_VERSION_LENGTH]; char server_version[SERVER_VERSION_LENGTH];
uint32 server_id = 0; uint32 server_id = 0;
...@@ -42,7 +39,8 @@ uint32 server_id = 0; ...@@ -42,7 +39,8 @@ uint32 server_id = 0;
ulong bytes_sent = 0L, bytes_received = 0L; ulong bytes_sent = 0L, bytes_received = 0L;
ulong mysqld_net_retry_count = 10L; ulong mysqld_net_retry_count = 10L;
uint test_flags = 0; uint test_flags = 0;
FILE *result_file;
static FILE *result_file;
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char* default_dbug_option = "d:t:o,/tmp/mysqlbinlog.trace"; static const char* default_dbug_option = "d:t:o,/tmp/mysqlbinlog.trace";
......
...@@ -18,19 +18,12 @@ ...@@ -18,19 +18,12 @@
#define CHECK_VERSION "1.02" #define CHECK_VERSION "1.02"
#include <global.h> #include "client_priv.h"
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h> #include <m_ctype.h>
#include "mysql.h"
#include "mysql_version.h" #include "mysql_version.h"
#include "mysqld_error.h" #include "mysqld_error.h"
#include <getopt.h>
#include "sslopt-vars.h" #include "sslopt-vars.h"
#include <m_string.h>
/* Exit codes */ /* Exit codes */
#define EX_USAGE 1 #define EX_USAGE 1
...@@ -50,9 +43,6 @@ DYNAMIC_ARRAY tables4repair; ...@@ -50,9 +43,6 @@ DYNAMIC_ARRAY tables4repair;
enum operations {DO_CHECK, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE}; enum operations {DO_CHECK, DO_REPAIR, DO_ANALYZE, DO_OPTIMIZE};
enum options {OPT_CHARSETS_DIR=256, OPT_COMPRESS, OPT_DEFAULT_CHARSET,
OPT_TABLES, OPT_AUTO_REPAIR};
static struct option long_options[] = static struct option long_options[] =
{ {
{"all-databases", no_argument, 0, 'A'}, {"all-databases", no_argument, 0, 'A'},
......
...@@ -27,13 +27,8 @@ ...@@ -27,13 +27,8 @@
*/ */
#define IMPORT_VERSION "2.7" #define IMPORT_VERSION "2.7"
#include <global.h> #include "client_priv.h"
#include <my_sys.h>
#include <m_string.h>
#include "mysql.h"
#include "mysql_version.h" #include "mysql_version.h"
#include <getopt.h>
static void db_error_with_table(MYSQL *mysql, char *table); static void db_error_with_table(MYSQL *mysql, char *table);
static void db_error(MYSQL *mysql); static void db_error(MYSQL *mysql);
...@@ -54,9 +49,6 @@ static uint opt_mysql_port=0; ...@@ -54,9 +49,6 @@ static uint opt_mysql_port=0;
static my_string opt_mysql_unix_port=0; static my_string opt_mysql_unix_port=0;
#include "sslopt-vars.h" #include "sslopt-vars.h"
enum mi_options {OPT_FTB=256, OPT_LTB, OPT_ENC, OPT_O_ENC, OPT_ESC,
OPT_LOW_PRIORITY, OPT_CHARSETS_DIR, OPT_DEFAULT_CHARSET};
static struct option long_options[] = static struct option long_options[] =
{ {
{"character-sets-dir", required_argument, 0, OPT_CHARSETS_DIR}, {"character-sets-dir", required_argument, 0, OPT_CHARSETS_DIR},
......
...@@ -119,9 +119,7 @@ int main(int argc,char *argv[]) ...@@ -119,9 +119,7 @@ int main(int argc,char *argv[])
/* Read options */ /* Read options */
static void get_options(argc,argv) static void get_options(register int *argc,register char **argv[])
register int *argc;
register char **argv[];
{ {
int help=0; int help=0;
char *pos,*progname; char *pos,*progname;
...@@ -163,9 +161,7 @@ register char **argv[]; ...@@ -163,9 +161,7 @@ register char **argv[];
/* Count rows in from-file until row that start with char is found */ /* Count rows in from-file until row that start with char is found */
static int count_rows(from,c,c2) static int count_rows(FILE *from, pchar c, pchar c2)
FILE *from;
pchar c,c2;
{ {
int count; int count;
long pos; long pos;
...@@ -189,9 +185,7 @@ pchar c,c2; ...@@ -189,9 +185,7 @@ pchar c,c2;
/* Read rows and remember them until row that start with char */ /* Read rows and remember them until row that start with char */
/* Converts row as a C-compiler would convert a textstring */ /* Converts row as a C-compiler would convert a textstring */
static int remember_rows(from,c) static int remember_rows(FILE* from, pchar c)
FILE *from;
pchar c;
{ {
int i,nr,start_count,found_end; int i,nr,start_count,found_end;
char row[MAXLENGTH],*pos; char row[MAXLENGTH],*pos;
...@@ -253,8 +247,7 @@ pchar c; ...@@ -253,8 +247,7 @@ pchar c;
/* Copy rows from memory to file and remember position */ /* Copy rows from memory to file and remember position */
static int copy_rows(to) static int copy_rows(FILE *to)
FILE *to;
{ {
int row_nr; int row_nr;
long start_pos; long start_pos;
......
...@@ -45,13 +45,11 @@ static int calc_check(byte *buf,uint length); ...@@ -45,13 +45,11 @@ static int calc_check(byte *buf,uint length);
/* Huvudprogrammet */ /* Huvudprogrammet */
int main(argc,argv) int main(int argc, char *argv[])
int argc;
char *argv[];
{ {
register uint i,j; register uint i,j;
uint ant,n1,n2,n3; uint ant,n1,n2,n3;
uint reclength,write_count,update,delete,check2,dupp_keys,found_key; uint reclength,write_count,update,opt_delete,check2,dupp_keys,found_key;
int error; int error;
ulong pos; ulong pos;
unsigned long key_check; unsigned long key_check;
...@@ -70,7 +68,7 @@ char *argv[]; ...@@ -70,7 +68,7 @@ char *argv[];
get_options(argc,argv); get_options(argc,argv);
reclength=37; reclength=37;
write_count=update=delete=0; write_count=update=opt_delete=0;
key_check=0; key_check=0;
keyinfo[0].seg=keyseg; keyinfo[0].seg=keyseg;
...@@ -169,7 +167,7 @@ char *argv[]; ...@@ -169,7 +167,7 @@ char *argv[];
printf("error: %d; can't delete record: \"%s\"\n", my_errno,record); printf("error: %d; can't delete record: \"%s\"\n", my_errno,record);
goto err; goto err;
} }
delete++; opt_delete++;
key1[atoi(record+keyinfo[0].seg[0].start)]--; key1[atoi(record+keyinfo[0].seg[0].start)]--;
key3[atoi(record+keyinfo[2].seg[0].start)]=0; key3[atoi(record+keyinfo[2].seg[0].start)]=0;
key_check-=atoi(record); key_check-=atoi(record);
...@@ -198,7 +196,7 @@ char *argv[]; ...@@ -198,7 +196,7 @@ char *argv[];
{ {
if (heap_scan_init(file)) if (heap_scan_init(file))
goto err; goto err;
j=rnd(write_count-delete); j=rnd(write_count-opt_delete);
while ((error=heap_scan(file,record) == HA_ERR_RECORD_DELETED) || while ((error=heap_scan(file,record) == HA_ERR_RECORD_DELETED) ||
(!error && j)) (!error && j))
{ {
...@@ -271,7 +269,7 @@ char *argv[]; ...@@ -271,7 +269,7 @@ char *argv[];
key_check-=atoi(record3); key_check-=atoi(record3);
key1[atoi(record+keyinfo[0].seg[0].start)]--; key1[atoi(record+keyinfo[0].seg[0].start)]--;
key3[atoi(record+keyinfo[2].seg[0].start)]=0; key3[atoi(record+keyinfo[2].seg[0].start)]=0;
delete++; opt_delete++;
ant=2; ant=2;
while ((error=heap_rnext(file,record3)) == 0 || while ((error=heap_rnext(file,record3)) == 0 ||
error == HA_ERR_RECORD_DELETED) error == HA_ERR_RECORD_DELETED)
...@@ -291,21 +289,21 @@ char *argv[]; ...@@ -291,21 +289,21 @@ char *argv[];
} }
if (!silent) if (!silent)
printf("- Read last key - delete - prev - prev - delete - prev -> first\n"); printf("- Read last key - delete - prev - prev - opt_delete - prev -> first\n");
if (heap_rlast(file,record3)) goto err; if (heap_rlast(file,record3)) goto err;
if (heap_delete(file,record3)) goto err; if (heap_delete(file,record3)) goto err;
key_check-=atoi(record3); key_check-=atoi(record3);
key1[atoi(record+keyinfo[0].seg[0].start)]--; key1[atoi(record+keyinfo[0].seg[0].start)]--;
key3[atoi(record+keyinfo[2].seg[0].start)]=0; key3[atoi(record+keyinfo[2].seg[0].start)]=0;
delete++; opt_delete++;
if (heap_rprev(file,record3) || heap_rprev(file,record3)) if (heap_rprev(file,record3) || heap_rprev(file,record3))
goto err; goto err;
if (heap_delete(file,record3)) goto err; if (heap_delete(file,record3)) goto err;
key_check-=atoi(record3); key_check-=atoi(record3);
key1[atoi(record+keyinfo[0].seg[0].start)]--; key1[atoi(record+keyinfo[0].seg[0].start)]--;
key3[atoi(record+keyinfo[2].seg[0].start)]=0; key3[atoi(record+keyinfo[2].seg[0].start)]=0;
delete++; opt_delete++;
ant=3; ant=3;
while ((error=heap_rprev(file,record3)) == 0 || while ((error=heap_rprev(file,record3)) == 0 ||
error == HA_ERR_RECORD_DELETED) error == HA_ERR_RECORD_DELETED)
...@@ -340,7 +338,7 @@ char *argv[]; ...@@ -340,7 +338,7 @@ char *argv[];
goto err; goto err;
if (heap_delete(file,record3)) goto err; if (heap_delete(file,record3)) goto err;
key_check-=atoi(record3); key_check-=atoi(record3);
delete++; opt_delete++;
key1[atoi(record+keyinfo[0].seg[0].start)]--; key1[atoi(record+keyinfo[0].seg[0].start)]--;
key3[atoi(record+keyinfo[2].seg[0].start)]=0; key3[atoi(record+keyinfo[2].seg[0].start)]=0;
ant=0; ant=0;
...@@ -348,9 +346,9 @@ char *argv[]; ...@@ -348,9 +346,9 @@ char *argv[];
error == HA_ERR_RECORD_DELETED) error == HA_ERR_RECORD_DELETED)
if (! error) if (! error)
ant++; ant++;
if (ant != write_count-delete) if (ant != write_count-opt_delete)
{ {
printf("next: Found: %d records of %d\n",ant,write_count-delete); printf("next: Found: %d records of %d\n",ant,write_count-opt_delete);
goto end; goto end;
} }
if (heap_check_heap(file,0)) if (heap_check_heap(file,0))
...@@ -361,7 +359,7 @@ char *argv[]; ...@@ -361,7 +359,7 @@ char *argv[];
puts("- Test if: Read rrnd - same - rkey - same"); puts("- Test if: Read rrnd - same - rkey - same");
DBUG_PRINT("progpos",("Read rrnd - same")); DBUG_PRINT("progpos",("Read rrnd - same"));
pos=rnd(write_count-delete-5)+5; pos=rnd(write_count-opt_delete-5)+5;
heap_scan_init(file); heap_scan_init(file);
i=5; i=5;
while ((error=heap_scan(file,record)) == HA_ERR_RECORD_DELETED || while ((error=heap_scan(file,record)) == HA_ERR_RECORD_DELETED ||
...@@ -399,14 +397,14 @@ char *argv[]; ...@@ -399,14 +397,14 @@ char *argv[];
{ {
HEAPINFO info; HEAPINFO info;
heap_info(file,&info,0); heap_info(file,&info,0);
/* We have to test with delete +1 as this may be the case if the last /* We have to test with opt_delete +1 as this may be the case if the last
inserted row was a duplicate key */ inserted row was a duplicate key */
if (info.records != write_count-delete || if (info.records != write_count-opt_delete ||
(info.deleted != delete && info.deleted != delete+1)) (info.deleted != opt_delete && info.deleted != opt_delete+1))
{ {
puts("Wrong info from heap_info"); puts("Wrong info from heap_info");
printf("Got: records: %ld(%d) deleted: %ld(%d)\n", printf("Got: records: %ld(%d) deleted: %ld(%d)\n",
info.records,write_count-delete,info.deleted,delete); info.records,write_count-opt_delete,info.deleted,opt_delete);
} }
} }
...@@ -429,10 +427,10 @@ char *argv[]; ...@@ -429,10 +427,10 @@ char *argv[];
check+=calc_check(record,reclength); check+=calc_check(record,reclength);
} }
} }
if (ant != write_count-delete) if (ant != write_count-opt_delete)
{ {
printf("rrnd: I can only find: %d records of %d\n", ant, printf("rrnd: I can only find: %d records of %d\n", ant,
write_count-delete); write_count-opt_delete);
goto end; goto end;
} }
if (heap_extra(file,HA_EXTRA_NO_CACHE)) if (heap_extra(file,HA_EXTRA_NO_CACHE))
...@@ -460,10 +458,10 @@ char *argv[]; ...@@ -460,10 +458,10 @@ char *argv[];
check2+=calc_check(record,reclength); check2+=calc_check(record,reclength);
} }
} }
if (ant != write_count-delete) if (ant != write_count-opt_delete)
{ {
printf("scan: I can only find: %d records of %d\n", ant, printf("scan: I can only find: %d records of %d\n", ant,
write_count-delete); write_count-opt_delete);
goto end; goto end;
} }
#ifdef OLD_HEAP_VERSION #ifdef OLD_HEAP_VERSION
...@@ -552,7 +550,7 @@ char *argv[]; ...@@ -552,7 +550,7 @@ char *argv[];
write_count++; write_count++;
if (heap_delete(file,record)) if (heap_delete(file,record))
goto err; goto err;
delete++; opt_delete++;
} }
pos++; pos++;
} }
...@@ -570,7 +568,7 @@ char *argv[]; ...@@ -570,7 +568,7 @@ char *argv[];
end: end:
printf("\nFollowing test have been made:\n"); printf("\nFollowing test have been made:\n");
printf("Write records: %d\nUpdate records: %d\nDelete records: %d\n", write_count,update,delete); printf("Write records: %d\nUpdate records: %d\nDelete records: %d\n", write_count,update,opt_delete);
heap_clear(file); heap_clear(file);
if (heap_close(file) || (file2 && heap_close(file2))) if (heap_close(file) || (file2 && heap_close(file2)))
goto err; goto err;
...@@ -629,8 +627,7 @@ static int get_options(int argc,char *argv[]) ...@@ -629,8 +627,7 @@ static int get_options(int argc,char *argv[])
/* Generate a random value in intervall 0 <=x <= n */ /* Generate a random value in intervall 0 <=x <= n */
static int rnd(max_value) static int rnd(int max_value)
int max_value;
{ {
return (int) ((rand() & 32767)/32767.0*max_value); return (int) ((rand() & 32767)/32767.0*max_value);
} /* rnd */ } /* rnd */
...@@ -650,9 +647,7 @@ static sig_handler endprog(int sig_number __attribute__((unused))) ...@@ -650,9 +647,7 @@ static sig_handler endprog(int sig_number __attribute__((unused)))
} }
} }
static int calc_check(buf,length) static int calc_check(byte *buf, uint length)
byte *buf;
uint length;
{ {
int check=0; int check=0;
while (length--) while (length--)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "heapdef.h" #include "heapdef.h"
int heap_update(HP_INFO *info, const byte *old, const byte *new) int heap_update(HP_INFO *info, const byte *old, const byte *heap_new)
{ {
uint key; uint key;
byte *pos; byte *pos;
...@@ -35,16 +35,16 @@ int heap_update(HP_INFO *info, const byte *old, const byte *new) ...@@ -35,16 +35,16 @@ int heap_update(HP_INFO *info, const byte *old, const byte *new)
for (key=0 ; key < share->keys ; key++) for (key=0 ; key < share->keys ; key++)
{ {
if (_hp_rec_key_cmp(share->keydef+key,old,new)) if (_hp_rec_key_cmp(share->keydef+key,old,heap_new))
{ {
if (_hp_delete_key(info,share->keydef+key,old,pos,key == if (_hp_delete_key(info,share->keydef+key,old,pos,key ==
(uint) info->lastinx) || (uint) info->lastinx) ||
_hp_write_key(share,share->keydef+key,new,pos)) _hp_write_key(share,share->keydef+key,heap_new,pos))
goto err; goto err;
} }
} }
memcpy(pos,new,(size_t) share->reclength); memcpy(pos,heap_new,(size_t) share->reclength);
if (++(share->records) == share->blength) share->blength+= share->blength; if (++(share->records) == share->blength) share->blength+= share->blength;
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -54,9 +54,9 @@ int heap_update(HP_INFO *info, const byte *old, const byte *new) ...@@ -54,9 +54,9 @@ int heap_update(HP_INFO *info, const byte *old, const byte *new)
info->errkey=key; info->errkey=key;
do do
{ {
if (_hp_rec_key_cmp(share->keydef+key,old,new)) if (_hp_rec_key_cmp(share->keydef+key,old,heap_new))
{ {
if (_hp_delete_key(info,share->keydef+key,new,pos,0) || if (_hp_delete_key(info,share->keydef+key,heap_new,pos,0) ||
_hp_write_key(share,share->keydef+key,old,pos)) _hp_write_key(share,share->keydef+key,old,pos))
break; break;
} }
......
...@@ -38,7 +38,7 @@ int heap_write(HP_INFO *info, const byte *record) ...@@ -38,7 +38,7 @@ int heap_write(HP_INFO *info, const byte *record)
DBUG_ENTER("heap_write"); DBUG_ENTER("heap_write");
#ifndef DBUG_OFF #ifndef DBUG_OFF
if (info->mode && O_RDONLY) if (info->mode & O_RDONLY)
{ {
DBUG_RETURN(my_errno=EACCES); DBUG_RETURN(my_errno=EACCES);
} }
......
...@@ -87,6 +87,8 @@ ...@@ -87,6 +87,8 @@
#define S_IFMT 0xF000 /* Mask for file type */ #define S_IFMT 0xF000 /* Mask for file type */
#define F_TO_EOF 0L /* Param to lockf() to lock rest of file */ #define F_TO_EOF 0L /* Param to lockf() to lock rest of file */
#define HUGE_PTR
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
...@@ -102,8 +104,13 @@ BOOL TlsSetValue( DWORD, PVOID); ...@@ -102,8 +104,13 @@ BOOL TlsSetValue( DWORD, PVOID);
#define lseek(A,B,C) _lseek64( A, B, C) #define lseek(A,B,C) _lseek64( A, B, C)
#define tell(A) _lseek64( A, 0, SEEK_CUR) #define tell(A) _lseek64( A, 0, SEEK_CUR)
void* dlopen( char* path, int flag);
char* dlerror( void);
void* dlsym( void* hmod, char* fn);
void dlclose( void* hmod);
/* Some typedefs */ /* Some typedefs */
typedef ulonglong os_off_t; typedef unsigned long long os_off_t;
/* config.h. Generated automatically by configure. */ /* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */ /* config.h.in. Generated automatically from configure.in by autoheader. */
......
...@@ -647,8 +647,15 @@ typedef off_t os_off_t; ...@@ -647,8 +647,15 @@ typedef off_t os_off_t;
#define socket_errno WSAGetLastError() #define socket_errno WSAGetLastError()
#define SOCKET_EINTR WSAEINTR #define SOCKET_EINTR WSAEINTR
#define SOCKET_EAGAIN WSAEINPROGRESS #define SOCKET_EAGAIN WSAEINPROGRESS
#define SOCKET_ENFILE ENFILE
#define SOCKET_EMFILE EMFILE
#elif defined(OS2) #elif defined(OS2)
#define socket_errno sock_errno() #define socket_errno sock_errno()
#define SOCKET_EINTR SOCEINTR
#define SOCKET_EAGAIN SOCEINPROGRESS
#define SOCKET_EWOULDBLOCK SOCEWOULDBLOCK
#define SOCKET_ENFILE SOCENFILE
#define SOCKET_EMFILE SOCEMFILE
#define closesocket(A) soclose(A) #define closesocket(A) soclose(A)
#else /* Unix */ #else /* Unix */
#define socket_errno errno #define socket_errno errno
...@@ -656,6 +663,8 @@ typedef off_t os_off_t; ...@@ -656,6 +663,8 @@ typedef off_t os_off_t;
#define SOCKET_EINTR EINTR #define SOCKET_EINTR EINTR
#define SOCKET_EAGAIN EAGAIN #define SOCKET_EAGAIN EAGAIN
#define SOCKET_EWOULDBLOCK EWOULDBLOCK #define SOCKET_EWOULDBLOCK EWOULDBLOCK
#define SOCKET_ENFILE ENFILE
#define SOCKET_EMFILE EMFILE
#endif #endif
typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */ typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */
......
...@@ -43,7 +43,7 @@ typedef struct st_mrg_info /* Struct from h_info */ ...@@ -43,7 +43,7 @@ typedef struct st_mrg_info /* Struct from h_info */
ulonglong data_file_length; ulonglong data_file_length;
uint reclength; /* Recordlength */ uint reclength; /* Recordlength */
int errkey; /* With key was dupplicated on err */ int errkey; /* With key was dupplicated on err */
uint options; /* HA_OPTIONS_... used */ uint options; /* HA_OPTION_... used */
} MERGE_INFO; } MERGE_INFO;
typedef struct st_mrg_table_info typedef struct st_mrg_table_info
......
...@@ -139,6 +139,7 @@ int pthread_mutex_unlock (pthread_mutex_t *); ...@@ -139,6 +139,7 @@ int pthread_mutex_unlock (pthread_mutex_t *);
int pthread_mutex_destroy (pthread_mutex_t *); int pthread_mutex_destroy (pthread_mutex_t *);
#define my_pthread_setprio(A,B) DosSetPriority(PRTYS_THREAD,PRTYC_NOCHANGE, B, A) #define my_pthread_setprio(A,B) DosSetPriority(PRTYS_THREAD,PRTYC_NOCHANGE, B, A)
#define pthread_kill(A,B) raise(B) #define pthread_kill(A,B) raise(B)
#define pthread_exit(A) pthread_dummy()
#else #else
#define pthread_mutex_init(A,B) InitializeCriticalSection(A) #define pthread_mutex_init(A,B) InitializeCriticalSection(A)
#define pthread_mutex_lock(A) (EnterCriticalSection(A),0) #define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
...@@ -146,7 +147,6 @@ int pthread_mutex_destroy (pthread_mutex_t *); ...@@ -146,7 +147,6 @@ int pthread_mutex_destroy (pthread_mutex_t *);
#define pthread_mutex_destroy(A) DeleteCriticalSection(A) #define pthread_mutex_destroy(A) DeleteCriticalSection(A)
#define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B)) #define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
#define pthread_kill(A,B) pthread_dummy(0) #define pthread_kill(A,B) pthread_dummy(0)
#define pthread_exit(A) pthread_dummy()
#endif /* OS2 */ #endif /* OS2 */
/* Dummy defines for easier code */ /* Dummy defines for easier code */
......
...@@ -69,7 +69,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */ ...@@ -69,7 +69,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */
ulonglong auto_increment; ulonglong auto_increment;
ulonglong key_map; /* Which keys are used */ ulonglong key_map; /* Which keys are used */
uint keys; /* Number of keys in use */ uint keys; /* Number of keys in use */
uint options; /* HA_OPTIONS_... used */ uint options; /* HA_OPTION_... used */
int errkey, /* With key was dupplicated on err */ int errkey, /* With key was dupplicated on err */
sortkey; /* clustered by this key */ sortkey; /* clustered by this key */
File filenr; /* (uniq) filenr for datafile */ File filenr; /* (uniq) filenr for datafile */
......
...@@ -57,7 +57,7 @@ typedef struct st_n_isaminfo /* Struct from h_info */ ...@@ -57,7 +57,7 @@ typedef struct st_n_isaminfo /* Struct from h_info */
uint reclength; /* Recordlength */ uint reclength; /* Recordlength */
uint mean_reclength; /* Mean recordlength (if packed) */ uint mean_reclength; /* Mean recordlength (if packed) */
uint keys; /* How many keys used */ uint keys; /* How many keys used */
uint options; /* HA_OPTIONS_... used */ uint options; /* HA_OPTION_... used */
int errkey, /* With key was dupplicated on err */ int errkey, /* With key was dupplicated on err */
sortkey; /* clustered by this key */ sortkey; /* clustered by this key */
File filenr; /* (uniq) filenr for datafile */ File filenr; /* (uniq) filenr for datafile */
......
...@@ -110,3 +110,25 @@ int _export FAR PASCAL libmain(HANDLE hModule,short cbHeapSize, ...@@ -110,3 +110,25 @@ int _export FAR PASCAL libmain(HANDLE hModule,short cbHeapSize,
} }
#endif #endif
#ifdef OS2
//
// This function is called automatically by _DLL_InitTerm
// Every dll runtime enviroment is not tz enabled, so tzset()
// must be called to enable TZ handling
// Also timezone is fixed.
//
extern "C" unsigned long _System DllMain(unsigned long modhandle,
unsigned long flag)
{
if (flag == 0) {
tzset(); // Set tzname
time_t currentTime = time(NULL);
struct tm *ts = localtime(&currentTime);
if (ts->tm_isdst > 0)
_timezone -= 3600;
}
}
#endif
...@@ -70,11 +70,10 @@ my_string mysql_unix_port=0; ...@@ -70,11 +70,10 @@ my_string mysql_unix_port=0;
#endif #endif
#if defined(MSDOS) || defined(__WIN__) #if defined(MSDOS) || defined(__WIN__)
#define ERRNO WSAGetLastError() // socket_errno is defined in global.h for all platforms
#define perror(A) #define perror(A)
#else #else
#include <errno.h> #include <errno.h>
#define ERRNO errno
#define SOCKET_ERROR -1 #define SOCKET_ERROR -1
#endif /* __WIN__ */ #endif /* __WIN__ */
...@@ -451,7 +450,7 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, ...@@ -451,7 +450,7 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
if (net_write_command(net,(uchar) command,arg, if (net_write_command(net,(uchar) command,arg,
length ? length : (ulong) strlen(arg))) length ? length : (ulong) 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));
end_server(mysql); end_server(mysql);
if (mysql_reconnect(mysql) || if (mysql_reconnect(mysql) ||
net_write_command(net,(uchar) command,arg, net_write_command(net,(uchar) command,arg,
...@@ -1213,7 +1212,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1213,7 +1212,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR) if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR)
{ {
net->last_errno=CR_SOCKET_CREATE_ERROR; net->last_errno=CR_SOCKET_CREATE_ERROR;
sprintf(net->last_error,ER(net->last_errno),ERRNO); sprintf(net->last_error,ER(net->last_errno),socket_errno);
goto error; goto error;
} }
net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE); net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE);
...@@ -1223,9 +1222,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1223,9 +1222,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (connect2(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr), if (connect2(sock,(struct sockaddr *) &UNIXaddr, sizeof(UNIXaddr),
mysql->options.connect_timeout) <0) 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; 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; goto error;
} }
} }
...@@ -1276,7 +1275,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1276,7 +1275,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if ((sock = (my_socket) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR) if ((sock = (my_socket) socket(AF_INET,SOCK_STREAM,0)) == SOCKET_ERROR)
{ {
net->last_errno=CR_IPSOCK_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; goto error;
} }
net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE); net->vio = vio_new(sock,VIO_TYPE_TCPIP,FALSE);
...@@ -1313,7 +1312,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1313,7 +1312,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (!(hp=gethostbyname(host))) if (!(hp=gethostbyname(host)))
{ {
net->last_errno=CR_UNKNOWN_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; goto error;
} }
memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length); memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
...@@ -1323,9 +1322,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1323,9 +1322,9 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (connect2(sock,(struct sockaddr *) &sock_addr, sizeof(sock_addr), if (connect2(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; 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);
goto error; goto error;
} }
} }
...@@ -1810,7 +1809,7 @@ send_file_to_server(MYSQL *mysql, const char *filename) ...@@ -1810,7 +1809,7 @@ send_file_to_server(MYSQL *mysql, const char *filename)
if (my_net_write(&mysql->net,"",0) || net_flush(&mysql->net)) if (my_net_write(&mysql->net,"",0) || net_flush(&mysql->net))
{ {
mysql->net.last_errno=CR_SERVER_LOST; mysql->net.last_errno=CR_SERVER_LOST;
sprintf(mysql->net.last_error,ER(mysql->net.last_errno),errno); sprintf(mysql->net.last_error,ER(mysql->net.last_errno),socket_errno);
my_free(tmp_name,MYF(0)); my_free(tmp_name,MYF(0));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
......
...@@ -77,7 +77,7 @@ extern ulong mysqld_net_retry_count; ...@@ -77,7 +77,7 @@ extern ulong mysqld_net_retry_count;
typedef my_bool thr_alarm_t; typedef my_bool thr_alarm_t;
typedef my_bool ALARM; typedef my_bool ALARM;
#define thr_alarm_init(A) (*(A))=0 #define thr_alarm_init(A) (*(A))=0
#define thr_alarm_in_use(A) (*(A)) #define thr_alarm_in_use(A) (*(A)!= 0)
#define thr_end_alarm(A) #define thr_end_alarm(A)
#define thr_alarm(A,B,C) local_thr_alarm((A),(B),(C)) #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))) inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __attribute__((unused)))
...@@ -372,7 +372,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -372,7 +372,7 @@ net_real_write(NET *net,const char *packet,ulong len)
#endif /* EXTRA_DEBUG */ #endif /* EXTRA_DEBUG */
} }
#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) #if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
if (vio_errno(net->vio) == EINTR) if (vio_errno(net->vio) == SOCKET_EINTR)
{ {
DBUG_PRINT("warning",("Interrupted write. Retrying...")); DBUG_PRINT("warning",("Interrupted write. Retrying..."));
continue; continue;
......
...@@ -44,18 +44,10 @@ ...@@ -44,18 +44,10 @@
#endif /* defined(__EMX__) */ #endif /* defined(__EMX__) */
#if defined(MSDOS) || defined(__WIN__) #if defined(MSDOS) || defined(__WIN__)
#ifdef __WIN__
#undef errno
#undef EINTR
#undef EAGAIN
#define errno WSAGetLastError()
#define EINTR WSAEINTR
#define EAGAIN WSAEINPROGRESS
#endif /* __WIN__ */
#define O_NONBLOCK 1 /* For emulation of fcntl() */ #define O_NONBLOCK 1 /* For emulation of fcntl() */
#endif #endif
#ifndef EWOULDBLOCK #ifndef EWOULDBLOCK
#define EWOULDBLOCK EAGAIN #define SOCKET_EWOULDBLOCK SOCKET_EAGAIN
#endif #endif
#ifndef __WIN__ #ifndef __WIN__
...@@ -327,8 +319,8 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive) ...@@ -327,8 +319,8 @@ int vio_keepalive(Vio* vio, my_bool set_keep_alive)
my_bool my_bool
vio_should_retry(Vio * vio __attribute__((unused))) vio_should_retry(Vio * vio __attribute__((unused)))
{ {
int en = errno; int en = socket_errno;
return en == EAGAIN || en == EINTR || en == EWOULDBLOCK; return en == SOCKET_EAGAIN || en == SOCKET_EINTR || en == SOCKET_EWOULDBLOCK;
} }
......
...@@ -111,21 +111,21 @@ typedef struct st_isam_mrg { ...@@ -111,21 +111,21 @@ typedef struct st_isam_mrg {
uint ref_length; uint ref_length;
uint max_blob_length; uint max_blob_length;
my_off_t records; my_off_t records;
} MRG_INFO; } PACK_MRG_INFO;
extern int main(int argc,char * *argv); extern int main(int argc,char * *argv);
static void get_options(int *argc,char ***argv); static void get_options(int *argc,char ***argv);
static MI_INFO *open_isam_file(char *name,int mode); static MI_INFO *open_isam_file(char *name,int mode);
static bool open_isam_files(MRG_INFO *mrg,char **names,uint count); static bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count);
static int compress(MRG_INFO *file,char *join_name); static int compress(PACK_MRG_INFO *file,char *join_name);
static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records); static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records);
static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees, static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees,
uint trees, uint trees,
HUFF_COUNTS *huff_counts, HUFF_COUNTS *huff_counts,
uint fields); uint fields);
static int compare_tree(const uchar *s,const uchar *t); static int compare_tree(const uchar *s,const uchar *t);
static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts); static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts);
static void check_counts(HUFF_COUNTS *huff_counts,uint trees, static void check_counts(HUFF_COUNTS *huff_counts,uint trees,
my_off_t records); my_off_t records);
static int test_space_compress(HUFF_COUNTS *huff_counts,my_off_t records, static int test_space_compress(HUFF_COUNTS *huff_counts,my_off_t records,
...@@ -143,7 +143,7 @@ static int make_huff_decode_table(HUFF_TREE *huff_tree,uint trees); ...@@ -143,7 +143,7 @@ static int make_huff_decode_table(HUFF_TREE *huff_tree,uint trees);
static void make_traverse_code_tree(HUFF_TREE *huff_tree, static void make_traverse_code_tree(HUFF_TREE *huff_tree,
HUFF_ELEMENT *element,uint size, HUFF_ELEMENT *element,uint size,
ulong code); ulong code);
static int write_header(MRG_INFO *isam_file, uint header_length,uint trees, static int write_header(PACK_MRG_INFO *isam_file, uint header_length,uint trees,
my_off_t tot_elements,my_off_t filelength); my_off_t tot_elements,my_off_t filelength);
static void write_field_info(HUFF_COUNTS *counts, uint fields,uint trees); static void write_field_info(HUFF_COUNTS *counts, uint fields,uint trees);
static my_off_t write_huff_tree(HUFF_TREE *huff_tree,uint trees); static my_off_t write_huff_tree(HUFF_TREE *huff_tree,uint trees);
...@@ -151,7 +151,7 @@ static uint *make_offset_code_tree(HUFF_TREE *huff_tree, ...@@ -151,7 +151,7 @@ static uint *make_offset_code_tree(HUFF_TREE *huff_tree,
HUFF_ELEMENT *element, HUFF_ELEMENT *element,
uint *offset); uint *offset);
static uint max_bit(uint value); static uint max_bit(uint value);
static int compress_isam_file(MRG_INFO *file,HUFF_COUNTS *huff_counts); static int compress_isam_file(PACK_MRG_INFO *file,HUFF_COUNTS *huff_counts);
static char *make_new_name(char *new_name,char *old_name); static char *make_new_name(char *new_name,char *old_name);
static char *make_old_name(char *new_name,char *old_name); static char *make_old_name(char *new_name,char *old_name);
static void init_file_buffer(File file,pbool read_buffer); static void init_file_buffer(File file,pbool read_buffer);
...@@ -159,13 +159,13 @@ static int flush_buffer(ulong neaded_length); ...@@ -159,13 +159,13 @@ static int flush_buffer(ulong neaded_length);
static void end_file_buffer(void); static void end_file_buffer(void);
static void write_bits(ulong value,uint bits); static void write_bits(ulong value,uint bits);
static void flush_bits(void); static void flush_bits(void);
static int save_state(MI_INFO *isam_file,MRG_INFO *mrg,my_off_t new_length, static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length,
ha_checksum crc); ha_checksum crc);
static int save_state_mrg(File file,MRG_INFO *isam_file,my_off_t new_length, static int save_state_mrg(File file,PACK_MRG_INFO *isam_file,my_off_t new_length,
ha_checksum crc); ha_checksum crc);
static int mrg_close(MRG_INFO *mrg); static int mrg_close(PACK_MRG_INFO *mrg);
static int mrg_rrnd(MRG_INFO *info,byte *buf); static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf);
static void mrg_reset(MRG_INFO *mrg); static void mrg_reset(PACK_MRG_INFO *mrg);
static int backup=0,error_on_write=0,test_only=0,verbose=0,silent=0, static int backup=0,error_on_write=0,test_only=0,verbose=0,silent=0,
...@@ -186,7 +186,7 @@ static const char *load_default_groups[]= { "myisampack",0 }; ...@@ -186,7 +186,7 @@ static const char *load_default_groups[]= { "myisampack",0 };
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int error,ok; int error,ok;
MRG_INFO merge; PACK_MRG_INFO merge;
char **default_argv; char **default_argv;
MY_INIT(argv[0]); MY_INIT(argv[0]);
...@@ -251,7 +251,7 @@ static struct option long_options[] = ...@@ -251,7 +251,7 @@ static struct option long_options[] =
static void print_version(void) static void print_version(void)
{ {
printf("%s Ver 1.10 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE); printf("%s Ver 1.11 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
} }
static void usage(void) static void usage(void)
...@@ -403,7 +403,7 @@ static MI_INFO *open_isam_file(char *name,int mode) ...@@ -403,7 +403,7 @@ static MI_INFO *open_isam_file(char *name,int mode)
} }
static bool open_isam_files(MRG_INFO *mrg,char **names,uint count) static bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count)
{ {
uint i,j; uint i,j;
mrg->count=0; mrg->count=0;
...@@ -445,7 +445,7 @@ static bool open_isam_files(MRG_INFO *mrg,char **names,uint count) ...@@ -445,7 +445,7 @@ static bool open_isam_files(MRG_INFO *mrg,char **names,uint count)
} }
static int compress(MRG_INFO *mrg,char *result_table) static int compress(PACK_MRG_INFO *mrg,char *result_table)
{ {
int error; int error;
File new_file,join_isam_file; File new_file,join_isam_file;
...@@ -721,7 +721,7 @@ static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees, uint trees, ...@@ -721,7 +721,7 @@ static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees, uint trees,
/* Read through old file and gather some statistics */ /* Read through old file and gather some statistics */
static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts) static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
{ {
int error; int error;
uint length; uint length;
...@@ -983,7 +983,7 @@ static void check_counts(HUFF_COUNTS *huff_counts, uint trees, ...@@ -983,7 +983,7 @@ static void check_counts(HUFF_COUNTS *huff_counts, uint trees,
huff_counts->end_space[huff_counts->field_length]+= huff_counts->end_space[huff_counts->field_length]+=
huff_counts->empty_fields; huff_counts->empty_fields;
} }
else if (huff_counts->tot_pre_space)
{ {
huff_counts->tot_pre_space+=length; huff_counts->tot_pre_space+=length;
huff_counts->max_pre_space=huff_counts->field_length; huff_counts->max_pre_space=huff_counts->field_length;
...@@ -1461,7 +1461,7 @@ static void make_traverse_code_tree(HUFF_TREE *huff_tree, ...@@ -1461,7 +1461,7 @@ static void make_traverse_code_tree(HUFF_TREE *huff_tree,
/* Write header to new packed data file */ /* Write header to new packed data file */
static int write_header(MRG_INFO *mrg,uint head_length,uint trees, static int write_header(PACK_MRG_INFO *mrg,uint head_length,uint trees,
my_off_t tot_elements,my_off_t filelength) my_off_t tot_elements,my_off_t filelength)
{ {
byte *buff=file_buffer.pos; byte *buff=file_buffer.pos;
...@@ -1639,7 +1639,7 @@ static uint max_bit(register uint value) ...@@ -1639,7 +1639,7 @@ static uint max_bit(register uint value)
} }
static int compress_isam_file(MRG_INFO *mrg, HUFF_COUNTS *huff_counts) static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts)
{ {
int error; int error;
uint i,max_calc_length,pack_ref_length,min_record_length,max_record_length, uint i,max_calc_length,pack_ref_length,min_record_length,max_record_length,
...@@ -2025,7 +2025,7 @@ static void flush_bits (void) ...@@ -2025,7 +2025,7 @@ static void flush_bits (void)
** functions to handle the joined files ** functions to handle the joined files
****************************************************************************/ ****************************************************************************/
static int save_state(MI_INFO *isam_file,MRG_INFO *mrg,my_off_t new_length, static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length,
ha_checksum crc) ha_checksum crc)
{ {
MYISAM_SHARE *share=isam_file->s; MYISAM_SHARE *share=isam_file->s;
...@@ -2060,7 +2060,7 @@ static int save_state(MI_INFO *isam_file,MRG_INFO *mrg,my_off_t new_length, ...@@ -2060,7 +2060,7 @@ static int save_state(MI_INFO *isam_file,MRG_INFO *mrg,my_off_t new_length,
} }
static int save_state_mrg(File file,MRG_INFO *mrg,my_off_t new_length, static int save_state_mrg(File file,PACK_MRG_INFO *mrg,my_off_t new_length,
ha_checksum crc) ha_checksum crc)
{ {
MI_STATE_INFO state; MI_STATE_INFO state;
...@@ -2090,7 +2090,7 @@ static int save_state_mrg(File file,MRG_INFO *mrg,my_off_t new_length, ...@@ -2090,7 +2090,7 @@ static int save_state_mrg(File file,MRG_INFO *mrg,my_off_t new_length,
/* reset for mrg_rrnd */ /* reset for mrg_rrnd */
static void mrg_reset(MRG_INFO *mrg) static void mrg_reset(PACK_MRG_INFO *mrg)
{ {
if (mrg->current) if (mrg->current)
{ {
...@@ -2099,7 +2099,7 @@ static void mrg_reset(MRG_INFO *mrg) ...@@ -2099,7 +2099,7 @@ static void mrg_reset(MRG_INFO *mrg)
} }
} }
static int mrg_rrnd(MRG_INFO *info,byte *buf) static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf)
{ {
int error; int error;
MI_INFO *isam_info; MI_INFO *isam_info;
...@@ -2138,7 +2138,7 @@ static int mrg_rrnd(MRG_INFO *info,byte *buf) ...@@ -2138,7 +2138,7 @@ static int mrg_rrnd(MRG_INFO *info,byte *buf)
} }
static int mrg_close(MRG_INFO *mrg) static int mrg_close(PACK_MRG_INFO *mrg)
{ {
uint i; uint i;
int error=0; int error=0;
......
...@@ -40,10 +40,10 @@ ...@@ -40,10 +40,10 @@
typedef struct st_buffpek { typedef struct st_buffpek {
my_off_t file_pos; /* Where we are in the sort file */ my_off_t file_pos; /* Where we are in the sort file */
ha_rows count; /* Number of rows in table */
uchar *base,*key; /* Key pointers */ uchar *base,*key; /* Key pointers */
uint mem_count; /* numbers of keys in memory */ ha_rows count; /* Number of rows in table */
uint max_keys; /* Max keys in buffert */ ulong mem_count; /* numbers of keys in memory */
ulong max_keys; /* Max keys in buffert */
} BUFFPEK; } BUFFPEK;
extern void print_error _VARARGS((const char *fmt,...)); extern void print_error _VARARGS((const char *fmt,...));
......
...@@ -113,4 +113,4 @@ insert into t1 values (1,2),(2,1),(0,0),(4,4),(5,5),(6,6); ...@@ -113,4 +113,4 @@ insert into t1 values (1,2),(2,1),(0,0),(4,4),(5,5),(6,6);
insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6); insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6);
flush tables; flush tables;
select * from t3 where a=1 order by b limit 2; select * from t3 where a=1 order by b limit 2;
drop table t1,t2,t3; drop table t3,t1,t2;
...@@ -19,45 +19,6 @@ ...@@ -19,45 +19,6 @@
#include "mysys_err.h" #include "mysys_err.h"
#include <errno.h> #include <errno.h>
#ifdef OS2
int _write64( int fd, const void *buffer, unsigned int count)
{
APIRET rc;
ULONG actual;
rc = DosWrite( fd, (PVOID) buffer, count, &actual);
switch (rc) {
case 0: /* NO_ERROR */
errno = 0;
return( actual);
break;
case ERROR_INVALID_FUNCTION:
errno = EPERM;
break;
case ERROR_ACCESS_DENIED:
errno = EACCESS;
break;
case ERROR_INVALID_HANDLE:
errno = EBADF;
break;
case ERROR_DISK_FULL:
errno = ENOSPC;
break;
default:
errno = EINVAL;
break;
}
// write failed
return(-1);
}
// redirect call
#define write _write64
#endif // OS2
/* Write a chunk of bytes to a file */ /* Write a chunk of bytes to a file */
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
#define HA_NO_FULLTEXT_KEY (HA_NO_PREFIX_CHAR_KEYS*2) #define HA_NO_FULLTEXT_KEY (HA_NO_PREFIX_CHAR_KEYS*2)
/* Parameters for open() (in register form->filestat) */ /* Parameters for open() (in register form->filestat) */
/* HA_GET_INFO does a implicit HA_ABORT_IF_LOCKED */ /* HA_GET_INFO does an implicit HA_ABORT_IF_LOCKED */
#define HA_OPEN_KEYFILE 1 #define HA_OPEN_KEYFILE 1
#define HA_OPEN_RNDFILE 2 #define HA_OPEN_RNDFILE 2
......
...@@ -98,16 +98,10 @@ static void mc_free_old_query(MYSQL *mysql); ...@@ -98,16 +98,10 @@ static void mc_free_old_query(MYSQL *mysql);
#define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES) #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES)
#if defined(MSDOS) || defined(__WIN__) #if defined(MSDOS) || defined(__WIN__)
#define ERRNO WSAGetLastError()
#define perror(A) #define perror(A)
#elif defined(OS2)
#define ERRNO sock_errno()
#define SOCKET_ERROR -1
#else #else
#include <sys/errno.h> #include <errno.h>
#define ERRNO errno
#define SOCKET_ERROR -1 #define SOCKET_ERROR -1
#define closesocket(A) close(A)
#endif #endif
#ifdef __WIN__ #ifdef __WIN__
...@@ -351,7 +345,7 @@ mc_net_safe_read(MYSQL *mysql) ...@@ -351,7 +345,7 @@ mc_net_safe_read(MYSQL *mysql)
{ {
DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d",
vio_description(net->vio),len)); vio_description(net->vio),len));
if (socket_errno != EINTR) if (socket_errno != SOCKET_EINTR)
{ {
mc_end_server(mysql); mc_end_server(mysql);
if(net->last_errno != ER_NET_PACKET_TOO_LARGE) if(net->last_errno != ER_NET_PACKET_TOO_LARGE)
...@@ -544,7 +538,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -544,7 +538,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user,
if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR) if ((sock = socket(AF_UNIX,SOCK_STREAM,0)) == SOCKET_ERROR)
{ {
net->last_errno=CR_SOCKET_CREATE_ERROR; net->last_errno=CR_SOCKET_CREATE_ERROR;
sprintf(net->last_error,ER(net->last_errno),ERRNO); sprintf(net->last_error,ER(net->last_errno),socket_errno);
goto error; goto error;
} }
net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE); net->vio = vio_new(sock, VIO_TYPE_SOCKET, TRUE);
......
...@@ -1455,10 +1455,6 @@ static int my_message_sql(uint error, const char *str, ...@@ -1455,10 +1455,6 @@ static int my_message_sql(uint error, const char *str,
} }
#ifdef __WIN__ #ifdef __WIN__
#undef errno
#undef EINTR
#define errno WSAGetLastError()
#define EINTR WSAEINTR
struct utsname struct utsname
{ {
...@@ -1571,18 +1567,26 @@ int main(int argc, char **argv) ...@@ -1571,18 +1567,26 @@ int main(int argc, char **argv)
tzset(); // Set tzname tzset(); // Set tzname
start_time=time((time_t*) 0); start_time=time((time_t*) 0);
#ifdef OS2
{
// fix timezone for daylight saving
struct tm *ts = localtime(&start_time);
if (ts->tm_isdst > 0)
_timezone -= 3600;
}
#endif
#ifdef HAVE_TZNAME #ifdef HAVE_TZNAME
#if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT) #if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT)
{ {
struct tm tm_tmp; struct tm tm_tmp;
localtime_r(&start_time,&tm_tmp); localtime_r(&start_time,&tm_tmp);
strmov(time_zone,tzname[tm_tmp.tm_isdst == 1 ? 1 : 0]); strmov(time_zone,tzname[tm_tmp.tm_isdst != 0 ? 1 : 0]);
} }
#else #else
{ {
struct tm *start_tm; struct tm *start_tm;
start_tm=localtime(&start_time); start_tm=localtime(&start_time);
strmov(time_zone,tzname[start_tm->tm_isdst == 1 ? 1 : 0]); strmov(time_zone,tzname[start_tm->tm_isdst != 0 ? 1 : 0]);
} }
#endif #endif
#endif #endif
...@@ -2263,7 +2267,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) ...@@ -2263,7 +2267,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
#else #else
if (select((int) max_used_connection,&readFDs,0,0,0) < 0) if (select((int) max_used_connection,&readFDs,0,0,0) < 0)
{ {
if (socket_errno != EINTR) if (socket_errno != SOCKET_EINTR)
{ {
if (!select_errors++ && !abort_loop) /* purecov: inspected */ if (!select_errors++ && !abort_loop) /* purecov: inspected */
sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */ sql_print_error("mysqld: Got error %d from select",socket_errno); /* purecov: inspected */
...@@ -2306,7 +2310,8 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) ...@@ -2306,7 +2310,8 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
size_socket length=sizeof(struct sockaddr_in); size_socket length=sizeof(struct sockaddr_in);
new_sock = accept(sock, my_reinterpret_cast(struct sockaddr *) (&cAddr), new_sock = accept(sock, my_reinterpret_cast(struct sockaddr *) (&cAddr),
&length); &length);
if (new_sock != INVALID_SOCKET || (errno != EINTR && errno != EAGAIN)) if (new_sock != INVALID_SOCKET ||
(socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN))
break; break;
#if !defined(NO_FCNTL_NONBLOCK) #if !defined(NO_FCNTL_NONBLOCK)
if (!(test_flags & TEST_BLOCKING)) if (!(test_flags & TEST_BLOCKING))
...@@ -2324,7 +2329,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused))) ...@@ -2324,7 +2329,7 @@ pthread_handler_decl(handle_connections_sockets,arg __attribute__((unused)))
{ {
if ((error_count++ & 255) == 0) // This can happen often if ((error_count++ & 255) == 0) // This can happen often
sql_perror("Error in accept"); sql_perror("Error in accept");
if (errno == ENFILE || errno == EMFILE) if (socket_errno == SOCKET_ENFILE || socket_errno == SOCKET_EMFILE)
sleep(1); // Give other threads some time sleep(1); // Give other threads some time
continue; continue;
} }
......
...@@ -277,7 +277,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -277,7 +277,7 @@ net_real_write(NET *net,const char *packet,ulong len)
int length; int length;
char *pos,*end; char *pos,*end;
thr_alarm_t alarmed; thr_alarm_t alarmed;
#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2) #if !defined(__WIN__)
ALARM alarm_buff; ALARM alarm_buff;
#endif #endif
uint retry_count=0; uint retry_count=0;
...@@ -372,7 +372,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -372,7 +372,7 @@ net_real_write(NET *net,const char *packet,ulong len)
#endif /* EXTRA_DEBUG */ #endif /* EXTRA_DEBUG */
} }
#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) #if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
if (vio_errno(net->vio) == EINTR) if (vio_errno(net->vio) == SOCKET_EINTR)
{ {
DBUG_PRINT("warning",("Interrupted write. Retrying...")); DBUG_PRINT("warning",("Interrupted write. Retrying..."));
continue; continue;
......
...@@ -182,7 +182,7 @@ int quick_rm_table(enum db_type base,const char *db, ...@@ -182,7 +182,7 @@ int quick_rm_table(enum db_type base,const char *db,
} }
/***************************************************************************** /*****************************************************************************
* Create at table. * Create a table.
* If one creates a temporary table, this is automaticly opened * If one creates a temporary table, this is automaticly opened
****************************************************************************/ ****************************************************************************/
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
/* /*
Functions to create a unireg form-file from a FIELD and a fieldname-fieldinfo Functions to create a unireg form-file from a FIELD and a fieldname-fieldinfo
struct. struct.
In the following functions FIELD * is a ordinary field-structure with In the following functions FIELD * is an ordinary field-structure with
the following exeptions: the following exeptions:
sc_length,typepos,row,kol,dtype,regnr and field nead not to be set. sc_length,typepos,row,kol,dtype,regnr and field nead not to be set.
str is a (long) to record position where 0 is the first position. str is a (long) to record position where 0 is the first position.
...@@ -502,7 +502,7 @@ static bool pack_fields(File file,List<create_field> &create_fields) ...@@ -502,7 +502,7 @@ static bool pack_fields(File file,List<create_field> &create_fields)
} }
/* save a empty record on start of formfile */ /* save an empty record on start of formfile */
static bool make_empty_rec(File file,enum db_type table_type, static bool make_empty_rec(File file,enum db_type table_type,
uint table_options, uint table_options,
......
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